SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software
Development resources, articles, tutorials, code samples, tools and downloads for SAP HANA and ABAP, HANA Database, SQLScript, SAP UI5, Screen Personas, Web Dynpro, Workflow


ABAP - Create Hierarchy Tree List using rs_tree_construct, rs_tree_list_display and snodetext


RS_TREE_LIST_DISPLAY is a function module which is used to display hierarchy.
rs_tree_list_display function module enables ABAP developers to display hierarchy structures.
It is also possible for ABAP programmers to manipulate hierarchies interactively.
Using rs_tree_list_display it is possible to use different colors for link nodes, node texts and to use icons for link nodes.

Here is the sample hierarchy tree screen display of the ABAP report example.
You can find the ABAP code of the example ABAP report used to create hierarchy tree list using rs_tree_list_display.

ABAP-rs_tree_list_display-for-hierarchy





Here is an ABAP sample report with ABAP source code for ABAP developers displaying the Chapter hierarchy tree of ABAP Objects book using rs_tree_construct and rs_tree_list_display.

REPORT zCreate_treelist_sample .

DATA :
  gs_nodetab TYPE snodetext,
  gt_nodetab TYPE TABLE OF snodetext.

TYPES :
  BEGIN OF gty_contents,
    name TYPE seu_name,
    tlevel TYPE seu_level,
    text TYPE seu_text,
  END OF gty_contents.

DATA :
  gs_contents TYPE gty_contents,
  gt_contents TYPE TABLE OF gty_contents.

CLEAR gt_contents.
CLEAR gs_contents.

gs_contents-name = 'Contents'.
gs_contents-tlevel = '01'.
gs_contents-text = 'ABAP Objects'.
APPEND gs_contents TO gt_contents.

gs_contents-name = '1'.
gs_contents-tlevel = '02'.
gs_contents-text = 'Introduction'.
APPEND gs_contents TO gt_contents.

gs_contents-name = '1.1'.
gs_contents-tlevel = '03'.
gs_contents-text = 'What is ABAP?'.
APPEND gs_contents TO gt_contents.

gs_contents-name = '1.1.1'.
gs_contents-tlevel = '04'.
gs_contents-text = 'Evolution of ABAP'.
APPEND gs_contents TO gt_contents.

gs_contents-name = '2'.
gs_contents-tlevel = '02'.
gs_contents-text = 'Practical Introduction to ABAP'.
APPEND gs_contents TO gt_contents.

gs_contents-name = '2.1'.
gs_contents-tlevel = '03'.
gs_contents-text = 'Functionality of Sample Application'.
APPEND gs_contents TO gt_contents.

LOOP AT gt_contents INTO gs_contents.

  gs_nodetab-name = gs_contents-name.
  gs_nodetab-tlevel = gs_contents-tlevel.
  gs_nodetab-nlength = '10'.
  gs_nodetab-color = 4.
  gs_nodetab-text = gs_contents-text.
  gs_nodetab-tlength ='50'.
  gs_nodetab-tcolor = 2.
  APPEND gs_nodetab TO gt_nodetab.
  CLEAR gs_nodetab.

ENDLOOP.

CALL FUNCTION 'RS_TREE_CONSTRUCT'
  TABLES
    nodetab = gt_nodetab.

CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
  EXPORTING
    use_control = 'L'.
Code

Note that in the above ABAP program, the first ABAP code block builds the gt_contents which is a table of snodetext where the node information is stored.
The second part of the example ABAP report zCreate_treelist_sample, populates the gt_nodetab within a ABAP LOOP structure.
In the ABAP LOOP, the gs_nodetab workarea fields are read from internal table.
Then we append each workarea structure to the gt_nodetab internal table which is used to construct the ABAP hierarchy tree list using RS_TREE_CONSTRUCT function call.
After the hierarchy tree is constructed, using the RS_TREE_LIST_DISPLAY ABAP function ABAP developers can display the sample hierarchy on the SAP screen.



SAP HANA and ABAP

Install SAP Free
CRM Companies List
Web Based CRM Software


Copyright © 2004 - 2021 Eralper YILMAZ. All rights reserved.