<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: ALV LIST DISPLAY (Combining two function module) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583985#M862892</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use Block ALV for solving your purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples for this type of Reports...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

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 = &amp;amp;1.

x_fldcat-seltext_m = &amp;amp;2.

x_fldcat-outputlen = &amp;amp;3.

x_fldcat-tech = &amp;amp;4.

x_fldcat-col_pos = &amp;amp;5.

x_fldcat-no_zero = 'X'.

x_fldcat-ddictxt = 'M'.

x_fldcat-datatype = &amp;amp;6.

x_fldcat-ddic_outputlen = &amp;amp;7.

if &amp;amp;6 = 'N'.

x_fldcat-lzero = 'X'.

endif.

*--build field catalog

append x_fldcat to t_field.

END-OF-DEFINITION.


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.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zfieldcatalog .

type-pools: slis.

data : w_fcat1 type slis_fieldcat_alv,
w_fcat2 type slis_fieldcat_alv,
w_fcat3 type slis_fieldcat_alv,
w_events type slis_alv_event,
flayout type slis_layout_alv.

data : t_fcat1 type slis_t_fieldcat_alv,
t_fcat2 type slis_t_fieldcat_alv,
t_fcat3 type slis_t_fieldcat_alv,
t_kna1 type kna1 occurs 1,
t_vbak type vbak occurs 1,
t_vbap type vbap occurs 1,

t_events1 type slis_t_event,
t_events2 type slis_t_event,
t_events3 type slis_t_event.

w_events-name ='TOP-OF-PAGE'.
w_events-form ='TOP1'.
append w_events to t_events1.

w_events-name ='TOP-OF-PAGE'.
w_events-form = 'TOP2'.
append w_events to t_events2.

w_events-name = 'TOP-OF-PAGE'.
w_events-form = 'TOP3'.
append w_events to t_events3.

select * from kna1 into table t_kna1 up to 5 rows.
select * from vbak into table t_vbak up to 5 rows.
select * from vbap into table t_vbap up to 5 rows.

perform top1.
perform top2.
perform top3.
perform get_data.

call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = sy-repid

    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * IT_EXCLUDING =

.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat1
i_tabname = 't_kna1'
it_events = t_events1

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_kna1

    * 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 function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat2
i_tabname = 't_vbak'
it_events = t_events2

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_vbak

    * 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 function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat3
i_tabname = 't_vbap'
it_events = t_events3

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_vbap.

    * 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 function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
*exporting

    * I_INTERFACE_CHECK = ' '
    * IS_PRINT =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    * 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.

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top1
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top1.
write: / 'customer information list'.
endform. "top1

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top2
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top2.
write:/ 'sales order information list'.
endform. "top2

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top3
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top3.
write:/ 'sales item list'.
endform. "top3

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form get_data
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form get_data.

w_fcat1-col_pos = 1.
w_fcat1-fieldname = 'kunnr'.
w_fcat1-seltext_m = 'customer number'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat1-col_pos = 2.
w_fcat1-fieldname = 'name1'.
w_fcat1-seltext_m = 'customer name'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat1-col_pos = 3.
w_fcat1-fieldname = 'land1'.
w_fcat1-seltext_m = 'country'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat2-col_pos = 1.
w_fcat2-fieldname = 'vbeln'.
w_fcat2-seltext_m = 'order number'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat2-col_pos = 2.
w_fcat2-fieldname = 'erdat'.
w_fcat2-seltext_m = 'order date'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat2-col_pos = 3.
w_fcat2-fieldname = 'netwr'.
w_fcat2-seltext_m = 'order value'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat3-col_pos = 1.
w_fcat3-fieldname = 'posnr'.
w_fcat3-seltext_m = 'order item '.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

w_fcat3-col_pos = 2.
w_fcat3-fieldname = 'arktx'.
w_fcat3-seltext_m = 'item description'.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

w_fcat3-col_pos = 3.
w_fcat3-fieldname = 'werks'.
w_fcat3-seltext_m = 'plant'.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

endform. "get_data

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="42680"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the example program - BALVBT01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="420111"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="404197"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dhruv Shah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Mar 2008 05:43:36 GMT</pubDate>
    <dc:creator>dhruv_shah3</dc:creator>
    <dc:date>2008-03-25T05:43:36Z</dc:date>
    <item>
      <title>ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583983#M862890</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I have a problem with using function module 'REUSE_ALV_LIST_DISPLAY'. i have two different structures to be used to display output based on condition for each. instead of using the function module twice how can i use single function module for both the structures. i have used as below other parameters in the function modules are same only the structure is different.here 'gt_vendor_cc' and 'gt_vendor' are my two structures.please suggest.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT p_bukrs IS INITIAL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt; EXPORTING&lt;/P&gt;&lt;P&gt;   I_CALLBACK_PROGRAM        = g_repid&lt;/P&gt;&lt;P&gt;   IT_FIELDCAT                          = lt_fcat&lt;/P&gt;&lt;P&gt;   I_SAVE                                  = 'A'&lt;/P&gt;&lt;P&gt;   IS_VARIANT                           = ls_vari&lt;/P&gt;&lt;P&gt;   IT_EVENTS                            = lt_evts&lt;/P&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    T_OUTTAB                            = gt_vendor_cc.&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt; EXPORTING&lt;/P&gt;&lt;P&gt;   I_CALLBACK_PROGRAM             = g_repid&lt;/P&gt;&lt;P&gt;   IT_FIELDCAT                               = lt_fcat&lt;/P&gt;&lt;P&gt;   I_SAVE                                       = 'A'&lt;/P&gt;&lt;P&gt;   IS_VARIANT                                = ls_vari&lt;/P&gt;&lt;P&gt;   IT_EVENTS                                 = lt_evts&lt;/P&gt;&lt;P&gt;  TABLES&lt;/P&gt;&lt;P&gt;    T_OUTTAB                                  = gt_vendor       .&lt;/P&gt;&lt;P&gt;IF SY-SUBRC &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:35:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583983#M862890</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:35:04Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583984#M862891</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Make use  FM REUSE_ALV_BLOCK_LIST_APPEND'&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See example Program .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BALVBT01.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Balakumar.G&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Reward Points if helpful.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:41:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583984#M862891</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583985#M862892</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use Block ALV for solving your purpose.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Examples for this type of Reports...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

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 = &amp;amp;1.

x_fldcat-seltext_m = &amp;amp;2.

x_fldcat-outputlen = &amp;amp;3.

x_fldcat-tech = &amp;amp;4.

x_fldcat-col_pos = &amp;amp;5.

x_fldcat-no_zero = 'X'.

x_fldcat-ddictxt = 'M'.

x_fldcat-datatype = &amp;amp;6.

x_fldcat-ddic_outputlen = &amp;amp;7.

if &amp;amp;6 = 'N'.

x_fldcat-lzero = 'X'.

endif.

*--build field catalog

append x_fldcat to t_field.

END-OF-DEFINITION.


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.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

report zfieldcatalog .

type-pools: slis.

data : w_fcat1 type slis_fieldcat_alv,
w_fcat2 type slis_fieldcat_alv,
w_fcat3 type slis_fieldcat_alv,
w_events type slis_alv_event,
flayout type slis_layout_alv.

data : t_fcat1 type slis_t_fieldcat_alv,
t_fcat2 type slis_t_fieldcat_alv,
t_fcat3 type slis_t_fieldcat_alv,
t_kna1 type kna1 occurs 1,
t_vbak type vbak occurs 1,
t_vbap type vbap occurs 1,

t_events1 type slis_t_event,
t_events2 type slis_t_event,
t_events3 type slis_t_event.

w_events-name ='TOP-OF-PAGE'.
w_events-form ='TOP1'.
append w_events to t_events1.

w_events-name ='TOP-OF-PAGE'.
w_events-form = 'TOP2'.
append w_events to t_events2.

w_events-name = 'TOP-OF-PAGE'.
w_events-form = 'TOP3'.
append w_events to t_events3.

select * from kna1 into table t_kna1 up to 5 rows.
select * from vbak into table t_vbak up to 5 rows.
select * from vbap into table t_vbap up to 5 rows.

perform top1.
perform top2.
perform top3.
perform get_data.

call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = sy-repid

    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * IT_EXCLUDING =

.

call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat1
i_tabname = 't_kna1'
it_events = t_events1

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_kna1

    * 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 function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat2
i_tabname = 't_vbak'
it_events = t_events2

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_vbak

    * 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 function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = flayout
it_fieldcat = t_fcat3
i_tabname = 't_vbap'
it_events = t_events3

    * IT_SORT =
    * I_TEXT = ' '

tables
t_outtab = t_vbap.

    * 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 function 'REUSE_ALV_BLOCK_LIST_DISPLAY'
*exporting

    * I_INTERFACE_CHECK = ' '
    * IS_PRINT =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    * 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.

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top1
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top1.
write: / 'customer information list'.
endform. "top1

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top2
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top2.
write:/ 'sales order information list'.
endform. "top2

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form top3
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form top3.
write:/ 'sales item list'.
endform. "top3

&amp;amp;--------------------------------------------------------------------
*&amp;amp; Form get_data
&amp;amp;--------------------------------------------------------------------

    * text

---------------------------------------------------------------------
form get_data.

w_fcat1-col_pos = 1.
w_fcat1-fieldname = 'kunnr'.
w_fcat1-seltext_m = 'customer number'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat1-col_pos = 2.
w_fcat1-fieldname = 'name1'.
w_fcat1-seltext_m = 'customer name'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat1-col_pos = 3.
w_fcat1-fieldname = 'land1'.
w_fcat1-seltext_m = 'country'.
w_fcat1-tabname = 't_kna1'.
append w_fcat1 to t_fcat1.

w_fcat2-col_pos = 1.
w_fcat2-fieldname = 'vbeln'.
w_fcat2-seltext_m = 'order number'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat2-col_pos = 2.
w_fcat2-fieldname = 'erdat'.
w_fcat2-seltext_m = 'order date'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat2-col_pos = 3.
w_fcat2-fieldname = 'netwr'.
w_fcat2-seltext_m = 'order value'.
w_fcat2-tabname = 't_vbak'.
append w_fcat2 to t_fcat2.

w_fcat3-col_pos = 1.
w_fcat3-fieldname = 'posnr'.
w_fcat3-seltext_m = 'order item '.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

w_fcat3-col_pos = 2.
w_fcat3-fieldname = 'arktx'.
w_fcat3-seltext_m = 'item description'.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

w_fcat3-col_pos = 3.
w_fcat3-fieldname = 'werks'.
w_fcat3-seltext_m = 'plant'.
w_fcat3-tabname = 't_vbap'.
append w_fcat3 to t_fcat3.

endform. "get_data

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="42680"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;See the example program - BALVBT01&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="420111"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[&lt;A class="jive_macro jive_macro_thread" href="https://community.sap.com/" __jive_macro_name="thread" modifiedtitle="true" __default_attr="404197"&gt;&lt;/A&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;HTH&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dhruv Shah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:43:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583985#M862892</guid>
      <dc:creator>dhruv_shah3</dc:creator>
      <dc:date>2008-03-25T05:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583986#M862893</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Abinash,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just call the ALV twice itself as you have coded.Y u want to change it.This is the most straight forward way of doing their requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks Arjun&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:43:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583986#M862893</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:43:53Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583987#M862894</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;call the function module only once and place all the data in one internal table, while creating the catalog check the condition.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
  IF NOT p_mat IS INITIAL.
    perform write_fcat using 'MATNR' 'ITAB' 'VBAP' c_n 'Material' c_n c_n.
    perform write_fcat using 'KUNNR' 'ITAB' 'VBAP' c_n 'Sold-To' c_n c_n.
    perform write_fcat using 'NAME1' 'ITAB' 'KNA1' c_n 'Desc' c_n c_n.
  ELSEIF NOT p_cst IS INITIAL.
    perform write_fcat using 'KUNNR' 'ITAB' 'VBAP' c_n 'Sold-To' c_n c_n.
    perform write_fcat using 'NAME1' 'ITAB' 'KNA1' c_n 'Desc' c_n c_n.
    perform write_fcat using 'MATNR' 'ITAB' 'VBAP' c_n 'Material' c_n c_n.
  ENDIF.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rgds,&lt;/P&gt;&lt;P&gt;bharat.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:45:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583987#M862894</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583988#M862895</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hai.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;check this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://www.saptechnical.com/index.html" target="test_blank"&gt;http://www.saptechnical.com/index.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;REPORT z_alv_list_block.&lt;/P&gt;&lt;P&gt;TYPE-POOLS: slis. " ALV Global types&lt;/P&gt;&lt;P&gt;SELECTION-SCREEN :&lt;/P&gt;&lt;P&gt;SKIP,&lt;/P&gt;&lt;P&gt;BEGIN OF LINE,&lt;/P&gt;&lt;P&gt;COMMENT 5(27) v_1 FOR FIELD p_max. &lt;/P&gt;&lt;P&gt;PARAMETERS p_max(2) TYPE n DEFAULT '02' OBLIGATORY.&lt;/P&gt;&lt;P&gt;SELECTION-SCREEN END OF LINE.&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;1st Table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;BEGIN OF gt_kna1 OCCURS 0, " Data displayed&lt;/P&gt;&lt;P&gt;kunnr LIKE kna1-kunnr, " Customer number&lt;/P&gt;&lt;P&gt;ernam LIKE kna1-ernam, " Name of Person who Created&lt;/P&gt;&lt;P&gt;erdat LIKE kna1-erdat, " Creation date&lt;/P&gt;&lt;P&gt;name1 LIKE kna1-name1, " Name 1&lt;/P&gt;&lt;P&gt;END OF gt_kna1,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;2nd Table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;BEGIN OF gt_mara OCCURS 0,&lt;/P&gt;&lt;P&gt;ernam LIKE mara-ernam, " Name of Person who Created&lt;/P&gt;&lt;P&gt;matnr LIKE mara-matnr, " Material number&lt;/P&gt;&lt;P&gt;ersda LIKE mara-e rsda, " Creation date&lt;/P&gt;&lt;P&gt;brgew LIKE mara-brgew, " Gross weight&lt;/P&gt;&lt;P&gt;END OF gt_mara,&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;3rd Table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;BEGIN OF gt_vbak OCCURS 0,&lt;/P&gt;&lt;P&gt;vkorg LIKE vbak-vkorg, " Sales organization&lt;/P&gt;&lt;P&gt;kunnr LIKE vbak-kunnr, " Sold-to party&lt;/P&gt;&lt;P&gt;vbeln LIKE vbak-vbeln, " Sales document&lt;/P&gt;&lt;P&gt;netwr LIKE vbak-netwr, " Net Value of the Sales Order&lt;/P&gt;&lt;P&gt;waerk LIKE vbak-waerk, " SD document currency&lt;/P&gt;&lt;P&gt;END OF gt_vbak.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INITIALIZATION.&lt;/P&gt;&lt;P&gt;v_1 = 'Maximum of records to read'.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;START-OF-SELECTION.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Read data&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SELECT * FROM kna1&lt;/P&gt;&lt;P&gt;UP TO p_max ROWS&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE gt_kna1.&lt;/P&gt;&lt;P&gt;SELECT * FROM mara&lt;/P&gt;&lt;P&gt;UP TO p_max ROWS&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE gt_mara.&lt;/P&gt;&lt;P&gt;SELECT * FROM vbak&lt;/P&gt;&lt;P&gt;UP TO p_max ROWS&lt;/P&gt;&lt;P&gt;INTO CORRESPONDING FIELDS OF TABLE gt_vbak.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_callback_program = sy-cprog&lt;/P&gt;&lt;P&gt;i_callback_user_command = 'USER_COMMAND'.&lt;/P&gt;&lt;P&gt;PERFORM list_append TABLES gt_kna1&lt;/P&gt;&lt;P&gt;USING '1'&lt;/P&gt;&lt;P&gt;'GT_KNA1'.&lt;/P&gt;&lt;P&gt;PERFORM list_append TABLES gt_mara&lt;/P&gt;&lt;P&gt;USING '2'&lt;/P&gt;&lt;P&gt;'GT_MARA'.&lt;/P&gt;&lt;P&gt;PERFORM list_append TABLES gt_vbak&lt;/P&gt;&lt;P&gt;USING '3'&lt;/P&gt;&lt;P&gt;'GT_VBAK'.&lt;/P&gt;&lt;P&gt;PERFORM f_list_display.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FORM USER_COMMAND *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM user_command USING i_ucomm LIKE sy-ucomm&lt;/P&gt;&lt;P&gt;is_selfield TYPE slis_selfield. "#EC CALLED&lt;/P&gt;&lt;P&gt;CASE i_ucomm.&lt;/P&gt;&lt;P&gt;WHEN '&amp;amp;IC1'. " Pick&lt;/P&gt;&lt;P&gt;CASE is_selfield-tabname.&lt;/P&gt;&lt;P&gt;WHEN 'GT_MARA'.&lt;/P&gt;&lt;P&gt;WHEN 'GT_KNA1'.&lt;/P&gt;&lt;P&gt;WHEN 'GT_VBAK'.&lt;/P&gt;&lt;P&gt;READ TABLE gt_vbak INDEX is_selfield-tabindex.&lt;/P&gt;&lt;P&gt;IF sy-subrc EQ 0.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Sales order number&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;SET PARAMETER ID 'AUN' FIELD gt_vbak-vbeln.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Display Sales Order&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;ENDFORM. " USER_COMMAND&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&amp;lt; /div&amp;gt; &lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Form list_append&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM list_append TABLES ut_table&lt;/P&gt;&lt;P&gt;USING u_no TYPE char1&lt;/P&gt;&lt;P&gt;u_tabname TYPE slis_tabname.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Macro definition&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;DEFINE m_fieldcat.&lt;/P&gt;&lt;P&gt;ls_fieldcat-fieldname = &amp;amp;1.&lt;/P&gt;&lt;P&gt;ls_fieldcat-ref_tabname = &amp;amp;2.&lt;/P&gt;&lt;P&gt;append ls_fieldcat to lt_fieldcat.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;DEFINE m_sort.&lt;/P&gt;&lt;P&gt;ls_sort-fieldname = &amp;amp;1.&lt;/P&gt;&lt;P&gt;ls_sort-up = 'X'.&lt;/P&gt;&lt;P&gt;append ls_sort to lt_sort.&lt;/P&gt;&lt;P&gt;END-OF-DEFINITION.&lt;/P&gt;&lt;P&gt;DATA :&lt;/P&gt;&lt;P&gt;ls_fieldcat TYPE slis_fieldcat_alv,&lt;/P&gt;&lt;P&gt;lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog&lt;/P&gt;&lt;P&gt;ls_sort TYPE slis_sortinfo_alv,&lt;/P&gt;&lt;P&gt;lt_sort TYPE slis_t_sortinfo_alv. " Sort table&lt;/P&gt;&lt;P&gt;DATA:&lt;/P&gt;&lt;P&gt;lt_events TYPE slis_t_event,&lt;/P&gt;&lt;P&gt;ls_event TYPE slis_alv_event,&lt;/P&gt;&lt;P&gt;ls_layout TYPE slis_layout_alv.&lt;/P&gt;&lt;P&gt;ls_layout-group_change_edit = 'X'.&lt;/P&gt;&lt;P&gt;ls_layout-colwidth_optimize = 'X'.&lt;/P&gt;&lt;P&gt;ls_layout-zebra = 'X'.&lt;/P&gt;&lt;P&gt;ls_layout-detail_popup = 'X'.&lt;/P&gt;&lt;P&gt;ls_layout-get_selinfos = 'X'.&lt;/P&gt;&lt;P&gt;ls_layout-max_linesize = '200'.&lt;/P&gt;&lt;P&gt;CASE u_no.&lt;/P&gt;&lt;P&gt;WHEN '1'.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Build field catalog and sort table&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;m_fieldcat 'KUNNR' 'KNA1'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'ERNAM' 'KNA1'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'ERDAT' 'KNA1'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'NAME1' 'KNA1'.&lt;/P&gt;&lt;P&gt;m_sort 'KUNNR'.&lt;/P&gt;&lt;P&gt;WHEN '2'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'MATNR' 'MARA'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'ERNAM' 'MARA'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'ERSDA' 'MARA'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'BRGEW' 'MARA'.&lt;/P&gt;&lt;P&gt;m_sort 'MATNR'.&lt;/P&gt;&lt;P&gt;WHEN '3'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'VBELN' 'VBAK'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'VKORG' 'VBAK'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'KUNNR' 'VBAK'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'NETWR' 'VBAK'.&lt;/P&gt;&lt;P&gt;m_fieldcat 'WAERK' 'VBAK'.&lt;/P&gt;&lt;P&gt;m_sort 'VBELN'.&lt;/P&gt;&lt;P&gt;ENDCASE.&lt;/P&gt;&lt;P&gt;IF u_no CA '13'.&lt;/P&gt;&lt;P&gt;MOVE 'TOP_OF_PAGE' TO ls_event-name.&lt;/P&gt;&lt;P&gt;CONCATENATE 'TOP_OF_PAGE' u_no INTO ls_event-form.&lt;/P&gt;&lt;P&gt;APPEND ls_event TO lt_events.&lt;/P&gt;&lt;P&gt;ELSE.&lt;/P&gt;&lt;P&gt;MOVE 'TOP_OF_LIST' TO ls_event-name.&lt;/P&gt;&lt;P&gt;CONCATENATE 'TOP_OF_LIST' u_no INTO ls_event-form.&lt;/P&gt;&lt;P&gt;APPEND ls_event TO lt_events.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;it_fieldcat = lt_fieldcat&lt;/P&gt;&lt;P&gt;is_layout = ls_layout&lt;/P&gt;&lt;P&gt;i_tabname = u_tabname&lt;/P&gt;&lt;P&gt;it_events = lt_events&lt;/P&gt;&lt;P&gt;it_sort = lt_sort&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;i_text =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;t_outtab = ut_table&lt;/P&gt;&lt;P&gt;EXCEPTIONS&lt;/P&gt;&lt;P&gt;program_error = 1&lt;/P&gt;&lt;P&gt;maximum_of_appends_reached = 2&lt;/P&gt;&lt;P&gt;OTHERS = 3.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM. " LIST_APPEND&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;Form f_list_display&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM f_list_display.&lt;/P&gt;&lt;P&gt;DATA ls_print TYPE slis_print_alv.&lt;/P&gt;&lt;P&gt;ls_print-no_print_selinfos = 'X'. " Display no selection infos&lt;/P&gt;&lt;P&gt;ls_print-no_print_listinfos = 'X'. " Display no listinfos&lt;/P&gt;&lt;P&gt;ls_print-reserve_lines = 2. " Lines reserved for end of page&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;i_interface_check = ' '&lt;/P&gt;&lt;P&gt;is_print = ls_print&lt;/P&gt;&lt;P&gt;EXCEPTIONS &lt;/P&gt;&lt;P&gt;program_error = 1&lt;/P&gt;&lt;P&gt;OTHERS = 2.&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno&lt;/P&gt;&lt;P&gt;WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDFORM. " F_LIST_DISPLAY&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FORM top_of_page1 *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM top_of_page1. "#EC CALLED&lt;/P&gt;&lt;P&gt;PERFORM top_of_page.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FORM top_of_page3 *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM top_of_page3. "#EC CALLED&lt;/P&gt;&lt;P&gt;PERFORM top_of_page.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FORM top_of_page *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM top_of_page.&lt;/P&gt;&lt;P&gt;ULINE.&lt;/P&gt;&lt;P&gt;WRITE : sy-uname, sy-title(56) CENTERED, sy-datum.&lt;/P&gt;&lt;P&gt;ULINE.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;FORM top_of_list2 *&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;STRONG&gt;----&lt;/STRONG&gt;&lt;/P&gt;&lt;HR originaltext="----------------------------------------------------------------" /&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;FORM top_of_list2. "#EC CALLED&lt;/P&gt;&lt;P&gt;WRITE 'TOP OF LIST2'.&lt;/P&gt;&lt;P&gt;ENDFORM.&lt;/P&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;UL&gt;&lt;LI level="14" type="ul"&gt;&lt;P&gt;END OF PROGRAM Z_ALV_LIST_BLOCK ***********************&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;regards.&lt;/P&gt;&lt;P&gt;sowjanya.b&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:46:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583988#M862895</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:46:24Z</dc:date>
    </item>
    <item>
      <title>Re: ALV LIST DISPLAY (Combining two function module)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583989#M862896</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If the structure of the gt_vendor_cc and gt_vendor are same, define another table with the same structure (Eg: gt_final).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now check the code below,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF NOT p_bukrs IS INITIAL.&lt;/P&gt;&lt;P&gt;gt_final[ ] = gt_vendor_cc[ ].&lt;/P&gt;&lt;P&gt;else.&lt;/P&gt;&lt;P&gt;gt_final[ ] = gt_vendor[ ].&lt;/P&gt;&lt;P&gt;endif.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'&lt;/P&gt;&lt;P&gt;EXPORTING&lt;/P&gt;&lt;P&gt;I_CALLBACK_PROGRAM = g_repid&lt;/P&gt;&lt;P&gt;IT_FIELDCAT = lt_fcat&lt;/P&gt;&lt;P&gt;I_SAVE = 'A'&lt;/P&gt;&lt;P&gt;IS_VARIANT = ls_vari&lt;/P&gt;&lt;P&gt;IT_EVENTS = lt_evts&lt;/P&gt;&lt;P&gt;TABLES&lt;/P&gt;&lt;P&gt;T_OUTTAB = gt_final[].&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Mar 2008 05:53:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/alv-list-display-combining-two-function-module/m-p/3583989#M862896</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-03-25T05:53:30Z</dc:date>
    </item>
  </channel>
</rss>

