SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Calling and leaving program units → Calling Processing Blocks → Calling Procedures → PERFORM → PERFORM - general →
PERFORM - subr_identifier
Syntax
... subr
| {subr|(sname) IN PROGRAM [prog|(pname)] [IF FOUND]}
| {n OF subr1 subr2 ...} ... .
Alternatives:
1. ... subr ... .
2. ... subr|(sname) IN PROGRAM [prog|(pname)] [IF FOUND] ... .
3. ... n OF subr1 subr2 ... .
Effect
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.
Note
As well as the alternatives shown here, there is another obsolete form of the external subroutine call.
... subr ... .
Effect
subr can be used to call any subroutine of the current program. The subroutine must exist.
... subr|(sname) IN PROGRAM [prog|(pname)] [IF FOUND] ... .
Effect
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 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.
Notes
Security Note
If used wrongly, dynamic calls of program units can present a serious security risk. Names of program
units that are passed to a program from the outside must be checked thoroughly before being used in dynamic calls. The system class CL_ABAP_DYN_PRG, for example, can be used to do this. See
Dynamic Calls.
... n OF subr1 subr2 ... .
Effect
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
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.
...