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: 

To Check is a Field is populated by F4 help or Manually.

abhishek37373
Participant
0 Kudos

HI Folks,

Need help to Check if a Field is populated by F4 help (Search help) or Manually in a Module pool program.

Basically the search help already contains all validation required for the field,so if i get to know that the user has selected value from F4 Popup i need not validate the value entered but when user had a manually populated the field i have to validate it with some conditions.

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

You may require to "interceot" the F4. In the POV section call a module for your field, in this module

  • Call the search help either statically or dynamically using FM F4IF_FIELD_VALUE_REQUEST and either passing TABNAME and FIELDNAME or SEARCHHELP (or any other F4 management)
  • When FM returns the result, memorize also the value in another field declared in top include

Now in your program if the current value is equal to this saved value, you can consider it comes from F4

Regards,

Raymond

16 REPLIES 16

karun_prabhu
Active Contributor
0 Kudos

Hello Abhishek.

     It is better to validate that field without worrying if it is entered manually or via F4 help. It will atleast be a single step process.

     If you opt for the other method, it involves two or more additional steps:

     1) Identifying how the input came.

     2) Using some variable to identify manual input.

     3) If the input is entered manually, perform validation.    

Regards.

0 Kudos

Hi Arun,

Thanks for your reply ,you are right i would had done that if the validation where simple and small...But this is not the case here..The validation is complicated and time taking too..so i am trying to avoid doing it again.

sivaganesh_krishnan
Contributor
0 Kudos

Hi Abhishek,

Instead of validating by checking for manual entries and search help entries why can't we make the field in display mode and allow values of search help which can be selected by user.

Check out the code.

PARAMETERS:p_matnr(18) TYPE c MODIF ID mid.

DATA:BEGIN OF itab OCCURS 0,

matnr TYPE matnr,

END OF itab.

AT SELECTION-SCREEN OUTPUT.


LOOP AT SCREEN .

IF screen-group1 EQ 'MID'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.



AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.

LOOP AT SCREEN .

IF screen-group1 EQ 'MID'.

screen-input = '1'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.



IF itab IS INITIAL.

itab-matnr = 'ABC123456788'.

APPEND itab.


itab-matnr = 'BCS123456788'.

APPEND itab.

itab-matnr = 'DFC123456788'.

APPEND itab.

itab-matnr = 'ASW123456788'.

APPEND itab.


ENDIF.


CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield = 'MATNR'

dynpprog = sy-repid

dynpnr = sy-dynnr

dynprofield = 'P_MATNR'

value_org = 'S'

TABLES

value_tab = itab.


LOOP AT SCREEN .

IF screen-group1 EQ 'MID'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

endloop.       " SEARCH  INPUT

Hope this logic would help you..

Regards,

Sivaganesh.

0 Kudos

Hi Siva

Thanks for your reply.But i cant make the field restrict only F4 help (Search help) entries.The field should be able to take both F4 and manual entries.

0 Kudos

Hi Abhishek,

Get the values of the search help from FM F4IF_SELECT_VALUES and then validate the value entered by user from the internal got from FM. Hope my understand is fine...

Regards,

Lokesh

0 Kudos

Hi Lokesh

Thanks for your reply.You are very right on this but wouldn't it fail in the scenario where user doesn't press F4 (i.e. search help is not triggered) and directly makes an Manual entry.

0 Kudos

Hi Abhishek,

Is F4 help value for that field depends on any other fields? if not give the search help name in FM

F4IF_SELECT_VALUES it will return search help values in internal table.

read internal table with the value user enters manually in screen.

Regards,

Lokesh

PeterJonker
Active Contributor
0 Kudos

What kind of search help is it ?

- fixed values domain ? 

- standard SAP search help (which one) ?

- custom search help ?

- on value request event ?

0 Kudos

Hi Peter,

Thanks for your reply.It is a collective search help,Using Search help exit.

raymond_giuseppi
Active Contributor
0 Kudos

You may require to "interceot" the F4. In the POV section call a module for your field, in this module

  • Call the search help either statically or dynamically using FM F4IF_FIELD_VALUE_REQUEST and either passing TABNAME and FIELDNAME or SEARCHHELP (or any other F4 management)
  • When FM returns the result, memorize also the value in another field declared in top include

Now in your program if the current value is equal to this saved value, you can consider it comes from F4

Regards,

Raymond

0 Kudos

You may require to "interceot" the F4.

You meant "intercept", didn't you? For a few minutes i was wondering if this is some parameter in the Search-help exit FMs

- Suhas

0 Kudos

Just a "typo"

karun_prabhu
Active Contributor
0 Kudos

But even with the method suggested by Raymond, there is one loophole.

Suppose user selects a record using F4 help and then changes it in the resultant input field....

It will not be validated as system will understand it has come from F4 help and not manually.

I feel it will be better to validate all the records irrespective of how they came.

It is ultimately up to you to decide based on the criticality of the App....

0 Kudos

Not exactly, I didn't keep in memory the fact that a value has been selected, but the actual value selected, so this value can be assumed as correct.

Regards,

Raymond

0 Kudos

I got it wrongly. You are right Raymond

former_member215344
Contributor
0 Kudos

Hi Abhishek,

You can make the field as a dropdown list and then set the value range using VRM_SET_VALUES function module. This way validation can be avoided. Also you might be aware that manual input is possible in dropdown list (but limited only to the entries present i.e for eg if the drop down is for country code it will allow you to input I, IN etc as soon as you put IN it will show you entries which start with IN lke India, Indonesia etc...)

Please try this option and please reward if found useful.

Thanks,

Ajay