SAP MDG · UTILITIES

How do I read the current SAP MDG application context and use the CR/workflow metadata in ABAP?

Use CL_USMD_APP_CONTEXT=>GET_CONTEXT( ) and then IF_USMD_APP_CONTEXT~GET_ATTRIBUTES to read the current MDG runtime values such as model, process, work item, change request ID, change request type, step, and index.

Use CL_USMD_APP_CONTEXT=>GET_CONTEXT( ) and then IF_USMD_APP_CONTEXT~GET_ATTRIBUTES to read the current MDG runtime values such as model, process, work item, change request ID, change request type, step, and index.

You can read the current MDG runtime context with CL_USMD_APP_CONTEXT=>GET_CONTEXT( ). If the context reference is bound, call GET_ATTRIBUTES to retrieve the current model, process, work item ID, change request ID, change request type, change request step, and change request index. This is the standard way to get MDG runtime metadata inside application or workflow context.

Process flow

  1. Call CL_USMD_APP_CONTEXT=>GET_CONTEXT( ) to get the application context reference.
  2. Check that the returned context reference is bound.
  3. Call GET_ATTRIBUTES on IF_USMD_APP_CONTEXT.
  4. Import the needed runtime values such as EO_MODEL, EV_PROCESS, EV_WI_ID, EV_CREQUEST_ID, EV_CREQUEST_TYPE, EV_CREQUEST_STEP, and EV_CREQUEST_INDEX.
  5. Use the returned values for process branching, workflow logic, or MDG reads.

ILLUSTRATIVE ABAP SAMPLE

Read current MDG runtime context

Standard context-read pattern from the source; use it inside an MDG application or workflow context.

1DATA lo_context TYPE REF TO if_usmd_app_context. 2 3lo_context = cl_usmd_app_context=>get_context( ). 4IF lo_context IS BOUND. 5 lo_context->get_attributes( 6 IMPORTING 7 eo_model = DATA(lo_model) 8 ev_process = DATA(lv_process) 9 ev_wi_id = DATA(lv_wi_id) 10 ev_crequest_id = DATA(lv_crequest_id) 11 ev_crequest_type = DATA(lv_crequest_type) 12 ev_crequest_step = DATA(lv_crequest_step) 13 ev_crequest_index = DATA(lv_crequest_index) ). 14ENDIF.

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

Related questions and keywords

Alternative questions

  • How do I get EV_CREQUEST_TYPE in MDG ABAP?
  • Which class provides the MDG application context?
  • How do I read the current MDG runtime context?

Possible questions

  • How do I get the current Change Request Type?
  • How do I get the current work item ID in MDG?
  • How do I read model, process, CR ID, and step from the runtime context?
  • How do I use application context values in feeder logic?
  • What does CL_USMD_APP_CONTEXT=>GET_CONTEXT return?

Keywords

CL_USMD_APP_CONTEXTIF_USMD_APP_CONTEXTGET_CONTEXTGET_ATTRIBUTESEO_MODELEV_PROCESSEV_WI_IDEV_CREQUEST_IDEV_CREQUEST_TYPEEV_CREQUEST_STEPEV_CREQUEST_INDEX