PERFORM - subr_identifier
Short Reference
ABAP Syntax ... subr
| {subr|(sname) IN PROGRAM [prog|(pname)] [IF FOUND]}
| {n OF subr1 subr2 ...} ... .
ABAP_ALTERNATIVES:
1 ... subr ... .
2 ... subr|(sname) IN PROGRAM [prog|(pname)] [IF FOUND] ... .
3 ... n OF subr1 subr2 ... .
What does it do? These names are used to specify subroutines, whereby
subr is the name of the subroutine declared in the statement
FORM , and prog is the name of an ABAP
program. sname and pname are character-like fields that
contain the name of a subroutine or a program when a statement is
executed.
Latest notes: As well as the alternatives shown here, there is another
obsolete form of the external subroutine
call.
ABAP_ALTERNATIVE_1 ... subr ... .
What does it do? subr can be used to call any subroutine of the
current program. The subroutine must exist.
ABAP_ALTERNATIVE_2 ... subr|(sname) IN PROGRAM [prog|(pname)] [IF
FOUND] ... .
What does it do? This specification is used to call any subroutine of
another program or the current program. The subroutine and the program
can either be specified statically as subr and prog
(static external subroutine call), or dynamically in the parenthesized
character-like fields sname and pname . When the statement
is executed, sname and pname must contain the name of a
subroutine or program in uppercase (dynamic external subroutine call).
If an external subroutine is statically specified, the syntax check
does not check whether the specified program and subroutine exist. Only
the extended program check
registers any nonexistent programs or subroutines as errors by default.
If the addition IF FOUND is specified, the extended program check
also skips the check.
If the statically or dynamically specified subroutine or program does
not exist at runtime, a handleable exception of the class
CX_SY_DYN_CALL_ILLEGAL_FORM or CX_SY_PROGRAM_NOT_FOUND is
raised by default. If the addition IF FOUND is specified, the
statement PERFORM is skipped.
If the specified program is available, it is loaded, if required, into
the internal session and scanned for the specified subroutine. The event
LOAD-OF-PROGRAM is not triggered. If the subroutine is
available, the event LOAD-OF-PROGRAM is triggered (if not already
triggered) and then the subroutine is executed.
Latest notes: External calls of subroutines are almost completely
obsolete. Instead of subroutines, methods and function modules can be
used as explicit functional interfaces of a program.
Furthermore, external calls of subroutines are critical, since there
is usually no static way of determining which
program groups are assigned to the frame program.
To call a subroutine in a program of another package, the definition
of the subroutine must be shared between a declaration part and an
implementation part using the additions
DEFINITION and IMPLEMENTATION . The declaration part must be
published in the package interface.
If no further addition is specified apart from IN PROGRAM (no
IF FOUND , no parameter list ), the
program name can be omitted and is added implicitly with the name of the
current program.
Specifying a subroutine dynamically is one of the dynamic programming
techniques.
See Dynamic Calls .
ABAP_ALTERNATIVE_3 ... n OF subr1 subr2 ... .
What does it do? This specification selects a subroutine subr of
the current program from a list. The list subr1 subr2 ... can
contain up to 256 directly specified subroutines. n must be a
numerical data object containing a number between 1 and the specified
number of subroutines when the statement is executed. The subroutine
subr is called, whose list position is in n . In this
variant, it is not possible to specify parameter_list and only
subroutines without a parameter interface can be called.
Example ABAP Coding This example calls n internal subroutines
subr_1 through subr_n successively from a list.
DATA n TYPE i.
...
DO n TIMES.
PERFORM sy-index OF subr_1 subr_2 ... .
ENDDO.
FORM subr_1.
...
ENDFORM.
FORM subr_2.
...
ENDFORM.
...
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved