Rule
Rule
Rule
Use
Using Rules, you can specify data at runtime according to a template defined at
definition time. This can be used, for example, in SAP Business Workflow. The f
ollowing types of rule can be resolved:
Agent determination rules
WebFlow rules
By resolving an agent determination rule in SAP Business Workflow you can, for e
xample, determine the responsible agents of a work item who have certain charact
eristics. You use WebFlow rules to determine elements of the pipeline for a Web
Activity.
Integration
The tools used for the Definition of an Agent Determination Rule or the Definiti
on of a WebFlow Rule are part of the Organizational Management component. SAP Bu
siness Workflow and mySAP Customer Relationship Management use rules as standard
.
Features
The system performs rule resolution. It is first performed at runtime depending
on and using information from the process currently running.
In a workflow step, the rule Orders Administrator for Customer <Customer> as of
Order Amount <Order Amount> is used.
If customer "Miller Ltd." and order amount "$34,569.34" are determined for a spe
cific order, the agents are determined at workflow runtime who are the "orders a
dministrator for customer Miller Ltd. as of order amount $34,569.34".
The principle of rule resolution is always the same:
The contents of the rule container are read.
The rules resulting from the rule category are applied to this data.
The result of the rule resolution is returned in an internal table. In the case
of agent determination rules, this table contains the agents as Organizational M
anagement objects (user, person, position, job, organizational unit) in any orde
r.
The category of the rule determines exactly how rule resolution is performed. Yo
u can determine the category when defining a rule.
Rule Resolution
Use
Using Rules, you can specify data at runtime according to a template defined at
definition time. This can be used, for example, in SAP Business Workflow. The f
ollowing types of rule can be resolved:
Agent determination rules
WebFlow rules
By resolving an agent determination rule in SAP Business Workflow you can, for e
xample, determine the responsible agents of a work item who have certain charact
eristics. You use WebFlow rules to determine elements of the pipeline for a Web
Activity.
Integration
The tools used for the Definition of an Agent Determination Rule or the Definiti
on of a WebFlow Rule are part of the Organizational Management component. SAP Bu
siness Workflow and mySAP Customer Relationship Management use rules as standard
.
Features
The system performs rule resolution. It is first performed at runtime depending
on and using information from the process currently running.
All responsibilities with the same priority are evaluated independently, and the
respective agents determined are all returned as a result.
If you want the workflow to receive the Error status if rule resolution does not
produce a result, set the corresponding flag. For more information, see Cancell
ation for Rule Resolution Without Result.
Creating Rule Containers
Use
The rule container must contain all the container elements for which you want to
define responsibilities. At runtime the system fills the rule container from th
e workflow or task container using binding.
Prerequisites
You are on the Rule: Change or Rule: Create screen, on the Container tab page.
You know the Data type references of the workflow or task container elements tha
t you want to transfer to the rule container.
Procedure
Choose .
The Change Container Element dialog box appears.
Make entries in the Element, Name, and Short Description fields.
Create either an object reference or an ABAP dictionary reference for the contai
ner element. As a guide, use the data type reference of the container element of
the workflow or task container from which the container will be filled at runti
me.
On the Properties tab page, set, if required, the Obligatory and/or Multiline in
dicators.
Repeat steps 1 to 4 until you have defined all the necessary elements for the ru
le container.
Creating a Responsibility
Prerequisites
All container elements whose values you want to check in a responsibility at run
time must be defined in the Rule Container.
You are on the Rule: Change or Rule: Create screen, on the Responsibilities tab
page.
Procedure
Choose .
The Create Responsibility dialog box appears.
Enter an abbreviation, a name, and the validity period of the responsibility and
confirm your entries.
The Change Responsibility for Rule <.....> screen appears. In this responsibilit
y editor, all container elements in the rule container are listed.
Enter a single value or a value range for the container elements whose content y
ou want the system to check during rule resolution. If you want to check several
single values or value ranges for one container element, you can create new ent
ry rows. Position the cursor in a row with the container element for which you n
eed a new row, and choose .
On the entry screen for Responsibility, select Container and enter &Material.Lab
or.Agents&.
You want to restrict the task of buying certain materials to certain individuals
within a specific organizational unit. This is achieved by creating an assignme
nt between a purchasing group (purchasing groups are SAP Organizational Object T
ypes ) and an organizational unit.
You can create assignments between any object classified as an SAP Organizationa
l Object, and the Organizational Management objects (organizational units, posit
ions, jobs, and work centers). You apply a validity period to these assignments,
so that changes in responsibility can be shown.
Prerequisites
The SAP organizational object types must be defined in the Business Object Repos
itory. For more information, see Editing the Basic Data of an Object Type.
In Organizational Management Customizing you must specify which Organizational M
anagement objects can be assigned to an organizational object type. For more inf
ormation, see Organizational Management Administration.
If you want to assign an organizational object type to an Organizational Managem
ent object that is not an organizational unit (for example, job or position), yo
u must know an organizational unit in which it is used. Organizational Managemen
t objects to be assigned are always selected via an organizational unit.
Procedure
If you want to evaluate the organizational structure, use the function module RH
_GET_STRUCTURE. For more information, see Defining Rules Using Evaluation Paths.
FUNCTION GET_REL_RESPONSIBLE.
*"----------------------------------------------------------
*"*"Lokale Schnittstelle:
*" TABLES
*" ACTOR_TAB STRUCTURE SWHACTOR
*" AC_CONTAINER STRUCTURE SWCONT
*" EXCEPTIONS
*" NOBODY_FOUND
*"----------------------------------------------------------
INCLUDE <CNTN01>.
* define variables stored in container
DATA: RELEASE_OBJECT TYPE SWC_OBJECT.
DATA: RELEASE_CODE LIKE RM06B-FRGAB.
* local data
DATA: BEGIN OF RELOBJECTKEY,
NUMBER LIKE EBAN-BANFN,
POSITION LIKE EBAN-BNFPO,
END OF RELOBJECTKEY.
REFRESH ACTOR_TAB.
CLEAR ACTOR_TAB.
* convert persistent container to runtime container
SWC_CONTAINER_TO_RUNTIME AC_CONTAINER.
* read elements out of container
SWC_GET_ELEMENT AC_CONTAINER 'ReleaseCode' RELEASE_CODE.
SWC_GET_ELEMENT AC_CONTAINER 'ReleaseObject' RELEASE_OBJECT.
* separate object key
SWC_GET_OBJECT_KEY RELEASE_OBJECT RELOBJECTKEY.
* loop and select table <TABLE> with
* RELEASE_CODE
* RELOBJECTKEY-NUMBER and RELOBJECTKEY-POSITION
* end of selection
* exception and parameter handling
IF SY-SUBRC NE 0.
RAISE NOBODY_FOUND.
ELSE.
ACTOR_TAB-OTYPE = <TABLE>-ACTOR_TYPE.
ACTOR_TAB-OBJID = <TABLE>-ACTOR_OBJID.
APPEND ACTOR_TAB.
ENDIF.
ENDFUNCTION.
Interface of Function Module for Agent Determination
The interface of a function module for rule resolution is described by the follo
wing parameters:
Table Parameters
AC_CONTAINER, Reference Structure SWCONT
Rule container with rule-specific parameters that must be available as input val
ues for rule resolution.
ACTOR_TAB, Reference Structure SWHACTOR
Table with results of rule resolution as return values.
The SWHACTOR structure has the following logical appearance:
Field name
Type
Length
Short text
Otype
CHAR
2
Object type in Organizational Management
ObjID
CHAR
12
ID of object in Organizational Management
Choose .
The Change Container Element dialog box appears.
Make entries in the Element, Name, and Short Description fields.
Create the required ABAP dictionary reference for the container element.
Repeat steps 1 to 3 until you have defined all the elements for the rule contain
er.
Result
The rule container contains elements with which an Organizational Management obj
ect can be transferred. At runtime either the container elements OType and ObjID
or the container element Org_Agent must be filled. If all container elements ar
e filled, only the value transferred in Org_Agent is evaluated.
Rule to Determine the Organizational Unit of a User
The recipients of a work item should be all users that belong to the organizatio
nal unit of a particular user.
At definition time:
As the agent determination rule for the agent responsible for the step, enter th
e rule Organizational Unit of a User ( FindOwnOrgUn / AC30000011 ). This rule us
es the RH_GET_STRUCTURE function module in conjunction with the WF_ORGUN evaluat
ion path ( organizational unit of a user/person).
In the binding from the workflow container to the rule container you transfer, f
or example, an expression that identifies the user as an Organizational Manageme
nt object.
You must ensure that the user is assigned to a position that itself belongs to a
n organizational unit.
At runtime:
At runtime the system uses the evaluation path to determine the user s organizatio
nal unit, and transfer it as the responsible agent. The recipients are the inter
section between possible and responsible agents.
By performing a suitable selection of possible agents for the task, you can, for
example, determine recipients who perform a particular activity within the orga
nizational unit. If, for example, the job Secretary is stored as a possible agen
t, and you use the rule to determine an organizational unit, all users who perfo
rm secretarial activities in that organizational unit become recipients of the w
ork item.
Cancellation for Rule Resolution Without Result
Empfängern
Definition
Indicator that determines how the system reacts if rule resolution fails to prod
uce a result.
Use
It is possible that rule resolution fails to find a valid user. Then rule resolu
tion triggers the exception NOBODY_FOUND , or returns an empty table.
If the indicator is set, the system gives the corresponding work item the status
Error.
If this indicator is not set, all Possible Agents of the work item become Recipi
ents.
The error situation is recorded in the workflow log.
If the name of the company and the invoice amount are known, the details in this
table are used for rule resolution, in order to find an administrator.
The following function modules are available, to ensure that you have access to
objects from Organizational Management that you need to fill the table and that
you can program possible entries.
Features
RH_DETERMINE_ORG_OBJECT
Determines the ID of any Organizational Management object.
Interface
Import Parameter
ORG_OBJECT , Reference structure SWHACTOR
Exceptions
NO_ACTIVE_PLVAR
NO_OBJECT_ID_SELECTED
NO_OBJECT_TYPE_SELECTED
This function module can be called without transfer parameters.
When you access this function module, a dialog box is displayed from which you c
an select an object type from Organizational Management.
Once you have selected an object type from Organizational Management, one of the
Organizational Management objects stored for this type can be selected and disp
layed using the search function.
The object type and ID of this Organizational Management object are returned as
an export parameter in the SWHACTOR structure and can be used in your applicatio
n.
RH_DETERMINE_ORG_OBJID
Determines the ID of an Organizational Management object from a predefined Organ
izational Management object type.
Interface
Export Parameters
ORG_OBJECT_TYPE , Reference field OBJEC-OTYPE
Import Parameter
ORG_OBJECT_OBJID , Reference field SWHACTOR-OBJID
Exceptions
NO_ACTIVE_PLVAR
NO_OBJECT_ID_SELECTED
This function module forms only the "second half" of the function module describ
ed above.
When you access it, you transfer the Organizational Management object type whose
possible values you want to display using the possible entries function. You tr
ansfer this Organizational Management object type as a one- or two-character ID.
Using the search function, you can select and display one of the entries stored
for the Organizational Management object type.
The ID of this Organizational Management object is returned as an export paramet
er in the variable ORG_OBJECT_OBJID and can be used in your application.
Definition of a WebFlow Rule
Use
WebFlow rules are used within a workflow in the basic data and in the Web activi
ty step type. Using a WebFlow rule you can individually execute the following pa
rts of a Web activity:
Determination of URL
Preparation of the XML document
Determination of the authentication data
Execution of the send procedure
Determination of transfer format
Prerequisites
To use a WebFlow rule, you must create an ABAP class. Depending on the type of t
he WebFlow rule, this class must support the following interfaces:
WebFlow Rule Type
Necessary Interface
WebFlow: Authentication
IF_SWF_XML_RULE_AUTHENTICATE
WebFlow: Sending
IF_SWF_XML_RULE_DATA_SEND
WebFlow: Preparation of the XML document
IF_SWF_XML_RULE_DATA_SET
WebFlow: URL determination
IF_SWF_XML_RULE_URL
WebFlow: Determine format (if group)
IF_SWF_XML_RULE_FORMAT
At the moment the rule type WebFlow: Signature is only used internally.
Features
If you use a WebFlow rule in a Web activity, the execution of the rule replaces
the usual process. Depending on the type of the WebFlow rule, the system automat
ically transfers particular data. For more information, see the appropriate inte
rface documentation.
In the WebFlow rules Send data and Prepare XML document, you can also make use o
f the standard process, executing your own process only in particular cases. The
methods for doing this are available in the class CL_WAPI_WEBFLOW_SERVICES.
Activities
You create a WebFlow rule by accessing the Rule: Change or Rule: Create screen.
Enter the abbreviation and the name of the rule, and select a rule type. Under O
bject type name, enter the ABAP class you created for the rule. You must transfe
r all additional data that you need for execution via the rule container. For mo
re information, see Creating Rule Containers.
Creating Rule Containers
Use
The rule container for a WebFlow rule must contain all additional container elem
ents that you need to execute the methods in the ABAP class. At runtime the syst
em fills the rule container from the workflow container using binding. For furth
er information about which data the methods contain as standard, see the interfa
ce documentation.
Prerequisites
You are on the Rule: Change or Rule: Create screen, on the Container tab page.
You know the data type references of the workflow container elements that you wa
nt to transfer to the rule container.
Procedure
1. Choose .
The Change Container Element dialog box appears.
2. Make entries in the Element, Name, and Short Description fields.
3. Create either an object reference or an ABAP dictionary reference for the con
tainer element. As a guide, use the data type reference of the container element
of the workflow container from which the container will be filled at runtime.
4. On the Properties tab page, set, if required, the Obligatory and/or Multiline
indicators.
5. Repeat steps 1 to 4 until you have defined all the necessary elements for the
rule container.