0% found this document useful (0 votes)
861 views

Agent Determination in Workflow Using Custom Table - SAP Blogs

This document describes a workflow that dynamically determines agents from a custom table and sends emails to them. It creates a custom BOR object ZSYSTEM copied from SYSTEM that contains methods to select agent data and emails from the custom ZAGENTS table. The workflow uses these methods to get agents, loop through them, and send a test email to each agent.

Uploaded by

Glauber Santana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
861 views

Agent Determination in Workflow Using Custom Table - SAP Blogs

This document describes a workflow that dynamically determines agents from a custom table and sends emails to them. It creates a custom BOR object ZSYSTEM copied from SYSTEM that contains methods to select agent data and emails from the custom ZAGENTS table. The workflow uses these methods to get agents, loop through them, and send a test email to each agent.

Uploaded by

Glauber Santana
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like


Community

Ask a Question Write a Blog Post Login

Former Member
December 26, 2006 6 minute read

Agent determination in work ow using custom table


1 Like 4,382 Views 6 Comments

This article demonstrates how agents can be determined dynamically in work ow.The agents along with their
email addresses are stored in the custom table ZAGENTS.I have used a custom BOR object ZSYSTEM which is
copied from the standard BOR object SYSTEM.ZSYSTEM contains two new methods “Get_Agents” and
“Get_EMAIL” which select the agent information along with their email addresses from ZAGENTS.Finally I have
created a work ow which sends test mails to all the agents existing in ZAGENTS table.This can be further
enhanced by updating the HR master tables in case of leave deductions or salary calculations.You can copy
SYSTEM BOR Object into ZSYSTEM BOR object in two ways : Creating a subtype : A subtype of an object is
another object whose creation is based upon a parent object . The subtype maintains references to all the
attributes and methods of its parent object. This means that any methods and attributes de ned on the parent
can be executed and accessed on the child object. If a subtype object were merely a copy of its parent, then all
the code contained within the parent would be physically copied to the child. This is not the case. The subtype
simply maintains references to its parents methods and attributes. The real di erence is that the subtype lets
you rede ne these methods and attributes. You can easily add your own business rules to the parent methods
by rede ning the subtypes method. Creating Object as delegation Type : In this case you de ne your own object
and de ne it as a delegation type of the main object ie SYSTEM. In all de nition tools you can still refer to the
original object type, but the SAP System uses the de nition of the delegation type for every access. The
delegation type must always be a subtype of the object type it is to replace. The delegation type can have
di erent or additional methods, attributes, and events. The various objects involved in this work ow are as
follows : Table : ZAGENTS This table stores the agent information along with their email addresses.Email
addresses will be selected from this table.This table can also be connected to HR master tables as a further
enhancement.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 1/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

BOR Object : ZSYSTEM :


Follow RSS feed Like

Copied from SYSTEM BOR Object This BOR object is ZSYSTEM is created as a subtype for the standard SAP
BOR object SYSTEM.The SYSTEM BOR object contains some important utility methods for selecting
agents,looping through agents and displaying agent information.In ZSYSTEM I have added some of my own
methods to select data from the custom table.You can create ZSYSTEM from SYSTEM either by creating a
subtype or by delegating.

This method “Get_Agents” is used for fetching agent information from the agents custom table.A result table is
returned containing all the agents fetched as per the selection criteria.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 2/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

This method GET_EMAIL is used to fetch the email addresses of the selected agents from the custom table.This
method also returns a result table containing all the email addresses.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 3/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

Write the following code in the program section : BEGIN_METHOD GET_AGENTS CHANGING CONTAINER.
types : begin of ty_agents, agent like wfsyst-agent, end of ty_agents. data : get_agents type standard table of
ty_agents. select agent from zagents into corresponding elds of table GET_AGENTS. SWC_SET_TABLE
CONTAINER RESULT GET_AGENTS. END_METHOD. BEGIN_METHOD GET_EMAIL CHANGING CONTAINER.
DATA: ACTUALLYPROCBY TYPE WFSYST-ACT_AGENT, GET_EMAIL TYPE BAPIADDR3-E_MAIL, EMAIL LIKE
ZAGENTS-E_MAIL. *Get the agent from the method container SWC_GET_ELEMENT CONTAINER
‘ActuallyProcBy’ ACTUALLYPROCBY. CLEAR EMAIL. select single e_mail from zagents into email where agent =
ACTUALLYPROCBY. if not email is initial. GET_EMAIL = email. *Set the value of the email back to the result.
SWC_SET_ELEMENT CONTAINER RESULT GET_EMAIL. endif. END_METHOD.
WORKFLOW STEPS Using transaction SWDD (Work ow Builder ) we create a work ow

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 4/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

Container elements used in the work ow are as follows :

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 5/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 6/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

The work ow steps along with the tasks are as follows : This step “Get Agents” gets back the list of all the
agents using the custom method “Get_Agents”

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 7/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

This step “Describe Agents” returns back the number of agents available.We are capturing this information into
the work ow container variables &AGENTS and &NUMOFAGENTS.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 8/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

This step “Loop at agents to get agents” loop at the “Agents” table and gets the current agent.The current
agent is stored in the “Agent” container element.For this purpose standard SYSTEM BOR object method
LOOPATAGENTS is used.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 9/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

Set the conditions of looping in the condition editor of the “Agents Loop” loop step.The loop will continue till the
number of agents becomes equal to zero as shown below.

Get the Email Address in the “GetEmail” step.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 10/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

Send the mail to the Agents got in the previous step.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 11/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

After sending the mail to every agent as per the result decrement the agents in the loop using the “Decrement
Agents” container step.This will ensure that endless loop condition does not happen.

This application be be further enhanced by connecting it to HR master tables and adding steps for updating HR
data before the mail is sent to the respective agent.

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 12/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like

Alert Moderator

Assigned tags

Retagging required | ravishankar rajan |

Related Blog Posts

Available Cloud BADIs for Purchase Requisition Flexible Work ow


By Yamuna Mathew , Oct 14, 2019
How to Find Work ow Agent using Class in Background Task
By yuvaraj kauthkar , Aug 27, 2020
Manage S/4HANA Cloud Flexible work ow triggers based on added eld under in-app extensibility in procurement process
By Pawan Kumar , Sep 29, 2020

Related Questions

Work ow Tables
By Former Member , Jun 15, 2009
Selection of agent from Custom BRF+ decesion table in rule base work ow in MDG
By Sanjay Shah , Nov 11, 2017
Leave Work ow- Agent Determination and Posting
By Waz _ , Apr 28, 2009

6 Comments

You must be Logged on to comment or reply to a post.

David Halitsky

December 26, 2006 at 2:56 pm

Hi Ravi -
This is a great post and one I'm sure will be helpful to me in the future.  (I'm taking BIT 600/601 in January.)

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 13/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

But a question for you:  are the emails in your z-table for a given "agent" the same as the emails in adr6 for
Follow
some "user". RSS feed Like

Or are the agents not "users" in the usr01 sense?

If agents = users, how come you decided to create a z-table instead of chasing the address numbers to adr 6? 
Are the emails for "agent" users not in adr6 even though the agents are users in usr01?

Please don't get me wrong - I'm really hoping you'll tell me why the agent emails
CAN'T be in adr6. 

Because then we'll have the billionth example of why the Codd/Ellison paradigm is so impoverished as to be
virtually useless once we're above the level of a trivial organization like a bank or Health and Human Services.

Like(0)

Former Member

December 26, 2006 at 6:30 pm

Hi David
Thanks for your comments.You are right in saying the emails can be in adr6 table.But What is been displayed in
this blog is a sample version of the actual custom table.The actual table contains some company speci c data
based on which the emails along with the superior information is determined.The actual table fetches
information based on some work ow rules created and is updated based on that.So based on the application
rules executed the email addresses can be completely di erent from the agent.In this blog I wanted to keep
things simple so that the basic concept can be understood without confusing the reader with too much details.

Like(0)

Former Member

January 18, 2007 at 4:59 am

Hi Ravi,
I dont understand why so many steps need to be there for this development.
Why cant we have a simple background step to determine agents and populate it into a a multiline attribute and
pass it back to work ow.
And give the agent as Expression with the Multline Container.
Hope i got ur requirement right

Like(0)

Former Member

February 15, 2007 at 5:15 am

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 14/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

there is aquestion for you... I had a requirement where a approval is needed by contract managers for a creadit
memoFollow RSS
generated. In this feedthe contarct manager
case Like is derived from the person responsible eld on WBS
assighnemnt.so if there are multiple contract managers are found for multiple WBS elements then work ow
should dynamically create a seperate approval for each manager. also subsequent approvals shuld escalate up
an approval structure so that lower level operational approval is received before the higher level approval.Oce all
approvals are nished then the billing block is deleted....
i will use a WBS in my rule container , but how do i go thru the org structure of the contract manager(person
respnsible  eld) and his subsequent or superior levels? please suggest some idea.

Thanks,
Vineela.

Like(0)

Former Member

March 19, 2007 at 7:39 pm

Hi,
  This is Nethaji thankyou for your clear explanation. I think it is good to us if you do many
more scenarioes
                                 Thanking you,
                                 N.Nethaji.

Like(0)

Former Member

July 20, 2008 at 10:22 pm

Hi Ravi,
Thanks for the elaborative blog. its really helpful. I copied steps by steps by what you have mentioned while
creting this work ow, but for me it is not working. Its hangs at the place of selecting agents from ztable. When i
tested my BO - ZSYSTEM and executed method GetAgents it showed an error -
Message ID:          OL
Message number:      831
Access 'C' is not valid for the verb type 'A'
kindly help. I dont know where i am going wrong.

Thanks

Saurabh Chauhan

Like(0)

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 15/16
3/14/2021 Agent determination in workflow using custom table | SAP Blogs

Follow RSS feed Like Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Cookie Preferences

Newsletter Support

https://blogs.sap.com/2006/12/26/agent-determination-in-workflow-using-custom-table/ 16/16

You might also like