SAP ABAP Syntax for FORM

Basic form

FORM form.

Additions

1. ... TABLES itab1 ... itabn
2. ... USING p1 ... pn
3. ... CHANGING p1 ... pn

Effect

Defines a subroutine called by PERFORM

Example

PERFORM WELCOME.
FORM WELCOME.
WRITE / 'Hello world'.
ENDFORM.
The subroutine WELCOME called by the PERFORM statement outputs 'Hello world'

Notes

Subroutines defined by FORM can have parameters and local fields. These parameters and local fields shadow global fields.

Any local fields you declare with DATA after a FORM statement are recreated and initialized for each PERFORM call.

When the call has finished, the memory for local fields is released again. FORM statements are not allowed within FORM ... ENDFORM structures (i.e. no nested definitions). Nested and
recursive calls are possible. The optional parameters must always be specified in the order TABLES , USING and CHANGING .

Addition 1

... TABLES itab1 ... itabn

Effect

TABLES allows you to pass internal tables with or without header lines to subroutines. For information about assigning types TABLES parameters, see Type assignment . TABLES
parameters are passed by reference.

Example

DATA: BEGIN OF X.
INCLUDE STRUCTURE SFLIGHT.
DATA: ADDITION(8) TYPE C,
END OF X.
...
PERFORM U USING X.
...
FORM U USING X STRUCTURE SFLIGHT.
WRITE: X-FLDATE.
ENDFORM.

Example

TYPES: BEGIN OF FLIGHT_STRUC,
FLCARRID LIKE SFLIGHT-CARRID,
PRICE LIKE SFLIGHT-FLDATE,
END OF FLIGHT_STRUC.
DATA: MY_FLIGHT TYPE FLIGHT_STRUC OCCURS 0
WITH HEADER LINE,
IBOOK1 LIKE SBOOK OCCURS 0 WITH
HEADER LINE,
IBOOK2 LIKE IBOOK1 OCCURS 0,
STRUC LIKE SBOOK.
PERFORM DISPLAY TABLES MY_FLIGHT IBOOK1
IBOOK2 USING STRUC.
FORM DISPLAY TABLES P_ITAB LIKE MY_FLIGHT[]
P_BOOK1 LIKE IBOOK1[]
P_BOOK2 LIKE IBOOK2[]
USING P_STRU LIKE STRUC.
DATA L_CARRID LIKE P_ITAB-FLCARRID.
...
WRITE: / P_STRU-CARRID, P_STRU-CONNID.
...
LOOP AT P_ITAB WHERE FLCARRID = L_CARRID.
...
ENDLOOP.
...
ENDFORM.

RELATED POST

Marketing and erp mysap crm options
Organizational Challenges with crm and mysap crm solutions
My sap crm and marketing planning

No comments :

Post a Comment