BOR Object : ZSYSTEM : 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.
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.
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 fields 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 (Workflow Builder ) we create a workflow
Container elements used in the workflow are as follows :
The workflow 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
This step Describe Agents returns back the number of agents available.We are capturing this information into the workflow container variables &AGENTS and &NUMOFAGENTS.
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.
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.
Send the mail to the Agents got in the previous step.
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.