Skip to Content

The series Web Dynpro Selection Screen Variants concludes with a demonstration of using component ZWDR_SELECT_OPTIONS_VARI within a Web Dynpro report selection-screen.

Part 5: Variants in Action

Open an existing Web Dynpro which implements a selection screen using component WDR_SELECT_OPTIONS. For this demonstration, we use a selection screen of fields from table SFLIGHT.

Add component ZWDR_SELECT_OPTIONS_VARI as a used component. Name the usage VARIANTS.

View

Add the VARIANTS used component interface controller to the view containing the selection screen,

Methods

In the view containing the selection screen, add the following into hook method WDDOINIT to initialize the variants component usage and link it with the current application and selection screen object. In the code snippet below, the object named selection_screen is the selection screen object obtained from the WDR_SELECT_OPTIONS component usage.

* -- Initialize the select-options variants component usage

  DATA(lo_cpuse_variants) = wd_this->wd_cpuse_variants( ).

  IF lo_cpuse_variants->has_active_component( ) IS INITIAL.
    lo_cpuse_variants->create_component( ).
  ENDIF.

* -- Initialize the variants component with this component's name, application and all
*    select-options

  DATA(lo_ifc_variants) = wd_this->wd_cpifc_variants( ).

  lo_ifc_variants->initialize(
    component_name     = wd_comp_controller->wd_get_api( )->get_component_info( )->get_name( )
    application_name   = wd_comp_controller->wd_get_api( )->get_component( )->get_application( )->get_application_info( )->get_name( )
    select_options_set = VALUE #( ( selection_screen ) )
  ).

Layout

In the view containing the selection screen, add a ViewContainerUIElement to the layout in the position where you want the variants button to appear. Assign the container ID, VC_VARIANTS.

Window

Lastly, embed interface view W_VARI of used component ZWDR_SELECT_OPTIONS_VARI into ViewContainerUIElement VC_VARIANTS.

Run the Application

Now your selection screen will include a Variants button offering users three familiar options: Get, Delete and Save as Variant.

Get Variant

When the user selects to Get a variant, a search help will guide them to select a variant.

Delete Variant

When the user selects to Delete a variant, a search help will guide them to select one or more variants and a confirmation dialog will confirm the deletion.

Save as Variant

When the user selects Save as Variant, a dialog will prompt them to enter a name and description for their variant.

To report this post you need to login first.

4 Comments

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

  1. Kazuo Azuma

    Hi Amy san

    I have a one question about sample coding(initialize the variants),
    an error occurred in the following message…..

    Field “SELECTION_SCREEN” is unknown. It is neither in one of the specified tables nor defined by a “DATA” statement. “DATA” statement…..

    what is the cause of the error?

    regards

    azuma

    (0) 
    1. Amy King Post author

      Hi Azuma,

      There must be someplace where you are using the field “selection_screen” where it has not yet been defined. If you click on the error message in SAPgui, the IDE should bring you to the location of the error.

      Cheers,
      Amy

       

      (0) 
  2. Kazuo Azuma

    Hi Amy san

    The point of my question is about the following sample code;method WDDOINIT…

    DATA(lo_ifc_variants) = wd_this->wd_cpifc_variants( ).

    lo_ifc_variants->initialize(
    component_name = wd_comp_controller->wd_get_api( )->get_component_info( )->get_name( )
    application_name = wd_comp_controller->wd_get_api( )->get_component( )->get_application( )->get_application_info( )->get_name( )
    select_options_set = VALUE #( ( selection_screen ) )
    ).

    Is this selection_screen a reserved word? Or is it necessary to declare?

    Regards

    azuma

    (0) 
    1. Amy King Post author

      Hi Azuma,

      That variable name is only a place holder. This final chapter of the series details how to add the variants feature to an existing web dynpro component which already uses a selection-screen. The code snippet is meant to be added into whichever view uses the IF_WD_SELECT_OPTIONS object. It is this object which is represented by the placeholder, selection_screen.

      In the code snippet below, the object named selection_screen is the selection screen object obtained from the WDR_SELECT_OPTIONS component usage.

      I hope that helps to clarify.

      Cheers,
      Amy

      (0) 

Leave a Reply