You are on page 1of 13

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

com
2010 SAP AG 1
Creating Freely Program Search
Help in WebDynpro ABAP
Applies to: WebDynpro ABAP
Summary
This document describes how we can use freely programmed search help in our WebDynpro components.
Author: Vishal Kapoor
Company: Accenture
Created on: 6 October 6, 2010

Author Bio
Vishal Kapoor is working with Accenture from last two years. He has 5 years of experience in HR ABAP,
WebDynpro and OO ABAP.
Creating Freely Program Search Help in WebDynpro ABAP
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
What is Freely Programmed Search Help .......................................................................................................... 3
How to Create is Freely Programmed Search Help ........................................................................................... 3
Related Content ................................................................................................................................................ 12
Disclaimer and Liability Notice .......................................................................................................................... 13

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 3
What is Freely Programmed Search Help
Freely programmed search help is one of the options to associate the search help with any input field of your
webdynpro ABAP screen. This allows to open a webdynpro component as F4 operation result from parent
component. It means a complete WD component appears as F4 help screen.
How to Create is Freely Programmed Search Help
In the below example, we will create a value help ( F4 help ) for one input field of our component
ZFP_CONSUMER and use component ZFP_PROVIDER which will bring the possible value in value help.
Create a WebDynpro ABAP component named ZFP_PROVIDER with view V_FPH and implement
the interface IWD_VALUE_HELP.


Make sure that your view V_FPH is embedded in the window WD_VALUE_HELP and not in the default
window created. The window WD_VALUE_HELP comes from the interface implemented above. So
Delete the default window created with the component and embed your view in window
WD_VALUE_HELP.


Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 4
Create one attribute in COMPONENTCONTROLLER VALUE_HELP_LISTENER of type
IF_WD_VALUE_HELP_LISTENER.


Go to the method SET_VALUE_HELP_LISTENER in COMPONENTCONTROLLER. This method
has come from the implemented interface. In this method, just store the listener reference in the
attribute created in above step.


Go to the EVENTS tab in COMPONENTCONTROLLER and add event VH_DATA_SELECTED.
Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 5


Create a context node name FLIGHT in COMPONENTCONTROLLER and map it into
VIEWCONTROLLER

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 6
Create one TABLE UIElement in view V_FPH and bind the context node FLIGHT with DataSOurce
property of it.


Create the binding of table with context node so that table can have as many columns as per the
attributes defined in context node FLIGHT. For that, right click on the TBL_FLIGHT (name of table
UIElement) and select Create Binding from context menu.

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 7
Select the standard cell editor as TextView and check all the check boxes for binding.


Click OK to complete the table control design. It looks like below in View Editor.

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 8
Create one button in the above screen. This will be used to close the search help screen. Name it
Close. Associate OnAction event On_CLOSE with this button.


Go in the method ON_CLOSE and write the below code.
method ONACTIONON_CLOSE.
*Select the currently selected record and pass it to the field where F4 is triggered
* i.e our consumer component ZFP_CONSUMER.
DATA lo_listener TYPE REF TO if_wd_value_help_listener.
DATA lv_attrib_name TYPE string.
*Read the attribute CARRID. We will pass this value in input field of consumer
component
DATA lo_nd_flight TYPE REF TO if_wd_context_node.
DATA lo_el_flight TYPE REF TO if_wd_context_element.
DATA ls_flight TYPE wd_this->element_flight.
DATA lv_carrid TYPE wd_this->element_flight-carrid.
* navigate from <CONTEXT> to <FLIGHT> via lead selection
lo_nd_flight = wd_context->get_child_node( name = wd_this->wdctx_flight ).
* get element via lead selection
lo_el_flight = lo_nd_flight->get_element( ).
* get single attribute
lo_el_flight->get_attribute(
EXPORTING
name = `CARRID`
IMPORTING
value = lv_carrid ).
lo_listener = wd_comp_controller->value_help_listener.
lv_attrib_name = lo_listener->f4_attribute_info-name.
lo_listener->f4_context_element->set_attribute( value = lv_carrid
name = lv_attrib_name ).
*Fire the event to indicate that data selection is done
wd_comp_controller->fire_vh_data_selected_evt( ).
*Colse the search help window
Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 9
wd_comp_controller->value_help_listener->close_window( ).
endmethod.
Fill the FLIGHT context node in the WDDOINIT method of COMPONENTCONTROLLER. There will
be the possible values for selection.


Create component ZFP_CONSUMER in object navigator (se80) with one view V_FPH. Declare the
usage of component ZFP_PROVIDER, created in above steps.


Create 1 node FLIGHT (cardinality 1:1) and 1 attribute named CARRID of type string in the
VIEWCONTROLLER. In the properties of attribute CARRID, take input help mode as freely
programmed and input help component usage as FREE_SEARCH (or whatever name you have
given during defining the component usage of ZFP_PROVIDER in above step).
Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 10


Create one InputField UIElement.

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 11
Bind the input UIElements value property with attribute CARRID.


o Create the application for ZFP_CONSUMER component and test it. The browser screen looks like:


Press F4 on the above input field. Below screen will appear.


Select any row from popup and press Close button. Values will be copied in the input field.

Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 12
Related Content
Please include at least three references to SDN documents or web pages.
Inside SDN
For more information, visit the ABAP homepage.
Creating Freely Program Search Help in WebDynpro ABAP
SAP COMMUNITY NETWORK SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com | UAC - uac.sap.com
2010 SAP AG 13
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.

You might also like