Display multiple list under same list using FM REUSE_ALV_BLOCK_LIST_DISPLAY

Display Multiple lists under a same list display using FM: "REUSE_ALV_BLOCK_LIST_DISPLAY". We have to call four function modules in sequence to achieve this:
1)REUSE_ALV_BLOCK_LIST_INIT
2)REUSE_ALV_BLOCK_LIST_APPEND
3)then again REUSE_ALV_BLOCK_LIST_APPEND
4)At last REUSE_ALV_BLOCK_LIST_DISPLAY

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
*&---------------------------------------------------------------------*
*& Report ZZSOURAV_MULTIPLE_LIST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*

REPORT zzsourav_multiple_list.
TYPE-POOLS:slis.

DATA:
v_repid TYPE syrepid,
i_spfli TYPE STANDARD TABLE OF spfli INITIAL SIZE 0,
i_scarr TYPE STANDARD TABLE OF scarr INITIAL SIZE 0,
i_fcat1 TYPE slis_t_fieldcat_alv,
i_fcat2 TYPE slis_t_fieldcat_alv,
wa_layout1 TYPE slis_layout_alv,
wa_layout2 TYPE slis_layout_alv,
i_events1 TYPE slis_t_event,
i_events2 TYPE slis_t_event.

INITIALIZATION.
v_repid = sy-repid.

START-OF-SELECTION.

SELECT * FROM spfli
INTO TABLE i_spfli.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'No data found!'.
LEAVE LIST-PROCESSING.
ENDIF.

SELECT * FROM scarr
INTO TABLE i_scarr.

IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'No data found!'.
LEAVE LIST-PROCESSING.
ENDIF.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'I_SCARR'
i_structure_name = 'SCARR'
i_client_never_display = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fcat1
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'Unable to populate field-catalog!'.
LEAVE LIST-PROCESSING.
ENDIF.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = v_repid
i_internal_tabname = 'I_SPFLI'
i_structure_name = 'SPFLI'
i_client_never_display = 'X'
* I_INCLNAME =
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =
CHANGING
ct_fieldcat = i_fcat2
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3
.
IF sy-subrc <> 0.
MESSAGE i001(00) WITH 'Unable to populate field-catalog!'.
LEAVE LIST-PROCESSING.
ENDIF.

END-OF-SELECTION.
wa_layout1-colwidth_optimize = wa_layout2-colwidth_optimize = 'X'.
wa_layout1-zebra = wa_layout2-zebra = 'X'.

CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
i_callback_program = v_repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* IT_EXCLUDING =
.


CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
is_layout = wa_layout1
it_fieldcat = i_fcat1
i_tabname = 'I_SCARR'
it_events = i_events1
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = i_scarr
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 = wa_layout2
it_fieldcat = i_fcat2
i_tabname = 'I_SPFLI'
it_events = i_events2
* IT_SORT =
* I_TEXT = ' '
TABLES
t_outtab = i_spfli
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.

The Output:

1 comment:

Mallaiah Yamani said...

I am very thankful to you for publishing such a good & useful program.

Post a Comment