SAP MDG · UTILITIES

How do I use the standard SAP MDG APIs for application context, entity reads, workflow lookup, and message formatting?

Use CL_USMD_APP_CONTEXT=>GET_CONTEXT for runtime MDG context, CL_USMD_MODEL_EXT=>GET_INSTANCE plus READ_ENTITY_DATA_ALL for active or inactive entity reads, CL_USMD_WF_SERVICE methods for workflow and step lookup, SAP_WAPI_READ_CONTAINER for container values, and FORMAT_MESSAGE to render SAP message text.

Use CL_USMD_APP_CONTEXT=>GET_CONTEXT for runtime MDG context, CL_USMD_MODEL_EXT=>GET_INSTANCE plus READ_ENTITY_DATA_ALL for active or inactive entity reads, CL_USMD_WF_SERVICE methods for workflow and step lookup, SAP_WAPI_READ_CONTAINER for container values, and FORMAT_MESSAGE to render SAP message text.

The standard MDG API set in this catalog covers five common tasks: reading runtime application context, reading active or inactive entity data, extracting dynamic attributes, navigating workflow/work items, and formatting messages. The key pattern is to use CL_USMD_APP_CONTEXT=>GET_CONTEXT for runtime values, CL_USMD_MODEL_EXT=>GET_INSTANCE plus READ_ENTITY_DATA_ALL for entity data, CL_USMD_WF_SERVICE=>GET_CR_TOP_WF and GET_WI_BY_TOPWI for workflow hierarchy, SAP_WAPI_READ_CONTAINER for work-item container values, and FORMAT_MESSAGE for rendered message text.

Process flow

  1. 1. Read runtime context with CL_USMD_APP_CONTEXT=>GET_CONTEXT and IF_USMD_APP_CONTEXT~GET_ATTRIBUTES.
  2. 2. Create the MDG model instance with CL_USMD_MODEL_EXT=>GET_INSTANCE.
  3. 3. Read inactive or active entity data with READ_ENTITY_DATA_ALL using the correct IF_ACTIVE setting.
  4. 4. If needed, dereference USMD_S_DATA_ENTITY-R_T_DATA and extract a field dynamically with ASSIGN COMPONENT.
  5. 5. Resolve the top workflow with CL_USMD_WF_SERVICE=>GET_CR_TOP_WF.
  6. 6. Read child work items with CL_USMD_WF_SERVICE=>GET_WI_BY_TOPWI and filter them explicitly.
  7. 7. Read a work-item container with SAP_WAPI_READ_CONTAINER if a workflow container value is needed.
  8. 8. Use CL_USMD_WF_SERVICE=>GET_INSTANCE and GET_CREQUEST_STEP to map CR/work item to MDG step data. 9. Format any SAP messages with FORMAT_MESSAGE before returning them to the user or log.

Referenced tables

ObjectPurpose
USMD_S_DATA_ENTITYDynamic MDG entity result row used with R_T_DATA during READ_ENTITY_DATA_ALL processing.
USMD_T_MESSAGEMDG message table returned by READ_ENTITY_DATA_ALL.
USMD_T_WIWork-item result table returned by CL_USMD_WF_SERVICE=>GET_WI_BY_TOPWI.
SWR_CONTWorkflow container result structure returned by SAP_WAPI_READ_CONTAINER.

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

Related questions and keywords

Alternative questions

  • Which MDG API should I use to read CR context or entity data?
  • How do I get the MDG work item or CR step from a change request?
  • How do I read inactive and active MDG entity data with standard APIs?

Possible questions

  • How do I use CL_USMD_APP_CONTEXT=>GET_CONTEXT?
  • How do I use CL_USMD_MODEL_EXT=>GET_INSTANCE and READ_ENTITY_DATA_ALL?
  • How do I extract one attribute from dynamic MDG entity data?
  • How do I get top workflow instances and work items for an MDG change request?
  • How do I read a workflow container element with SAP_WAPI_READ_CONTAINER?
  • How do I translate a CR and work item into an MDG step with GET_CREQUEST_STEP?
  • How do I format a SAP message with FORMAT_MESSAGE?

Keywords

CL_USMD_APP_CONTEXT=>GET_CONTEXTIF_USMD_APP_CONTEXT~GET_ATTRIBUTESCL_USMD_MODEL_EXT=>GET_INSTANCEIF_USMD_MODEL_EXT~READ_ENTITY_DATA_ALLUSMD_TS_DATA_ENTITYUSMD_T_MESSAGEUSMD_S_DATA_ENTITY-R_T_DATAASSIGN COMPONENTCL_USMD_WF_SERVICE=>GET_CR_TOP_WFCL_USMD_WF_SERVICE=>GET_WI_BY_TOPWISAP_WAPI_READ_CONTAINERCL_USMD_WF_SERVICE=>GET_INSTANCEGET_CREQUEST_STEPFORMAT_MESSAGEUSMD_T_WISWR_CONT