ABAP/4   ОКМ   ДМ   экономическая информатика   4GL   Теория и практика обработки информации

Компьютерный язык ABAP/4 - ключевые слова

PERFORM

Variants

1. PERFORM form.
2. PERFORM form(prog).
3. PERFORM form IN PROGRAM prog.
4. PERFORM n OF form1 form2 form3 ... .
5. PERFORM n ON COMMIT.

Variant 1

PERFORM form.

Additions




1. ... USING p1 p2 p3 ...
2. ... CHANGING p1 p2 p3 ...
3. ... TABLES itab1 itab2 ...

Effect

Calls the subroutine form specified in the FORM statement. On completion, processing in the main program resumes.

Example

PERFORM HELP_ME. ... FORM HELP_ME. ... ENDFORM.

The PERFORM statement calls the subroutine HELP_ME .

Notes

Nested calls are allowed (i.e. PERFORM within a FORM ... ENDFORM ).
Recursive calls are also possible.
To define local data, use the DATA statement after FORM . Each time you enter the subroutine, the data is recreated (with an initial value) and released at the end (from the stack).
To define global data used within a subroutine, use the LOCAL statement after FORM . The values are saved when you enter the subroutine and then released at the end (from the stack).

Note

Runtime errors

Addition 1

... USING p1 p2 p3 ...

Addition 2

... CHANGING p1 p2 p3 ...

Effect

These additions are equivalent to each other. For documentation reasons however, you should use the same one as with the associated FORM definition.
Both additions pass the parameters p1 p2 p3 ... to the called subroutine. You can use as many parameters as you like.
Sequence is important here because the first parameter of the PERFORM call is passed to the first parameter of the FORM definition, the second to the second and so on.
You can use the following as parameters:

Parameter offset and length can be passed as variables. The addition ' ...USING p1+off(*) ' causes parameter p1 to be passed with offset off so that the field limits of p1 are not exceeded.

Example

DATA: NUMBER_I TYPE I VALUE 5, NUMBER_P TYPE P VALUE 4, BEGIN OF PERSON, NAME(10) VALUE 'Paul', AGE TYPE I VALUE 28, END OF PERSON, ALPHA(10) VALUE 'abcdefghij'. FIELD-SYMBOLS . ASSIGN NUMBER_P TO . PERFORM CHANGE USING 1 NUMBER_I NUMBER_P PERSON ALPHA+NUMBER_I(). FORM CHANGE USING VALUE(PAR_1) PAR_NUMBER_I PAR_NUMBER_P PAR_POINTER PAR_PERSON STRUCTURE PERSON PAR_PART_OF_ALPHA. ADD PAR_1 TO PAR_NUMBER_I. PAR_NUMBER_P = 0. PAR_PERSON-NAME+4(1) = ALPHA. PAR_PERSON-AGE = NUMBER_P + 25. ADD NUMBER_I TO PAR_POINTER. PAR_PART_OF_ALPHA = SPACE. ENDFORM.

Field contents after the PERFORM call are as follows:

NUMBER_I = 6
NUMBER_P = 6
= 6
PERSON-NAME = 'Paula'
PERSON-AGE = 25
ALPHA = 'abcde j'

Note

The field type and length of the parameters remain. If parameter values change within the subroutine, these new values remain after you leave the subroutine. However, this does not apply to parameters passed with VALUE (see FORM ).
If you pass literals, you must either leave them unchanged or pass them in the FORM definition with the USING VALUE statement.

Addition 3

... TABLES itab1 itab2 ...

Effect

You use TABLES to pass internal tables to subroutines.

Example

DATA: BEGIN OF ITAB OCCURS 100, TEXT(50), NUMBER TYPE I, END OF ITAB. STRUC LIKE T005T. ... PERFORM DISPLAY TABLES ITAB USING STRUC. FORM DISPLAY TABLES PAR_ITAB STRUCTURE ITAB USING PAR STRUCTURE T005T. DATA LOC_COMPARE LIKE PAR_ITAB-TEXT. WRITE: / PAR-LAND1, PAR-LANDX. ... LOOP AT PAR_ITAB WHERE TEXT = LOC_COMPARE. ... ENDLOOP. ... ENDFORM.

Within the subroutine DISPLAY , you can apply all the available table operations to the internal tables passed.

Note

TABLES must always appear first in the PERFORM call. It must not be preceded by an addition.

Variant 2

PERFORM form(prog).

Additions




1. ... USING p1 p2 p3 ...
2. ... CHANGING p1 p2 p3 ...
3. ... TABLES itab1 itab2 ...
4. ... IF FOUND

Effect

Calls the subroutine form defined in the program prog (i.e. external PERFORM ).

Notes

Parameter passing to the external subroutine is the same as in variation 1.
Parameter passing can be implemented by using a common data area (see DATA BEGIN OF COMMON PART ).
Nested calls are possible, even with several external subroutines from different programs.
If you call a subroutine of a program prog , the system loads the program prog

Note

Runtime errors

Addition 1

... USING p1 p2 p3 ...

Effect

See addition 1 of variation 1.

Addition 2

... CHANGING p1 p2 p3 ...

Effect

See addition 2 of variation 1.

Addition 3

... TABLES itab1 itab2 ...

Effect

See addition 3 of variation 1.

Addition 4

... IF FOUND

Effect

Calls the specified subroutine only if it already exists. Otherwise, the statement is ignored.

Notes


Variant 3

PERFORM form IN PROGRAM prog.

Additions




1. ... USING p1 p2 p3 ...
2. ... CHANGING p1 p2 p3 ...
3. ... TABLES itab1 itab2 ...
4. ... IF FOUND

Effect

Similar to variation 2 (external PERFORM ), except that here you can specify both the subroutine and the program dynamically (at runtime); in this case, you must enclose the variables form or prog in parentheses. If you omit specification of the program after IN PROGRAM , ABAP/4 searches for the routine in the current program.

Example

DATA: RNAME(30) VALUE 'WRITE_STATISTIC', PNAME(8) VALUE 'ZYX_STAT'. PERFORM WRITE_STATISTIC(ZYX_STAT). PERFORM (RNAME) IN PROGRAM ZYX_STAT. PERFORM WRITE_STATISTIC IN PROGRAM (PNAME). PERFORM (RNAME) IN PROGRAM (PNAME).

All four of the above PERFORM statements have the same effect, i.e. they call the subroutine 'WRITE_STATISTIC' defined in the program 'ZYX_STAT' .

Note

This dynamic PERFORM requires more CPU time, since the system has to search for the subroutine each time.

Addition 1

... USING p1 p2 p3 ...

Effect

See addition 1 of variation 1.

Addition 2

... CHANGING p1 p2 p3 ...

Effect

See addition 2 of variation 1.

Addition 3

... TABLES itab1 itab2 ...

Effect

See addition 3 of variation 1.

Addition 4

... IF FOUND

Effect

Calls the specified subroutine only if it already exists. Otherwise, the statement is ignored.

Variant 4

PERFORM n OF form1 form2 form3 ... .

Effect

Drives a subroutine specified by the index n from a list of subroutine names listed in the statement. At runtime, the variable n must contain a value between 1 (first name) and the total number of subroutines specified (last name). Up to 256 subroutine names are possible.

Note

Runtime errors

Variant 5

PERFORM n ON COMMIT

Addition




1. ... LEVEL level

Effect

Executes the specified subroutine when a COMMIT WORK occurs. This allows you to execute a subroutine only if the logical transaction has ended successfully. The subroutine is not executed until the key word COMMIT WORK is called. FORMs specified several times are executed only once on COMMIT WORK (see COMMIT WORK ).
If you call ROLLBACK WORK , you delete all the specified routines.

Note

With PERFORM ... ON COMMIT , you cannot transfer any data with USING/CHANGING . To do this, you must either store the data in global variables or store it temporarily with EXPORT ... TO MEMORY .

Addition 1

... LEVEL level

Effect

The addition LEVEL , followed by a field, defines the order in which the subroutines are executed after COMMIT WORK . They are called in ascending order of level. If there is no addition LEVEL , the subroutine always has the level zero. If the level is the same, the order of calls determines the order of execution. Level assignment occurs during development, e.g. by defining constants in an include program. The level must be of type I.

Index
© SAP AG 1996
ABAP/4   ОКМ   ДМ   экономическая информатика   4GL   Теория и практика обработки информации

НОВОСТИ ФОРУМА

Форум Рыцари теории эфира


Рыцари теории эфира
 10.11.2021 - 12:37: ПЕРСОНАЛИИ - Personalias -> WHO IS WHO - КТО ЕСТЬ КТО - Карим_Хайдаров.
10.11.2021 - 12:36: СОВЕСТЬ - Conscience -> РАСЧЕЛОВЕЧИВАНИЕ ЧЕЛОВЕКА. КОМУ ЭТО НАДО? - Карим_Хайдаров.
10.11.2021 - 12:36: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от д.м.н. Александра Алексеевича Редько - Карим_Хайдаров.
10.11.2021 - 12:35: ЭКОЛОГИЯ - Ecology -> Биологическая безопасность населения - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> Проблема государственного терроризма - Карим_Хайдаров.
10.11.2021 - 12:34: ВОЙНА, ПОЛИТИКА И НАУКА - War, Politics and Science -> ПРАВОСУДИЯ.НЕТ - Карим_Хайдаров.
10.11.2021 - 12:34: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вадима Глогера, США - Карим_Хайдаров.
10.11.2021 - 09:18: НОВЫЕ ТЕХНОЛОГИИ - New Technologies -> Волновая генетика Петра Гаряева, 5G-контроль и управление - Карим_Хайдаров.
10.11.2021 - 09:18: ЭКОЛОГИЯ - Ecology -> ЭКОЛОГИЯ ДЛЯ ВСЕХ - Карим_Хайдаров.
10.11.2021 - 09:16: ЭКОЛОГИЯ - Ecology -> ПРОБЛЕМЫ МЕДИЦИНЫ - Карим_Хайдаров.
10.11.2021 - 09:15: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Екатерины Коваленко - Карим_Хайдаров.
10.11.2021 - 09:13: ВОСПИТАНИЕ, ПРОСВЕЩЕНИЕ, ОБРАЗОВАНИЕ - Upbringing, Inlightening, Education -> Просвещение от Вильгельма Варкентина - Карим_Хайдаров.
Bourabai Research - Технологии XXI века Bourabai Research Institution