freely programmed search help in webdynpro abap2

Upload: abid-sheik

Post on 03-Jun-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    1/12

    Freely programmed searchhelp in Webdynpro

    ABAP

    Freely programmed search help is one of the options to associate the search help with any input field ofyour 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 use a webdynpro component as a search help to an attribute in other webdynpro

    component ?

    One pre-requisite for the webdynpro component to be used as search help is that it should implement

    the webdynpro component interface: IWD_VALUE_HELP. By the time we are implementing the

    interface an window will be created in our component with the name WD_VALUE_HELP. We need to

    embed the View of our component to window WD_VALUE_HELP so that our view will be displayed as

    search help when the user triggers the F4. Later on this component created for providing search helpcan be added as a used component and its component usage can be assigned to the attribute for which

    search help type is assigned as freely programmed search help.

    When the User selects a particular value and clicks on ok button the user selected value has to be

    written in the input field from where the F4 help is called. The interface IWD_VALUE_HELP consists of

    two key attributes called F4_CONTEXT_ELEMENT and F4_ATTRIBUTE_INFO. This attribute

    F4_ATTRIBUTE_INFO consist of information on attribute from where the F4 help is triggered and the

    attribute F4_CONTEXT_ELEMENT consist element object reference for the attribute from where the

    input help is triggered. Using these information in the attribute we can transport the user selected value

    to the attribute from where the F4 help is called.

    Let us see a simple scenario that implements the freely programmed search help for field MATNR.

    Step-1:Design a webdynpro component : ZMSR_SEARCHHELPthat includes the logic for search help for

    MATNR field.

    Step-2:Use the component created in step-1 in another webdynpro component: ZMSR_SH_CONSUMER

    to provide search help for one of its component MATNR. Create an application for component

    ZMSR_SH_CONSUMER and test this.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    2/12

    Below are the Steps to create an example scenario for Search help on MATNR field:

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

    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.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    3/12

    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.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    4/12

    Step 4:Create an attribute value_help_listener in the attributes of the component controller to

    get the object reference of the search help.

    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.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    5/12

    Step 5:Go to the context tab of the view controller and create a context node MARA with

    cardinality 0..N as shown below.

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

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    6/12

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

    context node.

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

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    7/12

    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.

    method ONACTIONOK .

    DATA : LO_LISTENER TYPE REF TO IF_WD_VALUE_HELP_LISTENER,

    LV_NAME TYPE STRING,

    LO_ND_MARA TYPE REF TO IF_WD_CONTEXT_NODE,

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    8/12

    LO_EL_MARA TYPE REF TO IF_WD_CONTEXT_ELEMENT,

    LS_MARA TYPE WD_THIS->ELEMENT_MARA.

    * Getting the lead selected record

    LO_ND_MARA = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->WDCTX_MARA ).

    LO_EL_MARA = LO_ND_MARA->GET_ELEMENT( ).

    LO_EL_MARA->GET_STATIC_ATTRIBUTES( IMPORTING STATIC_ATTRIBUTES = LS_MARA ).* 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_MARA-MATNR ).

    * Instruct to close the Pop up window

    WD_COMP_CONTROLLER->VALUE_HELP_LISTENER->CLOSE_WINDOW( ).

    endmethod.

    Step 10 :Create component ZMSR_SH_CONSUMER in object navigator (se80) with one view V_MAIN1.

    Declare the usage of component ZMSR_SEARCHHELP, created in above steps.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    9/12

    Step 11:Create 1 node MARA (cardinality 1:1) and 1 attribute named MATNR of type string in the

    VIEWCONTROLLER. In the properties of attribute MATNR, 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 ZMSR_SEARCHHELP in above step).

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    10/12

    Map the node from component controller to view V_MAIN1 by drag and drop.

    Step 12:Create one InputField UIElement. Bind the input UIElementsvalue property with attribute

    MATNR.

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    11/12

    Step 13:Create the application for ZMSR_SH_CONSUMER component and test it. The browser screen

    looks like:

    Output

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

  • 8/11/2019 Freely Programmed Search Help in Webdynpro ABAP2

    12/12

    The selected value Is passed to the attribute.