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: 

tree structure in f4 help

Former Member
0 Kudos

Hi experts,

can any one give me sample code for providing tree structure in f4help. like object part field have in iw21 transaction

Regards

reddy

2 REPLIES 2

Former Member
0 Kudos

Hi Muttukundu,

SAP has provided a lot of sample programs for developing tree structures. Just go to SE38, type BCALVTREE and hit F4. You'll get different sample programs with a range of operations on trees

Go through the link,

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

Slowly check this code..you will get idea of how to develop tree structure.

REPORT y_hierarchies_in_tables

NO STANDARD PAGE HEADING.

PARAMETER: g_group TYPE grpname. " DEFAULT 'Z_GLAB0000'.

DATA:

g_setid TYPE setid,

g_class TYPE setclass.

DATA: lt_hier TYPE STANDARD TABLE OF sethier,

lt_val TYPE STANDARD TABLE OF setvalues.

DATA: hier LIKE sethier OCCURS 0 WITH HEADER LINE,

val LIKE setvalues OCCURS 0 WITH HEADER LINE,

setinfo LIKE setinfo OCCURS 0 WITH HEADER LINE.

DATA: zaccbas(20) TYPE c OCCURS 0 WITH HEADER LINE.

DATA: miss_val LIKE setvalues-from OCCURS 0 WITH HEADER LINE.

DATA: table_name TYPE tabname,

field_name TYPE setfld.

DATA: ambiguity_flag TYPE c.

Ambiguity check

PERFORM ambiguity_check.

Display Records

PERFORM display_records.

&----


*& Form AMBIGUITY_CHECK

&----


Ambiguity check

-


FORM ambiguity_check .

DATA: it_abaplist LIKE abaplist OCCURS 0 WITH HEADER LINE.

DATA: BEGIN OF it_ascilist OCCURS 0,

zeile(256) TYPE c,

END OF it_ascilist.

DATA: flag.

SUBMIT rgsovl00 "VIA SELECTION-SCREEN

WITH p_shrtn = g_group

WITH path = 'X'

EXPORTING LIST TO MEMORY

AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = it_abaplist

EXCEPTIONS

not_found = 1

OTHERS = 2.

CALL FUNCTION 'LIST_TO_ASCI'

TABLES

listasci = it_ascilist

listobject = it_abaplist

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3 .

LOOP AT it_ascilist.

IF it_ascilist-zeile = text-001.

flag = 'X'.

ENDIF.

IF flag = 'X' AND

it_ascilist-zeile = text-002.

ambiguity_flag = 'X'.

CLEAR flag.

ENDIF.

ENDLOOP.

FREE MEMORY.

ENDFORM. " AMBIGUITY_CHECK

&----


*& Form DISPLAY_RECORDS

&----


Display the Records

-


FORM display_records .

PERFORM get_records.

PERFORM header_data.

PERFORM item_data.

ENDFORM. " DISPLAY_RECORDS

&----


*& Form GET_RECORDS

&----


Get all the Node values

-


FORM get_records .

Get the ID name for the Hierarchy

CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'

EXPORTING

shortname = g_group

setclass = g_class

old_setid = g_setid

IMPORTING

new_setid = g_setid.

Get the Table and Field name for the Top Node

CALL FUNCTION 'G_SET_GET_INFO'

EXPORTING

setname = g_setid

no_set_title = 'X'

use_table_buffer = 'X'

IMPORTING

info = setinfo.

table_name = setinfo-tabname.

field_name = setinfo-fld.

Get all the Nodes for the Hierarchy

CALL FUNCTION 'G_SET_TREE_IMPORT'

EXPORTING

no_descriptions = ' '

no_rw_info = 'X'

setid = g_setid

TABLES

set_hierarchy = lt_hier

set_values = lt_val.

hier[] = lt_hier.

val[] = lt_val.

SELECT (field_name) FROM (table_name) INTO TABLE zaccbas.

LOOP AT zaccbas.

READ TABLE val WITH KEY FROM = zaccbas.

IF sy-subrc = 0.

DELETE zaccbas.

CLEAR zaccbas.

DELETE val INDEX sy-tabix.

CLEAR val.

ENDIF.

ENDLOOP.

ENDFORM. " GET_RECORDS

&----


*& Form HEADER_DATA

&----


Header Data

-


FORM header_data .

DATA: desc TYPE settext.

READ TABLE hier WITH KEY fieldname = field_name

shortname = g_group.

IF sy-subrc = 0.

desc = hier-descript.

ENDIF.

SKIP.

WRITE: 'Node :',g_group.

WRITE:75 'User name :', sy-uname.

WRITE:/ 'Description :', desc.

WRITE:75 'Date:', sy-datum.

WRITE:/ 'Table Name :' , table_name.

WRITE:75 'Time:', sy-timlo.

WRITE:/ 'Field Name :', field_name.

write:75 'Client:', SY-MANDT.

skip.

IF ambiguity_flag = 'X'.

WRITE:/ 'Ambiguity Check :'. WRITE: 'Success' COLOR 5.

ELSE.

WRITE:/ 'Ambiguity Check :'. WRITE: 'Failed' COLOR 6 .

ENDIF.

WRITE:/ sy-uline.

WRITE:/37 'Validation for Hierarchy'.

WRITE:/ sy-uline.

ENDFORM. " HEADER_DATA

&----


*& Form ITEM_DATA

&----


Output Report for Nodes

-


FORM item_data .

IF NOT zaccbas[] IS INITIAL.

WRITE:/ 'Missing Records from Hierarchy' COLOR 3.

LOOP AT zaccbas.

WRITE:/ zaccbas.

ENDLOOP.

ENDIF.

IF NOT val[] IS INITIAL.

SKIP 1.

WRITE:/ 'Additional Records in Hierarchy' COLOR 3.

LOOP AT val.

WRITE:/ val-from. ", 28 val-DESCRIPT.

ENDLOOP.

ELSEIF ZACCBAS[] IS INITIAL.

WRITE:/ 'No Missing Records Found' COLOR 3.

ENDIF.

ENDFORM. " ITEM_DATA

Reward if found helpfull,

Cheers,

Chaitanya.

0 Kudos

Hi chaitanya,

I have searched all the BC*ALVTREE programs.but my requirement it i have to display tree structure for user when he press f4. is threre any function module or class for displaying tree in f4 help.

Regards

reddy