Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

*&---------------------------------------------------------------------*

*& Report ZRP_ALV_TREE


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZRP_ALV_TREE.
"REPORT ZALV_TREE_DISPLAY.
*//Type Pool declaration
type-POOLS: slis.
*//Types Declaration for VBAK
types:BEGIN OF ty_vbak,
vbeln type vbak-vbeln,
END OF ty_vbak.
*//Types Declaration for VBAP
types:BEGIN OF ty_vbap,
vbeln type vbap-vbeln,
posnr type vbap-posnr,
end of ty_vbap.
*//Types Declaration for VBEP
types:BEGIN OF ty_vbep,
vbeln type vbep-vbeln,
posnr type vbep-posnr,
ETENR type vbep-etenr,
end of ty_vbep.
*//Internal Table and Work Area Declaration
data : it_vbak type table of ty_vbak,
wa_vbak type ty_vbak,
it_vbap type table of ty_vbap,
wa_vbap type ty_vbap,
it_vbep type TABLE OF ty_vbep,
wa_vbep type ty_vbep,
it_node type table of snodetext,
wa_node type snodetext .
START-OF-SELECTION.
select vbeln
from vbak
into table it_vbak
UP TO 50 ROWS.
*//it_vbak is not initial
if it_vbak is NOT INITIAL.
*//Retrive Data from VBAP
select vbeln posnr
from vbap
INTO TABLE it_vbap
FOR ALL ENTRIES IN it_vbak
where vbeln = it_vbak-vbeln.
sort it_vbap by vbeln posnr.
*//If LT_VBAP is not initial
if it_vbap is NOT INITIAL.
*//Retrive Data from VBEP
select vbeln posnr etenr
from vbep
INTO TABLE it_vbep
FOR ALL ENTRIES IN it_vbap
where vbeln = it_vbap-vbeln.
sort it_vbep by vbeln posnr etenr.
endif.
endif.
perform build_tree.
perform display_tree.
*&*
*& Form BUILD_TREE
*&*
* text
*-*
* > p1 text
* < p2 text
*-*
form BUILD_TREE .
clear : wa_node, it_node.
wa_node-type = T.
wa_node-name = SalesData.
wa_node-tlevel = 01'.
wa_node-nlength = 09'.
wa_node-color = 05'.
wa_node-text = HEADER.
wa_node-tlength = 06'.
wa_node-tcolor = 05'.
append wa_node to it_node.
clear wa_node.
loop at it_vbak into wa_vbak.
wa_node-type = P.
wa_node-name = VBELN.
wa_node-tlevel = 02'.
wa_node-nlength = 08'.
wa_node-color = 06'.
wa_node-text = wa_vbak-vbeln.
wa_node-tlength = 10'.
wa_node-tcolor = 06'.
append wa_node to it_node.
clear wa_node.
loop at it_vbap into wa_vbap.
if wa_vbak-vbeln = wa_vbap-vbeln.
wa_node-type = P.
wa_node-name = POSNR.
wa_node-tlevel = 03'.
wa_node-nlength = 08'.
wa_node-color = 04'.
wa_node-text = wa_vbap-posnr.
wa_node-tlength = 05'.
wa_node-tcolor = 04'.
append wa_node to it_node.
clear wa_node.
loop at it_vbep into wa_vbep.
if wa_vbap-vbeln = wa_vbep-vbeln and wa_vbap-posnr = wa_vbep-posnr.
wa_node-type = P.
wa_node-name = ETENR.
wa_node-tlevel = 04'.
wa_node-nlength = 08'.
wa_node-color = 04'.
wa_node-text = wa_vbep-etenr.
wa_node-tlength = 05'.
wa_node-tcolor = 04'.
append wa_node to it_node.
clear wa_node.
endif.
endloop.
endif.
endloop.
endloop.
endform. BUILD_TREE
*&*
*& Form DISPLAY_TREE
*&*
* text
*-*
* > p1 text
* < p2 text
*-*
form DISPLAY_TREE .
call function RS_TREE_CONSTRUCT
* EXPORTING
* INSERT_ID = 000000'
* RELATIONSHIP =
* LOG =
tables
nodetab = it_node.
call function RS_TREE_LIST_DISPLAY
exporting
callback_program = sy-cprog.
endform. DISPLAY_TREE

You might also like