Sie sind auf Seite 1von 729

Basic ABAP

Objectives
On Completing this course, participants will be able to

Understand the Structure of ABAP Program Work with ABAP Editor Declare Data Types and Data Objects Understand the internal tables and its types Work with internal tables Understand modularization Techniques Use message class Use Open SQL Statements for processing

ABAP Basics
Advanced Business Application Programming

The programming language for SAP


Platform independent Designed for dialog based Business Applications Enables multi-language Applications SAP R/3 written in ABAP ABAP Editor (Tcode - SE38) is used for creating simple ABAP Programs.

ABAP Basics - Introduction


Structure of an ABAP Program

ABAP Processing logic is responsible for processing data in R/3 application Programming

Declaration Part for Global Data

Dialog Module s

Event Blocks

Subroutines

etc..

Structure of ABAP Program


ABAP Programs cannot be constructed as a single sequential unit, but divided into sections that is assigned to individual dialog steps. To do this, ABAP Programs have a modular structure called Processing Block Processing Block consists of Set of ABAP Statements Every ABAP Program has the following 2 parts Declaration Part for Global Data , Classes and Selection Screens Container for Processing Blocks

Structure of ABAP Program (Contd.).


Declaration Part for Global Data , Classes and Selection Screens

Contains all declaration Statements for Global Data


Global Data is visible in all internal processing blocks Defined using Declarative Statements Appears before the first Processing Block Cannot declare Global Data in Dialog Modules or Event Blocks

All Selection Screen Definition

All Local Class Definition Local Classes are part of ABAP Objects (OO ABAP)

Structure of ABAP Program (Contd.).


Container for Processing Blocks Dialog Modules Event Blocks

Procedures
Methods Subroutines Function Modules

Structure of ABAP Program (Contd.).


Calling Processing Blocks
Using ABAP Commands , which is a part of processing block
E.g. : Procedures

Outside the ABAP Program


E.g. : Dialog Modules and Event Blocks
Event Block Triggered by an Event

Simple ABAP Program


Go to Transaction Code : SE38 ( ABAP Editor)

Simple ABAP Program (Contd.).

ABAP Program - Attributes


Type Status Application

Authorization Group
Development Class

Simple ABAP Program - Program Type


Specifies the Type of Program Created Executable Program
Controlled by Run-time Environment, which calls the processing blocks in a fixed sequence An Executable Program can be started in another ABAP Program using the SUBMIT Statement

Simple ABAP Program - Program Type


Referred as Reports because the main task of Executable program is to read data from the Database, Process and Display the results. Need not define Event Blocks START-OF-SELECTION is a processing Block which is available by Default A Transaction Code can be assigned

Module Pool Program

ABAP Program Program Type (Contd.).

Can Only Be controlled using Screen Flow Logic Must Start them using a Transaction Code Must Define Your own Screen Contains Dialog module belonging to various Screens Used when the program contains large number of screens whose flow logic determines the Program Flow

ABAP Program Program Type (Contd.).


INCLUDE Programs To Divide Program code into Smaller , more manageable Units INCLUDE Statement is used to insert the coding of an include program FUNCTION GROUPS Special Procedures that can be called from ABAP Programs

Cannot be started using a Transaction Code

ABAP Program Program Type (Contd.).


Subroutine Pool Containers for Subroutine which can be called from ABAP Programs

Cannot Run using transaction Code or by entering Program name


Cannot contain Screens

ABAP Program Program Type (Contd.).


Interface Pool Container for Global Interfaces in ABAP Objects

Creates in Class Builder Cannot Run using transaction Code or by entering Program name

ABAP Program Program Type (Contd.).


Class Pool Containers for Global Classes in ABAP Objects Cannot Run using transaction Code or by entering Program name Type-Pool Contains global type definitions and constant declarations

ABAP Program - Attributes


Status
Describes the status of Program Development

Application
Contains the short form of application Enables system to allocate the program to correct Business area

ABAP Program - Attributes


Authorization Group
Name of the program group To group different programs together for authorization checks

Logical Database
Determines the Logical Database used by Executable Program

ABAP Program - Attributes


Selection Screen
To specify a selection-screen other than the standard LDB selection screen. Specify a screen number less than 1000 ( 1000 reserved for standard selection screen number)

ABAP Syntax
The following rules in general applies to ABAP syntax
ABAP Programs comprises of individual sentences The first word in the statement is the ABAP keyword Each statement ends with a period (.)

ABAP Program
First ABAP Program
REPORT ZFIRSTPRG. WRITE 'MY FIRST PROGRAM'.

In the above program REPORT and WRITE are keywords. On Execution , this program displays a list on screen which contains a line

ABAP Statements
Chained Statements
Used to concatenate statements The chain operator used is : Example
Statement sequence: WRITE var1. WRITE var2. WRITE var3. Chain Statement: WRITE : var1, var2, var3.

ABAP Statements (Contd.).


Chained Statements
Example
Statement Sequence sum = sum + 1. sum = sum + 2. sum = sum + 3. Chained Statement: sum = sum + : 1, 2, 3.

Define data types

ABAP Statements - Declarative Statements

Declare Data Objects Examples


TYPES DATA TABLES

Define the processing blocks in ABAP Program


Defining Keywords

ABAP Statements - Modularization Statements

To define Subroutines, Function Modules, Dialog Modules and Methods


Examples METHOD...END METHOD FUNCTION ......END FUNCTION MODULE ..END MODULE

ABAP Statements
Control Statements
Used to control the flow of program within the processing block Examples:
IF, WHILE, CASE

Call Statements
Used to call the processing block Examples:
CALL METHOD , CALL TRANSACTION, SUBMIT, LEAVE TO

Data Types and Data Objects


Data Types Elementary Types Smallest indivisible unit Fixed Length 8 predefined types in ABAP C Character N Numeric Character D Date T Time X Hexa Decimal Byte Field I Integer P Floating Point Number F Packed Number Variable Length STRING XSTRING

Standard Data Types


Predefined Elementary Types
Data Type Initial Field Length Valid Field Length Initial Value

Numeric Types I P F 4 8 8 4 8 1-16 0 0 0.0000000E+0 0 00

Character Types C N 1 1 1 65535 1 65535

D
T

8
6 Hexa Decimal

8
6

00000000
000000

1-65535

X00

Data Types (Contd.).


Local Elementary Data Types are defined with reference to predefined elementary types
Syntax: TYPES <t>[(<length>)] [TYPE <type>|LIKE <obj>] [DECIMALS <dec>]
Where type is a predefined data type.. If TYPE or LIKE is not used , system takes the default type C

Data Types (Contd.).


Reference Types
Describes Data Objects that contain references to other objects No predefined references

Complex Types
Allows to manage and process related data under a single name

Data Types - Complex Data Types


Structures Sequence of any elementary types, reference types or complex data types Used in ABAP Programs to group work areas that logically belong together Example: TYPES : BEGIN OF address, name(20) TYPE c, street(30) TYPE c, city(20) TYPE c, END OF address.

Data Types - Complex Data Types


Internal Tables
Consists of series of lines which has the same data type Characterized By
Line Type
Elementary, Reference or Complex Type

The Key
Unique or non-Unique. Identifies Table Rows

What are Data Objects?


Physical units with which ABAP Statements work Instance of an abstract Data type Has a set of technical attributes Length Number of Decimal Places Data Type

Always defined with the DATA keyword


Can refer to an existing data object

Defining Data Objects


ABAP PROGRAM
Global Types ABAP Dictionary

TYPES gty_type_name TYPE . Predefined Data Types C I N P D F T X

DATA gd_myvar1 TYPE type_name. DATA gd_myvar2 LIKE gd_myvar1.

Named Data Objects


They are Data Objects which have a name Various Types Text Symbols Pointers to texts in the text pool of the ABAP program Variables Data Objects whose contents can be changed using ABAP statements Declared Using DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS statements

Constants Data Objects whose contents cannot be changed Declared Using CONSTANTS Statement. Example: CONSTANTS pi TYPE p DECIMALS 3 VALUE 3.141.

Pre-defined Data Objects


SPACE
Constant

Type C
Length - 1 byte Contains Space Character

System Fields from Structure SY


SY-SUBRC Return code for ABAP statements 0 - if a statement is executed successfully SY-UNAME logon name of the user SY-REPID: Current ABAP program SY-TCODE current transaction SY-INDEX Number of the current loop pass

Determining the attributes of Data Objects


Syntax: DESCRIBE FIELD <f> [LENGTH <l>] [TYPE <t> [COMPONENTS <n>]] [OUTPUT-LENGTH <o>] [DECIMALS <d>] [EDIT MASK <m>] [HELP-ID <h>].

Determining the attributes of Data Objects Cont.d..


Examples DATA : text(8) TYPE c, len TYPE i, typ TYPE c. DATA : fl TYPE f, out TYPE i, leng TYPE i. DESCRIBE FIELD text LENGTH len in CHARACTER MODE. DESCRIBE FIELD text TYPE typ. DESCRIBE FIELD fl LENGTH leng in BYTE MODE OUTPUT-LENGTH out Upon Execution, the value of len is 8 , typ is C, leng is 8 and out is 24.

Data Objects - Operations


Assigning Values
MOVE
MOVE source TO destination
Examples
MOVE 5.7 TO number. DATA : num1 TYPE i, num2 TYPE i. num1 = 10. MOVE num1 TO num2.

Data Objects Operations (Contd.).


Assigning Values MOVE-CORRESPONDING MOVE-CORRESPONDING sourcestruct TO destinationstruct Examples DATA : BEGIN OF address, fname(15) TYPE c VALUE Robert, lname(15) TYPE c VALUE David, compname(30) TYPE c VALUE WIPRO TECHNOLOGIES, number TYPE i VALUE 72, street(30) TYPE c VALUE Keonics Electronic City, city(10) TYPE c VALUE BANGALORE, END OF address. DATA : BEGIN OF name, lname(15) TYPE c , fname(15) TYPE c , END OF name. MOVE-CORRESPONDING address TO name.

Assigning Values
WRITE TO

Data Objects Operations (Contd.).


WRITE <f1> TO <f2> [<option>]. This statement converts <f1> to TYPE C and places the string in <f2> Example DATA : number TYPE f VALUE 4.38, text(10). WRITE number TO text . WRITE text.

Resetting Variables to Initial Values


CLEAR var. Resets var to appropriate initial value for its type Cannot use CLEAR to reset a CONSTANT Has different effect for different Data Types Elementary ABAP Types
Sets the value of the variable to initial value

References
Resets reference variable to initial value, so that it doesnt point to any object

Structures
Resets individual components of a structure to their respective initial values

Internal Tables
Deletes the entire contents of Internal Table

CLEAR var.
Example

Resetting Variables to Initial Values(Contd.).

DATA number TYPE i VALUE '10'. WRITE number. CLEAR number. WRITE number.
Output : 10 0

Type Conversions
When a Data Object is assigned to a variable the data types involved must be compatible or The source fields data type must be convertible into target fields data type. Two non-compatible data types can be converted to each other if a corresponding conversion rule exists Assignment Rules for Reference Variable The content of a reference variable can be assigned only to another reference variable. Data references can be assigned only to data reference variables Object references can be assigned only to object reference variables. No Conversion takes place during this assignments

Type Conversions (Contd.).


Conversion Rule for Structures No Conversion Rule for Structures that contain internal tables or strings Only assignment between structures that are compatible is possible

The system first converts all the structures concerned to type c fields and then performs the conversion between the two resulting elementary fields
Conversion Rule For Internal Tables Can only be converted into another internal table Internal tables which have internal tables as their line type are convertible if the internal tables which define the line types are convertible.

Numerical Operations
COMPUTE <n> = <expression>. COMPUTE is optional The interpretations of mathematical expressions are in the following order Expressions in parentheses Functions ** (powers) *, / , MOD, DIV (multiplication, division) +, - (addition, subtraction)

Arithmetic Operations
The following arithmetic operators are used in mathematical expressions:
Operator + _ Addition Subtraction Meaning

*
/ DIV MOD **

Multiplication
Division Integer division Reminder of Integer Division Powers

Arithmetic Calculations Using Structures


ADD-CORRESPONDING SUBTRACT-CORRESPONDING MULTIPLY-CORRESPONDING DIVIDE-CORRESPONDING

Example: DATA: BEGIN OF RATE, USA TYPE F VALUE '0.6667', FRG TYPE F VALUE '1.0', END OF RATE. DATA: BEGIN OF MONEY, USA TYPE I VALUE 100, FRG TYPE I VALUE 200, END OF MONEY. MULTIPLY-CORRESPONDING MONEY BY RATE. WRITE : MONEY-USA, MONEY-FRG.

Adding Sequences Of Fields


ADD <n1> THEN <n 2> UNTIL <n z> GIVING <m>. ADD <n1> THEN <n 2> UNTIL <n z> TO <m>. Example: DATA: BEGIN OF SERIES, N1 TYPE I VALUE 10, N2 TYPE I VALUE 20, N3 TYPE I VALUE 30, N4 TYPE I VALUE 40, N5 TYPE I VALUE 50, N6 TYPE I VALUE 60, END OF SERIES. DATA SUM TYPE I. ADD SERIES-N1 THEN SERIES-N2 UNTIL SERIES-N5 GIVING SUM. WRITE SUM. ADD SERIES-N2 THEN SERIES-N3 UNTIL SERIES-N6 to SUM. WRITE / SUM.

Date and Time calculations


Date and Time fields are of Character types But numeric operations can be performed The system performs automatic type conversions Example DATA: ultimo TYPE D. ultimo = SY-DATUM. ultimo+6(2) = '01'. ULTIMO = ULTIMO - 1. WRITE ultimo.

" first day of this month " last day of last month

Passing data between programs


Data can be passed between programs using the Internal Memory Areas There are two cross-program memory areas to which ABAP programs have access that can be used to pass data between programs SAP Memory ABAP Memory

Passing Data between Programs - SAP Memory


SAP memory is a memory area to which all main sessions within a SAPgui have access. SAP memory is used either to pass data from one program to another within a session, or to pass data from one session to another. Application programs that use SAP memory must do so using SPA/GPA parameters (also known as SET/GET parameters). These parameters can be set either for a particular user or for a particular program using the SET PARAMETER statement. Other ABAP programs can then retrieve the set parameters using the GET PARAMETER statement.

SPA/GPA
Filling an Initial Screen using SPA/GPA Parameters

SPA/GPA parameters are values that the system stores in the global, user-specific SAP memory.
SAP memory allows passing values between programs. A user can access the values stored in the SAP memory during one terminal session for all parallel sessions.

Each SPA/GPA parameter is identified by a 20-character code which is maintained in the Repository Browser in the ABAP Workbench.
The values in SPA/GPA parameters are user-specific.

SPA/GPA (Contd.).
Filling an Initial Screen using SPA/GPA Parameters

ABAP programs can access the parameters using the SET PARAMETER and GET PARAMETER statements.
To fill one, use: SET PARAMETER ID <pid> FIELD <f>. This statement saves the contents of field <f> under the ID <pid> in the SAP memory. If the ID <pid> does not exist, double-click <pid> in the ABAP Editor to create a new parameter object.

SPA/GPA (Contd.).
Filling an Initial Screen using SPA/GPA Parameters To read an SPA/GPA parameter, use: GET PARAMETER ID <pid> FIELD <f>. This statement fills the value stored under the ID <pid> into the variable <f>. If the system does not find a value for <pid> in the SAP memory, it sets SY-SUBRC to 4, otherwise to 0. To fill the initial screen of a program using SPA/GPA parameters, use the SET PARAMETER statement. On a selection screen, link fields to parameters using the MEMORY ID addition in the PARAMETERS or SELECTOPTIONS statement.

ABAP Memory
ABAP memory is a memory area that all ABAP programs within the same internal session can access using the EXPORT and IMPORT statements. Data within this area remains intact during a whole sequence of program calls. To pass data to a program which you are calling, the data needs to be placed in ABAP memory before the call is made. The internal session of the called program then replaces that of the calling program. The program called can then read from the ABAP memory. If control is then returned to the program which made the initial call, the same process operates in reverse.

Saving Data Objects in Memory


Any number of internal data objects of any complexity from an ABAP program can be stored temporarily in ABAP memory ABAP memory is a memory area within the internal session (roll area) of an ABAP program ABAP memory is independent of the ABAP program or program module from which it was generated. An object saved in ABAP memory can be read from any other ABAP program in the same call chain.

Data Objects in Memory


Data can be passed
From an executable program (report) to another executable program called using SUBMIT. From a transaction to an executable program (report). Between dialog modules.

Saving Data Objects in ABAP Memory


EXPORT <f1> [FROM <g 1>] <f 2> [FROM <g 2>] ... TO MEMORY ID <key>. Example
EXPORT text1 TO MEMORY ID text'.

Reading Data Objects From Memory


IMPORT <f1> [TO <g 1>] <f 2> [TO <g 2>] ... FROM MEMORY ID <key>. Example: IMPORT text1 to text2 FROM MEMORY ID 'text'.

Control Structures
Controlling the Program Flow
Logical Expressions
Operand1 operator operand2 Several Logical Expressions can be linked together with a condition

Checking For Initial Values


... IS INITIAL ...

Control Structures (Contd.).


Conditional Branching
The IF Control Structure
The Case Control Structure

Loops
Unconditional loops using the DO..ENDDO. Conditional Loops Using the WHILE .ENDWHILE.

Loops
Terminating Loops
Terminating Loop Pass Unconditionally
CONTINUE
EXIT

Terminate Loop Pass Conditionally


CHECK

Character Strings
Processing Character Strings
FIND
FIND [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern IN dobj.

REPLACE
REPLACE [{FIRST OCCURRENCE}|{ALL OCCURRENCES} OF] pattern IN dobj WITH new

TRANSALATE

Processing Character Strings

TRANSLATE text TO UPPER CASE.

TRANSLATE text TO LOWER CASE.


TRANSLATE text USING pattern

CONDENSE

Field Symbols
Placeholders or symbolic names for a Data Object. To Access Data Objects Dynamically in ABAP Programs Do not Physically reserve space for a field but points to its Contents Can point to any Data Object Allows the access of Data Objects whose name and attributes are not known till runtime

Field Symbols (Contd.).


Declaring Field Symbols
FIELD-SYMBOLS <fs> [typing].

Angle brackets are part of declaration


Typing specifies the type of field symbol

Assigning Data Objects to Field Symbols

Field Symbols - Example


TYPES: BEGIN OF LINE, COL1, COL2, END OF LINE.

DATA: WA TYPE LINE, ITAB TYPE HASHED TABLE OF LINE WITH UNIQUE KEY COL1, KEY(4) VALUE 'COL1'. FIELD-SYMBOLS <FS> TYPE ANY TABLE. ASSIGN ITAB TO <FS>. READ TABLE <FS> WITH TABLE KEY (KEY) = 'X' INTO WA.

To assign a data object to a field symbol, use the ASSIGN statement ASSIGN <f> TO <FS>.

Assigning Data Objects To Field Symbols

When the data object is assigned, the system checks whether the technical attributes of the data object <f> correspond to any type specifications for the field symbol <FS>.

Field Symbols - Example


FIELD-SYMBOLS: <F1>, <F2> TYPE I. DATA: TEXT(20) TYPE C VALUE 'Hello, how are you?', NUM TYPE I VALUE 5, BEGIN OF LINE1, COL1 TYPE F VALUE '1.1e+10', COL2 TYPE I VALUE '1234', END OF LINE1, LINE2 LIKE LINE1. ASSIGN TEXT TO <F1>. ASSIGN NUM TO <F2>. DESCRIBE FIELD <F1> LENGTH <F2>. WRITE: / <F1>, 'has length', NUM.

Creating Simple Reports


Simple output lists on the screen can be created by using the ABAP statements
WRITE ULINE

SKIP

When an executable program is

Simple Reports
WRITE Statement
The basic ABAP statement for displaying data on the screen is WRITE.
WRITE <f>.

The field <f> can be


Any Data Object

Output Format of Predefined Data Types


Data Type I P F C N D T Positioning Right-Justified Right-Justified Right-Justified Left-Justified Left-Justified Left-Justified Left-Justified

Syntax

Positioning WRITE Output on the List


WRITE AT [/][<pos>][(<len>)] <f>.
the slash '/' denotes a new line, <pos> is a number or variable up to three digits long denoting the position on the screen <len> is a number or variable up to three

Formatting Options for all Data Types


WRITE .... <f> <option>.
Function Option
Left-Justified

Output is left-justified. Output is centered. Centered Right-Justified Output is right-justified. Output starts directly under field Under <g> <g>. The blank after field <f> is omitted. NO-GAP Specifies format template <m>. Using Edit Mask(m) Using No Edit Deactivates a format template

Formatting Options for numeric fields


Option NO-SIGN Function The leading sign is not displayed on the screen. DECIMALS <d> defines the number of digits <d> after the decimal point. EXPONEN In type F fields, the exponent is T <e> defined in <e>. ROUND Type P fields are multiplied by <r> 10**(-r) and then rounded. CURRENC Format according to currency Y <c> <c> in table TCURX. UNIT <u> The number of decimal places is

Displaying Symbols and Icons on the List

WRITE <symbol-name> AS SYMBOL. WRITE <icon-name> AS ICON.

Example
INCLUDE <symbol>. INCLUDE <icon>. WRITE: / 'Telephone symbol:', sym_phone AS SY MBOL. WRITE: / 'Alarm icon: ', icon_alarm AS ICON.

Drawing Lines
Horizontal lines ULINE [AT [/][<pos>][(<len>)]]. WRITE [AT [/][<pos>][(<len>)]] SYULINE. WRITE [AT [/][<pos>][(<len>)]] '-----...'. Vertical Lines

Individual Page Header

Modifying the Structure of Lists

To layout a Page Header the event keyword TOP-OF-PAGE must be defined. The TOP-OF-PAGE event occurs as soon as the system starts processing a new page of a list The system processes the statements following TOP-OF-PAGE before outputting the

Determining The List Width


LINE-SIZE option of the REPORT statement is used to determine the width of the output list.

REPORT <rep> LINE-SIZE


<width>.

If the <width> is set to zero, the system uses the width of the standard list.

Page length of an output list, is determined using the LINE-COUNT option of the REPORT statement.

Determining the Page Length

REPORT <rep> LINE-COUNT <length>[(<n>)].


This statement determines the page length of the output list of program <rep> as <length> lines.

Defining a Page Footer


END-OF-PAGE event is used to determine the footer This event occurs if the system reaches the lines reserved for the page footer, or if the RESERVE statement triggers a page break The system only processes the processing block following END-OF-PAGE if the lines

Simple Reports - Example


REPORT DEMO_LIST NO STANDARD PAGE HEADING LIN E-SIZE 40 LINE-COUNT 20(2). TOP-OF-PAGE. WRITE: 'Top of Page', SY-PAGNO. END-OF-PAGE. ULINE. WRITE: 'End of Page', SY-PAGNO. START-OF-SELECTION. DO 100 TIMES. WRITE / SY-INDEX.

Programming Page Breaks


The NEW-PAGE statement is used to program unconditional page breaks.
NEW-PAGE [NO-TITLE|WITH-TITLE] [NOHEADING|WITH-HEADING]. Ends the current page and does not trigger the END-OF-PAGE event System does not output a page footer even if one is defined.

Simple Reports - Example


REPORT DEMO_LIST LINE-SIZE 40 LINECOUNT 5(1). END-OF-PAGE. ULINE. START-OF-SELECTION. NEW-PAGE LINE-COUNT 5. DO 4 TIMES. WRITE / sy-index. ENDDO. WRITE: / 'Next Loop:'. NEW-PAGE LINE-COUNT 6. DO 6 TIMES. WRITE / sy-index. ENDDO.

Messages
Single texts stored in table T100 Maintained in Transaction SE91 Provides a way to communicate with the user Mostly used for error handling

Messages (Contd.).
The message class and number are used to identify the message in table T100. The message types are one of the following:
A E I S W : Termination Message : Error Message : Information Message : Status : Warning

Messages Statement
Using a Global Message Class
MESSAGE tnnn [WITH f1 ... f4] [RAISING exc].

Specifying the Message Statically


MESSAGE tnnn(id) [WITH f1 ... f4] [RAISING exc].

Specifying the Message Dynamically

Creating Message Class

Messages - Examples
MESSAGE i001(zmsgs).

MESSAGE i003(ZMSGS) WITH 'This is th

Selection Screen
Selection screens are a standardized user interface. It is used when the user has to give data input. Input parameters are primarily used to control the program flow, while users can enter selection criteria to restrict the amount of data read from the database.

Defining Selection Screens


PARAMETERS for single fields SELECT-OPTIONS for complex selections SELECTION-SCREEN for formatting the selection screen and defining user-specific selection screens

Enables the user to enter values for single fields on the selection screen Each parameter declared with the PARAMETERS statement appears as an input field on the relevant selection screen. PARAMETERS p[(length)] [TYPE type|LIKE obj] [DECIMALS d].

Defining Input Fields for Single Values

Internal Tables - Introduction


Two ways to process large quantities of data
Internal Tables
Dynamic sequential dataset in which all records have the same structure and a key Individual records can be accessed by index or keys

Internal Tables (Contd.).


Line Type
Can be any data type

The data type of an internal table is usually a Structure Each component of a structure is a column in internal table

Internal Tables - Key


Standard Key
Tables with Structured and non -structured row type : all Character Type columns Tables with Elementary line-type : entire line is the default key If line type is an internal table : no default key
Tables with non-structured row type :

Internal Tables - Table Type


Determines how ABAP accesses the individual entries Three Types
Standard Tables Sorted Tables Hashed Tables

Have an internal linear index

Internal Tables - Standard Tables

Records are accessed by index or keys The response time for key access is proportional to number of entries The key is always non-unique

Always saved sorted by the key Have an internal index

Internal Tables - Sorted Tables

Records can be accessed by table index or key Uses Binary Search for access

Has no linear index

Internal Tables - Hashed Tables

Only accessed using its key Key must be Unique

Uses Hash Algorithm for accessing records

Creating Internal Tables


Syntax:
TYPES type TYPE|LIKE tabkind OF linetype [WITH key] [INITIAL SIZE n].

DATA itab TYPE type|LIKE obj.


Example:
DATA : BEGIN OF str_mat, matno(18), matname(30),

Internal table objects


Internal tables are dynamic variable data objects. Like all variables, declare them using the DATA statement.

Like all other data objects, declare internal table objects using the LIKE or TYPE addition of the DATA statement.
DATA <itab> TYPE <type>|LIKE <obj> [WITH HEADER LINE]. Here, the LIKE addition refers to an existing table object in the same program.

Reference to Declared Internal Table Types

Use it as a work area when working with the internal table. When using internal tables with header lines, the header line and the body of the table have the same name. If there is an internal table with header line, to address the body of the table, place brackets after the table name

Reference to Declared Internal Table Types

The entire body of the table is addressed as a single Data Object The following operations are done on the entire Internal Table
Assigning Internal Tables Initializing Internal Tables

Operations on Entire Internal Table

Assigning Internal Tables


Syntax:
MOVE itab1 TO itab2. itab2 = itab1. or

Example:
DATA : it_mat LIKE TABLE OF str_mat, it_mat1 LIKE TABLE OF str_mat. str_mat-matno = 'm01'. str_mat-matname = 'Notepads'.

Initializing Internal Tables


CLEAR itab.
The memory space required for the table is released, except for the initial memory requirement.

REFRESH itab
This always applies to the body of the table. With REFRESH, too, the initial memory

Processing Internal Tables


Sorting Internal Tables
Syntax
SORT itab [ASCENDING|DESCENDING] [AS text] [STABLE].

Determining the Attributes of Internal Tables

2 ways to access the individual table entries


Access Using a Work Area

Access Methods to Individual Table Entries

While accessing individual table entries, the data in the table is not directly accessed but through another Data Object like a Work Area Work Area is an interface to the entries in the Internal Table Work Area must be compatible with the line type of

Access using Field Symbols

Access Methods to Individual Table Entries

A line of the Internal Table is assigned to the Field Symbol i.e., the Field Symbol will have the same line type as the Internal Table Once an entry is assigned to the Field Symbol, working with it is like accessing the line of the Internal Table directly.

To Insert Individual Row at a Specific Position

Filling Internal Tables Line By Line

INSERT wa INTO TABLE itab. To Append Rows to the Internal Table APPEND wa TO itab.

Filling Internal Tables


Standard Tables
Lines are always Appended to the end of the Internal Table.

Sorted Tables
The lines are inserted into the table according to the table key

Inserting Lines
Inserting Several Lines
To insert several lines into the internal table use
INSERT LINES OF itab1 [FROM n1] [TO n2] INTO TABLE itab2.

Inserting Lines Using The Index


Inserting a Single Line

Appending Lines
Appending a Single Line
APPEND line TO itab.

Appending Multiple Lines


APPEND LINES OF itab1 TO itab2.

Reading Lines of Table


To Read a Single Line
READ TABLE itab key result.

If the system finds an entry it sets the system field SY-SUBRC to 0 and if not, it sets the value to 4.

Specifying The Search Key

Syntax: LOOP AT itab result condition. statement block ENDLOOP.

Processing Table Entries in Loops

The sequence in which lines are processed depends on the table type
Standard and Sorted Table
The lines are processed according to linear index

Loop blocks can be nested

Processing Table Entries in Loops (Contd.).

After the ENDLOOP, SY-SUBRC = 0 , if at least one table entry is processed. The loop may not contain any operations which may change the contents of the entire table

Changing Lines
Changing Lines of an Internal Table
MODIFY TABLE itab FROM wa [TRANSPORTING f1 f2 ...].

Changing Table Lines Using a Condition


MODIFY itab FROM wa TRANSPORTING f1 f2 ... WHERE cond.

Deleting Lines
DELETE TABLE itab FROM wa.
Deletion Using Table Key
DELETE TABLE itab WITH TABLE KEY k1 = f1 ... kn = fn.

Deletion Using a Condition


DELETE itab WHERE cond.

Deleting Lines Contd..


Deleting a line specifying the Index DELETE itab [INDEX idx]. Deleting Several Lines
DELETE [FROM n1] [TO n2] [WHERE condition].

Control Level Processing


Its for internal tables accessed using Loops Internal tables are divided into groups according to the sequence of the fields in the line structure. The first column defines the highest control level and so on.

Within the processing block of the loop, the control level statement AT is used to react to a control level change

Control Level Processing (Contd.).

The SUM statement to calculate totals from subsets of all lines


The AT statement introduces a statement block that is end with the ENDAT statement.

Control Level Statements are used to react to control breaks in internal tables instead of programming them with logical expressions According to the hierarchy of the control levels , the AT-ENDAT statements must be placed within the Loop. All character fields to the right of the

Control Level Processing (Contd.).

Open SQL
Subset of Standard SQL Enable the ABAP programs to access data irrespective of the database system installed Open SQL consists of the Data Manipulation Language (DML)

Open SQL allows to read (SELECT) and

Native SQL
Loosely integrated into ABAP Allows access to all of the functions contained in the programming interface of the respective database system Native SQL statements are not checked and converted, but sent directly to the database system

Open SQL
Open SQL consists of a set of ABAP statements that perform operations on the central database in the SAP Web AS ABAP Open SQL provides a uniform syntax and semantics for all of the database systems supported by SAP ABAP programs that only use Open SQL

Keywords used in Open SQL


Keyword Function
SELECT INSERT UPDATE MODIFY Reads data from database tables Adds lines to database tables Changes the contents of lines of database tables Inserts lines into database tables or changes the contents of existing lines Deleting Lines from Database Tables Reads lines of database tables

DELETE OPEN

Open SQL - Return Codes


All Open SQL statements fill the following two system fields with return codes:
sy-subrc
After every Open SQL statement, the system field sy-subrc contains the value 0 if the operation was successful, a value other than 0 if not.

sy-dbcnt

Open SQL - Client Handling


Open SQL Statements use automatic Client-handling The condition for the client field cannot be specified in the WHERE clause of the open SQL statement. If the client has to be specified in an Open SQL statement, use ... CLIENT SPECIFIED .... Directly after

Open SQL - Reading Data


Select Statement Syntax:
SELECT result INTO target FROM source [WHERE condition] [GROUP BY fields] [HAVING cond] [ORDER BY fields].

Open SQL Select Statement (Contd.).


Clause Description \
SELECT result The SELECT clause result defines the structure of the data that is to be read. i.e., single or several lines, column to be read, and for identical entries INTO target Determines the target area into which the selected data is to be written FROM Specifies the Database Table or View from source which the data is to be selected. WHERE Specifies the condition for Selection cond GROUP BY Produces a single line of results from a fields group of several lines. A group is a set of lines with identical values for each column listed in fields

Defines the structure of a result set which is to be read from the database A single SELECT statement can perform functions ranging from simply reading a single line to executing a very complicated database query Aggregate functions can be applied to individual columns.

Open SQL - Defining a Selection

Open SQL - Example


Specifying a flat work area as the target.
SELECT ... INTO [CORRESPONDING FIELDS OF] wa ...
DATA wa TYPE spfli.

SELECT * INTO CORRESPONDING FIELDS O F wa FROM spfli WHERE carrid EQ 'LH'. WRITE: / wa-carrid, wa-connid, wacityfrom, wa-cityto.

Open SQL - Example


Specifying an internal table as the target.
SELECT ... INTO|APPENDING [CORRESPONDING FIELDS OF] TABLE itab [PACKAGE SIZE n] ... DATA wa TYPE spfli. DATA it_spfli LIKE TABLE OF wa.

SELECT * INTO TABLE it_spfli FROM spfli WH ERE carrid EQ 'LH'.

LOOP AT it_spfli INTO wa.

Open SQL - Reading Aggregate Data for Columns


The expression agg represents one of the following aggregate functions:

SELECT lines agg( [DISTINCT] s1) [AS a1] agg( [DISTINCT] s2) [AS a2] ...

MAX: supplies the maximum value of the column MIN: supplies the minimum value of the column AVG: supplies the average value of the column

Example

Open SQL Aggregate Functions

DATA: average TYPE p DECIMALS 2, sum TYPE p DECIMALS 2. SELECT AVG( luggweight ) SUM( luggweight ) INTO (average, sum) FROM sbook.

WRITE: / 'Average:', average, / 'Sum

:', sum.

Examples

Open SQL - Specifying Columns Dynamically

DATA: itab TYPE STANDARD TABLE OF spfli, wa LIKE LINE OF itab. DATA: line(72) TYPE c, list LIKE TABLE OF line(72). line = ' CITYFROM CITYTO '. APPEND line TO list. SELECT DISTINCT (list) INTO CORRESPONDING FIELDS OF TABLE itab FROM spfli.

Example

Open SQL Reading Individual Line

DATA wa TYPE spfli.

SELECT SINGLE carrid connid cityfrom cityto INTO CORRESPONDING FIELDS OF wa FROM spfli WHERE carrid EQ 'LH' AND connid EQ '0400'.
IF sy-subrc EQ 0. WRITE: / wa-carrid, wa-connid, wa-cityfrom, wacityto. ENDIF.

Example:

Open SQL - Disable Automatic Client Handling


DATA wa TYPE spfli.

DATA name(10) TYPE c VALUE 'SPFLI.


SELECT * INTO wa FROM (name) CLIENT SPECIFIED WHERE mandt = '000'. WRITE: / wa-carrid, wa-connid. ENDSELECT.

Open SQL - Inner Join


Data From more than 1 table is read in a single select statement, such that the data in all tables has to meet the same condition.
SELECT ... ... FROM tab [INNER] JOIN dbtab [AS alias] ON cond options

Open SQL - Inner Join


Example
SELECT p~carrid p~connid f~fldate b~bookid INTO CORRESPONDING FIELDS OF TABLE itab FROM ( ( spfli AS p INNER JOIN sflight AS f ON p~carrid = f~carrid AND p~connid = f~connid ) INNER JOIN sbook AS b ON b~carrid = f~carrid AND b~connid = f~connid AND b~fldate = f~fldate )

Open SQL Left Outer Join


Specifying Two or More Database Tables as a Left Outer Join
In an inner join, a line from the left-hand database table or join is only included in the selection if there is one or more lines in the right-hand database table that meet the ON condition cond. The left outer join, on the other hand, reads lines from the left-hand database table or join

Open SQL - Left Outer Join


Example
SELECT s~carrid s~carrname p~connid INTO CORRESPONDING FIELDS OF TABLE itab FROM scarr AS s LEFT OUTER JOIN spfli AS p ON s~carrid = p~carrid AND p~cityfrom = 'FRANKFURT'.

Open SQL
Values in Intervals
SELECT... WHERE s NOT BETWEEN f1 AND f2...

Checking List of Values SELECT... WHERE s NOT IN (f1,......, fn)...

Open SQL (Contd.).


Checking for Null Values
SELECT... WHERE s IS NOT NULL...

Negating Conditions
SELECT... WHERE NOT cond... Linking Conditions

Open SQL - Dynamic Conditions


SELECT... WHERE (itab)...
SELECT... WHERE cond AND (itab)...

Example

Open SQL Dynamic Conditions

DATA: cond(72) TYPE c, itab LIKE TABLE OF cond. PARAMETERS: city1(10) TYPE c, city2(10) TYPE c. DATA wa TYPE spfli-cityfrom. CONCATENATE 'CITYFROM = ''' city1 '''' INTO cond. APPEND cond TO itab. CONCATENATE 'OR CITYFROM = ''' city2

Open SQL - Grouping Lines


The GROUP-BY clause summarizes several lines from the database table into a single line of the selection

To use the GROUP-BY clause, all of the relevant columns in the SELECT clause must be specified.
Example

The HAVING clause uses conditions to restrict the number of groups selected. The HAVING clause can be used only in conjunction with the GROUP-BY clause.
SELECT lines s1 [AS a1] s2 [AS a2]... agg sm [AS am] agg sn [AS an]... GROUP BY s1 s2.... HAVING cond.

Open SQL - Selecting Groups of Lines

Open SQL - Sorting


Specifying a Sort Order
The ORDER BY clause sorts the lines in the selection according to the contents of their columns Sorting by the Primary Key
SELECT lines * ...ORDER BY PRIMARY KEY.

Sorting by any Columns

Open SQL - SubQueries


A sub query is a special SELECT statement containing a sub query within particular conditions of the WHERE or HAVING clauses It cannot be used in the ON condition of the FROM clause
SELECT carrname INTO TABLE name_tab FROM scarr WHERE EXISTS ( select * FROM spfli WHERE carrid =

Open SQL - Insert


Inserting Lines into Table INSERT INTO <target> <lines>.
One or more lines can be inserted into the database table <target>.

Inserting a Single Line


INSERT INTO <target> VALUES <wa> .

Open SQL Insert


Inserting Several Lines
INSERT <target> FROM TABLE <itab> [ACCEPTING DUPLICATE KEYS].

Open SQL - Update


To Change data in the Database Table
UPDATE <target> <lines>.

UPDATE <target> SET <set1> <set 2> ... [WHERE <cond>]. UPDATE <target> FROM <wa> .
UPDATE <target> FROM TABLE <itab>.

Open SQL - Delete


To delete Lines from the Database Table
DELETE [FROM] <target> <lines>. DELETE FROM <target> WHERE <cond> . DELETE <target> FROM <wa>. DELETE <target> FROM TABLE itab <wa>.

Open SQL - Modify


Inserting or Changing Lines
To insert lines into a database table regardless of whether there is already a line in the table with the same primary key
MODIFY <target> <lines>. MODIFY <target> FROM <wa> MODIFY <target> FROM TABLE <itab>.

Committing Database Changes

Open SQL Commit Rollback

For confirming or undoing database updates

COMMIT WORK always concludes a database LUW and starts a new one ROLLBACK WORK always undoes all changes back to the start of the database LUW.

Native SQL
Native SQL statement begins with the EXEC SQL statement, and ends with the ENDEXEC statement.

There is no period (.) after Native SQL statements.


Using inverted commas () or an asterisk (*) at the beginning of a line does not introduce a comment as it would in normal

Native SQL - Example


DATA: BEGIN OF wa, connid TYPE spfli-connid, cityfrom TYPE spfli-cityfrom, cityto TYPE spfli-cityto, END OF wa. DATA c1 TYPE spfli-carrid VALUE 'LH'. EXEC SQL PERFORMING loop_output. SELECT connid, cityfrom, cityto INTO :wa FROM spfli WHERE carrid = :c1 ENDEXEC.

Modularization Techniques
ABAP programs are modular in structure and made up of processing blocks Two kinds of processing blocks
Called from outside a program by ABAP runtime system
Event Blocks Dialog Modules

The modularization of ABAP programs in event blocks and dialog modules serves for general execution of ABAP programs

Modularization Techniques (Contd.).

Modularization in procedures and source code modules serves for


Improving the readability Maintainability of ABAP programs,

Defining Processing Blocks


Event Blocks
Introduced by an Event Keyword

Ends when the next processing block begins


Event keywords have the same name as the events to which they react

Dialog Modules

Procedures
Contains a set of statements, and are called from other ABAP programs Procedures are defined in ABAP Programs When the program is generated, they remain as standalone modules. Procedures have an interface for passing data, and can also contain local data.

Subroutines
Used for local modularization Generally called from the program from which it is defined Use subroutines to write functions that are used repeatedly within a program Defining Subroutines

Subroutines - Example
FORM header. WRITE: / 'Program started by', sy-uname, / 'on host', sy-host, 'date:', sy-datum, 'time:', sy-uzeit. ULINE. ENDFORM.

The USING and CHANGING additions in the FORM statement define the formal parameters of a subroutine

Subroutines - Parameter Interface

When a subroutine is called, all formal parameters must be filled with the values from the actual parameters
At the end of the subroutine, the formal parameters are passed back to the

Subroutines (Contd.).
Subroutines has the following formal parameters
Parameters Passed by Reference Parameters passed by Value

Parameters Passed By Reference


Parameters are listed after USING or CHANGING without VALUE addition

Subroutine - Example
DATA: num1 TYPE i, num2 TYPE i, sum TYPE i. num1 = 2. num2 = 4. PERFORM addit USING num1 num2 CHANGING sum. num1 = 7. num2 = 11. PERFORM addit USING num1 num2 CHANGING sum. FORM addit USING add_num1TYPE any add_num2 TYPE any CHANGING add_sum TYPE any. add_sum = add_num1 + add_num2. PERFORM out USING add_num1 add_num2 add_sum.

Subroutines - Pass by Value


The formal parameter occupies its own memory space The value of the actual parameter is passed to the formal parameter If the value of the formal parameter changes, this has no effect on the actual parameter

Pass By Value - Example


DATA: num TYPE i VALUE 5, fac TYPE i VALUE 0. PERFORM fact USING num CHANGING fac. WRITE: / 'Factorial of', num, 'is', fac. FORM fact USING value(f_num) TYPE I CHANGING f_fact TYPE i. f_fact = 1. WHILE f_num GE 1. f_fact = f_fact * f_num. f_num = f_num - 1. ENDWHILE. ENDFORM.

Function Modules
Function modules are procedures that are defined in special ABAP programs called function groups

Function groups act as containers for function modules that logically belong together.
Function groups and function modules are created in the ABAP Workbench using the

Types of Function Modules


Normal Function Module Remote Function Module Update Function Module

Function Groups
Function groups are containers for function modules Function Groups cannot be executed When a function module, is called the system loads the whole of its function group into the internal session of the calling program

Function Modules
INCLUDE L<fgrp>TOP.
FUNCTION-POOL <fgrp> TABLES : .. TYPES:..... DATA:. INCLUDE L<fgrp>U01. INCLUDE L<fgrp>U02. INCLUDE L<fgrp>U03. FORM .. .. ENDFORM.

INCLUDE L<fgrp>UXX.

FUNCTION <name> . ENDFUNCTION

INCLUDE L<fgrp>F<xx>.

INCLUDE.

Main Program SAPL<fgrp>

Include Programs

Function Modules (Contd.).


The main program SAPLfgrp contains nothing but the INCLUDE statements for the following include programs:
LfgrpTOP : This contains the FUNCTIONPOOL statement (equivalent for a function group of the REPORT or PROGRAM statement) and global data declarations for the entire function group.
LfgrpUXX : This contains further INCLUDE

Exception Handling
Exception handling is the integral part of the designing the application. By raising the exception, we are providing the opportunity to the Caller program to handle the exception in its own way. When creating a reusable component like the Function Module,
Create the exception,

Exception Handling (Contd.).


In the Function module, there are situations when it is not advisable to process further because of, for example, missing data, conversion, etc. At that point of time, raise the excepetion. For this, we need to define the Exception under the tab "Exception" in the Function Builder.

Remote Function Module


RFC Interface
A remote function call is a call to a function module running in a system different from the caller's. The remote function can also be called from within the same system (as a remote call), but usually caller and callee will be in different systems

RFC consists of the following interfaces:


A calling interface for ABAP programs
Any ABAP program can call a remote function using the CALL FUNCTION.. DESTINATION statement. The DESTINATION parameter tells the SAP System that the called function runs in a system other than the caller's. RFC communication with the remote system happens as part of the CALL FUNCTION

RFC Function Module Interfaces

Calling interfaces for non-SAP programs


When either the caller or the called partner is a non-ABAP program, it must be programmed to play the other partner in an RFC communication.

RFC Function Module Interfaces

To help implement RFC partner programs in non-SAP Systems, SAP provides External Interfaces

Update Function Module


It is for Execution in Update Task The update Function is not Remotely Callable All database updates are processed at the end of the SAP LUW in contrast to normal FM call where the database updates are done and commited at the time of call (Database LUW).

When the Function Module is created, the Process Type Attribute is set to
Start Immediately
Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions can be restarted by the update task in case of errors.

Update Function Module (Contd.).

Immediate start but no restart


Set this option for high priority ("V1") functions that run in a shared (SAP LUW). These functions may not be restarted by the update task.

Source Code Modules


Sequence of ABAP Statements are placed in a module When the program is generated, the source code in the modularization unit is treated as though it were actually physically present in the main program ABAP Contains two source code modules

Macros
When the same set of statements has to be reused more than once in a program, it can be included in a Macro.

Macro can only be used within the program in which it is defined.


These statements can contain up to nine placeholders (&1, &2,...., &9).

Macros Example
DATA: result TYPE i, n1 TYPE i VALUE 5, n2 TYPE i VALUE 6. DEFINE operation. result = &1 &2 &3. output &1 &2 &3 result. END-OF-DEFINITION. DEFINE output. write: / 'The result of &1 &2 &3 is', &4. END-OF-DEFINITION.

Include Programs
They are global R/3 Repository objects The functions of Include Programs are
Library
It allows the usage of same source code in different programs

Order

Naming Standards
The names of specific developed objects are identified, at the beginning of the word (mostly), by characters Y or Z.
First character Y is reserved for Core system First character Z is reserved for Local systems

When standard SAP object will be copied, original name will be preceded by Y for a core development and Z for a local one.

Packages allow a grouping of development objects and facilitate the configuration management.

Naming Standards Packages

They guarantee that all objects of a topic are correctly transported.


Every specific object must be linked to a development class if it must be transported.

Data Dictionary

Data Dictionary
Data Definitions are created and Managed in ABAP Dictionary Describes the logical structure of objects use in application development Provides standard functions for editing fields on screens

ABAP Dictionary
Object Types in ABAP Dictionary are
Tables
Defined in Dictionary Independent of Database

Views
Logical Views

Types
Data elements Structures Table Types

Domain

Data Dictionary
Integration in ABAP Workbench
DEVELOPMENT ENVIRONMENT
ABAP Tools Data Modeler Screen Painter

ABAP Dictionary

ABAP Interpreter

Dialog Control

Interfaces .

Screen Interpreter

Runtime Environment Of The Application

Data Dictionary
Integration with ABAP Runtime Environment
Changes can be made to the Dictionary Objects before being activated Objects can both be Active and Inactive in the ABAP dictionary Inactive Objects have no effect on runtime System

Basic Objects
Domain
Contains Technical Characteristics of a Field
Field Length
Data Type

Defines a Value Range


Can be restricted by defining Fixed Values

Domain
Fixed Values
Used to restrict the values in the Domain Used in input check in screen templates If no other help is defined in field, Fixed Values are offered in F4 help. Value Range or Intervals can be defined by specifying the upper and lower limits

Domain
Fixed Values
Fixed Values are defined only for the following data types
CHAR NUMC DEC INT1 INT2 INT4

Domain
Relationship between Field, Data Element and Domain Data Type and Field Length are consistent
TABLE 1 TABLE 2 TABLE 3

DATA ELEMENT 1

DATA ELEMENT 2

DOMAIN

Tables
Value Tables
When a domain is defined, all the table fields or structure component referring to this domain can be checked against a table, the Value Table

A check is not implemented by simply entering a value table. The check against the value table only takes

Data Elements
Specifies the Semantic Characteristics of a Field Describes an elementary type or a Reference Type
Elementary type is defined by built-in data type and length These attributes can be defined directly or

Data Elements
Contains Field Label
Field Labels are used to display a screen field

F1 Documentation
The text appearing in the Field Help (F1 Help) comes from the documentation If there is no Documentation, the short text

Tables - Introduction
Defined Independent Of Database Fields are defined with Data types and Length On activation of the Table, a physical table definition is created in the database Table Types
Transparent Tables

Transparent Tables
One-to-one relationship with tables in database Most commonly Used Holds Application data
Master data or Transaction data Used by an application

Pooled Tables
Many-to-One Relationship with the table in Database SAP Proprietary Construct Stored in a Table Pool
Table Pools Hold large number of small Tables

Pooled Tables (Contd.).


Holds CUSTOMIZING data
Codes, Field Validations, number ranges, parameters Country Code table, Exchange Rate Table, etc..,

Data in Customizing Table is set by Functional Consultant during the initial

Pooled Tables (Contd.).


Definition of table pool contains 2 Key fields
Pooled Table TAB A Tabname Table Pool in Database Varkey (Contains Entry from all key fields) A B C TAB A
Key Data

A D

C E F

TAB B Pooled Table TAB B Tab name D E F

Var Key

DataLn

Vardata

Key

Data

Cluster Table
Many-to-One relationship with table in database Cluster tables are stores in Table Cluster in Database Used when the tables have a part of Primary Key in common

Data accessed Simultaneously

Pooled and Clustered table


Restrictions
Secondary Indexes cannot be created

Cannot Use ABAP/4 Constructs


Select DISTINCT GROUP BY

Cannot Use Native SQL

Cannot Specify Field names in ORDER BY

Tables
Components
Table Fields

Technical Settings
Foreign Keys Indexes

Table Fields
Field Name
Should begin with an Alphabet

Key Flag
Determines the Primary Key

Field Type
Data Type

Field Length Decimal Places


Number of Decimal Places

Short Text

Reference Fields required for the following Data Type


QUAN CURR

Reference Tables and Reference Fields

Reference Fields should of Type


UNIT CUKY

Reference Fields can be in the same table

Technical Settings
Data Class
Defines the physical area of the database in which tables should be created

Size Category
Defines the Expected Space for the table in the Database

Buffering Permission
Define whether and how a table is buffered

Buffering Type
Full-Buffering

Tables Buffering Types


Types
Full Buffering
Either the Full table is Buffered or The full table is not buffered Buffered Data Records Sorted by Table Key

When to Use
Tables up to 30KB Table Accessed Frequently Most Read Access

Types

Tables Buffering Types (Contd.).


When a record of the table is accessed, all the record whose generic key field match that record is buffered

Generic Buffering

When to Use
When Certain areas of table are normally used for processing Client-Specific Tables Language Specific Tables

Types

Tables Buffering Types (Contd.).


Only records that are actually read Requires less storage space More DB accesses are necessary to load the records

Single Record Buffering

When to Use
Select SINGLE is used mostly Record Size Between 100 200 KB

Tables - Transparent
Creation of Tables
Top-Down Approach
Table is first created Domain and Data element are created after creation of Table Easier to Use

Bottom-Up Approach
Domain and Data element are created More intuitive for first timers Cumbersome

Key Fields must be stored at the beginning of the field list Non-Key fields may not occur between two key fields Maximum of 16 key fields per table is allowed

Constraints of Tables Creation

Table may not have more than 249 fields

The same process as BOTTOM-UP is followed except for the order of execution Create Table in SE11. Specify Field name and a Data Element( which is yet to be created) Double click on the new Data Element Name

Tables Creation Top-Down Approach

Indexes
Copy of Database Table reduced to certain fields Always in sorted form Provides faster access to data records Contains a pointer to corresponding record of actual table

Tables
Indexes
The Primary index of the Table

Tables - Index
Secondary Index
Created if the table is frequently accessed using fields which is not a part of primary key Index distinguished with a three place identifier For certain database systems, the index improves performance

Tables - Index
Secondary Indexes
Only Few indexes should be there in tables where the entries are frequently changed The database system does not use suitable indexes for selection even if there is one The index used depends on the optimizer used for the database system Creating an additional index might have side

Tables - Buffering
Important in client/server environment Buffers reside in each application server Improves Performance

Buffers are filled by


Program accesses data of a buffered table

Buffer Synchronization
If Program changes data in a table on Application Server, it is noted in log table by Database Interface

A synchronization Mechanism runs at a fixed time interval


Log table is read and buffer contents are invalidated

Buffering Tables
Only Transparent and Pooled Tables Table that is frequently read and rarely changed The key fields of the buffered table should of the Character data types ( C, N, D, T) By pass the buffer if table data should be read from Database

Select . BY PASSING BUFFER Select FOR UPDATE

Statements that by pass buffer

Select With Aggregate Functions

Select DISTINCT ..
Select . WHERE . IS NULL

Foreign Keys
Defines Relationship between Tables Create Value Checks for input fields Link several tables in a view or a Lock Object

Tables Foreign Keys


Foreign Key Table T1 Field 1
Primary Key

Field 2

Field 3

Field 4

Check Table T2 Field 5 Field 6 Field 7

Primary Key

Check Table and Value Table


Comparison
Check Table
Field Level Data Validation Maintained at a client level The contents of the check will be used as an input help(F4 Help) for a particular field on which a check table is assigned. Checks are done for the foreign key table against the check table entries, once the foreign key relationship is established.

Value Table
Domain Level Data Validation Maintained as a customization Object The contents of Value Table are not used in Input Help.

All table fields referring to the domain which has a value table can then be checked against the corresponding field of this value table. For this check to be

Tables
Text Tables
The table has a additional key field of type Table B Key Fields K1, K2 LANG
K 1 K 2 F 1 F 2
Text Table A for B Key Fields k1, k2 and L (Type Lang)

1 1 1 2 X X Y Y Y Y X X

K 1

K L 2

TEXT


1 1 1 1 1 2 D E E N D E Text 1 ( German) Text 1 (English) Text 2 (German)

Tables
Table Types
Describes the Structure and functional attribute of an internal table in ABAP DATA statement in ABAP is used to Reference the table type

A user interface tool which is used to change the entry of the table or delete an entry from the table or create an entry for the table.

What is a Table Maintenance Generator

To make this feature work care should be taken while creating the database table that in the 'Delivery & Maintenance' tab, the 'Table View Maint.' should have the "Maintenance allowed" property defined.

Choose the table in SE11 for which Table Maintenance Generator is to be defined.

Table Maintenance Generator

Generate Table Maintenance Dialog

Maintenance Type
In the Maintenance Screen, the Maintenance Type can be
One Step
One Screen is created for Table Maintenance In SM30, after specifying the table name, the overview screen is displayed and when choosing New Entries, the records are entered in the same screen Multiple records can be entered at the same time Generally used as it is user friendly

About Structures
Structures
Contains Fields

Fields can refer to


An elementary data type Another structure Table type

Types :
Flat Structures

Creating Structures
Maintain Foreign Keys if required Save Activate the Structure

Includes
To add fields of another structure in Tables or Structures Structure
Includes Tabl e
F3 F4

F F F F F 1 2 3 4 5

F1 F2 F3 F4 F5

Database

Structures
Only Flat Structures can be included A Structure can be included more than once The field name of the structure should not be longer than 16 places

Append Structures
Append Structures
Used for Table Enhancement

Structure that is assigned to exactly one table


The possible enhancements are
Insert New fields Define Foreign Keys for fields of table Attach Search Help

About Views
View is data derived from one or more tables Used in ABAPView Program for data selection on tables Data is not stored physically
F1 F2 F3 F4 F5 F6 F7 F8

F1 F2 F4 F7 F8

Table T1

Table T2

Table T3

Types of Views
Database View Projection View Maintenance View

Help View

Database View
Provides application specific view on data distributed in tables Created in the database accessed using Open SQL and Native SQL If there is only one table in the view , write access is possible

Projection View
Used to hide fields of a table Contains exactly one table Selection conditions cannot be defined

Pooled and Clustered tables can be accessed as the projection view is not stored in the database

Maintenance View
Allows To maintain data of an Application Object All the tables in this view must be linked with foreign keys Join Conditions cannot be directly specified

Implements Outer Join

Help View
Created if a view with outer join is needed as selection method of search help All tables in help view must be linked with foreign Key Implements Outer Join

About Search Help


Used to Display list of all possible input values for a screen field on the press of F4 Useful when the field requires the input of a formal key Has to be assigned to the screen field Types of Search Helps
Elementary

Selection Method
Selection Method
Possible input values are determined at runtime by database selection If the values are from a single table, the corresponding table is selected as selection method If the values are from multiple tables, they must be linked with a view (Database or Help

Search Help Parameters


Defines the fields of selection method that should be used in input help Data element should be assigned to Search Help Parameter Import and Export Parameters
Import Parameter Information from the screen is copied to help process

Search helps can be attached to fields by the following ways


Attaching to Data Element Attaching to Check Tables

Attaching Search Help to Screen Fields

Attaching to a table field or Structure Field


Attaching to Screen Fields

Creating Search Helps


Specify
Search help exit Import Export LPos Spos Sdis

Save and Activate the search help

What are Lock Objects?


Lock Mechanism is used by R/3 to synchronize simultaneous access to same data by several users

Locks are set and released by calling Function Modules, which are automatically generated from the definition of lock objects
Lock Arguments

Lock Mode
A lock mode can be assigned to each table in the lock object Lock mode
Defines how the users can access the locked records of the table Write Lock
Locked Data can be displayed or edited by a single user. Can be requested several times from the same transaction and are processed successively

Activating a lock object automatically creates function modules

Function Modules for Lock Requests


ENQUEUE_<lock Object Name> - for setting the lock DEQUEUE_<lock Object Name> - for releasing the lock

Lock Objects
Creating Lock Objects (Contd.).
Specify the lock mode

Save
Activate The Function modules get automatically generated.

Introduction
Data is transferred from an external system into the SAP R/3 System Data Transfer is used when,
Transfer data from an external system into an R/3 System as it is installed. Transfer data regularly from an external system into an R/3 System.

BDC
Programming technique for loading data into SAP BDC is a combination of ABAP/4 Programming and built in SAP functionality Simulates the act of a user entering data into an SAP transaction.

The system picks the data from Database

Why BDC?
When a company decides to implement the SAP R/3 to manage business-critical data, it usually does not start from a nodata situation A SAP R/3 project comes in to replace or complement to an existing application. In the process of replacing current application and transferring application

Why BDC? (Contd.)..


It is very difficult to transfer large amount of data manually from an external system into the R/3 System.

A data transfer method is required that transfers the data automatically in the background without user intervention.
BDC is a very good answer to this problem.

BDC Data Transfer


The data transfer can be two- way
Outbound

SAP SAP Outbound is a data transfer from SAP to SAP / Non-SAP

Non SAP.

SAP

Inbound. Non-SAP

SAP

Data transfer from External System into SAP

There are three ways to transfer the data into SAP from any external system.
SESSION METHOD CALL TRANSACTION DIRECT INPUT.

Methods for transferring Data

SESSION Method and CALL TRANSACTION are called as BATCH INPUT Methods

Advantages of Batch Input


Processes large data volumes in batch Can be planned and submitted in the background No manual interaction is required when data is transferred. Data integrity is maintained as whatever data is transferred to the table is through

Analyzing Transaction

Steps involved in writing a Data Transfer Program

Declaring Internal Tables Transferring Data From Flat Files into internal Tables Population of BDCDATA into Internal Table

Analyzing Transaction
The following steps are involved in Analyzing transaction
The name, Type and length of the field Screen number and name of the module pool program Determine the mandatory fields

Declaring Internal Tables


Three internal tables to be declared
Internal table with structure similar to
The flat file
DDIC structure BDCDATA DDIC Structure BDCMSGCOLL

Depends on the source of the file The flat file can be in


Presentation Server Application Server

Transferring Data from flat file to Internal Table

Depending on the server , the programming is done in ABAP to upload

If the flat file resides on the presentation server the function module GUI_UPLOAD is used.

Transferring Data from flat file to Internal Table

The important parameters of GUI_UPLOAD are


Filename FileType

If the file is residing on the application server, the following statements are used :
OPEN DATASET for opening files
OPEN DATASET <dsn> [Additions]. OPEN DATASET <dsn> FOR INPUT.

File residing on the Application Server

CLOSE DATASET for closing files


CLOSE DATASET <dsn>.

DELETE DATASET for deleting files

After uploading data to internal table, the BDCDATA internal table is filled with values required to process single record .

Population of BDCDATA into the Internal Table

Loop
Loop this internal table and employ any of the below mentioned methods of data transfer
CALL TRANSACTION
CALL TRANSACTION <tcode> USING IT_BDCDATA MESSAGES INTO IT_BDCMSGCOLL

SESSION METHOD

The Conversion program uses the ABAP statement CALL TRANSACTION USING to run an SAP transaction

CALL TRANSACTION METHOD

External data does not have to be deposited in a session for later processing.
The entire batch input process takes place inline in the program.

Call Transaction Method (Contd.)..


CALL TRANSACTION <tcode> USING <bdc_tab> MODE <mode> UPDATE <update>

MESSAGES INTO

<BDCMSGCOLL_TAB>.
Where
<tcode> : Transaction code. <bdc_tab> : Internal table of structure BDCDATA.

BDC
After the BDC table has been built, it has to be submitted for SAP Processing Once the SAP data structure has been determined
Determine which fields can be transferred directly from the existing data. There is a direct match between an existing

BDC - Display Mode


Specifies whether the whether data transfer processing should be displayed as it happens.

There are 3 display modes to be chosen from:


A - stands for Display all. All screens and the data that goes in them appear when we run the program.

BDC - Update Mode


Specifies how updates produced by a transaction should be processed 3 update modes are available.
A - Asynchronous updating.
The called transaction does not wait for any updates it produces, to be completed.

Results in faster execution of the data transfer

S - Synchronous updating.

BDC - Update Mode (Contd.).

The called transaction waits for any updates that it produces to be completed. Execution is slower than with asynchronous updating because called transactions wait for updating to be completed. The called transaction will return any update error message that occurs to the program.

The Messages Parameter


When the records are uploaded in database table by Session Method error record is stored in the log file.

In Call transaction there is no such log file available and error record is lost unless handled.

Values Explanation 0 Successful The MESSAGES specification indicates <=100 Error in Dialog Program that all system messages issued during a 0

Session Method
The second way of data transfer is by submitting the BDC session to the system for batch processing.

Several transactions can be processed together


Unlike Call Transaction data is not processed immediately

Session Method (Contd.).


A session records transactions and data in a special format that can be interpreted by the R/3 System.

The data that a session enters into transaction screens is subject to the same consistency checking as in normal interactive operation.
Batch input sessions are subject to the

BDC Function Modules


There are three functional modules to be called from BDC Program for submitting the transactions for processing
BDC_OPEN_GROUP
BDC_INSERT BDC_CLOSE_GROUP

Asynchronous processing

Important Aspects of Session Interface

Transfers data for multiple transactions Synchronous database update

A batch input processing log is generated for each session

Generate the batch input session using function module BDC_OPEN _GROUP. BDC_OPEN_GROUP has the following Export Parameters:
CLIENT
Client in which the session is to be processed

Steps to Work With Session Method

GROUP
Name of the session to be created

Transaction of the Session


For each transaction of the session
Enter the value for all screens and fields in the BDC data structure, that must be processed in the transaction (i.e. fill the internal table IT_BDCDATA).

Use function module BDC_INSERT to transfer the transaction and the IT_BDCDATA to the session.

Close the batch input session with function module BDC_CLOSE_GROUP


BDC_CLOSE_GROUP needs no parameters. It automatically closes the session that is currently open in the program. A session must be closed before another session is open from the same program.

Close the batch input session

Processing the Session


Process the Session Online through SM35 in Background through program RSBDCSUB.
Repeat from the Step 2, for each transaction, when multiple transactions has to be processed through the same Session.

Processing Session
A batch input session is a set of one or more calls to transactions along with the data to be processed by the transactions.

The system normally executes the transactions in a session non-interactively, allowing rapid entry of bulk data into an R/3 System.
A Session can be processed in two ways:

In most cases, batch input sessions can be processed automatically. It is not necessary for a session to wait until a system administrator explicitly starts the processing of the session. The ABAP program RSBDCSUB must be scheduled as a periodic job in the R/3 background processing system.

Processing Sessions Automatically

Procedure
Schedule RSBDCSUB to run periodically in one or more background jobs. If there are batch input scheduled to run regularly, separate jobs can be scheduled for each of the scheduled data transfers. The start time for the RSBDCSUB job can be set according to the batch input schedule.

Session name

Input For the Program RSBDCSUB:

Date and time of generation Status : ready to run or held in the queue because of errors

Running a batch input session executes the transactions in the session and enters data into an R/3 System.

Starting Sessions Explicitly: Run Modes

Usually, the system will run batch input sessions automatically. However, it can also be started manually for the following reasons:
To correct transactions that had errors

Procedure
To start the session, mark the session and choose PROCESS from the toolbar Choose how to run a session and with what logging and display options Run Modes
There are 3 ways to run a session

BDC
Process/foreground:
Transactions that contain errors can be corrected and step through transactions that have not yet been executed.

Display errors only


This mode is like Process/foreground except that transactions that have not yet been run and which do not contain errors are run noninteractively. If an error occurs, processing stops and the

Displaying Session Logs


The batch input system keeps a detailed log of each session that is processed. The log contains not only progress messages from the batch input system itself, but also error messages from the transactions that are processed. To analyze an error in a session, start checking the session log for relevant

Session Status
Sessions in the session queue are sorted by date and time of generation and are grouped in different lists according to their status. Possible statuses are as follows:
New:
Session was created and recorded but not yet processed.

Incorrect :

Status
Processed:
It refers to all those sessions that have been successfully run. The log generated can be displayed by the session. All completed sessions generate a log. A completed session cannot be run a second time.

Note:

Status (Contd.).
In Background:
This status appears only if the Session is processed in the Background Mode

Being Created:
This status is seen only if the queue is displayed while a session is being generated

Direct Input Method


Direct input is a method for automatically transferring large quantities of data to the SAP R/3 System without the need for online processing. Data can be transferred at the time of installation and also at a later point of time Direct input can be used at different times for different purposes:

Direct Input Method


To ensure data consistency, the data transferred automatically must undergo the same checks as the data entered manually.
The same checks are made. The same error messages and warnings are issued. The data is posted and updated in the database in the same way.

Direct Input Method


To enhance the batch input procedure, the system offers the direct input technique, especially for transferring large amounts of data. In contrast to batch input, this technique does not create sessions, but stores the data directly. It does not process screens. To enter the data into the corresponding database tables directly, the system calls a

Direct Input Method Example


Program Applicati on
RFBIBL00 FI

RMDATIND
RVAFSS00 RAALTD11 RKEVEXT0

MM
SD AM CO-PA

Table Controls in BDC


BDC table control is an area on the screen in which data is displayed in tabular form. It is processed using a loop. To handle a scenario like sales order which may contain more than one material table controls are used.

Table controls in BDC plays a special role

To handle the variation in number of rows, the following things has to be taken care of.
To handle it, use the following steps:
Get the complete flat file entries in to a dummy table Differentiate the header data and item data using offset functionality

Table Controls in BDC (Contd.).

LSMW - Introduction
Legacy System Migration Workbench An R/3-based tool that supports when transferring data from non-SAP systems ("Legacy Systems") to SAP systems once or periodically The tool supports conversion of data of the legacy system in a convenient way.

The LSM Workbench was developed on the basis of the R/2R/3 Migration Workbench

Basic Principles of the LSMW

LSMW was developed on the following principles


Most of the functions should reside in the SAP system. No collection of individual programs on different platforms.

Advantages of LSMW
It is a part of the SAP system and thus independent of individual platforms A variety of technical possibilities of data conversion:
Data consistency due to standard import techniques

Generation of the conversion program on the basis of defined rules

Steps involved in LSMW


Start Transaction Code LSMW

LSMW - Procedure
Project
An ID to name the data transfer project

Sub Project
An ID used as a further structuring attribute

Object
An ID to name the business object

LSMW Procedure (Contd.).


Upon creating the project, subproject and Objects, execute and the process steps appear as follows:

The object type and import technique are selected

LSMW - Maintain Object Attributes

LSMW - Procedure
The following screen is displayed on choosing the overview

LSMW - Procedure (Contd.).


After the MM01 is processed, the following recording is displayed

LSMW - Procedure (Contd.).


Save the screen and the following screen is displayed

Define the structures of the object with name, description and the hierarchical relationships

LSMW Maintain the Source Structure

Fields are created and maintained for the structures defined in the preceding step.

LSMW - Maintain Source Fields

The structural relationships define the relationships between source and target structures. Since there is only one source and target, the relationship is maintained

LSMW - Maintain Structural Relationships

Assign source fields to target fields and define how the field contents will be converted.

Maintain Field Mapping and Conversion Rules

The following functions are available:


Field documentation :

Maintain Field Mapping and Conversion Rules (contd)

Displays a short documentation for the target field the cursor is positioned on. The documentation may branch off to further information.

Possible values:
Displays a selection list of all values possible for this target field.

Longtext / Documentation:

The following functions are available:

Maintain Field Mapping and Conversion Rules (contd)


Remove the assignment of a source field:
To remove a source field assigned before, position the cursor on a target field in the tree structure and select Remove source field. If one source field has been assigned only, this field is removed. If several source fields have been assigned, a list of all source fields assigned is displayed for selection. The corresponding source field can then be selected by double-clicking on it.

Maintain Fixed Values, Translations and User-written Routines Fixed value: Here you can specify length,
type, flag for lowercase/uppercase and value in addition to the description. Translation values: Here you specify the value table to be used during translation. The values can be uploaded from a PC file.
Process the reusable rules of a project

Specify Files
This step describes all files to be used in the following steps:
Legacy data on the PC and/or SAP server The file for the read data The file for the converted data If legacy data is on the PC:
In change mode, position the cursor on the line "Legacy data on PC (frontend)". Select Add entry. A popup is displayed. Specify file path (F4 help), file name and

Read Data
Can display all or a part of the read data in table form . To process all data belonging to an object, click on Execute. To migrate a part of the data only, limit the number of data to be migrated in field "General selection parameters". Make the selection in field "Transaction number"

Display Read Data


Display all or a part of the read data in table form. Clicking on a line displays all information for this line in a clear way. Change display allows to select either a one-line or multi-line view.

Display color palette displays the colors for

Convert Data
With regard to operation, this work step essentially corresponds to work step "Read Data".

If data selection is not to be made, confirm the process by clicking on Execute. Otherwise, make the selection in field "Transaction number" from "...to...". Here, multiple selection of transaction numbers is possible as well.

LSMW Procedure (Contd.).


Display Converted Data
The display the data that is converted.

Import Data
The steps displayed by the program depend on the selected object type:
Standard batch input or recording:
Generate batch input session Run batch input session

Standard direct input:


Start direct input session

BAPI or IDoc:

The standard batch input program belonging to the object is directly called. The name of the file with the converted data is already proposed. The batch input sessions to be generated are named after the LSMW object.

Generate Batch Input Session

LSMW Procedure
Run Batch Input Session
The program goes to SAP standard transaction SM35. Follow the procedure to run the session (which is already discussed in the Session method)

Import Data with Direct Input


Depending on the object type, either the standard direct input program belonging to the object is called or select a direct input

Data stored in a file by means of the IDoc technique is generally imported in two steps.

Import Data with BAPI or IDoc Technique

These steps can be called in LSM Workbench:


Start IDoc creation.
First, the file of the converted data is read. The "information packages" contained are stored in the SAP database in IDoc format. It is, however, not stored in the database of the

Screens Introduction
Screen is a repository object and is a component of ABAP Program Screen consists of input/output mask and the screen flow logic Screen is also called Dynpro which is Dynamic Program

Screens can be created using Screen

The screens in a single ABAP program can be combined to form screen sequences

Screens Introduction (Contd.).

Single screens or Screen sequences can be called by


using a transaction code from outside the ABAP program, using the CALL SCREEN statement in the corresponding ABAP program.

The screen flow logic is divided into


PBO event
Processed before the screen is displayed

Screens Introduction (Contd.).

PAI event
Processed after a user action on screen

Screens Introduction (Contd.).


GUI Status Function Codes

PBO

SCREENS

PAI

Screen

Same Names

SCREENS

PBO

PAI

Modules

Modules

The screen flow logic calls dialog modules in the ABAP program,
to prepare the screen for display or to process the user's entries

Screens Introduction (Contd.).

Screens are dynamic programs, and have their own data objects, called Screen Fields.

The screen Fields are linked to the

Each screen has a GUI status, containing a menu bar, standard toolbar, and an application toolbar.

Screens Introduction (Contd.).

Like screens, GUI statuses are independent components of the ABAP program.
They are created in the ABAP Workbench using the Menu Painter.

Screen Elements
Screen Elements are created using the screen painter (tcode SE51). There are different ways to access the screen painter.
From ABAP Development Workbench. From ABAP editor

Screen Fields
Screen Fields are Fields in the working memory of a screen Their contents are passed to identicallynamed 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

Program & Screen Attributes


Example:
For the Program given below the screen and program attributes are specified in the following screens.
DATA: text(10) TYPE c, number TYPE i. CALL SCREEN 200.

Screen 200 contains two fields


MARA-MATNR and MARA-MTART from the ABAP Dictionary

Screen Flow Logic


Screen flow logic contains the procedural part of a screen It is created in the flow logic editor in Screen Painter Screen Flow Logic does not contain explicit declaration

Screen fields are defined by placing

Event Blocks of Screens


There are four event blocks Each event is introduced with the keyword PROCESS The events are:
PROCESS BEFORE OUTPUT. PROCESS AFTER INPUT. PROCESS ON HELP-REQUEST. PROCESS ON VALUE-REQUEST.

Screens Event Blocks


Process Before Output (PBO)
Triggered after the PAI processing of the previous screen and before the current screen is displayed The PBO Processing of the screen is programmed in this event

Process After Input (PAI)


Triggered when the user chooses a function on the screen At the end of the PAI processing, the system

Event Blocks
The following screen Keywords can be used in theDescription event blocks: Keywor
d
MODULE Calls a module in ABAP Program Specifies the point at which the FIELD
contents of a screen field should be transported

ON

Used with FIELD

VALUES Used with FIELD Starts a Processing Chain CHAIN ENDCHA Ends a Processing Chain IN

Processing Screens
Two ways of calling a screen
Using a Transaction Code

Using CALL SCREEN Statement in the ABAP Program

When a screen is called, the PBO event is called and the corresponding event block in the screen flow logic is processed.

User Action on Screens


Filling Input Fields
Values in any input field on the screen, or change the value using the mouse, in the case of radio buttons and checkboxes Filling an input field does not normally trigger the PAI event. Exceptions to this are Checkboxes and Radio Buttons with Function Codes and input fields

Triggering the PAI event


Some of the events that trigger the PAI event are :
Choosing a pushbutton on the screen Selecting a checkbox or radio button to which a function code is assigned. Choosing a function in the menu, standard toolbar, or application toolbar. Choosing a function key on the keyboard. Selecting an entry from a drop down box.

All of these actions have in common that

Processing Screens
If the OK_CODE field in the element list has a name, it is filled with the corresponding function code when the user chooses the function If the OK_CODE field does not have a name, the PAI event is still triggered, but there is no screen field into which the function code can be passed.

All input/output fields have a name linking them to a screen field. The data type of the screen field determines the input format Radio buttons and checkboxes always have the data type CHAR and length 1. A selected radio button or checkbox has the value X, when empty, both have the value

Processing Input / Output Fields

The fields can be copied from the Dictionary to be used on the screens

Screen Fields with Dictionary reference

The fields can refer to both Structures and Database tables The advantage of referring to ABAP Dictionary data types is that both the screen fields and the fields in the ABAP program are updated automatically if the

Pushbuttons on the Screen


Pushbuttons are the only elements of screens that trigger the PAI event when the user chooses them

In each PAI event, the function code, as long as it is not empty, is placed in the system field SYST-UCOMM (SY-UCOMM) and assigned to the OK_CODE field.
Empty function codes are placed in neither

Checkboxes and radio buttons without a function code behave like normal input/output fields

Checkboxes and Radio Buttons

Clicking the object , changes the contents of the field, but does not trigger the PAI event.
When a function code is assigned to a checkbox or radio button, clicking it not

GUI Status
It is an independent component of an ABAP Program It is created in the ABAP Workbench using the Menu Painter The function of a GUI status is to provide the user with a range of functions on a screen

GUI Status (Contd..)


A GUI status consists of a menu bar, a standard toolbar, an application toolbar, and a function key setting

Menu Painter is also used to create area menus.


An area menu is a user interface that does not belong to an ABAP program and may therefore not trigger any PAI events.

Setting the GUI Status


SET PF-STATUS <stat> [OF PROGRAM <prog>] [EXCLUDING <f>|<itab>].
This statement defines the user interface for all subsequent screens of a screen sequence until another is set using a new SET PFSTATUS statement.
The EXCLUDING function allows to change the appearance and function of a GUI status

Setting a GUI Title


SET TITLEBAR <title> [OF PROGRAM <prog>] [WITH <g1 >... <g9>].
This statement defines the title of the user interface for all subsequent screens of a screen sequence until another is set using a new SET TITLEBAR statement A GUI title can contain up to nine

Reading Function Codes


In each PAI event that a user triggers by choosing either a pushbutton on the screen or an element in a GUI status,
the corresponding function code is placed into the system field SYST-UCOMM or SYUCOMM and placed in the OK_CODE field

Function Codes
Empty Function Codes P A I Non-Empty Function Codes P P A A I I OK_CODE Field P P A B I O OK_CODE Field

Screen P B O

SYSTUCOMM P A I

ABAP

SY-UCOMM

Function Codes Contd.


ABAP programs should use the OK_CODE field instead of SY-UCOMM. The two reasons for this are:
The ABAP program has full control over fields declared within it Never change the value of an ABAP system field

OK_CODE Field
The OK_CODE field in an ABAP program is initialized for the following reason:
The OK_CODE field in the ABAP program and the system field SY-UCOMM receive the contents of the corresponding screen fields in the PAI event, their contents are also assigned to the OK_CODE screen field and system field SYST-UCOMM in the PBO event Therefore, the OK_CODE field must be

The Dialog modules in an ABAP program can be called from more than one screen, the functions that is required in several screens can be centrally programmed in a single module. The main task of the screen flow logic is to call dialog modules in an ABAP program To distinguish between screen numbers in

Calling ABAP Dialog Modules

In the PBO event, the statement used to call any dialog module in the ABAP program that has been defined is MODULE <mod> OUTPUT. ... ENDMODULE.

Calling ABAP Dialog Modules

In the PAI, POH, and POV events, the statement to call any dialog module in the ABAP program that has been defined is

Calling Dialog Modules


The different ways of calling the dialog modules in the flow logic are
Simple Module Calls
The flow logic statement used to call a module is
MODULE <mod>.

Controlling the Data Transfer


The FIELD statement in the screen flow logic controls the moment at which data is passed from screen fields to their corresponding ABAP fields.

Simple Module Calls


MODULE <mod>.
The system starts the module that is defined in the event block in which the call occurs The data transport between the ABAP and Screen program is as follows:
In PAI, all data from screen is transported to ABAP after the automatic input checks and before the first PAI module is called

Controlling the Data Transfer


FIELD <f>.
Data is not transported from the screen field <f> into the ABAP field <f> until the FIELD statement is processed If a field occurs in more than one FIELD statement, its value is passed to the program when the first of the statements is reached.

Only screen fields that do not appear in a

There are special function codes with a special module call which calls the module irrespective of the user entry on screen

Calling modules Unconditionally

Type E function Codes


Can be assigned to pushbuttons in screens and elements in the GUI status Set the Function Type attribute in the screen

Conditional Module Calls


To specify conditions for single or a group of fields They Reduce the runtime of the program Conditions for Single Screen Fields
FIELD <f> MODULE <mod> ON INPUT|REQUEST|*-INPUT.

Conditions for Multiple Screen fields

Conditional Module Calls (Contd..)

PAI module is called when several screen fields meet a particular condition The module calls are combined in a flow logic to form a processing chain CHAIN. FIELD: <f1>, <f 2>,... MODULE <mod1> ON CHAIN-

Input Checks
Checks user input for consistency and validity Automatic Input Checks
Called in the PAI event before data is transported to the ABAP Program and before dialog modules are called

Input checks in the Flow Logic


Performed before the dialog modules are

Field Help (F1 Help)


Three ways of displaying field help for screen elements
Data Element Documentation
IF the field on the screen is placed from Data Dictionary Fields, the corresponding Data Element Documentation is displayed

Data Element Supplement Documentation


Data element supplement documentation created in this way is program- and screen-specific. To include it use,
PROCESS ON HELP-REQUEST. ... FIELD <f> [MODULE <mod>] WITH <num>.

Input Help
Provides the list of possible entries in a field Three techniques for input help are
Definition in the ABAP Dictionary Definition on a Screen
The FIELD statement with one of the additions VALUES or SELECT.

Drop Down box


Input/Output field can be defined as a drop down box which specifies a predefined set of input values to choose

When a value is chosen, the PAI event gets triggered


The Value list attribute of the screen element determines how the value list should be compiled.

Few attributes of the screen elements which are set statically in the screen painter can be overridden in ABAP Programs with special Internal Tables The following modifications can be done dynamically
Setting Attributes Dynamically

Modifying Screens Dynamically

A subset of the attributes of each screen field can be addressed using the system table SCREEN

Setting Attributes Dynamically

SCREEN is like an internal table with header line which need not be declared in the program
Screen table cannot be displayed in the debugger

Processing Screens
The statements that can be used in screens
LOOP AT SCREEN. ... MODIFY SCREEN. ... ENDLOOP. For the components of the SCREEN table except for length, 1 represents active and 0

Status Icons
Display elements that represents a state of program graphically Status icon is created in the graphical Screen painter When status icon is created , a place holder appears on the screen

The icon and the text are specified in the

Context Menus
The user interface is defined by a GUI status designed using the Menu Painter and assigned the type Dialog Status.

For each dialog status, the system automatically creates a standard context menu, which the user can display by clicking the right-hand mouse button on the screen (or choosing Shift+F10 ).

Context Menu (Contd.).


Context specific menus can be defined with the standard context menu for the following screen elements:
Input/Output Fields
Text Fields Table Controls

Subscreens
Embedding one screen within another Subscreen area is an area in the main screen where a Subscreen is placed When using a Subscreen, the flowlogic of the Subscreen is also embedded in the flowlogic of the main program

Subscreens allows to expand the content

Subscreens
To use a Subscreen,
Define the Subscreen area(s) on a screen

Define suitable Subscreen screens


Include the Subscreen screen in the Subscreen area.

Defining Subscreens
Defining Subscreen area
Subscreen area is defined using the screen painter in the layout of the screen

Defining Subscreen Screens


In the screen attribute, the screen type SUBSCREEN is selected The layout, element list and the flow logic of the sub screen is created in the same way as the normal screen

The Subscreen is included in the flowlogic of the min screen using


CALL SUBSCREEN PROCESS BEFORE OUTPUT. ... CALL SUBSCREEN <area> INCLUDING [<prog>] <dynp>.

Including Subscreen Screens

TabStrip Controls
A screen object that contains 2 or more pages Each tab page consists of a tab title and a page area Tabstrip controls allows to place a series of screens belonging to an application on a single screen, and to navigate between them easily

Creating a TabStrip
Define the tab area on a screen and the tab titles.
Designed in the Screen Layout

Assign a Subscreen area to each tab title.


Paging in the SAPgui
A separate Subscreen area is assigned to each tab title The function code for the tab titles is Type P In the screen flow logic , all the subscreens are called in the PBO event

Two ways of programming screen flow logic depending on the Tabstrip control Paging in SAPgui
Every Subscreen area has its own Subscreen.

Creating Tabstrips Screen Flow Logic

PROCESS BEFORE OUTPUT. CALL SUBSCREEN: <area1> INCLUDING [<prog 1>] <dynp 1>, <area2> INCLUDING [<prog 2>] <dynp 2>, <area3> INCLUDING [<prog 3>] <dynp 3>,

Creating Tabstrips (Contd.)


Program the ABAP processing logic
The control has to be created in the declaration part of the program.
CONTROLS <ctrl> TYPE TABSTRIP.

The only component of the control which is used in the program is ACTIVETAB
In the PBO Event
To activate the tab page asssign the function codes to the component ACTIVE TAB
<ctrl>-ACTIVETAB = <fcode>.

In the PAI Event

Paging in the SAPGui

Program the ABAP processing logic

The PAI event is not triggered when the user chooses a tab title, and the OK_CODE field is not filled The OK_CODE field is only filled by user actions in the GUI status or when the user chooses a pushbutton either outside the Tabstrip control or on one of the subscreens.

Paging on the Application Server


The PAI event is triggered when the user

Table controls
ABAP offers two mechanisms for displaying and using table data in a screen.
Table controls Step loops.

Table controls and step loops are types of screen tables that can be added to a screen in the Screen Painter.

To perform looping operations in the flow logic LOOP.ENDLOOP statement is used

Table controls - Using the Loop Statement

This statement is used in table controls and step loops


Between a LOOP and its ENDLOOP, the FIELD, MODULE, SELECT, VALUES and CHAIN keywords can be used

Loop Statement
Two Forms of Loop statement
LOOP
This statement loops through screen table rows, transferring the data in each block to and from the corresponding ABAP fields in the program. The screen table fields may be declared in ABAP as anything (database table, structure or individual fields) except as internal table fields.

LOOP at <Internal table>

Step Loops
A step loop is a repeated series of fieldblocks in a screen. Each block can contain one or more fields, and can extend over more than one line on the screen. Step loops as structures in a screen do not have individual names. The screen can contain more than one step loop, but if so, it must be programmed

Lists and Screens


When an executable program is run, the list processor is automatically started at the end of the last processing block, and the basic list created during the program is displayed. To display lists during screen processing, it must be programmed explicitly. Also, switching from list processing to

Leaving a Screen from a Program


LEAVE SCREEN. or LEAVE TO SCREEN Next Screen.

The LEAVE SCREEN statement ends the current screen and calls the subsequent screen.
The next screen is either
the static next screen

The LEAVE TO SCREEN statement exits the current screen and calls the dynamic next screen, which is specified as part of the statement. The LEAVE TO SCREEN statement is no more than a contraction of the two statements.
SET SCREEN Next Screen. LEAVE SCREEN.

Leaving a Screen from a Program (Contd.).

Switching Between Screen and List Processing

Starting Lists from Screen Processing


Screen processing always involves a screen sequence that is started either using CALL SCREEN or a transaction code. During screen processing, the ABAP program is controlled by the dialog processor. In the ABAP program, the PBO and PAI modules are executed as they are called from the screen flow logic.

To pass control from the dialog processor to the list processor, the following statement is included in one of the dialog modules: LEAVE TO LIST-PROCESSING [AND RETURN TO SCREEN <nnnn>]. This statement can be included in either the PBO or the PAI event.

Switching Between Screen and List Processing

Lists and Screens


If detail lists are defined in the corresponding event blocks of the ABAP program (AT LINE-SELECTION, AT USER-COMMAND), user actions on the basic list will lead to the detail list, and further interaction will lead to further list levels. There are two ways to leave list processing :

Lists and Screens (Contd.).


By default, the dialog processor returns to the PBO processing of the screen from which the list processor was called.

The optional addition AND RETURN TO SCREEN allows to specify a different screen in the current screen sequence at whose PBO event you want to resume processing.

Lists and Screens


Calling Screens from List Processing
To call a screen from list processing, use the statement
CALL SCREEN <nnnn>.

This inserts a screen sequence into the program flow as described in the section Calling Screen Sequences. The list processor passes control to the dialog processor.

Introduction
There are several ways for modifying a SAP standard. R/3 system can be adjusted to meet the customer needs in different ways
Customizing Personalization Modifications Enhancements

What is Customizing?
Customizing is the setting of system parameters via SAPs own interface. Possible changes to the standards have been thought out and organized by SAP. Customizing is an obligatory part of the R/3 implementation process.

Customizing (Contd.).
If a company has decided to implement the SAP System, they must adapt the software to meet their individual business requirements This process of customizing the system can be controlled and accelerated using the Accelerated SAP method. The term Customizing refers to the

Customizing (Contd.).
Customizing supports the project teams in the following situations:
Implementing the SAP System Enhancing the SAP System in release and system upgrades

Functions of Customizing
Customizing provides the following functions:
Tools for making and documenting system settings Recommendations for system settings Customizing projects as a means for controlling the management, editing and analysis processes of the implementation and upgrade projects

Support for transferring the system settings from the test system into the production system
Support for transferring the system settings by means of Business Configuration Sets in a group rollout

Personalization
Personalization means to adjust the SAP System to meet the work requirements of specific users or user groups.

Personalization is aimed at accelerating and simplifying the business transactions that the SAP System processes.
Based on the "What you see is what you need" slogan, application Personalization

The standard point of entry into the system is the SAP Easy Access user menu. Each user of the SAP System can be assigned a user menu tailored to the individual activities of that user that appears when the user logs on to the system. System administrators can choose from

Personalization - Simplifying Navigation

Menus and the transactions of the SAP System can be adjusted to the business environment of the company.

Personalization - Simplifying Transactions

In many cases, the fields and options contained in the standard transactions are not needed for specific process flows.
Besides other tools, transaction and screen variants are used to adjust the

SAP organizes its exits in packages are called SAP enhancements. Each SAP enhancement can contain many individual exits. Enhancements represent potential customer requirements that have not been developed in the standard.

Enhancements to the Standard

Enhancements to the SAP Standard with Customer-Exits


The R/3 enhancement concept allows to add own functionality to SAPs standard business applications without having to modify the original applications. SAP creates customer exits for specific programs, screens, and menus within standard R/3 applications. These exits do not contain any functionality. Instead, the customer exits act as hooks where add-on functionality can be hanged onto these hooks.

Enhancements with Customer-Exits

There are two main reasons why exits should be used rather than modifying SAP software. Add-ons attached to exits have the advantage that:
They do not affect standard SAP source code

Enhancements with Customer-Exits

When a new functionality is added to SAP System using SAPs exits, the source code of standard SAP programs in not altered any way. The code and screens created are encapsulated as separate objects.

Types of Exits
There are several different types of customer exits. Each of these exits acts as hooks where add-ons can be attached or "hanged" . Menu Exits
Menu exits add items to the pulldown menus in standard SAP applications. These menu items can be used to call up own screens or to trigger

Types of Exits (Contd.).


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/3 screen and calling a customer subscreen from the standard screens flow logic. The subscreen is called during flow control of the main screen with the CALL CUSTOMERSUBSCREEN statement.

Function Module Exits


Function module exits add functions to R/3 applications. Function module exits play a role in both menu and screen exits. SAP application developers create function module exits by writing calls to customer functions into the source code of standard R/3 programs. These calls have the following syntax: CALL CUSTOMER-FUNCTION 001.

To take advantage of exits if SAP has added them to one of its standard applications, we need to know how to locate the exits available in the SAP System.

Locating Applications that Have Exits

SAP organizes its exits in packages called SAP enhancements. Each SAP enhancement can contain

Managing an Add-On Project


An add-on project contains a series of exits, as well as the add-ons that is to be developed to attach to these exits.

To create an add-on project from within the ABAP Workbench menu, choose Utilities EnhancementsProject management.
Before defining a project, decide which application, application component, or specific standard transaction would be added to the

ADD-ON Project
There are two factors to keep in mind when creating an add-on project.
SAP enhancement package and the customer exits it contains should be included in one project only.

The same SAP enhancement may not appear in two separate customer projects.
In order to make add-ons, such as menu items or screen fields, appear in standard R/3 applications, activate the add-on project.

When a project is activated, all of the add-ons created within this project are activated as well. For this reason, ensure that the exits included in

Creating Add-Ons
After the project name is specified :
Choose Create. Describe the nature of the project by providing a short descriptive text. Choose Save. The system then prompts to assign a change request. This assignment allows to transport the project and its components into a productive system once completed.

Specify which SAP enhancement packages has to be included in the project by choosing SAP enhancements.
Enter the names of these SAP enhancements in the spaces provided.

Creating Add-ons (contd)


Enhancement packages that logically belong together should be choosen.
For example, if we plan to use several enhancements that deal with Materials Management modules, include all of these enhancements in the same project. If working on enhancements that deal with different applications, or if the enhancements are not logically related, include these enhancements in separate projects.

On identifying the SAP enhancements to be included in the project, add own functions to the exits offered in the enhancements.

After attaching the add-on functionality to the exits in the project, activate the project. Activating a project turns on all the addons. The project also has to be activated after transporting it from a development system into a production system. When activating the project, the system turns on all add-ons that the project

Activating and Deactivating a Project

To make changes to any of the add-ons, first deactivate the project that contains that add-on.

Activating and Deactivating a Project (Contd.).

Deactivating a project turns off all of that projects add-ons.


To deactivate an add-on project:
Call the Project management transaction. Choose Deactivate.

Transporting Add-on Projects


When an add-on project is created , assign the project to a change task. Assign all of the add-on components (include programs, subscreens, and menu texts) a change task number. If the project is spread out over more than one change task, assign these tasks to the same change request. On completion, release the change tasks. As a final step, release the change request

Customer-Specific Menus
Menu exits allows to add own functions to the pulldown menus in standard R/3 transactions.

To take advantage of a menu exit, create a project .


Then, include the SAP enhancement package that contains the menu exit which is to be used in the project.

Screen Exit
Screen exits allows to add own fields to specified screens in standard R/3 transactions.

To use the customer-specific subscreens, create projects.


Include the SAP enhancement that contains the screen exit to use in the project.

The global data defined in the standard SAP program is not known to the program that controls the customer subscreen. Also, the fields used in the subscreen are not known to the SAP program in which they appear. To compensate for this problem, SAP creates special flow logic modules when defining screen exits. SAP creates a special PBO module with a

Using Predefined Screen Data

Function module Exit


Customer-Specific Function Modules
Function module exits allows to implement own functions and processing logic in standard SAP programs.

SAP defines where function module exits are inserted and what kind of data they transfer
Function module exits play a role in both menu and screen exits.

SAP application developers create function module exits by writing calls to customer functions into the source code of standard R/3 programs.
These calls have the following syntax: CALL CUSTOMER-FUNCTION nnn.

From the main screen of the Project management transaction, proceed as follows:
Select Enhancement components and choose Change. Place the cursor on the function module exit to be used. Choose Edit component.

Creating Customer-Specific Function Modules

The system displays the exits corresponding function module, which has been prepared by an SAP application developer. Fill this module with functions required by calling the include program (called ZXnnnU01) contained within the module and insert the source code into it. Both the function module and the include

When using a function module exit, we should know how the function module fits into the program logic of the standard R/3 program that calls it. When defining function module calls in its standard program, SAP specifies exactly what data can be transferred to and from the standard program.

Using Predefined Interface Parameters

Finding Function Exit


Requirement : Specify predefined value for sold-to-party for tcode VA01. Choose the tcode VA01. Go to System Status Double click on the program name. Search for CALL CUSTOMER-FUNTION which ensures the availability of function exit.

Creating Function Exit


From the main screen of project Management System (CMOD) create a project .

Function Exit - Example


Specify a short text and save

Enhancements - Field
Customer-specific Documentation
For all data elements stored in the R/3 Repository ,SAPs enhancement concept allows to create

own keywords and online help documentation.


These documentation exits differ from the other exits in several ways:

SAP application developers do not need to prepare special exits for data elements. Customizing the texts of all standard data elements can be done in the SAP System.

The enhancement concept also allows you to alter a data elements short description (short text).

Enhancements Field (Contd.).

This brief text appears whenever a user calls up online help for that field with F1 .

The enhancement concept allows to create your own online documentation for all data elements in the ABAP Dictionary.

Creating Own Online Documentation

The system displays this documentation whenever a user chooses F1 to get more information about a screen field.

Enhancements - Table
Table Enhancements
A standard table can be enhanced with additional fields and structures using

Append Structures Customizing Includes.

Append structures
For enhancements that are not included in the standard. An append structure is a structure that is assigned to exactly one table or structure. There can be more than one append structure for a table or structure. The following enhancements can be made to a table or structure TAB with an append

Append Structures (contd..)


If an append structure is created or changed, the table or structure assigned to it is also adjusted to these changes when the append structure is activated. The customer creates append structures in the customer namespace. The append structure is protected against overwriting during an upgrade.

Append Structures (Contd.).


Table Definition in the ABAP Dictionary Field 1 Field 2 Field 3 Field ZZA Field ZZB Append Structure

Fiel Fiel Fiel Field d 1 d 2 d 3 ZZA

Field ZZB

Table Definition in the database

Customizing Includes
A Customizing include is a structure that satisfies a special naming convention. The name of a Customizing include begins with CI_ and the include lies in the customer namespace. If enhancements are already planned in the R/3 standard using customer-specific fields, such Customizing includes are

Customers can enhance tables and structures of the R/3 standard system without themselves having to modify the table and structure definitions. If a table or structure of the R/3 standard system is enhanced with customer fields using a Customizing include, these customer fields are automatically inserted in the new delivered table or structure

Customizing Includes (Contd.).

A Transaction variant is created to alter the layout of the screen Transaction variants are made up of a series of screen variants. The field values and settings for each screen in the transaction variant are stored in a screen variant

Introduction to Transaction Variants

Uses of Transaction Variant


Transaction Variants are used to
Insert default values into fields Change the ready for input status for fields Hide various screen elements, menu functions or entire screens Adjust table control settings

Screen Variants
Screen Variants are automatically created when the transaction variant is created A screen variant contains field values and attribute for exactly one screen.

Modification
Modifying the Standard
The standard SAP code is modified to meet the business needs. A registered development user registers changes in SAP sources and manual changes of SAP Data Dictionary objects. Exceptions to such registration are match codes, database indices, buffer settings, customer objects, patches, and objects whose changes are based on automatic generation (for example, in Customizing). 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.

SCCR Benefits
Benefit from SSCR (SAP Software Change Registration)
Quick error resolution and therefore high availability of modified systems

All changed objects are logged by SAP. Based on this information, SAPs First Level Customer Service can quickly localize and remove the causes of problems.
Dependable operation

The necessity to register will likely prevent unintended modifications.

Customization
Customer Development
During customer development, customer-specific objects are created in the customer namespace.

SAP has reserved namespaces for customer objects.


Using these namespaces ensures that the objects are not overwritten by SAP objects when new objects are imported into the system or during a release upgrade.

Exception Handling
Exception handling is the integral part of the designing the application. By raising the exception, an opportunity is provided to the Caller program to handle the exception in its own way. The occurrence of an exception is normally used to display an error situation.

Exception Handling (Contd.).


The handler of an exception
must try to correct the error that has occurred, find an alternative solution, or at least bring the affected context into a consistent state and then forward the error.

Since exceptions cannot be handled by means of program calls, all possible exceptions within the program itself must be handled to prevent a runtime error.
This rule does not apply to the coding

Exception Handling (Contd.).


In the Function module, sometimes there is a situation when it is not advisable to process further because of, for example, missing data, conversion, etc. At that point of time, raise an exception. To do this to define the Exception under the tab "Exception" in the Function Builder.

Variants
Variants allows to save sets of input values for programs that is often started with the same selections.

It can be used for any programs except subroutine pools (type S).
When a program in which selection screens are defined is started, the system displays a set of input fields for database-

Variants (Contd.).
Any number of variants can be created for any program in which selection screens are defined.

Variants are assigned exclusively to the program for which they were created.
Variants can be used to change the appearance of the selection screen by hiding selection criteria.

Job Scheduling
The scheduled time for when a job runs is one part of the jobs definition. Before any background processing can actually begin, background jobs must be defined and scheduled. In background processing, the SAP System automatically runs any report or program

Ways to schedule jobs


From Transaction SM36 (Define Background Job) With the "start program in the background" option of either Transaction SA38 (ABAP: Execute Program) or Transaction SE38 (the ABAP editor)

Job Scheduling - Features


Running a report in the background does not tie up the SAP sessions that we are currently working with.

When starting the report in the background, running the report does not influence the interactive work with the SAP System.
The execution of reports can be shifted to

Background processing is the only way to execute long-running jobs. To prevent tying up system resources with interactive sessions for long reports, the SAP System has a built-in time limit on interactive sessions. If a single ABAP report runs for more than 5 minutes continuously in an interactive

Job Scheduling - Features (Contd.).

Go to Transaction SM36 Specify the job name and the job class
The job class specifies the job priority

Procedure for Job Scheduling


Priori Descripti ty on
A High

B
C

Normal
Low

In Exec. Target specify whether the

What is ERP?
Enterprise Resource Planning Enterprise-wide system which integrates the business functions and processes of an organization An information system which integrates all applications for the business organization

Permits Organization to manage

Business Without ERP


PURCHASIN G 1 CUSTOMER PP contacts Purchasing for Raw Materials 4 PRODUCTION PLANNING 3

Customer calls to place an order for a car


3

Sales/ Inventory contacts PP

SALES 2 Sales office contacts Inventory

INVENTORY

Why Enterprise Architecture?


Highly Competitive Business Environment Data Accuracy Integration of Various Functions

Increased Information Availability

Planning An ERP Setup


Understand ERP fundamentals for maximum outcome Choose appropriate platform ERP software that supports the chosen platform Choose the ERP(s) that supports
the existing business processes

Hire or Buy ERP

Steps in implementing the ERP Software

Choose the ERP vendor Engaging an external body for ERP implementation Services Identify Functional / Technical (if any) SME from the organization as POC to coordinate the implementation

Advantages of ERP
Eliminates Duplication, Discontinuity and Redundancy in data Increases return of investment made on implementation Delivers Quality Information Reducing Manpower

Each department can act independently Ensures quicker processing of Information Quick and Efficient Response to Customers Weightage in Winning Business(Helps in Having a say over the competitor)

Advantages in Corporate entity

Disadvantages of ERP
Exorbitant investment of time and money Benefits are subject to proper implementation, training and use ERP Training requires more man days which results in overhead to the regular functioning of the organization

Catch word of ERP implementation SPEED

Significance of ERP Implementation

Understanding the business components and processes increases the organizational awareness among users Faster Implementation leads to quicker and better delivery

ERP Products
SAP
ORACLE e-BUSINESS SUITE PEOPLE SOFT JD EDWARDS

Introduction To SAP
SAP AG HISTORY OF SAP SAP PRODUCTS

SAP

SYSTEMS APPLICATIONS PRODUCTS


in Data Processing
R: Real Time 3: 3 Tier Client/Server Architecture

SAP AG
The Company behind the Package German Based Founded in 1972 as Systemanalyse und Programmentwicklung ("System Analysis and Program Development") by five former IBM engineers in Mannheim, BadenWrttemberg
Dietmar Hopp

History of SAP
Three Systems developed - R/1, R/2, R/3 R/1 Launched in 1973 R/2 Launched in 1979

R/3 Launched in 1992


For over 30yrs SAP has been driving the

SAP
Client/Server Technology Highly Customizable Industry Specific BEST Practices

Open Standards
Market and Technology leader in business

SAP
R/1 1972 R/2 1979
Mainframe

R/3 1992
Client/Server Compatible with multiple Platforms and Operating Systems

SAP Solutions
Applications Business Object Portfolio On-demand Solutions

Industry Specific Solutions Portfolio


SAP Netweaver

SAP Solutions - Applications


SAP Business Suite
SAP Enterprise Resource Planning
Addresses the core business software requirements of the most demanding mid-size businesses and large Organizations around the world Includes four individual solutions that support key functional areas
SAP ERP Financials SAP ERP HCM SAP ERP OPERATIONS SAP ERP CORPORATE SERVICES

SAP Business Suite


SAP SUPPLY CHAIN MANAGEMENT
Helps organizations transform a linear supply chain into an adaptive supply chain network Communities of customer-centric , demanddriven companies share knowledge Intelligently adapt to changing market condition

SAP SUPPLIER RELATIONSHIP MANAGEMENT


Helps organizations manage their vendor

SAP Solutions
SAP Business Objects Portfolio
Solution for Large Enterprises Solutions for small Businesses and Midsize Companies

On demand Solutions
SAP Business by Design SAP CRM on-demand Solution

SAP For Banking SAP For Insurance SAP For Defense & Security SAP For Healthcare SAP For Aerospace and Design SAP For Chemicals SAP For Oil & Gas SAP For Media SAP For Telecommunications

SAP Solutions - IndustrySpecific Solution

SOA based Open Technology Platform Unifies Technology Component Into A Single Platform Provides The Best Way To Integrate All Systems Running SAP or non-SAP Software People Integration
Right functionality to right people at right time Multi-Channel Access
Connect to Enterprise systems through

SAP Solutions SAP Netweaver

Constant Access to consistent information irrespective of where it is stored


Business Intelligence
Analyzes, integrates and Distributes timely information that supports decision-making Provides Reliable tools for Creating individual and interactive reports and applications

SAP Solutions - Information Integration

Knowledge Management
Access to unstructured information Repositories are directly linked to the portal with preconfigured or programmable connectors

The basis for Process Integration is SAP Exchange Infrastructure (SAP XI) Provides technical infrastructure for XML based message exchange to enable integration of SAP to SAP or non-SAP systems

SAP Solutions - Process Integration

SAP Solutions - For Small and


SAP Business All-in-One

Mid-Sized Companies

Ideal for companies with Industry Specific requirements Can be implemented quickly

SAP Business One


Manages the most important Business areas like the sales, distribution and finance with single, integrated application Ideal for small companies with less than 100 employees and 30 users

SAP Consultants
Technical Consultant Functional Consultant Basis Consultant

Modules Of SAP
Functional Modules
Material Management (MM) Sales and Distribution (SD) Production Planning (PP) Plant Maintenance (PM) Quality Management (QM) Financial Accounting & Controlling (FICO) SAP Business Warehouse (BW) SAP Enterprise Portals (EP)

SAP R/3 Landscaping


Arrangement of Servers SAP Recommends 3 system landscape
Development System DEV
Customizing client CUST

Quality Assurance System QAS


Quality Assurance Client QTST

System Landscape
Customizing Client
Consultants do the customization as per the Business requirement
Make all changes to Customizing Client Other clients with additional roles
Development Test Client (TEST) Prototype Client (SAND) Neat and Clean Client (GOLDEN)

SANDBOX doesnt affect the other clients Golden Client is a configuration only client

System Landscape (Contd.)


DEV
QAS

Test the customization Changes to cross-client data appear in the Quality Assurance (QAS) after Transport Test if the transports are complete

System Landscape (Contd.)


Production System
Go Live

Any new changes will be in the development DEVELOPMENT PRODUCTION client and request QUALITY will be transported in the same order as

SAP R/3 Architecture


All Application Programs and part of R/3 Basis System are written in ABAP (Advanced Business Application Programming) R/3 Repository
Individual components of application programs are stored in a special section of database

SAP Systems are used to map Business Processes Applications should be implemented independent of hardware environment (OS, DB) SAP Netweaver provides 2 runtime environments to achieve it

SAP R/3 Architecture SAP Basis System

For implementation of Server-based and Client-based Web applications Server Applications


Created in integrated development environment Contains web pages and static HTML code and dynamic script code

Architecture Of SAP WEB AS

SAP WAS is application platform of SAP Netweaver

SAP WAS

SAP WAS (Contd.).


The Internet Communication Manager (ICM) sets up connection to Internet
Can Process both client and Server requests

Dispatcher distributes the requests to Work Process


Requests are stored in Dispatcher Queue

ABAP Work Process executes ABAP Code

Platform for all applications in the R/3 system R/3 User


PRESENTATION COMPONENTS

SAP R/3 - Logical View of Basis system

R/3
ABAP Workbench
R/3 R/3

BASIS SYSTEM

Application1

Application n

KERNEL AND BASIS SERVICES DATABASE MANAGEMENT SYSTEM

DATABASE

Runtime environment for all R/3 applications

SAP R/3 Architecture - Kernel and Basis Services

Runtime environment written in C , C++ and ABAP Advanced Business Application Programming
Programming language for SAP

ABAP WORKBENCH

SAP R/3 Architecture (Contd.)

Development Environment for application in ABAP Fully integrated in R/3 System

Written in ABAP
Used to create, edit, test and organize application developments

The Software Components that make up the R/3 System


SAP GUI SAP GUI SAP GUI PRESENTATION LAYER

SAP R/3 Architecture Software Oriented View

Application server 1

Application server n

APPLICATION LAYER

Message Server DATABASE MANAGEMENT SYSTEM DATABASE

DATABASE LAYER

Consists of a Central Database System containing all data in R/3 system Contains 2 components
DBMS DB

SAP R/3 Architecture Database Layer

Supports many Database system


ORACLE SQL Server DB2 INFORMIX

Consists of 1 or more Application Server Consists of a Message Server


Responsible for Communication between Application Servers Passes request from one Application Server to another within the System

SAP R/3 Architecture Application Layer

Contains Software Component that makeup the SAPgui

SAP R/3 Architecture Presentation Layer

Interface between the R/3 System and its Users User interface for entering and displaying data

Sends the input to the application server

System Load Distributed

Advantages of Multi tier Architecture

Better System Performance Highly Scalable

Program Execution separated from User Input

SAP R/3 Architecture -User Oriented View


.. .. R/3 USER
SAP GUI session1

SAP
SAP GUI session6

SAP GUI session1

SAP
SAP GUI session6

SAP GUI session1

SAP
SAP GUI session6

..

GUI1

..

GUI 2

..

GUI 3

..

APPLICATION LAYER DATABASE LAYER

APPLICATION LAYER DATABASE LAYER

R/3 System 1

R/3 System 2

The screens that appear in the window of the screen are the visible components Windows are generated by Presentation Layer SAP LOGON a utility to start to logon to SAP
Choose an available SAP system Program connects to the message server of

User Oriented View of Application Server

An important component of R/3 System R/3 Programs run on Application Server Application Layer is made of Application servers and Message server Application Servers Communicate with Presentation Components, the database and also with each other using the

SAP R/3 Architecture Application Servers

SAP Architecture - Components


Work Processes (WP)

Of ABAP Application Server

Components that run an application Linked to the memory area containing the context of the application that is running Context contains current data for the application program It needs to be available in each DIALOG STEP

Dispatcher

SAP Architecture Components Of ABAP Application Server


Gateway
Each Application Server contains a Gateway Interface for R/3 Communication Protocols Can communicate with Application Servers
In Same R/3 System With Other R/3 System With R/2 Systems and With non-SAP System

Shared Memory
All Work Processes on an Application Server

SAP Architecture Components Of ABAP Application Server


User Context
Contains the Characteristics of a User logged in R/3 System like
The users Current Settings The Users Authorizations The names of the program user is currently running

Roll Area
Allocated by Work process for the instance of

SAP R/3 Architecture When we start up the R/3, each Application Server registers itself with the DB layer and receives a single dedicated channel Each Work process is a user of database system A work process can make DB changes only within a single DB Logical Unit Of

Database Connection

SAP R/3 Architecture Dispatching Dialog Steps


User 1 User 2

SAP GUI

SAP GUI 2 Dispatcher

1
4 5 context 3

context

Shared Memory

Work Process 1

Work Process 2

Work Process 3

context

The dispatcher receives the request to execute a dialog step from user 1 and directs it to work process 1, which happens to be free. The work process addresses the context of the application program (in shared memory) and executes the dialog step. It then becomes free again. The dispatcher receives the request to execute a dialog step from user 2 and directs it to work process 1, which is now

SAP R/3 Architecture Dispatching Dialog

SAP R/3 Architecture


Structure of Work Process
Executes individual dialog steps in R/3 application
Structure of Work Process

Screen Processor

SAP R/3 Architecture - Work Processes


User Interaction Controlled by Screens Screen contains Flow Logic Screen Flow Logic Controls User Interaction Screen Processor Executes the Screen Flow Logic Ensures Field contents are transferred from screen to flow logic Tells the ABAP Processor the order, as to which module of Screen Flow Logic should be

Database Interface

SAP R/3 Architecture Work Process (Contd.)


Establishing and terminating connections between the work process and the database. Access to R/3 Repository objects (ABAP programs, screens and so on) Access to catalog information (ABAP Dictionary) Controlling transactions (commit and rollback handling) Table buffer administration on the application

SAP R/3 Architecture Types Of Work Process

Dialog Work Process

SAP R/3 Architecture - Types Of Work Processes


Deals with requests from an active user to execute dialog steps

Update Work Process


Executes Database Update requests Part of SAP LUW that bundle the DB operations

Background Work Process


Processes Programs that does not require

SAP instances are defined during the installation of the SAP system. The term instance is often used synonymously with server or application server in the SAP system An SAP instance defines a group of resources such as memory, work processes and so on, usually in support of

SAP R/3 Architecture Instances

Basic Navigation
SAP GUI
Based on Windows Style

Available for Several Platforms, providing the same functions for each SAP GUI Types
SAP GUI For Windows Environment SAP GUI For Java Environment

Basic Navigation (Contd.)


SAP GUI For Windows Environment
For Windows Based Platform Supports all Transaction in SAP System Can Connect Presentation Servers over WAN

SAP GUI For Java Environment


Platform Independent Implementation of SAP GUI Can Connect Presentation Servers over WAN

Client

Basic Navigation - Logging On To SAP (Contd.).

Username Password

Logon Language

Client

Basic Navigation - Logging on to SAP(contd.)


Represents a company in an SAP system Several companies can be simultaneously represented and active in the system Corresponds to Specific Business Entities Have Access to data for the specific Client

Once logged on, we can work on several sessions

Basic Navigation (Contd.)


Multiple Logons to SAP Systems are allowed Its for Security and Licensing Reasons If the same User logs on more than once, then for each subsequent logon, the system displays a warning message with 3 options

Transaction Codes
Commonly Used Transaction Codes
SE80 : Object Navigator (ABAP Development Workbench) SE38 : ABAP Editor

SE37 : Function Builder


SE11 : ABAP Dictionary

Transaction Codes (Contd.).


SE51 : Screen Painter SE41 : Menu Painter ST05 : Performance Analysis

SE71 : Form Painter (SAP Scripts)


Smartforms : SAP Smartforms

SAP Implementation
SAP Implementation is the whole of processes that defines a complete method to implement the Enterprise Resource Planning SAP ERP software in an organization. The SAP implementation method described in this entry is a generic method and not a specific implementation method as such.

The implementation of SAP software, such as SAP R/3 is almost always a massive operation that brings a lot of changes in the organization. The resulting changes that the implementation of SAP generates are intended to reach high level goals, such as improved communication and increased return on information.

Implementation Methodologies

ASAP Accelerated SAP in Data Processing

Implementation Methodologies - ASAP

The implementation of the SAP System covers the following phases:


Project Preparation
In this phase plan the project and lay the foundations for successful implementation. It is at this stage that the strategic decisions crucial to the project are made:

Implementation Methodologies ASAP (Contd.) The implementation of the SAP System


covers the following phases:
Business Blueprint
In this phase create a blueprint which documents the enterprises requirements and establishes how the business processes and organizational structure are to be represented in the SAP System. Refine the original project goals and objectives and revise the overall project schedule in this

Implementation Methodologies ASAP (Contd.) The implementation of the SAP System


covers the following phases:
Realization
In this phase, configure the requirements contained in the Business Blueprint. The purpose of this phase is to implement all the business and process requirements based on the Business Blueprint.

Baseline configuration (major scope) is followed by

Implementation Methodologies ASAP (Contd.) The implementation of the SAP System


covers the following phases:
Final Preparation
In this phase, complete the preparations, including testing, end user training, system management, and cutover activities. Resolve all open issues in this phase.

Implementation Methodologies ASAP (Contd.). The implementation of the SAP System


covers the following phases:
Go Live & Support
In this phase move from a pre-production environment to the live system. The most important elements include
setting up production support, monitoring system transactions, and optimizing overall system performance.

Selection Screen
Selection screens are a standardized user interface. It is used when the user has to give data input. Input parameters are primarily used to control the program flow, while users can enter selection criteria to restrict the amount of data read from the database.

Selection Screen (Contd.).


Default Values for Parameters
PARAMETERS p ...... DEFAULT f ......

Allowing Parameters to Accept Upper and Lower Case


PARAMETERS p ...... LOWER CASE ......

Reducing the Visible Length

Selection Tables
SELECT-option S seltab FOR f.
Structure of Selection Tables
The row of a selection table consists of
Sign Option Low High

Structure of Selection Table


Sign
Data Type : c , length 1 The contents of sign determine for each row whether the result of the row condition is to be included in or excluded from the resulting set of all rows. Possible values are I and E.
I stands for inclusive (inclusion criterion operators are not inverted) E stands for exclusive (exclusion criterion operators are inverted)

Low

Structure of Selection Table (Contd.).


The data type of low is the same as the column type of the database table, to which the selection criterion is linked. If high is empty, the contents of low define a single field comparison. If high is filled, the contents of low and high specify the upper and lower limits for a range.

High

Select-Option
Default Values for Selection Criteria
SELECT-OPTIONS seltab FOR f DEFAULT g [TO h].... To fill only the low field (single field comparison):
........DEFAULT g.

To fill the low and high fields (range selection),:

Upper and lower case for selection criteria:


SELECT-OPTIONS selcrit FOR f ... LOWER CASE...

Additional Options for Selection Criteria

Reducing the Visible Length


SELECT-OPTIONS selcrit FOR f ... VISIBLE LENGTH len...

Link to Search helps:

Additional Options for Selection Criteria (Contd.).


SELECT-OPTIONS selcrit FOR f ... MATCHCODE OBJECT...

To hide input fields on the selection screen,


SELECT-OPTIONS selcrit FOR f ... NO DISPLAY...

The two statements:

User-defined selection screens

SELECTION-SCREEN BEGIN OF SCREEN numb [TITLE tit] [AS WINDOW]. ... SELECTION-SCREEN END OF SCREEN numb.

Define a user-defined selection screen with screen number numb.

Formatting Selection Screen


The selection screen that is define d using the PARAMETERS or SELECT-OPTIONS statements has a standard layout in which all parameters appear line by line When the standard layout is not sufficient, The SELECTION-SCREEN statement has its own formatting options that can be used to define the layout for selection screens.

Blank Lines, Underlines, and Comments


Blank Lines
To place blank lines on the selection screen
SELECTION-SCREEN SKIP [n].

Underlines
To place underlines on the selection screen SELECTION-SCREEN ULINE [[/]pos(len)] [MODIF ID key].

Check Box and Radio Buttons


PARAMETERS ... AS CHECKBOX | RADIOBUTTON GROUP ... USER-COMMAND fcode.

An individual function code fcode can be assigned to an individual checkbox A radio button group must have one shared function code.

When a checkbox or radio button in a

Selection Screen Processing


Selection screens are special screens that are defined with the help of ABAP statements

The ABAP runtime environment fully controls the processing flow of selection screens.
The ABAP runtime environment generates a number of special selection screen

The basic form of the selection screen events is the AT SELECTION-SCREEN event

Processing Selection Screen (Contd.).

This event occurs after the runtime environment has passed all input data from the selection screen to the ABAP program.

Selection Screen Processing starts after the INITIALIZATION event with AT SELECTION SCREEN OUTPUT.

Overview of Selection Screen Events

User actions on the selection screen result in other events that are either used for field or possible entries help, or that trigger PAI processing of the selection screen.
Only if the AT SELECTION-SCREEN

The AT SELECTION-SCREEN event is triggered in the PAI of the selection screen once the ABAP runtime environment has passed all of the input data from the selection screen to the ABAP program In the PBO of the selection screen, the AT SELECTION-SCREEN OUTPUT event is triggered.

Selection Screen - Basic Form

Selection Screen Processing


Processing Single Fields
In the PAI event of the selection screen, the event AT SELECTION-SCREEN ON field event is triggered.
The input field, field can be checked in the corresponding event block.

Processing Blocks

Processing Radio Buttons


In the PAI event of the selection screen, the event AT SELECTION-SCREEN ON RADIOBUTTON GROUP group event is triggered. This event block allows to check the whole group. The individual fields of radio button groups does not trigger the event AT

If the user opens the Multiple Selections dialog box for a selection option, the same events are triggered in the PAI of the selection screen as if the user had chosen Execute. In the Multiple Selections dialog box, user actions either lead to input help or trigger the PAI event of the dialog box. At first, the AT SELECTION-SCREEN ON seltab

Processing Multiple Selections

Defining Field Help


AT SELECTION-SCREEN ON HELPREQUEST FOR field

The event is triggered when the user calls the F1 help for the field field No event block AT SELECTION-SCREEN ON HELP-REQUEST can be created for input fields of the selection screen that are declared within the logical database used.

Defining Input Help


To create possible values help for report input fields that have no Dictionary reference, or to override the Dictionary input help linked to the field, an event block for the event can be created
AT SELECTION-SCREEN ON VALUE-REQUEST FOR field

The event is triggered when the user calls the F4 help for the field field.

Selection Screens as Subscreens

Subscreens and Tabstrip Controls


SELECTION-SCREEN BEGIN OF SCREEN scrn AS SUBSCREEN [NO INTERVALS] [NESTING LEVEL n]. ... SELECTION-SCREEN END OF SCREEN scrn.

Selection screens that is defined in this way can be included in:


Subscreens on screens

When a selection screen is used as a subscreen on a screen or in a tabstrip control on a screen, the CALL SUBSCREEN statement is executed in both the PBO and PAI events in the screen flow logic

Selection Screens as Subscreens

PAI modules for selection screens as subscreens cannot be programmed, the CALL SUBSCREEN statement ensures

A tabstrip area and the associated tab pages must be defined, and assigned to a subscreen to the tab pages.

Tabstrip Controls on Selection Screens

The tabstrip control or program the screen flow logic cannot be declared in ABAP program, since both are automatically generated.
SELECTION-SCREEN: BEGIN OF TABBED BLOCK tab_area FOR n LINES,

Displaying a subscreen in a subscreen area on a selection screen is a special case of a tabstrip control on a selection screen.

Subscreens on Selection Screens

To define a subscreen area on a selection screen


SELECTION-SCREEN: BEGIN OF TABBED BLOCK sub_area FOR n LINES,

Logical Database
Logical databases are special ABAP programs that retrieve data and make it available to application programs.

Logical databases contain Open SQL statements that read data from the database
LDB can be called using the function module LDB_PROCESS

Tasks of a LDB
Reading the same data for several programs. Defining the same user interface for several programs. Central authorization checks Improving performance

Has 3 components Structure Selections

Structure of a Logical Databases

Database Program
The database program contains the ABAP statements used to read the data and pass it

Structure
Defines the data view of the LDB The order in which data is made available to the user depends on the hierarchical structure of the logical database concerned. The structure of a logical database is usually based on the foreign key relationships between hierarchical tables

Structure
LFA1

LFBK LFB1

LFC1

Selections
Defines a selection screen Layout determined by Structure If LDB is called using the function module LDB_PROCESS, the selections are filled using interface parameters.

Database Program
The database program contains the ABAP statements used to read the data and pass it to the user of the logical database

A logical database program usually contains lot of subroutines. To mention a few:


FORM LDB_PROCESS_INIT
Called once only before the logical database is

Using Logical Databases


Two ways to use a LDB.
Link to an Executable Program

Use Function Module LDB_PROCESS in ABAP Program

Example Program without LDB DATA: wa_spfli TYPE spfli, wa_sflight TYPE sflight.
SELECT-OPTIONS: sel_carr FOR wa_spfli-carrid. SELECT carrid connid cityfrom cityto FROM spfli INTO CORRESPONDING FIELDS OF wa_spfl i WHERE carrid IN sel_carr. WRITE: / wa_spfli-carrid, wa_spfli-connid, wa_spfli-cityfrom, wa_spfli-cityto.

SELECT fldate FROM sflight INTO CORRESPONDING FIELDS OF wa_sflight WHERE carrid = wa_spfli-carrid AND connid = wa_spfli-connid.

Reports
There are different types of Reports
Simple reports

Classical reports
ALV Reports

Simple Reports
Creating Simple Reports
Simple output lists on the screen can be created by using the ABAP statements
WRITE

ULINE
SKIP

Events - INITIALIZATION
Occurs before the standard selection screen is called In this event the input fields of the standard selection screen can only be initialized once after the program has been started If an executable program declares a standard selection screen the same

The event AT SELECTION-SCREEN is the basic form of a whole series of events that occur while the selection screen is being processed. This event is used to validate the information entered in the selection screen The standard selection screen, either in an executable program or in the logical

Events - AT SELECTIONSCREEN

This event occurs after the selection screen has been processed and before data is read using the logical database

Events - START-OFSELECTION

It is used to prepare the data for reading and creating the list
In an executable program, any nondeclarative statements that occur between the REPORT or PROGRAM statement

This is the last of the events called by the runtime environment to occur. It is triggered after all of the data has been read from the logical database, and before the list processor is started. The event block is used to process and format all data that the program has stored in sequential datasets, such as internal

Events - END-OFSELECTION

Exiting Event Blocks


ABAP contains a series of statements that allows to leave an event block. They return control to the runtime environment. The subsequent sequence of events in the runtime environment depends on which statement is used and the event block in which it is used.

Exiting Event Blocks Using STOP


If the STOP statement is used within an event block, the system stops processing the block immediately.

Exiting Event Blocks (Contd.).

Exiting Event Blocks Using EXIT


If the EXIT statement is used within an event block but not in a loop, the system stops processing the block immediately.

Interactive Lists
Lists are the output medium for structured, formatted data from ABAP programs. Each program can produce up to 21 lists, one basic list and 20 secondary lists. The basic list is the standard screen of an executable program (report).

In list processing, the event is intercepted

Interactive Lists (Contd.).


When the system processes event blocks that are not assigned to interactive list events, and when processing dialog modules, the ABAP program writes its list output to the basic list. The ABAP system field SY-LSIND contains the index of the list currently being created.

Creating Detail Lists


All lists created during an interactive list event are detail lists. Each time the user executes an action on a list, the runtime environment checks whether there is an event block defined that corresponds to the function code. If there is, SY-LSIND is automatically increased by one, and the relevant event

Each interactive list event creates a new detail list. With one ABAP program, one basic list and up to 20 detail lists can be maintained. If the user creates a list on the next level , the system stores the previous list and displays the new one. The user can interact with whichever list is currently

Creating Detail Lists (Contd.).

Processing blocks cannot be nested

Consequences of Event Control

TOP-OF-PAGE event cannot be used in secondary lists but TOP-OF-PAGE DURING LINE-SELECTION can be used The system does process the event ENDOF-PAGE in secondary lists.

The GET and GET LATE cannot be used

System Field for Detail List


System Information Field SY-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 triggered SY-LILLI Absolute number of the line from which the event was triggered Contents of the line from which the event SYwas triggered LISEL

SY-

Position of the line in the window from

System Fields (Contd.).


System Field Information Page number of the first displayed page of the list from which the event was triggered Number of the first line of the first page displayed of the list from which the event was triggered (counting starts with 1). This line may contain the page header. Number of the first column displayed in the list from which the event was

SYCPAGE SYSTARO

SY-

Using Detail Lists


A classic report is a program that generates a single list Example
START-OF-SELECTION. WRITE: 'Basic List, SY-LSIND =', sylsind. AT LINE-SELECTION. WRITE: 'Secondary List, SY-LSIND =', sy-

Dialog Status For Lists


To allow the user to communicate with the system when a list is displayed, the lists must be able to direct user actions to the ABAP program. Function codes which are used for this purpose is maintained in the GUI status of the list screen GUI status is maintained in the Menu

Standard List Status


The GUI status for lists can be defined and attached to list level using SET PF-STATUS

If an event block is define d in the program using the event keyword AT SELECTION SCREEN, the system automatically assigns extra function to other function keys

Setting a Dialog Status


SET PF-STATUS <stat> [EXCLUDING <f>|<itab>] [OF PROGRAM <prog>] [IMMEDIATELY]. This statement sets the status <stat> for the current output list SET PF-STATUS SPACE is used to set the standard list status

Setting a Title for a List


SET TITLEBAR <ttl> [WITH <g1> ... <g9>] [OF PROGRAM <prog>].
Sets the title of the user interface for the output list It remains active for all screens until another SET TITLEBAR is specified

After a user interaction on a list, the ABAP runtime environment checks whether it should process the function code itself (for example, %EX or %PC), or whether it should trigger the relevant event. Unlike normal screens, in which the PAI event is triggered, the runtime environment triggers three special events when list events occur

List Events in an ABAP Program

Event Block for Function Code PICK

Interactive Lists Event Block

When the user triggers the function code PICK, AT LINE-SELECTION is always triggered if the cursor is positioned on a list line

Event Block for User-Defined Function Codes

Lists in Dialog Box


List can be displayed in a dialog box instead of on the full screen using the WINDOW statement
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 detail lists

Automatic Data Transfer


Using System Fields

Passing Data From Lists to Programs

System Fields provide the information about


the list index Position of List in the Output Window The cursor Position

The system field SY-LIESEL contains the contents of the selected line .

Using ABAP Statements


HIDE

Program-Controlled Data Transfer


Fundamental Statement for interactive reporting Defines the information that can be passed to subsequent lists

READ LINE
To read data from the lines of existing list levels Closely connected to HIDE technique

GET CURSOR
GET CURSOR FIELD and GET CURSOR LINE is

HIDE Technique
HIDE <f>.

Places the contents of the variable <f> for the current output line (system field SYLINNO) into the HIDE area. Always place the HIDE statement directly after the output statement for the variable <f>

Hide Technique (Contd.).


A line can be selected
By an interactive event.

By the READ LINE statement.

HIDE area is like a table, in which the system stores the names and values of all HIDE fields for each list and line number.

Reading Lines from the Lists


Used to To read a line from a list after an interactive list event
READ LINE <lin> [INDEX <idx>] [FIELD VALUE <f1> [INTO <g 1>] ... <f n> [INTO <g n>]] [OF CURRENT PAGE|OF PAGE <p>].

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-LISEL system field and fills all HIDE

Interactive Lists
Reading Lists at the Cursor Position
GET CURSOR FIELD <f> [OFFSET <off>] [LINE <lin>] [VALUE <val>] [LENGTH <len>].

Determining the Attributes of Lists


To retrieve the number of lines or pages of a list:
DESCRIBE LIST NUMBER OF LINES|PAGES <n> [INDEX <idx>].

The <options> of the statement can be


LINE-SIZE <col>
writes the page width into the variable <col>.

Retrieving Attributes of a Page

LINE-COUNT <len>
writes the page length into the variable <len>.

TOP-LINES <top>
writes the number of page header lines into the variable <top>.

TITLE-LINES <ttl>
writes the number of list header lines of the standard page header into the variable <ttl>.

A function to a function key must be assigned before it can be included in the application toolbar.

Defining An Application Toolbar

A maximum of 35 pushbuttons in the application toolbar can be included.


Application toolbar functions can contain an icon, a text, or both together.

ALV Reporting
ABAP List Viewer An SAP Tool for Reporting The tool provides common list operations as generic functions and can be enhanced by self-defined options. Reduces the development time of reports by providing the standard interfaces (

Traditional ABAP Reporting


50% of the time spent on finding the right tables and table relationships 30% of the time spent on providing fancy features sorting subtotals and overall totals. Interactive list events (AT LINESELECTION)

Programming with the ALV


50% of the time spent on finding the right tables and table relationships (selection process)

1% of the time spent on preparing field catalog and sort sequence information for the list viewer
9% of the time spent on fancy features for interactive list events

Declare data areas for list viewer Declare internal table to store selected data Select data into internal table Populate display variants Build field catalog Build sort catalog Build event catalog Build Layout

Steps involved in creating ALV reports.

Implementation Details
Declare data areas for list viewer
TYPE-POOLS: SLIS. ** For field catalog DATA: i_fieldcat TYPE SLIS_t_fieldcat_ALV. ** For events DATA: i_events TYPE SLIS_t_EVENT. ** For sorting DATA: i_sort TYPE slis_t_sortinfo_alv. ** For fieldgroups DATA: i_fieldgroups_tab TYPE SLIS_t_sp_group_ALV. ** For variant

ALV Reporting (Contd.).


Declare internal table to store selected data
Internal table definition, that will store the data to be displayed on the screen

Select data into Internal Table


To get the dat ainto the Internal Table

Populate Display Variant


To store onscreen display as Variants

ALV Reporting (Contd.).


Build sort catalog
Sort catalog contains fields on which the sorting of the list will be done.

Build event catalog


ALV supports normal ABAP reporting events and handles it internally as well as externally. The internal table I_EVENTS is populated with the name of the form corresponding to the event to be handled.

ALV Reporting (Contd.).


Build Field Groups
For easy onscreen display selection, fields can be grouped. Populate internal table i_fieldgroups_TAB with the groups and description. Assign the groups to the fields in the field catalog.

Start list viewer

ALV Functions
The commonly used ALV functions are:
REUSE_ALV_LIST_DISPLAY REUSE_ALV_GRID_DISPLAY REUSE_ALV_VARIANT_DEFAULT_GET REUSE_ALV_VARIANT_F4 REUSE_ALV_VARIANT_EXISTENCE REUSE_ALV_EVENTS_GET REUSE_ALV_COMMENTARY_WRITE REUSE_ALV_FIELDCATALOG_MERGE

Debugging
Debugger is a stepwise method of finding out errors or bugs ABAP Debugger allows to interrupt the running program after each step, to check intermediate results and processing logic. Debugger can be called in 2 ways.
By Setting Break Points

Debugging (Contd.).
The Debugger is a programming tool that is used to execute ABAP programs, by line or by section.

Using this tool, data objects can be displayed and the flow logic of programs can be checked.
Two Types of Debugging

Classic ABAP Debugger


The ABAP Debugger is an integrated test tool within the ABAP Workbench. It is used to check the program logic and to find errors in the source code of an ABAP program. In the Debugger, it is possible to step through the source code of a program.

There are two possible strategies for starting the Debugger in the ABAP Workbench:
By setting breakpoints then running the program By running the program in debugging mode.

Starting the Classic Debugger

Setting Breakpoints
A breakpoint is a signal in a specific line of the program source code. This signal indicates to the ABAP runtime processor to stop the program at the relevant line and start the ABAP Debugger. A distinction is made between static and dynamic breakpoints.

Direct Processing
Start the Debugger without previously having set breakpoints. This is the best procedure to use when a program has to be started right from the From the Object Select a program or transaction and choose beginning. Navigator Program Test Debugging.
From the ABAP Editor

The Debugger can be started in one of From any Screen ways: Choose System Utilities Debug ABAP. the following
Enter /h in the command field.

Choose Program Execute Debugging (or the Debugging pushbutton). In the source code display, you need to select the menu Program Test Debugging

Debugging Display modes


Display Modes Available Using Pushbuttons Button Description
Fields The scrollable field display contains the contents of up to eight fields. The contents of the three most important system fields are always displayed. This is the default display mode in the Debugger. Displays the contents of an internal table.

Table

A scrollable display containing up to 30 Breakpoin breakpoints. Next to each breakpoint is a counter. ts You can also delete breakpoints in this display Set a watchpoint for a field so that the program is Watchpoin interrupted whenever the value of that field ts changes. Calls This mode displays the current sequence of events,

Breakpoints
Apart from being able to execute an ABAP program in the Debugger, it is possible to start the Debugger by choosing a breakpoint. This is achieved by setting one or more of these breakpoints in the program. A breakpoint is a signal at a particular point in the program that tells the ABAP

Static Breakpoints
Static breakpoints are always userindependent if there is no specification of a user name.

On inserting BREAK-POINT or BREAK statement in an ABAP program, the system always interrupts the program at that point for that user or only for the user name.

Dynamic Breakpoints
Dynamic breakpoints are user-specific. All dynamic breakpoints are deleted when you log off from the R/3 System. Dynamic breakpoints are more flexible than static breakpoints because you can deactivate or delete them at runtime.

Breakpoints
Causes program execution to stop at that location and start the debugger Several breakpoints can be set simultaneously in the new Debugger by choosing the path Utilities Breakpoint Set. A debugger breakpoint is only valid while the Debugger instance, in which it was set,

Watchpoint
Like a breakpoint, a watchpoint is an indicator in a program that tells the ABAP runtime processor to interrupt the program at a particular point. Unlike breakpoints, however, watchpoints are not activated until the contents of a specified field change. Watchpoints, like dynamic breakpoints, are

Watchpoints (Contd.).
Used to interrupt a program when contents of field or structure change It allows the option of monitoring the content of individual variables The Debugger stops as soon as the value of the monitored variable changes. Creating a Watchpoint
Use the pushbutton Create Watchpoint in the toolbar of the New Debugger.

The New Debugger


The ABAP Debugger is an integrated test tool within the ABAP Workbench It is used to check the program logic and to find errors in the source code of an ABAP program. All the functions of the classic Debugger, with a few exceptions, are contained in the new Debugger

Select the Debugger

Debugger - Starting and Exiting

Start the Debugger via the path Utilities Settings ABAP Editor Debugging.

Start the New Debugger


Control can be passed from the application to the new Debugger at any time using the function code /h, even if the Debugger was already started

Exiting the New Debugger

SAPScripts and Smartforms

Sapscript - Introduction
SAP scripts is the standard SAP form design tools for user to developed customized form for printing

SAPScript is text processing tool of SAP


SAPScript is primarily used to print forms Forms can have Graphic element

Advantages of SAPScript
High performance during mass printing Multilingual capability Support to various hardware platforms and

Integrated connection to SAP transport organizer.

Components of SAPScript
Editor
For entering and editing the lines of a text

Styles and Forms


To print layouts These are created independent of the individual texts using the corresponding maintenance transactions

Composer

A Programming Interface

Components of SAPScript (Contd.).


Allows to include SAPScript components into the application programs and to control the output of forms from within the programs

Database Tables
For storing texts, styles and forms

SAPScript
SAP Script

Define

SAP document

Read Data

Layout Set Template

Print Forms

Client and Language Version


Forms and styles are client-specific. A form or style other than the SAP standard in client 000 is available only in the client in which it was created Forms and styles are also languagespecific

The definitions and texts in a form or style

SAPScript - Layout
Each form consists of a start page and any number of subsequent pages, depending on the length of the letter text.

Whenever a window on one page is full, the remaining text is automatically output on the subsequent page.
The window thus controls the page break.

Form Painter (SE71)


Form Painter is used to create, display, and change SAPscript forms SAPscript form consists of the following objects:
Header Data Paragraph and Character Formats Windows and Text Elements Pages

Header Data
Header Data is in both form and style maintenance In style maintenance, it is used primarily to present important information
Information designed to make it easier for the end user to select a style.

The header data in form maintenance is used for information and control purposes

Form - Pages
A page must be defined for a form A First Page must be designated in the form header The system should be informed about the page to be used (NEXT PAGE) after reaching the end of First Page

If a next page is not specified, the output

Form - Windows
Forms consist of individual text areas. To provide these areas with texts, define the areas as output areas. Then print the appropriate texts in these output areas, controlled by the print program.

SAPscript calls such an output area a

Form - Windows
Texts can be assigned to each form window. Text elements are part of the form and stored together with the other form elements. Text elements also receive names which are used to refer to the respective text elements via the programming interface.

Form Pages and Windows

Pages Windows

Form Window Types


Window Types
When defining a form window a window type must be selected for the window. Three types of windows are:
Constant Windows (CONST)
Variable Windows (VAR)

Form - Window
Date
Heading Variable Window
Window with Body Text

Main Window

Footer

The contents of variable windows are processed again for each page, on which the window appears.

Windows Variable and Constant

The system outputs only as much text as fits into the window.
Text exceeding the window size is truncated and the system does not trigger a page break.

Form - Main Windows


Each form must have one window of type MAIN. For SAPScript forms, the main window has a central meaning:
It controls the page break. It contains the text body that may cover several pages. It allows to fix text elements at the upper and lower margins of the allocated page window (for example, for column headings).

Form - Main Windows


If a page does not have a main window, the system implicitly processes all other windows of the page and continues with the subsequent page. This page must not call itself as subsequent page (recursive call), since this would produce an endless loop. In such a case, SAPscript terminates the

For outputting texts in the main window, or, more correctly, in a page window of type MAIN, there are three different areas.
The upper margin of the main window is called TOP area; The lower margin is called BOTTOM area.
The area in-between is called BODY of the main window.

Output Areas in the Main Window

Form - Main Window


The different areas in the main window are
TOP, BODY, and BOTTOM Areas of a Main Window

The contents of the three areas TOP, BODY, and BOTTOM can be determined or modified dynamically during the output of the form.

Main Window - TOP Area


The TOP area always appears at the beginning of the main window. It can be used to automatically output headings on the subsequent pages for tables that cover several pages. All output you place into the TOP area using the print program is not formatted at once, but stored internally in SAPscript

The BOTTOM area appears at the end of the main window. Unlike the TOP area, the BOTTOM area can be defined for the current page after the output to the BODY area is complete, provided there is enough space left on the page. Otherwise, the BOTTOM area text is

Main Window BOTTOM Area

Page Window
A page window is the definition of a rectangular output area on the output medium (for example, DIN A4 paper page), determined by the left upper edge and the height and width of the area. By defining page windows, which windows has to appear on a page, their sizes and their positions are determined. When defining windows and pages, the position and spacing of the texts to be

Page Windows
Top Margin Left Margin

Window

Height

Page Window
Pag e

Width

Defining Page Windows


When defining a page window, determine
Which windows appear on a certain page,

What size the windows have (width, height),


Their position (distance between the left upper window edge and the left and upper page margins).

Paragraph Format
In SAPScript, paragraphs are formatted using formats and their corresponding attributes.

Text processing is simplified by the use of different paragraph attribute groups:


Standard Font Tabs Outline

Paragraph Format
In the Standard attribute group, the general attributes that can be defined in paragraph formats are:
Description
Precise explanation of your paragraph tag, so that the user can immediately identify it.

Left or right margin


Amount of space between the paragraph and the left or right border of the form window.

Indent first line


Indent of the first line of a paragraph. If the value is positive, it is indented to the right, if it is negative, it is indented to the left. If you specify a negative value, then you must place the minus sign after the number: 1-.

Space before and space after


Space before and space after control the amount of space between

Character Format
Character formats, as opposed to paragraph attributes, allows to format entire blocks of text within a paragraph.

Character attribute groups can be:


Standard Font

Text Elements
A window contains texts and variables to be printed in the window Text elements (window texts) can be defined for each window. SAPscript calls the individual text components of a form text elements.

Text elements are related to a window.

Text Elements (Contd.).


In the layout of a text element, use only the paragraph and character formats defined in the form.

Example of a text element in an order confirmation:


/E ITEM_LINE IL &VBDPA-POSNR&,,&VBDPAMATNR&,,&VBDPA-ARKTX& / &'Customerarticlenumber 'VBDPA-IDNKD'

Text Elements (Contd.).


Different Types of Text Elements
Text Element with Name
Can only be defined for a window An interfacw function WRITE_FORM is required

Text Element without Name


They are default text elements whose text lines and control statements appear at the beginning of

Print Program
An application that allows to print documents The print program retrieves the required data from the database and combines them with the data the user entered. R/3 applications (FI, CO, MM and so on) deliver standardized forms and print programs that customers may have to

Graphics
The SAPscript Graphics Administration (transaction code SE78) is used to import, administer, transport, and preview graphics before printing. Graphics are stored in a document server *.BMP and *.TIF files can be imported.

Uploading Graphics
2. Include Graphics using Standard Programs
i. Go to ABAP Editor-SE38 ii. Execute RSTXLDMC program.

iii.Specify the Tif file name, the type and the text name. iv.Execute

SAPScript Symbols
SAPscript recognizes four different kinds of symbols:
System symbols
SAPscript provides values for the system symbols.

Standard symbols
Standard symbols and their values are defined in the TTDTG table

Program symbols

Syntax Of Symbols
Each symbol has a name that is used when the symbol is called. A call to a symbol is normally made in a line of text that also includes other kinds of text. Use the delimiter & both immediately before and after the symbol.

Program Symbols
The integration of SAPscript allows to link data that is stored in various applications of the SAP system into text modules;

The system can evaluate the ABAP Dictionary information (output length, number of decimal places, and so on) not only for TABLES fields, but also for INFOTYPES fields and variables with a LIKE reference.

Standard Symbols
Standard symbols are defined in table TTDTG. This table contains both the name of each symbol and its value. The value is language-dependent.

Text Symbols
All the text symbols contained either in the current text or in a form assigned to the text are displayed.

The effect of assigning a value is temporary, since the values assigned are not stored with the text but are lost as soon as you leave the editor.
In the text the control command DEFINE is

The functionality of the SAPscript editor is made available through a set of commands.

SAPscript Control Commands

These commands give full editing control over your text and are executed immediately when called.
These commands are not interpreted by the SAPscript editor, but are passed

Syntax of control Commands


Enter the paragraph format /: in the format column to identify a control command. Enter the command in the text line. Enter only one control command in each line.

NEW-PAGE
Explicit Page Break: NEW-PAGE
SAPscript automatically inserts a page break when the main window of a page (MAIN) is full.
The NEW-PAGE command is used to force a page break in the text at any point The text following this command then appears on a new page.

Preventing Page Breaks


PROTECT
If a particular paragraph should not be split in two by a page break use PROTECT.ENDPROTECT Command If this page protect attribute is set, then the complete paragraph is always printed on one page.

Syntax

Next Main Window


NEW-WINDOW
Each page can consist of up to 99 main windows. Each main window is assigned a consecutive identifying number (0..98), and the windows are filled in this order.
When one main window fills up, the next main window on that page is taken, if there is a next one.

DEFINE & ADDRESS


Assigning a Value to a Text Symbol: DEFINE
Syntax
/: DEFINE &symbol_name& = 'value' /: DEFINE &subject& = 'Your letter of 7/3/95

Formatting Addresses: ADDRESS


The ADDRESS - ENDADDRESS control command formats an address according to the postal convention of the recipient country defined in the COUNTRY parameter. Syntax
/: ADDRESS [DELIVERY] [TYPE t] [PARAGRAPH a] [PRIORITY p] [LINES l] /: TITLE title /: NAME name1[,name2[,name3[,name4]]] /: DEPARTMENT department /: STREET street name HOUSE house number /: LOCATION additional location information /: POBOX po box [CODE post code / zip code] [CITY city] /: POSTCODE post code / zip_code .. /: ENDADDRESS

Setting a Header Text in the Main Window: TOP


The TOP.. ENDTOP control command is used to specify lines of text that is to be printed always at the top of the main window.

Header Text in the Main Window

These text lines are also known as header texts. Syntax

Setting a Footer Text in the Main Window: BOTTOM


The footer texts for the main window can be specified in a similar way to header texts. Footer texts are always printed at the bottom of the window. Syntax
/: BOTTOM

Footer Text in the Main Window

Conditional Text
IF
The IF control command is used to specify that text lines should be printed only when certain conditions are met.
Syntax
/: IF condition : /: ELSEIF condition : /: ENDIF

Finding a Match
CASE
The CASE command covers a special case of the multiple case IF command. Syntax
/: CASE symbol /: WHEN value1 : /: WHEN value2 : /: WHEN valuen

Subroutines
ABAP Subroutines: PERFORM
The PERFORM command is used to call an ABAP subroutine from any program. PERFORM commands, like all control commands, are executed when a document is formatted for display or printing. Communication between a subroutine that you call and the document is by way of symbols whose values are set in the subroutine.

Subroutines (Contd.).
INVAR1 and INVAR2 are variable symbols and may be of any of the four SAPscript symbol types.

OUTVAR1 and OUTVAR2 are local text symbols and must therefore be character strings.
The ABAP subroutine called via the command line stated above must be

Subroutine (Contd.).
Form

/: PERFORM <form> IN PROGRAM <prog>


/: USING &invar1& /: USING &invar2& /: CHANGING &outvar1& . /: ENDPERFORM

Report <prog>. FORM <form> TABLES in_tab STRUCTURE itcsy Out_tab STRUCTURE itcsy. .. ENDFORM.

NA VAL ME UE Inva . r1 Inva .. r2 ABAP Report

ABAP Dictionar y

Boxes, Lines and Shading


BOX, POSITION, SIZE
The BOX, POSITION, and SIZE commands are used for drawing boxes, lines, and shading to print particular windows within a form or passages of text within a window in a frame or with shading. Syntax
/: BOX [XPOS] [YPOS] [WIDTH] [HEIGHT] [FRAME]

SAPScript Styles
Styles are used to define the paragraph and character formats A style can be allocated to every text Styles can be used to highlight texts Styles are used for the main windows of the form

SAPScript Styles (Contd.).


To modify SAP Styles the development environment has to be set:
Make sure that no SAP standard styles are stored as client-dependent copies in the development client.

To modify the styles, copy the style from client 000 to the development client.
Assign a name from the name area reserved for

Using Styles
Paragraph and Character formats can be defined independent of forms Styles can be assigned to any text in SAPScript The naming conventions for style names are :
The name must start with a letter.

Style Components
Header Data Paragraph Format and Attributes Paragraph formats control the formatting of paragraphs in SAPscript . Character Formats and Attributes

Creating and changing Style


Choose the tcode : SE72 or Tools Word processing Style(SE72) Create/Change
Define the paragraph formats of the style. Define the character formats of the style. Complete the header data of the style

Modifying SAP Forms


To modify the SAP Forms, the following development environment has to be set:
1. Make sure that no SAP-standard forms are stored as client-specific copies in the development client.
Such forms should be held only in client 000, the SAP development and installation client..

2. To modify SAP standard forms,


Copy the forms from client 000 to the development client. Rename the forms using a name from the

Comparing Client Contents


This is used
To check whether a particular standard text, style, or form already exists in another client. To identify differences in the object attributes and definitions.

It is possible to choose single objects for a comparison, or generate comparisons of a whole set of objects. A comparison covers only the attributes and, if applicable, the formal definition of

Comparing Client Contents


When the comparison is completed, the system displays a list with the source client in the left-hand column and the target client in the right-hand column. An empty line in either column indicates that the object does not exist in the corresponding client. The list highlights attributes that differ.

Copying Client Contents


To copy one or more standard texts, forms, or styles from one client to another client, choose Copy from client.

It is not possible to copy styles or forms to client 000.


To copy an object or set of objects from one client to another,

SAPScript
2. Goto SE38. Enter the print program name and execute. 3. Now its possible to debug the script both page and window wise

Smart Forms - Introduction


SAP Smartform is a tool used to create and maintain forms with minimal programming effort.

It also allows to execute simple modifications to the form and in the form logic by using simple graphical tools.
Its easy to create the form without much programming knowledge

Data retrieval and form logic are separated from each other. Application program passes data to Smartform through Function module interface which is generated automatically on Smartform activation. Provides GUI which helps user in performing critical tasks like creating and

Basic Features of SMARTFORM

The adaptation of forms is supported to a large extent by graphic tools for layout and logic, so that no programming knowledge is necessary

Key Benefits of SMARTFORM

Displaying table structures (dynamic framing of texts) Output of background graphics, for form design in particular the use of templates

Reusing Font and paragraph formats in forms (Smart Styles) Data interface in XML format (XML for Smart Forms, in short XSF) Form translation is supported by standard translation tools

Key Benefits of SMARTFORM (Contd.).

Flexible reuse of text modules

SMARTFORM Architecture
Smart Form WEB Browser ABAP Function Module (Generated)

Application Program

Printer

Fax Data base Data Retrieval Form Logic Output Device

Smart Forms
When the Smart Form is activated, 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 modules interface to transfer any table data previously selected and to print the form according to the form description.

Different Transaction codes used while working with Smartforms are :


Transaction Code Smartforms Smartstyles Description To Create forms to create paragraph formats, character formats, tab settings etc. to create any graphic image which in turn can be used as logo or

Transaction Codes in Smart Forms

SE78

Structure of SmartForm
SMARTFORMS provides a graphical user interface which is divided into three different parts:
Navigation Panel
PC Editor Form Painter

Pages and Windows


Provides list of all components of form. All the basic elements are maintained under this node
Pages, Windows, Graphic, Address.

Pages
Each form consists of one or more pages. The first page in the tree structure is the start page The page layout includes the page format and the position of windows on a page

Procedure for Creating Page


Select an existing page node to position the new page node. Create a new page node in the navigation tree of the Form Builder. Enter a unique name for the node and a description

Determine the format and the mode of the

Windows
Windows are output areas for all output data. The size and position of a window can be set graphically in the Form Painter. There are main windows and secondary windows.

The most important difference is that the

Window Types
The following window types can be defined in a form:
Main Window Secondary Windows

Copies Windows
Final Windows

Main Window
A main window is used to display text and data, which can cover several pages. 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.

Secondary Windows
In a secondary window text and data displayed in a predetermined output area. Text and data that do not fit into the secondary window are truncated and not displayed. The main difference between a main window and a sub window is that, the contents of the main window, which is

Copies Window
The copies window is used to define an output area for the print output, whose content has to appear either only on the copy or only on the original. this window type is used only to print copies of the form. In the spool dialog in the Number input field of the Copies group box enter the

Final Window
To display values that are processed in the initial pages . Processing first skips all windows of this type in the tree and works its way to the end of the tree. Only after the actual processing is finished, the final windows are processed in the order in which they appear in the

Texts and Data in a Form


PC Editor is used to enter texts. The following operations can be performed in the PC Editor:
Enter, delete, select, cut and copy texts. Assign paragraph and character formats. Include, change and delete fields.

Data can be character strings or numbers.

To format texts and fields (data), paragraph and character formats are used.

Texts and Data in a Form (Contd.).

Paragraph formats are assigned to entire paragraphs and character formats to individual character strings.
The paragraph format determines:
Font family and font size,

All texts in the form are displayed using text nodes. The only exception is addresses, which are displayed using their own node. Features
The following text types exist:

Positioning of Texts on the Form

Text Nodes are used to display texts in form Addresses are displayed in separate nodes

Positioning of Texts in Forms (Contd.).

Superior node of the text node determines its use.

The different Text Types are

Entering Texts in PC Editor


New texts are entered in PC Editor The system fields and the user-defined fields are used to include data from form interface SAP Smart Forms replaces these fields with the corresponding values on processing the form

Text Modules
Text modules are used to centrally store texts that are used frequently in forms in the system.

Text modules are included in forms using texts nodes


Allows easy use of text from a text module in several forms

Including SAPScript Texts


The text type Include Text of the text node is used to refer to a SAPscript text that already exists in the system

This text type corresponds to the SAPscript statement INCLUDE.


SAP Smart Forms does not allow any control statements in include texts

Character Format
Character formats are used to assign special output attributes to sections of texts or character strings within a paragraph After creating a character format, you can choose the following attributes:

Font attributes and superscripting/subscripting

Inserting Addresses
Addresses are administered using the Business Address Services (BAS). Depending on how the address is used, the application uses a particular address type. The addresses are stored in the database tables of the central address administration and identified by the

Depending on the addressee of an address, an address is made up of different components.

Mapping of Application Addresses

For a contact person in a company, for example, the company address and the name of the contact person is required and possibly the name of the department.
This is why it makes sense to distinguish between different types of addresses.

Graphics In Smartforms
The graphic administration is used to import, administer, and transport graphics, and to display them in a print preview.

Graphics can be incorporated statically into a form or include them dynamically using an appropriate field.
To copy any form in the Form Painter, scan the desired form as graphic and

Form printing is triggered by calling as few as two function modules. The first module uses the name of the form to determine the name of the generated function module.

Integrating the Smart Form into the Application

The name of the generated function module is unique only within one system.

Procedure (Contd.).
In the application program define a variable of type RS38L_FNAM for the name of the generated function module:

Data fm_name type RS38L_FNAM.


The Smart Form can be called in other parts of the application program as well.

Procedure (Contd.).
Call function module SSF_FUNCTION_MODULE_NAME . It returns the name of the generated function module:
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME' EXPORTING formname = <form name> " Specify th e form name * VARIANT ='' * DIRECT_CALL ='' IMPORTING FM_NAME = fmname "The function mo

Call the generated function module


CALL FUNCTION '/1BCDWB/SF00000187' * EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = * CONTROL_PARAMETERS = * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = * OUTPUT_OPTIONS = * USER_SETTINGS = 'X' * IMPORTING * DOCUMENT_OUTPUT_INFO = * JOB_OUTPUT_INFO = * JOB_OUTPUT_OPTIONS = * MARA_T = * EXCEPTIONS * FORMATTING_ERROR =1 * INTERNAL_ERROR =2 * SEND_ERROR =3

Working with Tables


Tables are Used to display or print contents in tabular form. The following node types can be used for tables:
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.

Printing tables
Smartform can display data in the form of tables The table can be designed independent of the number of lines The size of the table depends on how much data the application program passes to the form at runtime

Accessing Application Data


For accessing data in the application to display or print it in a table. The application program reads the data to be displayed on the form as a table from the database and writes it into an internal table. When calling the Smart Form, this internal table is passed to the form interface to

Reading Internal Tables


The table is printed in the form line by line as the number of selected entries in the internal table differs.

The table node, unlike the loop node, allows to define a table layout.
The table node is used to print one internal table as a table in the form.

1.Create a work area for the internal table in the global definitions.
a)If the Tables tab is used to pass the table at the form interface, work area is not required. b)Field symbols point to the current line instead of copying it into a work area.

Procedure to read Internal Tables

2.Go to the Data tab of the loop or table node and mark Internal Table else the loop is deactivated. 3.Enter the name of the internal table that is passed at the form interface.

Combining Loop and Tables


Both table and loop nodes have a Data tab, which enables to read internal tables. When multiple internal tables has to be accessed:
a table node is creates and Data tab is used to access the first internal table. In this node create the table layout using line types. Instead of creating table lines as directly inferior nodes of the table node, create a loop

Page Protection for Tables


Tables with application data are usually displayed in the main window because the number of lines to be output depends on the amount of data to be transferred. If there is not enough room in the main window, the output is continued on the next page. The automatic page break in the default

Page Protection for tables


Data protection for table lines prevents this from happening. Several table lines can be protected against automatic page break, which is particularly beneficial for the output of multiline tables. The columns of multiline tables are output on several lines.

Events and Output


SAP Smart Forms automatically inserts the calculations and initializations into processing.

The events are not visible in the navigation tree; they are triggered implicitly by SAP Smart Forms.
In the table below, which contains one sort criterion, these implicit events are

Branching within a form


To process one of two nodes, alternatively (including inferior nodes). Procedure
Create a node of type Alternative in the navigation tree of the Form Builder. On the General Attributes tab determine an unstructured condition in the Node Conditions box. The system offers the same features as in the Output Conditions box on the Conditions tab.

Dynamic Page Break


As soon as a page is full, SAP Smart Forms automatically triggers a page break. A page is full as soon as all output areas on this page are filled. Output to all output areas except the main window is truncated as soon as the area is full.

Page Numbering
Smart Forms use page counters to determine the page number.
&SFSY-PAGE& for the current page number &SFSY-FORMPAGES& for the total number of pages in the form &SFSY-JOBPAGE& for the total number fo pages in all forms in the print job

Use the General Attributes tab of the page

Migrating SAPscript Forms


SAP delivers Smart Forms for important business processes. two tools are provided by SAP to migrate SAPScripts to smartforms. Make use of this migration only to make extensive changes to existing SAPscript forms.

Individual Migration
It is possible to migrate a SAPscript form into a Smart Form and convert a SAPscript style into a Smart Style.

When converting a SAPscript style into a Smart Style, the system converts all paragraph and character formats with all their properties and attributes without any changes.

When migrating a SAPscript form into a Smart Form, the system executes the following steps:
It copies the language attributes and the output options. It migrates the layout information including pages, windows, and their attributes and positions on the page. It copies the texts in the form. It displays the fields (SAPscript notation: program symbols) in the texts.

Migrating SAPScript to SmartForms

Go to the SAP Smart Forms initial screen (transaction SMARTFORMS). In the Form field enter the name of the Smart Form to create. Choose Utilities Migration SAPscript form. The dialog window Migrate SAPscript Form appears.

Procedure to Migrate a SAPscript form

Migrating Forms - Procedure


If the selected SAPscript form does not exist in the selected language, a dialog window appears on which you can select one of the existing languages. Now change the design of the form and of the form logic. To activate the Smart Form choose Activate.

Converting a SAPscript style


Go to the Smart Styles inital screen (transaction SMARTSTYLES). In the Style name field enter the name of the Smart Style to create. Choose Smart Styles Convert SAPscript style.

Enter the name of the SAPscript style to

In Reporting select the program SF_MIGRATE and execute it.

Mass Migration of SAPscript Forms

Select the names and the language of the SAPscript forms and choose Execute. The system creates the Smart Forms under the names of the SAPscript forms plus the extension _SF. It displays a list of the migrated forms.

Das könnte Ihnen auch gefallen