Application Development and Automation 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: 
Read only

Handle stack navigation in control framework application development.

Former Member
0 Likes
387

Hello,

Let me know if anyone has implemented in any application using OO controls as ALV-GRID, TREE, HTML, TextEdit, etc., using a stack of navigation similar to transaction SE80.

If anyone could implement an stack navigation, please share its experience in this forum.

Thanks.

Edited by: Roberto Rodríguez on Jun 20, 2008 9:49 PM

Edited by: Roberto Rodríguez on Jun 20, 2008 9:50 PM

2 REPLIES 2
Read only

Former Member
0 Likes
356

Roberto,

Not sure if this will help you, but I use SAPCOLUMN_TREE_CONTROL_DEMO to create a menu, but it easily could have been changed to display like SE80.

I nearly totaly rewrote there include module COLUMN_TREE_CONTROL_DEMOF01 for it and did as follows. You could easily get the info to fill the tree from tables to do as you prefer.


*-------------------------------------------------------------------
***INCLUDE column_tree_control_demoF01 .
*-------------------------------------------------------------------

*&---------------------------------------------------------------------*
*&      Form  CREATE_AND_INIT_TREE
*&---------------------------------------------------------------------*
FORM create_and_init_tree.
*  DATA: NODE_TABLE TYPE TREEV_NTAB,
*        ITEM_TABLE TYPE ITEM_TABLE_TYPE,
  DATA: event TYPE cntl_simple_event,
        events TYPE cntl_simple_events,
        hierarchy_header TYPE treev_hhdr.

* create a container for the tree control
  CREATE OBJECT g_custom_container
    EXPORTING
      " the container is linked to the custom control with the
      " name 'TREE_CONTAINER' on the dynpro
      container_name = 'TREE_CONTAINER'
    EXCEPTIONS
      cntl_error = 1
      cntl_system_error = 2
      create_error = 3
      lifetime_error = 4
      lifetime_dynpro_dynpro_link = 5.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.


* setup the hierarchy header
  hierarchy_header-heading = 'System'.                      "#EC NOTEXT
  " heading
  hierarchy_header-width = 40.         " width: 30 characters

* create a tree control

* After construction, the control contains one column in the
* hierarchy area. The name of this column
* is defined via the constructor parameter HIERACHY_COLUMN_NAME.
  CREATE OBJECT g_tree
    EXPORTING
      parent              = g_custom_container
      node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
      item_selection = 'X'
      hierarchy_column_name = 'Column1'
      hierarchy_header = hierarchy_header
    EXCEPTIONS
      cntl_system_error           = 1
      create_error                = 2
      failed                      = 3
      illegal_node_selection_mode = 4
      illegal_column_name         = 5
      lifetime_error              = 6.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.

* define the events which will be passed to the backend
  " node double click
  event-eventid = cl_gui_column_tree=>eventid_node_double_click.
  event-appl_event = 'X'. " process PAI if event occurs
  APPEND event TO events.

  " item double click
  event-eventid = cl_gui_column_tree=>eventid_item_double_click.
  event-appl_event = 'X'.
  APPEND event TO events.

  " expand no children
  event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
  event-appl_event = 'X'.
  APPEND event TO events.

  " link click
  event-eventid = cl_gui_column_tree=>eventid_link_click.
  event-appl_event = 'X'.
  APPEND event TO events.

  " button click
  event-eventid = cl_gui_column_tree=>eventid_button_click.
  event-appl_event = 'X'.
  APPEND event TO events.

  " checkbox change
  event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
  event-appl_event = 'X'.
  APPEND event TO events.

  " header click
  event-eventid = cl_gui_column_tree=>eventid_header_click.
  event-appl_event = 'X'.
  APPEND event TO events.

  CALL METHOD g_tree->set_registered_events
    EXPORTING
      events = events
    EXCEPTIONS
      cntl_error                = 1
      cntl_system_error         = 2
      illegal_event_combination = 3.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.

* assign event handlers in the application class to each desired event
  SET HANDLER g_application->handle_node_double_click FOR g_tree.
  SET HANDLER g_application->handle_item_double_click FOR g_tree.
  SET HANDLER g_application->handle_expand_no_children FOR g_tree.
*  SET HANDLER G_APPLICATION->HANDLE_LINK_CLICK FOR G_TREE.
*  SET HANDLER G_APPLICATION->HANDLE_BUTTON_CLICK FOR G_TREE.
*  SET HANDLER G_APPLICATION->HANDLE_CHECKBOX_CHANGE FOR G_TREE.
  SET HANDLER g_application->handle_header_click FOR g_tree.

* insert two additional columns

  perform add_a_column using 'Column2'      "col_name.
                             '50'           "col_width
                             'Description'. "col_text
  perform add_a_column using 'Column3'      "col_name.
                             '21'           "col_width.
                             'Tran Code'.   "col_text


* add some nodes to the tree control
* NOTE: the tree control does not store data at the backend. If an
* application wants to access tree data later, it must store the
* tree data itself.

  PERFORM build_node_and_item_table USING node_table item_table.

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

  PERFORM expand_the_root USING 'Root'.
  PERFORM expand_the_root USING 'Root2'.
*  PERFORM expand_the_root USING 'Root3'.
*  PERFORM expand_the_root USING 'Root4'.
*  PERFORM expand_the_root USING 'Root5'.


ENDFORM.                    " CREATE_AND_INIT_TREE

*&---------------------------------------------------------------------*
*&      Form  build_node_and_item_table
*&---------------------------------------------------------------------*

FORM build_node_and_item_table
  USING
    node_table TYPE treev_ntab
    item_table TYPE item_table_type.
* Root 1
  PERFORM add_root USING node_table 'Root'.
  PERFORM add_item_info USING item_table
                              'Root'                        "node_key
                              'Column1'                     "col1_name
                              'Account'                     "col1_text
                              'Column2'                     "col2_name
                              ' '                           "col2_text
                              'Column3'                     "col3_name
                              ' '.                          "col3_text.

  PERFORM add_child USING node_table 'Root' 'Child1'.
  PERFORM add_item_info USING item_table
                              'Child1'                      "node_key
                              'Column1'                     "col1_name
                              'Add Lead'                    "col1_text
                              'Column2'                     "col2_name
                              'Add New Lead'                "col2_text
                              'Column3'                     "col3_name
                              'ZLM01'.                      "col3_text.

  PERFORM add_child USING node_table 'Root' 'Child2'.
  PERFORM add_item_info USING item_table
                              'Child2'                      "node_key
                              'Column1'                     "col1_name
                              'Modify Lead'                 "col1_text
                              'Column2'                     "col2_name
                              'Modify Existing Lead'        "col2_text
                              'Column3'                     "col3_name
                              'ZLM02'.                      "col3_text.

  PERFORM add_child USING node_table 'Root' 'Child3'.
  PERFORM add_item_info USING item_table
                              'Child3'                      "node_key
                              'Column1'                     "col1_name
                              'Display Lead'                "col1_text
                              'Column2'                     "col2_name
                              'Display Existing Lead'       "col2_text
                              'Column3'                     "col3_name
                              'ZLM03'.                      "col3_text.

  PERFORM add_child USING node_table 'Root' 'Child4'.
  PERFORM add_item_info USING item_table
                              'Child4'                      "node_key
                              'Column1'                     "col1_name
                              'Search Help'                 "col1_text
                              'Column2'                     "col2_name
                              'Search Help'                 "col2_text
                              'Column3'                     "col3_name
                              'ZLMR5'.                      "col3_text.

* Root 2
  PERFORM add_root USING node_table 'Root2'.
  PERFORM add_item_info USING item_table
                              'Root2'                       "node_key
                              'Column1'                     "col1_name
                              'Reports'                     "col1_text
                              'Column2'                     "col2_name
                              ' '                           "col2_text
                              'Column3'                     "col3_name
                              ' '.                          "col3_text.
  PERFORM add_child USING node_table 'Root2' 'Child21'.
  PERFORM add_item_info USING item_table
                              'Child21'                     "node_key
                              'Column1'                     "col1_name
                              'Lead Detail'                 "col1_text
                              'Column2'                     "col2_name
                              'Selection List'              "col2_text
                              'Column3'                     "col3_name
                              'ZLMR4'.                      "col3_text.

  PERFORM add_child USING node_table 'Root2' 'Child22'.
  PERFORM add_item_info USING item_table
                              'Child22'                     "node_key
                              'Column1'                     "col1_name
                              'Unassigned Leads'            "col1_text
                              'Column2'                     "col2_name
                              'Unassigned Leads'            "col2_text
                              'Column3'                     "col3_name
                              'ZLMR2'.                      "col3_text.

  PERFORM add_child USING node_table 'Root2' 'Child23'.
  PERFORM add_item_info USING item_table
                              'Child23'                     "node_key
                              'Column1'                     "col1_name
                              'Follow Up Required'          "col1_text
                              'Column2'                     "col2_name
                              'Follow Up Required'          "col2_text
                              'Column3'                     "col3_name
                              'ZLMR3'.                      "col3_text.

  PERFORM add_child USING node_table 'Root2' 'Child24'.
  PERFORM add_item_info USING item_table
                              'Child24'                     "node_key
                              'Column1'                     "col1_name
                              'Birthday Report'             "col1_text
                              'Column2'                     "col2_name
                              'Select Contacts by Birthdate' "col2_text
                              'Column3'                     "col3_name
                              'ZLMR6'.                      "col3_text.

  PERFORM add_child USING node_table 'Root2' 'Child25'.
  PERFORM add_item_info USING item_table
                              'Child25'                     "node_key
                              'Column1'                     "col1_name
                              'Mailing Labels'              "col1_text
                              'Column2'                     "col2_name
                              'Mailing Labels'              "col2_text
                              'Column3'                     "col3_name
                              'ZLMR8'.                      "col3_text.

  PERFORM add_child USING node_table 'Root2' 'Child26'.
  PERFORM add_item_info USING item_table
                              'Child26'                     "node_key
                              'Column1'                     "col1_name
                              'Pipeline'                    "col1_text
                              'Column2'                     "col2_name
                              'Pipeline'                    "col2_text
                              'Column3'                     "col3_name
                              'ZLMR9'.                      "col3_text.

** Root 3
*  PERFORM add_root USING node_table 'Root3'.
*  PERFORM add_item_info USING item_table
*                              'Root3'                       "node_key
*                              'Column1'                     "col1_name
*                              'Utilities'                   "col1_text
*                              'Column2'                     "col2_name
*                              ' '                           "col2_text
*                              'Column3'                     "col3_name
*                              ' '.                          "col3_text.
*
*  PERFORM add_child USING node_table 'Root3' 'Child31'.
*  PERFORM add_item_info USING item_table
*                              'Child31'                     "node_key
*                              'Column1'                     "col1_name
*                              'Maintain'                    "col1_text
*                              'Column2'                     "col2_name
*                              'Homes File'                  "col2_text
*                              'Column3'                     "col3_name
*                              'ZLMX3'.                      "col3_text.

ENDFORM.                    " build_node_and_item_table

*&---------------------------------------------------------------------*
*&      Form  add_root
*&---------------------------------------------------------------------*
FORM add_root   USING
    node_table TYPE treev_ntab
    root_name.
  node-node_key = root_name.
  " Key of the node
  CLEAR node-relatkey.      " Special case: A root node has no parent
  CLEAR node-relatship.     " node.

  node-hidden = ' '.        " The node is visible,
  node-disabled = ' '.      " selectable,
  node-isfolder = 'X'.      " a folder.
  CLEAR node-n_image.       " Folder-/ Leaf-Symbol in state "closed":
  " use default.
  CLEAR node-exp_image.     " Folder-/ Leaf-Symbol in state "open":
  " use default
  CLEAR node-expander.      " see below.
  APPEND node TO node_table.
ENDFORM.                    " add_root
*&---------------------------------------------------------------------*
*&      Form  add_child
*&---------------------------------------------------------------------*
FORM add_child USING
    node_table TYPE treev_ntab
    root_name
    child_name.

  node-node_key = child_name.
  " Key of the node
  " Node is inserted as child of the node with key 'Root'.
  node-relatkey = root_name.
  node-relatship = cl_gui_column_tree=>relat_last_child.

  node-hidden = ' '.
  node-disabled = ' '.
  node-isfolder = ' '.
  CLEAR node-n_image.
  CLEAR node-exp_image.
  node-expander = ' '. " The node is marked with a '+', although
  " it has no children. When the user clicks on the
  " + to open the node, the event expand_nc is
  " fired. The programmerr can
  " add the children of the
  " node within the event handler of the expand_nc
  " event  (see callback handle_expand_nc).
  APPEND node TO node_table.
ENDFORM.                    " add_child
*&---------------------------------------------------------------------*
*&      Form  expand_the_root
*&---------------------------------------------------------------------*
FORM expand_the_root USING    root_name.
* expand the node with key 'Root'
  CALL METHOD g_tree->expand_node
    EXPORTING
      node_key = root_name
    EXCEPTIONS
      failed              = 1
      illegal_level_count = 2
      cntl_system_error   = 3
      node_not_found      = 4
      cannot_expand_leaf  = 5.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.
ENDFORM.                    " expand_the_root
*&---------------------------------------------------------------------*
*&      Form  add_item_info
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ITEM_TABLE  text
*      -->P_ROOT_NAME  text
*      -->P_COL1_NAME  text
*      -->P_COL1_TEXT  text
*      -->P_COL2_NAME  text
*      -->P_COL2_TEXT  text
*      -->P_COL3_NAME  text
*      -->P_COL3_TEXT  text
*----------------------------------------------------------------------*
FORM add_item_info USING item_table TYPE item_table_type
                         node_key
                         col1_name
                         col1_text
                         col2_name
                         col2_text
                         col3_name
                         col3_text.

  CLEAR item.
  item-node_key = node_key.
  item-item_name = col1_name.     " Item of Column 'Column1'
  item-class = cl_gui_column_tree=>item_class_text. " Text Item
  item-text = col1_text.
  APPEND item TO item_table.

  CLEAR item.
  item-node_key = node_key.
  item-item_name = col2_name.     " Item of Column 'Column2'
  item-class = cl_gui_column_tree=>item_class_text.
  item-text = col2_text.
  APPEND item TO item_table.

  CLEAR item.
  item-node_key = node_key.
  item-item_name = col3_name.     " Item of Column 'Column3'
  " Item is a link (click on link fires event LINK_CLICK)
  item-class = cl_gui_column_tree=>item_class_text.
  item-text = col3_text.             "
  APPEND item TO item_table.

ENDFORM.                    " add_item_info
*&---------------------------------------------------------------------*
*&      Form  add_a_column
*&---------------------------------------------------------------------*
form add_a_column using    col_name
                           col_width
                           col_text.
  CALL METHOD g_tree->add_column
    EXPORTING
      name = col_name
      width = col_width
      header_text = col_text
    EXCEPTIONS
      column_exists                 = 1
      illegal_column_name           = 2
      too_many_columns              = 3
      illegal_alignment             = 4
      different_column_types        = 5
      cntl_system_error             = 6
      failed                        = 7
      predecessor_column_not_found  = 8.
  IF sy-subrc <> 0.
    MESSAGE a000.
  ENDIF.
endform.                    " add_a_column

Read only

Former Member
0 Likes
356

Not, but thanks!...

I need implement an stack navigation for return to the previous state of an application to use Controls as ALV-GRID, TREE, and others controls when the user makes a F3 (BACK).

A clear example of a stack of navigation is implemented in the transaction SE80... But it's very complex to copy in an application for a client.

I looking for someone if ever did something similar, but in a less complex way.

Thanks!