Enabling F4 search help and customizing them for fields in PR (ME51N/52N) & PO (ME21N/22N)
https://blogs.sap.com/2023/04/25/enabling-f4-search-help-and-customizing-them-for-fields-in-purchase-requisition-me51n-52n-purchase-orders-me21n-22n/
Today, I would like to discuss a scenario that I recently came across. As an ABAP consultant, finding and enhancing standard transactions is the need for the business and achieving the same is a crucial task.
When I got the requirement to assign F4 help to a field in PR and PO, I started scratching my head looking for resources online to achieve the same.
So to begin with, lets see how these standard transactions for creation/change of PR and PO look like.
We’ll pick the requisitioner field (AFNAM) for this instance.
Here is the PR creation screen below

AFNAM in PR creation screen
and here below comes the PO creation screen.

AFNAM in PO creation screen
Now if you notice in both the above screens, we don’t have any search help assignment to this field and in the same way many other fields.
Now, in a scenario wherein validation and correctness of such fields are necessary, its crucial to avoid the errors from the end user side to a minimal extent possible. This can be achieved with a search help.
Steps to achieve Search help for PR creation/change:
Assignment of search help involves 2 steps:
Enable search help so that the F4 event is recognized.
Handle the search help to populate list of possible values.
Enable search help so that the F4 event is recognized.
In SE38, Open the Report LMEGUICJM and navigate to the method GET_FIELDS_FOR_F4.
Create implicit enhancement at the end of this method and add the code below:
Activate this enhancement.
Now execute T-code ME51N and you should see the screen below.

F4 help enabled for PR screen
As you can see, the F4 help is now enabled and this event can be handled further.
Handle the search help to populate list of possible values.
Create a Function Module which can be used in both the PR and PO transactions to handle the F4 help for this field.
Parameters for the function Module are as below.
Code to be written inside this FM is as follows.
Activate this Function Module. This will be used in the enhancement to handle F4 help.
Create Implicit enhancement to handle the F4 event.
In SE38, Open the Report LMEGUICJM and navigate to the method HANDLE_F4.
Create implicit enhancement at the end of this method and add the code below:
Activate this enhancement.
Now execute T-Code ME51N and click on F4 help on the Requisitioner field. You can see the F4 help values in the list.

F4 help for AFNAM in PR Screen
Hence, we have achieved the implementation of Search help for PR Transactions. Same process can be followed for any other field where the Search help is not enabled by standard SAP.
Steps to achieve Search help for PO creation/change:
Similar to PR, assignment of search help involves 2 steps:
Enable search help so that the F4 event is recognized.
Handle the search help to populate list of possible values.
Enable search help so that the F4 event is recognized.
Here, the process is a little different as compared to how it is done for the PR screens.
Go to T-code ME21N and find the technical information for the field by using F1 help.

F1 information for AFNAM in PO screen
Enter the Program name and screen number in SE51 and go to the flow logic screen,
In the PROCESS ON VALUE-REQUEST event, create an insert and add the below code.
Activate the screen and generate the program SAPLMEGUI.
This will enable the F4 event and the screen in ME21N will look as follows.

F4 help enabled for PO screens
As you can see, the F4 help is now enabled and this event can be handled further.
Handle the search help to populate list of possible values.
In SE38, Open the Report LMEGUICIM and navigate to the method POV_LIST.
Create implicit enhancement at the end of this method and add the code below:
Activate the enhancement.
Now execute T-Code ME21N and click on F4 help on the Requisitioner field. You can see the F4 help values in the list.

F4 help for AFNAM in PO Screen
Hence, we have achieved the implementation of Search help for PO Transactions. Same process can be followed for any other field where the Search help is not enabled by standard SAP.
Finally, we have reached the end of this blog. This is my first blog and would welcome your suggestions and reviews to make it better.
Last updated
Was this helpful?