Anda di halaman 1dari 213

%& :RUNIORZ 'HYHORSPHQW

%&

:RUNIORZ 'HYHORSPHQW
SAP AG 1999

R/3: BC610 Workflow Development

Release 4.6 C

November 2000

Material Number: 5004 2450

&RS\ULJKW

&RS\ULJKW  6$3 $* $OO ULJKWV UHVHUYHG

1HLWKHU WKLV WUDLQLQJ PDQXDO QRU DQ\ SDUW WKHUHRI PD\


EH FRSLHG RU UHSURGXFHG LQ DQ\ IRUP RU E\ DQ\ PHDQV
RU WUDQVODWHG LQWR DQRWKHU ODQJXDJH ZLWKRXW WKH SULRU
FRQVHQW RI 6$3 $* 7KH LQIRUPDWLRQ FRQWDLQHG LQ WKLV
GRFXPHQW LV VXEMHFW WR FKDQJH DQG VXSSOHPHQW ZLWKRXW SULRU
QRWLFH
$OO ULJKWV UHVHUYHG

SAP AG 1999

7UDGHPDUNV:
Some software products marketed by SAP AG and its distributors contain proprietary software
components of other software vendors.
n Microsoft, WINDOWS, NT, EXCEL, Word and SQL Server are registered trademarks of
Microsoft Corporation.
n IBM, DB2, OS/2, DB2/6000, Parallel Sysplex, MVS/ESA, RS/6000, AIX, S/390,
AS/400, OS/390, and OS/400 are registered trademarks of IBM Corporation.
n ORACLE is a registered trademark of ORACLE Corporation, California, USA.
n INFORMIX-OnLine for SAP and Informix Dynamic ServerTM are registered trademarks of
Informix Software Incorporated.
n UNIX, X/Open, OSF/1, and Motif are registered trademarks of The Open Group.
n HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C, World Wide
Web Consortium, Laboratory for Computer Science NE43-358, Massachusetts Institute of
Technology, 545 Technology Square, Cambridge, MA 02139.
n JAVA is a registered trademark of Sun Microsystems, Inc. , 901 San Antonio Road, Palo Alto, CA
94303 USA.
n JAVASCRIPT is a registered trademark of Sun Microsystems, Inc., used under license for
technology invented and implemented by Netscape.
n SAP, SAP Logo, mySAP.com, mySAP.com Marketplace, mySAP.com Workplace, mySAP.com
Business Scenarios, mySAP.com Application Hosting, WebFlow, R/2, R/3, RIVA, ABAP, SAP
Business Workflow, SAP EarlyWatch, SAP ArchiveLink, BAPI, SAPPHIRE, Management Cockpit,
SEM, are trademarks or registered trademarks of SAP AG in Germany and in several other countries
all over the world. All other products mentioned are trademarks or registered trademarks of their
respective companies.
n Design: SAP Communications Media
n

%XVLQHVV ,QWHJUDWLRQ 7HFKQRORJLHV ,


/HYHO 
5 days

SAP Business
Workflow Build and Use

Workflow

3 days



SAP ArchiveLink

3 days

Data Archiving

2 days

ADK - Retrieval
programming

Archiving



2 days
Data Archiving Retention
Tool (DART)

2 days




SAP Business Connector

SAP AG 1999

3 days

SAP Business
Workflow - Programming

SAP Business
Workflow - Introduction

2 days




/HYHO 

Web connection

%XVLQHVV ,QWHJUDWLRQ 7HFKQRORJLHV ,,


/HYHO 

/HYHO 

1

3 days
Application Link
Enabling (ALE)
Technology


T



!
US

4 days

EDI Interface

5 days



"!


2 days
Communication
Interfaces in ABAP

 
"!

5 days
Programming with
BAPIs in JAVA

5 days
R/3 Interface and BAPI
Programming in C++
SAP AG 1999

@@S
 !

5 days
Programming with
BAPIs in Visual Basic

B D D 0 B A0
$ EF"4%C)@9
( 6 4 0 (&
875321)'$%#

 


Data Transfer

 
CR

3 days

Business Integration
Technology

1 day
SAP IDoc Interface Development

( B $ 4 P 6 I ( 4& 4
171QC858HG

2 days
SAP IDoc Interface
Technology

3UHUHTXLVLWHV %& 

l (VVHQWLDO
%&  ,QWURGXFWLRQ WR WKH $%$3 :RUNEHQFK
%&  $%$3 'LFWLRQDU\
%&  6$3 %XVLQHVV :RUNIORZ  ,QWURGXFWLRQ
%&  6$3 %XVLQHVV :RUNIORZ  %XLOG DQG 8VH
*RRG RU YHU\ JRRG NQRZOHGJH RI $%$3
l 5HFRPPHQGHG
%DVLF NQRZOHGJH RI REMHFWRULHQWHG SURJUDPPLQJ
%DVLF NQRZOHGJH RI WUDQVDFWLRQ FRQFHSWV

SAP AG 1999

7DUJHW $XGLHQFH %&

l :RUNIORZ GHYHORSHUV DQG FRQVXOWDQWV ZLWK JRRG RU


YHU\ JRRG NQRZOHGJH RI $%$3

SAP AG 1999

&RXUVH 2YHUYLHZ

l &RXUVH *RDOV

l &RXUVH 2EMHFWLYH V
l &RXUVH &RQWHQW

l &RXUVH 2YHUYLHZ 'LDJUDP

SAP AG 1999

SAP AG

BC610

1-1

&RXUVH *RDOV

$W WKH FRQFOXVLRQ RI WKLV FRXUVH \RX ZLOO EH DEOH WR


l 3HUIRUP ZRUNIORZ SURJUDPPLQJ DW DOO OHYHOV

l 0DQDJH DQG PRQLWRU WKH ZRUNIORZ UXQWLPH V\VWHP

SAP AG 1999

SAP AG

BC610

1-2

&RXUVH 2EMHFWLYHV 

$W WKH FRQFOXVLRQ RI WKLV FRXUVH \RX ZLOO EH DEOH WR

l ,GHQWLI\ DOO SRLQWV LQ WKH ZRUNIORZ V\VWHP DW ZKLFK

SURJUDPPLQJ LV SRVVLEOH RU QHFHVVDU\

l &UHDWH \RXU RZQ REMHFW W\SHV DQG H[WHQG H[LVWLQJ

RQHV

l &UHDWH UROH IXQFWLRQ PRGXOHV


l 3URJUDP HYHQWV

l &UHDWH FKHFN DQG UHFHLYHU W\SH IXQFWLRQ PRGXOHV

SAP AG 1999

SAP AG

BC610

1-3

&RXUVH 2EMHFWLYHV 
$W WKH FRQFOXVLRQ RI WKLV FRXUVH \RX ZLOO EH
DEOH WR
l &UHDWH ZRUN LWHPV YLD $3,

l $GPLQLVWUDWH WKH ZRUNIORZ UXQWLPH V\VWHP

SAP AG 1999

SAP AG

BC610

1-4

&RXUVH &RQWHQW
3UHIDFH
Unit 1
Unit 2
Unit 3
Unit 4
Unit 5

&RXUVH 2YHUYLHZ

,QWURGXFWLRQ

2EMHFW 'HILQLWLRQ DQG


,PSOHPHQWDWLRQ

Unit 6
Unit 7

(YHQW 'HILQLWLRQ DQG


,PSOHPHQWDWLRQ
:RUNIORZ 5XQWLPH
6\VWHP

7DVNV
5ROHV

([HUFLVHV

6ROXWLRQV

$SSHQGL[
SAP AG 1999

SAP AG

BC610

1-5

&RXUVH 2YHUYLHZ 'LDJUDP

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

SAP AG

BC610

1-6

0DLQ %XVLQHVV 6FHQDULR

SAP AG 1999

Full text in appendix.

SAP AG

BC610

1-7

,QWURGXFWLRQ
&RQWHQWV

l 7DVNV RI D ZRUNIORZ V\VWHP

l 6$3 %XVLQHVV :RUNIORZ $UFKLWHFWXUH

l 3URJUDPPLQJ LQ 6$3 %XVLQHVV :RUNIORZ

SAP AG 1999

SAP AG

BC610

2-1

,QWURGXFWLRQ 8QLW 2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l ([SODLQ WKH 6$3 %XVLQHVV :RUNIORZ DUFKLWHFWXUH
l 5HFRJQL]H WKH FRPSRQHQWV RI 6$3 %XVLQHVV

:RUNIORZ WKDW HQDEOH RU UHTXLUH SURJUDPPLQJ E\ WKH


XVHU

SAP AG 1999

SAP AG

BC610

2-2

:KDW ,V :RUNIORZ 0DQDJHPHQW"

l $ V\VWHP WKDW GHOLYHUV ZRUN


,Q WKH FRUUHFW VHTXHQFH

:LWK DOO WKH QHFHVVDU\ LQIRUPDWLRQ

$W WKH FRUUHFW WLPH

7R WKH SHRSOH UHVSRQVLEOH

SAP AG 1999

Linking work steps automatically

Application-independent control of connected activities across transactions

SAP AG

BC610

2-3

7DVNV RI D :RUNIORZ 0DQDJHPHQW 6\VWHP


l 3URFHVV GHILQLWLRQ
:KDW KDSSHQV LQ ZKDW RUGHU"
:RUNIORZ EXLOGHU WDVN GHILQLWLRQ

l 2UJDQL]DWLRQ PRGHOLQJ
:KR GRHV ZKDW"
2UJDQL]DWLRQ PRGHO UROH GHILQLWLRQ

l $SSOLFDWLRQ HQFDSVXODWLRQ
:KLFK REMHFWV DUH UHTXLUHG"
%XVLQHVV 2EMHFW %XLOGHU %XVLQHVV 2EMHFW 5HSRVLWRU\

SAP AG 1999

Process definition - "Work is delivered in the correct sequence ..."

Organization modeling - "Work is delivered to the people responsible ..."

Application encapsulation - "Work is delivered with all the necessary information ..."

SAP AG

BC610

2-4

7DVNV RI D :RUNIORZ 0DQDJHPHQW 6\VWHP

l (QG XVHU VXSSRUW


:KDW KDYH , JRW WR GR WRGD\"
%XVLQHVV :RUNSODFH

l 3URFHVV FRQWURO
:KDW KDSSHQV ZKHQ"
:RUNIORZ PDQDJHU ZRUN LWHP PDQDJHU
l 3URFHVV HYDOXDWLRQ
:KR GLG ZKDW DQG ZKHQ"
5HSRUWLQJ DQG DQDO\VLV

SAP AG 1999

End user support - "Work is delivered to the people responsible at the correct time ..."

Process control - "Work is delivered in the correct sequence at the correct time ..."

SAP AG

BC610

2-5

6$3 %XVLQHVV :RUNIORZ 'HILQLWLRQ $UFKLWHFWXUH

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

Explanation A ! B = A uses B

Example:
Step definition uses attributes (container operation), events (wait steps), methods (secondary
methods).
Task uses workflow definition (in multistep tasks) or methods (in single-step tasks).

SAP AG

BC610

2-6

6$3 %XVLQHVV :RUNIORZ 3URJUDPPLQJ

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

Other areas in which programming is possible:


Administration
Reporting
Creation of work items

SAP AG

BC610

2-7

:KDW 'RHV :RUNIORZ 1RW 'R"

l 6LPSOLI\ DSSOLFDWLRQ WUDQVDFWLRQV


&RPSOH[ DSSOLFDWLRQ IXQFWLRQV UHPDLQ FRPSOH[
DSSOLFDWLRQ IXQFWLRQV

l 3URYLGH HIILFLHQW EXVLQHVV SURFHVVHV DXWRPDWLFDOO\


%XVLQHVV DVSHFWV PXVW EH FDWHUHG IRU E\ PRGHOHUV

SAP AG 1999

Existing interfaces or menu structures cannot be affected through using workflow.

As soon as the application is called via the workflow, only the application has control over which
actions can be performed.

SAP AG

BC610

2-8

,QWURGXFWLRQ 8QLW 6XPPDU\

l ([SODLQ WKH 6$3 %XVLQHVV :RUNIORZ DUFKLWHFWXUH

l 1DPH WKH FRPSRQHQWV RI 6$3 %XVLQHVV :RUNIORZ

WKDW HQDEOH RU UHTXLUH SURJUDPPLQJ E\ WKH XVHU

SAP AG 1999

SAP AG

BC610

2-9

2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


&RQWHQWV

l 0RWLYDWLRQ DQG EDVLF FRQFHSWV


l 2EMHFW GHILQLWLRQ

l 2EMHFW LPSOHPHQWDWLRQ

SAP AG 1999

SAP AG

BC610

3-1

2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ 8QLW


2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l ([SODLQ WKH EDVLF WHFKQLFDO FRQFHSWV RI WKH %XVLQHVV

2EMHFW 5HSRVLWRU\

l ([SODLQ WKH GHSHQGHQFLHV EHWZHHQ REMHFW GHILQLWLRQ

DQG LPSOHPHQWDWLRQ

l &UHDWH D QHZ REMHFW W\SH RU H[WHQG DQ H[LVWLQJ RQH


l ,PSOHPHQW DQ REMHFW W\SH XVLQJ WKH REMHFW PDFURV

SAP AG 1999

BOR - Business Object Repository - Data

BOB - Business Object Builder - Tool

SAP AG

BC610

3-2

&RXUVH 2YHUYLHZ 'LDJUDP

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

SAP AG

BC610

3-3

2EMHFWV  0RWLYDWLRQ

.H\V

$WWULEXWHV

0HWKRGV

%XVLQHVV 2EMHFW
5HSRVLWRU\

7DEOH 

7DEOH 

7$
7$

$SSOLFDWLRQ


 




5HSRUW;;
&KDQJH GRFXPHQWV VWDWXV PDQDJHPHQW 

(YHQWV
SAP AG 1999

Note: Events are dealt with later in a separate unit

The application data (tables) and the changes and queries (transactions and reports) that can be
performed on this data are encapsulated in the Business Object Builder.
This encapsulation is used
To simplify process modeling
As a standard interface for the workflow runtime system

SAP AG

BC610

3-4

8VLQJ 2EMHFWV
6WHS GHILQLWLRQ

&RQGLWLRQDO
EUDQFK

)RUN

/RRS

&RQWDLQHU RSHUDWLRQ

(YHQW
FUHDWRU

:DLW IRU
HYHQW

SAP AG 1999

Objects are used in


Tasks

Executing methods

Control structures

Querying attributes

Container operation

Querying attributes

Wait steps, event creator

Triggering or receiving events

Check FM, receiver type FM

Querying attributes

Receiver function module

Receiving events

Roles

Querying attributes

Secondary methods

Calling methods

SAP AG

BC610

3-5

2EMHFW 7\SHV  5HODWLRQVKLSV

l ,QKHULWDQFH
)XQFWLRQDO H[WHQVLRQ  LV D W\SH RI
l &RPSRVLWLRQ
.H\ H[WHQVLRQ  LV SDUW RI

l $VVRFLDWLRQ
)RUHLJQ NH\ UHODWLRQVKLS  LQ UHODWLRQ WR

SAP AG 1999

Example of inheritance: Accounting document Customer document

Key extensions are not allowed with inheritance. Interfaces can only be extended in an upwardcompatible manner (only possible to add new components or redefine existing ones).

Example of composition: Order

Order item

Example of association: Material

Purchase requisition

SAP AG

BC610

3-6

2EMHFW 7\SH  'HILQLWLRQ


3URJUDP

2EMHFW W\SH
,QWHUIDFHV
.H\
ILHOGV
$WWULEXWHV

0HWKRGV

9LUWXDO DWWULEXWHV
)LHOG UHIHUHQFHV
2EMHFW UHIHUHQFHV

$%$3 &RGH

6\QFKURQRXV

7UDQVDFWLRQ

$V\QFKURQRXV

)XQFWLRQ PRGXOH

(YHQWV

5HSRUW

SAP AG 1999

BOR is a client-independent directory of all defined object types

Each object type is assigned to a development class and, therefore, indirectly to an application
component.

SAP AG

BC610

3-7

2EMHFWV 3URSHUWLHV

l 'DWD HQFDSVXODWLRQ
l ,QKHULWDQFH

l 3RO\PRUSKLVP

SAP AG 1999

Object definitions and implementations can only be manipulated via the Business Object Builder.

Data encapsulation - definition: Abstraction for the modeler, irrespective of the concrete SAP tables,
transactions, etc.

Data encapsulation - runtime: A standard interface for calling application functionality is available to
the workflow runtime system, irrespective of the actual implementation.

Inheritance: Object properties such as attributes, methods and events are passed on to subtypes.
Properties inherited can be redefined in the subtype.

Polymorphism: Depending on the object type, the object manager always selects the relevant
implementation for the property requested. This property is implemented technically using the "late
binding" principle.

Dynamic call interface for calls from the workflow runtime system.

SAP AG

BC610

3-8

,QWHUIDFHV

l $VVXUDQFH RI D SDUWLFXODU EHKDYLRU

l 'HILQLWLRQV RI DWWULEXWHV PHWKRGV HYHQWV


l 6SHFLILFDWLRQ RI D GHIDXOW LPSOHPHQWDWLRQ
l +LHUDUFKLFDO VWUXFWXUH

l 5HSODFHPHQW IRU PXOWLSOH LQKHULWDQFH

SAP AG 1999

The implementation of an interface using an object type means the assurance of a particular
behavior.

The definition of an interface can contain a specified default implementation that is used if the
including object type does not perform any implementation of its own.

An object type that implements an interface must implement all the attributes and methods belonging
to the interface (unless there is a default implementation).

At present, the Business Object Builder does not check whether all the components belonging to the
interface are actually implemented.

Interfaces can also enter into inheritance relationships.

Interfaces replace multiple inheritance. They offer the same options as multiple inheritance, but are
easier to handle (for example, no conflicts when method names are the same).

SAP AG

BC610

3-9

,QWHUIDFHV  ([DPSOH

'RFXPHQWV
6'

00

),

%.3)

(..2

9%$.

%&$"!
# 

6 4 2 ) '
5310(

7 # % ' % 7
&A@8
%86

%86

%86

7 # % ' % 7
&98

%86

%86

&$"!5 @
% #   

%86

SAP AG 1999

BKPF
BUS2019
BUS2020
BUS2041
BUS2069
BUS2029
EKKO
VBAK
BUS2032

Posting document
Customer document
Vendor document
Asset document
G/L account document
Price change
Purchasing document
Sales document
Sales order

IFSTATUS
IFARCH21
IFIDOCOUT

Generate events from status management


Archive Link Interface
IDoc outbound processing

SAP AG

BC610

3-10

.H\ )LHOGV
l 6SHFLILFDWLRQ RI REMHFW NH\

l 6HYHUDO NH\ ILHOGV SRVVLEOH

l 5HIHUHQFH WR XQGHUO\LQJ DSSOLFDWLRQ WDEOH V


l &OLHQW QRW QHFHVVDU\

SAP AG 1999

The English ABAP Dictionary names are proposed automatically as the names of the key fields.

Key fields must be character-based.

The concatenated key fields can contain a maximum of 70 characters.

SAP AG

BC610

3-11

$WWULEXWHV

l 'DWDEDVH RU YLUWXDO DWWULEXWHV

l 7\SH LQIRUPDWLRQ IURP $%$3 'LFWLRQDU\ ILHOG RU


REMHFW W\SH
l 6LQJOHOLQH DQG PXOWLSOHOLQH DWWULEXWHV

SAP AG 1999

Database attributes are read from the associated application table and buffered in the object. Source
code is generated beforehand by the Business Object Builder for this purpose.

Virtual attributes are calculated on calling.

There are different macros for single-line and multiple-line attributes.

SAP AG

BC610

3-12

9LUWXDO $WWULEXWHV

l &RPELQDWLRQ RI RWKHU DWWULEXWHV RU FRQVWDQWV


l ([SOLFLW LPSOHPHQWDWLRQ UHTXLUHG

l &DOFXODWLRQ XSRQ DWWULEXWH DFFHVV

l %XIIHULQJ LQ WKH %XVLQHVV 2EMHFW %XLOGHU

SAP AG 1999

For performance reasons, virtual attributes are always preferable to reading background steps,
because the evaluation can take place directly in the workflow manager removing the need to create
a background step.

The Business Object Builder cannot generate a source code for virtual attributes. The algorithm
required for calculation of the attribute value must therefore always be explicitly programmed.

Typical examples:
language-dependent texts
time-dependent values
net/gross values
object references

SAP AG

BC610

3-13

0XOWLSOH/LQH $WWULEXWHV

l &RUUHVSRQG WR LQWHUQDO WDEOHV

l $UH DOPRVW DOZD\V YLUWXDO DWWULEXWHV

l &DQ FRQWDLQ HLWKHU GDWDEDVH ILHOGV RU REMHFW UHIHUHQFHV

SAP AG 1999

Example:
List of purchase requisitions for a material (BUS1001.PurchaseRequisition).

SAP AG

BC610

3-14

6\QFKURQRXV$V\QFKURQRXV 0HWKRGV

l 6\QFKURQRXV PHWKRG

5HVXOW UHWXUQHG GLUHFWO\ WR FDOOLQJ SURJUDP

B
B

5HWXUQ RI H[FHSWLRQV SRVVLEOH

5HVXOW FDQ RQO\ EH UHWXUQHG YLD DQ HYHQW

l $V\QFKURQRXV PHWKRG

2QO\ UHVWULFWHG H[FHSWLRQV SRVVLEOH

0HWKRG LWVHOI GRHV QRW ZDLW IRU D SRVVLEOH WHUPLQDWLQJ HYHQW

B
B
SAP AG 1999

(Import) parameters can be defined in both.

Asynchronous methods are always necessary if the encapsulated application functionality uses
updating.

Asynchronous methods can only trigger exceptions in the "dialog part".

SAP AG

BC610

3-15

6\QFKURQRXV 0HWKRGV

0HWKRG

([SRUW
5HVXOW
([FHSWLRQV

,PSRUW
&DOOHU

7LPH

l $OO GLVSOD\ PHWKRGV

l $OO PHWKRGV WKDW GR QRW ZULWH WKHLU FKDQJHV WR WKH


GDWDEDVH XVLQJ WKH XSGDWH WDVN

SAP AG 1999

The solid arrows represent the control flow.

The broken arrows represent the transfer of data and control flow.

The dotted line represents the waiting time of the caller.

SAP AG

BC610

3-16

$V\QFKURQRXV 0HWKRGV

'LDORJ

0HWKRG

8SGDWH

,PSRUW
&DOOHU
7LPH

l $OO PHWKRGV WKDW ZULWH WKHLU FKDQJHV WR WKH GDWDEDVH


XVLQJ WKH XSGDWH WDVN
l 3URFHVVHV PXVW EH V\QFKURQL]HG

SAP AG 1999

The solid arrows represent the control flow.

The broken arrows represent the data transfer.

The dotted line represents the waiting time of the caller.

The distinction between synchronous and asynchronous applies to both dialog and background
methods.

It is up to the caller to coordinate a resynchronization as necessary.


It is up to the method to make the synchronization possible technically ( Events).

SAP AG

BC610

3-17

&RPPXQLFDWLRQ 0HWKRGV &DOOHU  0HWKRG

l &RPPXQLFDWLRQ YLD SDUDPHWHUV


B

Import parameters
B

Export parameters

l &RPPXQLFDWLRQ YLD UHVXOW

l &RPPXQLFDWLRQ YLD H[FHSWLRQV


B

Temporary error
B

Application error
B

System error

l &RPPXQLFDWLRQ YLD HYHQW

SAP AG 1999

Synchronous methods support communication via parameters, results and exceptions.

Asynchronous methods support communication via import parameters. An event should be triggered
once they have been processed.

Export parameters should be avoided. Use a result instead. The result can be multiple-line.
Parameters should be avoided completely if the value can also be read as an object attribute.

If the result is based on a fixed value domain, automatic branching is possible via these values in the
WF definition.

If object attributes on the database are changed in the method, the Business Object Builder object
buffer must be invalidated with the macro SWC_REFRESH_OBJECT.

The type of exception subsequently determines error handling in the work item.

Exceptions are generally triggered via the macro EXIT_RETURN. There are two special macros,
EXIT_OBJECT_NOT_FOUND and EXIT_CANCELLED, the latter is used to return a user
termination in a synchronous method. User terminations reported in this way are then treated as
temporary errors.

SAP AG

BC610

3-18

5HDFWLRQ WR ([FHSWLRQ  'LDORJ 6WHS

6WHS
PHWKRG

6\V
HUURU

7HPS
HUURU

,Q SURFHVV

(UURU

2.

7HPS
HUURU

6\V
HUURU

6XEVHTXHQW
VWHS

6XEVHTXHQW
VWHS

6XEVHTXHQW
VWHS

0RGHOHG

1RW PRGHOHG

SAP AG 1999

In the workflow definition

The exception is defined for the object method


as a temporary exception:

as an application
or system error:

a subsequent step is
modeled for this exception

The status of the step changes to completed and the


subsequent step is executed

no subsequent step is

The step is not yet completed


modeled for this exception
associated

SAP AG

BC610

The status of the step


and remains 'in process'.and
workflow changes to
error.

3-19

SAP AG
n

BC610

3-20

Background steps also offer the option of modeling a repeat counter for a temporary error.
If this repeat counter is modeled and an error occurs, the step is repeated automatically as often as
defined, before either assuming "error" or "completed" status (with subsequent execution of the
subsequent step modeled).
SAP AG 1999

1RW PRGHOHG

0RGHOHG

P H
5dq b
q p
h5H f i1H &"$`
b g f

5Yq b
P H
hSH f i1H h"f`
q p
b g

P
5Hdq b
h"H f &H h"`
q p
i b g f

P
"Hdq b
q p
&"H f &H hS$`
i b g f

AVWUT u
T T

b H t VT
hb h"YSPsp r

AVdTc"H H
T 3YeT "
T VTT
R 13`
b b&a !`
a

T5Hhp f heq w
q
V t x
T 3V YT UT T5
AWU5H H
T VT
R "P vI H "
SQ1SG

T"Hdhp f ht9q f 1Wq xyw


q
V
V
T 3V VYUT "
AWTU5H H
T TT
R "P XI 1H
SQ5"G

DF
EC

AVWe"H H
T T3YT eT S
VTT
R R &!`
b &a !`
b a

T VT
3YUT u
V P
bhb Hht"YTSsp r &b t"W"sp r
b H VT P
T Hq
5Yhp f Vht
q f 1Wq yw
V x
T AV YT cT T5
AYU"H H
T VT
R "P XI H "
Sv1SG

T5H&p V t x
q
f hsWq yw
T3YUT"H
AV T c5
R "P I H "
9Q1SG

6WHS
PHWKRG

5HDFWLRQ WR ([FHSWLRQ  %DFNJURXQG 6WHS

9LUWXDO $WWULEXWHV  %DFNJURXQG 0HWKRG


9LUWXDO $WWULEXWHV

%DFNJURXQG 0HWKRGV

5HDG RU FDOFXODWH LQGLYLGXDO YDOXHV


RU D OLVW RI KRPRJHQHRXV YDOXHV

5HDG RU FDOFXODWH D OLVW RI


KHWHURJHQHRXV YDOXHV
&DOFXODWH YDOXHV ZKLFK DUH QRW
GHSHQGHQW RQ RWKHU DWWULEXWHV RU
V\VWHP YDOXHV
&KDQJH YDOXHV
(YDOXDWLRQ LQ ZRUNIORZ
PDQDJHU H[HFXWLRQ LQ
ZRUN LWHP PDQDJHU

(YDOXDWLRQ DQG H[HFXWLRQ LQ


ZRUNIORZ PDQDJHU
%XIIHULQJ RI WKH UHVXOWV LQ WKH
%XVLQHVV 2EMHFW %XLOGHU

1R EXIIHULQJ RI UHVXOWV

)L[HG FRPPXQLFDWLRQ ZLWK WKH


FDOOHU

$OO FRPPXQLFDWLRQ PHWKRGV


SRVVLEOH

SAP AG 1999

The buffering of the virtual attributes must be programmed explicitly in the implementation of the
attribute.

The return of the value of a virtual attribute to the caller corresponds, in principle, to a result value of
a method.

SAP AG

BC610

3-21

(YHQWV

l 'HILQLWLRQ DQG LPSOHPHQWDWLRQ DUH VHSDUDWH

l 'HIDXOW SDUDPHWHUV QHHG QRW EH VHW H[SOLFLWO\

l 8VHUGHILQHG SDUDPHWHUV DUH VHW H[SOLFLWO\ YLD FRQWDLQHU


PDFURV
l 'RFXPHQWDWLRQ LV LQGLVSHQVDEOH

SAP AG 1999

Only definitions of events in the Business Object Builder.

Default parameters are in the include RSWEINCL.


The following parameters are always incorporated:
Triggering object (type, key and object reference)
Name of event
Language, date and time
Triggering user.

User-defined parameters are only possible for events that are programmed explicitly. Parameters
should not be object attributes of the triggering object.

SAP AG

BC610

3-22

2EMHFW 7\SH  5HOHDVH 6WDWXV

l 0RGHOHG
1RW DFFHVVLEOH DW UXQWLPH

l ,PSOHPHQWHG
2QO\ LQ WHVWV RU LQWHUQDO XVH SRVVLEO\ XQVWDEOH

l 5HOHDVHG
5HOHDVHG IRU XVH E\ WKH FXVWRPHU 2QO\ XSZDUG
FRPSDWLEOH HQKDQFHPHQWV SRVVLEOH
l 2EVROHWH
7KH IXQFWLRQDOLW\ KDV EHHQ UHSODFHG 7KH ROG
IXQFWLRQDOLW\ LV VWLOO VXSSRUWHG IRU WZR UHOHDVHV

SAP AG 1999

The "modeled" status is the only status in which execution is not possible. Customers should,
however, only use components with the "released" status.

The release information should be noted when a components status changes to "obsolete".

SAP AG

BC610

3-23

2EMHFW 7\SH  'HIDXOW 6HWWLQJV

l 2EMHFW QDPH
'HVFULSWLYH QDPH IRU REMHFWV RI WKLV W\SH

l 'HIDXOW PHWKRG
'LVSOD\ IRU SUHVHQWLQJ DQ REMHFW LQVWDQFH
l 'HIDXOW DWWULEXWH
,GHQWLI\LQJ DWWULEXWH RI DQ REMHFW LQVWDQFH

SAP AG 1999

The object name is used as the element name in the container definition, for example.

The default method is used, for example, when you double-click objects in a list of object links.

The default attribute is used, for example, to display objects in lists.

SAP AG

BC610

3-24

SAP AG

BC610

3-25

Each object type has a program that implements the object type.

The macro instructions required for programming are incorporated via the include <object>.

The Business Object Builder always works with object references. These references are used to read
and manipulate the actual application data. An object reference of this kind must be created in the
calling program with the macro SWC_CREATE_OBJECT before a method is called or an attribute
determined.

Each object program contains the variable SELF which, in turn, contains a reference to the object
instance with which the program was called.

The object-key-sales document variable (generally: object-key-<name of key>) is declared in


conjunction with the BEGIN_DATA OBJECT macro.

The declaration between BEGIN_DATA and END_DATA is generated entirely from the definition
data.
SAP AG 1999

csfEXpW&(Uhk~hU8W
i r q pm ee f io m e ii g
"eFs
y u
y x i x | i
1chdhh{(8ccUrr
y u f
5eEsc(
y i xs u
h8ev~s~k
eee s o s i xs s
{r(c8(Y(ihWv~r(}k
i r | | r i i s v s
F(8|Us8xU8eschesjc(8xWh{izk
y i xs v u f
hhWwsc8nk
t i i
hc(
8ew(U(crs(w
i xs v s s
r(jhje8|ls8e8|{8ee~
s i r | i xs v
c(fFvpWm!&fi(UFhnlehcUjcheU8
is r q p ee o
m k i i gf
e d
hUEe(c


U8h

@h

YY1UWUcd W

YY1UWUcd W

WYdY W

U
dYdeW(

YY1eeUed W

WU&W WW

Y dUW W

dUW W

UW W d hUe 


Y eYd
&W

dU


e c

WdY W
eU Ud @

W d

Y hc e c Y W
WW&UWUeY e W e1Y

,PSOHPHQWLQJ .H\ )LHOGV

SAP AG

BC610

3-26

Source code is generated in the implementation program to read the date from the application table.

The source code between GET_TABLE_PROPERTY and END_PROPERTY is generated entirely


from the definition data. The form select_table_<table name> is also generated automatically for the
actual database access.

The macro EXIT_OBJECT_NOT_FOUND returns the exception "Object not found". This exception
corresponds to the T100 message OL826.
SAP AG 1999

eSWc
|su
e&(c
u
e i x g i
&8(cUs8x
e s
EcUr
e r
&
e i x i x g
&8{j8((U
e e e s r u
&u(0hEces
e s r r s
&heYEcUr
e8h|cUU(icceWesc8x
r r
E(8|dY{(8{o
i i r i | s
u vr i x | u f r
8W88jWsFQcjr
hEjhhc@e
e i r x i x g
EF88hc@e
i i r i | i x g u
e s s r f r i x g i g r |s
&cWrYrcjhcUc(hWeccvWu
e s vs vg
SY8UW
e&(c
u
e u g g g
hdU
e s r u
hsEhes
hshcUrc8hgWeccX|W(v
e f r i x i g r s us
r s v iq rr
s  hv e s ss  ei q s r r p p
r(heschUscj(
s fii p pq
s f i i hl  c c h Ui i j hp U8 h (p Yq j   {
Uhejche(l88Yj{
ecUcWcjhesic(
s r r s r i
e i s vs v g i g
18xW8eh(Ye@(f

Y dY WWY


Ue cY @
YU1W YW

8

W dUY e

dUY e

YUc (


UW Y hUW d

deUWeeWUe WYeW e

c UeW


e d U e

d eWc Uh W

Y Wd


We (

Y Uc


Uee YU1UUU deWY1UWU
deWY1UWU


dWdY W

dY

8
 WY1UWU


Y WWd

&W
dde


Y c

WW e
WU Ud @

W

YW&cYc& Y (
 WY1UWU 8

,PSOHPHQWLQJ 'DWDEDVH )LHOG $WWULEXWHV

SAP AG

BC610

3-27

The source code between GET_TABLE_PROPERTY and END_PROPERTY is generated entirely


from the definition data.

The macro EXIT_OBJECT_NOT_FOUND returns the exception "Object not found". This exception
corresponds to the T100 message OL826.

An object reference is generated automatically as an attribute value. This procedure only works
correctly if the referenced object type has precisely one key field. Otherwise, the attribute must be
implemented itself.
SAP AG 1999

e | u
SWsc
&(c
e u
e i x i
&8g(cUs8x
eEcUr
s
e r
&
e i x i x
&8{j8(g(U
e u e e s r u
&(0hEces
e s r s
&herYEcUr
e(8|UUcrceWesc8x
ri
i i | r i | s
E(8dY{(8{o
u v i x su fr
8Wr88j|WFQcjr
e r x i x g
hiEjhhc@e
r i | i x g u
iiEF88hc@e
&cWrYrcjhcUcr(hgWeiccv|Wu
e s
s r f i x g r s
e s vs vg
SY8UW
&(c
e u
e u g g g
hdU
e s r u
hsEhes
ehhcUfcr8hgWeiccX|W(v
s r
i x g r s u s
r(heschUscjr(p
s vs iq r
Uheijche(l88Yj{
s fii
p pq
e s r s r i i
cUrcWcjhesc(
e i s vs g i g
18xW8ehv(Ye@(f


W& W


@8

Y Y YUY


UW cW 

YU&e WY

888

Y YUY W

8

YUY W

YUc d (

UW W hUW d

dWcWeeWUe WYeW W

c UeW


e d U e

d eWc Uh Y

e Wd

We (

W Uc


We1U Yc
We1U Yc

YWdY W

dY

8


YcU Yc

Y WWd


&W
dde


e c

YdW e

WU Ud @
Y

Y cU  W 8
ecUc c Y (

,PSOHPHQWLQJ 'DWDEDVH )LHOG $WWULEXWHV 2EMHFW

SAP AG

BC610

3-28

The data declaration is generated from the definition data and is used as a runtime buffer.

The implementation between GET_PROPERTY and END_PROPERTY must be created manually,


since there is no other definition information. The object reference to be returned, in particular, must
be created explicitly via the macro SWC_CREATE_OBJECT.

Both the Business Object Builder runtime buffer "object-salesgroup" and the associated container
element "SalesGroup" must be completed for data transfer.
SAP AG 1999


Uc chd W

e s vs v
SY8UgW
e vsf i v s r
"ccr(crc(U$Scic
c((8e@Y r
s i | g r g
s i s us
c8j(wcU1c@ejcs
"vW8h8x!5c8Yyccr(crc(cU
e sf x i q vsf i
c@egWc(@Y r
is g
s u s i s
hcUcF
eh(h|cccricUW(Ujj8{(o
r x s
hxeFQcUr
i | su f r
e s i f fi
hcc(socvcfcr(icXY8U(f
s r s vs vg
e ii g
hU8W
ehW@gd r8YXvcUr

v sfri
"eFsc
y u
ee
e
y u f
5eEsc(
ehcUjicheU8
i gf


8

W e YeY


ee UY
WeW Wd

Y YeW Y d

YeW Y d

We


eW e hee
WYUUYUYce YdUW dW

cWe@


e W c c

d YUc Uh Y 8

W Wd 

YU (


Y cU

  cd U1 cc h Y

cc h Y


W eeU

YYYYeW

Uc @e Y

c Y WWd


hW
WU


W

YYd Y

ee UW
Y 8

Uc @e Y Y (
cc YY e Y 8

,PSOHPHQWLQJ 9LUWXDO $WWULEXWHV

SAP AG

BC610

3-29

The data declaration is generated from the definition data and is used as a runtime buffer.

The implementation between GET_PROPERTY and END_PROPERTY must be created manually,


since there is no other definition information. The object reference to be returned, in particular, must
be created explicitly via the macro SWC_CREATE_OBJECT.

Both the Business Object Builder runtime buffer "object-salesgroup" and the associated container
element "SalesGroup" must be completed for data transfer.

The actual implementation of the attribute also contains a query as to whether the runtime buffer is
completed.
SAP AG 1999

e s vs v
SY8UgW
ehecU(cUUci(shUicY r
r | r | s g r g
(8e(sc s  U p
| si
su frr
"e(
e v
e r | | vv
hecUUjcXe8Ui
e vi x p | g is
5Uhgehh@U( ecFe@Ygd r
ehchUicceihFEsUr(8dehe8x
s r v gv x v gvi
"Uicceh~QU
e gvi x i v
su is
s U 
e r i x gv
h(h|ccccrUW(Ujj8ecUi(x
e88UUr(crceWc@esjc8{o
| i x s
vi x i vi x |su
eigcU8whUcU(ve8jeFscr
ii
U
e1cjjU j8UQei({cveccU8{
s i o o rs v x i gvi x ii
e gvi x u
"Ucehws
y v vi x s
s(Ur(8W8{cjUr(8v
&hW8{cchx
y x vi x
y vi x f t ii
"egcU8wuj8&
e g r v | ii
chUY hYXUcs
"U8lr(Wic
e vi x
ic(8
i si m
e
hscic(siocE@evY8U(f
f f r | s vs vg
e ii g
hU8W
e rs g r v r |
j8U{e@d 8YjUc
"eFsc
y u
ee
e
y u f
5eEsc(
ehcUjicheU8
i gf


W &Y Y


@h

Y W WeW


ee UY
ee1Y ed

W WWe e

WWe e

eeU (

UW Y d hWe

YeeeeWeUU YYeW YW


c UUY


U Y U U

Y We ch Y 8

W Yd


We 8
d U


hW WY&UeeUhY e

&W


dWYd Y

W
h


&W

c W Ye

1Y

Yc


W d c

eY W

Ue UY
Y 8

&W h Y 8
hW  W 8

,PSOHPHQWLQJ 0XOWLSOH/LQH 9LUWXDO $WWULEXWHV

SAP AG

BC610

3-30

The implementation between BEGIN_METHOD and END_METHOD is generated from the


definition data.

The macro SWC_REFRESH_OBJECT must also be called after the application functionality for
synchronous methods that can change object attributes, in order to delete the object buffer.
SAP AG 1999

Yh


&Y
WcYeW YYW 

ceW

UcU&5U e (


deYe
c dec Y

UcU&c deeU U YYeW YW

e1c(e(8e
o |g
e s rsu
rvvW(Uh@ c8ics
r i p ir s i
eh(h|ccciceW(Ujcu"c8p cjcheic8v~r
r r s | si
&c(jciUvUhW(oW(8|(gWch
e s i f f o i vr f

dd hY Ue (


Y Ue (
d YW1Y U1

W

dYYWW(W
Y Ue (

ed d YU We Ued



cWUW


Y WYY U W


he


Y dW Weyd dd

WW e c W Ye

UW UW 

1Y

ce d

d Ue (ce d
Ue "UU

Y dehe U


e

Y

YYd Y
YYYYeW


ee Udd

ce

ee d
Y Ue (ce d
Y ce "UW

,PSOHPHQWLQJ 6\QFKURQRXV 0HWKRGV

SAP AG

BC610

3-31

The implementation between BEGIN_METHOD and END_METHOD is generated from the


definition data. The generated source text has been extended so that the transaction is only called if a
delivery block is set.

It is not necessary to call the macro SWC_REFRESH_OBJECT in this case, because the object
context is always lost in an asynchronous method

The terminating event must be triggered within the transaction called.

The single-step task that encapsulates this method requires at least one terminating event.
SAP AG 1999

eUhgW
o |
e u
&(
e sr rsu v r i p s i
1jech@ icr(ij
e r r
8h|cUciceW(esu
s | si
Sc8p cj8Ui8v~r
r r s x u
cjscve8eEvW(sc(eh{hU
o | x
&8vWsUchhw
e i r d ru i x u
e8hcUer(icrceWesjU8{o
| x s
i x |su f r
hje{Qccr
e s ffi s o |g f
hcic(socE(cr(shehxWj(ehec8

WU eW WccdYd

Yc ( Y dYd


Y dehe c1

W

YYYWW(e
YYYWU U WU W

d
he


ecWWe WYW 
cWe

eU11U Y


c WWWY c Wh

eU @
ccU1& UUe e YYee e

UEd YdUd dd ee Ued



c UWee


c W Yed U W (


1W

e dU ddcyd dd

YYY W Y eYd

ee Udd


&W

eU
U5Ue d
cc"eU


W d c

eY W

UW cY

Ue
WeYc (U We Wce
WdYee U WU W5UU


Y WY1Y e

e
YYYWY(W


edWYc (e YU Y

,PSOHPHQWLQJ $V\QFKURQRXV 0HWKRGV

SAP AG

BC610

Every exception must correspond to a T100 message.

Up to four parameters, which correspond to the four parameters of the T100 message, can be
transferred with the EXIT_RETURN macro.

3-32

No source code is generated for triggering an exception.

The triggering of exceptions is the same for all error types.


SAP AG 1999
Object type Temp.

1000
7000

1000
BUS1001
30D

UhW
e o |g
ee
e
e
&u(
e&8vWrji8WhYsic8|Uec@eEWcU@
i
vr i vr s i V s s g
s8F(eiQFcvW(s(cj8se8ecE
r s o
s isi | s s sis v|
e s r
hsEhercYsu
e V
W c@eu
gfs
r v
U(
U
0
i g


h
v
hWrg
is i |
c(8deYes
U(8|
s i
8vc
fs
p g u i
1(pc(UheTc(Uj
ee
e
e si f fio
&(sc(Ur UhY(j(ehec8
xrr | f o |gf

Message
Application area
MA
Message
279
& blocked by another user

Error type
Temporary error
Application error
System error

Exception
Object type
Release
Exception 1000
No.

App.

Syst.

AppArea

Message

Message text

MA
M3

BUS1001
BUS1001

279
195

& blocked by another user


No selectable views

Exceptions

hS  (P A7
R Q I 
'1 Gec e1
    
" H2
"
 
F A7 E 4 D ( 2C1 % B W ( "  #  cU W ' A  S c c
@9 486 6 5(  3" )0U &'%$  " c! U    "ee W

,PSOHPHQWLQJ ([FHSWLRQV LQ 0HWKRGV

SAP AG

BC610

3-33

The parameter transfer source code is generated entirely from the definition data.

Single-line input parameters are generally read via the macro SWC_GET_ELEMENT, and output
parameters written via the macro SWC_SET_ELEMENT.
The macros SWC_GET_TABLE and SWC_SET_TABLE are used for multiple-line parameters.
SAP AG 1999

v
~

sy h

` yyt
Bd v0a ` X
a%Bt 0sf
i`} } bg`
B c` aBB` v` 0sy
i | `tx b |`
` Bg aBB` v` 0sy
i y `tx b |`
dB cr at cq
bgx y

`tx b | b ` y yg
d0B` d` 0` %a %g Bhq

br r BBBB
b yg xg
h yag 0xBg

`0v v0B%duBB` Bgf


yyx` w tr p ig
` y x` wu r p ig
0v vy0B%dtBB` Bgf

x
d
vw
BBd aBBvBsBa` Bhf
` yx` wutrqp ig

` { i i
B icx B` d yc du%
y bvaBv
r
r
yy vB' w w
bbvrB'
p ` bb y` bg
a yc` b0hr BsB` 0wvg B

xh cr B c b0avq
y tp`
`%dvz
wg
yp Bd
`
`pg i`
0a0` hy
`0v v0a ` X
yyt
bB` y0vg bB
` w g

v
v

` x yt px b
ddrsBh cr 0ag0ag
BBd yaB`BuvBsBa` Bhf
` x w trqp ig
B` y0dg B
b ` w bg
e ` dY BaYX
c b`

` yyt
Bd v0a ` X

View

System Help

Program

e
e
e
e i is i is
&(crr(sic
e18Y(8UUr(iccq@p jc(8|Uh~Ur
v | r u p s isi v
e r is i isq
&(ic81r(
c((8e@Y r
s i | g f g
e18Y(8UUr(iccq@p jc(8|Uh~Ur
v | r u p s isi v
e v | r r vq | mri
18W88UU(icnh8W(hcc8Wc
c((8e@Y r
s i | g f g
e V r is
&c(%cic8
yi(cehYs8W88UU(cn&
s i i x v | r ir t ii
&(sci(Usc((eheU8
e si f f o is o |g f

x
dw
x
dw
a` 'v cr 0ga` b
i b x y

Goto

xg i
BB aB d' w

Other view

Object Edit

Exceptions

Utilities

nf n v os q p nmjlkj i h fe d
s%Yshu tWs r d hs ddc sohsvdvYgv B

,PSOHPHQWLQJ 3DUDPHWHU 7UDQVIHU

SAP AG
n

BC610

3-34

The result parameter must be set explicitly under the name "result" using the macro
SWC_SET_ELEMENT. The constant "result" is predefined and need not be defined explicitly.
SAP AG 1999

e o g
1U8|(W
e1cr(
i
(@
e i g
ho
e
e&hY8vd8WshYjWU(U@
i vr i r i vr i vr VV s s g
o
e V
e&icrY~Ujcic888Uc@(crY r

gs v rs s | g g
o
e
hhercYcr(
e s r
i
e
h
s
hei
V u g g|s
%jc@dUWu
r v
8U(
Ugd{
ir s v
c(ichv
r gs
fs v|
8W
s
8|ceUY(Uj
s |s
h|cWu
fs
8vc
18ec@h(UU6hUj
p g p gU u i
e&ichU8eu( scjUrYv&ic(
r s v r i |s r i gs t i
e s i ffi xs vv o |gf
hcc(socs8ehUisUhW8

Y

( 8


@@

U Y c U 
e Y e U

U W c W 
ee UY

WeW Wd

W YeW Y 

Yee W 

Wec (


eU U UU

WW Uc

WW Uc


W WeW@

c W WWd


1W

e c

WdY W

eU Ud @

UU
e W U e @ h c e @
We ce&UU


WYdW e
d

(@8


eY Uc

,PSOHPHQWLQJ WKH 5HWXUQ RI 5HVXOWV

SAP AG

BC610

3-35

The include <cntn01> must always be incorporated in the calling program. This include is also
incorporated in the implementation program via the include <object>.

Before attribute access, an object reference must be created by calling the macro
SWC_CREATE_OBJECT. Error handling measures must be incorporated if the object reference
cannot be created.

Attribute access for single-line attributes uses the macro SWC_GET_PROPERTY, and for multipleline attributes the macro SWC_GET_TABLE_PROPERTY - irrespective of whether a virtual or a
database attribute is read.

Attributes cannot be set via macros. Object values can only be changed via methods.
SAP AG 1999

U h W

e"vcsfhr(r ccr @vWs8e8gdgd r


g i
v s i ss gr ir vs v f
ss u sri s i is
EQvcc8esF
e u
&
f io sss s
({s E8U8{
e s r u
F8cUcYrs

eSehgdsgdiUr 88g c@r
s r
s s gr i
gis
c@eWU@gd r
s u s i s
hchejF
he@d 8YXc@rr
e g r v vsf g i
y
e@gd r8vYsc@rt1c(
s s g ir ii
e i g r r t s |i i
chxdhhx{vehdssgdicr8Us8v
e dV q
he8e(Ec(c

Y dY YeY


UW cY @
YU1W YY

Y dUY W d

dUY W d

YUc (


ee e hUW 
YYceWeWUe YWWe W

c dUWe

e d e U


Wec Uh Y (

W WY


eW (

Y UU

d cd U& Uc chd W




Uc chd W


Y eec

W
YWdWW(e

U @ed W

Y eYd


hW
YU


e

YYY W

ee Udd
Y (

e  W 8
Uc @Wd W Y (

,PSOHPHQWLQJ $WWULEXWH $FFHVV

SAP AG

BC610

Before attribute access, an object reference must be created by calling the macro
SWC_CREATE_OBJECT. Error handling measures must be incorporated if the object reference
cannot be created.

The import parameters of the method must also be completed before the method call.

The actual method call is implemented with the macro SWC_CALL_METHOD.

3-36

The include <cntn01> must always be incorporated in the calling program. This include is also
incorporated in the implementation program via the include <object>.

The export parameters can be read after the call.


e1U8(g W(s(8WW8(U8Y(8
i x
s v| i x
s i o | gf g
cc(gW(e((~(h|edd r
s si v s v i
c((|ei8~8cssF
e&sc@eUh| W((UhUs8c
i go
ss v| q x
s r ir o gi g
csg(UUh|d@d r
je(8|wF
o i
e s g |
"W(s(c@ve W((8U
ss v|
s i o | gr g
cc(gW(e((~(h|edd r
| r o s u s |isi v s v|
(oe(8~8esEr8Uh~heE(crE
SAP AG 1999

e u
&
f i sss
(o{s 8c8{
s
eEhcUcYs
s r r u
e gs r i
Sed@g(cr h
s grir g
csdccUgWcis@d r
s u s i s
hc1ejF
e o | s i g
hscic8gWe(8~c(@Y r
e i x
&s (ehh{
(U8g
i x
yee (ciujcsi hhx{ c(c@cve
e
i
ss g |
y g
e@d r8Ws@g1c(
v ss r ir t ii
eh%eqhe(Ec(c
dV

Parameter

Object type Created

CompCurrency
NetvalueInCompCurr

VBAK
VBAK

40A
40A

Overview

Dictionary
Dictionary
Reference table
Reference field
Search help

VBAK
WAERK

Data type reference


Import
Export
Multiple-line

Mandatory

Parameter properties
Description

Comparison currency

Parameter
Object type
Release

CompCurrency
VBAK
40A

Texts
Name

Comparison currency

Parameter CompCurrent

I  )
# !  Q & "
" U %0& '& B

hS  (P A7
 R Q I 
'1 Gec e1

    
" "H2
@6A
hAA ( h6 7 '" Be '"$  & eS & U    "ee W
@' D 1 )0U ( &
U5Q ' W ' A 'ESc c

,PSOHPHQWLQJ 0HWKRG &DOOV

0DFURV  6XPPDU\

l 0DFURV IRU REMHFW SURFHVVLQJ LQ LQFOXGH FQWQ!


B

Container macros, for example setting or reading container


elements
B

Object macros, for example creating objects or reading


attribute values

l 2EMHFWV FDQ DOVR EH PDQLSXODWHG RXWVLGH WKH


ZRUNIORZ YLD PDFURV

SAP AG 1999

The macro number must always be included if you are working in a program with objects. The
macro is included automatically in the Business Object Builders implementation programs via
<object>.

Only macros from <cntn01> may be used to manipulate objects and containers.

SAP AG

BC610

3-37

0DFURV IRU 2EMHFW 'HILQLWLRQ DQG &UHDWLRQ

l 2EMHFW UHIHUHQFH
B

Declaration
DATA: <obj_ref> TYPE SWC_OBJECT
B

Creation
SWC_CREATE_OBJECT <obj_ref> <obj_type> <obj_key>

SAP AG 1999

When SWC_CREATE_OBJECT is called, the method "ExistenceCheck" of the associated object


type is always called implicitly, in order to prevent references to non-existent objects.

SAP AG

BC610

3-38

0DFURV IRU $WWULEXWHV DQG 0HWKRGV

l $WWULEXWH DFFHVV
B

SWC_GET_[TABLE_]PROPERTY <obj_ref> <attribute> <value>

SWC_CALL_METHOD <obj_ref> <method> <container>

l 0HWKRG FDOO

SAP AG 1999

An object reference must be created before an object macro is called (for example, for attribute
access or method call).

These macros are not usually used in object implementation, but are required in the program that the
object uses.

If the <method> is SPACE for SWC_CALL_METHOD, the default method is executed.

SAP AG

BC610

3-39

0DFURV IRU 7ULJJHULQJ ([FHSWLRQV

l 7ULJJHULQJ H[FHSWLRQV
B

EXIT_RETURN <exception_no> <var1> ... <var4>


B

EXIT_OBJECT_NOT_FOUND
B

EXIT_CANCELLED

SAP AG 1999

EXIT_RETURN - trigger general exceptions (similar to T100 messages).

EXIT_OBJECT_NOT_FOUND - specified object instance not found.

EXIT_CANCELLED - action cancelled by user (for example, in methods after BACK).

It is not necessary to define the exceptions EXIT_OBJECT_NOT_FOUND and


EXIT_CANCELLED explicitly in a method.

Customer-defined exceptions must be in the customer name range.

SAP AG

BC610

3-40

0DFURV IRU 0DQDJLQJ WKH 2EMHFW 5HIHUHQFH

l 7\SH DQG NH\

SWC_GET_OBJECT_TYPE <obj_ref> <obj_type>

SWC_GET_OBJECT_KEY <obj_ref> <obj_key>

l 5HIUHVKLQJ REMHFW W\SHV

SWC_REFRESH_OBJECT <obj_ref>

SAP AG 1999

When a work item is executed, the objects in the associated container are automatically refreshed.

SAP AG

BC610

3-41

&RQWDLQHU 0DFURV

l 'HILQLWLRQ DQG LQLWLDOL]DWLRQ

SWC_CONTAINER <cont>

SWC_CREATE_CONTAINER <cont>

l 5HDGLQJ DQG VHWWLQJ HOHPHQWV

SWC_GET/SET_ELEMENT <cont> <element> <value>

SWC_GET/SET_TABLE <cont> <element> <int_tab>

SAP AG 1999

The container macros are also located in the include <cntn01>.

All types of container are manipulated via these macros (for example, task, role, event).

SAP AG

BC610

3-42

'HOHJDWLRQ
3URFHVV GHILQLWLRQ

%2%
A6%3C




'''

'8



%%H


%E

' A8 C

HH




''

'8


D
%8D


%%%8




''H

''8


E6 D

%8D

%%%8


`
T p
55D5hq

A6%3C


' A8 C
HH


%55


%' 6

''A

8E

H1Ssq x "&"p r
t p T H

6 


' A8 C
HH

A6%3C


6%


' A8 C
HH


%55

%% 6H

%H


'8

AV x 5H H
p q

6 


' A8 C
HH

SAP AG 1999

Problem:
How can customers use their own object extensions with the tasks, events, etc. supplied by SAP
Without having to change the application program where events are triggered,
Without having to redefine existing tasks.

Solution:
Define subtype and delegation.
Delegation "covers" the original supertype.
Continue to use the supertype.

Gray/Top: Behavior without inheritance


Red/Middle: Behavior with inheritance
Blue/Bottom:Behavior with delegation - the object type BUS1001 is regarded as having the
properties of Z_BUS1001 (that is, additional events, attributes and methods).

In the Business Object Builder itself, you can only see from the basic data for a supertype whether a
delegation has been defined.

SAP AG

BC610

3-43

2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ 8QLW 6XPPDU\

l ([SODLQ WKH EDVLF WHFKQLFDO FRQFHSWV RI

WKH %XVLQHVV 2EMHFW %XLOGHU

l ([SODLQ WKH GHSHQGHQFLHV EHWZHHQ REMHFW GHILQLWLRQ

DQG LPSOHPHQWDWLRQ

l ([SODLQ WKH SRLQWV WR QRWH ZKHQ FUHDWLQJ RU

H[WHQGLQJ DQ REMHFW W\SH

SAP AG 1999

SAP AG

BC610

3-44

([HUFLVHV
8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ

6HFWLRQ 0RWLYDWLRQ DQG 3URSHUWLHV RI 2EMHFW 7\SHV

After completion of these exercises, you will be able to:

Navigate in the Business Object Builder

Change the default settings and release status of an object type

As a member of the workflow development group in your enterprise, you


must:

Understand the basic technical concepts of the BOB

Master the search and navigation options in the BOB

Be familiar with the various statuses of an object type

Note: After every implementation step in the following tasks, note


the changes of color, status and icons. For example, the various
statuses are represented with different icons.

1-1

Familiarize yourself with the Business Object Repository.


1-1-1 Find and check your object type =
your group number.

0$5$. The ## characters refer to

1-1-2 Set the default attribute to MaterialDescription.


Note: You can find the default settings of an object type via Goto >
Basic data on the Change object type screen.

1-1-3 Change the status of your object type to released. You can ignore the
message The method ExistenceCheck is not redefined .
Note: If you have not completed this step, you cannot use your
object type in a task or role.

SAP AG

BC610

3-45

8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ 2EMHFW GHILQLWLRQ

After completion of these exercises, you will be able to:


Define a new object type

When implementing a workflow you will notice that not all customerspecific business processes can be modeled using a business object
supplied by SAP. In these cases, you must create a new object type.

2-1

Create a new business object type


2-1-1 Create a new business object type =3/$17  where ## stands for your
group number. Complete the basic data of this object type as below.

Supertype

3OHDVH GR QRW FRPSOHWH WKLV ILHOG

Object type

ZPLANT##

Object name

Plant_##

Name

Plant ##

Short description

Plant for group ##

Program

ZPLANT##

Application

Note: The names of the object type and the program must be in the
customer namespace.
Note: The object type, object name and program name must not
contain any blank characters.
2-1-2 You must define a key field for your new object type. In a second session,
look at the key of table T001W, the lines of which each represent a plant.
Define the key of your business object based on the key of this underlying
application table.
2-1-3 Create a new attribute 1DPH based on the field NAME1 of table T001W.
Generate the implementation for your definition with the Business Object
Builder.

SAP AG

BC610

3-46

2-1-4 Redefine the method 'LVSOD\. Do not define the method with reference to a
transaction or a function module. First, look at the implementation proposal
generated by the Business Object Builder. Then complete the
implementation of this method by copying the missing lines from the
method Display of the object type BUS0008 supplied by SAP.
Note: You must declare the view V_T001W in the implementation
program of your object type.

SAP AG

BC610

3-47

8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ 2EMHFW LPSOHPHQWDWLRQ

After completion of these exercises, you will be able to:


Create a new object type as subtype of an existing object type

When implementing a workflow you will notice that the object types
supplied by SAP do not meet your requirements fully. In these cases, you
must extend an existing object type by creating a customer-specific
subtype for it.

3-1

Create a subtype of your material object type.


3-1-1 Create a subtype ZMARA##A for your object type Z##MARA. Complete
the basic data of your new object type as below.

Supertype

Z##MARA

Object type

ZMARA##A

Object name

MARA_##_Version_A

Name

MARA ## Version A

Short description

Material group ## Version A

Program

ZMARA##A

Application

Note: The names of the object type and the program must be in the
customer namespace.
Note: The object type, object name and program name must not
contain any blank characters.

SAP AG

BC610

3-48

3-2

Extend your new object type so that it meets additional requirements.


Note: After each definition step, also check the source code in the
implementation program of the object type.

3-2-1 For the workflow development, you require events as triggering or


terminating events for your tasks.
Create two new events %DVLF0DWHULDO&KDQJHG and 2OG0DWHULDO&KDQJHG
for your object type.
3-2-2 Change the status of the two events to implemented .
3-2-3 Implement the two events using event creation from change documents. The
change document required is MATERIAL. Restrict the triggering of the
event for %DVLF0DWHULDO&KDQJHG to the field MARA-WRKST and for
2OG0DWHULDO&KDQJHG to MARA-BISMT.
3-2-4 Define another event 'HDGOLQH7HVW for your object type with a parameter
/DWHVW(QG'DWH that refers to the field SYST-DATUM. This parameter will
be used later to transfer an end deadline for a step within a workflow.
3-2-5 Create a new attribute &KDQJHG%\ based on the field MARA-AENAM.
This attribute specifies the user who last changed the underlying material.
You will use this attribute later to filter out your material.
3-2-6 Create a new method &KDQJH on the basis of transaction MM02.
Note: The transaction MM02 writes your changes to the database via
an update task.

3-2-7 Create a new method &KDQJH'RF'LVSOD\.


This method is to display all change documents for a particular material and
hence make the change history visible. Use the transaction MM04 for the
implementation.
3-2-8 Create a new method 'LVSOD\9LHZ.
The purpose of this method is to display a material from a particular view.
The desired view is to be transferred via the input parameter 0DWHULDO9LHZ.
Use the implementation to ensure that value "K" (corresponds to view
"Basic data 1") is accepted as the default for this parameter.
The actual view is displayed using transaction MM03.
Note: Transaction MM03 recognizes a SET/GET parameter MXX
via which the view used to start the transaction can be controlled.
Supply this SET/GET parameter with your input parameter value.
Note: The 0DWHULDO9LHZ input parameter must be defined with
reference to the database field T132T-STATM.

SAP AG

BC610

3-49

3-2-9 Create a (virtual object-value) attribute 3ODQW for one of the plants
connected with the material.
Use the field MARC-WERKS for the implementation of the attribute to
determine the plants in which the particular material is defined. Return the
first plant found in this manner in the form of an object reference from your
object type ZPLANT## as a value of the attribute.
3-3

Optional extensions
3-3-1 Create a (virtual database field) attribute ,QGXVWU\1DPH for the long text
for the value of the existing attribute Industry. This industry name can be
read from the field MBBEZ of table T137T on a language-specific basis.
3-3-2 Create a (virtual, multiline and object-value) attribute 40HVVDJHV that lists
all quality notifications in which the current material is used.
Note: Use the field MATNR in table QMEL to find the quality
notifications. The object type BUS2078 supplied by SAP
implements the quality notifications.

3-3-3 Create a new method &UHDWH0DWHULDO)URP5HIHUHQFH.


Using a material number transferred via the input parameter
5HIHUHQFH0DWHULDO1XPEHU, this instance-independent asynchronous
method is intended to generate a new material for which the material type
and the industry from the reference material are transferred. If no material
exists for the transferred reference material number, an exception is to be
triggered with reference to the T100 message M3 305 ("The material & is
not available").
To create the material, use transaction MM01.
Note: Transaction MM01 recognizes the following three SET/GET
parameters:
1) RMA to set the reference material number
2) MTA to set the material type
3) MTP to set the industry
Supply these SET/GET parameters with the values from your input
parameters.
Note: The 5HIHUHQFH0DWHULDO1XPEHU input parameter must be
defined with reference to the database field MARA-MATNR.

SAP AG

BC610

3-50

6ROXWLRQV
8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ

7RSLF 0RWLYDWLRQ DQG 3URSHUWLHV RI 2EMHFW 7\SHV

1-1

Familiarize yourself with the Business Object Builder.


Solution:
Object type Z00MARA
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Business
Object Builder
Note: Test materials (for all following tasks as well):
200-100 as material of type HALB
200-101 as material of type FERT
200-210 as material of type ROH

,PSOHPHQWDWLRQ RI REMHFW W\SH =0$5$

INCLUDE <OBJECT>.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here ...
" end of private,
BEGIN OF KEY,
MATERIAL LIKE MARA-MATNR,
END OF KEY,
PLANT TYPE SWC_OBJECT.
END_DATA OBJECT. " Do not change.. DATA is generated
BEGIN_METHOD CHANGEDOCDISPLAY CHANGING CONTAINER.
SET PARAMETER ID MAT FIELD OBJECT-KEY-MATERIAL.
CALL TRANSACTION MM04 AND SKIP FIRST SCREEN.
END_METHOD.

SAP AG

BC610

3-51

GET_PROPERTY PLANT CHANGING CONTAINER.


DATA: FIRST_PLANT LIKE MARC-WERKS OCCURS 0 WITH HEADER LINE.
IF OBJECT-PLANT IS INITIAL. " check buffer contents.
" find one arbitrary plant related to this material
SELECT WERKS FROM MARC CLIENT SPECIFIED
INTO TABLE FIRST_PLANT
UP TO 1 ROWS
WHERE MANDT = SY-MANDT AND
MATNR = OBJECT-KEY-MATERIAL.
" create an object reference using the found plant key
" if we found no such plant, well implicitly create an empty ref
READ TABLE FIRST_PLANT INDEX 1.
SWC_CREATE_OBJECT OBJECT-PLANT ZPLANT00 FIRST_PLANT.
ENDIF.
SWC_SET_ELEMENT CONTAINER Plant OBJECT-PLANT.
END_PROPERTY.
BEGIN_METHOD DISPLAYVIEW CHANGING CONTAINER.
DATA:MATERIALVIEW LIKE T132T-STATM.
SWC_GET_ELEMENT CONTAINER MaterialView MATERIALVIEW.
IF MATERIALVIEW IS INITIAL.
MATERIALVIEW = K. " display basic view
ENDIF.
SET PARAMETER ID MAT FIELD OBJECT-KEY-MATERIAL.
SET PARAMETER ID MXX FIELD MATERIALVIEW.
CALL TRANSACTION MM03 AND SKIP FIRST SCREEN.
END_METHOD.
BEGIN_METHOD CHANGE CHANGING CONTAINER.
SET PARAMETER ID MAT FIELD OBJECT-KEY-MATERIAL.
CALL TRANSACTION MM02 AND SKIP FIRST SCREEN.
END_METHOD.

SAP AG

BC610

3-52

8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ 2EMHFW GHILQLWLRQ

After completion of these exercises, you will be able to:


Define a new object type

When implementing a workflow you will notice that not all customerspecific business processes can be modeled using a business object
supplied by SAP. In these cases, you must create a new object type.

2-1

Create a new business object type


Solution:
Object type ZPLANT00
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Business
Object Builder


,PSOHPHQWDWLRQ RI REMHFW W\SH =3/$17
INCLUDE <OBJECT>.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here ...
" end of private,
BEGIN OF KEY,
PLANT LIKE T001W-WERKS,
END OF KEY,
_T001W LIKE T001W.
END_DATA OBJECT. " Do not change.. DATA is generated

TABLES: T001W, V_T001W.

SAP AG

BC610

3-53

GET_TABLE_PROPERTY T001W.
DATA SUBRC LIKE SY-SUBRC.
* Fill TABLES T001W to enable Object Manager Access to Table Properties
PERFORM SELECT_TABLE_T001W USING SUBRC.
IF SUBRC NE 0.
EXIT_OBJECT_NOT_FOUND.
ENDIF.
END_PROPERTY.
* Use Form also for other Properties to fill TABLES T001W
FORM SELECT_TABLE_T001W USING SUBRC LIKE SY-SUBRC.
IF OBJECT-_T001W-MANDT IS INITIAL AND
OBJECT-_T001W-WERKS IS INITIAL.
" read data from database table, if BOR buffer is empty
SELECT SINGLE * FROM T001W CLIENT SPECIFIED
WHERE MANDT = SY-MANDT
AND WERKS = OBJECT-KEY-PLANT.
SUBRC = SY-SUBRC.
IF SUBRC NE 0. EXIT. ENDIF.
OBJECT-_T001W = T001W.
ELSE. " read data from BOR buffer
SUBRC = 0.
T001W = OBJECT-_T001W.
ENDIF.
ENDFORM.
BEGIN_METHOD DISPLAY CHANGING CONTAINER.
" coding copied from BUS0008
CLEAR V_T001W.
V_T001W-MANDT = SY-MANDT.
V_T001W-WERKS = OBJECT-KEY-PLANT.
CALL FUNCTION VIEW_MAINTENANCE_SINGLE_ENTRY
EXPORTING
ACTION
= SHOW
VIEW_NAME
= V_T001W
CHANGING
ENTRY
= V_T001W.
END_METHOD.

SAP AG

BC610

3-54

8QLW 2EMHFW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ 2EMHFW LPSOHPHQWDWLRQ

After completion of these exercises, you will be able to:


Create a new object type as subtype of an existing object type

When implementing a workflow you will often notice that the object
types supplied by SAP do not meet your requirements fully. In these
cases, you must extend an existing object type by creating a customerspecific subtype for it.

3-1

Create a subtype of your material object type.

3-2

Extend your new object type so that it meets additional requirements.


Solution:
Object type Z00MARA
Path (via SAP Easy Access):

3-3

To create/change the object type


Tools > SAP Business Workflow > Development > Definition tools > Business
Object Builder
For the linkage between event execution and a change document
Tools > SAP Business Workflow > Development > Definition tools > Events >
Event creation > Change documents > Linkage

Optional extensions
Solution:
Object type ZRGMARA
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Business
Object Builder

SAP AG

BC610

3-55

,PSOHPHQWDWLRQ RI REMHFW W\SH =5*0$5$

INCLUDE <OBJECT>.
BEGIN_DATA OBJECT. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
" begin of private,
" to declare private attributes remove comments and
" insert private attributes here ...
" end of private,
BEGIN OF KEY,
MATERIAL LIKE MARA-MATNR,
END OF KEY,
QMESSAGES TYPE SWC_OBJECT OCCURS 0,
INDUSTRYNAME LIKE T137T-MBBEZ.
END_DATA OBJECT. " Do not change.. DATA is generated
TABLES: T137T.
TABLES: QMEL.
TABLES: MARA.
TABLES: T006.
GET_PROPERTY INDUSTRYNAME CHANGING CONTAINER.
DATA: GETINDUSTRYNAME LIKE T137T-MBBEZ.
DATA: INDUSTRY_KEY LIKE MARA-MBRSH.
IF OBJECT-INDUSTRYNAME EQ SPACE. " check buffer contents
SWC_GET_PROPERTY SELF Industry INDUSTRY_KEY.
SELECT SINGLE * FROM T137T
WHERE SPRAS = SY-LANGU AND
MBRSH = INDUSTRY_KEY.
IF SY-SUBRC EQ 0.
OBJECT-INDUSTRYNAME = T137T-MBBEZ.
ELSE.
OBJECT-INDUSTRYNAME = SPACE.
ENDIF.
ENDIF.
SWC_SET_ELEMENT CONTAINER IndustryName OBJECT-INDUSTRYNAME.
END_PROPERTY.

SAP AG

BC610

3-56

BEGIN_METHOD GETINDUSTRYNAME CHANGING CONTAINER.


DATA: GETINDUSTRYNAME LIKE T137T-MBBEZ.
DATA: INDUSTRY_KEY LIKE MARA-MBRSH.
SWC_GET_PROPERTY SELF Industry INDUSTRY_KEY.
SELECT SINGLE * FROM T137T
WHERE SPRAS = SY-LANGU AND
MBRSH = INDUSTRY_KEY.
IF SY-SUBRC EQ 0.
GETINDUSTRYNAME = T137T-MBBEZ.
ELSE.
GETINDUSTRYNAME = SPACE.
ENDIF.
SWC_SET_ELEMENT CONTAINER RESULT GETINDUSTRYNAME.
END_METHOD.
GET_PROPERTY QMESSAGES CHANGING CONTAINER.
DATA: LOCAL_QMEL LIKE QMEL OCCURS 0 WITH HEADER LINE.
DATA: THIS_QMEL TYPE SWC_OBJECT.
DATA: LINENO LIKE SY-TFILL.
DESCRIBE TABLE OBJECT-QMESSAGES LINES LINENO. " check buffer contents
IF LINENO = 0.
" read from database
SELECT * FROM QMEL INTO TABLE LOCAL_QMEL
WHERE MATNR = OBJECT-KEY-MATERIAL.
LOOP AT LOCAL_QMEL.
SWC_CREATE_OBJECT THIS_QMEL BUS2078 LOCAL_QMEL-QMNUM.
IF SY-SUBRC EQ 0.
APPEND THIS_QMEL TO OBJECT-QMESSAGES.
ENDIF.
ENDLOOP.
ENDIF.
SWC_SET_TABLE CONTAINER QMessages OBJECT-QMESSAGES.
END_PROPERTY.
BEGIN_METHOD CREATEMATERIALFROMREFERENCE CHANGING CONTAINER.
DATA: REFERENCEMATERIALNO LIKE MARA-MATNR,
INDUSTRY LIKE MARA-MBRSH,
MAT_TYPE LIKE MARA-MTART.
DATA: REF_MAT TYPE SWC_OBJECT.
SWC_GET_ELEMENT CONTAINER ReferenceMaterialNo
REFERENCEMATERIALNO.
SWC_CREATE_OBJECT REF_MAT Z00MARA REFERENCEMATERIALNO.
IF SY-SUBRC NE 0.
EXIT_RETURN 2000 REFERENCEMATERIALNO SPACE SPACE SPACE.
ENDIF.
SWC_GET_PROPERTY REF_MAT Industry INDUSTRY.
SWC_GET_PROPERTY REF_MAT MaterialType MAT_TYPE.
SET PARAMETER ID RMA FIELD REFERENCEMATERIALNO.
SET PARAMETER ID MTA FIELD MAT_TYPE.
SET PARAMETER ID MTP FIELD INDUSTRY.
CALL TRANSACTION MM01.
END_METHOD.
SAP AG

BC610

3-57

BEGIN_METHOD COPYMATERIAL CHANGING CONTAINER.


DATA: INDUSTRY LIKE MARA-MBRSH,
MAT_TYPE LIKE MARA-MTART.
SWC_GET_PROPERTY SELF Industry INDUSTRY.
SWC_GET_PROPERTY SELF MaterialType MAT_TYPE.
SET PARAMETER ID RMA FIELD OBJECT-KEY-MATERIAL.
SET PARAMETER ID MTA FIELD MAT_TYPE.
SET PARAMETER ID MTP FIELD INDUSTRY.
CALL TRANSACTION MM01.
END_METHOD.

SAP AG

BC610

3-58

7DVNV

&RQWHQWV

l 6LQJOHVWHS WDVNV
l 0XOWLVWHS WDVNV

SAP AG 1999

SAP AG

BC610

4-1

7DVNV 8QLW 2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l ([SODLQ WKH GLIIHUHQFH EHWZHHQ D VLQJOHVWHS WDVN DQG

D PXOWLVWHS WDVN

l 'HILQH DQG VWDUW VLQJOHVWHS DQG PXOWLVWHS WDVNV

l 5HFRJQL]H DQG GHILQH WKH ELQGLQJV ZLWKLQ D PXOWLVWHS

WDVN

SAP AG 1999

SAP AG

BC610

4-2

7DVNV 2YHUYLHZ 'LDJUDP

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

SAP AG

BC610

4-3

6LQJOH6WHS 7DVNV

6LQJOHVWHS WDVN

%2%

2UJDQL]DWLRQ
PRGHO

2EMHFW W\SH
0HWKRG

(YHQW

I 8$S TASR
' IU G Q
PIH)&9$F6C
G 'E D A
CB
4
124)#A24)@93875624)#33210)(
' 1 '1 '
%  
&$"#! 


$WWULEXWHV

2UJ XQLW

-RE

3RVLWLRQ

(PSOR\HH
8VHU

SAP AG 1999

The default role is evaluated if the task is used either outside a workflow or in a step definition
without agent assignment.

The following texts can be defined:


Work item text (workflow inbox in Business Workplace)
Task description (work item preview in Business Workplace)
Completion text
Latest end text
Latest start text
Requested end text

SAP AG

BC610

4-4

6\QFKURQRXV$V\QFKURQRXV 7DVNV

l 6LQJOHVWHS WDVN UHIHUULQJ WR V\QFKURQRXV PHWKRG

Single-step task is terminated when method reports back to


caller

Binding between task container and method container in


both directions

l 6LQJOHVWHS WDVN UHIHUULQJ WR DV\QFKURQRXV PHWKRG

Method started by workflow system

Single-step task is terminated when terminating event


occurs

Report back by terminating event

SAP AG 1999

Communication between single-step task and object method:


Synchronous:
The method is called, takes over the process control and reports back to the caller after processing.
Asynchronous:
The method is called, runs without any connection to the caller and does not report back to the
caller.

Note the following about synchronous/asynchronous calling and synchronous/asynchronous


reporting back in the step definition of a workflow:
The task method is always called synchronously (meaning in the same session as the calling
program).
Before and after methods are always called synchronously.

Secondary methods are always called asynchronously (meaning in a new external session).

Reports back to the workflow are only made from the task method. Secondary methods are only
for display.
n

An explicit confirmation can be modeled in the step definition for both synchronous and
asynchronous tasks.

Synchronous tasks can also have terminating events. The task is then terminated either when it has
been successfully executed or when the terminating event has been received. In this case, the
terminating event cannot be triggered within the associated object method.

SAP AG

BC610

4-5

6\QFKURQRXV 7DVNV

0HWKRG

([SRUW
5HVXOW
([FHSWLRQV

,PSRUW
:,0

7LPH

SAP AG 1999

The task is started via the work item manager (WIM).

The method is started within the task. The WIM caters for the input parameters of the method.

The WIM waits until execution of the method is terminated.

Once execution of the method is terminated, the WIM receives the export parameters or exceptions
of the method.

SAP AG

BC610

4-6

$V\QFKURQRXV 7DVNV

'LDORJ

0HWKRG

8SGDWH
7HUPLQDWLRQ
RI WKH
HYHQW

,PSRUW
:,0
(0

(QWHU OLQNDJH IRU


WHUPLQDWLQJ HYHQW

'HOHWH OLQNDJH IRU


WHUPLQDWLQJ HYHQW
7LPH

SAP AG 1999

The task is started via the work item manager (WIM). When the associated work item is created, the
WIM writes the linkages for the terminating events.

The method is started within the task. The WIM caters for the input parameters of the method.

The WIM waits for the end of the synchronous part of the method execution (this part takes place
within a dialog process) and can then execute actions that are independent of the terminating event.

Once the asynchronous part of the method execution is terminated (usually within an updating
process), the WIM receives a terminating event of the task, deletes all linkages and then continues.

SAP AG

BC610

4-7

:RUNIORZ 'HILQLWLRQ 6WHSV


:RUNIORZ WHPSODWH

:RUNIORZ GHILQLWLRQ

6WHS
Activity (task reference)
Condition
Multiple condition
Event creator
Wait for event
Process control
Container operation
User decision
Loop (until)
Loop (while)
Fork
Document from template
Send mail
Web activity

Reference to

ZRUNIORZ GHILQLWLRQ

Definition of WULJJHULQJ
HYHQWV
,QWHUIDFH definition
(import and export
parameters as
elements of the
workflow container)
,QLWLDO YDOXH
DVVLJQPHQW
$JHQW DVVLJQPHQW
for starting from the
workflow development
environment

SAP AG 1999

The steps can be arranged in sequence or in parallel.

Each step is a determining component of its own block. Operations carried out on individual steps
always affect the entire block in which the step is located.

SAP AG

BC610

4-8

8VLQJ WKH :RUNIORZ &RQWDLQHU


:RUNIORZ
&RQWDLQHU


Start via event

Container operation

Condition

Wait step

Activity

Deadline monitoring

SAP AG 1999

The workflow container is basically used to determine the import and export parameters of the entire
workflow and to exchange data between the individual steps.

(1) Data from the triggering event is transferred to the workflow container as input parameters.

(2) In a container operation as well, data is both read from (right-hand side of the allocation) and
written to (left-hand side of the allocation) the workflow container.

(3) Data is read from the workflow container in a branch control condition.

(4) In a wait step, data is both read from (for example, to set up the instance linkage for the event to
be received) and written to (for example, data received with the event) the workflow container.

(5) In an activity as well, data is both read from (for example, the input parameters of the task to be
executed) and written to (for example, the output parameters of this task) the workflow container.
In addition, data is read from the workflow container to resolve the role used in the step for agent
determination.

(6) Data is read from the workflow container for deadline monitoring (for example, the latest end).

SAP AG

BC610

4-9

&RQWDLQHUV DQG %LQGLQJ


5ROHV
&RQWDLQHU

:RUN ,WHP
&RQWDLQHU

0HWKRGV
&RQWDLQHU

HYHQW
&RQWDLQHU

I($ d

6
D A
&&4 WX
` Y




%$
H" a
`
34 YSX

($ d
I


DA
6
`
&4 Y b



%$
H"
`
34 Y a b

C3&
4B
1 '1 '
240)31 0)W



4B
C3&
1c4H)P4@86
A ) '

:RUNIORZ
&RQWDLQHU


SAP AG 1999

(1) (11) Event creator fills event container using container macros; no binding.

(2) Binding between triggering event and workflow containers. This binding is essential.

(3) (8) Binding between workflow container and role container for setting the role input parameters.
This binding is essential. (This only applies if the role was entered in the step definition. In the case
of a default role in the task definition, the parameters are supplied from the work item container.)

(4) (7) (9) (13) Binding between workflow container and task container (work item container) for
setting the input and reading the output parameters of the task. For this binding, it is irrelevant
whether the underlying task is synchronous or asynchronous. The workflow builder generates a
proposal for this binding in the step definition.

(5) (6) (10) Binding between task and method containers. For synchronous tasks, there is a binding
for both the import and export parameters (5) and (6); for asynchronous tasks, only for import
parameters (10). If this binding is not defined in the respective task, the task container is copied to
the method container at runtime.

(12) Binding between event and task containers. This binding is necessary if the event contains data
that was not previously contained in the task container (for example, with events from create
methods).

SAP AG

BC610

4-10

$OWHUQDWLYH %LQGLQJ  ,GHD

l %LQGLQJ EHWZHHQ VWUXFWXUHV DQG VFDODU YDOXHV

l %LQGLQJ EHWZHHQ PXOWLSOHOLQH DQG VLQJOHOLQH YDOXHV

l 3URJUDPPLQJ YLD IXQFWLRQ PRGXOH ZLWK IL[HG LQWHUIDFH


l &DQ EH GHILQHG IRU DOO ELQGLQJV

SAP AG 1999

Required with binding for BAPI methods, for example, since BAPIs generally work with structures
while container definitions cannot contain any structures (e.g. binding between workflow and singlestep task).

Function module entries in the binding editor via the "alternative binding" context menu.

SAP AG

BC610

4-11

$OWHUQDWLYH %LQGLQJ  ([DPSOH

rsr i g
3b eqpPWhb f
ed v ig
q qPdWhb f

#4HU d
'
2``P`
%
' 6% b ) g

FShb873sb
e tr r
tr r
& i 73sb
2`c`` 73sb
tr r
2`c`` 73sb
tr r
v a b tr r
wuW8e73sb

eqPpWhb
ig
eqPpWhb
ig
eqPpWhb
ig
eqPpWhb
ig
e ig
qPpWhb

f3U 3A
1A 14
f
Y )
f CH' X
f 
y!A e CP') x

!A e
f



$%$3 'LFWLRQDU\
6WUXFWXUH
%$3,.1$

Fb W
v eb

& i
Sd X
vv
Fahb e  X dcx
v
i
v ab
yuWe

:6
:RUNIORZ &RQWDLQHU

6WHS 
76
.1$&UHDWH)URP'DWD
7DVN FRQWDLQHU

)XQFWLRQ PRGXOH
)XQFWLRQ PRGXOH
966)B'$7$)/2:B:6
966)B'$7$)/2:B:6
SAP AG 1999

Example in step 21 of the multistep task WS20000102 (creating a customer via web form): The
workflow container only contains scalar values, which must be grouped together for BAPI method
KNA1.CreateFromData for structure BAPIKNA101.
This is mapped in function module VSSF_DATAFLOW_WS20000084. The scalar values from the
workflow container here are written to the appropriate structure fields of the PiAddress variables
using the container macros SWC_GET_ELEMENT and SWC_SET_ELEMEMT.

SAP AG

BC610

4-12

$OWHUQDWLYH %LQGLQJ  )XQFWLRQ 0RGXOH ,QWHUIDFH

l ,QWHUIDFH
function prog_binding
importing dataflow
tables
called_container
calling_container

like swabindef-dataflow
structure swcont
structure swcont

'DWDIORZ
(
,

([SRUW
,PSRUW

FDOOHGBFRQWDLQHU

FDOOLQJBFRQWDLQHU

SAP AG 1999

The variable DATAFLOW can only accept the values E (export, meaning binding from the
Calling_Container to the Called_Container) and I (import, meaning binding from the
Called_Container to the Calling_Container).

The FM must not trigger any exceptions.

The FM must not trigger any commits or rollbacks.

SAP AG

BC610

4-13

6WDUWLQJ 7DVNV

l 9LD WKH VWHS GHILQLWLRQ ZLWKLQ D PXOWLVWHS WDVN


l 9LD WKH ZRUNIORZ GHYHORSPHQW HQYLURQPHQW
l 9LD WKH 6\VWHP PHQX

l 9LD WKH $3, RI WKH ZRUN LWHP PDQDJHU


l 9LD D WULJJHULQJ HYHQW RI WKH WDVN

SAP AG 1999

Tasks are usually started via the step definition.

For test purposes, tasks are started via the WF development environment. The current user must be a
possible agent of the task.

Tasks can be started via the "Workflow" entry in the System menu from the application transaction,
if an appropriate link is provided by the application.
This link is already implemented in the following applications:
Accounting (FI and CO)
Logistics - Purchasing
Logistics - Master Data
Plant Maintenance
Quality Management
Service Management

Starting tasks via the WIM API is discussed in the unit dealing with the runtime system.

Starting tasks via an event is discussed in the unit dealing with the event manager.

SAP AG

BC610

4-14

7DVNV 8QLW 6XPPDU\

l ([SODLQ WKH GLIIHUHQFH EHWZHHQ D VLQJOHVWHS WDVN DQG

D PXOWLVWHS WDVN

l 'HILQH DQG VWDUW ERWK D VLQJOHVWHS WDVN DQG D

PXOWLVWHS WDVN

SAP AG 1999

SAP AG

BC610

4-15

([HUFLVHV
8QLW 7DVNV

7RSLF 6LQJOH6WHS 7DVNV

After completion of these exercises, you will be able to:

Create new single-step tasks

You have either found or created all the object types that you want to use
in your business process with the associated attributes and methods in
the Business Object Builder. Now you want to create single-step tasks
based on the object methods that you can use later in your workflow
definition.
Note: All tasks are based on the object type ZMARA##A.

1-1

Create a new standard task for displaying a material master.


1-1-1 Create the task = 0DW'LVS with the method Display. Define the task as a
general task. Specify both a work item text and a task description. Output
the material number in both texts.
1-1-2 Test the task by starting it via the workflow development environment.

1-2

Create a new standard task for changing a material master.


1-2-1 Create the task = 0DW(GLW with the method Change. Define the task as a
general task. Specify a work item text, a text for latest end and completion,
and a task description. In addition to the material number, also output the
number and name of the plant for this material in all texts.
1-2-2 As this task is asynchronous, you must define at least one terminating event.
Use the event BasicMaterialChanged. In this case, the event does not require
a binding definition.

SAP AG

BC610

4-16

1-2-3 Test the task in two steps. Start the task in the first step as usual, but do not
change the field basic material. Instead, initiate the transaction again. Now
view the instance linkages from the work item display.
1-2-4 In the second step, change the field basic material and search again for the
instance linkages.
1-2-5 Check the event trace to ensure that the terminating event really was
triggered.
1-3

Create a new standard task for displaying a material master from a particular view.
1-3-1 Create the task = 0DW'LVS9 with the method DisplayView. Define the
task as a general task. Specify both a work item text and a task description.
Output the material number in both texts.
1-3-2 Define view "K" (corresponds to "Basic data 1") as the default value for the
parameter for controlling the view called for the material.
1-3-3 Test the task by starting it via the workflow development environment.

SAP AG

BC610

4-17

8QLW 7DVNV

6HFWLRQ 0XOWLVWHS 7DVNV

After completion of these exercises, you will be able to:


Create new multistep tasks

You have either found or created the single-step tasks that represent the
steps in your business process. Now you want to incorporate these singlestep tasks into a workflow definition.

Note: If not specified otherwise, the workflow initiator is always to be


the agent responsible for a step. Agent assignment via role resolution is
dealt with in the next unit.
Note: Each time a new step is inserted, you should check, save, activate,
and test your workflow definition again.

2-1

Define a workflow with a triggering event.


2-1-1 Create the workflow template = 06,352& for changing a material
master. Define the input parameters required for this workflow. Define
OldMaterialChanged as triggering event for your workflow. Implement the
binding between the triggering event and the workflow and activate the
event linkage.
2-1-2 Incorporate the single-step task Z##MatDisp into your workflow definition.
2-1-3 Check, save, and activate your workflow definition.
Test your workflow with your material by starting it from the workflow
development environment.
2-1-4 Add the single-step task Z##MatEdit to your workflow definition as a new
first step. Define the workflow initiator as the message recipient for
completed processing.

SAP AG

BC610

4-18

2-1-5 This step is to have deadline monitoring. Activate deadline monitoring for
the latest end. This is to be triggered if processing of the step is not finished
after 5 minutes. Define the workflow initiator as the message recipient if the
latest end is missed.
2-1-6 For the display step, also define a secondary method, which displays all
change documents belonging to the current material in a separate session.
2-1-7 Check, save, activate and test your workflow again. Check whether, after
the Edit step, you have the notification of completion in your Business
Workplace.
2-2

Optional extensions: Create and change a second workflow.


2-2-1 Copy your first workflow template =
template = 06,352&.

06,352& to the new workflow

2-2-2 Change the message recipient for completion for the "Edit" step. The
manager of the workflow initiator is now to receive the notification of
completion.
Note: Use the role AC00000168 to determine the manager of a
specific user. Read the documentation on this role in order to define
the binding from the workflow to the role container correctly.

2-2-3 Define another input parameter /DWHVW(QG'DWH for your workflow. This
parameter is used to determine the latest end for the Edit step.
2-2-4 Define another input parameter 0DWHULDO9LHZ for your workflow. This
parameter is used to control the view in the display step of the process.
Define view "K" as the default for this parameter.
2-2-5 Define DeadlineTest as another triggering event for your new workflow.
Define the binding between the event parameters and the input parameters
of the workflow. Activate the event linkage.
2-2-6 The latest end for the Edit step should be on the date determined via
/DWHVW(QG'DWH, five minutes after the current time. Ensure in your
workflow definition that this parameter cannot contain a deadline in the
past.
2-2-7 In the display step, replace the original task Z##MatDisp with the task
Z##MatDispV Supply the step parameter for controlling the display view
with the value of the 0DWHULDO9LHZ parameter from the workflow container.
2-2-8 Check, save, activate and test your new workflow both by starting it from
the development environment and by triggering the new triggering event
explicitly.

SAP AG

BC610

4-19

2-3

Optional extensions: Alternative binding


2-3-1 Create a function module = B%,1'B:)B72B',63/$<B67(3 for an
alternative binding between the workflow container and the task container
of the display step.
Note: You only require one binding from the workflow to the task
container of task Z##MatDispV.

2-3-2 Enter your new function module as an alternative binding for the display
step in your workflow definition Z##MSIPROC2.

SAP AG

BC610

4-20

6ROXWLRQV
8QLW 7DVNV

7RSLF 6LQJOH6WHS 7DVNV

1-1

Create a new standard task for displaying a material master.


Solution:
TS30900005 Z00MatDisp
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Tasks/Task
groups > Create

1-2

Create a new standard task for changing a material master.


Solution:
TS3090006 Z00MatEdit
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Tasks/Task
groups > Create

1-3

Create a new standard task for displaying a material master from a particular view.
Solution:
TS98000008 Z00MatDispV
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Tasks/Task
groups > Create

SAP AG

BC610

4-21

8QLW 7DVNV

6HFWLRQ 0XOWLVWHS 7DVNV

After completion of these exercises, you will be able to:


Create new multistep tasks

You have either found or created the single-step tasks that represent the
steps in your business process. Now you want to incorporate these singlestep tasks into a workflow definition.

2-1

Define a workflow with a triggering event.


6ROXWLRQ
WS96000011 Z00MSIPROC1
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Tasks/Task
groups > Create

2-2

Optional extensions: Create and change a second workflow.


6ROXWLRQ
WS96000012 Z00MSIPROC2
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools > Tasks/Task
groups > Copy

2-3

Optional extensions: Alternative Binding


6ROXWLRQ
Z##_BIND_WF_TO_DISPLAY_STEP
Path (via SAP Easy Access):
To create the function module
Tools > ABAP Workbench > Development > Function Builder
To incorporate the function module in the step definition
Tools > SAP Business Workflow > Development > Definition tools >
Tasks/Task groups > Change

SAP AG

BC610

4-22

)XQFWLRQ PRGXOH =B%,1'B:)B72B',63/$<B67(3


FUNCTION Z00_BIND_WF_TO_DISPLAY_STEP.
*"---------------------------------------------------------------------*"*"Local interface:
*"
IMPORTING
*"
VALUE(DATAFLOW) LIKE SWABINDEF-DATAFLOW
*"
TABLES
*"
CALLED_CONTAINER STRUCTURE SWCONT
*"
CALLING_CONTAINER STRUCTURE SWCONT
*"---------------------------------------------------------------------DATA: MAT_OBJECT TYPE SWC_OBJECT.
DATA: MAT_VIEW LIKE T132T-STATM.
IF DATAFLOW EQ E.
" only consider export dataflow from wf to wi container
" read data from workflow (= calling) container
SWC_GET_ELEMENT CALLING_CONTAINER MaterialMaster MAT_OBJECT.
SWC_GET_ELEMENT CALLING_CONTAINER MaterialView MAT_VIEW.
" write data to work item (= called) container
SWC_SET_ELEMENT CALLED_CONTAINER WI_LEADING_OBJECT
MAT_OBJECT.
SWC_SET_ELEMENT CALLED_CONTAINER MaterialView MAT_VIEW.
ENDIF.
ENDFUNCTION.

SAP AG

BC610

4-23

5ROHV

&RQWHQWV

l 'HWHUPLQLQJ DJHQWV YLD UROH IXQFWLRQ PRGXOHV

SAP AG 1999

SAP AG

BC610

5-1

5ROHV 8QLW 2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l 'HILQH DQG XVH D UROH YLD D UROH IXQFWLRQ PRGXOH
l ,PSOHPHQW D UROH IXQFWLRQ PRGXOH

SAP AG 1999

SAP AG

BC610

5-2

5ROHV 2YHUYLHZ 'LDJUDP

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

SAP AG

BC610

5-3

5ROH 5HVROXWLRQ

l (YDOXDWLRQ XVLQJ RUJDQL]DWLRQ PRGHO


Superior of...
Head of organizational unit
Departmental secretary

l (YDOXDWLRQ XVLQJ PDVWHU GDWD


Person responsible for material
Customer service employee

l (YDOXDWLRQ XVLQJ &XVWRPL]LQJ GDWD


Accounting clerk
Person responsible for release

SAP AG 1999

Roles are used to restrict or define more closely the number of recipients according to business
considerations.

Benefits:
dynamic restriction of the number of possible agents
actual organizational plan does not need to be known
agents determined according to current conditions (role resolution at runtime)

The definition of a role contains


the specification of the rules for role resolution (> function module), and
the specification of the runtime-dependent role parameters required for role resolution.

Role definition, use of roles and role resolution using the role "Superior of." as an example.

The roles "Manager" and "sap_org_unit" are supplied by SAP.

SAP AG

BC610

5-4

$GGUHVVLQJ YLD )XQFWLRQ 0RGXOHV

l 5ROH IXQFWLRQ PRGXOHV FDQ EH XVHG IRU DQ\ HYDOXDWLRQV

l 5ROH IXQFWLRQ PRGXOHV PXVW EH ZULWWHQ E\ WKH FXVWRPHU

l ,QWHUIDFH
IXQFWLRQ UROHBIP
WDEOHV
DFWRUBWDE
VWUXFWXUH VZKDFWRU
DFBFRQWDLQHU VWUXFWXUH VZFRQW
H[FHSWLRQV
QRERG\BIRXQG
l &RQWDLQHU FRQWDLQV WKH SDUDPHWHUV GHILQHG IRU WKH UROH

SAP AG 1999

The role container must be filled with a binding. If the role is used in a step, data can be transferred
from the workflow container. If the role is used as the default role of the task, data can be transferred
from the task container.

The function module must have the interface outlined above.

SAP AG

BC610

5-5

SAP AG

BC610

5-6

The actual function module SWX_DLI_READ_FOR_ROLE is more extensive - this is only an


extract. The function module is used for agent determination on the basis of a distribution list.

The result of a role resolution does not necessarily have to be a user - it can also be any
organizational object (for example, an organizational unit, a position, etc).
SAP AG 1999
% 0 ) 
i"$"'("$
%$ji"' $$09v$"t"$uhy98$A0u"
'   %  0 5  q 0
1 8 7 % 8 )
1
g f q ) 5 7 ) 8 '
y9$("$
% 0 0 
y9$A0""Q"8
% q 8 ) 5 7 ) 8  
%99D(7Qq"hQh@1""7$)Q$ @"(wu$$r 99A9`@08
h 8

 D
5 
 q 0 D q 8 ) 5 7 )
% P U  ) 0 D q 8 ) 5 7 )
Qe"F9A9`@08
%  8 1 d  ) 5 7 q h  h
&"QF2$T"FA@("Q$"3
7  x
%1($7$("@vT"$
 ) 5  ) 8 0 0
% '   %  ' 5  0 q 0
t"("""0A"Qu$7tq$91`"
1 8 %   7 D 1 '
%
A"
1 7 x )
(90
1  4
("0$) 9"$
1""7")($ @u1($$)("6"

 7  5
1($698)
 q
 h 8 5
96@u
Q98"
 h 5
) 7 0 4
$$
!
tY(b $QH(d(FR$"(w$
E 5 d E I S 5 Y
5 P
0 ) ' 8
%  h 8 5  E 5Y H
&Q6@"(I($(Qd 8$("0$ ($Q9" W61
7  )
5 8 )  h  5 )  5 3
% q 8 ) 5 7 0 ) 8 x 1  7 '  7 % q 8 5 7 )
9`@$"""y9$) @08u$"
7 8 
%&$w$w9)vwQ$v!$Q$$"0p$"u$7$Q$6"(
 7   8  x x 3  1 7 0
)   1  i
1  )  5
stQ6W9!"'($r 90p$"
 h 8 5 r q 0 D
q 0 1  i
Q"(
 h 8 5
g 8 ) 8
&$
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D C
""D$"D"D"D""""""""D$"""""""""""$"""""""B
d  U R 5 d R G
"$$$f 9e("R(
c
B
P 9Y("QI
 R  b I a
C
"B
6R$ VWTI"U$$T"I(W`F$65FE

P
S U   S  P S  Y E  R  
C
"B
S   X V
$RE96WPTI"9"$TG(F $E
S U   U S P
E 5 S R 
C
"B
Q""G(F
P I H E
C
"B
D D
"D"D$D"""D"""D"D""D""D$"""""""""""$"""""""B
D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D D C
%  0 5 7 0 5  8  5  5 4 1 )
&$$7A@"' 9$""7 "6"32$0$"('
&#$" 
% !       

l 7ULJJHU H[FHSWLRQ
QRERG\BIRXQG

l 5HWXUQ DJHQWV IRXQG


RU
l (YDOXDWH LQWHUQDO
DSSOLFDWLRQ GDWD IRU
DJHQW GHWHUPLQDWLRQ

l 5HDG UROH SDUDPHWHUV


IURP UROH FRQWDLQHU

6WUXFWXUH RI D 5ROH )XQFWLRQ 0RGXOH

5HVROXWLRQ RI $GGUHVVLQJ

l )LUVW OHYHO
7DVN SURILOH
l 6HFRQG OHYHO
'HWHUPLQDWLRQ RI UHVSRQVLEOH DJHQWV RU GHIDXOW
UROH RI WDVN
l 7KLUG OHYHO
5HPRYDO RI H[FOXGHG DJHQWV

SAP AG 1999

The level above may consist only of a further restriction of the level below. Therefore, if the first
level is missing because the task profile was not maintained, agents cannot be found in the
subsequent levels.

Unlike e-mails, the work items derived from the tasks are not delivered as copies. Instead, just one
work item exists for all recipients and they have only a view on it.

The explicit definition of possible agents in the task definition can be replaced by classification as a
"general task". In this case, all users known in the system can process the task.

If a role is specified both in the step definition and in the task definition, the role in the step
definition overrides the default role from the task definition.

Users who are not possible agents of the task never see the WI, even if they are responsible agents
because of a role resolution.

The default role of a task is also evaluated if the agent assignment using a role in the step definition
ends without a result, and the indicator "terminate if role resolution has no result" is not set for this
role.

SAP AG

BC610

5-7

5ROHV 8QLW 6XPPDU\

l 'HILQH DQG XVH D UROH GHILQHG YLD D UROH IXQFWLRQ

PRGXOH

l ,PSOHPHQW D UROH IXQFWLRQ PRGXOH

SAP AG 1999

SAP AG

BC610

5-8

([HUFLVHV
8QLW 5ROHV

7RSLF 5ROH 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ

After completion of these exercises, you will be able to:


Create role definitions
Create a role function module

The flow of the business process is now stored in the workflow definition.
You now want to assign the individual dialog steps based on the current
data of the object to be processed to the correct recipients.

1-1

Create a new role =

0DW'LVS$F using a role function module.

1-1-1 Create a role function module = B00B0*5B25B86(5B*(7. This


function module returns the manager of the initiator of the workflow as
agent if the material type of the material entered has the value ROH (raw).
Otherwise the initiator is returned.
Note: Use the function module from role AC00000168 to determine
the manager of a specific user. Read the documentation on this role in
order to provide the role container correctly with the input data.

1-1-2 Now define the role using the new function module. Define the parameters
for this role according to the implementation of your function module.
Note: The role parameters are defined via the role container.
Note: The workflow initiator can be defined with reference either to
field WFSYST-INITIATOR or to RHOBJECTS-OBJECT.

1-1-3 Use the newly created role for the agent assignment of the display step in
your workflow Z##MSIPROC2.
1-1-4 Check, activate and test your workflow Z##MSIPROC2 again.

SAP AG

BC610

5-9

6ROXWLRQV
8QLW 5ROHV

7RSLF 5ROH 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ

Create a new role =

1-1

0DW'LVS$F using a role function module.

Solution:
AC30900129 Z00MatDispAc
Function module Z00_MM_MGR_OR_USER_GET
Organizational structure
O 00003100 Plant Chicago
----- S 50014947 Project Leader Engineering
----- P 00010810 Kimberley Hughes
----- US WF-BC-MGR Kimberley Hughes
----- S 50011158 Electrical Engineer
----- P 00010812 Caroline Douglas
----- US WF-BC-CLERK Caroline Douglas
Path: (via SAP Easy Access)

For the role


Tools > SAP Business Workflow > Development > Definition tools > Standard roles >
Create

For the function module


Tools > ABAP Workbench > Development > Function Builder

For the organizational structure


Tools > SAP Business Workflow > Development > Definition tools > Organizational
Management > Organizational plan > Display

SAP AG

BC610

5-10

FUNCTION Z00_MM_MGR_OR_USER_GET.
*"---------------------------------------------------------------------*"*"Local interface:
*"
TABLES
*"
ACTOR_TAB STRUCTURE SWHACTOR
*"
AC_CONTAINER STRUCTURE SWCONT
*"
EXCEPTIONS
*"
NOBODY_FOUND
*"---------------------------------------------------------------------DATA: MATERIAL_TYPE LIKE MARA-MTART. " type of changed material
DATA: WF_INITIATOR LIKE SWHACTOR.
" workflow initiator
DATA: COUNTER
TYPE I.
REFRESH ACTOR_TAB. CLEAR ACTOR_TAB.
* get type of material under consideration
SWC_GET_ELEMENT AC_CONTAINER MaterialType MATERIAL_TYPE.
SWC_GET_ELEMENT AC_CONTAINER WorkflowInitiator WF_INITIATOR.
CASE MATERIAL_TYPE.
WHEN ROH. " get manager of wf_initiator from role
SWC_SET_ELEMENT AC_CONTAINER ORG_OBJECT WF_INITIATOR.
CALL FUNCTION SWX_GET_MANAGER
TABLES
ACTOR_TAB
= ACTOR_TAB
AC_CONTAINER
= AC_CONTAINER
EXCEPTIONS
NOBODY_FOUND
= 1.
IF SY-SUBRC NE 0.
RAISE NOBODY_FOUND.
ENDIF.
WHEN OTHERS.
ACTOR_TAB = WF_INITIATOR.
APPEND ACTOR_TAB.
ENDCASE.
* check if we have found any agents at all
DESCRIBE TABLE ACTOR_TAB LINES COUNTER.
IF COUNTER = 0.
RAISE NOBODY_FOUND.
ENDIF.
ENDFUNCTION.

SAP AG

BC610

5-11

(YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ

&RQWHQWV
l (YHQW PDQDJHU

l 7ULJJHULQJ HYHQWV H[SOLFLWO\


l 5HFHLYLQJ HYHQWV
l (YHQW TXHXH

SAP AG 1999

SAP AG

BC610

6-1

(YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ 8QLW


2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l ([SODLQ WKH EDVLF FRQFHSWV RI WKH HYHQW PDQDJHU
l 7ULJJHU DQ HYHQW H[SOLFLWO\ XVLQJ SURJUDPPLQJ
l (YDOXDWH DQG UHFHLYH DQ HYHQW
l $GPLQLVWUDWH WKH HYHQW TXHXH

SAP AG 1999

SAP AG

BC610

6-2

(YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ 2YHUYLHZ

2UJDQL]DWLRQ

3URFHVVHV

%XVLQHVV
REMHFWV

3RVLWLRQMRE

3HUVRQ

2UJ XQLW

7DVN

5ROH

:) GHILQLWLRQ

$WWULEXWHV

6WHS

(YHQWV

0HWKRGV

2EMHFW

SAP AG 1999

SAP AG

BC610

6-3

(YHQWV 0RWLYDWLRQ

l 6KLIW RI FRPSOH[LW\
l *UHDWHU IOH[LELOLW\

l (DVLHU WR H[WHQG DQG LQWHJUDWH


l *UHDWHU WUDQVSDUHQF\

SAP AG 1999

The complexity and management of general information are shifted from the applications to a central
component. The information on possible linkages is no longer in the applications.

Linkages can be easily activated and deactivated at runtime.

New linkages can be easily integrated without changing the source code of the application. External
components can also be connected.

The transparency of the entire system is enhanced by disclosing general information.

Examples of applications include:


Starting workflows from the application (flexible linkage)
Terminating steps with updating (integration)
Waiting for concurrent actions (integration, transparency)

SAP AG

BC610

6-4

(YHQW /LQNDJH %DVLF &RQFHSWV

l 3XEOLVK DQG VXEVFULEH


l (&$ SDUDGLJP

l 6WDWLF RU G\QDPLF HYDOXDWLRQ


l 7LPHLQGHSHQGHQW

l /LQNDJH PRGH VHTXHQWLDO DQG WUDQVDFWLRQGHSHQGHQW

SAP AG 1999

Linkages are entered according to the principle of "publish and subscribe", meaning that the creator
publishes the event without considering possible receivers. The number of receivers makes no
difference to the creator.
Interested receivers have to "subscribe" with the event manager (EM).

Linkages are evaluated by the EM according to the ECA paradigm. The event is triggered (E=event),
the linkage tables are checked and, if necessary, check function modules are called (C=condition),
and finally the receivers found are notified (A=action).
In accordance with the OO approach for the creators, the linkage is evaluated hierarchically.

There is an option for a dynamic evaluation of the linkage using the check and receiver type
determination function modules.

Triggered events are evaluated immediately, meaning the receiver is called immediately. The events
are not stored temporarily.

The event is only triggered after an SAP commit (ABAP keyword COMMIT WORK); an implicit
database commit is not sufficient. Triggering does not take place after a ROLLBACK WORK.

SAP AG

BC610

6-5

7UDQVDFWLRQDO 5)& %DVLF 'HVLJQ

l 'HSHQGHQW RQ H[SOLFLW &200,7 :25.


l 1HZ ORJLQ

l (UURU KDQGOLQJ YLD VHSDUDWH ORJ

SAP AG 1999

Without an explicit commit work, the events "do not take place" (transactional property).

A new login is carried out for the event receivers with each destination (RFC property).

The transactional RFC (tRFC) log can be read via transaction SM58.

SAP AG

BC610

6-6

(YHQWV &UHDWRU DQG 5HFHLYHU &RQWH[W


$SSOLFDWLRQ  &UHDWRU

(YHQW 0DQDJHU

)% VZHBHYHQWBFUHDWH

(YDOXDWLRQ RI
OLQNDJH WDEOHV

$SSOLFDWLRQ  5HFHLYHU

&DOO UHFHLYHU
W\SH )0

&RPPLW :RUN

&DOO
FKHFN )0

&DOO
UHFHLYHU )0

&UHDWRU FRQWH[W

5HFHLYHU FRQWH[W

   5
%6%#4
!    
 3

% 12) $ 0(
'%##"! 
& $  
  
SAP AG 1999

The receiver type FM and check FM run in the creators context in order to avoid superfluous tRFCs.

SAP AG

BC610

6-7

(YHQWV 7\SH /LQNDJH

l /LQNDJH EHWZHHQ WULJJHULQJ REMHFW W\SH DQG UHFHLYLQJ


REMHFW W\SH

l 0DLQWHQDQFH HLWKHU H[SOLFLW XVLQJ YLHZ PDLQWHQDQFH RU


XVLQJ IXQFWLRQ PRGXOHV
l 7UDQVSRUW RI DFWLYLW\ LQGLFDWRU RQO\ RQ UHTXHVW

SAP AG 1999

The type linkage is implemented using the type linkage table. The "global" indicator is activated.

An entry in the type linkage table is always required if a receiver is to be notified. Maintenance takes
place either explicitly or internally using function modules.

The table entries can be transported, but the transport is usually carried out without the activity
indicator. Therefore the linkages usually have to be activated explicitly in the target system. If the
activity indicator is to be transported, this can be done using the general transport link of the
generated view maintenance.

All linkages are client-specific.

Type linkages for triggering events are entered by the workflow runtime system when the linkage is
activated in the task definition, if there are no check or receiver type function modules. If at least one
such function module is required, the linkage must always be entered manually (as part of
Customizing for the relevant workflow).

Type linkages for terminating events are entered automatically by the workflow runtime system
when the associated work item is created, if there are no check or receiver type function modules. If
at least one such function module is required, the linkage must always be entered manually (as part
of Customizing for the relevant workflow).

SAP AG

BC610

6-8

(YHQWV ,QVWDQFH /LQNDJH

l /LQNDJH EHWZHHQ WULJJHULQJ REMHFW LQVWDQFH DQG UHFHLYLQJ


REMHFW LQVWDQFH

l 'LVSOD\ H[SOLFLW XVLQJ ZRUNIORZ GHYHORSPHQW HQYLURQPHQW


RU XVLQJ ZRUN LWHP GLVSOD\
l 0DLQWHQDQFH XVXDOO\ LPSOLFLW XVLQJ IXQFWLRQ PRGXOHV
l 1R WUDQVSRUW

SAP AG 1999

The instance linkage is implemented using a combination of the type linkage table and the instance
linkage table. In the type linkage table the "global" indicator is deactivated.

The instance linkage table is only evaluated if the associated type linkage is "active" and not
"global". Maintenance usually takes place using only function modules. The appropriate workflowrelated entries (for example, for terminating events of a step) are entered and deleted automatically
by the workflow runtime system.
For test purposes, it is also possible to make entries in or changes to the instance linkage table
manually.

The table entries are never transported.

All linkages are client-specific.

SAP AG

BC610

6-9

(YHQW 0DQDJHU  3URFHVVLQJ /RJLF

l 6HDUFK IRU DOO DFWLYH W\SH OLQNDJHV

l (YDOXDWH G\QDPLF UHFHLYHU GHWHUPLQDWLRQ


l ,I JOREDO OLQNDJH
7

Call receiver FM
7

Call check FM

Search for all instance linkages


7

Call check FM for each instance linkage


7

Call receiver FM for each instance linkage

l 2WKHUZLVH

SAP AG 1999

SAP AG

BC610

6-10

(YHQWV (YHQW 7UDFH

l $OO WULJJHUHG HYHQWV ORJJHG

l $FWLYDWH GHDFWLYDWH DQG GLVSOD\ YLD ZRUNIORZ


GHYHORSPHQW HQYLURQPHQW
l (QWULHV GR QRW VSHFLI\ EHKDYLRU RI UHFHLYHU

l 7KH HYHQW WUDFH IXQFWLRQ VKRXOG EH GHDFWLYDWHG LQ WKH


OLYH V\VWHP

SAP AG 1999

All triggered events are entered, irrespective of whether and how many receivers were found. A
separate entry is made for each receiver.
Errors in the check and receiver type function modules are also logged.

Internally, the trace is regarded as an additional receiver which is always triggered. It is independent
of the commit behavior of other (explicit) receivers.

Updating and writing the trace is time consuming because a separate tRFC is triggered. For this
reason, the trace should be deactivated in live systems (see note 46358).

You can restrict the writing of the trace to selected object types or events.

SAP AG

BC610

6-11

(YHQWV 'HILQLQJ  7ULJJHULQJ

l 'HILQH HYHQWV LQ WKH %XVLQHVV 2EMHFW %XLOGHU


l 7ULJJHU HYHQW
7

Implicitly via generic tools, for example


change documents
status management
message control

or
or

Explicitly via function module


SWE_EVENT_CREATE
SWE_EVENT_CREATE_IN_UPD_TASK
SWE_EVENT_CREATE_FOR_UPD_TASK

or
or

SAP AG 1999

Events must be defined in the Business Object Builder for the relevant object type. Not all defined
events must be triggered, but all triggered events must be defined.

Implicit triggering via change documents does not require any ABAP coding. Customizing activities
for the triggering application are necessary instead.
Explicit triggering via function modules requires the source code of the application to be changed or
extended.
Important: the function module SWE_EVENT_CREATE can trigger exceptions. If these are not
caught by the triggering application, a runtime error occurs.

The triggering modules do not execute COMMIT WORKs themselves. It is the task of the triggering
application to issue a COMMIT WORK at the right time.

Events with user-defined parameters must always be triggered explicitly if these parameters are to be
set.

SWE_EVENT_CREATE - event triggered immediately. SWE_EVENT_CREATE_IN_UPD_TASK


- as SWE_EVENT_CREATE, but defined as updating function module.
SWE_EVENT_CREATE_FOR_UPD_TASK - as SWE_EVENT_CREATE, but is required if the
object that triggers the event is not generated via the application until the update.

Explicit triggering via function modules usually takes place in customer systems by the customer
programming an existing user exit.

SAP AG

BC610

6-12

SAP AG
n

BC610

6-13

,PSRUWDQW
If the event is triggered in a user exit, a COMMIT WORK usually must not be programmed here,
since this would destroy the commit logic of the application.
SAP AG 1999

wi b8 i
HHDBQBtBA
g@9@hBsHHD%0DBhDHhb@
8s GAi P sb b a s
Y q8 F9
`HBG
g 98 F a o i G 9 i i x i
DhBCBB9@@D@BpD@pBE@DDF ~
Y U G 9 eEs xs
}DABQ44H}q@8
Y WU i s ob
B}|2hGDi
s 9i8 b GA
%BD2hv@G
HBD@b9@DQuTHp@B9hDah9@BuTHDBHG
G98 a i A b G i G 8 b iA b9 G
s%@Q4a@b
GC e
d`BHB9hhdwi
FGg a oA
HDBHG
b9 G
x@G@vDH#4ir{Hhh#4i
w ub AG e i xGw e
d UWp x i G b e
BBBQz@ydw%HxTH#4i
g 98 b i
D4DDH%hv@G
d q tq P uS Rq rq q pd 9i 8 b A 9 q C C a
uS2BshTQ4Q42uT2v6jBHDHDE@BBBA
b9GG
BBBHrG@o@@BHg@BBS0
b Gg 8
Y`@Hu4Bsrx@G@vDH#4i
xGw b Gs a i
w ub AG e
HdDHB6ji
Y U U W Ud
eE9 ueEs xGw ubGss
BGBH2HtHB2BH%a
Y@V%m@BBhHDhDHB6ji
d n l k W U U U U U Ud
i 9 ub G s a xGw ubGss
D2DhshQB2BH%a
HdDHB6jBF@BA2xhHQDDB2BH%a
Y W U U Ud i G i u 9 a i A xG w ub Gs s
x@G@DBh2irt%QBTDP0
w b AG e Gs i i
Y dhd'9DHGBF@BG@#u%E@BQtg@HDeHBDa@9hBDHDDDhhCQDuTts
g d 9 a 8 f G u a C qd G 9 8 b i A ub G b 9 G G G ub G s A
HBD@b9@DADBHHh9hQH@DG2@20hBB
G98 a i b 9GG ib 8 s Gb a a Gb8
Y`HGBDa@bhiBbBG
98 9 A u
@BhDa@%DuTDts
G98 b 9i A A
Y Gw i iAbs 9 s Gw
xhBteth%E@HHQh8GD4H@8@C
x@H#AB4dHBDF
G w ub G ei c a b a
Y`@Hu4BspBirF@BG
xGw b Gs a q
9
y 9 a C
VDhC9hhaHD9@aHw@8@C
G
G eE e
B%B4H92u@Ets
y W 9 9 a a G
QhChahHCD9@Hw@8@C
DQDHa
i 9 ub Gss
yQHDDHD9@Hw@8@BhBHQBtHA
s w E e aC a G C GFiA ux9a i
y`@G@vtBsrBph8g@QefdHBDF
x w ub Gs a qi 9 G c aba
Y XWU R RP GF EC A
`4HVTS24QI0HD4DB9@8

l 7ULJJHU HYHQW ZLWK


H[SOLFLW FRPPLW ZRUN

l )0 FDOO HUURU KDQGLQJ

l &DOO VZHBHYHQWBFUHDWH

l &RPSRVH REMHFW NH\ IRU


WULJJHULQJ REMHFW

l )LOO HYHQW FRQWDLQHU ZLWK


HYHQW SDUDPHWHUV

7ULJJHULQJ DQ (YHQW ([SOLFLWO\

SAP AG
n

BC610

6-14

The event is only triggered for the supertype.


SAP AG 1999

Y wi b i
'hB0B82BtHA
g9 ss GA sb ab
H@8hH%HHiDPD@@pbBH@@s
Y WU i s G ob
HQHti
H@8D%h@hG
s 9i b GA v
G 8 9i u G i G98 b 9i u 9 G
HH9hDa@bhBATbBBrHBhBa@@BA2bDD@BG
sDHC24ahb
G e
'BDBB@3dji
d FGb aG A
bDD@BG
9 G
xGw b AG ei i xGw e
HHuDB4@Hh2i
d BU@UBDQ@x d @4H2i
W W p z
i G xb e
g9 bi
Bh8DHBQhvhG
q@S2tDs@SQQ4Qutq2v6de@BhABDEhCBBHA
d tq P u Rq rq p 9i8b 9 q Ca
D9BBHB@rHB@@8DBS"
b GG Gob Ggg
HdBh%mHBkBHBHUB6jipHHbDB#ti
Y d n l W U U Ud
xGw u AG e
Y`@B9hDa@D9@iBbDHG
G 8 b A u
HGBh8Dh@DQtts
9 ab 9i A uA
x4GD4eTihQE@HA@hQ9h8BtGhHHC
Y w
i bs G s w8
xGw ub AG i c aba
@@v@h#e4HBBF
`X4@R4S2TP2@DCDB9h8
Y WU R I GF E A

=B%86
%86

2EMHFW W\SH

&UHDWHG
&UHDWHG

(YHQW

:6
:6

5HFHLYHU W\SH

,QKHULWDQFH 7ULJJHULQJ  6XSHUW\SH

SAP AG
n

BC610

6-15

The event is triggered for the subobject type as well as for all supertypes for which the event is
defined.
SAP AG 1999

`@HBQBtBA
Y wi b8 i
g 8ss GAi P b ab
@9@hBHHDBHshpbDHh@s
Y W i
BU}s2HGD4bDi
o
s i b GA v
D9B@8BQ@@G
G98 b 9i A ub G i G98 b 9 A u 9G
HBDa@%DDHr@BhDah@iDQTbDBHHG
s G ea
@C24@b
'BGhDHB@wi
d F b a G Ad
bDBHHG
9G
x@HvDH#e4rHHe4i
Gw ub AG i i xGw
d BHBD%z@2uv wpGDH4@e4i
WUUW p x d i xb
g 9 bi v
Dh8BBHQh@G
d S tq P S Rq q q p 9i8 A Eq C a
uq@Q4Bs@uTQ4Qr42uT2vde@H@bDB9D@BCBBA
b GG G b gg S
B9BBBBohrHGBH@8BB0
Y dB@%m@BBh@BHUDip@HwvbDH#e4i
d n l k W U U Ud
xG u AG
Y`HBD@bhBuTBBG
G98 a 9iA b
@GBh%@BA2Tts
98 ab 9i uA
Y xGw e iAbs 98 Gs
B4tih%E@HHQh%H4}G@w@HC
8
x w u AG e c a a
HGh#vbDH#4idHbBDF
`hVR4QtQHDE4CDB@8
Y XWU S RP I GF A9

=B%86
%86

2EMHFW W\SH

&UHDWHG
&UHDWHG

(YHQW

:6
:6

5HFHLYHU W\SH

,QKHULWDQFH 7ULJJHULQJ  6XEW\SH

5HFHLYHU )XQFWLRQ 0RGXOH

,QWHUIDFH
function receiver_fm
importing objtype like swetypecou-objtype
objkey
like sweinstcou-objkey
event
like swetypecou-event
rectype like swetypecou-rectype
tables
event_container structure swcont
3URFHVV LQ VHSDUDWH FRQWH[W

SAP AG 1999

If possible, the function module should not trigger any exceptions, since these are only recorded
directly in the tRFC log. If this occurs, workflow receiver function modules send an error message to
the workflow system administrator.

Example of a function module: SWW_WI_START_VIA_EVENT

In the case of propagated events, the default parameter _EVT_OBJTYPE contains the triggering
object type (that is, the subtype), while the interface parameter OBJTYPE contains the propagated
object type (that is, the supertype).
This also applies to the check and receiver type function modules.

_EVT_OBJECT always contains the triggering object type!

SAP AG

BC610

6-16

&KHFN )XQFWLRQ 0RGXOH

l
l

7HVW IRU UHOHYDQFH IRU UHFHLYHU

,QWHUIDFH
function check_fm
importing objtype like swetypecou-objtype
objkey
like sweinstcou-objkey
event
like swetypecou-event
rectype like swetypecou-rectype
tables
event_container structure
swcont
exceptions others
3URFHVV LQ FUHDWRU FRQWH[W

SAP AG 1999

The check FM cannot commit (nor rollback).

Exceptions are recorded in the event trace.

SAP AG

BC610

6-17

SAP AG
n

BC610

6-18

If the event is triggered before the object data is written to the database, the object attributes are not
yet available for querying, since the database is accessed when the attributes are evaluated by the
Business Object Builder.
This may occur, for example, if the event is triggered implicitly when generating the object (that is,
via change documents, status management, etc.) and the object is not generated until later in
updating.
Write additional values to the event container.
Object attribute query using the macro SWC_GET_PROPERTY
Default parameter query (for example, date, time, object type)

Other typical contents of a check function module


SAP AG 1999

Y i b A9 EqF9
`9@B8hBDhBHBG
Y q8 F9
`HBG
Y FGC8a q u A oA Gs 8a
BBBDQtw@DGBHp4HD
2BT#TQhxh@ir%G@4DuTH9@HDHq@8
Y C a uG b uA X I xb i g 8b a8 b8 98
G i G 8s GF 8 b ei g b 8b8 98 q wA G A
D9@pFBH@QH0sG%HxTH#4pH9@8@Da@BHDhH8r@DHo@
eDH4Di2tH9@8@Da@Bb@hG24hB#b%@vA
Y G xb ug b 8 8 98 xbi u G u
HB9h%9@B2DBHHDH%Gh%%TDBQuTts
G 8 ab iA ub 9GG b 9G C G ub Gg A
HD4a@bhBBBBHtDH2htpBhBbBBhgh%HHD"
G 98 9iA b9GG i q G xb ei g98 a98 8 i FaG s
q A G A q 9 8 ab 9 G GC
hw@DHo@rhirHi@HbBHDDDhh@t
Y xb i iA G xb G s Gw8C G xbi g98 a8b 898 c aba
G24hheThQE@@D%@4DDthHHrQhH#uTBhHbBHHDHHdHBDF
YqhD@HDBQ4rhQu eBhHaBB%h%T%DHi@%TsBh8Br%@4QTbHQuTA
d S x uS q d GEC b9G GC G b 9 A Gw C G xb i u G
yh`HH2ttDBeGDBQhThQE@HADH4bBt}G@w@HH44DH4D2uTA
d P d E C a G x b ei i G x G s
8C C a uG xb i
c sb abs i
dH%9@HQ9@BA
Y XWU RS RP GF EC A
`4H#4Q42I0HD4DB9@8
HBHDhDHB@BHB@BHB@BHBHDhDHB@BHB@BHBHHHBHDhDHB@BHB

HG@C@DBHABDohQ9@B8h#4HBHG0
F 8 aq uw G A s i b GAv
b iA
9@BDts
HD4DDHb@}HD48@bhBBBGBHG
G Eb A E s G 9 a 9iA ub9
s2hTH
GC eab
G xbA G iA G x G
QhHDH%E@H%h4bDts
G 8
BwhDC%@tDBB
G xb AG

b G G iA G x G
9@D@%E@H%h4bDts
G 8
BwhDC
b9
BBGBHG

xhBtth%E@HBh%h8Dts
Gw ei iAbs 9 G
G 8
BwhDC
x w e
@G@#4i

GQhth%E@H%h4bDts
xb ei iA G x G
G 8
BwhDC G@4b@#trHH8h%@i2@t
x ei g9 b 8
HBHDhDHB@BHB@BHB@BHBHDhDHB@BHB@BHBHHHBHDhDHB@BHB

2BTBHDhVvG2hBDtt#Tw@BDhpBi@BHD9BHq
Y C aAi F8 u xb ubA G ei u AG oA 9 8bA E

l 7ULJJHU DQ H[FHSWLRQ RU
HQG IXQFWLRQ PRGXOH
l &KHFN FRQGLWLRQ

l 5HDG HYHQW SDUDPHWHUV


IURP HYHQW FRQWDLQHU

,PSOHPHQWLQJ D &KHFN )XQFWLRQ 0RGXOH

5HFHLYHU 7\SH )XQFWLRQ 0RGXOH

l
l

'\QDPLF GHWHUPLQDWLRQ RI UHFHLYHU W\SH GHSHQGHQW RQ HYHQW GDWD


,QWHUIDFH
function rectypeget_fm
importing objtype
like swetypecou-objtype
objkey
like sweinstcou-objkey
eventlike swetypecou-event
rectype
like swetypecou-rectype
tables
event_container structure swcont
3URFHVV LQ FUHDWRU FRQWH[W

SAP AG 1999

The receiver type FM cannot commit (nor rollback).

The table entry "receiver type" (rectype) from the type linkage table can be used as an input
parameter generic_rectype for the function module.

Exceptions are recorded in the event trace.

SAP AG

BC610

6-19

SAP AG
n

BC610

6-20

If the event is triggered before the object data is written to the database, the object attributes are not
available yet for querying, since the database is accessed when the attributes are evaluated by the
Business Object Builder.
This may occur, for example, if the event is triggered implicitly when generating the object (that is,
via change documents, status management, etc.) and the object is not generated until later in
updating.
SAP AG 1999

Y i b A9 EqF9
`9@B8hBDhBHBG
Y q8 F9
`HDq
Y 8 ei s Fb
F@th@h@iHDH4DHDs
G xb AG
QhHhH@bpDH4DHDs
Y G xbis F i G xb AG
DC%q
Y Gs
QhHDHi4Has
Y G xbA G u 9 Gs 8
Y U G9 As Es xs
V}HHVetH}q@
Y bs wi uC i bs i
h2F2Qw@DF
F9 awiF xGw a
BharHHHB2Hh%D@FrHaBHHpBHo@
i wiF GG
s2@b4HB0}hHH4sDHG@Ds
F iq GC g98 b A C G
shF@rhtBtD@pQHBG@AhrHHB0
b GC eab i q G xb G8 G FaG
'x@H4#4phBBhBBF
Y Gw ei i xGw a
Y bs i F uC d p zS tSp Rq P
Qw@DQQhQ4HHS2Q4z@BDd
HB9h%9@B2DBHHDH%Gh%%TDBQuTts
G 8 ab iA ub 9GG b 9G C G ub Gg A
HGBDa@hiBBBBHiHq02Dah@DH%hhDi@rHHD"
98 b 9 A b9GG s Eb bs b 9G EA F FaG s
p@4DG@@DHHBphirHi@HbBHDDDhh@t
q G xb 8 GAG q 9 8 ab 9 G GC
'x@G@DHHhDG
Y w a F qi F9
y b i F a F Gw8C Cb wi
dC@w@D4#tHBhBHhDF
y i F a F Gw8 wi
HHw@D4#tHBhBCrBHhDF
y 9 i F a F Gw8 9wi
@Bw@D4#tHBhBCrHBhDF
y a i F a F Gw8 a wi
hDw@D4#tHBhBCr@DhDF
y Gw a F i 8 gG c aba
x@H4DHpq@r9h%h2efdHBDF
hs2i44DHBh8BbhQw@i%TdHBDF
Y b w F a F Gw C s F uC c aba
Y XWU RS RP GF EC A
`4H#4Q42I0HD4DB9@8
B@BHB@BHBHDhDHB@BHB@BHB@BHBHDhDHB@BHB@BHBHHHBHDhDHB@BHB

G@4DHB2uTB90Q9@B8h#4HBHG0
xb AG i s i b GAv
b iA s G E A E
9@BDtHbBDHhb@s
HD48@bhBBBGBHG
G 9 a 9iA ub9
s2hTH
GC eab
G xb A E AG xb G
%@4DHGB42iBBQD%TsBhBC
Gw8
G xbA G g9 b v
QBDHHH8h%@i24HG0
G xb A E AG xb G
%@4DHGB42iBBQD%TsBhBC
Gw8
G x AG u 8 G9G
%HTbBBQTA@@BHBg

D9BHH42iBBQD%TsBhBC
b GG E AG xb G
Gw8
b9
BBGBHG

@H42iB@b@s9@D%TsBhBC
xGw ei E A
8 G
Gw8
x w e
@G@#4i

G x ei E AG xb G
%@4b@42iBBQD%TsBhBC
Gw8
G@4b@#trHH8h%@i2@t
x ei g9 b 8

B@BHB@BHBHDhDHB@BHB@BHB@BHBHDhDHB@BHB@BHBHHHBHDhDHB@BHB
Y bGg ub w F A ub9GG q A 9 8bA E
BB2hs2i2uTHGB2BBBH2uTDHhpBi@BHD9BHq

l 7ULJJHU DQ H[FHSWLRQ RU
HQG IXQFWLRQ PRGXOH
l 'HWHUPLQH WKH UHFHLYHU
W\SH RQ WKH EDVLV RI
DSSOLFDWLRQVSHFLILF
VHWWLQJV

l 5HDG HYHQW SDUDPHWHUV


IURP HYHQW FRQWDLQHU

,PSOHPHQWLQJ D 5HFHLYHU 7\SH )XQFWLRQ 0RGXOH

(YHQW 4XHXH 3UREOHP

l (YHQW UHFHLYHUV DUH VWDUWHG E\ W5)&

l W5)& SURFHVVLQJ LV D FHQWUDO FRPSRQHQW RI WKH DSSOLFDWLRQ


VHUYHU
l 3UREOHPV DULVH LI WKHUH DUH
/RWV RI HYHQWV

7
7

:LWK SRVVLEO\ ORWV RI UHFHLYHUV

7KH DPRXQW RI W5)&V LQ D VKRUW SHULRG RI WLPH

7KH FDOOV DIIHFW WKH ZKROH DSSOLFDWLRQ VHUYHU

l &DXVH RI WKH SUREOHP


l (IIHFW

SAP AG 1999

SAP AG

BC610

6-21

(YHQW 4XHXH ,GHD

l (YHQW UHFHLYHUV DUH QRW FDOOHG GLUHFWO\

l &DOO GLVWULEXWHG RYHU D ORQJHU SHULRG RI WLPH


l &DOO PDGH

%\ D EDFNJURXQG MRE

,Q GHILQHG XQLWV

$W SUHGHWHUPLQHG LQWHUYDOV

7
7

SAP AG 1999

If the receivers are still started by tRFC (default), no less tRFCs are initiated than when the event
queue is not used. But the calls are distributed over a longer period of time so the short-term system
load is reduced.

SAP AG

BC610

6-22

(YHQW 4XHXH &RQVWUXFWLRQ

Event

Event manager

tRFC call

Immediately

Determination of
receivers

Starting of
receivers

Event queue

Linkage tables

Entering in
queue
Inserting

Event queue
Selection

(t)RFC call

start

Background job

SAP AG 1999

When an event occurs the receivers are determined

Starting of receivers
Directly by tRFC
Using the queue if:
- The event queue is activated
- The event linkage allows the queue to be used

When the queue is used


Entry in queue
Processing from queue by background job
RFCs called in background by job
tRFC not required

SAP AG

BC610

6-23

(YHQW 4XHXH $GPLQLVWUDWLRQ

l 2YHUYLHZ RI WKH VWDWXV RI WKH HYHQW TXHXH


l 6HWWLQJ WKH EDVLF GDWD

l $FWLYDWLQJ WKH HYHQW TXHXH

l &RQILJXULQJ WKH EDFNJURXQG MRE


l &RQILJXULQJ WKH HYHQW GHOLYHU\

l 2YHUYLHZ RI WKH OLQNDJHV ZLWK HUURUV

SAP AG 1999

SAP AG

BC610

6-24

3URFHGXUH LQ WKH (YHQW RI (UURUV

l 6\VWHP SUHVHWWLQJ LQ DFFRUGDQFH ZLWK WKH EDVLF GDWD RI


HYHQW TXHXH DGPLQLVWUDWLRQ
l &DQ EH UHGHILQHG E\ FRQILJXULQJ WKH HYHQW OLQNDJH
l 3RVVLEOH VHWWLQJV

'HDFWLYDWLRQ RI OLQNDJH

0DUN OLQNDJH DV KDYLQJ HUURUV


'R QRW FKDQJH OLQNDJH

7
7

SAP AG 1999

SAP AG

BC610

6-25

'HDFWLYDWLRQ RI /LQNDJH

l (YHQW OLQNDJH LV GHDFWLYDWHG


l $GPLQLVWUDWRU LV QRWLILHG

l (YHQW FDQQRW EH SURFHVVHG DJDLQ

l /LQNDJH LV QRW HYDOXDWHG IRU IXWXUH HYHQWV

SAP AG 1999

SAP AG

BC610

6-26

0DUN /LQNDJH $V +DYLQJ (UURUV

l (YHQW OLQNDJH LV PDUNHG DV KDYLQJ HUURUV

l (YHQW LV HQWHUHG LQ TXHXH ZLWK WKH VWDWXV ZDLWLQJ


EHFDXVH RI HUURU
l $GPLQLVWUDWRU LV QRWLILHG

l (YHQW FDQ EH GHOLYHUHG DJDLQ

l )XWXUH HYHQWV DUH SXW LQWR WKH TXHXH

SAP AG 1999

SAP AG

BC610

6-27

'R 1RW &KDQJH /LQNDJH

l (YHQW OLQNDJH LV QRW FKDQJHG

l (YHQW LV HQWHUHG LQ TXHXH ZLWK WKH VWDWXV ZDLWLQJ


EHFDXVH RI HUURU
l $GPLQLVWUDWRU LV QRWLILHG

l (YHQW FDQ EH GHOLYHUHG DJDLQ

l )XWXUH HYHQWV DUH SURFHVVHG DV XVXDO

SAP AG 1999

SAP AG

BC610

6-28

(YHQW 4XHXH %URZVHU

l 2YHUYLHZ RI HYHQWV LQ HYHQW TXHXH


l 5HVWULFW GLVSOD\ XVLQJ ILOWHU
l 'HWDLOHG GLVSOD\ RI HYHQWV

SAP AG 1999

SAP AG

BC610

6-29

(YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


8QLW 6XPPDU\

l ([SODLQ WKH EDVLF FRQFHSWV RI WKH HYHQW PDQDJHU

l ([SODLQ KRZ DQ HYHQW FDQ EH WULJJHUHG H[SOLFLWO\ XVLQJ

SURJUDPPLQJ

l ([SODLQ KRZ DQ HYHQW FDQ EH HYDOXDWHG DQG UHFHLYHG

l ([SODLQ WKH SXUSRVH DQG RSHUDWLRQ RI WKH HYHQW TXHXH

SAP AG 1999

SAP AG

BC610

6-30

([HUFLVHV
8QLW (YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ
6HFWLRQ (YHQW 0DQDJHU

After completion of these exercises, you will be able to:


Display the event linkage tables
Display the event trace
Simulate an event
You have completed your workflow definition and assigned the individual
dialog steps to the correct agents. Now you want to check whether your
workflow is started correctly via events.

1-1

Recall the effect of the entries in the type linkage table.


1-1-1 Ensure that your two workflows are correctly linked to the event
OldMaterialChanged of your object type.
1-1-2 Simulate the event OldMaterialChanged. Check the output of the simulation
tool.
1-1-3 Check the event trace for entries for the event DeadlineTest for your object
type that you had triggered in an earlier task.

SAP AG

BC610

6-31

8QLW (YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ ,PSOHPHQWLQJ DQ (YHQW

After completion of these exercises, you will be able to:


Trigger an event explicitly (by programming)
Create a check and receiver type function module

The event linkage to your workflow definitions is created correctly. Now


you want to start workflows via an event that is triggered explicitly in an
ABAP program you have written.

2-1

Trigger an event explicitly.


2-1-1 Create a report = (97&5 that calls the function module
SWE_EVENT_CREATE, in order to trigger the event DeadlineTest for
your object type.
2-1-2 Check whether your workflow is triggered irrespective of whether you are
the last person to change the material or not.

2-2

Create a check function module to filter out irrelevant events.


2-2-1 Create a check function module
= B&+(&.B0$7(5,$/B&+$1*('%<. This function module is
intended to ensure that your workflow is only started if you trigger the event
for one of "your" materials (T-BBC##, T-FBC##) and if you are the last
person who changed the material.
Check in the function module whether the transferred material number
represents one of your materials and whether the object attribute ChangedBy
has your login ID as a value. If this is not the case, an exception should be
triggered.
2-2-2 Insert the check function module into the existing linkages from the event
OldMaterialChanged of your object type to your two workflow definitions
Z##MSIPROC1 and Z##MSIPROC2.
2-2-3 Now check whether your workflow is only triggered when you are the last
person to change the material.

SAP AG

BC610

6-32

2-3

Optional extensions: Create a receiver type function module to decide depending on


runtime data which of your two workflow definitions is to be started.
2-3-1 Create a receiver type function module
= B5(&7<3(B'(7(50,1(B0$77<3(. This function module
determines the workflow to be started based on the material type of the
triggering object. If the object attribute MaterialType has the value FERT
(finished), the workflow Z##MSIPROC1 should be started, otherwise
Z##MSIPROC2.
2-3-2 Change the type linkage table again so that the workflow to be started is
now determined via the receiver type function module for the event
OldMaterialChanged of your object type.
2-3-3 Now check whether the workflow associated with the material type of the
triggering material is started.

SAP AG

BC610

6-33

6ROXWLRQV
8QLW (YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ
7RSLF (YHQW 0DQDJHU

1-1

Recall the effect of the entries in the type linkage table.


1-1-1 Ensure that your two workflows are correctly linked to the event
OldMaterialChanged of your object type.
Path (via SAP Easy Access):
Tools > Business Workflow > Development > Definition Tools > Events >
Event Linkages > Type Linkages
1-1-2 Simulate the event OldMaterialChanged. Check the output of the simulation
tool.
Path (via SAP Easy Access):
Tools > Business Workflow > Development > Utilities > Events > Simulate
Event
1-1-3 Check the event trace for entries for the event DeadlineTest for your object
type that you had triggered in an earlier task.
Path (via SAP Easy Access):
Tools > Business Workflow > Development > Utilities > Events > Event
Trace > Display Event Trace

SAP AG

BC610

6-34

8QLW (YHQW 'HILQLWLRQ DQG ,PSOHPHQWDWLRQ


6HFWLRQ ,PSOHPHQWLQJ DQ (YHQW

After completion of these exercises, you will be able to:


Trigger an event explicitly (by programming)
Create a check and receiver type function module

The event linkage to your workflow definitions is created correctly. Now


you want to start workflows via an event that is triggered explicitly in an
ABAP program you have written.

2-1

Trigger an event explicitly.


Solution:
Z00EVTCR
Path (via SAP Easy Access):
Tools > ABAP Workbench > Development > ABAP Editor

SAP AG

BC610

6-35

*&---------------------------------------------------------------------*& Explicit triggering of Z00MARA.DEADLINETEST


*&---------------------------------------------------------------------REPORT Z00EVTCR.
INCLUDE <CNTN01>.

" include container macros

DATA: OBJKEY LIKE SWEINSTCOU-OBJKEY,


EVENTID LIKE SWEDUMEVID-EVTID.
DATA: EVENT_CONTAINER LIKE SWCONT OCCURS 0 WITH HEADER LINE.
PARAMETERS:
OBJTYPE LIKE SWETYPECOU-OBJTYPE DEFAULT Z00MARA,
MATERIAL LIKE MARA-MATNR,
EVENT LIKE SWETYPECOU-EVENT DEFAULT DEADLINETEST,
END_DATE LIKE SYST-DATUM
DEFAULT SPACE.
OBJKEY = MATERIAL.
* write parameter into event container
IF EVENT EQ DEADLINETEST AND END_DATE EQ SPACE.
END_DATE = SY-DATUM + 1.
ENDIF.
SWC_SET_ELEMENT EVENT_CONTAINER LatestEndDate END_DATE.
CALL FUNCTION SWE_EVENT_CREATE
EXPORTING
OBJTYPE
= OBJTYPE
OBJKEY
= OBJKEY
EVENT
= EVENT
IMPORTING
EVENT_ID
= EVENTID
TABLES
EVENT_CONTAINER = EVENT_CONTAINER
EXCEPTIONS
OBJTYPE_NOT_FOUND = 1.
IF SY-SUBRC NE 0.
WRITE : / Object type, OBJTYPE, unknown.
ELSE.
IF EVENTID NE 0.
WRITE : / At least one receiver found.
COMMIT WORK.
ELSE.
WRITE : / No receivers found.
ENDIF.
ENDIF.

SAP AG

BC610

6-36

2-2

Create a check function module to filter out irrelevant events.


Solution:
Z00_CHECK_MATERIAL_CHANGEDBY
Path (via SAP Easy Access):

For the function module


Tools > ABAP Workbench > Development > Function Builder

For the linkage between event and workflow


Tools > Business Workflow > Development > Definition Tools > Events >
Event Linkages > Type Linkages

FUNCTION Z00_CHECK_MATERIAL_CHANGEDBY.
*"---------------------------------------------------------------------*"*"Local interface:
*"
IMPORTING
*"
VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
*"
VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
*"
VALUE(EVENT) LIKE SWETYPECOU-EVENT
*"
VALUE(RECTYPE) LIKE SWETYPECOU-RECTYPE
*"
TABLES
*"
EVENT_CONTAINER STRUCTURE SWCONT
*"
EXCEPTIONS
*"
OBJECT_NOT_FOUND
*"
INVALID_USER
*"
INVALID_MATERIAL
*"---------------------------------------------------------------------* This check fm checks, if the user who triggered the event (USER) is
* the same person who is related to the sample material and if
* the material changed is really one of my sample materials.
CONSTANTS:
MY_SAMPLE_MATERIAL_ROH LIKE MARA-MATNR VALUE 200-110,
MY_SAMPLE_MATERIAL_FERT LIKE MARA-MATNR VALUE 200-101,
MY_SAMPLE_MATERIAL_HALB LIKE MARA-MATNR VALUE 200-100,
MY_OWN_USER LIKE SY-UNAME VALUE WF-BC-CLERK.
DATA:
MY_SAMPLE_MATERIALS LIKE MARA-MATNR
OCCURS 3 WITH HEADER LINE.
DATA: OBJECT TYPE SWC_OBJECT.
DATA: CHANGER LIKE MARA-AENAM,
USER_ACT LIKE SWHACTOR,
USER
LIKE SY-UNAME.

SAP AG

BC610

6-37

* build int table with my sample materials


MOVE MY_SAMPLE_MATERIAL_ROH TO MY_SAMPLE_MATERIALS.
APPEND MY_SAMPLE_MATERIALS.
MOVE MY_SAMPLE_MATERIAL_HALB TO MY_SAMPLE_MATERIALS.
APPEND MY_SAMPLE_MATERIALS.
MOVE MY_SAMPLE_MATERIAL_FERT TO MY_SAMPLE_MATERIALS.
APPEND MY_SAMPLE_MATERIALS.
* check, if the triggering material is one of my materials
READ TABLE MY_SAMPLE_MATERIALS WITH KEY = OBJKEY.
IF SY-SUBRC NE 0.
RAISE INVALID_MATERIAL.
ENDIF.
* create the material object for later attribute access
SWC_CREATE_OBJECT OBJECT OBJTYPE OBJKEY.
IF SY-SUBRC NE 0.
RAISE OBJECT_NOT_FOUND.
ENDIF.
* read attribute ChangedBy from material object
SWC_GET_PROPERTY OBJECT ChangedBy CHANGER.
IF SY-SUBRC NE 0.
RAISE OBJECT_NOT_FOUND.
ENDIF.
* check if my sample user and material changer are identical
IF CHANGER NE MY_OWN_USER.
RAISE INVALID_USER.
ENDIF.
ENDFUNCTION.

SAP AG

BC610

6-38

2-3

Optional extensions: Create a receiver type function module to decide depending on


runtime data which of your two workflow definitions is to be started.
Solution:
Z00_RECTYPE_DETERMINE_MATTYPE
Path (via SAP Easy Access):

For the function module


Tools > ABAP Workbench > Development > Function Builder

For the linkage between event and workflow


Tools > Business Workflow > Development > Definition Tools > Events >
Event Linkages > Type Linkages

FUNCTION Z00_RECTYPE_DETERMINE_MATTYPE.
*"---------------------------------------------------------------------*"*"Local interface:
*"
IMPORTING
*"
VALUE(OBJTYPE) LIKE SWETYPECOU-OBJTYPE
*"
VALUE(OBJKEY) LIKE SWEINSTCOU-OBJKEY
*"
VALUE(EVENT) LIKE SWETYPECOU-EVENT
*"
VALUE(GENERIC_RECTYPE) LIKE SWETYPECOU-RECTYPE
*"
EXPORTING
*"
VALUE(RECTYPE) LIKE SWEINSTCOU-RECTYPE
*"
TABLES
*"
EVENT_CONTAINER STRUCTURE SWCONT
*"
EXCEPTIONS
*"
OBJECT_NOT_FOUND
*"---------------------------------------------------------------------* This receiver type fm determins the process to be started by the
* material type
DATA: OBJECT TYPE SWC_OBJECT.
DATA: MTYPE LIKE MARA-MTART.
* create the material object
SWC_CREATE_OBJECT OBJECT OBJTYPE OBJKEY.
IF SY-SUBRC NE 0.
RAISE OBJECT_NOT_FOUND.
ENDIF.
* check material typ and set receiver type depending on value
SWC_GET_PROPERTY OBJECT MaterialType MTYPE.
IF MTYPE EQ FERT.
RECTYPE = WS96000011.
" Z00MSIPROC1
ELSE.
RECTYPE = WS96000012.
" Z00MSIPROC2
ENDIF.
ENDFUNCTION.
SAP AG

BC610

6-39

:RUNIORZ 5XQWLPH 6\VWHP

&RQWHQWV
l &RPSRQHQWV DQG DUFKLWHFWXUH
l :RUN LWHPV

l 'HDGOLQH PRQLWRULQJ DQG HUURU KDQGOLQJ


l $GPLQLVWUDWLRQ IXQFWLRQV
l 3HUIRUPDQFH

SAP AG 1999

SAP AG

BC610

7-1

:RUNIORZ 5XQWLPH 6\VWHP 8QLW 2EMHFWLYHV

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l ([SODLQ WKH FRPSRQHQWV RI WKH UXQWLPH V\VWHP DQG

KRZ WKH\ LQWHUDFW LQ D ZRUNIORZ

l *HQHUDWH DQG H[HFXWH ZRUN LWHPV YLD WKH ZRUN LWHP

PDQDJHU $3,

l ([SODLQ GHDGOLQH PRQLWRULQJ DQG HUURU KDQGOLQJ DQG

XVH WKH RSWLRQV SURYLGHG WR FRQWURO GHDGOLQH


PRQLWRULQJ

SAP AG 1999

SAP AG

BC610

7-2

:RUNIORZ 5XQWLPH 6\VWHP 8QLW 2EMHFWLYHV 

$W WKH FRQFOXVLRQ RI WKLV XQLW \RX ZLOO EH DEOH WR


l 8VH WKH DGPLQLVWUDWLRQ IXQFWLRQV RI WKH UXQWLPH

V\VWHP

l $YRLG PRGHOLQJ DQG FRQILJXUDWLRQ VHWWLQJV WKDW

XQQHFHVVDULO\ VORZ GRZQ WKH UXQWLPH V\VWHP

SAP AG 1999

SAP AG

BC610

7-3

:RUNIORZ 5XQWLPH 6\VWHP  2YHUYLHZ

2EMHFW
PDQDJHU
LQYRNH

:RUNIORZ
GHILQLWLRQ

7DVN
GHILQLWLRQ

%25

H[HFXWH
UHVXOW

UHVXOW

$SSOLFDWLRQ

:RUN LWHP
PDQDJHU

FUHDWH
UHVXOW

Definition
System

:RUNIORZ
PDQDJHU

Runtime
System

UHVXOW

UHVXOW

(YHQW
PDQDJHU

SAP AG 1999

The workflow manager (WFM) reads the workflow definition and the step definition and creates one
work item (WI) per step using the work item manager (WIM). The WFM is then finished.

The WIM manages the WI and triggers the application via the object manager (OM).

If the underlying method is synchronous, the result and the export parameters of the method are
returned to the WIM via the OM.
If the underlying method is asynchronous, the result of the method is returned to the WIM via an
event that is triggered in the event manager (EM). This event must be defined as a "terminating
event" for the step.

After receiving the return parameters, the WIM checks the return code and, if successful, returns the
data to the WFM.

This loop continues until the end of the workflow is reached.

Event creator, conditions, process control and container operations are executed locally in the WFM
without a work item being created.

SAP AG

BC610

7-4

:RUNIORZ 0DQDJHU 7DVNV

l &RQWURO H[HFXWLRQ RI WKH ZRUNIORZ GHILQLWLRQ

l 'DWD WUDQVIHU EHWZHHQ LQGLYLGXDO VWHSV RI D ZRUNIORZ


GHILQLWLRQ
l 3URYLGH LQLWLDO GDWD IRU D ZRUNIORZ

l 'HDGOLQH FDOFXODWLRQ IRU VWHSV LQ D ZRUNIORZ


GHILQLWLRQ
l 5ROH UHVROXWLRQ RQ VWHS OHYHO

l ([HFXWLRQ RI FRQWDLQHU RSHUDWLRQV SURFHVV FRQWURO


DQG HYHQW FUHDWRUV
l (YDOXDWLRQ RI FRQGLWLRQV

SAP AG 1999

SAP AG

BC610

7-5

:RUNIORZ 0DQDJHU :RUNIORZ /RJ

l 5HFRUG WKH ZRUNIORZ H[HFXWLRQ SURFHVV

Work items: when created/processed/done

Process: branches, loops, start/end of forks, subworkflows

l 6WDWXV RI ZRUNIORZ H[HFXWLRQ

l /RJ RSHUDWLRQV RQ WKH ZRUNIORZ

Stop/continue process

Abort work item/whole process

l (QWU\ SRLQW IRU WURXEOHVKRRWLQJ

SAP AG 1999

SAP AG

BC610

7-6

:RUN ,WHP 0DQDJHU 7DVNV

l &RQWURO SURFHVVLQJ RI LQGLYLGXDO VWHSV LQ D ZRUNIORZ


GHILQLWLRQ
l 0RQLWRU GHDGOLQHV IRU LQGLYLGXDO VWHSV LQ D ZRUNIORZ
GHILQLWLRQ
l $VVLJQ DJHQWV IRU LQGLYLGXDO VWHSV LQ D ZRUNIORZ
GHILQLWLRQ

l /RJ DOO DFWLYLWLHV H[HFXWHG RQ D VWHS LQ D ZRUNIORZ


GHILQLWLRQ
l 5HVROYH GHIDXOW UROH

SAP AG 1999

A work item (WI) is created for every activity in a workflow.

Processing is monitored using the individual WI statuses. The processing sequence is determined by
the statuses and the possible transitions. The WI is also locked during processing using the individual
statuses.

Deadlines are monitored using the background job SWWDHEX and the report RSWWDHEX (see
below).

For precise evaluation of the agent assignment, refer to the unit "Roles".
An agent who is not a possible agent for the task underlying the WI never receives the WI in their
Business Workplace, even if they were the result of a role resolution.

All the activities executed by a user are logged with the WI. There is therefore a complete processing
history for each WI.

During execution, all secondary methods are started as well as the method from the task. Secondary
methods run in a separate session.

Before the method from the task is executed, the before methods are executed in an arbitrary
sequence. After the main method has been executed, the after methods are executed in an arbitrary
sequence.

SAP AG

BC610

7-7

:RUN ,WHP 7\SHV

l $  :RUN TXHXH ZRUN LWHP

l %  %DFNJURXQG ZRUN LWHP

l &  &RQWDLQHU OLQNDJH ZRUN LWHP


l '  0LVVHG GHDGOLQH ZRUN LWHP
l (  :DLW VWHS ZRUN LWHP

l )  :RUNIORZ ZRUN LWHP


l 5  :HE ZRUN LWHP

l :  'LDORJ ZRUN LWHP

SAP AG 1999

A work queue work item is a "logical unit" of objects and tasks that are to be executed together. Both
objects and tasks can be different.

A background work item is used to execute tasks that do not require dialog. They are executed
automatically by the WF runtime system and do not appear in the Business Workplace.

A container linkage work item serves as a logical relationship between several associated objects. It
corresponds to the assignment table from WF21. A container linkage does not possess any semantics
of its own and never appears in the Business Workplace.

A missed deadline work item is created by default when the WF system detects that a monitored
deadline has been missed.

A wait step work item receives events created externally or by other WIs. A wait step has no
processing logic and does not appear in the Business Workplace.

A workflow work item represents a workflow to be processed, the definition of which is then
processed by the WFM.

A Web work item represents a Web activity.

A dialog work item represents a step in a WF, which is to be executed by a user.

SAP AG

BC610

7-8

:RUN ,WHP /DQJXDJH

l (DFK ZRUN LWHP KDV D ODQJXDJH

l 7KH ODQJXDJH RI D ZRUN LWHP LV GHULYHG IURP WKH


ODQJXDJH RI WKH VXSHURUGLQDWH ZRUNIORZ

l 7KH ZRUNIORZ ODQJXDJH FDQ EH VHW GXULQJ FUHDWLRQ


l 7KH ODQJXDJH RI DQ HYHQW FDQ EH VHW DV D GHIDXOW
SDUDPHWHU

SAP AG 1999

The WI language determines the language of the short text and the status texts. The language of the
long text is determined by the users logon language.

When a workflow is started via an event, the language of the event is passed on to the workflow.

Under "Personal workflow settings" in the Business Workplace, the user can set whether his or her
work items in the Business Workplace always appear in the logon language. In this case, all WI texts
are put into the users current logon language when the Business Workplace is compiled. This setting
reduces performance considerably, however.

SAP AG

BC610

7-9

:RUN ,WHP 6WDWXV

l :$,7,1*

 ZDLWLQJ

l 6(/(&7('

 UHVHUYHG

l 5($'<

l 67$57('

l &200,77('
l (5525

l &203/(7('
l &$1&(//('

 UHDG\

 LQ SURFHVV
 H[HFXWHG
 HUURU

 FRPSOHWHG

 ORJLFDOO\ GHOHWHG

SAP AG 1999

A WI has the status WAITING if its requested start has not yet been reached. With this status it
cannot be seen by any user.

A WI with status READY appears in the Business Workplace of the recipients. WIs running in the
background with this status are executed immediately.

The status SELECTED only applies to dialog and work queue work items. It means that the WI has
been reserved by one of the recipients and therefore disappears from the Business Workplace of the
others.

When the underlying method has been started but not yet completed, the WI has the status
STARTED. The WI remains in the Business Workplace of the current agent.

If the underlying method has been executed successfully but the WI has to be set to done manually,
it has the status COMMITTED.

If, during execution of the method, a return code not modeled in the related workflow was returned
or irreparable damage occurred in the WIM, the WI is assigned the status ERROR.

If processing of the WI has been completed successfully, it is assigned the status COMPLETED.

If the WI is no longer required within the flow logic of the workflow, it is assigned the status
CANCELLED.

SAP AG

BC610

7-10

6WDWXV 7UDQVLWLRQV

&DQFHOOHG

:DLWLQJ

5HDG\

(UURU

6WDUWHG

6HOHFWHG

&RPSOHWHG

&RPPLWWHG

SAP AG 1999

Not all work item types can assume all statuses (for example, SELECTED only for dialog and work
queue work items, COMMITTED only for dialog work items).

The start statuses are WAITING or READY.

The end statuses are CANCELLED or COMPLETED.

The change from one status into another always happens implicitly on the basis of an executed
activity (for example, "reserve" in the Business Workplace).

SAP AG

BC610

7-11

:,0 $3,  )XQFWLRQ 0RGXOHV

l &UHDWH D ZRUN LWHP


6::B:,B&5($7( B6,03/(

l ([HFXWH D ZRUN LWHP


6::B:,B:,7+287B:/&B(;(&87(

l 6WDUW D ZRUN LWHP FUHDWH DQG H[HFXWH LPPHGLDWHO\


6::B:,B67$57 B6,03/(
l *HQHUDO $3, IXQFWLRQV
)XQFWLRQ JURXS 6::$

SAP AG 1999

Important: the function modules in the function group SWWA are not officially released externally,
meaning that their interface may change. However, all efforts are being made to keep enhancements
upwardly compatible.
Only the function module WORKITEM_ARCHIVE_OBJECT for archiving a work item is officially
released.

When a work item is started or created, the caller must first fill the task container with the input
parameters of the task according to the task definition.
The caller must also incorporate error handling measures if the WI cannot be created or started.

Before a work item is executed, the caller must check whether all the prerequisites for execution
have been fulfilled (for example, is the current user permitted to execute the WI).

All administration function modules (SWW_WI_ADMIN_*), for example, are in the SWWA
function group.

All function modules of the SAP WAPI interface can also be used (SAP_WAPI_*). These are in
function groups SWRC and SWRR.

SAP AG

BC610

7-12

6$3 :$3, )XQFWLRQ 0RGXOHV

l )XQFWLRQ JURXS 6:5&


)XQFWLRQ PRGXOHV IRU SURFHVVLQJ WKH ZRUNOLVW RI D XVHU

l )XQFWLRQ JURXS 6:5,


)XQFWLRQ PRGXOHV IRU VHOHFWLQJ ZRUN LWHPV DFFRUGLQJ WR
YDULRXV FULWHULD HJ IRU UHSRUWLQJ DQG DQDO\VLV

l )XQFWLRQ JURXS 6:55


)XQFWLRQ PRGXOHV IRU VWDUWLQJ D ZRUNIORZ RU IRU WULJJHULQJ
DQ HYHQW

SAP AG 1999

SAP WAPI is an SAP-specific API based on the interface definitions of the Workflow Management
Coalition.

The SAP WAPI function modules call again the function modules internally from SWWA. The
functionality is the same, but the interface is different.

If possible, the function modules from SWRI should be used instead of direct table access (e.g. to
tables SWWWIDEADL and SWWWIRET) for work item selection within analysis and reporting.

SAP AG

BC610

7-13

:,0 $3,  7DEOHV

l 5HOHDVHG KHDGHU GDWD


9LHZ 6::938%/,&
l 'HDGOLQH GDWD
7DEOH 6:::,'($'/

l 5HWXUQ GDWD IURP PHWKRG H[HFXWLRQ


7DEOH 6:::,5(7
l 2EMHFWV LQ ZRUN LWHP FRQWDLQHU
7DEOH 6::B&2172%

l 1RQREMHFWV LQ ZRUN LWHP FRQWDLQHU


7DEOH 6::B&217

SAP AG 1999

The entire header data is located in the table SWWWIHEAD. The view SWWVPUBLIC contains
the elements that are available for general selection and do not represent internal administrative data
of the WIM.

Changes to the structure of the SWWVPUBLIC view are only upward compatible. The structures of
the remaining tables and others are not guaranteed. If data of a known work item is to be read, the
function modules SWW_WI_HEADER_READ, SWW_WI_DEADLINES_READ and
SWW_WI_RETURN_READ from the SWWA function group should be used (or as of 4.5A,
SWW_WIS_*_READ, if the data from several work items is to be imported).

If the container of a known work item is to be read, the function module


SWW_WI_CONTAINER_READ in the function group SWWA should always be used.

Non-objects in the work item container include scalar values (char, integer) and structures.

Changes to work items must never be made by direct table changes, but always via the function
modules in the function group SWWA.

SAP AG

BC610

7-14

2EMHFW 5HIHUHQFHV

l 5XQWLPH KDQGOHV 5+V

Used in BOR

Valid during runtime of creating program

Used in workflow

Can be saved in the database

l 3HUVLVWHQW REMHFW UHIHUHQFHV 325V

SAP AG 1999

The BOR only recognizes RHs (for example, as a result of macro SWC_CREATE_OBJECT, as
input for method calls, and so on). An RH is only valid during the runtime of the creating program
and expires immediately afterwards.

This is not sufficient for the workflow, since there may be program changes or several days between
the individual steps. For this reason, there must also be a persistent presentation. This presentation is
visible, for example, when you look at the work item container.

All BOR macros expect an RH; all workflow FMs expect PORs.

The workflow ensures correct conversion automatically. An explicit conversion is always necessary
when you write your own FMs that are called on the interface between the workflow system and the
BOR (for example, check FMs in the event manager).
The explicit conversion takes place using the macros SWC_CONTAINER_TO_RUNTIME and
SWC_CONTAINER_TO_PERSISENT from the include <cntn01>.

SAP AG

BC610

7-15

2EMHFW 5HIHUHQFHV LQ WKH :RUNIORZ &RQWH[W





 


(YHQW 0DQDJHU

5XQWLPH KDQGOH

1 0 5 3
""  42
(("(&#$" ! 
1 0 ) ' %    

3HUVLVWHQW
REMHFW UHIHUHQFH

5)&
:)

5XQWLPH KDQGOH

%25$SSOLFDWLRQ
:)

3HUVLVWHQW
REMHFW UHIHUHQFH

%25$SSOLFDWLRQ

5XQWLPH KDQGOH

:)

3HUVLVWHQW
REMHFW UHIHUHQFH

%25$SSOLFDWLRQ

5XQWLPH KDQGOH

:)
SAP AG 1999

User-controlled conversion is always necessary when the caller requires a different type of
presentation than the current one.

With every user-controlled conversion, the caller must ensure that a "re-conversion" takes place
afterwards, since the original presentation is expected again in the subsequent context.

When a workflow is started directly via the API, the RHs created in the program using the BOR
macros must also be converted to PORs before SWW_WI_CREATE (or SWW_WI_START) is
called.

SAP AG

BC610

7-16

8VHU'HILQHG :RUN ,WHP 'LVSOD\

l $GGLWLRQDO WDE LQ WKH ZRUN LWHP GLVSOD\


l 6XEVFUHHQ FRQWDLQV LWV RZQ IORZ ORJLF

l 6XEVFUHHQ FRPPXQLFDWHV ZLWK VXSHURUGLQDWH ZRUN


LWHP GLVSOD\

SAP AG 1999

Process or step-specific data can be displayed on the additional tab.

The user-defined tab is never visible in processing chains, since the object method underlying the
step is executed immediately.

SAP AG

BC610

7-17

5HIHUHQFH LQ WKH 6WHS 'HILQLWLRQ

Enter your subscreen

SAP AG 1999

The screen entered must be defined as a "subscreen".

SAP AG

BC610

7-18

)ORZ /RJLF RI WKH 6FUHHQ


l ,QLWLDOL]LQJ WKH GDWD IRU 3%2

l 6WDWXVGHSHQGHQW UHIUHVKLQJ RI WKH GDWD IRU 3%2 RSWLRQDO


l 5HDFWLRQ WR 2. &RGH IRU 3$,

(LWKHU
'LUHFW SURFHVVLQJ LQ WKH VXEVFUHHQ

2U
7UDQVIHU RI WKH 2. FRGH WR WKH VXSHURUGLQDWH :, VWDQGDUG VFUHHQ

SAP AG 1999

The programming is carried out via macros from the <widisp> include. This include must be
included in the module pool.

The online documentation contains complete documentation on the macro.

SAP AG

BC610

7-19

,QLWLDOL]LQJ WKH 6FUHHQ IRU 3%2

4XHU\ WKH LQLWLDO UXQ


6HW WKH WLWOH
4XHU\ WKH DVVRFLDWHG :, ,'
4XHU\ WKH DVVRFLDWHG
DSSOLFDWLRQ REMHFW

5HDG WKH DWWULEXWHV RI WKH


DVVRFLDWHG DSSOLFDWLRQ
REMHFW

SAP AG 1999

The SAP_WAPI_* function modules implement the WfMC Interface 2 and are in the SWRC
function group.

SAP_WAPI_GET_OBJECTS returns the leading object as a POR. A transformation to an RH must,


therefore, take place before the BOR macro is called by calling
SWC_OBJECT_FROM_PERSISTENT.

To use the BOR macro, the include <cntn01> must be incorporated.

SAP AG

BC610

7-20

SAP AG
n

BC610

7-21

The online documentation contains the complete list of IDs for transferring the OK codes.
SAP AG 1999

SP8D@F8uC$9 9
9 R Q I H G 9 EC 9 x
B y@9uqpR
x C I Ai
9 R Q I H G 9 C X X I Q
gaD8@E`w@9$SVA v
W 9 9A I X s r 9C U Wi RA QA 9 f 7
@u"t8@qpVhV@gSX
9 E Q 9 Q I H G 9 EC A 9 X W U
@FCedCcRba8D@`SVYVA T
9 R Q H G 9 EC BA 9 7
SIP8D@FD@86

5HDFWLRQ WR 2. &RGH IRU 3$,

5XQWLPH 'LVSOD\

X f 9C X i i 9 f A QY R 9CA 9 X W
wI FY I@SXbpuSi
X SuC 9$gVSpVcV$U (
i U
X X I QA f A QY UC
X C 7 i A C U I 9
$9ug&FFC$bC$@V"pQ
I idY @@fbS9u@XeVwX$$@I 
i I 9 X f C QC X 9 I
B x f i R
U SSX pC 8y4Q
9 i A
9 E C Wi X W Qi C I W 7 Q C X 9 I
Fwqp&yS`YeVwX$$@I 
SAP AG 1999

The "Data for process" is always displayed as the first tab.

The "Resubmit approval" button is mapped to OK code 0002.


The "Add attachment" button is mapped to OK code 0018.
The "Display application" button is handled directly using the SHOW_FORM form.

SAP AG

BC610

7-22

'HDGOLQH 0RQLWRULQJ

l 0RQLWRULQJ IRXU GHDGOLQHV

Requested start (resubmission)

Latest start

Requested end

Latest end

Either periodically on a regular basis

Or only as required (default)

l 0RQLWRULQJ DOO GHDGOLQHV XVLQJ D EDFNJURXQG MRE

SAP AG 1999

All deadlines are monitored using the background job SWWDHEX with job class A. The job calls
the report RSWWDHEX.

You can choose between deadline monitoring on an individual or on a periodic basis. Individual
monitoring is active by default.

With individual monitoring, the background job is rescheduled for the next deadline to be monitored
and is updated if a new deadline is entered for a WI that is sooner than any others. The background
job therefore, only runs if it is really needed.
Important: if the background job aborts for any reason, it must be rescheduled by starting the above
report.

This procedure is not economical for monitoring a large number of deadlines. In this case, you
should switch to periodic deadline monitoring (for example, every three minutes).

You can switch between the two monitoring types at any time via SWWA or using the report
RSWWDHIN.

SAP AG

BC610

7-23

'HDGOLQH 0RQLWRULQJ ,QKHULWDQFH

l 'HDGOLQH GDWD DQG PRQLWRULQJ DFWLYLW\ LQKHULWHG E\


GHSHQGHQW ZRUN LWHPV IURP ZRUNIORZ

l 'HILQLWLRQ RI PRQLWRULQJ DFWLYLW\ IRU GHSHQGHQW ZRUN


LWHP RYHUZULWHV LQKHULWDQFH

l &KHFN GHDGOLQH GDWD LQ GHSHQGHQW ZRUN LWHP DJDLQVW


LQKHULWHG GHDGOLQHV

SAP AG 1999

Inheritance only applies on creation of the subordinate work item. Subsequent changes to data in the
superordinate workflow are not passed on to existing dependent work items.

Every change in the data in the dependent work item is checked against the superordinate workflow.
It is not possible to postpone beyond the inherited deadlines.

SAP AG

BC610

7-24

'HDGOLQH 0RQLWRULQJ  6SHFLDO 6LWXDWLRQV

l 0DQ\ GHDGOLQHV
6ZLWFK IURP VLQJOH FDVH EDVHG WR SHUPDQHQW
l 6HYHUDO LQVWDQFHV RI 6::'+(;
'HOHWH DOO LQVWDQFHV YLD MRE RYHUYLHZ
5HVFKHGXOH
l 1R LQVWDQFHV RI 6::'+(;
&KHFN VHOHFWLRQ IRU MRE RYHUYLHZ
5HVFKHGXOH

SAP AG 1999

SWWDHEX is rescheduled via transaction SWWB.

When many deadlines are to be monitored, a conflict may arise with background job
SAP_REORG_JOBS. In this case, deadline monitoring should be suppressed while
SAP_REORG_JOBS is running.

When displaying background jobs in the job overview, remember that this is a cross-client display.
You should therefore check whether the background jobs displayed are actually scheduled in the
current client.

SAP AG

BC610

7-25

(UURU +DQGOLQJ

(UURU VLWXDWLRQ
:,

(UURU FRUUHFWLRQ
:,

(5525

),

),

(5525





&RUUHFWLRQ
(UURU 5HVWDUW

(UURU 5HVWDUW

SAP AG 1999

Error situation
1) The status of the work item changes to ERROR.
2) The error is propagated to the superordinate workflow.
3) The status of the superordinate workflow also changes to ERROR.

Error correction
1) The work item is corrected (for example, by correcting the work item container).
2) A "restart after error" is executed on the superordinate workflow.
3) The superordinate workflow propagates the restart to the work item.
4) A "restart after error" is executed on the work item implicitly.

When an error occurs, it is propagated "bottom up" to all superordinate workflows.

To correct the error, the WI is first repaired locally.

Then the workflow is restarted from the top down and all work items belonging to the workflow are
also restarted. The restart must always be performed at the highest level workflow, and never from
the WI with the error.

Work items with errors should not be restarted with SM58 (prior to 4.0A), since steps already
executed may be executed a second time.

All correction actions on work items should be performed with great caution to avoid side effects.

SAP AG

BC610

7-26

%HKDYLRU :LWK 8QPRGHOHG (UURUV

7HPSRUDU\ HUURU
%DFNJURXQG
ZRUN LWHPV
:RUNIORZ
ZRUN LWHPV
'LDORJ
ZRUN LWHPV

1RQWHPSRUDU\
HUURU

67$57(' VWDWXV
UHVWDUW ZLWK
6::(55(

(5525 VWDWXV
VHQG DQ
HUURU PDLO WR
:) DGPLQLVWUDWRU

67$57(' VWDWXV
H[HFXWHG DJDLQ
E\ WKH XVHU

(5525 VWDWXV
:, UHPDLQV LQ
%XVLQHVV :RUNSODFH
RI WKH XVHU

SAP AG 1999

Behavior with unmodeled errors

The method definition determines whether an error is temporary or not.

The background activities are monitored by the job RSWWERRE.

The status of background work items and workflow work items changes to ERROR after the nth
unsuccessful execution.

SAP AG

BC610

7-27

(UURU +DQGOLQJ  'HDGOLQH 0RQLWRULQJ


6::(55(

6::'+(;

7ULJJHU

:RUN LWHP VWDWXV

'HDGOLQH GDWD

$FWLRQ

3UHGHILQHG DFWLRQ
WULJJHU YLD W5)&

-RE

-RE FODVV &


SHULRGLF MRE

3UHGHILQHG RU XVHU
GHILQHG DFWLRQ WULJJHU YLD
W5)&

,QWHUYDO

-RE FODVV $
VHOI VFKHGXOLQJ MRE

&RQILJXUDEOH

&RQILJXUDEOH RU
GHSHQGHQW RQ GHDGOLQHV

$XWKRUL]DWLRQ

1RUPDO DXWKRUL]DWLRQ
FKHFN

&KHFN
GHDFWLYDWHG

6FKHGXOLQJ

&XVWRPL]LQJ RU
DXWRFXVWRPL]LQJ

&XVWRPL]LQJ RU
DXWRFXVWRPL]LQJ

SAP AG 1999

Neither job allows real-time control since background jobs that are running are not interrupted.

SAP AG

BC610

7-28

:RUN ,WHP 0DQDJHU /RJJLQJ

l :ULWH WHPSRUDU\ ORJ HQWU\ IRU DOO XVHU DFWLYLWLHV LI


VXFFHVVIXO

l :ULWH WHPSRUDU\ ORJ HQWU\ IRU DOO DFWLYLWLHV LI HUURUV


RFFXU

l :ULWH SHUPDQHQW ORJ HQWU\ DIWHU H[SOLFLW LQVWUXFWLRQ

SAP AG 1999

Initially, only temporary log entries are written to a buffer so that the commit logic of the caller is
not destroyed.

A log entry is written for all activities that can be triggered by a user (including) via the user
interface, if successful (FM SWW_WI_LOG_WRITE_SUCCESS).

A log entry is always written if an error occurs so that the call hierarchy can be traced to the point of
error (FM SWW_WI_LOG_WRITE_EXCEPTION).

The function module SWW_WI_LOG_FLUSH must be called before the database commit, so that
the temporary log entries can be written from the buffer to the database.

If work items are created via the WIM API (or, more generally, the work items are controlled via the
WIM API) and the commit is controlled by the creator (that is, the parameter DO_COMMIT was set
to SPACE), the creator must call the function module SWW_WI_LOG_FLUSH before commit
work. In all other cases, the call is performed by the workflow runtime system.

SAP AG

BC610

7-29

:RUN ,WHP $GPLQLVWUDWLRQ

l ,QLWLDWH ZDLWLQJ :,V

l 5HOHDVH UHVHUYHG :,V

l 5HVWDUW D :, DIWHU HUURUV


l /RJLFDO GHOHWLRQ RI D :,

l ([SOLFLW VXFFHVVIXO FRPSOHWLRQ RI D :,

SAP AG 1999

All administrator FMs are checked with regard to authorization. They are used to process a WI in
exceptions.
Note: the necessary authorizations are contained in the authorization profile S_WF_WF_ADMIN.

When a waiting WI is initiated, its status is changed from WAITING to READY. This function can
be executed if deadline monitoring is not running due to overloading of the background queue or an
error in the background system.

The status of the WI is changed from SELECTED or STARTED to READY again. This function can
be used in order to make a WI that is blocked by an absentee visible for other recipients.

When restarting after an error, the status of the WI is changed from ERROR to STARTED, the
underlying method may be executed automatically.

Logical deletion changes the status of the WI to CANCELLED.

The system administrator for WF can explicitly change the status of a WI to COMPLETED, but is
responsible for filling the container of the WI with the expected return parameters of the method
beforehand.

SAP AG

BC610

7-30

:RUN ,WHP 0DQDJHU $V\QFKURQRXV


&RPPXQLFDWLRQ

l 5HTXLUHG IRU WUDQVLWLRQ IURP GLDORJ WR EDFNJURXQG


SURFHVVLQJ
l 8VH RI WUDQVDFWLRQDO 5)& W5)&

l 0DLQWHQDQFH RI ORJLFDO GHVWLQDWLRQ


:25.)/2:B/2&$/ B&OQW! UHTXLUHG

SAP AG 1999

tRFC is a Basis component (CALL FUNCTION ... IN BACKGROUND TASK). The FM called is
triggered after the next SAP Commit (see unit on events).

The logical destination WORKFLOW_LOCAL<Clnt> is maintained for the WF runtime system


within Customizing via the transaction SWUB. The user entered there must have all authorizations
and should therefore, for security reasons, be a background user.
Important: If the password of this user is changed within user administration, this change must also
be made in SWUB.
Important: The logical destination WORKFLOW_LOCAL<Clnt> cannot be maintained via the
transaction SM59.

The tRFCs issued are logged until they are executed. If execution is successful, these entries are
deleted. If an error occurs during execution, this is also recorded in the log.
Only up to 3.1G: The log can be viewed via SM58. It is accessed with the name of the user who
called the tRFC. For the WF system, it is normally the user who is entered in the destination
WORKFLOW_LOCAL_<Clnt>.

There is another access possibility from the workflow development environment via "RFC monitor".

SAP AG

BC610

7-31

)LQGLQJ :RUN ,WHPV

l 6HOHFWLRQ UHSRUW IRU ILQGLQJ ZRUN LWHPV

ID

Work item type

Status

Task

l 'LVSOD\ DQG FKDQJH ZRUN LWHPV RI DOO W\SHV

SAP AG 1999

After the work item has been selected, the users can change and/or process the work item if they are
assigned to the underlying task via the task profile and the work item is not already reserved by
another recipient.

If the work item is not task-based (for example, wait steps, work queues, and so on), the user can
change and/or process it if it is not already reserved by another recipient.

SAP AG

BC610

7-32

:RUNIORZ 'LDJQRVLV 7RRO

l $FFHVV WR ZRUNIORZ DQG ZRUN LWHP GHEXJJLQJ

Verification of workflow Customizing

Problem: Task not started

Problem: Workflow hanging

Test environment (special test tools)

l &RQWH[WVHQVLWLYH GLDJQRVLV RI ZRUNIORZ LQVWDQFHV

SAP AG 1999

Access either via Utilities in the workflow development environment or directly via the transaction
SWUD.

All the tools and procedures that will be described in detail can be executed via this tool.

Problems triggering events can also be investigated via this tool.

SAP AG

BC610

7-33

:RUN ,WHP 'HEXJJLQJ

l :RUNIORZ ORJ HYDOXDWLRQ

l :RUNIORZ WUDFH HYDOXDWLRQ

SAP AG 1999

The workflow log is always written and cannot be switched off. It follows the database commit and
writes to the database.

The workflow trace must be switched on explicitly. It is not dependent on the database commit and
writes to the file system of the application server.

The workflow trace is helpful with regard to problems in background work items or binding.

SAP AG

BC610

7-34

7URXEOHVKRRWLQJ  6WDUWLQJ D :RUNIORZ

l :RUNIORZ GRHV QRW VWDUW

Check the Customizing settings

Check event trace for initiator

Check event linkage (exists and active)

Check tRFC log under initiators login

Check tRFC log under users login from


WORKFLOW_LOCAL_<Clnt>

Check workflow definition (active version)

SAP AG 1999

The consistency check for Customizing must be carried out before you first work with SAP Business
Workflow.

Note: Linkages with errors are deactivated automatically and a mail is sent to the system
administrator for workflow.

SAP AG

BC610

7-35

7URXEOHVKRRWLQJ  :RUN ,WHP &DQQRW %H )RXQG

l :RUN LWHP LV QRW LQ WKH %XVLQHVV :RUNSODFH

Check whether work item created correctly (see above)

Search for work item via work item selection

Check agent assignment via task profile and step definition

Check role definition and/or role function module

SAP AG 1999

The buffer for organizational assignments may have to be refreshed.

SAP AG

BC610

7-36

7URXEOHVKRRWLQJ  :RUN ,WHP 1RW LQ (QG 6WDWXV

l :RUN LWHP FDQQRW EH FRPSOHWHG


Workflow log check

Application or temporary error

If background step, check via report RSWWERRE

Check whether the system administrator for workflow has


received mail

If asynchronous step, check event instance linkage

Initiate test execution

Check container contents

SAP AG 1999

A breakpoint should be set in the method implementation before the "test execution".

If the instance linkage table is filled correctly, the terminating event can also be triggered via the
workflow development environment for test purposes.

SAP AG

BC610

7-37

7URXEOHVKRRWLQJ  :RUNIORZ +DQJLQJ

l :RUN LWHP FRPSOHWHG EXW ZRUNIORZ QRW FRQWLQXLQJ


Workflow log check

w
w
w
w

Preceding step completed correctly


Status transition implemented correctly
No waiting for event in a parallel branch
Work item for next step created correctly

Check whether step task is locked against instantiation

Check whether the system administrator for workflow has


received mail

Search for created work item (see above)

SAP AG 1999

SAP AG

BC610

7-38

$UFKLYLQJ DQG 'HOHWLQJ :RUN ,WHPV

l 'HOHWH LQ WHVW V\VWHP XVLQJ UHSRUWV 56:::,'( DQG


56::+,'(
l 'HOHWH LQ SURGXFWLRQ V\VWHP RQO\ XVLQJ DUFKLYLQJ
REMHFW :25.,7(0

SAP AG 1999

Reports RSWWWIDE and RSWWHIDE are only intended for internal use. The work items are
deleted from the database without further query or authorization check. They can be started through
the Administration menu in the workflow development environment.
The reports should always be called with the "display only" indicator set first to check them. The
actual deletion should then be performed using a background job.

Workflow work items automatically delete their dependent work items as well.

In a production system, the work items must be archived before they are deleted (transaction SARA).
The contents of the archive files can be deleted afterwards.

Archived work items can be read, but not reloaded for security reasons. The read program must be
written individually by the customer. An example program is supplied by SAP (RSWWARCR).

Other archiving objects can also archive work items using the archiving class WORKITEM. Work
items cannot, however, be deleted in this manner for reasons of data consistency.

Container linkage work items should be deleted using the report RSWWCIDE.

SAP AG

BC610

7-39

5HDG $UFKLYHG :RUN ,WHPV


l 5HDG SURJUDP 56::$5&5

Sequential reading of the entire archive

Template for own read programs

Read a process for a particular object

Workflow log formatting

l 5HDG SURJUDP 56::$5&3

SAP AG 1999

RSWWARCR can be used as a template for user-defined programs. The user source code begins
after calling the function module SWW_WI_LIST_ARCHIVED_READ, which imports the whole
archive to internal tables. The tables contain all processes in a depth-first storage format.

RSWWARCP is a special case of a self-written read program. It searches for the associated process
for a particular application object and restructures the workflow log for this process (as far as
possible).

The archive data cannot be reloaded to the original WI tables, since the runtime system reuses the
WI numbers (i.e. data could be overwritten when reloaded).

SAP AG

BC610

7-40

&RPSDULVRQ $UFKLYLQJ  'HOHWLQJ

5HSRUW 56:::,'(
3RVVLEOH LQ HYHU\ VWDWXV
'LUHFW VWDUW ZLWKRXW
DXWKRUL]DWLRQ FKHFN

'LUHFW GHOHWLRQ IURP


GDWDEDVH

([HFXWLRQ LQ GLDORJ RU
LQ EDFNJURXQG
/RJ GDWD QRW GHOHWHG

$UFKLYLQJ REMHFW
:25.,7(0

2QO\ SRVVLEOH LQ &203/(7('


RU &$1&(//(' VWDWXV
$XWKRUL]DWLRQ FKHFN XVLQJ
WUDQVDFWLRQ 6$5$
$UFKLYLQJ DQG GHOHWLQJ
LQ WZR VHSDUDWH VWHSV

([HFXWLRQ LQ EDFNJURXQG
ODWHU
/RJ GDWD DOVR
DUFKLYHG DQG GHOHWHG

SAP AG 1999

WI data must never be deleted directly in tables, only using the function module
SWW_WI_DELETE.

Large amounts of data should always be deleted in background processing.

Report RSWIWADO can be used to determine the requirement for archiving/deleting.

If only the workflow log is to be deleted, report RSWWHIDE can be used for this.

SAP AG

BC610

7-41

,PSURYLQJ 3HUIRUPDQFH  W5)&

l 5HSODFH UHDGLQJFDOFXODWLQJ EDFNJURXQG PHWKRGV


ZLWK YLUWXDO DWWULEXWHV

l 1R ZRUNIORZV WKDW FKHFN LQSXW GDWD LQ WKH ILUVW VWHS

l 1R ZRUNIORZ VWDUWV YLD HYHQW IURP XVHU ZULWWHQ UHSRUW


l &RPELQH VPDOOHU EDFNJURXQG PHWKRGV LQWR
ODUJHU XQLWV
l 3DFNDJLQJ RI LQSXW GDWD LQWR VPDOOHU XQLWV

SAP AG 1999

Packaging is particularly relevant if large quantities of data are imported into the system (for
example, with a batch input).

A check function module can be implemented instead of a "check step" in the workflow when the
workflow is started via an event, for example.

The WIM API can be used instead of an event if a workflow is started from a user-defined report that
is scheduled as a background job.

A destination can be specified for each event receiver in the type linkage table. Specific events can
then be received on a specific application server (to keep the other application servers free, for
example).

SAP AG

BC610

7-42

,PSURYLQJ 3HUIRUPDQFH  %XVLQHVV :RUNSODFH

l 'HWDLOHG WDVN DVVLJQPHQW LQ WKH RUJDQL]DWLRQ PRGHO


l 'R QRW GLVSOD\ GHDGOLQH RU JURXSLQJ GDWD LQ WKH
VWDQGDUG FRQILJXUDWLRQ

l 'LVSOD\ ZRUN LWHPV LQ FUHDWLRQ ODQJXDJH UDWKHU WKDQ


ORJRQ ODQJXDJH
l $OORZ EXIIHULQJ RI RUJDQL]DWLRQDO GDWD
l 'HOHWH ZRUN LWHPV QR ORQJHU UHTXLUHG

SAP AG 1999

General tasks should not be used if at all possible. If they are, a restrictive agent assignment should
be performed in the step definition.

The following lead to subsequent selection if they are adopted in the standard configuration:
Object
Group

_WI_GROUP_ID

Task text

WI_RHTEXT (if work item display in logon language)

To do by (date)

WI_LED

To do by (time)
n

_WI_OBJECT_ID

WI_LET

The buffering of organizational data can be controlled via the table T77S0.
Please refer to note 98407.

SAP AG

BC610

7-43

:RUNIORZ 5XQWLPH 6\VWHP 8QLW 6XPPDU\ 

l ([SODLQ WKH FRPSRQHQWV RI WKH UXQWLPH V\VWHP DQG

KRZ WKH\ LQWHUDFW LQ D ZRUNIORZ

l &RQWURO WKH FUHDWLRQ DQG H[HFXWLRQ RI ZRUN LWHPV ZLWK

WKH ZRUN LWHP PDQDJHU $3,

l ([SODLQ GHDGOLQH PRQLWRULQJ DQG HUURU KDQGOLQJ DV

ZHOO DV WKH RSWLRQV IRU FRQWUROOLQJ GHDGOLQH


PRQLWRULQJ

SAP AG 1999

SAP AG

BC610

7-44

:RUNIORZ 5XQWLPH 6\VWHP 8QLW 6XPPDU\ 

l 8VH WKH DGPLQLVWUDWLRQ IXQFWLRQV WR FRUUHFW D


ZRUNIORZ ZLWK HUURUV FRQWLQXH LW DQG DUFKLYH LW
RQFH LW LV WHUPLQDWHG

l 1DPH WKH PRGHOLQJ DQG FRQILJXUDWLRQ VHWWLQJV WKDW


XQQHFHVVDULO\ VORZ GRZQ WKH UXQWLPH V\VWHP

SAP AG 1999

SAP AG

BC610

7-45

([HUFLVHV
8QLW :RUNIORZ 5XQWLPH 6\VWHP
7RSLF :RUN ,WHP 0DQDJHU $3,

After completion of this exercise, you will be able to:


Create a work item via the API of the work item manager

You want to start a workflow not via an event, but directly via the API
of the work item manager (for example for performance reasons).

1-1

Start a workflow via the work item manager API.


1-1-1 Create a report = 67$57 that starts your workflow Z##MSIPROC1 by
calling the API function module SWW_WI_START_SIMPLE .

SAP AG

BC610

7-46

8QLW :RUNIORZ 5XQWLPH 6\VWHP

6HFWLRQ 8VHU'HILQHG :RUN ,WHP 'LVSOD\

After completion of this exercise, you will be able to:

Implement a subscreen for a user-defined work item display

Incorporate a subscreen for a user-defined work item display in your


process.

You want to display process-specific data for the end user before the
work item is executed.

2-1

Optional extensions: Define a subscreen for a user-defined work item display.


2-1-1

Create a VFUHHQ  in your function group that displays the following
data from the material master:
+ Material number
+ Last person to change the material
+ Material type
+ Lab/office of the material.
The user is also to be able to display the material stock at the click of a
button
Note: The screen entered must be defined as a "subscreen". In this
case, the OK code does not have to be declared explicitly as a field
in the screen layout.
Note: The material stock can be displayed via transaction MMBE.

2-1-2

Change the display step in your process Z##MSIPROC1 in such a way


that a user-specific work item is displayed using the subscreen that you
implemented previously.
Note: If you have not implemented your own screen, you can use the
screen SAPLZ610 0100.
Note: To make the user-defined screen visible when it is displayed,
you must choose the User view without ActiveX for the Work
item display under User-defined workflow settings.

SAP AG

BC610

7-47

8QLW :RUNIORZ 5XQWLPH 6\VWHP

6HFWLRQ $GPLQLVWUDWLYH )XQFWLRQV

After completion of these exercises, you will be able to:

Execute administrative functions such as selecting or deleting work


items

Several workflows have been successfully executed. After a time, you


want to delete these workflow instances.
Some workflows seem to have been running for an unusually long time
without terminating and you require detailed information about these
workflow instances.
3-1

Search for the work items based on specific criteria.


3-1-1 Create a report = 72'$< that lists all workflow instances started
today by a specific user. The list is to display the initiator, the status and
the task ID for each instance of this kind.
Note: The initiator is saved in the table SWW_CONT, and all other
data in the table SWWWIHEAD (or in view SWWVPUBLIC).

3-1-2 Using the report RSWWWIDE, delete all the work items you created on
the first day of the workshop.
Note: First execute the report with the flag Display list only set.
Only if the list contains exclusively your work items, remove the
flag for the second run of the report and actually delete the work
items.
Important: Once you have deleted the work items, they are lost
irretrievably.

3-2

SAP AG

Optional extensions

3-2-1 Create a report = :((./ that lists all unterminated workflow


instances started more than a week ago. The list is to display the task ID,
the status and the creation date for each instance of this kind.

BC610

7-48

6ROXWLRQV
8QLW :RUNIORZ 5XQWLPH 6\VWHP
7RSLF :RUN ,WHP 0DQDJHU $3,

1-1

Start a workflow via the work item manager API.


Solution:
Z00START
Path (via SAP Easy Access):
Tools > ABAP Workbench > Development > ABAP Editor

REPORT Z00START .
INCLUDE <CNTN01>. " definition of container and object macros
PARAMETERS: OBJKEY LIKE MARA-MATNR DEFAULT 200-100.
DATA:TASK
LIKE SWWVPUBLIC-WI_RH_TASK VALUE WS96000011,
WI_ID
LIKE SWWVPUBLIC-WI_ID,
OBJECT
TYPE SWC_OBJECT.
DATA:AGENTS
LIKE SWHACTOR OCCURS 0 WITH
HEADER LINE,
WI_CONTAINER LIKE SWCONT
OCCURS 0 WITH HEADER
LINE.
* set the import parameter for flow Z00MSIPROC1
* first: create object reference (runtime handle)
SWC_CREATE_OBJECT OBJECT Z00MARA OBJKEY.
* second: write reference to work item container using parameter def
SWC_SET_ELEMENT WI_CONTAINER MaterialMaster OBJECT.
* third: convert references in container from runtime handle to
* persistent object reference
SWC_CONTAINER_TO_PERSISTENT WI_CONTAINER.

SAP AG

BC610

7-49

* start the workflow via the function API


CALL FUNCTION SWW_WI_START_SIMPLE
EXPORTING
*
CREATOR
*
PRIORITY
TASK
*
CALLED_IN_BACKGROUND
*
DEADLINE_DATA
IMPORTING
WI_ID
*
WI_HEADER
*
RETURN
*
WI_RESULT
TABLES
AGENTS
*
DEADLINE_AGENTS
*
DESIRED_END_AGENTS
*
LATEST_START_AGENTS
*
EXCLUDED_AGENTS
*
NOTIFICATION_AGENTS
*
SECONDARY_METHODS
WI_CONTAINER
EXCEPTIONS

=
= NO_PRIO
= TASK
=
=
= WI_ID
=
=
=
= AGENTS " not needed here
=
=
=
=
=
=
= WI_CONTAINER

ID_NOT_CREATED
=1
READ_FAILED
=2
IMMEDIATE_START_NOT_POSSIBLE
=3
EXECUTION_FAILED
=4
INVALID_STATUS
=5
OTHERS
= 6.
IF SY-SUBRC NE 0.
" error message
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ELSE.
" success message
MESSAGE ID WZ TYPE S NUMBER 703 WITH WI_ID.
ENDIF.

SAP AG

BC610

7-50

8QLW :RUNIORZ 5XQWLPH 6\VWHP

6HFWLRQ 8VHU'HILQHG :RUN ,WHP 'LVSOD\

After completion of this exercise, you will be able to:

Implement a subscreen for a user-defined work item display

Incorporate a subscreen for a user-defined work item display in your


process.

You want to display process-specific data for the end user even before the
work item is executed.

2-1

Optional extensions: Define a subscreen for a user-defined work item display.


2-1-1 Create a VFUHHQ  in your function group.
Solution:
SAPLZ610 0100
Path (via SAP Easy Access):
Tools > ABAP Workbench > Development > User Interface > Screen
Painter
2-2-2 Change the display step in your process Z##MSIPROC1 in such a way that
a user-specific work item is displayed using the subscreen that you
implemented previously.
Solution:
WS96000011 Z00MSIPROC1
Path (via SAP Easy Access):
Tools > SAP Business Workflow > Development > Definition tools >
Tasks/Task groups > Change

SAP AG

BC610

7-51

MODULE INIT_0100 OUTPUT.


*- ask frame dynpro if this is the first call of this subscreen...
SWL_WIDISP_GET_INIT INIT_D0100.
CHECK INIT_D0100 IS INITIAL.
INIT_D0100 = X.
*- set a title heading this subscreen on the tabstrip control...
SWL_WIDISP_SET_TITLE Process data.
*- ask frame dynpro for the ID of workitem in display...
CLEAR G_WI_ID.
SWL_WIDISP_GET_WI_ID G_WI_ID.
*- now we get the data to be displayed...
*- we want to show some data concerning the material, which is connected
* to the workitem as an object.
* therefore, we use a released interface to get the workitems object.
CALL FUNCTION SAP_WAPI_GET_OBJECTS
EXPORTING
WORKITEM_ID
= G_WI_ID
IMPORTING
LEADING_OBJECT
= G_MATERIAL.
*
return_code
=
*
TABLES
*
OBJECTS
=
*
MESSAGE_LINES
=
*
MESSAGE_STRUCT
=.
*- from the material object we can get the data we want to show
CLEAR G_OBJECT. CLEAR MARA.
MOVE G_MATERIAL-OBJECT_ID TO G_OBJECT.
SELECT SINGLE * FROM MARA
WHERE MATNR = G_OBJECT-OBJKEY.
* we do not use a possible attribute access here, because the attribute
* BasicMaterialNumber does not exist and Laboratorty is defined
* as an object based attribute, so wed need to implement another
* attribute access for object type T024L
* clear g_runtime.
* swc_object_from_persistent g_object g_runtime.
* swc_get_property g_runtime Material
mara-matnr.
* swc_get_property g_runtime ChangedBy
mara-aenam.
* swc_get_property g_runtime MaterialType
mara-mtart.
* swc_get_property g_runtime OldMaterial
mara-bismt.
* swc_get_property g_runtime BasicMaterialNumber
mara-wrkst.
* swc_get_property g_runtime Laboratory
mara-labor.
ENDMODULE.
" INIT_0100 OUTPUT
SAP AG

BC610

7-52

MODULE USER_COMMAND_0100 INPUT.


DATA: OKAY
LIKE SY-UCOMM.
SWC_CONTAINER L_CONTAINER.
SWL_WIDISP_GET_OKCODE OKAY.
CASE OKAY.
*- we implement just one function of our own...
WHEN DISM. " this is the only OK code, ignore anything else
*- we want to show the material, which is related to the work item
* therefore, we use a released interface to get the workitems object.
IF G_MATERIAL IS INITIAL.
CALL FUNCTION SAP_WAPI_GET_OBJECTS
EXPORTING
WORKITEM_ID
= G_WI_ID
IMPORTING
LEADING_OBJEC
= G_MATERIAL.
*
return_code
=
*
TABLES
*
OBJECTS
=
*
MESSAGE_LINES
=
*
MESSAGE_STRUCT
=.
ENDIF.
*- we show the material stock using ta mmbe
CLEAR G_OBJECT.
MOVE G_MATERIAL-OBJECT_ID TO G_OBJECT.
SET PARAMETER ID MAT FIELD G_OBJECT-OBJKEY.
CALL TRANSACTION MMBE AND SKIP FIRST SCREEN.
*- now its more secure to clear the okcode to the frame dynpro,
* because it must not be handled again overthere...
SWL_WIDISP_CLEAR_OKCODE.
ENDCASE.
ENDMODULE.

SAP AG

" USER_COMMAND_0100 INPUT

BC610

7-53

8QLW :RUNIORZ 5XQWLPH 6\VWHP

6HFWLRQ $GPLQLVWUDWLYH )XQFWLRQV

After completion of these exercises, you will be able to:

Execute administrative functions such as selecting or deleting work


items

Several workflows have been successfully executed. After a time, you


want to delete these workflow instances.
Some workflows seem to have been running for an unusually long time
without terminating and you require detailed information about these
workflow instances.
3-1

Search for the work items based on specific criteria.


3-1-1 Create a report = 72'$< that lists all workflow instances started today
by a specific user.
Solution:
Z00TODAY
View Z00VHEACON
Path (via SAP Easy Access):

For the report


Tools > ABAP Workbench > Development > ABAP Editor

For the view


Tools > ABAP Workbench > Development > ABAP Dictionary

3-1-2 Using the report RSWWWIDE, delete all the work items you created on the
first day of the workshop.
Path (via SAP Easy Access):
Tools > ABAP Workbench > Development > ABAP Editor

SAP AG

BC610

7-54

REPORT Z00TODAY LINE-SIZE 512

INCLUDE RSWWINCL.
TABLES: Z00VHEACON. " view over SWWWIHEAD and _WF_INITIATOR
PARAMETERS: USER LIKE SY-UNAME DEFAULT SY-UNAME.
DATA:

CAND_WIS LIKE Z00VHEACON OCCURS 0 WITH HEADER LINE,


INITIATOR LIKE SWHACTOR,
LINE_NO
LIKE SY-TFILL.

* determine intitiator
INITIATOR-OTYPE = US.
INITIATOR-OBJID = USER.
* search list of candidate wis
IF USER NE SPACE.
" search for flows of this user
WRITE: / Number of flows started today by user , USER, :.
SELECT * FROM Z00VHEACON INTO TABLE CAND_WIS
WHERE WI_CD EQ SY-DATUM AND
WI_CHCKWI EQ SPACE
AND " top level flows only
VALUE
EQ INITIATOR.
ELSE. " search for flows independent of user
WRITE: / Number of flows started today by all users :.
SELECT * FROM Z00VHEACON INTO TABLE CAND_WIS
WHERE WI_CD EQ SY-DATUM AND
WI_CHCKWI EQ SPACE. " top level flows only
ENDIF.
DESCRIBE TABLE CAND_WIS LINES LINE_NO.
WRITE: LINE_NO.
SORT CAND_WIS BY WI_RH_TASK VALUE.
* display result list
LOOP AT CAND_WIS.
WRITE : / CAND_WIS-WI_ID, CAND_WIS-WI_RH_TASK, CAND_WIS-WI_STAT,
CAND_WIS-WI_CD, CAND_WIS-VALUE.
ENDLOOP.

SAP AG

BC610

7-55

3-2

Optional extensions
3-2-1 Create a report = :((./ that lists all unterminated workflow instances
started more than a week ago.
Solution:
Z00WEEKL
Path (via SAP Easy Access):
Tools > ABAP Workbench > Development > ABAP Editor

REPORT Z00WEEKL LINE-SIZE 512.


INCLUDE RSWWINCL.
TABLES: Z00VHEACON. " public view on work item header data
PARAMETERS:

TASK

07.

LIKE SWWWIHEAD-WI_RH_TASK,
DAYS_AGO LIKE SWWWIHEAD-RETRY_CNT DEFAULT

DATA: CAND_WIS
HEADER LINE.

LIKE Z00VHEACON OCCURS 0 WITH

DATA: START_DATE

LIKE SY-DATUM.

WRITE : / List of flows started longer than , DAYS_AGO, days ago:.


* determine start date for candidate work flows
START_DATE = SY-DATUM - DAYS_AGO.
* search list of candidate flows
IF TASK NE SPACE.
" search for a specific task
SELECT * FROM Z00VHEACON INTO TABLE CAND_WIS
WHERE WI_RH_TASK EQ TASK
AND
WI_CD <= START_DATE AND
WI_CHCKWI EQ SPACE AND " top-level flows only
( WI_STAT NE WI_STATUS_COMPLETED AND
WI_STAT NE WI_STATUS_CANCELLED ) .
ELSE.
" search for all tasks
SELECT * FROM Z00VHEACON INTO TABLE CAND_WIS
WHERE WI_CD
<= START_DATE AND
WI_CHCKWI EQ SPACE AND " top-level flows only
( WI_STAT NE WI_STATUS_COMPLETED AND
WI_STAT NE WI_STATUS_CANCELLED ) .
ENDIF.
* display result list
LOOP AT CAND_WIS.
WRITE : / CAND_WIS-WI_ID, CAND_WIS-WI_RH_TASK, CAND_WIS-WI_STAT,
CAND_WIS-WI_CD, CAND_WIS-VALUE.
ENDLOOP.

SAP AG

BC610

7-56

$SSHQGL[

l 7KLV VHFWLRQ FRQWDLQV VXSSOHPHQWDU\


PDWHULDO WR EH XVHG IRU UHIHUHQFH

l 7KLV PDWHULDO LV QRW SDUW RI WKH VWDQGDUG FRXUVH


l 7KHUHIRUH WKH LQVWUXFWRU PLJKW QRW FRYHU WKLV
GXULQJ WKH FRXUVH SUHVHQWDWLRQ

SAP AG 1999

SAP AG

BC610

8-1

$EEUHYLDWLRQ /LVW
$EEUHYLDWLRQ
API
BI
BOB
BOR
ECA
EM
FM
FG
FI
RH
LIS
LUW
POR
RFC
tRFC
WF
WI
WIM
WIS

/RQJ WH[W
Application Programming Interface
Background Work Item
Business Object Builder
Business Object Repository
Event Condition Action
Event Manager
Function Module
Function Group
Workflow Work Item
Runtime Handle
Logistics Information System
Logical Unit of Work
Persistent Object Reference
Remote Function Call
Transactional RFC
Workflow
Work Item (General)
Work Item Manager
Workflow Information System

)LUVW PHQWLRQ
Unit 3
Unit 6
Unit 2
Unit 2
Unit 5
Unit 3
Unit 2
Unit 6
Unit 6
Unit 2
Unit 7
Unit 5
Unit 2
Unit 5
Unit 5
Unit 1
Unit 6
Unit 3
Unit 7

SAP AG 1999

SAP AG

BC610

8-2

6$3 5HYLHZ
9ROXPH  ,VVXH 

06, %35

-XO\ 

Motor Sports International (MSI) has successfully implemented SAP R/3. SAP Business
Workflow helped in achieving the goals set by the company for optimizing business processes
(Business Processing Reengineering, or BPR).
The following study investigates the process used by MSI to achieve these objectives with the
help of the SAP Business Workflow tools. The study does not really outline the precise MSI
workflow implementation solution, but rather explains the business process in detail and
suggests courses of action.
This case study is not like a typical workflow process that would occur in your enterprise; it aims
to motivate you in this course and provide you with support for implementing workflow
successfully.

7KH SUREOHP DW 06, The existing system at MSI could not notify the designer of relevant
changes to material master records. This communication gap led to a delay in adjusting the
production line, which in turn resulted in large quantities of obsolete and unwanted warehouse
stock.
7KH VROXWLRQ DW 06, With the help of SAP Business Workflow, BPR helped MSI to make
considerable savings reducing warehouse stock.
,Q VKRUW 7KH ZRUNIORZ SURFHVV DW 06,
7ULJJHULQJ This business process always starts when a user changes the 2OG 0DWHULDO field
in a material master record. The result of the change triggers a workflow event (for example,
OldMaterialChanged), which then initiates one of two workflow processes.
The triggering event is actually initiated by a link to the SAP change documents. As soon as
the field is changed from a value * to your group number XX, the OldMaterialChanged
event is triggered.

*** Trigger
event ***

*Note: Enquiries at MSI have shown that this field is not used. Changes to its value
are therefore used to inform the designer of a relevant change to the material master.
'LVWLQJXLVKLQJ As mentioned above, the event triggers one of two workflows. The
definitions of the two workflows are identical, but different role resolutions are used. The
material type determines which workflow is started. The first workflow is started for material
type FERT for finished goods. All other material types start the second workflow.
0RQLWRULQJ: Not all changes to the 2OG 0DWHULDO field start the workflow process. For this case
study, you must ensure that the FKDQJHU of the material master is your logon ID.

SAP AG

BC610

*** Receiver type


function module
***

*** Check
function module
***

8-3

&RUH SURFHVV As soon as a material is changed, a particular designer must be informed.


The agent responsible is based on the "laboratory" field.

*** Role
resolution ***

After the notification, the designer adjusts the production process to suit the change. To
inform the workflow system that this work has been completed, the designer changes the
%DVLF 0DWHULDO field of the relevant material master. This event is therefore a terminating
event of an asynchronous task.
*Note: Enquiries during the project indicate that nobody else uses the %DVLF 0DWHULDO
field. A change to the value represents a status change.
If the designer does not complete all activities within a specified time interval (for example,
five minutes), the superior of the designer must be informed of this delay.

As soon as the workflow system is notified that the designer has completed their work, it
sends a notification of completion stating that the process is completed and that the material
just changed can now return to production. The workflow determines who receives this
notification (note that in practice this would be implemented using role resolution). The first
workflow (for material type FERT) forwards the notification to the user who changed the
material at the start. The second workflow (all other material types) forwards the notification
to the designer's superior for review.
$QDO\]LQJ The management team at MSI expects a specific daily report on all newly started
workflows. As well as the total number, the list that is output also contains the workflow
initiator for each workflow instance.

*** Deadline
monitoring ***
*** Terminating
event ***
*** Notification
of completion ***

*** Workflow
runtime
environment ***

The system administrator wants to maintain the database with minimal effort so a monthly
archiving procedure must be planned. To support planning, the workflow administrator
requires a weekly report on the workflows that have been started but not yet terminated.

Table I: Overview of Material Object Types


3URSHUW\

1DPH

0HDQLQJ

.H\

Material

Unique ID of a particular material

ChangedBy

The owner of the material

Plant

The main factory where the material is made

ExistenceCheck

Checks whether a given material exists or not

$WWULEXWH
0HWKRG

Edit

Enables the designer to change the %DVLF 0DWHULDO field

Display

Displays a given material

ChangeDocDisplay

Displays all changes to a given material

SAP AG

BasicMaterialChang
ed

Designer has completed processing by changing the %DVLF


0DWHULDO field

OldMaterialChanged

(YHQW

Workflow trigger: user has changed the 2OG 0DWHULDO field

BC610

8-4

Anda mungkin juga menyukai