Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV

Former Member
0 Kudos

Hi,

i have hierarchical report in which i displayed header and item data,my requirement is to display the alv tree for each item in hierarchical report

1 ACCEPTED SOLUTION

Former Member
0 Kudos

hi,

Refer to the link.

http://www.sapdev.co.uk/reporting/alv/alvtree.htm

This Might help.

Regards

Sumit Agarwal

12 REPLIES 12

Former Member
0 Kudos

hi,

Refer to the link.

http://www.sapdev.co.uk/reporting/alv/alvtree.htm

This Might help.

Regards

Sumit Agarwal

Former Member
0 Kudos

Hi Surendra

Check the program in below link

http://www.saptechnical.com/Tutorials/ALV/Hierarchical/demo.htm

Regards,

Syf

Former Member
0 Kudos

Hi

follow this link

Cheers

Snehi

Former Member
0 Kudos

HI,

REPORT ZDE_S2D_TREE_SIMPLE.

types: begin of ty_mara,

matnr type matnr,

mbrsh type mbrsh,

mtart type mtart,

meins type meins,

end of ty_mara.

data: gt_mara type TABLE OF TY_MARA,

gt_mara1 type TABLE OF TY_MARA,

GW_MARA TYPE TY_MARA.

data: gr_tree type ref to cl_salv_tree.

data: nodes type ref to cl_salv_nodes,

node type ref to cl_salv_node.

data: key type SALV_DE_NODE_KEY.

START-OF-SELECTION.

SELECT matnr mbrsh mtart meins from mara INTO TABLE gt_mara UP TO 50 rows.

*TRY.

CALL METHOD CL_SALV_TREE=>FACTORY

  • EXPORTING

  • R_CONTAINER =

  • HIDE_HEADER =

IMPORTING

R_SALV_TREE = gr_tree

CHANGING

T_TABLE = gt_mara1

.

nodes = gr_tree->get_nodes( ).

key = ' '.

node = nodes->add_node( related_node = key

relationship = cl_gui_column_tree=>relat_first_child ).

LOOP AT gt_mara into gw_mara.

node->set_data_row( gw_mara ).

key = node->get_key( ).

node = nodes->add_node( related_node = key

relationship = cl_gui_column_tree=>relat_last_child ).

nodes = gr_tree->get_nodes( ).

ENDLOOP.

gr_tree->display( ).

I think it will be useful for you.

Thanks & regards

Deepika

Former Member
0 Kudos

Hi Surendra,

Check this sample code:

[ALV Heirarchial with header and item data|;

Regards,

Chandra Sekhar

former_member206441
Contributor
0 Kudos

hi i sent u the model code to create tree view

CLASS DEFINITION

CLASS lcl_application DEFINITION.

PUBLIC SECTION.

METHODS:

handle_node_double_click

FOR EVENT node_double_click

OF cl_gui_list_tree

IMPORTING node_key,

handle_expand_no_children

FOR EVENT expand_no_children

OF cl_gui_list_tree

IMPORTING node_key,

handle_item_double_click

FOR EVENT item_double_click

OF cl_gui_list_tree

IMPORTING node_key item_name,

handle_button_click

FOR EVENT button_click

OF cl_gui_list_tree

IMPORTING node_key item_name,

handle_link_click

FOR EVENT link_click

OF cl_gui_list_tree

IMPORTING node_key item_name,

handle_checkbox_change

FOR EVENT checkbox_change

OF cl_gui_list_tree

IMPORTING node_key item_name checked.

ENDCLASS.

CLASS IMPLEMENTATION

CLASS lcl_application IMPLEMENTATION.

METHOD handle_node_double_click.

" this method handles the node double click event of the tree

" control instance

" show the key of the double clicked node in a dynpro field

READ TABLE itab_data WITH KEY node_key = node_key INTO wa_data.

  • You now have the data to do anything you wish

  • u2026.

ENDMETHOD.

METHOD handle_item_double_click.

" this method handles the item double click event of the tree

" control instance. You have variables node_key and item_name

" show the key of the node and the name of the item

" of the double clicked item in a dynpro field

READ TABLE itab_data WITH KEY node_key = node_key INTO wa_data.

  • You now have the data to do anything you wish

  • u2026.

ENDMETHOD.

METHOD handle_link_click.

" this method handles the link click event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked link in a dynpro field

g_node_key = node_key.

g_item_name = item_name.

ENDMETHOD.

METHOD handle_button_click.

" this method handles the button click event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked button in a dynpro field

g_node_key = node_key.

g_item_name = item_name.

ENDMETHOD.

METHOD handle_checkbox_change.

" this method handles the checkbox_change event of the tree

" control instance

" show the key of the node and the name of the item

" of the clicked checkbox in a dynpro field

g_node_key = node_key.

g_item_name = item_name.

ENDMETHOD.

METHOD handle_expand_no_children.

DATA: node_table TYPE treev_ntab,

node TYPE treev_node,

item_table TYPE item_table_type,

item TYPE mtreeitm.

  • show the key of the expanded node in a dynpro field

g_node_key = node_key.

IF node_key = 'Child2'. "#EC NOTEXT

  • add the children for node with key 'Child2'

  • Node with key 'New3'

CLEAR node.

node-node_key = 'New3'. "#EC NOTEXT

node-relatkey = 'Child2'.

node-relatship = cl_gui_list_tree=>relat_last_child.

APPEND node TO node_table.

  • Node with key 'New4'

CLEAR node.

node-node_key = 'New4'. "#EC NOTEXT

node-relatkey = 'Child2'.

node-relatship = cl_gui_list_tree=>relat_last_child.

APPEND node TO node_table.

  • Items of node with key 'New3'

CLEAR item.

item-node_key = 'New3'.

item-item_name = '1'.

item-class = cl_gui_list_tree=>item_class_text.

item-length = 11.

item-usebgcolor = 'X'. "

item-text = 'SAPTROX1'.

APPEND item TO item_table.

CLEAR item.

item-node_key = 'New3'.

item-item_name = '2'.

item-class = cl_gui_list_tree=>item_class_text.

item-alignment = cl_gui_list_tree=>align_auto.

item-font = cl_gui_list_tree=>item_font_prop.

item-text = 'Comment to SAPTROX1'. "#EC NOTEXT

APPEND item TO item_table.

  • Items of node with key 'New4'

CLEAR item.

item-node_key = 'New4'.

item-item_name = '1'.

item-class = cl_gui_list_tree=>item_class_text.

item-length = 11.

item-usebgcolor = 'X'. "

item-text = 'SAPTRIXTROX'.

APPEND item TO item_table.

CLEAR item.

item-node_key = 'New4'.

item-item_name = '2'.

item-class = cl_gui_list_tree=>item_class_text.

item-alignment = cl_gui_list_tree=>align_auto.

item-font = cl_gui_list_tree=>item_font_prop.

item-text = 'Comment to SAPTRIXTROX'. "#EC NOTEXT

APPEND item TO item_table.

ENDIF.

CALL METHOD g_tree->add_nodes_and_items

EXPORTING

node_table = node_table

item_table = item_table

item_table_structure_name = 'MTREEITM'

EXCEPTIONS

failed = 1

cntl_system_error = 3

error_in_tables = 4

dp_error = 5

table_structure_name_not_found = 6.

IF sy-subrc <> 0.

MESSAGE a000(tree_control_msg).

ENDIF.

ENDMETHOD.

ENDCLASS.

Former Member
0 Kudos

Hi,

Iam attaching both ALV TREE and ALV HOERARCHIAL Programmes.Hope this would help you..Please give Points , if it is useful for u.

ALV TREE :

report z_alv_po_oops_me23n

no standard page heading message-id z9d_alv_oops

line-count 200 line-size 200.

*&--types for t_ekko

types : begin of type_ekko,

ebeln type ebeln, "Purchasing Document Number

bukrs type bukrs, "Company Code

aedat type erdat, "Date on which the record was created

ekorg type ekorg, "Purchasing Organization

end of type_ekko.

*&--types for t_ekpo

types : begin of type_ekpo,

ebeln type ebeln, "Purchasing Document Number

ebelp type ebelp, "Item Number of Purchasing Document

txz01 type txz01, "Short text

ematn type ematnr, "Material number

menge type bstmg, "Purchase order quantity

netpr type bprei,

"Net price in purchasing document (in document currency)

pstyp type pstyp, "Item category in purchasing document

knttp type knttp, "Account assignment category

end of type_ekpo.

*&--types for t_eket

types : begin of type_eket,

ebeln type ebeln, "Purchasing Document Number

ebelp type ebelp, "Item Number of Purchasing Document

etenr type eeten, "Delivery Schedule Line Counter

eindt type eindt, "Item delivery date

end of type_eket.

*&---types for t_podetail

types : begin of type_podetail,

ebeln type ebeln, "Purchasing Document Number

ebelp type ebelp, "Item Number of Purchasing Document

txz01 type txz01, "Short text

ematn type ematnr, "Material number

menge type bstmg, "Purchase order quantity

netpr type bprei,

"Net price in purchasing document (in document currency)

pstyp type pstyp, "Item category in purchasing document

knttp type knttp, "Account assignment category

  • EBELN type EBELN, "Purchasing Document Number

  • EBELP type EBELP, "Item Number of Purchasing Document

etenr type eeten, "Delivery Schedule Line Counter

eindt type eindt, "Item delivery date

end of type_podetail.

*&----types

types : type_t_ekko type type_ekko,

type_t_ekpo type type_ekpo,

type_t_eket type type_eket,

type_t_podetail type type_podetail.

*&----internal tables

data : it_ekko type standard table of type_t_ekko,

it_ekpo type standard table of type_t_ekpo,

it_eket type standard table of type_t_eket,

it_podetail type standard table of type_t_podetail.

*&----work areas

data : wa_ekko type type_t_ekko,

wa_ekpo type type_t_ekpo,

wa_eket type type_t_eket,

wa_podetail type type_t_podetail.

*&--data declaration for selection screen

data : w_ebeln type ebeln,

w_aedat type erdat,

w_ekorg type ekorg,

w_bukrs type bukrs,

gd_date1(10), "field to store output date

gd_date2(10). "field to store output date

*&-----data declaration for ok_code.

data : ok_code_0101 like sy-ucomm,

*&-----work area for field catalog

wa_fieldcatalog2 type lvc_s_fcat,

*&-----internal table for field catalog

it_fieldcatalog2 type lvc_t_fcat,

*&-----tree2 for alv tree

tree2 type ref to cl_gui_alv_tree,

*&-----l_tree_container_name

l_tree_container_name(30) type c,

*&-----custom_container

custom_container type ref to cl_gui_custom_container,

*&-----lt_list_commentary

lt_list_commentary type slis_t_listheader,

*&-----l_logo for header

l_logo type sdydo_value,

*&-----ls_line

ls_line type slis_listheader,

*&-----hirarchy header

l_hierarchy_header type treev_hhdr.

data: l_system(12) type c.

data : o_header type ref to cl_salv_form_layout_grid,

o_header_1 type ref to cl_salv_form_layout_grid.

&--


defining the selection-screen--

selection-screen begin of block bl1 with frame title text-001.

select-options : s_ebeln for w_ebeln obligatory.

select-options : s_bukrs for w_bukrs.

select-options : s_aedat for w_aedat.

select-options : s_ekorg for w_ekorg.

selection-screen end of block bl1.

&--


validation on the selection-screen--

*&---validation for ebeln

at selection-screen on s_ebeln.

if s_ebeln[] is initial.

set cursor field 's_ebeln-low'.

message e000. "plz enter po document number

else.

select ebeln into w_ebeln

up to 1 rows

from ekko

where ebeln in s_ebeln.

endselect.

*&---checking for sy-subrc

if sy-subrc <> 0.

set cursor field 's_ebeln-low'.

message e001. "entered document number is invalid

endif.

endif.

*&---validation for bukrs

at selection-screen on s_bukrs.

select bukrs into w_bukrs

up to 1 rows

from t001

where bukrs in s_bukrs.

endselect.

*&---checking for sy-subrc

if sy-subrc <> 0.

set cursor field 's_bukrs-low'.

message e007. "entered company code is invalid

endif.

*&---validation for ekorg

at selection-screen on s_ekorg.

select ekorg into w_ekorg

up to 1 rows

from t024e

where ekorg in s_ekorg.

endselect.

*&---checking for sy-subrc

if sy-subrc <> 0.

set cursor field 's_ekorg-low'.

message e006. "entered purchasing organization is invalid

endif.

*&-----main logic.

start-of-selection.

*&--perform for fetch_detail

perform fetch_detail.

end-of-selection.

call screen 0101.

&----


*& Form fetch_detail

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form fetch_detail .

*&--clear work area

clear wa_ekko.

*&--refresh internal table

refresh it_ekko.

*&---populate the data from ekko

select ebeln

bukrs

aedat

ekorg

into table it_ekko

from ekko

where ebeln in s_ebeln and

bukrs in s_bukrs and

aedat in s_aedat and

ekorg in s_ekorg.

*&--checking for sy-subrc

if sy-subrc <> 0.

message e002. "header data doesn't exists

else.

sort it_ekko by ebeln.

endif.

*&--clear work area

clear wa_ekpo.

*&--refresh internal table

refresh it_ekpo.

if it_ekko[] is not initial.

*&----populate the data from ekpo.

select ebeln "Purchasing Document Number

ebelp "Item Number of Purchasing Document

txz01 "Short text

ematn "Material number

menge "Purchase order quantity

netpr "Net price in purchasing document (in document currency)

pstyp "Item category in purchasing document

knttp "Account assignment category

into table it_ekpo

from ekpo

for all entries in it_ekko

where ebeln = it_ekko-ebeln.

*&--checking for sy-subrc

if sy-subrc <> 0.

message e003. "items data doesn't exists

else.

sort it_ekpo by ebeln ebelp.

endif.

endif.

*&--populate the data from eket

if it_ekpo[] is not initial.

select ebeln "Purchasing Document Number

ebelp "Item Number of Purchasing Document

etenr "Delivery Schedule Line Counter

eindt "Item delivery date

into table it_eket

from eket

for all entries in it_ekpo

where ebeln = it_ekpo-ebeln and

ebelp = it_ekpo-ebelp.

*&--checking for sy-subrc

if sy-subrc <> 0.

message e004. "delivery date doesn't exists

else.

sort it_eket by ebeln ebelp.

endif.

endif.

*&-------populate it_podetail

loop at it_ekpo into wa_ekpo.

wa_podetail-ebeln = wa_ekpo-ebeln.

wa_podetail-ebelp = wa_ekpo-ebelp.

wa_podetail-txz01 = wa_ekpo-txz01.

wa_podetail-ematn = wa_ekpo-ematn.

wa_podetail-menge = wa_ekpo-menge.

wa_podetail-netpr = wa_ekpo-netpr.

wa_podetail-pstyp = wa_ekpo-pstyp.

wa_podetail-knttp = wa_ekpo-knttp.

read table it_eket into wa_eket with key ebeln = wa_ekpo-ebeln

ebelp = wa_ekpo-ebelp

binary search.

wa_podetail-eindt = wa_eket-eindt.

append wa_podetail to it_podetail.

clear wa_podetail.

endloop.

endform. " fetch_detail

&----


*& Module STATUS_0101 OUTPUT

&----


  • text

----


module status_0101 output.

set pf-status 'MENU_ALV_OOPS'.

endmodule. " STATUS_0101 OUTPUT

&----


*& Module SET_ALV OUTPUT

&----


  • text

----


module set_alv output.

*&---setting the pf-status

case sy-ucomm.

when 'BCK1'.

leave screen.

when 'EXT1'.

leave program.

when others.

endcase.

*&--declaring astructure of type t_podetail

data : it_podetail1 type standard table of type_podetail.

*&---if tree is empty

if tree2 is initial.

l_tree_container_name = 'TREE2'.

*&--sy-batch means program is running at back ground

if sy-batch is initial.

*&----creating the object for the custom_container

create object custom_container

exporting

container_name = l_tree_container_name

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

*&-----creating the object tree2

create object tree2

exporting

parent = custom_container

node_selection_mode =

cl_gui_column_tree=>node_sel_mode_single

item_selection = 'X'

no_toolbar = ' '

no_html_header = ' '

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

illegal_node_selection_mode = 5

failed = 6

illegal_column_name = 7

others = 8

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

*&---perofrm for hiraechy

perform build_hierarchy_header changing l_hierarchy_header.

*&---perform for html-header

perform build_comment using lt_list_commentary

l_logo.

*&---perform for field catalog.

perform field_catalog.

*&----calling the function to print data

call method tree2->set_table_for_first_display

exporting

is_hierarchy_header = l_hierarchy_header

it_list_commentary = lt_list_commentary

i_logo = l_logo

changing

it_outtab = it_podetail1[]

it_fieldcatalog = it_fieldcatalog2[]

.

*&---create the hirarchy

perform create_hierarchy.

*&---calling the method frontend_method.

call method tree2->frontend_update.

endif.

endif.

endmodule. " SET_ALV OUTPUT

&----


*& Form build_comment

&----


  • text

----


  • -->P_LT_LIST_COMMENTARY text

  • -->P_L_LOGO text

----


form build_comment using p_lt_list_commentary type slis_t_listheader

p_l_logo type sdydo_value.

*DATA: GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.

*&--list heading line type 'H'.

clear ls_line.

ls_line-typ = 'H'.

ls_line-info = 'rapidigm-fujitsu'.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--list status line type 'S'.

ls_line-typ = 'S'.

ls_line-key = 'PO DOCUMENT NO:'.

concatenate s_ebeln-low ' TO ' s_ebeln-high into ls_line-info

separated by space.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--list status line type 'S'.

ls_line-typ = 'S'.

ls_line-key = 'CREATION DATE:'.

write s_aedat-low to gd_date1 mm/dd/yyyy.

write s_aedat-high to gd_date2 mm/dd/yyyy.

concatenate gd_date1 ' TO ' gd_date2 into ls_line-info

separated by space.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--list status line type 'S'.

ls_line-typ = 'S'.

ls_line-key = 'PURCHASING ORGANIZATION:'.

concatenate s_ekorg-low ' TO ' s_ekorg-high into ls_line-info

separated by space.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--list status line type 'S'.

ls_line-typ = 'S'.

ls_line-key = 'COMPANY CODE:'.

concatenate s_bukrs-low ' TO ' s_bukrs-high into ls_line-info

separated by space.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--list status line type 'S'.

ls_line-typ = 'S'.

ls_line-key = 'DATE:'.

ls_line-info = sy-datum.

append ls_line to p_lt_list_commentary.

clear ls_line.

*&--logo

p_l_logo = 'ENJOYSAP_LOGO'.

endform. " build_comment

&----


*& Form field_catalog

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form field_catalog .

clear wa_fieldcatalog2 .

refresh it_fieldcatalog2 .

*&-POPULATING THE FIELD EBELN

wa_fieldcatalog2-col_pos = 1. "position of the column

wa_fieldcatalog2-fieldname = 'EBELN'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 10. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'PO DOC NO'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD EBELP

wa_fieldcatalog2-col_pos = 2. "position of the columnt

wa_fieldcatalog2-fieldname = 'EBELP'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 10. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'ITEM NO'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD KNTTP

wa_fieldcatalog2-col_pos = 3. "position of the column

wa_fieldcatalog2-fieldname = 'KNTTP'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 10. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Acc assig cat'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD PSTYP

wa_fieldcatalog2-col_pos = 4. "position of the column

wa_fieldcatalog2-fieldname = 'PSTYP'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 10. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Item cat in pur doc'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD EMATN

wa_fieldcatalog2-col_pos = 5. "position of the column

wa_fieldcatalog2-fieldname = 'EMATN'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 18. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Material number'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD TXZ01

wa_fieldcatalog2-col_pos = 6. "position of the column

wa_fieldcatalog2-fieldname = 'TXZ01'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 40. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Short text'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD MENGE

wa_fieldcatalog2-col_pos = 7. "position of the column

wa_fieldcatalog2-fieldname = 'MENGE'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 13. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'PO QTY'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD EINDT

wa_fieldcatalog2-col_pos = 8. "position of the column

wa_fieldcatalog2-fieldname = 'EINDT'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKET'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 18. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Item delivery date'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

*&-POPULATING THE FIELD NETPR

wa_fieldcatalog2-col_pos = 9. "position of the column

wa_fieldcatalog2-fieldname = 'NETPR'. "field name

wa_fieldcatalog2-tabname = 'IT_podetail'. "INTERNAL table name

wa_fieldcatalog2-ref_table = 'EKPO'. "FOR REFERENCE

wa_fieldcatalog2-outputlen = 11. "output length of the field.

wa_fieldcatalog2-scrtext_l = 'Net price'.

"long key word

append wa_fieldcatalog2 to it_fieldcatalog2.

clear wa_fieldcatalog2.

endform. " field_catalog

&----


*& Form build_hierarchy_header

&----


  • text

----


  • <--P_L_HIERARCHY_HEADER text

----


form build_hierarchy_header changing p_l_hierarchy_header type

treev_hhdr.

p_l_hierarchy_header-heading = 'Hierarchy Header'.

p_l_hierarchy_header-tooltip =

'This is the Hierarchy Header !'.

p_l_hierarchy_header-width = 30.

p_l_hierarchy_header-width_pix = ''.

endform. " build_hierarchy_header

&----


*& Form create_hierarchy

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form create_hierarchy .

*&---data declaration

data : l_ebeln_key type lvc_nkey,

l_ebelp_key type lvc_nkey ,

l_eindt_key type lvc_nkey. "#EC NEEDED

data : wa_detail type type_podetail.

*&--sorting the it_podetail

sort it_podetail by ebeln ebelp.

loop at it_podetail into wa_podetail.

*&---for every ebeln

at new ebeln.

read table it_podetail into wa_detail with key ebeln =

wa_podetail-ebeln.

if sy-subrc = 0.

call method tree2->add_node

exporting

i_relat_node_key = ' '

i_relationship =

cl_gui_column_tree=>relat_last_child

"here it comes like folder

is_outtab_line = wa_detail

"it takes for every new ebeln

i_node_text = 'PO NO'

importing

e_new_node_key = l_ebeln_key

"it returns the child ie., next node

exceptions

relat_node_not_found = 1

node_not_found = 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.

endif.

endat.

*&---for every ebelp

at new ebelp.

clear wa_detail.

read table it_podetail into wa_detail with key ebeln =

wa_podetail-ebeln

ebelp =

wa_podetail-ebelp

binary search.

if sy-subrc = 0.

call method tree2->add_node

exporting

i_relat_node_key = l_ebeln_key

i_relationship =

cl_gui_column_tree=>relat_last_child

"here it comes like folder

is_outtab_line = wa_detail

"it takes for every new ebelP

i_node_text = 'ITEM'

importing

e_new_node_key = l_ebelp_key

"it returns the child ie., next node

exceptions

relat_node_not_found = 1

node_not_found = 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.

endif.

endat.

*&---for eindt

clear wa_detail.

read table it_podetail into wa_detail with key ebeln = wa_podetail-ebeln

ebelp = wa_podetail-ebelp

binary search.

if sy-subrc = 0.

call method tree2->add_node

exporting

i_relat_node_key = l_ebelp_key

i_relationship =

cl_gui_column_tree=>relat_last_child

"here it comes like folder

is_outtab_line = wa_detail

"it takes for every new ebeln

i_node_text = 'DATE'

importing

e_new_node_key = l_eindt_key "#EC NEEDED

"it returns the child ie next node

exceptions

relat_node_not_found = 1

node_not_found = 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.

endif.

clear wa_detail.

endloop.

endform. " create_hierarchy

Hierachial Sequential ALV:

report z_alv_hierachial_sequential no standard page heading line-count 200 line-size 200.

*&--Type Group

type-pools : slis.

*&--Tables

tables : vbak , vbap.

*&--Types

types : begin of type_vbak,

vbeln type vbak-vbeln,

erdat type vbak-erdat,

netwr type vbak-netwr,

kunnr type vbak-kunnr,

end of type_vbak.

types : begin of type_vbap,

vbeln type vbap-vbeln,

posnr type vbap-posnr,

matnr type vbap-matnr,

arktx type vbap-arktx,

end of type_vbap.

*&--Internal Tables

data : it_vbak type standard table of type_vbak,

it_vbap type standard table of type_vbap,

it_fcat type slis_t_fieldcat_alv.

*&--Work Areas

data : wa_vbak type type_vbak,

wa_vbap type type_vbap,

wa_fcat type slis_fieldcat_alv,

wa_keyinfo type slis_keyinfo_alv.

*&--Variables

data : v_kunnr type kna1-kunnr.

*&--Selection Screen

selection-screen begin of block bl1 with frame title text-001.

select-options : s_kunnr for v_kunnr.

selection-screen end of block bl1.

*&--Main Logic

start-of-selection.

*&--Fetch vbak

select vbeln erdat netwr kunnr into table it_vbak

from vbak

where kunnr in s_kunnr.

sort it_vbak by vbeln.

*&--Fetch vbap

select vbeln posnr matnr arktx into table it_vbap

from vbap

for all entries in it_vbak

where vbeln = it_vbak-vbeln.

sort it_vbap by vbeln posnr.

*&---Field Catalog for vbak

wa_fcat-col_pos = 1.

wa_fcat-fieldname = 'VBELN'.

wa_fcat-tabname = 'IT_VBAK'.

wa_fcat-seltext_m = 'Order No'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 2.

wa_fcat-fieldname = 'ERDAT'.

wa_fcat-tabname = 'IT_VBAK'.

wa_fcat-seltext_m = 'Order Date'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 3.

wa_fcat-fieldname = 'NETWR'.

wa_fcat-tabname = 'IT_VBAK'.

wa_fcat-seltext_m = 'Order Value'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 4.

wa_fcat-fieldname = 'KUNNR'.

wa_fcat-tabname = 'IT_VBAK'.

wa_fcat-seltext_m = 'Customer No'.

append wa_fcat to it_fcat.

clear wa_fcat.

*&---Field Catalog for VBAP

wa_fcat-col_pos = 1.

wa_fcat-fieldname = 'VBELN'.

wa_fcat-tabname = 'IT_VBAP'.

wa_fcat-seltext_m = 'Order No'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 2.

wa_fcat-fieldname = 'POSNR'.

wa_fcat-tabname = 'IT_VBAP'.

wa_fcat-seltext_m = 'Item No'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 3.

wa_fcat-fieldname = 'MATNR'.

wa_fcat-tabname = 'IT_VBAP'.

wa_fcat-seltext_m = 'Material No'.

append wa_fcat to it_fcat.

clear wa_fcat.

wa_fcat-col_pos = 4.

wa_fcat-fieldname = 'ARKTX'.

wa_fcat-tabname = 'IT_VBAP'.

wa_fcat-seltext_m = 'Material Description'.

append wa_fcat to it_fcat.

clear wa_fcat.

*&--Key Information

wa_keyinfo-header01 = 'VBELN'.

wa_keyinfo-item01 = 'VBELN'.

*&--Function Module

call function 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_CALLBACK_PROGRAM =

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • IS_LAYOUT =

it_fieldcat = it_fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

i_tabname_header = 'IT_VBAK'

i_tabname_item = 'IT_VBAP'

  • I_STRUCTURE_NAME_HEADER =

  • I_STRUCTURE_NAME_ITEM =

is_keyinfo = wa_keyinfo

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE =

  • IR_SALV_HIERSEQ_ADAPTER =

  • IT_EXCEPT_QINFO =

  • I_SUPPRESS_EMPTY_DATA = ABAP_FALSE

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab_header = it_vbak

t_outtab_item = it_vbap

  • 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.

Regards,

Deepthi.

0 Kudos

Hi Deepthi ,

i want this in ABAP only not in OOPS plz send that

Former Member
0 Kudos

hi,

Hierarchical sequential list: function module

'REUSE_ALV_HIERSEQ_LIST_DISPLAY'.for more information visit the link:

http://www.saptechies.com/alv-faq--general-information/.Hope this helps

Former Member
0 Kudos

- for hierarchical sequential tables (class CL_SALV_HIERSEQ_TABLE)

- for tree structures (class CL_SALV_TREE)

praveen_kumar132
Participant
0 Kudos

Hi ,

Please go through this code .

TABLES: VBAK,VBAP.

TYPE-POOLS: slis.

TYPES:BEGIN OF TY_VBAK,
        vbeln TYPE VBAK-vbeln,
        expand,
      END OF TY_VBAK,

      BEGIN OF TY_VBAP,
        vbeln TYPE vbeln,
        posnr TYPE posnr,
        matnr TYPE matnr,
        netpr TYPE netpr,
      END OF TY_VBAP.
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.

DATA: IT_VBAP_fieldcat TYPE slis_t_fieldcat_alv,
      WA_VBAP_fieldcat TYPE slis_fieldcat_alv.

DATA: s_layout TYPE slis_layout_alv.

DATA: s_keyinfo TYPE slis_keyinfo_alv.

*INITIALIZATION
INITIALIZATION.
  s_layout-subtotals_text = 'SUBTOTAL TEXT'.
  s_layout-key_hotspot = 'X'.
  s_layout-expand_fieldname = 'EXPAND'.

  s_keyinfo-header01 = 'VBELN'.
  s_keyinfo-item01   = 'VBELN'.

*START OF SELECTION
START-OF-SELECTION.

  PERFORM FIELDCATALOG.

  SELECT vbeln  FROM vbak
                      INTO TABLE IT_VBAK
                      UP TO 25 ROWS.

  IF NOT IT_VBAK  IS INITIAL.

    SELECT vbeln
           posnr
           matnr
           netpr  FROM vbaP
                  INTO TABLE IT_VBAP
                  FOR ALL ENTRIES IN IT_VBAK
                  WHERE vbeln = IT_VBAK-vbeln.
  ENDIF.
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM             =  SY-REPID
      IS_LAYOUT                      =  s_layout
      IT_FIELDCAT                    =  IT_VBAP_fieldcat
      I_TABNAME_HEADER               =  'IT_VBAK'
      I_TABNAME_ITEM                 =  'IT_VBAP'
      IS_KEYINFO                     =   s_keyinfo
   TABLES
      T_OUTTAB_HEADER                = IT_VBAK
      T_OUTTAB_ITEM                  = IT_VBAP
   EXCEPTIONS
     PROGRAM_ERROR                  = 1
     OTHERS                         = 2
            .

*&---------------------------------------------------------------------*
*&      Form  FIELDCATALOG
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM FIELDCATALOG.
  WA_VBAP_fieldcat-col_pos   = '1'.
  WA_VBAP_fieldcat-fieldname = 'VBELN'.
  WA_VBAP_fieldcat-tabname   = 'IT_VBAK'.
  WA_VBAP_fieldcat-rollname  = 'VBELN'.
  WA_VBAP_fieldcat-outputlen = '12'.
  APPEND WA_VBAP_fieldcat TO IT_VBAP_fieldcat.
  CLEAR: WA_VBAP_fieldcat.

  WA_VBAP_fieldcat-col_pos   = '1'.
  WA_VBAP_fieldcat-fieldname = 'VBELN'.
  WA_VBAP_fieldcat-tabname   = 'IT_VBAP'.
  WA_VBAP_fieldcat-rollname  = 'VBELN'.
  WA_VBAP_fieldcat-outputlen = '12'.
  APPEND WA_VBAP_fieldcat TO IT_VBAP_fieldcat.
  CLEAR: WA_VBAP_fieldcat.

  WA_VBAP_fieldcat-col_pos   = '2'.
  WA_VBAP_fieldcat-fieldname = 'POSNR'.
  WA_VBAP_fieldcat-tabname   = 'IT_VBAP'.
  WA_VBAP_fieldcat-rollname  = 'POSNR'.
  APPEND WA_VBAP_fieldcat TO IT_VBAP_fieldcat.
  CLEAR: WA_VBAP_fieldcat.

  WA_VBAP_fieldcat-col_pos   = '3'.
  WA_VBAP_fieldcat-fieldname = 'MATNR'.
  WA_VBAP_fieldcat-tabname   = 'IT_VBAP'.
  WA_VBAP_fieldcat-rollname  = 'MATNR'.
  APPEND WA_VBAP_fieldcat TO IT_VBAP_fieldcat.
  CLEAR: WA_VBAP_fieldcat.

  WA_VBAP_fieldcat-col_pos   = '4'.
  WA_VBAP_fieldcat-fieldname = 'NETPR'.
  WA_VBAP_fieldcat-tabname   = 'IT_VBAP'.
  WA_VBAP_fieldcat-rollname  = 'NETPR'.
  WA_VBAP_fieldcat-do_sum    = 'X'.
  APPEND WA_VBAP_fieldcat TO IT_VBAP_fieldcat.
  CLEAR: WA_VBAP_fieldcat.
ENDFORM.                    "FIELDCATALOG

0 Kudos

Hi Praveen,

your answer is some what helpful but actually my requirement is i want to display in tree format