Application Development and Automation Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Thajudheen
Explorer
3,216

  In the world of SAP, Search Helps play a crucial role in simplifying user input by providing dropdown lists or search options directly in the application. However, in certain scenarios, it is essential to control the visibility of these options to ensure that only authorized users can access specific data. This is where the Search Help Exit comes into play. 

A Search Help Exit is a powerful mechanism that allows developers to customize and enhance the standard behavior of Search Helps in SAP. By leveraging a Search Help Exit, you can filter the data dynamically at runtime based on custom logic, ensuring that only specific users or groups of users have access to the relevant data. 

In this blog, we’ll walk you through a practical example of implementing a Search Help Exit to restrict data visibility to authorized users. We'll cover the following: 

  1. Understanding Search Help Exits: 
  1. What is a Search Help Exit? 
  1. Key steps in the Search Help process (SELONE, PRESEL, SELECT, DISP, RETURN). 
  1. Creating a Custom Authorization Table: 
  1. How to store user-specific authorizations in a custom SAP table. 
  1. Developing a Custom Search Help Exit: 
  1. Step-by-step guide to implement a Search Help Exit with ABAP code. 
  1. Filtering data dynamically based on authorized users. 
  1. Assigning and Testing the Exit: 
  1. Linking the Search Help Exit to your Search Help in SE11. 
  1. Verifying the behavior with authorized and unauthorized users. 

By the end of this blog, you’ll have a clear understanding of how to enhance the functionality of Search Helps to align with your business requirements, improving both data security and user experience. Whether you’re an SAP ABAP developer or a functional consultant, this guide will equip you with the tools to implement Search Help Exits effectively. 

So, let’s dive into the world of Search Help Exits and learn how to restrict data to authorized users! 

As we know Search Help Exit is a Function Module that has a Predefined Interface , which is used to write the logic for Search help to Enhance the Search help. 

The Standard Function Module  for Search help is F4IF_SHLP_EXIT_EXAMPLE, So we make a copy of this search help exit and create our own search help exit. 

So we have parameters Inside this Function Module like Changing parameter [ SHLP AND CALL CONTROL] and Table parameter like [ SHLP_TAB  AND RECORD_TAB] . 

So First we need to create a Custom Database Table , having 2 fields MANDT AND UNAME, 

And whatever the user name which we provide inside the UNAME , only that users will be authorized and all other users are unauthorized, only the names provided in the table , only that users will be able to see the data , apart from those users no other users will be able to see the data. 

So we have a parameter called as CALL CONTROL , Inside this parameter we have various options like 

SELONE, PRESEL, SELECT, DISP, RETURN 

SELONE  -  It is used to select one of the elementary search helps, This step is applicable for collective search help. 

PRESEL – Enter Selection Conditions. 

SELECT – Select values. 

DISP – Display values. 

RETURN –  To return the values. 

 

Thajudheen_0-1736579377922.png

so here I have maintained 1 user [ HANAUSER28] so only that user will be having the access to display the data, other user will not have the access to display the data. 

Thajudheen_1-1736579451197.png

 

Now create a Search help  

Thajudheen_2-1736579515011.png

 

Then create a Search help exit , and In the source code write the below Code . 

 

 DATA: LV_USER TYPE CHAR30. 
 
  IF CALLCONTROL-STEP = 'DISP'. 
    SELECT SINGLE UNAME 
    FROM ZUSER_AUTHOR 
      INTO LV_USER 
      WHERE UNAME =  SY-UNAME. 
 
    IF SY-SUBRC <> 0. 
      REFRESH : RECORD_TAB. 
    ENDIF. 
  ENDIF. 

 

Put a break point  inside the Function module , and Run the search help using the Authorized User . 

Thajudheen_3-1736579744726.png

 

So Initially the CALLCONTROL-STEP will be SELONE, Then click on F8. 

Then it will be PRESEL1 , click on f8,  

Then it will be PRESEL,  

Then it will be SELECT  

Again click on f8 , value will be DISP 

Thajudheen_4-1736579794817.png

 

AGAIN CLICK ON F8, The values will be displayed. 

Thajudheen_5-1736579831877.png

 

Now Try to Login with another user Id. 

Thajudheen_6-1736579868121.png

 

Now if you are trying to run the search help, It will not display the value. 

Thajudheen_7-1736580000986.png