Hi, I provide training in SAP UI5. Also feel free to checkout my new web page https://saptechblog.com
Webdynpro ABAP

Creating a freely programmed search help

Scenario: Provide the freely programmed search help to the attribute CARRID. Design a webdynpro component that provides the list of possible airline ID and use that component to provide search help for the attribute CARRID.

 

Steps to design a Search Help component:

 

Step 1: Go to the TCode SE80 and create a webdynpro component.

 

clip_image001

 

Assign the component to the package or save it in the local object.

 

 

Step 2: Add the interface IWD_VALUE_HELP to the component and re-implement the interface.

 

clip_image002

Step 3: After re-implementing the interface a window will be created in the component with the name WD_VALUE_HELP. Main view created at the time of creation of component will be embedded in the default window created at the time of creation of component. For our main view to be displayed as the f4 help it need to be embedded to the window WD_VALUE_HELP.

 

clip_image003

 

 

clip_image004

 

 

Step 4: Create an attribute value_help_listener in the attributes of the component controller to get the object reference of the search help.

 

clip_image005

 

 

SET_VALUE_HELP_LISTENER is the method that will import the object reference of the search help interface.  Write the following code inside the method.

 

clip_image006

 

 

 

Step 5: Go to the context tab of the view controller and create a context node with cardinality 0..N as shown below.

 

clip_image007

 

 

 

Step 6: Fill the values for the context node in the doinit method of the view controller.

 

clip_image009

 

 

 

Step 7: In the layout tab of the view controller create the table UI element and bind it to the context node.

 

clip_image010

 

Step 8: Create a Button UI element Ok and create an action for it.

 

clip_image011

 

 

Step 9: In the event handler method created for the Button UI element. Write the following code to transport the data selected from the search help component to the component from where the F4 help is being triggered.

 

 

Code:

 

DATA : LO_LISTENER TYPE REF TO IF_WD_VALUE_HELP_LISTENER,
       LV_NAME
TYPE STRING,
       LO_ND_SFLIGHT
TYPE REF TO IF_WD_CONTEXT_NODE,
       LO_EL_SFLIGHT
TYPE REF TO IF_WD_CONTEXT_ELEMENT,
       LS_SFLIGHT
TYPE WD_THIS->ELEMENT_SFLIGHT.

* Getting the lead selected record

LO_ND_SFLIGHT
= WD_CONTEXT->GET_CHILD_NODE(

                 NAME = WD_THIS->WDCTX_SFLIGHT ).

LO_EL_SFLIGHT
= LO_ND_SFLIGHT->GET_ELEMENT( )
.

LO_EL_SFLIGHT
->GET_STATIC_ATTRIBUTES(

 
IMPORTING
    STATIC_ATTRIBUTES
= LS_SFLIGHT ).

* Getting the object reference of interface for search help


LO_LISTENER
= WD_COMP_CONTROLLER->VALUE_HELP_LISTENER.

* Gives the name of the attribute from where F4 help is triggered

LV_NAME
= LO_LISTENER->F4_ATTRIBUTE_INFO-NAME.

* Set the selected value in the attribute

LO_LISTENER
->F4_CONTEXT_ELEMENT->SET_ATTRIBUTE( NAME = LV_NAME
                                       
VALUE = LS_SFLIGHT-CARRID )
.


* Instruct to close the Pop up window


WD_COMP_CONTROLLER
->VALUE_HELP_LISTENER->CLOSE_WINDOW( ).

 

 

Save and activate the whole component.

 

So far we have created the component that can be used to provide the search help for the CARRID field.

About Arun

0 Comments:

Post a Comment

Powered by Blogger.