LOAD-OF-PROGRAM: Program Constructor Event

by | Sep 19, 2018 | ABAP Beginner

Home » SAP » ABAP » ABAP Beginner » LOAD-OF-PROGRAM: Program Constructor Event

Preface – This post is part of the ABAP Beginner series.

Program Constructor Event

A Program Constructor event in SAP ABAP is used to load global constant value or data of a program. It consist only one Event: LOAD-OF-PROGRAM

LOAD-OF-PROGRAM

Load of Program is Just like a Class Constructor or Static Constructor of a Class.

Now if you don’t know class constructor, then simply understand this thing, A Load of Program loads default values for a session e.g. Language.

Now you may say, we can load default values using INITIALIZATION, yes you can but it will be executed for every run, while Load of Program is executed once for a session.

LOAD OF PROGRAM is useful only in case of a report called using SUBMIT or the one that run using a transaction code else it will perform same as INITIALIZATION.

 

Example of LOAD-OF-PROGRAM:

LOAD-OF-PROGRAM.
DATA global_langu TYPE sy-langu.
global_langu = COND #( WHEN sy-langu = 'D' THEN 'German' ELSE 'English' ).

Explanation:

The above program have two statements.

  • The first statement is declaring a variable g_langu (A global variable for language) of type sy-langu (it fetches system language that is based on the system location).
  • The second statement is checking a condition, if the system language is D (i.e. German) then assign g_langu as ‘German’ and assign ‘English’ for any other system language.

Notes:

  • It is the first even executed by SAP ABAP
  • It is used to initialize global default values
  • If in a program, LOAD-OF-PROGRAM is only used for initialization and there is no executable lines after that, then LOAD-OF-PROGRAM event is not raised

Flow of an Executable Program

The statement SUBMIT is used to load the program in a separate internal session and based upon the following sequence calls different events as mention below:

  1. LOAD-OF-PROGRAM
  2. INITIALIZATION
  3. AT SELECTION-SCREEN OUTPUT
  4. START-OF-SELECTION
  5. END-OF-SELECTION

Author

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Author