SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Definition and a Program on ALV

Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message

Joined: 01 Sep 2007
Posts: 1639

PostPosted: Sun Sep 02, 2007 4:38 am    Post subject: Definition and a Program on ALV Reply with quote

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

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:

* 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.

* 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.


* 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 = ' '.


repid = sy-repid.
i_callback_program = repid
it_fieldcat = it_fieldcat
it_events = gt_events[]
is_layout = it_layout
t_outtab = tab_output.

-- Pavel Jelinek

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List All times are GMT + 4 Hours
Page 1 of 1

Jump to:  
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.