This is the second blog of 3 blogs series explaining how variants can be saved and retrieved for selection screens created in Webdynpro for ABAP. The first blog gave the outline of the process involved. This blog will focus on saving variants. Our example consists of one *Main *View having *two select options, one for customer and other for plant*. It has 2 buttons, one to save variant and other to get variants. There are 2 others views, *Save_Variant_1* ( for saving dialog) and other is *Get_Variant_1* ( for showing the list of available variants and let user choose one).The example WDA component will use *WDR_SELECT_OPTIONS* as used component. The 3 following attributes are also added to all 3 views. *M_HANDLER* type ref to IF_WD_SELECT_OPTIONS ( to keep the instance of select option handler class)0.1. *RANGE_TABLE_CUST* type ref to data ( to keep range table of customer select option)0.1. *RANGE_TABLE_PLANT* type ref to data ( to keep range table of plant select option)On *WDDOINIT *method of Main View, the used component instance is created, the instance of the select options handler class is obtained and two select options (for customer and plant) are added on the selection screen. The code for this is as following.
code is executed on *OnAction* event.
First, we get the values and options entered by user in customer and plant select options and store them in view attributes and then fire navigational outbound plug to navigate to SAVE_VARAINT_1 view along with the parameters. The SAVE_VARAINT_1 view will accept Variant name, description and Global indicator. It will look like as following.