SAP ABAP Syntax for Perform part two

SAP ABAP Syntax for Perform is discussed in the previous post and it is in continuation with it.

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.

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

Variant 2

PERFORM form(prog).

Effect

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

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 .

ABAP TOPIC WISE COMPLETE COURSE

BDC
OOPS ABAP
ALE
IDOC'S
BADI
BAPI
Syntax Check
Interview Questions
ALV Reports with sample code
ABAP complete course
ABAP Dictionary
SAP Scripts
Script Controls
Smart Forms
Work Flow
Work Flow MM
Work Flow SD
Communication Interface

Learn about abap programming Finance sap abap sample codes and reports here.

SAP ABAP Syntax for Perform

The sap abap syntax for perform has different variants an shown below.

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 .

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).

Runtime errors

· PERFORMANCE_PARAMETER_MISSING : The called form expects more parameters than were specified.

· PERFORM_PARAMETER_COUNT ,

· PERFORM_TOO_MANY_PARAMETERS : More parameters were given than the FORM expected.

· PERFORM_CONFLICT_TYPE ,

· PERFORM_CONFLICT_GENERIC_TYPE ,

· PERFORM_BASE_WRONG_ALIGNMENT ,

· PERFORM_PARAMETER_TOO_SHORT ,

· PERFORM_TABLE_REQUIRED : The parameter type does not match the type specified in the FORM definition.

· PERFORM_BASE_LITL : A literal was passed to a structured parameter.

Addition 1

... USING p1 p2 p3 ...

Addition 2

... CHANGING p1 p2 p3 ...

Effect

These additions are equivalent to each other.

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'

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.

ABAP TOPIC WISE COMPLETE COURSE

BDC
OOPS ABAP
ALE
IDOC'S
BADI
BAPI
Syntax Check
Interview Questions
ALV Reports with sample code
ABAP complete course
ABAP Dictionary
SAP Scripts
Script Controls
Smart Forms
Work Flow
Work Flow MM
Work Flow SD
Communication Interface