You are on page 1of 3

-1https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/HYPERLINK+in+ALV https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/SUBTOTAL+in+ALV https://www.sdn.sap.com/irj/scn/wiki?path=/display/ABAP/SORT+in+ALV https://www.sdn.sap.com/irj/scn/wiki?

path=/display/ABAP/OPTIONS+OF+LAYOUT+IN+ALV

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING i_interface_check = 'X' i_callback_program = sy-cprog i_callback_pf_status_set = 'SET_PF_STATUS' -> perform name i_callback_user_command = 'USER_COMMAND' -> perform name i_grid_title = lc_title is_layout = lc_layout it_fieldcat = it_fieldcat[] i_save = 'A' -> Allow save the layouts is_variant = gb_variant TABLES t_outtab = it_result EXCEPTIONS program_error = 1 OTHERS = 2.

FORM user_command USING p_ucomm TYPE syucomm is_selfield TYPE slis_selfield.

*Delete records of the Internal table and is_selfield-refresh = 'X'. -> Refresh

ENDFORM. "user_command

*First field of the ALV is a box DATA: BEGIN OF st_fieldcat, box, -> first field of internal must be "box" . . end of st_fieldcat. lc_layout-box_fieldname = 'BOX'.

*Build the fieldcat in runtime

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE' EXPORTING i_program_name = sy-repid i_internal_tabname = 'ST_FIELDCAT' -> Must be declared in Global program i_inclname = sy-repid i_bypassing_buffer = 'X' CHANGING ct_fieldcat = it_fieldcat EXCEPTIONS inconsistent_interface = 1 program_error = 2 OTHERS = 3.

FORM set_pf_status USING rt_extab TYPE slis_t_extab. DATA: wa_status TYPE slis_extab. IF ra_del IS INITIAL. MOVE: 'DEL' TO wa_status-fcode. APPEND wa_status TO rt_extab. ENDIF.

SET PF-STATUS 'STATUS' OF PROGRAM sy-cprog EXCLUDING rt_extab. ENDFORM. "set_pf_status

ALV

-2-

1) What is ALV programming in ABAP? When is this grid used in ABAP? ALV is Application List viewer. Sap provides a set of ALV (ABAP LIST VIEWER) function modules which can be put into use to embellish the output of a report. This set of ALV functions is used to enhance the readability and functionality of any report output. Cases arise in sap when the output of a report contains columns extending more than 255 characters in length. In such cases, this set of ALV functions can help choose selected columns and arrange the different columns from a report output and also save different variants for report display. This is a very efficient tool for dynamically sorting and arranging the columns from a report output. The report output can contain up to 90 columns in the display with the wide array of display options. The commonly used ALV functions used for this purpose are; 1. REUSE_ALV_VARIANT_DEFAULT_GET 2. REUSE_ALV_VARIANT_F4 3. REUSE_ALV_VARIANT_EXISTENCE 4. REUSE_ALV_EVENTS_GET 5. REUSE_ALV_COMMENTARY_WRITE 6. REUSE_ALV_FIELDCATALOG_MERGE 7. REUSE_ALV_LIST_DISPLAY 8. REUSE_ALV_GRID_DISPLAY 9. REUSE_ALV_POPUP_TO_SELECT 2)How you call this function in your report? After completion of all the data fetching from the database and append this data into an Internal Table. say I_ITAB. Then use follwing function module. CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING I_CALLBACK_PROGRAM = 'Prog.name' I_STRUCTURE_NAME = 'I_ITAB' I_DEFAULT = 'X' I_SAVE = 'A' TABLES T_OUTTAB = I_ITAB. IF SY-SUBRC <> 0. WRITE: 'SY-SUBRC: ', SY-SUBRC . ENDIF. ENDFORM. " GET_FINAL_DATA 3) Upload Logo for REUSE_ALV_COMMENTARY_WRITE For those who wish to upload and use a picture in your ALV abap reports. Steps for uploading Logo :-: 1. Goto the transaction OAER 2. Enter the class name as 'PICTURES' 3. Enter the class type as 'OT' 4. Enter the object key as the name of the logo you wish to give 5. Execute 6. Then in the new screen select Standard doc. types in bottom window Click on the Screen icon Now, it will ask for the file path where you have to upload the logo 7. Now you can use this logo in REUSE_ALV_COMMENTARY_WRITE or Import Logo and Background Picture for Reporting In this step, you can import a customer-specific logo and a background picture into the R/3 System. These will be displayed in the header area of reports in HR Funds and Position Management. From the SPRO:

-3-

HR Funds and Position Management -> Dialog Control --> Customize Reporting Interface -> Import Logo and Background Picture for Reporting. Activities 1. Enter the Name of your logo/background picture as an object key in the initial screen. 2. Make sure that the class name is PICTURES, and the class type is OT. 3. Choose Execute. 4. Double-click the document type Picture on the Create tab page. A dialog box will appear in which you can enter the path in which the logo/background picture can be found. 5. Enter the path and choose Open. The logo will be uploaded into the current R/3 System. If the logo/background picture is to be transported into other systems as well, choose Transport. 6. Return to the initial screen and repeat the procedure after having entered the Name of your background picture as an object key. Please note that the logo/background picture can only be displayed in ALV-based reports with an HTML header. Manually programmed reports such as business distribution plans are not based on the ALV. If you have selected several initial objects, ALV-based reports in HR Funds and Position Management will automatically use a hiearchical-sequential display. A logo is not displayed here either. Note also that the logo cannot be printed (see print preview in program). Make sure that the logo does not exceed a height of 100 pixels because it would mean that the header of the report will be scrollable. 4) How can I insert my company logo in the standard report? It is not possible to print logo in the ordinary report, but it can be done through ALV. Write the code in Top-of-page event in ALV. The following is the code for inserting the logo in ALV. FORM TOP_OF_PAGE. CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE' EXPORTING I_LOGO = 'ENJOYSAP_LOGO' IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE. 5) How to Refresh ALV List/Grid once it is displayed? This mean to say that if you have a 'refresh' push button in your gui status, every time you press the button, the list should get refreshed. In ALV, to refresh the table you have to call the method "refresh_table_display". It has the syntax very similar to creating the table. It has two parameters. In the first one, you can mention if you want to refresh only the data (the icons are not refreshed) or if you want to refresh only the icons around the grid (the data is not refreshed - this option is mostly not used in day to day applications). the synatx is :call method grid (name of grid )->refresh_table_display exporting IS_STABLE = <STRUCT OF TYPE LVC_S_STBL> (THIS IS FOR DATA REFRESHING) I_SOFT_REFRESH = <VARIABLE OF CHAR 01> (THIS IS FOR ICON REFRESHING).

You might also like