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

Function Modules

Former Member
0 Likes
765

hi! all

can anybody explain what does the following Function Module dose.

1. REUSE_ALV_FIELDCATALOG_MERGE

2. REUSE_ALV_BLOCK_LIST_APPEND

3. REUSE_ALV_BLOCK_LIST_DISPLAY

what are the parameters to be passed to the Function Module REUSE_ALV_BLOCK_LIST_DISPLAY .

4 REPLIES 4
Read only

prasanth_kasturi
Active Contributor
0 Likes
669

hi,

REUSE_ALV_FIELDCATALOG_MERGE

you can get the fieldcat of the structure or table you used directly from DDIC. your internal table structure must be same as that of ddic structure

2. REUSE_ALV_BLOCK_LIST_APPEND

in blocked alv you use this function module. its used to append all the tables which are to be displayed on the o/p. it Appends Simple List in Block Mode

3. REUSE_ALV_BLOCK_LIST_DISPLAY

its used to dispaly the o/p of report in normal list format

No need to pass any parameters

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

EXCEPTIONS

program_error = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

reward if helpful

prasanth

Read only

Former Member
0 Likes
669

Hai

Classical Report

A classic report is a program that generates a single list, which must contain all of the required detail information.

1) This procedure may result in extensive lists from which the user has to pick the relevant data.

2) For background processing, this is the only possible method. After starting a background job, there is no way of influencing the program.

3) The desired selections must be made beforehand and the list must provide detailed information.

4) For dialog sessions, there are no such restrictions.

5) The user is present during the execution of the program and can control and manipulate the program flow directly.

6) To be able to use all advantages of the online environment, classical reporting was developed into interactive reporting.

ALV

ABAP List Viewer

The common features of report are column alignment, sorting, filtering, subtotals, totals etc. To implement these, a lot of coding and logic is to be put. To avoid that we can use a concept called ABAP List Viewer (ALV).

This helps us to implement all the features mentioned very effectively.

Using ALV, We can have three types of reports:

1. Simple Report

2. Block Report

3. Hierarchical Sequential Report

There are some function modules which will enable to produce the above reports without much effort.

All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS.

1. SIMPLE REPORT.

The important function modules are

a. Reuse_alv_list_display

b. Reuse_alv_fieldcatalog_merge

c. Reuse_alv_events_get

d. Reuse_alv_commentary_write

e. Reuse_alv_grid_display

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

The important parameters are :

I. Export :

i. I_callback_program : report id

ii. I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing pf status

iii. I_callback_user_command : routine where the function codes are handled

iv. I_structure name : name of the dictionary table

v. Is_layout : structure to set the layout of the report

vi. It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be populated automatically by the function module

vii. It_events : internal table with a list of all possible events of ALV and their corresponding form names.

II. Tables :

i. t_outtab : internal table with the data to be output

B. REUSE_ALV_FIELDCATALOG_MERGE : This function module is used to populate a fieldcatalog which is essential to display the data in ALV. If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as a parameter(I_structure name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

The Important Parameters are :

I. Export :

i. I_program_name : report id

ii. I_internal_tabname : the internal output table

iii. I_inclname : include the report name where all the dynamic forms are handled.

II Changing

ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is

declared in the type pool SLIS.

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

Parameters :

I. Import :

Et_Events : The event table is returned with all possible CALLBACK events

for the specified list type (column 'NAME'). For events to be processed by Callback, their 'FORM' field must be filled. If the field is initialized, the event is ignored. The entry can be read from the event table, the field 'FORM' filled and the entry modified using constants from the type pool SALV.

II. Export :

I_List_type :

0 = simple list REUSE_ALV_LIST_DISPLAY

1 = hierarchcal-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

3 = hierarchical-sequential block list

REUSE_ALV_BLOCK_LIST_HS_APPEND

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

Parameters :

I. it_list_commentary : internal table with the headings of the type slis_t_listheader.

This internal table has three fields :

Typ : u2018Hu2019 u2013 header, u2018Su2019 u2013 selection , u2018Au2019 - action

Key : only when typ is u2018Su2019.

Info : the text to be printed

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

Parameters : same as reuse_alv_list_display

This is an example for simple list.

2. BLOCK REPORT

This is used to have multiple lists continuously.

The important functions used in this report are:

A. REUSE_ALV_BLOCK_LIST_INIT

B. REUSE_ALV_BLOCK_LIST_APPEND

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

D. REUSE_ALV_BLOCK_LIST_DISPLAY

A. REUSE_ALV_BLOCK_LIST_INIT

Parameters:

I. I_CALLBACK_PROGRAM

II. I_CALLBACK_PF_STATUS_SET

III. I_CALLBACK_USER_COMMAND

This function module is used to set the default gui status etc.

B. REUSE_ALV_BLOCK_LIST_APPEND

Parameters :

Export :

I. is_layout : layout settings for block

II. it_fieldcat : field catalog

III. i_tabname : internal table name with output data

IV. it_events : internal table with all possible events

Tables :

i. t_outtab : internal table with output data.

This function module adds the data to the block.

Repeat this function for all the different blocks to be displayed one after the other.

C. REUSE_ALV_BLOCK_LIST_HS_APPEND

This function module is used for hierarchical sequential blocks.

D. REUSE_ALV_BLOCK_LIST_DISPLAY

Parameters : All the parameters are optional.

This function module display the list with data appended by the above function.

Here the functions REUSE_ALV_FIELDCATALOG_MERGE, REUSE_ALV_EVENTS_GET, REUSE_ALV_COMMENTARY_WRITE can be used.

3. Hierarchical reports :

Hierarchical sequential list output.

The function module is

A. REUSE_ALV_HIERSEQ_LIST_DISPLAY

Parameters:

I. Export:

i. I_CALLBACK_PROGRAM

ii. I_CALLBACK_PF_STATUS_SET

iii. I_CALLBACK_USER_COMMAND

iv. IS_LAYOUT

v. IT_FIELDCAT

vi. IT_EVENTS

vii. i_tabname_header : Name of the internal table in the program containing the

output data of the highest hierarchy level.

viii. i_tabname_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

ix. is_keyinfo : This structure contains the header and item table field

names which link the two tables (shared key).

II. Tables

i. t_outtab_header : Header table with data to be output

ii. t_outtab_item : Name of the internal table in the program containing the

output data of the lowest hierarchy level.

slis_t_fieldcat_alv : This internal table contains the field attributes. This internal table can be populated automatically by using u2018REUSE_ALV_FIELDCATALOG_MERGEu2019.

Important Attributes :

A. col_pos : position of the column

B. fieldname : internal fieldname

C. tabname : internal table name

D. ref_fieldname : fieldname (dictionary)

E. ref_tabname : table (dictionary)

F. key(1) : column with key-color

G. icon(1) : icon

H. symbol(1) : symbol

I. checkbox(1) : checkbox

J. just(1) : (R)ight (L)eft (C)ent.

K. do_sum(1) : sum up

L. no_out(1) : (O)blig.(X)no out

M. outputlen : output length

N. seltext_l : long key word

O. seltext_m : middle key word

P. seltext_s : short key word

Q. reptext_ddic : heading (ddic)

R. ddictxt(1) : (S)hort (M)iddle (L)ong

S. datatype : datatype

T. hotspot(1) : hotspot

ALV provides following benefits over Classical report:

1. You can sort, Cut, Copy, Paste the output data

2. Option to play around with the data

3. You can filter the data as per your requirement

4. You can do totaling or sub-totaling

5. You can reduce the number of columns which you want in output

6. You can download the output to excel or html or text file

7. You can have editable ALV & edit & save records

8. Data output is in tabular format --> User friendly output

Go to SE38 transaction

Type BCALV* and click F4

A list of all standard sample SAP ALV programs would be displayed.

6. REUSE_ALV_BLOCK_LIST_INIT: - (This module is used for the initialization of blocks & called first before calling REUSE_ALV_BLOCK_LIST_APPEND or REUSE_ALV_BLOCK_LIST_HS_APPEND)

IMPORTING

VALUE(I_CALLBACK_PROGRAM) LIKE SY-REPID

VALUE(I_CALLBACK_PF_STATUS_SET) TYPE SLIS_FORMNAME

DEFAULT SPACE

VALUE(I_CALLBACK_USER_COMMAND) TYPE SLIS_FORMNAME

DEFAULT SPACE

VALUE(IT_EXCLUDING) TYPE SLIS_T_EXTAB OPTIONAL

I_CALLBACK_PROGRAM: -

Same as in REUSE_ALV_LIST_DISPLAY

I_CALLBACK_PF_STATUS_SET: -

Same as in REUSE_ALV_LIST_DISPLAY

I_CALLBACK_USER_COMMAND: -

Same as in REUSE_ALV_LIST_DISPLAY

IT_EXCLUDING: -

Same as in REUSE_ALV_LIST_DISPLAY

7.REUSE_ALV_BLOCK_LIST_APPEND: -(this behaves same as REUSE_ALV_LIST_DISPLAY)

IMPORTING

VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV

VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV

VALUE(I_TABNAME) TYPE SLIS_TABNAME

VALUE(IT_EVENTS) TYPE SLIS_T_EVENT

VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL

VALUE(I_TEXT) TYPE SLIS_TEXT40 DEFAULT SPACE

TABLES

T_OUTTAB

EXCEPTIONS

PROGRAM_ERROR

MAXIMUM_OF_APPENDS_REACHED

IS_LAYOUT: -

Same as in REUSE_ALV_LIST_DISPLAY

IT_FIELDCAT: -

Same as in REUSE_ALV_LIST_DISPLAY

I_TABNAME: -

IT_EVENTS: -

Same as in REUSE_ALV_LIST_DISPLAY

IT_SORT: -

Same as in REUSE_ALV_LIST_DISPLAY

I_TEXT: -

T_OUTTAB: -

Same as in REUSE_ALV_LIST_DISPLAY

8.REUSE_ALV_BLOCK_LIST_HS_APPEND: -(this behaves same as REUSE_ALV_HIERSEQ_LIST_DISPLAY)

IMPORTING

VALUE(IS_LAYOUT) TYPE SLIS_LAYOUT_ALV

VALUE(IT_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV

VALUE(IS_KEYINFO) TYPE SLIS_KEYINFO_ALV

VALUE(I_HEADER_TABNAME) TYPE SLIS_TABNAME

VALUE(I_ITEM_TABNAME) TYPE SLIS_TABNAME

VALUE(IT_EVENTS) TYPE SLIS_T_EVENT

VALUE(IT_SORT) TYPE SLIS_T_SORTINFO_ALV OPTIONAL

VALUE(I_TEXT) TYPE SLIS_TEXT40 DEFAULT SPACE

TABLES

T_OUTTAB_HEADER

T_OUTTAB_ITEM

EXCEPTIONS

PROGRAM_ERROR

IS_LAYOUT: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

IT_FIELDCAT: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

IS_KEYINFO: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

I_HEADER_TABNAME: -

Same as I_TABNAME_HEADER in REUSE_ALV_HIERSEQ_LIST_DISPLAY

I_ITEM_TABNAME: -

Same as I_TABNAME_ITEM in REUSE_ALV_HIERSEQ_LIST_DISPLAY

IT_EVENTS: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

IT_SORT: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

I_TEXT: -

T_OUTTAB_HEADER: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

T_OUTTAB_ITEM: -

Same as in REUSE_ALV_HIERSEQ_LIST_DISPLAY

9. REUSE_ALV_BLOCK_LIST_DISPLAY: - (This module is called display blocks after appending then.)

IMPORTING

VALUE(I_INTERFACE_CHECK) DEFAULT SPACE

VALUE(IS_PRINT) TYPE SLIS_PRINT_ALV OPTIONAL

VALUE(I_SCREEN_START_COLUMN) DEFAULT 0

VALUE(I_SCREEN_START_LINE) DEFAULT 0

VALUE(I_SCREEN_END_COLUMN) DEFAULT 0

VALUE(I_SCREEN_END_LINE) DEFAULT 0

EXPORTING

VALUE(E_EXIT_CAUSED_BY_CALLER)

VALUE(ES_EXIT_CAUSED_BY_USER) TYPE SLIS_EXIT_BY_USER

EXCEPTIONS

PROGRAM_ERROR

I_INTERFACE_CHECK: -

Same as in REUSE_ALV_LIST_DISPLAY

IS_PRINT: -

Same as in REUSE_ALV_LIST_DISPLAY

I_SCREEN_START_COLUMN: -

Same as in REUSE_ALV_LIST_DISPLAY

I_SCREEN_START_LINE: -

Same as in REUSE_ALV_LIST_DISPLAY

I_SCREEN_END_COLUMN: -

Same as in REUSE_ALV_LIST_DISPLAY

I_SCREEN_END_LINE: -

Same as in REUSE_ALV_LIST_DISPLAY

E_EXIT_CAUSED_BY_CALLER: -

Same as in REUSE_ALV_LIST_DISPLAY

ES_EXIT_CAUSED_BY_USER: -

Same as in REUSE_ALV_LIST_DISPLAY

10.REUSE_ALV_LIST_LAYOUT_INFO_GET: - (this module is used to read current ALV list information)

XPORTING

VALUE(ES_LAYOUT) TYPE SLIS_LAYOUT_ALV

VALUE(ET_FIELDCAT) TYPE SLIS_T_FIELDCAT_ALV

VALUE(ET_SORT) TYPE SLIS_T_SORTINFO_ALV

VALUE(ET_FILTER) TYPE SLIS_T_FILTER_ALV

VALUE(ES_LIST_SCROLL) TYPE SLIS_LIST_SCROLL

VALUE(ES_VARIANT) LIKE DISVARIANT

STRUCTURE DISVARIANT

XCEPTIONS

NO_INFOS

PROGRAM_ERROR

ES_LAYOUT: -

Same as IT_LAYOUT in REUSE_ALV_LIST_DISPLAY

ET_FIELDCAT: -

Same as IT_FIELDCAT in REUSE_ALV_LIST_DISPLAY

ET_SORT: -

Same as IT_SORT in REUSE_ALV_LIST_DISPLAY

ET_FILTER: -

Same as IT_FILTER in REUSE_ALV_LIST_DISPLAY

ES_LIST_SCROLL: -

Structure with fields which describe the current list scroll status:

o lsind

See the documentation of the system field SY-LSIND

o cpage

See the documentation of the system field SY-CPAGE

o staro

See the documentation of the system field SY-STARO

o cursor_line

Current cursor row position in the list (not in the internal output

Table)

o cursor_offset

current cursor column position in the list (not in the internal output table)

ES_VARIANT: -

Same as IS_VARIANT in REUSE_ALV_LIST_DISPLAY

thanks

sitaram

Read only

Former Member
0 Likes
669

hi,

REUSE_ALV_FIELDCATALOG_MERGE:

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

If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create the field catalog. Its enough to mention the table name as parameter (I_structure_name) in the REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

REUSE_ALV_BLOCK_LIST_APPEND:Some of the important parameters are

Export :

a. IS_LAYOUT : layout settings for block

b. IT_FIELDCAT : field catalog

c. I_TABNAME : Internal table name of the output data

d. IT_EVENTS : internal table name with all possible events

Tables :

a. T_OUTTAB : internal table with output data.

This function module adds the data to the block

REUSE_ALV_BLOCK_LIST_DISPLAY : All the parameters are optional.

This function module display the list with data appended by the above function.

Read only

Former Member
0 Likes
669

Hi,

No parametes are required(Not mandatory) to pass into the FM 'REUSE_ALV_BLOCK_LIST_DISPLAY'.

you can comment all the parametes.

But in the FM REUSE_ALV_BLOCK_LIST_APPEND you need to fill the different tabnames and fieldcat names that you want to display in different blocks.

Please reward if helpful......