Skip to Content

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

Dec 29, 2017 at 01:37 PM


avatar image
Former Member

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.



10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
avatar image
Former Member Jan 03 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)
Show 3 Share
10 |10000 characters needed characters left characters exceeded

Thanks for posting the info, the technique is useful in some scenarios.

But I don’t really see the need for it here, what was wrong with Gerrit’s suggestion? Takes 10 minutes, 2-5 lines of code and doesn’t need enhancements that are hard to find and troubleshoot.

Former Member

Hello Mike Pokraka,

Thanks for your reply, I trying to implemented the Gerrit's solution, but my skills with workflow is not good and was easier make an enhancements, if you can explain better the Gerrit's solution I will be grateful.



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.

Gerrit Beukema Jan 02 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.

10 |10000 characters needed characters left characters exceeded
Anjan Paul Jan 03 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 .


10 |10000 characters needed characters left characters exceeded