Posted: Sun Sep 02, 2007 4:38 am Post subject: 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.
Quote:
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.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.