Sap Abap Refresher Course NoRestriction

1074
ABAP: Refresher Course ABAP: Refresher Course

description

Abap satyam material.

Transcript of Sap Abap Refresher Course NoRestriction

Page 1: Sap Abap Refresher Course NoRestriction

ABAP: Refresher CourseABAP: Refresher Course

Page 2: Sap Abap Refresher Course NoRestriction

Course Content

Table of ContentsTable of Contents

Topic 1 INTRODUCTION TO ABAP

�� Sap Netweaver: An overview�� Sap Netweaver: An overview�� Navigation in R/3 system�� Overview of ABAP

Topic 2 ABAP WORKBENCH BASICS

�� Data types and data objects �� Internal tables �� Modularization of R/3 : Subroutines, Macros , Passing Data, Terminating Subroutines etc.

�� ABAP runtime system : Debugging�� Function groups and function modulesg p

Topic 3 ABAP DICTIONARY

�� Introduction �� Database Tables �� Domains �� Views�� Search helps�� Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 3: Sap Abap Refresher Course NoRestriction

Topic

Course Content

Topic

Topic 4 ADVANCED ABAP

O SQL�� Open SQL �� Dynamic programming

Topic 5 ABAP OBJECTS

Cl d bj t�� Classes and objects �� Inheritance �� Polymorphism (casting) �� Interfaces �� Events �� Global classes and interfaces �� Exception handling

Topic 6 LIST CREATION TECHNIQUES

�� Extract Datasets�� List ( Standard, Self defined, List with several pages )�� Interactive lists( At line selection, At user-command )�� List creation with the ALV grid control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 4: Sap Abap Refresher Course NoRestriction

Topic

Course Content

Topic

Topic 7 DIALOG PROGRAMMING�� Screen (basics) �� Screen logic, Screen Painter , Menu Painter �� Input checks, changing of input values�� Error handling�� Step loops�� Table Control�� Table Control�� Field help and value help

Topic 8 DATABASE CHANGES

�� Database updates with open SQL�� LUW Processing �� Update Bundling Techniques�� Programming Bundling Updates�� Programming Bundling Updates.�� Unbundled Updates�� Local Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 5: Sap Abap Refresher Course NoRestriction

Topic

Course Content

Topic

Topic 9 ENHANCEMENTS & MODIFICATIONS

�� Enhancements to SAP Objects E h t i M E it / S E it / F ti M d l it�� Enhancements via Menu Exits / Screen Exits / Function Module exits

�� Business Add-Ins �� Modifications via Registering the Modifications in SSCR, Modification Adjustment, Rules for Modifications

Topic 10 ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

�� Introduction to BAPI�� BAPI Usage�� Structure of Business Objects�� Important Transaction codes�� BAPI Creation�� Understanding Business Requirements before BAPI Creation�� Technical Steps for BAPI Creationp�� List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 6: Sap Abap Refresher Course NoRestriction

Topic

Course Content

Topic

Topic 11 ADDITIONAL TOPICS : SMART FORMS

�� Introduction to Smart Forms

�� Structure of a form

�� Windows

�� Architecture

�� Forms

�� Nodes

�� Form Painter

�� Table Painter

�� PC Editor

�� Style Builder

�� Driver Program�� Driver Program

Topic 12 ADDITIONAL TOPICS : SAP SCRIPTS

�� Standard Text�� Layout Set�� Layout Set�� Print Program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 7: Sap Abap Refresher Course NoRestriction

Topic

Course Content

Topic

Topic 13 ADDITIONAL TOPICS : WORKFLOW BASICS

B i W k l�� Business Workplace�� Workflow Builder�� Tasks�� Business Object Repository (BOR)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 8: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

Sap Netweaver: An overview

Navigation in R/3 system

Overview of ABAP

SAP PMG Delivering Solution Excellence and Innovation

Page 9: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 10: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 11: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 12: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 13: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 14: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 15: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 16: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 17: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 18: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 19: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 20: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 21: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 22: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 23: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 24: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 25: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and Innovation

Page 26: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

Sap Netweaver: An overview

Navigation in R/3 system

Overview of ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 27: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 28: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 29: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 30: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 31: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 32: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 33: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 34: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 35: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 36: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 37: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

Sap Netweaver: An overview

Navigation in R/3 system

Overview of ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 38: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 39: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 40: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 41: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 42: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 43: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 44: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 45: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 46: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 47: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 48: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 49: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 50: Sap Abap Refresher Course NoRestriction

1. INTRODUCTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 51: Sap Abap Refresher Course NoRestriction

2. ABAP WORKBENCH BASICS

Data Types & Data Objects

Internal Tables

Modularization of ABAP R/3

ABAP Runtime system : Debugging

Function Module & Function Groupsp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 52: Sap Abap Refresher Course NoRestriction

The following list is an overview of the main features of data types and

Data Types

e o o g st s a o e e o t e a eatu es o data types a dobjects:•Data types: A data type describes the technical attributes of all the objects with that type. There is no memory associated with data types.

Data types Predefined User-definedElementary C,D,F,I,N,P,T,X ABAP/4 Contains

eight predefined elementary data types

User defined elementary data typesare based on the yp yppredefined Elementary data types

Structured TABLE : Field Strings and internal tables :internal tables :

This predefined structured data type is used for the typing of formal parameters and field symbols

These structured data types can be used for data objects and are user defined.symbols user defined.

Reference Reference types describe data objects You will have to create your own that contain references (pointers) to references other

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

objects (data objects and objects in ABAP Objects).

Page 53: Sap Abap Refresher Course NoRestriction

•Predefined:

Elementary Data Types- Predefined:

Predefined elementary types are the smallest indivisible unit of types. They can be grouped as those with fixed length and those with variable length.g

•Fixed-Length Elementary Types:There are eight predefined types in ABAP with fixed length:

A)Four character types: Character (C), Numeric character (N), Date (D), and Time (T).

B)One hexadecimal type: Byte field (X)B)One hexadecimal type: Byte field (X).C)Three numeric types: Integer (I), Floating-point number (F)

and Packed number (P). •Variable-Length Elementary Types:

There are two predefined types in ABAP with variable length: STRING for character strings XSTRING for byte strings

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

STRING for character strings XSTRING for byte strings

Page 54: Sap Abap Refresher Course NoRestriction

Elementary Data Types - User Defined

User-defined:elementary data types are based entirely on predefined

elementary data types. To define your own elementary data types, you use the TYPES statement

Example:TYPES NUMBER TYPE ITYPES: NUMBER TYPE I.

DATA: NO_FLIGHTS TYPE NUMBER

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 55: Sap Abap Refresher Course NoRestriction

Structured Data types are made up of other types and generally are user

Structured Data Types:

defined. There are two kind of structured data types.•Field Strings:

A field string is a collection of other data types You Define FieldA field string is a collection of other data types.You Define Field string with the TYPES statement or with the DATA statement. structures as components.

Internal Tables:Internal tables consists of a several lines that all have the sameInternal tables consists of a several lines that all have the same

data type. Unlike field strings, which extends only horizontally, Internal Table also extends vertically.You define Internal Table with occurs parameter of the types or Data statement p ypInternal tables are characterized by:

The line type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

The key and The access method.

Page 56: Sap Abap Refresher Course NoRestriction

ABAP/4 Program Layout

To write a high quality program you should keep certain Layout o te a g qua ty p og a you s ou d eep ce ta ayoutstandards for ABAP/4 Programs. You should observe these standards as soon as you start defining your data. Follow when structuring your program flow, and use as many as informative comments as possible. If you follow these suggestions your program will be

• more readablemore readable

• easier to test and change

• more reliable

• To improve the quality of your programs, use the following Techniques:

Indenting statement blocks

Using Modularization Tools

Inserting Program comments

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Inserting Program comments

Page 57: Sap Abap Refresher Course NoRestriction

Indenting statement blocks

ABAP/4 Program Layout

You should combine statements that belong together into a single block . Indent each block by at least two columns.

Using Modularization ToolsUsing Modularization Tools

To produce good programs you should use modularization tools. If you write larger processing blocks as subroutines, the logical structure of

b i t id tif It l ll t t thyour program becomes easier to identify.It also allows you to sort the subroutines according to the tasks they perform.

Inserting Program comments Correctlyg g y

You should avoid placing comments on statement line. Placing them on separate comment lines improves the readability of the program.To insert subroutine headings and comments in your program use the ready-madesubroutine headings and comments in your program use the ready made structures available in ABAP/4 Editor.

Pretty Printer:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

The ABAP/4 Editor includes a tool which helps you to design the Layout of your program more easily. It follows ABAP/4 Layout guidelines

Page 58: Sap Abap Refresher Course NoRestriction

Inserting ready-made structures

Ready-made structures simplify the coding of ABAP/4 ProgramsReady-made structures simplify the coding of ABAP/4 Programs. They provide the exact syntax and follow the ABAP/4 layout guidelines.

Y i t t ki d f d d t t i tYou can insert two kinds of ready-made structures into your program code when using the ABAP/4 Editor:

A) Ready-Made Keyword Structures

To insert a ready-made keyword structure into your code, proceed as follows:

1. Place the cursor on the line where you want to insert the structure.

2.Choose EDIT --> Insert statement or select Pattern.

3 In the dialogue Box that appears choose a statement with3. In the dialogue Box that appears, choose a statement with radiobutton or enter it in the other instruct . Field: To display a list of all available ready-made keyword structures, place the cursor in other instruct field and click the possible entry button to the right of

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

other instruct. field and click the possible entry button to the right of the input field.

Page 59: Sap Abap Refresher Course NoRestriction

Inserting ready-made Comment Lines

B) Inserting Ready-Made Comment Lines:

To insert ready-made comment lines into your code, proceed as follows:

1.Follow steps 1 to 2 in inserting Ready-Made keyword1.Follow steps 1 to 2 in inserting Ready Made keyword structures.

2.Select a structure with an asterisk(*) as a first structure from the other instruct fieldthe other instruct. field.

3.The system inserts comment lines into your program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 60: Sap Abap Refresher Course NoRestriction

Data Objects

Data objects contain the data with which ABAP programs work at runtime.

ABAP contains the following kinds of data objects:ABAP contains the following kinds of data objects:

A) LiteralThey are not created by declarative statements Instead they existThey are not created by declarative statements. Instead, they exist

in the program code. They have fixed technical attributes but no name. Hence they are also referred to as unnamed data objects.

B) Named Data ObjectsYou declare these data objects either statically or dynamically atYou declare these data objects either statically or dynamically at

runtime. Their technical attributes are always fixed. ABAP contains the following kinds of named data objects:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 61: Sap Abap Refresher Course NoRestriction

Text symbols are pointers to texts in the text pool of the ABAP

Data Objects

Text symbols are pointers to texts in the text pool of the ABAP program. Variables are data objects whose contents can be changed using ABAP t t tABAP statements. Constants are data objects whose contents cannot be changed. Interface work areas are special variables that serve as interfaces between programs, screens, and logical databases.Predefined Data Objects

They do not have to be declared explicitly they are alwaysThey do not have to be declared explicitly - they are always available at runtime. Dynamic Data Objects

You create them dynamically using data references. They do not have a name.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 62: Sap Abap Refresher Course NoRestriction

•Internal data objects are created for use in one particular program. They

Internal Data objects

have no validity outside that program.

•Internal data objects include:A)Lit lA)Literal

- Text literals (using type c) Example: Data name(10) type c value ‘SATYAM’.

- Numeric literals (using type n)Example: Data Pincode(10) type n value '600024'.

B)VariablesB)Variables Example:

DATA: S1 TYPE I.SUM = S1 + 10.

C)Constants Example:

CONSTANTS PI TYPE P DECIMALS 10 VALUE '3.1415926536’.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 63: Sap Abap Refresher Course NoRestriction

External data objects

Data Objects

External data objects

External data objects exist independent of programs. You cannot work directly with them, but you can copy them to internal data objects y , y py jand write them back when you have finished. External data objects can be used globally throughout the system environment.

ABAP/4 stores external data objects in tables defined in the ABAP/4 Dictionary. To access this data from within a program, you declare the tables in the program with the TABLES statement .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 64: Sap Abap Refresher Course NoRestriction

System-defined data objects

Data Objects : Contd..

System-defined data objectsBesides user-defined data objects, some data objects are defined

automatically by the system. When you start an ABAP/4 program, some data objects are available automatically and do not need to be declared.data objects are available automatically and do not need to be declared. These are called System-defined data objects. They include:

Space:The data Object SPACE is a constant of type C. It is one character

long and contains a space.

System fields:All System fields have names with the format SY-<name>, where

<name> specifies an individual field. To display a list of available system fields in the ABAP/4 Editor type SHOW SY in the command linefields in the ABAP/4 Editor, type SHOW SY in the command line.

Example:SY-UNAME : login name of the userSY-DATUM : current date

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

SY-DATUM : current dateSY-UZEIT : current time

Page 65: Sap Abap Refresher Course NoRestriction

Special data objects

ABAP/4 includes some data objects with special features namely:ABAP/4 includes some data objects with special features, namely:

- Parameters

Parameters are variables which are linked to a selection screen. They can accept values after a program is started.

- Selection criteria

Selection criteria are special internal tables used to specify value ranges. They are linked to a selection screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 66: Sap Abap Refresher Course NoRestriction

Creating Data Objects and Types

Apart from literals, you must declare each data object with a declarative pa t o te a s, you ust dec a e eac data object t a dec a at estatement . In declarative statements, you must specify the data type of all data objects

You define the data type of an object in the declarative statement eitherYou define the data type of an object in the declarative statement, either

directly, using <declaration>…………TYPE<datatype>…………..

Indirectly, using <declaration>like<dataobject>…………..Indirectly, using <declaration>like<dataobject>…………..

•Type and like are optional additions to most of the data declaration yp pstatements listed below.

•With the TYPE option, you assign the data type<datatype>directly to the declared data objectdeclared data object.

•With the like option,you assign the data type of another data object<data object> to the declared data object.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 67: Sap Abap Refresher Course NoRestriction

Creating Data Objects and Data Types:

ABAP/4 includes the keywords for creating Data objects and Data types statically:

The Data statement for creating variables

Th C t t t t t f ti t tThe Constants statement for creating constants

The Statics statement for creating variables which exist as long

as the program runs but areas the program runs, but are

only visible in a procedure

The Tables system for creating table work areasThe Tables system for creating table work areas

The Type statement for creating user-defined data types

In the context of Internal Tables, you use the operational statements , y pAPPEND,COLLECT and INSERT to create lines of an Internal Tables dynamically.

In case of selection screens you use the additional statements

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

In case of selection screens,you use the additional statements PARAMETERS SELECT-OPTIONS to create Data objects with special function

Page 68: Sap Abap Refresher Course NoRestriction

Basic Form of the DATA Statement

•Data Statement

S t•Syntax

DATA <f>[(<length>)] <type> [<value>] [<decimals>].

In its basic form, the keyword DATA has the following parameters:

<f> Naming a Variablef Naming a Variable <length> <type> Specifying the Data Type and the Length of

the Variable <value> Specifying a Start Valuep y g<decimals> Specifying the Number of Digits after the

Decimal Point

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 69: Sap Abap Refresher Course NoRestriction

Constants,Static and Tables

If you use a constant frequently in a program, you can declare it as a you use a co sta t eque t y a p og a , you ca dec a e t as aFixed value variable with the CONSTANTS statement as follows:

Syntax: Constants<c>[<length>]<type><value>[<decimals>]

Statics StatementIf you want to retain the value of variable beyond the runtime of a

d d fi th i bl ith STATICS St t t i th tprocedure, you define the variable with STATICS Statement in that procedure.

Syntax: Statics<s>[<Length>]<type>[<Value>][<decimals>]Syntax: Statics<s>[<Length>]<type>[<Value>][<decimals>]

Tables statementWith the TABLES statement you can create a data object called aWith the TABLES statement, you can create a data object called a table work area. A Table work area is a field string which refers to ABAP/4 dictionary objects.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Syntax: Tables<dbtab>

Page 70: Sap Abap Refresher Course NoRestriction

The Types Statement

You use the TYPES statement to create user-defined elementary data types and structured data types. You can use data types defined by the TYPES statement in the same way you use predefined data types for d l i d t bj tdeclaring data objects.

Syntax: Types<t>[<length>]<<type>[<decimals>]

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 71: Sap Abap Refresher Course NoRestriction

TYPE GROUPS

You use Type-Groups to store user-defined data types or constants in the ABAP/4 Dictionary for cross program use.In your ABAP/4 program, you declare type groups with the TYPE-POOLS statement as:

S t T P lSyntax: Type-Pools<name>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 72: Sap Abap Refresher Course NoRestriction

Determining the Decimal Places

To determine the number of decimals for a Type P field, you use the DECIMALS parameter with the DESCRIBE FIELD statement as follows:

Syntax: Describe Field<f>Decimals<d>.Syntax: Describe Field<f>Decimals<d>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 73: Sap Abap Refresher Course NoRestriction

Determine the conversion routine

To determine whether a conversion routine exists for a field in ABAP/4 Dictionary use the EDIT MASK parameter with the Describe Field statement as follows:

Syntax: Describe Field<f>EDIT MASK<m>If a conversion routine exists for the field <f> in the ABAP/4 Dictionary, th t it it t th fi ld d t th t d l ithe system writes it to the field <m> and sets the return code value in the System Field SY-SUBRC equal to 0.You can then use the field <m> directly as a format template in a write statement , as below:

Write<f>using EDIT MASK<m>Write<f>using EDIT MASK<m>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 74: Sap Abap Refresher Course NoRestriction

2. ABAP WORKBENCH BASICS

Data Types & Data Objects

Internal Tables

Modularization of ABAP R/3

ABAP Runtime system : Debugging

Function Module & Function Groupsp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 75: Sap Abap Refresher Course NoRestriction

Internal Tables

Objective:

The following section explains :

• Defining Internal Tables

• Processing Internal Tables

A i I t l T bl• Accessing Internal Tables

• Initializing Internal Tables

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 76: Sap Abap Refresher Course NoRestriction

I t l t bl t t d d t t id d b ABAP/4

Internal Tables

Internal tables are structured data types provided by ABAP/4.Internal tables cannot be accessed outside the program environment.

Purpose of internal tables

• Internal tables are used to reorganize the contents of databaseInternal tables are used to reorganize the contents of databasetables according to the needs of your program

• Internal tables are used to perform calculations on subsets ofInternal tables are used to perform calculations on subsets ofdatabase tables.

• The number of lines in an internal table is not fixed• The number of lines in an internal table is not fixed.

• Internal tables exist only during the run time of a program.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 77: Sap Abap Refresher Course NoRestriction

•You access internal tables line by line. You must use a work area as an

Accessing Internal Tables

interface for transferring data to and from the table.

•When you read data from an internal table, the contents of the addressed t bl li it th t t f th ktable line overwrite the contents of the work area..

• When you write data to an internal table, you must first enter the data in the work area from which the system can transfer the data to the internalthe work area from which the system can transfer the data to the internal table.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 78: Sap Abap Refresher Course NoRestriction

There are two kinds of internal tables in ABAP/4:

Types of internal tables

There are two kinds of internal tables in ABAP/4:

· Internal tables with header line

If you create an internal table with header line, the system automatically creates a work area with the same data type as the lines of the internal table.

Note : Work area has the same name as the internal table.

· Internal tables without header line

Internal tables without a header line do not have a table workarea which can be used implicitly you must specify a work areaarea which can be used implicitly you must specify a work area explicitly.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 79: Sap Abap Refresher Course NoRestriction

Creating Internal Tables

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 80: Sap Abap Refresher Course NoRestriction

Creating Internal Tables

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 81: Sap Abap Refresher Course NoRestriction

Creating Internal Tables

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 82: Sap Abap Refresher Course NoRestriction

Filling Internal Tables

Appending Lines:To append a line to an internal table, use the APPEND statement as follows:

SyntaxAPPEND [<wa> TO] <itab>.

Eg: TYPES : BEGIN OF LINE,COL1 TYPE C,COL2 TYPE NCOL2 TYPE N,END OF LINE.

DATA TAB1 TYPE STANDARD TABLE OF LINE.

LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

APPEND LINE TO TAB1.

Page 83: Sap Abap Refresher Course NoRestriction

Filling Internal Tables

Appending Lines depending on the Standard Key (COLLECT STATEMENT)

To fill an internal table with lines which have unique standard keys.

S tSyntaxCOLLECT [<wa> INTO] <itab>

If an entry with the same key already exists(all non numeric fields) theIf an entry with the same key already exists(all non-numeric fields) the collect statement does not append a new line but adds the contents of the numeric fields in the work area to the contents of the numeric fields in the existing entryexisting entry

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 84: Sap Abap Refresher Course NoRestriction

Filling Internal Tables

Eg: TYPES : BEGIN OF LINE,COL1 TYPE C,COL2 TYPE I,END OF LINEEND OF LINE.

DATA ITAB1 TYPE STANDARD TABLE OF LINE.

ITAB1 COL1 = ‘A’ ITAB1 COL2 = ‘1’ITAB1-COL1 = A . ITAB1-COL2 = 1 .COLLECT TAB1.ITAB1-COL1 = ‘B’. ITAB1-COL2 = ‘2’.COLLECT TAB1.COLLECT TAB1.ITAB1-COL1 = ‘A’. ITAB1-COL2 = ‘1’.COLLECT TAB1.

This Produces the output as follows:A 2B 2

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 85: Sap Abap Refresher Course NoRestriction

Inserting lines :

Filling Internal Tables

se t g es

To insert a new line before a line in an internal table, you use the INSERT statement as follows:

Syntax

INSERT [ INTO] it b [INDEX id ]INSERT [<wa> INTO] <itab> [INDEX <idx>].

Eg: TYPES : BEGIN OF LINE,COL1 TYPE CCOL1 TYPE C,COL2 TYPE N,END OF LINE.

DATA TAB1 TYPE STANDARD TABLE OF LINEDATA TAB1 TYPE STANDARD TABLE OF LINE.LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.INSERT LINE INTO TAB1 INDEX 2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

INSERT LINE INTO TAB1 INDEX 2.

Page 86: Sap Abap Refresher Course NoRestriction

COPYING INTERNAL TABLES :

Filling Internal Tables

CO G S

To copy the entire contents of one internal table into another, use the MOVE statement.

Syntax:

MOVE <itab1> to <itab2>

Eg: TYPES : BEGIN OF LINE,COL1 TYPE C,COL2 TYPE NCOL2 TYPE N,END OF LINE.

DATA TAB1 TYPE STANDARD TABLE OF LINE.DATA TAB1 TYPE STANDARD TABLE OF LINE.DATA TAB2 TYPE STANDARD TABLE OF LINE.LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

MOVE TAB1[ ] TO TAB2.

Page 87: Sap Abap Refresher Course NoRestriction

Filli I t l T bl f D t b T bl

Filling Internal Tables

Filling Internal Table from Database Table:

Example

DATA : ITAB TYPE STANDARD TABLE OF SPFLI WITH HEADER LINE.

SELECT * FROM SPFLI INTO TABLE ITABSELECT FROM SPFLI INTO TABLE ITABWHERE CARRID = 'LH'.

LOOP AT ITAB.WRITE: / ITAB-CONNID, ITAB-CARRID.

ENDLOOP.In this example, all lines from the database table SPFLI in which CARRID field contains "LH" are read into the internal table ITAB, where they can be processed further.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 88: Sap Abap Refresher Course NoRestriction

T d d t t b t i t th i t l t bl

Filling Internal Tables

To read data component by component into the internal table.

In this example, all lines from the database table SPFLI in which CARRID field contains "LH" are read into the internal table ITAB1 one by one, where they can be processed further.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 89: Sap Abap Refresher Course NoRestriction

To read the contents of internal tables for further processing, you can use

Reading Internal Tables

either the LOOP or the READ statement.

Reading Internal Tables Line by Line

You use the the LOOP statement to read internal tables line by line.

LOOP AT <itab> [INTO <wa>] [WHERE <condition>]LOOP AT <itab> [INTO <wa>] [WHERE <condition>]......

ENDLOOP.

Eg: DO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX * SY-INDEX.APPEND LINE TO TAB1.ENDDO.LOOP AT TAB1 WHERE COL1 > 2.WRITE : / TAB1-COL1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDLOOP.

Page 90: Sap Abap Refresher Course NoRestriction

You can select a single line by the READ statement:

Reading Internal Tables

ou ca se ect a s g e e by t e state e t

Syntax:

READ TABLE <itab> [INTO <wa>] WITH KEY<key> [BINARY SEARCH].

Eg:TYPES BEGIN OF LINETYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINEEND OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMES. LINE-COL1 = SY-INDEX LINE-COL2 = SY-INDEX ** 2LINE COL1 SY INDEX. LINE COL2 SY INDEX 2.APPEND LINE TO TAB1.ENDDO.READ TABLE TAB1 INTO LINE WITH KEY COL2 = 4.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 91: Sap Abap Refresher Course NoRestriction

Reading Internal Tables

The COMPARING addition, the specified table fields <f i > of the structured e CO G add t o , t e spec ed tab e e ds i o t e st uctu edline type are compared with the corresponding fields of the work area before being transported. If the contents of the compared fields are the same, SY-SUBRC is set to 0. If the contents of the compared fields are not the same, it returns the value 2. Syntax:READ TABLE <itab> [INTO <wa>] INDEX <idx> COMPARING <fields>.EEg:

TYPES : BEGIN OF LINE,COL1 TYPE C,COL2 TYPE NCOL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMESDO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX ** 2.APPEND LINE TO TAB1.ENDDO.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

READ TABLE TAB1 INTO LINE INDEX 2 COMPARING COL1 COL2.

Page 92: Sap Abap Refresher Course NoRestriction

You can modify single line using MODIFY statement:

Modifying Internal tables

Syntax :MODIFY itab [FROM wa] [INDEX idx].MODIFY itab [FROM wa] [INDEX idx].

Eg:TYPES : BEGIN OF LINE,

COL1 TYPE CCOL1 TYPE C,COL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINEDATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX ** 2.APPEND LINE TO TAB1APPEND LINE TO TAB1.ENDDO.LINE-COL1 = ‘A’.MODIFY TAB1 FROM LINE INDEX 2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 93: Sap Abap Refresher Course NoRestriction

Modifying Internal tables

Syntax :

MODIFY itab [FROM wa] [TRANSPORTING f1 ... fn [WHERE cond]].

Eg:TYPES : BEGIN OF LINETYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINE.END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX ** 2.APPEND LINE TO TAB1.ENDDO.LINE-COL1 = ‘A’.

O O S O G CO CO

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

MODIFY TAB1 FROM LINE TRANSPORTING COL1 WHERE COL2 = 4.

Page 94: Sap Abap Refresher Course NoRestriction

Deleting Internal tables

T d l t li f i t l t bl i lTo delete lines from an internal table in a loop:

Syntax:

DELETE <itab>DELETE <itab>.

Note: The System can process this statement only within an LOOP..ENDLOOP block.

Eg: DO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX * SY-INDEX.APPEND LINE TO TAB1APPEND LINE TO TAB1.ENDDO.LOOP AT TAB1.IF TAB1-COL1 > 2IF TAB1 COL1 > 2.DELETE TAB1.ENDIF.

ENDLOOP.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 95: Sap Abap Refresher Course NoRestriction

TO d l t th li i I d

Deleting Internal tables

TO delete the lines using Index.

Syntax:

DELETE <itab> INDEX <idx>DELETE <itab> INDEX <idx>.

Eg:TYPES : BEGIN OF LINE,TYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMES. LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX * SY-INDEX.APPEND LINE TO TAB1.ENDDO.DELETE TAB1 INDEX 2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 96: Sap Abap Refresher Course NoRestriction

Deleting Internal tables

TO delete the Adjacent Duplicates from the Internal Table.

Syntax:

DELETE ADJACENT DUPLICATE ENTRIES FROM it b [ COMPARINGDELETE ADJACENT DUPLICATE ENTRIES FROM <itab> [ COMPARING <comp>]

Eg:TYPES : BEGIN OF LINETYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINE.END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1.LINE-COL1 = ‘A’. LINE-COL2 = ‘2’.APPEND LINE TO TAB1.DELETE ADJACENT DUPLICATE ENTRIES FROM TAB1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

COMPARING COL1.

Page 97: Sap Abap Refresher Course NoRestriction

TO d l t th Adj t D li t f th I t l T bl

Deleting Internal tables

TO delete the Adjacent Duplicates from the Internal Table.

Syntax:

DELETE ADJACENT DUPLICATE ENTRIES FROM <itab> [ COMPARINGDELETE ADJACENT DUPLICATE ENTRIES FROM <itab> [ COMPARING <comp>]

Eg:TYPES : BEGIN OF LINE,TYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.LINE-COL1 = ‘A’. LINE-COL2 = ‘2’.APPEND LINE TO TAB1.LINE-COL1 = ‘A’. LINE-COL2 = ‘2’.APPEND LINE TO TAB1.DELETE ADJACENT DUPLICATE ENTRIES FROM TAB1

COMPARING ALL FIELDS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

COMPARING ALL FIELDS.

Page 98: Sap Abap Refresher Course NoRestriction

Deleting Internal tables

TO delete a set of selected lines from the Internal Table.

Syntax:

DELETE it b [FROM 1 ] [TO 2 ] [WHERE diti ]DELETE <itab> [FROM <n1>] [TO <n2>] [WHERE <condition>].

Eg:TYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1APPEND LINE TO TAB1.LINE-COL1 = ‘A’. LINE-COL2 = ‘2’.APPEND LINE TO TAB1.DELETE TAB1 WHERE COL2 = 2

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

DELETE TAB1 WHERE COL2 = 2.

Page 99: Sap Abap Refresher Course NoRestriction

Sorting Internal Table

TO Sort an Internal Table .

Syntax:

SORT <itab> [<order>] [AS TEXT] [BY <f1> [<order>] [AS TEXT] . . <fn> [<order>] [AS TEXT] ] .

Eg:Eg:

TYPES : BEGIN OF LINE,COL1 TYPE C,COL2 TYPE NCOL2 TYPE N,END OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.LINE-COL1 = ‘A’ LINE-COL2 = ‘2’LINE COL1 A . LINE COL2 2 .APPEND LINE TO TAB1.LINE-COL1 = ‘A’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

SORT TAB1 BY COL2 ASCENDING .

Page 100: Sap Abap Refresher Course NoRestriction

Loop Processing

Calculating the totals within loop…endloop.Ca cu at g t e tota s t oop e d oop

Syntax: SUM

Eg.TYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE I,END OF LINEEND OF LINE.

DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.DO 3 TIMES. LINE COL1 = SY INDEX LINE COL2 = SY INDEX ** 2LINE-COL1 = SY-INDEX. LINE-COL2 = SY-INDEX ** 2.APPEND LINE TO TAB1.ENDDO.LOOP AT TAB1LOOP AT TAB1.SUM.ENDLOOP.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 101: Sap Abap Refresher Course NoRestriction

Using Control Levels

This topic describes how to use control level statement blocks which s top c desc bes o to use co t o e e state e t b oc s cprocess only specific values within loop…endloop.

Syntax:

AT <line><statement block>

ENDAT.

The line condition <line>, at which the statement block within AT-ENDAT. <Line> Meaning FIRST First line of the internal table LAST Last line of the internal table NEW <f> Beginning of a group of line with same contents

in the fields <f> & in the fields of <f>. END OF <f> E d f f li ith t t iEND OF <f> End of a group of line with same contents in the fields <f> & in the fields of <f>.

Note: Before working with control breaks, You should sort the internal

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

table in the same order as its columns are defined.

Page 102: Sap Abap Refresher Course NoRestriction

Using Control Levels

Hierarchy of AT-ENDAT statementHierarchy of AT-ENDAT statement.

If the internal table has the columns <col1>,<col2>,… and if it is sorted by the columns as they are defined, the loop is to be programmed as f llfollows:LOOP AT <itab>.

AT FIRST. …..ENDAT.AT NEW <col1>….ENDAT.

AT NEW <col2>……ENDAT.…….<single line processing>……...AT END OF < l2> ENDATAT END OF <col2>…..ENDAT.

AT END OF <col1>……ENDAT.AT LAST……ENDAT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDLOOP.

Page 103: Sap Abap Refresher Course NoRestriction

Using Control Levels

Example:Example:TYPES : BEGIN OF LINE,

COL1 TYPE C,COL2 TYPE ICOL2 TYPE I,END OF LINE.DATA TAB1 TYPE TABLE OF LINE WITH HEADER LINE.LINE-COL1 = ‘A’ LINE-COL2 = ‘2’LINE-COL1 = A . LINE-COL2 = 2 .APPEND LINE TO TAB1.LINE-COL1 = ‘B’. LINE-COL2 = ‘1’.APPEND LINE TO TAB1.APPEND LINE TO TAB1.LINE-COL1 = ‘A’. LINE-COL2 = ‘3’.APPEND LINE TO TAB1.LINE-COL1 = ‘C’. LINE-COL2 = ‘4’.APPEND LINE TO TAB1.SORT TAB1 BY COL1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 104: Sap Abap Refresher Course NoRestriction

Using Control Levels

ContCont..LOOP AT TAB1.

AT FIRST.WRITE:/ ‘HEADING’.

ENDAT. AT NEW COL1.

WRITE:/ TAB1-COL1.ENDATENDAT.AT END OF COL1.

SUM.WRITE:/ TAB1-COL1, TAB1-COL2.,

ENDAT. AT LAST. SUM.

WRITE:/ TAB1-COL1, TAB1-COL2. ENDAT.WRITE:/ TAB1 COL1, TAB1 COL2. ENDAT.ENDLOOP.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 105: Sap Abap Refresher Course NoRestriction

Initializing Internal Tables

T i iti li i t l t bl ith ith t h d liTo initialize an internal table with or without header line.

Syntax :REFRESH <itab>.

This statement resets an internal table.

CLEAR <itab>.If you are working with an internal table with a header line , the clearIf you are working with an internal table with a header line , the clear statement clears only the table work area resetting to initial values.

CLEAR <itab>[ ].The square bracket after the name of the internal table refer to the body ofThe square bracket after the name of the internal table refer to the body of the internal table.This statement also resets an internal table.

FREE <itab>.You can release the memory with the FREE statement once initialized.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 106: Sap Abap Refresher Course NoRestriction

Initializing Internal Tables

Example:

TYPES : BEGIN OF LINE,COL1 TYPE C,COL1 TYPE C,COL2 TYPE I,END OF LINE.DATA TAB1 .

LINE-COL1 = ‘A’. LINE-COL2 = ‘2’.APPEND LINE TO TAB1.LINE-COL1 = ‘B’. LINE-COL2 = ‘1’.

APPEND LINE TO TAB1.CLEAR TAB1.REFRESH TAB1REFRESH TAB1.IF TAB1 IS INITIAL.WRITE:/ ‘TAB1 IS EMPTY’.FREE TAB1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

FREE TAB1.ENDIF.

Page 107: Sap Abap Refresher Course NoRestriction

2. ABAP WORKBENCH BASICS

Data Types & Data Objects

Internal Tables

Modularization of ABAP R/3

ABAP Runtime system : Debugging

Function Module & Function Groupsp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 108: Sap Abap Refresher Course NoRestriction

Modularizing ABAP/4 Programs

Objective:

The following section explains :

• Include Programs

• Macros

• Subroutines

• Passing Data

• Terminating Subroutines

• Field Symbols

Clusters• Clusters

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 109: Sap Abap Refresher Course NoRestriction

Each ABAP/4 program has a modular structure.

Modularizing ABAP/4 Programs

ac / p og a as a odu a st uctu e

ABAP/4 programs are divided into:

· Processing blocks that are controlled by events when the program is a report program ( program of type 1).

· Modules that are controlled by the screen flow logic when the program is an dialog program (module pool of type M) You can modularize eitheran dialog program (module pool of type M). You can modularize either your source code or tasks which are to be performed repeatedly.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 110: Sap Abap Refresher Course NoRestriction

Source Code Modularization

To modularize source codes the following two methods apply:

a. Include programs

b Macrosb. Macros

To modularize tasks the following two methods apply:To modularize tasks the following two methods apply:

a. Subroutine

b. Functional modules

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 111: Sap Abap Refresher Course NoRestriction

Include Programs

If you want to use the same sequence of statements in several programs, you can code them once in an include program.

Example - In the case of lengthy data declarations.

How to create include programs ?

How to use Include programs ?

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 112: Sap Abap Refresher Course NoRestriction

Defining and Calling Macros

You can create callable modules of program code within your ABAP/4 program by defining macrosprogram by defining macros.

To define a macro which contains part of the source code, you use the DEFINE statement as follows:DEFINE statement as follows:

Syntax:DEFINE <macro>.

<statements>END-OF-DEFINITION.

f fThis defines the macro <macro>. You must specify complete statements between DEFINE and END-OF-DEFINITION.

Note : Debugger does not stop at break points applied at Macro

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Note : Debugger does not stop at break-points applied at Macro.

Page 113: Sap Abap Refresher Course NoRestriction

Subroutines

Subroutines are program modules which can be called from ABAP/4 programs.

There are two types of subroutines.

I t l b ti· Internal subroutines:The source code of internal subroutines is in the same ABAP/4 program as the calling procedure (internal call).

· External subroutines:The source code of external subroutines is in an ABAP/4 program other than the calling procedure (external call)than the calling procedure (external call).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 114: Sap Abap Refresher Course NoRestriction

Defining Subroutines

A subroutine is a block of code introduced by FORM and concluded by ENDFORM T d fi b ti th f ll i tENDFORM. To define a subroutine, use the following syntax:

Syntax:FORM <subr> [<pass>]FORM <subr> [<pass>].

<statement block>ENDFORM.

<subr> - The name of the subroutine.<pass> - You specify how to pass data to and from the

subroutine {mainly for external call}.{ y }

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 115: Sap Abap Refresher Course NoRestriction

1 Calling Internal Subroutines:

Calling Subroutines

1. Calling Internal Subroutines:

To call an internal subroutine, use the PERFORM statement as follows:Syntax:Syntax:PERFORM <subr> [<pass>].

2. Calling External Subroutines:

To call an external subroutine, use the PERFORM statement as follows:Syntax:PERFORM <subr>(<prog>) [<pass>] [IF FOUND].

[<pass>] can be interpreted as :

[TABLES itab1 itab2 ...] [USING a1 a2 ...] [CHANGING a1 a2 ...]

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 116: Sap Abap Refresher Course NoRestriction

Calling Subroutines

Note:

· In the case of internal subroutines, you do not have to use the <pass> option, because the subroutine can access all data objects declared inoption, because the subroutine can access all data objects declared inthe main ABAP/4 program.

· In the case of external subroutines, you must decide whether to use the y<pass> option or declare data objects in common parts of the memory.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 117: Sap Abap Refresher Course NoRestriction

Passing Data

Passing Data Between Calling Programs and Subroutines:

1. Declaring Data as Common Part1. Declaring Data as Common Part

2. Passing Data by Parameters

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 118: Sap Abap Refresher Course NoRestriction

Declaring Data As Common Part

To declare data objects as common part, use the DATA statement as follows:

Syntax:

DATA: BEGIN OF COMMON PART [<name>],d t d l ti<data declaration>,

..............END OF COMMON PART [<name>].

You can use several common parts in one program. In this case, you must assign a name <name> to each common part. If you use only one common part per program, the name <name> is optional.common part per program, the name <name> is optional.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 119: Sap Abap Refresher Course NoRestriction

Passing Data By Parameters

You can pass data between calling programs and subroutines by using parameters. · Parameters which are defined during the definition of a subroutine with gthe FORM statement are called formal parameters.· Parameters which are specified during the call of a subroutine with the PERFORM statement are called actual parameters.

Syntax:PERFORM <subr>[(<prog>)] [TABLES <actual table list>]

[USING t l i t li t ][USING <actual input list>][CHANGING <actual output list>]

FORM <subr> [TABLES <formal table list>]FORM <subr> [TABLES <formal table list>][USING <formal input list>]

[CHANGING <formal output list>]

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 120: Sap Abap Refresher Course NoRestriction

Different Methods Of Passing Data

Calling by Reference : During a subroutine call, only the address of the actual parameter is transferred to the formal parameters. The formal

t h f it If h th f l tparameter has no memory of its own. If you change the formal parameter, the field contents in the calling program also change.

Calling by Value : During a subroutine call the formal parameters areCalling by Value : During a subroutine call, the formal parameters are created as copies of the actual parameters. The formal parameters have memory of their own. Changes to the formal parameter have no effect on the actual parameter.the actual parameter.

Calling by Value and Result : During a subroutine call, the formal parameters are created as copies of the actual parameters. The formal p p pparameters have their own memory space. Changes to the formal parameters are copied to the actual parameter at the end of the subroutine.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 121: Sap Abap Refresher Course NoRestriction

Passing By Reference

To pass data between calling programs and subroutines by reference, use USING or CHANGING for the <pass> option of the FORM and PERFORMUSING or CHANGING for the <pass> option of the FORM and PERFORM statements as follows:

Syntax:Syntax:PERFORM... [USING <ai1> ... <ain>] [CHANGING <ao1> ... <aon>] …FORM ..... [USING <fi1> ... <fin>] [CHANGING <fo1> ... <fon>] ...

You specify the formal and actual parameters in the list behind USING and CHANGING without any addition.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 122: Sap Abap Refresher Course NoRestriction

Passing By Value

To ensure that an input parameter is not changed in the calling programTo ensure that an input parameter is not changed in the calling program, even if it is changed in the subroutine, you can pass data to a subroutine by value. For this, use USING for the <pass> option of the FORM and PERFORM statements as follows:PERFORM statements as follows:

Syntax:PERFORM... USING .......<aii> ..FORM ..... USING ...VALUE(<fii>) ..

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 123: Sap Abap Refresher Course NoRestriction

Passing By Value And Result

If you want to return a changed output parameter from a subroutine to the y g p pcalling program only after the subroutine has run successfully, use CHANGING for the <pass> option of the FORM and PERFORM statements as follows:

Syntax:FORM ..... CHANGING ...VALUE(<fii>) ..PERFORM CHANGING < ii>PERFORM... CHANGING .......<aii> ..

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 124: Sap Abap Refresher Course NoRestriction

Example

REPORT FORMTEST.

DATA:DATE1 TYPE D, DATE2 TYPE T,STRING1(6) TYPE C STRING2(8) TYPE CSTRING1(6) TYPE C, STRING2(8) TYPE C,NUMBER1 TYPE P DECIMALS 2, NUMBER2 TYPE P,COUNT1 TYPE I, COUNT2 TYPE I.PERFORM TYPETEST USING DATE1 STRING1 NUMBER1 COUNT1PERFORM TYPETEST USING DATE1 STRING1 NUMBER1 COUNT1.PERFORM TYPETEST USING DATE2 STRING2 NUMBER2 COUNT2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 125: Sap Abap Refresher Course NoRestriction

Example

Cont..

FORM TYPETEST USING NOWFORM TYPETEST USING NOWTXT TYPE CVALUE(NUM) TYPE PINT TYPE I.DATA: T.DESCRIBE FIELD NOW TYPE T.WRITE: / 'Type of NOW is', T.DESCRIBE FIELD TXT LENGTH T.WRITE: / 'Length of TXT is', T.DESCRIBE FIELD NUM DECIMALS T.WRITE: / 'Decimals of NUM are' TWRITE: / 'Decimals of NUM are', T.DESCRIBE FIELD INT TYPE T.WRITE: / 'Type of INT is', T.ENDFORM

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDFORM.

Page 126: Sap Abap Refresher Course NoRestriction

Example

Example of passing internal tables:

PROGRAM FORM_TEST.

DATA: BEGIN OF LINE,CO 1COL1 TYPE I,COL2 TYPE I,END OF LINE.

DATA ITAB LIKE STANDARD TABLE OF LINE.

PERFORM FILL CHANGING ITABPERFORM FILL CHANGING ITAB.

PERFORM OUT USING ITAB.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 127: Sap Abap Refresher Course NoRestriction

Cont..

Example

Co t

FORM FILL CHANGING F_ITAB LIKE ITAB.DATA F_LINE LIKE LINE OF F_ITAB.DO 3 TIMES.

F_LINE-COL1 = SY-INDEX.F_LINE-COL2 = SY-INDEX ** 2.APPEND F LINE TO F ITABAPPEND F_LINE TO F_ITAB.

ENDDO.ENDFORM.

FORM OUT USING VALUE(F_ITAB) LIKE ITAB.DATA F_LINE LIKE LINE OF F_ITAB.LOOP AT F ITAB INTO F LINELOOP AT F_ITAB INTO F_LINE.

WRITE: / F_LINE-COL1, F_LINE-COL2.ENDLOOP.ENDFORM.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 128: Sap Abap Refresher Course NoRestriction

Terminating Subroutines

To terminate the processing of a subroutine, you can proceed in a similar way as for terminating a loop by using the EXIT or CHECK statements.

· Use EXIT to terminate a subroutine unconditionally.U CHECK t t i t b ti di t diti· Use CHECK to terminate a subroutine according to a condition.

If you terminate a subroutine using EXIT or CHECK, the system terminates the processing of the subroutine at this point passes theterminates the processing of the subroutine at this point, passes the parameters, and continues with the statement after the PERFORM statement.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 129: Sap Abap Refresher Course NoRestriction

Field Symbols

Field symbols are placeholders or symbolic names for other fields. They d t h i ll f fi ld b t i t t it t t Ado not physically reserve space for a field, but point to its contents. A field symbol can point to any data object. The data object to which a field symbol points is assigned to it after it has been declared in the program.

To declare a Field Symbol, use the statement,FIELD-SYMBOLS <FS> [<type>|STRUCTURE <s> DEFAULT <wa>].

Typing Field Symbols:The <type> addition allows you to specify the type of a field symbol.Syntax:FIELD-SYMBOLS <FS> <type>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 130: Sap Abap Refresher Course NoRestriction

E l

Field Symbols

Example:

DATA: WA(10) VALUE '0123456789'.DATA: BEGIN OF LINE1,COL1(3),COL2(2),COL3(5)COL3(5),END OF LINE1.

DATA: BEGIN OF LINE2DATA: BEGIN OF LINE2,COL1(2),COL2 LIKE SY-DATUM,END OF LINE2END OF LINE2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 131: Sap Abap Refresher Course NoRestriction

Field Symbols

Cont..

FIELD-SYMBOLS: <F1> STRUCTURE LINE1 DEFAULT WA,<F2> STRUCTURE LINE2 DEFAULT WA.WRITE: / <F1>-COL1, <F1>-COL2, <F1>-COL3,/ <F2>-COL1, <F2>-COL2.

The output is:

012 34 56789012 34 5678901 2345/67/89

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 132: Sap Abap Refresher Course NoRestriction

Static Assign:

Field Symbols

The name of the data object you want to assign to a field symbol before run time.

S tSyntax:

ASSIGN <f> TO <FS>.

Eg:Eg:

FIELD-SYMBOLS: <F1> , <F2> TYPE I.DATA : NUM TYPE I VALUE 5,TEXT(10) TYPE C VALUE ‘HELLO’.ASSIGN TEXT TO <F1>.ASSIGN NUM TO <F2>.WRITE: / <F1> <F2>WRITE: / <F1> , <F2>.

OUTPUT:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

HELLO 5

Page 133: Sap Abap Refresher Course NoRestriction

Dynamic Assign:

Field Symbols

y a c ss g

The name of the data object you want to assign to a field symbol only at run time.

Syntax:Syntax:

ASSIGN (<f>) TO <FS>.

Eg:Eg:

PROGRAM SAPMZTST.PERFORM FORM1(SAPMZTST1). * Calling Subroutine

PROGRAM SAPMZTST1.FORM FORM1.FIELD-SYMBOLS <F1>.DATA : NUM TYPE N VALUE 5.ASSIGN (NUM) TO <F1>.WRITE: / <F1>.ENDFORM

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDFORM.OUTPUT: 5

Page 134: Sap Abap Refresher Course NoRestriction

Clusters

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 135: Sap Abap Refresher Course NoRestriction

Data Clusters

You can store data clusters in ABAP/4 memory.ABAP/4 memory is not dependent on the ABAP/4 program or program module which generates it during a transaction. This means that an object stored in ABAP/4 memory can be read again by any ABAP/4 program during the same transaction.

For example, you can pass data between:· Reports and other Reports called with SUBMIT

Transactions and Reports· Transactions and Reports· Programs and Function Modules

Note :Note :The memory is released again when you leave the transaction.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 136: Sap Abap Refresher Course NoRestriction

Storing Data Objects In ABAP/4 Memory

To write data objects from an ABAP/4 program to ABAP/4 memory, you use the following statement:

Syntax:

EXPORT <f1> <f2> ... TO MEMORY ID <key>.EXPORT <f1> <f2> ... TO MEMORY ID <key>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 137: Sap Abap Refresher Course NoRestriction

Reading Data Objects From Memory

To read data objects from ABAP/4 memory into an ABAP/4 program, youTo read data objects from ABAP/4 memory into an ABAP/4 program, you use the following statement:

Syntax:

IMPORT <f1> [TO <g1>] <f2> [TO <g2>] ... FROM MEMORY ID <key>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 138: Sap Abap Refresher Course NoRestriction

2. ABAP WORKBENCH BASICS

Data Types & Data Objects

Internal Tables

Modularization of ABAP R/3

ABAP Runtime system : Debugging

Function Module & Function Groupsp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 139: Sap Abap Refresher Course NoRestriction

OBJECTIVES

The slides for the ABAP/4 Development Workbench’s on line Debuggers C t i th f ll i t iContain the following topics:

•Online debugging tools•Starting the debugger•Starting the debugger•The debugger’s views•Using break points•Setting static break pointsSetting static break points•Setting dynamic break points•Setting watch points•Setting breakpoints at keywords or eventsg p y•Deleting and deactivating breakpoints•Stepping through program codes•Displaying field contents

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 140: Sap Abap Refresher Course NoRestriction

Debugging•Displaying Internal tables•Displaying ABAP/4 lists•Replacing field values at runtime•Changing internal tables at runtimeS it hi t th ABAP/4 Edit•Switching to the ABAP/4 Editor

•Releasing the database during debugging

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 141: Sap Abap Refresher Course NoRestriction

•Online debugging tools : A reviewDebugging

The ABAP/4 Debugger lets you stop a program during runtime andexamine the flow and results of each statement during execution.St i th h ith th d b h l t d t t dStepping through a program with the debugger helps you to detect andcorrect errors in your code.This documentation is designed fordevelopers new to the Workbench’s debugging facilities or for those whowant to learn the tool to use the tool more effectivelywant to learn the tool to use the tool more effectively.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 142: Sap Abap Refresher Course NoRestriction

Debugging

After working through this slides , you should be able to debug both familiar and unfamiliar programs effectively. With this slides, you will learn how to

•Switch on the debugger•Set and delete static and dynamic break points.•Set watch points•Set watch points•Stop a program at specific key words or events or when a field contents change.•Continue processing after an interrupt.Continue processing after an interrupt.•Display field contents during runtime.•Display the contents of an internal table.•Change field contents for testing purposes.g g p p•Change the contents of an internal table.•Display and use debugger’s views.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 143: Sap Abap Refresher Course NoRestriction

Debugging

Debugging Strategies form within ABAP/4 Development Work bench. We t b k i t i d th t t th ithi thcan set breakpoints in a program and then start the program within the

Debugger.Alternatively, we can run the program in the debugger without any breakpoints.

A Breakpoint is a signal within a line of code that tells the ABAP/4runtime processor to interrupt the program at the line.Setting breakpoints is a good strategy if we want to examine a program:points is a good strategy if we want to examine a program:

After the system has already processed certain eventsJust before a specific event is carried outBy skipping quickly to a specific routines or calls.y pp g q y p

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 144: Sap Abap Refresher Course NoRestriction

•Starting the DebuggerDebugging

On running a program in the debugging mode the following steps can be followed.

In the object browser ,Select a report or transaction.Choose debugging in the ABAP/4 editor initial screenChoose debugging in the ABAP/4 editor initial screenChoose Program Execute Debugging or choose debugging.From any screen , Choose System Utilities Debug ABAP/4.

•Debugger’s views

A debugger selects different views , by selecting appropriate view name gg , y g pp pin debugger’s menu.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 145: Sap Abap Refresher Course NoRestriction

Debugging

Th b tt h f ll i ifi iThese buttons has following specific meaning.

Overview - Displays the structure of the program to be debuggeddebugged.

Call stack - Displays an active event chain and the call sequence up to the current breakpoint.

Fields - Displays the fields content and technicalFields Displays the fields content and technical characteristics.

Table - Displays the content of an internal table.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 146: Sap Abap Refresher Course NoRestriction

•Structure of the Debugging view.Debugging

Each debugging view has the same structure. The top half of the screendisplays a portion of the programs source code. The lower half showsi f ti ifi t th t ti l i At th Li ‘S C d f’information specific to that particular view .At the Line ‘Source Code of’appears two push buttons to scroll through the program code.

The line currently ready for processing is indicated by “>” A small stopThe line currently ready for processing is indicated by > .A small stopsign appears to the left of each dynamic break point .Using Breakpoints

A breakpoint is a signal within a program’s code , which tells the ABAP/4processor to interrupt the program at a particular point. The type ofbreakpoint depends on the purpose of debugging.p p p p gg g

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 147: Sap Abap Refresher Course NoRestriction

DebuggingABAP Debugging Screen

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 148: Sap Abap Refresher Course NoRestriction

Debugging

Following are the types of breakpoints.

•Static Th i d d t t di tl i t ’ d ith thThese are user independent , set directly into a program’s code with the editor. User dependent breakpoints also is possible.

•Dynamic•Dynamic Set within the ABAP/4 debugger or editor. This type is visible when the program is displayed in the editor.

•Watch points Set within the ABAP/4 debugger .Watch points are field-specific. This is used to observe changes to a particular field .The debugger interrupts g p gg pthe program when fields content change.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 149: Sap Abap Refresher Course NoRestriction

•Key word (statement) or event breakpointsDebugging

Set within the ABAP/4 debugger. The debugger interrupts the programwhen the ABAP/4 processor comes in contact with a specific key word(statement) or event in program’s code.

•When a static breakpoint is used?Static break point are generally user-independent. On setting this

breakpoint , every use who executes the program encounters thebreakpoint , every use who executes the program encounters thebreakpoint. This is used when several developers are working in the sameprogram, and all wants to the program to interrupt at the same placeduring execution.g

These breakpoints are visible in the programs code.

•When a dynamic breakpoint is used?Dynamic break point is user-specific. If we want to interrupt a

program when we execute and while others are running, we use dynamicbreak-point.

D namic breakpoints are more fle ible than static breakpoint the

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Dynamic breakpoints are more flexible than static breakpoint , theycan be removed or deactivated during runtime.

Page 150: Sap Abap Refresher Course NoRestriction

•When to use watch points.

Debugging

e to use atc po ts

We can set watchpoints only from within the debugger.They are useful ifwe want to interrupt a program only when there is a change in a particularfield or a field string. We can set and remove watch points asNeeded .This , as dynamic breakpoint , does not disturb the other usersof the same program.

•When to use breakpoints at Keywords (statements) or Events.

From within debugger we can allocate breakpoint for specific ABAP/4From within debugger , we can allocate breakpoint for specific ABAP/4keywords or program events.This is useful if we do not know exactly where a key word or event occurs

but still want the program to be interrupted just before the command or, but still want the program to be interrupted just before the command orevent is carried out.

•Setting Static Breakpoints.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

g pTo set a static break point use ‘BREAK-POINT’ keyword.Place the break point on the line where to interrupt the program:

Page 151: Sap Abap Refresher Course NoRestriction

REPORT RSDEBUG1Debugging

……………CHECK ACCOUNT

IF SY SUBRC NE 0IF SY-SUBRC NE 0.BREAK-POINT.

ENDIF.…….When we start the report , ABAP/4 interrupts the processing at the breakpoint.We can number breakpoints like BREAK-POINT1 ,BREAK-POINT2..forWe can number breakpoints like BREAK POINT1 ,BREAK POINT2..foreasier identification.

•Removing Breakpoints.g pIt is necessary to remove the breakpoints after debugging .Use functionUtilities Global search to help in locating break-points in largerprograms. It is necessary to remove breakpoints since it may cause

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

serious disruptions in productive process.

Page 152: Sap Abap Refresher Course NoRestriction

•Setting Dynamic BreakpointsDebugging

We can set dynamic breakpoint , without changing the program’s code.Following are the steps to set a breakpoint in ABAP/4 Editor.

Place the cursor on the line where to position the breakpoint.

Choose Utilities > Breakpoint Set or press the ‘stop’ pushbutton at theChoose Utilities --> Breakpoint Set or press the stop pushbutton at thetop.

A display of all breakpoints in a program can be obtained by selectingA display of all breakpoints in a program can be obtained by selecting

Utilities Breakpoint Display .

The dynamic breakpoint display leads to navigate to a certain breakpointor delete one or all breakpoints from the program code.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 153: Sap Abap Refresher Course NoRestriction

•Setting Watchpoints.Debugging

A watch point is set to interrupt a program when the contents of aspecific field or a string change.F ll i th t t t t h i tFollowing are the steps to set a watch point.

•On the Debugging editor, enter the table-field.•Press the pushbutton ‘Watchpoint’ on the top left .•A dialog box appears asking for the ‘local watch point’•A dialog box appears , asking for the local watch point ,relational operator and comparison field .Fill in as perrequirement.

•Fill the appropriate value in the text field next and press•Fill the appropriate value in the text field next and pressthe tick .•A display of watch points can be viewed by goto-->Controldebugging--> Watchpoint.gg g p

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 154: Sap Abap Refresher Course NoRestriction

•Setting Breakpoints at (statements) keywords or subroutines.Debugging

If we want to interrupt the program directly before a certain keyword eventor a subroutine , we use this facility.W hi thi ith th f ll i t i th ditWe can achieve this with the following steps in the editor.

•Choose either Breakpoint Breakpoint at Statement orsubroutine or function modulesubroutine or function module.

•The system will display a small screen prompting to enterstatement keyword or subroutine etc., as per requirement.statement keyword or subroutine etc., as per requirement.

The system will set a breakpoint each time the statement ,or subroutine appears in the program.pp p g

•For break point in form routines , it is possible to access thecurrent program , not external subroutine calls.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 155: Sap Abap Refresher Course NoRestriction

•Deleting a dynamic Break-point.Debugging

To delete a dynamic breakpoint , place the cursor in a line and chooseBreakpoint Set/Delete or Delete.Deleting this breakpoint is also possible by double clicking the

i t liappropriate line.

From within the editor, deleting the dynamic breakpoint is done by thefollowing stepsfollowing steps.

•Choose Goto--> Control Debugging-->Breakpoint.•The System will list all the breakpoints.•The System will list all the breakpoints.•Select one breakpoint.•Choose individual by double clicking on the icon ‘Stop’and it deletes .

Temporary deleting of Dynamic breakpoint is possible by selecting theappropriate line and select Breakpoint Deactivate/Activate in the abap

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Debugger.

Page 156: Sap Abap Refresher Course NoRestriction

•Deleting Watchpoints.Debugging

Watch points are special break points set for specific fields. To remove awatch point , the following steps will do.

Ch G t C t l d b i W t h i tChoose Goto --> Control debugging-->Watchpoint.A display of the watch point occurs , and can be deleted by pressing‘delete’ checkbox at the end of each Watchpoint .

•Displaying the Location of breakpoints.

Select Goto--> Control Debugging -->Breakpoints to get an overview ofall existing breakpoints in a program’s code.From the breakpoint display , it is possible to set or delete individualp p y , pbreakpoints.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 157: Sap Abap Refresher Course NoRestriction

•Stepping through program code.

Debugging

From within the debugger several options for stepping through theprogram.

Single step : Execute a program statement by statement. If single step ischosen while on a line that calls a FORM routine , for example the nextmouse click carries to the called routine After stepping the way throughmouse click carries to the called routine.After stepping the way throughthe subroutine, returns to the line of code directly following thesubroutine call.

Execute : Process a program line by line. On choosing Execute while ona line, that calls a FORM routine, the debugger executes the subroutinesubroutine and halts at the line of code directly following the call.y gThus this skips over the lines of the subroutine itself.

Continue: Processes the program up to the next active dynamic or static

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

break point. If no further breakpoints exists, the system executes thereport in its entirety without stopping.

Page 158: Sap Abap Refresher Course NoRestriction

Debugging

Return: Returns the debugger to where a calling program resumescontrol.Can be used from within a subroutine call.

Di l i th fi ld t t•Displaying the field contents.

While debugging display of the critical of the critical contents of the fieldsare possibleare possible.Display of the contents up to eight fields or field strings possible can bedone. We can enter the field names directly in the spaces provided ordouble click the field in the code display and the system lists it as adouble click the field in the code display and the system lists it as avariable automatically.We can use the variable screen to display the contents of any system fieldor all field that a program references. Also the debugger to display fieldsp g gg p ydefined in the ABAP/4 Dictionary can be used.To display the contents of dictionary fields, we must define relevant tablein the TABLES statement of the current program.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 159: Sap Abap Refresher Course NoRestriction

Additionally the contents of the fields from external programs can beDebugging

displayed.For this we need to place the name of the external program in brackets infront of the field name.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 160: Sap Abap Refresher Course NoRestriction

•Displaying Internal tables.Debugging

Within the debugger , we can display the contents of an internal table bychoosing the Table pushbutton.Th di l h T bl i S if bl i h I lThe system displays the Table view. Specify a table name in the Internaltable field or double click on the table. If the internal table contains aheader line, this line appears before the actual table contents and ismarked in the display by >>>>>>> The table rows are numbered We canmarked in the display by >>>>>>>.The table rows are numbered. We canscroll through the table display using the Index field or the scroll icons. Ifwe want to see those parts of the tables that are not visible on the left orright of the screen use the push buttons for horizontal scrolling orright of the screen , use the push buttons for horizontal scrolling orsimply shift the title bar of the table.

Using the column header line, we can also change the sequence of theg , g qfields we want to see. If we remove a field name from the column headerline, then the system deletes the field from the display. If we specify anincorrect field name, the system displays a string of question marks.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 161: Sap Abap Refresher Course NoRestriction

A View of internal table display

Debugging

e o te a tab e d sp ay

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 162: Sap Abap Refresher Course NoRestriction

If the space you leave to display a field is too small , the system truncatesDebugging

the display and indicates this by a “<” character.

As with the field display , we can customize the display format for internalt bl Th t d d t i th F t fi ld i E (f dit d) Ytables. The standard entry in the Format field is an E (for edited) . You canchange this to an X for hexadecimal or a C for character display.

Once we have finished examining the internal table return to theOnce we have finished examining the internal table , return to thescreen with the field display and program code by selecting the programbutton.

•Displaying ABAP/4 Lists.

If we are debugging an online report that generates a list, we can displaygg g p g , p ythis list in the debugger. As soon as this list is started, the display listpushbutton appears. Choose Display list to switch to the list display. Thesystem displays all the lines generated so far in their respective formats.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Note : The current list line is formatted only after completion (NEW-LINE).

Page 163: Sap Abap Refresher Course NoRestriction

•Replacing fields at Runtime. Debugging

While we are debugging a program , we might want to change the contentof specific fields to influence our program’s flow. If error analysis revealsth t fi ld t i l f l l ththat a field contains a wrong value , for example , we can replace thefaulty value at run time to determine if the program then runs correctly.

We can change the values of all fields database tables (with offset) andWe can change the values of all fields , database tables (with offset) andinternal tables referenced in a report . If we alter the values of databasefields , we do not change them in the database itself , but only in the workarea ABAP/4 provides for one run of the report .The system displays anarea ABAP/4 provides for one run of the report .The system displays anappropriate message if any format errors occur.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 164: Sap Abap Refresher Course NoRestriction

To replace the value , we can do the following steps.Debugging

1.Go to the variable display screen.This is the Debugger’s default view.

2 D bl li k i bl t l it i th i bl di l2.Double click on a variable to place it in the variables display.3.Enter a new value in the field contents row .4.Choose the ‘Change field content’ button.

ABAP/4 writes the new value back to the program field or fields and thesystem notes the change in the system log. If we forget to click on the‘Change field content’ push-button , the system ignores the values weChange field content push button , the system ignores the values weentered.

Note: ABAP/4 accepts our entries in the contents column exactly as wep yspecified them. You need to pay special attention to the correct format.(Upper or lower case , right justified output with packed numbers).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 165: Sap Abap Refresher Course NoRestriction

•Changing Internal Tables at RuntimeDebugging

The debugger allows to manipulate the contents of an internal tableduring runtime. We can delete, edit or add a row to an internal table.

•Deleting a row

To delete an entry from an internal table:To delete an entry from an internal table:1. Go to the table display screen2. Enter the table name in the internal table field.3. Choose Enter.3. Choose Enter.

The system displays the table’s contents.4.Place the cursor on the line you wish to remove from the table.y5.Press ‘Delete’ pushbutton.

The line disappears from the table and the system adjusts the line

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

numbering accordingly.

Page 166: Sap Abap Refresher Course NoRestriction

•Editing a row Debugging

The functions Change , Insert and append are field-specific in theDebugger and can be carried out only one field at a time by pressing therespective pushbuttons.respective pushbuttons.

For example ,If we want to edit the following line:

LH001 FRANKFURT NEWYORK 145400 400 X,

we first need to decide which field to change.

Then the following steps must be done.

1.Place the cursor on the row and field we want to edit.

2.Choose Change.

3.Enter a new value for the field.

4.Choose Enter.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

The system updates the line and displays the new contents in the table.

Page 167: Sap Abap Refresher Course NoRestriction

.•Adding a RowDebugging

We can add a new row to an internal table by using either Append or theInsert function. Append places the new line at the end of the table.

Insert lets us to position the line anywhereInsert lets us to position the line anywhere.

To add a new row to the end of the table , the following steps will do.

1.Choose append.1.Choose append.

2.Enter a value for the first field in the line.

3.Choose Enter.

The system adds a line to the table and fills in the first field.

4.Enter the remaining fields of the line by following the procedure forediting a row as described above.

To insert a new line anywhere in the internal table ,position the cursor onthe line directly following the line where we want the new row to appear.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

y g ppThen ,Choose Insert button and proceed as we want to append the line.

Page 168: Sap Abap Refresher Course NoRestriction

.•Switching to the ABAP/4 EditorDebugging

We can switch from the Debugger to ABAP/4 Editor at any time. If wediscover a program error during the debugging process , for example,wecan enter the ABAP/4 Editor to immediately correct the error in thecan enter the ABAP/4 Editor to immediately correct the error in theprogram’s code. We can also switch back to the editor in order to set newstatic break-points.

After we set static breakpoints in the editor they are not active in theAfter we set static breakpoints in the editor,they are not active in thedebugger when we switch back.We must re-generate the program.Thenthe breakpoints appear in the debugger.

To return to the Editor for the program currently being debugged ,

Select Development-->ABAP/4 Editor.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 169: Sap Abap Refresher Course NoRestriction

DebuggingSYNOPSIS

ABAP/4 Debugger

A representation of Debugging Process -Branching to Debugging Mode

ABAP/4 Editor

Debugging

Object List

Development object ... ... .... . .

/gg g

Program B170D051Test/execute. . .

Breakpoints Any screen

Program ... . Breakpoint ... . ... ... ... System Help. . .Utilities. . .

. . .Debug ABAP/4

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

. . . Debug ABAP/4. . ./h

Page 170: Sap Abap Refresher Course NoRestriction

Debugging Mode

Debugging

Debugging Mode

Execute Single step Execute Continue Table

PROGRAM B170D051.DATA: DIFF TYPE P,

.

.

.

O S V F T P

View pushbuttons

COMPUTE DATE_1 = SY-DATUM....

V i bl

DATE_1 00000000

SY-DATUM 19940223

Variables

R

R

R

X R

R

R

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 171: Sap Abap Refresher Course NoRestriction

The Most Important Debugging Functions

Debugging

e ost po ta t ebugg g u ct o s

Single Step Processes the next program lineSingle Step Processes the next program line.

Execute In contrast to the single step, executesall processing steps belonging to one line.a p ocess g steps be o g g to o e e

Continue Processing continues until the next breakpoint oruntil the end of the program.

Table Displays the contents of internal tables.

Breakpoint With the functions of this menu youdefine breakpoints.

Editor You go to the ABAP/4 editor.Hexadecimal-display

Data contents can be displayed in hexadecimal format.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 172: Sap Abap Refresher Course NoRestriction

Setting Breakpoints

Debugging

Setting Breakpoints

Menu Utilities-> Breakpoints

ABAP/4 Editor11

Keyword

Breakpoints

BREAK-POINTKeyword BREAK POINT

Line selection (double-click)Debugging mode22

Menu: Breakpoint-> Set/deleteGoto-> Breakpoints

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 173: Sap Abap Refresher Course NoRestriction

Debugging

General QueriesGe e a Que esQuestion•Static Break-point are user independent (YES/NO)YESYES

•Dynamic Breakpoints are not user-specific(YES/NO)

NO

•Dynamic breakpoints are visible in the program(YES/NO)

YES

•Dynamic Breakpoints are more flexible than Static Breakpoints(YES/NO)

YES

•Static Breakpoints are hard-coded in the program(YES/NO)

YES

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

•Temporary deletion of dynamic breakpoints are not possible(YES/NO)

NO

Page 174: Sap Abap Refresher Course NoRestriction

Debugging•Watchpoints can be set only from within the debugger (YES/NO).

YES

•How can a temporary deletion of dynamic Breakpoints are done?

Temporary deletion of Breakpoints are done by optionACTIVATE/DEACTIVATE in the debugging editor.

•What are the different options to step through the program in the•What are the different options to step through the program in thedebugger?

Single Step

Execute

Continue

Return

•While debugging ,it is impossible to correct wrong values in a table’sfield dynamically during runtime (YES/NO)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

field dynamically during runtime (YES/NO)

NO

Page 175: Sap Abap Refresher Course NoRestriction

Debugging•Addition and deletion of fields in a table is possible inDebugger(YES/NO).

YES

F th ABAB D b it hi t ABAP/4 Edit i t ll d•From the ABAB Debugger , switching to ABAP/4 Editor is not allowed.

(YES/NO)

NONO

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 176: Sap Abap Refresher Course NoRestriction

Summary

Debugging

SummaryThe above slides have given an idea of debugging , the debugging tools for various operations like usage of breakpoints , watch points ,internal t bl di l t i th h d it hi t ABAPtables display,stepping through a program code, switching to ABAP editor and associated utilities.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 177: Sap Abap Refresher Course NoRestriction

2. ABAP WORKBENCH BASICS

Data Types & Data Objects

Internal Tables

Modularization of ABAP R/3

ABAP Runtime system : Debugging

Function Module & Function Groupsp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 178: Sap Abap Refresher Course NoRestriction

Function Modules

ObjectiveObject e

The following section is intended to explain:

• What function modules are

• Components of function modules

• Testing and releasing of function modules

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 179: Sap Abap Refresher Course NoRestriction

Function Modules

• Function modules are special external subroutines(program type F)

• Function modules are classified in function groups and stored in the F ti Lib F ti t t i f f tiFunction Library. Function groups act as containers for function modules that logically belong together.

• Function modules allow us to encapsulate and reuse global functions• Function modules allow us to encapsulate and reuse global functions in the R/3 System.

• Function modules also play an important role in database updates andFunction modules also play an important role in database updates and in remote communications between R/3 Systems or between an R/3 System and a non-SAP system.

• The R/3 System provides numerous predefined function modules that we can call from your ABAP/4 programs. We can also create your own function modules using Function Builder. (Transaction Code SE 37)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 180: Sap Abap Refresher Course NoRestriction

Function Modules vs Subroutines

• Subroutines are principally for local modularization while Function modules are for global modularization, that is, they are always called from a different program. p g• Subroutines are defined in ABAP programs while Function modules are defined within function groups

• Function modules have clearly defined data interfaces to the calling program.

• We can test function modules in a stand-alone mode independent of the calling program.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 181: Sap Abap Refresher Course NoRestriction

Function Groups

• Function groups are containers for function modules• Function groups are containers for function modules.

• We cannot execute a function group. When we call a function module, the system loads the whole of its function group into the internal

i f th lli (if it h t l d b l d d)session of the calling program (if it has not already been loaded).

• Function group names are freely definable up to a maximum length of 26 alphanumeric characters.p

• When we create a function group or function module in the Function Builder , the main program and include programs are generated

t ti llautomatically.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 182: Sap Abap Refresher Course NoRestriction

Creating Function Groups

New function groups can be created from the menu Goto - Function Group - Create

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 183: Sap Abap Refresher Course NoRestriction

Programming Function Modules

To program a function module, we must include our statements o p og a a u ct o odu e, e ust c ude ou state e tsbetween the FUNCTION and ENDFUNCTION statements as follows:Syntax : FUNCTION <module>

<statements><statements>ENDFUNCTION

An existing Function Module can be inserted into ABAP Code usingAn existing Function Module can be inserted into ABAP Code using Edit - Pattern

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 184: Sap Abap Refresher Course NoRestriction

Import: Values transferred from the calling program to the function module.You

Components of Functional Modules

po t a ues t a s e ed o t e ca g p og a to t e u ct o odu e oucannot overwrite the contents of import parameters at runtime.

Export:Values transferred from the function module back to the calling program.

Changing :Values that act as import and export parameters simultaneously. Th i i l l f h i t i t f d f th lliThe original value of a changing parameter is transferred from the calling program to the function module. The function module can alter the initial value and send it back to the calling program.

Tables: Internal tables that can be imported and exported. The internal table's contents are transferred from the calling program to the function module. The function module can alter the contents of the internal table and then send itfunction module can alter the contents of the internal table and then send it back to the calling program. Tables are always passed by reference.

Exceptions:Error situations that can occur within the function module.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

pThe calling program uses exceptions to find out if an error has occurred in the function module. It can then react accordingly.

Page 185: Sap Abap Refresher Course NoRestriction

Import Parameters

Import parameters : These must be supplied with data when we call the function module, unless they are flagged as optional. We cannot change them in the function module.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 186: Sap Abap Refresher Course NoRestriction

Export parameters: These pass data from the function module back to the

Export Parameters

calling program. Export parameters are always optional. We do not have to receive them in our program.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 187: Sap Abap Refresher Course NoRestriction

Changing parameters : Changing parameters are passed by reference or

Changing Parameters

C a g g pa a ete s C a g g pa a ete s a e passed by e e e ce oby value and result. Changing parameters act simultaneously as import and export parameters. They change the value passed to the function module and return it to the calling program.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 188: Sap Abap Refresher Course NoRestriction

Tables Parameters

Tables parameters :We use these to pass internal tables. They are treated like CHANGING parameters. However, we can also pass internal tables with other parameters if you specify the parameter type appropriately. The use of these exists in earlier FM definitions, as they are considered obsolete now .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 189: Sap Abap Refresher Course NoRestriction

Exceptions

• When creating function modules, we can define exceptions. The calling program determines whether and which exceptions it is to handle itself.

• We can assign the same error number to several exceptions• We can assign the same error number to several exceptions.

• The OTHERS clause covers all exceptions not explicitly specified.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 190: Sap Abap Refresher Course NoRestriction

Source Code Tab

This tab shows the source of the function module in the ABAP/4 editor. We can work with the source code in the same way as is done for normal ABAP/4 programs opened via forward navigation.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 191: Sap Abap Refresher Course NoRestriction

Creating Function Modules

• Check whether a suitable function module already exists. If not, create one as follows.

• Create a function group, if no appropriate group exists yet. • Create the function module.

Define the function module interface by entering its parameters and• Define the function module interface by entering its parameters andexceptions.

• Write the actual ABAP code for the function module, adding anyWrite the actual ABAP code for the function module, adding any relevant global data to the TOP include.

• Activate the module. • Test the module. • Document the module and its parameters for other users. • Release the module for general use

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

• Release the module for general use.

Page 192: Sap Abap Refresher Course NoRestriction

• The CALL FUNCTION statement can pass import export and changing

Runtime Considerations

The CALL FUNCTION statement can pass import, export, and changing parameters either by value or by reference. Table parameters are always transferred by reference.

• If you declare the parameters with reference to ABAP Dictionary fields or structures, the system checks the type and length when the parameters are transferred. If the parameters from the calling program do not pass this check, the calling program terminates.

• At runtime, all function modules belonging to a function group are l d d ith th lli A lt h ld l f llloaded with the calling program. As a result, you should plan carefully which functions really belong in a group and which do not. Otherwise, calling your function modules will unnecessarily increase the amount of memory required by the userof memory required by the user.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 193: Sap Abap Refresher Course NoRestriction

Function Builder

The Function Builder allows us to create, test, and administer function modules in an integrated environment.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 194: Sap Abap Refresher Course NoRestriction

Function Builder

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 195: Sap Abap Refresher Course NoRestriction

Function Module Attributes

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 196: Sap Abap Refresher Course NoRestriction

Function Module Attributes - Processing Types

• Normal Function Module : Indicates that the function is a normal one

• Remote-enabled Module : Shows that the function is remote enabled

• Update Module

• Start Update Immediately :The function module is processed immediately in the update taskimmediately in the update task.

• Immediate Start, No restart : The function module will be edited in the update task. It cannot be updated subsequently.

• Start Delayed :The function module is processed in the update task as a low priority item. You use delayed update primarily for database changes that are not time-critical (e.g. statistical updates). g ( g p )

• Collective Run :A number of similar function modules that previously used to run individually in the V2 update process can be

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

grouped together and run collectively.

Page 197: Sap Abap Refresher Course NoRestriction

Finding Function Modules

U i th R it I f ti S t• Using the Repository Information SystemTo search for a module, choose Find from the initial screen of the Function Builder. The system displays the standard Function

Module search screenModule search screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 198: Sap Abap Refresher Course NoRestriction

Finding Function Modules

U i th A li ti Hi h• Using the Application HierarchyThe Application Hierarchy provides an overview of all the applications in your R/3 system. You can use this hierarchy to display function modules associated with particular applicationsmodules associated with particular applications.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 199: Sap Abap Refresher Course NoRestriction

Calling Function Modules

CALL FUNCTION < d l >CALL FUNCTION <module>[EXPORTING f1 = a 1.... f n = a n] [IMPORTING f1 = a 1.... f n = a n] [CHANGING f = a f = a ][CHANGING f1 = a 1.... f n = a n] [TABLES f1 = a 1.... f n = a n] [EXCEPTIONS e1 = r 1.... e n = r n [ERROR_MESSAGE = r E] [OTHERS = ro] ].[OTHERS ro] ].

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 200: Sap Abap Refresher Course NoRestriction

PROGRAM CALL FUNCTION CASE SY-SUBRC

CALL FUNCTION - Example

PROGRAM CALL_FUNCTION.

DATA: TEXT(10) TYPE C VALUE '0123456789',TEXT1(6) TYPE C,

CASE SY-SUBRC.WHEN 0.WRITE: / TEXT, / TEXT1, / TEXT2.WHEN 1.TEXT1(6) TYPE C,

TEXT2(6) TYPE C.

PARAMETERS POSITION TYPE I.

CALL FUNCTION

WHEN 1.WRITE 'Target field 1 too short!'.WHEN 2.WRITE 'Target field 2 too short!'.

CALL FUNCTION 'STRING_SPLIT_AT_POSITION'

EXPORTINGSTRING = TEXT

WHEN 3.WRITE 'Invalid split position!'.WHEN 4.

POS = POSITIONIMPORTING

STRING1 = TEXT1STRING2 = TEXT2

WRITE 'Other errors!'.ENDCASE.

STRING2 = TEXT2EXCEPTIONSSTRING1_TOO_SMALL = 1STRING2_TOO_SMALL = 2

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

POS_NOT_VALID = 3OTHERS = 4.

Page 201: Sap Abap Refresher Course NoRestriction

Documenting function modules

Th d t ti f th f ti d l i d i th F tiThe documentation for the function module is done in the Function Builder. There are two kinds of documentation - parameter documentation, and full function module documentation.

f• The parameter documentation must provide users with information about the different parameters and exceptions.

• Function module documentation contains important detailed pinformation about the task of the function module. A detailed documentation will help us to understand the function module without having to examine its source code.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 202: Sap Abap Refresher Course NoRestriction

Activating Function Module

Function Module can be activated from the menu as shown belowFunction Module can be activated from the menu as shown below.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 203: Sap Abap Refresher Course NoRestriction

Activating Function Group

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 204: Sap Abap Refresher Course NoRestriction

Testing Function Modules - Initial Screen

• We can test function modules without having to include them in a• We can test function modules without having to include them in a program using the Function Builder. When we test a function module, the system displays any exceptions. The system also identifies the time required to execute the module in microseconds.required to execute the module in microseconds.

Example Function : BAPI_CCODE_GET_FIRSTDAY_PERIODImport Parameters: Company Code, Fiscal Period, Fiscal Year

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 205: Sap Abap Refresher Course NoRestriction

Testing Function Module - Result Screen

The function BAPI CCODE GET FIRSTDAY PERIOD when executed with e u ct o _CCO _G _ S _ O e e ecuted tvalues given in the previous screen gives the following output. It also shows the time required for executing the function module.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 206: Sap Abap Refresher Course NoRestriction

Releasing function modules

Releasing a function module is a purely administrative gesture with no effect on the function or its usability. Releasing a function module signals that a developer has tested it. When a function module is released its documentation is released for translation and appears in the relevant t l t ' kli ttranslator's worklist.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 207: Sap Abap Refresher Course NoRestriction

Function Modules

Summary

This section explained :

• The creation of function modules

• Components of function modules

• Releasing and activation of function modules

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 208: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 209: Sap Abap Refresher Course NoRestriction

Data Dictionary

The ABAP Dictionary centrally describes and manages all the datadefinitions used in the system. The ABAP Dictionary is completelyintegrated in the ABAP Development Workbench. All the othercomponents of the Workbench can actively access the definitionsstored in the ABAP Dictionarystored in the ABAP Dictionary.The most important object types in the ABAP Dictionary are :-1> Tables2> Views3> Types (data elements, structures, table types)4> Domains5> Search helps6 L k bj t

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

6> Lock objects

Page 210: Sap Abap Refresher Course NoRestriction

Data Dictionary

Tables are defined in the ABAP Dictionary independently of thedatabase. A table having the same structure is then created from thistable definition in the underlying database.

Views are logical views on more than one table The structure of theViews are logical views on more than one table. The structure of theview is defined in the ABAP Dictionary. A view on the database canthen be created from this structure.then be created from this structure.

Types are used in ABAP program. The structure of a type can bedefined globally in ABAP programs. Changes to a type automaticallytake effect in all the programs using the type.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 211: Sap Abap Refresher Course NoRestriction

Data Dictionary

Lock Objects are used to synchronize access to the same data bymore than one user. Function modules that can be used inapplication programs are generated from the definition of a lockobject in the ABAP Dictionary.

Different fields having the same technical type can be combined indomains. A domain defines the value range of all table fields anddomains. A domain defines the value range of all table fields andstructure components that refer to this domain.

The ABAP Dictionary also contains the information displayed withthe F1 and F4 help for a field in an input template.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 212: Sap Abap Refresher Course NoRestriction

Data Dictionary

The documentation about the field is created for a data element thatdescribes the meaning of the contents of a table field.

The list of possible input values that appears for the input help isThe list of possible input values that appears for the input help iscreated by a foreign key or a search help.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 213: Sap Abap Refresher Course NoRestriction

Data Dictionary

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ABAP Dictionary (Transaction se11): Initial Screen

Page 214: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 215: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Technical Settings

Page 216: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Data ClassIf you choose the data class correctly, your table is automatically

i d t th t (t bl DB ) f th d t bassigned to the correct area (tablespace or DBspace) of the databasewhen it is created. Each data class corresponds to a physical area inwhich all the tables assigned to this data class are storedwhich all the tables assigned to this data class are stored.

There are the following data classes:APPL0 (master data): Data which is seldomly changed. An exampleof master data is the data contained in an address file, such as thename, address and telephone number.

APPL1 (t ti d t ) D t th t i f tl h d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

APPL1 (transaction data): Data that is frequently changed.

Page 217: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

An example of transaction data is the goods in a warehouse, whichchange after each purchase order.

APPL2 (organizational data): Customizing data that is defined whenthe system is installed and seldomly changed. An example is the table with country codes.

Two further data classes, USR and USR1, are provided for thecustomer. These are for user developments. The tables assigned top gthese data classes are stored in a tablespace for user developments.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 218: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 219: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Size CategoryThe size category defines the expected space required for the table inth d t b Y h i t f 0 t 4 fthe database. You can choose a size category from 0 to 4 for yourtable.

Each category is assigned a certain fixed memory size in the database,which depends on the database system used.

When a table is created, initial space (an Initial Extent) is reservedin the database. If more space is required at a later time due to dataentries, additional memory will be added depending on the selectedi t

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

size category.

Page 220: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Selecting the correct size category prevents a large number of verysmall extents from being created for a table. It also prevents space

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

from being wasted if extents which are too large are created.

Page 221: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

BufferingYou must define whether and how a table is buffered in the technical

tti f th t bl Th th ibiliti hsettings for the table. There are three possibilities here:1> Buffering not permitted: Table buffering is not permitted, for

example because application programs always need the mostexample because application programs always need the mostrecent data from the table or the table is changed too frequently.

2> Buffering permitted but not activated: Buffering is permitted fromthe business and technical points of view. Applications which access the table execute correctly with and without table buffering.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 222: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Whether or not table buffering will result in a gain in performancedepends on the table size and access profile of the table (frequencyof the different types of table access).

Table buffering is deactivated because it is not possible to knowTable buffering is deactivated because it is not possible to knowwhat these values will be in the customer system. If table bufferingwould be advantageous for the table size and access profile of thewould be advantageous for the table size and access profile of thetable, you can activate it in the customer system at any time.

3> Buffering activated: The table should be buffered. In this caseyou must specify a buffering type.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 223: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Buffering types:

1> Single-Record buffering1> Single-Record bufferingWith single-record buffering, only the records that are actuallyread are loaded into the buffer. Single-record buffering thereforerequires less storage space in the buffer than generic and fullbuffering. The administrative costs in the buffer, however, aregreater than for generic or full buffering. Considerably moredatabase accesses are necessary to load the records than for theother buffering typesother buffering types.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 224: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

In this example, the record highlighted in red is read by a programfrom table SCOUNTER. If single-record buffering is selected for thetable, only the record that was read is loaded into the buffer.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 225: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

When Should you Use Single-Record Buffering?Single-record buffering should be used particularly for large tableswhere only a few records are accessed with SELECT SINGLE.The size of the records being accessed should be between 100 and200 KB200 KB.

Full buffering is usually more suitable for smaller tables that areFull buffering is usually more suitable for smaller tables that areaccessed frequently. This is because only one database access isnecessary to load such a table with full buffering, whereas severaldatabase accesses are necessary for single-record buffering.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 226: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

2> Generic bufferingWith generic buffering, all the records in the buffer whosegeneric key fields match this record are loaded when one recordof the table is accessed. The generic key is a part of the primarykey of the table that is left justifiedkey of the table that is left-justified.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 227: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

In this example, the record highlighted in red is read by a programfrom table SCOUNTER. If the table is generically buffered, all therecords read whose generic key fields (MANDT and CARRID)agree are loaded into the buffer.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 228: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

When Should you Use Full Buffering?A table should be buffered generically if only certain generic areasof the table are normally needed for processing.

Client specific fully buffered tables are automatically genericallyClient-specific, fully-buffered tables are automatically genericallybuffered since normally it is not possible to work in all clients at thesame time on an application server. The client field is the genericpp gkey.Language-specific tables are another example where genericbuffering is recommended. In general, only records of one languagewill be needed on an application server. In this case, the generic keyi l d ll th k fi ld t d i l di th l fi ld

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

includes all the key fields up to and including the language field.

Page 229: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

3> Full bufferingWith full buffering, either the entire table is in the buffer or thetable is not in the buffer at all. All the records of the table areloaded into the buffer when one record of the table is read.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 230: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

In this example, a program reads the record highlighted in red fromtable SCOUNTER. If the table is fully buffered, all the records of thetable are loaded into the buffer.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 231: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

When Should you Use Full Buffering?When deciding whether a table should be fully buffered, you shouldtake into account the size of the table, the number of read accesses,and the number of write accesses. Tables best suited to full bufferingare small read frequently and rarely writtenare small, read frequently, and rarely written.Full buffering is recommended in the following cases:Tables up to 30 KB in size. If a table is accessed frequently, but allp q y,accesses are read accesses, this value can be exceeded. However, youshould always pay attention to the buffer utilization.

Larger tables where large numbers of records are frequently

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 232: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

accessed. If these mass accesses can be formulated with a veryselective WHERE condition using a database index, it could bebetter to dispense with buffering.

Tables for which accesses to non existent records are frequentlyTables for which accesses to non-existent records are frequentlysubmitted. Since all the table records reside in the buffer, the systemcan determine directly in the buffer whether or not a record exists.can determine directly in the buffer whether or not a record exists.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 233: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

LoggingThe logging flag defines whether changes to the data records of atable should be logged If logging is activated every changetable should be logged. If logging is activated, every change(with UPDATE, DELETE) to an existing data record by a useror an application program is recorded in a log table in thedatabase.

Note: Activating logging slows down accesses that change thetable. First of all, a record must be written in the log table foreach change. Secondly, many users access this log table in parallel.This could cause lock situations even though the users are

ki ith diff t li ti t blworking with different application tables.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 234: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Dependencies Logging only takes place if parameter rec/client in the system profile is set correctly Setting the flag on its own does not cause the tableis set correctly. Setting the flag on its own does not cause the table changes to be logged.

The existing logs can be displayed with Transaction Table historyg g p y y(SCU3).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 235: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

Delivery classThe delivery class controls the transport of table data for installation

d li t d h t ti b t t,upgrade, client copy and when transporting between customersystems. The delivery class is also used in the extended tablemaintenancemaintenance.

There are the following development classes:A: Application table (master and transaction data). C: Customer table, data is only maintained by the customer. L: Table for storing temporary data.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 236: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Table

G: Customer table, SAP may insert new data records but may notoverwrite or delete existing ones. E: System table with its own namespace for customer entries.The customer namespace must be defined in table TRESC. S: System table data changes have the status of program changesS: System table, data changes have the status of program changes. W: System table (e.g. table of the development environment) whosedata is transported with its own transport objectsdata is transported with its own transport objects(e.g. R3TR PROG, R3TR TABL, etc.).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 237: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 238: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

Fixed values for a domainThe value range of a domain can be further restricted by definingfi d l If fi d l d fi d f d i th dfixed values. If fixed values are defined for a domain, these are usedin the input check in screen templates. If no other means of help isdefined for a field ( search help foreign key ) the fixed values aredefined for a field ( search help,foreign key ), the fixed values arealso offered in the input (F4) help.Domain S_CLASS (data type CHAR, length 1) in the flight modeldescribes the possible classes of a flight booking. The value range ofdomain S_CLASS is defined by the fixed values C (business class),F (first class) and Y (economy class). Only the values C, F and Y maybe entered in screen templates for all the fields that refer to thisd i

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

domain.

Page 239: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

You can define fixed value intervals either by entering upper andlower limits or by specifying single values. Value ranges and singlevalues can be combined as required. You can enter an explanatorytext for every single value or interval; it is displayed in the inputhelphelp.

It is only possible to define fixed values for domains of data typesIt is only possible to define fixed values for domains of data typesCHAR, NUMC, DEC, INT1, INT2 and INT4.There is only an input check of the template for data typesCHAR and NUMC.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 240: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Fixed values for a domain

Page 241: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

Value Table for a domainIn some cases you can see when you define a domain that all thetable fields or structure components referring to this domain shouldbe checked against a certain table. This information can be stored inthe domain by entering a value tablethe domain by entering a value table.The system proposes the value table as check table when you try todefine a foreign key for the field or component. This proposal cang y p p pbe overridden.Domain S_CARR_ID (data type CHAR, length 3) in the flight modeldescribes the three-place code of the airlines. All the airlines arelisted together with their codes in table SCARR.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 242: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

It is generally advisable to check fields referring to domain S_CARR_ID against table SCARR. SCARR is therefore entered asvalue table for domain S_CARR_ID. If you want to define a foreignkey for a field referring to S_CARR_ID, SCARR is proposed as thecheck tablecheck table.

A check is not implemented by simply entering a value table!A check is not implemented by simply entering a value table!The check against the value table only takes effect when aforeign key has been defined.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 243: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Domain

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Value table for a domain

Page 244: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Domain

Before creating a new domain, check whether a domain that definesthe same value range already exists. In this case you should use theexisting domain if possible.Procedure1> Select object type Domains in the initial screen of the ABAP1> Select object type Domains in the initial screen of the ABAP

Dictionary, enter the name of the domain and choose Create.

2> The maintenance screen for domains appears.Enter an explanatory short text in the field Short text. You can for example find the domain at a later time using thisshort text.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 245: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Domain

3> On the Data type tab page, choose the data type, number of places (valid positions without editing characters such as commaor period) and number of decimal places (only needed for datatypes DEC, FLTP, QUAN and CURR). Note that some data types have a fixed length For example theNote that some data types have a fixed length. For example, thedata type CLNT (client) always has 3 places. If you enter aninvalid number of places for such a data type, the system correctsp yp , ythis automatically after issuing a warning.

4> If only certain input values are valid for the domain, you canenter them in the Value range tab page as fixed values. Y l d fi l t bl d l f f i

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

You can also define a value table as proposed value for foreign

Page 246: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Domain

key checks on this tab page.

5> Save the domain. You are asked to assign the domain a development class.

6> Choose Activate icon.ResultResultThe domain is activated. You can find information about theactivation flow in the activation log, which you can call withUtilities ® Activation log. If errors occurred when the domain wasactivated, the activation log is automatically displayed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 247: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Foreign Key

Procedure1> In the field maintenance screen of the table, select the check field

and choose If the domain of the check field has a value table, youcan have the system create a proposal with the value table as checktable In this case a proposal will be made for the field assignmenttable. In this case a proposal will be made for the field assignmentin the foreign key.If the domain does not have a value table or if you reject they jproposal, the screen for foreign key maintenance appears withoutproposals. In this case, enter the check table and save your entries.The check table must have a key field to which the domain of thecheck field is assigned.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 248: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Foreign Key

2> Enter an explanatory short text in the field Short text. The short text provides a technical documentation of the meaningof the foreign key.

3> Choose Copy The foreign key is saved and you return to the3> Choose Copy. The foreign key is saved and you return to themaintenance screen for the table.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 249: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 250: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views

Inner Join and Outer JoinThe data that can be selected with a view depends primarily onwhether the view implements an inner join or an outer join.

With an inner join you only get the records of the cross product forWith an inner join, you only get the records of the cross-product forwhich there is an entry in all tables used in the view. With an outerjoin, records are also selected for which there is no entry in some ofjoin, records are also selected for which there is no entry in some ofthe tables used in the view.

The set of hits determined by an inner join can therefore be asubset of the hits determined with an outer join.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 251: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 252: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views

Data about an application object is often distributed on severaltables.

By defining a view, you can define an application-dependentview that combines this data The structure of such a view is definedview that combines this data. The structure of such a view is definedby specifying the tables and fields used in the view.

Fields that are not required can be hidden, thereby minimizinginterfaces. A view can be used in ABAP programs for data selection.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 253: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 254: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views

Four different view types are supported. These differ in the way inwhich the view is implemented and in the methods permitted foraccessing the view data.Database views are implemented with an equivalent view on thedatabasedatabase.

Projection views are used to hide fields of a table (only projection).j ( y p j )

Help views can be used as selection method in search helps.

Maintenance views permit you to maintain the data distributedl t bl f li ti bj t t ti

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

on several tables for one application object at one time.

Page 255: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Database Views

Data about an application object is often distributed on severaldatabase tables. A database view provides an application-specificview on such distributed data.Database views are defined in the ABAP Dictionary. A databaseview is automatically created in the underlying database when it isview is automatically created in the underlying database when it isactivated.Application programs can access the data of a database view usingpp p g gthe database interface. You can access the data in ABAP programswith both OPEN SQL and NATIVE SQL. However, the data isactually selected in the database. Since the join operation is executedin the database in this case, you can minimize the number of database

i thi D t b i i l t i j i

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

accesses in this way. Database views implement an inner join.

Page 256: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Database Views

If the database view only contains a single table, the maintenancestatus can be used to determine if data records can also be insertedwith the view. If the database view contains more than one table,o can onl read the data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

you can only read the data.

Page 257: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Creating Database Views

Procedure1> Enter an explanatory short text in the field Short text.

You can for example find the view at a later time using this shorttext.

2> Define the tables to be included in the view in the Tables field of2> Define the tables to be included in the view in the Tables field ofthe Tables/Join conditions tab page. Keep in mind that you can only include transparent tables in ap y y pdatabase view.

3> Link the tables with join conditions. Place the cursor on a table name and choose Relationships.All foreign keys to other tables defined for this table aredi l d S l t th f i k d h C

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

displayed. Select the foreign keys and choose Copy.

Page 258: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Creating Database Views

The join condition is now derived from the definitions in the foreignkey.4> On the View fields tab page, select the fields that you want to copy

to the view. Choose Table fields All the tables contained in the view areChoose Table fields. All the tables contained in the view aredisplayed in a dialog box. Select a table. All the fields containedin this table are displayed. You can copy fields by selecting themp y py y gin the first column and choosing Copy.

5> On the Selection conditions tab page, you can (optionally)formulate restrictions for the data records to be displayed withthe view .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 259: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Creating Database Views

The selection conditions define the data records that can be selectedwith the view.6> With Goto - Technical settings you can (optionally) maintain the6> With Goto - Technical settings , you can (optionally) maintain the

technical settings of the database view. You can define whether and how the database view should beb ff d h P d f h h i l i f blbuffered here. Proceed as for the technical settings of a table

7> On the Maintenance status tab page, select the maintenance statusof the database viewof the database view. If the view contains more than one table, the maintenance statusread only cannot be altered.y

8> Save your entries. You are asked to assign the view adevelopment class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

9> Choose Activate .

Page 260: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Projection View

Projection views are used to hide fields of a table. This can minimizeinterfaces; for example when you access the database, you only readinterfaces; for example when you access the database, you only readand write the field contents actually needed.

A projection view contains exactly one table. You cannot defineselection conditions for projection views.There is no corresponding object in the database for a projectionview. The R/3 System maps the access to a projection view to thecorresponding access to its base table You can also access pooledcorresponding access to its base table. You can also access pooledtables and cluster tables with a projection view.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 261: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Projection View

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Projection View

Page 262: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Creating Projection View

Procedure1> Enter an explanatory short text in the field Short text.

You can for example find the view at a later time using this shorttext.

2> Enter a table name in the field Base table2> Enter a table name in the field Base table. A projection view always contains exactly one table.

3> Select the fields of the base table that you want to include in theyview. Choose Table fields. The fields of the table are nowdisplayed in a dialog box. You can copy fields by selecting themin the first column and choosing Copy.

4> Save your entries.You are asked to assign the view a developmentl

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

class.

Page 263: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views- Creating Projection View

5> Choose Activate.

ResultThe help view is activated. At activation, a log is written; it can bedisplayed with Utilities ® Activation log. If errors or warningsoccurring when the view was activated, they are displayed directlyin the activation log.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 264: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views-Help View

You have to create a help view if a view with outer join is needed asselection method of a search help.p

The selection method of a search help is either a table or a view.If you have to select data from several tables for the search help,you should generally use a database view as selection method.However, a database view always implements an inner join. If youneed a view with outer join for the data selection, you have to use ahelp view as selection methodhelp view as selection method.

The creation method for Help view is similar to that of Database view.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

p

Page 265: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Views-Help View

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 266: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 267: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help

The input help (F4 help) is a standard function of the R/3 System.The user can display the list of all possible input values for a screenfield with the input help.

This standard process can be completely defined by creating a searchThis standard process can be completely defined by creating a searchhelp in the ABAP Dictionary. This search help only has to beassigned to the screen fields in which they should be available.g yThere are two types of search help:Elementary search helps describe a search path. The elementarysearch help must define where the data of the hit list should beread from (selection method), how the exchange of values betweenth t l t d l ti th d i i l t d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

the screen template and selection method is implemented

Page 268: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help

(interface of the search help) and how the online input help shouldbe defined (online behavior of the search help).

Collective search helps Combine several elementary search helps. Acollective search help thus can offer several alternative search pathscollective search help thus can offer several alternative search paths.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 269: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help- Examples

Each customer of a carrier or of a travel agency has a customernumber. You want to find a search option for this customer number.The user must be offered two different search paths.1> The user should be able to search for the customer number using

the customer data such as the name and addressthe customer data, such as the name and address.

2>The user should be able to search for the customer number usinggexisting customer bookings.

Two elementary search helps SCUSTOM_NAME (for searchingwith the customer data) and SCUSTOM_BOOK (for searching

ith th i ti b ki ) t d f th t l h th

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

with the existing bookings) are created for the actual search paths.

Page 270: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help- Examples

These elementary search helps are included in the collective searchhelp SCUSTOM.Elementary Search Help SCUSTOM_NAMEThis elementary search help should enable you to search for thecustomer number using the name and address (street city country)customer number using the name and address (street, city, country).All this data is contained in table SCUSTOM. Table SCUSTOMmust therefore be selected as the selection method of the elementarymust therefore be selected as the selection method of the elementarysearch help.You now have to decide which fields of the selection method areneeded for the input help process. These are the fields that shouldappear either in the dialog box for restricting values or in the hit list.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 271: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help- Examples

In the dialog box for restricting values, the user should be able torestrict values with the customer’s name and address, i.e. the fieldsfor the street, city and country. These fields as well as the customer’snumber (the information to be found must always be in the hit list)should appear in the hit list The fields ID NAME STREET CITYshould appear in the hit list. The fields ID, NAME, STREET, CITYand COUNTRY of table SCUSTOM must be included in the searchhelp as parameters.help as parameters.The parameter ID is declared to be an import parameter. A patternentered in the corresponding field of a screen template can thereforebe used directly for the value selection. Restrictions for the otherparameters of the search help must be entered in the dialog box for

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 272: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help- Examples

value selection.All the parameters of the search help are declaredto be export parameters. As a result, all the parameters of the hit listcan be returned to the screen template if the corresponding fieldsare available there.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 273: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Search Help- Examples

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Elementary Search help

Page 274: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

Procedure1> In the initial screen of the ABAP Dictionary, select object class

Search help, enter the name of the search help and choose Create. A dialog box appears in which you must select the type of searchhelphelp.

2> Select Elementary search help and choose .y pThe maintenance screen for elementary search helps appears.

3> Enter an explanatory text in the field Short text. You can for example find the search help at a later time usingthi h t t t

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

this short text.

Page 275: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

4> In the Definition tab page enter the selection method of the searchhelp. You can enter the name of a table or a view (database view, projection view or help view) here. If you enter a table that hasa text table, the name of the text table is automatically enteredin the corresponding fieldin the corresponding field.

5> Using the input help (F4 help), select fields of the selectiong p p ( p),method as parameter in the Search help parameter area. Selectthe fields that should be used in the dialog box for value selectionor in the hit list. If the selection method is a table that has a text table, both thefi ld f th t bl d th fi ld f th t t t bl ff d i th

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

fields of the table and the fields of the text table are offered in the

Page 276: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

input help.The data element of the parameter is automatically copied from theselection method. The data element defines the output attributesand the F1 help of the parameter in the hit list and in the dialog boxfor value selectionfor value selection.You can assign the parameter another data element. To do so, selectthe Mod flag. The Data element field is now ready for input. Theng y pselect a data element with the input help (F4 help). Only dataelements whose data type, length and number of decimal places isthe same as those of the previous data element can be assigned.This removes the link between the data element of the search help

t d th d t l t f th l ti th d fi ld h i

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

parameter and the data element of the selection method field having

Page 277: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

the same name. If you cancel the Mod flag, the data element of theassigned table field is used again.

6> Define the attributes of the search help parameters. Select the IMP flag if it is an import parameter Select the EXPSelect the IMP flag if it is an import parameter. Select the EXPflag if it is an export parameter.You can define the dialog for the input help with the fields LPos,g p p ,SPos and SDis. Enter the parameter position in the hit list inLPos. If you enter nothing or the value 0 here, the parameter isnot displayed in the hit list.Enter the parameter position in the dialog box for value selectioni SP If t thi th l 0 h th t i

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

in SPos. If you enter nothing or the value 0 here, the parameter is

Page 278: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

not displayed in the dialog box for value selection.Set the SDis flag if the parameter should be a pure display field inthe dialog box for value selection. The user is thus informed thatthe contents of the parameter restrict the value, but he cannotchange this restriction This makes sense for example when thechange this restriction. This makes sense for example when theparameter is an import parameter or if it has a default value.You can assign the parameter a default value in the Defaultg pvalue field.

7> Select the dialog type of the search help. The dialog type defines how the hit list is displayed in the inputh l

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

help.

Page 279: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

8> Save your entries. A dialog box appears in which you have to assign the search helpa development class.

9> Choose Activate9> Choose Activate .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 280: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

Dialog types for a Search helpThe dialog type of an elementary search help defines how the hit listi di l d h th i t h l i ll dis displayed when the input help is called.The following dialog types are possible:1> Immediate value display: The hit list is immediately displayed1> Immediate value display: The hit list is immediately displayed

when the input help is called. This is only meaningful if the hit listusually only contains a few entries.

2> Complex dialog with value restriction: The dialog window forrestricting values is offered immediately. Choose this option ifthe list of possible entries is usually very large. If the user limitsth t f d t t b d th hit li t ill b

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

the amount of data to be processed, the hit list will become more

Page 281: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Search Help

comprehensible and the system load during value selection will bereduced.

3> Dialog depending on number of values: If the hit list contains lessthan 100 entries it is displayed immediately If the hit listthan 100 entries, it is displayed immediately. If the hit listcontains more than 100 entries, the dialog box for restrictingvalues is displayed.values is displayed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 282: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Collective Search Help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Collective Search Help SCUSTOM

Page 283: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Collective Search Help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

F4 for Collective Search Help

Page 284: Sap Abap Refresher Course NoRestriction

Data Dictionary/Creating Collective Search Help

Procedure1> In the initial screen of the ABAP Dictionary, select object class

Search help, enter the name of the search help and choose Create.A dialog box appears in which you must select the type of searchhelphelp.

2> Select Collective search help and choose .2 Select Collective search help and choose .The maintenance screen for collective search helps is displayed.

3> Enter an explanatory text in the field Short text.You can forexample find the search help at a later time using this short text.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 285: Sap Abap Refresher Course NoRestriction

Data Dictionary/Creating Collective Search Help

4> In the Definition tab page enter the parameters of the collectivesearch help. Select the Imp flag if it is an import parameter. Selectthe Exp flag if it is an export parameterthe Exp flag if it is an export parameter.Define the types for the parameters of a collective search help byassigning a data element. Enter the name of the data element thatdescribes the contents of the search help parameter in the Datadescribes the contents of the search help parameter in the Dataelement field.You can assign the parameter a default value in the Default valuefield.

5> In exceptions it could be necessary to change the standardprocess defined by the search help. You can implement thedeviation from the standard using a search help exit.In this case enter the name of the search help exit in thecorresponding field.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

corresponding field.

Page 286: Sap Abap Refresher Course NoRestriction

Data Dictionary/Creating Collective Search Help

6> On the Included search helps tab page, define the search helpsthat you want to include in the collective search help.You cani l d l t h h l d ll ti h h l Uinclude elementary search helps and collective search helps. Usethe Hide flag to control whether an included search help shouldappear in the dialog box for selecting the elementary search help.If the flag is set the search help is not offeredIf the flag is set, the search help is not offered.

7> Save your entries.A dialog box appears in which you have to assign a developmentA dialog box appears in which you have to assign a developmentclass to the search help.

8> Choose Activate.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 287: Sap Abap Refresher Course NoRestriction

3. ABAP DATA DICTIONARY

Introduction

Database tables

Domains

Views

Search Helpsp

Locking Concept

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 288: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

The R/3 System synchronizes simultaneous access of several usersto the same data records with a lock mechanism. When interactivetransactions are programmed, locks are set and released by callingfunction modules . These function modules are automaticallygenerated from the definition of lock objects in the ABAP Dictionarygenerated from the definition of lock objects in the ABAP Dictionary.

Structure of a Lock ObjectjThe tables in which data records should be locked with a lockrequest are defined in a lock object together with their key fields.When tables are selected, one table (the primary table) is firstselected. Further tables (secondary tables) can also be added usingf i k l ti hi

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

foreign key relationships.

Page 289: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 290: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

Lock ArgumentsThe lock argument of a table in the lock object consists of the keyg j yfields of the table.The lock argument fields of a lock object are used as inputparameters in the function modules for setting and removing locksgenerated from the lock object definition. When these function

d l ll d th t bl t b l k d l k dmodules are called, the table rows to be locked or unlocked arespecified by defining certain values in these fields. These values canalso be generic The lock argument fields therefore define whichalso be generic. The lock argument fields therefore define whichsubset of the table rows should be locked.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 291: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

The simplest case of a lock object consists of exactly one table andth l k t f th t bl i th i k f thi t blthe lock argument of the table is the primary key of this table.Several tables can also be included in a lock object. A lock requesttherefore can lock an entire logical object and not only a record oftherefore can lock an entire logical object, and not only a record ofa table. Such a logical object can be for example a documentcomprising an entry in a header table and N entries in a position

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

table.

Page 292: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 293: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

Lock ModeThe lock mode controls whether several users can access datarecords at the same time The lock mode can be assigned separatelyrecords at the same time. The lock mode can be assigned separatelyfor each table in the lock object. When the lock is set, thecorresponding lock entry is stored in the lock table of the systemfor each table.for each table.Access by more than one user can be synchronized in the followingways:Exclusive lock: The locked data can only be displayed or edited bya single user. A request for another exclusive lock or for ah d l k i j t dshared lock is rejected.

Shared lock: More than one user can access the locked data at thesame time in display mode A request for another shared lock is

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

same time in display mode. A request for another shared lock is

Page 294: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Lock Objects

accepted, even if it comes from another user. An exclusive lock isrejected. Exclusive but not cumulative: Exclusive locks can be requestedseveral times from the same transaction and are processedsuccessively. In contrast, exclusive but not cumulative locks can becalled only once from the same transaction. All other lock requestsare rejectedare rejected.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 295: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Lock Object

1> Select object type Lock object in the initial screen of the ABAPDictionary, enter an object name and choose Create.The name of a lock object should begin with an E (Enqueue). The maintenance screen for lock objects is displayed.

2> Enter an explanatory short text in the field Short text. You can then use the short text to find the lock object at a laterjtime, for example with the R/3 Repository Information System.

3> Enter the name of the primary table of the lock object. All other tables in the lock object must be linked with the primaryt bl i f i k

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

table using foreign keys.

Page 296: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Lock Object

4> Select the lock mode of the primary table in the field below it. The lock mode is used as the default value for the correspondingparameters of the function modules generated from the lockobject.

5> Choose Add if you want to lock records in more than one tablewith the lock object. jA list of all the tables linked with the primary table using validforeign keys is displayed. Select the appropriate table. The lockmode of the primary table is copied as lock mode. You can changethis setting as required, for example you can assign the lock mode

t l f h t bl

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

separately for each table.

Page 297: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Lock Object

Similarly, you can add a table linked with the secondary table justadded with foreign keys. To do this, place the cursor on the name of the secondary table and choose Add.If no lock mode is assigned to a table, no lock is set for the entriesin this table when the generated function modules are called Youin this table when the generated function modules are called. Youshould not assign a lock mode if a secondary table was only usedto define a path between the primary table and another secondaryp p y ytable with foreign keys.

6> Save your entries. A dialog box appears in which you have to assign the lock object

d l t l

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

a development class.

Page 298: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Lock Object

7> You can define whether the function modules generated from thelock object should be RFC-enabled on the Attributes tab page. If you set the Allow RFC flag, the generated function modulescan be called from within another system with Remote FunctionCallCall.If you permit Remote Function Calls for an existing lock object,you must ensure that the generated function modules are calledy gfrom within an ABAP program with parameters appropriate forthe type. You should therefore check all programs that use theassociated function modules before activating the lock object withthe new option.

8 Ch A ti t

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

8> Choose Activate.

Page 299: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Creating Lock Object

ResultWhen you activate the lock object, the two function modulesENQUEUE_<lockobjectname> and DEQUEUE_<lockobjectname>are generated from its definition to set and release locks.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 300: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

When booking flights it is important to prevent flights from beingoverbooked. For this reason, you have to lock the particular flightas well as all the bookings existing for this flight during processing.You can do this with lock object E_BOOKING.

The flights are recorded in table SFLIGHT and the bookings for theflights in table SBOOK. The two tables are linked with a foreign key.flights in table SBOOK. The two tables are linked with a foreign key.Lock object E_BOOKING must therefore contain table SFLIGHTas primary table and table SBOOK as further table.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 301: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 302: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

The lock argument of table SFLIGHT thus contains the fieldsMANDT, CARRID, CONNID, and FLDATE. The lock argument oftable SBOOK thus contains the fields MANDT, CARRID, CONNID,FLDATE, BOOKID and CUSTOMID.

Select exclusive lock mode, that is the locked data can only bedisplayed and edited by one user.displayed and edited by one user.When the lock object is activated, the following function modulesare generated from its definition:ENQUEUE_ E_BOOKING (set locks) DEQUEUE_ E_BOOKING (release locks)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 303: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Calling Enqueue Function module

Page 304: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

With this call, flight LH 400 on Nov. 29,1998 is exclusively(lock mode E) locked in table SFLIGHT together with all thebookings entered in table SBOOK for this flight (since the initialvalue 0 is transferred for BOOKID and CUSTOMID).

The lock is sent to the update program (_SCOPE = ‘2’). If there isa lock conflict, another attempt is made to set the lock after a, pcertain time (_WAIT = ‘X’).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 305: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Calling Dequeue Function module

Page 306: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Function Modules for Lock Requests

The existing exclusive lock entries for flight LH 400 are deleted in table SFLIGHT and the bookings for this flight are deleted in tableSBOOK. The request to delete the lock entries is passed on to theupdate program (_SCOPE = ‘3’).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 307: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

Field Names of the Lock ObjectThe keys to be locked must be passed here.A further parameter X_<field> that defines the lock behavior whenthe initial value is passed exists for every lock field <field>. If theinitial value is assigned to <field> and X <field> then a generic lockinitial value is assigned to <field> and X_<field>, then a generic lockis initialized with respect to <field>. If <field> is assigned the initialvalue and X <field> is defined as X, the lock is set with exactly the_ , yinitial value of <field>.

Parameters for Passing Locks to the Update ProgramA lock is generally removed at the end of the transaction or whenth di DEQUEUE f ti d l i ll d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

the corresponding DEQUEUE function module is called.

Page 308: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

Parameter _SCOPE controls how the lock or lock release is passedto the update program. You have the following options:_SCOPE = 1: Locks and lock releases are not passed to the updateprogram. The lock is removed when the transaction is ended. SCOPE = 2: The lock or lock release is passed to the update_SCOPE = 2: The lock or lock release is passed to the update

program. The update program is responsible for removing the lock.The interactive program with which the lock was requested no longerp g q ghas an influence on the lock behavior. _SCOPE = 3: The lock or lock release is also passed to the updateprogram. The lock must be removed in both the interactive programand in the update program. This is the standard setting for theDEQUEUE f ti d l

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

DEQUEUE function module.

Page 309: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

Controlling Lock TransmissionParameter _COLLECT controls whether the lock request or lockrelease should be performed directly or whether it should first bewritten to the local lock container. This parameter can have thefollowing values:following values:Initial value: The lock request or lock release is sent directly to thelock server.

X : The lock request or lock release is placed in the local lockcontainer. The lock requests and lock releases collected in this lockcontainer can then be sent to the lock server at a later time as a

b lli th f ti d l FLUSH ENQUEUE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

group by calling the function module FLUSH_ENQUEUE.

Page 310: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

Behavior for Lock Conflicts (ENQUEUE only)The ENQUEUE function module also has the parameter _WAIT.This parameter determines the lock behavior when there is a lockconflict.You have the following options:You have the following options:Initial value: If a lock attempt fails because there is a competing lock,the exception FOREIGN LOCK is triggered. p _ ggX : If a lock attempt fails because there is a competing lock, the lockattempt is repeated after waiting for a certain time. The exceptionFOREIGN_LOCK is triggered only if a certain time limit haselapsed since the first lock attempt. The waiting time and the timeli it d fi d b fil t

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

limit are defined by profile parameters.

Page 311: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

Controlling Deletion of the Lock Entry (DEQUEUE only)The DEQUEUE function module also has the parameter_SYNCHRON. If X is passed, the DEQUEUE function waits until the entry has beenremoved from the lock table Otherwise it is deleted asynchronouslyremoved from the lock table. Otherwise it is deleted asynchronously,that is, if the lock table of the system is read directly after the lock isremoved, the entry in the lock table may still exist., y y

Exceptions of the ENQUEUE Function ModuleFOREIGN_LOCK: A competing lock already exists. You can findout the name of the user holding the lock by looking at system

i bl SY MSGV1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

variable SY-MSGV1.

Page 312: Sap Abap Refresher Course NoRestriction

Data Dictionary/ Parameters of Function modules

SYSTEM_FAILURE: This exception is triggered when the lockserver reports that a problem occurred while setting the lock. In thiscase, the lock could not be set.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 313: Sap Abap Refresher Course NoRestriction

Data Dictionary/Summary

SUMMARY( The ABAP Dictionary centrally describes and manages all the datadefinitions used in the system. The ABAP Dictionary is completelyintegrated in the ABAP Development Workbench.( Tables are defined in the ABAP Dictionary independently of the

database.Vi l i l i h bl( Views are logical views on more than one table.

( A domain defines the value range of all table fields andstructure components that refer to this domainstructure components that refer to this domain.

( Lock Objects are used to synchronize access to the same data bymore than one user.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 314: Sap Abap Refresher Course NoRestriction

EXERCISEEXERCISE

Data Dictionary/Exercise

EXERCISEEXERCISE

Using SE11 create an user defined table with the following fields,Employee No (Primary Key)Employee No. (Primary Key)NameDesignationSalary

Try to add few records into that table.N t F ll th t l i d i th t ti f th ti fNote: Follow the steps explained in the presentation for the creation of the table.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 315: Sap Abap Refresher Course NoRestriction

4. ADVANCED ABAP

Open SQL

Dynamic Programming

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 316: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 317: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 318: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 319: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 320: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 321: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 322: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 323: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 324: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 325: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 326: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 327: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 328: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 329: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 330: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 331: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 332: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 333: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 334: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 335: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 336: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 337: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 338: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 339: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 340: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 341: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 342: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 343: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 344: Sap Abap Refresher Course NoRestriction

ADVANCED ABAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 345: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 346: Sap Abap Refresher Course NoRestriction

Course Contents

Course Contents : Module VCourse Contents :Module IABAP Objects Overview

Classes and Objects

Module VGlobal classes

Module VIReport development using ALVClasses and Objects

Visibility sections

Methods

C t t

Report development using ALV

Module VIIException handling in classes

M d l VIIIConstructors

Inheritance

Module II

Module VIIICasting

Interfaces

Module IIIEvents handling in classes

Theory Test

Practical Test

Course Duration :Module IVFriends

Persistent Classes

5 working days

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 347: Sap Abap Refresher Course NoRestriction

ABAP Objects

ABAP Obj t i f i l t i R/3 Th t h t i

About ABAP Objects

ABAP Objects is fairly a new concept in R/3. The term has two meanings.

• It stands for the entire ABAP runtime environmentIt stands for the entire ABAP runtime environment.

and

• It represents the object-oriented extension of the ABAP language

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 348: Sap Abap Refresher Course NoRestriction

ABAP Objects

Th ABAP W kb h ll t t R/3 R it bj t

ABAP Runtime Environment

• The ABAP Workbench allows you to create R/3 Repository objects such as

•programs•authorization objects•lock objects•Customizing objects, etc.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 349: Sap Abap Refresher Course NoRestriction

ABAP Objects The Object-oriented Language Extension

• ABAP Objects is a complete set of object-oriented statements that has been introduced into the ABAP languagethat has been introduced into the ABAP language.

• This object-oriented extension of ABAP builds on the existing j glanguage, and is fully compatible with it.

Y ABAP Obj t i i ti d l• You can use ABAP Objects in existing programs, and can also use "conventional" ABAP in new ABAP Objects programs.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 350: Sap Abap Refresher Course NoRestriction

ABAP Objects The Object-oriented Language Extension

• ABAP Objects supports object-oriented programming

• The object-oriented enhancement of ABAP is based on the models of Java and C++. It is compatible with external object interfaces such as DCOM and CORBADCOM and CORBA

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 351: Sap Abap Refresher Course NoRestriction

ABAP Objects

Object orientation (OO), or to be more precise, object-oriented

Object-Orientation

Object o e tat o (OO), o to be o e p ec se, object o e tedprogramming, is a problem-solving method in which the software solution reflects objects in the real world .

•Objects

• An object is a section of source code that contains data and provides iservices.

• The data forms the attributes of the object.

• The services are known as methods (also known as operations or functions).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 352: Sap Abap Refresher Course NoRestriction

ABAP Objects

•The main difference between real object orientation and function groups is that

Advantages of OO

j g palthough a program can work with the instances of several function groups at the same time, it cannot work with several instances of a single function group.

Thi i t i t b bj t i t ti ABAP Obj t ll t d fi• This requirement is met by object orientation. ABAP Objects allows you to define data and functions in classes instead of function groups. Using classes, an ABAP program can work with any number of instances (objects) based on the same template.te p ate

•Complex software systems become easier to understand, since object-oriented structuring provides a closer representation of reality than other programmingstructuring provides a closer representation of reality than other programming techniques. •In a well-designed object-oriented system, it should be possible to implement changes at class level, without having to make alterations at other points in the

t Thi d th ll t f i t i dsystem. This reduces the overall amount of maintenance required. •Through polymorphism and inheritance, object-oriented programming allows you to reuse individual components. •In an object-oriented system, the amount of work involved in revising and

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

j y , gmaintaining the system is reduced, since many problems can be detected and corrected in the design phase

Page 353: Sap Abap Refresher Course NoRestriction

ABAP Objects Classes

• Classes describe objects.

• Classes are templates for objects

• From a technical point of view, objects are runtime instances of a class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 354: Sap Abap Refresher Course NoRestriction

ABAP Objects Objects

•Objects are instances of classes.

•Each object has a unique identity and its own attributes. j q y

•All transient objects reside in the context of an internal session (memory area of an ABAP program).

•A class can have any number of objects (instances).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 355: Sap Abap Refresher Course NoRestriction

ABAP Objects Overview Graphic - Classes

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 356: Sap Abap Refresher Course NoRestriction

ABAP Objects Structure of a Class

• A class contains components

• Each component is assigned to a visibility section

• Classes implement methods

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 357: Sap Abap Refresher Course NoRestriction

ABAP Objects

All t d l d i th d l ti t f th l

Class Components

• All components are declared in the declaration part of the class.

• The components define the attributes of the objects in a class. p j

• When you define the class, each component is assigned to one of th th i ibilit ti hi h d fi th t l i t f f ththe three visibility sections, which define the external interface of the class.

• All of the components of a class are visible within the class. All components are in the same namespace.

• This means that all components of the class must have names that are unique within the class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 358: Sap Abap Refresher Course NoRestriction

ABAP Objects Attributes

•Attributes are internal data fields within a class that can have any ABAP data type.

• The state of an object is determined by the contents of its attributes.

• One kind of attribute is the reference variable.

Reference variables allow you to create and address objects• Reference variables allow you to create and address objects. Reference variables can be defined in classes, allowing you to access objects from within a class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 359: Sap Abap Refresher Course NoRestriction

ABAP Objects

•Methods are internal procedures in a class that define the behavior of

Methods

•Methods are internal procedures in a class that define the behavior of an object.

•They can access all of the attributes of a class. This allows them to change the data content of an object.

•They also have a parameter interface, with which users can supply them with values when calling them, and receive values back from themthem

•The private attributes of a class can only be changed by methods in p y g ythe same class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 360: Sap Abap Refresher Course NoRestriction

ABAP Objects Methods - syntax

• The definition and parameter interface of a method is similar to that of function modules.

• You define a method <met> in the definition part of a class and implement it in the implementation part using the following processing block:

METHOD <meth>....ENDMETHODENDMETHOD.

• You can declare local data types and objects in methods in the same way as in other ABAP procedures (subroutines and function

) C Omodules). You call methods using the CALL METHOD statement.

• CALL METHOD <ObjName> -> <Method>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

• CALL METHOD <ObjName> -> <Method>

Page 361: Sap Abap Refresher Course NoRestriction

ABAP Objects Methods - types

• Instance Methods

You declare instance methods using the METHODS statement. They can access all of the attributes of a class, and can trigger all of the events of the class

• Static MethodsYou declare static methods using the CLASS-METHODS statement.

They can only access static attributes and trigger static events.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 362: Sap Abap Refresher Course NoRestriction

ABAP Objects Types of classes

• Types of classes - local and global

• Local classesd fi d i- are defined in your program.

- cannot be accessed outside your program.

• Global classes- Are defined in the repository using either transaction SE80 or SE24- Can be accessed by all programs

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 363: Sap Abap Refresher Course NoRestriction

ABAP Objects

•Encapsulation:

Encapsulation - Classes Visibility

capsu at o•Objects restrict the visibility of their resources (attributes and methods) to other users. Every object has an interface, which determines how other objects can interact with it. The implementation of the object is encapsulated, i.e. invisible outside the object itself.

•Encapsulation is implemented using class visibility sections.

•Classes Visibility Sections•You can divide the declaration part of a class into up to three visibility areas:areas:

PUBLIC SECTION....

PROTECTED SECTIONPROTECTED SECTION....

PRIVATE SECTION.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

...

Page 364: Sap Abap Refresher Course NoRestriction

ABAP Objects Public Section

Public Section•All of the components declared in the public section are accessible to all users of the class, and to the methods of the class and any classesall users of the class, and to the methods of the class and any classes that inherit from it.

•The public components of the class form the interface between the class and its usersclass and its users.

•READ-ONLY addition can be used for public attributes. This implies that the public attributes can be read from outside the class, but can be modified by only methods of the class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 365: Sap Abap Refresher Course NoRestriction

ABAP Objects Private Section

•Private Section•Components that you declare in the private section are only visible in the methods of the same classthe methods of the same class.

•The private components are not part of the external interface of the class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 366: Sap Abap Refresher Course NoRestriction

ABAP Objects Protected Section

• Protected SectionAll components in the protected section can be accessed by all methods of the same class as well as all methods of its sub-classesmethods of the same class as well as all methods of its sub-classes.

All of the components in the protected section can access the components from the public section. In turn, they can be accessed by the components of the private sectionthe components of the private section.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 367: Sap Abap Refresher Course NoRestriction

ABAP Objects

CLASS C COUNTER DEFINITION

Introductory Example

CLASS C_COUNTER DEFINITION.PUBLIC SECTION.

METHODS: SET_COUNTER IMPORTING VALUE(SET_VALUE) TYPE I,INCREMENT_COUNTER,GET_COUNTER EXPORTING VALUE(GET_VALUE) TYPE I.

PRIVATE SECTION.DATA COUNT TYPE I.

ENDCLASS.ENDCLASS.

CLASS C_COUNTER IMPLEMENTATION.METHOD SET_COUNTER.

COUNT SET VALUECOUNT = SET_VALUE.ENDMETHOD.METHOD INCREMENT_COUNTER.

ADD 1 TO COUNT.ENDMETHOD.METHOD GET_COUNTER.

GET_VALUE = COUNT.ENDMETHOD

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

ENDMETHOD.ENDCLASS.

Page 368: Sap Abap Refresher Course NoRestriction

ABAP Objects Object references

•To access an object from an ABAP program, you use object references.

•Object references are pointers to objects. In ABAP, they are alwaysObject references are pointers to objects. In ABAP, they are always contained in reference variables.

•A reference variable is either initial or contains a reference to an existing object.

•The identity of an object depends on its reference.

•A reference variable that points to an object knows the identity of that object.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 369: Sap Abap Refresher Course NoRestriction

ABAP Objects Data Types for References

•You define class references using the ... TYPE REF TO <class>

•LIKE may not be used.

•LIKE can be used for local data types.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 370: Sap Abap Refresher Course NoRestriction

ABAP Objects Creating Objects

•Before you can create an object for a class, you need to declare a reference variable with reference to that class.

•DATA: <obj> TYPE REF TO <class>

•Once you have declared a class reference variable <obj> for a class <class>, you can create an object using the statementCREATE OBJECT <obj>.

•This statement creates an instance of the class <class>, and the reference variable <obj> contains a reference to the object.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 371: Sap Abap Refresher Course NoRestriction

ABAP Objects Addressing the Components of Objects

•Programs can only access the instance components of an object using references in reference variables.

•To access an attribute <attr>: <obj>-><attr>

•To call a method <meth>: CALL METHOD <obj>-><meth>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 372: Sap Abap Refresher Course NoRestriction

ABAP Objects Addressing the Components of Objects

•You can access static components using the class name as well as the reference variable. •It is also possible to address the static components of a class before an p pobject has been created.

•Addressing a static attribute <attr>: <class>=><attr>

•Calling a static method <meth>: CALL METHOD <class>=><meth>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 373: Sap Abap Refresher Course NoRestriction

ABAP Objects Self references

•Within a class, you can use the self-reference ME to access the individual components:

•To access an attribute <attr> in the same class: ME-><attr> •To call a method <meth> in the same class: CALL METHOD ME-><meth>

•Self references allow an object to give other objects a reference to it.

•You can also access attributes in methods from within an object even if they are b d b l l tt ib t f th th dobscured by local attributes of the method.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 374: Sap Abap Refresher Course NoRestriction

ABAP Objects

REPORT zharesh

Self references- Example

REPORT zharesh .

CLASS lcl DEFINITION.PUBLIC SECTION.METHODS: m1.

PRIVATE SECTION.DATA: v1 VALUE 'a'.

ENDCLASS. "lcl DEFINITIONENDCLASS. lcl DEFINITION

CLASS lcl IMPLEMENTATION.METHOD m1.DATA 1 VALUE 'b'DATA: v1 VALUE 'b'.WRITE v1. "This will print 'b' since it is local data and has more

precedence than global data*Now how do we print the global data v1 (which has vale 'a')?p g ( )*We use the self-reference "ME"

WRITE me->v1. "Now this will print ‘a'ENDMETHOD. "m1

ENDCLASS "lcl IMPLEMENTATION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

ENDCLASS. lcl IMPLEMENTATION

Page 375: Sap Abap Refresher Course NoRestriction

ABAP Objects Overview Graphic - Objects

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 376: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 1

The DATA statement creates a class reference variable CREF1 with typeThe DATA statement creates a class reference variable CREF1 with type C_COUNTER. This variable can contain references to all instances of the class C_COUNTER. The class C_COUNTER must be known to the program when the DATA statement occurs. You can either declare it locally before the data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

statement in the same program, or globally using the Class Builder. The contents of CREF1 are initial. The reference does not point to an instance.

Page 377: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 2

The CREATE OBJECT statement creates an object (instance) of the classThe CREATE OBJECT statement creates an object (instance) of the class C_COUNTER. The reference in the reference variable CREF_1 points to this object.This instance of the class C_COUNTER is called C_COUNTER<1>, because

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

this is how the contents of the object variable REF_COUNTER_1 are displayed in the debugger after the CREATE OBJECT statement has been executed.

Page 378: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 3

The ABAP program can access the public components of the object using theThe ABAP program can access the public components of the object using the reference variable CREF1, that is in this case, it can call the public methods of the class C_COUNTER. After the program on the left-hand side has been executed, the program variables NUMBER and the private object attribute

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

COUNT both have the value 8.

Page 379: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 4

This declares three different class reference variables for the classThis declares three different class reference variables for the class C_COUNTER. All of the references are initial.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 380: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 5

The system creates three objects of the class from the three class referenceThe system creates three objects of the class from the three class reference variables. The references in the three reference variables each point to one of these objects. In the internal program management, the individual instances are called

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

C_COUNTER<1>, C_COUNTER<2>, and C_COUNTER<3>. They are named in the order in which they were created.

Page 381: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 6

The ABAP program can use the reference variables to access individual objectsThe ABAP program can use the reference variables to access individual objects, that is in this case, to call the public methods of the class C_COUNTER.Each object has its own state, since the private instance attribute COUNT has a separate value for each object. The program on the left-hand side administers

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

several independent counters.

Page 382: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 7

Here three class reference variables are declared for the class C COUNTERHere, three class reference variables are declared for the class C_COUNTER, and two objects are created for the class. The references in the reference variables CREF1 and CREF2 each point to one of these objects. The reference in CREF3 is initial.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 383: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 8

After the MOVE statement CREF3 contains the same reference as CREF2 andAfter the MOVE statement, CREF3 contains the same reference as CREF2, and both references point to the object C_COUNTER<2>. A user can thus use either reference to address the object C_COUNTER<2>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 384: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 9

The CLEAR statement resets the reference in CREF2 to its initial value TheThe CLEAR statement resets the reference in CREF2 to its initial value. The reference variable CREF2 then contains the same value as it did immediately after its declaration, and does not point to an object any more.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 385: Sap Abap Refresher Course NoRestriction

ABAP Objects Example - Step 10

The effect of the assignment statement is to copy the reference from CREF1 toThe effect of the assignment statement is to copy the reference from CREF1 to CREF2. As a result, the reference in CREF3 also points to the object C_COUNTER<1>. No more references point to the object C_COUNTER<2>, and it is automatically deleted by the Garbage Collection. The internal name

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

C_COUNTER<2> is now free again.

Page 386: Sap Abap Refresher Course NoRestriction

ABAP Objects Declaring Methods

You can declare methods in the declaration part of a class or in an interface ToYou can declare methods in the declaration part of a class or in an interface. To declare instance methods, use the following statement:

METHODS <meth> IMPORTING.. [VALUE(]<ii>[)] TYPE type [OPTIONAL].. EXPORTING.. [VALUE(]<ei>[)] TYPE type [OPTIONAL].. CHANGING.. [VALUE(]<ci>[)] TYPE type [OPTIONAL].. RETURNING VALUE(<r>) EXCEPTIONS <ei>EXCEPTIONS.. <ei>..

and the appropriate additions.

To declare static methods, use the following statement: CLASS METHODS thCLASS-METHODS <meth>...

Unlike in function modules, the default way of passing a parameter in a method is by reference. y

To pass a parameter by value, you must do so explicitly using the VALUE addition.

The return value (RETURNING parameter) must always be passed explicitly as a

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

The return value (RETURNING parameter) must always be passed explicitly as a value.

Page 387: Sap Abap Refresher Course NoRestriction

ABAP Objects Implementing Methods

You must implement all of the methods in a class in the implementation part of the class in a

METHOD <meth>METHOD <meth>....ENDMETHOD.block.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 388: Sap Abap Refresher Course NoRestriction

ABAP Objects Calling Methods

To call a method use the following statement:To call a method, use the following statement: CALL METHOD <meth> EXPORTING... <ii> =.<f i>...

IMPORTING... <ei> =.<g i>... CHANGING ... <ci> =.<f i>...

RECEIVING hRECEIVING r = h EXCEPTIONS... <ei> = rc i...

Within the implementation part of a class, you can call the methods of the same t t e p e e tat o pa t o a c ass, you ca ca t e et ods o t e sa eclass directly using their name <meth>.

CALL METHOD <meth>...

Outside the class the visibility of the method depends on whether you can call it atOutside the class, the visibility of the method depends on whether you can call it at all. Visible instance methods can be called from outside the class using

CALL METHOD <ref>-><meth>...

where <ref> is a reference variable whose value points to an instance of the class. Visible instance methods can be called from outside the class using

CALL METHOD <class>=><meth>...where <class> is the name of the relevant class

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

where <class> is the name of the relevant class.

Page 389: Sap Abap Refresher Course NoRestriction

ABAP Objects

C

Constructors

Constructors

•Constructors are special methods that cannot be called using CALL METHOD.

•Instead, they are called automatically by the system to set the starting state of a new object or class.

E t d l i t t th ti f ti bj t•Executed only once per instance at the time of creating an object

•Constructors initialize objects

•Constructors are methods with a predefined name.

•To use them, you must declare them explicitly in the class.

•Only has IMPORTING parameters and EXCEPTIONS

•METHODS CONSTRUCTOR IMPORTING param TYPE type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

EXCEPTIONS exception.

Page 390: Sap Abap Refresher Course NoRestriction

ABAP Objects

S C

Static Constructors

Static Constructors•CLASS-METHODS: CLASS_CONSTRUCTOR

•Only accessed once per programOnly accessed once per program

•Automatically called before the class is first accessedEg:C ti f 1st bj t•Creation of 1st object

•1st access of static method•1st access of static attribute

•Cannot have parameters and exceptions

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 391: Sap Abap Refresher Course NoRestriction

ABAP Objects Functional Methods

Functional Methods

These are methods which can be called like functions.

•Only 1 parameter can be RETURNING parameter and this has to passed BY VALUE•Can have importing parametersN EXPORTING d CHANGING t•No EXPORTING and CHANGING parameters

Format:Eg: a = b + function name().g _ ()

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 392: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 393: Sap Abap Refresher Course NoRestriction

ABAP Objects

Inheritance allows you to derive a new class from an existing class.

Inheritance - 1

y g

You do this using the INHERITING FROM addition in the

CLASS <subclass> DEFINITION INHERITING FROM <superclass>CLASS <subclass> DEFINITION INHERITING FROM <superclass>.

statement.

The new class <subclass> inherits all of the components of the existing class <superclass>.

The new class is called the subclass of the class from which it is derivedThe new class is called the subclass of the class from which it is derived.

The original class is called the superclass of the new class.

Only the public and protected components of the superclass are visible in the subclass.

You can declare private components in a subclass that have the same names as

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

You can declare private components in a subclass that have the same names as private components of the superclass. Each class works with its own private components.

Page 394: Sap Abap Refresher Course NoRestriction

ABAP Objects Inheritance - 2

A class can have more than one direct subclass, but it may only have one direct superclass. This is called single inheritance.

The root node of all inheritance trees in ABAP Objects is the predefinedThe root node of all inheritance trees in ABAP Objects is the predefined empty class OBJECT. This is the most generalized class possible, since it contains neither attributes nor methods.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 395: Sap Abap Refresher Course NoRestriction

ABAP Objects Inheritance - Example

Inheritance Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 396: Sap Abap Refresher Course NoRestriction

ABAP Objects

f

Inheritance – Redifining Methods - 1

All subclasses contain the components of all classes between themselves and the root node in an inheritance tree. The visibility of a component cannot be changed.

However, you can use the REDEFINITION addition in the METHODS statement toHowever, you can use the REDEFINITION addition in the METHODS statement to redefine an inherited public or protected instance method in a subclass and make its function more specialized.

Wh d fi th d t h it i t f Th th dWhen you redefine a method, you cannot change its interface. The method retains the same name and interface, but has a new implementation. i.e. method method overloading is not allowedoverloading is not allowed.

However, method overloading is allowed in case of constructors.

Any reference that points to an object of the subclass uses the redefined method, even if the reference was defined with reference to the superclasseven if the reference was defined with reference to the superclass.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 397: Sap Abap Refresher Course NoRestriction

ABAP Objects

f f S

Inheritance – Redifining Methods - 2

Within a redefined method, you can use the pseudoreference SUPER-> to access the obscured method. This enables you to use the existing function of the method in the superclass without having to recode it in the subclass.

The method declaration and implementation in the superclass is not affected when you redefine the method in a subclass.

Any reference that points to an object of the subclass uses the redefined method, even if the reference was defined with reference to the superclass. p

If, for example, a superclass method M1 contains a call CALL METHOD ME->[M2], and M2 is redefined in a subclass calling M1 from an instance of the superclass willand M2 is redefined in a subclass, calling M1 from an instance of the superclass will cause the original method M2 to be called, and calling M1 from an instance of the subclass will cause the redefined method M2 to be called.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 398: Sap Abap Refresher Course NoRestriction

ABAP Objects

If d fi t t i th b l th i ti f h th h

Inheritance – Constructors

• If you define a constructor in the sub-class, then irrespective of whether you have defined a constructor in the super-class or not, you need to explicitly call the constructor of the super-class using the statement

CALL METHOD SUPER->CONSTRUCTOR.Incase the super-class does not have a constructor, the default constructor will be called by the system. (which will do nothing)

• If you don’t have a constructor in the sub class but if you have a constructor in the• If you don t have a constructor in the sub-class but if you have a constructor in the super-class, and if you create an object of the sub-class, then the default constructor of the sub-class will call the constructor of the super-class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 399: Sap Abap Refresher Course NoRestriction

ABAP Objects Redefining Methods - Example

Method RedefinitionMethod Redefinition Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 400: Sap Abap Refresher Course NoRestriction

ABAP Objects

S C O S C SS

Abstract, Final and Singleton

The ABSTRACT and FINAL additions to the METHODS and CLASS statements allow you to define abstract and final methods or classes.

Abstract –Abstract •Abstract classes cannot be instantiated. •An abstract method is defined in an abstract class and cannot be implemented in that class. Instead, it HAS to be implemented in the subclass.

Final –•Final classes cannot have subclasses. •They conclude an inheritance tree. y•A final method cannot be redefined in a subclass. •All methods in final classes are automatically final.

Singleton ClassesSingleton Classes –•Classes that are both abstract and final are known as Singleton classes•Only static components can be used.•Only 1 instance (“single”) of such a class may be defined

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

•This instance needs to be defined within the class itself

Page 401: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 402: Sap Abap Refresher Course NoRestriction

ABAP Objects

f f f f

Polymorphism

If you redefine a method of a superclass in a subclass, you can use a reference variable defined with reference to the superclass to address objects with different method implementations.

When you address the superclass, the method has the original implementation, but when you address the subclass, the method has the new implementation.

U i i l f i bl t ll id ti ll d th d th tUsing a single reference variable to call identically-named methods that behave differently is called polymorphism.

e.g.g

Polymorphism Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 403: Sap Abap Refresher Course NoRestriction

ABAP Objects

• Getting a super class variable to refer to a subclass variable is called Narrowing

Narrowing Cast

g p gCast• E.g. Obj_super = obj_sub.

• After Narrowing cast you can use the super class reference to access the• After Narrowing cast, you can use the super class reference to access the components of the subclass instance that were inherited from super class

• The components inherited from the superclass can be addressed

• Also called “Up-Cast”

• Use: A user who is not interested in the finer points of subclasses but only in the• Use: A user who is not interested in the finer points of subclasses, but only in the attributes of the superclass, does not need to know about them. The user only wants to work with references to the superclass. Hence in order to allow the user to work with subclass objects, you need a Narrowing cast

• Also used to access interface components

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 404: Sap Abap Refresher Course NoRestriction

ABAP Objects

Getting a sub class variable to refer to a superclass variable is called Widening Cast

Widening Cast

g p g

The problem (Need for widening cast):Data: r_vehicle TYPE REF To lcl_vehicle.LOOP AT vehicle list INTO r vehicleLOOP AT vehicle_list INTO r_vehicle.*Only for trucks*ENDLOOP.------------------------------------------------------------------------------------------------------The solution (Widening cast):Data: r_vehicle TYPE REF To lcl_vehicle,

r truck TYPE REF TO lcl truckr_truck TYPE REF TO lcl_truck.LOOP AT vehicle_list INTO r_vehicle.TRY.

r_truck ?= r_vehicle.*processing for trucks

CATCH CX_SY_MOVE_CAST_ERROR INTO r_exception.*processing for error situation

CLEANUP.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

CLEANUP.ENDTRY.

ENDLOOP.

Page 405: Sap Abap Refresher Course NoRestriction

ABAP Objects Widening Cast

Widening Cast

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 406: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 407: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces

•It is often necessary for similar classes to provide similar functions that are coded•It is often necessary for similar classes to provide similar functions that are coded differently in each class but which should provide a uniform point of contact for the user.

•For example, you might have two similar classes, savings account and check account, both of which have a method for calculating end of year charges. The interfaces and names of the methods are the same, but the actual implementation is different The user of the classes and their instances must also be able to run thedifferent. The user of the classes and their instances must also be able to run the end of year method for all accounts, without having to worry about the actual type of each individual account.

ABAP Obj t k thi ibl b i i t f I t f i d d t•ABAP Objects makes this possible by using interfaces. Interfaces are independent structures that you can implement in a class to extend the scope of that class. •Interfaces extend the scope of a class by adding their own components to its public section.

•This allows users to address different classes via a universal point of contact. Interfaces, along with inheritance, provide one of the pillars of polymorphism, since they allow a single method within an interface to behave differently in different

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

since they allow a single method within an interface to behave differently in different classes.

Page 408: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces - Defining Interfaces

Lik l d fi i t f ith l b ll i th R/3 R it•Like classes, you can define interfaces either globally in the R/3 Repository or locally in an ABAP program.

•The definition of a local interface <intf> is enclosed in the statements:INTERFACE <intf>.

...ENDINTERFACE.

•The definition contains the declaration for all components (attributes, methods, events) of the interface.

•The components of interfaces do not have to be assigned individually to a visibility section, since they automatically belong to the public section of the class in which the interface is implemented.

•Interfaces do not have an implementation part, since their methods are implemented in the class that implements the interface.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 409: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces - Implementing Interfaces

•Unlike classes interfaces do not have instances Instead interfaces areUnlike classes, interfaces do not have instances. Instead, interfaces are implemented by classes.

•To implement an interface in a class, use the statementCLASS l DEFINITION INTERFACES i tfCLASS <class> DEFINITION INTERFACES <intf>.

in the declaration part of the class. This statement may only appear in the public section of the class.

A component <icomp> of an interface <intf> can be addressed as though it were a member of the class under the name <intf~icomp>.The class must implement the methods of all interfaces implemented in it. The implementation part of the class m st contain a method implementation for eachimplementation part of the class must contain a method implementation for each interface method <imeth>:

METHOD <intf~imeth>....ENDMETHOD.

Interfaces can be implemented by different classes. Each of these classes is extended by the same set of components However the methods of the interface

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

extended by the same set of components. However, the methods of the interface can be implemented differently in each class.

Page 410: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces - Interface References

•Instead of creating reference variables with reference to a class, you can also define them with reference to an interface.

•To define an interface reference, use the addition TYPE REF TO <intf> in theTo define an interface reference, use the addition TYPE REF TO intf in the TYPES or DATA statement.

•A reference variable with the type interface reference is called a interface reference i bl i t f f f h tvariable, or interface reference for short.

•An interface reference <iref> allows a user to use the form <iref>-><icomp> to address all visible interface components <icomp> of the object to which the object p p j jreference is pointing.

•It allows the user to access all of the components of the object that were added to its definition by the implementation of the interfaceits definition by the implementation of the interface.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 411: Sap Abap Refresher Course NoRestriction

ABAP ObjectsAddressing Objects Using Interface References

If th l < l > i l t i t f <i tf> th f ll iIf the class <class> implements an interface <intf>, you can use the following assignment between the class reference variable <cref> and an interface reference <iref> to make the interface reference in <iref> point to the same object as the class reference in <cref>:

<iref> = <cref>

If the interface <intf> contains an instance attribute <attr> and an instance methodIf the interface <intf> contains an instance attribute <attr> and an instance method <meth>, you can address the interface components as follows:

Using the class reference variable <cref>:To access an attribute <attr>: <cref>-><intf~attr> To call a method <meth>: CALL METHOD <cref>-><intf~meth>

Using the interface reference variable <iref>:Using the interface reference variable <iref>: To access an attribute <attr>: < iref>-><attr> To call a method <meth>: CALL METHOD <iref>-><meth>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 412: Sap Abap Refresher Course NoRestriction

ABAP ObjectsAddressing Objects Using Interface References

As far as the static components of interfaces are concerned, you can only use theAs far as the static components of interfaces are concerned, you can only use the interface name to access constants:

Addressing a constant <const>: < intf>=><const>

For all other static components of an interface, you can only use object references or the class <class> that implements the interface:

Addressing a static attribute <attr>: < class>=><intf~attr>

Calling a static method <meth>: CALL METHOD <class>=><intf~meth>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 413: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Overview Graphics - 1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 414: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Overview Graphics - 2

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 415: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Introductory Example – Part 1

INTERFACE I COUNTER. CLASS C COUNTER2 DEFINITION._METHODS: SET_COUNTER IMPORTING

VALUE(SET_VALUE) TYPE I,INCREMENT_COUNTER,GET_COUNTER EXPORTING VALUE(GET_VALUE)

TYPE I.

_PUBLIC SECTION.

INTERFACES I_COUNTER.PRIVATE SECTION.

DATA COUNT TYPE I.ENDCLASS.TYPE I.

ENDINTERFACE.

CLASS C_COUNTER1 DEFINITION.PUBLIC SECTION.

ENDCLASS.

CLASS C_COUNTER2 IMPLEMENTATION.METHOD I_COUNTER~SET_COUNTER.

COUNT = ( SET_VALUE / 10) * 10.INTERFACES I_COUNTER.

PRIVATE SECTION.DATA COUNT TYPE I.

ENDCLASS.

ENDMETHOD.METHOD I_COUNTER~INCREMENT_COUNTER.

IF COUNT GE 100.MESSAGE I042(00).COUNT = 0.

CLASS C_COUNTER1 IMPLEMENTATION.METHOD I_COUNTER~SET_COUNTER.

COUNT = SET_VALUE.ENDMETHOD.METHOD I COUNTER INCREMENT COUNTER

ELSE.ADD 10 TO COUNT.

ENDIF.ENDMETHOD.METHOD I COUNTER~GET COUNTER.

METHOD I_COUNTER~INCREMENT_COUNTER.ADD 1 TO COUNT.

ENDMETHOD.METHOD I_COUNTER~GET_COUNTER.

GET_VALUE = COUNT.

_ _GET_VALUE = COUNT.

ENDMETHOD.ENDCLASS.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

ENDMETHOD.ENDCLASS.

Page 416: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Introductory Example–Part 2

The interface I_COUNTER contains three methods SET_COUNTER, INCREMENT_COUNTER, and GET_COUNTER.

The classes C COUNTER1 and C COUNTER2 implement the interface in the publicThe classes C_COUNTER1 and C_COUNTER2 implement the interface in the public section.

Both classes must implement the three interface methods in their implementation part.

C_COUNTER1 is a class for counters that can have any starting value and are then increased by one. C_COUNTER2 is a class for counters that can only be increased in steps of 10. Both classes have an identical outward face. It is fully defined by the p y yinterface in both cases.

The following sections explain how a user can use an interface reference to address the objects of both classes:the objects of both classes:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 417: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Introductory Example–Part 3

First, two class reference variables CREF1 and CREF2 are declared for the classes C_COUNTER1 and C_COUNTER2. An interface reference IREF is also declared for the interface I_COUNTER. All of the reference variables are initial.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 418: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Introductory Example–Part 4

The CREATE OBJECT statement creates an object for each class to which the references in CREF1 and CREF2 point.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 419: Sap Abap Refresher Course NoRestriction

ABAP Objects Interfaces – Introductory Example–Part 5

When the reference of CREF1 is assigned to IREF, the reference in IREF also points to the object with the internal name C_COUNTER<1>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 420: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 421: Sap Abap Refresher Course NoRestriction

ABAP Objects

“ ” f f

Events

An “event” is the occurrence of a special condition during the execution of an ABAP program.

This occurrence must be of sufficient importance for the ABAP program to take aThis occurrence must be of sufficient importance for the ABAP program to take a special action.

The following steps are required in an ABAP program in order to handle events:T i i E t•Triggering Events

•Handling Events

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 422: Sap Abap Refresher Course NoRestriction

ABAP Objects Triggering Events

Triggering EventsTo trigger an event, a class must· Declare the event in its declaration part· Trigger the event in one of its methodsTrigger the event in one of its methods

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 423: Sap Abap Refresher Course NoRestriction

ABAP Objects

f f

Declaring Events

You declare events in the declaration part of a class or in an interface. To declare instance events, use the following statement:

EVENTS <evt> EXPORTING... VALUE(<ei>) TYPE type [OPTIONAL]..EVENTS evt EXPORTING... VALUE( ei ) TYPE type [OPTIONAL]..

To declare static events, use the following statement: CLASS-EVENTS <evt>...

Both statements have the same syntax.

When you declare an event, you can use the EXPORTING addition to specify y , y p yparameters that are passed to the event handler.

The parameters are always passed by value.

Instance events always contain the implicit parameter SENDER, which has the type of a reference to the class or the interface in which the event is declared.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 424: Sap Abap Refresher Course NoRestriction

ABAP Objects Triggering Events

An instance event in a class can be triggered by any method in the class.

Static events can be triggered by any static method. To trigger an event in a method, use the following statement:method, use the following statement:

RAISE EVENT <evt> EXPORTING... <ei> = <fi>...

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 425: Sap Abap Refresher Course NoRestriction

ABAP Objects Handling Events

Events are handled using special methods. To handle an event, a method must· be defined as an event handler method for that event· be registered at runtime for the event.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 426: Sap Abap Refresher Course NoRestriction

ABAP Objects

Any class can contain event handler methods for events from other classes. You

Declaring Event Handler Methods

ycan, of course, also define event handler methods in the same class as the event itself. To declare an event handler method, use the following statement:

METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING <ei>METHODS <meth> FOR EVENT <evt> OF <cif> IMPORTING.. <ei>..for an instance method.

For a static method, use CLASS-METHODS instead of METHODS.

<evt> is an event declared in the class or interface <cif>.

•The interface of an event handler method may only contain formal parameters•The interface of an event handler method may only contain formal parameters defined in the declaration of the event <evt>. The attributes of the parameter are also adopted by the event. •The event handler method does not have to use all of the parameters passed in the RAISE EVENT statement. If you want the implicit parameter SENDER to be used as well, you must list it in the interface. This parameter allows an instance event handler to access the trigger, for example, to allow it to return results. •If you declare an event handler method in a class, it means that the instances of the

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

If you declare an event handler method in a class, it means that the instances of the class or the class itself are, in principle, able to handle an event <evt> triggered in a method.

Page 427: Sap Abap Refresher Course NoRestriction

ABAP Objects

To allow an event handler method to react to an event, you must determine at

Registering Event Handler Methods

, yruntime the trigger to which it is to react. You can do this with the following statement: SET HANDLER... <hi>... [FOR]...It links a list of handler methods with corresponding trigger methodsIt links a list of handler methods with corresponding trigger methods.

For an instance event, you must use the FOR addition to specify the instance for which you want to register the handler. You can either specify a single instance as the trigger, using a reference variable <ref>:

SET HANDLER... <hi>...FOR <ref>.or you can register the handler for all instances that can trigger the event:

SET HANDLER <hi> FOR ALL INSTANCESSET HANDLER... <hi>...FOR ALL INSTANCES.The registration then applies even to triggering instances that have not yet been created when you register the handler. You cannot use the FOR addition for static events:

SET HANDLER... <hi>...The registration applies automatically to the whole class, or to all of the classes that implement the interface containing the static event. In the case of interfaces, the registration also applies to classes that are not loaded until after the handler has

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

registration also applies to classes that are not loaded until after the handler has been registered.

Page 428: Sap Abap Refresher Course NoRestriction

ABAP Objects Overview Graphic - Events

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 429: Sap Abap Refresher Course NoRestriction

ABAP Objects Example – Events

Events Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 430: Sap Abap Refresher Course NoRestriction

ABAP Objects Class Practice - Events

lcl vehiclelcl_vehicleClass-data: count

Class-methods: class_constructor,

increment

lcl-carClass-data: count

Class-methods: class constructor

lcl-truckClass-data: count

Class-methods: class constructorClass methods: class_constructor,

incrementClass-methods: class_constructor,

increment

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 431: Sap Abap Refresher Course NoRestriction

ABAP Objects Friends

•A class can offer friendship to other classes or interfacesA class can offer friendship to other classes or interfaces.

•Friends have access to all components of a class and can always instantiate a class.

•A class offering friendship is not automatically a friend of its friends.

•Sub-classes of friends automatically become friends of the class offering friendship

•Advantages:Advantages:

•Unrestricted access

•Fast access

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 432: Sap Abap Refresher Course NoRestriction

ABAP Objects Persistent Classes

Transient and persistent dataTransient and persistent data

•ABAP programs work with local program data, which resides in the program’s internal session. This data lives only as long as its context – that is, as long as its associated procedure (for local procedure data); its object (for attributes of classes);associated procedure (for local procedure data); its object (for attributes of classes); or its program (for global program data). This data is known as transient. Data that can be preserved beyond the runtime of the program is known as persistent.

Data in object-oriented programmingData in object oriented programming

•An object in ABAP Objects is transient. It exists in the internal program session only from the time it is generated (using CREATE OBJECT) until it is deleted by the Garbage Collector. g

•Ideally you could save the encapsulation of data and functions persistently within the object instead. A program could then leave an object in a certain state and a second program could continue working on the object in that state. p g g j

•Classes of objects are already persistent anyway, but you need some way of saving the attributes of an object persistently and then make reference to the appropriate class. The Persistence Service allows you to do exactly that.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

pp p y y

Page 433: Sap Abap Refresher Course NoRestriction

ABAP Objects Persistent Classes

The Persistence Service for Persistent ObjectsThe Persistence Service for Persistent Objects

•ABAP Objects are always transient, just like the data objects in ABAP programs. There are no persistent objects in ABAP Objects. However, the Persistence Service within Object Services allows application developers to work with persistent objectswithin Object Services allows application developers to work with persistent objects. The Persistence Service can be thought of as a software layer between the ABAP program and the data repository (that is, the database), which allows you to save the attributes of objects with a unique identity, and then load them again when you

d thneed them.

•Put simply, the Persistence Service ensures that an object is initialized in a specified state, and saves the state of that object when required.

•The relationship between the object and the description of its state in the database is similar to the relationship between transient and persistent data outlined above. The state of the object when it is instantiated reflects the state of the data in the database at that timedatabase at that time.

•Changes to the object state in the ABAP program are not written to the database immediately, but only after the appropriate request has been made (that is, the COMMIT WORK statement has been executed) Thus a persistent object exists as

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

COMMIT WORK statement has been executed). Thus, a persistent object exists as an original in the database and as a copy in one or more ABAP programs.

Page 434: Sap Abap Refresher Course NoRestriction

ABAP Objects Persistent Classes

Persistent ClassesPersistent Classes•To use the Persistence Service for objects, the classes of these objects must be created as persistent classes in the Class Builder. •The term persistent class does not imply that a class is persistent. (As a template for objects, every class is persistent). •Rather, it means that the objects of that class and their state are managed by the Persistence Service.

•For example, the objects of these classes are instantiated in the ABAP program with a method of the Persistence Service, which ensures that the initialization is correct (not with the usual CREATE OBJECT statement).

•When the Class Builder creates a persistent class, it automatically generates an associated class, known as the class actor or class agent, whose methods manage the objects of persistent classes.j p

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 435: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 436: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 1

• To Create a Class

•Go to Transaction SE80 or SE24Go to Transaction SE80 or SE24

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 437: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 2

• To Create a Class…

•Then specify whether you want to create a class or interface.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 438: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 3

• To Create a Method.

•Double click on the object Name(ZNDC) and it will take you the following Screen, where you define the level, visibility, Description etc. for particular method in a class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 439: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 4

• To Implement your method.Double click on the Method to implement your method. Click to implement yourClick to implement your

method

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 440: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 5

• To Implement your method.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 441: Sap Abap Refresher Course NoRestriction

ABAP Objects Global Classes - 6

• Classes Visibility Section.

•Public SectionPublic Section

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 442: Sap Abap Refresher Course NoRestriction

ABAP Objects

S f C & f

Global Classes - 7

Public Section of the Class, which is visible & accessible to all users of the class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 443: Sap Abap Refresher Course NoRestriction

ABAP Objects

G f f

ALV Grids - 1

The ALV Grid control is a flexible tool for displaying lists. The tool provides common list operations as generic functions and can be enhanced by self-defined options.

The ALV Grid control is used to build non-hierarchical, interactive, and modern-design lists. As a control, it is a component that is installed on the local PC.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 444: Sap Abap Refresher Course NoRestriction

ABAP Objects

S 1

ALV Grids - 2

Step 1: In Screen Painter: Create a screen with a custom control object on it and give

the custom control a name (e.g. CC_ALV)

Step 2: In Screen logic: Create TYPE REF’s to cl_gui_custom_container and

cl_gui_alv_grid

DATA: container TYPE REF TO cl_gui_custom_container,grid TYPE REF TO cl_gui_alv_grid.

Step 3:In PBO of screen: create objects for the above 2 reference variables

IF container IS INITIALIF container IS INITIAL.CREATE OBJECT container

EXPORTING container_name = ' CC_ALV '.ELSE .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

CALL METHOD grid->refresh_table_display ENDIF.

Page 445: Sap Abap Refresher Course NoRestriction

ABAP Objects

C O C

ALV Grids - 3

CREATE OBJECT gridEXPORTING i_parent = container.

Step 4:Step 4: In PBO of screen or start-of-selection: -Create an internal table having structure same as what you want to display-Populate internal table with data to be displayed

Step 5:In PBO of screen: Transfer data to the grid

CALL METHOD grid->set_table_for_first_displayEXPORTING

i_structure_name = '‘ “structure nameCHANGINGCHANGING

it_outtab = . “internal table name

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 446: Sap Abap Refresher Course NoRestriction

ABAP Objects

S 6

ALV Grids – 4

Step 6:Before LEAVE PROGRAM: Free the container

call method custom container1->free.call method custom_container1 free.call method cl_gui_cfw=>flush.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 447: Sap Abap Refresher Course NoRestriction

ABAP Objects

ALV grids with Field Catalog

ALV Grids – 5

ALV grids with Field Catalog

*ITAB & W.A FOR FIELDCATLOGDATA ITAB_FCAT TYPE LVC_T_FCAT.DATA WA_FCAT LIKE LINE OF itab_fcat.

*POPULATE ITABWA FCAT-FIELDNAME = ‘CTYPE'.WA_FCAT FIELDNAME CTYPE . WA_FCAT-REF_FIELD = 'CUSTTYPE' . “Database field nameWA_FCAT-REF_TABLE = 'SBOOK'. “Database table name WA_FCAT-COL_POS = 27.APPEND WA FCAT TO ITAB FCATAPPEND WA_FCAT TO ITAB_FCAT.

*Call method “set_table_for_first_display”, passing the name of the field catalogCALL METHOD r alv grid->set table for first display_ _g _ _ _ _ p yEXPORTING

I_STRUCTURE_NAME = 'SBOOK'CHANGING

IT OUTTAB = ITAB

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

IT_OUTTAB = ITABIT_FIELDCATALOG = ITAB_FCAT.

Page 448: Sap Abap Refresher Course NoRestriction

ABAP Objects

f ( )

Class Practice – ALV Grids

Using a selection screen, read the value of material type. (MARA-MTART)Create an ALV on another screen in the same module pool program and display 100 records. Display only the following fields:Display only the following fields:Material number (MARA-MATNR)Material Group (MARA-MATKL)Material Description (MAKT-MAKTX)

Create GUI status for proper navigation.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 449: Sap Abap Refresher Course NoRestriction

ABAP Objects

The occurrence of an exception is normally used to display an error situation.

Class-Based Exceptions - Overview

p y p y

Class-based exception handling is based on exception classes.

All exception classes are part of an inheritance hierarchy with a commonAll exception classes are part of an inheritance hierarchy with a common superclass, CX_ROOT.

Class-based exceptions can, therefore, be raised and handled in all ABAP contexts (programs, processing blocks).

Class-based exceptions are either raised 1 Explicitly by the ABAP statement RAISE EXCEPTION or1. Explicitly by the ABAP statement RAISE EXCEPTION or 2. Automatically by the ABAP runtime environment.

If a class-based exception occurs, the system interrupts the normal program flow and tries to find a suitable handler. If it does not find a handler, a runtime error occurs.

Exceptions that are raised in procedures but are not handled in the procedureitself are forwarded to the caller.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

itself are forwarded to the caller.

The caller can either handle the exception or forward it.

Page 450: Sap Abap Refresher Course NoRestriction

ABAP Objects

f f

Class-Based Exceptions–Handling Exceptions

The handler of an exception must try to correct the error that has occurred, find analternative solution, or (if this is not possible) at least bring the affected context into a consistent state and then forward the error.

If a call hierarchy does not contain a handler for an exception, the program is ended with a runtime error.

Cl b d ti h dl d i th f ll i t l t tClass-based exceptions are handled in the following control structure:TRY.... " TRY block (application coding)

CATCH cx ... cx ... ..._ _... " CATCH block (exception handler)

CATCH cx_... cx_... ...... " CATCH block (exception handler)

...CLEANUP.... " CLEANUP block (cleanup context)

ENDTRY.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 451: Sap Abap Refresher Course NoRestriction

ABAP Objects

C 1 f f

Class-Based Exceptions–Handling Exceptions

Case 1: An exception occurs and there is no handler defined for it either in the current TRY-ENDTRY block or in the caller blocks⇒Runtime error occurs

Case 2: An exception occurs and there is a handler for it in the same TRY-ENDTRY block⇒Program flow is interrupted

C di CATCH bl k t t d⇒Corresponding CATCH block gets executed⇒CLEANUP is not executed ⇒Program flow continues after the TRY-ENDTRY block

Case 3: An exception occurs, there is no handler for it in the same TRY-ENDTRY block, but there is a handler for it either in the enclosing TRY-ENDTRY block or the calling procedure⇒Program flow is interrupted⇒Program flow is interrupted⇒CATCH is not executed for the current TRY-ENDTRY block⇒CLEANUP is executed in the current TRY-ENDTRY block if it exists⇒CATCH gets executed in the enclosing/calling block

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 452: Sap Abap Refresher Course NoRestriction

ABAP ObjectsClass-Based Exceptions – Handling Exceptions

The TRY statement opens a control structure to be ended with ENDTRY, in whichthree statement blocks can be listed in a specified order.

1. A TRY block, in which exceptions can occur.1. A TRY block, in which exceptions can occur.This exception block consists of all the statements between the TRY and the CATCH statement.

2 O CATCH bl k f t hi ti2. One or more CATCH blocks for catching exceptions.These exception blocks are initiated with CATCH and ended with a further CATCH, CLEANUP, or ENDTRY.

3. A CLEANUP block for cleanup work after the exceptions have been caught.This statement block is initiated by CLEANUP and ended with ENDTRY. A TRY-ENDTRY structure must not contain more than one CLEANUP block in precisely this positionblock in precisely this position.

TRY-ENDTRY structures can be nested in any statement blocks.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 453: Sap Abap Refresher Course NoRestriction

ABAP Objects

The TRY block contains the application coding whose exceptions are to be handled.

Class-Based Exceptions – Try Block

pp g pThis statement block is processed sequentially. It can contain further control structures and calls of procedures or other ABAP programs.

• If an exception occurs in the TRY block or in a procedure called up here the• If an exception occurs in the TRY block or in a procedure called up here, the system starts by searching for a CATCH statement of the same TRY-ENDTRY structure.• It then searches from the inside out for a CATCH statement in any enclosingTRY-ENDTRY structures that handle the event. The system may call this handler. • If the system does not find a handler, but the TRY-ENDTRY structure is contained in a procedure, it tries to propagate the exception to the caller.

Exceptions cannot be propagated in any processing blocks without a local data area (event blocks, dialog modules).

A runtime error occurs immediately if the handler is missing.

If no exceptions occur in the TRY block, program execution is continued directly after ENDTRY after the block has been completed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

after ENDTRY after the block has been completed.

Page 454: Sap Abap Refresher Course NoRestriction

5. ABAP OBJECTS

Classes and objects

I h itInheritance

Polymorphism (casting)

Interfaces

Events

Gl b l l d i t fGlobal classes and interfaces

Exception handling

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 455: Sap Abap Refresher Course NoRestriction

ABAP Objects

• A catch block contains the exception handler that is executed when a

Class-Based Exceptions – Catch Block

pparticular exception has occurred in the TRY block of the same TRY-ENDTRY structure.

• A TRY ENDTRY structure can contain several exception handlers The syntax• A TRY-ENDTRY structure can contain several exception handlers. The syntax for introducing an exception handler is:CATCH cx_... cx_... INTO ref.

• This defines an exception handler for all the specified exception classes and their subordinate classes.

• After an exception occurs the system searches through the listed exception• After an exception occurs, the system searches through the listed exception handlers in the specified order. The first exception handler whose CATCH statement contains the corresponding exception class or one of its superclasses is executed.

• The system then continues program execution directly after ENDTRY.

• No subsequent exception handlers are considered. For this reason,

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

No subsequent exception handlers are considered. For this reason, the order of the different exception handlers within a TRY-ENDTRY structure must be based on the inheritance hierarchy of the specified exception classes.

Page 456: Sap Abap Refresher Course NoRestriction

ABAP Objects

f f

Class-Based Exceptions – Catch Block

• The syntax check ensures that the handlers for more specific exceptions (subordinate classes) can only be listed before the handlers for more general exceptions (superclasses).

• With the INTO addition, a reference to the exception object can be placed into a reference variable. This enables the attributes of the exception object to be accessed in the handler.

• The reference variable must be suitable for the exception. Its static type must be the exception class itself or one of its superclasses.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 457: Sap Abap Refresher Course NoRestriction

ABAP Objects

• If the system has not found a handler for an exception, but the exception is

Class-Based Exceptions – CleanUp Block

y p , phandled in an enclosing TRY-ENDTRY structure or is propagated to a caller, the CLEANUP block is executed before the TRY-ENDTRY structure is exited.

• Precisely one CLEANUP block can be defined in each TRY ENDTRY structure• Precisely one CLEANUP block can be defined in each TRY-ENDTRY structure.

• For example, objects often have to be brought into a consistent state or external resources, to which an external handler no longer has access, have to be released.

• All the statements that change the control flow, which cause the CLEANUP block to be exited and would initiate a processing block of the same programblock to be exited and would initiate a processing block of the same program, are forbidden.

• This applies to statements such as RETURN, STOP, for example. All the exceptions that occur within a CLEANUP block must also be handled here.

• It is, however, permissible to leave the overall program (LEAVE PROGRAM) or call up procedures, programs, and screen sequences if the system returns to the CLEANUP block.

• The runtime environment always recognizes that a CLEANUP block is being

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

The runtime environment always recognizes that a CLEANUP block is being exited illegally and then reacts with a runtime error.

Page 458: Sap Abap Refresher Course NoRestriction

ABAP Objects Class-Based Exceptions – Example

Class based exceptions Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 459: Sap Abap Refresher Course NoRestriction

ABAP Objects Sub-Classes of CX_ROOT

CX NO CHECK CX DYNAMIC CHECK CX STATIC CHECKCX_NO_CHECK CX_DYNAMIC_CHECK CX_STATIC_CHECK

You CAN handle these exceptions.

You MUST handle these exceptions or pass them along explicitly using the RAISING addition.

If you don’t, they are passed alongpassed along automatically.

They cannot be passed explicitly using theexplicitly using the RAISING addition.

Not part of syntax check Not part of syntax check Part of syntax check

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 460: Sap Abap Refresher Course NoRestriction

ABAP Objects

• Class-based exceptions that occur in procedures (methods, function modules,

Class-Based Exceptions – Propagating Exceptions

p p ( , ,subroutines) do not necessarily have to be handled here. They can be propagated to the caller of the procedure. If the caller is a procedure and the call takes place in a TRY block, the caller can handle the exception or propagate it to its callerits caller.

• The highest level to which exceptions can be propagated is processing blocks without a local data area, in other words, event blocks or dialog modules. Both the exceptions forwarded from called procedures and the exceptions that have occurred in the individual coding must be handled here. Otherwise, a runtime error will occur.

• A static constructor of a class cannot propagate exceptions, since a user of a class does not know whether it is the first user and whether or not it has to handle any exceptions that are propagated by the static constructor.

• Likewise, event handler methods cannot propagate exceptions.

• To propagate exceptions from procedures, the RAISING addition must usually

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

To propagate exceptions from procedures, the RAISING addition must usually be used for the definition of the interface of a procedure (except for static constructors and event handlers).

Page 461: Sap Abap Refresher Course NoRestriction

ABAP Objects Propagating Exceptions Example

PropagatingPropagating Exceptions

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 462: Sap Abap Refresher Course NoRestriction

ABAP Objects

• The most important feature of a caught exception is the fact that it has occurred

Class-Based Exceptions – Exception Texts

p g pand that it is handled in the program. It is left to the handler to decide how the exception situation is dealt with. It is not up to the exception itself to interact with the program user.

• Nevertheless, an explanatory text is assigned to each exception. This text describes the exception situation more precisely and is output as an error message if the exception is not handled.

• It should, however, only be used sparingly during exception handling for communication with the user. The exception text describes an error situation from a mostly technical viewfrom a mostly technical view.

• If an exception is described to a user, it should be described from the user's perspective.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 463: Sap Abap Refresher Course NoRestriction

ABAP Objects Exception Texts - Example

Exception Texts

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 464: Sap Abap Refresher Course NoRestriction

ABAP ObjectsClass Practice

Class Based Exceptions + Widening cast

Create a super class and its sub class. Create objects of both classes. Try to assign the object of the superclass to the object of the subclass If successful writethe object of the superclass to the object of the subclass. If successful, write “Bingo” else handle the exception.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGSatyam SAP PMG

Page 465: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Extract datasets

Data output in lists( Standard, Self-defined, Lists with several pages )p g )

Interactive lists( At line-selection , At User-command)

List creation with the ALV grid control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 466: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Refining Data

A t t t d t l l t t t l t it i li t d

.

A report must sort data,calculate totals,count item in lists and so on.

you can read the data to be refined from database tables or from sequential files or u can create generic report.

The refining process is independent of the process of retrieving data.

Create data set

Refine the data set

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 467: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Creating and Refining datasets:Creating and Refining datasets:

Abap/4 offers two methods of creating datasets in the storage

.Internal tables

Extract datasets

Internal tables :

If you want the datasets to map the underlying data structures as closely as possible and if you want to access individual data directly.

Extract datasets :

An extract is a sequential dataset you can create with a report.Use e tracts if o ant to process large amo nt of data as a hole

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

extracts if you want to process large amount of data as a whole several times

Page 468: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Refining data using EXTRACT DATASETS:Refining data using EXTRACT DATASETS:

An Extract is a sequential dataset in the report’s storage area.this means that you can access its data only within a loop.

.During the report’s run time,the system can create exactly one extract datasetdataset.

As for internal tables the size of the extract data set is principallyAs for internal tables the size of the extract data set is principally unlimited,since the system rolls it out if necessary.

In one extract dataset,you can store records of different length and structure one after the other.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 469: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Declaring Extract Records as Field Groups

.An extract dataset consists of a sequence of records. These records may have different structures. All records with the same structure form a record type You must define each record type of an extract dataset as arecord type. You must define each record type of an extract dataset as a field group, using the FIELD-GROUPS statement.

SyntaxFIELD-GROUPS <fg>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 470: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Filli E t t ith D tFilling an Extract with Data

Once you have declared the possible record types as field groups and

.

Once you have declared the possible record types as field groups and defined their structure, you can fill the extract dataset using the following statements:

SyntaxEXTRACT <fg>.g

When the first EXTRACT statement occurs in a program, the system t th t t d t t d dd th fi t t t d t it I hcreates the extract dataset and adds the first extract record to it. In each

subsequent EXTRACT statement, the new extract record is added to the dataset

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 471: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

R di E t tReading an ExtractLike internal tables, you can read the data in an extract dataset using aloop

.

loop.syntaxLOOP.…[AT FIRST | AT <fgi> [WITH <fg j>] | AT LAST. ...ENDAT.]...ENDLOOPENDLOOP.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 472: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Sorting an Extract

You can sort an extract dataset in much the same way as an internal table

.

You can sort an extract dataset in much the same way as an internal table by using the following statement:

syntaxSORT [ASCENDING|DESCENDING] [AS TEXT] [STABLE]BY <f1> [ASCENDING|DESCENDING] [AS TEXT]BY <f1> [ASCENDING|DESCENDING] [AS TEXT] ...<fn> [ASCENDING|DESCENDING] [AS TEXT].

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 473: Sap Abap Refresher Course NoRestriction

LIST PROCESSING

Processing Control LevelsProcessing Control Levels

When you sort an extract dataset, control levels are defined in it. For

.

general information about control levels, The control level hierarchy of an extract dataset corresponds to the sequence of the fields in the HEADER field group. After sorting, you can use the AT statement within a loop to program statement blocks that the system processes only at a control break, that is, when the control level changes.

SyntaxAT NEW <f> | AT END OF <f>....ENDAT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 474: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Extract datasets

Data output in lists( Standard, Self-defined, Lists with several pages )p g )

Interactive lists( At line-selection , At User-command)

List creation with the ALV grid control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 475: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Lists

Lists are the output medium for data from ABAP/4 report programs. Each program can produce up to 21 lists: one basic list and 20 secondary lists.

Structure and the options of a list are

The Standard ListThe Self-Defined ListLists with Several PagesLists with Several Pages

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 476: Sap Abap Refresher Course NoRestriction

BASIC LISTS

The standard list

If an ABAP/4 report makes use only of the WRITE, SKIP, and ULINE t t t t t Thi li t i ll d t d d li toutput statements .This list is called standard list.

The standard list consists of:

Standard Page Header

Standard PageStandard Page

User Interface of the Standard List

The next slide shows a standard list.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 477: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 478: Sap Abap Refresher Course NoRestriction

BASIC LISTS

The Self-Defined List

Self-defined list is a list created by modifying the standard list bySelf defined list is a list created by modifying the standard list by using options of the REPORT statement and using event keywords TOP-OF-PAGE and END-OF-PAGE.

The possible modifications that can be performed in a standard list are :

Page Header List Width Page Length Page FooterPage Footer

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 479: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Page HeaderPage Header

To layout a page header individually, you must define it in the processing block following the event keyword TOP-OF-PAGE:block following the event keyword TOP OF PAGE:

SyntaxTOP-OF-PAGE.WRITE: ....

The TOP-OF-PAGE event occurs as soon as the system starts processing a new page of a list and before outputting the first line on a new page.

Note :The self defined page header appears beneath the standard page headerThe self-defined page header appears beneath the standard page header. If you want to suppress the standard page header, use the NO STANDARD PAGE HEADING option of the REPORT statement.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 480: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT d li t h di NO STANDARD PAGE HEADINGREPORT demo_list_page_heading NO STANDARD PAGE HEADING.

TOP-OF-PAGE.

WRITE: sy-title, 40 'Page', sy-pagno.ULINE.WRITE: / 'SAP AG', 29 'Walldorf, ',sy-datum,WRITE: / SAP AG , 29 Walldorf, ,sy datum,

/ 'Neurottstr. 16', / '69190 Walldorf/Baden'.ULINE.

START-OF-SELECTION.

DO 5 TIMES.WRITE / sy-index.

ENDDO.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 481: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 482: Sap Abap Refresher Course NoRestriction

BASIC LISTS

List Width

To determine the width of the output list, use the LINE-SIZE option of the REPORT statement.

Syntax

REPORT <rep> LINE-SIZE <width>.

Note :

•If you set <width> to 0 the system uses the width of theIf you set <width> to 0, the system uses the width of the standardlist .•The system field SY-LINSZ contains the current line width

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 483: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Page Length

To determine the page length of an output list, use the LINE-COUNT ti f th REPORT t t toption of the REPORT statement.

Syntax

REPORT <rep> LINE-COUNT <length>[(<n>)].

<n> ---->The system reserves <n> lines of the page length for the<n> >The system reserves <n> lines of the page length for the page footer.

Note :•If you set <length> to zero, the system uses the standard page

length . •The system field SY-LINCT contains the current number of lines per page

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 484: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_line_count LINE-SIZE 40 LINE-COUNT 4.

WRITE: 'SY-LINCT:', sy-linct.SKIP.SKIP.

DO 6 TIMES.WRITE / sy-index.

ENDDO.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 485: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 486: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Page Footer

To define a page footer, use the END-OF-PAGE event.

Syntax

END OF PAGEEND-OF-PAGE.WRITE: ....

This event occurs when the system reaches the lines reserved for theThis event occurs when the system reaches the lines reserved for the page footer, or if the RESERVE statement triggers a page break.

Note :

The system only processes the processing block following END-OF-PAGE if you reserve lines for the footer in the LINE-COUNT option of the

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

REPORT statement .

Page 487: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_end_of_page LINE-SIZE 40 LINE-COUNT 6(2)NO STANDARD PAGE HEADING.

TOP OF PAGETOP-OF-PAGE.

WRITE: 'Page with Header and Footer'.ULINE AT /(27)ULINE AT /(27).

END-OF-PAGE.

ULINE.WRITE: /30 'Page', sy-pagno.

START-OF-SELECTION.

DO 6 TIMES.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

WRITE / sy-index.ENDDO.

Page 488: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 489: Sap Abap Refresher Course NoRestriction

BASIC LISTSLists with Several Pages

If in your report has more number of lines than defined in the LINE-COUNT option of the REPORT statement, the system automatically

tcreates a new page .

Apart from automatic page breaks, you can use the NEW-PAGE and RESERVE statements to code page breaks explicitlyRESERVE statements to code page breaks explicitly.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 490: Sap Abap Refresher Course NoRestriction

BASIC LISTSPage Break- Conditional

To execute a page break under the condition that less than a certain number of lines is left on a page, use the RESERVE statement:

Syntax

RESERVE <n> LINESRESERVE <n> LINES.

This statement triggers a page break if less than <n> free lines are leftThis statement triggers a page break if less than <n> free lines are left on the current list page between the last output and the page footer. Before starting a new page, the system processes the END-OF-PAGE event.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 491: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_reserve LINE-SIZE 40 LINE-COUNT 8(2).

END-OF-PAGE.

ULINE.

START-OF-SELECTION.

DO 4 TIMES.WRITE / sy-index.

ENDDO.

DO 2 TIMES.WRITE / sy-index.

ENDDO.

RESERVE 3 LINES.WRITE: / 'LINE 1',

/ 'LINE 2',/ 'LINE 3'.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 492: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 493: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Page Break- Unconditional

Syntax

NEW-PAGE.

* Ends the current page. All other output appears on a new page.* The system then increases the SY-PAGNO system field by one.* Does not trigger the END-OF-PAGE event. Does not trigger the END OF PAGE event.

Variants in NEW_PAGE are:

NEW-PAGE [NO-TITLE|WITH-TITLE] NO-HEADING|WITH-HEADING].NEW-PAGE LINE-COUNT <length>.NEW-PAGE LINE-SIZE <width>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 494: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_new_page LINE-SIZE 40.

TOP-OF-PAGE.

WRITE: 'TOP-OF-PAGE', sy-pagno.ULINE AT /(17).

START-OF-SELECTION.

DO 2 TIMES.WRITE / 'Loop:'.

DO 3 TIMES.WRITE / sy-index.

ENDDO.

NEW-PAGE.ENDDO.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 495: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 496: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling from within the Program

From within the program, you can scroll through lists vertically and h i t llhorizontally.

The SCROLL statement allows you:

Vertical Scrolling

Scrolling Window by WindowScrolling Window by Window Scrolling by Pages

Horizontal Scrollingg

Scrolling to the List's Margins Scrolling by Columns

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 497: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling Window by WindowScrolling Window by Window

To scroll through a list vertically by the size of the current window use this statement:this statement:

Syntax

SCROLL LIST FORWARD|BACKWARD.

This statement scrolls forward or backward through the current list by the size of the current window.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 498: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo list scroll 1 NO STANDARD PAGE HEADING LINE-SIZE 40.REPORT demo_list_scroll_1 NO STANDARD PAGE HEADING LINE SIZE 40.

TOP-OF-PAGE.

WRITE: 'Top of Page', sy-pagno, 'SY-SROWS:', sy-srows.ULINE.

START-OF-SELECTION.

DO 100 TIMES.DO 100 TIMES.WRITE / sy-index.

ENDDO.

DO 3 TIMES.SCROLL LIST FORWARD.

ENDDO.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 499: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 500: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling by Pages

To scroll a list vertically depending on the page length, the SCROLL t t t ff t tistatement offers two options.

Scrolling to Certain PagesScrolling to Certain Pages

Scrolling by a Certain Number of Pages

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 501: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling to Certain Pages

To scroll to certain pages, use the TO option of the SCROLL statement:

Syntax

SCROLL LIST TO FIRST PAGE | LAST PAGE | PAGE <page>SCROLL LIST TO FIRST PAGE | LAST PAGE | PAGE <page> .

This statement scrolls the current list to the first, to the last, or to the page numbered <page> .page numbered <page> .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 502: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling by a Certain Number of Pages

To scroll a list by a certain number of pages, use the following options of th SCROLL t t tthe SCROLL statement:

Syntax

SCROLL LIST FORWARD | BACKWARD <n> PAGES.

This statement scrolls forward or backward <n> pages.This statement scrolls forward or backward <n> pages.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 503: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling to the List's Margins

To scroll horizontally to the left or right margin of a list, use the following options of the SCROLL statement:

Syntax

SCROLL LIST LEFT | RIGHT.

This statement scrolls to the left or right margin of the currentlistThis statement scrolls to the left or right margin of the currentlist.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 504: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_scroll_3 NO STANDARD PAGE HEADING LINE-SIZE 200.

TOP-OF-PAGE.

WRITE: AT 161 'Top of Page', sy-pagno,

'SY SCOLS:' sy scolsSY-SCOLS: , sy-scols.

ULINE.

START OF SELECTIONSTART-OF-SELECTION.

DO 200 TIMES.

WRITE sy indexWRITE sy-index.ENDDO.

SCROLL LIST RIGHT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 505: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 506: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling by Columns

To scroll a list horizontally by columns, the SCROLL statement offers two options. A column in this case means one character of the list line.

•Scrolling to Certain Columns

•Scrolling by a Certain Number of Columns•Scrolling by a Certain Number of Columns

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 507: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Scrolling to Certain ColumnsScrolling to Certain Columns

To scroll to certain columns, use the TO COLUMN option of theTo scroll to certain columns, use the TO COLUMN option of the SCROLL statement:

Syntax

SCROLL LIST TO COLUMN <colm> .

This system displays the current list starting from column <colm>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 508: Sap Abap Refresher Course NoRestriction

BASIC LISTS

S lli b C t i N b f C lScrolling by a Certain Number of Columns

To scroll a list by a certain number of columns use the following optionTo scroll a list by a certain number of columns, use the following option of the SCROLL statement:

SyntaxSyntax

SCROLL LIST LEFT | RIGHT BY <n> PLACES.

This system scrolls the current list to the left or right by <n> columns.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 509: Sap Abap Refresher Course NoRestriction

BASIC LISTS

REPORT demo_list_scroll_4 NO STANDARD PAGE HEADING LINE-SIZE 200.

TOP OF PAGETOP-OF-PAGE.

WRITE: AT 161 'Top of Page', sy-pagno,'SY SCOLS:' sy scolsSY-SCOLS: , sy-scols.

ULINE.

START-OF-SELECTION.START OF SELECTION.

DO 200 TIMES.WRITE sy-index.y

ENDDO.

SCROLL LIST TO COLUMN 178.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 510: Sap Abap Refresher Course NoRestriction

BASIC LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 511: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Left Boundary for Horizontal ScrollingLeft Boundary for Horizontal Scrolling

To determine the left boundary of the horizontally scrollable area, use:

Syntax

SET LEFT SCROLL-BOUNDARY [COLUMN <col>].

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 512: Sap Abap Refresher Course NoRestriction

BASIC LISTS

Excluding Lines from Horizontal Scrollingc ud g es o o o ta Sc o g

To exclude a line (for example, a header or comment line) from horizontal scrolling, define the line feed for that line as follows:

Syntax

NEW LINE NO SCROLLINGNEW-LINE NO-SCROLLING.

The line following the statement cannot be scrolled horizontallyThe line following the statement cannot be scrolled horizontally. However, it can be scrolled vertically.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 513: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Extract datasets

Data output in lists( Standard, Self-defined, Lists with several pages )p g )

Interactive lists( At line-selection , At User-command)

List creation with the ALV grid control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 514: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTA list is an interactive list if the user interface allows actions that trigger events and if the corresponding interactive event keywords occur in the report.

All li t t d d i i t ti li t t d li tAll lists created during an interactive list event are secondary lists.Interactive lists enhance the classical type of output list with dialog functionality,thus coming close to dialog programming. Interactive lists provide the user with so called “interactive reporting” facilitylists provide the user with so-called interactive reporting facility.

Interactive reporting allows the user to participate actively in retrieving and presenting data during the the session. Instead of oneretrieving and presenting data during the the session. Instead of one extensive and detailed list,with interactive reporting you create a condensed basic list from which the user can call detailed information by positioning the cursor and entering commands.y p g g

Interactive reporting thus reduces information retrieval to the data actually required.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Detailed information is presented in secondary lists.

Page 515: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Interactive Reporting

Interactive List

Secondary List

REPORT

TRANSACTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 516: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

E t f I t ti Li tEvents for Interactive Lists

•AT LINE-SELECTIONAT PF•AT PF<nn>

•AT USER-COMMAND

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 517: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

All i Li S l tiAllowing Line Selection

To allow the user to select a line from the list, define and write a processing block for the AT LINE SELECTION event in your program:processing block for the AT LINE-SELECTION event in your program:

Syntax

AT LINE-SELECTION.<statements>.

In the predefined interface, Edit --> Choose and F2 are assigned to PICK.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 518: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Page Headers for Secondary Listsage eade s o Seco da y sts

On secondary lists, the system does not trigger the event TOP-OF-PAGE. To create page headers for secondary list:

Syntax

TOP-OF-PAGE DURING LINE-SELECTION.

The system triggers this event for each secondary listThe system triggers this event for each secondary list.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 519: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSProgram which shows At LINE-SELECTION & TOP-OF-PAGE DURING LINE-SELECTION.

REPORT demo_list_interactive_3 .

START-OF-SELECTION.

WRITE 'Basic List'.

AT LINE-SELECTION.

WRITE 'Secondary List'.

TOP-OF-PAGE DURING LINE-SELECTION.

CASE sy-lsind.WHEN 1.

WRITE 'First Secondary List'.WHEN 2WHEN 2.

WRITE 'Second Secondary List'.WHEN OTHERS.

WRITE: 'Secondary List, Level:', sy-lsind.ENDCASE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDCASE.ULINE.

Page 520: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Page Header in Basic List

This is the basic list

• When clicked on the basic list Event AT LINE-SELECTION is triggered.

• Next Slide shows the modified Page Header and Text of the Secondary List

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 521: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Changed Page Header in secondary listlist

This is the secondary list

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 522: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Allowing Function Key Selectiono g u ct o ey Se ect o

To allow the user to select an action by pressing a function key,

Syntax

AT PF<nn>.t t t<statements>.

<nn> is a number between 1 and 24.

SY-UCOMM returns the function code PF<nn>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 523: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSSTART-OF-SELECTION.

WRITE 'Basic List, Press PF5, PF6, PF7, or PF8'.

AT pf5.PERFORM tPERFORM out.

AT pf6.PERFORM out.

AT pf7.PERFORM out.

AT pf8AT pf8.PERFORM out.

FORM out.WRITE: 'Secondary List by PF Key Selection'WRITE: 'Secondary List by PF-Key Selection',

/ 'SY-LSIND =', sy-lsind,/ 'SY-UCOMM =', sy-ucomm.

ENDFORM.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 524: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

If any function keys f5,f6,f7 & f8 are pressed it will take you to the relavent secondary list

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 525: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Secondary list when function key(f5) isSecondary list when function key(f5) is pressed

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 526: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

S tti St tSetting a Status

You set the status with the SET PF STATUS statementYou set the status with the SET PF-STATUS statement,

Syntax

SET PF-STATUS <stat> [EXCLUDING <f>|<itab>].

Note:

For the Status type of interactive lists, choose List or List in dialog box. The system then automatically loads function codes predefined for list processing into the Menu Painter.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 527: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Th AT USER COMMAND E tThe AT USER-COMMAND Event

To allow your program to react to a user action triggering a self-defined function codefunction code

Syntax

AT USER-COMMAND.<statements>.

The AT USER-COMMAND event occurs whenever the user selects a self-defined function code from a self-defined user interface.

The event does not occur if the user selects function codes predefined for system functions or the function code PICK, which always triggers the AT LINE SELECTION e ent

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

LINE-SELECTION event.

Page 528: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT demo list at user command NO STANDARD PAGE HEADINGREPORT demo_list_at_user_command NO STANDARD PAGE HEADING.

START-OF-SELECTION.WRITE: 'Basic List',

/ 'SY LSIND:' sy lsind/ 'SY-LSIND:', sy-lsind.

TOP-OF-PAGE.WRITE 'Top-of-Page'.ULINEULINE.

TOP-OF-PAGE DURING LINE-SELECTION.CASE sy-pfkey.

WHEN 'TEST'WHEN TEST .WRITE 'Self-defined GUI for Function Codes'.ULINE.

ENDCASE.

AT LINE-SELECTION.SET PF-STATUS 'TEST' EXCLUDING 'PICK'.PERFORM out.sy lsind = sy lsind 1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

sy-lsind = sy-lsind - 1.

Page 529: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

When clicked on the Basic list AT LINE-SELECTION event i t i d d d li t i di l d hi h h fis triggred and secondary list is displayed which has pf-status.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 530: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

At USER-COMMAND when any of the button in application tool bar are pressed it pp pwill take to relavent lists.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 531: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

I t t S t Fi ld f S d Li tImportant System Fields for Secondary Lists

SY LSIND Index of the list created during the current event (basic listSY-LSIND Index of the list created during the current event (basic list = 0)

SY-LISTI Index of the list level from which the event was triggeredSY LISTI Index of the list level from which the event was triggered

SY-LILLI Absolute number of the line from which the event was triggeredgg

SY-LISEL Contents of the line from which the event was triggered

SY-UCOMM Function code that triggered the event

SY-PFKEY Status of the displayed list

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 532: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

M i Li tMessages in Lists:

They are grouped by language, a two-character ID, and a three-digit number From your program you can send a message with differentnumber. From your program, you can send a message with different qualifications:

A Abend; the current transaction is stoppedE Error; the system waits for new input dataI Information; after pressing ENTER, the system continues

processingprocessingS Confirmation; the message appears on the next screenW Warning; you can change the input data or continue by

pressing ENTERpressing ENTER

You must specify the MESSAGE-ID behind the REPORT statement of your program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

program.

Page 533: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT d li t i t ti 4 NO STANDARD PAGE HEADINGREPORT demo_list_interactive_4 NO STANDARD PAGE HEADING.

START-OF-SELECTION.

WRITE 'Basic List'.MESSAGE s888(sabapdocu) WITH text-001.

AT LINE-SELECTION.IF sy-lsind = 1.MESSAGE i888(sabapdocu) WITH text-002.( p )ENDIF.IF sy-lsind = 2.MESSAGE e888(sabapdocu) WITH text-003 sy-lsind text-004.ENDIF.WRITE: 'Secondary List, SY-LSIND:', sy-lsind.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 534: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Popup window showing the message in the lists

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 535: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Defining Titles for Interactive Listse g t es o te act e sts

By default, the system uses the program title as the title of the output screen of a report. To choose another title for the output screens, use this statement:

Syntax

SET TITLEBAR <tit> [WITH <g1> ... <g9>].

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 536: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Displaying Lists in Dialog Windowssp ay g sts a og do s

To display a secondary list in a dialog window use the WINDOW statement:

Syntax

WINDOW STARTING AT l ft [ENDING AT i ht l ]WINDOW STARTING AT <left> <upper> [ENDING AT <right> <lower>].

The WINDOW statement takes effect only within the processing block of an interactive event that is only for secondary listsof an interactive event, that is, only for secondary lists.

Note:Dialog windows have no menu bar and no standard toolbarDialog windows have no menu bar and no standard toolbar

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 537: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSREPORT demo_list_window NO STANDARD PAGE HEADING.

START-OF-SELECTION.SET PF-STATUS 'BASIC'.WRITE 'Select line for a demonstration of windows'.

AT USER-COMMAND.CASE sy-ucomm.

WHEN 'SELE'.IF l i d 1IF sy-lsind = 1.

SET PF-STATUS 'DIALOG'.SET TITLEBAR 'WI1'.WINDOW STARTING AT 5 3 ENDING AT 40 10.WRITE 'Select line for a second indo 'WRITE 'Select line for a second window'.

ELSEIF sy-lsind = 2.SET PF-STATUS 'DIALOG' EXCLUDING 'SELE'.SET TITLEBAR 'WI2'.WINDOW STARTING AT 45 10 ENDING AT 60 12WINDOW STARTING AT 45 10 ENDING AT 60 12.WRITE 'Last window'.

ENDIF.ENDCASE.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 538: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 539: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Triggering Events from within the Program

Instead of letting the user trigger an interactive event by an action on the t t lf t i t f ithi thoutput screen, you can yourself trigger events from within the program.

Syntax

SET USER-COMMAND <fc>.

This statement takes effect after the current list is completed. Before theThis statement takes effect after the current list is completed. Before the system displays the list, it triggers the event that corresponds to the function code stored in <fc>,independent of the applied user interface.

Note:

Function code PICK triggers an event only if the cursor is located on a list

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

line .

Page 540: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Passing data from list to reportass g data o st to epo t

To effectively use interactive lists for interactive reporting, it is not sufficient for the program to react to events triggered by user actions on the output list. You must also be able to interpret the lines selected by the user and their contents.

F ll i ti il blFollowing options are available:

Passing data automatically using system fieldsUsing statements in the program to fetch data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 541: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Using SY-LISELUs g S S

The SY-LISEL system field is a field of type C with a length of 255 characters.characters.

It contains the selected line as one single character string, thus ki it diffi lt f t t i th l f i di id l fi ldmaking it difficult for you to retrieve the values of individual fields.

To process certain parts of SY-LISEL, you must specify the corresponding offsets

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 542: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT demo list sy lisel NO STANDARD PAGE HEADINGREPORT demo_list_sy_lisel NO STANDARD PAGE HEADING.

DATA num TYPE i.

SKIP.WRITE 'List of Quadratic Numbers between One and Hundred'.SKIP.WRITE 'List of Cubic Numbers between One and Hundred'.

TOP-OF-PAGE.

WRITE 'Choose a line!'.ULINE.

TOP-OF-PAGE DURING LINE-SELECTION.

WRITE sy-lisel

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

WRITE sy-lisel.ULINE.

Page 543: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

AT LINE-SELECTIONAT LINE-SELECTION.

IF sy-lisel(4) = 'List'.CASE sy-lilli.CASE sy lilli.WHEN 4.DO 100 TIMES.num = sy-index ** 2.WRITE: / sy-index, num.

ENDDO.WHEN 6.DO 100 TIMES.num = sy-index ** 3.WRITE: / sy-index, num.

ENDDOENDDO.ENDCASE.

ENDIF.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 544: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 545: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 546: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Passing Data by Program Statements

HIDE

The moment you create a list level you can define which information to pass to the subsequent secondary lists.

READ LINE

Use the statements READ LINE and READ CURRENT LINE to explicitlyUse the statements READ LINE and READ CURRENT LINE to explicitly read data from the lines of existing list levels.

GET CURSOR

Use the statements GET CURSOR FIELD and GET CURSOR LINE to pass the output field or output line on which the cursor was positioned during

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

the interactive event to the processing block.

Page 547: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

The HIDE Techniquee ec que

You use the HIDE technique while creating a list level to store line-specific information for later use.

SyntaxHIDE <f>.

This statement stores the contents of variable <f> in relation to the current output line (system field SY-LINNO) internally in the so-called HIDE area The variable <f> need not necessarily appear on the currentHIDE area. The variable <f> need not necessarily appear on the current line.

As soon as the user selects a line for which you stored HIDE fields theAs soon as the user selects a line for which you stored HIDE fields, the system fills the variables in the program with the values stored.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 548: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT Z_HIDE1 .TABLES : SPFLI, SFLIGHT.SELECT-OPTIONS : CARR FOR SPFLI-CARRID.SELECT OPTIONS : CARR FOR SPFLI CARRID.SELECT * FROM SPFLI WHERE CARRID IN CARR.WRITE :/ SPFLI-CARRID , SPFLI-CONNID.HIDE SPFLI-CARRID.ENDSELECT.AT LINE-SELECTION.CASE SY-LSIND.WHEN '1'.SELECT * FROM SFLIGHT WHERE CARRID = SPFLI-CARRID.WRITE :/ SFLIGHT-FLDATE, SFLIGHT-SEATSOCC.ENDSELECTENDSELECT.ENDCASE.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 549: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 550: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Value is stored

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 551: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 552: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Reading Lines from Lists

To read a line from a list after an interactive list event occurred, use the ,READ LINE statement:

Syntax

READ LINE <lin> [INDEX <idx>][FIELD VALUE <f1> [INTO <g1>] ... <fn> [INTO <gn>]].

The statement without any options stores the contents of line <lin> from the list on which the event was triggered (index SY LILLI) in the SY LISELthe list on which the event was triggered (index SY-LILLI) in the SY-LISEL system field and fills all HIDE information stored for this line back into the corresponding fields .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 553: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Reading Lists at the Cursor Positionead g sts at t e Cu so os t o

To retrieve information on the cursor position during an interactive event, use the GET CURSOR statement to refer to either the field or the line.

Syntax

GET CURSOR FIELD f [VALUE l ]GET CURSOR FIELD <f> [VALUE <val>] .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 554: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT demo_list_get_cursor NO STANDARD PAGE HEADING LINE-SIZE 40.

DATA: hotspot(10) TYPE c VALUE 'Click me!',

f(10) TYPE c, off TYPE i, lin TYPE i, val(40) TYPE c, len TYPE i.

FIELD-SYMBOLS <fs> TYPE ANY.

ASSIGN hotspot TO <fs>.

WRITE 'Demonstration of GET CURSOR statement'.

SKIP TO LINE 4.

POSITION 20.

WRITE <fs> HOTSPOT COLOR 5 INVERSE ON.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 555: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

AT LINE-SELECTION.

WINDOW STARTING AT 5 6 ENDING AT 45 20.GET CURSOR FIELD f OFFSET off

LINE lin VALUE val LENGTH len.WRITE: 'Result of GET CURSOR FIELD: '.ULINE AT /(28).WRITE: / 'Field: ', f,

/ 'Offset:', off,/ 'Line: ', lin,/ 'Value: ', (10) val,/ 'Length:', len.

SKIP.GET CURSOR LINE lin OFFSET off VALUE val LENGTH len.WRITE: 'Result of GET CURSOR LINE: '.

/( )ULINE AT /(27).WRITE: / 'Offset:', off,

/ 'Value: ', val,/ 'Length:', len.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 556: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 557: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

C lli R tCalling Reports

To call a report from with in other report,use the SUBMIT statement.

To set the name of the called program statically in the programcodingTo set the name of the called program statically in the programcoding.

Syntax :Syntax :

SUBMIT <rep> [AND RETURN] [<options>].

The first statement starts the report<rep>,the second statement starts the p preport whose name is stored in field<rep>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 558: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

I thi lli t t1 t lid h thIn this program we r calling a program zsapmztst1 next slide shows thezsapmztst1.

REPORT ZSAPMZTSTREPORT ZSAPMZTST .

DATA : ITAB TYPE I OCCURS 10,NUM TYPE I.NUM TYPE I.

SUBMIT ZSAPMZTST1 AND RETURN.IMPORT ITAB FROM MEMORY ID 'HK'.LOOP AT ITAB INTO NUM.WRITE / NUM.ENDLOOP.WRITE 'REPORT 1'.ULINE.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 559: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

REPORT ZSAPMZTST1REPORT ZSAPMZTST1 .DATA : NUMBER TYPE I,ITAB TYPE I OCCURS 10.SET PF STATUS 'MYBACK'SET PF-STATUS MYBACK .DO 5 TIMES.NUMBER = SY-INDEX.APPEND NUMBER TO ITAB.APPEND NUMBER TO ITAB.WRITE : 'NUMBER'.ENDDO.TOP-OF-PAGE.WRITE 'REPORT 2'.ULINE.AT USER-COMMAND.CASE SY-UCOMM.WHEN 'MYBACK'.EXPORT ITAB TO MEMORY ID 'HK'.LEAVE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

LEAVE.ENDCASE.

Page 560: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 561: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Called Report

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 562: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Exercise 1Exercise 1

Create an interactive list using hide technique based on tables ekko and ekpo. Output the following field in the basic list.

EKKO-EBELN.

Based on the output of the basic list I.e., EKKO-EBELN, output the following fields in the secondary list by passing the field EKKO MATNRfollowing fields in the secondary list by passing the field EKKO-MATNR by HIDE Technique.

EKPO-BUKRS

EKPO-WERKS

EKPO-LGORT

EKPO-MENGE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 563: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSSolutionTABLES: EKKO, EKPO.

DATA: BEGIN OF ITAB1 OCCURS 0,EBELN LIKE EKKO EBELNEBELN LIKE EKKO-EBELN,END OF ITAB1.DATA : BEGIN OF ITAB2 OCCURS 0,MATNR LIKE EKPO MATNRMATNR LIKE EKPO-MATNR,BUKRS LIKE EKPO-BUKRS,WERKS LIKE EKPO-WERKS,LGORT LIKE EKPO-LGORT,LGORT LIKE EKPO LGORT,MENGE LIKE EKPO-MENGE,END OF ITAB2.SELECT EBELN FROM EKKO INTO ITAB1-EBELN.WRITE :/ ITAB1-EBELN HOTSPOT.HIDE ITAB1-EBELN.

ENDSELECT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 564: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSTOP-OF-PAGE DURING LINE-SELECTION.WRITE:/ 'MATERIAL' ,12 'COMPANY',18 'PLANT',28

'STORAGE',38'QUANTITY'.

AT LINE SELECTIONAT LINE-SELECTION.* Interactive event, details list* Read data corresponding to the selection criteria and* display* displaySELECT MATNR BUKRS WERKS LGORT MENGE FROM EKPO INTO

CORRESPONDINGFIELDS OF ITAB2 WHERE EBELN = ITAB1-EBELN.FIELDS OF ITAB2 WHERE EBELN ITAB1 EBELN.

WRITE: / ITAB2-MATNR, * Material Number12 ITAB2-BUKRS, * Company code18 ITAB2-WERKS, * Plant,28 ITAB2-LGORT, * Storage Location38 ITAB2-MENGE. *Quantity

ENDSELECT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 565: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Exercise NO: 2Exercise NO: 2

Task:

Create a list of all flight connections for each airline carrierCreate a list of all flight connections for each airline carrier.

Output the following fields:

SPFLI-CARRID SPFLI-CONNID SPFLI-CITYFROMSPFLI CARRID, SPFLI CONNID, SPFLI CITYFROM,

SPFLI-CITYTO, SPFLI-DEPTIME, SPFLI-ARRTIME.

Define a selection screen on which the user can enter selections for the airline carrier (SPFLI-CARRID) and the connection ID (SPFLI-CONNID). Read the data from table SPFLI in accordance with this selection.When the user selects a line the system should display a secondaryWhen the user selects a line, the system should display a secondary showing the flights (table SFLIGHT) available for the flight connection concerned (see example list). Output the selected line as the header of the secondary list. Calculate and output the number of vacant seats for

h fli ht M k th t th h dl i lid li

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

each flight. Make sure that the program can handle invalid line selection.

Page 566: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

Example listExample list

AA 0017 NEW YORK SAN FRANCISCO 13:30:00 16:31:00

Date Price SeatsDate Price Seats

max. occupied free

10.29.1995 666.67 USD 660 10 650

11.11.1995 666.67 USD 660 20 640

11.16.1995 666.67 USD 660 38 622

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 567: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SolutionREPORT ZABCD00111 .TABLES: SPFLI, SFLIGHT.* Report defined selection criteria for airline and for* connection idSELECT-OPTIONS: SELCARR FOR SPFLI-CARRID,

SELCONN FOR SPFLI-CONNID.* A ili fi ld b f f t* Auxiliary field: number of free seatsDATA: SFREE LIKE SFLIGHT-SEATSMAX.

START OF SELECTIONSTART-OF-SELECTION.* Read data corresponding to the selection criteria and* displaySELECT * FROM SPFLISELECT FROM SPFLI

WHERE CARRID IN SELCARR AND CONNID IN SELCONN.WRITE: / SPFLI-CARRID,

SPFLI-CONNID,

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

,SPFLI-CITYFROM,SPFLI-CITYTO,

Page 568: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SPFLI-DEPTIMESPFLI-DEPTIME,SPFLI-ARRTIME.

HIDE: SPFLI-CARRID, SPFLI-CONNID.ENDSELECT.ENDSELECT.END-OF-SELECTION.

CLEAR SPFLI-CARRID. "initialization

AT LINE-SELECTION.* Interactive event, details list

CHECK NOT SPFLI-CARRID IS INITIAL.* Display detail list only if valid line-selectionWRITE SY-LISEL.WRITE: /5 TEXT-001, 29 TEXT-002, 49 TEXT-003,

/ TEXT 004 UNDER TEXT 003 60 TEXT 005 70 TEXT 006/ TEXT-004 UNDER TEXT-003, 60 TEXT-005, 70 TEXT-006.* D: TEXT-001: Date* D: TEXT-002: Price* D: TEXT-003: Seats

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

D: TEXT-003: Seats* D: TEXT-004: Max* D: TEXT-005: occupied TEXT-006: free

Page 569: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

ULINEULINE.SELECT * FROM SFLIGHT WHERE CARRID EQ SPFLI-CARRID

AND CONNID EQ SPFLI-CONNID.* Read data for details list using the hided key fields, Read data for details list using the hided key fields,* list outputWRITE: /5 SFLIGHT-FLDATE,

SFLIGHT-PRICE,SFLIGHT-CURRENCY.SFREE = SFLIGHT-SEATSMAX - SFLIGHT-SEATSOCC.WRITE: SFLIGHT-SEATSMAX,

SFLIGHT-SEATSOCC,SFREE.

ENDSELECT.CLEAR SPFLI CARRID "initializationCLEAR SPFLI-CARRID. "initialization

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 570: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTS

SummarySummary

Extract datasets :

An extract is a sequential dataset you can create with a report.UseAn extract is a sequential dataset you can create with a report.Use extracts if you want to process large amount of data as a whole several times

Declaring Extract Records as Field GroupsDeclaring Extract Records as Field GroupsFilling an Extract with DataReading an Extract

Sorting an Extract

ListsLists are the output medium for data from ABAP/4 report programs. Each program can produce up to 21 lists: one basic list and 20

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

p g p psecondary lists.

Page 571: Sap Abap Refresher Course NoRestriction

INTERACTIVE LISTSStructure and the options of a list are

The Standard ListThe Self-Defined ListLists with Several Pages

Interactive List

A list is an interactive list if the user interface allows actions that triggerA list is an interactive list if the user interface allows actions that trigger events and if the corresponding interactive event keywords occur in the report.

Events for Interactive ListsAT LINE-SELECTIONAT PF<nn>AT USER-COMMAND

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 572: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Extract datasets

Data output in lists( Standard, Self-defined, Lists with several pages )p g )

Interactive lists( At line-selection , At User-command)

List creation with the ALV grid control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 573: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

INTRODUCTION

• The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).called ABAP List Viewer (ALV).

• Using ALV, we can have three types of reports:1 Si l R t1. Simple Report2. Block Report3. Hierarchical Sequential Report

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 574: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

There are some function modules which will enable to produce the above reports without much effort.

All the definitions of internal tables, structuresand constants are declared in a type-pool called SLIS.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 575: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT

1. Simple Report

The important function modules are:

Reuse_alv_list_displayReuse_alv_fieldcatalog_mergeR l t tReuse_alv_events_getReuse_alv_commentary_writeReuse_alv_grid_display

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 576: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD….

A. REUSE_ALV_LIST_DISPLAY: This is the function module which prints the data.

The important parameters are:

1. Export:

a. I_callback_program : report idb. I_callback_pf_status_set : routine where a user can set his own pf status

or change the functionality of the existing pf g y g pstatus.

c. I_callback_user_command : routine where the function codes arehandled.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 577: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

d. I_structure name : name of the dictionary tablee. Is_Layout : structure to set the layout of the reportf. It_fieldcat : internal table with the list of all fields and their

attributes which are to be printed (this table canattributes which are to be printed (this table canbe populated automatically by the functionmodule REUSE_ALV_FIELDCATALOG_MERGE)

g. It_events : internal table with a list of all possible events of ALVand their corresponding routine names.

2. Tables:a. t_outtab : internal table with the data to be output

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 578: Sap Abap Refresher Course NoRestriction

SIMPLE REPORT CONTD...

6. LIST PROCESSING TECHNIQUES

B. REUSE_ALV_FIELDCATALOG_MERGE:

This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I structure name) in the REUSE ALV LIST DISPLAY Butparameter(I_structure_name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 579: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

The important parameters are:

1. Export:1. Export:a. I_program_name : report idb. I_internal_tabname : the internal output tablec. I_inclname : include or the report name where all the dynamic

f h dl dforms are handled.

2. Changingct fieldcat : an internal table with the type SLIS T FIELDCAT ALV_ yp _ _ _

which is declared in the type pool SLIS.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 580: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

C . REUSE_ALV_EVENTS_GET: Returns table of possible events for a a list type

1 Import:1. Import:

Et_Events : The event table is returned with all possibleCALLBACK events for the specified list type(column ‘NAME’). For events to be processed bythe Callback, their ‘FORM’ field must be filled. Ifthe field is initialized, the event is ignored. Theentry can be read from the event table the fieldentry can be read from the event table, the field‘FORM’ filled and the entry modified usingconstants from the type pool SLIS.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 581: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

2. Export:

I list type:I_list_type: 0 = simple list1 = hierarchical-sequential list 2 = simple block list3 hi hi l ti l bl k li t3 = hierarchical-sequential block list

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 582: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.

1. It_list_commentary : Internal table with the headings of the type slis t listheader.type slis_t_listheader.

This internal table has three fields:

T ‘H’ h d ‘S’ l ti ‘A’ tiTyp : ‘H’ - header, ‘S’ - selection, ‘A’ - action

Key : only when typ is ‘S’.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Info : the text to be printed

Page 583: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SIMPLE REPORT CONTD...

E. REUSE_ALV_GRID_DISPLAY: A new function in 4.6 version, to display the results in grid rather than as a list.

Parameters : same as reuse_alv_list_display

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 584: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

The example of a simple list is as follows:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 585: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

HIERARCHICAL REPORTS

Hierarchical sequential list output.

The f nction mod le isThe function module is

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

1. Export:a. I_CALLBACK_PROGRAMb. I_CALLBACK_PF_STATUS_SETc I CALLBACK USER COMMANDc. I_CALLBACK_USER_COMMANDd. IS_LAYOUT

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 586: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Hierarchical Reports Contd.….

e. IT_FIELDCAT

f. IT_EVENTS

g. I_TABNAME_HEADER : Name of the internal table in the program containing the output data of the highest hierarchy level.containing the output data of the highest hierarchy level.

h. I_TABNAME_ITEM : Name of the internal table in the program containing the output data of the lowest hierarchy level.

i. IS_KEYINFO : This structure contains the header and item table field names which link the two tables (shared key).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 587: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Hierarchical reports Contd.….p

2. Tables

a. T_OUTTAB_HEADER : Header table with data to be output

b. T_OUTTAB_ITEM : Name of the internal table in the program containing the output data of the lowest hierarchy level.p y

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 588: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 589: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

BLOCK REPORT

This is used to display multiple lists continuouslyThis is used to display multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B REUSE ALV BLOCK LIST APPENDB. REUSE_ALV_BLOCK_LIST_APPEND

D. REUSE_ALV_BLOCK_HS_LIST_APPEND

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

C. REUSE_ALV_BLOCK_LIST_DISPLAY

Page 590: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

BLOCK REPORT CONTD..

A. REUSE_ALV_BLOCK_LIST_INITParameters:

I CALLBACK PROGRAMa. I_CALLBACK_PROGRAMb. I_CALLBACK_PF_STATUS_SETc. I_CALLBACK_USER_COMMAND_ _ _

This function module is used to set the default GUI status etcetc.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 591: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

BLOCK REPORT CONTD..

B. REUSE_ALV_BLOCK_LIST_APPEND

Export :Export :a. IS_LAYOUT : layout settings for blockb. IT_FIELDCAT : field catalogc. I_TABNAME : Internal table name of the output datad. IT_EVENTS : internal table name with all

possible eventsTables :

a T OUTTAB : internal table with output dataa. T_OUTTAB : internal table with output data.

This function module adds the data to the block.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 592: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

REUSE ALV LIST HS APPEND : -REUSE_ALV_LIST_HS_APPEND : -

I d t d th Hi hi l S ti l bl kIs used to append the Hierarchical Sequential blocks.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 593: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

BLOCK REPORT CONTD..

C. REUSE_ALV_BLOCK_LIST_DISPLAY

Parameters : All the parameters are optional.

This function module display the list with data appended by the above functionfunction.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 594: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

Here the functions REUSE ALV FIELDCATALOG MERGE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.

Page 595: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

INTERNAL TABLES IN SLIS

Slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using ‘REUSE ALV FIELDCATALOG MERGE’.REUSE_ALV_FIELDCATALOG_MERGE .

Important Attributes:a. col_pos : position of the columnb fi ld i t l fi ldb. fieldname : internal fieldnamec. tabname : internal table named. ref_fieldname : fieldname (dictionary)e. ref tabname : table (dictionary)_ ( y)f. key(1) : column with key-colorg. icon(1) : iconh. hotspot(1) : hotspot

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 596: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

i S b l(1) b li. Symbol(1) : symbolj. Checkbox(1) : checkboxk. just(1) : (R)ight (L)eft (C)entl. do sum(1) : sum up_ ( ) pm. no_out(1) : (O)blig. (X)no outn. outputlen : output lengtho. seltext-l : long key wordp seltext m : middle key wordp. seltext_m : middle key wordq. seltext_s : short key wordr. reptext_ddic : heading(ddic)s. ddictxt(1) : (S)hort (M)iddle (L)ongt. datatype : datatype

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 597: Sap Abap Refresher Course NoRestriction

6. LIST PROCESSING TECHNIQUES

2. SLIS_T_EVENT : Internal table for storing all the possible events of the ALV. This can be populated by the function module Reuse alv events getby the function module Reuse_alv_events_get

The columns are :

•name : name of the event•form : name of the routine

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 598: Sap Abap Refresher Course NoRestriction

SYNTAXES FOR THE ROUTINES

6. LIST PROCESSING TECHNIQUES

• I_CALLBACK_PF_STATUS_SET Syntax : FORM set_pf_status USING rt_extab TYPE slis_t_extab

The table RT_EXTAB contains the function codes which are hidden in the standard interfacethe standard interface.

• I_CALLBACK_USER_COMMAND

Syntax : FORM user_command USING r_ucomm LIKE sy-ucomm

rs_selfield TYPE slis_selfield.

The parameter r_ucomm contains the function code.

The structure rs_selfield has the details about the current cursor position.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 599: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 600: Sap Abap Refresher Course NoRestriction

• A Transaction is a program that conducts a dialog with the User

7. DIALOG PROGRAMMING

• A Transaction is a program that conducts a dialog with the User

• In a typical dialog, the system displays the screen on which the user can enter or request information.

• As per the user input or request, transaction is used to

– Branch to the next Screen

– Display an output

– Change/Update the database

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 601: Sap Abap Refresher Course NoRestriction

Central Components of an Online Program

ABAP/4 Development WorkbenchABAP/4 Development Workbench

ABAP/4Dictionary

ScreenPainter

MenuPainter

ABAP/4Editor

Runtime environment

Online processor ABAP/4 Processor

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 602: Sap Abap Refresher Course NoRestriction

Transactions

• Structure of the Dialog Programming• SCREEN Painter• MENU Painter

I t Ch k• Input Checks • Error Handling• Flow LogicFlow Logic• Screen Modification• Table Control and Step Loop• Branching to List Processing

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 603: Sap Abap Refresher Course NoRestriction

Structure of the Dialog Programming

Program Name– Dictionary StructureDictionary Structure– Global data– PBO modules– PAI modules– Subroutines– Screens– GUI Status– Transaction code

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 604: Sap Abap Refresher Course NoRestriction

Transactions- Structure

Att ib tScreenPainter

Define screens AttributesFullscreenABAP/4 Dict. fieldsField listFl l i

Painter

Programd l l

Flow logic

Global dataABAP/4

Online programmodule pool Global data

PBO modulesPAI modulesSubroutines

Define call Transaction code

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 605: Sap Abap Refresher Course NoRestriction

Summary

Creating module pool andmaintaining attributes

Creating screen 100:S 100

Program

Creating screen 100:- define attributes- define screen templates

and field texts- maintain field list

Screen 100

- define flow logicsee screen 100

Defining ABAP/4 fieldsGl b l d t

Screen 200

Defining ABAP/4 fields(same name asscreen fields!)

Defining processing(before screen is displa ed)PBO Module

Global data

(before screen is displayed)

Defining processing afterthe user has pressed ENTERPAI Module

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Defining the code you use to call the online programTransaction code

Page 606: Sap Abap Refresher Course NoRestriction

Each Screen contains fields used to display or request Information The

Screen Painter

Each Screen contains fields used to display or request Information. The fields can be text Sting, Input/Output fields, Radio Buttons, Check boxes or Pushbuttons .

E h i t fEach screen consists of

• Screen Attributes

• Screen Elements• Screen Elements

• Screen Fields

• Screen Flow LogicScreen Flow Logic

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 607: Sap Abap Refresher Course NoRestriction

P (t M)

Screen Attributes

•Program (type M)•Screen Number : A four-digit number, unique within the ABAP program, that identifies the screen within the program.•Screen Type : A normal screen occupies a whole GUI window. Modal dialog boxes only cover a part of a GUI window. A subscreen is a screen that you can display in a subscreen area on a different screen in the same y p yABAP program. •Next Screen : Specifies the next screen.H ld D t If th ll th th d i t i l•Hold Data : If the user calls the screen more than once during a terminal

session, he or she can retain changed data as default values.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 608: Sap Abap Refresher Course NoRestriction

Screen Elements

Text Fields: Display elements, which cannot be changed either by the user or by the ABAP program.

I t/O t t Fi ld U d t di l d t f th ABAP fInput/Output Fields: Used to display data from the ABAP program or for entering data on the screen. Linked to screen fields

Radio Buttons: Special input/output fields that are combined into groups. Within a radio button group, only a single button can be selected at any one time.

Check boxes: Special input/output fields which the user can select (valueCheck boxes: Special input/output fields which the user can select (value ‘X’) or deselect (value SPACE).

Pushbuttons: Elements on the screen that trigger the PAI event of the screen flow logic when chosen by the user There is a function codescreen flow logic when chosen by the user. There is a function code attached to each pushbutton, which is passed to the ABAP program when it is chosen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 609: Sap Abap Refresher Course NoRestriction

Screen Elements

Subscreen: Area on the screen in which you can place another screen.

Table Controls: Tabular input/output fields.

T b St i C t l A th i hi h it h b tTab Strip Controls: Areas on the screen in which you can switch between various pages.

Status Icons: Display elements, indicating the status of the application program.

Ok_Code Field: Every screen has a twenty-character OK_CODE field (also known as the function code field), which is not displayed on the screen.known as the function code field), which is not displayed on the screen. User actions that trigger the PAI event also place the corresponding function code into this field, from where it is passed to the ABAP program. You can also use the command field in the standard toolbar to p genter the function code. You must assign a name to the OK_CODE field to be able to use it for a particular screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 610: Sap Abap Refresher Course NoRestriction

Screen fields are fields in the working memory of a screen. Their contents

Screen Fields

are passed to identically-named fields in the ABAP program in the PAI event, and filled from the same identically-named fields in the program in the PBO event. The screen fields are linked with the input/output fields.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 611: Sap Abap Refresher Course NoRestriction

C t

Screen Fields(Attributes)

Cont..

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 612: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 613: Sap Abap Refresher Course NoRestriction

Screen flow logic contains the procedural part of a screen. The language

Screen Flow Logic

used to program screen flow logic has a similar syntax to ABAP, but is not part of ABAP itself.It is otherwise referred to as Screen Language.It contains no explicit data declarations.It serves as a container for

i bl kprocessing blocks.There are four event blocks, each of which is introduced with the screen keyword PROCESS:y

PROCESS BEFORE OUTPUT....PROCESS AFTER INPUTPROCESS AFTER INPUT....PROCESS ON HELP-REQUEST....PROCESS ON VALUE-REQUEST.

The screen flow logic must contain at least the two statements PROCESS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

gBEFORE OUTPUT and PROCESS AFTER INPUT in the correct order.

Page 614: Sap Abap Refresher Course NoRestriction

Cont..

Screen Flow Logic

Co tPROCESS BEFORE OUTPUT (PBO) is automatically triggered after the PAI processing of the previous screen and before the current screen is displayed You can program the PBO processing of the screen in thisdisplayed. You can program the PBO processing of the screen in this block. At the end of the PBO processing, the screen is displayed. PROCESS AFTER INPUT (PAI) is triggered when the user chooses a function on the screen You can program the PAI processing of the screenfunction on the screen. You can program the PAI processing of the screen in this block. At the end of the PAI processing, the system either calls the next screen or carries on processing at the point from which the screen was calledwas called.

PROCESS ON HELP-REQUEST (POH) and PROCESS ON VALUE-REQUEST (POV) are triggered when the user requests field help (F1) or possible values help (F4) respectively. You can program the appropriate coding in the corresponding event blocks. At the end of processing, the system carries on processing the current screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 615: Sap Abap Refresher Course NoRestriction

Keyword Function

Screen Flow Logic

Keyword FunctionMODULE Calls a dialog module in an ABAP programFIELD Specifies the point at which the contents of a

screen field should be transportedON Used in conjunction with FIELD VALUES Used in conj nction ith FIELDVALUES Used in conjunction with FIELDCHAIN Starts a processing chainENDCHAIN Ends a processing chainENDCHAIN Ends a processing chainCALL Calls a subscreenLOOP Starts processing a screen tableENDLOOP Stops processing a screen table

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 616: Sap Abap Refresher Course NoRestriction

Screen Painter

Screenattributes

Screenlayout

Fieldattributes Flow logicattributes

Screen numberShort descriptionScreen typeFollow up screen

layout attributesField NameData TypeLengthI t/O t t

PROCESS BEFORE OUTPUT.MODULE CLEAR.

PROCESS AFTER INPUT

Flow logicTextFieldsInput/Output

templatesFollow-up screen...

Input/Output....

PROCESS AFTER INPUT.MODULE READ.

templates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 617: Sap Abap Refresher Course NoRestriction

S P i t T ABAP/4 Edit

Screen Painter

Screenattributes

Screenlayout

Fieldattributes Flow logic

Screen Painter To ABAP/4 EditorSCREENPAINTER

attributesScreen numberShort descriptionScreen typeFollow up screen

layout attributesField NameData TypeLengthI t/O t t

PROCESS BEFORE OUTPUT.MODULE CLEAR.

PROCESS AFTER INPUT

Flow logicTextFieldsInput/Output

templates

ABAP/4

Follow-up screen...

Input/Output....

PROCESS AFTER INPUT.MODULE READ.

templates

ABAP/4Editor

MODULE CLEAR OUTPUT MODULE READ INPUTDATA: NUMBER(10)Global data PBO module PAI module

MODULE CLEAR OUTPUT.CLEAR NUMBER.

ENDMODULE....

MODULE READ INPUT.SELECT ...

.

.

.ENDMODULE.

DATA: NUMBER(10)TYPE C.

.

.

.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

.

.

.

Page 618: Sap Abap Refresher Course NoRestriction

To call a module, use the flow logic statement

Screen Painter

MODULE <mod>.The system starts the module <mod>, which must have been defined for the same event block in which the call occursthe same event block in which the call occurs. If you only use simple modules in the screen flow logic, the data transport between the ABAP program and the screen is as follows: • In the PAI event, all of the data from the screen is transported to the ABAP program (as long as there are program fields with the same names as the screen fields) after the automatic input checks and before the first PAI module is called. This includes the contents of the system fields (for example, SY-UCOMM, which contains the current function code). • At the end of the last PBO module, and before the screen is displayed, , p y ,all of the data is transported from the ABAP program to any identically-named fields in the screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 619: Sap Abap Refresher Course NoRestriction

Screen Painter

Data Transfer within the Screen and Module Pool work Area .

Screen work area

SAREA-AREA

Module pool work areaTABLES: SAREA.FI Financial accounting

ScreenPainter ABAP/4

PBO

PAISAREA-AREATEXT

OK-CODE

FI

Financial accounting

AREA AREATEXT

DATA: OK-CODE(4).OK CODE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 620: Sap Abap Refresher Course NoRestriction

Sequence of operation

ScreenPainter

Sequence of operations

Execute module APROCESS BEFORE OUTPUT.MODULE A

Data transport fromthe ABAP/4 work area

Execute module BMODULE A.MODULE B.

PROCESS AFTER INPUT.

Send screen

the ABAP/4 work areato the screen work areaMODULE C.

MODULE D.

ENTER

Data transport from thek t thscreen work area to the

ABAP/4 work area

Execute module C

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Execute module D

Page 621: Sap Abap Refresher Course NoRestriction

Overview

SET SCREEN

CALL SCREEN

. . .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 622: Sap Abap Refresher Course NoRestriction

Set Screen / Leave Screen

ScreenPainter

ScreenPainterScreen attributes Screen attributes

Screen number 100...Follow-up screen 200

Screen number 201...Follow-up screen 301

ScreenPainter

ScreenPainter

PROCESS AFTER INPUT.MODULE OK_CODE.

PROCESS BEFORE OUTPUT....

ABAP/4

PROCESS AFTER INPUT..

MODULE OK_CODE INPUT...

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

.

.

..SET SCREEN 201.LEAVE SCREEN.

Page 623: Sap Abap Refresher Course NoRestriction

Inserting a Screen as a Screen Sequence

ScreenPainter

ScreenPainterScreen attributes Screen attributes

Screen number 100...Follow-up screen 200

Screen number 201...Modal pop-up window...

ScreenPainter

Follow-up screen 301

PROCESS BEFORE OUTPUT.

ScreenPainter

PROCESS AFTER INPUT.MODULE OK_CODE.

.

.

.PROCESS AFTER INPUT.MODULE OK_CODE.

ABAP/4MODULE OK_CODE INPUT....CALL SCREEN 201

ABAP/4MODULE OK_CODE INPUT....SET SCREEN 0

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

CALL SCREEN 201STARTING AT 30 10ENDING AT 60 20.

SET SCREEN 0.LEAVE SCREEN....

Page 624: Sap Abap Refresher Course NoRestriction

S t

Leaving Screen

Syntax:• LEAVE TO SCREEN <screen number>.

(or)(or)• SET SCREEN <screen number>.

LEAVE SCREEN.

• LEAVE TO SCREEN 0. – From called screen– From main screen

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 625: Sap Abap Refresher Course NoRestriction

SET TITLEBAR ‘T01’ WITH 1 2 3 4

Menu Painter

• SET TITLEBAR ‘T01’ WITH v1 v2 v3 v4Example:Module status 100.Module status_100.SET TITLEBAR ‘T01’ with EKKO-EBELN’.Endmodule.

• SET PF-STATUS ‘xxxxxxxx’.• SET PF-STATUS ‘xxxxxxxx’ EXCLUDING <itab>.Example:Module Status 100 on inputModule Status_100 on input.SET PF-STATUS ‘PF0100’.End Module.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 626: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 627: Sap Abap Refresher Course NoRestriction

Fi ld f t Ch k Thi f t li it th ki d f i t th t i lid

Input Checks

Field format Check :This format limits the kind of input that is valid. For ex. , a DATS field (Date field) is an 8 char string in YYYYMMDD format. All char must be numbers . For the given value entered, the system checks that the day value is validsystem checks that the day value is valid.

Required Check : In the screen painter you can set a field’s required Input Attribute . The system requires the user to enter the input b f t i PAI P ibefore entering PAI Processing.

Foreign Key Check:The field can have a foreign key relationship with another table or its domain can specify a fixed value list for the p yfield.The system checks the user input value can be found in the related check table or in the fixed-value lists.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 628: Sap Abap Refresher Course NoRestriction

Field Format Check

Field list

ScreenPainter

Field name Format

DATE DATE...

AMOUNT DEC

Date Date31.11.199311.13.1996

Amount

E: Invalid date

Amount

E: Please enter numeric value

12A33A9Y

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 629: Sap Abap Refresher Course NoRestriction

Required Field

Field list

ScreenPainter

Field name OBLIGATORY

TEST FIELD XTEST FIELD X

??

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 630: Sap Abap Refresher Course NoRestriction

Foreign Key Check

Field name Check table

ABAP/4Dictionary

...FIELD1 P1.

Check table P1

KEYAScreen

..

BC...

Field listField Foreign keyFIELD1 X

ScreenPainter

FIELD1 X

Check

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Field1 C

Page 631: Sap Abap Refresher Course NoRestriction

Use the FIELD..VALUES to check the field values in Screen Flow Logic.

Changing Input Values

Screen

FIELD <screen field> VALUES [<value list>]

PainterPROCESS AFTER INPUT.FIELD <screen field>

VALUES (<copy1>, <copy2>, ...).

Copy:

<value>NOT <value>

Screen

BETWEEN <value1> AND <value2>NOT BETWEEN <value1> AND <value2>

PROCESS AFTER INPUT.FIELD SCOUR-COURSE

VALUES ('01', BETWEEN '20' AND '30', 'ABC').

Painter

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 632: Sap Abap Refresher Course NoRestriction

Input Check in Module Pool

The FIELD..MODULEstatement checks the validity for a particular screen field.

ScreenPainter ABAP/4

PROCESS AFTER INPUT.FIELD <screen field>

MODULE <module> INPUT...

MODULE <module>. .MESSAGE E ... .

ENDMODULE.

1 1

E M

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

E...Message

Page 633: Sap Abap Refresher Course NoRestriction

Example

ScreenPainterPROCESS AFTER INPUT.

FIELD SCOUR-COURSEMODULE CHECK_SCOUR.

Painter

MODULE CHECK_SCOUR INPUT.

SELECT SINGLE * FROM SCOUR

ABAP/4

SELECT SINGLE * FROM SCOURWHERE AREA = SCOUR-AREAAND COURSE = SCOUR-COURSE.

IF SY SUBRC NE 0IF SY-SUBRC NE 0.MESSAGE E123 WITH 'SCOUR'.

ENDIF.

ENDMODULE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDMODULE.

Page 634: Sap Abap Refresher Course NoRestriction

Field Group-Related Checks

ScreenPainter ABAP/4

MODULE <module> INPUT...

PROCESS AFTER INPUT.CHAIN.

.MESSAGE E ... .

ENDMODULE.

FIELD: <screen field1>,<screen field2>,

.

.

.<screen field n><screen field n>.

MODULE <module>.ENDCHAIN.

..111

1

E... Message

..11

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ready for input1

Page 635: Sap Abap Refresher Course NoRestriction

Example

PROCESS AFTER INPUT.CHAIN

ScreenPainter

CHAIN.FIELD: SCOUR-AREA, SCOUR-COURSE.

MODULE CHECK_FIELD.ENDCHAIN.

MODULE CHECK_SCOUR INPUT.

SELECT SINGLE * FROM SCOUR

ABAP/4

SELECT SINGLE * FROM SCOURWHERE AREA = SCOUR-AREAAND COURSE = SCOUR-COURSE.

IF SY SUBRC NE 0IF SY-SUBRC NE 0.MESSAGE E123 WITH 'SCOUR’,’COURSE’.

ENDIF.

ENDMODULE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

ENDMODULE.

Page 636: Sap Abap Refresher Course NoRestriction

ON INPUT

Conditional Check

• ON INPUT:If the field value is different from the initial value.

• ON REQUEST:

This module will be executed if a value has been entered inthe specific field since the screen was displayed.

AT EXIT COMMAND• AT EXIT-COMMAND:At EXIT-COMMAND module will be executed only if the user invokes a function code with ‘E’ function type.yp

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 637: Sap Abap Refresher Course NoRestriction

On Input / on Chain Input

PROCESS AFTER INPUT.FIELD <screen field>

ScreenPainter

FIELD <screen field>MODULE <module> ON INPUT.

.

.

.

PROCESS AFTER INPUT.C

ScreenPainter

CHAIN.FIELD: <screen field 1>,

<screen field 2>,....

<screen field n>.MODULE <module> ON CHAIN-INPUT.

ENDCHAIN.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

.

.

.

Page 638: Sap Abap Refresher Course NoRestriction

On Request / On Chain Request

PROCESS AFTER INPUT.FIELD <screen field>

ScreenPainter

FIELD <screen field>MODULE <module> ON REQUEST.

.

.

.

PROCESS AFTER INPUT.CHAIN

ScreenPainter

CHAIN.FIELD: <screen field 1>,

<screen field 2>,....

<screen field n>.MODULE <module> ON CHAIN-REQUEST.

ENDCHAIN.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

.

.

.

Page 639: Sap Abap Refresher Course NoRestriction

At Exit Command I

Cancel

Field ?

PROCESS AFTER INPUT.MODULE X

ScreenPainter

Cancel

MODULE X.MODULE TERMINATE

AT EXIT-COMMAND....

...

ABAP/4

MODULE TERMINATE INPUT.SET SCREEN ... .LEAVE SCREEN.

ENDMODULE.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

...

Page 640: Sap Abap Refresher Course NoRestriction

At Exit Command II

F ti li t

MenuPainterFunction list

Function TypeABBR E

Painter

Field ?

List of modification groups

Field name Fcode Type

ScreenPainter

Cancel

Field name Fcode TypeABEND ABBR E

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 641: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 642: Sap Abap Refresher Course NoRestriction

Error Handling

• Error (E) - Displays Error Message on the current screen • Warning (W) - Displays Warning Message on the current screen • Information (I) - Displays Popup Message on the current screen • Abend (A) - The current Transaction will be Terminated • Success (S) Message is displayed on the Following Screen• Success (S) - Message is displayed on the Following Screen

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 643: Sap Abap Refresher Course NoRestriction

Error Handling Overview

PROCESS AFTER INPUT.CHAIN

ScreenPainter

CHAIN. FIELD: <screen field 1>,

<screen field 2>.MODULE CHECK.

ENDCHAINENDCHAIN.

PROGRAM B220MAIN MESSAGE-ID <id>.ABAP/4

.

.

.MODULE CHECK INPUT.... IF SY-SUBRC ...

MESSAGE <qnnn>WITH <value 1>..<value 4>.

ENDIF.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

.ENDMODULE.

Page 644: Sap Abap Refresher Course NoRestriction

At runtime , you may want to change the attributes depending on what

Dynamic Screen Modification

user has requested in the previous screen.The attributes for each screen field are stored in the memory as SCREEN.You need not declare as table in your program.The system maintains it internally and updates during

h

Display Change

every screen change.

Change <-> Display

A

Change <-> Display

AB B

Output template Input/outputtemplate

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 645: Sap Abap Refresher Course NoRestriction

Dynamic Screen Modification

SC CField and its attrib. active

Required entry field

SCREEN-ACTIVE

SCREEN-REQUIRED

Input field

Output field

SCREEN-INPUT

SCREEN-OUTPUTOutput field

Highlighted

SCREEN OUTPUT

SCREEN-INTENSIFIED

Invisible

Shorter output length

SCREEN-INVISIBLE

SCREEN-LENGTH

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 646: Sap Abap Refresher Course NoRestriction

Dynamic Screen Modification- Program

PROCESS BEFORE OUTPUT...

ScreenPainter

.MODULE MODIFY_SCREEN.

...

MODULE MODIFY_SCREEN OUTPUT....

ABAP/4

LOOP AT SCREEN.IF SCREEN-GROUP1 = 'GR1'.

SCREEN-INPUT = 1.ENDIF.IF SCREEN-NAME = 'TAB-FELD'.SCREEN-ACTIVE = 0.ENDIF.MODIFY SCREEN.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

MODIFY SCREEN.ENDLOOP.

Page 647: Sap Abap Refresher Course NoRestriction

SCREEN TABLES

A screen table is a repeated series of table rows in a screen Each entryA screen table is a repeated series of table rows in a screen. Each entry contains one or more fields, and all rows have the same field structure.

• Table controls and step loops are types of screen tables you can add to a screen in the Screen Painter.

• These are the two mechanisms offered by ABAP/4 for displaying and using table data in a screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 648: Sap Abap Refresher Course NoRestriction

Table Controls

With table controls, the user can:

• Scroll through the table vertically and horizontally

• Re-size the width of a column

• Select table rows or columns

• Re-order the sequence of columns

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 649: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 650: Sap Abap Refresher Course NoRestriction

Step Loops

• The feature of step loops is that their table rows can span more than oneline on the screen. By contrast, the rows in a table control are always single lines, but can be very long.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 651: Sap Abap Refresher Course NoRestriction

Screen Table Processing

You process a screen table by looping through it as you would through the rows of an internal table. To do this, you place a LOOP...ENDLOOPdynpro statement in the screen's flow logic.

What the LOOP Statement Does?The LOOP statement is responsible for getting screen table values passed back and forth between the screen and the ABAP/4 programpassed back and forth between the screen and the ABAP/4 program. As a result, you must code a LOOP statement in both the PBO andPAI events for every table in your screen.

Note :Atleast, an empty LOOP...ENDLOOP must be there in PAI.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 652: Sap Abap Refresher Course NoRestriction

7. DIALOG PROGRAMMING

S (b i )Screen (basics)

Screen logic, Screen Painter , Menu Painter g , ,

Input checks, changing of input values

Error handling

St lStep loops

Table Control

Field help and value help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 653: Sap Abap Refresher Course NoRestriction

Syntax for table Controls

At PBO.Loop at <itab> with control <name> cursor <name>-top_line.

Module <mod_name>.Endloop.

At PAI.Loop at <itab>.

Endloop.

Declaration for table control.controls <name> type tableview using screen <no>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 654: Sap Abap Refresher Course NoRestriction

Syntax for step loops

At PBO.Loop at <itab> cursor <var>.

Module <mod_name>.Endloop.

At PAI.L t it bLoop at <itab>.

Endloop.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 655: Sap Abap Refresher Course NoRestriction

Leaving to transaction

To branch to another transaction and end the current one, use the LEAVE TO TRANSACTION statement:

Syntax

LEAVE TO TRANSACTION '<TRAN>'.

Once the new transaction starts, the user can not return to the previous transaction by pressing the Exit icon. Any data the user did not save in the previous transaction is lost.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 656: Sap Abap Refresher Course NoRestriction

Calling a transaction

If you want the user to be able to return to the initial transaction afterIf you want the user to be able to return to the initial transaction after processing an interim transaction, use the ABAP/4 statement:

Syntaxy

CALL TRANSACTION '<TRAN>'.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 657: Sap Abap Refresher Course NoRestriction

Suppressing the transactions initial screen

When you call a transaction you can tell the system to suppress theWhen you call a transaction, you can tell the system to suppress the transaction's initial screen and proceed directly to the next screen in the sequence:

syntax:

CALL TRANSACTION '<TRAN>' AND SKIP FIRST SCREEN.

The initial screen is processed but not displayed. while suppressing the first screen, for all required fields in the initial screen, your program must pass in data values when calling the transaction.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 658: Sap Abap Refresher Course NoRestriction

Passing data with SPA / GPA Parameters

You can pass data to a called program using SPA/GPA parameters. SPA/GPA parameters are field values saved globally in memory. Each parameter is identified by a three-character code.

There are two ways to use SPA/GPA parameters:

• by setting field attributes in the Screen Painter

• by using the SET PARAMETER or GET PARAMETER• by using the SET PARAMETER or GET PARAMETER statements

SyntaxSyntaxSET PARAMETER ID 'RID' FIELD <FIELD NAME1>.GET PARAMETER ID 'RID' FIELD <FIELD NAME1>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 659: Sap Abap Refresher Course NoRestriction

·SUBMIT

Ways to produce list from within transaction

·SUBMIT Use the SUBMIT statement to start a separate report directly from the transaction.SUBMIT <prog>.SUBMIT prog .SUBMIT <prog> AND RETURN.SUBMIT <prog> VIA SELECTION-SCREENSUBMIT <prog> WITH <prog sele var> = <fld>SUBMIT <prog> WITH <para> IN <seltab>

Produce the list from your module pool using LEAVE TO LIST-PROCESSINGLEAVE TO LIST-PROCESSING AND RETURN TO

SCREEN <screen number>.LEAVE LIST PROCESSINLEAVE LIST-PROCESSIN

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 660: Sap Abap Refresher Course NoRestriction

How List-Mode in Dialog-Mode Works

You can code list-mode logic in PBO or PAI for the current screen.

· To display the list output in addition to the current screen:

Place the LEAVE TO LIST-PROCESSING logic at the end of PAI. On return from the list display, the system repeats processing for the current screen starting with the beginning of PBOscreen, starting with the beginning of PBO.

· To display the list output instead of the current screen:

Code the LEAVE TO LIST-PROCESSING logic in the PBO, and follow it with LEAVE SCREEN. This tells the system to display the list without displaying the current screen. PAI processing for the current screen is not p y g p gexecuted.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 661: Sap Abap Refresher Course NoRestriction

Leaving the List

Your program runs in list-mode until one of the following occurs

The system reaches a LEAVE LIST-PROCESSING statement in your code.The system reaches a LEAVE LIST PROCESSING statement in your code. The LEAVE LIST-PROCESSING statement returns control to the dialog screen. On return, the system re-starts processing at the beginning of PBO.

The user requests BACK or CANCEL from the basic-list level of the report.

If the user, exits the list using the BACK or CANCEL icons, you do not need to program an explicit LEAVE LIST-PROCESSING. When the user presses one of these the system returns to the screen containing thepresses one of these, the system returns to the screen containing the LEAVE TO LIST-PROCESSING and re-starts PBO processing screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 662: Sap Abap Refresher Course NoRestriction

Returning to different screen

When returning to dialog-mode, your program can also re-route the user to a screen different from the one that started the list. To do this, use the keywords AND RETURN TO SCREEN when you first branch to list-mode:

tsyntaxLEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 100.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 663: Sap Abap Refresher Course NoRestriction

Programming Field- and Value-Help

You can program help texts and possible values lists using the PROCESSYou can program help texts and possible values lists using the PROCESS ON HELP-REQUEST (POH) and PROCESS ON VALUE-REQUEST (POV) events.

Syntax

PROCESS ON HELP-REQUEST.FIELD <field> MODULE <module>.

PROCESS ON VALUE-REQUEST.FIELD <field> MODULE <module> .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 664: Sap Abap Refresher Course NoRestriction

Programming Field- and Value-Help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 665: Sap Abap Refresher Course NoRestriction

Customizing F4 value request

• Matchcode helpMatchcode help• Check tables• Help views• Domain values

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 666: Sap Abap Refresher Course NoRestriction

Customizing F4 value request

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 667: Sap Abap Refresher Course NoRestriction

Customizing F1 Help

The ABAP/4 development environment provides a number of ways of designing a context-sensitive F1 help:

• Data element documentation

• Using the PROCESS ON HELP-REQUEST event.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 668: Sap Abap Refresher Course NoRestriction

Database

DBDBINSERT

DBDBUPDATE

DELETE

MODIFYMODIFY

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 669: Sap Abap Refresher Course NoRestriction

INSERT

I t d i t d t bInsert a new record into a database

Syntax:

INSERT <table>[<workarea>]INSERT <table>[<workarea>]

Eg:

MOVE ‘BC’ TO SPLAN-AREA.MOVE BC TO SPLAN AREA. MOVE ‘BC200’ TO SPLAN-COURSEMOVE ….INSERT SPLAN.

MOVE ‘BC’ TO REC-AREA. MOVE ‘BC200’ TO REC-COURSEMOVE BC200 TO REC COURSEMOVE ….INSERT INTO SPLAN VALUES REC.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 670: Sap Abap Refresher Course NoRestriction

UPDATE

UPDATE Changes a record in the databaseU C a ges a eco d t e database

syntax: UPDATE <table>.

UPDATE <TABLE> SET <F1> = <V1>…<FN> = < VN>WHERE <f1> = <x1> .

Eg:SELECT SINGLE * FROM SPLAN WHERE AREA = ‘BC’

AND COURSE = ‘BC200’AND WEEK = ‘23’.

SPLAN-TID1 = ‘007’.UPDATE SPLAN.

UPDATE SPLANUPDATE SPLAN SET TID1 = ‘007’

TID2 = ‘003’ WHERE AREA = ‘BC’ AND COURSE = ‘BC200’

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

WHERE AREA = BC AND COURSE = BC200 AND WEEK = ‘23’.

Page 671: Sap Abap Refresher Course NoRestriction

DELETE

Delete record from the databaseDelete record from the database.

Syntax: DELETE <table> .

DELETE FROM <table> WHERE <F1> = <V1>..DELETE FROM table WHERE F1 V1 ..

Eg:

MOVE ‘BC’ TO SPLAN-AREA. MOVE ‘BC200’ TO SPLAN-COURSEMOVE ….MOVE ….DELETE SPLAN.

DELETE FROM SPLAN WHERE AREA = ‘BC’ AND COURSE = ‘BC200’ AND WEEK = ‘23’.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 672: Sap Abap Refresher Course NoRestriction

ARRAY OPERATIONS

ARRAY operations improve the performance of the database updatesARRAY operations improve the performance of the database updates

Syntax: INSERT <table< FROM <itab>.UPDATE <table< FROM <itab>UPDATE <table< FROM <itab>.DELETE <table< FROM <itab>.

Eg:g

Data: begin of itab occurs 10.Include structure splan.

Data: end of itabData: end of itab.

Move ‘BC’ to itab-area.Append itab.…..

INSERT SPLAN FROM ITAB.UPDATE SPLAN FROM ITAB

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

UPDATE SPLAN FROM ITAB.DELETE SPLAN FROM ITAB.

Page 673: Sap Abap Refresher Course NoRestriction

COMMIT WORK – ROLLBACK WORK

ABAP/4...

MODULE UPDATE INPUT...

ABAP/4

Dialog1Dialog1 Dialog2Dialog2 Dialog3Dialog3

.UPDATE <table1>.IF SY-SUBRC EQ 0.COMMIT WORK.

ELSE. UPDATE1 UPDATE2ROLLBACK WORK.MESSAGE E ... .

ENDIF.UPDATE <table2>.

DB-COMMIT DB-COMMIT (Implicit)...

ENDMODULE....

SAP-COMMIT (Explicit)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 674: Sap Abap Refresher Course NoRestriction

Programming database updates

T d t b d t ff ti l i lTo program database updates effectively, programmers are mainly concerned with:

• maintaining database correctness.

• optimizing response times for users• optimizing response times for users.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 675: Sap Abap Refresher Course NoRestriction

LUW

• If the transaction runs successfully, all changes should be carried out.• If the transaction encounters an error, no changes should be carried out,

t ti llnot even partially.

In the database world, an "all-or-nothing" transaction is called an LUW (Logical Unit of Work) There are two types of LUW’s(Logical Unit of Work).There are two types of LUW s.

• Database LUW• SAP LUW• SAP LUW

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 676: Sap Abap Refresher Course NoRestriction

Update Bundling

With Update Bundling you can execute updates at the end of the updateWith Update Bundling you can execute updates at the end of the update transaction, rather than at every screen change.

You can avoid your updates being committed at each screen change.

You can lock the objects to be updated across multiple screens.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 677: Sap Abap Refresher Course NoRestriction

Bundling Techniques

With update bundling, you package your updates in special routines that run only when your program issues a ABAP/4 commit/rollback. To do this you use:this, you use:

•PERFORM ON COMMIT •CALL FUNCTION IN UPDATE TASKCALL FUNCTION IN UPDATE TASK •CALL FUNCTION IN BACKGROUND TASK

These statements specify that a given FORM routine or function module be executed not immediately, but rather at the next ABAP/4 commit/rollback.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 678: Sap Abap Refresher Course NoRestriction

Updating in the dialog task

The PERFORM ON COMMIT statement calls a form routine in the dialog task, but delays its execution until the system encounters the next COMMIT WORK t t tCOMMIT WORK statement.

Updating in the update task:

The CALL FUNCTION IN UPDATE TASK statement logs a function module for execution in the update task. The subsequent COMMIT WORK statement triggers actual execution.statement triggers actual execution.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 679: Sap Abap Refresher Course NoRestriction

Updating in a background task

The CALL FUNCTION IN BACKGROUND TASK statement logs a function module to run in a background task. Normally, this statement is used to execute functions on remote hosts (by specifying an additional DESTINATION parameter).

B k d t k f ti d l i it t b t llBackground-task functions are processed as low-priority requests, but all requests for the same destination run in a common update transaction.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 680: Sap Abap Refresher Course NoRestriction

EXAMPLE

In this Exercise we see how to write a simple TransactionIn this Exercise we see how to write a simple TransactionFirst create a program with naming convention SAPMZ<initials>.Eg. SAPMZ_EMPDET

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 681: Sap Abap Refresher Course NoRestriction

N t i T ti SE80

EXAMPLE

Now create a screen using Transaction SE80

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 682: Sap Abap Refresher Course NoRestriction

W l t i T ti SE51

EXAMPLE

We can also create a screen using Transaction SE51

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click the create button

Page 683: Sap Abap Refresher Course NoRestriction

Enter a meaningful description for the screen and select the screen

EXAMPLE

type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the save button to save the entries

Page 684: Sap Abap Refresher Course NoRestriction

Select the program name and click the change icon

EXAMPLE

Select the program name and click the change icon.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Double click on the Include MZ<initial>TOP

Page 685: Sap Abap Refresher Course NoRestriction

Declare the Global variables in this include section

EXAMPLE

Declare the Global variables in this include section

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 686: Sap Abap Refresher Course NoRestriction

EXAMPLE

Cont. Of the previous screen

Click on the SAVE icon to save the code.

Click the BACK icon to come out.Click the BACK icon to come out.

Click on the LAYOUT BUTTON on the application toolbar to design the screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 687: Sap Abap Refresher Course NoRestriction

Click on the DICT/PROGRAM fields button on the application toolbar to

EXAMPLE

C c o t e C / OG e ds butto o t e app cat o too ba toinclude the fields on the screen from the dictionary tables or internal tables or other fields declared in the program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 688: Sap Abap Refresher Course NoRestriction

Enter the Internal or Table or field name on the Table/Field name and click

EXAMPLE

Enter the Internal or Table or field name on the Table/Field name and click on the Get from program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 689: Sap Abap Refresher Course NoRestriction

Using the corresponding icon (Text Entry Check and so on) on the object

EXAMPLE

Using the corresponding icon (Text, Entry, Check and so on) on the object bar and drag and place the object on he screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the SAVE icon to save the code .

Page 690: Sap Abap Refresher Course NoRestriction

Double Click on the table Control object to view the attributes or

EXAMPLE

properties

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 691: Sap Abap Refresher Course NoRestriction

Now write the code for the PBO PAI POV and POH for this screen

EXAMPLE

Now write the code for the PBO, PAI, POV and POH for this screen flow logic

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 692: Sap Abap Refresher Course NoRestriction

In the PBO write the relevant code for PF-STATUS and TITLE BAR

EXAMPLE

t e O te t e e e a t code o S US a d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the SAVE icon to save the code .

Page 693: Sap Abap Refresher Course NoRestriction

This is a GUI status containing buttons and menus for the screen. All

EXAMPLE

ABAP programs will have a default GUI status.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 694: Sap Abap Refresher Course NoRestriction

Th titl B f th i d th t ill t di l

EXAMPLE

The title Bar of the window that you will use to display.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 695: Sap Abap Refresher Course NoRestriction

I th PAI f th fl l i th diti l t t t

EXAMPLE

In the PAI of the flow logic we can use the conditional statementAT EXIT-COMMAND as below.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the SAVE icon to save the code .

Page 696: Sap Abap Refresher Course NoRestriction

Code for the Field check in the PAI module.

EXAMPLE

Code o t e e d c ec t e odu e

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the SAVE icon to save the code .

Page 697: Sap Abap Refresher Course NoRestriction

In this module we can even write the code to Retrieve the Data,

EXAMPLE

t s odu e e ca e e te t e code to et e e t e ata,Branching to Different Screen and also use function codes .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 698: Sap Abap Refresher Course NoRestriction

Depending on the user requirements in the previous screen 100 you can

EXAMPLE

Depending on the user requirements in the previous screen 100, you can dynamically change the Attributes of the object using SCREEN Attributes in the screen 200.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 699: Sap Abap Refresher Course NoRestriction

I th P l t (POV) f th fl l i th

EXAMPLE

In the Process on value request (POV) of the flow logic we can use the search help for a particular field

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 700: Sap Abap Refresher Course NoRestriction

You Can Use the F4 to see the search help

EXAMPLE

You Can Use the F4 to see the search help

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 701: Sap Abap Refresher Course NoRestriction

In the Process on value Help (POH) of the flow logic we can use the

EXAMPLE

t e ocess o a ue e p ( O ) o t e o og c e ca use t eadditional documentation descriptive text for the data element in the ABAP/4 Dict.

In the screen painter you place the cursor in the field string of a screen onIn the screen painter you place the cursor in the field string of a screen on the field to be documented and select the menu goto > documentation > data el. extra

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 702: Sap Abap Refresher Course NoRestriction

N ill t ith th d t l t d th b f th

EXAMPLE

Now you will get a popup with the data element and the number of the current screen as an identifier for the additional text. In addition to the help contents in the ABAP/4 Dict you can enter your own Description

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 703: Sap Abap Refresher Course NoRestriction

Here you enter your own description and SAVE

EXAMPLE

Here you enter your own description and SAVE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 704: Sap Abap Refresher Course NoRestriction

N hil R i t ti l th th fi ld d F1

EXAMPLE

Now while Running transaction place the cursor on the field and press F1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 705: Sap Abap Refresher Course NoRestriction

Layout slide for screen 200

EXAMPLE

Layout slide for screen 200.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 706: Sap Abap Refresher Course NoRestriction

Now Create a transaction code for your dialog program using Txn SE93

EXAMPLE

o C eate a t a sact o code o you d a og p og a us g S 93

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Click on the enter button

Page 707: Sap Abap Refresher Course NoRestriction

EXAMPLE

Enter the information in the fields and SAVE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Enter the information in the fields and SAVE

Page 708: Sap Abap Refresher Course NoRestriction

I S 100 i th i d i t(E l N ) d t i th

EXAMPLE

In Screen 100 we give the required input(Employee No) and retrieve the Data from the Data Dictionary and display the details on to the screen 200.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 709: Sap Abap Refresher Course NoRestriction

EXAMPLE

The details of the employee in screen 200.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 710: Sap Abap Refresher Course NoRestriction

Example : Table Control

In this example we will create a screen and use the table control object to t s e a p e e c eate a sc ee a d use t e tab e co t o object todisplay data. Use SE51 to Create a screen (In our case 300)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 711: Sap Abap Refresher Course NoRestriction

W ill d i th ith t t bj t d th t bl t l bj t

Example : Table Control

We will design the screen with a text object and the table control object

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 712: Sap Abap Refresher Course NoRestriction

Enter the Internal or Table or field name on the Table/Field name and click

Example : Table Control

te t e te a o ab e o e d a e o t e ab e/ e d a e a d c con the Get from program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 713: Sap Abap Refresher Course NoRestriction

Using the attribute button of the table control you can put vertical and

Example : Table Control

Us g t e att bute butto o t e tab e co t o you ca put e t ca a dhorizontal separators an resizing if required and name the table control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 714: Sap Abap Refresher Course NoRestriction

Now we have to write code for the data retrieval and populate the internal

Example : Table Control

Now we have to write code for the data retrieval and populate the internal table. In the PAI of the screen 100 we are branching it to our table control screen i.e. 300.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 715: Sap Abap Refresher Course NoRestriction

We write code to retrieve Data

Example : Table Control

We write code to retrieve Data.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 716: Sap Abap Refresher Course NoRestriction

Now using the PBO of the screen 300 flow logic we populate the table

Example : Table Control

Now using the PBO of the screen 300 flow logic we populate the table control

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 717: Sap Abap Refresher Course NoRestriction

In our example when the user clicks the LIST Button in the initial screen

Example : Table Control

In our example when the user clicks the LIST Button in the initial screen, the complete list of employees will be displayed in the second screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 718: Sap Abap Refresher Course NoRestriction

Here we get the list of all employees

Example : Table Control

Here we get the list of all employees.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 719: Sap Abap Refresher Course NoRestriction

Transactions

SummarySu a y

The slides explained the structure of transaction, screen and menu painter and all the main features associated with dialog programmingprogramming.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 720: Sap Abap Refresher Course NoRestriction

8. DATABASE UPDATES

Database updates with open SQL

LUW processingLUW processing

Update Bundling Techniques

Programming Bundling Updates

Unbundled Updates

Local UpdatesLocal Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 721: Sap Abap Refresher Course NoRestriction

Database

DBDBINSERT

DBDBUPDATE

DELETE

MODIFYMODIFY

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 722: Sap Abap Refresher Course NoRestriction

INSERT

I t d i t d t bInsert a new record into a database

Syntax:

INSERT <table>[<workarea>]INSERT <table>[<workarea>]

Eg:

MOVE ‘BC’ TO SPLAN-AREA.MOVE BC TO SPLAN AREA. MOVE ‘BC200’ TO SPLAN-COURSEMOVE ….INSERT SPLAN.

MOVE ‘BC’ TO REC-AREA. MOVE ‘BC200’ TO REC-COURSEMOVE BC200 TO REC COURSEMOVE ….INSERT INTO SPLAN VALUES REC.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 723: Sap Abap Refresher Course NoRestriction

UPDATE

UPDATE Changes a record in the databaseU C a ges a eco d t e database

syntax: UPDATE <table>.

UPDATE <TABLE> SET <F1> = <V1>…<FN> = < VN>WHERE <f1> = <x1> .

Eg:SELECT SINGLE * FROM SPLAN WHERE AREA = ‘BC’

AND COURSE = ‘BC200’AND WEEK = ‘23’.

SPLAN-TID1 = ‘007’.UPDATE SPLAN.

UPDATE SPLANUPDATE SPLAN SET TID1 = ‘007’

TID2 = ‘003’ WHERE AREA = ‘BC’ AND COURSE = ‘BC200’

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

WHERE AREA = BC AND COURSE = BC200 AND WEEK = ‘23’.

Page 724: Sap Abap Refresher Course NoRestriction

DELETE

Delete record from the databaseDelete record from the database.

Syntax: DELETE <table> .

DELETE FROM <table> WHERE <F1> = <V1>..DELETE FROM table WHERE F1 V1 ..

Eg:

MOVE ‘BC’ TO SPLAN-AREA. MOVE ‘BC200’ TO SPLAN-COURSEMOVE ….MOVE ….DELETE SPLAN.

DELETE FROM SPLAN WHERE AREA = ‘BC’ AND COURSE = ‘BC200’ AND WEEK = ‘23’.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 725: Sap Abap Refresher Course NoRestriction

ARRAY OPERATIONS

ARRAY operations improve the performance of the database updatesARRAY operations improve the performance of the database updates

Syntax: INSERT <table< FROM <itab>.UPDATE <table< FROM <itab>UPDATE <table< FROM <itab>.DELETE <table< FROM <itab>.

Eg:g

Data: begin of itab occurs 10.Include structure splan.

Data: end of itabData: end of itab.

Move ‘BC’ to itab-area.Append itab.…..

INSERT SPLAN FROM ITAB.UPDATE SPLAN FROM ITAB

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

UPDATE SPLAN FROM ITAB.DELETE SPLAN FROM ITAB.

Page 726: Sap Abap Refresher Course NoRestriction

COMMIT WORK – ROLLBACK WORK

ABAP/4...

MODULE UPDATE INPUT...

ABAP/4

Dialog1Dialog1 Dialog2Dialog2 Dialog3Dialog3

.UPDATE <table1>.IF SY-SUBRC EQ 0.COMMIT WORK.

ELSE. UPDATE1 UPDATE2ROLLBACK WORK.MESSAGE E ... .

ENDIF.UPDATE <table2>.

DB-COMMIT DB-COMMIT (Implicit)...

ENDMODULE....

SAP-COMMIT (Explicit)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 727: Sap Abap Refresher Course NoRestriction

8. DATABASE UPDATES

Database updates with open SQL

LUW processingLUW processing

Update Bundling Techniques

Programming Bundling Updates

Unbundled Updates

Local UpdatesLocal Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 728: Sap Abap Refresher Course NoRestriction

LUW

• If the transaction runs successfully, all changes should be carried out.• If the transaction encounters an error, no changes should be carried out,

t ti llnot even partially.

In the database world, an "all-or-nothing" transaction is called an LUW (Logical Unit of Work) There are two types of LUW’s(Logical Unit of Work).There are two types of LUW s.

• Database LUW• SAP LUW• SAP LUW

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 729: Sap Abap Refresher Course NoRestriction

Database Update TechniquesPROGRAMMING DATABASE UPDATES

To program database updates effectively, programmers are mainlyconcerned with:concerned with:

( Maintaining database Correctness( Maintaining database Correctness.( Optimizing response times for users.

For a quick introduction before programming updates, see:

( Transaction in the SAP system.( Introduction to Update Bundling.( Introduction to SAP Locking

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 730: Sap Abap Refresher Course NoRestriction

Database Update TechniquesTRANSACTIONS IN THE SAP SYSTEM

( If the transaction runs successfully, all changes should becarried out.carried out.

( If the transaction encounters an error, no changes should becarried out, not even partially., p y

In the database world, an "all-or-nothing" transaction is called an LUW(Logical Unit of Work).There are three types of LUW’s.

( Database LUW( SAP LUW( SAP LUW( ABAP/4 Transaction

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 731: Sap Abap Refresher Course NoRestriction

Database Update TechniquesDATABASE LUW

The SAP System triggers database commit operations automatically atevery screen change. Database LUW lasts (at longest) from one screenchange to the next.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 732: Sap Abap Refresher Course NoRestriction

Database Update TechniquesSAP LUW

As a logical unit, update transactions should be executed entirely, or notat all. In general, an update transaction usually spans several databaseLUWs and is closed at the ABAP/4 level with a COMMIT WORK command.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 733: Sap Abap Refresher Course NoRestriction

Database Update TechniquesABAP/4 TRANSACTION

An ABAP/4 or SAP transaction is an application program that you startusing a transaction code. It may contain one or more SAP LUWs.Whenever the system reaches a COMMIT WORK or ROLLBACK WORKWhenever the system reaches a COMMIT WORK or ROLLBACK WORKstatement that is not at the end of the last dialog step of the SAPtransaction, it opens a new SAP LUW.

( With one or more SAP LUWs.

Transactions in this form consist entirely of processing blocks (dialogTransactions in this form consist entirely of processing blocks (dialogmodules, event blocks, function module calls, and subroutines). Youshould be careful to ensure that external subroutines or function modules d t l d t COMMIT WORK ROLLBACK WORK t t tdo not lead to COMMIT WORK or ROLLBACK WORK statements accidentally being executed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 734: Sap Abap Refresher Course NoRestriction

Database Update Techniques( By inserting an SAP LUW

The ABAP statements CALL TRANSACTION (start a new transaction),SUBMIT (start an executable program), and CALL FUNCTION...DESTINATION (call a function module using RFC) open a new SAP LUWDESTINATION (call a function module using RFC) open a new SAP LUW.When you call a program, it always opens its own SAP LUW. However, itdoes not end the LUW of the SAP transaction that called it. This meansthat a COMMIT WORK or ROLLBACK WORK statement only applies to they ppSAP LUW of the called program. When the new LUW is complete, thesystem carries on processing the first SAP LUW.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 735: Sap Abap Refresher Course NoRestriction

Database Update Techniques( By running two SAP LUWs in parallel

The CALL FUNCTION... STARTING NEW TASK statement calls a functionmodule asynchronously in a new session. Unlike normal functionmodule calls, the calling transaction carries on with its own processingas soon as the function module has started, and does not wait for it tofinish processing. The function call is asynchronous. The called functionmodule can now call its own screens and interact with the user.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 736: Sap Abap Refresher Course NoRestriction

8. DATABASE UPDATES

Database updates with open SQL

LUW processingLUW processing

Update Bundling Techniques

Programming Bundling Updates

Unbundled Updates

Local UpdatesLocal Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 737: Sap Abap Refresher Course NoRestriction

Database Update TechniquesINTRODUCTION TO UPDATE BUNDLING

With Update Bundling you can execute updates at the end of theupdate transaction, rather than at every screen change. ABAP/4provides commands for bundling updates in special updateprovides commands for bundling updates in special updateroutines.

( You can avoid your updates being committed at each screen( You can avoid your updates being committed at each screenchange.

( You can lock the objects to be updated across multiplej p pscreens.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 738: Sap Abap Refresher Course NoRestriction

Database Update TechniquesSUMMARY OF BUNDLING TECHNIQUES

With update bundling, you package your updates in special routines thatrun only when your program issues a ABAP/4 commit/rollback. To dothis, you use:

( PERFORM ON COMMIT( CALL FUNCTION IN UPDATE TASK( CALL FUNCTION IN UPDATE TASK( CALL FUNCTION IN BACKGROUND TASK

These statements specify that a given FORM routine or function moduleThese statements specify that a given FORM routine or function modulebe executed not immediately, but rather at the next ABAP/4 commit/rollback. An ABAP/4 commit is an ABAP/4 statement that triggers adatabase commit, but also perform other functions.The ABAP/4, pstatements for performing these commits and roll backs are:

( COMMIT WORK

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

( ROLL BACK

Page 739: Sap Abap Refresher Course NoRestriction

Database Update TechniquesBUNDLED UPDATING IN THE DIALOG TASK

The PERFORM ON COMMIT statement calls a form routine in the dialogtask, but delays its execution until the system encounters the nextCO OCOMMIT WORK statement.

Using PERFORM ON COMMIT:

You can bundle updates for dialog-task processing and have themexecute in the last LUW for the transaction. To do this:

1. Place all update statements (insert, update,Modify, Delete) in aFORM routine.

2. Call the transaction with PERFROM <form> ON COMMIT>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 740: Sap Abap Refresher Course NoRestriction

Database Update TechniquesThe effect of using PERFORM ON COMMIT, Instead of simple perform, isthat the system delays execution of the form routine until it encountersthe COMMIT WORK statement. You should position the commit WORK atthe end of the statement or wherever user can select the save condition.

ASSIGNING RUN PRIORITIES TO FORM ROUTINES:

You can assign a run priority to each form routine by adding the levelYou can assign a run priority to each form routine by adding the levelparameter to the PREFORM ON COMMIT statement.

For Ex.

PERFORM update_table1 ON COMMIT LEVEL 2.….PERFORM update_table2 ON COMMIT LEVEL 3.….PERFORM update_table3 ON COMMIT LEVEL 1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 741: Sap Abap Refresher Course NoRestriction

Database Update TechniquesWhen this reaches COMMIT WORK statement, the FORM routines will runin this order.

First : Update_table3.Second : Update table1Second : Update_table1.Third : Update_table2.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 742: Sap Abap Refresher Course NoRestriction

Database Update TechniquesBUNDLED UPDATING IN THE UPDATE TASK

The CALL FUNCTION IN UPDATE TASK statement logs a function modulefor execution in the update task. The subsequent COMMIT WORK

fstatement triggers actual execution. You can perform updates in thedialog task as well as in the update task. Dialog task updates aresynchronous updates. Update task updates are asynchronous. (Anexception is You can trigger an update function with COMMIT WORK ANDexception is You can trigger an update function with COMMIT WORK ANDWAIT: this is synchronous.)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 743: Sap Abap Refresher Course NoRestriction

Database Update TechniquesThe following diagram illustrates the Synchronous Update in Update Task

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 744: Sap Abap Refresher Course NoRestriction

Database Update TechniquesCREATING UPDATE FUNCTION MODULES

To create a function module, you first need to start the Function Builder.Choose Tools - ABAP Workbench, Function Builder.

To be able to call a function module in an update work process, you mustflag it in the Function Builder When you create the function module setflag it in the Function Builder. When you create the function module, setthe Process Type attribute to one of the following values:

• Update with immediate start• Update with immediate startSet this option for high priority ("V1") functions that run in a shared (SAPLUW). These functions can be restarted by the update task in case oferrors.• Update w. imm. start, no restartSet this option for high priority ("V1") functions that run in a shared (SAP

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Set this option for high priority ("V1") functions that run in a shared (SAPLUW). These functions may not be restarted by the update task.

Page 745: Sap Abap Refresher Course NoRestriction

Database Update Techniques

• Update with delayed start

S t thi ti f l i it ("V2") f ti th t i th iSet this option for low priority ("V2") functions that run in their ownupdate transactions. These functions can be restarted by the update taskin case of errors.To display the attributes screen in the Function Builder, chooseGoto - Administration.DEFINING THE INTERFACEDEFINING THE INTERFACEFunction modules that run in the update task have a limited interface:• Result parameters or exceptions are not allowed since update-

task function modules cannot report on their results.• You must specify input parameters and tables with reference fields or

reference structures defined in the ABAP Dictionary.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

y

Page 746: Sap Abap Refresher Course NoRestriction

Database Update TechniquesCALLING UPDATE TASK FUNCTION MODULES:

Function modules that run in update task can run synchronously orasynchronously.

( COMMIT WORK:Your program does not wait for the requested functions to finishYour program does not wait for the requested functions to finishprocessing, which specifies asynchronous processing.

( COMMIT WORK AND WAITYour program will wait for the requested functions to finish processing.Control returns to your program after function module run successfully.Control returns to your program after function module run successfully.Which specifies synchronous processing.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 747: Sap Abap Refresher Course NoRestriction

Database Update TechniquesCALLING UPDATE FUNCTIONS DIRECTLY

To call a function module directly, use CALL FUNCTION IN UPDATE TASK directly in your codeTASK directly in your code.

CALL FUNCTION 'FUNCTMOD' IN UPDATE TASK EXPORTING... For EX:For EX:

a = 1. CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = APAR = A... a = 2. CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A...

3a = 3. COMMIT WORK. Here, the function module UPD_FM is performed twice in the

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

update task: the first time, with value 1 in PAR, the second time with value 2 in PAR.

Page 748: Sap Abap Refresher Course NoRestriction

Database Update TechniquesADDING UPDATE TASK CALLS TO A SUBROUTINE

You can also put the CALL FUNCTION IN UPDATE TASK into a subroutine and call the subroutine with:subroutine and call the subroutine with:

PERFORM SUBROUT ON COMMIT.

If you choose this method, the subroutine is executed at the commit.Thus the request to run the function in the update task is also loggedThus the request to run the function in the update task is also loggedduring commit processing. As a result, the parameter values logged withthe request are those current at the time of the commit.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 749: Sap Abap Refresher Course NoRestriction

Database Update Techniquesa = 1. PERFORM F ON COMMIT. a = 2. PERFORM F ON COMMIT. a = 3a = 3. COMMIT WORK.

FORM fFORM f. CALL FUNCTION 'UPD_FM' IN UPDATE TASK EXPORTING PAR = A. ENDFORM.

In this example, the function module UPD_FM is carried out with the value3 in PAR. The update task executes the function module only once,despite the two PERFORM ON COMMIT statements. This is because agiven function module, logged with the same parameter values, can

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

never be executed more than once in the update task.

Page 750: Sap Abap Refresher Course NoRestriction

Database Update TechniquesTRANSACTION THAT CALL UPDATE TASK FUNCTIONS

If your program calls another program that itself calls an update functionmodule you should be aware of the following:module, you should be aware of the following:

When the new program is called, a new SAP LUW begins, and a newd t k i t d Thi k i d t id tif ll d t t kupdate key is generated. This key is used to identify all update-task

operations requested during the called program.

When returning from the program, the LUW of the calling program isrestored together with the old update key.

If the called program does not contain its own COMMIT WORK, thedatabase update requests are not processed, and the update functionmodules are not called In the following example F1 F2 and F3 are

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

modules are not called. In the following example, F1, F2, and F3 areupdate function modules:

Page 751: Sap Abap Refresher Course NoRestriction

Database Update Techniques

Here, F1 and F3 are executed in the update task, because the COMMIT WORK for the main program triggers their execution. However, since transaction ZABC contains no COMMIT WORK statement, the function F2is never executed by the update taskis never executed by the update task.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 752: Sap Abap Refresher Course NoRestriction

Database Update TechniquesBUNDLED UPDATING IN A BACKGROUND TASK

The CALL FUNCTION IN BACKGROUND TASK statement logs a functionmodule to run in a background task. Normally, this statement is used toexecute functions on remote hosts (by specifying an additionalexecute functions on remote hosts (by specifying an additionalDESTINATION parameter).

For Example if you are maintaining a replicated data in two databasesFor Example if you are maintaining a replicated data in two databases.While making the primary updates in the update task of the local system,you would also execute the same updates on a remote database. Thissystem uses RFC to send request to the remote system.y q y

To execute updates on a remote host, use the statement:

CALL Function <fctmode> IN BACKGROUNG TASK DESTINATION<dest>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 753: Sap Abap Refresher Course NoRestriction

Database Update TechniquesThis statement requests execution of an update function in an externalsystem. The destination specifies the remote system. On encounteringthis statement, the system writes your request to the log table and thenexecutes it at the next commit statement.

You can also use this statement without the DESTINATION parameter.Inthis case , the function runs in a separate work process, but on the localhosthost.

All remote host background task functions triggered with sameCOMMIT WORK run together in a common LUW.g

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 754: Sap Abap Refresher Course NoRestriction

Database Update TechniquesERROR HANDLING FOR BUNDLED UPDATES

Runtime errors can occur during execution of bundled updates. How arethey handled? In general, COMMIT WORK processing occurs in thethey handled? In general, COMMIT WORK processing occurs in thefollowing order:

All di l t k FORM ti l d ith PERFORM ONAll dialog-task FORM routines logged with PERFORM ONCOMMIT are executed.All high-priority (V1) update-task function modules areexecuted.The end of V1-update processing marks the end of the . If youused COMMIT WORK AND WAIT to trigger commit processing,gg p g,control returns to the dialog-task program.All low-priority (V2) update-task function modules are

triggered.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

triggered.All background-task function modules are triggered.

Page 755: Sap Abap Refresher Course NoRestriction

Database Update TechniquesRuntime errors can occur either in the system itself, or because your program issues an termination message (MESSAGE type ‘A’). Also, the ROLLBACK WORK statement automatically signals a runtime error. Thesystem handles errors according to where they occur:y g y

In a FORM routine (called with PERFORM ON COMMIT)

− Updates already executed for the current update transaction are rolled back.are rolled back.− No other FORM routines will be started.− No further update-task or background-task functions will be started.− An error message appears on the screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 756: Sap Abap Refresher Course NoRestriction

Database Update TechniquesIn a V1 update-task function module (requested IN UPDATE TASK)

− Updates already executed for V1 functions are rolled back.− All further update-task requests (V1 or V2) are thrown away.− All background-task requests are thrown away.

Updates already executed for FORM routines called with− Updates already executed for FORM routines called with PERFORM ON COMMIT are not rolled back.− An error message appears on the screen, if your system is set

t d thup to send them

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 757: Sap Abap Refresher Course NoRestriction

Database Update TechniquesIn a V2 update-task function module (requested IN UPDATE TASK)

− Updates already executed for the current V2 function are rolled backrolled back.− All update-task requests (V2) still to be executed are carried out.− All background-task requests still to be executed are carried out.− No updates for previously executed V1 or V2 function areNo updates for previously executed V1 or V2 function are rolled back.− No updates previously executed for FORM routines (called with ON COMMIT) are rolled backwith ON COMMIT) are rolled back.− An error message appears on the screen, if your system is set up to send them

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 758: Sap Abap Refresher Course NoRestriction

Database Update TechniquesIn a background-task function module (requested IN BACKGROUND TASK DESTINATION)

B k d t k d t l d t d f th t− Background-task updates already executed for the current DESTINATION are not rolled back.− All further background-task requests for the same DESTINATION are thrown away.− No other previously-executed updates are not rolled back.

No error message appears on the screen− No error message appears on the screen.

If your program detects that an error in remote processing has occurred, it can decide whether to resubmit the requests at a later time.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 759: Sap Abap Refresher Course NoRestriction

Database Update TechniquesUNBUNDLED UPDATES

You can make database updates in ABAP/4 without these bundling HereYou can place update statements (insert,Modify,DELETE) directly in yourcode These are inline updates without using any bundling techniquescode. These are inline updates without using any bundling techniques.Even if you code No COMMIT WORK statement the database commit atthe next screen change will commit the updates to the database.

This inline update is only suitable for the single screen transactions. WithMultiple screen transactions, if any error occurs in later screens, youcan't roll back the data committed in earlier screens.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 760: Sap Abap Refresher Course NoRestriction

8. DATABASE UPDATES

Database updates with open SQL

LUW processingLUW processing

Update Bundling Techniques

Programming Bundling Updates

Unbundled Updates

Local UpdatesLocal Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 761: Sap Abap Refresher Course NoRestriction

Database Update TechniquesUNBUNDLED UPDATES

You can make database updates in ABAP/4 without these bundling HereYou can place update statements (insert,Modify,DELETE) directly in yourcode These are inline updates without using any bundling techniquescode. These are inline updates without using any bundling techniques.Even if you code No COMMIT WORK statement the database commit atthe next screen change will commit the updates to the database.

This inline update is only suitable for the single screen transactions. WithMultiple screen transactions, if any error occurs in later screens, youcan't roll back the data committed in earlier screens.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 762: Sap Abap Refresher Course NoRestriction

Database Update TechniquesAdvantages and Disadvantages:

( Inline updating may feel simpler and more natural.

( PERFORM ON COMMIT may make more efficient use of data resources, since all accesses are performed at one time.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 763: Sap Abap Refresher Course NoRestriction

8. DATABASE UPDATES

Database updates with open SQL

LUW processingLUW processing

Update Bundling Techniques

Programming Bundling Updates

Unbundled Updates

Local UpdatesLocal Updates

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 764: Sap Abap Refresher Course NoRestriction

Database Update TechniquesLOCAL UPDATES

In ABAP/4 You can tell the system to perform updates locally, rather thanin the update task. To do this, use the statement SET UPDATE TASKLOCAL whenever your program runs in background You can check theLOCAL whenever your program runs in background. You can check thetask from your code by querying the SY-BATCH system variable.

IF SY-BATCH NE SPACE.SET UPDATE TASK LOCAL.

ENDIF.…CALL FUNCTION UPDATE TABLE1 IN UPDATE TASKCALL FUNCTION UPDATE_TABLE1 IN UPDATE TASK.…CALL FUNCTION UPDATE_TABLE2 IN UPDATE TASK.…COMMIT WORK.

LOCKING IN THE SAP SYSTEM

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

LOCKING IN THE SAP SYSTEMPlease refer the Locking concepts in DATA DICTIONARY.

Page 765: Sap Abap Refresher Course NoRestriction

Database Update TechniquesSUMMARYSUMMARY

( Transaction is an operation that lets the user make changes to the database. The operation must be carried out in “all or nothing fashion”.fashion .

( The different transactions in SAP are Database LUW, SAP LUW and ABAP Transactions.

( The ABAP/4 bundling techniques let you distribute your updates to different work processes.

( We have seen the bundling techniques in different updates like dialog task, update task and Background task. ABAP/4 id d f b dli d i i l i( ABAP/4 provides commands for bundling updates in special routines like PERFORM ON COMMIT, CALL FUNCTION IN UPDATE TASK and CALL FUNCTION IN BACKGROUND TASK. Execution of these routine is delayed until your program issues an explicit “SAP COMMIT”is delayed until your program issues an explicit “SAP COMMIT”

( In a local update, the update program is run by the same work process that processed the request.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 766: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

Enhancements to SAP Objects

E h t i M it / S it / FM itEnhancements via Menu exits / Screen exits / FM exits

Business Add-Ins

Modifications ( Registering the Modifications in SSCR,

Modification Adjustment, Rules for Modifications )

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 767: Sap Abap Refresher Course NoRestriction

Enhancements

R/3

ADAPTABILITY OF SAP

R/3

Customizing Modifying Enhancements Customer Development

Project Dependent Project Independent

Menu Exit Function Exit Screen Exit Field Exit Keyword Exit

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 768: Sap Abap Refresher Course NoRestriction

Enhancements

There are four different ways of adapting the SAP system to fit your needs :

Customizing : Configuration of system parameters via a special user interface, the possible changes are preplanned and organized.interface, the possible changes are preplanned and organized. Customizing is required during implementation of the system.

Modification : Alteration of SAP Repository objects in the form of custom changes when SAP changes occur the customer version andcustom changes when SAP changes occur, the customer version and the new SAP version must be reconciled manually.

Enhancement concept : Changing of SAP Repository objects by the customer without modification.

Custom development : Creation of custom objects within the customer name range.g

Modification and Customer development involve high maintenance and costs. Hence use these only when customer requirements are not met by customizing or by user exits

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

met by customizing or by user exits.

Page 769: Sap Abap Refresher Course NoRestriction

Enhancements

Advantages of Enhancements

Th t i h h ld it th thThere are two main reasons why you should use exits rather than modifying SAP software yourself. Add-ons attached to exits have the advantage that:

They do not affect standard SAP source code.

They do not affect software updates.

Enhancements can be achieved by Exits.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 770: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

Enhancements to SAP Objects

E h t i M it / S it / FM itEnhancements via Menu exits / Screen exits / FM exits

Business Add-Ins

Modifications ( Registering the Modifications in SSCR,

Modification Adjustment, Rules for Modifications )

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 771: Sap Abap Refresher Course NoRestriction

Enhancements

There are three types of exits:

Menu Exits

Screen Exits

Function module Exits

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 772: Sap Abap Refresher Course NoRestriction

Enhancements

Locating Applications that Have Exits

SAP organizes its exits in packages are called SAP enhancements. Each SAP enhancement can contain many individual exits.

Choose utilities -->Enhancements --> Project Management from the ABAP Workbench menu.

From here, choose utilities --> SAP enhancements to call a selection screen that lets you look for the exits available in the standard applications. To list all the enhancements in the entire system, choose the Executefunction without specifying any selection criteria.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 773: Sap Abap Refresher Course NoRestriction

Enhancements

Searching in the Application Hierarchy

Application Hierarchy can be accessed by choosingABAP Workbench > Overview > Application hierarchyABAP Workbench --> Overview --> Application hierarchy.

For a particular application area, for example exits associated with Material Management, proceed as follows:

Place the cursor on the material management branch of the application tree and choose sel / dsel --> repository infosys.

Expand the Environment sub tree in the repository informationExpand the Environment sub-tree in the repository information system.

Expand the Exit Techniques sub-tree. Choose either Enhancements or Projects.

Choose Execute.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 774: Sap Abap Refresher Course NoRestriction

Enhancements

MENU EXITS

Menu exits allow you to attach your own processes to action menu items. For this, the SAP applications programmer reserves certain menu entries in the GUI interface.menu entries in the GUI interface.

The Menu exit entries have function codes that begin with + (Plus sign).

Once you activate the menu exits, they become visible in the application. When the menu item is selected, either the functionality provided by the SAP applications programmer or your own functionality implemented in the program exit is processed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 775: Sap Abap Refresher Course NoRestriction

Enhancements

Step-by-step process of creating Menu Exits

Evoke the Transaction code CMOD or alternatively you can use the path tools --> ABAP workbench --> utilities --> Enhancements --> Project Management.Project Management.

Specify a Project name in the Enhancement Text box.

Click on the create icon on the screen. For example let us create an enhancement project say zuser.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 776: Sap Abap Refresher Course NoRestriction

Enhancements

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 777: Sap Abap Refresher Course NoRestriction

Enhancements

In the next screen enter the description of the project.

Save the changes made so far in the development class.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 778: Sap Abap Refresher Course NoRestriction

Enhancements

Select Enhancement components. The system lists all customer exits contained in the enhancements included in your project.

Place the cursor on the menu exit you want to add your own functionPlace the cursor on the menu exit you want to add your own function to.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 779: Sap Abap Refresher Course NoRestriction

Enhancements

Choose Edit component.The system displays technical information about the menu entry. It also displays two input fields where you can specify a language and the text you want your menu item to have.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 780: Sap Abap Refresher Course NoRestriction

Enhancements

Enter the name of your menu function (such as test menu) in the field New text.

Choose Save text.Your special menu function will not appear in the pulldown menu ofYour special menu function will not appear in the pulldown menu of the corresponding standard transaction until you activate your enhancement project.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 781: Sap Abap Refresher Course NoRestriction

Enhancements

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 782: Sap Abap Refresher Course NoRestriction

Enhancements

After activation the menu(rounded) will be visible on the standard menu for the transaction S001.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 783: Sap Abap Refresher Course NoRestriction

Enhancements

Screen Exits

Screen exits add fields to screens in R/3 applications. SAP creates screen exits by placing special subscreen areas on a standard R/3screen exits by placing special subscreen areas on a standard R/3 screen and calling a customer subscreen from the standard screen’s flow logic.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 784: Sap Abap Refresher Course NoRestriction

Enhancements

Step-by-step process of creating Screen Exits

From the main screen of the Project management transaction, proceed as follows:

Select Enhancement components and choose Change.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 785: Sap Abap Refresher Course NoRestriction

Enhancements

Choose Edit component.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 786: Sap Abap Refresher Course NoRestriction

Enhancements

Choose the screen e it and do ble click on it

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Choose the screen exit and double click on it

Page 787: Sap Abap Refresher Course NoRestriction

Enhancements

Create your subscreen using the Screen Painter.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 788: Sap Abap Refresher Course NoRestriction

Enhancements

Design your screen to be added to the standard screen and activate the particular screen and return back to the flow logic .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 789: Sap Abap Refresher Course NoRestriction

Enhancements

Choose the PAI and PBO to write down the logic.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 790: Sap Abap Refresher Course NoRestriction

Enhancements

Generate your screen and choose Back (the green arrow) to return to the Project management transaction.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 791: Sap Abap Refresher Course NoRestriction

Enhancements

Go to the transaction ME22 to view the customer defined screen exit.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 792: Sap Abap Refresher Course NoRestriction

Enhancements

Enter the purchase order number and press Enter.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 793: Sap Abap Refresher Course NoRestriction

Enhancements

Go to the menu header --> Details.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 794: Sap Abap Refresher Course NoRestriction

Enhancements

Purchase number is visible on the standard screen(rounded). u c ase u be s s b e o t e sta da d sc ee ( ou ded)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 795: Sap Abap Refresher Course NoRestriction

Enhancements

Function module Exits

Function module exits allow you, as customer, to implement additional logic in an application function. The SAP applications programmer defines where in the application function the function module exits aredefines where in the application function the function module exits are placed and which data is to be transferred. The programmer also creates the related function modules with short text, interface, and documentation and describes the intended functionality of the function module exit in the SAP documentation.

You code the function modules, and if needed the screens, text elements, and your own Includes for the function group.elements, and your own Includes for the function group.

After you activate the enhancement project that contains the function module as component the ABAP/4 code will be processed. Before that, the program exits have no effectthe program exits have no effect.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 796: Sap Abap Refresher Course NoRestriction

Enhancements

Step-by-step process of creating Functional module Exits.

From the main screen of the Project management transaction, or transaction CMOD proceed as follows:transaction CMOD proceed as follows:

Select Enhancement components and choose ChangeSelect Enhancement components and choose Change.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 797: Sap Abap Refresher Course NoRestriction

Enhancements

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 798: Sap Abap Refresher Course NoRestriction

Enhancements

Place the cursor on the function module exit you want to use.y

Choose Edit component.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 799: Sap Abap Refresher Course NoRestriction

Enhancements

Call the function module’s include program by double-clicking on it.p g y g

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 800: Sap Abap Refresher Course NoRestriction

Enhancements

Confirm that you want to create the include program. y p g

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 801: Sap Abap Refresher Course NoRestriction

Enhancements

Enter your function’s source code in the editor.y

Sa e o r incl de program and acti ate it

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Save your include program and activate it.

Page 802: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

Enhancements to SAP Objects

E h t i M it / S it / FM itEnhancements via Menu exits / Screen exits / FM exits

Business Add-Ins

Modifications ( Registering the Modifications in SSCR,

Modification Adjustment, Rules for Modifications )

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 803: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 804: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 805: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 806: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 807: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 808: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 809: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 810: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 811: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 812: Sap Abap Refresher Course NoRestriction

9. ENHANCEMENTS & MODIFICATIONS

Enhancements to SAP Objects

E h t i M it / S it / FM itEnhancements via Menu exits / Screen exits / FM exits

Business Add-Ins

Modifications ( Registering the Modifications in SSCR,

Modification Adjustment, Rules for Modifications )

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 813: Sap Abap Refresher Course NoRestriction

Modifications

Registering the Modification in SSCR

A registered development user registers changes in SAP sources and l h f SAP D t Di ti bj t E ti t hmanual changes of SAP Data Dictionary objects. Exceptions to such

registration are matchcodes, database indices, buffer settings, customer objects, patches and objects whose changes are based on automatic generation If the same user changes the object again at a later time nogeneration. If the same user changes the object again at a later time, no new query is made for the registration key. Once an object is registered, the related key is locally stored and copied automatically for later changes, regardless of which registered user is making the change.changes, regardless of which registered user is making the change.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 814: Sap Abap Refresher Course NoRestriction

Modifications

How do you benefit from SSCR ( SAP Software Change Registration)?

Quick error resolution and therefore high availability of modified systems

All th h d bj t l d b SAP B d thi i f tiAll the changed objects are logged by SAP. Based on this information, SAP’ s First Level Customer Service can quickly localize and remove the causes of problems. This increases the availability of your R/3 systemsystem.

Dependable Operation

The necessity to register will likely prevent unintended modifications.The necessity to register will likely prevent unintended modifications. This in turn promises the dependable operation of your R/3 system.

Simplification of upgrades

Upgrades and release changes become considerably easier because of fewer modifications.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 815: Sap Abap Refresher Course NoRestriction

Modifications

Procedure for a Registered Modification

If you change one of the SAP's Repository objects, the Workbench Organizer will require a change request, same as if you were creating your own object.. The object is automatically added to a repair task.your own object.. The object is automatically added to a repair task.

Once the development is completed, the Programmer releases the task. The objects and the object locks are transferred from the task to the change requestchange request..

Once the project is completed, you release the change request. This will remove the object locks of the change request.

Change request may be transportable or local. The WBO will automatically classify the change request depending upon the development class. Only transportable change request will be p y p g qtransferred to the transport system after their release.

Immediately after the export a test import will check if all objects can be imported into the target system

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

can be imported into the target system.

Page 816: Sap Abap Refresher Course NoRestriction

Modifications

Repository objects are exported to the central transport directory.

The result of export and test import are recorded in the transport log of the change request to be verified by the programmer.

Th i t i t th t t t i t t ti th it i i iti t dThe import into the target system is not automatic, rather it is initiated by the system administrator of the transport control program tp at the operating system level.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 817: Sap Abap Refresher Course NoRestriction

Modifications

Modification Adjustment at Release Change

The modifications must be adjusted to the new standard during release hchange.

The same is true for maintenance upgrades.

Procedure : Determination of overlap and manual adjustmentProcedure : Determination of overlap and manual adjustment.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 818: Sap Abap Refresher Course NoRestriction

Modifications

oldZABAP

old

Full versionRelease

request

ZABAPold

Backward Delta

Release requestq

When you release a change request, a complete version of all objects contained in the changes request is written to the versions database.contained in the changes request is written to the versions database.

If you later edit a Repository object again, the current object becomes the complete copy and the differences between the old and the new object are stored in the versions database as backward deltaobject are stored in the versions database as backward delta.

When you assign a Repository object to a task, the system checks whether the current version agrees with the complete copy in the

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

versions database. If not, a complete copy is created. This takes place the first time you change an object.

Page 819: Sap Abap Refresher Course NoRestriction

Modifications

The versions of a Repository object are the basis for the modification adjustment .To support this adjustments,information on whether the version was created by SAP or by the customer is also storedversion was created by SAP or by the customer is also stored

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 820: Sap Abap Refresher Course NoRestriction

Modifications

Objects of the Modification Adjustment

Dictionary objects

Tables, Data Elements, Domains, Matchcodes, Views

ABAP/4 Programs

Reports, Module Pools, Function groups

Screens

Menus

Enterprise Data Models

The object listed above are managed by version ,therefore they are included in the modification adjustment.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 821: Sap Abap Refresher Course NoRestriction

Modifications

Modification Adjustment

The modification adjustment for Dictionary objects is done during the release change. Other Repository objects are adjusted after the release change.change.

A Dictionary adjustment after the release change would result in the loss of new custom fields.

The Dictionary adjustment is done with transaction SPDD, the adjustment of the remaining Repository objects with transaction SPAU.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 822: Sap Abap Refresher Course NoRestriction

Modifications

Rules for Modifications

Use the following rules when modifying or adjusting:

Try to concentrate the changes in one place ( possibly by using I l d ithi th t )Includes within the customer name range).

The workbench Organizer does not allow modifications by DDIC and SAP*.

Release open repairs and open requests containing repair objects prior to the release change. Such repairs and requests will be pointed out to your during the upgrade.pointed out to your during the upgrade.

Never create custom programs within the SAP name range. You will find the customer name range in the SAP Style Guide.

Avoid modification adjustments by avoiding modifications.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 823: Sap Abap Refresher Course NoRestriction

Modifications

Avoiding the Adjustmentsg j

Try to avoid changing SAP objects to prevent the necessity for modification adjustments.

By using program enhancements and appends for SAP tables you can enhance SAP object without having these changes overwritten by SAP during an upgrade.

To avoid manual patches ,SAP offers online correction services in release 3.0 which allow automatic implementation and deimplementation of hot packages and patches

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 824: Sap Abap Refresher Course NoRestriction

Summary

Summary

There are four ways of modifying the standard system.

Customizing

Modifications

Enhancement Concepts

Custom Development

The advantages of enhancements are

They do not affect standard SAP source code

They do not affect software updates

Enhancements can be achieved by ExitsEnhancements can be achieved by Exits.

There are three types of Exits.

Menu Exits

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Menu Exits

Screen Exits

Page 825: Sap Abap Refresher Course NoRestriction

Summary

Function Module Exits

Registering the Modifications in SAP Software Change Registration (SSCR).

P d f R i t d M difi tiProcedure for a Registered Modification.

Rules for modifications or adjusting.

Avoid the adjustment using the program enhancements for SAP tablesAvoid the adjustment using the program enhancements for SAP tables.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 826: Sap Abap Refresher Course NoRestriction

Exercise

Exercise

Create a menu exit SDW00003 in the area menu ‘TEST’ and add an user-defined report for that menu exit.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 827: Sap Abap Refresher Course NoRestriction

Exercise

Solution

Follow the steps mention in the step-by-step process of creating the menu exits.

F th it SDW00003 T ti d DW3 i d fi dFor the menu exits SDW00003, Transaction code +DW3 is predefined. Now go to transaction SE80 and select the user-defined report say for example : ZTEST56.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 828: Sap Abap Refresher Course NoRestriction

Exercise

For the particular report create the transaction as shown in the picture.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 829: Sap Abap Refresher Course NoRestriction

Exercise

Mention the transaction code that is predefined by the menu exit and mention the short text, highlight the Program and selection screen radiobutton and press enter.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 830: Sap Abap Refresher Course NoRestriction

Exercise

Assign report ZTEST55 to the transaction +DW3 and save it.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 831: Sap Abap Refresher Course NoRestriction

Exercise

Go to the transaction S001 and go the menu TEST, there you can find USER DEFINED REPORTS menu item. Click the menu item and it will take you to the output of the report.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 832: Sap Abap Refresher Course NoRestriction

Exercise

Output for the report ZTEST56 executed through the transaction +DW3.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 833: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 834: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 835: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 836: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 837: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 838: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 839: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

St t f B i Obj tStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

T h i l St f BAPI C tiTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 840: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 841: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 842: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 843: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and Innovation

Page 844: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Microsoft Word DocumentDocument

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 845: Sap Abap Refresher Course NoRestriction

10. ADDITIONAL TOPICS : BAPI & BUSINESS OBJECTS

Introduction to BAPI & BAPI Usage

Structure of Business ObjectsStructure of Business Objects

Important Transaction codes

BAPI Creation

Understanding Business Requirements before BAPI Creation

Technical Steps for BAPI CreationTechnical Steps for BAPI Creation

List of Macros

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 846: Sap Abap Refresher Course NoRestriction

SAP Smart FormsSAP Smart Forms

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 847: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Objectives

About SAP Smart Forms

D i i S t FDesigning Smart Forms

Writing Programs for Smart Formsg g

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 848: Sap Abap Refresher Course NoRestriction

SAP Smart Forms

•Introduction to Smart Forms

•Structure of a form

•Windows•Windows

•Architecture

•Forms

•Nodes

•Form Painter

•Table Painter

•PC Editor

•Style Builder

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Style Builder

•Driver Program

Page 849: Sap Abap Refresher Course NoRestriction

SAP Smart Forms

What is SAP Smart Forms?

• SAP Smart Forms is introduced in SAP Basis Release 4.6C as the tool for creating and maintaining forms for mass printing in SAP Systems.

SAP S t F ll t t i l difi ti t th f d i• SAP Smart Forms allow you to execute simple modifications to the form and in the form logic by using simple graphical tools.

• Besides using the printer for standard output you can also select the Internet g p p y(by using a generated HTML output), a fax, or e-mail as output medium.

• Transaction to start SAP Smart Forms : SMARTFORMS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 850: Sap Abap Refresher Course NoRestriction

SAP Smart Forms

SAP Smart Forms offers the following advantages:

Advantagesg g

• The adaptation of forms is supported to a large extent by graphic tools for layout and logic, so that no programming knowledge is necessary (at least 90% of all adjustments). Therefore, power user forms can also make configurations for your business processeswith data from an SAP system.

• Displaying table structures (dynamic framing of texts)

• Output of background graphics for form design in particular the use of templates which• Output of background graphics, for form design in particular the use of templates which were scanned.

• Colored output of texts

• Reusing Font and paragraph formats in forms (Smart Styles)

• Data interface in XML format (XML for Smart Forms, in short XSF)

• HTML output of forms (Basis release 6.10)

• Interactive Web forms with input fields, pushbuttons, radio buttons, etc. (Basis-Release 6.10)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 851: Sap Abap Refresher Course NoRestriction

SAP Smart Forms

A form consists of:

Structure of a Form

•pages•output areas – called “windows”•Addressesgraphics (such as company logo)•graphics (such as company logo)

•data or text contents.

Within an output area, you can use static or dynamic tables to display data or texts p y y p yin lines, columns, or cells.

To further structure and format text and data, use paragraphs with the paragraph and character formatsand character formats.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 852: Sap Abap Refresher Course NoRestriction

SAP Smart FormsOn the pages of a form you determine the page layout and the sequence of pages with different structures

Pages of a form

with different structures.

Draft pages and print pages:You use a draft page to determine the layout and the contents of one or several p g yprint pages. In SAP Smart Forms, you use the Form Builder to define draft pages.

Print pages are those pages that are eventually printed. The page layout includes the page format (for example DIN A4 Letter DIN A5 landscape) and the position ofthe page format (for example, DIN A4, Letter, DIN A5 landscape) and the position of the windows on a page.

For each draft page, you must specify a next page to make the page sequence clear. You can also repeatedly call the same draft page if you want recursive output.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 853: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Pages of a form

Many forms contain only two pages of different structure, for example one for the letter and one for listing the invoice items. For such a form you need two draft pages; the second page, which is defined as next page of the first one calls itself as next page If the text does notwhich is defined as next page of the first one, calls itself as next page. If the text does not entirely fit onto the second print page, another print page with identical structure is started automatically.

For draft page 2 the page break is triggered either automatically by the main window or built

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

For draft page 2, the page break is triggered either automatically by the main window or built into the form logic.

Page 854: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Windows

O th t diff t t f t t f t t d d t thOn a page, there are two different types of output areas for texts and data: the main window and the secondary window.

You can position windows anywhere on a page, even overlapping.You can position windows anywhere on a page, even overlapping.

You can position the same window (determined by the technical name on several pages of a form, so that the same contents are displayed on all these pages.

You can choose a different size for the window on each page, except for the main window.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 855: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Main Window

In a main window you display text and data, which can cover several pages (flow text). As soon as a main window is completely filled with text and data, the system continues displaying the text in the main window of the next page. It automatically triggers the page break.triggers the page break.

You can define only one window in a form as main window.

Th i i d t h th idth h b t diff i h i htThe main window must have the same width on each page, but can differ in height.

A page without main window must not call itself as next page, since this would trigger an endless loop. In such a case, the system automatically terminates after gg p , y ythree pages.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 856: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Secondary Windows

In a secondary window you display text and data in a predetermined output area.

There is no flow text display with page break. If you position a secondary window ith th l th t di l th t t f thiwith the same name on several pages, the system displays the contents of this

secondary window on each page.

Text and data that do not fit into the secondary window are truncated and not ydisplayed.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 857: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Architecture

The architecture of SAP Smart Forms separates application data retrieval from the actual definition of the formWhen you activate the Smart Form, the system generates a function moduleWhen you activate the Smart Form, the system generates a function module that encapsulates all attributes of the Smart Form. As soon as the application program calls the function module, the Smart Form uses the module's interface (which corresponds to the form interface) to transfer any table data previously

l t d d t i t th f di t th f d i ti Thi i l

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

selected and to print the form according to the form description. This is also referred to as 'calling a Smart Form for printing'.

Page 858: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Creating and Printing Forms

When creating a form, you must:• Retrieve the application data. • Describe your form. • Pass the application data to the formPass the application data to the form.

Printing the Form:Call a function module generated by SAP Smart Forms to print your form.

SAP Smart Forms supports the following output options:• The form is printed on a printer connected to the SAP System. Before

printing, use the print preview to check whether the form is correct. p g, p p• The function module generates an XSF data stream that transfers, for

example, the form description including the retrieved data to programs of third-party companies.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 859: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Describing a Form

1. Describe the interface of the form. It results from the application data previously selected.

2 Create one or more pages On a page you can position windows addresses2. Create one or more pages. On a page, you can position windows, addresses, and graphics. Within a window, you can create additional elements.

3. Create elements (text, graphics, tables, and so on) for each page, using other tools of the Form Builder: * Use the Form Painter to position windows, graphics, and addresses on a

page (the other elements are displayed in an assigned window). * Use the PC Editor to write your texts. * Use the Table Painter to format your tables Use the Table Painter to format your tables.

4.Use the flow control to control whether and when to print pages and elements

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 860: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Form Attributes

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 861: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Form InterfaceWe define the form interface to pass the data to the form. In the form interface we can define import and export parameters, tables and exceptions.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 862: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Global Definitions

Global definition apply for the entire form We can use any object defined thereGlobal definition apply for the entire form. We can use any object defined there in all nodes of the tree.

We can initialize the global data before we start processing the start page. Withi th f ti t l b l d t l li itlWithin the form routines we cannot access any global data unless we explicitly pass them to the form routine interface.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 863: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Global Definitions

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 864: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Form logic

I th F B ild d ib S t F b t f d T d thiIn the Form Builder you describe a Smart Form by a set of nodes. To do this, you build up a tree structure on the left side of the user interface

The numbering of the nodes also shows the sequence in which they are

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

The numbering of the nodes also shows the sequence in which they are processed (from top to bottom). The first node is the root node.

Page 865: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Nodes in Smart Forms

P•Page•Window•Text•Graphicp•Template•Table•Command•Loop•Loop•Alternative•Folder•Complex Section•Program Lines

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 866: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Node Types - 1

O t t AOutput AreasNode type Description Possible direct

successorsPage A page of the form. Direct successors of this node can Window, graphic,

Window Output area on a page. There are main windows and subwindows.

All except window and page nodes

be placed directly on the page. address

Elementary nodes (without successors)Node type DescriptionText You use this node to print any texts (and table contents), except addresses.p y ( ), p

Graphic You use this node to position graphics in the form. To include background graphics, use node type Page .

Address You use this node to include an address. The system reads the address data directly from the database tables and formats them for print outputthe database tables and formats them for print output.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 867: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Node Types - 2 Table outputab e output

Icon Node Type Description Possible Directly Inferior Nodes

Template You use this node to print a table with All except window,Template You use this node to print a table with fixed layout

All except window, page, table, and template nodes

Table You use this node to print a table with dynamic layout

Directly inferior nodes are automatically thedynamic layout are automatically the three nodes Header , Main Area and Footer . As their directly inferior nodesdirectly inferior nodes, loop nodes, folder nodes, or table nodes are allowed.

Table line You use this node to print a table line in a table or template

Table cell

Table cell You use this node to print a table cell of a table line according to the line type

As with the template node

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

a table line according to the line type node

Page 868: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Node Types - 3Flow Control

Node type Description Possible direct successors

Command Executes special commands (next page, paragraph numbering, printer control)

(no successor)

Loop Processes successor node repeatedly. All except window and page nodes

Alternative Branches depending on condition. Direct successors are automatically the nodes TRUE and FALSE. The direct successors of these are all nodes except window and page nodes.

Other NodesN d t D i ti P ibl di tNode type Description Possible direct successors

Folder Combines successor nodes to logical groups

All except window and page nodes

Complex section Combines all attributes of the node types template, table, loop, folder

All except window and page nodes

Program lines Executes ABAP program code (for (no successors)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

example, conversion routines).

Page 869: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Tools in Smart Forms

F P i t•Form Painter

•Table Painter

•PC Editor

•Navigation Tree

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 870: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Form Painter

U d t d i th l t f th S t F•Used to design the layout of the Smart Form •Used to create and change the size of the windows •Add graphical images

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 871: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Table Painter

D i d l•Drawing rows and columns

•Inserting , cutting ,copying and deleting lines

•Deleting cells

•Splitting cells

•Selecting table patterns

•Changing cell size and moving cell separator lines

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 872: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Table Painter

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 873: Sap Abap Refresher Course NoRestriction

SAP Smart Forms PC Editor

•Enter delete select cut and copy textsEnter, delete, select, cut, and copy texts •Assign paragraph and character formats •Include, change, and delete fields

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 874: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Inserting Addresses

In many applications addresses are administered using the Business AddressIn many applications, addresses are administered using the Business Address Services (BAS).

The addresses are stored in the database tables of the central address administration and identified by the application via a number.

Procedure1.Create a node of type Address in the navigation tree of the Form Builder. 2.Create the address node as directly inferior node of the page node or use the2.Create the address node as directly inferior node of the page node or use the

context menu in the layout of the Form Painter. You can then position the address anywhere on the page.

3.Enter a unique name for the node and a description4 D t i th dd t th G l Att ib t t b4.Determine the address type on the General Attributes tab.

For organization addresses you must specify only an address number. For any other address types, you must specify a person number and an address yp , y p y pnumber. To do this, use the search help.

In the box Additional Address Specifications you can maintain other attributes to specify how you want to display the address.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 875: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Inserting Addresses - Illustration

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 876: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Including Fields in the PC Editor

Y i l d fi ld ( fi ld d t fi ld ) t di l i bl d t i thYou include fields (your own fields and system fields) to display variable data in the form. The field serves as placeholder. When the system displays the form, it replaces the field with the value that was assigned to it during processing.

PrerequisitesIf you use your own fields, you must have defined them either as global data or as parameters in the form interface.The text node into which you want to include a field must existThe text node into which you want to include a field must exist.

Process:1.Include field ( ) to include a defined field into the text( )2.A dialog window appears. Enter the field name in a line. Make sure that the field name is enclosed in ampersands ('&').

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 877: Sap Abap Refresher Course NoRestriction

SAP Smart Forms System Fields

Field NameDescription

&SFSY-DATE& Displays the date. You determine the display format in the user master record.&SFSY-TIME& Displays the time of day in the form HH:MM:SS.&SFSY-PAGE& Inserts the number of the current print page into the text. You determine the format of the page

number (for example Arabic numeric) in the page nodenumber (for example, Arabic, numeric) in the page node.&SFSY-FORMPAGES& Displays the total number of pages for the currently processed form. This allows you to include

texts such as ‘Page x of y’ into your output.

&SFSY-JOBPAGES& Contains the total page number of all forms in the currently processed print request. &SFSY-WINDOWNAME& Contains the name of the current window (string in the Window field)&SFSY-PAGENAME& Contains the name of the current page (string in the Page field)&SFSY-XSF& Smart Forms sets this flag ( SFSY-XSF = 'X' ), if you want to print the form in XSF format

or HTML format On the Conditions tab of a node you can use this field to suppressor HTML format. On the Conditions tab of a node, you can use this field to suppress output that is intended only for these output formats (for example, pushbuttons).

&SFSY-COPYCOUNT& Queries whether the original is printed or which number the copy has. COPYCOUNT = 1 : orginal, COPYCOUNT = 2 : first copy; COPYCOUNT = 3: second copy, and so on.

&SFSY-COPYCOUNT0& Queries whether the original is printed or which number the copy has. COPYCOUNT = 0 :Queries whether the original is printed or which number the copy has. COPYCOUNT 0 : orginal, COPYCOUNT = 1 : first copy; COPYCOUNT = 2 : second copy, and so on.

SFSY-SUBRC Return value that you can query in program lines nodes. This enables you to react dynamically to error situations during output. Up to now, this field can be used only for include texts and text modules:

T t d l i l d t t f d d i t d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

•SFSY-SUBRC = 0 :Text module or include text found and printed •SFSY-SUBRC = 4 :Text module or include text not found

SFSY-USERNAME Logon name of the user who prints the form.

Page 878: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Tabular Data LayoutYou can use the following node types for tabular data layout:

•The template node. Templates are static because the number of columns and lines are determined before the actual output.

•The table node. Tables are dynamic because the table size depends on the amount of data selected at runtime.

To specify the layout of both node types, use line types.

Line Types:You use the line type to describe the following attributes of a table line:You use the line type to describe the following attributes of a table line:•The width of the table line •The number and width of individual cells within the table line

A major difference between line types of templates and line types of tables lies in the height: •line types of templates all have the same height, •while SAP Smart Forms determines the height of table lines dynamically

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

•while SAP Smart Forms determines the height of table lines dynamically (depending on the output in the table).

Page 879: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Style Builder

Use Transaction Code SMARTSTYLES to maintain paragraph and characterUse Transaction Code SMARTSTYLES to maintain paragraph and character formats.

A Smart Style contains•Header data containing the default values of a Smart Style •Paragraph formats including indents and spacing, font attributes, tabs, and outline and numbering •Character formats including effects (superscript, subscript),Character formats including effects (superscript, subscript), bar-code and font attributes •Colors and underlines for a paragraph or character format •Preview

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 880: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Style Builder

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 881: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Driver Program

REPORT ZSALES PRINT NO STANDARD PAGE HEADINGREPORT ZSALES_PRINT NO STANDARD PAGE HEADING.

DATA FLAG(1).DATA: FORM NAME(30) VALUE 'ZSALES PRINT'._ ( ) _DATA: FM_NAME TYPE RS38L_FNAM.

PARAMETERS: VBELN LIKE VBAK-VBELN OBLIGATORY,KUNNR LIKE VBAK KUNNR OBLIGATORYKUNNR LIKE VBAK-KUNNR OBLIGATORY.

DATA: BEGIN OF ZITAB OCCURS 0.INCLUDE STRUCTURE VBAP.

DATA: END OF ZITAB.

DATA ZITAB1 LIKE ZITAB OCCURS 0 WITH HEADER LINE.DATA: SVBELN TYPE DDSHRETVALDATA: SVBELN TYPE DDSHRETVAL.TABLES: VBAK, VBAP.

START-OF-SELECTION.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

SELECT SINGLE * FROM VBAK WHERE VBELN = VBELNAND KUNNR = KUNNR.

Page 882: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Driver Program

SELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ZITABSELECT * FROM VBAP INTO CORRESPONDING FIELDS OF TABLE ZITABWHERE VBELN = VBAK-VBELN .

CALL FUNCTION 'SSF FUNCTION MODULE NAME'_ _ _EXPORTING

FORMNAME = FORM_NAMEIMPORTING

FM NAME = FM NAMEFM_NAME = FM_NAME.

CALL FUNCTION FM_NAMEEXPORTING

VBELN = VBELNKUNNR = KUNNRFLAG = FLAGFLAG = FLAG

TABLESZITAB = ZITABZITAB1 = ZITAB1.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 883: Sap Abap Refresher Course NoRestriction

SAP Smart Forms

Example Forms Available in Standard SAP R/3

SF_EXAMPLE_01 Simple example; invoice with table output of flight booking for one customer

SF_EXAMPLE_02 Similar to SF_EXAMPLE_01 but with subtotals

SF EXAMPLE 03SF_EXAMPLE_03 Similar to SF_EXAMPLE_02, whereby several customers are selected in the application program; the form is called for each customer and all aform outputs are included in an output request

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 884: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Frequently Asked questions

Forcing a page break within table loopForcing a page break within table loop

Create a loop around the table. Put a Command node before the table in the loop that forces a NEWPAGE on whatever condition you want. Then only loop through a subset of the internal table (based on the conditions in the Command node) of the elements in the Table node.

Font style and Font size

Goto Transaction SMARTSTYLES. There you can create Paragraph formats etc just like in sapscript. Then in your window under OUTPUT OPTIONS you include this SMARTSTYLE and use the Paragraph and character formats.

Line in Smartform

Either you can use a window that takes up the width of your page and only has a height of 1 t e you ca use a do t at ta es up t e dt o you page a d o y as a e g t omm. Then you put a frame around it (in window output options). Thus you have drawn a box but it looks like a line. Or you can just draw "__" across the page and play with the fonts so that it joins each UNDER_SCORE.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 885: Sap Abap Refresher Course NoRestriction

SAP Smart Forms Frequently Asked questions

Difference between 'forminterface' and 'global definitions' in global settings of smart formsforms

The Difference is as follows.

Form Interface is where you declare what must be passed in and out of the smartform (in from the print program to the smartform and out from the smartform to the print program).

Global definitions is where you declare data to be used within the smartform on a global scope ie: anything you declare here can be used in any other node in the formscope ie: anything you declare here can be used in any other node in the form.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 886: Sap Abap Refresher Course NoRestriction

Sap Script

SAP ScriptSAP Script

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 887: Sap Abap Refresher Course NoRestriction

INTRODUCTION

Sap Script

SAP Script is the SAP System's own text-processing system.Also calledas Word processing tool of SAP.

SAP Script is tightly integrated into the SAP System

Note:Entering and formatting text in SAP script is a little bit different than traditional text-processing programs on a PC. p g p gThe main difference: the text that you enter is not in its final format. SAP script applies your formatting to text only when a documentis printed, print-previewed, or displayed on-line in the SAP System

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 888: Sap Abap Refresher Course NoRestriction

How does a SAP Script work ?

Sap Script

Every Script has a driver / print program attached or calling it.

In case you are creating an entirely new script you also need to createIn case you are creating an entirely new script ,you also need to create the driver program.

This program can be executed directly or attached to attached to certainThis program can be executed directly or attached to attached to certainevents viz. Creation of Purchase Order , Sales Order , Hiring an Employee.

Standard SAP scripts can be modified by copying them in the customerp y py gname space and making the required chnages.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 889: Sap Abap Refresher Course NoRestriction

Components of a SAP Scripts

Sap Script

Components of a SAP Scripts

1. Standard TextThis is like a normal document.You can create letters , articles bascially, yany static text.This can be created from transaction SO10.

2. Layout SetThis also called as Form created from Transaction SE71.

3 P i t P3. Print ProgramThis program retrieves desired data from the database , calls the Form,supplies data to the Form and finally closes the Layout Set ( Form ).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 890: Sap Abap Refresher Course NoRestriction

S li

Sap Script

Driver Program Layout set Gets printed

Suppliesdata

Defines

Forms

SapScriptScript

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 891: Sap Abap Refresher Course NoRestriction

Name

Sap Script

NameHouse namePostal CodeCity

WINDOW

City

NNameHouse namePostal CodeCity Page windowCity Page window

Particular area in the page where the windowis printed o tis printed out

Page

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 892: Sap Abap Refresher Course NoRestriction

SAP Script : Standard Text

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Transaction SO10

Page 893: Sap Abap Refresher Course NoRestriction

After creating a Standard Text assign it a Style.

SAP Script : Standard Text

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 894: Sap Abap Refresher Course NoRestriction

If you want text in your standard text to appear as per attributes ofcharacter string , you need to enclose the text <character string>TEXT</>.

SAP Script : Standard Text

character string , you need to enclose the text <character string>TEXT</>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 895: Sap Abap Refresher Course NoRestriction

OBJECTS OF LAYOUT SET

SAP Script : Layout Set

• Header

• Paragraph and Character format• Paragraph and Character format

• Windows and Text Elements

• Pages

• Page Windowsg

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 896: Sap Abap Refresher Course NoRestriction

Header data is found both in style and layout set maintenance. In style

SAP Script : Header

maintenance, it is used primarily to present information designed to make it easier for the end user to select a style.

Th h d d t i l t t i t th th h d i d fThe header data in layout set maintenance, on the other hand, is used for information and control purposes.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 897: Sap Abap Refresher Course NoRestriction

SAP Script : Header

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGHEADER INFORMATION GLOBAL DATA

Page 898: Sap Abap Refresher Course NoRestriction

I SAP S i t h f tt d i f t d th i

SAP Script : Paragraph

In SAP Script, paragraphs are formatted using formats and their corresponding attributes. Word processing is simplified by the use of different paragraph attribute groups:

• Standard

• FontFont

• Tabs

• Outline

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 899: Sap Abap Refresher Course NoRestriction

SAP Script : Paragraph

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGParagraph Format

Page 900: Sap Abap Refresher Course NoRestriction

SAP Script : Character Format

Character formats • Allow you to format entire blocks of text within a paragraphy p g p

•Which will override the paragraph format

•Character formats are defined in character strings

Eg: <B1> &VBDKA-TDNAME& ,, &VBDKA-TFGEU&</>

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 901: Sap Abap Refresher Course NoRestriction

WINDOWS

SAP Script : Windows and Text Elements

We can combine information contained in a document into certain groups and make each group appear on the printed page in an individual area. SAP Scripts calls such a group a window

• To refer a window via program each window must have a unique nameW i t t t h i d i t t l t• We can assign text to each windows via text elements

TEXT ELEMENTS

Text elements can be defined in layout set maintenance for each window. The text elements are accessed by name by a print program, formatted, and output in the respective window. The /E in the tag column is used toand output in the respective window. The /E in the tag column is used to identify the text as a text element

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 902: Sap Abap Refresher Course NoRestriction

Wi d d fi d i l t t i t Th t

SAP Script : Windows

Windows are defined in layout set maintenance. They represent areas which are positioned on pages -- as page windows -- and in which text is later output. At least one window must be defined for each layout set. If not a text cannot be formatted by SAP ScriptIf not, a text cannot be formatted by SAP Script.

The following window types can be used: • mainmain • variable• constant

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 903: Sap Abap Refresher Course NoRestriction

SAP Script : Windows

WINDOWS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 904: Sap Abap Refresher Course NoRestriction

MAIN

SAP Script : Windows

MAINMain window in which continuous text is output. The text in the main window can extend over several pages. If the text fills one page, output continues in the window of the next and subsequent pages, as long ascontinues in the window of the next and subsequent pages, as long as MAIN has been defined for these pages.

VAR Window with variable contents. The text can vary on each page in which the window is positioned. Variable windows are formatted for each page.

CONST Window with constant contents which is only formatted once.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 905: Sap Abap Refresher Course NoRestriction

At least one page must be defined for every layout set. You must also

SAP Script : Pages

t east o e page ust be de ed o e e y ayout set ou ust a sodesignate a "first" page in the layout set header. Otherwise text formatting is not possible.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 906: Sap Abap Refresher Course NoRestriction

PAGES

SAP Script : Pages

PAGES

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 907: Sap Abap Refresher Course NoRestriction

Wh d fi i d th i d li k d t

SAP Script : Page Windows

When you define page windows, the window names are linked to page names. To do this, you need to specify the position and size of the window on the assigned page.

Width of the main window must be the same on all pages.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 908: Sap Abap Refresher Course NoRestriction

Sap ScriptSAP Script : Page Windows

PAGE WINDOWS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 909: Sap Abap Refresher Course NoRestriction

Sap Script

COMPONENTS OF SCRIPT

• Text ElementsText Elements

• Style

• Layout set

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 910: Sap Abap Refresher Course NoRestriction

The text elements are related to a window . Th i t ll th ti t t l t f th i d

SAP Script : Text Elements

The print program calls the respective text elements of the window

TYPES OF TEXT ELEMENTS

•TEXT ELEMENTS WITH OUT NAMES

•TEXT ELEMENTS WITH NAMETEXT ELEMENTS WITH NAME

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 911: Sap Abap Refresher Course NoRestriction

SAP Script : Text Elements

NAMED TEXT ELEMENTS

• We recognize named text elements by paragraph format /EWe recognize named text elements by paragraph format /E

• The name can be up to 40 characters

• The different windows can have same named text elements

• To out put named text elements we have to call the function moduleWRITE_FORM

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 912: Sap Abap Refresher Course NoRestriction

A style defines the set of paragraph and character formats that are

SAP Script : Style

sty e de es t e set o pa ag ap a d c a acte o ats t at a eavailable for formatting a document.

If a style is selected, then it provides the character and paragraph formats for your document. Any formats defined in the layout set selected for a document are then ignored.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 913: Sap Abap Refresher Course NoRestriction

• Layout sets are used to control the page layout and also the text

SAP Script : Layout Set

formatting in your documents.

• If a document is formatted for output to the screen or to a printer, then al t t t b ifi d f itlayout set must be specified for it.

• If no other layout set is specified for a document, then the SYSTEMlayout set is assigned to the document by defaultlayout set is assigned to the document by default.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 914: Sap Abap Refresher Course NoRestriction

LAYOUT SET CONTROL

SAP Script : Layout Set

LAYOUT SET CONTROL

OPEN_FORM - Initializes the SAP script composer and opens the specified layout setp y

CLOSE_FORM - Closes the layout set ( if close_form is missing in the program nothing will be printed)

WRITE_FORM ,WRITE_FORM_LINES, CONTROL_FORM - To output data( this can be used as many times

between OPEN_FORM and CLOSE_FORM)

PAGE CONTROL IN LAYOUT SETS•STATIC DEFINITION- Specify the starting page in header and for each

page specify the subsequent pagepage specify the subsequent page

•DYNAMIC DEFINITION - Specify START PAGE when you call START FORM

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

START_FORM

Page 915: Sap Abap Refresher Course NoRestriction

SAP Script : Symbols

SYMBOLS

Symbols are constants that can be inserted in a document. They save the k h l i ti f t t h tuser unnecessary work when replacing sections of text, phrases, etc.

Possible symbol types are:• System symbols y y

• Standard symbols

• Program symbols

• Text symbols.Text symbols.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 916: Sap Abap Refresher Course NoRestriction

THE SYNTAX OF SYMBOLS

SAP Script : Symbols

THE SYNTAX OF SYMBOLS

• The delimiter & must be used both immediately before and after the symbolsymbol.

•The name of a symbol may not contain spaces.

• A SAP Script editor line break should not occur between the symbol delimiters.

• If additional formatting options are required, these should be enclosedin round brackets and inserted immediately after the symbol name.

• The code letters identifying these options must be given in capitals.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 917: Sap Abap Refresher Course NoRestriction

SYSTEM SYMBOLS

SAP Script : Symbols

S S S O S

SAP script provides values for the system symbolsExample &date& &time& &month& &year& &uline& &vline& &page&

STANDARD SYMBOLS

St d d b l d fi d i th TTDTG t bl• Standard symbols are defined in the TTDTG table.• This table contains both the name of each symbol and its value.• The value, which is language-dependent, can contain up to 60 chars. • This table is delivered complete with standard entries supplied by SAP• This table is delivered complete with standard entries supplied by SAP. • It may be extended with customer-specific symbols

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 918: Sap Abap Refresher Course NoRestriction

Symbols

PROGRAM SYMBOL

SAP Script cannot read this data out of the SAP database itself, but has to ll th t d thi Th d t th i d i t kcall on another program to do this. The data are then copied into work

areas declared using TABLES. If SAP Script is now called from this program in order to format a text, it can copy the data out of these work areasareas.

Symbols which obtain their values from this kind of data area are called program symbols.program symbols.

Note• The value of a program symbol is limited up to a maximum of 255 chars. p g y p

• The name of a program symbol consists of the table name and the fieldname separated by a hyphen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 919: Sap Abap Refresher Course NoRestriction

TEXT SYMBOLS

SAP Script : Symbols

S O S

All symbols which do not correspond to one of the three types of symbol described above are text symbols. You define the value of a text symbol yourself in the text module.

There are two ways of doing this: U th t i i th t t dit• Use the menu entries in the text editor

• Use the control command DEFINE

for e gfor e.g/: DEFINE &mysymbol& = ‘XXXX’/ &mysymbol&/: DEFINE &mysymbol& = ‘YYYY’/: DEFINE &mysymbol& YYYY/ &mysymbol&

would print XXXX

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

would print XXXXYYYY

Page 920: Sap Abap Refresher Course NoRestriction

Control Command is a type of SAP script command which are used to

Control Commands

Control Command is a type of SAP script command which are used to control output formatting.

The Syntax of Control CommandsThe Syntax of Control Commands• The paragraph format /: must be entered in the format column to

identify a control.

• You enter the command itself in the text line.

• A control command, together with any parameters it requires, may not occupy more than a single line

• A maximum of one control command may appear in each line

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 921: Sap Abap Refresher Course NoRestriction

Control Commands

SYNTAX OF CONTROL COMMANDS

• In tag column, indicate control commands with paragraph format /:

• Enter complete control commands and necessary parameters on one line

• Enter only one control command per line

• Editor formatting does not affect lines with control commands

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 922: Sap Abap Refresher Course NoRestriction

SOME IMPORTANT CONTROL COMMANDS:

Control Commands

SOME IMPORTANT CONTROL COMMANDS:

/: NEW-PAGE

/: PROTECT & /: ENDPROTECT

/: SET DATE MASK = 'date_mask’

/: SET TIME MASK = 'time_mask’

/ RESET h f t/: RESET paragraph_format

/: INCLUDE name [OBJECT o] [ID i] [LANGUAGE l ][PARAGRAPH p] [NEW-PARAGRAPH np]

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

(Cont….. Next page)

Page 923: Sap Abap Refresher Course NoRestriction

Control Commands

/: TOP:

/: ENDTOP

/: BOTTOM :

/: ENDBOTTOM

/: IF condition :

/: ENDIF

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 924: Sap Abap Refresher Course NoRestriction

SET DATE MASK command

Control Commands

The formatting for date fields can be defined with the SAPscript SET DATE MASK command. Executing this command causes all subsequent date fields to be output using the specified formattingsubsequent date fields to be output using the specified formatting.

Syntax/: SET DATE MASK = 'date mask'/: SET DATE MASK date_mask

The following templates may be used in the date mask: For day : DD / DDD / DDDDyFor month : MM / MMM / MMMMFor year : YY / YYYY

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 925: Sap Abap Refresher Course NoRestriction

SET TIME MASK command

Control Commands

You can use the SAPscript SET TIME MASK command to format time fields in a way that differs from the standard setting. Executing this command causes all subsequent time fields to be output using thecommand causes all subsequent time fields to be output using the specified formatting.

Syntax:Syntax:/: SET TIME MASK = 'time_mask'

The following templates may be used in the time mask: g p yHH hours (two digits) MM minutes (two digits) SS seconds (two digits)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 926: Sap Abap Refresher Course NoRestriction

BOXES LINES SHADING: BOX POSITION SIZE

Control Commands

BOXES, LINES, SHADING: BOX, POSITION, SIZE

The BOX, POSITION and SIZE commands for drawing boxes, lines and shadowing can be used for specifying that within a layout set particularshadowing can be used for specifying that within a layout set particular windows or passages of text within a window are to be output in a frame or with shadowing.

Syntax1. /: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME] [INTENSITY]2. /: POSITION [XORIGIN] [YORIGIN] [WINDOW] [PAGE]3. /: SIZE [WIDTH] [HEIGHT] [WINDOW] [PAGE]

.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 927: Sap Abap Refresher Course NoRestriction

ADDRESS

Control Commands

ADDRESS

The command formats an address according to the postal standardsof the destination country defined in the parameter COUNTRYof the destination country defined in the parameter COUNTRYsap scripts calls function module ADDRESS_INTO_PRINTFORMto format the address/: ADDRESS[DELIVERY] [PARAGRAPH a] [PRIORITY p] [LINES l][ ] [ ] [ p] [ ]/: TITLE title/: NAME name1[,name 2[,name 3[,name 4]]]/:STREET street/:POBOX po box[CODE zip code]/:CITY town1[,town 2]/:REGION region/ COUNTRY t/:COUNTRY country/: FROMCOUNTRY from country/: ENDADDRESS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 928: Sap Abap Refresher Course NoRestriction

Control Commands

BOTTOM /ENDBOTTOM

/:BOTTOM The te t lines bet een the t o commands are o tp t at the bottom ofThe text lines between the two commands are output at the bottom of MAIN window

/:ENDBOTTOM/:ENDBOTTOM

/:DEFINE &symbolname& = ‘value’

Text symbol receive their value through an explicit assignment. This assignment can be done interactively in the editor via include-symbols-text. The assigned value may have a maximum of 60 charactersg y

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 929: Sap Abap Refresher Course NoRestriction

Incorporating Graphics

For e.g Company Logo1. .bmp / .jpg file has to be converted to .tiff file

2. Upload the file as text module using ABAP/4 report “RSTXLDMC”specify BMON or BCOL

3 S t t t d f th t t3. System generates a suggested name for the texte.g ZHEX-MACRO-LOGO Use ID “ST” and logon language.

4 Include ZHEX MACRO LOGO object Text ID ST in the Layout4. Include ZHEX-MACRO-LOGO object Text ID ST in the Layout.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 930: Sap Abap Refresher Course NoRestriction

Example of Print Program

Calling an Script from a program created in SE38

REPORT ZSCRIPT .TABLES: SPFLI.DATA: I SPFLI LIKE SPFLI OCCURS 0 WITH HEADER LINEDATA: I_SPFLI LIKE SPFLI OCCURS 0 WITH HEADER LINE.SELECT * FROM SPFLI INTO CORRESPONDING FIELDS OF TABLE I_SPFLI.

CALL FUNCTION 'OPEN_FORM'EXPORTINGFORM = 'ZTEST11'.CALL FUNCTION 'WRITE_FORM'EXPORTINGELEMENT = 'HEADER_ITEM'

* FUNCTION = 'SET'TYPE = 'BODY'WINDOW = 'MAIN'.

(Contd Ne t Page)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

(Contd….. Next Page)

Page 931: Sap Abap Refresher Course NoRestriction

CALL FUNCTION 'WRITE_FORM'EXPORTING

Example of Print Program

EXPORTINGELEMENT = 'ADDRESS_LIST'

* FUNCTION = 'SET'TYPE = 'BODY'TYPE BODYWINDOW = 'WINDOW1'.

LOOP AT I_SPFLI.CALL FUNCTION 'WRITE_FORM'EXPORTINGELEMENT = 'LINE_ITEM'

* FUNCTION = 'SET'TYPE = 'BODY'WINDOW = 'MAIN'WINDOW = 'MAIN'.

ENDLOOP.CALL FUNCTION 'CLOSE_FORM'.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 932: Sap Abap Refresher Course NoRestriction

Example of Print Program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGOutput of the program

Page 933: Sap Abap Refresher Course NoRestriction

Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGDetails of Layout Set Header Data

Page 934: Sap Abap Refresher Course NoRestriction

Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGPages

Page 935: Sap Abap Refresher Course NoRestriction

Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGWindows

Page 936: Sap Abap Refresher Course NoRestriction

Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGPage Windows

Page 937: Sap Abap Refresher Course NoRestriction

Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMGMain Window Details

Page 938: Sap Abap Refresher Course NoRestriction

Formatting Options

Offset - specifying an offset of ‘n’ , n left most characters are not displayed.E g &s mbol& > 1234576789E.g &symbol& ---> 1234576789

&symbol+3& ----> 456789

Output Lengthp g&symbol(3)& ----> 123&symbol(7)& ----> 1234567

Time MaskTime Mask&Time&Normally 10:08:12

(hh) : (mm): (ss)

/: Set Time Mask = ‘HH:MM’&Time& = 10:08

/: Set Time Mask = ‘HH hours MM minutes’&Time& = 10 hours 08 minutes&Time(Z)& = 10 hours 8 minutes

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 939: Sap Abap Refresher Course NoRestriction

ExampleDate Mask/: Set Date Mask = ‘DDMMYY’/ Set ate as

&Date& = 01 05 01/: Set Date Mask = ‘MMMM DD,YYYY’

&Date& = May 01,2001

Fill CharacterLeading spaces in a value can be replaced with a fill character.The ‘F’ option is used and character to be filled is specified.p pE.g &KNA1-UMSAT& = 700.00

&KNA1-UMSAT(F*)& = **700.00

Space CompressionSpace Compression&symbol(C)&It has a effect of replacing each string of space characters with a single space andshifting the words to left as necessary to close up gaps.Also Leading spaces are completely removed.

Omitting Leading Zeros&symbol(Z)&

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

&symbol(Z)&&Day& = 01&DAY(Z)& = 1

Page 940: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

SAP Business Workflow: IntroductionSAP Business Workflow: Introduction

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 941: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

WfMC

• WfMC : The Workflow Management Coalition is the globally• WfMC : The Workflow Management Coalition is the globally recognized body for the advancement of workflow management technology and its use in industry.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 942: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Definition of Workflow

• According to WfMC Workflow is defined as the automation• According to WfMC , Workflow is defined as the automation of a business process , in whole or part , during which documents , information or tasks are passed from one participant to another for action according to a set ofparticipant to another for action , according to a set of procedural rules.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 943: Sap Abap Refresher Course NoRestriction

Wh i W kfl d d ?

ADDITIONAL TOPICS: SAP Business Workflow

When is Workflow needed ?It is particularly beneficial• when different people are involved in different parts of

the process • when the users need to be reminded of what they need to

ddo • when the duration of the process is critical and deadlines

have to be met

By automating the process, you free the users from having to know what to do when. Work items are sent to th ti i t tif i th f h t th h t dthe participants notifying them of what they have to do, and a single click on the notification calls the correct transaction and navigates to the relevant screen.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 944: Sap Abap Refresher Course NoRestriction

H d it k ?

ADDITIONAL TOPICS: SAP Business Workflow

How does it work ?• When the workflow runs it creates work items which are like

e mails bute-mails, buto they have the advantage that they contain the intelligence needed to

execute the relevant task with the correct data when the operational user executes them,

o they provide their own functionality so that the operational user has access to everything that is useful to improve the flow of the process,

o they disappear on their own when they have been executed by someone else or made obsolete.

• These work items can be received in the R/3 business workplace, MS Outlook (or any other MAPI compatible client), Lotus Notes, or work item notifications can be

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

distributed by e-mail.

Page 945: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Purpose of SAP Business Workflow• SAP Business Workflow can be used to define business processes that

are not yet mapped in the R/3 System. These may be simple release or approval procedures, or more complex business processes such as creating a material master and the associated coordination of the gdepartments involved.

• SAP Business Workflow is particularly suitable for situations in which work processes have to be run through repeatedly or situations in whichwork processes have to be run through repeatedly, or situations in which the business process requires the involvement of a large number of agents in a specific sequence.

• SAP provides several workflows that map predefined business processes . These workflows do not require much implementation

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 946: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Integration • SAP Business Workflow uses the existing transactions g

and functions of the R/3 System and does not change the functions. You can combine the existing functions of the R/3 System to form new business processes with SAPR/3 System to form new business processes with SAP Business Workflow. The workflow system takes over control of the business processes.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 947: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Technical Principles

• The definition and execution of Workflow can be divided into four main areas.

Business WorkplaceWorkflow BuilderTasksTasksBusiness Object Repository (BOR)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 948: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Technical Principles

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 949: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Technical Principles • BUSINESS WORKPLACE

o Work items are displayed to the user for execution in their SAP Inbox• WORKFLOW BUILDER

W kfl d fi iti d fi d hi h d f t th t t lo Workflow definitions are defined which are made up of steps that control the workflow or the tasks to be executed . This linking is defined in Workflow Builder .

• TASKSTASKS

o Tasks describe elementary business activities . They always refer to the method of the object . Tasks can be background tasks or dialog tasks .

• OBJECTS AND OBJECT TYPEOBJECTS AND OBJECT TYPE

o Object type describes the data with which you want to work in workflow , e.g. MATERIAL . Each Object type has methods in which activities are defined which can be executed with data e.g. creation of material .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

g

Page 950: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

General Procedure Model • With SAP Business Workflow, you can map business processesWith SAP Business Workflow, you can map business processes

in the R/3 System and process them (several times if required) under the control of the workflow system

A orkflo management s stem can process and monitor• A workflow management system can process and monitor structured processes that:

Contain a sequence of activities Reoccur in the same or similar forms Involve several people or groups of people Require a lot of coordinationRequire a lot of coordination

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 951: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

General Procedure Model • Process FlowProcess Flow

Objects and Object Typeo You identify all objects involved in your business process. y j y po You check whether the relevant object types with their methods, attributes

and events are defined in the Business Object Repository. If you find an object type whose definition meets your requirements, you can use it without making any modifications.If you find an object type whose definition does not quite meet your requirements, you extend its definition.If d fi d i bl bj d fi bjIf you do not find a suitable object type, you define your own object type.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 952: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

General Procedure Model • Process Flow

Tasks o You identify the tasks involved in your business process.

Y t bli h hi h bj t th d i t b t d f th t ko You establish which object method is to be executed for the task

Rules for Agent Determination o You identify possible agent rules in your business process .o You use these rules when agents are to be found using specific, business,

functionally-oriented criteria. EventsEvents

o You define the events used to initiate and control the Workflow.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 953: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

General Procedure Model

• Process Flow• Process FlowWorkflow

o To describe a business process create a workflow templateo To describe a business process , create a workflow template .o The tasks defined are to be included in the workflow template .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 954: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Demo Example • Process Flow• Process Flow

o An employee enters a notification of absence (leave request) in the R/3 System by filling out the relevant input template.

o The direct superior of the employee is responsible for approving or rejecting the notification of absence. The R/3 System determines the direct superior automatically on the basis of the

i ti l l i t i dorganizational plan maintained. o If the request is approved the creator is notified by mail: o If the request is not approved, the creator is informed and can

decide whether to withdraw the notification of absence or revise it. If the superior has given reasons for the rejection in an attachment, the creator can take these into consideration.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 955: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Demo Example • Process Flow• Process Flow

o If the creator revises the request, it is submitted to the superior for approval again. The applicant can also add an attachment,

hi h th b d b th iwhich can then be accessed by the superior. o This cycle is repeated until either the superior approves the

leave request or the creator withdraws it.o The applicant can find out the current processing status at any

time by looking in their workflow outbox.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 956: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Demo Example

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 957: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Roles in Workflow

Process Cons ltant• Process Consultant Person within the system of workflow roles who analyses the existing business processes, identifies those that are suitable for SAP Business Workflow and maps them onto a business process model.The process consultant is also responsible for the maintenance ofThe process consultant is also responsible for the maintenance of the organizational plan required for the workflow.Roles to be assigned

SAP BC SRV USERSAP_BC_SRV_USER SAP_BC_BMT_WFM_PROCESS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 958: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Roles in Workflow

Workflo De eloper• Workflow DeveloperPerson within the system of workflow roles who implements the workflow based on the business process model developed by the process consultant and using the SAP Business Workflow definition tools .

Roles to be assigned

SAP_BC_BMT_WFM_DEVELOPER

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 959: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Roles in Workflow

Workflo S stem Administrator• Workflow System AdministratorPerson within the system of workflow roles who is responsible for the technical maintenance of the development environment and the runtime behavior after automatic Customizing.

Roles to be assignedRoles to be assigned SAP_BC_ENDUSER SAP_BC_SRV_USER SAP BC BMT WFM ADMINSAP_BC_BMT_WFM_ADMIN

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 960: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Roles in Workflow

Workflo Agent• Workflow AgentPerson within the system of workflow roles who appears as an end user in productive workflowsuser in productive workflows.The workflow agent starts workflows and processes work items. Their work area is the Business Workplace.

Roles to be assigned

SAP_BC_SRV_USER

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 961: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Roles in Workflow

Process Controller• Process ControllerPerson within the system of workflow roles who evaluates the workflow from a business perspective at runtime, and is responsible for suggesting improvements.

Roles to be assigned gSAP_BC_SRV_USERSAP_BC_BMT_WFM_CONTROLLER

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 962: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object BuilderBusiness Object Builder

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 963: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

USE :Y h B i Obj B ild di l hYou use the Business Object Builder to create , display or change object types .The path is Tools Business Workflow Development D fi i i T l W kfl B ildDefinition Tools Workflow BuilderThe transaction code is SWO1

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 964: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

OBJECT TYPES :

• Object Type is the description of data (objects) in the system created at definition time in the Business Object Buildercreated at definition time in the Business Object Builder

• The examples are :

o Documents (invoices, purchase requisitions, job applications, and so on)

o Master data (customer, material, vendor, and so on) o Transaction data (order, quotation, and so on) ( , q , )

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 965: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

• Object types are described and implemented by specifying the following components:

o Basic data o Key fields o Attrib teso Attributes o Methods with parameters, result and exceptions o Events with parameterso Events with parameters o Implementation program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 966: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • INTEGRATION :INTEGRATION :

o If you want to display or change a defined object type in theBusiness Object Builder, you must know its ID, name or descriptiondescription

o If you do not know the object type precisely or if you are not sure whether there is an appropriate object type, you can find an object type via its position in the component hierarchy or via its relationships to other object types . In this case Business Object Repository Browser is used .

• FEATURES : o Various functions such as check, test, generate or where-used list

are available.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 967: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder MAINTENANCE OF OBJECT TYPES :MAINTENANCE OF OBJECT TYPES :

USE The maintenance of object types encompasses the functions of the j yp pBusiness Object Builder for creating, displaying and changing object types.

You need these functions if you want to:yo Look at and analyze the definition and implementation of a

particular object type o Create a new object type or change an existing object type j yp g g j ypo Change the release status of an object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 968: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder MAINTENANCE OF OBJECT TYPES :MAINTENANCE OF OBJECT TYPES :

• INTEGRATION : o If required you can get an overview of the existing object typeso If required, you can get an overview of the existing object types

including their relationships using the Business Object Repository Browser. The Business Object Repository Browser is called from the Business Object Builder.j

• FEATURESo You create a new object type with initially just its basic data.

This assigns the appropriate position in the Business Object Repository to the object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 969: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder CREATING OBJECT TYPES :CREATING OBJECT TYPES :• There are two ways of creating a new object type:

You create a completely new object typep y j ypYou create an object type as a subtype of an existing object type, which inherits the components of the existing object type automatically.y

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 970: Sap Abap Refresher Course NoRestriction

PROCEDURE :

ADDITIONAL TOPICS: SAP Business Workflow

PROCEDURE :1. Choose Tools Business Workflow Development Definition tools

Business Object Builder. This displays the screen Business Object Builder: Initial Screen.

2. Select Create.

3 Th C Obj T di l b3. The Create Object Type dialog box appears.

4. Edit the fields Object type, Object name, Name and Description. When doing so, bear in mind the general naming conventions for object types. Leave the field Supertype blank.

5. Enter the name of a new program for the implementation of the object type Bear in mind the naming conventions in your applicationtype. Bear in mind the naming conventions in your application.

6. Specify the code letter of your application (usually Y or Z).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 971: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 972: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder GENERAL NAMING CONVENTION FOR OBJECT TYPES :GENERAL NAMING CONVENTION FOR OBJECT TYPES :

• Object name

o The object name is specified when the object type is created. The object name has 20 characters and should be in English regardless of the user language. To make the object name easier to read, upper and lower cases should be used

• Object type name

o The object type name is a short, language-dependent text with 20 characters, which can be used on screens or in lists to identify ythe object type.

o The object type name is entered when the object type is created. It can be changed at any time in the basic data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

g y

Page 973: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

GENERAL NAMING CONVENTION FOR OBJECT TYPES :

• Object type description

Th bj t t d i ti i l t lo The object type description is an explanatory, language-dependent text with 80 characters, which can be used in lists of object types or for brief documentation.Th d i ti i t d h th bj t t i t d Ito The description is entered when the object type is created. It can be changed at any time in the basic data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 974: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder RULES FOR NAMING OBJECT TYPE COMPONENTS :

• The following naming rules apply to each object type component's ID, name and description:

• ID• IDo The ID of an object type component must be unique. An ID already

allocated to a key field, for example, can no longer be used as an ID for an attribute a method or an eventan attribute, a method or an event.

o The ID of a object type component has an identifying character. It has a maximum of 20 characters, and should be in English and comprehensible semantically. The ID begins with a letter, which is followed by letters, digits and underscores.

o Upper/lower cases are not significant for identification since only upper case is used. Upper case only can therefore be changed easily into

/l U /l l i l ibilit

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

upper/lower case. Upper/lower case always improves legibility even within a word.

Page 975: Sap Abap Refresher Course NoRestriction

Business Object BuilderADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder RULES FOR NAMING OBJECT TYPE COMPONENTS :

ID• IDo The ID of an object type component should not repeat the ID of the

object type or the object name. The object type ID precedes the object t t ID i li t Th bj t t ID d bj t ttype component ID in a list. The object type ID and object type component ID are separated with a period

E l f bj t t t ID f th bj t t• Examples of object type component IDs of the object type Material are:

Key field : Material.Material Attribute : Material.Industry Method : Material.Display Event : Material.Created

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 976: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder RULES FOR NAMING OBJECT TYPE COMPONENTS :RULES FOR NAMING OBJECT TYPE COMPONENTS :

• Nameo This is a short, language-dependent text with a length of 20 characters

• Descriptiono The description is an explanatory, language-dependent text with a

length of 80 characters, which can be used in lists of components or for brief documentation

• Key fieldso The ID must be an English noung

• Attributeso The ID must be an English noun

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 977: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder EDITING THE BASIC DATA OF AN OBJECT TYPEEDITING THE BASIC DATA OF AN OBJECT TYPE :

o The basic data contains both changeable, general information about the object type and information generated automatically by the system

• Procedure• Procedureo Select . o The takes you to the screen Object Type <object type>: Edit Basic Data.

The object type information displayed above the tab pages cannot beThe object type information displayed above the tab pages cannot be changed.

o On the tab page General, edit the name and the description of the object type. Assign the object type to the data model if required, in order to define it as a business objectorder to define it as a business object.

o If the object type corresponds to an SAP organizational entity, select Organizational type.

o Edit the default method and the default attribute on the tab page

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Defaults

Page 978: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROCESSING OBJECT TYPES :

• Checko To check that the implementation program with the attribute

and method accesses is syntactically correct and complete with regard to the object type definition, select .

• Change release statuso To change the release status of the object type, choose Object

t Ch l t t ttype Change release status to .... o To change the release status of an object type component,

proceed as follows:o Open the object type in change mode. o Select the object type component. o Choose Edit ® Change release status Object type component ....

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 979: Sap Abap Refresher Course NoRestriction

Business Object BuilderADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder RELEASE STATUSES :

• The following release statuses exist for object types and object type g j yp j ypcomponents:

• Modeled• You cannot call modeled object types/object type components at

runtime.• Implemented

• Implemented object types/object type components are either in the test phase or are only used internally. You can call and test them at runtime. Implementation may not yet be stable.

R l d• Released• Released object types/object type components are released for use.

You can call them at runtime. Any enhancements made by SAP to l d bj t t d bj t t t d

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

released object types and object type components are upward-compatible

Page 980: Sap Abap Refresher Course NoRestriction

PROCESSING OBJECT TYPES

ADDITIONAL TOPICS: SAP Business Workflow

PROCESSING OBJECT TYPES :

• Generate• To generate an object type and make it available for the runtime system, select .

• Test/Execute• To test whether the implementation of the methods and attributes of the object type was

successful, select Test. • If objects already exist for the object type, select an object for testing the instance-j y j yp , j g

dependent attributes and methods. • This displays the screen for testing an object type.• If no objects exist yet for the object type, only the attributes and methods that are defined

as instance-independent are offered for testing . To test the attributes and methods that operate on an object as well, select Create instance. You are then asked to enter the key fields of an object of the type to be executed in order to specify it.

• A screen with the attributes of the object and their current values is displayed. You execute the methods on this object by double-clicking on the appropriate line.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 981: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

DEFINITION OF OBJECT TYPE COMPONENTS :DEFINITION OF OBJECT TYPE COMPONENTS :o You need object type components to work with an object type.

A newly created object type only has the object type components that is inherits from the standard interface, which is supported by every object type

o To set up the object type for your tasks, you define key fields, attributes, methods and events

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 982: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROCESS FLOW :

• To define an object type, you do not have to edit all object type components. You should follow the sequence below:

• You check whether any object type components required are already contained in interfaces and implement themalready contained in interfaces and implement them.

• You define the key fields. • You create the necessary attributes.

Y h h d f hi h d fi• You create the necessary methods, for which you can define method parameters and exceptions.

• You create the necessary events, for which you can create ddi i l

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

additional event parameters.

Page 983: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

MAINTENANCE OF OBJECT TYPE COMPONENTS :

• Editing an object type component• Position the cursor on an object type component and selectj yp p

• Creating an object type component• Position the cursor on the object type component name with a blue

background and select .• You can now process the newly-created object type component

directly• Redefining an object type component

• Redefining an object type component inherited from the supertype allows you to process it. Position the cursor on the object type component and select . A redefined object type component loses its red background

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 984: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder MAINTENANCE OF OBJECT TYPE COMPONENTS :

• Deleting and renaming individual object type components• Position the cursor on the object type component to be j yp p

processed. To delete it, select . To rename it, select

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 985: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder IMPLEMENTATION OF INTERFACES :

o You use this function to define the interfaces that your object type supports

o SAP supplies interfaces that you can use when defining your pp y g yown object types

o Using interfaces standardizes the definition of the object type components.p

o Using an interface guarantees that the object type fully supports the methods (with all parameters and all exceptions), attributes and events in the interface

o All objects types support the standard interface.o This contains the interfaces Check existence and Displayo You can add other interfaces to your object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

o You can add other interfaces to your object type

Page 986: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE AGGREGATE :

o The aggregate type is used to specify functional relationships between object types

o There is no inheritanceo The attribute Aggregate contains the reference to this aggregate

typeo You do not have to implement anything in the program of theo You do not have to implement anything in the program of the

object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 987: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE EXTENDED APPROVAL :

• Result of this method

• The method XApproval has one result with four possible values. The values are specified using the fixed values for the domainThe values are specified using the fixed values for the domain SWF_XAPPRE :

• 0 (object approved) • 1 (object proposed for approval) • 3 (object proposed for rejection) • 4 (object rejected)

• In the implementation of this method, the container element RESULT of the method container must be assigned one of the four values at the end

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 988: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE APPROVAL :

• The interface Approval is used to offer a method for the object type, which can be used in an approval task.

• The implementation of this method is always incomplete and not p y padapted to the current conditions of the object type

• RESULTS OF THIS METHOD :– The method Approval has one result with two possible values. These are

specified using the fixed values for the domain SWF_APPRES :– 0 (object approved)– 4 (object rejected)4 (object rejected)

– In the implementation of this method, the container element RESULT of the method container must be assigned one of the two values at the end

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 989: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE CREATE :

• Used for creating an object for the object type • EXCEPTIONS FOR THIS METHOD :

• Three exceptions are defined in the interface Create for the methodThree exceptions are defined in the interface Create for the method Create

• You must implement these exceptions at the appropriate points in the program. Use the macro following macro instruction:

EXIT_RETURN <Code> <Variable1> <Variable2> <Variable3> <Variable4>

• As the <Code>, enter the exception’s 4-digit number specified when the exception was defined. The variables (maximum of four) are derived from the definition of the message that is linked to the exception

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 990: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

INTERFACE DISPLAY :INTERFACE DISPLAY :The interface Display contains the method Display for displaying an objectTh th d Di l i i l t d f th i t f i hThe method Display is implemented for the interface in such a manner that the key field values of the object are displayed as standardIt is also entered as default method in the basic data

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 991: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE EDIT :INTERFACE EDIT :

• To offer a method for editing an object for your object type

• Exceptions for the method• The exception Object does not exist is defined for the method

Edit under the number 0001 in the interface Edit. You must implement this exception at the appropriate point in the

U th f ll i i t tiprogram. Use the macro following macro instruction:» EXIT_RETURN 0001 SPACE SPACE SPACE SPACE

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 992: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE FIND :

With this method you can use the inherited source code unchanged.The source code is not entered in the program of your object type, but only in the program of the interface Find, from which it is inheritedThe system sets up an object reference in the inherited implementation of the method Find. To do this, the system generates a dialog box with input fields for the key fields of the object Th t l h k ithi th i l t ti h th th kThe system also checks within the implementation whether the key fields entered actually identify an existing object So that the method Find really does only return objects that exist, you must also define and implement the method ExistenceCheck (interfacemust also define and implement the method ExistenceCheck (interface Check existence) for the object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 993: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder INTERFACE FIND :

• Exceptions for the method• Two exceptions are defined for the method Find : • Exception 0001: Object does not existException 0001: Object does not exist • Exception 1017: Cancellation by user

• The exceptions are implemented in the program of the interface FindFind

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 994: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder

STANDARD INTERFACE :All object types support the standard interface and hence inherit the attribute ObjectType and the interfaces Display and Check existenceThese contain the methods Display and ExistenceCheckThe attribute ObjectType returns the type of an object

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 995: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINING KEY FIELDS :

• Objects are always identified using one or more key fields

• The identifying key of an object is made up of all the key fields of the object type

• Procedure• Position the cursor on the component name Key fields (blue

background). • Select • Answer YES to the question Create with ABAP Dictionary field

proposals? The Create with Data Dictionary Field Proposals dialog box appearsdialog box appears

• Enter the table from which you want to reference the fields, and select the fields that are the key fields of your object type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 996: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF ATTRIBUTES FOR AN OBJECT TYPE :

• You must define attributes for an object type when you want to query particular properties, statuses or values at runtime

• Attributes can be used to formulate conditions in the workflow• Attributes can be used to formulate conditions in the workflow definition

• At runtime, the attribute values are read or calculated, and can also be used to control the workflow

• Object type attributes can return data in the following formats:• Value of ABAP Dictionary fieldValue of ABAP Dictionary field • Object reference • Value calculated at runtime • Object status in status management

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

• Object status in status management

Page 997: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF ATTRIBUTES FOR AN OBJECT TYPE :

Att ib t h i f i f ti• Attributes have various sources of information

VIRTUALAttribute for which a read procedure always has to be implemented, since no field content in the database corresponds to this attribute. A virtual attribute can return the value of an ABAP Dictionary field or an object reference

DATABASE FIELDDATABASE FIELDWhen this type of attribute is defined, reference is made to a database field as the source of the required information. An attribute whose source is a database field can eitherAn attribute whose source is a database field can either return the database field contents or an object reference

OBJECT STATUSAttribute whose value is an object status

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Attribute whose value is an object status

Page 998: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF ATTRIBUTES FOR AN OBJECT TYPE :

o Relationships between two object types are described using attributes, which return their information as object references to the other object type

o In the field Inverse attribute, enter the attribute of the other object type, which contains the object reference to this object type

o You can use macros to access the attribute

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 999: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHODS FOR AN OBJECT TYPE :

• With a method you define a function with which you can edit, create, search for or delete an object of this object type

• The methods refer to ABAP functions (transactions function• The methods refer to ABAP functions (transactions, function modules, dialog modules, and so on) and make them available to the workflow system

• Features

– You can also define the following data for each method:Import parameters (for synchronous and asynchronous p p ( y ymethods) A result (only for synchronous methods) Export parameters (only for synchronous methods)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Exceptions (only for synchronous methods)

Page 1000: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHODS FOR AN OBJECT TYPE :

• SYNCHRONOUS METHODS :

– Method that assumes process control for the duration of its execution and reports back to the calling component (in thisexecution and reports back to the calling component (in this case the work item manager) after its execution

– Terminating events can be defined for a single-step task described with a synchronous object methoddescribed with a synchronous object method

– A synchronous method can return the following data to the workflow:

Return parameters– Return parameters – One result – Exceptions

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1001: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHODS FOR AN OBJECT TYPE :

• ASYNCHRONOUS METHODS :

– Method that does not report back directly to the calling component (in this case the work item manager) after itscomponent (in this case the work item manager) after its execution

– It does not return any result, any parameters or any exceptionsexceptions

– At least one terminating event must be defined for a single-step task described with an asynchronous object methodAn asynchronous method must enter its results itself Import– An asynchronous method must enter its results itself. Import parameters can be passed to it only

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1002: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHODS FOR AN OBJECT TYPE :

• RESULT

– A specific parameter of a synchronous method for returning the essential result of this methodthe essential result of this method

– The possible values of this result can be defined in a fixed value domain or a check table so that they are known in the workflow definition and can be taken into accountworkflow definition and can be taken into account

– A method can only ever have one result, but it can have any number of return parameters as wellA method does not necessarily have to have a result– A method does not necessarily have to have a result

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1003: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHODS FOR AN OBJECT TYPE :

• EXCEPTIONS

– Object type component: Error which may occur during method execution and indicates whether a method wasmethod execution and indicates whether a method was successful

– Exception categories:Application and system error– Application and system error

– Temporary error – Temporary errors can occur when system resources are not

il blavailable

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1004: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • DEFINITION OF METHODS FOR AN OBJECT TYPE :

• PROCEDURE

– To create methods for an object type, position the cursor on the name Methods (blue background) and selectthe name Methods (blue background), and select

– If the new method is based on a function module, you should answer the question with YES . You are then supported by a wizard in the definition of the methodwizard in the definition of the method

– GENERAL TAB– DIALOG : If you do not set the indicator Dialog on the tab

page General the method is executed in the background atpage General, the method is executed in the background at runtime

– SYNCHRONOUS – RESULT

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

SU– INSTANACE DEPENDENT

Page 1005: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • DEFINITION OF METHODS FOR AN OBJECT TYPE :

• PROCEDURE

– RESULT TYPE TAB • Define the reference to ABAP Dictionary• Define the reference to ABAP Dictionary

– ABAP TAB • You enter the function to be executed when the method is

A Acalled on the tab page ABAPe.g if the transaction has to be called by the method then

Checkbox “Transaction” is to be selected and the transaction code to be entered in the NAME

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1006: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • DEFINITION OF METHOD PARAMETERS :

• You define method parameters for a method under the following circumstances:

When the method requires other input values apart from the– When the method requires other input values apart from the object reference, which are not requested in dialog.

– When the method returns parameters apart from the object referencereference

• Integration

– The following data type references exist for method parameters:

– ABAP Dictionary reference – Object type reference

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

j yp

Page 1007: Sap Abap Refresher Course NoRestriction

B i Obj t B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHOD EXCEPTIONS :

Yo define e ceptions for a method hen o ant to "p blici e" error• You define exceptions for a method when you want to "publicize" error situations in a standardized manner in order to give the caller of the method the opportunity to react to the error situations

T d fi ti f th d iti th th th d d• To define exceptions for a method, position the cursor on the method and select Exceptions. The existing exceptions for the method are displayed and you select to create a new exception.

Gi th ti id tif i b i th di l b Add• Give the exception an identifying number in the dialog box Add Exceptions, which is used to address it in the implementation program. The following number ranges apply:

0001 1000 E ti d fi d f i t f» 0001-1000: Exceptions defined for interfaces » 1001-7999: Application-specific exceptions, reserved for SAP

development » 8000-8999: Exceptions triggered by the object manager

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

p gg y j g» 9000-9999: Customer-defined exceptions, reserved for

customers

Page 1008: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF METHOD EXCEPTIONS :

• Exceptions are classified according to error types.• Temporary error: This error type indicates that certain system

resources are not available at the moment, and that it is ,advisable to call the method again at a later point in time. Temporary errors can also occur if the method is temporarily locked by another user for processing.

• Application error: This error type is caused within the application called in the method. A table that cannot be maintained or a document that does not exist are typical application errors.application errors.

• System error: This error type shows incorrect configuration of the object manager or an inconsistency between object type definition and method call. Missing mandatory method

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

parameters when calling a method are an example of a system error.

Page 1009: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF EVENTS FOR AN OBJECT TYPE :

• You define events for an object type, if a status change in an object of this type is to be published across the system

• You use an event in a workflow under the following• You use an event in a workflow under the following circumstances:

• In a workflow or task definition as a triggering event• The workflow or task is started when the event is triggered.• In a task definition as a terminating event• The task is terminated when the event is triggered.• In a workflow definition for steps of the types Event creator

and Wait for event. • The event is triggered (event creator) or the workflow is

continued when the event is triggered (wait for event)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

continued when the event is triggered (wait for event).

Page 1010: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF EVENTS FOR AN OBJECT TYPE :

o The event is not normally triggered in the implementation program, but instead by an event creation. You can use the function modules SWE_EVENT_CREATE or SAP_WAPI_CREATE_EVENT to trigger

tan evento An event is published without the creating application being informed

as to whether a receiver reacts to this event. The system enters potential receivers in a linkage table, which is evaluated by the event managerreceivers in a linkage table, which is evaluated by the event manager

o Every event has an event container that contains data about the context of its creation. The data is passed to the task or workflow via a binding

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1011: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF EVENT PARAMETERS :

• You define event parameters to supplement the system event parameters

• EVENT PARAMETERS :• EVENT PARAMETERS :

– Runtime-specific information from the event creation context

– Event parameters are defined as elements of the event container and are passed to the event receivers via binding

– The following event parameters are automatically contained in the event container:

– The reference to the object whose change of state is described by the event.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

– The user name of the party who triggered the event creation.

Page 1012: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder DEFINITION OF EVENT PARAMETERS :

• The event parameters are displayed as event container elements and you use them in binding definitions between the event container and the task or workflow container

• There are two different types of data type reference for event parameters:

• ABAP Dictionary reference • Object type reference

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1013: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROGRAMMING IN THE IMPLEMENTATION PROGRAM :

o The information specified about the object type components is only of a descriptive nature. Attribute accesses and method calls are programmed in the implementation program of the object type

o This program is called and executed by the system at runtime.o During object type definition you select Program to go to the g j yp y g g

ABAP Editoro You go directly to the lines in the implementation program that

contain the relevant source text for the selected method or attribute

o Parts of the source text can be generated automatically to help implementation

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

p

Page 1014: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROGRAMMING IN THE IMPLEMENTATION PROGRAM :

• The source text is generated based on the specifications you made when defining the object type and the object type components, and inserted into the implementation programp p g

• MANUAL POSTPROCESSING

– You need to check the program as automatic program i igeneration only provide templates

• CHANGES AFTER PROGRAM GENERATION

– Changes made to object type components do not g j yp pautomatically change the program

– So all subsequent changes have to be made manually

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1015: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROGRAMMING IN THE IMPLEMENTATION PROGRAM :

• Only in the following cases the source code gets automatically changed in the implementation program

• Deletion of methods• Deletion of methods• Deletion of virtual attributes• Renaming of methods• Renaming of virtual attributes• Renaming of virtual attributes

• INCLUDING MACRO INSTRUCTIONS• Macro instructions for processing containers and accessing

bj t d i th i l t tiobjects are used in the implementation program• The macro instructions are available if the macro <OBJECT>

has been included into the implementation program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1016: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder PROGRAMMING IN THE IMPLEMENTATION PROGRAM :

• The macro instructions for processing the container can also be used outside the implementation program

• The macro instructions for accessing objects attributes and• The macro instructions for accessing objects, attributes and methods can only be used within the implementation program

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1017: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • MACRO INSTRUCTIONS FOR PROCESSING A CONTAINER

These macro instructions can be used in following programs :• Implementation programs of object types • Function modules for event creationFunction modules for event creation • Function modules for role resolution

Processing a container instance includes:A i f i• Accessing the value of a container element

• Entering a value for a container element

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1018: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • The include file <CNTN01> must have been included into the

program in order to use these macros

• The container must be declared and initialized with the following macro instructions:

– SWC_CONTAINER <Container>. "DeclarationSWC_CREATE_CONTAINER <Container>. "Initialization

• You can assign the content of a field to a container element or• You can assign the content of a field to a container element or write the content of a container into a field

• This content can be multiline, that is, in the form of an internal table

• The content of a field can be an elementary data type, a structure or an object reference

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

o a object e e e ce

Page 1019: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • ACTIVITIES :

Deleting a container elementSWC_DELETE_ELEMENT <Container> <ContainerElement>.

Copying a container elementSWC_COPY_ELEMENT <SourceContainer> <SourceElement> <TargetContainer> <TargetElement><SourceElement> <TargetContainer> <TargetElement>.

Writing a field value SWC_SET_ELEMENT <Container> <ContainerElement> <Value><ContainerElement> <Value>.

Reading a field value SWC_GET_ELEMENT <Container>

C i El Fi ldV i bl

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

<ContainerElement> <FieldVariable>.

Page 1020: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • ACTIVITIES :

• Writing a multiline field value – SWC_SET_TABLE <Container> <ContainerElement> <Value>.

• Reading a multiline field value S C G A C i C i l– SWC_GET_TABLE <Container> <ContainerElement> <TableVariable>.

• Writing an object reference– DATA <Object> TYPE SWC OBJECT.j _

SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.SWC_SET_ELEMENT <Container> <ContainerElement> <Object>.

• Reading an object referenceDATA <Object> TYPE SWC OBJECT– DATA <Object> TYPE SWC_OBJECT.SWC_GET_ELEMENT <Container> <ContainerElement> <Object>.SWC_GET_OBJECT_KEY <Object> <ObjectKey>.SWC_GET_OBJECT_TYPE <Object> <ObjectType>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1021: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • ACTIVITIES :

• Writing a multiline object reference– DATA <ObjectList> TYPE SWC_OBJECT OCCURS 0.

DATA <Object> TYPE SWC_OBJECT.SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.APPEND <Object> TO <ObjectList>.......SWC_SET_TABLE <Container> <ContainerElement> <ObjectList>.

• Reading a multiline object reference– DATA <ObjectList> TYPE SWC_OBJECT OCCURS 0.

SWC_GET_TABLE <Container> <ContainerElement> <ObjectList>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1022: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • MACRO INSTRUCTIONS FOR ACCESSING OBJECTS ,

ATTRIBUTES AND METHODS • You can use these macros for simplifying access to Business

Object Repository objects• The include file <OBJECT> must be incorporated into the

program in order to use these macros• You must declare variables in which an object reference is to

b t d ith th f ll i i t tibe stored with the following instruction:» DATA : <Object> TYPE SWC_OBJECT.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1023: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • GENERAL MACROS

• SWC_CREATE_OBJECT <Object> <ObjectType> <ObjectKey>.

• SWC_REFRESH_OBJECT <Object>.• SWC_GET_OBJECT_TYPE <Object> <ObjectType>.• SWC_GET_OBJECT_KEY <Object> <ObjectType>.• SWC_CALL_METHOD <Object> <Method> <Container>.• SWC_GET_PROPERTY <Object> <Attribute>

<AttributeValue>.

SWC GET TABLE PROPERTY <Obj t> <Att ib t >• SWC_GET_TABLE_PROPERTY <Object> <Attribute> <AttributeValue>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1024: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • EXECUTING MACROS ON OWN OBJECT

• All the macros in the section General macros can also be executed directly on the object itself in the implementation program

• To do this, you replace <Object> with SELF in the macro callse.g.

» SWC_GET_PROPERTY SELF <Attribute> <Att ib t V l ><AttributeValue>. .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1025: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • SETTING AN OBJECT KEY

• When implementing methods with which an object is created, the object key must be set

• This typically applies to the methods Create and Find • SWC_SET_OBJECTKEY <ObjectKey>.

• RAISING EXCEPTIONS • Within the implementation program, you can raise the W e p e e o p og , you c se e

exceptions defined for a method• EXIT_RETURN <Exception> <Var1> <Var2> <Var3>

<Var4>.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1026: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • DATA DECLARATION FOR VARIABLES USED

• The system automatically creates an area for the data declaration for key fields, attributes and method parameters in the implementation program

• This area is between the two macro instructions BEGIN_DATA OBJECT and END_DATA OBJECT at the beginning of the source text

• The data structure of the object key is between the macro• The data structure of the object key is between the macro instructions BEGIN OF KEY and END OF KEY and is created automatically by the system

• The method parameters and attributes are then declared p• Since the system obtains the information about the names of

the variables and the field references directly from the definition of the individual object type components, you cannot

k h h

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

make any changes here

Page 1027: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • DATA DECLARATION FOR VARIABLES USED

BEGIN_DATA OBJECT. " Do not change.. DATA is generated* only private members may be inserted into structure privateDATA:" begin of private," to declare private attributes remove comments and" to declare private attributes remove comments and" insert private attributes here ..." end of private,

BEGIN OF KEY,MATERIAL LIKE MARA-MATNR,

END OF KEY,PURCHASEREQUISITION TYPE SWC_OBJECT OCCURS 0,PURCHASEORDER TYPE SWC_OBJECT OCCURS 0,PURCHASINGINFO TYPE SWC_OBJECT OCCURS 0,PURCHOUTLINEAGREEMT TYPE SWC OBJECT OCCURS 0PURCHOUTLINEAGREEMT TYPE SWC_OBJECT OCCURS 0,DOCUMENT TYPE SWC_OBJECT OCCURS 0,COSTESTIMATE TYPE SWC_OBJECT OCCURS 0,PIECEOFEQUIPMENT TYPE SWC_OBJECT OCCURS 0,_MAKT LIKE MAKT,

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

_MARA LIKE MARA.END_DATA OBJECT. " Do not change.. DATA is generated

Page 1028: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • PROGRAMMING ASYNCHRONOUS METHODS

• It is programmed between the macro instructions BEGIN_METHOD

• <Method> and END_METHOD • The unique ID of the object is available in the structure of the

key fields under the variable OBJECT-KEY• An asynchronous method can be implemented with a

t ti Th t ti i ll d i th ith thtransaction. The transaction is called in the program with the ABAP command CALL TRANSACTION

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1029: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • PROGRAMMING SYNCHRONOUS METHODS

• It is programmed between the macro instructions BEGIN_METHOD <Method> and END_METHOD

• The unique ID of the object is available in the structure of the key fields under the variable OBJECT-KEY

• A synchronous method can be implemented with a function module. The function module is called with the ABAP command CALL FUNCTION in the programcommand CALL FUNCTION in the program

• In the case of synchronous methods, a result and/or the export parameters can be returned to the caller if you pass the result to the container CONTAINER within the method implementation

• The result is always put into the container element RESULT. The result is available in the task container in the container l t WI RESULT

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

element _WI_RESULT

Page 1030: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • PROGRAMMING EXCEPTIONS

• You implement exceptions within a method, that is within the macro instructions BEGIN_METHOD <Method> and END_METHOD , using the macro instruction EXIT_RETURN

• EXIT_RETURN <Code> <Variable1> <Variable2> <Variable3> <Variable4>.

• You must declare <Code> with the type SWOTINVOKE-CODECODE

• STANDARD EXCEPTIONS • EXIT_OBJECT_NOT_FOUND• EXIT_CANCELLED• EXIT_NOT_IMPLEMENTED• EXIT_PARAMETER_NOT_FOUND

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1031: Sap Abap Refresher Course NoRestriction

Business Object BuilderADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder EXTENDING AND ADAPTING OBJECT TYPES

• You can extend an object type to add more object type j yp j ypcomponents not in the standard version

• This ensures that productive workflows and tasks remain executable in the same manner with the original object type

• Process FlowYou cannot change the object types supplied by SAP. If you want to use one of these object types, but would like to make specific extensions or adaptations in certain areas you proceedspecific extensions or adaptations in certain areas, you proceed as follows:» You create a new object type as a subtype of the object type that you want to

extend. For further information, refer to Creating Subtypes. The new object type inherits the components and their implementation from the supertypetype inherits the components and their implementation from the supertype.

» You modify and add to this object type. You can redefine existing attributes and methods and create new object type components. For further information, refer to Maintenance of an Object Type Component.

» You make this object type into a delegation type of the supertype For further

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

» You make this object type into a delegation type of the supertype. For further information, refer to Defining Delegation Types.

Page 1032: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • EXTENDING AND ADAPTING OBJECT TYPES

DELEGATION TYPE » Object type whose definition is considered at runtime instead of the

definition of another object type, although this other object type is specified in all definition components (for example task and workflowspecified in all definition components (for example task and workflow definition, linkage tables). In all definition tools you can still refer to the original object type, but the system uses the definition of the delegation type for every access.

» The delegation type must always be a subtype of the object type it is to replace. The delegation type can have different or additional methods, attributes and events.

» A delegation type is always defined for an object type on a system-wide and cross-client basis

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1033: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • EXTENDING AND ADAPTING OBJECT TYPES

DELEGATION TYPE » Object type whose definition is considered at runtime instead of the

definition of another object type, although this other object type is specified in all definition components (for example task and workflowspecified in all definition components (for example task and workflow definition, linkage tables). In all definition tools you can still refer to the original object type, but the system uses the definition of the delegation type for every access.

» The delegation type must always be a subtype of the object type it is to replace. The delegation type can have different or additional methods, attributes and events.

» A delegation type is always defined for an object type on a system-wide and cross-client basis

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1034: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • EXTENDING AND ADAPTING OBJECT TYPES

• DEFINING DELEGATION TYPES Defining a customer-specific delegation type across the system» Choose Settings Delegation System-wide. You are on the screen

Display View "Customizing Object Types": DetailsDisplay View Customizing Object Types : Details.» Select . » Select New entries. » The screen New Entries: Details of Added Entries is displayed.

E h ID f h bj f hi h d fi d l i» Enter the ID of the object type for which you want to define a delegation type. in the field Object type.

» Enter the name of a person responsible. » Enter the ID of the subtype for the object type in the field Delegation type

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1035: Sap Abap Refresher Course NoRestriction

B i Obj B ild

ADDITIONAL TOPICS: SAP Business Workflow

Business Object Builder • EXTENDING AND ADAPTING OBJECT TYPES

• DEFINING DELEGATION TYPES Defining a customer-specific delegation type for a specific frontend» On the screen Business Object Builder: Initial Screen,

enter the ID of an object type as a frontend-specific delegation type in the field Object/interface type.

» You can only specify a frontend-specific delegation for an object type if you checked "GUI specific" beforehand forobject type if you checked GUI-specific beforehand for this object type when maintaining system-wide delegation.

» Choose Settings Delegation Frontend.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1036: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Tasks and Task Groups Tasks and Task Groups

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1037: Sap Abap Refresher Course NoRestriction

T k

ADDITIONAL TOPICS: SAP Business Workflow

Tasks • DEFINITION OF TASK

o You use a Task to define an activity that can be executed within a workflow definition or independently (as a single step). This

activity can be an SAP System transaction.o You have to create new tasks as standard tasks .

CREATING A TASK – Choose Tools Business Workflow Development Definition Tools

Tasks/Task Groups Create.

– Select the relevant task type.Select the elevant task type.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1038: Sap Abap Refresher Course NoRestriction

T k

ADDITIONAL TOPICS: SAP Business Workflow

Tasks • SINGLE STEP TASK

– Maintain names, work item text, object type and method Tab page Basic data– Maintain agent assignment Additional data Agent assignment

Maintain– Maintain elements in task container Container– Maintain elements in task container Container– Maintain triggering events Tab page Triggering events– Maintain terminating events Tab page Terminating events– Maintain default rules Tab page Default rules– Maintain description and notification texts Tab page Description– Maintain additional data Additional data Selection

criteria...Additional data Classification Change

– Maintain SAPphone properties Tab page SAPphone.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1039: Sap Abap Refresher Course NoRestriction

T k

ADDITIONAL TOPICS: SAP Business Workflow

Tasks • MULTI STEP TASK

– Maintain names, work item text, object type and method Tab page Basic data– Maintain agent assignment Additional data Agent assignment

Maintain– Maintain elements in task container Container– Maintain elements in task container Container– Maintain triggering events Tab page Triggering events– Maintain description and notification texts Tab page Description– Maintain additional data Additional data Selection

criteria...Additional data Classification Change

– Maintain SAPphone properties Tab page SAPphone.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1040: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Tasks

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1041: Sap Abap Refresher Course NoRestriction

CONTAINER

ADDITIONAL TOPICS: SAP Business Workflow

CONTAINER • The elements of a container are described with ID, data type reference

and other properties

• Types of ContainerTypes of Container Method ContainerEvent ContainerRule ContainerTask ContainerWorkflow Container

• Usually containers are already defined. These containers hold standardUsually containers are already defined. These containers hold standard container elements defined by the workflow system

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1042: Sap Abap Refresher Course NoRestriction

BINDING

ADDITIONAL TOPICS: SAP Business Workflow

BINDING • Values can be assigned to container elements in different

ways.Value assignment using a binding from another container according to a binding definition carried out previously. V l i di l i i i h fValue assignment directly to a container instance in the program of an application. Value assignment with an initial value determined at definition time when the container instance is created.

• At definition time you create binding definitions for the workflow. This involves specifying the assignment rules for how data is exchanged p y g g gbetween two containers. At runtime these binding definitions are executed making workflow execution possible

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1043: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

BINDING

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1044: Sap Abap Refresher Course NoRestriction

BINDINGADDITIONAL TOPICS: SAP Business Workflow

BINDING • Binding Definition from Task Container

• You define the bindings from the task container in the following twoYou define the bindings from the task container in the following two places.– In the definition of a task

» There are binding definitions to the:» There are binding definitions to the:» Method container (for import parameters of method) » Rule container (for definition of default rules)

– In the step definition in the Workflow Builder» The binding definition to the workflow container.

• Binding Definitions to Workflow Container• You define the bindings from the workflow container within the g

Workflow Builder. There are binding definitions to the:» Task container (activity, user decision, document from template, send

mail, form step) » E ent container (e ent creator)

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

» Event container (event creator) » Rule container (for definition of responsible agents and recipients)

Page 1045: Sap Abap Refresher Course NoRestriction

BINDINGADDITIONAL TOPICS: SAP Business Workflow

BINDING • Binding Definition from Method Container

You define the binding from the method container to the task containerYou define the binding from the method container to the task container (for export parameters of the method with synchronous methods) during definition of a task.

• Binding Definition from the Rule ContainerYou make the binding definition from the rule container to the workflow container during the definition of a step.

• Binding Definition from Event ContainerYou define the bindings from the event container in the following three places.

» In the definition of a task for the binding definition to the task container (for triggering or terminating events of the task)container (for triggering or terminating events of the task).

» In the Workflow Builder in the basic data of a workflow for the binding definition to the workflow container (for triggering events of the workflow). I th W kfl B ild i th d fi iti f it t f th

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

» In the Workflow Builder in the definition of a wait step for the binding definition to the workflow container.

Page 1046: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Workflow Builder Workflow Builder

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1047: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER• This is the main WebFlow Engine tool for creating, displaying, and

i kfl d fi iti Y t t kfl d fi iti dprocessing workflow definitions. You can test workflow definitions and

generate operable versions.

• The Workflow Builder provides a graphical and an alphanumeric p g p p

modeling view and also a tree display of the workflow definition

• You can only use the graphical modeling view if you are working with the SAPGUI for Windows If you call the Workflow Builder using athe SAPGUI for Windows. If you call the Workflow Builder using a different SAP GUI, the alphanumeric modeling view is displayed

automatically

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1048: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1049: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERWorkflow

Here you can insert new steps into the workflow definition and process existing ones. Double-clicking on a step calls the associated step definition.

OverviewOverviewThe overview graphic is displayed here. The part of the workflow graphic displayed in the screen area Workflow is marked with a green rectangle. Changing the size or position of the rectangle changes the display in the screen area Workflowchanges the display in the screen area Workflow.

Step typesAll step types that you can use in the workflow are displayed here if you are in change mode. You can insert a new step usingif you are in change mode. You can insert a new step using Drag&Drop.

ObjectsThis screen area contains the following:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1050: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER» Workflow container» All workflow container elements are displayed here You can also define new» All workflow container elements are displayed here. You can also define new

container elements and generate a where-used list here. In the options in the Workflow Builder, you can choose not to display the workflow system elements here.

» My workflows and tasks» Tasks and workflows that are displayed can be inserted into your workflow

definition as activities by double-clicking. The binding between the task container and the workflow container as well as the other container elements required is generated automatically by the workflow system as far as possible. You can also go directly to the relevant definition. You define which workflows and tasks are displayed here yourself. For more information, see Business Workflow Explorer.

» Document templates» All the workflow's document templates that can be used in steps of the type

document from template are displayed here. You can use a where-used list to determine the steps in which a document template is useddetermine the steps in which a document template is used.

» Workflow Wizards» All Workflow Wizards that you can use in the definition of your workflow are

displayed here.

T ki

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

» Teamworking» Here you can search for steps by selected criteria. The result is displayed

graphically in the workflow area.

Page 1051: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER» Workflows of this definition» Your Workflow Outbox is displayed here which displays all running workflows» Your Workflow Outbox is displayed here, which displays all running workflows

for this definition.

Navigation» The workflow steps are displayed here according to the

workflow definition display. You can go directly to the relevant step definition from the list.

Messages» All messages generated in where used lists and workflow tests» All messages generated in where-used lists and workflow tests

are displayed here. Double-clicking on a message takes you to the relevant step definition.

Information» This displayed which workflow is loaded in which definition,

the status of the respective workflow, and the version number of this workflow in the original system

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1052: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERCALLING THE WORKFLOW BUILDER

Direct StartTools Business Workflow Development Definition tools Workflow Builder .

St t f T k D fi itiStart from Task Definition» If you start the Workflow Builder from a screen for

processing or displaying a multistep task, choose Workflow Builder on the tab page Basic Data. The active version of the workflow definition is loaded. If there is no active version, the version with the highest version number is loaded.

» To call another version of the workflow definition, choose Goto Workflow Builder Choose version in the task definition. This takes you to a dialog box in which you can choose a version of the workflow definition.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1053: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDERADDITIONAL TOPICS: SAP Business Workflow

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1054: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Activities• At runtime, an activity is represented with a work item of one

of the following types:» Dialog work item if the activity references a task with dialog. » Background work item if the activity references a task

processed by the system without dialog. » Workflow work item if the activity represents a workflow.» Workflow work item if the activity represents a workflow.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1055: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Mail Transmission• You use this step type to send a mail to different recipients. You

define the text and subject of the mail when defining the step. Y i bl i th t t hi h fill d f th t kYou can use variables in the text, which are filled from the task container at runtime.

• This step type replaces the wizard Include "Send mail".• The system creates a task automatically which sends the mail• The system creates a task automatically, which sends the mail.

The text to be sent is stored with the task. The system creates the variables used within the step definition in the task container and defines a binding from the workflow container to the task container for them

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1056: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Form StepsThis step type enables you to display or process the data in a container element of the workflow container. The container element must refer to a structure whose fields are used in the form. A form can be generateda structure whose fields are used in the form. A form can be generated automatically by the workflow system. You can process the form generated to adapt it to suit your individual requirements

• The maintenance of a form step is spread across several tab pages. You it ti th hcan process its properties on them, such as:

» Data for deadline monitoring» Outcomes » Responsible agentsp g

• At runtime, a form step is represented by a dialog work item

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1057: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of User Decision• In a user decision, the recipients receive the task description

together with the possible decision options during execution. You d i i i th f ll i it tican use a user decision in the following situations:

» Only one of several possible alternatives can be processed in the workflow from a business point of view at execution time.

» A decision about the progression of the workflow must be made p gin dialog with a user.

» An instruction (= user decision with only one decision option) is required to continue the workflow.

» For approval and release steps possibly in connection with a» For approval and release steps, possibly in connection with a secondary method (the latter is possible without the application having to cater for these functions).

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1058: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERMaintenance of Documents from a Templatep

• You use this step type to create documents of various PC applications and process them within the workflow. The work item recipient creates the document based on a document template,

hi h l i i l f h kflwhich can also contain container elements of the workflow container

• The maintenance is spread across several tab pages. You can process properties on them such as:process properties on them, such as:

» Template selection » Responsible agents» Deadline monitoringg

• At runtime, this step is represented by a dialog work item in the Workflow Inbox of its recipients.

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1059: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERMaintenance of Conditions

• You use a condition in a workflow definition if:» At execution time, only one of two possible alternatives can be

processed during the workflow, from a business point of view. » The workflow system can make a decision based on the contents

of the workflow container without user interaction• The system inserts a step of the type condition into the workflow

definition The system adds a branch to the workflow definition fordefinition. The system adds a branch to the workflow definition for each outcome. To ensure the consistency of the block structure, all branches created are brought together before the next step of the workflow definition

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1060: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERMaintenance of Multiple Conditions p

• You use a multiple condition in a workflow definition if:» At execution time, only one of several possible alternatives can

be processed during the workflow, from a business point of view. » The workflow system can make a decision based on the contents

of the workflow container. » The decision can be formulated based on a comparison between

an expression from workflow container and a finite amount of pcomparison values (constants, expressions).

» The system inserts a step of the type condition into the workflow definition. The system adds a branch to the workflow definition for each outcome. To ensure the consistency of the blockfor each outcome. To ensure the consistency of the block structure, all branches created are brought together before the next step of the workflow definition

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1061: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERMaintenance of Event Creators

• Use an event creator if you want to publish an event from a workflow. This event can be used as follows:– To start other workflows or tasks.– For this, the event must be entered as a triggering event for the

relevant workflow or task.» As a terminating event of a task. » For internal communication and synchronization» For internal communication and synchronization

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1062: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Wait Steps • The following shows possible uses of a wait step in a workflow

definition:d h i i f h kfl il d fi d» To suspend the entire execution of the workflow until a defined

event has occurred. » To wait for an event in a parallel processing branch, which

renders processing in the other branches unnecessary

• At runtime, a wait step is represented by a wait step work item

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1063: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Container Operations • You use a container operation to change a container element of the

kfl i iworkflow container at runtime

Maintenance of Process Controls Y hi l l h k i f• You use this step type to complete or cancel other work items of the current workflow or the workflow itself at runtime

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1064: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDERMaintenance of Until Loops p

• You use an UNTIL loop in a workflow definition if:» At execution time with one of two possible alternatives, the

workflow is to "jump back" to process sections of the workflow d fi i i idefinition again.

» The workflow system can make a decision based on the contents of the workflow container

Maintenance of While LoopsMaintenance of While Loops• You use the WHILE loop in a workflow definition if:

» At execution time, only one of several possible alternatives can be processed in the workflow from a business point of view, and h h i i b f d ithen the comparison is to be performed again.

» The workflow system can make a decision based on the contents of the workflow container.

» The decision can be formulated based on a comparison between

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

pan expression from workflow container and a finite amount of comparison values (constants, expressions).

Page 1065: Sap Abap Refresher Course NoRestriction

WORKFLOW BUILDER

ADDITIONAL TOPICS: SAP Business Workflow

WORKFLOW BUILDER

Maintenance of Forks • You use a fork in a workflow definition when the business process

can be continued by several users at the same time. You can also fi th f k i h th t t ll b h h t bconfigure the fork in such a manner that not all branches have to be

processed .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1066: Sap Abap Refresher Course NoRestriction

ADDITIONAL TOPICS: SAP Business Workflow

Events in Workflow Events in Workflow

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1067: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS

An event is created from any application program and published system-wide. Any number of receivers can react to the eventEvents that you want to use must be defined as components of an object type.Events are published without the creating application knowing whether a receiver reacts to them. The event manager checks whether there are active linkages for the published event

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1068: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS

• An event can be used as follows in SAP Business Workflow:• As a triggering event of a task or a workflow.

– When the event occurs, the task or workflow is started as a response.

• As a terminating event of a task. – When the event occurs, the task is terminated as a response.

• In workflow definition steps of the types event creator and wait• In workflow definition steps of the types event creator and wait for event

• If you use events only within SAP Business Workflow, the linkages required are created automatically by the workflowlinkages required are created automatically by the workflow system. You can edit existing linkages .

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1069: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS

• EVENT CREATION • Events can be created in following ways :

• Function Module like SWE_EVENT_CREATE• Change Documents : Events are created when change documents are

written• General Status Management : Events creation at status changes• Message ControlMessage Control• LIS : Event creation when an exception situation occurs• Business Transaction Events• HR Master Data : Event creation when HR Master data changes

• You can used ‘Wizard’ for Event Creation

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1070: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS• EVENT CONTAINER

Th t t i t i th t t t i• The event container contains the event parameters as container elements.

• If you define triggering events or terminating events for a task, you can specify the binding from the event container to the taskcan specify the binding from the event container to the task container.

• If you define triggering events for a workflow, you can specify the binding from the event container to the workflow container

• You define a binding from the workflow container to the event container in the definition of an event creator.

• You define a binding from the event container to the workflow i i h d fi i i f icontainer in the definition of a wait step.

• The event container contains workflow system elements as standard. You can add more container elements to the event container within object type definition in the Business Object

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

container within object type definition in the Business Object Builder

Page 1071: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS• USING LINKAGESUSING LINKAGES

• A linkage defines the assignment of events to the event receivers interested in them

• The potential receiver of an event must define the linkage. This p gcan be done using function modules provided or a maintenance transaction

• The workflow system in the form of the event manager evaluates ll h d I d i hi h iall the events created. In doing this, the event manager carries out

the following steps:

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1072: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1073: Sap Abap Refresher Course NoRestriction

EVENTS

ADDITIONAL TOPICS: SAP Business Workflow

EVENTS• Receiver Type Function Module

Y t i t f ti d l f th li k t• You can enter a receiver type function module for the linkage to determine a receiver type at runtime . The interface of the receiver type function module is described in the documentation for the function module SWE_TEMPLATE_RECTYPE_FB . This _ _ _function module can be used as a template and is stored in the function group SWE_TEMPLATE .

• Check Function Module • You can enter a check function module for the linkage to decide

whether the receiver function module should actually be called. The data in the event container can be used for this

R i F ti M d l• Receiver Function Module • A receiver function module must be entered for each linkage,

which executes the actual reaction to the event

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG

Page 1074: Sap Abap Refresher Course NoRestriction

Thank YouThank You

SAP PMG Delivering Solution Excellence and InnovationSatyam SAP PMG