Skip to Content

Introduction

I was looking for a custom solution for the F4-functionality in WebDynpro for ABAP, when I encountered the lack of information provided for the moment. Maybe the forum viewers would like to know what I’ve been doing with the information I requested. That’s why I decided to post an overview of the result.

I have to thank Rich Heilmann for the Using Select Options in a Web Dynpro(ABAP) Application he did on select option, it helped me almost at the point of delivery.

Get what you need

I started out by copying the selection template WDR_SELECT_OPTIONS that was allready there and just removed the button row out of the layout of the view SELECTION_SCREEN.

image

That way I had my own component for it ZKLAB_DEMO_HELP.

So far, so good. All I needed was the value help itself, so i created a component ZF4_PROFILE (because I’ll be looking for project profiles 😉 ). Double click on the component and add the component use of the freshly created help functionality.

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro2.jpg|height=295|alt=image|width=457|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro2.jpg|border=0!

and implement the needed interface for the value help.

image

Now go to the component controller and add an attribute M_LISTENER, this one will handle the events in the called popup.

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro4.jpg|height=163|alt=image|width=467|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro4.jpg|border=0!

image

In the properties you should define component use for the value_help you just selected, this will create the events automatically. In the methods I added the following:

image


method CANCEL .

wd_this->m_listener->CLOSE_WINDOW( ).

endmethod.

METHOD selection_made .
DATA: ls_profile TYPE zklab_demo_profile.
wd_this->m_listener->f4_context_element->get_static_attributes( importing static_attributes = ls_profile ).
ls_profile-project_profile = id.

wd_this->m_listener->f4_context_element->set_static_attributes( ls_profile ).

wd_this->m_listener->close_window( ).

ENDMETHOD.

method SET_VALUE_HELP_LISTENER .
wd_this->m_listener = listener.

endmethod.

Selection screen

For this I should redirect you to Rich’s blog . You just have to add a few things on top of that. I added a search and cancel button (instead of the continue button). And the actions linked to them as wel as the selection of a tableview row.

In the tableview I just added an onSelect action:

image

TYPE table.

  • Retrieve the data from the select option

  rt_profile = wd_this->m_handler->get_range_table_of_sel_field(

                           i_id = ‘S_PROJECT_PROFILE’ ).

  • Assign it to a field symbol

  ASSIGN rt_profile->* TO .

  • Retrieve that data from the database.  Normally it is suggested to

  • encapsulate the data retrieval in a separate class.

  • For simplicity, the SELECT statement has been implemented here.

  • CLEAR iscc. REFRESH iscc.

CALL FUNCTION ‘ZKLAB_GET_PROFILES’

    DESTINATION ‘ID4CLNT800’

    TABLES

      profiles = lt_profiles

      id = .

  • Bind the data to the context

    node_profile = wd_context->get_child_node( name = `PROFILES` ).

    node_profile->bind_elements( lt_profiles ).

  • ENDIF.

endmethod.

METHOD onactionselected .

  DATA: node TYPE REF TO if_wd_context_node,

        elements TYPE wdr_context_element_set,

        element TYPE REF TO if_wd_context_element,

        selected_elements TYPE wdr_context_element_set,

        row TYPE REF TO if_wd_context_element,

        lv_line TYPE zklab_demo_propro,

        lo_component type ref to IF_WD_COMPONENT.                     “#EC NEEDED

  node = wd_context->get_child_node( ‘PROFILES’ ).

  selected_elements = node->get_selected_elements( ).

  READ TABLE selected_elements INTO row INDEX ‘1’.

  IF sy-subrc EQ 0.

    row->get_static_attributes( IMPORTING static_attributes = lv_line ).

  ENDIF.

  node->set_attribute( name = ‘PROFIDPROJ’ value = lv_line-profidproj ).

  wd_comp_controller->selection_made( lv_line-profidproj ).

ENDMETHOD.

METHOD wddoexit .

  DATA: lr_usage TYPE REF TO if_wd_component_usage.

  lr_usage =   wd_this->wd_cpuse_select_options( ).

  IF lr_usage->has_active_component( ) IS NOT INITIAL.

    lr_usage->delete_component( ).

  ENDIF.

ENDMETHOD.

METHOD wddoinit .

  DATA:

  lt_range_table       TYPE REF TO data,

  rt_range_table       TYPE REF TO data,

  read_only            TYPE abap_bool,

  typename             TYPE string.

  DATA:

    lr_componentcontroller TYPE REF TO ig_componentcontroller,

    l_ref_cmp_usage TYPE REF TO if_wd_component_usage.

  • create the used component

  l_ref_cmp_usage = wd_this->wd_cpuse_select_options( ).

  IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.

    l_ref_cmp_usage->create_component( ).

  ENDIF.

*instantiate m_view

  • wd_this->m_view ?= wd_this->wd_get_api( ).

  • get a pointer to the interface controller of the select options

*component

  wd_this->m_wd_select_options =

       wd_this->wd_cpifc_select_options( ).

  • init the select screen

  wd_this->m_handler =

       wd_this->m_wd_select_options->init_selection_screen( ).

  • create a range table that consists of this new data element

  lt_range_table =

    wd_this->m_handler->create_range_table(

         i_typename = ‘PROFIDPROJ’ ).

  • add a new field to the selection

  wd_this->m_handler->add_selection_field(

                 i_id = ‘S_PROJECT_PROFILE’

                 it_result = lt_range_table

                 i_read_only = read_only ).

ENDMETHOD.

The called bapi is just a getlist function that works with range input ant table output. Now everything is set up on the side of the plugin, just creating a main screen left.

Main view

I went for only one view, with a series of inputfields, of which one is prepared with a custom F4 functionality. Therefor I needed to add the used components:

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro9.jpg|height=272|alt=image|width=400|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro9.jpg|border=0!

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro8.jpg|height=292|alt=image|width=342|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro8.jpg|border=0!

Include the components and interface in your main component.

Add the used components to you main view:

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro10.jpg|height=315|alt=image|width=442|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro10.jpg|border=0!

Select the attribute you want the Value help for in your context, and update the properties like this:

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro11.jpg|height=129|alt=image|width=494|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro11.jpg|border=0!

Now you should be able to see the following when you execute your main application:

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro12.jpg|height=222|alt=image|width=363|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro12.jpg|border=0!

use the F4

!https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro13.jpg|height=300|alt=image|width=314|src=https://weblogs.sdn.sap.com/weblogs/images/251706049/dynpro13.jpg|border=0!

Select one and the (key)value is passed to the main screen.

To report this post you need to login first.

4 Comments

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

  1. Labie Koen Post author
    Thank you very much, I’m under the impression that your blog has disappeared, I can no longer find it in the search eather.

    grtz

    Koen

    (0) 
  2. Cristian Berri
    Hi Koen,
    Are you still updating this blog?
    It seems that there are some missing steps.
    It would be great if you can add a “map” of the different objects involved in this development, because it is a bit confussing.
    thanks
    (0) 
  3. Gopi Gopi
    I have gone through the blog but some how the information provided doesn’t seems to be clear.
    It would be better if you can add some more steps to make it clear.
    (0) 

Leave a Reply