cancel
Showing results for 
Search instead for 
Did you mean: 

Change &_WF_INITIATOR& at runtime

kirankerudi
Active Participant
0 Kudos

Hello Experts,

I have a requirement where I have to determine &_WF_INITIATOR& at runtime. Is it possible to set the &_WF_INITIATOR& at the beginning ?

This may sound a bit odd. You may ask me "Why on earth you're changing the &_WF_INITIATOR& ?"

The requirement goes like this. If the Initiator of the workflow has left the company, a replacement initiator would be maintained in some table. This replacement would behave as the new initiator.

Regards,

Kiran

Accepted Solutions (1)

Accepted Solutions (1)

ronen_weisz
Active Contributor
0 Kudos

My not simply use substitution? no need to change the workflow, and all workitems which belong to the user who left are immediately shown in the new user's business workplace. any new workitem which will be crated for the user who left will also be seen.

https://help.sap.com/saphelp_nw70ehp2/helpdata/en/8d/25f558454311d189430000e829fbbd/content.htm

You can set the substitution for other users in transaction RMPS_SET_SUBSTITUTE. 

kirankerudi
Active Participant
0 Kudos

Hi Ronen,

That's a good option. My workflow container &_WF_INITIATOR&  has my USER ID as USJKK. (I am not sure why it has US appended to my UID.)

Now, if the substitute has been maintained as JMM for my User ID which is JKK, will the substitute be the new initiator ?

Regards,

Kiran

Answers (3)

Answers (3)

kirankerudi
Active Participant
0 Kudos

Hello All,

I solved this by creating a new task. This will fetch the workflow initiator name stored in some Z-Table.

I am filling a container similar to Initiator and using this wherever the agent is Initiator.

and , thanks for sharing the info on using substitutes. I would definitely try that in future.

Thanks,

Kiran

former_member186746
Active Contributor
0 Kudos

Hi,

Usually you just use substitution when someone has left the company. In some cases where you need to redirect workitems you can also use SWIA to use an administrator forward (Shift+F12) to make sure that work continues.

You can use transaction SWI2_ADM1 to find out if workitems exist without an agent.

Kind regards, Rob Dielemans

kirankerudi
Active Participant
0 Kudos

Hi Rob,

I had no idea of substitution. I have replied on Ronen's answer. Can you suggest something on that ?

Regards,

Kiran

former_member186746
Active Contributor
0 Kudos

Hi Kiran,

First of all how is the initiator used in your workflow design. Will it get a workitem at one point or only messages.

If user interaction is needed (dialog workitems like user decision) then setting up a substitute will fix all of your problems.

If this user is used in background processing on master data where this user is used as the changed by then you have a problem, but you can solve it by either changing the workflow container manuall, by cancelling the workflow in its entirety and executing the remaining steps manually outside workflow, or if no databases have been updated yet simply retrigger the workflow with the correct initiator.

If this user is only used in the end for a confirmation email. Then you can change the email id of the user that has left the company to someone who handles their remaining work.

Kind regards, Rob Dielemans

kirankerudi
Active Participant
0 Kudos

Hi Rob,

Thanks for the explanation. I have interactions like user decisions. That will solve the problem.

I am sending a reminder mails based on the Initiator. I am getting the initiator's mail ID.

Now, in this case if the substitute is maintained, will the mail reach to substitute?

Thanks,

Kiran

0 Kudos

To determine &_WF_INITIATOR& use below logic

Call FM  SAP_WAPI_WORKITEMS_TO_OBJECT for particular BO & Object Key

Then find your relative Workflow Id and  do below

CALL FUNCTION 'SAP_WAPI_READ_CONTAINER'

       EXPORTING

            WORKITEM_ID      = L_WI_ID

       TABLES

            SIMPLE_CONTAINER = LT_CONTAINER

       EXCEPTIONS

            OTHERS           = 1.

  READ TABLE LT_CONTAINER WITH KEY ELEMENT = '_WI_OBJECT_ID'.

  IF SY-SUBRC EQ 0.

    MOVE LT_CONTAINER-VALUE TO LS_POR.

    SELECT SINGLE * FROM SWXFORMABS

      WHERE FORMNUMBER = LS_POR-OBJKEY.

    IF SY-SUBRC EQ 0.

      SWXFORMABS-PROCSTATE = L_INPUT.

      IF SY-SUBRC EQ 0.

        EXPORT L_PREPROCESSED TO MEMORY ID 'PREPROC'.

        L_OKAY = 'X'.

      ENDIF.

    ENDIF.

  ENDIF

kirankerudi
Active Participant
0 Kudos

Hi Aditya,

I have to do this in Workflow. Where I have to add this ? Because, the decision step has expression set to &_WF_INITIATOR&. This has to be changed to new initiator at runtime if maintained in the table.

Regards,

Kiran