i_class type klah-class -> class number
i_classtype type klah-klart -> class type
i_key_date type sy-datum default sy-datum -> key date for classification
value( et_objects ) type standard table of clobjekte -> table of objects assigned to class
et_data type ref to data -> table with characteristics data for all objects assigned to class
e_tablestr type ref to cl_abap_tabledescr -> table type structure
e_structure type ref to cl_abap_structdescr -> structure
fetch_values_error
structure_error
method get_objects_of_class.
*This is the code from http://abapblog.com.
field-symbols: <table> type standard table,
<line> type any,
<obj> type clobjekte.
data: mt_class type standard table of sclass.
data: ms_data type ref to data.
"call FM to get all objects with given class
call function 'CLAF_OBJECTS_OF_CLASS'
exporting
class = i_class
* CLASSES = ' '
classtext = abap_true
classtype = i_classtype
* FEATURES = 'X'
language = sy-langu
* OBJECT_HIGH = ' '
* OBJECT_LOW = ' '
* UPDATE_MODE = ' '
key_date = i_key_date
initial_charact = abap_true
no_value_descript = abap_true
* CHANGE_SERVICE_CLF = 'X'
* INHERITED_CHAR = ' '
* OBJECTTABLE = ' '
* CHANGE_NUMBER = ' '
tables
t_class = mt_class
* T_OBJECTDATA = T_OBJECTDATA
t_objects = et_objects
* I_SEL_CHARACTERISTIC = I_SEL_CHARACTERISTIC
* T_NO_AUTH_CHARACT = T_NO_AUTH_CHARACT
exceptions
no_classification = 1
invalid_class_type = 2
others = 3.
if sy-subrc eq 0.
if et_data is requested.
"if we request table with characteristics for all objects
"then we need to create structure for it
zcl_abapblog_com_classific=>create_structure_for_class(
exporting
i_class = i_class
i_classtype = i_classtype
i_key_date = i_key_date
importing
e_structure = e_structure
et_data = et_data
e_table = e_tablestr
exceptions
others = 1
).
if sy-subrc eq 0.
assign et_data->* to <table>.
if sy-subrc eq 0.
"Then loop through all objects and get characteristics values
loop at et_objects assigning <obj>.
data: m_object type bapi1003_key-object.
data: m_objecttable type bapi1003_key-objecttable.
m_object = <obj>-objekt.
m_objecttable = <obj>-obtab.
zcl_abapblog_com_classific=>get_object_details(
exporting
i_object = m_object
i_class = i_class
i_classtype = i_classtype
i_objecttable = m_objecttable
i_key_date = i_key_date
i_structure = e_structure
importing
* et_objvaluesnum = et_objvaluesnum
* et_objvalueschar = et_objvalueschar
* et_objvaluescurr = et_objvaluescurr
e_data = ms_data
exceptions
others = 1
).
if sy-subrc eq 0.
assign ms_data->* to <line>.
if sy-subrc eq 0.
if <line> is not initial.
insert <line> into table <table>.
clear <line>.
endif.
endif.
else.
raise fetch_values_error.
endif.
endloop.
endif.
else.
raise structure_error.
endif.
elseif e_structure is requested or e_tablestr is requested.
"if we want to get structures only
zcl_abapblog_com_classific=>create_structure_for_class(
exporting
i_class = i_class
i_classtype = i_classtype
i_key_date = i_key_date
importing
e_structure = e_structure
* et_data = et_data
e_table = e_tablestr
exceptions
others = 1
).
if sy-subrc ne 0.
raise structure_error.
endif.
endif.
else.
raise fetch_values_error.
endif.
endmethod.