Google
 

Monday, September 3, 2007

SAP - ABAP Help documentation

Data Declarations in Events

With "DATA X" in an event: When is X local, when is it global?


When you declare data (for example, using DATA), it depends on where in the program you define it as to whether it is global (can be addressed anywhere in the program), or whether the scope is restricted to the event in which you have placed it (local). Whilst it is clear that DATA X between FORM and ENDFORM or FUNCTION and ENDFUNCTION defines a variable X that is only recognized within the routine, the handling of this issue is not so clear with events. In this case, it depends whether the event is implemented internally as a FORM routine or not.

Global:

INITIALIZATION
START-OF-SELECTION
END-OF-SELECTION
TOP-OF-PAGE...
MODULE


Local:
AT SELECTION-SCREEN...
GET dbtab...
SAP ABAP Help

Example :

Global data definition:

INITIALIZATION.
DATA X.

START-OF-SELECTION.
MOVE 'A' TO X.

is syntactically correct.

Example

Local data definition:

AT SELECTION-SCREEN.
DATA X.

START-OF-SELECTION.
MOVE 'A' TO X.
results in a syntax error because the field X is known only in connection with the event "AT SELECTIONSCREEN".

No comments: