0% found this document useful (0 votes)
120 views2 pages

Read Entity Data

This document code is reading entity data from various APIs and data structures. It calls methods to get instance references to conversion and request APIs. It reads an object list for a material entity type, retrieves the material value, and assigns it to a data structure field symbol. It then inserts the data structure into a table and calls a method to read the entity data into a result table field symbol.

Uploaded by

sachinkumarpn01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views2 pages

Read Entity Data

This document code is reading entity data from various APIs and data structures. It calls methods to get instance references to conversion and request APIs. It reads an object list for a material entity type, retrieves the material value, and assigns it to a data structure field symbol. It then inserts the data structure into a table and calls a method to read the entity data into a result table field symbol.

Uploaded by

sachinkumarpn01
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

*Read Entity

DATA: l_if_crequest TYPE REF TO if_usmd_crequest_api,


l_if_conv_api TYPE REF TO if_usmd_conv_som_gov_api,
l_i_entities TYPE usmd_t_crequest_entity,
l_dr_entity_structure TYPE REF TO data,
l_wa_entity_data TYPE usmd_gov_api_s_ent_data,
l_wa_entity TYPE usmd_gov_api_s_ent_tabl,
l_is_entity_keys TYPE usmd_gov_api_ts_ent_tabl,
l_is_re TYPE usmd_gov_api_ts_ent_tabl.

CONSTANTS: l_c_material TYPE usmd_entity VALUE 'MATERIAL'.

FIELD-SYMBOLS: <l_fs_entity_table> TYPE SORTED TABLE,


<l_fs_data1> TYPE ANY TABLE.

IF l_if_conv_api IS NOT BOUND.


l_if_conv_api ?= cl_usmd_conv_som_gov_api=>get_instance( ).

CALL METHOD cl_usmd_crequest_api=>get_instance


EXPORTING
iv_crequest = l_v_crequest
IMPORTING
re_inst_crequest_api = l_if_crequest.

IF l_if_crequest IS BOUND.
CALL METHOD l_if_crequest->read_objectlist
EXPORTING
iv_entity_type = l_c_material
IMPORTING
et_entity = l_i_entities
et_message = l_i_message.
READ TABLE l_i_entities ASSIGNING FIELD-SYMBOL(<l_fs_entity>) INDEX
1.
IF sy-subrc EQ 0
AND <l_fs_entity> IS ASSIGNED.
DATA(l_v_material) = <l_fs_entity>-usmd_value.
ENDIF.
ENDIF.

IF l_if_conv_api IS BOUND.
l_if_conv_api->get_entity_structure(
EXPORTING
iv_entity_name = l_c_yybasic01
iv_struct_type = if_usmd_model_ext=>gc_struct_key_attr
"GC_STRUCT_KEY " Type of Data Structure
IMPORTING
er_structure = l_dr_entity_structure
er_table = l_wa_entity_data-entity_data
).
ENDIF.

ASSIGN l_dr_entity_structure->* TO FIELD-SYMBOL(<l_fs_entity_data>).


IF <l_fs_entity_data> IS ASSIGNED.
ASSIGN l_wa_entity_data-entity_data->* TO <l_fs_entity_table>.
IF <l_fs_entity_table> IS ASSIGNED.
l_wa_entity-entity = l_c_yybasic01. " prepares the read
ASSIGN COMPONENT l_c_material OF STRUCTURE <l_fs_entity_data> TO
FIELD-SYMBOL(<l_fs_value>).
IF <l_fs_value> IS ASSIGNED
AND l_v_material IS NOT INITIAL.
<l_fs_value> = l_v_material.
ENDIF.
INSERT <l_fs_entity_data> INTO TABLE <l_fs_entity_table>.

ENDIF.
ENDIF.

l_wa_entity-tabl = l_wa_entity_data-entity_data.
INSERT l_wa_entity INTO TABLE l_is_entity_keys.
IF l_if_conv_api IS BOUND.
l_if_conv_api->if_usmd_conv_som_gov_entity~read_entity_data( "#EC
CI_NO_EXC_LIST
*As it is interface we are unable to catch the exceptions.
EXPORTING
iv_struct =
if_usmd_model_ext=>gc_struct_key_attr " Type of Data Structure
it_entity_keys = l_is_entity_keys " MDG: Table
Type for Table of Entities Structure
RECEIVING
rt_entity_data = l_is_re " MDG: Table Type for
Table of Entities Structure
).
ENDIF.

READ TABLE l_is_re ASSIGNING FIELD-SYMBOL(<l_fs_data_re>) WITH KEY


entity = l_c_yybasic01. "#EC CI_SORTSEQ
IF sy-subrc IS INITIAL AND <l_fs_data_re> IS NOT INITIAL.
ASSIGN <l_fs_data_re>-tabl->* TO <l_fs_data1>.
ENDIF.
ENDIF.
*End Read

You might also like