Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Prevent user from typing in an input field with search help

former_member355261
Participant
0 Kudos

Hello,

I have a screen with a step loop on an input/output field and I use the FM  F4IF_FIELD_VALUE_REQUEST in the POV event to assign a search help element to each input field.

What I want to do is to prevent the user from typing text in the input fields but just using search helps to fill the fields.

I would also like to be able to change the width of each input field dynamiclly depending on the length of elements in the search help.

Thanks in advance.

12 REPLIES 12

Former Member
0 Kudos

Hello Occoro,

I am just hinting at an idea here, I am not sure it will work.
I do not have access to SAP system right now to test it .

What if, you set the input box as an output field only, and fill in data only using the search help.?

I am assuming your requirement is that user has to use the F4 help only ..

0 Kudos

Hi Sajid,

This is unfortunately not working.

Actually, I'm looking for something to disable input from code (in PBO or PAI events).

gabmarian
Active Contributor

Hi,

Regarding your first question:

What you should do is set the screen field to input only, then fill the desired field at POV using

FM DYNP_VALUES_UPDATE. (Simple value assignment for the field won't work!)

Regarding your second question:

Do you mean changing the field to the possible maximum length, or always chaning it based on the value the user has choosen?

BR,

Gabor

0 Kudos

Hi,

Regarding the second question, I mean changing the field to the possible maximum length of the data element of the fieldname attribute of the FM F4IF_FIELD_VALUE_REQUEST.

gabmarian
Active Contributor
0 Kudos

That should be done at PBO time for each field individually. You can use  LOOP AT SCREEN for the purpose :

  LOOP AT screen.

    CASE screen-name.

    

     WHEN ...

        screen-length = ....

    ENDCASE.

    MODIFY screen.

  ENDLOOP.

For dynamically calculate size of structure fields I recommend the following piece of code:

FORM get_size USING iv_tabname   TYPE dfies-tabname

                                   iv_fieldname TYPE dfies-fieldname

               CHANGING cv_size      TYPE I.

   DATA:

     rv_data TYPE REF TO data.

   FIELD-SYMBOLS:

     <lv_field>  TYPE any.

   CREATE DATA rv_data TYPE (iv_tabname).

   ASSIGN rv_data->(iv_fieldname) TO  <lv_field>.

   DESCRIBE FIELD <lv_field> LENGTH cv_size IN CHARACTER MODE.

ENDFORM.


I hope I get your requirement right

0 Kudos

Do you mean set screen field to input not possible?

And with your method the field gets filled when clicking on the search help square, so I can't get the value selected from the search help elements.

Any ideas to solve this ?

gabmarian
Active Contributor
0 Kudos

Hi,

I only meant mean that in order to "grey out" the field preventing it from receiving input you have to set it read-only.


When did you update the field contents?


Here is an example how I use. It fills the dynpro field GS_FIELD with a user ID via search help (input on the field is disabled).


MODULE field_f4 INPUT.

   CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

     EXPORTING

       tabname           = space

       fieldname         = space

       searchhelp        = 'USER_COMP'

     TABLES

       return_tab        = gt_return

     EXCEPTIONS

       field_not_found   = 1

       no_help_for_field = 2

       inconsistent_help = 3

       no_values_found   = 4

       OTHERS            = 5.

   IF sy-subrc <> 0.

     RETURN.

   ENDIF.

   READ TABLE gt_return INTO gs_return INDEX 1.

   gs_dynpfields-fieldname  = 'GS_FIELD'.

   gs_dynpfields-fieldvalue = gs_return-fieldval.

   APPEND gs_dynpfields TO gt_dynpfields.

   CALL FUNCTION 'DYNP_VALUES_UPDATE'

     EXPORTING

       dyname               = gs_dyname

       dynumb               = gs_dynumb

     TABLES

       dynpfields           = gt_dynpfields

     EXCEPTIONS

       invalid_abapworkarea = 1

       invalid_dynprofield  = 2

       invalid_dynproname   = 3

       invalid_dynpronummer = 4

       invalid_request      = 5

       no_fielddescription  = 6

       undefind_error       = 7

       OTHERS               = 8.

   IF sy-subrc <> 0.

     RETURN.

   ENDIF.

ENDMODULE.

0 Kudos

Hi,

I used exactly same code as you but it's not working.

I can't double-click on the values proposed by the search help, so the gt_return table is empty.

Does this code work for you ? in th POV event ?

gabmarian
Active Contributor
0 Kudos

Yes, it works in POV in both an NSP demosystem (EHP2) and in ECC EHP6.

Could you include your code? Maybe the difference is outside of this.

0 Kudos

PROCESS ON VALUE-REQUEST.

   FIELD: wa_emp-name MODULE fill_on_f4.

MODULE fill_on_f4 INPUT.

   DATA: step LIKE sy-stepl,

         tab TYPE dfies-tabname,

         field TYPE dfies-fieldname.

   DATA: t_dynpfields TYPE TABLE OF dynpread,

       s_dynpfields TYPE dynpread,

       t_return TYPE TABLE OF ddshretval,

       s_return TYPE ddshretval.

   CALL FUNCTION 'DYNP_GET_STEPL'

     IMPORTING

       povstepl = step.

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

   READ TABLE it_emp INTO wa_emp INDEX step.

   CASE wa_emp-id.

     WHEN ...

       tab = ...

       field = ...

     WHEN ...

   ENDCASE.

   CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

     EXPORTING

       tabname           = tab

       fieldname         = field

       dynpprog          = sy-repid

       dynpnr            = sy-dynnr

       dynprofield       = 'WA_EMP-NAME'

       stepl             = step

     TABLES

       return_tab        = t_return

     EXCEPTIONS

       field_not_found   = 1

       no_help_for_field = 2

       inconsistent_help = 3

       no_values_found   = 4

       OTHERS            = 5.

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

   READ TABLE t_return INTO s_return INDEX step.

   s_dynpfields-fieldname = 'WA_EMP-NAME'.

   s_dynpfields-fieldvalue = s_return-fieldval.

   APPEND s_dynpfields TO t_dynpfields.

   CALL FUNCTION 'DYNP_VALUES_UPDATE'

     EXPORTING

       dyname     = sy-repid

       dynumb     = sy-dynnr

     TABLES

       dynpfields = t_dynpfields

*   EXCEPTIONS

*     INVALID_ABAPWORKAREA       = 1

*     INVALID_DYNPROFIELD        = 2

*     INVALID_DYNPRONAME         = 3

*     INVALID_DYNPRONUMMER       = 4

*     INVALID_REQUEST            = 5

*     NO_FIELDDESCRIPTION        = 6

*     UNDEFIND_ERROR             = 7

*     OTHERS     = 8

     .

   IF sy-subrc <> 0.

* Implement suitable error handling here

   ENDIF.

ENDMODULE.

0 Kudos

In fact, I figured out that my requirement is not possible.

http://scn.sap.com/thread/721390

I must control user entries manually.

Anyway, thanks a lot for your help.

gabmarian
Active Contributor
0 Kudos

What bothers me, that I managed to achieve it (it also works for me in a step loop) in a certain case. Maybe it has to do something with the origin of the search help? Could you please provide the type of WA_EMP-NAME or the name of the search help?

Thx,

Gabor