Step 1: Go to Tcode SE80 and Create a Webdynpro Component. Assign the component to the package or save it in the local object.
Step 2 : To the main Component, Add the component WDR_SELECT_OPTIONS in the used components tab. To use the functionality of the another webdynpro component it has to be added to our Component used components list where as if it is a standard interface it has to be added to the Implemented Interface.
Step 3: Add the interface controller of WDR_SELECT_OPTIONS in the view controller in which we need to use the select options. Doing so will create a method in the interface of the view and this method will return the object reference for the interface of the select options using which we can get the access to the select-option methods.
Click on the create controller usage button.
From the popup choose the interface controller of the select-options component.
Step 3: Go to Layout and insert View Container UI Element. This View Container UI Element is used to display the View of the other component into our View. Whenever we call the select options method and create a selection screen the output will be displayed in the view of the select options component. To display the output here in our view we need the screen into our view. For which we need view container to embed the view of the select options to our view.
Right click on the rootuielementcontainer and select insert element to insert a UI element in the view.
Provide the ID and Type for the UI element and press enter.
Step 4: Go to Window controller. Expand the Window. Right click on the Select_options(UI Container Created in previous step) and embed the view of the standard component(WDR_SELECT_OPTIONS) to be displayed in our window.
Press F4 help on the View to be embedded to choose the view.
Choose the view WND_SELECTION_SCREEN in which selection parameters will be displayed.
Press Enter after choosing the View.
You can see the view embedded to the view container.
Step 5: Now we have to write the coding in the WDDOINIT method to initialize the selection field on the screen. Go the method WDDOINIT of the View.Using Code Wizard generate the coding as mentioned below.
Step 6: First we need to Instantiate the Used Component to check for the active component usages. While adding the interface controller of the select option in the properties of the view two methods will be created in the interface for the views.
A method will be created with the naming convention wd_cpuse_ followed by the component name which we have given for select options. This method will return the object reference for the component usage using which we will check whether the component usage is active or not.
In Code wizard, general tab choose the option Instantiate Used component and select the select option which we added using the F4 Help.
Choose the component select_options.
Code will be generated as below.
Step 7: To access the method of another component we need the object reference to the interface controller of the component. While adding the interface controller of the select options component to the view controller, a method will be created with the naming convention wd_cpifc followed by the component name which we provided for it. This method will returns the object reference for the interface controller of the select option.
Using code wizard choose the radio button method call in used controller and provide the component name using F4 help.
Double click on the select options component.
Now choose the method INIT_SELECTION_SCREEN which will return you the reference to the select options interface if_wd_select_options.
Select the method INIT_SELECTION_SCREEN.
Code will be generated as below.
The reference variable lv_r_helper_class will contain the object reference to the select options interface.
Step 8:
The interface if_wd_select_options contains a method called create_range_table which is used to create a range for the select option field.Using the ABAP Object pattern call the method Create table range from the interface we are using (IF_WD_SELECT_OPTIONS).
Code will be generated as below.
Replace me with object which refers to the interface IF_WD_SELECT_OPTIONS. Pass the Data element in the place of the type name and create a range table of type ref to data same as the receiving parameter RT_RANGE_TABLE.
Modify the code as below.
Call the Method add selection field using the same procedure as mentioned above to set the selection field on the screen.
Code will be generated as below.
Replace “me” with the object referring to the IF_WD_SELECT_OPTIONS. Pass the range table which we received from the returning parameter in the previous step.
Step 10 : Save and activate the component and create an application to test the component.
Output:
We have some default buttons here in the screen to disable this button go back to the method WDDOINIT do the following. Call the method set global options and set the buttons which you don’t need as ABAP_FALSE. Click on the pattern and choose abap object pattern, Enter the interface “IF_WD_SELECT_OPTIONS” and choose the method “SET_GLOBAL_OPTIONS”.
Code wizard will generate the following code.
Remove the comments and set the buttons you don’t need as ABAP_FALSE.
Here I had disabled the buttons check and execute. The Output will look like.
Codes in the WDDOINIT Method
* instantiate the used component.
data lo_cmp_usage type ref to if_wd_component_usage.
lo_cmp_usage = wd_this->wd_cpuse_select_options( ).
if lo_cmp_usage->has_active_component( ) is initial.
lo_cmp_usage->create_component( ).
endif.
* call the method in the used controller
data lo_interfacecontroller type ref to iwci_wdr_select_options .
lo_interfacecontroller = wd_this->wd_cpifc_select_options( ).
data lv_r_helper_class type ref to if_wd_select_options.
lv_r_helper_class = lo_interfacecontroller->init_selection_screen(
).
*
* create the range table.
data rt_range_table type ref to data.
call method lv_r_helper_class->create_range_table
exporting
i_typename = ‘ebeln’
* i_length =
* i_decimals =
receiving
rt_range_table = rt_range_table.
* add selection field
call method lv_r_helper_class->add_selection_field
exporting
i_id = ‘ebeln’
* i_within_block = mc_id_main_block
* i_description =
* i_is_auto_description = abap_true
it_result = rt_range_table
i_obligatory = abap_true
* i_complex_restrictions =
* i_use_complex_restriction = abap_false
* i_no_complex_restrictions = abap_false
* i_value_help_type = if_wd_value_help_handler=>co_prefix_none
* i_value_help_id =
* i_value_help_mode =
* i_value_help_structure =
* i_value_help_structure_field =
* i_help_request_handler =
* i_lower_case =
* i_memory_id =
* i_no_extension = abap_false
* i_no_intervals = abap_false
* i_as_checkbox = abap_false
* i_as_dropdown = abap_false
* it_value_set =
i_read_only = abap_false
* i_dont_care_value =
* i_explanation =
* i_tooltip =
* i_is_nullable = abap_true
* i_format_properties =
* i_suggest_values =
.
* set global options
call method lv_r_helper_class->set_global_options
exporting
i_display_btn_cancel = abap_true
i_display_btn_check = abap_false
i_display_btn_reset = abap_true
i_display_btn_execute = abap_false .
0 Comments:
Post a Comment