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

How to create menu tree with checkbox

Hi friends,

I had a requirement of creating menu with checkbox.

simlar to pfcg->create new activity group -> (Copy menu) From SAP Menu ->

a menu list with checkbox is generated.

A

- B

- b1

- b2

- C

- D

This is a simple menu but i want a checkbox before B, C & D and b1 and b2.

So that I can select the nodes and do the necessary operations based on that.

please help me out.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Mar 24, 2006 at 02:01 PM

    Hello Sanjeev,

    i can give you few pointers for solving your problem.

    firstly you can use <b>cl_column_tree_model</b>to create the tree.

    now the tree creation flow goes like this

    1.Create a screen with a control area. CCAREA_TREE

    2.Create an instance of the class which we are using for the tree control

    data : gref_tree TYPE REF TO cl_column_tree_model,

    gref_docking_container TYPE REF TO cl_gui_custom_container,

    xt_treemcitac TYPE treemcitac,

    ls_treemcitac LIKE LINE OF xt_treemcitac.

    3.Create tree model for the instance of the class.

    create object gref_tree

    exporting

    node_selection_mode = cl_column_tree_model=>node_sel_mode_single

    • HIDE_SELECTION =

    • EXCEPTIONS

    • ILLEGAL_NODE_SELECTION_MODE = 1

    • others = 2

    .

    4. Now we require to create containers for the tree model

    create object gref_docking_container

    exporting

    • PARENT =

    container_name = 'CCAREA_TREE'

    • STYLE =

    • LIFETIME = lifetime_default

    • REPID =

    • DYNNR =

    • NO_AUTODEF_PROGID_DYNNR =

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

    5. Create the view control for the tree model.

    CALL METHOD gref_tree->create_tree_control

    EXPORTING

    • LIFETIME =

    parent = gref_docking_container

    • SHELLSTYLE =

    • IMPORTING

    • CONTROL =

    • EXCEPTIONS

    • LIFETIME_ERROR = 1

    • CNTL_SYSTEM_ERROR = 2

    • CREATE_ERROR = 3

    • FAILED = 4

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

    6. Define the nodes of the tree

    ls_treemcitac-node_key = key.

    ls_treemcitac-item_name = 'COL1'.

    ls_treemcitac-text = 'test1'.

    ls_treemcitac-class = <b>cl_column_tree_model=>ITEM_CLASS_CHECKBOX</b> .

    *"item_class_link.

    APPEND ls_treemcitac TO xt_treemcitac.

    7. finally add nodes to the tree

    CALL METHOD gref_tree->add_items

    EXPORTING

    item_table = gt_treemcitac

    • EXCEPTIONS

    • NODE_NOT_FOUND = 1

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

    To sum it up.. you need to check the attributes for <b>cl_column_tree_model</b>.

    I ll be glad to answer your further queries.

    Regards,

    Kinshuk Saxena

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Sanjeev,

      If we are not using classes then i feel the only way to do that is list tree, but here i dont find a way to insert a <i>check box</i>.

      the most that can be done is a <i>input</i> box of desired length.

      If you have a look at the procedure of the list tree

      DATA: gt_nodes LIKE TABLE OF <b>snodetext</b> WITH KEY id, 
            gd_nodes LIKE snodetext.
      
      <b>gd_nodes-input  </b> = 'X'.
      gd_nodes-kind    = ' '.
      gd_nodes-hotspot = 'X'.
      gd_nodes-tlength = 2.
      gd_nodes-tcolor  = 0.
      
      append gd_nodes to gt_nodes.
      
       CALL FUNCTION 'RS_TREE_CONSTRUCT'
            EXPORTING
                 insert_id          = '000000'
                 relationship       = ' '
            TABLES
                 nodetab            = gt_nodes
            EXCEPTIONS
                 tree_failure       = 1
                 id_not_found       = 2
                 wrong_relationship = 3
                 OTHERS             = 4.
       IF sy-subrc <> 0.
         MESSAGE ID 'CNV_MBT' TYPE 'E' NUMBER 016.
       ENDIF.
      
       CALL FUNCTION 'RS_TREE_LIST_DISPLAY'
            EXPORTING
                 callback_program      = lv_callback_program
               EXCEPTIONS
                 OTHERS                = 1.

      in the above example check the structure <b>snodetext</b>. you can use it as an alternative to check box but not exactly check box.

      Hope you find this answer useful.

      regards,

      Kinshuk Saxena

      PS do reward points if you find the answer useful

  • Posted on Mar 24, 2006 at 03:06 PM

    Hi Sanjev,

    Please take a look at this SAP demo programs.

    <b>SAPCOLUMN_TREE_CONTROL_DEMO

    SAPTLIST_TREE_CONTROL_DEMO

    SAPSIMPLE_TREE_CONTROL_DEMO</b>

    Hope this will help.

    Regards,

    Ferry Lianto

    Add a comment
    10|10000 characters needed characters exceeded

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.