Skip to Content
avatar image
Former Member

FM to add possible agents at runtime in workflow

Hi experts,

We have requirement to restrict forwarding of workitem. I know we can achieve this by define possible agents in agent assignment of the task (General forwarding not allowed).

But our requirement is to fetch the possible agents from custom table at runtime dynamically. So, is there any FM or BAPI available to fill the possible agents dynamically instead of static assignment in the task. Or is there any other way to achieve this requirement.

We are trying to map custom workflow task to 'My inbox' fiori app. In this custom workflow, there is a functionality that it can be forwarded to only a particular group of users which is fetched from Z-table at runtime (company code wise)

Now, we require this functionality in the fiori app also. While R&D, we have restricted the users via possible agent option in the task(Task -> Extra -> Agent assignment -> Maintain -> Attributes -> General forwarding not allowed). In this option, we have assigned some test users. When we tried to use forward option in the fiori app, only the assigned users were allowed.

But it's a static restriction. we can assign possible agents before the execution of task and we have to assign all the users from all the company codes.

Our requirement is to assign possible agents(company code wise) at runtime to match our custom functionality in fiori app also. So, the forward functionality should work only for respected set of users per company code.

Is there any way to do so?

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

8 Answers

  • Best Answer
    May 09, 2017 at 10:11 PM

    Workaround: Copy your main task to a series of tasks for each company code with the possible agent subset. I'm not a big fan of Z-tables anyway, so would check if it's possible to use roles or org units? This is definitely the recommended approach for agent assignment.

    Then just assign each role/org unit to the corresponding task.

    Use dynamic task assignment to select the right one at runtime. With a functional method it can all be done in your WF activity step.

    Not a perfect solution (well, replacing Z-tables is a better solution), but quick and easy to implement and uses standard SAP functionality.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Thanks a lot Mike,

      I think your workaround is near to perfect solution. Probably the only solution. :)

      Regards, Vijay

  • May 05, 2017 at 02:27 PM

    Hi,

    Adhoc forwarding can be done with transaction SWIA, check if this conforms to the clients needs.

    Also, if forwarding is something that is done so many times that the need arises to control it then in all probability the original agent assignment was wrong and you should fix that. The moniker of SAP Business Workflow is:"the right information at the right time to the right person"

    Kind regards, Rob Dielemans

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Rob,

      We are trying to map custom workflow task to 'My inbox' fiori app. In this custom workflow, there is a functionality that it can be forwarded to only a particular group of users which is fetched from Z-table at runtime (company code wise)

      Now, we require this functionality in the fiori app also. While R&D, we have restricted the users via possible agent option in the task(Task -> Extra -> Agent assignment -> Maintain -> Attributes -> General forwarding not allowed). In this option, we have assigned some test users. When we tried to use forward option in the fiori app, only the assigned users were allowed.

      But it's a static restriction. we can assign possible agents before the execution of task and we have to assign all the users from all the company codes.

      Our requirement is to assign possible agents(company code wise) at runtime to match our custom functionality in fiori app also. So, the forward functionality should work only for respected set of users per company code.

      Is there any way to do so?

      Regards, Vijay

  • May 05, 2017 at 02:48 PM

    Hi!

    You can create a new FM to determine agents please check the following links:

    https://blogs.sap.com/2015/04/02/workflow-agent-determination-customization/

    http://saptechnical.com/Tutorials/Workflow/Rules/Create.htm

    Hope it's helpful

    Evgeny

    Add comment
    10|10000 characters needed characters exceeded

  • May 08, 2017 at 06:06 AM

    Hi,

    Check the below function module

    SWW_WI_AGENTS_CHANGE

    Thanks,Pavan

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      In the given Function Module there is parameter for every Agent,but no parameter for Possible agent.

      can u please help.

  • May 08, 2017 at 07:41 AM

    Hi,

    maybe SWL_WI_POSSIBLE_AGENTS_ASSGIN is what you are looking for?

    Regards

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Vijay,

      you are right. But is the answer from him then not the right one? With SWW_WI_AGENTS_CHANGE you can change the agents for a workitem. And every agent who is allowed is a possible agent untill one of them starts to work at this workitem?

  • May 08, 2017 at 09:10 AM

    Hi ,

    Try with the below function module RH_WI_ORGTASK_ACT_AGENT_SET. Actually, in the first mentioned function module you have to pass the possible agents in the agents tables parameter.

    Thanks, Pavan

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 08, 2017 at 10:01 AM

    Hi Sascha and Pavan,

    I've updated my post to elaborate our requirement. Can you please have a look again to the question section.

    If you have completed the whole question, you should get the complete picture of the requirement. Now, if we use 'SWW_WI_AGENTS_CHANGE' FM then the workitem will be forwarded to all the users of particular company code. But we don't want to send the workitem to every user. We only need to restrict the users while forwarding. One can forward a workitem only to the set of users (company code wise) not to everyone.

    Because of that, we need dynamic possible agent assignment at runtime.

    Regards, Vijay

    Add comment
    10|10000 characters needed characters exceeded

  • May 09, 2017 at 08:14 PM

    Vijay,

    I was going to post the same question so I will just monitor this one, I have a decision task in a parforeach and each loop is a different approver (supervisor,manager,director). This is dynamic based on $ amount, my scenario is if this only needs a supervisor then I would like to dynamically fill possible agents with just supervisors. Right now I have supervisors, managers and directors as possible agents. I would like to just list the supervisors so they don't forward to a directors and vise versa. I could make a separate decision tasks and populate accordingly but seems like something that should be remedied with the ability to populate POSSIBLE agents dynamically before the task is called in a wf.

    I already have the responsible agent determined and know that they are a sup,man,dir so seems I should be able to load the possible dynamically but have not found anyway to do so.

    Regards

    Jim

    Add comment
    10|10000 characters needed characters exceeded