Professional Documents
Culture Documents
Content.
Preliminaries. Data Declaration. Data Processing. List Processing.
Internal Tables Processing. Selection Screens. Field Symbols. Modularization.
Preliminaries:
• Notation.
• Literals.
• Elementary Data Types.
• Correspondence between ABAP/4 Dictionary Data Types and Elementary Data
Types.
• Specifying Offset Values for Data Objects.
• Conversion Rules:
o Elementary Data Types.
o Field Strings.
o Internal Tables.
o Alignment of Data Objects.
• Formatting Options.
Declaring Data:
• Types Definition:
o TYPES.
Elementary Types.
Internal Tables.
Lines of Internal Tables.
Field Strings.
o TYPE-POOLS.
• Data Definition:
o TABLES.
o DATA.
o CONSTANTS.
o STATICS.
o Determining the Attributes of Data Objects (DESCRIBE FIELD|TABLE).
Data Processing:
• Assignment Operations:
o Assignment Operator.
o MOVE TO.
o MOVE-CORRESPONDING.
o WRITE TO.
o CLEAR.
o FREE.
• Numerical Operations:
o COMPUTE.
o Using Mathematical Functions.
o Basic Arithmetical Operations.
o Arithmetical Operations with Field Strings (-CORRESPONDING).
o Adding Sequences of Fields (ADD extensions).
o Operators Precedence.
• Character Strings Operations:
o SHIFT, REPLACE, TRANSLATE, CONVERT, OVERLAY, SEARCH,
CONDENSE, STRLEN, CONCATENATE, SPLIT, MOVE
PERCENTAGE.
• Logical Operations:
o Comparisons:,
All Field Types.
Character Strings and Numeric Strings.
Bit Structures.
o Checking Whether a Field Belongs to a Range (BETWEEN).
o Checking for the Initial Value.
o Checking Selection Criteria.
o Combine Operators and Operators Precedence.
Lists Processing:
• Write Operation:
o WRITE.
o Type-Specific Output.
o Positioning Output on the Screen.
o Outputting Symbols and Icons.
o Lines and Blank Lines (ULINE, SKIP etc.)
o Outputting Field Content as Checkbox.
o Outputting Field Content as Line.
o FORMAT statement:
COLOR.
SUMMARY, DETAIL.
HOTSPOT.
INPUT.
RESET.
• Define Structure of List:
o List Width (REPORT..).
o Page Length (REPORT..).
o Individual Page Header (REPORT.., TOP-OF-PAGE).
o Individual Page Footer (REPORT.., END-OF-PAGE).
o Page Break (NEW-PAGE).
RESERVE.
o Scrolling.
o Displaying Lists in Dialog Window.
o Positioning the Output (POSITION, BACK).
o SET TITLE.
o Retrieving List Attributes (DESCRIBE LIST).
• Interactive Lists:
o HIDE.
o READ LINE, MODIFY LINE.
o GET CURSOR, SET CURSOR.
o Events Control in Interactive Lists:
AT LINE-SELECTION.
AT PFnn.
AT USER-COMMAND.
SET USER-COMMAND.
o SET PF-STATUS.
o Messages in Lists.
Messages Types.
• Predefined System Codes.
Selection Screens:
• Parameters
• Selection Options
• Selection Screen Formatting
• Selection Screen Events:
o INITIALIZATION,
o AT SELECTION-SCREEN,
o AT SELECTION-SCREEN ON ...,
o AT SELECTION-SCREEN ON END OF...,
o AT SELECTION-SCREEN ON BLOCK...,
o AT SELECTION-SCREEN ON RADIOBUTTON GROUP...,
o AT SELECTION-SCREEN ON VALUE-REQUEST FOR ....
o AT SELECTION-SCREEN ON HELP-REQUEST FOR ....
o AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN,
MODIFY SCREEN,
Field Symbols:
Modularization:
Preliminaries.
Notation.
Go to top...
Go to next...
Literals.
Go to top...
Go to next...
Text Literals
Text literals are sequences of alphanumeric characters enclosed in single
quotation marks:
• 'Hello, world!'
• 'Victor''s Home Page.'
Can be up to 254 characters long. If a text literal contains a quotation mark, you
must repeat it to enable the system to recognize the contents as a text literal and
not as the end of the literal.
Numbers Literals
Number literals are sequences of digits that may contain a leading sign. They can
contain up to 15 digits:
• 151163
• -1917
• +4
Non-integer values or a longer numbers can be defined as text literals which are
converted to the correct type automatically (see Conversion Rules):
• '151163151163151163151163'
• '+4.5'
Likewise, text literal represents a floating-point value. This must have the
following format:
'[<mantissa>][E][<exponent>]'
• '1E77'
• '+1.5E-12'
Conversion Rules.
Go to top...
Go to next...
• Internal tables that have internal tables as line types are convertible if the
internal tables that define the line types are convertible.
• Internal tables that have line types that are field strings with internal tables
as components are convertible only if the field strings are compatible.
Declaring Data.
Types Definition.
Go to top...
Go to next...
• TYPES <type>[<length>].
Default C(1). <length> should only be used with the types C, N, P and X.
Other types can only be created in the standard length. Additions:
o TYPE <knowntype>.
LIKE <f>.
Defines the new type. <f> - a database field or an already defined
internal field.
o TYPE <knowntype> OCCURS <n>.
LIKE <f> OCCURS <n>.
Defines the new type of an internal table without a header line.
This table consists of any number of table lines that have the same
structure as that specified by TYPE.
The OCCURS parameter <n> specifies how many table lines of
storage is required. This storage reservation process does not
happen until the first line is inserted in the table. The value <n> of
the OCCURS specification has no effect on type checking, i.e. data
objects which have types with different OCCURS specifications
are type-compatible.
o TYPE LINE OF <itabtype>.
LIKE LINE OF <itab>.
Creates a type corresponding to the line type of the specified table
type <itabtype> or of the specified table <itab>.
• TYPES BEGIN OF <rectype>
...
END OF <rectype>.
Defines the field string <rectype>.
TYPE-POOLS:
TYPE-POOLS <name>.
Allows using all the data types and constants defined in the type group <name>.
Type groups store user-defined data types or constants in the ABAP/4 Dictionary
for cross-program use.
Data Definition.
Go to top...
Go to next...
TABLES:
TABLES <databasetable>.
Makes the database table, view or structure known to the program. Defines the
identical field string - the table work area - in the program. The names and the
sequence of the fields of the table work area correspond exactly to the names and
the sequence of the fields when declaring the database table or view in the
ABAP/4 Dictionary. The ABAP/4 data type and the length of the fields are
derived from the data types in the ABAP/4 Dictionary as follows.
DATA:
the DATA statement has the same form as TYPES, plus optional additions:
CONSTANTS:
the CONSTANTS statement has the same form as DATA, but addition ...
VALUE <value> is obligatory.
STATICS:
the STATICS statement has the same form as DATA.
Retains the value of a variable beyond the runtime of a procedure (subroutine or
function module).
Determining the Attributes of Data Objects:
DESCRIBE FIELD <f> [LENGTH <l>] [TYPE <type> [COMPONENTS
<n>]] [OUTPUT-LENGTH <lo>] [DECIMALS <nd>] [EDIT MASK
<mask>].
The attributes of the data object <f> specified by the parameters of the statement
are written to the variables following the parameters:
Data Processing.
Assignment Operations.
Go to top...
Go to next...
Assignment Operator:
<fn> = ... <f3> = <f2> = <f1>.
Equivalent to MOVE. Executed from right to left.
MOVE TO:
MOVE <f1> TO <f2>.
Follows the Conversion Rules.
See also MOVE PERCENTAGE for character string.
MOVE-CORRESPONDING:
MOVE-CORRESPONDING <fstring1> TO <fstring2>.
This statement assigns the contents of components of field string fstring1 to those
components of field string fstring2 which have the same names.
WRITE TO:
WRITE <f1> TO <f2> [<options>].
Does NOT follow the Conversion Rules. The target field is interpreted as a type C
field.
Option - all Formatting Options except UNDER and NO-GAP.
Always checks the settings in the user's master record, e.g. whether the decimal
point appears as a period (.) or a comma (,).
Specifying the Source field at Runtime with WRITE TO:
WRITE (<f1>) TO <f2>.
The system places the value of the data object assigned to <f1> in <f2>.
Example:
DATA: NAME(10) VALUE 'SOURCE',
SOURCE(10) VALUE 'Antony',
TARGET(10).
...
WRITE (NAME) TO TARGET.
WRITE: TARGET.
This produces the output:
Antony
CLEAR:
CLEAR <f>|<fstring> [WITH <g>|NULL].
Resets the contents to initial values (or to a first byte of <g> or to X'00').
FREE:
FREE <f>|<fstring>.
Like CLEAR, resets the contents to initial values. Also releases any resources
connected with the data object.
This may be relevant with internal tables, structures with tabular components as
well as table work areas.
Numerical Operations.
Go to top...
Go to next...
COMPUTE:
[COMPUTE] <n> = <expression>.
Using Mathematical Functions:
[COMPUTE] <n> = <function>( <m> ).
The blanks between the parentheses and the argument <m> are obligatory.
Functions for all Numeric Data Types: ABS, SIGN, CEIL, FLOOR, TRUNC,
FRAC.
Floating-Point functions: COS, SIN, TAN, ACOS, ASIN, ATAN, COSH, SINH,
TANH, EXP, LOG, LOG10, SQRT.
Operators Precedence:
The order of evaluation is:
1. expressions in parentheses
2. functions
3. ** (exponentiation)
4. *, / , MOD, DIV (multiplications, divisions)
5. +, - (additions, subtractions)
SHIFT * :
SHIFT <c> [BY <n> PLACES] [LEFT|RIGHT|CIRCULAR].
<n> can be a variable, must be >0 (no actions if <0), default is 1. LEFT is default.
SHIFT <c> UP TO <str> [LEFT|RIGHT|CIRCULAR].
<str> is a substring to search in <str> and can be a variable. LEFT is default.
If <str> is not found in <c>, SY-SUBRC is set to 4 and <c> is not shifted.
Otherwise, SY-SUBRC is set to 0.
SHIFT <c> LEFT DELETING LEADING <str>.
SHIFT <c> RIGHT DELETING TRAILING <str>.
<str> can be a variable.
REPLACE * :
REPLACE <str1> WITH <str2> INTO <c> [LENGTH <len>].
Searches the field <c> for the first occurrence of the first <len> positions of the
pattern <str1>. If no length is specified, it searches for the pattern <str1> in its full
length. Then, the statement replaces the first occurrence of the pattern <str1> in
field <c> with the string <str2>. If a length <len> was specified, only the relevant
part of the pattern is replaced.
SY-SUBRC = 0: string replaced; SY-SUBRC = 4: string not replaced.. <str1>,
<str2>, and <len> can be variables.
TRANSLATE * :
TRANSLATE <c> TO UPPER CASE.
TRANSLATE <c> TO LOWER CASE.
To convert also umlauts the profile parameter abap/locale_ctype must be set and
character set must be found.
TRANSLATE <c> USING <str>.
<str> contains pairs of letters, where the 1st letter of each pair is replaced by the
2nd letter. Can be a variable.
TRANSLATE <c> FROM CODE PAGE <g1> TO CODE PAGE <g2>.
TRANSLATE <c> FROM CODE PAGE <g>.
TRANSLATE <c> TO CODE PAGE <g>.
Conversion tables <g1> and <g2> must exist, otherwise Runtime error. Use
transaction SPAD to maintain conversion tables TCP00 - TCP02. Some
conversion combinations maintained at Runtime for performance reason (e.g.
'1110' - HP, '0100' - EBCDIC (IBM 274)).
I, P, F, X fields remain unchanged.
TRANSLATE <c> FROM NUMBER FORMAT <N1> TO NUMBER
FORMAT <N2>.
TRANSLATE <c> FROM NUMBER FORMAT <N>.
TRANSLATE <c> TO NUMBER FORMAT <N>.
Number format <N> can be '0000' (HP, SINIX,IBM) or '0101' (DEC alpha OSF).
Function module SYSTEM_FORMAT displays system code page and number
format.
CONVERT:
CONVERT TEXT <c> INTO SORTABLE CODE <sc>.
Source <c> must be C or W type. Target <sc> should be of type X and at least 16
times (for C) or 4 times (for W) as long as source. The method of conversion
depends on the text environment of the running ABAP/4 program. The text
environment is defined in the user's master record or, as an exception, can be set
via SET LOCALE LANGUAGE.
The purpose of this statement is to create an accompanying field <sc> for a
character field <c>, which can serve as an alphabetical binary sort key for <c>,
which is NOT dependent of platform-specific internal coding of the individual
letters.
OVERLAY * :
OVERLAY <c1> WITH <c2> [ONLY <str>].
Overlays all positions in <c1> containing letters which occur in <str> with the
contents of <c2>. If omit ONLY <str>, only SPACEs are overwritten.
SY-SUBRC = 0 : at least one character was replaced; SY-SUBRC = 4 : other
cases.
SEARCH * :
SEARCH <c> FOR <str> [<options>].
Searches <c> for the character string in <str>. If successful, SY-SUBRC = 0 and
SY-FDPOS = offset. Otherwise SY-SUBRC = 4.
Pattern:
Options:
CONDENSE * :
CONDENSE <c> [NO-GAPS].
Removes leading blanks. Replaces other sequences of blanks with one blank or
removes all blanks if NO-GAPS.
STRLEN * :
[COMPUTE] <n> = STRLEN( <c> ).
CONCATENATE * :
CONCATENATE <c1> ... <cn> INTO <c> [SEPARATED BY <s>].
Trailing blanks ignored. SY-SUBRC = 0 : OK; SY-SUBRC = 4 : result has to be
truncated.
SPLIT * :
SPLIT <c> AT <delimiter> INTO <c1> ... <cn>.
To place all fragments in different target fields, you must specify enough target
fields. Otherwise, the last target field is filled with the rest of the field <c> and
still contains delimiters.
SY-SUBRC = 0 : All target fields are long enough and no fragment has to be
truncated. Otherwise SY-SUBRC = 4.
SPLIT <c> AT <delimiter> INTO TABLE <itab>.
For each part of the character string, the system adds a new table line.
MOVE PERCENTAGE:
MOVE <c1> TO <c2> PERCENTAGE <n> [RIGHT].
<n> = 0...100. PERCENTAGE ignored when either <c1> or <c2> are not C type.
Logical Operations.
Go to top...
Go to next...
Comparisons:
... <f1> <operator> <f2> ...
All Field Types:
Operators:
NE
EQ LT LE GT GE
<>
= < <= > >=
><
The operands can be database fields, internal fields, literals, or constants;
structured data types (compared component by component and nested structures
are broken down into elementary fields); internal tables. Fields of different data
types can be compared (if they are convertible) after an automatic Type
Conversions according to the following hierarchical rules:
One of the Other
Conversion
operands operand
F any to F
P any to P
to D or T.
D or T any Note. Comparison between D and T not supported
and causes program termination.
C X to C
C N both to P
Character Strings and Numeric Strings:
Only for types C and N.
Case- Trailing SY-FDPOS SY-FDPOS
Op. Meaning True if
sensitive Blanks if true if false
CO Contains yes included <f1> contains length of <f1> offset of the
Only only characters first character
from <f2> of <f1> that
does not occur
in <f2>
offset of the
<f1> contains
first character
contains characters other
CN yes included of <f1> that length of <f1>
Not Only than those in
does not occur
<f2>
in <f2>
offset of the
<f1> contains at
first character
Contains least one
CA yes ? of <f1> that length of <f1>
Any character from
occurs in
<f2>
<f2>
offset of the
<f1> contains no
contains first character
NA yes ? one character length of <f1>
Not Any of <f1> that
from <f2>
occurs in <f2>
Contains <f1> contains offset of <f2>
CS no ignored length of <f1>
String <f2> in <f1>
contains <f1> does not offset of <f2>
NS no ignored length of <f1>
No String contain <f2> in <f1>
CP Contains no ignored <f1> contains offset of <f2> length of <f1>
Pattern pattern <f2>: in <f1>
• * - any
character
string;
• + - any
single
character;
• #c - the
particular
character
(in upper
or lower
case);
• #* - the
"*"
symbol;
• #+ - the
"+"
symbol;
• ## - the
"#"
symbol
itself;
• #___ -
the
trailing
blanks.
<f1> does not
contains offset of <f2>
NP no ignored contain pattern length of <f1>
No Pattern in <f1>
<f2>
Bit Structures:
Compares first byte of the <f1> with <f2>, which should have length 1 byte
(recommended use as <f2> type X length 1).
Operator Meaning True if
O bits are one bits that are 1 in <f2>, are 1 in <f1> as well
Z bits are zero bits that are 1 in <f2>, are 0 in <f1>
from bits that are 1 in <f2>, at least one is 1 an one is 0 in
M bits are mixed
<f1>
Checking Whether a Field Belongs to a Range:
... <f1> BETWEEN <f2> AND <f3> ...
it is short form of
... <f1> GE <f2> AND <f1> LE <f3> ...
Checking for the Initial Value:
... <f> IS INITIAL ...
true if <f> contains the initial value for its type. In general, any field, elementary
or structured (field strings and internal tables), contains its initial value after a
CLEAR <f> statement is executed.
Checking Selection Criteria:
... <f> IN <sel> ...
If the selection criteria <sel> is attached to <f> with the SELECT-OPTIONS
statement the short form can be used:
... <sel> ...
Combine Operators and Operators Precedence:
Priority: NOT AND OR. Equal priority operations are processed from left to
right. If one of the component expressions is recognized as true or false, the
remaining part is not performing if total expression can be known. Therefore you
can improve performance by organizing logical expressions (for example, by
placing comparisons which are often false at the beginning of an AND chain and
expensive comparisons, such as searches for character strings, at the end).
Lists Processing.
Write Operation.
Go to top...
Go to next...
WRITE (see transaction LIBS for SAP guidelines using colors, symbols, icons etc. in
lists):
WRITE <f> [<formatting options>].
<f> can be:
• / - new line;
• <pos>, <len> - numbers or variables up to 3 digits;
• AT can be omitted if <pos>, <len> are not variables.
If <len> is too short, fewer characters are displayed. Numeric fields are truncated
on the left and prefixed with an asterisk (*). All other fields are truncated on the
right, but no indication is given that the field is shorter.
• vertical lines, output with the system field SY-VLINE or using a field
with the contents "|" (vertical line);
• horizontal lines, output with the system field SY-ULINE or using a field
with at least 2 consecutive minus signs "--".
Exactly how each line segment is output (e.g. whether as straight line, corner, T-
piece or cross) depends on the adjoining characters.
The include <LINE> (or the more comprehensive include <LIST>) contains the
relevant identifiers for lines as constants, e.g. LINE_TOP_LEFT_CORNER,
LINE_BOTTOM_MIDDLE_CORNER.
FORMAT:
FORMAT <option1> [ON|OFF] <option2> [ON|OFF] ... .
FORMAT <option1>=<var1> <option2>=<var2> ... .
Effective from next output (WRITE or new line) operation until next event or
turning OFF. ON = default. <vari> should be of type I. If the <vari>=0, the
variable has the same effect as the OFF option. If WRITE statement follows the
FORMAT statement, the settings of the WRITE statement overwrite the
corresponding settings of the FORMAT statement for the current output.
•
Call the SHOWCOLO report in any system for demonstration of colors
in lists.
• SUMMARY. this is equivalent to FORMAT INTENSIFIED ON.
DETAIL. this is equivalent to FORMAT INTENSIFIED OFF.
• FORMAT HOTSPOT [ON|OFF].
Affects the display format of the mouse pointer and the effect of the
mouse single click: If you drag the mouse pointer over list areas which are
output with the format ...HOTSPOT (lines or fields), the mouse pointer
switches from its standard display format (usually an arrow) to the format
of a hand with an outstretched index finger. If you then click once, the
effect is like double-clicking or pressing the function key F2 (AT LINE-
SELECTION). Has no effect on input fields.
• FORMAT INPUT [ON|OFF].
Determines whether the user can enter data. See READ LINE.
• FORMAT RESET.
The same as FORMAT COLOR OFF INTENSIFIED OFF INVERSE
OFF HOTSPOT OFF INPUT OFF.
• SCROLL works for completed lists only. If you use SCROLL before the
first output statement of a list, it does not affect this list. If you use
SCROLL after the first output statement of a list, it affects the entire list,
that is, all subsequent output statements as well;
• While creating a secondary list, a SCROLL statement without INDEX
option always refers to the previously displayed list on which the
interactive event occurred (index SY-LISTI);
• Only when creating the basic list does the SCROLL statement refer to the
currently created list;
• You can use the INDEX option to explicitly scroll on existing list levels.
To do this, the lists need not be displayed. When the user displays the list
again, it is scrolled to the specified position. If the specified list level does
not exist, the system sets SY-SUBRC to 8;
• If, during an interactive event, you want to scroll through the list you are
currently creating, use SY-LSIND as the index in the SCROLL statement.
Note that a manipulation of SY-LSIND takes effect only at the end of the
event on the created list, independent of where you place the statement in
the processing block. If you want to set the list level explicitly, you must
manipulate SY-LSIND in the last statement of the processing block to
make sure that a SCROLL statement within the processing block accesses
the correct list;
• Another way of scrolling interactive lists from within the program is to use
the SET USER-COMMAND statement in connection with the
corresponding system-defined function codes;
• SY-SUBRC = 0 : Ok; = 4 : scrolling was not possible (exit boundaries); =
8 : list level does not exist.
POSITION <column>.
Sets horizontal output position. Se also WRITE AT and SKIP TO LINE for
vertical output position.
BACK.
Subsequent output appears beneath the page header or to the first line of a block
of lines defined with the RESERVE, if used. If you specify BACK at the TOP-
OF-PAGE event, the system does not set the output position to beneath the entire
page header, but only to beneath the standard page header. Any output written
now overwrites the self-defined page header specified at TOP-OF-PAGE.
SET TITLEBAR:
SET TITLEBAR <titlebar> [WITH <f0> <f1> ... <f9>].
Sets a screen title. A set title remains valid within a transaction until you call SET
TITLEBAR again. SY-TITLE (can be up to 70 characters long) contains the
current screen title. Allows you to build up to 9 parameters into the header, using
the variables &1 to &9.
Retrieving List Attributes:
You should use this key word only in exceptional cases (e.g. when editing an
'anonymous' list in a program other than that which generated the list). In all other
cases, you should save the relevant values when you generate the list. Take care
when attempting to retrieve the list attributes being set up (...INDEX SY-LSIND),
since some attributes (number of pages, number of lines, ...) may not have been
updated yet.
DESCRIBE LIST NUMBER OF LINES|PAGES <n> [INDEX <index>].
Returns the number of lines|pages in the list. SY-SUBRC=0 : Ok, <>0 : list does
not exists.
DESCRIBE LIST LINE <nl> PAGE <n> [INDEX <index>].
Returns the number of the page for the line <nl> in the list. SY-SUBRC=0 : Ok, 4
: line does not exists, 8 : list does not exists.
DESCRIBE LIST PAGE <np> <options> [INDEX <index>].
Returns the attributes of the page <np> in the list. SY-SUBRC=0 : Ok, 4 : page
does not exists, 8 : list does not exists. <options>:
Interactive Lists.
Go to top...
Go to next...
HIDE:
HIDE <f>.
Stores the contents of variable <f> in relation to the current output line (system
field SY-LINNO) internally in the so-called HIDE area. <f> must not necessarily
appear on the current line.
READ LINE:
The system internally stores all lists created in succession by one report program.
Therefore, you can access any list from within the program that was created
during the current dialog session and has not been deleted by returning to a
previous list level.
READ LINE <n> [INDEX <index>]
[FIELD VALUE <f1> [INTO <g1>] ... <fn> [INTO <gn>]]
[OF CURRENT PAGE|OF PAGE <n>].
READ CURRENT LINE
[FIELD VALUE <f1> [INTO <g1>] ... <fn> [INTO <gn>]]
Stores the contents of line from the list on which the event was triggered (list
index SY-LISTI, line number SY-LILLI) in the SY-LISEL system field and fills
all HIDE information stored for this line back into the corresponding fields.
SY-SUBRC = 0 : Ok; = 4 : line does not exist.
FIELD VALUE uses Conversion Rules (see Source Type C). Fields that do not
appear in a line, do not affect the target field. If a field appears several times in a
line, the system uses only the first one.
MODIFY LINE:
MODIFY {LINE <n> | LINE <n> OF CURRENT PAGE | LINE <n> OF
PAGE <page> | CURRENT LINE}
[INDEX <index>] - index=SY-LSIND, applied only for LINE <n>
[LINE FORMAT <fmt1> ... <fmtn>] - applied for whole line
[FIELD FORMAT <f1> <fmt11> ... <fmt1m> [... <fn> <fmtn1> ...
<fmtnm>]]
[LINE VALUE FROM <wa>]
[FIELD VALUE <f1> [FROM <g1>] [... <fn> [FROM <gn>]]. - <f1>
means <f1> FROM <f1>
Changes the line of the list taking values from SY-LISEL (or from the <wa> or
<gn>). Usually after List Events: AT LINE-SELECTION, AT PFxx, AT USER-
COMMAND, where the SY-LISEL is filled. Fills HIDE information.
SY-SUBRC = 0 : Ok; <> 0 : line was not changed.
GET CURSOR:
GET CURSOR FIELD <f> [OFFSET <o>] [LINE <n>] [VALUE <val>]
[LENGTH <l>].
Transfers the name of the field on which the cursor is positioned during a user
action into the variable <f>. If the cursor is on a field, the SY-SUBRC is 0,
otherwise 4. The system transports the names of global variables, constants, field
symbols, or reference parameters of subroutines. For literals, local fields, and
VALUE parameters of subroutines, the system sets SY-SUBRC to 0, but transfers
SPACE as the name.
GET CURSOR LINE <n> [OFFSET <o>] [VALUE <val>] [LENGTH <l>].
Transfers the number of the line on which the cursor is positioned during a user
action into the variable <n>. If the cursor is on a list line, the SY-SUBRC is 0,
otherwise 4.
• <o> contains the position of the cursor within the field. If the cursor is on
the first column, <o> = 0;
• <n> contains the number of the list line on which the cursor is positioned
(SY-LILLI);
• <val> contains the character string output representation of the field|line
on which the cursor is positioned. The representation includes formatting
characters;
• <l> contains the output length of the field on which the cursor is
positioned.
SET CURSOR:
SET CURSOR FIELD <f> [OFFSET <o>] [LINE <n>].
Set cursor at begin of field <f> (should be in uppercase), or at column <o> (begin
is ). In step loop or in list processing (if the field is displayed on several lines)
<n> is needed. In list processing <n> means SY-LILLI.
SET CURSOR LINE <n> [OFFSET <o>].
In list processing <n> means SY-LILLI.
SET CURSOR <column> <line>.
<column> and <line> are absolute position on the current screen.
Event Control for Interactive Lists:
<command> Event
self-defined function code AT USER-COMAND
'PICK' AT LINE-SELECTION
'PF<nn>' AT PF<nn>
Predefined Function Code not event, but direct action
SET PF-STATUS:
SET PF-STATUS <status> [EXCLUDING <function>|<itab>]
[IMMEDIATELY].
Sets user-defined <status> for all subsequent list levels until you set another
status. SY-PFKEY - status of the current list. <status> is SPACE to set system
status. <function>, type C(4), (or list of functions in the <itab>) - function code(s)
to be deactivated in the <status>. IMMEDIATELY changes the status of the
currently displayed list (SY-LISTI) within the processing block of the interactive
event. Without this option, the system changes the status of the current secondary
list (SY-LSIND) that is displayed only at the end of the processing block.
Messages in Lists:
Messages are stored and maintained in the T100 "Messages" table by
• Standard - by definition, the key fields of an internal table are those fields
which are not numeric (type F, I, and P) and are not internal tables. These
key fields form the standard key of an internal table. To obtain the
standard key of an internal tables with nested structures (table lines which
contain field strings as components), the system breaks down the sub-
structures to the level of elementary fields;
• Self-Defined - can be specified when reading lines from an internal table
using the READ TABLE.
Filling Table.
Go to top...
Go to next...
Appending Lines:
APPEND [{<wa>|INITIAL LINE} TO] <itab>.
Appends a new line to table. For tables with a header line the source area can be
omitted. After statement, the SY-TABIX contains the index of the appended line.
APPEND LINES OF <itab1> [FROM <idx1>] [TO <idx2>] TO <itab2>.
Appends lines from one table to another table. Default appends entire table. After
statement, the SY-TABIX contains the index of the last appended line. About 3 to
4 times faster than appending lines line by line in a loop.
APPEND [<wa> TO] <itab> SORTED BY <f>.
Inserts the new line so that the internal table <itab> is sorted in descending order
by the field <f>. If you use the SORTED BY option, the table can contain only the
number of lines specified in the OCCURS parameter. If you add more lines than
specified, the last line is discarded. This is useful for creating ranked lists of
limited length (e.g. "Top Ten"). For ranked lists containing more than 100 entries,
use instead the SORT for performance reasons.
Inserting Lines:
INSERT [{<wa>|INITIAL LINE} INTO] <itab> [INDEX <idx>].
Inserts a new line into table. For tables with a header line the source area can be
omitted. With INDEX option, the new line is inserted before the line which has
the index <idx>. After the insertion, the new entry has the index <idx> and the
index of the following lines is incremented by 1.
If the table consists of <idx> - 1 entries, the system appends the new entry after
the last existing table line. If the table has less than <idx> - 1 entries, the system
cannot insert the entry: SY-SUBRC = 4. If success, SY-SUBRC = 0.
Use INSERT without the INDEX option is allowed only within a LOOP -
ENDLOOP loop by inserting the new entry before the current line (i.e. the line
which has the index returned by SY-TABIX).
INSERT LINES OF <itab1> [FROM <idx1>] [TO <idx2>] INTO <itab2>
[INDEX <idx>].
Inserts lines from one table into another table. Default inserts entire table. Can be
up to 20 times faster than inserting lines line by line in a loop.
Collecting Lines:
COLLECT [<wa> INTO] <itab>.
If a table entry with the same standard key does not exists (all non-numeric
fields), the COLLECT has the same effect as the APPEND. If exists, the
COLLECT adds the contents of the numeric fields in the work area to the contents
of the numeric fields in the existing entry. SY-TABIX contains the index of the
processed line.
Reading Table.
Go to top...
Go to next...
LOOP Processing:
LOOP AT <itab> [INTO <wa>] [FROM <n1>] [TO <n2>] [WHERE
<condition>].
...
ENDLOOP.
<itab> is read line by line into <wa> or into the table work area. For each line
read, processed the statement block between LOOP and ENDLOOP. Within the
statement block, SY-TABIX contains the index of the current line. The loop ends
as soon as all lines of the table have been processed. After the ENDLOOP
statement:
Note. The FROM and TO options restrict the number of lines which the system
has to read. The WHERE option only prevents unnecessary filling of the work
area. With the WHERE option, the system must read all lines. To improve
performance, you should use the FROM and TO options as much as possible. It
can be also beneficial to leave the loop with the EXIT statement instead of using
the WHERE option.
Calculating Totals:
SUM.
Can be used only in LOOP - ENDLOOP block. A component of an internal table
line may not be another table. In an AT - ENDAT block, calculates totals for the
numeric fields (I, F, P) of all lines in the current line group and writes them to the
corresponding fields in the work area. Outside an AT - ENDAT block - do it for
lines of the internal table in each loop pass. Therefore, SUM should be used only
in AT - ENDAT blocks.
Using Control Levels for Groups of Lines (AT ... ENDAT Events):
AT <line>.
...
ENDAT.
The <line> condition:
<line> Meaning
FIRST First line of the internal table
LAST Last line of the internal table
Beginning of a group of lines with the same contents in the field <f>
NEW <f>
and in the fields left of <f>
END OF End of a group of lines with the same contents in the field <f> and in
<f> the fields left of <f>
<f> can be:
• All default key fields [on the right of <f>] are filled with '*';
• All other fields [on the right of <f>] are cleared;
• If SUM used then appropriate control totals are inserted in numeric fields;
• After AT the old contents of LOOP output area are restored.
Modifying Table.
Go to top...
Go to next...
MODIFY <itab> [FROM <wa>] [INDEX <idx>] [TRANSPORTING <f1> ... <fn>
[WHERE <condition>]].
Modifies the line in the table. For tables with a header line the source area can be
omitted. With INDEX option, will be modified the line which has the index
<idx>. In this case: SY-SUBRC = 4 if no line with <idx> exists; SY-SUBRC = 0
- success.
Use MODIFY without the INDEX option is allowed only within a LOOP -
ENDLOOP loop by modifying the current line (i.e. the line which has the index
returned by SY-TABIX).
With the TRANSPORTING option, the system transports only the components
<f1> ... <fn> from the work area into the internal table. Strongly recommended
suppress unnecessary transports of fields which are internal tables itself. You can
specify a component dynamically by writing (<name>). In this case, the system
reads the name of the component from field <name> at runtime. An invalid
component name leads to a runtime error.
WHERE <condition> with the TRANSPORTING option determines all the lines
of the table into which the components <f1> ... <fn> are to be transported. First
operand should be a component of the internal table's line structure. WHERE
cannot be used together with the INDEX option.
WRITE <f>[+<o1>][(<l1>)] TO <itab>[+<o2>][(<l2>)] INDEX <idx>.
Variant of WRITE TO. Overwrites the section of the line of the <itab> that has
index <idx>. Does not affect header line. Does not recognize the structure of table
lines. Return codes: SY-SUBRC = 4 - no line with <idx> exists; SY-SUBRC = 0
- success. If <idx> <= 0 - runtime error.
Deleting lines:
DELETE <itab>.
Deletes current line in LOOP - ENDLOOP (that is line which have index SY-
TABIX). After the first line has been deleted, the current line and its assignment
to the contents of SY-TABIX can be undefined. To process further lines within
this loop, use only statements with the INDEX option.
DELETE <itab> INDEX <idx>.
Deletes line with the index <idx>. Return codes: SY-SUBRC = 4 - no line with
<idx> exists; SY-SUBRC = 0 - success.
DELETE ADJACENT DUPLICATES FROM <itab> [COMPARING {<f1>
... <f1>|ALL FIELDS}].
Deletes adjacent duplicates entries. Return codes: SY-SUBRC = 0 - at least one
entry was deleted; SY-SUBRC = 4 - otherwise. Without the COMPARING
option, the contents of the standard key fields must be the same.
DELETE <itab> [FROM <n1>] [TO <n2>] [WHERE <condition>].
Deletes selected entries. At least one of three criteria should be used. First
operand in WHERE should be a component of the internal table's line structure.
Return codes: SY-SUBRC = 0 - at least one entry was deleted; SY-SUBRC = 4 -
otherwise.
Clearing Table.
Go to top...
Go to next...
You can check whether an internal table is empty using logical expression:
... <itab> IS INITIAL ...
REFRESH <itab>.
Empties internal table.
CLEAR <itab>[].
Empties internal table without clearing the table work area.
CLEAR <itab>.
Empties internal table that has no table work area (header line).
Clears the table work area if the table has it.
FREE <itab>.
Empties internal table and releases reserved memory without clearing the table
work area.
Without the option AS TEXT, the system sorts character fields binarily and
according to their platform-dependent internal coding. With the option AS TEXT,
the system sorts character fields alphabetically according to the current text
environment. By default, the text environment is set in the user's master record.
As an exception, you can set the text environment with the SET LOCALE
LANGUAGE. The option AS TEXT frees you from converting a character field
into a sortable format before sorting. Such a conversion is only necessary, if you
want to
AS TEXT before BY influences only the character fields in the sort key. If you
specify AS TEXT after a field name, this field must be of type C. Sorting is not
stable. This means that the old sequence of lines with the same sort key may not
necessarily be retained. If there is not enough space for sorting in the main
memory, the system writes data into a temporary external file. The name of this
file is defined in the SAP profile parameter DIR_SORTTMP.
Searching Internal Tables for Character String:
SEARCH <itab> FOR <str> [<options>].
Options and patterns like searching string for string. No type conversion is
performed also (the entire table line is treated as character string). <itab> is
always table, not header line, if even the table has header line. In addition to SY-
SUBRC and SY-FDPOS, SY-TABIX is set to found line index.
Logical Expressions:
... <itab1> {EQ|=|NE|<>|><|GE|>=|LE|<=|GT|>|LT|<} <itab2> ...
The first criterion for comparing internal tables is the number of lines they
contain. The more lines an internal table contains, the larger it is. If two internal
tables contain the same number of lines, they are compared line by line,
component by component. If components of the table lines are themselves internal
tables, they are compared recursively. If you use operators other than the equality
operator, the system stops the comparison as soon as it finds a pair of components
which are not equal and returns the result. In the case of internal tables with a
header line, you can use square brackets ([]) after the table name to distinguish the
table body from the table work area.
Assignment Operator:
MOVE <itab1> TO <itab2>.
[COMPUTE] <itab2> = <itab1>.
Copies entire contens of internal table that has not header line.
MOVE <itab1>[] TO <itab2>[].
[COMPUTE] <itab2>[] = <itab1>[].
Copies entire contens of internal table with header line.
RANGES.
Go to top...
Go to next...
Selection Screens.
Parameters.
Go to top...
Go to next...
PARAMETERS <parm>[(<length>)] <type> [<decimals>].
Creates a parameter <parm>. The additions length, type, and decimals are the
same as for DATA. Cannot have type F. Comments on the left side of the input
fields can be changed using Selection Texts.
Other additions:
Selection Options.
Go to top...
Go to next...
• NO-DISPLAY
• LOWER CASE
• OBLIGATORY
• MEMORY ID <pid>
• MATCHCODE OBJECT <mobj>
• MODIF ID <key>
Specific additions:
FOR FIELD option has as a result, if the user requests help on the comment on
the selection screen, the help text for the assigned field is displayed.
SELECTION-SCREEN BEGIN OF LINE.
...
SELECTION-SCREEN END OF LINE.
Places several elements on a single line. Note that the selection text (name of the
parameter or text element) is not displayed when this option used. To display a
selection text COMMENT option must be used.
SELECTION-SCREEN POSITION <pos>.
<pos> can be a number (in this case it is relative to the frame if inside BEGIN OF
BLOCK WITH FRAME...END OF BLOCK) or POS_LOW|POS_HIGH.
SELECTION-SCREEN BEGIN OF BLOCK <block> [WITH FRAME [TITLE
<text>]] [NO INTERVALS].
...
SELECTION-SCREEN END OF BLOCK <block>.
Creates a logical block. Blocks can be nested. Only 5 blocks with frames can be
nested. NO INTERVALS displays all SELECT-OPTIONS within the block as
with NO INTERVALS addition; inherited by subordinate blocks with frames and
does not by subordinates blocks without frames.
INITIALIZATION.
Executes a processing block before the selection screen is processed. In this block
you initialize the selection screen. This is also the only possibility to change the
default values of parameters or selection criteria defined in logical databases. You
can find out the names of the internal fields you want to change either by
examining the logical database SAPDB<ldb> itself (with the transaction SLDB or
by choosing Tools->ABAP/4 Development Workbench->Development-
>Programming environ.->Logical databases), or by retrieving the technical
information of that field.
AT SELECTION-SCREEN.
Executes a processing block after the system has finished processing the selection
screen. If an error|warning message is sent from this processing block, the system
displays the selection screen again and all input fields can be changed.
AT SELECTION-SCREEN ON <parm>|<selopt>.
Executes a processing block after the system has finished processing the <parm>|
<selopt>. If an error|warning message is sent from this processing block, the
system displays the selection screen again and only this input field can be
changed.
AT SELECTION-SCREEN ON END OF <selopt>.
Executes a processing block at the end of processing Multiple Selection Window
of the <selopt>. Can be used to check the entries in the internal table
<selopt>. Both the E and W messages are sent in dialog window.
AT SELECTION-SCREEN ON BLOCK <block>.
Executes a processing block after the system has finished processing the <block>.
If an error|warning message is sent from this processing block, the system
displays the selection screen again and only the input fields in the <block> can be
changed.
AT SELECTION-SCREEN ON RADIOBUTTON GROUP <radi>.
Executes a processing block after the system has finished processing the <radi>.
If an error|warning message is sent from this processing block, the system
displays the selection screen again and only the radiobutton group <radi> can be
changed.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <parm>|<selopt>.
The possible entries button automatically appears next to the input field for
<parm>|<selopt> when it is selected on the selection screen. Executes a
processing block which allows user to choice a value from a list when user
presses the button or F4. Can be used only in report programs, not in a logical
database program.
AT SELECTION-SCREEN ON HELP-REQUEST FOR <parm>|<selopt>.
Executes a processing block which displays a help text when user presses F1 or
the button on the selected <parm>|<selopt>. Can be used only in report
programs, not in a logical database program.
AT SELECTION-SCREEN OUTPUT.
Executes a processing block during the PBO of a selection screen for each
ENTER. For example, here can be applied a modifications to the screen:
LOOP AT SCREEN.
....
MODIFY SCREEN.
ENDLOOP.
To change at runtime attributes of screen fields. SCREEN is memory table which
automatically created and maintained by system (with header line). The structure
of the SCREEN:
Name Length Description
NAME 30 Name of the screen field
GROUP1 3 Modification group 1
GROUP2 3 Modification group 2
GROUP3 3 Modification group 3
GROUP4 3 Modification group 4
ACTIVE 1 Visible and ready for input
REQUIRED 1 Mandatory
INPUT 1 Ready for input
OUTPUT 1 For display only
INTENSIFIED 1 Highlighted
INVISIBLE 1 Supressed
LENGTH 1 Output length is reduced
DISPLAY_3D 1 Displayed with 3D frames
VALUE_HELP 1 Displayed with value help
To activate a field attribute, set its value to 1. To deactivate it, set it to 0. If
ACTIVE = 0, then system sets INVISIBLE = 1 and INPUT = 0, and user can
neither see the field nor enter values into it.
Field Symbols.
Concept.
Field symbols are placeholders for existing fields. A field symbol does not
physically reserve space for a field, but points (like a pointer in C) to a field
which is not known until runtime of the program. But Field Symbols are not real
equivalent to pointers in the sense of variables which contain a memory address
and can be used without the contents operator. You can only work with the data
object to which a field symbol points. A field must first be assigned to field
symbol before working with it in the program. Assignments to field symbols may
extend beyond field boundaries. This allows effective access to regularly stored
data. At runtime, the system performs checks to prevent erroneous assignments
outside the defined data areas:
• The table storage area for internal tables. Its size depends on the number
of table lines which is not fixed, but often extended dynamically at
runtime;
• The DATA storage area for other data objects. Its size is fixed during the
data declaration and equal to sum of all data objects sizes.
Field symbols cannot point to addresses outside these areas. If the system
encounters this at runtime, it stops processing the program.
Note. Certain system information, such as the control blocks of internal tables, is
also stored in the DATA storage area. Therefore, despite the runtime checks, you
may unintentionally overwrite some of these fields and cause subsequent errors
(e.g. destruction of the table header).
Defining Field Symbols for Internal Fields.
FIELD-SYMBOLS <FS> [<type>].
For field symbols, the angle brackets are part of the syntax.
<type> Syntax check for field assignment.
No type
System accepts any field type and uses all attributes and
specification,
structure of the field for the <FS>
TYPE ANY
System accepts only an internal table uses all attributes of the
TYPE TABLE
table for the <FS>
System accepts only an appropriate field type. The <FS>
TYPE C, N, P, X
inherits field length (and DECIMALS for P)
TYPE D, F, I, T
LIKE <f>
System accepts only completely compatible field type.
TYPE <user-defined-
type>
Defining Structured Field Symbols.
FIELD-SYMBOLS <FS> STRUCTURE <fstring> DEFAULT <f>.
Defines a structured <FS> which points initially to the field <f> (this assignment
can be changed later). The <FS> inherits the structure of <fstring>, which can be
any field string or a structure defined in the ABAP/4 Dictionary. <fstring> and
<f> must be specified without quotation marks. Specification at runtime is not
allowed. If <fstring> contains no components of type I or F, <f> can be any
internal field with at least the same length as the structure <fstring>. If <f> is
shorter than <fstring>, an error occurs during the syntax check. This will be also
while assigning later in program. Dynamic assignment causes a runtime error. If
<fstring> contains components of type I or F (that is this structure is aligned),
then the data object must also be aligned accordingly, otherwise a runtime error
occurs.
Defining Local Field Symbols.
If <fstring> id defined in a subroutine or function module then each time the
subroutine or function module is called, no field is assigned to the local field
symbol, even if an ASSIGN was executed the previous time.
Dinamic Assignment:
• ASSIGN [LOCAL COPY OF] (<n>) TO <FS> [TYPE <type>]
[DECIMALS <d>].
Offset cannot be specified. Order of search for the field's name <n>:
1. Local Data of the Subroutine or Function Module;
2. Global Data of the Program;
3. Table work areas declared with the TABLES statement in the main
program of the current program group. A program group consists
of a main program and all programs containing definitions of the
external subroutines called by the main program (including nested
ones).
This type of search has very adverse effect on response times. Return
code: SY-SUBRC=0 if success, otherwise SY-SUBRC=4.
Dinamic Assignment:
Additions:
Modularization.
IF CASE
CASE <f>.
IF <condition1>.
WHEN <f1>.
<statement block>
<statement block>
ELSEIF <condition2>.
WHEN <f2>.
<statement block>
<statement block>
......
......
ELSE.
WHEN OTHERS.
<statement block>
<statement block>
ENDIF.
ENDCASE.
DO WHILE
DO [<n> TIMES] [VARYING <f> FROM WHILE <condition> [VARY <f> FROM
<f1> NEXT <f2>]. <f1> NEXT <f2>].
<statement block> <statement block>
...... ......
[CONTINUE.] [CONTINUE.]
[EXIT.] [EXIT.]
[CHECK <condition>. [CHECK <condition>.
<statement block>] <statement block>]
ENDDO. ENDWHILE.
Unlimited nesting is allowed. An EVENT keyword may not be inside of block.
<n> can be literal or a variable. If <n> <=0, the system does not process the loop.
SY-INDEX contains the number of times the loop has been processed.
<f>, <f1>, <f2> must be a series of equidistant fields of the same type and length in
memory. In the first loop pass, <f1> is assigned to <f>; in the second loop pass <f2> is
assigned to <f>; and so on. Several VARYING|VARY options can be used in one DO|
WHILE statement. If you change the control variable <f> inside the DO loop, the system
changes the corresponding field <fi> automatically. If loop processed more times than the
number of variables <fi>, this may result in a runtime error.
Terminating Loops.
CONTINUE.
Terminates a loop pass immediately without any condition, continues with the
next loop pass.
EXIT.
Acts in following sequence:
CHECK <condition>.
Acts in following sequence:
1. For a loop, if the condition is false, skips all the remaining statements in
the current statement block and continues with the next loop pass;
2. For GET event, if the condition is false, equivalent to REJECT. (Leaves
the processing block of a GET event and processes the next GET event at
the same hierarchical level of the logical database.);
3. For processing block, if the condition is false, leaves the processing block
and branches to the processing block of the next occurring event;
4. For a subroutine, if the condition is false, terminates the subroutine.
Events.
Go to top...
Go to next...
All statements between two event keywords or between an event keyword and a FORM
statement are a processing block. When an event occurs, the system processes the
processing block after the corresponding event keyword. Each statement in an ABAP/4
report program is part of a processing block or a subroutine. Statements which do not
follow an event keyword or a FORM-ENDFORM block are automatically part of the
processing block of the default event START-OF-SELECTION.
Note. All statements between an ENDFORM statement and an event keyword or between
an ENDFORM statement and the end of the program are never processed. Do not place
any statements there. Place all subroutines at the end of your program.
• Leaves the processing block of a GET event and processes the next GET
event of a superior hierarchical level of the logical database <dbtab>
• Leaves the processing block of a GET event and processes the next GET
event at the same hierarchical level of the logical database.
See also:
EXIT, CHECK.
Dialogs.
Go to top...
Go to next...
Using Macros.
DEFINE <macro>.
<statements>
END-OF-DEFINITION.
Defines <macro>. The <statements> can contain up to 9 placeholders: &1, &2, ...
&9.
<macro> [<p1> <p2> ... <p9>].
Calls <macro> (System replaced macro during generation of the program). Macro
can call another macro, but cannot call itself.
Using Include Programs.
INCLUDE <name_of_include_program>
Inserts the source code <name_of_include_program> into the ABAP/4 program
during the syntax check and during generation.
• INCLUDE statement must be whole on one line and only on this line;
• The INCLUDE program must consist of complete statements (and
comments);
Service report RSINCL00 can be used to generate reference list for included
programs.
Subroutines.
Go to top...
Go to next...
Defining Subroutines.
FORM <subroutine> [<parameters>].
<statements>
ENDFORM.
Calling Subroutines.
Internal subroutines have the source code in the calling ABAP/4 program:
PERFORM <subroutine> [<parameters>].
PERFORM (<subrname>) [<parameters>].
Specifies the subroutine name at runtime.
PERFORM <subroutine> ON COMMIT [LEVEL <n>].
Calls the subroutine later on a first encountered COMMIT WORK statement. The
subroitine is called only once even if call performed many times. LEVEL <n>
(literal or constant, default is 0) defines order of execution of subroutines on
COMMIT WORK. The subroutines are called in ascending level order, or in order
of calls if level the same.
External subroutines have the source code in another ABAP/4 program:
PERFORM <subroutine>(<program>) [<parameters>] [IF FOUND].
PERFORM <subroutine> IN PROGRAM <program> [<parameters>] [IF
FOUND].
IF FOUND - call subroutine only if found in program, otherwise skip call.
PERFORM (<subrname>) IN PROGRAM (<progname>) [<parameters>]
[IF FOUND].
Specifies the subroutine and/or program names at runtime.
PERFORM <idx> OF <form2> ... <formn>.
Calls a subroutine that has index <idx> (literal or variable) from the list.
Passing Data to/from Subroutines.
Declaring Data as Common Part.
DATA: BEGIN OF COMMON PART [<name>].
<data declaration>
END OF COMMON PART [<name>].
<name> is needed if several common parts used. It is better way to use common
parts placed in INCLUDE. Table work areas defined in TABLES are common
automatically.
Parameters.
[TABLES <list of internal tables with or without header line>]
[USING <list of parameters - all data types (including internal tables) and|or
field symbols>]
[CHANGING <list of parameters - all data types (including internal tables)
and|or field symbols>]
Actual parameters can be specified with variable offset and length specifications.
Methods of Passing Data Using Parameters:
By Reference.
FORM ... [USING <fi1> ... <fin>] [CHANGING <fo1> ... <fon>] ...
PERFORM ... [USING <ai1> ... <ain>] [CHANGING <ao1> ... <aon>] ...
In this case USING and CHANGING are equivalent.
By Value.
FORM ... USING ... VALUE(<fii>) ...
PERFORM ... USING ... <aii> ...
New local object <fii> created and processed for each call.
By Value and Result.
FORM ... CHANGING ... VALUE(<fii>) ...
PERFORM ... CHANGING ... <aii> ...
New local object <fii> created and processed for each call. Only when the
subroutine has completed successfully, system pass the current value of <fii> to
<aii>. If the subroutine processing is stopped because of a dialog message, the
actual parameter <aii> remains unchanged.
Typing Formal Parameters:
Type of a formal parameter can be specified in the FORM statement using TYPE
<type> or LIKE <object> after this parameter in the TABLES, USING, or
CHANGING lists. While PERFORM system checks types compatibility of the
actual and formal parameters. The compatibility rules are the same as for Field
Symbols assignment. There are no type conversions. If types are incompatible, the
system outputs an error message during the syntax check for internal subroutine
calls or reacts with a runtime error in the case of external subroutine calls.
Passing Fields Strings:
To pass a field string into subroutine and access components of this field string in
this subroutine - type of the field string must be specified. For internal subroutines
- directly, for external - also in the program where the called subroutine placed
(can be done using Type Groups, Includes or ABAP/4 Dictionary Structures).
Passing Internal Tables:
Can be passed after TABLES (always be Reference), USING or CHANGING.
Type must be specified also for access components separately (as for Field
Strings). If actual parameter table has no header line, but formal parameter table
with header line, the header line will be automatically created in the subroutine
for this table.
Defining Local Data in Subroutines.
Dynamic Local Data Types and Objects.
TYPES, DATA - define automatic objects that newly created for each call and
deleted after exit.
Static Local Data Types and Objects.
STATICS - defines static objects that initialized for first call and keep their values
after exit.
LOCAL <f>.
Preserves the value of a global data object from being changed inside a subroutine
(for example, a work area of a database table defined using TABLES). Instead a
local copy of the <f> used inside of subroutine.
Terminating Subroutines.
See EXIT, CHECK.
Function Modules.
Go to top...
Go to next...
Interfaces:
Import parameter:
Pass data from the calling program to the function module. Cannot be overwritten,
even when passed by reference.
Export parameters:
Pass data from the function module back to the calling program. Always optional.
CHANGING parameter:
Internal tables. Treated like changing parameters and are always passed by
reference.
Exception:
See also:
• Main Page.
• ABAP/4 compendium.
• SAP R/3 system fields.
• ABAP/4 functions.
• ABAP/4 obsolete statements and functions.
• ABAP/4 skeletons.
• ABAP in SAP R/3 ver 4.6 - Object Oriented Language.
• Object Oriented ABAP - Features and Restrictions.
• Object Oriented ABAP - Demos.
• ABAP/4 UNIX browser.
• ABAP Utilities.
• Main Page.