04-04-2015 9:51 AM
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.
04-04-2015 11:25 AM
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 ..
04-04-2015 12:10 PM
Hi Sajid,
This is unfortunately not working.
Actually, I'm looking for something to disable input from code (in PBO or PAI events).
04-04-2015 12:12 PM
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
04-04-2015 12:18 PM
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.
04-04-2015 12:35 PM
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
04-04-2015 2:24 PM
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 ?
04-04-2015 3:06 PM
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.
04-04-2015 3:51 PM
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 ?
04-04-2015 4:31 PM
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.
04-04-2015 4:41 PM
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.
04-04-2015 6:06 PM
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.
04-05-2015 7:59 PM
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