Skip to Content
author's profile photo Former Member
Former Member

tree structure in f4 help

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 31, 2008 at 08:21 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.