ABAP Program Structure and Runtime Flow
Understand how a classical ABAP report starts, flows and executes in real SAP systems.
Explanation
A classical ABAP report is not just a list of statements. It follows a runtime flow controlled by events such as INITIALIZATION, AT SELECTION-SCREEN, START-OF-SELECTION and END-OF-SELECTION. INITIALIZATION is used to set default values. AT SELECTION-SCREEN is used for input validation. START-OF-SELECTION is where the main data selection and processing usually begins. END-OF-SELECTION is used for final output processing. In real projects, understanding this flow helps developers place validation, data fetch and output logic in the right place. Poor structure makes reports difficult to debug and maintain.
Code example
REPORT zsales_report. PARAMETERS p_vkorg TYPE vkorg OBLIGATORY.SELECT-OPTIONS s_erdat FOR sy-datum. INITIALIZATION. s_erdat-low = sy-datum - 30. s_erdat-high = sy-datum. APPEND s_erdat. AT SELECTION-SCREEN. IF p_vkorg IS INITIAL. MESSAGE 'Sales organization is mandatory' TYPE 'E'. ENDIF. START-OF-SELECTION. PERFORM fetch_data. PERFORM display_output.Real project scenario
A sales report requires default date range, mandatory sales organization validation and final ALV output. Defaults should go in INITIALIZATION, validation in AT SELECTION-SCREEN, data selection in START-OF-SELECTION and output rendering after data preparation.
Common mistakes
- Putting validation after data selection. - Writing all logic directly in START-OF-SELECTION. - Not separating fetch, process and display logic. - Using report events without understanding sequence.
Best practices
- Keep report flow clean. - Separate validation, fetch, processing and display. - Avoid writing everything in one block. - Use meaningful FORM/method names.
Interview angle
Freshers should know report events. Experienced developers should explain where validation, data selection and output logic should be placed.