This is the last installment of this series. Although it took some time, I enjoyed putting it together and hope you found it useful.
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.
Now I’m going to show how easy it is to use the variant component in your own Web Dynpro component. Start off by creating a new Web Dynpro component that uses one or more components of type WDR_SELECT_OPTIONS and this custom variant component.
In your view Layout, add a ViewContainer UI element. In the associated window, right-click on the ViewContainer and embed the ZES_SELOPT_VARIANT component.
In your view Context, create a new controller usage of both Select Options and the Variant components.
In your view WDDOINIT method, initialize the Select Options component just as you would any other time. My method looks like this.
After initialization of the selection screen, you must initialize the ZES_SELOPT_VARIANT component. After creating the component usage, you get a handle to the interface and do both of the following:
- Set the program name. All variants are saved against this report id.
- Append one or more selection screens to the variant. All fields from all selection screens are available within the variant. An important caveat: if you attach more than one selection screen to the variant, you must manage distinct field names.
It’s really that easy. Save and activate your component and you’ll have a robust selection screen with classic variant functionality.
Thanks for reading about it. Feel free to drop a comment with questions or suggestions.