1 1 1 1 1 Rating 0% (0 Votes)
As I promised I will show how to use the methods we've prepared in previous parts of this tread. I will write simple program that calls the method get_objects_of_class and then loops through the results of it. But before I'll prepare program I need to have classification with some characteristics and an object to which I will add classification. So lets start with CL01 to create our test classification. I'll name it ECM_CLASS1, and I'll add one characteristic for each data type so NUM, CURR, CHAR, DATE and TIME.
Then I'll classify change number in CC02 for two change numbers available there (of course we can do it for how many objects we want) .
Now it's time for fast code to call method get_objects_of_class.

report  zab_classifications.
*This is the code from http://abapblog.com.
datagt_objects_1 type standard table of clobjekte.
datagt_objects_2 type standard table of clobjekte.
datagt_data1     type ref to data.
datagt_data2     type ref to data.
field-symbols:  <tab1> type standard table,
                <tab2> type standard table,
                <wa1> type any,
                <wa2> type any,
                <any> type any.

"call aour method to get objects of class and all details
    i_class            'ECM_CLASS1'
    i_classtype        '025'
    i_key_date         sy-datum
    et_objects         gt_objects_1
*    e_tablestr         = e_tablestr
*    e_structure        = e_structure
    fetch_values_error 1
    structure_error    2
    others             3
if sy-subrc eq 0.
  "assign data to FS
  assign gt_data1->to <tab1>.
  loop at <tab1> assigning <wa1>.
    assign component 'OBJECT_NUMBER' of structure <wa1> to <any>.
    if sy-subrc eq 0.
      write:'OBJECT_NUMBER: '<any>.
    "you can get all components from structure so no need to manually
    "write all the names of characteristics  but just to show it I will
    "it fast and I'll directly put characteristic name
    assign component 'CHARACT_NUM1' of structure <wa1> to <tab2>.
    if sy-subrc eq 0.
      "then loop through characteristic values
      loop at <tab2> assigning <wa2>.
        assign component 'LOW' of structure <wa2> to <any>.
        if sy-subrc eq 0.
          write:'LOW: '<any>.
        assign component 'HIGH' of structure <wa2> to <any>.
        if sy-subrc eq 0.
          write:'HIGH: '<any>.
        assign component 'OPTLOW' of structure <wa2> to <any>.
        if sy-subrc eq 0.
          write:'OPTLOW: '<any>.
        assign component 'OPTHIGH' of structure <wa2> to <any>.
        if sy-subrc eq 0.
          write:'OPTHIGH: '<any>.

The result of such code is, but the most important things you can find while debugging.
This is the list of components of our dynamic structure from cl_abap_structdescr.
Here is the result of created work area in method get_object_details, you can see here that we have some key fields like object_number or class_type and also a tables with all values for each characteristic (as you can have multiple values in one characteristic)
If you click into details of such table of characteristics then you'll find same structure for each of them and the values for checked object.
The reference data result of method get_objects_of_class is a table with all results from get_object_details
Additionally in et_objects table you can find only the object numbers and classification id in case you don't want to read the values of characteristics but you want to get all objects that are assigned to class.
Maybe on the first look it looks to complex but when you'll start to work with classifications, then you'll see that this will help a lot.

Classifications - Part 3 - get all objects assigned to class
Classifications - Part 2 - Get Object Details
Classifications - Part 1 - prepare structure for class data

ABAP Favorites Eclipse plugin

Drag to your running Eclipse* workspace. *Requires Eclipse Marketplace Client