Definition and a Program on
ALV
Give definition and a Program on ALV. I would say that ALV is a tool that you can use in ABAP to display data in a grid - you just call a function doing it, pass the data to it and the function itself produces a nice report with many functions (like sort by, filtler etc.) I attach a demo program, which is perfectly prepared that you change the columns to contain what you want. There is also another way of doing the same, using the objects. REPORT z_pj_test_reuse . * A demo program for the function REUSE_ALV_LIST_DISPLAY * Types that we need TYPE-POOLS slis. TYPES: BEGIN OF ts_my_item, * This structure represents a line of our table * You can change this structure in any way you want, * but do not forget : you must then modify the form show_alv_grid * to show also the new components of this structure m_element1 TYPE char30, m_element2 TYPE num5, * If there is an element in this structure for which you do not * insert the statement "ls_fieldcat-fieldname = ..." * then the element will not be displayed, for example this one: m_element_not_displayed TYPE char32, END OF ts_my_item. TYPES : t_tab_my_item TYPE TABLE OF ts_my_item. * After you run the program, this will be executed: PERFORM main. *---------------------------------------------------------------------* * FORM main * *---------------------------------------------------------------------* * Main program *---------------------------------------------------------------------* FORM main. DATA lt_items TYPE t_tab_my_item. PERFORM fill_test_data USING lt_items. PERFORM show_alv_grid USING lt_items. ENDFORM. *---------------------------------------------------------------------* * FORM fill_test_data * *---------------------------------------------------------------------* * ........ * *---------------------------------------------------------------------* * --> LT_ITEMS * *---------------------------------------------------------------------* FORM fill_test_data CHANGING lt_items TYPE t_tab_my_item. * Here the structure will be filled with demo data * In reality, the structure will have different components * (those which you need) * And will be filled with real data DATA ls_line TYPE LINE OF t_tab_my_item. CLEAR lt_items. * First line of ALV grid ls_line-m_element1 = 'Some data'. ls_line-m_element2 = '4444'. ls_line-m_element_not_displayed = 'This will not be displayed'. APPEND ls_line TO lt_items. * second line ls_line-m_element1 = 'Some other data'. ls_line-m_element2 = '4445'. APPEND ls_line TO lt_items. * third line ls_line-m_element1 = 'More data'. APPEND ls_line TO lt_items. ENDFORM. ************************************************************** * FORM show_alv_grid * FORM show_alv_grid CHANGING tab_output TYPE t_tab_my_item. DATA: it_fieldcat TYPE slis_t_fieldcat_alv, gt_events TYPE slis_t_event, repid LIKE sy-repid, ls_fieldcat TYPE slis_fieldcat_alv, it_layout TYPE slis_layout_alv. """""""""""""""""""""""""""""""" " ls_fieldcat ls_fieldcat-tabname = 'IT_DENIK'. " Interní tabulka ls_fieldcat-ref_tabname = 'EKKO'. " Pùvodní tabulka. * The following three lines must be here for each element * that we want to display * The fieldname must be in capital letters ls_fieldcat-fieldname = 'M_ELEMENT1'. ls_fieldcat-reptext_ddic = 'Title of 1st column'. APPEND ls_fieldcat TO it_fieldcat. ls_fieldcat-fieldname = 'M_ELEMENT2'. ls_fieldcat-reptext_ddic = 'Title of 2nd column'. APPEND ls_fieldcat TO it_fieldcat. * I purpochasely ommited the element m_element_not_displayed * Therefore it will not be displayed """""""""""""""""""""""""""""""" " it_layout * There is a lot of code which I do not understand * You can write some strings there and watch where on the screen * they will appear. CLEAR it_layout. it_layout-detail_popup = ' '. it_layout-detail_titlebar = ' '."Detail of the window (?) it_layout-info_fieldname = ' '. it_layout-header_text = 'Our title'. it_layout-no_colhead = ' '. "'X' cancels headlines of columns it_layout-no_hotspot = ' '. "'X' = cannot select a column it_layout-window_titlebar = it_layout-header_text. it_layout-list_append = ' '. it_layout-item_text = ' '. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " call REUSE_ALV_LIST_DISPLAY repid = sy-repid. CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY' EXPORTING i_callback_program = repid it_fieldcat = it_fieldcat it_events = gt_events[] is_layout = it_layout TABLES t_outtab = tab_output. ENDFORM.-- Pavel Jelinek
More Function Module
Tables
ABAP Books List
Smart Forms
ABAP Menu:
Return to Index:-
(c) www.gotothings.com All material on this site is Copyright.
|