Search on this Website

Sunday, June 17, 2007

Typical Structure of ABAP Program

1. Report Definitions
2. Table and Data definitions
3. Initialization event
4. Screen Select Options/Inputs
5. Selection-screen event
6. Start-of-selection event
7. Performs and other Events Statements
8. End-of-selection event

1. Initialization
• Triggered prior to first display of selection screen
• To specify Default value in SELECT-OPTIONS

2. At Selection-Screen
• Processed after the selection screen value are entered
• For validation of screen accepts
• Returns back to SELECT-OPTIONS

4. START-OF-SELECTION & END-OF-SELECTION
• This is implicit in any ABAP/4 program
• Start & end of main processing logic
• More in use with logical database access
• All Statements between START-OF-SELECTION and END-OF-ELECTION is
only executed
• By Default , no need to have END-OF-SELECTION
• Each procedural statement in an ABAP program automatically belongs to
START-OF-SELECTION
5. Form Event
• Similar to PERFORM/SUBROUTINES
• STARTS with FORM and ends with ENDFORM
• All statements between ENDFORM and end of program are never processed
• Similarly all statements between ENDFORM and event keyword are never
processed.


6. Limitations of Simple PERFORM
• Values can be passed through PERFORM to FORM.
• Giving the flexibility to use the same subroutine multiple number of times.
Syntax1: PERFORM using
changing
FORM using like
changing like - Pass by reference
OR
FORM using value (YYY) like - Pass by value,
creates another copy of the variable.

Example1:

PERFORM date-invert using in-date
Changing out-date

FORM date-invert using in-date like datum

Syntax2: PERFORM function-name(program) IF FOUND.

Example2: PERFORM HEADER(FORMPOOL) IF FOUND.


6. Get event
• GET <>
• Reads data of all columns from all database table falling in the hierarchy
• Needs to mention table name in TABLES: parameters.........
• Only fields part of the tables mentioned in the TABLES: parameter can be
viewed & edited

7. To Exit from an Event
• Exit ¬ It exits from the respective subroutine were this syntax is used ,
generally condition for the EXIT is stated before this syntax
• Check - here the conditional check is done at the same time .

CHECK
If the condition is not satisfied, the system leaves the subroutine and resumes
the processing after the PERFORM statement
• Stop ¬ it is the abrupt stopping the program flow

8. CALLing Functional Modules

Syntax:
CALL FUNCTION
[EXPORTING f1 = a1 .... fn = an]
[IMPORTING f1 = a1 .... fn = an]
[CHANGING f1 = a1 .... fn = an]
[TABLES f1 = a1 .... fn = an]
[EXCEPTIONS e1 = r1 .... en = rn

Example:
CALL FUNCTION 'Z_DATE_CONVERSION'
EXPORTING STD_DATE = GEN_DATE
IMPORTING CH_DATE = NEW_DATE

9. List Events

TOP-Of-PAGE, END-OF-PAGE,
AT LINE-SELECTION, AT USER-COMMAND
These events are triggered by the ABAP runtime environment while a list is
being created or when a user performs an action on a list. The statement in
these blocks can format the list or process the user's request.

No comments: