SAP MDG · UTILITIES

How do I read active MDG entity data with selection using CL_USMD_MODEL_EXT?

Use CL_USMD_MODEL_EXT=>GET_INSTANCE to get IF_USMD_MODEL_EXT, pass the MDG model and entity, then call READ_ENTITY_DATA_ALL with IF_ACTIVE = abap_true and IT_SEL filled with your selection rows.

Use CL_USMD_MODEL_EXT=>GET_INSTANCE to get IF_USMD_MODEL_EXT, pass the MDG model and entity, then call READ_ENTITY_DATA_ALL with IF_ACTIVE = abap_true and IT_SEL filled with your selection rows.

Use CL_USMD_MODEL_EXT=>GET_INSTANCE to obtain IF_USMD_MODEL_EXT for the required MDG model, then read active entity data with READ_ENTITY_DATA_ALL. The key points are to pass the leading entity name, build IT_SEL with the selection criteria, and keep ET_MESSAGE so you do not lose API messages.

Process flow

  1. Define the MDG model and leading entity.
  2. Build a `USMD_TS_SEL` selection table with the required filter rows.
  3. Call `CL_USMD_MODEL_EXT=>GET_INSTANCE` for the model.
  4. Check that the returned `IF_USMD_MODEL_EXT` reference is bound.
  5. Call `READ_ENTITY_DATA_ALL` with `IF_ACTIVE = abap_true` and `IT_SEL`.
  6. Evaluate `ET_MESSAGE` and consume `ET_DATA_ENTITY` only after validating the returned data.

Referenced tables

ObjectPurpose
USMD_TS_SELSelection rows passed to the MDG model read API.
USMD_TS_DATA_ENTITYDynamic result table for entity data returned by `READ_ENTITY_DATA_ALL`.
USMD_T_MESSAGEMessage table returned by MDG model API calls.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1" Inputs: model, leading entity, selection rows. 2DATA lv_model TYPE usmd_model VALUE '0G'. 3DATA lv_entity TYPE usmd_fieldname VALUE 'CCTR'. 4DATA lo_model_ext TYPE REF TO if_usmd_model_ext. 5DATA lt_selection TYPE usmd_ts_sel. 6DATA lt_data_entity TYPE usmd_ts_data_entity. 7DATA lt_message TYPE usmd_t_message. 8 9INSERT VALUE #( fieldname = lv_entity sign = 'I' option = 'EQ' 10 low = '0000001000' ) INTO TABLE lt_selection. " Adapt 11 12cl_usmd_model_ext=>get_instance( 13 EXPORTING i_usmd_model = lv_model 14 IMPORTING eo_instance = lo_model_ext et_message = lt_message ). 15 16IF lo_model_ext IS BOUND. 17 lo_model_ext->read_entity_data_all( 18 EXPORTING i_fieldname = lv_entity if_active = abap_true it_sel = lt_selection 19 IMPORTING et_message = lt_message et_data_entity = lt_data_entity ). 20ENDIF.

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

Related questions and keywords

Alternative questions

  • How can I read active entity data in SAP MDG for a given selection?
  • What is the standard ABAP pattern for READ_ENTITY_DATA_ALL on active MDG data?
  • How do I retrieve active MDG entity rows by key using IF_ACTIVE = abap_true?

Possible questions

  • How do I read inactive CR entity data with I_CREQUEST?
  • How do I extract a specific attribute from dynamic MDG entity data?
  • How do I read MDG application context in ABAP?
  • How do I get the current CR step or workflow work item for MDG?
  • How do I format MDG API messages in ABAP?

Keywords

CL_USMD_MODEL_EXTIF_USMD_MODEL_EXTREAD_ENTITY_DATA_ALLIT_SELIF_ACTIVEUSMD_TS_SELUSMD_TS_DATA_ENTITYUSMD_T_MESSAGE