SAP MDG · UTILITIES

How do I extract a specific attribute from MDG entity data returned by READ_ENTITY_DATA_ALL?

Use `USMD_TS_DATA_ENTITY` from `READ_ENTITY_DATA_ALL`, dereference `R_T_DATA` as a dynamic internal table, then `ASSIGN COMPONENT` for the required attribute and collect non-initial values. This is the standard MDG pattern for reading a single field from dynamic entity data.

Use `USMD_TS_DATA_ENTITY` from `READ_ENTITY_DATA_ALL`, dereference `R_T_DATA` as a dynamic internal table, then `ASSIGN COMPONENT` for the required attribute and collect non-initial values. This is the standard MDG pattern for reading a single field from dynamic entity data.

Use the MDG model API result `USMD_TS_DATA_ENTITY` from `READ_ENTITY_DATA_ALL`, then dereference each `USMD_S_DATA_ENTITY-R_T_DATA` as a dynamic internal table and extract the required attribute with `ASSIGN COMPONENT`. The pattern below collects all non-initial values for one entity field and deduplicates them.

Process flow

  1. Get the MDG result table in `USMD_TS_DATA_ENTITY` from `READ_ENTITY_DATA_ALL`.
  2. Filter the relevant entity block by `USMD_ENTITY` or `USMD_ENTITY_CONT`.
  3. Assign `R_T_DATA` to a generic internal table field symbol.
  4. Loop over the dynamic rows.
  5. Use `ASSIGN COMPONENT` for the target attribute.
  6. Append only non-initial values.
  7. Sort and delete adjacent duplicates if unique results are needed.

No configuration step is required for this extraction pattern; it is an ABAP runtime pattern on MDG entity data.

Referenced tables

ObjectPurpose
USMD_TS_DATA_ENTITYReturned entity blocks from `READ_ENTITY_DATA_ALL`.
USMD_S_DATA_ENTITYSingle entity result block containing dynamic reference `R_T_DATA`.
USMD_T_VALUEValue table used to collect extracted attribute values.

ILLUSTRATIVE ABAP SAMPLE

Extract a dynamic attribute from MDG entity data

This is the source pattern adapted from the knowledge-base example. Replace the entity and attribute names as needed.

1DATA lv_target_entity TYPE usmd_entity VALUE 'CCTR'. 2DATA lv_attribute TYPE usmd_attribute VALUE 'NAME'. 3DATA lt_values TYPE usmd_t_value. 4 5FIELD-SYMBOLS <lt_rows> TYPE ANY TABLE. 6FIELD-SYMBOLS <ls_row> TYPE any. 7FIELD-SYMBOLS <lv_value> TYPE any. 8 9LOOP AT lt_data_entity INTO DATA(ls_data_entity) 10 WHERE usmd_entity = lv_target_entity 11 OR usmd_entity_cont = lv_target_entity. 12 13 ASSIGN ls_data_entity-r_t_data->* TO <lt_rows>. 14 IF sy-subrc <> 0. 15 CONTINUE. 16 ENDIF. 17 18 LOOP AT <lt_rows> ASSIGNING <ls_row>. 19 UNASSIGN <lv_value>. 20 ASSIGN COMPONENT lv_attribute OF STRUCTURE <ls_row> TO <lv_value>. 21 IF sy-subrc = 0 AND <lv_value> IS NOT INITIAL. 22 APPEND VALUE #( fieldname = lv_attribute value = <lv_value> ) TO lt_values. 23 ENDIF. 24 ENDLOOP. 25ENDLOOP. 26 27SORT lt_values BY fieldname value. 28DELETE ADJACENT DUPLICATES FROM lt_values COMPARING fieldname value.

The remaining configuration, implementation details, and testing guidance continue from this answer more…

Related questions and keywords

Alternative questions

  • How do I read one field from dynamic MDG entity data in ABAP?
  • How can I get attribute values from USMD_TS_DATA_ENTITY?
  • What is the ABAP pattern to loop over READ_ENTITY_DATA_ALL results and read a single component?

Possible questions

  • How do I extract a specific attribute from MDG entity data returned by READ_ENTITY_DATA_ALL?
  • How do I read one field from dynamic MDG entity data in ABAP?
  • How can I get attribute values from USMD_TS_DATA_ENTITY?
  • What is the ABAP pattern to loop over READ_ENTITY_DATA_ALL results and read a single component?
  • How do I deduplicate extracted MDG attribute values?

Keywords

SAP MDGABAPREAD_ENTITY_DATA_ALLUSMD_TS_DATA_ENTITYUSMD_S_DATA_ENTITYdynamic internal tableASSIGN COMPONENTattribute extractionCL_USMD_MODEL_EXTgeneric MDG read