* Hierchial Abap List Viewer
report z_anu_alv
no standard page heading .
type-pools: slis.
tables: ekpo.
data:begin of it_header occurs 0,
ebeln like ekko-ebeln,
bukrs like ekko-bukrs,
lifnr like ekko-lifnr,
bedat like ekko-bedat,
end of it_header.
data: begin of it_item occurs 0,
sno like ekpo-ebeln,
ebelp like ekpo-ebelp,
menge like ekpo-menge,
netwr like ekpo-netwr,
end of it_item.
*************
data v_repid like sy-repid.
data x_layout type slis_layout_alv .
data it_fieldcat type slis_fieldcat_alv occurs 0 with header line.
data x_keyinfo type slis_keyinfo_alv.
*************
initialization.
v_repid = sy-repid.
select-options: s_ebeln for ekpo-ebeln.
start-of-selection.
perform fill_data.
perform fill_fieldcat.
perform layout.
x_keyinfo-header01 = 'EBELN'.
x_keyinfo-item01 = 'SNO'.
perform key_modifier.
perform display_output.
&----
*& Form fill_data
&----
text
----
--> p1 text
<-- p2 text
----
form fill_data.
select ebeln
bukrs
lifnr
bedat
from ekko into table it_header
where ebeln in s_ebeln. " where ebeln in s_ebeln.
select ebeln
ebelp
menge
netwr from ekpo into table it_item
where ebeln in s_ebeln. " where ebeln in s_ebeln.
endform. " fill_data
&----
*& Form fill_fieldcat
&----
text
----
--> p1 text
<-- p2 text
----
form fill_fieldcat.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_HEADER'
i_inclname = v_repid
changing
ct_fieldcat = it_fieldcat[]
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.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = v_repid
i_internal_tabname = 'IT_ITEM'
i_inclname = v_repid
changing
ct_fieldcat = it_fieldcat[]
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. " fill_fieldcat
&----
*& Form KEY_MODIFIER
&----
text
----
--> p1 text
<-- p2 text
----
form key_modifier.
loop at it_fieldcat. "Avoid Repitiotion of data.
case it_fieldcat-fieldname.
when 'SNO'.
if it_fieldcat-tabname = 'IT_ITEM'.
it_fieldcat-no_out = 'X'.
it_fieldcat-key = space.
endif.
when 'NETWR'.
if it_fieldcat-tabname = 'IT_ITEM'.
it_fieldcat-do_sum = 'X'.
it_fieldcat-key = space.
endif.
endcase.
modify it_fieldcat index sy-tabix.
endloop.
endform. " KEY_MODIFIER
&----
*& Form display_output
&----
text
----
--> p1 text
<-- p2 text
----
form display_output.
call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
exporting
i_callback_program = v_repid
is_layout = x_layout
it_fieldcat = it_fieldcat[]
i_tabname_header = 'IT_HEADER'
i_tabname_item = 'IT_ITEM'
is_keyinfo = x_keyinfo
tables
t_outtab_header = it_header
t_outtab_item = it_item
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.
endform. " display_output
&----
*& Form LAYOUT
&----
text
----
--> p1 text
<-- p2 text
----
form layout.
x_layout-zebra = 'X' .
x_layout-detail_popup = 'X' .
*
endform. " LAYOUT
Add a comment