Skip to Content

How to know when the workitem is approved with a substitute user?

Hello Specialists,

I have the next problem with workflow approvals. When for example the user USER01 approval a workitem (Purchase Order) from SBWP, when executed BAPI_PO_RELEASE the user that finally execute this function is SY-UNAME = WF-BATCH, then I replace SY-UNAME by T16FW-objid that is USER01, but the problem is when USER01 have a sutitute USER02, I have not way to know what is who approval the PO, USER01 or USER02?

Any help?

Thanks Regards

FUNCTION bapi_po_release.

ENHANCEMENT 1  ZM_002.    "active version


  data l_objid type ACTORID.

* Si el usuario de sistema es WF-BATCH, se actualiza

* con el aprobador para que el log de modificaciones del

* Pedido (CDHDR) Aparesca el aprobador correcto en lugar del

* Usuario WF-BATCH.

* De no cambiarlo el Formulario de Pedido saldrá, Incorrecto.

  IF sy-uname = 'WF-BATCH'.

    select SINGLE objid from T16FW

      into l_objid

      WHERE FRGGR = '01'          " 01 para pedidos.

        and FRGCO = PO_REL_CODE   " Código de liberación.

        and OTYPE = 'US'.         " Usuario.

      IF sy-subrc is INITIAL.

        WRITE l_objid to sy-uname.



Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Jan 03, 2018 at 02:06 PM

    Regars guys,

    Thanks for your reply.

    I have solved the problem with an ENHANCEMENT into SWW_WI_EXECUTE_INTERNAL_RFC because this is the function that run on job with user WT-BATCH, the user that aproved the PO can recover from input structure IM_EXECTX-EXEC_USER.

    Then recover this value on BAPI_PO_RELEASE and WRITE im_exectx-exec_user TO sy-uname.



    debug.jpg (128.0 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Sorry slightly delayed reply,

      If you don’t understand someone’s suggestion, feel free to ask for clarification. Most of us are happy to help.

      Anyway, the basic idea is in the workflow builder you must create a container element in your workflow to hold the agent who executed it. Then in your step definition, go to the binding editor and drag and drop the system element “Actual Agent” (or something like _WI_Actual_agent if you have technical names on) from the task container to your workflow’s new element to create the binding. Once everything is saved and activated, the workflow will then transfer the user who completed the item to your element.

      Then in your step where you need this info, you also need to define this as an importing parameter. Do the binding from WF to your step and it will be populated in your method at runtime. If your method is OO based all you need is the importing parameter, in BOR objects you need to read the information.

      Small note: Agents are always expressed as Org Management objects consisting of object type and object ID. Users have the prefix US, so a user BATMAN becomes USBATMAN. The structure is SWHACTOR (I think, just double click on the Actual Agent to check).

      This is pretty standard, if you have done it once or twice it should take a few minutes, hence I was wondering why you went a slightly longer way round.

  • Jan 02, 2018 at 06:09 PM

    I think the easiest way is to record the actual agent in the approval step and then pass this in a container element to the release step. This would cover all scenarios, including forwarded work items and substitutions.

    Add comment
    10|10000 characters needed characters exceeded

  • Jan 03, 2018 at 09:02 AM


    First use the FM SAP_WAPI_WORKITEMS_TO_OBJECT to get the workitem for the related Dialogue step. Then use fm

    SAP_WAPI_GET_WORKITEM_DETAIL to get agent id for the fields WI_AAGNET .


    Add comment
    10|10000 characters needed characters exceeded