RSS Feed

Credits

Sunday, December 19, 2010

OVS help in the Web Dynpro application

In one of my Scenarios, I’ve to get the Job Id and Job Description from the Database Table for Creating a Position in the Organizational Structure. I have provided the Object Value Selector (OVS) which takes Job Id and Job Description with ‘*’ (For Exact Selection it is not necessary to Use ‘*’) as input and list out all the Job Id and Job Descriptions corresponding to that Selections. On selecting one of the Entries from the Output List, the corresponding Job Id and Job Description will get displayed in the Screen.

Introduction About Object Value Selector

Generic help like value help can only be used for the field to which it is binded i.e. its scope is limited to that structure to which it is binded. But there are scenarios where we need a search help that allow multiple input fields to be populated or take multiple fields for search criteria. In this case, OVS comes into picture. OVS provide us with the selection screen that can contain multiple input fields to which our selection criteria can be restricted and displaying results values that can be used to populate different input fields.

OVS makes use of the PHASE MODEL. We have two components in picture: OVS component and Consumer component. At certain point of time, OVS Component requires some information from consumer component. For this, OVS component fires OVS event.

The parameter PHASE_INDICATOR is used to indicate the type of information requested. An event handler method in the consumer component subscribes to the OVS event and collects the information requested. For handling back this information to the OVS component, it makes use of certain methods in the OVS component. The reference to the object OVS_CALLBACK_OBJECT containing these methods is provided by the OVS event. These methods include: SET_CONFIGURATION (), SET_INPUT_STRUCTURE (), SET_OUTPUT_TABLE ().

3. Declare the WDR_OVS Component in the used component list in your WD component as shown below.

4. Now go to the View, in the Properties Tab click the Create Controller Usage Button.

5. It will open a screen with Component Use Entries. There select the Component Use OVS with Interface Controller as shown below. Press Enter.

6. It will display as follows in the View Properties.

7. Go to the Context Tab, Right Click the Context and select Create à Attribute.

8. Give Attribute Name as JOB_ID with Type SHORT_D.In the Input Help Mode Field, Select ‘Object Value Selector’ from the dropdown. Then press F4 in the Field OVS Component Usage.

9. It will open a Pop-up. Select OVS and press Enter.

10. Press Enter.

11. Create another Attribute with Name JOB_DESC and Type STEXT.

12. In the Layout Tab of the View, Right click the ROOTUIELEMENTCONTAINER and give Insert Element. It will open a Pop-Up for Creating an Element.

13. Enter LABEL_JOBID in the Name Field and Select Label in the Type Field and Press Enter.

14. Create another UI Element with INPUT_JOBID in the Name Field and Select InputField in the Type Field and Press Enter.

15. Create another UI Element with TEXT_JOBDESC in the Name Field and Select TextView in the Type Field and Press Enter.

16. In the Label Properties, Select INPUT_JOBID from the Dropdown for the labelfor Field and Enter ‘Job Id in the Text Field.

17. Create Context binding For the INPUT_JOBID by Clicking the Button in the Right Side of the value in the Properties. It will open a Popup with the Context Element. In that Select the Attribute JOB_ID and Press Enter.

18. Then Create Context binding For the TEXT_JOBDESC by Clicking the Button in the Right Side of the text in the Properties. It will open a Popup with the Context Element. In that Select the Attribute JOB_DESC and Press Enter.

19. Declare one event handler method with Name ON_OVS in the Method tab of the view. Then Press F4 in the Column Event.

20. Select the Event OVS as shown below and Press Enter.

21. Double Click the Method ON_OVS and write the Following Coding.

ON_OVS

method ON_OVS .

* declare data structures for the fields to be displayed and* for the table columns of the selection list, if necessary types: begin of lty_stru_input,* add fields for the display of your search input here job_id type string, job_desc type string, end of lty_stru_input.

types: begin of lty_stru_list,* add fields for the selection list here short type short_d, stext type stext, end of lty_stru_list.

* In this phase you can set the structure and default values* of the search structure. If this phase is omitted, the search* fields will not be displayed, but the selection table is* displayed directly.* Read values of the original context (not necessary, but you* may set these as the defaults). A reference to the context* element is available in the callback object.

when if_wd_ovs=>co_phase_2.* If phase 1 is implemented, use the field input for the* selection of the table.* If phase 1 is omitted, use values from your own context.

if ovs_callback_object->query_parameters is not bound.******** TODO exception handling endif. assign ovs_callback_object->query_parameters->* to .

if not is assigned.******** TODO exception handling endif.

* call business logic for a table of possible values* lt_select_list = ???

lv_short = -job_id. lv_stext = -job_desc.

REPLACE ALL OCCURRENCES OF '*' IN lv_short WITH '%' . REPLACE ALL OCCURRENCES OF '*' IN lv_stext WITH '%' .

IF lv_short NE ' ' AND lv_stext NE ' '.

SELECT short stext FROM hrp1000 INTO TABLE lt_select_list WHERE plvar = '01' AND otype = 'C' AND langu = 'EN' AND endda GE sy-datum AND ( short LIKE lv_short AND stext LIKE lv_stext ) ORDER BY short ASCENDING.

ELSEIF lv_short EQ ' ' AND lv_stext NE ' '.

SELECT short stext FROM hrp1000 INTO TABLE lt_select_list WHERE plvar = '01' AND otype = 'C' AND langu = 'EN' AND endda GE sy-datum AND stext LIKE lv_stext ORDER BY short ASCENDING.

ELSEIF lv_short NE ' ' AND lv_stext EQ ' '.

SELECT short stext FROM hrp1000 INTO TABLE lt_select_list WHERE plvar = '01' AND otype = 'C' AND langu = 'EN' AND endda GE sy-datum AND short LIKE lv_short ORDER BY short ASCENDING.

ENDIF.

ovs_callback_object->set_output_table( output = lt_select_list ).

when if_wd_ovs=>co_phase_3.* apply result

if ovs_callback_object->selection is not bound.******** TODO exception handling endif.