ABAP--一个实现Search Help Exits的完整样例(转载)
Search help exit is used to modify the F4 values at run time before its being displayed as a list to the user for selection. This document explains step by step procedure for implementing a search help exit with an example.
1)       SELONE - in this step FM 'DD_SHLP_GET_DIALOG_INFO' is called to populate the internal description of the fields for search help fields in table  SHLP_TAB 
2)      PRESEL1 - in this step the maximum records, internal length, offset attributes of the fields are set 
3)      PRESEL - in this step a pop-up is displayed for the user to enter the selection criteria. 
4)      SELECT - in this step based on the selection criteria entered by the user data will be selected to RECORD_TAB internal table based on the selection method specified for the search help 
5)      DISP - this is the final step before the result list is displayed to the user.                               
2)
3)
4)
5)
Example Scenario
Consider searching for sales order through VA03, and select sales document not fully confirmed tab, enter customer number and press enter

The result list will be displayed as below,

Now say our requirement is to have customer number and customer name in the customer column as '121- BHARAT FORGES'.
We can achieve this by implementing a search help exit and modifying the internal length & output length attributes of the customer field at run time and concatenating customer name to customer number at run time.
For the purpose of this document I have copied search help VMVAC to ZVMVAC and implemented an exit for this search help.

Steps in implementing Search Help Exit
1)       Create a function group 'ZVMVAC' using transaction SE80      
2)       Create a function module ZVMAC_SHLP_EXIT for search help exit      

3)
Changing Parameters
Parameter                     Type spec.                                Associated type                                                 
SHLP                             TYPE                                       SHLP_DESCR                                                                
CALLCONTROL              TYPE                                       DDSHF4CTRL                                                 

SHLP- Structure containing search help type, interface and field descriptions of the search help.
CALLCONTROL - Structure containing the current step of the search help process.
Tables Parameters
Parameter                     Type spec.                    Associated type                                     
SHLP_TAB                    TYPE                           SHLP_DESCT                                            
RECORD_TAB              TYPE                            SEAHLPRES
                                           

SHLP_TAB -contains search help field description, field properties and selection criteria.
RECORD_TAB - contains the search help result list.
In this example we will be modifying RECORD_TAB in control step DISP i.e. display as below
1)
2)
3)
4)
Once these steps are done output will appear as below,
Input Customer - 121

Output with Customer number and name.

Sample code
*"----------------------------------------------------------------------
*"*"Local interface:
*"
*"
*"
*"
*"
*"
*"----------------------------------------------------------------------
DATA: ls_fielddescr TYPE dfies, "loc str for shlp-fielddescr
*Local structure for itab record_tab
DATA: BEGIN OF ls_record.
INCLUDE STRUCTURE seahlpres.
DATA: END OF ls_record.
DATA: ls_name1 TYPE name1_gp,
*Internal table to store Customer Name
DATA: BEGIN OF gt_kna1 OCCURS 0,
RANGES: lr_kunnr FOR kna1-kunnr.
*Build range for customer number
*Select Customer name
 
                    
                     
                    
                 
                    
                
