Introduction to ALV Classic Reporting

A step-by-step programming guide to ALV reports

INTRODUCTION

SAP has introduced a lot of new technologies with Release 4.6. All of these are designed to have a more pleasing user interface and make the work of the developer easier by automating many of the standard functionalities, which was needed to be coded explicitly earlier. Along with automation, the new technologies also bring with it a host of new and powerful features. But to use these features you have to master them. It is similar to saying that if you have a Formula 1 Ferrari, the thrill is only if you can drive it at 200 kms/hr. ALV or the SAP LIST VIEWER is one such technology. It is a tool for making reports with a better and standardized interface. All clients want the latest of technologies to be used for their implementation and our client was no exception. We initially found the going tough because there is hardly any documentation on ALV with the small exception of a few sample codes on the Internet. But with hard work and an exploring attitude we (the SAP MAM Team of Transco ODC) developed a fair amount of competency in ALV. This document is in a way, the documentation of our learnings. This document is NOT a comprehensive work on ALV. Indeed, there are many features that we discover every week. This manual gives an introduction to ALV and on how a person can write simple ALV reports. It has been written with FULL code dumps and screen shots so that there is no scope for confusion. It tries to give the initial impetus required to venture into further exploration of the technology. There is no doubt that you will find newer features and ‘smarter’ way of doing things in ALV. It is our request to you to document these learnings and contribute to the EAS Knowledge Base. Remember, Rome was not built in a day. With this let us put our best foot forward …

All programs in this document (ZSOMALV1-7) are available in the SAP PDC Server. In case you are using them, you are requested to make a copy of them and then work on the copy.

INDEX

1. A Simple ALV Program ........................................................................................................................ 2. Choosing and saving Layouts. ........................................................................................................... 3. Specifying a field Catalogue................................................................................................................ 4. Initialize Events ..................................................................................................................................... 5. Customize you PF Status .................................................................................................................... 6. Process callback events ...................................................................................................................... 7. Sort Catalogue....................................................................................................................................... APPENDIX: A – TYPE-POOL ‘SLIS’ ........................................................................................................ APPENDIX: B – HOW TO COLOUR LINES OF A REPORT..................................................................

Chapter

1
A Simple ALV Program
TOPICS INTRODUCED
1) A simple ALV program. 2) REUSE_ALV_GRID_DISPLAY. 3) Minimum parameters to be passed.

Report ZSOMALV1:
REPORT zsomalv1 NO STANDARD PAGE HEADING. *Description-----------------------------------------------------------* * This program shows a simple ALV display of the table QMEL. Use the * 'Pattern' button to write the call to function * 'REUSE_ALV_GRID_DISPLAY'. Pass the table i_qmel to the function. *----------------------------------------------------------------------* DATA: i_qmel LIKE qmel OCCURS 0. SELECT * FROM qmel INTO TABLE i_qmel. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' * I_CALLBACK_PROGRAM = ' ' * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' i_structure_name = 'QMEL' * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = * IS_LAYOUT = * IT_FIELDCAT = * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' * I_SAVE = ' ' * IS_VARIANT = * IT_EVENTS =

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.* IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_qmel EXCEPTIONS program_error = 1 OTHERS = 2 . 2 . IF sy-subrc <> 0. OUTPUT .

DATA: i_layout TYPE slis_layout_alv. sort. save as a local file etc). Report ZSOMALV2: REPORT zsomalv2 NO STANDARD PAGE HEADING. Chapter 2 Choosing and saving Layouts TOPICS INTRODUCED 1) How we can ensure that report allows the user to make. Due to it. 3 . PERFORM f1000_layout_init CHANGING i_layout. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' . TYPE-POOLS: slis. ALV automatically sets a standard PF-STATUS (the row of buttons above the report). 3) Other options that can be specified for layouts. report_id = sy-repid. In the above case we are passing the name of the table itself (in place of the field catalogue which is discussed later). 2) Optimize the column width to display data in the most efficient manner.  Field Catalogue (Details of the format of the columns to be displayed in the report)  And the data to be populated in those columns. DATA: report_id LIKE sy-repid. SELECT * FROM qmel INTO TABLE i_qmel. The function automatically creates the field catalogue in this case. choose and save layouts (also called display variants). the function does not recognize the structure name being passed to it.Any ALV program requires a minimum of two parameters to be passed to the function REUSE_ALV_GRID_DISPLAY. A common mistake that every beginner does is not to uncomment the ‘EXPORTING’ line of the function after writing it by the Pattern button. DATA: i_qmel LIKE qmel OCCURS 0. With these you can do a lot of standard functions like send it by mail.

*&---------------------------------------------------------------------* *& Form F1000_Layout_Init *&---------------------------------------------------------------------* FORM f1000_layout_init USING i_layout TYPE slis_layout_alv. i_layout-colwidth_optimize = 'X'. 4 .EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' i_structure_name = 'QMEL' * I_BACKGROUND_ID = ' ' * I_GRID_TITLE = * I_GRID_SETTINGS = is_layout = i_layout * IT_FIELDCAT = * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = * IT_EVENTS = * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_qmel EXCEPTIONS program_error = 1 OTHERS = 2 . ENDFORM. " F1000_Layout_Init . IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. CLEAR i_layout. ENDIF.

OUTPUT Difference in this program is the usage of a Type-Pool (SLIS). ' ' = No display variants can be saved 'X' = Only standard display variants can be saved 'U‘ = Only user-specific display variants can be saved 'A' = Standard and user-specific display variants can be saved Note that 2 other buttons have appeared in the PF-STATUS (Change Layout and Save layout). slis_alv_layout). which are to be populated and passed to REUSE_ALV_GRID_DISPLAY. 5 . . This is also included in this document as APPENDIX A. Other difference is that we are passing a value ‘A’ to the parameter i_save. It is a good idea to keep a printout of this type-pool when coding ALV programs. This type pool contains all the standard structures and tables (for eg. Value range of parameter i_save can be. which all columns to be displayed and other properties). a window comes up where you can specify the sort order. When you click on ‘Change Layout’.

We found that a lot of such options were not working. .). For all such interactive functions to work. 6 . i_layout-no_scrolling = ‘X”  Scrolling is disabled. But it should never be passed alone. i_layout-no_vline = ‘X”  Columns are separated by space. The final thing is the passing of layout specifications (i_layout) to ALV. Then you are asked whether it is user specific or default. For example. If you do further R&D on this. only after assigning it to a variable.You can also sort the report using the sort buttons etc and click ‘Save Layout’. i_layout-zebra = ‘X’  This will result in the lines of the report having alternate colour. please document them and contribute to the EAS KB. Please refer to the other fields in the structure slis_layout_alv (it is combination of two structures which has more structures etc). we also need to pass the program ID (sy-repid) to ALV (I meant REUSE_ALV …. Through them you can specify a host of other properties.

DATA: BEGIN OF i_data OCCURS 0. chk. ws_char(5) TYPE c. Most probably it will be an internal table with a specific set of fields from different tables and maybe plain integer or character fields. qmtxt LIKE qmel-qmtxt. qmart LIKE qmel-qmart. pass it to ALV and also a field catalogue (also called fieldcat). In real life situations we will not need to simply display a table as we have been doing above. Create a field catalogue for the report. qmnum LIKE qmel-qmnum. SELECT qmnum qmart qmtxt INTO TABLE i_data FROM qmel WHERE qmnum <= '00030000010'. Specify a heading for a report. DATA: DATA: DATA: DATA: report_id ws_title i_layout i_fieldcat LIKE TYPE TYPE TYPE sy-repid. 2) Create a field catalogue for the report. . * 2. lvc_title VALUE 'An ALV Report'. ws_row TYPE i. In such cases the simplest method to follow is to create an internal table (of the same structure as what is to be displayed in the report) with the data. slis_layout_alv. slis_t_fieldcat_alv. 7 .Chapter 3 Specifying a field Catalogue TOPICS INTRODUCED 1) Specify a heading for a report. Report ZSOMALV3: REPORT zsomalv3 NO STANDARD PAGE HEADING. LOOP AT i_data. END OF i_data. *Description-----------------------------------------------------------* * TOPICS INTRODUCED: * 1. *----------------------------------------------------------------------* TYPE-POOLS: slis.

i_data-ws_row = sy-tabix. report_id = sy-repid. i_data-ws_char = 'AAAAA'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = * IT_EVENTS = * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2 . PERFORM f2000_fieldcat_init CHANGING i_fieldcat. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. *&---------------------------------------------------------------------* *& Form F1000_Layout_Init *&---------------------------------------------------------------------* . MODIFY i_data. 8 . ENDLOOP. IF sy-subrc <> 0. PERFORM f1000_layout_init CHANGING i_layout.

= 'I_DATA'. " This option ensures that you can " edit the checkbox. line_fieldcat-checkbox = 'X'. line_fieldcat-ref_tabname = 'I_DATA'. line_fieldcat-fieldname = 'CHK'. = 'Description'. = 'WS_ROW'. APPEND line_fieldcat TO i_fieldcat. CLEAR line_fieldcat. line_fieldcat-tabname = 'I_DATA'.'. " Shows the field as a hotspot. " f2000_fieldcat_init . i_fieldcat. ENDFORM. DATA: line_fieldcat TYPE slis_fieldcat_alv. line_fieldcat-hotspot = 'X'. = 'CHAR'. CLEAR line_fieldcat. APPEND line_fieldcat TO i_fieldcat. = '15'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-key line_fieldcat-seltext_m APPEND line_fieldcat TO = 'QMNUM'. " F1000_Layout_Init *&---------------------------------------------------------------------* *& Form f2000_fieldcat_init *&---------------------------------------------------------------------* FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv. Else it will " be protected. " name are the two minimum req. CLEAR line_fieldcat. = 'I_DATA'. " The field name and the table = 'I_DATA'.FORM f1000_layout_init USING i_layout TYPE slis_layout_alv. ENDFORM. i_fieldcat. = 'WS_CHAR'. CLEAR line_fieldcat. = 'Test Character Field'. = 'Row Number'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_l line_fieldcat-datatype line_fieldcat-outputlen APPEND line_fieldcat TO = 'QMTXT'. line_fieldcat-seltext_l = 'Checkbox'. " Column Header i_fieldcat. i_layout-colwidth_optimize = 'X'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. line_fieldcat-fieldname = 'QMART'. 9 . line_fieldcat-seltext_m = 'Notif Type'. " You can specify the width of a i_fieldcat. = 'X'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. " column. = 'I_DATA'. CLEAR i_layout. " Display this field as a checkbox line_fieldcat-edit = 'X'. i_layout-edit = 'X'. " Specifies the column as a key (Blue) = 'Notification No.

. C – Centre. The table we are using to create a field catalogue (i_fieldcat) is of type slis_t_fieldcat_alv. 10 . line_fieldcat-lzero = ’X’  Allows leading zeroes to be shown for a number column. Ones with DDIC (Data Dictionary Reference) and others without. Etc. Refer to the SLIS type-pool to get the other options that you can specify for a column. line_fieldcat-icon = ‘X’  Specifies this column as a column of icons. You can display a heading for the report using type lvc_title as shown. You must then specify valid icon values for tnem to be shown in the report.OUTPUT Over here we are purposely using a customized internal table which is being displayed in ALV. line_fieldcat-just = ‘R’  R – Justify right. L – Left. Notice that it contains two kinds of fields. It is a table of structure slis_fieldcat_alv. NOTE: The table i_fieldcat is passed to the parameter it_fieldcat of the function instead of i_structure_name as earlier. For example.

Report ZSOMALV4: REPORT zsomalv4 NO STANDARD PAGE HEADING. SELECT qmnum qmart qmtxt INTO TABLE i_data FROM qmel WHERE qmnum <= '00030000010'. 11 . . * 4. REUSE_ALV_COMMENTARY WRITE. lvc_title VALUE 'An ALV Report'. Initialize events. * 2. slis_layout_alv. ws_row TYPE i. DATA: DATA: DATA: DATA: DATA: DATA: report_id ws_title i_layout i_fieldcat i_events i_header LIKE TYPE TYPE TYPE TYPE TYPE sy-repid. Execute a specific requirement when an event is triggered. qmnum LIKE qmel-qmnum. *Description-----------------------------------------------------------* * TOPICS INTRODUCED: * 1. DATA: BEGIN OF i_data OCCURS 0.Chapter 4 Initialize Events TOPICS INTRODUCED 1) Initialize events. ws_char(5) TYPE c. *----------------------------------------------------------------------* TYPE-POOLS: slis. END OF i_data. 2) Execute a specific requirement when an event is triggered. qmtxt LIKE qmel-qmtxt. slis_t_event. qmart LIKE qmel-qmart. 4) REUSE_ALV_COMMENTARY WRITE. * 3. slis_t_fieldcat_alv. chk. 3) Use an event 'TOP_OF_PAGE' to write a header for the report. Use an event 'TOP_OF_PAGE' to write a header for the report. slis_t_listheader.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2 . ENDIF.LOOP AT i_data. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. ENDLOOP. i_data-ws_row = sy-tabix. PERFORM f4000_events_init CHANGING i_events. 12 . report_id = sy-repid. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. MODIFY i_data. i_data-ws_char = 'AAAAA'. PERFORM f3000_build_header CHANGING i_header. . PERFORM f1000_layout_init CHANGING i_layout.

" Column Header i_fieldcat. " F1000_Layout_Init *&---------------------------------------------------------------------* *& Form f2000_fieldcat_init *&---------------------------------------------------------------------* FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv. = 'WS_CHAR'. CLEAR line_fieldcat.*&---------------------------------------------------------------------* *& Form F1000_Layout_Init *&---------------------------------------------------------------------* FORM f1000_layout_init USING i_layout TYPE slis_layout_alv. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. " The field name and the table = 'I_DATA'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-key line_fieldcat-seltext_m APPEND line_fieldcat TO = 'QMNUM'. " Display this field as a checkbox line_fieldcat-edit = 'X'. ENDFORM. " Shows the field as a hotspot. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. line_fieldcat-fieldname = 'CHK'. line_fieldcat-checkbox = 'X'. = 'X'. i_layout-edit = 'X'.'. ENDFORM. line_fieldcat-seltext_l = 'Checkbox'. " Specifies the column as a key (Blue) = 'Notification No. = 'Test Character Field'. i_fieldcat. = 'WS_ROW'. = 'I_DATA'. line_fieldcat-tabname = 'I_DATA'. " f2000_fieldcat_init . Else it will " be protected. = 'I_DATA'. " You can specify the width of a i_fieldcat. = 'I_DATA'. line_fieldcat-ref_tabname = 'I_DATA'. line_fieldcat-hotspot = 'X'. DATA: line_fieldcat TYPE slis_fieldcat_alv. = 'Description'. = 'CHAR'. " column. " name are the two minimum req. line_fieldcat-seltext_m = 'Notif Type'. = '15'. " This option ensures that you can " edit the checkbox. CLEAR line_fieldcat. 13 . APPEND line_fieldcat TO i_fieldcat. CLEAR line_fieldcat. CLEAR i_layout. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_l line_fieldcat-datatype line_fieldcat-outputlen APPEND line_fieldcat TO = 'QMTXT'. CLEAR line_fieldcat. line_fieldcat-fieldname = 'QMART'. i_fieldcat. = 'Row Number'. i_layout-colwidth_optimize = 'X'. APPEND line_fieldcat TO i_fieldcat.

TO i_header. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = i_header. CLEAR gs_line. gs_line-info = 'This is line of type HEADER'. ENDFORM. DATA: gs_line TYPE slis_listheader. CLEAR gs_line. . APPEND gs_line TO i_header.*&---------------------------------------------------------------------* *& Form f3000_build_header *&---------------------------------------------------------------------* FORM f3000_build_header USING i_header TYPE slis_t_listheader. gs_line-typ = 'H'. DATA: line_event TYPE slis_alv_event. " f3000_build_header *&---------------------------------------------------------------------* *& Form f4000_events_init *&---------------------------------------------------------------------* FORM f4000_events_init CHANGING i_events TYPE slis_t_event. 'This is also line of type STATUS'. ENDFORM. APPEND line_event TO i_events. gs_line-typ = 'A'. CLEAR line_event. 'STATUS 2'. 'This is line of type STATUS'. ENDFORM. gs_line-typ = gs_line-key = gs_line-info = APPEND gs_line gs_line-key = gs_line-info = APPEND gs_line 'S'. line_event-form = 'F4100_TOP_OF_PAGE'. gs_line-info = 'This is line of type ACTION'. line_event-name = 'TOP_OF_PAGE'. 'STATUS 1'. 14 . CLEAR gs_line. APPEND gs_line TO i_header. TO i_header. " f3000_events_init *---------------------------------------------------------------------* * FORM F4100_TOP_OF_PAGE * *---------------------------------------------------------------------* FORM f4100_top_of_page.

4. HEADER. we have defined the event TOP_OF_PAGE (By defining an event. ITEM_DATA_EXPAND REP REP_SEL_MODIFY CALLER_EXIT USER_COMMAND . first declare a table of type slis_t_event and through a form (f4000_events_init) append lines to the table i_events. To define an event. STATUS or ACTION as defined in the type slis_listheader. which is a line item of slis_t_listheader. ABAP is a event driven language. which is executed when that event occurs). 3. As you may be aware. To this function we pass a table of the text that we want to be written in the report. It is of type slis_t_listheader. the event and the associated form. Later i_events is passed to ALV. (P.OUTPUT First let us discuss about events. 5. I don’t know!!) ALV supports 16 events. Each line is of type slis_alv_event and contains only two fields. I mean associating a form to it. Over here in the above example. we use the function REUSE_ALV_COMMENTARY_WRITE. which is executed upon that event. They are: 1. 15 .S: Please don’t ask we why we have only three types. To write a header. which can of three types. Through ALV we can cause one or more things to occur when an event is triggered. This is a table of rows. 2. This function can be used to write headers or footers for reports.

16. TOP_OF_PAGE DATA_CHANGED TOP_OF_COVERPAGE END_OF_COVERPAGE FOREIGN_TOP_OF_PAGE FOREIGN_END_OF_PAGE PF_STATUS_SET LIST_MODIFY TOP_OF_LIST END_OF_PAGE END_OF_LIST AFTER_LINE_OUTPUT BEFORE_LINE_OUTPUT 19. 9. 12. 11. 13. 16 .6. 8. 14. 17. 7. 18. SUBTOTAL_TEXT . 15. 10.

In most practical cases. Use transaction SE41 to view all the function codes. ws_char(5) TYPE c. lvc_title VALUE 'An ALV Report'. ws_row TYPE i. DATA: BEGIN OF i_data OCCURS 0. slis_t_fieldcat_alv. slis_layout_alv. Actually. END OF i_data. * 2. we have seen that ALV displays a standard PF Status by default. Learn about the ‘Standard’ PF-Status that comes as default. (For example. this PF Status is the ‘STANDARD’ PF Status of the program SAPLSALV with 46 function codes excluded (disabled). 17 . which contains a bare minimum function codes (also called fcodes). there are reports where the user must NOT be allowed to sort). qmtxt LIKE qmel-qmtxt. DATA: DATA: DATA: DATA: . Report ZSOMALV5: REPORT zsomalv5 NO STANDARD PAGE HEADING. In all the previous reports.Chapter 5 Customize you PF Status TOPICS INTRODUCED 1) Learn about the ‘Standard’ PF-Status that comes as default. we will need to exclude some function codes from the standard PF Status because they might be irrelevant to our report or because we may need to disable certain standard function codes. qmart LIKE qmel-qmart. report_id ws_title i_layout i_fieldcat LIKE TYPE TYPE TYPE sy-repid. chk. qmnum LIKE qmel-qmnum. This is helpful because we do not have to explicitly code the PF Status. *----------------------------------------------------------------------* TYPE-POOLS: slis. In the following program we will see how we display the entire ‘STANDARD’ PF Status (including the 46 fcodes which are usually disabled) and also disable 4 of the fcodes. *Description-----------------------------------------------------------* * TOPICS INTRODUCED: * 1. Exclude function codes from ‘Standard’ PF-Status and customize it. 2) Exclude function codes from ‘Standard’ PF-Status and customize it.

PERFORM f1000_layout_init CHANGING i_layout. i_data-ws_char = 'AAAAA'. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. TYPE slis_t_listheader. report_id = sy-repid. MODIFY i_data. SELECT qmnum qmart qmtxt INTO TABLE i_data FROM qmel WHERE qmnum <= '00030000010'. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = . PERFORM f3000_build_header CHANGING i_header. LOOP AT i_data. TYPE slis_t_extab. ENDLOOP. PERFORM f4000_events_init CHANGING i_events. 18 . i_data-ws_row = sy-tabix.DATA: i_events DATA: i_header DATA: i_extab TYPE slis_t_event.

line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. " You can specify the width of a i_fieldcat. DATA: line_fieldcat TYPE slis_fieldcat_alv. " Shows the field as a hotspot. ENDIF. 19 . = '15'. CLEAR line_fieldcat. line_fieldcat-hotspot = 'X'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_l line_fieldcat-datatype line_fieldcat-outputlen APPEND line_fieldcat TO = 'QMTXT'. " F1000_Layout_Init *&---------------------------------------------------------------------* *& Form f2000_fieldcat_init *&---------------------------------------------------------------------* FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv. CLEAR i_layout. CLEAR line_fieldcat. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-key line_fieldcat-seltext_m APPEND line_fieldcat TO = 'QMNUM'. = 'CHAR'. line_fieldcat-ref_tabname = 'I_DATA'. i_fieldcat. = 'Row Number'. . line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. *&---------------------------------------------------------------------* *& Form F1000_Layout_Init *&---------------------------------------------------------------------* FORM f1000_layout_init USING i_layout TYPE slis_layout_alv. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. = 'WS_CHAR'. CLEAR line_fieldcat. = 'Test Character Field'. i_layout-edit = 'X'. ENDFORM. APPEND line_fieldcat TO i_fieldcat. " Specifies the column as a key (Blue) = 'Notification No. line_fieldcat-fieldname = 'QMART'. IF sy-subrc <> 0. " name are the two minimum req. = 'I_DATA'.TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2 . = 'I_DATA'.'. i_layout-colwidth_optimize = 'X'. " Column Header i_fieldcat. " The field name and the table = 'I_DATA'. = 'WS_ROW'. " column. i_fieldcat. = 'Description'. = 'I_DATA'. line_fieldcat-seltext_m = 'Notif Type'. = 'X'.

" f3000_events_init *---------------------------------------------------------------------* * FORM F4100_TOP_OF_PAGE * *---------------------------------------------------------------------* . DATA: line_event TYPE slis_alv_event. " f3000_build_header *&---------------------------------------------------------------------* *& Form f4000_events_init *&---------------------------------------------------------------------* FORM f4000_events_init CHANGING i_events TYPE slis_t_event. line_event-form = 'F4200_PF_STATUS_SET'. ENDFORM. ENDFORM. DATA: gs_line TYPE slis_listheader. CLEAR gs_line. 'This is also line of type STATUS'. line_event-name = 'TOP_OF_PAGE'. line_fieldcat-fieldname = 'CHK'. 'STATUS 1'. 'This is line of type STATUS'. line_fieldcat-tabname = 'I_DATA'. CLEAR line_event. APPEND line_event TO i_events. 20 . " Display this field as a checkbox line_fieldcat-edit = 'X'. CLEAR line_event. TO i_header. CLEAR gs_line. APPEND line_event TO i_events. line_fieldcat-seltext_l = 'Checkbox'. APPEND gs_line TO i_header. ENDFORM. gs_line-typ = 'A'. line_event-name = 'PF_STATUS_SET'. gs_line-typ = gs_line-key = gs_line-info = APPEND gs_line gs_line-key = gs_line-info = APPEND gs_line 'S'. line_event-form = 'F4100_TOP_OF_PAGE'. Else it will " be protected. gs_line-info = 'This is line of type HEADER'. TO i_header. gs_line-typ = 'H'. 'STATUS 2'. APPEND gs_line TO i_header. APPEND line_fieldcat TO i_fieldcat. CLEAR gs_line. " f2000_fieldcat_init *&---------------------------------------------------------------------* *& Form f3000_build_header *&---------------------------------------------------------------------* FORM f3000_build_header USING i_header TYPE slis_t_listheader.CLEAR line_fieldcat. gs_line-info = 'This is line of type ACTION'. line_fieldcat-checkbox = 'X'. " This option ensures that you can " edit the checkbox.

i_extab. APPEND ws_fcode TO ws_fcode = '&LFO'. SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV' EXCLUDING i_extab. " ABC Analysis. " Info Select. DATA: ws_fcode TYPE slis_extab. i_extab. ENDFORM. " Information. REFRESH i_extab. " Call up Report. PERFORM f4210_exclude_fcodes CHANGING i_extab. APPEND ws_fcode TO ws_fcode = '&ABC'. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = i_header. CLEAR ws_fcode. *---------------------------------------------------------------------* * FORM F4200_PF_STATUS_SET * *---------------------------------------------------------------------* FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab. " f4210_exclude_fcodes . ws_fcode = '&EB9'. *&---------------------------------------------------------------------* *& Form f4210_exclude_fcodes *&---------------------------------------------------------------------* FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.FORM f4100_top_of_page. APPEND ws_fcode TO ws_fcode = '&NFO'. ENDFORM. 21 . i_extab. i_extab. APPEND ws_fcode TO ENDFORM.

Chapter 6 . Then call a form. which gets populated by the names of the 46 function codes that are populated by default by ALV. which populates i_extab with the names of the 4 fcodes. declare a new internal table ( i_extab) of type slis_t_extab. Inside this form (F4200_PF_STATUS_SET). 22 . first refresh the table i_extab. Finally set the PF Status. This will contain all the function codes. Initialize a new event called PF_STATUS_SET by assigning a form to it.OUTPUT For starters. which should be excluded from the PF Status.

Customize the processing of such events. . qmart LIKE qmel-qmart. slis_layout_alv. *Description-----------------------------------------------------------* * TOPICS INTRODUCED: * 1. slis_t_listheader. 23 . i_data-ws_char = 'AAAAA'. Add customized buttons (function codes) to ‘Standard’ PF Status. i_data-ws_row = sy-tabix. ws_char(5) TYPE c. lvc_title VALUE 'An ALV Report'.Process callback events TOPICS INTRODUCED 1) Add customized buttons (function codes) to ‘Standard’ PF Status. ENDLOOP. we may need to add buttons (function codes) to our PF status and assign a code that will be executed when that function code is triggered. * 2. qmnum LIKE qmel-qmnum. slis_t_fieldcat_alv. END OF i_data. SELECT qmnum qmart qmtxt INTO TABLE i_data FROM qmel WHERE qmnum <= '00030000010'. qmtxt LIKE qmel-qmtxt. MODIFY i_data. We can either create our own PF status or copy the STANDARD pf status of program SAPLSALV creating our own to which we can add buttons and function codes. *----------------------------------------------------------------------* TYPE-POOLS: slis. In many cases. slis_t_extab. slis_t_event. 2) Customize the processing of such events. ws_row TYPE i. LOOP AT i_data. DATA: DATA: DATA: DATA: DATA: DATA: DATA: report_id ws_title i_layout i_fieldcat i_events i_header i_extab LIKE TYPE TYPE TYPE TYPE TYPE TYPE sy-repid. Report ZSOMALV6: REPORT zsomalv6 NO STANDARD PAGE HEADING. chk. DATA: BEGIN OF i_data OCCURS 0.

PERFORM f4000_events_init CHANGING i_events. ENDIF. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING * I_INTERFACE_CHECK = ' ' * I_BYPASSING_BUFFER = * I_BUFFER_ACTIVE = ' ' i_callback_program = report_id * I_CALLBACK_PF_STATUS_SET = ' ' * I_CALLBACK_USER_COMMAND = ' ' * I_CALLBACK_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_TOP_OF_PAGE = ' ' * I_CALLBACK_HTML_END_OF_LIST = ' ' * i_structure_name = ' ' * I_BACKGROUND_ID = ' ' i_grid_title = ws_title * I_GRID_SETTINGS = is_layout = i_layout it_fieldcat = i_fieldcat * IT_EXCLUDING = * IT_SPECIAL_GROUPS = * IT_SORT = * IT_FILTER = * IS_SEL_HIDE = * I_DEFAULT = 'X' i_save = 'A' * IS_VARIANT = it_events = i_events * IT_EVENT_EXIT = * IS_PRINT = * IS_REPREP_ID = * I_SCREEN_START_COLUMN = 0 * I_SCREEN_START_LINE = 0 * I_SCREEN_END_COLUMN = 0 * I_SCREEN_END_LINE = 0 * IT_ALV_GRAPHICS = * IT_ADD_FIELDCAT = * IT_HYPERLINK = * IMPORTING * E_EXIT_CAUSED_BY_CALLER = * ES_EXIT_CAUSED_BY_USER = TABLES t_outtab = i_data EXCEPTIONS program_error = 1 OTHERS = 2 . PERFORM f3000_build_header CHANGING i_header. PERFORM f2000_fieldcat_init CHANGING i_fieldcat. *&---------------------------------------------------------------------* *& Form F1000_Layout_Init *&---------------------------------------------------------------------* FORM f1000_layout_init USING i_layout TYPE slis_layout_alv. 24 . IF sy-subrc <> 0. . MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. PERFORM f1000_layout_init CHANGING i_layout.report_id = sy-repid. CLEAR i_layout.

" Specifies the column as a key (Blue) = 'Notification No. line_fieldcat-seltext_l = 'Checkbox'. . = 'Test Character Field'. line_fieldcat-fieldname = 'QMART'. 25 . line_fieldcat-ref_tabname = 'I_DATA'. APPEND line_fieldcat TO i_fieldcat. = 'I_DATA'.i_layout-colwidth_optimize = 'X'. line_fieldcat-checkbox = 'X'. i_fieldcat. = 'Row Number'. = 'I_DATA'. " F1000_Layout_Init *&---------------------------------------------------------------------* *& Form f2000_fieldcat_init *&---------------------------------------------------------------------* FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv. CLEAR line_fieldcat. line_fieldcat-hotspot = 'X'. i_layout-edit = 'X'. = 'CHAR'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. " name are the two minimum req. CLEAR line_fieldcat. CLEAR line_fieldcat. i_fieldcat. " Display this field as a checkbox line_fieldcat-edit = 'X'. " This option ensures that you can " edit the checkbox. Else it will " be protected.'. " f2000_fieldcat_init *&---------------------------------------------------------------------* *& Form f3000_build_header *&---------------------------------------------------------------------* FORM f3000_build_header USING i_header TYPE slis_t_listheader. DATA: line_fieldcat TYPE slis_fieldcat_alv. line_fieldcat-seltext_m = 'Notif Type'. = 'I_DATA'. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_m APPEND line_fieldcat TO CLEAR line_fieldcat. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-key line_fieldcat-seltext_m APPEND line_fieldcat TO = 'QMNUM'. line_fieldcat-fieldname = 'CHK'. = 'WS_ROW'. " column. = 'WS_CHAR'. " Shows the field as a hotspot. line_fieldcat-tabname = 'I_DATA'. = 'Description'. CLEAR line_fieldcat. APPEND line_fieldcat TO i_fieldcat. line_fieldcat-fieldname line_fieldcat-tabname line_fieldcat-seltext_l line_fieldcat-datatype line_fieldcat-outputlen APPEND line_fieldcat TO = 'QMTXT'. = '15'. " The field name and the table = 'I_DATA'. " Column Header i_fieldcat. ENDFORM. " You can specify the width of a i_fieldcat. ENDFORM. = 'X'.

APPEND line_event TO i_events. gs_line-typ = 'H'. CLEAR line_event. *---------------------------------------------------------------------* * FORM F4200_PF_STATUS_SET * *---------------------------------------------------------------------* FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab. ENDFORM. line_event-form = 'F4300_USER_COMMAND'. gs_line-info = 'This is line of type HEADER'. line_event-form = 'F4100_TOP_OF_PAGE'. " f3000_build_header *&---------------------------------------------------------------------* *& Form f4000_events_init *&---------------------------------------------------------------------* FORM f4000_events_init CHANGING i_events TYPE slis_t_event. " f3000_events_init *---------------------------------------------------------------------* * FORM F4100_TOP_OF_PAGE * *---------------------------------------------------------------------* FORM f4100_top_of_page. APPEND line_event TO i_events. TO i_header. line_event-name = 'PF_STATUS_SET'. 26 . gs_line-info = 'This is line of type ACTION'. 'STATUS 2'. ENDFORM. APPEND line_event TO i_events. 'This is also line of type STATUS'. 'STATUS 1'. CLEAR line_event. line_event-form = 'F4200_PF_STATUS_SET'. line_event-name = 'USER_COMMAND'. gs_line-typ = 'A'. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING it_list_commentary = i_header. . TO i_header. CLEAR gs_line. APPEND gs_line TO i_header. CLEAR line_event. line_event-name = 'TOP_OF_PAGE'. DATA: line_event TYPE slis_alv_event. CLEAR gs_line. ENDFORM. APPEND gs_line TO i_header. 'This is line of type STATUS'. CLEAR gs_line. gs_line-typ = gs_line-key = gs_line-info = APPEND gs_line gs_line-key = gs_line-info = APPEND gs_line 'S'.DATA: gs_line TYPE slis_listheader.

i_extab. ENDIF. PERFORM f4210_exclude_fcodes CHANGING i_extab. APPEND ws_fcode TO ws_fcode = '&LFO'. SET PARAMETER ID 'IQM' FIELD i_data-qmnum. " f4210_exclude_fcodes *&---------------------------------------------------------------------* *& Form f4300_user_command *&---------------------------------------------------------------------* FORM f4300_user_command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield. WHEN 'CHNG'. ENDFORM. " ABC Analysis. CLEAR ucomm. i_extab. ENDCASE. IF i_data-qmnum NE space. CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN.REFRESH i_extab. SET PARAMETER ID 'IQM' FIELD i_data-qmnum. i_extab. 27 . * The PF status is an exact copy of the PF status 'STANDARD' of program * SAPLSALV but with command 'CHNG' added to it. "Double Click line Item READ TABLE i_data INDEX selfield-tabindex. ENDIF. *&---------------------------------------------------------------------* *& Form f4210_exclude_fcodes *&---------------------------------------------------------------------* FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab. CLEAR ucomm. SET PF-STATUS 'ZSOM_STANDARD' EXCLUDING i_extab. " Information. CLEAR ucomm. APPEND ws_fcode TO ws_fcode = '&NFO'. APPEND ws_fcode TO ws_fcode = '&ABC'. i_extab. ws_fcode = '&EB9'. ENDFORM. " Change Notification Icon READ TABLE i_data INDEX selfield-tabindex. " Call up Report. APPEND ws_fcode TO ENDFORM. " f4300_user_command . " Info Select. DATA: ws_fcode TYPE slis_extab. IF i_data-qmnum NE space. CASE ucomm. CALL TRANSACTION 'IW52' AND SKIP FIRST SCREEN. CLEAR ws_fcode. WHEN '&IC1'.

it comes back to the report. If we write functionality for an existing fcode. . In this example. then this gets precedence over the default functionality that might be associated with it. Creation of PF status is not covered in this document. we capture a standard fcode ‘&IC1’ that is nothing but double clicking a line of the report. as it is available in any standard ABAP material. When the user clicks the “Back’ button in IW52. which was an exact copy of STANDARD of program SAPLSALV through transaction SE41 (Menu Painter). After this this we set this PF status instead of STANADRD.OUTPUT In this program. 28 . We initialize a third event USER_COMMAND and associate a form with it. In this form we can capture the function codes and write any functionality under it. Then we added another button to it (circled in white) with a new fcode called ‘CHNG’. We are capturing the notification number of that line and calling transaction IW52 with it. We are also doing the same when a user clicks on the new ‘Change Notification’ button. first we created a PF status (ZSOM_STANDARD).

e. " Ascending APPEND line_sortinfo TO i_sortcat. line_sortinfo-fieldname = 'WS_ROW'. REUSE_ALV_GRID_DISPLAY) *&---------------------------------------------------------------------* *& Form f5000_sortcat_init *&---------------------------------------------------------------------* form f5000_sortcat_init changing i_sortcat TYPE slis_t_sortinfo_alv. " Second sort by this field. This is a table of the structure slis_sortinfo_alv. line_sortinfo-tabname = 'I_DATA'. table names. line_sortinfo-tabname = 'I_DATA'. * * * * * it_fieldcat IT_EXCLUDING IT_SPECIAL_GROUPS IT_SORT IT_FILTER IS_SEL_HIDE I_DEFAULT = i_fieldcat = = = i_sortcat = = = 'X' . CLEAR line_sortinfo. Creating a sort catalogue is very similar to creating a field catalogue. 2) Sort a report using a sort catalogue. whether it should be sorted ascending or descending. " First sort by this field. " Descending APPEND line_sortinfo TO i_sortcat. line_sortinfo-up = 'X'. DATA: line_sortinfo TYPE slis_sortinfo_alv. order of sorting. line_sortinfo-fieldname = 'QMART'. endform. (i. " f5000_sortcat_init Then pass i_sortcat to ALV through the parameter it_sort. line_sortinfo-spos = 2. In it we can specify the fieldnames. 29 .. line_sortinfo-down = 'X'. line_sortinfo-spos = 1. Then create the sort catalogue in a form which is to be called before the call to ALV. The steps to be taken are.Chapter 7 Sort Catalogue TOPICS INTRODUCED 1) Define a sort catalogue for a report. first declare an internal table ( i_sort ) of type slis_t_sortinfo_alv.

OUTPUT In this example we have sorted the above list first by notification type (QMART) descending and then by row number (WS_ROW) ascending. 30 . SET PF-STATUS 'ZSOM_STANDARD' OF PROGRAM 'ZSOMALV6' EXCLUDING i_extab. In short the statement. Or else you will get an error. This is because this PF status was created for program ZSOMALV6. SORT i_data BY qmart DESCENDING ws_row ASCENDING.In form F4200_pf_status_set. Just sort the internal data table (i_data) in the required manner before passing it to ALV and it will be displayed as shown above. The only difference is that the red arrows won’t be there. Do note the small red arrows that come up in the column header indicating the type of sort. The usage of a sort catalogue is actually not required !! This is also the reason why I have decided to put it towards the last. . Is enough to replace all the code written above !! . change the setting of the PF status to.

"<<Y9CK015723 ">>Y9CK016292 *Trace Extern-Intern-Konvertierung types: begin of slis_lvc_s_expa. . types: slis_lvc_t_bds2 type slis_lvc_s_bds2 occurs 1. 31 . bytesize type int4. LFIELDNAME type FNAM_____4. FIELDNAME type FIELDNAME. CONVEXIT type CONVEXIT. ">>Y9CK015723 types: begin of slis_lvc_s_bds_extended. include type slis_lvc_s_bds_extended. include type lvc_s_bds. LOWER type RSSCR_LOWC. end of slis_lvc_s_expa. types: begin of slis_lvc_s_bds2. *Text-Tabelle(ALV Batch) types: slis_lvc_t_1022 type slis_lvc_s_1022 occurs 1. *INCLUDE type TABFIELD TABNAME type TABNAME. *Textstruktur(ALV-Batch) types: begin of slis_lvc_s_1022. types: end of slis_lvc_s_bds2.Appendix A Type-Pool ‘SLIS’ type-pool slis . "Y9CK016268 end of slis_lvc_s_bds_extended. SIGN type SIGNFLAG. EXTOBJID type char255. CURRENCY type CHAR30. *INCLUDE type RSCONVLITE ACTIVE type RSSCR_CFLG. *Ausgabefiles types: begin of slis_lvc_s_fils. INTERN type LVC_VALUE. OP type CHAR4. DECIMALS type RSDECIMALS. EXTERN type LVC_VALUE. end of slis_lvc_s_1022. line(1022) type c. OLENGTH type RSSCR_OLEN.

*types: begin of slis_filtered_entries. . *X255-Tabelle types: slis_lvc_t_mime type w3mime occurs 1. types: slis_t_add_fieldcat type slis_add_fieldcat occurs 0. appl(4) type c. *--. * index type i. BINARY type FLAG. MIMETYPE type CHAR128. SIZE type INT4. end of slis_lvc_s_mima. slis_sel_tab_field(60) type c.Structure for reprep-initialization types: begin of slis_reprep_id. 32 . slis_fieldname(30) type c. fieldname type slis_fieldname. types: slis_tabname(30) type c.FILENAME type CHAR255. PRIMARY type FLAG. end of slis_lvc_s_fils. tool(2) type c. web_field type slis_fieldname. slis_entry(60) type c. *ALV-W3Text types: slis_lvc_t_text type w3html occurs 1. end of slis_add_fieldcat. slis_formname(30) type c. * end of slis_filtered_entries. end of slis_reprep_id. slis_char_1(1) type c. types: slis_t_filtered_entries type i occurs 0. onam(54) type c. subc(2) type c. MIMETYPE type CHAR128. *--. *ALV: Mime-Mapping types: slis_lvc_t_mima type slis_lvc_s_mima occurs 1. BINARY type FLAG. slis_edit_mask(60) type c. href_hndl type i. slis_coldesc(4) type c. "<<Y9CK016292 types: slis_list_type(1) type n. *Filestruktur types: slis_lvc_t_fils type slis_lvc_s_fils occurs 1.Structure for additional fieldcat types: begin of slis_add_fieldcat. *Tabelle X1022 types: slis_lvc_t_x1022 type bapiconten occurs 1. slis_text40(40) type c. *Mimetype-Mapping types: begin of slis_lvc_s_mima.

heacolfir type slis_color. hearowfir type slis_color. " technical field . inv type i. heahie type slis_color. " write no-sign no_zero(1) type c. cfieldname type slis_fieldname. " emphasize fix_column(1) type c. hig type slis_color.types: begin of slis_reprep_communication. higsumhig type slis_color. " (O)blig. " as checkbox just(1) type c. lisbod type slis_color. *** Structure for colors types: begin of slis_color. " (R)ight (L)eft (C)ent. " position of the column fieldname type slis_fieldname. higpos type slis_color. " field with quantity unit qtabname type slis_tabname. types: begin of slis_coltypes. " write no-zero no_convext(1) type c. " output in row col_pos like sy-cucol. lisbodfir type slis_color. higcol type slis_color. " initial column quantity(3) type c. end of slis_coltypes. " Spalte fixieren do_sum(1) type c. hearownex type slis_color. " emphasize(4) type c. heacolnex type slis_color. " column with key-color icon(1) type c. higsumlow type slis_color. end of slis_color. " as icon symbol(1) type c. " round in write statement exponent(3) type c. higneg type slis_color. lzero(1) type c. 33 . int type i. edit_mask type slis_edit_mask. stop(1) type c. " " " " " " " " " " " " " " " " " " " heading_cols_first heading_cols_nex heading_rows_first heading_rows_next list_body_first list_body_next list_body highlight_col_key highlight_col highlight_row highlight_sum highlight_sum_high highlight_sum_low highlight_inserted highlight_positive highlight_negative highlight heading_hier list_body_hierinfo *** Fieldcat types: begin of slis_fieldcat_main0. " field with currency unit ctabname type slis_tabname. higsum type slis_color. currency(5) type c. tabname type slis_tabname. higins type slis_color. " exponent for floats key(1) type c.(X)no out tech(1) type c. " sum up no_out(1) type c. higrow type slis_color. higcolkey type slis_color. qfieldname type slis_fieldname. " leading zero no_sign(1) type c. end of slis_reprep_communication. lisbodnex type slis_color. " as symbol checkbox(1) type c. col type i. lisbodhie type slis_color. row_pos like sy-curow. " and table ifieldname type slis_fieldname. " and table round type i.

decimalsfieldname type slis_fieldname. types: end of slis_fieldcat_alv1. " edit(1) type c. types: begin of slis_fieldcat_main1. " hotspot(1) type c. include type slis_fieldcat_main0. end of slis_fieldcat_main1. types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1. offset type dd03p-outputlen. before(1) type c. types: begin of slis_fieldcat_alv. decimals_out(6) type c. reptext_ddic like dd03p-reptext. * Callback Interface structure for non display subtotals text types: begin of slis_subtot_text. 34 . end of slis_fieldcat_main0. types: end of slis_fieldcat_main. types: begin of slis_fieldcat_main. " short key word ddictxt(1) type c. types: end of slis_fieldcat_alv. intlen like dd03p-intlen. include type slis_fieldcat_main1. " middle key word seltext_s like dd03p-scrtext_s. lowercase like dd03p-lowercase. criteria type slis_fieldname. roundfieldname type slis_fieldname. types: slis_t_event_exit type slis_event_exit occurs 1. inttype like dd03p-inttype. * Events for Callback types: begin of slis_event_exit. roundtabname type slis_tabname. field not obligatory do not sum up group specification selection for rep/rep input internal use only hotspot . " input(1) type c. " no_sum(1) type c. include type slis_fieldcat_main1. key_sel(1) type c. " decimals in write statement text_fieldname type slis_fieldname. ref_tabname like dd03p-tabname. include type slis_fieldcat_alv_spec. types: begin of slis_fieldcat_alv_spec. " long key word seltext_m like dd03p-scrtext_m. types: begin of slis_fieldcat_alv1. datatype like dd03p-datatype.outputlen like dd03p-outputlen. types: ucomm like sy-ucomm. ref_fieldname like dd03p-fieldname. include type slis_fieldcat_main. end of slis_event_exit. " end of slis_fieldcat_alv_spec. " sp_group(4) type c. " (S)hort (M)iddle (L)ong rollname like dd03p-rollname. decimalstabname type slis_tabname. after(1) type c. " heading (ddic) ddic_outputlen like dd03p-outputlen. " offset seltext_l like dd03p-scrtext_l. " reprep(1) type c.

max_len like dd03p-outputlen. 35 . display_text_for_subtotal(255) type c. " reserve_lines type i. " print to spool " moment to print the title types: begin of slis_print_alv1. types: begin of slis_print_alv. print(1) type c. include type slis_print_alv1. no_min_linesize(1) type c. prnt_title(1) type c. *** Layout types: begin of slis_print_alv0. no_colhead(1) type c.keyword like dd03p-reptext. no_author(1) type c. no_uline_hs(1) type c. " " " " " " " " " " " " " no headings headings not as hotspot striped pattern columns separated by space not suppress field replication for grid only for grid only totals for NUMC-Fields possib. only display fields " report report interface active do not fix keycolumns Expand all positions No standard authority check " default status space or 'A' " Text for item button types: begin of slis_layout_alv_spec1. no_keyfix(1) type c. criteria_text(255) type c. end of slis_subtot_text. cell_merge(1) type c. * Exceptions lights_fieldname type slis_fieldname. end of slis_layout_alv_spec0. expand_all(1) type c. no_input(1) type c. exceptiondocu . no_vline(1) type c. end of slis_layout_main. edit(1) type c. types: begin of slis_layout_main. include type alv_s_prnt." fieldname for exception lights_tabname type slis_tabname. types: begin of slis_layout_alv_spec0. reprep(1) type c. no_hotspot(1) type c. "don't expand item end of slis_print_alv1. " fieldname for exception lights_rollname like dfies-rollname. " display no listinfos no_change_print_params(1) type c. " no_new_page(1) type c. types: end of slis_print_alv. " don't change linesize no_print_hierseq_item(1) type c." rollname f. " line size = width of the list min_linesize like sy-linsz. end of slis_print_alv0. * PF-status def_status(1) type c. * Display options colwidth_optimize(1) type c. numc_sum(1) type c. " Default 250 window_titlebar like sy-title. edit_mode(1) type c. " if initial min_linesize = 80 max_linesize like sy-linsz. " lines reserved for end of page no_print_listinfos(1) type c. " display no selection infos no_coverpage(1) type c. f2code like sy-ucomm. dummy. item_text(20) type c. zebra(1) type c. no_print_selinfos(1) type c.

" text for 1st col." Titlebar for detail Display variants header_text(20) type c. types: end of slis_layout_alv. " no choice for summing up no_totalline(1) type c. group_buttons(1) type c. " fieldname flag hotspot confirmation_prompt. " no scrolling Detailed screen detail_popup(1) type c. include type slis_layout_main. " eXtended INTeraction(SAPQuery) dtc_layout type dtc_s_layo. " colors others list_append(1) type c. include type slis_layout_alv_spec1. types: begin of slis_layout_alv_spec. " eXtended interaction(SAPQuery) xidirect type flag. in total line subtotals_text(60) type c. " fieldname for exception Sums no_sumchoice(1) type c." rollname for checkbox expand_fieldname type slis_fieldname. tabname type slis_tabname. " buttons for COL1 . " show also initial lines detail_titlebar like sy-title. " show detail in popup detail_initial_lines(1) type c. " confirm. " infofield for listoutput coltab_fieldname type slis_fieldname. " no sep. types: begin of slis_layout_alv1.Lineinfo before output types: begin of slis_lineinfo. *--." tabname for checkbox box_rollname like dd03p-rollname. " no choice for subtotals no_subtotals(1) type c. " read selection screen group_change_edit(1) type c. fcode like rsmpe-func. tot. include type slis_layout_alv_spec1. " Items as default colour info_fieldname type slis_fieldname. include type slis_layout_alv_spec0. prompt when leaving key_hotspot(1) type c. in subtotals Interaction box_fieldname type slis_fieldname. " fieldname for checkbox box_tabname type slis_tabname. types: end of slis_layout_alv1.. 36 .lines by inh.units totals_before_items type c.* * * * * * lights_condense(1) type c. " text for 1st col.Structure for the excluding table (function codes) types: begin of slis_extab.. include type slis_layout_alv_spec. include type slis_layout_main. types: end of slis_layout_alv_spec. " no total line no_subchoice(1) type c. " no call screen xifunckey type aqs_xikey. end of slis_extab. "Layout for configure the Tabstip end of slis_layout_alv_spec1. " show only totals totals_text(60) type c. " keys as hotspot " K_KEYHOT flexible_key(1) type c. . " no subtotals possible no_unit_splitting type c. " key columns movable. " Text for header button default_item(1) type c.. " diplay totals before the items totals_only(1) type c. " fieldname flag 'expand' hotspot_fieldname type slis_fieldname.COL5 get_selinfos(1) type c. types: begin of slis_layout_alv. " Settings by user for new group no_scrolling(1) type c. *--.

37 . linsz like sy-linsz. refresh(1) type c. endsum(1) type c. cursor_offset like sy-cucol. sel_tab_field type slis_sel_tab_field. up like alvdynp-sortup. . collect_from type i. subtot like alvdynp-subtotals. tabindex like sy-tabix. text(40) type c. staco like sy-staco. cpage like sy-cpage. " ignore selection by checkboxes (F2) col_stable(1) type c. spos like alvdynp-sortpos. value type slis_entry. sumindex like sy-tabix. collect_to type i. end of slis_lineinfo. * special groups for column selection types: begin of slis_sp_group_alv. exit(1) type c. *--. after_action(1) type c. *--. * information cursor position ALV types: begin of slis_selfield. endsum(1) type c.excluding table types: slis_t_extab type slis_extab occurs 1. group like alvdynp-grouplevel. subtot(1) type c. * colwidth_optimize(1) type c.tabindex like sy-tabix. types: slis_t_sp_group_alv type slis_sp_group_alv occurs 1. cursor_line like sy-curow. tabname type slis_fieldname. end of slis_selfield. ignore_multi(1) type c. * subtot(1) type c. end of slis_sp_group_alv. sp_group(4) type c. * down(1) type c. linno like sy-linno. before_action(1) type c.Structure for scrolling in list types: begin of slis_list_scroll. subtot_level(2) type n. * group(2) type c. fieldname type slis_fieldname. staro like sy-staro. sumindex like sy-tabix. lsind like sy-lsind. fieldname type slis_fieldname. tabname type slis_tabname. down like alvdynp-sortdown. row_stable(1) type c. * up(1) type c. end of slis_list_scroll. grouplevel type i. * spos(2) type n. comp(1) type c. * information for sort and subtotals types: begin of slis_sortinfo_alv.

edit_mask type slis_edit_mask. types: slis_t_filter_alv type slis_filter_alv occurs 1. org_selname type rsscr_name. stype(1). tabname type slis_tabname. valuf(80). seltext(40). include type slis_filter_alv0. fieldname type slis_fieldname. optio(2). obligatory(1) type c. sign_icon(4). stype(1). fieldname type slis_fieldname. field like dfies-fieldname. "introduced this FO 09. 38 . or(1) type c. types: slis_seldis_alv type slis_seldis1_alv occurs 1. no_sign(1) type c. end of slis_sortinfo_alv. * information for selections types: begin of slis_seldis1_alv. end of slis_filter_alv1. sign0(1). table like dfies-tabname. valut_int(80).00 end of slis_seldis1_alv. inttype like dfies-inttype. . valuf(80). lowercase like dfies-lowercase. inttype like dfies-inttype. sign0(1). tabname type slis_tabname. exception(1) type c. ref_tabname like dfies-tabname. intlen like dfies-intlen. ltext(40). types: begin of slis_filter_alv1. convexit like dfies-convexit.01. types: end of slis_filter_alv. decimals like dfies-decimals. types: slis_t_sortinfo_alv type slis_sortinfo_alv occurs 1. valut(80). end of slis_filter_alv0. stext(40). * filter types: begin of slis_filter_alv0.expa(1) type c. no_text(1). types: begin of slis_filter_alv. cqvalue(5) type c. valuf_int(80). include type slis_filter_alv1. length type p. ref_fieldname like dfies-fieldname. valut(80). ddic_outputlen like dfies-outputlen. order type order. datatype like dfies-datatype. optio(2).

"(R)eplace or (C)hange t_entries type slis_t_selentry_hide_alv. include type slis_seldis1_alv. S = Selection. types: begin of slis_status. end of slis_alv_event. color type slis_color. A = Action key(20) type c. end of slis_data_caller_exit. header03 type slis_fieldname. types: slis_t_listheader type slis_listheader occurs 1. dummy like sy-repid. mode(1) type c. *--. * Header table for top of page types: begin of slis_listheader. "(D)elete (A)dd selname like rsparams-selname. end of slis_keyinfo_alv. name(30). fieldname type slis_fieldname. item01 type slis_fieldname. actual_list_to_display type i. callback_program like sy-repid.Structure for key information types: begin of slis_keyinfo_alv. header02 type slis_fieldname. info type slis_entry. end of slis_sel_hide_alv. end of slis_listheader.Structure for event handling types: begin of slis_alv_event. . types: slis_t_specialcol_alv type slis_specialcol_alv occurs 1. " H = Header. nokeycol(1) type c. *--. flg_to_be_refreshed. types end of slis_selentry_hide_alv. *--. counter_of_lists_added type i. * delete or add an entry in the select-option info types: begin of slis_sel_hide_alv. without_load_variant(1). item04 type slis_fieldname. item05 type slis_fieldname. types: slis_t_selentry_hide_alv type slis_selentry_hide_alv occurs 1. header05 type slis_fieldname. 39 . item02 type slis_fieldname. callback_pf_status_set type slis_formname. callback_header_transport type slis_formname. columnopt(1). *--.Structure for specific color settings types: begin of slis_specialcol_alv. mode(1) type c.* delete or add an entry in the select-option info types: begin of slis_selentry_hide_alv. end of slis_specialcol_alv. header01 type slis_fieldname. types: slis_t_event type slis_alv_event occurs 0. item03 type slis_fieldname. form(30). header04 type slis_fieldname. it_excluding type slis_t_extab.Structure for callback CALLER_EXIT and REUSE_ALV_POPUP_TO_SELECT types: begin of slis_data_caller_exit. callback_user_command type slis_formname. typ(1) type c.

slis_ev_foreign_top_of_page type slis_formname value 'FOREIGN_TOP_OF_PAGE'. slis_ev_after_line_output type slis_formname value 'AFTER_LINE_OUTPUT'. constants: * Events slis_ev_item_data_expand type slis_formname value 'ITEM_DATA_EXPAND'. slis_ev_list_modify type slis_formname value 'LIST_MODIFY'. flg_intcheck(1) type c. slis_ev_subtotal_text type slis_formname value 'SUBTOTAL_TEXT'. 40 . slis_ev_user_command type slis_formname value 'USER_COMMAND'. slis_ev_end_of_page type slis_formname value 'END_OF_PAGE'. slis_ev_data_changed type slis_formname value 'DATA_CHANGED'. slis_ev_reprep_sel_modify type slis_formname value 'REPREP_SEL_MODIFY'. end of slis_status.print type slis_print_alv. slis_ev_foreign_end_of_page type slis_formname value 'FOREIGN_END_OF_PAGE'. flg_checkboxes_active. slis_ev_end_of_list type slis_formname value 'END_OF_LIST'. . cancel(1) type c. exit(1) type c. slis_ev_end_of_coverpage type slis_formname value 'END_OF_COVERPAGE'. slis_ev_before_line_output type slis_formname value 'BEFORE_LINE_OUTPUT'. end of slis_exit_by_user. slis_ev_top_of_coverpage type slis_formname value 'TOP_OF_COVERPAGE'. slis_ev_pf_status_set type slis_formname value 'PF_STATUS_SET'. * Exporting structure types: begin of slis_exit_by_user. flg_overview_active. slis_ev_top_of_list type slis_formname value 'TOP_OF_LIST'. slis_ev_top_of_page type slis_formname value 'TOP_OF_PAGE'. slis_ev_caller_exit_at_start type slis_formname value 'CALLER_EXIT'. back(1) type c.

(1 = on. kunum LIKE viqmel-kunum. zzvalstat LIKE viqmel-zzvalstat. p_i_layout-zebra = 'X'. qmart LIKE viqmel-qmart. Include a 4-character field in the internal data table that is being passed to REUSE_ALV_GRID_DISPLAY. 2. loop through the lines of the internal table and assign values to this field. (1 = on. which can be any value from (1 – 7). Char 4 (z) – Inverse display on/off. valstattxt LIKE zawprcode-valstattxt. IF (expression 1). i_data-ws_color = ‘C510’. . it is clear that we can have only 28 different coloring options) Eg: C401.Appendix B How to colour lines of a report 1. qmnum LIKE viqmel-qmnum. 0 = off). Char 3 (y) – Intensity on/off. MODIFY i_data. 3. END OF i_data. p_i_layout-colwidth_optimize = 'X'.Cxyz. FORM f1200_define_layout CHANGING p_i_layout TYPE slis_layout_alv. Char 2 (x) – color code. ws_color(4)TYPE c. When specifying the layout properties. ENDLOOP. LOOP AT i_data. ELSE. ELSEIF(expression 2). i_data-ws_color = ‘C200’. Eg: DATA: BEGIN OF i_data OCCURS 10. CLEAR p_i_layout. qmtxt LIKE viqmel-qmtxt. (From the above. ENDIF. Char 1 – is always C indicating that it’s a color property. bstnk LIKE viqmel-bstnk. 41 . The 4character value will be of the format . i_data-ws_color = ‘C711’. In the code. 0 = off). specify the name of this field (ws_color) as the color field.

ELSEIF cnt = 12. i_data-ws_color = 'C310'. . 42 . i_data-ws_color = 'C110'. elseIF cnt = 8. i_data-ws_color = 'C710'. i_data-ws_color = 'C100'. ELSEIF cnt = 13. IF cnt = 1. i_data-ws_color = 'C610'. ELSEIF cnt = 11. ELSEIF cnt = 5. i_data-ws_color = 'C200'. " F1200_define_layout Example: Shown below is screen dump with 14 coloring options. ELSEIF cnt = 9. ENDFORM. ELSEIF cnt = 6. ELSEIF cnt = 10 i_data-ws_color = 'C300'. ENDIF. i_data-ws_color = 'C400'. i_data-ws_color = 'C600'. ELSEIF cnt = 14. ENDLOOP. ELSEIF cnt = 2. ELSEIF cnt = 3. MODIFY i_data. You could try out the rest 14!! Code: LOOP AT i_data. ELSEIF cnt = 4. i_data-ws_color = 'C410'. i_data-ws_color = 'C700'. i_data-ws_color = 'C510'. i_data-ws_color = 'C210'. ELSEIF cnt = 7. i_data-ws_color = 'C500'. cnt = cnt + 1.p_i_layout-info_fieldname = 'WS_COLOR'.

. 43 .

Sign up to vote on this title
UsefulNot useful