Skip to Content
Author's profile photo Kiran Kumar Valluru

Automatically Trigger onEnter event after selecting value from the Value Help(F4 Help)

Introduction

This document helps how to call onEnter action handler of Input filed after selecting value in the Value Help without pressing Enter Key. In the earlier versions of Netweaver ( before Netweaver 7.4 ) you have to manually press Enter key in the Input field after selecting value from the F4 help.

Prerequisites

SAP NetWeaver 7.4


Step by Step Process

Step 1: Create a Web Dynpro Component.

Go to the SE80 transaction and create a Web Dynpro Component.

/wp-content/uploads/2013/08/1_256220.jpg

Enter Description and click on OK.

/wp-content/uploads/2013/08/2_256221.jpg

Save and Activate the Component.

Step 2: Data Binding

Go to the Context tab of Main View and create an attribute CARRID of type S_CARRID_ID( which has dictionary search help).

/wp-content/uploads/2013/08/3_256222.jpg

/wp-content/uploads/2013/08/4_256227.jpg

Step 3: Layout Design.

   Now Go to Layout tab,

   Create label UI with text ‘Airline’ and input field. Bind the Value of Input filed to the context attribute CARRID.

   /wp-content/uploads/2013/08/5_256238.jpg

Create an Action for onEnter of Input field.

/wp-content/uploads/2013/08/6_256239.jpg

Now go to Methods tab of MAIN view and write the below code ONACTIONGET_FLIGHTDATA method.

ONACTIONGET_FLIGHTDATA
method ONACTIONGET_FLIGHTDATA .

**  Get the Airline and update the dependent input fields/ view fields
**  or Get the Flight Data

*  For Demo purpose I am just displaying a success message

*  Report success message
   wd_this->wd_get_api( )->get_message_manager( )->report_success( ‘On Enter Event Triggered’ ).

endmethod.

Step 4: Create Application.

Save and Activate the Web Dynpro Component.  Create the Web Dynpro Application and Save it.

/wp-content/uploads/2013/08/13_256255.jpg

Enter description and save it.


/wp-content/uploads/2013/08/7_256240.jpg

Test Application

Now Right click on Web Dynpro Application and click on Test.

/wp-content/uploads/2013/08/8_256243.jpg

Now Select the F4 help in the input field.

/wp-content/uploads/2013/08/9_256245.jpg

Select the Value in the Value Help and click on OK.

/wp-content/uploads/2013/08/10_256250.jpg

After selecting the value we have to press Enter to trigger onEnter event.

/wp-content/uploads/2013/08/11_256251.jpg

Now we can see onEnter event was triggered after pressing Enter manually  in the Input Field.

/wp-content/uploads/2013/08/12_256252.jpg

It is preferable that the onEnter action handler of an Input Fields is executed directly after a value has been selected from the value help.

To Trigger the onEnter event of Input fields automatically after selecting the value from the value help, we have to call the method register_on_enter_for_f4() of interface IF_WD_VIEW_CONTROLLER.

We have to write the below code in WDDOINIT method.

  DATA lr_view_controller TYPE REF TO cl_wdr_view.


   lr_view_controller ?= wd_this->wd_get_api( ).

   lr_view_controller->if_wd_view_controller~register_on_enter_for_f4( register_on_enter = abap_true ).

Write the below code in WDDOINIT method.

WDDOINIT

method WDDOINIT .

*  Register onEnter for Value Help

  wd_this->wd_get_api( )->register_on_enter_for_f4( register_on_enter = abap_true ).

endmethod.

Note: This setting can be made for all value helps for each view separately by calling method register_on_enter_for_f4() in the WDDOINIT method of each view.

Save and Activate the Component.

Result

Now Test the Web Dynpro Application.

Select the F4 help in the input field.

/wp-content/uploads/2013/08/9_256245.jpg

Select the Value in the Value Help and click on OK.

/wp-content/uploads/2013/08/10_256250.jpg

After selecting the value we can see the onEnter action handler is called automatically.

/wp-content/uploads/2013/08/14_256263.jpg

Conclusion

Using this feature we can make onEnter action handler to call automatically immediately after selecting the value from the Value Help. This feature is useful to update the other View Fields that are dependent on the input field by calling onEnter action handler of the input fields automatically after selecting the value from the Value Help.  Here I demonstrated a simple Web Dynpro Application. You can use this according to your requirements.


Follow me on Google+

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Nice document. Helpful. Thanks for sharing!

      Regards,

      Karthik

      Author's profile photo Chris Paine
      Chris Paine

      For those who aren't yet at 7.4 level - here's a blog I wrote 3 years ago which basically shows how to do the same thing on a 7.1 stack

      Firing a WDA event on using a Search Help - how to do it, without an NDA

      Cheers,

      Chris

      Author's profile photo Former Member
      Former Member

      Hi Chris,

      Will this be applicable to Date field also...

      Author's profile photo Chris Paine
      Chris Paine

      Hi, am afraid I'm not sure. I always followed the pattern of using date navigator if I needed an immediate event on date selection. Although it is likely that by slightly changing the code I mention in my blog that you would be able to get the date to event. However, using the date navigator would be a much simpler option.

      Author's profile photo Former Member
      Former Member

      But can we asssign Date Navigator to Search Help of Input field.

      As of now i am using SYDATUM as field type for Input field so its populating calendar in the searh help.

      Date Navigator functionality works in the similar way

      Author's profile photo Chris Paine
      Chris Paine

      No, not assign as search help, use instead of input field. As it throws an event on date selection.

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Nice Document. One question will it be possible to triggered the event on custom search helps too ?

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru
      Blog Post Author

      Hi Bhanu,

      What do you mean by custom search helps? Did you mean DDIC Z search helps! If so, the answer is yes. For all DDIC search helps this will work.

      For OVS search help, this won't trigger automatically. For OVS in the even handler of OVS you can call the method explictly.

      Regards,

      Kiran

      Author's profile photo Former Member
      Former Member

      Hello Kiran Kumar Valluru,

      I followed you document to register an event on I/P field.Below is the code i written in my WDDOINIT( ) of my View controller which is having one I/P field.

        DATA lr_view_controller TYPE REF TO cl_wdr_view.
        lr_view_controller ?= wd_this->wd_get_api( ).

        lr_view_controller->if_wd_view_controller~register_on_enter_for_f4( register_on_enter = abap_true ).

      But i'm getting error "IF_WD_VIEW_CONTROLLER~REGISTER_ON_EVENT_FOR_F4 is not declared or inherited in class "CL_WDR_VIEW" .Pls guide me.

      Thanks

      Katrice

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru
      Blog Post Author

      Hi,

      Please see the prerequisite. You should be on Netweaver 7.4 to use the mentioned method. If you are on lower Netweaver version you can follow the blog which Chis Paine has mentioned above in the comments.

      Cheers,

      Kiran

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      Will it work for the Standard Date input field?

      I have an On_Enter method for the Date input field. Will the same method will trigger the method while selecting teh date from the calendar.

      I tried but it didnt got triggered. Please give your suggestion.

      Thanks

      Nalla B.

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru
      Blog Post Author

      Hi,

      No, The onEnter event will not be called automatically for date fields as there is no screen render when you select the date from date value help.

      Regards,

      Kiran

      Author's profile photo Former Member
      Former Member

      Thanks kiran.

      But I have a dropdown value which has to be loaded based on the dates in the input field?

      What is the possibility other than On_Enter or going for a custom button to load the values?

      Kindly give some suggestions.

      Thanks,

      Nalla B.

      Author's profile photo Kiran Kumar Valluru
      Kiran Kumar Valluru
      Blog Post Author

      Hi,

      As mentioned earlier, you cannot trigger Enter event automatically for date fields. You need to press Enter(or some action) after entering dates. Or, remove the date field and create a DateNavigator with events associated with it. Or creating a Freely programmed value help for calendar help which is tricky.

      Regards,

      Kiran

      Author's profile photo Former Member
      Former Member

      Hi Kiran,

      It is very useful.I tired it on input fields and it worked. But how to trigger the same in ALV table having input fields?.

      Because, i have To-Date field in my ALV table, if we select todate as past date and on press on enter only, It is triggering the event. I want to achieve the same as per your document.

      Thanks

      Katrice

      Author's profile photo SRIKANTH DHEEKONDA
      SRIKANTH DHEEKONDA

      Its' very useful. Thanks

      -Srikanth

      Author's profile photo Sameer Dhuke
      Sameer Dhuke

      Hi Kiran,

      Thanks for the blog.

      I am facing one issue with it. The action is triggering twice in my case. I am selecting the value from F4 help and its calling the same action twice.

      I am showing in one popup in this action and its coming twice.

      Is there any way to stop this?

      Thanks in Advance.

      Regards,

      Sameer

      Author's profile photo hari krishnan
      hari krishnan

      I have a question.Suppose i have a table with an add button on it's toolbar and an input field having F4 help.Now the user can click on add many times creating multiple blank rows.Now he/she presses on the F4 help of say xth row and selects a value.How will i get the index of the selected value?

      Author's profile photo Tomas Stekla
      Tomas Stekla

      Nice document. Helpful. Thanks for sharing!