Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV Function modules

Former Member
0 Likes
883

Hi All,

Could any body please explain me in detail the use of all ALV function modules and parameters required for those FM's.

If possible send me some example program consists of all FM's.

Thanks in advance,

Rakesh.

5 REPLIES 5
Read only

Former Member
0 Likes
775

hi,,

please check this fallowing program it contains some fm of alv.

&----


*& Report ZVEN_2ALVLISTS

*&

&----


*&

*&

&----


REPORT zven_2alvlists.

TYPE-POOLS:slis.

*internal table for purchase header.

DATA:BEGIN OF it_ekko OCCURS 0,

ebeln TYPE ekko-ebeln, "puchase document no

bukrs TYPE ekko-bukrs, "company code

bstyp TYPE ekko-bstyp, "puchase document category

bsart TYPE ekko-bsart, "Purchasing Document Type

bsakz TYPE ekko-bsakz, "Control indicator for purchasing document type

END OF it_ekko.

*internal table for purchase item

DATA:BEGIN OF it_ekpo OCCURS 0,

ebeln TYPE ekpo-ebeln, "Purchasing Document Numbe

loekz TYPE ekpo-loekz, "Deletion indicator in purchasing document

statu TYPE ekpo-statu, "RFQ status

aedat TYPE ekpo-aedat, "Purchasing document item change date

txz01 TYPE ekpo-txz01, "Short text

matnr TYPE ekpo-matnr, "Material Number

ematn TYPE ekpo-ematn, "Material number

END OF it_ekpo.

DATA:it_fcat1 TYPE slis_t_fieldcat_alv WITH HEADER LINE,

it_fcat2 TYPE slis_t_fieldcat_alv WITH HEADER LINE,

it_event1 TYPE slis_t_event,

it_event2 TYPE slis_t_event,

wa_event TYPE slis_alv_event,

it_layout TYPE slis_layout_alv.

*start-of-selection.

START-OF-SELECTION.

PERFORM get_data_ekko.

PERFORM get_data_ekpo.

PERFORM build_fieldcat_for_ekko_ekpo.

PERFORM layout_list.

PERFORM build_events.

PERFORM build_evnts_ekpo.

PERFORM display_two_lists.

&----


*& Form get_data_ekko

&----


  • text

FORM get_data_ekko .

SELECT ebeln

bukrs

bstyp

bsart

bsakz FROM ekko

INTO TABLE it_ekko

UP TO 15 ROWS.

IF sy-subrc = 0.

SORT it_ekko BY ebeln.

ENDIF.

ENDFORM. " get_data_ekko

&----


*& Form get_data_ekpo

&----


  • text

FORM get_data_ekpo .

SELECT ebeln

loekz

statu

aedat

txz01

matnr

ematn FROM ekpo

INTO TABLE it_ekpo

UP TO 10 ROWS.

IF sy-subrc = 0.

SORT it_ekpo BY ebeln.

ENDIF.

ENDFORM. " get_data_ekpo

&----


*& Form build_fieldcat_for_ekko_ekpo

&----


  • text

FORM build_fieldcat_for_ekko_ekpo .

CLEAR it_fcat1.

it_fcat1-fieldname = 'EBELN'.

it_fcat1-col_pos = '1'.

it_fcat1-tabname = 'EKKO'.

it_fcat1-seltext_l = 'puchase document no'.

APPEND it_fcat1.

CLEAR it_fcat1.

it_fcat1-fieldname = 'BUKRS'.

it_fcat1-col_pos = '2'.

it_fcat1-tabname = 'EKKO'.

it_fcat1-seltext_l = 'company code'.

APPEND it_fcat1.

CLEAR it_fcat1.

it_fcat1-fieldname = 'BSTYP'.

it_fcat1-col_pos = '3'.

it_fcat1-seltext_l = 'puchase document category'.

it_fcat1-tabname = 'EKKO'.

APPEND it_fcat1.

CLEAR it_fcat1.

it_fcat1-fieldname = 'BSART'.

it_fcat1-col_pos = '4'.

it_fcat1-tabname = 'EKKO'.

it_fcat1-seltext_l = 'Purchasing Document Type'.

APPEND it_fcat1.

CLEAR it_fcat1.

it_fcat1-fieldname = 'BSAKZ'.

it_fcat1-col_pos = '5'.

it_fcat1-tabname = 'EKKO'.

it_fcat1-seltext_l = 'Control indicator for pd type'.

APPEND it_fcat1.

CLEAR it_fcat1.

*FOR EKPO

CLEAR it_fcat2.

it_fcat2-fieldname = 'EBELN'.

it_fcat2-col_pos = '1'.

it_fcat2-seltext_l = 'puchase document no'.

it_fcat2-tabname = 'EKPO'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'LOEKZ'.

it_fcat2-col_pos = '2'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'Deletion indicator in pd'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'STATU'.

it_fcat2-col_pos = '3'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'RFQ status'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'AEDAT'.

it_fcat2-col_pos = '4'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'Purchasing document icd'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'TXZ01'.

it_fcat2-col_pos = '5'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'Short text'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'MATNR'.

it_fcat2-col_pos = '6'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'material no'.

APPEND it_fcat2.

CLEAR it_fcat2.

it_fcat2-fieldname = 'EMATN'.

it_fcat2-col_pos = '7'.

it_fcat2-tabname = 'EKPO'.

it_fcat2-seltext_l = 'material no'.

APPEND it_fcat2.

CLEAR it_fcat2.

ENDFORM. " build_fieldcat_for_ekko_ekpo

&----


*& Form build_events

&----


  • text

FORM build_events .

CLEAR wa_event.

wa_event-name = slis_ev_top_of_page.

wa_event-form = 'TOP_OF_PAGE-EKKO'.

APPEND wa_event TO it_event1.

CLEAR wa_event.

wa_event-name = slis_ev_end_of_list.

wa_event-form = 'END_OF_LIST-EKKO'.

APPEND wa_event TO it_event1.

ENDFORM. " build_events

&----


*& Form TOP_OF_PAGE-EKKO

&----


  • text

----


FORM TOP_OF_PAGE-EKKO.

WRITE:/ 'TOP OF PAGE:PURCHASE ORDER HEADER'.

ENDFORM. "TOP_OF_PAGE-EKKO

&----


*& Form END_OF_PAGE-EKKO

&----


  • text

----


FORM end_of_list-ekko.

WRITE:/ 'END OF PAGE:PURCHASE ORDER HEADER'.

ENDFORM. "END_OF_PAGE-EKKO

&----


*& Form display_two_lists

&----


  • text

FORM display_two_lists .

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

EXPORTING

i_callback_program = sy-repid.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = it_layout

it_fieldcat = it_fcat1[]

i_tabname = 'EKKO'

it_events = it_event1

  • IT_SORT = IT_SORT

  • I_TEXT = ' '

TABLES

t_outtab = it_ekko

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • MAXIMUM_OF_APPENDS_REACHED = 2

  • OTHERS = 3

.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

EXPORTING

is_layout = it_layout

it_fieldcat = it_fcat2[]

i_tabname = 'EKPO'

it_events = it_event2

TABLES

t_outtab = it_ekpo

EXCEPTIONS

program_error = 1

maximum_of_appends_reached = 2

OTHERS = 3.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

ENDFORM. " display_two_lists

&----


*& Form layout_list

&----


  • text

FORM layout_list .

it_layout-zebra = 'X'.

ENDFORM. " layout_list

&----


*& Form build_evnts_ekpo

&----


  • text

FORM build_evnts_ekpo .

CLEAR wa_event.

wa_event-name = slis_ev_top_of_page.

wa_event-form = 'TOP_OF_LIST-EKPO'.

APPEND wa_event TO it_event2.

CLEAR wa_event.

wa_event-name = slis_ev_end_of_list.

wa_event-form = 'END_OF_PAGE-EKPO'.

APPEND wa_event TO it_event2.

ENDFORM. " build_evnts_ekpo

&----


*& Form top_of_page-ekpo

&----


  • text

----


FORM top_of_list-ekpo.

WRITE:/ 'top-of-page:puchase document items'.

ENDFORM. "top_of_page-ekpo

&----


*& Form end_of_page-ekpo

&----


  • text

----


FORM end_of_page-ekpo.

WRITE:/ 'end-of-page:Puchase document item'.

ENDFORM. "end_of_page-ekpo

Read only

former_member156446
Active Contributor
0 Likes
775

Read only

Former Member
0 Likes
775

Hi,

pls find the below list of ALV function modules.

ACC_REUSE_ALV_LIST_DISPLAY

REUSE_ALV_BLOCK_LIST_APPEND

REUSE_ALV_BLOCK_LIST_DATA_GET

REUSE_ALV_BLOCK_LIST_DATA_SET

REUSE_ALV_BLOCK_LIST_DISPLAY

REUSE_ALV_BLOCK_LIST_HS_APPEND

REUSE_ALV_BLOCK_LIST_INIT

REUSE_ALV_BLOCK_LIST_REFRESH

REUSE_ALV_BLOCK_STATUS_GET

REUSE_ALV_CHECKBOX_SET

REUSE_ALV_COMMENTARY_WRITE

REUSE_ALV_EVENTS_GET

REUSE_ALV_EVENTS_TRANSFER

REUSE_ALV_EVENT_NAMES_GET

REUSE_ALV_FIELDCATALOG_MERGE

REUSE_ALV_HIERSEQ_LIST_DISPLAY

REUSE_ALV_HS_LIST_WIDTH_GET

REUSE_ALV_HS_TABLES_GET

REUSE_ALV_LIST_DISPLAY

REUSE_ALV_LIST_LAYOUT_INFO_GET

REUSE_ALV_LIST_LAYOUT_INFO_SET

REUSE_ALV_LIST_WIDTH_GET

REUSE_ALV_POPUP_TO_SELECT

REUSE_ALV_TABLES_GET

REUSE_ALV_TABLE_CREATE

REUSE_ALV_TEXTPOOL_WRITE

REUSE_ALV_TRANSFER_DATA

REUSE_ALV_TRANSFER_DATA_BACK

REUSE_ALV_VARIANT_ALL_MAINTAIN

REUSE_ALV_VARIANT_DEFAULT_GET

REUSE_ALV_VARIANT_EXISTENCE

REUSE_ALV_VARIANT_F4

REUSE_ALV_VARIANT_MAINTAIN

REUSE_ALV_VARIANT_SAVE

REUSE_ALV_VARIANT_SELECT

REUSE_MINIALV_LIST_DISPLAY

CALL_REUSE_ALV_SAVE_EXTRACT

REUSE_ALV_EXTRACT_AT_F4_P_EX1

REUSE_ALV_EXTRACT_AT_F4_P_EX2

REUSE_ALV_EXTRACT_AT_INIT

REUSE_ALV_EXTRACT_AT_SELSCREEN

REUSE_ALV_EXTRACT_DELETE

REUSE_ALV_EXTRACT_EXISTENCE

REUSE_ALV_EXTRACT_F4

REUSE_ALV_EXTRACT_LOAD

REUSE_ALV_EXTRACT_SAVE

REUSE_ALV_EXTRACT_SAVE_LEVELS

REUSE_ALV_GRID_COMMENTARY_SET

REUSE_ALV_GRID_DISPLAY

REUSE_ALV_GRID_DISPLAY_LVC

REUSE_ALV_GRID_LAYOUT_INFO_GET

REUSE_ALV_GRID_LAYOUT_INFO_SET

SLVC_SERVICES_2

REUSE_DOUBLE_ALV

basically you can display report the reports in 5 ways using ALV's

1) List display

2) Grid display

3) Blocked ALV

4) Hirerarchy display

5) Tree ALV-----this we can achieve by using OOPs.

the below are the major ALV fm we use

REUSE_ALV_LIST_DISPLAY

EUSE_ALV_GRID_DISPLAY

REUSE_ALV_BLOCK_LIST_DISPLAY

REUSE_ALV_HIERSEQ_LIST_DISPLAY

do one thing go to SE37 type any of this FM name and press CTRLSHIFTF3, whcih will give you the list of programs which are using this FM, take a look into that programs, in this way you can easily get the examples of all the function modules.

Reward if useful.

Regards,

Sreeram.

Read only

Former Member
0 Likes
775

Dear Rakesh,

Function modules used in ABAP List Viewer are listed as below:

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

The commonly used Function Modules and their explanations are:

A. REUSE_ALV_LIST_DISPLAY: This is the function module which prints the data.

B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV.

C . REUSE_ALV_EVENTS_GET: Returns table of possible events for a a list type

D. REUSE_ALV_COMMENTARY_WRITE : This is used in the Top-of-page event to print the headings and other comments for the list.

E. REUSE_ALV_GRID_DISPLAY: A new function in 4.6 version, to display the results in grid rather than as a list.

For a program you can refer to the link given below.

[ALV Grid Programming|http://www.abap4.it/download/ALV.pdf]

[Use of Function Modules for ALV|sap.niraj.tripod.com/id66.html]

Best Regards,

Rajesh

Please reward points if found helpful.

Read only

Former Member
0 Likes
775

You would wnat to use: REUSE_ALV_GRID_DISPLAY

You dont' have to populate everything. Just the following is fine. But you do need to setup field catelog, events, sort catelog if you use it. itab_rpt is where you pass in your table for display. The field name will have to match the field name you set in the field catelog

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = rpt_id

  • i_callback_pf_status_set = 'SET_PF_STATUS'

i_callback_user_command = '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 = grid_title

  • I_GRID_SETTINGS =

  • is_layout =

it_fieldcat = fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • it_sort = sortcat

  • IT_FILTER =

  • IS_SEL_HIDE =

  • i_default =

i_save = 'A'

  • is_variant = default_variant

  • it_events = eventcat

it_event_exit = event_exit

is_print = print_info

  • 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 =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = itab_rpt

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2