Tree ALV in ABAP
Report
REPORT zab_rp_tree_alv.
TABLES: vbak.
DATA: gt_node TYPE TABLE OF snodetext,
gs_node TYPE snodetext.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln.
IF s_vbeln IS INITIAL.
MESSAGE 'Please select sale document' TYPE 'E'.
ELSE.
SELECT a~vbeln, b~posnr,b~matnr,b~kwmeng,b~vrkme,c~maktx
FROM vbak AS a LEFT OUTER JOIN vbap AS b
ON a~vbeln = b~vbeln
INNER JOIN makt AS c
ON b~matnr = c~matnr
INTO TABLE @DATA(lt_final)
WHERE a~vbeln IN @s_vbeln.
ENDIF.
gs_node-type = 'T'.
gs_node-name = 'Sale Document'.
gs_node-tlevel = '1'.
gs_node-nlength = '20'.
gs_node-color = '3'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
LOOP AT lt_final INTO DATA(lr_final).
gs_node-name = 'VBELN'.
gs_node-tlevel = '2'.
gs_node-nlength = '20'.
gs_node-color = '3'.
gs_node-text = lr_final-vbeln.
gs_node-tlength = '20'.
gs_node-tcolor = '6'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
gs_node-name = 'SALE ITEM'.
gs_node-tlevel = '3'.
gs_node-nlength = '20'.
gs_node-color = '3'.
gs_node-text = 'MATERIAL NUMBER'.
gs_node-tlength = '20'.
gs_node-tcolor = '6'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
gs_node-tlevel = '4'.
gs_node-text = lr_final-posnr.
gs_node-tlength = '20'.
gs_node-tcolor = '3'.
gs_node-text1 = lr_final-matnr.
gs_node-tlength1 = '20'.
gs_node-tcolor = '6'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
gs_node-name = 'MATERIAL NUMBER'.
gs_node-tlevel = '5'.
gs_node-nlength = '20'.
gs_node-color = '3'.
gs_node-text = 'DESCIPTION'.
gs_node-tlength = '20'.
gs_node-tcolor = '6'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
gs_node-tlevel = '6'.
gs_node-text = lr_final-matnr.
gs_node-tlength = '20'.
gs_node-tcolor = '3'.
gs_node-text1 = lr_final-maktx.
gs_node-tlength1 = '20'.
gs_node-tcolor1 = '6'.
APPEND gs_node TO gt_node.
CLEAR:gs_node.
ENDLOOP.
CALL FUNCTION 'RS_TREE_CONSTRUCT'
TABLES
nodetab = gt_node
EXCEPTIONS
tree_failure = 1
id_not_found = 2
wrong_relationship = 3
OTHERS = 4.
CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
EXPORTING
callback_program = sy-cprog.
Input
Output
******************************Thank You***************************
Comments
Post a Comment