The problem

In the old version of WDR_SELECT_OPTIONS (not v2) there is a general issue with controlling the layout of the create Selection Screen. You can create it dynamically, predefine the layout, but later it’s difficult to get access and adjust if it resets. This is for example visible when updating text labels – they need to be removed and recreated and end up last on the element list.

I know that it’s an obsolete approach, and V2 should be used with the more unified looks. But in my case the old version fit my needs, so why not.

The idea

Initially I implemented a post-exit on the wddomodify view of the WD WDR_SELECT_OPTIONS, and that would do, but it would mean my enhancement in there needs to know and access the class I created for managing my selection screen.
If I had more usages of that component it would mean a numer of post-exit implementations on that method, each per layout – that is not a clean solution, something better needs to exist.

The solution

  1. First off I encapsulated control of my selection screen in a dedicated class, so that field value retrieval (with all the dereferrencing), screen initialization etc is made easier. I also keep a reference of the select options in an attribute (IF_WD_SELECT_OPTIONS).
  2. Second I enhanced IF_WD_SELECT_OPTIONS with an event, that I would raise each time the original view was modified, this can be done with Enhancement Framework. It has the IR_VIEW reference parameter of type IF_WD_VIEW

    SCREEN_INIT Instance Event

  3. Then in the assistance class of the selection component I added a raise method

    RAISE EVENT if_wd_select_options~screen_init EXPORTING ir_view = ir_view.

  4. Then I enhanced wddomodify of SELECTION_SCREEN view of WDR_SELECT_OPTIONS with a post-exit to only trigger this event, and pass the view variable, If you need you could also pass FIRST_TIME flag.

    wd_assist
    ->raise_screen_init( ir_view = view ).

  5. In my custom class I created an event handler, that would react to the view changes as represented by that IF_WD_SELECT_OPTIONS even, and fix the layout each time for me. As an importing parameter I pass the VIEW (IF_WD_VIEW).

    methods
    LAYOUT for event SCREEN_INIT of IF_WD_SELECT_OPTIONS
    importing
           !IR_VIEW
    .

  6. In that method I can adjust the view as I want each time it’s reset:

        lr_root_container ?= ir_view->get_element( ‘CONTENT’ ).

     CHECK lr_root_container->get_child( id = ‘BL01’ ) IS NOT INITIAL.

     lr_matrix   = cl_wd_matrix_layout=>new_matrix_layout( container = lr_root_container stretched_horizontally = abap_false ).

     lr_root_container->set_width( value = ‘750px’  ).

     lr_root_container->set_layout( lr_matrix ).

This way if I ever need to apply a similar solution to another app I don’t have to touch that WDR_SELECT_OPTIONS component, but only subscribe to the event of the interface IF_WD_SELECT_OPTIONS and make my layout changes there.
I can keep the labels where i want them, align blocks one to another and control the width as I please like in my attachment – I marked with red some of the changes I was after.

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