17
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com © 2010 SAP AG 1 How to Achieve OVS Search Help in Select Option Applies to: SAP Net Weaver Web Dynpro for ABAP. For more information, visit the Web Dynpro ABAP homepage . Summary This tutorial provides a step-by-step guide for using OVS search help functionality in Select Option in a WDA application. This tutorial assumes that have a good understanding of the basics of Web Dynpro for ABAP. Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He is Computer Science Graduate and working on Technologies like ABAP, Web Dynpro ABAP, Floor Plan Manager & SAP Interactive forms,.

How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 1

How to Achieve OVS Search Help

in Select Option

Applies to:

SAP Net Weaver – Web Dynpro for ABAP. For more information, visit the Web Dynpro ABAP homepage.

Summary

This tutorial provides a step-by-step guide for using OVS search help functionality in Select Option in a WDA application. This tutorial assumes that have a good understanding of the basics of Web Dynpro for ABAP.

Author: Chinnaiya Pandian

Company: HCL AXON

Created on: 15 December 2010

Author Bio

Chinnaiya Pandian is working for HCL AXON. He is Computer Science Graduate and working on Technologies like ABAP, Web Dynpro ABAP, Floor Plan Manager & SAP Interactive forms,.

Page 2: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 2

Table of Contents

Creating the Web Dynpro for ABAP (WDA) Object ............................................................................................ 3

Define Used Components ................................................................................................................................... 4

Creating a View .................................................................................................................................................. 4

Creating Context ................................................................................................................................................. 5

Creating Layout .................................................................................................................................................. 6

Defining Attributes .............................................................................................................................................. 8

Method Implementation ...................................................................................................................................... 9

Creating Event Handler Method For OVS in Select Option .............................................................................. 10

Embed View into Window ................................................................................................................................. 12

Create the Application ...................................................................................................................................... 13

Testing the Application ..................................................................................................................................... 14

Related Content ................................................................................................................................................ 16

Disclaimer and Liability Notice .......................................................................................................................... 17

Page 3: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 3

Creating the Web Dynpro for ABAP (WDA) Object

Go to transaction code SE80. This is the ABAP Workbench. In the object list box, choose Web Dynpro Comp / Inf. Enter the name of the object as ZPC_OVS_IN_SO and hit Enter. The system will ask you if you want to create this object. Click Yes.

Enter the Description for your Component and Save it as Local object [$TMP]

Now the WDA Object has been created.

Page 4: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 4

Define Used Components

Define the used web dynpro components for the application. Double click on the web dynpro component. Add the component under the "Used Components" table. Enter CU_SELECT_OPTIONS as the Component Use, and WDR_SELECT_OPTIONS as the Component.

Creating a View

Create a view by right clicking on the object name and choose Create->View. Give the view name as "MAIN" and a description. Click on the properties tab of the view. In the "Used Controllers/Components" tab, click the create icon. Add the two components for Select_Options.

Page 5: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 5

Creating Context

Click on the Context tab of the view. Create a node called "P0002". Set the Cardinality as 0..N. Next create the attributes by right clicking on the node and choosing Create Using the Wizard->Attributes from Components of Structure. Enter PA0002 as the structure to be copied. Select all fields except MANDT and hit enter. The Context should now look like this.

Choose the fields from the Displayed structure. The Node should now look like this.

Page 6: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 6

Creating Layout

Now create the layout for the Component.

UI elements need to be created

View container – to place the Select option

Button – to get the values entered in Select option and processing

Table – to display the output data

Create View container UI element

Create Button UI element & create an action for the button with the name vact_ongetdetail

Page 7: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 7

Create Table UI element

Finally add a table to the layout, name it as "TBL_P0002", define the data source as the NODE_P0002 node from the view controller. Bind the table to the view context by right clicking on the TBL_P0002 in the ROOTUIELEMENTCONTAINER. Select all set the standard cell editor as Text View.

Page 8: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 8

Now the Lay out will look as below

Defining Attributes

Click on the Attributes tab of the view. Add the following attributes as seen here are required for the select option

Page 9: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 9

Method Implementation

Click on the Methods tab of the view. Double click on the WDDOINIT method. Add the code as you see here

METHOD wddoinit .

DATA: lt_range_table TYPE REF TO data,

rt_range_table TYPE REF TO data,

read_only TYPE abap_bool,

typename TYPE string.

DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.

lo_cmp_usage = wd_this->wd_cpuse_cu_select_option( ).

IF lo_cmp_usage->has_active_component( ) IS INITIAL.

lo_cmp_usage->create_component( ).

ENDIF.

wd_this->m_wd_select_options = wd_this->wd_cpifc_cu_select_option( ).

wd_this->m_handler = wd_this->m_wd_select_options->init_selection_screen( ).

* Setting Globle options

wd_this->m_handler->set_global_options(

i_display_btn_cancel = abap_false

i_display_btn_check = abap_false

i_display_btn_reset = abap_false

i_display_btn_execute = abap_false ).

* create a range table that consists of this new data element

lt_range_table = wd_this->m_handler->create_range_table(

i_typename = 'PERSNO' i_length = 8 ).

* add a new field to the selection

wd_this->m_handler->add_selection_field(

i_id = 'EMP_ID'

it_result = lt_range_table

i_read_only = read_only

i_no_intervals = abap_true “ disable intervals

i_value_help_type = if_wd_value_help_handler=>co_prefix_ovs ).

ENDMETHOD.

Click on the Methods List button. Double click on the ONACTIONVACT_ONGETDETAIL method. Add the code as you see here.

METHOD onactionvact_ongetdetail .

DATA: node_p0002 TYPE REF TO if_wd_context_node.

DATA: rt_p0002 TYPE REF TO data.

DATA: lt_p0002 TYPE TABLE OF pa0002.

DATA: ls_p0002 TYPE p0002.

FIELD-SYMBOLS: <fs_pernr> TYPE table.

rt_p0002 = wd_this->m_handler->get_range_table_of_sel_field(

Page 10: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 10

i_id = 'EMP_ID' ).

ASSIGN rt_p0002->* TO <fs_pernr>.

CLEAR ls_p0002.

REFRESH lt_p0002[].

SELECT * INTO CORRESPONDING FIELDS OF TABLE lt_p0002 FROM pa0002

WHERE pernr IN <fs_pernr>.

node_p0002 = wd_context->get_child_node( name = `NODE_P0002` ).

node_p0002->bind_table( lt_p0002 ).

ENDMETHOD.

Creating Event Handler Method For OVS in Select Option

Create a method ON_OVS_IN_SO choose method type as EVENTHANDLER. Add ON_OVS event of select option component in the event column

Double click on the ON_OVS_IN_SO method. Add the code as you see here

METHOD on_ovs_in_so .

TYPES : BEGIN OF ty_pernr,

pernr TYPE persno ,

vorna TYPE pad_vorna,

nachn TYPE pad_nachn,

END OF ty_pernr.

DATA : lt_pernr TYPE STANDARD TABLE OF ty_pernr,

ls_pernr LIKE LINE OF lt_pernr .

FIELD-SYMBOLS:

<lt_ovs_result> LIKE lt_pernr,

Page 11: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 11

<p0002> LIKE LINE OF <lt_ovs_result>,

<lt_sel_opt_result> TYPE STANDARD TABLE.

CASE i_ovs_data-m_ovs_callback_object->phase_indicator.

WHEN if_wd_ovs=>co_phase_0.

i_ovs_data-m_ovs_callback_object->set_configuration(

col_count = 2 table_multi_select = abap_true ).

WHEN if_wd_ovs=>co_phase_1.

** i_ovs_data-m_ovs_callback_object->set_input_structure( input = P0002 ).

WHEN if_wd_ovs=>co_phase_2.

SELECT pernr

vorna

nachn INTO CORRESPONDING FIELDS OF TABLE lt_pernr

FROM pa0002 UP TO 10 ROWS.

i_ovs_data-m_ovs_callback_object->set_output_table( output = lt_pernr ).

WHEN if_wd_ovs=>co_phase_3.

ASSIGN i_ovs_data-m_ovs_callback_object->selection->* TO <lt_ovs_result>.

ASSIGN i_ovs_data-mt_selected_values->* TO <lt_sel_opt_result>.

LOOP AT <lt_ovs_result> ASSIGNING <p0002> .

INSERT <p0002>-pernr INTO TABLE <lt_sel_opt_result>.

ENDLOOP.

ENDCASE.

ENDMETHOD.

Page 12: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 12

Embed View into Window

Double-click on the window under the Windows folder in the object tree to the left. Drag and drop the MAIN view to the Window.

Expand the window, right click on VIEW_CONTAINER and select Embed View. In the dialog hit F4 on the "View to be embedded" Select the WND_SELECTION_SCREEN from the help.

The Window should now look like this.

Page 13: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 13

Create the Application

Finally, create the application and test it. Make sure that you save and activate the web dynpro component.

Page 14: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 14

Testing the Application

After executing the application we will get below screen:

After pressing the help for the personnel Number the below help table will be display

Page 15: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 15

You can choose Multiple entries

Press the get detail button to display the records for selected employee numbers

Page 16: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 16

Related Content

http://forums.sdn.sap.com/thread.jspa?threadID=1513448

Wiki for webdynpro ABAP

For more information, visit the Web Dynpro ABAP homepage

Page 17: How to Achieve OVS Search Help in Select Option · Author: Chinnaiya Pandian Company: HCL AXON Created on: 15 December 2010 Author Bio Chinnaiya Pandian is working for HCL AXON. He

How to Achieve OVS Search Help in Select Option

SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com

© 2010 SAP AG 17

Disclaimer and Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.