The concept of a selection screen variant is something that most SAP users have come to expect, yet this feature is unavailable in standard Web Dynpro. Below is the next in a series of posts detailing how to bring this necessary feature back to Web Dynpro. Start here to see the full requirements.
Start your development by creating a new Web Dynpro component named ZES_SELOPT_VARIANT. This WD component will have a public interface with a few methods used to initialize the report name and selection screens. It will have one main window that contains three buttons (by default): Get Variant, Save Variant, and Delete Variant.
In the Web Dynpro component, we’ll need to use two instances of the Web Dynpro ALV component:
|ALV1||SALV_WD_TABLE||List of existing selection screen variants for this Web Dynpro application)|
|ALV2||SALV_WD_TABLE||List of fields assigned to this set of selection screens.|
In the Component Controller, add the following context nodes:
Node: TEXT stores the values of various labels used through the component.
Node: IN stores values that are bound to various screen elements throughout. This elements in this node could have used a little more structure – maybe split out by view - given the time.
Node: VARIANT_LIST is a table of variants associated with the REPORT_NAME assigned when the component is initialized.
Node: VARIANT_FIELDS holds a table of fields associated with the currently selected (or newly created) variant.
Node: FIELD_PARAMS is a single-line structure that holds the values selected by the user from view V_ASK_PARAMETERS that are used to help determine dynamic dates (more later).
One additional attribute is required on the Component Controller: M_CLEAR_MSGS. This value will be set at each *first* display of the W_GET_VARIANT and W_SAVE_VARIANT windows in order to prevent ‘required field’ warnings from being shown to the user. The MO_GET_WINDOW is not used. It was added as part of an attempt to get the W_GET_VARIANT window to auto-close when a row is selected.
I added the following events to the Component Controller:
The following methods were added as part of the Web Dynpro Component interface in order of importance:
SET_REPORT_NAME: Here we’re simply setting the the context node element to remember the value.
It’s also important to know what the REFRESH_VARIANT_LIST routine is doing. It’s called when the report name is set in addition to a couple of other important times. This retrieves a list of variants from the transparent table created for storing the variants for the report name indicated above. It binds this list to the VARIANT_LIST context node.
APPEND_SELOPT_SCREEN: Add the value supplied to the list of selection screens to process later when getting/saving the variant.
SHOW_BUTTONS: Show/hide Get/Save/Delete buttons (untested)
GET_VARIANT_NAME: Get variant name chosen by user (untested)
The WDDOINIT method is called immediately at initialization. First, I’m initializing the list of ‘dynamic date’ routines used later for DATS fields. Then I’m setting the labels for various controls used through the views based on logon language. Finally, I indicate that the MAIN view should show all three buttons by default.
Okay that gets a real good start on the Component Controller. In truth there are quite a few more methods on this object that we’ll get into a little later. These methods are called by user-events, but were placed at the Component Controller level, because it already had access to the shared Context nodes we created above.