ABAP Syntax Code for Perform in SAP Programming

ABAP Code for programming SAP data retrieval has a key word perform and the previous post deals with syntax of perform and this is in continuation of that.

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

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.

Runtime errors

· PERFORM_INDEX_0 : The index specified was too small.

· PERFORM_INDEX_NEGATIVE : The index specified was negative.

· PERFORM_INDEX_TOO_LARGE : The index specified was too large.

SAP Finance sample report for abap code and programming can be learned here.

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

No comments:

Post a Comment