2008 Mar 16 11:17 PM
Hi Experts ,
I got 4 internal tables in my report . I have retrieved the data .
I should display the report in alv . How can i merge all the internal tables into single output table.
i want to print all the fields of my internal tables in single table.
thanks
Raj
Hi Experts ,
I got 4 internal tables in my report . I have retrieved the data .
I should display the report in alv . How can i merge all the internal tables into single output table.
i want to print all the fields of my internal tables in single table.
thanks
Raj
2008 Mar 17 5:44 AM
Hi
For that you should have some common unique fields in all the internal tables. If so you can loop one internal table and read all the other table with unique key fields.
2008 Mar 17 5:44 AM
Hi Raj,
As mentiones u have data in 4 different internal tables and u want to display through 1 internal table, so declare ur it_final that should have all the fields to be displayed.
Now move the data from all 4 internal tables into this it_final using statement:
Move-Corresponding.
Say u have 4 internal tables it_tab1, it_tab2......
Loop At it_tab1 into wa_tab1.
Move-Corresponding wa_tab1 to wa_final.
Append wa_final to it_final.
EndLoop.
Loop at it_tab2 into wa_tab2
Move-corresponding wa_tab2 to wa_final
modify it_final from wa_final transporting fld1 fld2......
Endloop.
Here transportingwill contain the fields which are to be transfered frfom second internal table, so it will not affect the modifications from internal table1.
Hope it helps to resolve ur problem.
Please revert back for any clarification.
Regards,
Ashish
2008 Mar 17 5:54 AM
Hi,
If those internal tables have common key then u can merge all into on single that should contain all fields of 4 internal tables .
Otherwise you have one option in ALV to display all internal tables one by one .
Here is the sample program for Blocked ALV
report zvenkat_blocked_alv.
**********************************************************************
Declarations.
**********************************************************************
Types
Work Areas
Internal tables
data:
i_0000 type standard table of pa0000,
i_0001 type standard table of pa0001,
i_0002 type standard table of pa0002,
i_0008 type standard table of pa0008.
Variables
Constants
&----
ALV Declarations
----
Types Pools
type-pools:
slis.
Types
types:
t_fieldcat type slis_fieldcat_alv,
t_events type slis_alv_event,
t_layout type slis_layout_alv.
Workareas
data:
w_fieldcat1 type t_fieldcat,
w_fieldcat2 type t_fieldcat,
w_fieldcat3 type t_fieldcat,
w_fieldcat4 type t_fieldcat,
w_events type t_events,
w_layout type t_layout.
Internal Tables
data:
i_fieldcat1 type standard table of t_fieldcat,
i_fieldcat2 type standard table of t_fieldcat,
i_fieldcat3 type standard table of t_fieldcat,
i_fieldcat4 type standard table of t_fieldcat,
i_events type standard table of t_events.
**********************************************************************
start-of-selection.
**********************************************************************
start-of-selection.
perform get_data.
**********************************************************************
end-of-selection.
**********************************************************************
end-of-selection.
perform display_data.
**********************************************************************
FORM : get_data
***********************************************************************
form get_data.
select *
from pa0000
into table i_0000 up to 10 rows.
select *
from pa0001
into table i_0001 up to 10 rows.
select *
from pa0002
into table i_0002 up to 10 rows.
select *
from pa0008
into table i_0008 up to 10 rows.
endform. "get_data
**********************************************************************
FORM : display_data
***********************************************************************
form display_data.
perform build_fieldcatalog using 'PA0000' changing i_fieldcat1.
perform build_fieldcatalog using 'PA0001' changing i_fieldcat2[].
perform build_fieldcatalog using 'PA0002' changing i_fieldcat3[].
perform build_fieldcatalog using 'PA0008' changing i_fieldcat4[].
perform display_data_alv.
endform. "display_data
&----
*& Form display_data_ALV
&----
form display_data_alv .
call function 'REUSE_ALV_BLOCK_LIST_INIT'
exporting
i_callback_program = 'ZVENKAT_BLOCKED_ALV'.
perform build_block_list_append tables i_0000[] using w_layout i_fieldcat1[] 'PA0000' i_events[].
perform build_block_list_append tables i_0001[] using w_layout i_fieldcat2[] 'PA0001' i_events[].
perform build_block_list_append tables i_0002[] using w_layout i_fieldcat3[] 'PA0002' i_events[].
perform build_block_list_append tables i_0008[] using w_layout i_fieldcat4[] 'PA0008' i_events[].
call function 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endform. " display_data_ALV
&----
*& Form build_block_list_append
&----
text
----
-->P_0141 text
-->P_0142 text
-->P_0143 text
-->P_0144 text
----
form build_block_list_append tables outtab using layout fieldcat tabname events .
call function 'REUSE_ALV_BLOCK_LIST_APPEND'
exporting
is_layout = layout
it_fieldcat = fieldcat
i_tabname = tabname
it_events = events
IT_SORT =
I_TEXT = ' '
tables
t_outtab = outtab
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.
endform. " build_block_list_append
&----
*& Form build_fieldcatalog
&----
text
----
-->P_0113 text
----
form build_fieldcatalog using structure changing i_fieldcat1.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = 'ZVENKAT_BLOCKED_ALV'
I_INTERNAL_TABNAME =
i_structure_name = structure
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
changing
ct_fieldcat = i_fieldcat1
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 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.
endform. " build_fieldcatalog
Regards,
Venkat.O
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |