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 module

Former Member
0 Likes
910

Can u give detail description on FM

1.REUSE_ALV_BLOCK_LIST_INIT

2.REUSE_ALV_BLOCK_LIST_APPEND

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
809
<b>First one is for GUI STATUS.</b>
second one is to append the reports to list..after appending you can call the list display fm
  V_REPID = SY-REPID.
* Set Default GUI status
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      I_CALLBACK_PROGRAM = V_REPID.

*- To display quantity not in SAP

  IF NOT IT_FINAL1[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                  = X_LAYOUT
        IT_FIELDCAT                = IT_FIELDCAT
        I_TABNAME                  = 'IT_FINAL1'
        IT_EVENTS                  = IT_EVENTS2
      TABLES
        T_OUTTAB                   = IT_FINAL1
      EXCEPTIONS
        PROGRAM_ERROR              = 1
        MAXIMUM_OF_APPENDS_REACHED = 2
        OTHERS                     = 3.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).
    ENDIF.

  ENDIF.
*- To display records with total = 0 in ZLEGACY_INV_COST
  IF NOT IT_TOTAL[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                  = X_LAYOUT
        IT_FIELDCAT                = IT_FIELDCAT
        I_TABNAME                  = 'IT_TOTAL'
        IT_EVENTS                  = IT_EVENTS1
      TABLES
        T_OUTTAB                   = IT_TOTAL
      EXCEPTIONS
        PROGRAM_ERROR              = 1
        MAXIMUM_OF_APPENDS_REACHED = 2
        OTHERS                     = 3.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).

    ENDIF.

  ENDIF.

  IF NOT IT_FINAL1[] IS INITIAL OR NOT IT_TOTAL[] IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
      EXCEPTIONS
        PROGRAM_ERROR = 1
        OTHERS        = 2.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_DISPLAY'(003).
    ENDIF.
  ENDIF.
7 REPLIES 7
Read only

Former Member
0 Likes
809

Hi,

Take a look at program BALVBT01. You will understand.

Basically INIT fm is to set callbacks for Block lists and APPEND fm is to actually append a list to Block..

Block lists are a technique for combining display of two or more ALV lists with different structures.

So general flow is,

1. Call to INIT fm to set callbacks

2. Prepare your data and call APPEND fm for the first ALV list

3. Prepare your data and call APPEND fm for the second ALV list

4. .... APPEND (if necessary)

5. .... APPEND (if necessary)

6. .... APPEND (if necessary)

7. Call to REUSE_ALV_BLOCK_LIST_DISPLAY fm to finally display all the ALV lists together..

Hope this helps..

Sri

Message was edited by: Srikanth Pinnamaneni

Message was edited by: Srikanth Pinnamaneni

Read only

Former Member
0 Likes
810
<b>First one is for GUI STATUS.</b>
second one is to append the reports to list..after appending you can call the list display fm
  V_REPID = SY-REPID.
* Set Default GUI status
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      I_CALLBACK_PROGRAM = V_REPID.

*- To display quantity not in SAP

  IF NOT IT_FINAL1[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                  = X_LAYOUT
        IT_FIELDCAT                = IT_FIELDCAT
        I_TABNAME                  = 'IT_FINAL1'
        IT_EVENTS                  = IT_EVENTS2
      TABLES
        T_OUTTAB                   = IT_FINAL1
      EXCEPTIONS
        PROGRAM_ERROR              = 1
        MAXIMUM_OF_APPENDS_REACHED = 2
        OTHERS                     = 3.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).
    ENDIF.

  ENDIF.
*- To display records with total = 0 in ZLEGACY_INV_COST
  IF NOT IT_TOTAL[] IS INITIAL.

    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
      EXPORTING
        IS_LAYOUT                  = X_LAYOUT
        IT_FIELDCAT                = IT_FIELDCAT
        I_TABNAME                  = 'IT_TOTAL'
        IT_EVENTS                  = IT_EVENTS1
      TABLES
        T_OUTTAB                   = IT_TOTAL
      EXCEPTIONS
        PROGRAM_ERROR              = 1
        MAXIMUM_OF_APPENDS_REACHED = 2
        OTHERS                     = 3.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_APPEND'(002).

    ENDIF.

  ENDIF.

  IF NOT IT_FINAL1[] IS INITIAL OR NOT IT_TOTAL[] IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
      EXCEPTIONS
        PROGRAM_ERROR = 1
        OTHERS        = 2.
    IF SY-SUBRC <> 0.
      MESSAGE I002 WITH 'Error in REUSE_ALV_BLOCK_LIST_DISPLAY'(003).
    ENDIF.
  ENDIF.
Read only

Former Member
0 Likes
809

Hi, i am sending you a complete pogram..just run it to have an idea..

plz reward point if it helps you..

REPORT zanid_test MESSAGE-ID zz.

*

----


  • Declarations for BLOCK ALV DISPLAY

----


*--type pools

TYPE-POOLS:slis.

DATA:x_layout TYPE slis_layout_alv,

t_field TYPE slis_t_fieldcat_alv,

*--field catalog

x_fldcat LIKE LINE OF t_field,

*--to hold all the events

t_events TYPE slis_t_event,

x_events TYPE slis_alv_event,

t_sort TYPE slis_t_sortinfo_alv,

x_sort LIKE LINE OF t_sort ,

*--Print Layout

x_print_layout TYPE slis_print_alv.

*----Macro to add field catalog.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

DEFINE add_catalog.

clear x_fldcat.

x_fldcat-fieldname = &1.

x_fldcat-seltext_m = &2.

x_fldcat-outputlen = &3.

x_fldcat-tech = &4.

x_fldcat-col_pos = &5.

x_fldcat-no_zero = 'X'.

x_fldcat-ddictxt = 'M'.

x_fldcat-datatype = &6.

x_fldcat-ddic_outputlen = &7.

if &6 = 'N'.

x_fldcat-lzero = 'X'.

endif.

*--build field catalog

append x_fldcat to t_field.

END-OF-DEFINITION.

*----- data declerations.

data: v_repid like sy-repid.

data: begin of itab occurs 0,

matnr like mara-matnr,

ernam like mara-ernam,

meins like mara-meins,

end of itab.

data: begin of jtab occurs 0,

matnr like makt-matnr,

maktx like makt-maktx,

end of jtab.

select matnr ernam meins

up to 20 rows

from mara

into table itab.

select matnr maktx

up to 20 rows

from makt

into table jtab.

v_repid = sy-repid.

*DISPLAY alv

  • Initialize Block

call function 'REUSE_ALV_BLOCK_LIST_INIT'

exporting

i_callback_program = v_repid.

*Block 1:

*INITIALIZE

refresh t_field. clear t_field.

refresh t_events.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

add_catalog:

'MATNR' 'Material' '18' '' '1' 'C' '18',

'ERNAM' 'Created By' '12' '' '2' 'C' '12',

'MEINS' 'Unit' '5' '' '3' 'C' '3'.

*--build table for events.

x_events-form = 'TOP_OF_LIST1'.

x_events-name = slis_ev_top_of_list.

append x_events to t_events.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = x_layout

it_fieldcat = t_field

i_tabname = 'ITAB'

it_events = t_events

it_sort = t_sort

tables

t_outtab = itab

exceptions

program_error = 1

maximum_of_appends_reached = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

*--BLOCK 2(SUMMARY REPORT)

*INITIALIZE

refresh t_field. clear t_field.

refresh t_events.

*field "text "length "tech "COL_POS "DATATYPE "DDIC_OUTPUTLEN

add_catalog:

'MATNR' 'Material' '20' '' '1' 'C' '18',

'MAKTX' 'Description' '40' '' '2' 'C' '40'.

*--build table for events.

x_events-form = 'TOP_OF_LIST2'.

x_events-name = slis_ev_top_of_list.

append x_events to t_events.

  • Append table block.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'

exporting

is_layout = x_layout

it_fieldcat = t_field

i_tabname = 'JTAB'

it_events = t_events

tables

t_outtab = jtab

exceptions

program_error = 1

maximum_of_appends_reached = 2

others = 3.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

endif.

*--CALL FM TO DISPLAY THE BLOCK REPORT.

call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'

  • exporting

  • is_print = x_print_layout

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.

form top_of_list1.

skip 1.

write: 10 'List 1',

/5 '----


'.

skip 1.

format reset.

endform.

form top_of_list2.

skip 1.

write: 10 'List 2',

/5 '----


'.

skip 1.

format reset.

endform.

Read only

Former Member
0 Likes
809

Hi Jayasree,

I hope you Understand what for the FMs are used..

Plese close the thread if your problem solves..

regards

vijay

Read only

Former Member
0 Likes
809

Hi Jayshree,

Function module REUSE_ALV_BLOCK_LIST_INIT is used for:

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

Function module REUSE_ALV_BLOCK_LIST_APPEND is used for:

This function module adds the data to the block.

Regards,

Siddarth

Read only

Former Member
0 Likes
809

Hi,

REUSE_ALV_BLOCK_INIT function module is used to set the default GUI status.

REUSE_ALV_BLOCK_LIST_INIT

Parameters:

a. I_CALLBACK_PROGRAM

b. I_CALLBACK_PF_STATUS_SET

c. I_CALLBACK_USER_COMMAND

REUSE_ALV_BLOCK_LIST_APPEND function module is used to adds the data to the block.

REUSE_ALV_BLOCK_LIST_APPEND

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.

Read only

Former Member
0 Likes
809

Friends ,

Is there any limitation here to append as I am getting error after I append 21st list, this is in standard program RV13KNAA

Regards

Prashant.