Você está na página 1de 8

Chapter No 2: REPORT PROGRAMMING

SECTIONS : 1. 2. 3. 4. CLASSICAL REPORTING EVENTS INTERACTIVE REPORTING EVENTS CONTROL BREAK / AT EVENTS ALV REPORTS

Reports help the management to take the decisions on performance of business system and to device strategies for the future. ABAP Programming is event based Programming language. There are different types of events that can be categorized as external and internal events An event is a happening or occurrence that has set timing. Whenever an event happens, there will be some kind of reaction. Hence an ABAP programmer, one should learn what is the time of each of the events and what one should do when an event is fired

EVENTS
EXTERNAL EVENTS INTERNAL EVENTS

CLASSICAL

INTERACTIVE

ALV

REPORT / LIST PROGRAMMING


ABAP Editor Database Data declaration --------------------------------------Data selection 3 ------------------------------------4 Output ----------------------------------1 3 8 4 4 Secondary Lists 1 2 3 9 Selection screen 2 Basic List 5 6 7

1 INITIALIZATION 2 AT SELECTION-SCREEN 3 START-OF-SELECTION 4 END-OF-SELECTION 5 TOP-OF-PAGE

4 20

7 AT LINE-SELECTION 8 TOP-OF PAGE DURING LINE SELECTION 9 AT USER-COMMAND

6 END-OF-PAGE

LOAD-OF-PROGRAM: This is basically an internal event triggered every time, when the program is executed. It loads the active version of the code into program content.

(1) CLASSICAL REPORTING EVENTS


1 INITIALIZATION This is the first event triggered externally. It is triggered after the execution of program but before displaying of the selection screen. It can be used to refresh global variables and to initialize global variables and selection screen fields.

2 AT SELECTIONSCREEN

This event is triggered when control is at selection screen. That is once the user has entered the input values and executed the program, and then this event is fired. We use this event to validate the selection screen input values. This event is fired when there are no exceptions in the AT SELECTION-SCREEN event. We use this event to select as much data as possible to be printed on basic list. If there is an exception in this event, we use ABAP statement STOP. In this case, the control is passed onto the event END-OF-SELECTION and the rest of START-OF-SELECTION event is skipped. This event is triggered either because of the STOP statement in START-OF-SELECTION event or after complete execution of START-OFSELECTION event. We use this event to write the output or to throw exceptions. This event is fired with the very first write statement in the program This event is generally used to print report headers. This event is generally used to print footer (page).A new page can be triggered in two ways NEW-PAGE or LINE-COUNT 20(2). By default, every page has 65,000 lines and 255 characters width

3 START-OFSELECTION

4 END-OFSELECTION

5 TOP-OF-PAGE

6 END-OF-PAGE

(2) INTERACTIVE REPORTING EVENTS


7 AT LINE-SELECTION This event is fired when the user double clicks on a line output. This event is used to print page headers for secondary lists.

TOP-OF PAGE DURING LINE SELECTION

AT USER-COMMAND

This event is fired whenever the user clicks on a button or a menu option.

Note: The list screen displayed immediately after the execution of program is known as BASIC LIST. This list has an index 0. By using interactive events, we have provision to create further drill down to secondary lists whose index stars from 1 maximum of 20.

Interactive lists use two statements (1) HIDE: when we use HIDE statement, the corresponding work area values are stored behind every line return in the output screen. Thus whenever a user double clicks on a specific line, the system internally copies the hidden work area. (2) GET CURSOR: when we use GET CURSOR statement, the system senses the field name and the cursor position. System variables helpful in the reports SY-LISEL Contains data of the selected line. SY-LSIND Contains the index of the list currently being created. While the basic list is being created, SY-LSIND is zero. SY-LINNO contains line number

(3) CONTROL BREAK / AT EVENTS


Control Break statements or At events can be used only inside a loop statements. AT FIRST This event is fired at first index of SY-TABIX and fired only once. One can use this event to write some kind of a subheading because it is fired only once.

AT LAST

This event is fired at last index, since it is fired only once. One can use this for arriving at grand totals.

AT NEW OF <c1>

This event is fired every time the value of c1 becomes new. It can be used to avoid printing duplicate values.

AT END OF <c1>

This event is fired every time the value of c1 ends. It can be used for arriving at sub-totals.

Customer No.(c1) 1 1 1 2 3 3 4

Region(c2) HYDERABAD DELHI MUMBAI HYDERABAD DELHI HYDERABAD DELHI

Sales(c3) 20 30 50 50 60 20 30

ALV REPORTS
ALV reports are written by using a standard type group called SLIS. One can make use of standard function modules. ALV Function Modules starts with or can be searched with Reuse*ALV*. Advantages of ALV Reporting over Normal Reporting: (1)DYNAMIC LAYOUT: when the requirement says that the user would like to change the layout of the report at runtime. (2)ADDITIONAL TOOLS AND UTILITIES: when the requirement says that the user needs lot of other options like download, totaling, subtotaling sorting of data.

STEPS FOR CREATING ALV REPORTING: STEP-1 STEP-2 STEP-3 Define Type-pools SLIS. Define an internal table of type SLIS_T_FIELDCAT_ALV. Define another internal table of type SLIS_T_EVENTS.

STEP-4

Define another internal table that should be structure of the desired output.

STEP-5

Fill up the ITAB created in STEP-2 with all the technical information of the layout. This step is also known as preparing the Field Catalog. In this step, one must provide all the properties for every column of the desired layout. These properties are available in the Type-Group SLIS. For example: Key column, totals, sub-totals.

STEP-6

This step should be carried out only if our report is supposed to use ALV events. Under this step, one should fill up the internal table created in step-3 with the list of ALV events. The list of events is available in Type-pool SLIS.

STEP-7

Fill up the data supposed to be printed in the internal table created in Step-4. This table is also known as Data table.

STEP-8

Call the function module. REUSE_ALV_LIST_DISPLAY OR REUSE_ALV_GRID_DISPLAY Pass all the three internal tables created so far in the program.

LAB EXERCISES: 1. 2. 3. 4. 5. 6. Write a program using classical events Write a program using interactive events Write a program to demonstrate control break statements Write an ALV program using ALV events Write an ALV program to display logo Write an ALV program to hide the any one of the additional button or tool on Application toolbar

Interview questions/ Test yourself: Name all the EVENTS in order of their execution Can you trigger AT USER-COMMAND and AT LINE SELECTION at the same time? What are the function codes and how do you define them? How do you define PF-STATUS and what are the components of it? How do you identify a basic list from secondary list? What are the various ways of triggering a new-page? What are the defaults of PAGE-SIZE and LINE-SIZE? How do you decide whether to write ALV or NORMAL reports? Name few ALV function modules and ALV events? What is the function of SUBMIT in a report? How do Export To and Import From work? How do you call a transaction from a report? How do SET PARAMETER ID and GET PARAMETER ID work? Can you create your own parameter ID and how? What are the different variants of AT SELECTION-SCREEN event? What are the TYPE-GROUPS? What are the FIELD-SYMBOLS?

Você também pode gostar