Skip to Content

Dynamic ABAP WebDynpro is extremely powerful.  Here is an easy walkthrough example of reading a table at runtime to determine which tabs to dynamically create on your view.

Step 1:  Create a WebDynpro Application like the following

/wp-content/uploads/2013/01/pic__173803.jpg

Step 2:  Create a Node called ROADMAP and an Attribute called STEP (type string) in your view context

/wp-content/uploads/2013/01/pic__173803.jpg

Step 3:  Create a Table Type which will be used to store runtime information for building the tabs

/wp-content/uploads/2013/01/pic__173803.jpg

Step 4:  In the attributes of your view, declare a table of your table type

/wp-content/uploads/2013/01/pic__173803.jpg

Step 5:  In the Actions of your view, declare a “SELECT” action

/wp-content/uploads/2013/01/pic__173803.jpg

Step 6:  In the WDINIT event, add some configuration to your table that you can use to build the tabs

  data l_dyn_tabs type zphil_dyn_tabs.

  l_dyn_tabsguid = ‘A’.
  l_dyn_tabsscrntext = ‘TAB1’.
  l_dyn_tabsstype    = ’01’.
  l_dyn_tabssposid   = 01.
  append l_dyn_tabs to wd_this->dyn_tabs.

  l_dyn_tabsguid = ‘B’.
  l_dyn_tabsscrntext = ‘TAB2’.
  l_dyn_tabsstype    = ’02’.
  l_dyn_tabssposid   = 02.
  append l_dyn_tabs to wd_this->dyn_tabs.

  l_dyn_tabsguid = ‘C’.
  l_dyn_tabsscrntext = ‘TAB3’.
  l_dyn_tabsstype    = ’03’.
  l_dyn_tabssposid   = 03.
  append l_dyn_tabs to wd_this->dyn_tabs.

/wp-content/uploads/2013/01/pic__173803.jpg

Step 7:  In the WDMODIFYVIEW event, build the tabs on the view (from your table configuration)

  data l_ui_matrix_head_data type ref to cl_wd_matrix_head_data.
  data l_container type ref to cl_wd_uielement_container.
  data l_cl_wd_road_map type ref to cl_wd_road_map.
  data l_step type ref to cl_wd_road_map_step.
  data l_dyn_tabs type zphil_dyn_tabs.
  data idx_counter type i.

  if first_time = abap_true.
    call method cl_wd_road_map=>new_road_map
      exporting
        id            = ‘MYROADMAP’
        on_select     = ‘SELECT’
        selected_step = ‘ROADMAP.STEP’
      receiving
        control       = l_cl_wd_road_map.

    idx_counter = 0.
    loop at wd_this->dyn_tabs into l_dyn_tabs.
      idx_counter = idx_counter + 1.

      call method cl_wd_road_map_step=>new_road_map_step
        exporting
          id          = l_dyn_tabsguid
          description = l_dyn_tabsscrntext
        receiving
          control     = l_step.


      call method l_cl_wd_road_map->add_step
        exporting
          index    = idx_counter
          the_step = l_step.
    endloop.

    l_ui_matrix_head_data = cl_wd_matrix_head_data=>new_matrix_head_data( l_cl_wd_road_map ).
    l_cl_wd_road_map->set_layout_data( l_ui_matrix_head_data ).
    l_container ?= view->get_element( ‘ROOTUIELEMENTCONTAINER’ ).

    call method l_container->add_child
      exporting
        the_child = l_cl_wd_road_map.
  endif.

/wp-content/uploads/2013/01/pic__173803.jpg

Step 8:  Test your ABAP WebDynPro

/wp-content/uploads/2013/01/pic__173803.jpg

As you can see, this is pretty simple and powerful.  Of course, you would now need to put code into the ONACTIONSELECT method from your SELECT action.  Depending on which TAB is selected (which you can read from the context), you would fire different plugs or you could even redraw the screen with different dynamic controls.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply