Skip to Content

Rule not processing correctly

Hello all,

I have created a couple of rules that each have a parameter 'Location'. Then responsibilities are assigned based on location. Location is a virtual attribute on my business object with the following logic:


Data: lv_pernr type pa0001-pernr.

SELECT single pernr into lv_pernr from pa0105

where usrid = sy-uname.

SELECT werks into OBJECT-LOCATION from pa0001 where pernr = lv_pernr

and endda >= sy-datum.




My workflow has several steps and for each step I need to look at the personnel area (PA0001-WERKS) of the workflow initiator (the person who created the customer record via VD01) and determine who should receive workflow. In my test the initiator has a personnel area of ex. '1234'.

Step 1 - rule is processing normally and returning location '1234'. But when I get to Step 2 it is returning a location of '5678' which is the location of the person who processed Step 1. Since there is no agent assigned in the responsibilities tab for location '5678' workflow stops there. From the workflow log I can see in the container for that task that KNA1.location = '5678'.

Is sy-uname the correct field to look at for the initiator of workflow? I've seen several posts that suggest to use that field to lookup the wf initiator without the 'US' in front.

Thanks for your help!

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Nov 09, 2012 at 06:24 AM


    There are tow points that you need to consider in tyour case is

    SELECT single pernr into lv_pernr from pa0105

    where usrid = sy-uname.

    Instead of sy-uname you have to make use of the WF_INITIATOR user name, Export wf_initiator from workflow container to task container excluding US as from task container to method.

    or before starting the the workflow itself from VD01 , I hope you might have used a kind of user exit or badi to initiate the workflow so populate the sy-uname at this level and export it to workflow container and make use of this workflow container element instead of WF_INITIATOR.



    Add a comment
    10|10000 characters needed characters exceeded

    • Hello,

      If you test ZKNA1 in SWO1 by creating an instance, can you see

      the userid of the user who created the cutomer record in any of

      the attributes?

      If yes, then use that attribute to get the username in

      your Location attribute and use that for the select from PA01015.

      If no, then you should make Location a method (FindLocation, perhaps)

      which has a username as input. Create a task that calls that method

      and then create a step in the workflow that calls that task.


      Rick Bakker / hanabi technology

  • Posted on Nov 08, 2012 at 08:39 PM


    Workflow is ruuning by user WF_BATCH.

    you should use wf_initator without 'US' and pass it to rule.

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi,

      WF_BATCH is not initiator. If you use SY-UNAME then you found WF_BATCH because workflow always run by this user.

      You should pass WF_INITIATOR container element to rule. In the rule container create a element for user say USER with type wfsyst-initiator.

      And in upper mention rule you get the element USER .

      swc_get_element ac_container 'USER' uname.

      shift uname by 2 places. " for deleting fron US

      Then use uname instead of sy-uname

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.