Академический Документы
Профессиональный Документы
Культура Документы
05 MAR 2015onTree
Reports which has the capability to drill down to multiple levels are of good use. It
serves as a simple overview as well as more detailed report when you want to look
into a particular record in detail. SAP makes it easy to create Tree List reports with
Function Modules RS_TREE_CONSTRUCT and RS_TREE_LIST_DISPLAY .
Now we are going to develop a Tree List report with three levels of details. First level
will be the the list of Customers, second level will be the list of Sales Order Headers for
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
that Customer and third level will be the list of Items in a particular Sales Order.
Before going into the steps, we are going to declare the variables needed for our
program. We have to store the three levels of data in three di erent internal tables
and the rst thing to do is de ning the types for those three structures.
types:
"Customer Structure (Level 1)
begin of s_kna1,
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
ort01 type kna1-ort01,
end of s_kna1,
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
vbeln type vbap-vbeln,
posnr type vbap-posnr,
matnr type vbap-matnr,
netwr type vbap-netwr,
waerk type vbap-waerk,
end of s_vbap.
data:
"Internal tables and Work Areas
"for all three levels of data
gt_kna1 type standard table of s_kna1,
gs_kna1 type s_kna1,
gt_vbak type standard table of s_vbak,
gs_vbak type s_vbak,
gt_vbap type standard table of s_vbap,
gs_vbap type s_vbap,
We have colors in our report and it is good practice to declare them as constants, so
that we will be able to change them without messing up the program. The values
comes from the Type Pool col .
constants:
c_col_key type c length 1 value col_key,
c_col_data type c length 1 value col_normal,
c_col_curr type c length 1 value col_total,
c_col_kunnr type c length 1 value col_key,
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
c_col_vbeln type c length 1 value col_positive,
c_col_posnr type c length 1 value col_group.
start-of-selection.
perform load_all_data.
perform prepare_node_table.
perform display_list_tree.
form load_all_data .
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
select
vbeln
erdat
erzet
netwr
waerk
kunnr
from vbak
into table gt_vbak
for all entries in gt_kna1
where
kunnr = gt_kna1-kunnr.
endform.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Important elds in SNODETEXT are,
loop at Customers.
endloop.
endloop.
endloop.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Now the exact code is as follows.
form prepare_node_table .
data:
l_netwr type c length 15.
clear gs_node.
gs_node-tlevel = 2.
"Customer Number
gs_node-name = gs_kna1-kunnr.
gs_node-nlength = 20.
gs_node-color = c_col_kunnr.
"Country code
gs_node-text = gs_kna1-land1.
gs_node-tlength = 5.
gs_node-tcolor = c_col_data.
"Customer Name
gs_node-text1 = gs_kna1-name1.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
gs_node-tlength1 = 40.
gs_node-tcolor1 = c_col_data.
"City
gs_node-text2 = gs_kna1-ort01.
gs_node-tlength2 = 25.
gs_node-tcolor2 = c_col_data.
clear gs_node.
gs_node-tlevel = 3.
"Created date
gs_node-text = gs_vbak-erdat.
gs_node-tlength = 12.
gs_node-tcolor = c_col_data.
"Created Time
gs_node-text1 = gs_vbak-erzet.
gs_node-tlength1 = 10.
gs_node-tcolor1 = c_col_data.
"Net worth
l_netwr = gs_vbak-netwr.
gs_node-text2 = l_netwr.
gs_node-tlength2 = 15.
gs_node-tcolor2 = c_col_curr.
"Currency
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
"Currency
gs_node-text3 = gs_vbak-waerk.
gs_node-tlength3 = 5.
gs_node-tcolor3 = c_col_curr.
clear gs_node.
gs_node-tlevel = 4.
"Item Number
gs_node-name = gs_vbap-posnr.
gs_node-nlength = 15.
gs_node-color = c_col_posnr.
"Material Number
gs_node-text = gs_vbap-matnr.
gs_node-tlength = 12.
gs_node-tcolor = c_col_data.
"Net worth
l_netwr = gs_vbap-netwr.
gs_node-text1 = l_netwr.
gs_node-tlength1 = 15.
gs_node-tcolor1 = c_col_curr.
"Currency
gs_node-text2 = gs_vbap-waerk.
gs_node-tlength2 = 5.
gs_node-tcolor2 = c_col_curr.
endloop.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
endloop.
endloop.
endform.
takes gt_node as input and processes it internally and lls in the necessary elds of
that internal table while RS_TREE_LIST_DISPLAY is for displaying the Tree List in the
screen.
form display_list_tree .
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
exporting
callback_program = sy-repid.
endform.
report zfar_list_tree.
type-pools:
col. "For color constants
types:
"Customer Structure (Level 1)
begin of s_kna1,
kunnr type kna1-kunnr,
land1 type kna1-land1,
name1 type kna1-name1,
ort01 type kna1-ort01,
end of s_kna1,
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
netwr type vbap-netwr,
waerk type vbap-waerk,
end of s_vbap.
data:
"Internal tables and Work Areas
"for all three levels of data
gt_kna1 type standard table of s_kna1,
gs_kna1 type s_kna1,
gt_vbak type standard table of s_vbak,
gs_vbak type s_vbak,
gt_vbap type standard table of s_vbap,
gs_vbap type s_vbap,
constants:
c_col_key type c length 1 value col_key,
c_col_data type c length 1 value col_normal,
c_col_curr type c length 1 value col_total,
c_col_kunnr type c length 1 value col_key,
c_col_vbeln type c length 1 value col_positive,
c_col_posnr type c length 1 value col_group.
start-of-selection.
perform load_all_data.
perform prepare_node_table.
perform display_list_tree.
form load_all_data .
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
form prepare_node_table .
data:
l_netwr type c length 15.
clear gs_node.
gs_node-tlevel = 2.
"Customer Number
gs_node-name = gs_kna1-kunnr.
gs_node-nlength = 20.
gs_node-color = c_col_kunnr.
"Country code
gs_node-text = gs_kna1-land1.
gs_node-tlength = 5.
gs_node-tcolor = c_col_data.
"Customer Name
gs_node-text1 = gs_kna1-name1.
gs_node-tlength1 = 40.
gs_node-tcolor1 = c_col_data.
"City
gs_node-text2 = gs_kna1-ort01.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
gs_node-text2 = gs_kna1-ort01.
gs_node-tlength2 = 25.
gs_node-tcolor2 = c_col_data.
clear gs_node.
gs_node-tlevel = 3.
"Created date
gs_node-text = gs_vbak-erdat.
gs_node-tlength = 12.
gs_node-tcolor = c_col_data.
"Created Time
gs_node-text1 = gs_vbak-erzet.
gs_node-tlength1 = 10.
gs_node-tcolor1 = c_col_data.
"Net worth
l_netwr = gs_vbak-netwr.
gs_node-text2 = l_netwr.
gs_node-tlength2 = 15.
gs_node-tcolor2 = c_col_curr.
"Currency
gs_node-text3 = gs_vbak-waerk.
gs_node-tlength3 = 5.
gs_node-tcolor3 = c_col_curr.
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
append gs_node to gt_node.
clear gs_node.
gs_node-tlevel = 4.
"Item Number
gs_node-name = gs_vbap-posnr.
gs_node-nlength = 15.
gs_node-color = c_col_posnr.
"Material Number
gs_node-text = gs_vbap-matnr.
gs_node-tlength = 12.
gs_node-tcolor = c_col_data.
"Net worth
l_netwr = gs_vbap-netwr.
gs_node-text1 = l_netwr.
gs_node-tlength1 = 15.
gs_node-tcolor1 = c_col_curr.
"Currency
gs_node-text2 = gs_vbap-waerk.
gs_node-tlength2 = 5.
gs_node-tcolor2 = c_col_curr.
endloop.
endloop.
endloop.
form display_list_tree .
twitter.com/fareez_ahamed
0 Comments fareez.info
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
Recommend ⤤ Share
ALSO ON FAREEZ.INFO
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com
YOU MIGHT ENJOY
open in browser PRO version Are you a developer? Try out the HTML to PDF API pdfcrowd.com