141
BIT611 SAP Business Workflow - Advanced Programming with ABAP OO SAP NetWeaver Date Training Center Instructors Education Website Participant Handbook Course Version: 62 Course Duration: 1 Day Material Number: 50087408 An SAP course - use it to learn, reference it for work

BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Embed Size (px)

Citation preview

Page 1: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611SAP Business Workflow -

Advanced Programming withABAP OOSAP NetWeaver

Date

Training Center

Instructors

Education Website

Participant HandbookCourse Version: 62Course Duration: 1 DayMaterial Number: 50087408

An SAP course - use it to learn, reference it for work

Page 2: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Copyright

Copyright © 2008 SAP AG. All rights reserved.

No part of this publication may be reproduced or transmitted in any form or for any purposewithout the express permission of SAP AG. The information contained herein may be changedwithout prior notice.

Some software products marketed by SAP AG and its distributors contain proprietary softwarecomponents of other software vendors.

Trademarks

� Microsoft®, WINDOWS®, NT®, EXCEL®, Word®, PowerPoint® and SQL Server® areregistered trademarks of Microsoft Corporation.

� 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.

� ORACLE® is a registered trademark of ORACLE Corporation.� INFORMIX®-OnLine for SAP and INFORMIX® Dynamic ServerTM are registered

trademarks of Informix Software Incorporated.� UNIX®, X/Open®, OSF/1®, and Motif® are registered trademarks of the Open Group.� Citrix®, the Citrix logo, ICA®, Program Neighborhood®, MetaFrame®, WinFrame®,

VideoFrame®, MultiWin® and other Citrix product names referenced herein are trademarksof Citrix Systems, Inc.

� HTML, DHTML, XML, XHTML are trademarks or registered trademarks of W3C®, WorldWide Web Consortium, Massachusetts Institute of Technology.

� JAVA® is a registered trademark of Sun Microsystems, Inc.� JAVASCRIPT® is a registered trademark of Sun Microsystems, Inc., used under license for

technology invented and implemented by Netscape.� SAP, SAP Logo, R/2, RIVA, R/3, SAP ArchiveLink, SAP Business Workflow, WebFlow, SAP

EarlyWatch, BAPI, SAPPHIRE, Management Cockpit, mySAP.com Logo and mySAP.comare trademarks or registered trademarks of SAP AG in Germany and in several other countriesall over the world. All other products mentioned are trademarks or registered trademarks oftheir respective companies.

Disclaimer

THESE MATERIALS ARE PROVIDED BY SAP ON AN "AS IS" BASIS, AND SAP EXPRESSLYDISCLAIMS ANY AND ALL WARRANTIES, EXPRESS OR APPLIED, INCLUDINGWITHOUT LIMITATION WARRANTIES OF MERCHANTABILITY AND FITNESS FOR APARTICULAR PURPOSE, WITH RESPECT TO THESE MATERIALS AND THE SERVICE,INFORMATION, TEXT, GRAPHICS, LINKS, OR ANY OTHER MATERIALS AND PRODUCTSCONTAINED HEREIN. IN NO EVENT SHALL SAP BE LIABLE FOR ANY DIRECT,INDIRECT, SPECIAL, INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES OF ANYKIND WHATSOEVER, INCLUDING WITHOUT LIMITATION LOST REVENUES OR LOSTPROFITS, WHICH MAY RESULT FROM THE USE OF THESE MATERIALS OR INCLUDEDSOFTWARE COMPONENTS.

g2008022104036

Page 3: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

About This HandbookThis handbook is intended to complement the instructor-led presentation of thiscourse, and serve as a source of reference. It is not suitable for self-study.

Typographic ConventionsAmerican English is the standard used in this handbook. The followingtypographic conventions are also used.

Type Style Description

Example text Words or characters that appear on the screen. Theseinclude field names, screen titles, pushbuttons as wellas menu names, paths, and options.

Also used for cross-references to other documentationboth internal (in this documentation) and external (inother locations, such as SAPNet).

Example text Emphasized words or phrases in body text, titles ofgraphics, and tables

EXAMPLE TEXT Names of elements in the system. These includereport names, program names, transaction codes, tablenames, and individual key words of a programminglanguage, when surrounded by body text, for exampleSELECT and INCLUDE.

Example text Screen output. This includes file and directory namesand their paths, messages, names of variables andparameters, and passages of the source text of aprogram.

Example text Exact user entry. These are words and characters thatyou enter in the system exactly as they appear in thedocumentation.

<Example text> Variable user entry. Pointed brackets indicate that youreplace these words and characters with appropriateentries.

2008 © 2008 SAP AG. All rights reserved. iii

Page 4: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

About This Handbook BIT611

Icons in Body TextThe following icons are used in this handbook.

Icon Meaning

For more information, tips, or background

Note or further explanation of previous point

Exception or caution

Procedures

Indicates that the item is displayed in the instructor'spresentation.

iv © 2008 SAP AG. All rights reserved. 2008

Page 5: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

ContentsCourse Overview ..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii

Course Goals .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .viiCourse Objectives ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .vii

Unit 1: Introduction..... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1From BOR Objects to ABAP Classes ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2Technical View and Business Example .. . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

Unit 2: ABAP Classes Definition and Implementation ..... . . . . . 15Underlying Concepts of ABAP Object Classes in SAP BusinessWorkflow... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

Class Definition - Instance Handling and Key Fields... . . . . . . . . . . 29Class Definition - Attributes and Methods .. .. . . . . . . . . . . . . . . . . . . . . . 53

Unit 3: Use Classes in Workflow Architecture ..... . . . . . . . . . . . . . . . 91Exceptions, Events and API Functions .. . . . . . . . . . . . . . . . . . . . . . . . . . . 92Using Classes in Workflow Architecture ... . . . . . . . . . . . . . . . . . . . . . . . 110

2008 © 2008 SAP AG. All rights reserved. v

Page 6: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Contents BIT611

vi © 2008 SAP AG. All rights reserved. 2008

Page 7: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Course OverviewThis course covers customer adaptations and enhancements to workflows thatrequire programming. You will learn how to program workflow interfaces at theABAP class level. This includes attributes, methods and events.

The course also provides information on developing functional methods withthe new �Container Parameter Interface� , including check function modules,and so on.

Target AudienceThis course is intended for the following audiences:

� Workflow developers (with ABAP and ABAP OO knowledge)� Workflow consultants (with ABAP and ABAP OO knowledge)

Course PrerequisitesRequired Knowledge

� SAPTec� BIT601� BIT610� BC400 and BC401 or equivalent knowledge

Recommended Knowledge

� BIT600� DBITWF

Course GoalsThis course will prepare you to:

� Perform workflow programming at all levels� Use ABAP classes in SAP Business Workflow

Course ObjectivesAfter completing this course, you will be able to:

� Identify all points in the workflow system at which programming is possibleor necessary

� Create your own classes and use them in the workflow architecture

2008 © 2008 SAP AG. All rights reserved. vii

Page 8: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Course Overview BIT611

� Use �Container Parameter Interface� as the new application programminginterface (API) for workflow related functions (check, receiver type, and soon)

SAP Software Component InformationThe information in this course pertains to the following SAP Software Componentsand releases:

� SAP Web Application Server 6.20

viii © 2008 SAP AG. All rights reserved. 2008

Page 9: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1Introduction

Unit OverviewThis unit covers a brief overview of the uses and tasks of a workflow managementsystem.

It explains the definition architecture and the places within it that can beprogrammed.

This unit also introduces the example that will be used in the course exercises.

Unit ObjectivesAfter completing this unit, you will be able to:

� Repeat the main points of SAP Business Workflow architecture.� Recognize the components of SAP Business Workflow that enable or require

programming by the user.� Compare and contrast ABAP classes and business object types used in

workflow development.� Identify the main technical aspects of ABAP Classes and BOR� Analyze the Business Process� Compare the business object components (available) with the ABAP class

components needed

Unit ContentsLesson: From BOR Objects to ABAP Classes.. .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2Lesson: Technical View and Business Example.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8

2008 © 2008 SAP AG. All rights reserved. 1

Page 10: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Lesson: From BOR Objects to ABAP Classes

Lesson OverviewThis lesson repeats the underlying architecture and terminology of the workflowengine. It also compares and contrasts ABAP Classes and SAP Business Objectsused in workflow development.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Repeat the main points of SAP Business Workflow architecture.� Recognize the components of SAP Business Workflow that enable or require

programming by the user.� Compare and contrast ABAP classes and business object types used in

workflow development.

Business ExampleYour company have implemented some new business functions as Add On to theSAP ERP system. These functions are developed with ABAP Objects and yourdevelopers have many experience in this part of programming technique.

To gain advantage of these resources, the existing business functions should usedin workflow architecture to model the important business processes in this Add On.

Workflow Management StructureThere are some important declarations, you have to discuss, to describe aworkflow management system:

� A system that delivers work:

� In the correct sequence� With all the necessary information� At the correct time� To the responsible people

Workflow Management is used to link work steps automatically. It enables thecontrol of connected activities across transactions and across different applications.

2 © 2008 SAP AG. All rights reserved. 2008

Page 11: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: From BOR Objects to ABAP Classes

To work with structured processes in a workflow management system, there has tobe a variety of services to develop the necessary functions at design time:

� Processdefinition

What happens, and in which order?

Workflow builder, task definition

� Organizational modeling

Who does what?

Organization model, rule definition

� Application encapsulation

Which objects are required?

Business Object Builder, Class Builder

Through the process definition, the a workflow management system ensures that�work is delivered in the correct sequence... �.

Through organization modeling, a workflow management system ensures that�work is delivered to the people responsible...�.

Through application encapsulation, a workflow management system ensures that�work is delivered with all the necessary information�.

There has to be a variety of services to control the workflow runtime. Tools likethe following allow to gain access of the advantages of a workflow managementsystem:

� Support for end users

What have I got to do today?

Business Workplace

� Process control

What happens when?

Workflow manager, work item manager

� Evaluation of processing

Who did what and when?

Reporting and analysis

Through end user support, a workflow management system ensures that �work isdelivered to the people responsible at the correct time�.

Through process control, a workflow management system ensures that �work isdelivered in the correct sequence at the correct time�.

2008 © 2008 SAP AG. All rights reserved. 3

Page 12: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Figure 1: SAP Business Workflow: Definition Architecture

In the graphic, A→ B means that A uses B

For example:

A step definition uses attributes (container operation), events (wait steps), methods(submethods).

Tasks use workflow definitions (in multistep tasks) or methods (in single steptasks).

History of Business Process ManagementBusiness Process Management services were first introduced with release 2.0,but 3.0c was SAP�s first real concerted effort at providing Business ProcessManagement with the introduction of SAP Business Workflow.

At that time, object-oriented programming was more an idea than a reality inABAP; however it was already clear that object oriented techniques were the wayof the future and critical to the underpinnings of SAP Business Workflow.

4 © 2008 SAP AG. All rights reserved. 2008

Page 13: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: From BOR Objects to ABAP Classes

Figure 2: History of Business Objects and ABAP Classes

As a result, SAP Business Workflow was delivered with an approximation ofobject-oriented programming called the Business Objects Repository (BOR). Theaim of the BOR was clearly to provide object oriented (style) techniques andservices in systems that were not yet capable of object oriented programming.

Major strengths of the BOR was in how well it provided object orientedcapabilities - such as inheritance, delegation, association, and polymorphism- to such an extent that it wasn�t until R/3 release 4.6C that similar depth ofobject oriented capabilities was available in ABAP OO and not until SAP WebApplication Server 6.20 that ABAP OO was able to be integrated with SAPBusiness Workflow to the same degree as the BOR.

Why use Classes?

� It�s the way forward!� Standard SAP applications starting to use classes� Modern editor & improved coding standards� Clever bindings using functional methods� Usage not limited to workflow� Maintainable by developers without workflow knowledge� Adding additional components to classes is really easy!

The need for workflow services outstripped the introduction of ABAP OO, and bythe time ABAP OO was fully available and capable of replacing the BOR, a largebody of business content had already been provided by the BOR.

2008 © 2008 SAP AG. All rights reserved. 5

Page 14: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Why not use Classes?!

� More up front �Do It Yourself� when creating a class� Knowledge of OO syntax essential (but not hard to pick up!)� 1000+ BOR Object Types exist and can still be used� Older versions of SAP do not support OO Classes

It is no longer a simple matter of replacing code fragments in macros - a majoreffort would be needed to convert existing workflow content from the BORto ABAP OO.

Currently the effort required to convert the existing body of BOR content toABAP OO, and the disruption to customers that would be caused by such a majorchange in direction, exceeds the ROI of such an activity.

6 © 2008 SAP AG. All rights reserved. 2008

Page 15: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: From BOR Objects to ABAP Classes

Lesson Summary

You should now be able to:� Repeat the main points of SAP Business Workflow architecture.� Recognize the components of SAP Business Workflow that enable or require

programming by the user.� Compare and contrast ABAP classes and business object types used in

workflow development.

2008 © 2008 SAP AG. All rights reserved. 7

Page 16: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Lesson: Technical View and Business Example

Lesson OverviewThis lesson will identify the main technical aspects of the two necessary developingareas. We will also compare the business object components (available) with theABAP class components needed, and conduct the detailed project analysis.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Identify the main technical aspects of ABAP Classes and BOR� Analyze the Business Process� Compare the business object components (available) with the ABAP class

components needed

Business ExampleMotor Sports International has decided to implement SAP Business Workflow asits business solution for the �Material Master Change� business process.

First Technical ViewThere are some important changes in the workflow architecture to make the use ofclasses possible:

� SAP Business Workflow now supports two object repositories:

� SWO1 (Business Object Repository)� SE24 (Class Builder)

� Persistent object keys now have three components:

� Object category (CATID)� Object type (TYPEID)� Object key (INSTID)

� Both repositories are equally well supported:

� But: There is no delegation feature for ABAP Objects� SE24 support covers the same aspects as BOR support:

� Container, Expressions, Methods and Events

The main developing area to create workflow functions still is the Business ObjectRepository (see explanations in the previous lesson). To create class functions,you have to use a generic (cross component) tool called the Class Builder.

8 © 2008 SAP AG. All rights reserved. 2008

Page 17: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Technical View and Business Example

The class builder is not workflow specific, so you have to develop workflowfunctions in the borders of the object oriented approach it represents.

One important change in handling business objects is that the broadened persistentobject key now includes the category (BOR or ABAP Objects), the type (BORobject type or ABAP class name) and the key.

Figure 3: Business Object / ABAP Classes Comparison

Steps in process definitions contain, in most cases, object methods that will beinvoked at runtime to execute application logic. At runtime, the workflow engineexecutes the processes, determines the relevant steps and invokes the methodsof each step.

In general, the methods invoked by the workflow engine, are based on businessobject types.

With Web AS 6.40, it is also possible to use methods of ABAP Classes.

One important aspect of workflow enabling a class is persistence management.Only persistent objects can survive the frequent context changes the workflowsystem encounters. For business objects, the Business Object Manager handlesthe variety of context changes as a �Black Box�.

In workflow classes, it is the main aspect of programming to implement sucha management.

Business Process ReviewMotor Sports International Business Process is a scenario that involves MaterialMaster change. The problem at MSI is the delayed notification when a materialchanges.

2008 © 2008 SAP AG. All rights reserved. 9

Page 18: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Figure 4: Motor Sports International - Business Process Review

The production line is not notified about the changes in time and continuesproducing what is eventually obsolete inventory. They have decided that SAPBusiness Workflow is their solution.

Main Business Scenario I

� The problem at MSI:The existing system at MSI could not notify thedesigner of relevant changes to material master records.

This communication gap led to a delay in adjusting the production line, whichin turn resulted in large quantities of obsolete and unwanted warehouse stock.

� Triggering:This business process always starts when a user changes the Old Materialfield in a material master record. The result of the change triggers aworkflow event (for example, OldMaterialChanged), which theninitiates one of two workflow processes.

The triggering event is actually initiated by a link to the change documents.As soon as you change the field from the value * to your group number ##,the OldMaterialChanged event is triggered.

� *Note:Tests at MSI have shown that this field is not used. Changes to its value areused to inform the designer of a relevant change to the material master.

10 © 2008 SAP AG. All rights reserved. 2008

Page 19: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Technical View and Business Example

The Main Business Scenario is based on a Material Master change. The ABAPObject class has to be implemented like the object type for Material Master:�BUS1001006� . The triggering event determined is OldMaterialChanged, and itis linked to Change Documents (transaction SWEC).

It is important to differentiate between synchronous and asynchronous edit (bothdo not exist). An Asynchronous edit method and task is needed to allow changesand/or updates that are terminated by raising a terminating event.

Main Business Scenario II

� Core process:As soon as a material is changed, a particular designer must be informed.The agent responsible is based on the Laboratory field.

After notification, the designer adjusts the production process to correspondto the change. To inform the workflow system that this work has beencompleted, the designer changes the Basic Material field of the relevantmaterial master.

This event is therefore a terminating event of an asynchronous task.

� *Note:Tests carried out during the project indicate that no one else uses the BasicMaterial field. A change to the value represents a status change.If the designer does not complete all activities within a specified timeinterval (for example, five minutes), the designer�s manager must beinformed of this delay.

As soon as the workflow system is notified that the designer has completedhis or her work, it sends a notification of completion, stating that the processis completed and that the material just changed can now return to production.The workflow determines who receives this notification (in practice, thiswould be implemented using rule resolution).

The process involves notifying the designer when a material is changed.The responsible agent for the first step is based on the Laboratory field(MARA-LABOR).

The company has also decided that Basic Material is also available to be usedfor a terminating event.

2008 © 2008 SAP AG. All rights reserved. 11

Page 20: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 1: Introduction BIT611

Necessary components of class (compare ZRGMARA)

� Attributes

� ChangedBy� IndustryName� PLANT� QMessages

� Methods

� Change (asynchronous)� DisplayView (parameter MaterialView)� CreateMaterialFormReference (parameter ReferenceMaterialNumber)

� Events

� BasicMaterialChanged� OldMaterialChanged� DeadlineTest (with parameter �LatestEndDate�)

Not all components called above are implemented in the following exercises dueto time constraints. However, all necessary functions will be shown.

12 © 2008 SAP AG. All rights reserved. 2008

Page 21: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Technical View and Business Example

Lesson Summary

You should now be able to:� Identify the main technical aspects of ABAP Classes and BOR� Analyze the Business Process� Compare the business object components (available) with the ABAP class

components needed

2008 © 2008 SAP AG. All rights reserved. 13

Page 22: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit Summary BIT611

Unit SummaryYou should now be able to:� Repeat the main points of SAP Business Workflow architecture.� Recognize the components of SAP Business Workflow that enable or require

programming by the user.� Compare and contrast ABAP classes and business object types used in

workflow development.� Identify the main technical aspects of ABAP Classes and BOR� Analyze the Business Process� Compare the business object components (available) with the ABAP class

components needed

14 © 2008 SAP AG. All rights reserved. 2008

Page 23: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2ABAP Classes Definition and

Implementation

Unit OverviewThis unit provides a short description of the underlying concepts of ABAPClasses for SAP Business Workflow and explains the definition of a class and itscomponents in detail.

You will learn how attributes and methods are defined and implemented. You willalso learn how to implement exceptions in methods, and how parameters arecalled and returned in method processing.

The final part of the unit covers access to attributes and calling methods insideand outside the BOR, and performance recommendations for implementing anobject type.

Unit ObjectivesAfter completing this unit, you will be able to:

� Explain the basic technical concepts of ABAP Object classes in SAPBusiness Workflow

� Classify some important concepts of object-oriented programming� Create a class� Create instance handling required for workflow engine� Define key fields� Define attributes with a database reference� Define �virtual attributes�, like values� Define multiline attributes� Describe how object references are addressed in the BOR and the workflow

Unit ContentsLesson: Underlying Concepts of ABAP Object Classes in SAP BusinessWorkflow .... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17Lesson: Class Definition - Instance Handling and Key Fields ... . . . . . . . . . . 29

Exercise 1: Create a Class with Instance Handling.. . . . . . . . . . . . . . . . . . . . 41

2008 © 2008 SAP AG. All rights reserved. 15

Page 24: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Lesson: Class Definition - Attributes and Methods .. .. . . . . . . . . . . . . . . . . . . . . . . 53Exercise 2: Create Attributes for Workflow Class .. . . . . . . . . . . . . . . . . . . . . . 65Exercise 3: Create Methods for Workflow Class .. . . . . . . . . . . . . . . . . . . . . . . 79

16 © 2008 SAP AG. All rights reserved. 2008

Page 25: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

Lesson: Underlying Concepts of ABAP Object Classesin SAP Business Workflow

Lesson OverviewIn general, the methods invoked by the workflow engine are based on object types(BOR). The workflow engine is also able to invoke methods of ABAP classes.This lesson describes the underlying technical concepts of ABAP Object classesfor SAP Business Workflow.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Explain the basic technical concepts of ABAP Object classes in SAPBusiness Workflow

� Classify some important concepts of object-oriented programming

Business ExampleYou have introduced workflow techniques in your company and now need toinsert functions from your customer-based add-ons, where standard object typesare not sufficient for your requirements. The developers in your company arefamiliar in programming ABAP Objects and most of the add-on functions arebased on this language.

Classes in SAP Business WorkflowClasses have to encapsulate the application data (tables) and actions that can beperformed on this data (such as transactions, reports and function modules) bythe workflow engine. Because the workflow engine has to handle all objects in auniform way, this means, the class has to react in the exact way like its businessobject type pendant.

2008 © 2008 SAP AG. All rights reserved. 17

Page 26: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 5: Objects / Classes - Purpose

A class instance defines a stable, extendable �business� view. Users of the instanceare not affected by changes to the underlying database tables, transactions, reportsand so on, by using standard interface components like attributes, methods andevents. The class handles the functional changes internally by implementingappropriate changes for all of its users. This encapsulation has the followingadvantages:

� Simple modeling of processes� Stable processes with a high degree of reusability� On a technical level: A standard calling interface for the workflow runtime

system

18 © 2008 SAP AG. All rights reserved. 2008

Page 27: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

Since the engine stores information about the process' state, steps and relatedobjects in database tables, it must be able to convert references to instances ofABAP classes to a representation that can be saved (and vice versa: it must bepossible to create an instance of an ABAP class from a previously stored persistentrepresentation).

� Methods

� In tasks: Define the �core� of an activity� In steps: Before methods, after methods and secondary methods

� Attributes

� Conditions: Branches, loops, parallel processing forks, conditionsbefore and after steps

� Container operation, binding, agent assignment, deadlines� Events

� Start workflows, end steps� Create event, wait for event

Use of methods in steps (methods can change object data)

� The �main method� of an activity is encapsulated in a task so that it can bereused.

� Before, after and secondary methods define subordinate or parallel activitiesand are directly specified at a particular step.

Use of attributes (access to object attributes in the workflow is always read-only)

� Values are used for process control or transferred as parameters on themethod.

� You can query attributes in your own modules in programming exits(check type function modules, programmed binding, receiver type functionmodules).

Use of events:

� Events are created for communicating between the application and theworkflow system or for communicating different workflows.

� The Wait for Event prompt (for example, �Wait until a specific document isreleased?�) is used for synchronizing processes or parts of a process. Forexample, �Wait until a particular document is released.�. The user is thennotified of the release by an event.

2008 © 2008 SAP AG. All rights reserved. 19

Page 28: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 6: Class - Definition in Class Builder

The Class Builder (SE24) is a client-independent directory of all defined ABAPObject classes. Each class is assigned to a development class and therefore, is alsoindirectly assigned to an application component.

Key fields provide a unique reference between an object type and a database table(or a view). Each object instance is clearly displayed in a row in the table specified.

Two types of Attribute can be can be created:

� Database attribute (attribute value is contained in the specified database table)� Virtual attribute (source text is run to determine the value)

Methods are implemented using transactions, BAPIs, reports and so on.Depending on the implementation, methods are classified according totheir processing model (synchronous/asynchronous) or interaction model(dialog/background).

Events are only declared in the class (both their names and parameters aredeclared). Events are triggered and received using other tools.

Interfaces

Interfaces differ from regular inheritance in their area of use. In terms ofprogramming, there are hardly any differences, however. From a technical pointof view, interfaces are simply superclasses that cannot be instantiated, do not havean implementation part, and only have public components.

20 © 2008 SAP AG. All rights reserved. 2008

Page 29: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

In ABAP Objects, interfaces primarily serve to define uniform interfaces(protocols) for services. Various classes can thus offer (implement) these servicesin different ways, but keep the same semantics. Interfaces therefore contain noimplementations.

To recognize the semantic differences from regular inheritance, you canconcentrate on the following, typical use cases:

Figure 7: Central Definition of Shared Components

For example, you want to allow for the option of having multiple classesimplementing a service in different ways, but using the same method names andwith a uniform signature. With regular inheritance, you would define such amethod in the shared superclass.

However, if you cannot model a superclass suitably for inheritance, you need todefine an interface and then define this method there. Therefore, you can comparethis case with a generalization relationship with a superclass.

Development Support for Creating a classTo be able to use an object of an ABAP class with the workflow engine, the classhas to implement the interface �IF_WORKFLOW�. This interface provides a totalof six different methods which cover the requirements from workflow architecture(see below).

2008 © 2008 SAP AG. All rights reserved. 21

Page 30: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 8: Interface � IF_WORKFLOW

Be aware that classes implementing IF_WORKFLOW can be used in anyworkflow by any workflow modeler. This means that a class, implementing thisinterface, has automatically status �released� (compare with behavior of BORobjects!).

As a first conclusion, such a class should only be changed in a compatible waythat does not invalidate existing users (never delete attributes, change methods inan upward compatible way). There is no �where used list� that shows in whichworkflow a class is used: you should always assume that there are unknown usersof your class in some subsequent systems or at the customer�s site.

The second conclusion is that �your� (internal) classes should not implementinterface IF_WORKFLOW. To protect internal classes, it is better to usewrapper classes that implement IF_WORKFLOW. These wrapper classeswould be constructed especially for use within workflow and could provide aprocess-specific subset of methods and attributes of your internal class.

22 © 2008 SAP AG. All rights reserved. 2008

Page 31: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

Figure 9: Interface � BI_PERSISTENT

One important aspect of workflow-enable a class is persistence management. Asmentioned before, only persistent objects can survive the frequent context changesthe workflow system encounters.

If you want to convert a persistent saved display of an object into an instance ofthe corresponding ABAP class, the workflow engine calls the FIND_BY_LPORmethod. The LPOR method is the counterpart to the FIND_BY_LPOR method. Itprovides the persistent display for an existing instance of an ABAP object.

The workflow engine calls the REFRESH method when the system has to ensurethat all values of an object are valid or that they correspond exactly with thepersistent display of the object.

2008 © 2008 SAP AG. All rights reserved. 23

Page 32: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 10: Interface � BI_OBJECT

Different Workflow tools (inbox, workflow log, and so on) display objects thatare attached to processes or process steps. In general, the object key is used torepresent the object. If these tools should use a value different from the object key(for example, a descriptive text) to represent an object instance, then the objectitself has to provide the value.

The method DEFAULT_ATTRIBUTE_VALUE is used to get this value from anobject. If this method doesn't return any value, the object key will be used as thedisplay attribute.

The tools that represent objects in a textual way (for example, workflow inbox)by displaying their default attribute also allow to navigate to an object byclicking on that default value. Since the generic tools cannot know how tonavigate to a given object (which may be of some user-defined class), thesystem calls a generic method that implements this navigation. This method isEXECUTE_DEFAULT_METHOD.

By calling the RELEASE method, an application can signal that it no longer needsthe given object. The instance could therefore be removed from the instancemanagement as soon as the last reference to this object is released. This enablesthe garbage collector to free the related memory.

24 © 2008 SAP AG. All rights reserved. 2008

Page 33: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

Additional Concepts of the Object-OrientedProgramming Model

Figure 11: Additional Concepts of the Object-Oriented Programming Model

� InheritanceInheritance defines the implementation relationships between classes,so that one class (the subclass) adopts the structure and behavior ofanother class (superclass), possibly also adapting or extending it.

� PolymorphismIn object-orientation, polymorphism is when instances of differentclasses respond differently to the same messages.

� Event controlInstead of sending messages directly to specific objects, objects canalso trigger events. Events can be triggered if it is not yet known at thetime of development if objects will react, and if so, how they will react.

Use customer-specific object extensions

2008 © 2008 SAP AG. All rights reserved. 25

Page 34: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Caution: Before SAP NetWeaver 7.0, it was not possible to extendclasses like business object types. The only way, to implement customerspecific object extensions in SAP classes, is to use explicit enhancementpossibilities (User-Exits, BAdIs, and so on) delivered in the standardprogramming.

There is no technique like delegation in ABAP classes for SAP BusinessWorkflow.

With SAP NetWeaver 7.0, some new enhancement options have been added:

Enhancement Points and Enhancement Sections.

The most interesting fact is that customer enhancements with such �implicit�enhancement points (in contrast to the old fashioned way) do not need to beprepared by SAP.

An enhancement point is a possibility to add (without modification) source code,variable- and parameter- declarations in SAP-programs, function modules andclasses.

Explicit enhancement points are SAP prepared extension possibilities inapplication programming, while implicit enhancement points exits standardized atdefinite places in SAP programming syntax, that means, without SAP preparation:

� at the beginning and end of methods of local/global classes� at the end of the importing/exporting/changing declaration area of methods

of local classes� at interface definitions of methods of global classes� at the end of public/protected/private section of local classes (to define

additional attributes and methods)� you can add additional attributes and methods to global classes

Hint: Classes Without Multiple Instantiation (Singleton Pattern):

There are many cases (but not the workflow one) in which you need toprevent a class from being instantiated more than once for each programcontext. You can do this using the singleton concept.

The class is defined with the additions FINAL and CREATE PRIVATEand is instantiated using its static constructor.

The singleton concept is not a commencement to develop workflow relatedfunctions. You need to use classes in workflow architecture with multipleinstances, so an only once instantiated class construct is not fitting.

26 © 2008 SAP AG. All rights reserved. 2008

Page 35: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Underlying Concepts of ABAP Object Classes in SAP Business Workflow

Hint: Persistent Objects with ABAP Objects

In principle, ABAP programs work with data and objects that are valid atruntime. They are transient (temporary) and disappear when the programends. If this data is to be stored permanently and independently of theprogram (persistently) it must be stored in a database.

For this purpose, the Persistence Services for ABAP Objects wereintroduced in the SAP Web AS 6.10. On request, these services write thecurrent attribute values of objects defined as persistent to the associatedtransparent tables. On receiving another request, they import these valuesfrom the tables again, and write the attributes to an object previouslydefined as persistent.

2008 © 2008 SAP AG. All rights reserved. 27

Page 36: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Lesson Summary

You should now be able to:� Explain the basic technical concepts of ABAP Object classes in SAP

Business Workflow� Classify some important concepts of object-oriented programming

28 © 2008 SAP AG. All rights reserved. 2008

Page 37: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Lesson: Class Definition - Instance Handling and KeyFields

Lesson OverviewThis lesson explains how to create a class, and define its key fields and attributes.An essential function of a class, used in workflow, is its instance handling. Thislesson describes the form in which the classes must be available to workflowruntime.

Attributes of classes can refer to all kinds of data types, because their values areset by the methods of the class. There is no difference in attribute properties, likein object types (database fields, virtual attributes - database references, objectreferences).

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Create a class� Create instance handling required for workflow engine� Define key fields

Business ExampleYou have introduced workflow techniques in your company and now need toinsert functions from your customer-based add-ons, where standard object typesare not sufficient for your requirements.

First, create the class and define the key fields and the required attributes.

Instance handling in classes for SAP BusinessWorkflowThe persistent representation of an object can appear in different processes or atdifferent places within one process. The workflow engine itself does not providean instance manager that detects if an object has already been instantiated in thecurrent context (for BOR objects, this is a feature of the corresponding objectmanager).

2008 © 2008 SAP AG. All rights reserved. 29

Page 38: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 12: Persistent vs. Runtime

Having two instances of the same object may lead to unexpected behavior, forexample:

� in particular if the object data is changed within that context� mutual locking� one instance overwrites data the other has just written� inconsistent data display of the �older� instance

Furthermore, creating instances from persistent representations are oftenperformance critical, since operations like an existence-check, initialization, andso on may require elaborate actions.

Interface BI_PERSISTENT

The following example demonstrates, how an instance management could berealized. This example uses a private attribute that keeps all created instances andtheir persistent representation:

30 © 2008 SAP AG. All rights reserved. 2008

Page 39: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Figure 13: Instance Handling

Instance management is automatic for business objects. The workflow engine usethe Business Object Manager for these purposes. ABAP classes have also thepossibility to handle its instances automatically.

Hint: To be able to work with ABAP Objects persistently, the �persistenceservice� was introduced with SAP R/3 Basis Release 6.10. Objects andtheir attributes can be written to the database and re-imported.

However, the concept of persistent ABAP classes is not flexible enough to handleworkflow instances, so you usually handle the persistence of these objects in theclass itself (as described in the following sections):

Figure 14: Object References handled in Classes

2008 © 2008 SAP AG. All rights reserved. 31

Page 40: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

The only input parameter of the following persistence handling method is apersistent object reference, a structure of type SIBFLPOR (POR = PersistentObject Reference). This structure consists of three components:

� CATID

Contains an indicator (a �category ID�) describing what kind of object isrepresented. Since the Workflow Engine handles BOR Objects and ABAPClasses, the system must be able to distinguish between these two objectcategories.

It contains �BO� for BOR object and �CL� for an ABAP class.

� TYPEID

Contains the name of the object type (for example, the ABAP class) thatshould be instantiated.

� INSTID

The key of the object. This field is restricted to 32 characters

Figure 15: Implementation � FIND_BY_LPOR

It could therefore be useful to manage already instantiated objects within the class,to make sure that different calls of FIND_BY_LPOR will all return a pointerto the same instance. Changes on this instance, which are done by a client areimmediately visible to all other clients.

METHOD bi_persistent~find_by_lpor.

*- method parameter LPOR is the persistent object reference

*- LPOR = Local Persistent Object Reference

32 © 2008 SAP AG. All rights reserved. 2008

Page 41: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

* begin of local data

DATA: l_standardmaterial TYPE REF TO zbit611_... . " reference to class instance

DATA: l_matnr TYPE mara-matnr. " key field

DATA: ls_instance TYPE t_instance. " instance handling

* end of local data

* Check if LPOR is filled

CHECK lpor-instid IS NOT INITIAL.

* instid is the key of the object

l_matnr = lpor-instid.

* read mst_instances into ls_instance to test, if instance already exists

READ TABLE mst_instances WITH KEY number = l_matnr

INTO ls_instance.

* if no result is found

IF sy-subrc NE 0.

* create object l_standardmaterial with key l_matnr and catch exception

* if exception is raised, exit the method

TRY.

CREATE OBJECT l_standardmaterial

EXPORTING

im_matnr = l_matnr

.

CATCH cx_bo_error .

EXIT.

ENDTRY.

* load l_matnr and l_standardmaterial in ls_instance and append the structure

* to table mst_instances

ls_instance-number = l_matnr.

ls_instance-instance = l_standardmaterial.

APPEND ls_instance TO mst_instances.

* endif of no result is found

ENDIF.

* load ls_instance-instance into result

result = ls_instance-instance.

ENDMETHOD.

2008 © 2008 SAP AG. All rights reserved. 33

Page 42: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

The method coding uses the class name and object key passed in the LPORparameter to create an ABAP object instance. Depending on the persistence modelchosen for this ABAP class, the instance data could be loaded right away or couldbe loaded later (on demand).

Method LPOR is the counterpart of FIND_BY_LPOR:

Figure 16: Implementation � LPOR

FIND_BY_LPOR receives a persistent representation of an object reference andreturns a �live� ABAP instance. LPOR is called on the live instance and returnsthe persistent object reference for that instance.

There is a close relationship between these two methods: by first callingFIND_BY_LPOR for a persistent reference to get an instance, and then callingLPOR on this instance, you should get back to the persistent reference that youstarted out with.

If an instance manager is used, as in the FIND_BY_LPOR example above, codingof the following type could be used:

METHOD bi_persistent~lpor.

DATA: ls_instance TYPE t_instance.

READ TABLE mst_instances WITH KEY object = me

INTO ls_instance.

IF sy-subrc = 0.

* return the persistent representation

result = ls_instance-lpor.

ELSE.

* instance not found... create the persitent representation

* an other way

34 © 2008 SAP AG. All rights reserved. 2008

Page 43: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

...

ENDIF.

ENDMETHOD.

There are also several ways of implementing this method in this case. There is animplementation example in the CL_SWF_FORMABSENC demo class.

Figure 17: Implementation - REFRESH

Depending on how the class organizes its own delta handling, the implementationof the method may remain empty. The method is called by the workflow engine,whenever the system has to make sure that the internal values of the object arevalid , that is, in sync with the persistent image. If required, reload the objectinstance data from database in this method:

METHOD read_attributes.

* get public attributes... (DDIC)

* load table mara

SELECT SINGLE * FROM mara INTO m_mara

WHERE matnr = me->matnr.

me->materialgroup = me->m_mara-matkl.

me->materialtype = me->m_mara-mtart.

...

* call table makt and m_makt

SELECT SINGLE * FROM makt INTO m_makt

WHERE matnr = me->matnr

AND spras = sy-langu.

2008 © 2008 SAP AG. All rights reserved. 35

Page 44: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

* load field maktx of structure m_makt into

* class attribute description

me->description = m_makt-maktx.

...

ENDMETHOD.

If this method is not needed by a class, the interface-method still needs some�empty� implementation to avoid dumps if the system calls this method. Inthis case, just enter the METHOD ... ENDMETHOD statements (withoutimplementation in between) as coding.

Object Functions Handling in ClassesInterface BI_OBJECT

Figure 18: Implementation � DEFAULT_ATTRIBUTE_VALUE

This example demonstrates how this method could be implemented. The exampleassumes that the class has an instance attribute DESCRIPTION that is to be usedto identify the object. The statement GET REFERENCE OF is used to return apointer to the DATA-Object (REF TO DATA) rather than the data object itself.

Even if a class does not return a specific default value (thus indicating that theobject key will be used), the interface method DEFAULT_ATTRIBUTES_VALUEstill needs some �empty� implementation to avoid dumps if the system calls thismethod. In this case, just enter the METHOD ... ENDMETHOD statements(without implementation in between) as coding.

36 © 2008 SAP AG. All rights reserved. 2008

Page 45: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Figure 19: Implementation � EXECUTE_DEFAULT_METHOD

The tools that represent objects in a textual way (for example, workflow inbox)by displaying their default attribute, also allow you to navigate to an object byclicking on that default value. Since the generic tools cannot know how tonavigate to a given object (which may be of some user-defined class), the systemcalls EXECUTE_DEFAULT_METHOD, which implements this navigation.

The example above demonstrates, how this method could be implemented. Itexpects that the class has a method DISPLAY that shows a dialog for an instanceof this class. For many existing business objects, this method is implementedsimply by calling the standard display transaction:

METHOD DISPLAY.

*- begin of local data

DATA: ls_return TYPE bapiret1.

*- end of local data

CALL FUNCTION 'BAPI_MATERIAL_DISPLAY'

EXPORTING

material = me->matnr

IMPORTING

return = ls_return

.

CASE ls_return-number.

WHEN '000'.

2008 © 2008 SAP AG. All rights reserved. 37

Page 46: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

WHEN '262'.

RAISE EXCEPTION TYPE cx_bo_error.

WHEN '305'.

RAISE EXCEPTION TYPE cx_bo_error.

WHEN OTHERS.

ENDCASE.

ENDMETHOD.

If a class does not have a default method, the interface method still needssome �empty� implementation to avoid dumps if the system calls the method.In this case, just enter the METHOD ... ENDMETHOD statements (withoutimplementation in between) as coding.

By calling the method RELEASE, an application can signal that it no longer needsthe given object. The instance could therefore be removed from the instancemanagement as soon as the last reference to this object is released. This enablesthe garbage collector to free the related memory.

Most classes will not implement this method. Nevertheless, an �empty�implementation is required to avoid dumps if the method is called by the system.

Key fieldsClasses implementing interface IF_WORKFLOW are recognized by transactionSE24 as �Workflow� enabled: such a class can declare attributes as key fields. Ifkey attributes are specified, the system can provide different services, for example,generic dialogs to find an instance.

38 © 2008 SAP AG. All rights reserved. 2008

Page 47: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Figure 20: Implementation of Key Fields

If an object type specifies multiple key fields, the order is the same as displayed inthe class builder.

All specified key fields must be character fields (elementary types CHAR,NUMC, DATS or TIMS) with fixed length. Furthermore, the total length whenconcatenating all key attributes must not exceed 32 characters. The reason for thisrestriction is that the length of the field INSTID of the persistent representation foran object has a length of 32.

For general ABAP classes implementing IF_WORKFLOW, it is of course alsopossible to use a character guid (GUID32) as the type of the key field (in thiscase, only one key field is possible). Applications that internally use raw-guids(GUID16) should define the key field as an (additional) character guid field anmove the raw-guid to this attribute in the constructor.

2008 © 2008 SAP AG. All rights reserved. 39

Page 48: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

40 © 2008 SAP AG. All rights reserved. 2008

Page 49: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Exercise 1: Create a Class with InstanceHandling

Exercise ObjectivesAfter completing this exercise, you will be able to:� Create a class for use in the workflow architecture� Implement instance handling for the workflow engine� Define key fields

Business ExampleYour company has developed some add-ons to the standard business scenarios ofthe SAP ERP system. These extensions are implemented in an ABAP Object.

To gain experience with the techniques of inserting these functions in the workflowarchitecture, someone has to test the possibilities. You have the task of creatingsome ABAP class functions as examples for your colleagues.

We want to create functions like these encapsulated in the BOR object typeBUS1001006.

Hint: Please be aware that you have to be an experienced developer toimplement all following functions in the given exercise time.

You could also copy some coding from the example implementation ofclass ZBIT611_MARA. Please use this possibility if you do not haveenough time or you are not an experienced developer.

Task:Create a new class for use in the workflow architecture.

Caution: If you create the following class, a warning like �Implementationmissing for method "BI_OBJECT~RELEASE" . . � could appear.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create a new class ZBIT611_##, where ## represents your group number.Complete the basic data of this class as follows:

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 41

Page 50: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Object type: ZBIT611_## (Class)Description: Class Group ## (Material)Package: Z001

Use the IF_WORKFLOW interface to define the standard behavior ofyour class.

2. Enter the key fieldMaterial Number into class ZBIT611_##.

3. Develop the �Instance Handling� of your class. You need to implementsome types and attributes to administer the class instances, and you haveto program FIND_BY_LPOR an LPOR method.

To call the CONSTRUCTOR method in a object oriented way, please createan import parameter, like the key field inserted above, for this function. Alsomaintain an exception to handle within this method.

4. To finish the implementation of the �Instance Handler� functions, insert thenecessary code in the CONSTRUCTOR method.

There are some functions, which have to be handled in this method:

- the assignment of import variable to key field of class- calling of the existencecheck method- set the initial values of the class reference for handling in workflow

The existencecheck method has to be implemented (part of the nextexercise), so please set coding (read single entry from leading database table)at first in the constructor method itself.

Also calling the functions to set initial values of workflow class is part ofa later exercise.

5. Test your implementation by using the �Test� button (F8).

42 © 2008 SAP AG. All rights reserved. 2008

Page 51: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

Solution 1: Create a Class with InstanceHandlingTask:Create a new class for use in the workflow architecture.

Caution: If you create the following class, a warning like �Implementationmissing for method "BI_OBJECT~RELEASE" . . � could appear.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create a new class ZBIT611_##, where ## represents your group number.Complete the basic data of this class as follows:

Object type: ZBIT611_## (Class)Description: Class Group ## (Material)Package: Z001

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 43

Page 52: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Use the IF_WORKFLOW interface to define the standard behavior ofyour class.

a) To create a class, navigate to the class builder:Tools→ BusinessWorkflow → Development → Definition Tools → ApplicationIntegration→ Class Builder (SE24)

Insert class name ZBIT611_## and press the �Create� Button.

In the next dialog, check selection �Class� and press Enter (F8).

In the next dialog, enter the description Class Group ## (Material)

Check the following parameters and press Enter (F8):

Instantiation: PublicClass Type: Usual ABAP ClassOnly Modeled: -> no entryFinal: 'X'

b) Go to the tab �Interfaces� and insert interface IF_WORKFLOW.Press enter.

The following entries should appear:

BI_OBJECTBI_PERSISTENTIF_WORKFLOW

Save your class (Ctrl + S).

Continued on next page

44 © 2008 SAP AG. All rights reserved. 2008

Page 53: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

2. Enter the key fieldMaterial Number into class ZBIT611_##.

a) Use the business object type BUS1001006 as an exampleimplementation to compare features of your class with some existingcode.

b) Go to the tab �Attributes� and insert the following properties into firstline:

Attribute: MATNRLevel: Instance AttributeVisibility: PublicKey Attribute: 'X'Read-Only: 'X'Typing: TypeAssociated Type: MARA-MATNRDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

3. Develop the �Instance Handling� of your class. You need to implementsome types and attributes to administer the class instances, and you haveto program FIND_BY_LPOR an LPOR method.

To call the CONSTRUCTOR method in a object oriented way, please createan import parameter, like the key field inserted above, for this function. Alsomaintain an exception to handle within this method.

a) Call Edit -> Create Constructor and mark the created entry in tab�Methods�. Press the �Parameters� Button and insert the followingproperties into first line:

Parameter: IM_MATNRPass Value: -> no entryOptional: -> no entry

Typing Method: TypeAssociated Type: MARA-MATNRDefault Value: -> not requiredDescription: -> set automatically

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 45

Page 54: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Save your class (Ctrl + S).

b) To handle the raised exceptions of this method, insert exception class�CX_BO_ERROR� in the exception list of the CONSTRUCTORmethod (tab �Exceptions�).

Exceptions are theme of chapter 3, however it is necessary to handle afailed constructor method. Please insert the information as describedand wait for an explanation until chapter 3.

c) Go to the tab �Types� and insert two entries T_INSTANCE andT_INSTANCES with Visibility �Private�.

Press the �Direct Type Entry� button (after column Associated) anddeclare the types in next GUI as follows:

TYPES:

BEGIN OF t_instance,

number TYPE mara-matnr,

instance TYPE REF TO zbit611...,

END OF t_instance .

TYPES:

t_instances TYPE STANDARD TABLE OF t_instance .

Save your class (Ctrl + S) and navigate back into your class.

d) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: MST_INSTANCESLevel: Static AttributeVisibility: PrivateKey Attribute: -> no entryRead-Only: -> no entryTyping: TypeAssociated Type: T_INSTANCESDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

e) Go to the tab �Methods� (with the 'Back to methods' button) and doubleclick the BI_PERSISTENT~FIND_BY_LPOR method. Implementthe coding as shown in the following example.

Continued on next page

46 © 2008 SAP AG. All rights reserved. 2008

Page 55: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

If you want to compare your coding, please call the implementation ofclass ZBIT611_MARA!

METHOD bi_persistent~find_by_lpor.

DATA: l_standardmaterial TYPE REF TO zbit... . " reference of object

DATA: l_matnr TYPE mara-matnr. " key field

DATA: ls_instance TYPE t_instance. " instance handling

* Check if LPOR is filled

CHECK lpor-instid IS NOT INITIAL.

* instid of import parameter LPOR is object key

l_matnr = lpor-instid.

* ??? instance already exists ???

READ TABLE mst_instances WITH KEY number = l_matnr

INTO ls_instance.

* if no result found

IF sy-subrc NE 0.

* create object l_standardmaterial

TRY.

CREATE OBJECT l_standardmaterial

EXPORTING

im_matnr = l_matnr

.

CATCH cx_bo_error .

EXIT.

ENDTRY.

* append result to mst_instances

ls_instance-number = l_matnr.

ls_instance-instance = l_standardmaterial.

APPEND ls_instance TO mst_instances.

ENDIF.

* fill result

result = ls_instance-instance.

ENDMETHOD.

Save your class (Ctrl + S).

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 47

Page 56: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

f) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: M_PORLevel: Instance AttributeVisibility: PrivateKey Attribute: -> no entryRead-Only: -> no entryTyping: TypeAssociated Type: SIBFLPORDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

g) Go to the tab �Methods� (with the 'Back to methods' button) and doubleclick the BI_PERSISTENT~LPOR method. Implement the coding asshown in the following example.

If you want to compare your coding, please call the implementation ofclass ZBIT611_MARA!

METHOD bi_persistent~lpor.

* fill attribute m_por

* could also be placed in the constructor

m_por-catid = 'CL'.

m_por-typeid = 'ZBIT611...'.

m_por-instid = me->matnr.

* load instance attribute m_por into result

result = m_por.

ENDMETHOD.

Save your class (Ctrl + S).

4. To finish the implementation of the �Instance Handler� functions, insert thenecessary code in the CONSTRUCTOR method.

There are some functions, which have to be handled in this method:

Continued on next page

48 © 2008 SAP AG. All rights reserved. 2008

Page 57: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

- the assignment of import variable to key field of class- calling of the existencecheck method- set the initial values of the class reference for handling in workflow

The existencecheck method has to be implemented (part of the nextexercise), so please set coding (read single entry from leading database table)at first in the constructor method itself.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 49

Page 58: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Also calling the functions to set initial values of workflow class is part ofa later exercise.

a) It is possible to use the existence check to fill the main table entry ofthe main application table into an attribute of your class.

Go to tab �Attributes� and insert a new line with the followingproperties:

Attribute: M_MARALevel: Instance AttributeVisibility: PrivateKey Attribute: -> no entryRead-Only: -> no entryTyping: TypeAssociated Type: MARADescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

b) Go to the tab �Methods� (with the 'Back to methods' button) and doubleclick the CONSTRUCTOR method. Implement the coding as shownin the following example.

If you want to compare your coding, please call implementation ofclass ZBIT611_MARA!

METHOD constructor.

* assignment of import variable to key field of class

matnr = im_matnr.

* calling of the existence check method

SELECT SINGLE * FROM mara INTO m_mara

WHERE matnr = me->matnr.

IF sy-subrc NE 0.

* DUMMY

ENDIF.

ENDMETHOD.

Save your class (Ctrl + S) and activate it.

Continued on next page

50 © 2008 SAP AG. All rights reserved. 2008

Page 59: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Instance Handling and Key Fields

5. Test your implementation by using the �Test� button (F8).

a) Press the �Test� button (F8).

b) Enter the material �T-BBD##� into the field IM_MATNR and pressthe �Instance� button.

c) A screen should be displayed, where you see the interfaces�BI_OBJECT�, �BI_PERSISTENT� and �IF_WORKFLOW�.

One attribute (the key field MATNR) should also be shown.

2008 © 2008 SAP AG. All rights reserved. 51

Page 60: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Lesson Summary

You should now be able to:� Create a class� Create instance handling required for workflow engine� Define key fields

52 © 2008 SAP AG. All rights reserved. 2008

Page 61: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Lesson: Class Definition - Attributes and Methods

Lesson OverviewIn business object types, attributes can refer to database fields, or they can bevirtual attributes whose content is determined at runtime, based on stored coding.

In classes, the value of attributes always set by methods (for example, in theconstructor). This lesson describes the main programming aspects in connectionwith the handling of class attributes in the workflow engine. It also describes theform in which attributes handle object references and multiline values and itsconjunctions to the runtime environment.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Define attributes with a database reference� Define �virtual attributes�, like values� Define multiline attributes� Describe how object references are addressed in the BOR and the workflow

Business ExampleYou have created a new customer-specific class and defined instance handling andkey fields. Now you want to create the attributes to be handled in the workflowengine and also the methods that you require.

You want the methods to be called using parameters, and return parameters andexceptions.

Definition of AttributesThe workflow engine provides the possibility to access all public attributes of anobject. There are no restrictions as to the data type of these attributes. All simpleABAP types and all DDIC types or references to other classes can be used.

The following attribute natures are developed (in business object types) to behandled in workflow engine (and should reflected by the class structures):

� database attributes - access to database tables� virtual attributes - calculation with user's own ABAP code� attributes typed either with an ABAP dictionary field or an object type / class� single-line and multiline attributes

2008 © 2008 SAP AG. All rights reserved. 53

Page 62: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

A Database Attribute is defined with reference to a column of the relatedapplication table. When the database is first accessed, you have the possibility toread the complete database row and buffer it in the class.

A Virtual Attribute is a special function of object types:

-> in classes you always have the possibility to calculate the values ofattributes with (your own) ABAP code by implementing it in the relevantmethods (SET_-method) and call them, for example, in the CONSTRUCTOR-> to get a behavior like �Virtual Attributes� in business object types - thecoding will be passed at runtime (when the workflow engine calls the virtualattribute) - a �Functional Method� (GET_-method) has to be implementedwith special properties (see below).

Some General Hints:

� Class attributes work like variables� They have to be set in CONSTRUCTOR method� They have to be refreshed in the BI_PERSISTENT~REFRESH method� It is recommended to flag them as read-only� Performance Note: Avoid complex attributes that are not always needed, as

this is executed for each instance whether the attribute is used or not

Database Attributes

Figure 21: Implementing Database Field Attributes

54 © 2008 SAP AG. All rights reserved. 2008

Page 63: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

The workflow engine provides the possibility to access all public attributes of anobject. There are no restrictions as to the data type of these attributes. All simpleABAP types and all DDIC-types or references to other classes can be used.

The necessary attributes should set in the CONSTRUCTOR method of class,because the workflow engine need the values when object instance is created.

To refresh attribute values, especially when business content of object ischanged, you have to implement the settings of the relevant attributes in theBI_PERSISTENT~REFRESH method.

Virtual Attributes

Figure 22: Functional Methods (Virtual Attributes) - Example

Hint: To simulate the behavior of Virtual Attributes you can useFunctional Methods:

� Method with one returning parameter� Can have importing but no exporting parameters� Naming convention: GET_

- for example, GET_EMAIL_ADDRESS� Returning parameter has to be named like virtual attributes - for

example, EMAIL_ADDRESS� Can be used in bindings and container operations

- Enhanced equivalent of BOR Virtual Attributes� Can NOT be used in Work Item Texts

- Bind to separate task container element in-stead

2008 © 2008 SAP AG. All rights reserved. 55

Page 64: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Virtual attributes have to be calculated if the workflow engine calls them in aprocess context. This behavior is a speciality of attributes from business objecttypes.

Normal class attributes are set with method functions in CONSTRUCTOR (or inREFRESH) method (see explanations above). To reach the �old� BOR behavior inclasses, the workflow engine interprets Functional Methods as Virtual Attributes.

ReferencesIf attributes have to be object references (ABAP Objects), then these classes arenot required to implement IF_WORKFLOW (it is required for the objects storeddirectly in the workflow context (container) but is not required for attributes ofthese objects).

The workflow system assumes that object valued attributes of a persistentobject will automatically be instantiated by the persistent class when itsFIND_BY_LPOR method is called - in other words, no instantiation automatismis invoked for attributes.

Figure 23: Implementing Class References

It is also possible to define attributes that point to BOR objects. Such attributeshave to be declared using the structure �SWOTOBJID� as the data type which theworkflow system recognizes as a persistent BOR object handle.

Such an attribute then points to �any BOR object�. To become more specific anddeclare your attribute as, for example a BOR object of type �BUS2012�, you needto provide an initial value in which you supply the object type.

56 © 2008 SAP AG. All rights reserved. 2008

Page 65: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Figure 24: Implementing Object Type References

METHOD set_... .

DATA: lt_porder TYPE swfborptab,

ls_porder TYPE swotobjid VALUE ' BUS2012'.

...

ENDMETHOD.

Caution: Structure SWOTOBJID is the BOR specific persistentrepresentation of an object. This structure consists of the fields LOGSYS,OBJTYPE, OBJKEY and DESCRIBE.

Here, �OBJTYPE� is the only field you have to fill.

Since we need to leave the field LOGSYS blank, the initial value of thisattribute starts with 10 spaces (for LOGSYS) followed by the object type�BUS1001006� in upper case.

2008 © 2008 SAP AG. All rights reserved. 57

Page 66: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

The above steps declare an attribute that represents a BOR object of a giventype. To initialize this attribute with a specific BOR object instance, you canuse the common BOR macros. This type of initialization is typically done inthe CONSTRUCTOR of your class.

Hint: In the �Local types� section of your class, under Goto ->Class-local types -> Local class implementations, you need the line:

INCLUDE <cntn03>.

Figure 25: INCLUDE <cntn03>

Hint: In the �Macros� section of your class, under Goto -> Class-localtypes -> Macros, you need the line:

INCLUDE <cntn02>.

Figure 26: INCLUDE <cntn02>

Using Attributes in ProcessesAttributes are typically accessed in workflow expressions like�&my_object.attribute&�. These expressions can occur in

� data binding� conditions� container operations� in any location, where the process or its steps can be dynamically configured

(for example, selection of responsible agent, deadlines, and so on)

Starting in release 6.30, an expression can also be used to synchronously call amethod. Therefore, attributes need not be exposed as public attributes, but canalso be accessed via GET_-methods.

58 © 2008 SAP AG. All rights reserved. 2008

Page 67: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Definition of MethodsIndividual steps that are executed by the workflow engine as part of businessprocesses, invoke methods of objects that are accessible within the processcontext. Since these objects can be implemented by ABAP classes, methods ofthese classes can be executed within a step.

Figure 27: Synchronous and Asynchronous methods

The methods implement business logic. They can invoke dialogs, they can runsynchronously or asynchronously, their execution (status) appears in the workflowlog, and so on.

In short, these methods have all the features that, in previous releases, werereserved for BOR methods.

2008 © 2008 SAP AG. All rights reserved. 59

Page 68: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Figure 28: Properties of Workflow Steps

There is one difference between BOR and Class methods. To define the behaviorof the workflow engine, you have to set some properties in BOR methods (asexample, dialog/background, synchronous/asynchronous).

Note: The BOR method properties are then pasted to the �Standard Task�properties automatically.

You do not have the possibility to define these properties to a Class method.Therefore, there is another place to set these properties in connection with theworkflow architecture (see figure above).

Note: You have to set the Class method properties in the �StandardTask� directly!

In general, only public methods can be invoked. These methods could be definedin different ways:

� defined at the class or one of its super-classes� included via interfaces

60 © 2008 SAP AG. All rights reserved. 2008

Page 69: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Methods defined at the class itself or one of its super-classes can always be useddirectly within the workflow engine. For methods that are included via interfaces,a restriction applies:

Hint: Since some methods included via interfaces are specified in the form�interface-name�~�method-name�,for example, IF_WORKFLOW~FIND_BY_LPOR.

The total length for a method name may exceed 30 characters (currentlythe maximum length for a method name that can be entered in a singlestep task).

If the method name gets too long, the class which includes the interfaceshould simply define an alias name for this method. One can then usea public alias name (when defining tasks, as well as, when definingexpressions) and avoid the length problem.

Parameters of Methods

In most cases, methods will have parameters (import-, export-, and so on). Whencalling a method in a step of a process, it is possible of pass values (for example,import parameters) or to receive values (for example, export parameters).

Since the workflow engine in some cases uses RFC ( calling methods inbackground - using an RFC - requires that all parameters can internally beserialized / deserialized) to call a method, the types of the method parametersare restricted to one of the following:

� Simple types (for example, string, integer, and so on)� Any DDIC type (for example, structures, tables, complex types) not

containing ABAP-OO references� BOR object references� References to ABAP classes that support the interface IF_WORKFLOW

2008 © 2008 SAP AG. All rights reserved. 61

Page 70: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Method parameters representing persistent objects could be defined in anyof the following ways:

� ABAP classes (implementing IF_WORKFLOW)

� TYPE SIBFLPORB

The object is passed using its persistent representation

� TYPE REF TO <classname>

The object is passed as object handle

� BOR objects

� TYPE SIBFLPORB

The object is passed using its persistent representation

� TYPE SWOTOBJID

the object is passed using its persistent representation that is only validfor BOR objects

Caution: Using one of the persistent object reference (POR) structureswill lead to parameters with an unspecified object type.

However, when one of the POR structures is used, the persistent referencecan be typed using initial values. There are more options to type apersistent object reference if these methods are used in tasks.

When defining a task that calls this method, the method parameters arereplicated into the task container. In that case, edit the task container andchange the object type of this parameter (element) to the concrete objecttype you need.

When you integrate this task into a workflow step later, the workflowbuilder will �see� only the correctly typed element in your task container.This way, you can make sure that only objects of a specific type can bepassed to the task (and hence to the method) through data binding inthe workflow.

62 © 2008 SAP AG. All rights reserved. 2008

Page 71: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Figure 29: Implementing the Return of Results

In defining BOR methods there is also a technique called �Return of Results�.Result parameters have an influence on the use of methods in workflow steps:

If the result parameter is defined with a data reference on a fixed value domain(such as CHAR1 with the fixed values �A�, �B� and �C�), the modeler receivesthree outputs with the name �A�, �B� and �C� in the Workflow Builder for thenew step when he or she incorporates a step based on this method.

When processing the workflow, the system always specifically selects the outputthat returns the method as a value for the result parameter.

To implement this feature please define a �Returning� parameter in methodinterface that contains a domain with an explicit maintained value range (see alsotable field SWXFORMABS-PROCSTATE with domain SWX_PROCST).

2008 © 2008 SAP AG. All rights reserved. 63

Page 72: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

64 © 2008 SAP AG. All rights reserved. 2008

Page 73: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Exercise 2: Create Attributes for WorkflowClass

Exercise ObjectivesAfter completing this exercise, you will be able to:� Define attributes with different references

Business ExampleYour company has developed some add-ons to the standard business scenarios ofthe SAP ERP system. These extensions are implemented in ABAP Objects.

To get experience with the techniques of inserting these functions in workflowarchitecture, someone has to test the possibilities. Your have the task of creatingsome ABAP class functions as examples for your colleagues.

We want to create functions like these encapsulated in the BOR object typeBUS1001006.

Hint: Please be aware that you have to be an experienced developer toimplement all following functions in the given exercise time.

You could also copy some coding from the example implementation ofclass ZBIT611_MARA. Please use this possibility if you do not haveenough time or you are not an experienced developer.

Task:To take advantage of class functions in the workflow architecture, you have toimplement some different types of attributes in your implementation. Please insertsome attributes with database and object reference and an attribute that refers to alist of purchase orders (also object references).

Caution: If you create the following class, you may see a warning like�Implementation missing for method "BI_OBJECT~RELEASE" . . �.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create a read_attributes method in your class to set all necessary attributesto handle within your class:

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 65

Page 74: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

- MATERIALGROUP- MATERIALTYPE- INDUSTRY- LABOR

Insert a call of this method in the BI_PERSISTENT~REFRESH method.

2. Create a set_description method to set a default attribute like the one inbusiness object types. It should contain the material number and the text(table MAKT).

To use this attribute, insert a call of it in the BI_OBJECT~DEFAULT_AT-TRIBUTE_VALUE method.

3. To execute the above developed methods at the right time (for workflowengine), you have to call it in the CONSTRUCTOR method.

4. Create a (virtual, single-line) get_actual_date attribute (functional method)to get the actual date and time when the virtual attribute is called fromworkflow engine.

Use the class CL_BSP_UTILITY for this purpose.

5. OPTIONAL:

Create a set_formabsenc method to set the result of a class attribute pointsto a reference of class CL_SWF_FORMABSENC.

6. OPTIONAL:

Create a set_purchaseorder method to set the result of a class attributepoints to a list of object references of object type BUS2012.

7. Test your implementation by using the �Test� button (F8).

66 © 2008 SAP AG. All rights reserved. 2008

Page 75: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Solution 2: Create Attributes for WorkflowClassTask:To take advantage of class functions in the workflow architecture, you have toimplement some different types of attributes in your implementation. Please insertsome attributes with database and object reference and an attribute that refers to alist of purchase orders (also object references).

Caution: If you create the following class, you may see a warning like�Implementation missing for method "BI_OBJECT~RELEASE" . . �.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create a read_attributes method in your class to set all necessary attributesto handle within your class:

- MATERIALGROUP- MATERIALTYPE- INDUSTRY- LABOR

Insert a call of this method in the BI_PERSISTENT~REFRESH method.

a) To change your class, navigate to the class builder:Tools→ BusinessWorkflow → Development → Definition Tools → ApplicationIntegration→ Class Builder (SE24)

Insert the class name ZBIT611_## and press the �Change� button.

b) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: MATERIALGROUPLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: Type

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 67

Page 76: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Associated Type: MARA-MATKLDescription: -> set automaticallyInitial Value: -> not required

Attribute: MATERIALTYPELevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: TypeAssociated Type: MARA-MTARTDescription: -> set automaticallyInitial Value: -> not required

Attribute: INDUSTRYLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: TypeAssociated Type: MARA-MBRSHDescription: -> set automaticallyInitial Value: -> not required

Attribute: LABORLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: TypeAssociated Type: MARA-LABORDescription: -> set automaticallyInitial Value: -> not required

Continued on next page

68 © 2008 SAP AG. All rights reserved. 2008

Page 77: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Save your class (Ctrl + S).

c) Go to the tab �Methods� and insert following entries in new line:

Method: READ_ATTRIBUTESLevel: Instance MethodVisibility: Private

Method type: -> no entryDescription: Read attributes from database tables

Save your class (Ctrl + S).

d) Double-click the READ_ATTRIBUTES method. Implement thecoding as shown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD read_attributes.

SELECT SINGLE * FROM mara INTO m_mara

WHERE matnr = me->matnr.

me->materialgroup = me->m_mara-matkl.

me->materialtype = me->m_mara-mtart.

me->industry = me->m_mara-mbrsh.

me->labor = me->m_mara-labor.

ENDMETHOD.

Save your class (Ctrl + S).

e) Go to the tab �Methods� and double click the BI_PERSISTENT~RE-FRESH method. Implement the coding as shown in the followingexample.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD bi_persistent~refresh.

read_attributes( ).

ENDMETHOD.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 69

Page 78: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Save your class (Ctrl + S).

2. Create a set_description method to set a default attribute like the one inbusiness object types. It should contain the material number and the text(table MAKT).

To use this attribute, insert a call of it in the BI_OBJECT~DEFAULT_AT-TRIBUTE_VALUE method.

a) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: M_MAKTLevel: Instance AttributeVisibility: PrivateKey Attribute: -> no entryRead-Only: -> no entryTyping: TypeAssociated Type: MAKTDescription: -> set automaticallyInitial Value: -> not required

Attribute: DESCRIPTIONLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: TypeAssociated Type: SYST-TITLEDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

b) Go to the tab �Methods� and insert following entries in new line:

Continued on next page

70 © 2008 SAP AG. All rights reserved. 2008

Page 79: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Method: SET_DESCRIPTIONLevel: Instance MethodVisibility: Private

Method type: -> no entryDescription: Set description

Save your class (Ctrl + S).

c) Double-click the SET_DESCRIPTION method. Implement the codingas shown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD set_description.

* call table makt and m_makt

SELECT SINGLE * FROM makt INTO m_makt

WHERE spras = sy-langu

AND matnr = matnr.

* load field maktx of structure m_makt into class attribute description

CONCATENATE 'Text zu' matnr ':' m_makt-maktx INTO description

SEPARATED BY space.

ENDMETHOD.

Save your class (Ctrl + S).

d) Go to the tab �Methods� and double-click the BI_OBJECT~DE-FAULT_ATTRIBUTE_VALUE method. Implement the coding asshown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD bi_object~default_attribute_value.

GET REFERENCE OF description INTO result.

ENDMETHOD.

Save your class (Ctrl + S) and activate it.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 71

Page 80: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

3. To execute the above developed methods at the right time (for workflowengine), you have to call it in the CONSTRUCTOR method.

a) Double-click the CONSTRUCTOR method. Implement the coding asshown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

me->read_attributes( ).

me->set_description( ).

Save and activate your class (Ctrl + S).

4. Create a (virtual, single-line) get_actual_date attribute (functional method)to get the actual date and time when the virtual attribute is called fromworkflow engine.

Use the class CL_BSP_UTILITY for this purpose.

a) Go to the tab �Methods� and insert following entries in new line:

Method: GET_ACTUAL_DATELevel: Instance MethodVisibility: Public

Method type: -> no entryDescription: Get actual date (as virtual attribute)

Save your class (Ctrl + S).

b) Press the �Parameters� button and insert a new line with the followingproperties:

Parameter: EX_ACTUAL_DATEType: ReturningPass Value: -> set automaticallyOptional: -> set automaticallyTyping Method: Type

Continued on next page

72 © 2008 SAP AG. All rights reserved. 2008

Page 81: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Associated Type: STRINGDefault Value: -> set automaticallyDescription: -> set automatically

Save your class (Ctrl + S).

c) Double-click the GET_ACTUAL_DATE method. Implement thecoding as shown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD get_actual_date.

DATA: lref_bsp_utility TYPE REF TO cl_bsp_utility,

lv_timestamp TYPE char14,

lv_result TYPE string.

CONCATENATE sy-datum sy-uzeit INTO lv_timestamp.

CALL METHOD cl_bsp_utility=>date_to_string_http

EXPORTING

timestamp = lv_timestamp

RECEIVING

result = lv_result.

actual_date = lv_result.

ENDMETHOD.

Save your class (Ctrl + S).

5. OPTIONAL:

Create a set_formabsenc method to set the result of a class attribute pointsto a reference of class CL_SWF_FORMABSENC.

a) Go to the tab �Methods� and insert following entries in new line:

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 73

Page 82: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Method: SET_FORMABSENCLevel: Instance MethodVisibility: Private

Method type: -> no entryDescription: Set object reference of class

CL_SWF_FORMABSENC

Save your class (Ctrl + S).

b) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: FORMABSENCLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: Type Ref ToAssociated Type: CL_SWF_FORMABSENCDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

c) Double-click the SET_FORMABSENC method. Implement the codingas shown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD set_formabsenc.

* Local Data

DATA l_formabsenc TYPE REF TO cl_swf_formabsenc.

* Create Object Reference

TRY.

CREATE OBJECT l_formabsenc

EXPORTING

im_number = '0000004980'

.

Continued on next page

74 © 2008 SAP AG. All rights reserved. 2008

Page 83: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

CATCH cx_bo_error .

EXIT.

ENDTRY.

* Fill class attribute

formabsenc = l_formabsenc.

ENDMETHOD.

Save your class (Ctrl + S).

d) Insert the just created method in the CONSTRUCTOR method.

6. OPTIONAL:

Create a set_purchaseorder method to set the result of a class attributepoints to a list of object references of object type BUS2012.

a) Go to the tab �Attributes� and insert a new line with the followingproperties:

Attribute: PURCHASEORDERLevel: Instance AttributeVisibility: PublicKey Attribute: -> no entryRead-Only: 'X'Typing: TypeAssociated Type: SWFBORPTABDescription: -> set automaticallyInitial Value: -> not required

Save your class (Ctrl + S).

b) Go to the tab �Methods� and insert following entries in new line:

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 75

Page 84: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Method: SET_PURCHASEORDERLevel: Instance MethodVisibility: Private

Method type: -> no entryDescription: Set object references of object type BUS2012

Save your class (Ctrl + S).

c) To get all functions referring to the macro language used to handlebusiness object types, you have to insert the following lines:

Hint: In the �Local types� section of your class, under Goto ->Class-local types -> Local class implementations, you needthe line:

INCLUDE <cntn03>.

In the �Macros� section of your class, under Goto ->Class-local types -> Macros, you need the line:

INCLUDE <cntn02>.

d) Double-click the SET_PURCHASEORDER method. Implement thecoding as shown in the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD set_purchaseorder.

DATA: lref_porder TYPE swc_object,

lt_tekdoc TYPE STANDARD TABLE OF ekdoc,

ls_tekdoc TYPE ekdoc,

lv_werks TYPE ekpo-werks.

DATA: lt_porder TYPE swfborptab,

ls_porder TYPE swotobjid

VALUE ' BUS2012'.

CLEAR lv_werks.

CALL FUNCTION 'ME_CHECK_DOCUMENT_FOR_MATERIAL'

EXPORTING

* EXISTENCE_CHECK = ' '

matnr = matnr

* PLANT_INITIAL = ' '

Continued on next page

76 © 2008 SAP AG. All rights reserved. 2008

Page 85: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

werks = lv_werks

* PLANT_INFO = ' '

* BWART =

* BWKEY =

* NO_ACCOUNT_ASSIGNED = ' '

* BMATN =

* MPROF =

* IF_SOBKZ =

* IF_VBELN =

* IF_VBELP =

* IF_PSPNR =

* IMPORTING

* CONTRACT_FLAG =

* DELPLAN_FLAG =

* INFO_FLAG =

* PO_FLAG =

* REQ_FLAG =

* RFQ_FLAG =

TABLES

xekdoc = lt_tekdoc

EXCEPTIONS

OTHERS.

.

LOOP AT lt_tekdoc INTO ls_tekdoc WHERE bstyp = 'F'.

swc_create_object lref_porder 'BUS2012' ls_tekdoc-ebeln.

swc_object_to_persistent lref_porder ls_porder.

APPEND ls_porder TO lt_porder.

ENDLOOP.

purchaseorder = lt_porder.

ENDMETHOD.

Save your class (Ctrl + S).

Caution: The Default Value of �LS_PORDER� should have10 spaces before the object type name (see also description inthe previous lesson).

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 77

Page 86: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

e) Insert the just created method in the CONSTRUCTOR method.

7. Test your implementation by using the �Test� button (F8).

a) Press �Test� Button (F8).

b) Enter the material �R-1003� in the field IM_MATNR and press the�Instance� button.

c) A screen should be displayed where you see the interfaces�BI_OBJECT�, �BI_PERSISTENT� and �IF_WORKFLOW�.

It should also show the above developed attributes.

78 © 2008 SAP AG. All rights reserved. 2008

Page 87: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Exercise 3: Create Methods for WorkflowClass

Exercise ObjectivesAfter completing this exercise, you will be able to:� Define methods with import and export parameters

Business ExampleYour company has developed some add-ons to the standard business scenarios ofthe SAP ERP system. These extensions are implemented in ABAP Objects.

To gain experience with the techniques of inserting these functions in workflowarchitecture, someone has to test the possibilities. You have the task of creatingsome ABAP class functions as examples for your colleagues.

We want to create functions like those encapsulated in the BOR object typeBUS1001006.

Hint: Please be aware that you have to be an experienced developer toimplement all following functions in the given exercise time.

You could also copy some coding from the example implementation ofclass ZBIT611_MARA. Please use this possibility if you do not haveenough time or you are not an experienced developer.

Task:To handle the basic functions of an object used in the workflow architecture,create in the some �ExistenceCheck� and �Display� methods.

The last part of this exercise should be the implementation of some methods withimport and export parameters.

Caution: If you create the following class, you may see a warning like�Implementation missing for method "BI_OBJECT~RELEASE" . . �.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create an �ExistenceCheck� method to validate the key structure, givenfrom the workflow engine.

It is only the call of main application table for business scenario and shouldnot have other code.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 79

Page 88: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

2. Create a �Display� method to display application data with the functionalityof BAPI_MATERIAL_DISPLAY.

To implement the behavior of the default method, insert a call of this methodin BI_OBJECT~EXECUTE_DEFAULT_METHOD method.

3. Create a �DisplayView� method with the Import Parameter �MaterialView�to display special application data. Use transaction MM03 and the necessarySET/GET parameter.

4. Create a �Change� method to change application data. Use transactionMM02 and necessary SET/GET parameter.

5. Test your implementation by using the �Test� button (F8).

6. OPTIONAL

Create a �Create� method with interface BAPI_STANDARDMATE-RIAL_CREATE. This is a static function, that means, it works withoutinstance.

7. OPTIONAL

You could also test some of your developed functions in standard task. Yet,this is part of last exercise of this course.

80 © 2008 SAP AG. All rights reserved. 2008

Page 89: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Solution 3: Create Methods for WorkflowClassTask:To handle the basic functions of an object used in the workflow architecture,create in the some �ExistenceCheck� and �Display� methods.

The last part of this exercise should be the implementation of some methods withimport and export parameters.

Caution: If you create the following class, you may see a warning like�Implementation missing for method "BI_OBJECT~RELEASE" . . �.

If so, please go into method implementation of called function and inserta line with a space betweenMETHOD ... . and ENDMETHOD. andsave the method.

1. Create an �ExistenceCheck� method to validate the key structure, givenfrom the workflow engine.

It is only the call of main application table for business scenario and shouldnot have other code.

a) Go to the tab �Methods� and insert following entries in new line:

Method: EXISTENCECHECKLevel: Instance Method

Visibility: Public

Method type: -> no entryDescription: Existence Check to verify data fromworkflow

engine

To handle the raised exceptions, insert exception �CX_BO_ERROR�in the exception list of the EXISTENCECHECK method (tab�Exceptions�).

Exceptions are theme of chapter 3, however it is necessary to handle afailed constructor method. Please insert the information as describedand wait for an explanation until chapter 3.

Save your class (Ctrl + S).

b) Double-click the EXISTENCECHECK method. Implement thecoding as shown in the following example.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 81

Page 90: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD existencecheck.

SELECT SINGLE * FROM mara INTO m_mara

WHERE matnr = me->matnr.

IF sy-subrc NE 0.

RAISE EXCEPTION TYPE cx_bo_error.

ENDIF.

ENDMETHOD.

Save your class (Ctrl + S).

c) Call EXISTENCECHECK method in the CONSTRUCTOR method:

METHOD constructor.

* assignment of import variable to key field of class

matnr = im_matnr.

TRY.

CALL METHOD me->existencecheck.

CATCH cx_bo_error.

EXIT.

ENDTRY.

...

ENDMETHOD.

Save your class (Ctrl + S).

2. Create a �Display� method to display application data with the functionalityof BAPI_MATERIAL_DISPLAY.

To implement the behavior of the default method, insert a call of this methodin BI_OBJECT~EXECUTE_DEFAULT_METHOD method.

a) Go to the tab �Methods� and insert following entries in new line:

Continued on next page

82 © 2008 SAP AG. All rights reserved. 2008

Page 91: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Method: DISPLAYLevel: Instance MethodVisibility: Public

Method type: -> no entryDescription: Display application data

Save your class (Ctrl + S).

b) Press the �Parameters� Button and insert the following propertiesinto the first line:

Parameter: EX_RETURNType: ExportingPass Value: -> no entryOptional: 'X'

Typing Method: TypeAssociated Type: BAPIRET1Default Value: -> not requiredDescription: -> set automatically

c) Double-click the DISPLAY method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD display.

CALL FUNCTION 'BAPI_MATERIAL_DISPLAY'

EXPORTING

material = matnr

IMPORTING

return = ex_return.

CASE ex_return-number.

* DUMMY

ENDCASE.

ENDMETHOD.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 83

Page 92: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

Save your class (Ctrl + S).

d) Go to the tab �Methods� and double-click the BI_OBJECT~EXE-CUTE_DEFAULT_METHOD method. Implement the coding asshown in the following example.

The exception class cx_root handles all exceptions frommethod displayand communicates them to the workflow engine. It has not to be insertedinto interface of BI_OBJECT~EXECUTE_DEFAULT_METHOD.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD bi_object~execute_default_method.

TRY.

display( ).

CATCH cx_root.

ENDTRY.

ENDMETHOD.

Save your class (Ctrl + S) and activate it.

3. Create a �DisplayView� method with the Import Parameter �MaterialView�to display special application data. Use transaction MM03 and the necessarySET/GET parameter.

a) Go to the tab �Methods� and insert following entries in a new line:

Method: DISPLAYVIEWLevel: Instance MethodVisibility: Public

Method type: -> no entryDescription: Display application data with Import

Parameter MaterialView

Save your class (Ctrl + S).

b) Press the �Parameters� Button and insert the following propertiesinto the first line:

Continued on next page

84 © 2008 SAP AG. All rights reserved. 2008

Page 93: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Parameter: IM_MATERIALVIEWType: ImportingPass Value: -> no entryOptional: 'X'

Typing Method: TypeAssociated Type: T132T-STATMDefault Value: 'K'Description: -> set automatically

c) If you want to compare your coding, call the implementation of classZBIT611_MARA.METHOD displayview.

SET PARAMETER ID 'MAT' FIELD matnr.

SET PARAMETER ID 'MXX' FIELD im_materialview.

CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN.

ENDMETHOD.

Save your class (Ctrl + S).

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 85

Page 94: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

4. Create a �Change� method to change application data. Use transactionMM02 and necessary SET/GET parameter.

a) Go to the tab �Methods� and insert following entries in a new line:

Method: CHANGELevel: Instance MethodVisibility: Public

Method type: -> no entryDescription: Change application data

Save your class (Ctrl + S).

b) Double-click the CHANGE method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD change.

SET PARAMETER ID 'MAT' FIELD matnr.

CALL TRANSACTION 'MM02' AND SKIP FIRST SCREEN.

ENDMETHOD.

Save your class (Ctrl + S).

5. Test your implementation by using the �Test� button (F8).

a) Press the �Test� button (F8).

b) A screen should be displayed where you see only the �CREATE�method.

c) Click the �Instance� button and enter the material �R-1003� in the fieldIM_MATNR and press the �Instance� button.

d) A screen should be displayed where you see the interfaces�BI_OBJECT�, �BI_PERSISTENT� and �IF_WORKFLOW�.

Also, it should display the above developed attributes.

Lastly, it should display the variety of methods, that you can test:�EXISTENCECHECK�, �DISPLAY�, �DISPLAYVIEW�, and so on.

Continued on next page

86 © 2008 SAP AG. All rights reserved. 2008

Page 95: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

6. OPTIONAL

Create a �Create� method with interface BAPI_STANDARDMATE-RIAL_CREATE. This is a static function, that means, it works withoutinstance.

a) Go to the tab �Methods� and insert following entries in a new line:

Method: CREATELevel: Static MethodVisibility: Public

Method type: -> no entryDescription: Create Material

Save your class (Ctrl + S).

b) Press the �Parameters� button and insert the following propertiesinto the first line:

Parameter: EX_RETURNType: ExportingPass Value: -> no entryOptional: 'X'

Typing Method: TypeAssociated Type: BAPIRET1Default Value: -> not requiredDescription: -> set automatically

c) Double-click the CREATE method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD create.

CALL FUNCTION 'BAPI_STANDARDMATERIAL_CREATE'

IMPORTING

material = ex_newmaterial

return = ex_return.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 87

Page 96: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 2: ABAP Classes Definition and Implementation BIT611

CASE ex_return-number.

* DUMMY

ENDCASE.

ENDMETHOD.

Save your class (Ctrl + S).

7. OPTIONAL

You could also test some of your developed functions in standard task. Yet,this is part of last exercise of this course.

a) Create some standard tasks with transaction �PFTC�.

b) Test the created standard tasks with transaction �SWUS�.

88 © 2008 SAP AG. All rights reserved. 2008

Page 97: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Class Definition - Attributes and Methods

Lesson Summary

You should now be able to:� Define attributes with a database reference� Define �virtual attributes�, like values� Define multiline attributes� Describe how object references are addressed in the BOR and the workflow

2008 © 2008 SAP AG. All rights reserved. 89

Page 98: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit Summary BIT611

Unit SummaryYou should now be able to:� Explain the basic technical concepts of ABAP Object classes in SAP

Business Workflow� Classify some important concepts of object-oriented programming� Create a class� Create instance handling required for workflow engine� Define key fields� Define attributes with a database reference� Define �virtual attributes�, like values� Define multiline attributes� Describe how object references are addressed in the BOR and the workflow

90 © 2008 SAP AG. All rights reserved. 2008

Page 99: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3Use Classes in Workflow Architecture

Unit OverviewThis unit shows additional concepts for controlling processes in Business ProcessManagement like Exception Handling in class methods and Event Handling inrelation to the object oriented paradigm of ABAP classes.

It shows the consequences of these techniques for the process flow and gives youhints about the most important aspects you have to know in building workflowwith ABAP classes.

Unit ObjectivesAfter completing this unit, you will be able to:

� Understand the exception techniques in workflow classes and their handlingin the workflow engine

� Define events and trigger them to start processes� Use API functions to affect workflow functions based on classes� Define and start single-step tasks and multistep tasks� Explain and define bindings within a multistep task� Use class components in workflow architecture

Unit ContentsLesson: Exceptions, Events and API Functions .. . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

Exercise 4: Create Exception and Event Handling for Classes .. . . . .101Lesson: Using Classes in Workflow Architecture.. . . . . . . . . . . . . . . . . . . . . . . . . .110

Exercise 5: Create and Test Workflow Functions with ABAPClasses ... . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119

2008 © 2008 SAP AG. All rights reserved. 91

Page 100: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Lesson: Exceptions, Events and API Functions

Lesson OverviewThere are some additional techniques to control processes in the workflow engine.In this lesson, we discuss the class �Exception Handling�, the �Events� in classesand the necessary areas to use class API functions.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Understand the exception techniques in workflow classes and their handlingin the workflow engine

� Define events and trigger them to start processes� Use API functions to affect workflow functions based on classes

Business ExampleYou have to implement some additional techniques in your material masterprocess to control its flow.

To do this, you have to understand the �Exception Handling�, �Event Handling�with ABAP classes and the technique to set container values with newprogramming API.

Exceptions in MethodsMethods might also have exceptions that report errors to the caller. The workflowengine is able to handle these exceptions. In general, the engine can distinguishbetween temporary exceptions (for example, object is locked) and applicationexceptions that report �permanent� errors.

Depending on the kind of exception, the system behaves differently:

� For BOR-Object types, the type of exception (temporary or applicationexception) can be defined using the Business Object Builder

� For ABAP classes, the different types of exception are based on either theexception class hierarchy or on naming conventions.

An exception is triggered directly for all error types (temporary, application orsystem errors), using the method exceptions in the class builder and entering the�RAISE EXCEPTION TYPE� statement.

To define customer based exceptions, it is also possible to create own exceptionclasses by subclassing the class-based workflow exceptions (for exampleCX_BO_TEMPORARY).

92 © 2008 SAP AG. All rights reserved. 2008

Page 101: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Figure 30: Reaction to Exception - Dialog Steps

In the object method, exceptions are defined as temporary exceptions, asapplication errors, or as system errors. If a subsequent step is modeled in theworkflow definition for this exception, this step is executed.

If no subsequent step is modeled, the workflow assumes an error status forapplication errors and system errors, and for temporary errors, the workflowremains in the status �in process�.

Figure 31: Reaction to Exception - Background Steps

Background steps also allow you to model a repeat counter for a temporary error.

2008 © 2008 SAP AG. All rights reserved. 93

Page 102: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

If this repeat counter is modeled, the step is automatically repeated, for the numberof times specified in the definition, whenever a temporary error occurs. The stepswitches permanently to either �error� or �completed� status (followed by themodeled subsequent step) only when this number of repetitions is complete.

The repetition is implemented by a background job (SWWERRE). Thebackground job must be scheduled to allow the repetition to be carried out iftemporary errors occur.

Figure 32: Handle Exceptions from ABAP Classes

Class-Based Exceptions

Class-based exceptions can be used for methods. At runtime, the workflow enginewill catch the thrown exceptions and treat them as application exceptions.

To raise temporary exceptions, you can use the exception classCX_BO_TEMPORARY and its subclasses. All exceptions of this class and thesubclasses are handled as temporary exceptions.

Therefore, it is also possible to create your own exception classes for temporaryexceptions by subclassing CX_BO_TEMPORARY.

For dialog methods, it might be useful to raise an exception if the usercancels the dialog (as a temporary exception). In this case, you can useCX_BO_ACTION_CANCELLED (subclass of CX_BO_TEMPORARY) to raisethis specific exception.

Non Class-Based Exceptions

94 © 2008 SAP AG. All rights reserved. 2008

Page 103: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Non class-based exceptions could also be used for methods. These exceptions willalso be caught by the engine. Like above, these exceptions will be handled asapplication exceptions.

To raise temporary exceptions, the name of an exception has to start with TMPor TEMP. For dialog methods it might be useful to raise an exception if theuser cancels the dialog (as a temporary exception). In this case, you can useTMP_EXIT_CANCELLED or TEMP_EXIT_CANCELLED to raise this specificexception.

Handling EventsThe workflow engine makes use of an event manager that handles events andcalls the corresponding receivers (for example, processes, that should be startedor steps within a process that should be completed). These events are triggeredby calling the Event Manager API.

The events are handled asynchronously and the receivers are started in their ownLUW (Logical Unit of Work). The sender and receiver of the event do not needto reside on the same logical system.

Figure 33: Basic logic to trigger Events

ABAP classes can also define events that are used to communicate between ABAPobjects residing in the same context (roll area). These events, which are triggeredusing built-in ABAP statements, and the previously mentioned events handled bythe event manager, are completely different.

If an event is triggered by the following ABAP objects command, this has nosignificance for the event manager:

RAISE EVENT <evt> EXPORTING... <ei> = <f i> ...

2008 © 2008 SAP AG. All rights reserved. 95

Page 104: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Figure 34: Event Handling in Classes

Nevertheless, public events that are defined at a class could also be used to triggerevents for the workflow engine. To achieve this, an event handler in an ABAPprogram code would have to make explicit calls to the workflow system�s eventmanger through its API, thus dispatching a local ABAP event to a workflow event.It is also possible to use event parameters to pass values to possible event handlers.

However, because the workflow event manager uses RFC to dispatch its events,restrictions concerning data types apply:

� event parameters are restricted to simple types (for example, string, integer,and so on)

� any possible ABAP dictionary types (for example, structures, tables,complex types)

� BOR object references or references to ABAP classes that implement theinterface IF_WORKFLOW

The following sections describe how events can be triggered via the workflowevent manager API. Since the handlers will be started in their own LUW using atRFC, a COMMIT WORK is always required to actually start the receivers.

This section describes how static methods could be used to trigger an event.Before the event is triggered, the corresponding value for the event parameter isset. The handling of event parameters is optional.

Triggering Events Via Static Methods

*- begin of local data

DATA: l_event_parameters TYPE REF TO if_swf_ifs_parameter_container.

*- begin of local data

96 © 2008 SAP AG. All rights reserved. 2008

Page 105: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

TRY.

*--- get the event container that is used to transport the event parameters

CALL METHOD cl_swf_evt_event=>get_event_container

EXPORTING

im_objcateg = ‘CL‘ “category for classes

im_objtype = ‘CL_DEMO_CLASS‘ “the classname

im_event = ‘CHANGED‘ “event that will be triggerd

RECEIVING

re_reference = l_event_parameters.

*--- set the values of the parameters

CALL METHOD l_event_parameters->set

EXPORTING

name = ‘USER‘ “the name of the event parameter

value = sy-uname. “the value

*--- raise the event

CALL METHOD cl_swf_evt_event=>raise

EXPORTING

im_objcateg = ‘CL‘ “category for classes

im_objtype = ‘CL_DEMO_CLASS‘ “the classname

im_event = ‘CHANGED‘ “the event name

im_objkey = ‘…‘ “the obj.-key (instid)

im_event_container = l_event_parameters. “the event params

*--- start the receivers (tRFC)

COMMIT WORK.

CATCH cx_swf_evt_exception. “except. while raising the event

CATCH cx_swf_cnt_container. “except. while setting event params

ENDTRY.

Raising an event without COMMIT WORK will not start any receiver. If the eventis triggered within a transaction, the COMMIT WORK of the running transactioncan (and should) be used. The following event definition is used to show themechanism of dispatching an ABAP event to a workflow event manger event. Theexample also shows the mechanism for passing event parameters.

This section gives an example of how to raise the same event using instancemethods. It is up to the user weather to use static or instance methods. There is nodifference between these possibilities.

Trigger Events Using Instance Methods

2008 © 2008 SAP AG. All rights reserved. 97

Page 106: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

*- begin of local data

DATA: l_event_parameters TYPE REF TO if_swf_ifs_parameter_container.

DATA: l_event TYPE REF TO if_swf_evt_event.

*- end of local data

TRY.

*--- get an event object

CALL METHOD cl_swf_evt_event=>get_instance

EXPORTING

im_objcateg = ‘CL‘ “category for classes

im_objtype = ‘CL_DEMO_CLASS‘ “the classname

im_event = ‘CHANGED‘ “event that will be triggerd

im_objkey = ‘…‘ “the object-key (instid)

RECEIVING

re_event = l_event.

*--- get the event container to set the parameters

l_event_parameters = l_event->get_event_container( ).

*--- set the values of the parameters

CALL METHOD l_event_parameters->set

EXPORTING

name = ‘USER‘ “the name of the event parameter

value = sy-uname. “the value

*--- raise the event

CALL METHOD l_event->raise.

*--- start the receivers (tRFC)

COMMIT WORK.

CATCH cx_swf_evt_exception. “exception while raising the event

CATCH cx_swf_cnt_container. “exception while setting event params

ENDTRY.

98 © 2008 SAP AG. All rights reserved. 2008

Page 107: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Note that events say something about object status changes that have actuallyoccurred. Therefore, ensure that the event is not created until the relevant statuschange has taken place. To do this, call the method for creating an event in thesame logical unit of work (LUW) that the status change is made in.

� Interface IF_SWF_IFS_PARAMETER_CONTAINER

To set the event parameters, use the IF_SWF_IFS_PARAMETER_CON-TAINER interface. Use the SET method of this interface to set the relevantparameters. Use the TRY ... ENDTRY instruction to catch the exceptionscx_swf_evt_execption (error in event creation) and cx_swf_cnt_container(error in setting a parameter).

� Class CL_SWF_EVT_EVENT

The ABAP class CL_SWF_EVT_EVENT has two methods,RAISE and RAISE_IN_UPDATE_TASK, which behave in thesame way as the function modules SWE_EVENT_CREATE andSWE_EVENT_CREATE_FOR_UPD_TASK.

Parameter Container InterfaceProgramming with containers always meant manipulating internal tables ofstructure SWCONT using container macros. To overcome the limitations of theold container implementation, a new, ABAP Objects based programming modelhas been developed.

In this new programming model, the container is represented as an ABAP Objectreference of type IF_SWF_IFS_PARAMETER_CONTAINER. SWCONT has notdisappeared everywhere (for example, it is still used when programming BORmethods) but some APIs already use the above interface and more of them willfollow.

IF_SWF_IFS_PARAMETER_CONTAINER contains the following methods:

2008 © 2008 SAP AG. All rights reserved. 99

Page 108: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Figure 35: Parameter Container Interface

The new container interface could used in, as example, check function modules, todevelop BOR methods, triggering events in customer specific programming, andso on. See the new interface implementation in some programming examples:

� FB sww_wi_create_via_event_ibf (receiver function module for standard wf)� FB swb_2_check_fb_start_cond_eval (check function module)� FB swe_event_create (function module to generate an event)

Figure 36: Examples for Using New Interface

100 © 2008 SAP AG. All rights reserved. 2008

Page 109: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Exercise 4: Create Exception and EventHandling for Classes

Exercise ObjectivesAfter completing this exercise, you will be able to:� Define exception and event handling for classes

Business ExampleYour company has developed some add-ons to the standard business scenarios ofthe SAP ERP system. These extensions are implemented in ABAP Objects.

To gain experience with the techniques of inserting these functions in workflowarchitecture, someone has to test the possibilities. You have the task of creatingsome ABAP class functions as examples for your colleagues.

We want to create functions like those encapsulated in the BOR object typeBUS1001006.

Hint: Please be aware that you have to be an experienced developer toimplement all following functions in the given exercise time.

You could also copy some coding from the example implementation ofclass ZBIT611_MARA. Please use this possibility if you do not haveenough time or you are not an experienced developer.

Task:To handle the basic functions of an object used in workflow architecture, you havecreated some methods in the last exercise.

To check some important function results, it has to be implemented an exceptionhandling in the previously developed methods.

There should also be some workflow events triggered, when business contentis created or changed.

1. Please realize the exception handling of ExistenceCheck and Constructormethod implemented in the previous exercises.

2. The return codes of BAPI_MATERIAL_DISPLAY in the method Displayshould be handled from workflow engine.

3. OPTIONAL

The return codes of BAPI_STANDARDMATERIAL_CREATE in themethod Create should be handled from the workflow engine.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 101

Page 110: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

4. To define customer specific time points for the process, create two additionalevents; one for the change of field Basic Material and one for the change offield Old Material.

5. OPTIONAL

To make the creation of a new material public, you have to implement atriggering event �CREATED� in the Create method.

It should be include a parameter �User�.

6. Test your implementation by using the �Test� button (F8).

102 © 2008 SAP AG. All rights reserved. 2008

Page 111: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Solution 4: Create Exception and EventHandling for ClassesTask:To handle the basic functions of an object used in workflow architecture, you havecreated some methods in the last exercise.

To check some important function results, it has to be implemented an exceptionhandling in the previously developed methods.

There should also be some workflow events triggered, when business contentis created or changed.

1. Please realize the exception handling of ExistenceCheck and Constructormethod implemented in the previous exercises.

a) These implemented exceptions handle the general behavior of class inworkflow context, if no business object is available to the given key.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

2. The return codes of BAPI_MATERIAL_DISPLAY in the method Displayshould be handled from workflow engine.

a) To handle the raised exceptions, insert exceptions �CX_BO_ERROR�and �CX_BO_ACTION_CANCELLED� in the exceptions list of themethod (tab �Exceptions�).

Save your class (Ctrl + S).

b) Double-click the DISPLAY method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD display.

...

CASE ex_return-number.

WHEN '000'.

* material is displayed

WHEN '262'.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 103

Page 112: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

RAISE EXCEPTION TYPE cx_bo_error

EXPORTING textid = 'No materialnumber transfered.'.

WHEN '305'.

RAISE EXCEPTION TYPE cx_bo_error

EXPORTING textid = 'Material not existing.'.

WHEN OTHERS.

RAISE EXCEPTION TYPE cx_bo_error

EXPORTING textid = 'Other Error'.

ENDCASE.

ENDMETHOD.

Save your class (Ctrl + S).

c) Save your class (Ctrl + S) and activate it.

3. OPTIONAL

Continued on next page

104 © 2008 SAP AG. All rights reserved. 2008

Page 113: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

The return codes of BAPI_STANDARDMATERIAL_CREATE in themethod Create should be handled from the workflow engine.

a) To handle the raised exceptions, insert exceptions �CX_BO_ERROR�and �CX_BO_ACTION_CANCELLED� in the exceptions list of themethod (tab �Exceptions�).

Save your class (Ctrl + S).

b) Double-click the CREATE method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD create.

...

CASE ex_return-number.

WHEN '000'.

WHEN '355'.

RAISE EXCEPTION TYPE cx_bo_action_cancelled

EXPORTING textid = 'No material has been created.'.

when '356'.

* material is created

WHEN OTHERS.

RAISE EXCEPTION TYPE cx_bo_error

EXPORTING textid = 'other'.

ENDCASE.

ENDMETHOD.

Save your class (Ctrl + S).

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 105

Page 114: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

4. To define customer specific time points for the process, create two additionalevents; one for the change of field Basic Material and one for the change offield Old Material.

a) Go to the tab �Events� and insert the following entries:

Event BASICMATERIALCHANGED

Type InstanceVisibility PublicDescription Field basic material changed

Event OLDMATERIALCHANGED

Type InstanceVisibility PublicDescription Field old material changed

Save your class (Ctrl + S).

5. OPTIONAL

To make the creation of a new material public, you have to implement atriggering event �CREATED� in the Create method.

It should be include a parameter �User�.

a) Go to tab �Events� and insert the following entry:

Event CREATED

Type InstanceVisibility PublicDescription Material Master created

Define a parameter �User� for the CREATED event. Mark the createdentry and use the �Parameters� button to insert the following properties:

Continued on next page

106 © 2008 SAP AG. All rights reserved. 2008

Page 115: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Parameter USEROptional -> no entryTyping TypeAssociatedType

SY-UNAME

DefaultValue

-> no entry

Description -> set automatically

Save your class (Ctrl + S).

b) Double-click the CREATE method. Implement the coding as shownin the following example.

If you want to compare your coding, call the implementation of classZBIT611_MARA.

METHOD create.

*- begin of local data

DATA: l_event_parameters TYPE REF TO if_swf_ifs_parameter_container.

*- end of local data

...

CASE ex_return-number.

...

WHEN '365'.

TRY.

*--- get the event container that is used to transport the event parameters

CALL METHOD cl_swf_evt_event=>get_event_container

EXPORTING

im_objcateg = 'CL'

im_objtype = 'ZBIT611_...'

im_event = 'CREATED'

RECEIVING

re_reference = l_event_parameters.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 107

Page 116: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

*--- set the values of the parameters

CALL METHOD l_event_parameters->set

EXPORTING

name = 'USER'

value = sy-uname.

*--- raise the event

CALL METHOD cl_swf_evt_event=>raise

EXPORTING

im_objcateg = 'CL'

im_objtype = 'ZBIT611_...'

im_event = 'CREATED'

im_objkey = ex_newmaterial

im_event_container = l_event_parameters.

*--- start the receivers (tRFC)

COMMIT WORK.

CATCH cx_swf_evt_exception.

CATCH cx_swf_cnt_container.

ENDTRY.

...

ENDCASE.

ENDMETHOD.

Save your class (Ctrl + S).

6. Test your implementation by using the �Test� button (F8).

a) Press the �Test� Button (F8).

b) A screen should be displayed where you see only the �CREATE�method.

c) Create a new material and check the event triggering in transactionSWEL.

d) To check exception handling, call the CREATE method of yourclass and check the reaction of system. If you abort the creation ofmaterial with the yellow �Exit� button (or press Schift + F3), theCX_BO_ACTION_CANCELLED exception should be raised.

108 © 2008 SAP AG. All rights reserved. 2008

Page 117: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Exceptions, Events and API Functions

Lesson Summary

You should now be able to:� Understand the exception techniques in workflow classes and their handling

in the workflow engine� Define events and trigger them to start processes� Use API functions to affect workflow functions based on classes

2008 © 2008 SAP AG. All rights reserved. 109

Page 118: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Lesson: Using Classes in Workflow Architecture

Lesson OverviewThis lesson explains the concept behind calling synchronous and asynchronousmethods in tasks. It also describes how tasks can be started and integrated intoworkflows.

This includes saving binding specifications, so that you can work correctly withthe required objects in the individual business process steps at runtime.

Lesson ObjectivesAfter completing this lesson, you will be able to:

� Define and start single-step tasks and multistep tasks� Explain and define bindings within a multistep task� Use class components in workflow architecture

Business ExampleYou want to use the methods and attributes of your new class definition in aworkflow.

To do this, you need to define tasks.

Definition of Standard Tasks

Figure 37: Single-Step Tasks

110 © 2008 SAP AG. All rights reserved. 2008

Page 119: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

The default rule is evaluated if the task is used either outside a workflow, or in astep definition without an 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

Calling Synchronous and Asynchronous Methods

� Single-step task referring to a synchronous method

� Single-step task is terminated when the method reports back to caller� Binding between task container and method container in both directions

� Single-step task referring to asynchronous method

� Method started by workflow system� Report back by terminating event� Single-step task is terminated when terminating event occurs

Communication between single-step task and object method:

� Synchronous:

The method is called, it takes over the process control and, after it has beenprocessed, reports back to the caller.

� Asynchronous:

The method is called, the synchronous part of the method is processedand ends without returning any export parameters. The asynchronous part(update) runs without any connection to the caller and must report backto the caller with an event.

2008 © 2008 SAP AG. All rights reserved. 111

Page 120: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Please repeat the following notes about synchronous/asynchronous calling ofworkflow steps:

� The task method is always called synchronously (that is, in the same sessionas the calling program)

� Previous methods and subsequent methods are always called synchronously� Secondary methods are always called asynchronously (that is, in a new

external session)� Reports back to the workflow are made only from the task method.

Secondary methods are for display only.

An explicit confirmation can be modeled in the step definition for bothsynchronous 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 hasbeen received. In this case, the terminating event cannot be triggered within theassociated object method.

Options for Starting Tasks

� Automatically through the workflow system when you reach a step withina multistep task

� Directly using the workflow development environment� Program-driven through the API of the work item manager� Using a triggering event� Directly, using the system menu

Usually, tasks are started automatically through the step definition when aworkflow is processed.

112 © 2008 SAP AG. All rights reserved. 2008

Page 121: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Workflow Definition Steps

Figure 38: Workflow Definition Steps

All block-oriented modeling constructs such as branches and loops are available.The steps can be arranged in sequence or parallel.

The modeling interface (�Workflow Builder�) contains the relevant graphicaloperators for handling blocks. Each step is a determining component of its ownblock. Operations such as, copying or deleting on individual steps (for example,the �loop� step type) always affect the entire block (the entire loop contents, forexample) that depends on this step.

2008 © 2008 SAP AG. All rights reserved. 113

Page 122: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Container and Binding Definition

Figure 39: Using the Workflow Container

The workflow container stores the data available throughout the process. It isused to perform the following tasks:

� Specify the import and export parameters for the entire workflow (elementswith the property �Import� or �Export�)

� Exchange data between individual steps

(1) When the workflow is started, data from a triggering event is transferredto the workflow container as input parameters.

(2) In a container operation, data in the workflow container can be changedby an allocation or a calculation.

(3) The expressions in a condition refer to data belonging to the workflowcontainer.

(4) In a wait step, data is read from the workflow container (for example,to create the instance linkage for the event being received), whereas theevent parameters are written to the workflow container with a binding.

(5)+(6) Data from the workflow container is read in an activity(binding for the task) and written (the output parameters of thetask are transferred to the workflow container with binding).In addition, data is read from the workflow container to resolve the ruleused in the step for agent determination and determine any dates (6)defined on the step (such as the deadline) with an expression.

114 © 2008 SAP AG. All rights reserved. 2008

Page 123: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Figure 40: Binding in Workflow Execution

(1)(11) The event container is filled when the event is created using thecontainer macro (that is, before the event is triggered).

(2) Binding from the triggering event to the workflow. This binding isabsolutely essential; usually, the reference of the triggering object andthe user name (or �event initiator�) are transferred to the workflowcontainer.

(3) (8) Binding from the workflow container to the rule: This sets the inputparameters for the rule if one is defined for agent determination in thestep. If there is a default rule in the task definition, the parameters aresupplied from the work item container.

(4)(7) (9)(13)

Binding between the workflow container and task container (workitem container) for setting the input parameters (during the call) andreading the output parameters of the task (once the task is completed).The Workflow Builder generates a proposal for this binding in the stepdefinition.

(5) (6)(10)(12)

Binding between the task and the method container. There is abinding for synchronous tasks in import (5) and export (6) direction.In asynchronous tasks, the import binding is directly defined (10),whereas the return binding is defined during the terminating event (12).The runtime system copies the entire container if no binding is definedbetween the task and method.

2008 © 2008 SAP AG. All rights reserved. 115

Page 124: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Components of Class in Workflow Architecture

Figure 41: Using ABAP Objects in Workflow I

Figure 42: Using ABAP Objects in Workflow II

116 © 2008 SAP AG. All rights reserved. 2008

Page 125: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Figure 43: Using ABAP Objects in Workflow III

2008 © 2008 SAP AG. All rights reserved. 117

Page 126: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

118 © 2008 SAP AG. All rights reserved. 2008

Page 127: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Exercise 5: Create and Test WorkflowFunctions with ABAP Classes

Exercise ObjectivesAfter completing this exercise, you will be able to:� Create standard tasks with ABAP classes� Create process flows with ABAP classes

Business ExampleYou have either found or created all the classes that you want to use in yourbusiness process with the associated attributes and methods in the Class Builder.

Now, you want to create single-step tasks based on the object methods, which youcan use later in your workflow definition.

Hint: It is a prerequisite for the course that participants know how tocreate and maintain tasks.

The solution therefore only refers to created sample tasks.

The following pages give a brief description of how to avoid problemswhen creating and maintaining tasks.

All tasks are based on the class ZBIT611_##.

Create a Standard Task.

1. Call transaction PFTS and choose Create.

2. Input data on the basic screen:

ID: As specified in the exercise

Name: As appropriate for the required task

Work item text: As specified in the exercise

Enter the material number in the text using the �Insert variables� button underneaththe text.

Section object methods:

Object category: CL ABAP class

Enter the class ZBIT611_## and the method required in the exercise.

Press Enter to confirm. When prompted, transfer elements that are not availablefrom the object method.

3. Enter the task description: Description tab page

2008 © 2008 SAP AG. All rights reserved. 119

Page 128: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Task description text type

Choose the Change button

Text: As specified in the exercise

Enter the material number by choosing the menu option Include - Expression

4. Enter the possible agents:

Possible agents are the users who are authorized to carry out the task in a businesscontext.

Maintenance: On the Task maintenance basic screen, choose the menu path:Additional Data -> Maintain Agent Assignment.

Select the task ID and choose the Properties button. Then select General Task.

5. Enter texts for missed deadlines/completion: Description tab page

Text type: Required texts (latest end text/completion text)

Text: As specified in the exercise

6. Enter a terminating event: Terminating Events tab page

Entry in the ELEMENT field: Using the F4 help, select the element_WI_OBJECT_ID.

Again, using the F4 help, select the terminating event.

7. Enter a default value for the input parameter MaterialView/Mainte-nancestatus

On the basic screen for the task:

Container tab page

Double click on the line containing MaterialView/Maintenancestatus

Initial Value tab page

Enter the value K for the Basic Data 1 view.

8. Test a task

Call transaction SWUS.

Under Task, enter the following: TSxxxxxxxx

Transfer test data:

Click on the line containing the expression _WI_OBJECT_ID

An input line opens on the bottom edge of the screen.

Use the F4 help to select the material that you want to test.

9. Display the instance data

120 © 2008 SAP AG. All rights reserved. 2008

Page 129: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Call the Workplace (transaction SBWP or Office - Workplace)

Open the Inbox folder

Click on the Workflow folder.

Select the required work item and choose the Display icon.

Choose Goto -> Technical Work Item Display

Choose Extras -> Instance Linkage

10. Display the event trace

Call transaction SWEL

Enter your object type ZBIT611_##

Choose Execute

The triggered terminating event is displayed.

In the detailed data (double-click on Event), you can view the number of the workitem that was terminated by the event.

Task 1:Create a new standard task for displaying a material master from a predeterminedview.

1. Create the task ZCL##MatDisV with the method DisplayView. Define thetask as a general task. Enter a work item text.

Text:Display Material < Material number from object>.

Display the material number with view. Display the material number in thework item text.

Define the view K (corresponds to the Basic data 1 view) as default valuefor parameter �IM_MATERIALVIEW� to control the view initially calledfor the material.

2. Test the task by starting it in the workflow development environment(transaction SWUS).

Task 2:Create a new standard task for changing a material master.

1. Create the ZCL##Change task with the Change method.

Define the task as a general task. Specify a work item text, a text for latestend and a text for completion. In addition to the material number, alsoissue the number and name of a plant for this material in all texts. Use thefollowing texts:

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 121

Page 130: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Text: Change material <Material number from object>

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.

3. Test the task by starting it in the workflow development environment usingtransaction SWUS.

Task 3:Create a new standard task for creating a material master.

1. Create the ZCL##Create task with the Create method.

Define the task as a general task. Enter the following text as the work itemtext and description: Create a material master record.

2. Test the task by starting it in the workflow development environment usingtransaction SWUS.

Task 4:Define a workflow with a triggering event.

Hint: It is a prerequisite for the course that participants know how tocreate and maintain a task.

The solution therefore only refers to created sample tasks.

The following pages give a brief description of how to avoid problemswhen creating and maintaining tasks.

The description follows the tasks.

Workflow definition.

1. Creating a Workflow:

Call transaction SWDD

Choose the Save button.

Enter the required workflow ID.

Create the workflow as a local object.

2. Integrate the standard tasks as specified in the exercise.

Select the undetermined step in the Workflow Builder.

Choose the Create step icon.

Continued on next page

122 © 2008 SAP AG. All rights reserved. 2008

Page 131: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Click on the step type Activity.

Enter your task.

3. Select the responsible agents from the possible agents:

Section Agents.

Choose Users followed by the required users.

4. Define recipients for notification of completion:

Notification tab page.

Select the Workflow initiator expression.

5. Define a missed deadline

Latest End tab page.

Reference time: Generate work item

Action: Send text

Recipient: Select the Workflow initiator expression.

6. Link a triggering event

On the Workflow Builder basic screen:

Click on the Workflow Container tab page (on the left of the screen).

Double-click reference variables for your material on the Properties tab page.Select the Import indicator.

On the basic screen of the Workflow Builder, choose: Goto→ Basic Data, tabpage Start Events

Enter your object type and select the event.

Activate the event linkage by clicking on the button under A...

(Event linkage active/inactive)

7. Testing the workflow

On the Workflow Builder basic screen - click the Test icon.

The workflow automatically switches to the test transaction SWUS.

Remember to maintain the test data.

1. Create a workflow template called ZCL##MSIPROC1 for creating anddisplaying a material master.

2. Incorporate the single-step task ZCL##Change into your workflowdefinition.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 123

Page 132: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

3. Define OldMaterialChanged as the triggering event for your workflow.Implement the binding between the triggering event and the workflow andactivate the event linkage.

4. Check, save, and activate your workflow definition. Test your workflow withyour material by starting it from the workflow development environment.

5. Define another input parameter MaterialView for your workflow. Thisparameter is used to control the view in the display step of the process.Define view �K� as the default for this parameter.

6. Add the single-step task ZCL##MatDisV to your workflow definition afterthe ZCL##Change step. Assign the value of theMaterialView parameterfrom the workflow container to the step parameter for controlling the displayview.

124 © 2008 SAP AG. All rights reserved. 2008

Page 133: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Solution 5: Create and Test WorkflowFunctions with ABAP ClassesTask 1:Create a new standard task for displaying a material master from a predeterminedview.

1. Create the task ZCL##MatDisV with the method DisplayView. Define thetask as a general task. Enter a work item text.

Text:Display Material < Material number from object>.

Display the material number with view. Display the material number in thework item text.

Define the view K (corresponds to the Basic data 1 view) as default valuefor parameter �IM_MATERIALVIEW� to control the view initially calledfor the material.

a) Refer to the following task definition as a solution:

TS99700174 - ZCL00MatDisV

Use the following path to display the task (starting from SAP EasyAccess): Tools→ Business Workflow→ Development→ DefinitionTools→ Tasks/Task Groups→ Create.

For further details see general description.

2. Test the task by starting it in the workflow development environment(transaction SWUS).

a) For further details, see general description.

Task 2:Create a new standard task for changing a material master.

1. Create the ZCL##Change task with the Change method.

Define the task as a general task. Specify a work item text, a text for latestend and a text for completion. In addition to the material number, alsoissue the number and name of a plant for this material in all texts. Use thefollowing texts:

Text: Change material <Material number from object>

a) Refer to the following task definition as a solution:

TS99700175 - ZCL00Change

For further details, see general description.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 125

Page 134: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

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.

a) Enter the terminating event in the task definition.

3. Test the task by starting it in the workflow development environment usingtransaction SWUS.

a) For further details see general description.

Task 3:Create a new standard task for creating a material master.

1. Create the ZCL##Create task with the Create method.

Define the task as a general task. Enter the following text as the work itemtext and description: Create a material master record.

a) Refer to the following task definition as a solution:

TS99700176 - ZCL00Create

For further details, see general description.

2. Test the task by starting it in the workflow development environment usingtransaction SWUS.

a) For further details, see general description.

Task 4:Define a workflow with a triggering event.

Hint: It is a prerequisite for the course that participants know how tocreate and maintain a task.

The solution therefore only refers to created sample tasks.

The following pages give a brief description of how to avoid problemswhen creating and maintaining tasks.

The description follows the tasks.

Workflow definition.

1. Creating a Workflow:

Call transaction SWDD

Choose the Save button.

Continued on next page

126 © 2008 SAP AG. All rights reserved. 2008

Page 135: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Enter the required workflow ID.

Create the workflow as a local object.

2. Integrate the standard tasks as specified in the exercise.

Select the undetermined step in the Workflow Builder.

Choose the Create step icon.

Click on the step type Activity.

Enter your task.

3. Select the responsible agents from the possible agents:

Section Agents.

Choose Users followed by the required users.

4. Define recipients for notification of completion:

Notification tab page.

Select the Workflow initiator expression.

5. Define a missed deadline

Latest End tab page.

Reference time: Generate work item

Action: Send text

Recipient: Select the Workflow initiator expression.

6. Link a triggering event

On the Workflow Builder basic screen:

Click on the Workflow Container tab page (on the left of the screen).

Double-click reference variables for your material on the Properties tab page.Select the Import indicator.

On the basic screen of the Workflow Builder, choose: Goto→ Basic Data, tabpage Start Events

Enter your object type and select the event.

Activate the event linkage by clicking on the button under A...

(Event linkage active/inactive)

7. Testing the workflow

On the Workflow Builder basic screen - click the Test icon.

The workflow automatically switches to the test transaction SWUS.

Continued on next page

2008 © 2008 SAP AG. All rights reserved. 127

Page 136: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit 3: Use Classes in Workflow Architecture BIT611

Remember to maintain the test data.

1. Create a workflow template called ZCL##MSIPROC1 for creating anddisplaying a material master.

a) Define a workflow with a triggering event.

WS99700306 - ZCL00MSIPROC

Path (starting from SAP Easy Access):Tools→ Business Workflow→Development→ Definition Tools→ Workflow Builder→ Create

2. Incorporate the single-step task ZCL##Change into your workflowdefinition.

a) see task 4-1a)

3. Define OldMaterialChanged as the triggering event for your workflow.Implement the binding between the triggering event and the workflow andactivate the event linkage.

a) see task 4-1a)

4. Check, save, and activate your workflow definition. Test your workflow withyour material by starting it from the workflow development environment.

a) see task 4-1a)

5. Define another input parameter MaterialView for your workflow. Thisparameter is used to control the view in the display step of the process.Define view �K� as the default for this parameter.

a) see task 4-1a)

6. Add the single-step task ZCL##MatDisV to your workflow definition afterthe ZCL##Change step. Assign the value of theMaterialView parameterfrom the workflow container to the step parameter for controlling the displayview.

a) see task 4-1a)

128 © 2008 SAP AG. All rights reserved. 2008

Page 137: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Lesson: Using Classes in Workflow Architecture

Lesson Summary

You should now be able to:� Define and start single-step tasks and multistep tasks� Explain and define bindings within a multistep task� Use class components in workflow architecture

2008 © 2008 SAP AG. All rights reserved. 129

Page 138: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Unit Summary BIT611

Unit SummaryYou should now be able to:� Understand the exception techniques in workflow classes and their handling

in the workflow engine� Define events and trigger them to start processes� Use API functions to affect workflow functions based on classes� Define and start single-step tasks and multistep tasks� Explain and define bindings within a multistep task� Use class components in workflow architecture

130 © 2008 SAP AG. All rights reserved. 2008

Page 139: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

BIT611 Course Summary

Course SummaryYou should now be able to:

� Identify all points in the workflow system at which programming is possibleor necessary

� Create your own classes and use them in the workflow architecture� Use �Container Parameter Interface� as the new application programming

interface (API) for workflow related functions (check, receiver type, and soon)

Related Information

� Use information in SAP Help Portal� Use information in release notes� Use information in Service Marketplace and Notes

2008 © 2008 SAP AG. All rights reserved. 131

Page 140: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

Course Summary BIT611

132 © 2008 SAP AG. All rights reserved. 2008

Page 141: BIT611_EN_Col62_FV_Part_A4[1] - SAP Business Workflow Programming With ABAP OO

FeedbackSAP AG has made every effort in the preparation of this course to ensure theaccuracy and completeness of the materials. If you have any corrections orsuggestions for improvement, please record them in the appropriate place in thecourse evaluation.

2008 © 2008 SAP AG. All rights reserved. 133