SAP MDG · UTILITIES

How do I get the top workflow and child work items for an SAP MDG change request?

Use CL_USMD_WF_SERVICE=>GET_CR_TOP_WF to get the top workflow instance(s) for the change request, convert their WI IDs to SWW_WIID, then call CL_USMD_WF_SERVICE=>GET_WI_BY_TOPWI to retrieve the child work items. Always filter the returned items by status, task, or step before choosing one row.

Use CL_USMD_WF_SERVICE=>GET_CR_TOP_WF to get the top workflow instance(s) for the change request, convert their WI IDs to SWW_WIID, then call CL_USMD_WF_SERVICE=>GET_WI_BY_TOPWI to retrieve the child work items. Always filter the returned items by status, task, or step before choosing one row.

Use the standard MDG workflow service in two steps: first resolve the top workflow for the change request, then fetch the child work items by top WI. The returned list is generic, so you should always apply your own filtering for the required status, task, or step before selecting a work item.

Process flow

  1. Declare the change request as `USMD_CREQUEST`.
  2. Call `CL_USMD_WF_SERVICE=>GET_CR_TOP_WF` with `ID_CREQUEST`.
  3. Check `ED_RTcode` and verify that the returned top workflow table is not initial.
  4. Loop over the returned top workflow rows and collect each `WI_ID` into a `USMD_T_WI`-compatible list.
  5. Convert each `WI_ID` to `SWW_WIID`.
  6. Call `CL_USMD_WF_SERVICE=>GET_WI_BY_TOPWI` with the collected top WI IDs.
  7. Filter the returned work items by required status, task, or step before using one.
  8. If needed, resolve the CR step separately with `GET_CREQUEST_STEP`.

Referenced tables

ObjectPurpose
USMD_T_WITable type used to hold work-item IDs for workflow hierarchy processing.
SWW_WIIDWorkflow work-item ID type used when converting top workflow IDs.

ILLUSTRATIVE ABAP SAMPLE

Source ABAP example

Exact relevant implementation excerpt from the knowledge document.

1" Input: change request. Outputs: top workflow and child work items. 2DATA lv_crequest TYPE usmd_crequest. " Supply 3DATA lt_top_ids TYPE usmd_t_wi. 4 5cl_usmd_wf_service=>get_cr_top_wf( 6 EXPORTING id_crequest = lv_crequest 7 IMPORTING et_workflow = DATA(lt_top_workflow) 8 ed_rtcode = DATA(lv_return_code) ). 9 10LOOP AT lt_top_workflow INTO DATA(ls_top_workflow). 11 APPEND CONV sww_wiid( ls_top_workflow-wi_id ) TO lt_top_ids. 12ENDLOOP. 13 14IF lt_top_ids IS NOT INITIAL. 15 DATA(lt_workitems) = cl_usmd_wf_service=>get_wi_by_topwi( 16 it_topwi = lt_top_ids ). 17 " Filter by the required status/type/task/step before selecting one row. 18ENDIF.

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

Related questions and keywords

Alternative questions

  • How do I find the workflow instances for an MDG change request?
  • How do I read child work items for an MDG CR?
  • Which standard API returns the top workflow and related work items?

Possible questions

  • How do I find the workflow instances for an MDG change request?
  • How do I read child work items for an MDG CR?
  • Which standard API returns the top workflow and related work items?
  • How can I determine the current workflow step for a CR work item?
  • How do I filter the returned work items by task, status, or step?

Keywords

CL_USMD_WF_SERVICE=>GET_CR_TOP_WFCL_USMD_WF_SERVICE=>GET_WI_BY_TOPWIUSMD_T_WISWW_WIIDchange requestworkflow hierarchywork items