Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
amy_king
Active Contributor

Overview

I have seen this question raised a couple of times in the Web Dynpro ABAP community,

How can a developer prevent the user from manually typing a value into an InputField, and instead force the user to use the field's search help to enter a value?

It is possible to achieve this scenario with a little slight-of-hand on the view.

Procedure

1.0 Create Context Node FLIGHT

In the component controller, create a 1..1 context node named FLIGHT with a single attribute CARRID of type SFLIGHT-CARRID, then map context node FLIGHT to the view's context.

2.0 Create the View

Here comes the slight-of-hand. Instead of using one InputFIeld, we use two, one which is read-only and echoes the user's search help selection and another which is invisible to the user but contributes its search help functionality to the view.

  • Create InputField READ_ONLY_FIELD. Set its readOnly property to true, and bind its value property to context attribute FLIGHT-CARRID.
  • Create InputField INPUT_FIELD. Set its width property to 0px, and bind its value property to context attribute FLIGHT-CARRID.

Because we have given INPUT_FIELD a width of zero pixels, the field itself is invisible to the user, and the user is prevented from manually typing a value into the field. However, INPUT_FIELD's search help is still visible to the user, and the user may use the search help to select a value. Because READ_ONLY_FIELD is bound to the same context attribute as INPUT_FIELD, it will display the value selected from the search help.

Result

It will appear to the user that there is only a single field on the view. Because that field is read-only, the user is forced to use the search help to enter a value into the field.

5 Comments
Labels in this area