3
Defining Custom Rules for use in SAP Workflow “I would like to explain about creating custom rules in SAP Workflow. The rules can be created or changed using the standard SAP transaction PFAC. Once the rules are created you can call these rules in any workflow via the rule container”. In this article I am creating a rule, which will find the users based on Position id. I have created a custom function module ZWF_FIND_USERS which will return me back a position under Asset Analyst (HRP1001-SOBID). The custom function created should have the same interface as that of the SAP standard function module RH_GET_ACTORS. The following table parameters have to exist in the custom function module. “ACTOR_TAB STRUCTURE SWHACTOR” “AC_CONTAINER STRUCTURE SWCONT” Following is the function module code: FUNCTION ZWF_FIND_USERS. *"----------------------------------------------------------- *"*"Local Interface: *" TABLES *" ACTOR_TAB STRUCTURE SWHACTOR *" AC_CONTAINER STRUCTURE SWCONT *" EXCEPTIONS *" NOAGENT_FOUND *"-----------------------------------------------------------  INCLUDE <CNTN01>.  DATA : POSITION_ID LIKE ZBUSAREA-OBJID,  LT_HOLDERS TYPE STANDARD TABLE OF SWHACTOR,  LWA_HOLDERS TYPE SWHACTOR,  LWA_USERS TYPE STANDARD TABLE OF HRP1001,  WA_USERS TYPE HRP1001,  NUM_LINES TYPE I. *Read values assigned to the rule criteria  SWC_GET_ELEMENT AC_CONTAINER 'POSITION_ID' POSITION_ID.  SELECT * FROM HRP1001 INTO table LWA_USERS  WHERE OBJID = POSITION_ID.  IF NOT LWA_USERS IS INITIAL.  REFRESH LT_HOLDERS[].  loop at LWA_USERS into WA_USERS.  Condense WA_USERS-SOBID.  LWA_HOLDERS-OTYPE = 'US'.  LWA_HOLDERS-OBJID = WA_USERS-SOBID.  APPEND LWA_HOLDERS TO LT_HOLDERS.  APPEND LINES OF LT_HOLDERS TO ACTOR_TAB.  endloop.  ENDIF.  DESCRIBE TABLE ACTOR_TAB LINES NUM_LINES.  IF NUM_LINES IS INITIAL.  RAISE NOAGENT_FOUND.  ENDIF. ENDFUNCTION. Creating a rule using the PFAC Transaction  Assign the fun ction modu le ZWF_FIND_ USERS in the " Rule Definition Tab"

CustomRulesforuseinSAPWorkflow.docx

Embed Size (px)

Citation preview

8/12/2019 CustomRulesforuseinSAPWorkflow.docx

http://slidepdf.com/reader/full/customrulesforuseinsapworkflowdocx 1/3

8/12/2019 CustomRulesforuseinSAPWorkflow.docx

http://slidepdf.com/reader/full/customrulesforuseinsapworkflowdocx 2/3

8/12/2019 CustomRulesforuseinSAPWorkflow.docx

http://slidepdf.com/reader/full/customrulesforuseinsapworkflowdocx 3/3