Вы находитесь на странице: 1из 12

9/18/2010 SAP Community Network Blogs

Blogs

Controlling/Manipulating data of Search Help using Subscribe

search help Exit Print

Vishal Sharma Permalink


Business Card Share
Company: INFOSYS
Posted on Mar. 11, 2009 08:37 PM in ABAP

1. Introduction

Search Help
A search help is an object of the ABAP Dictionary which helps to purpose some list of values for some input filed.

2. Types of search helps


There are three types of search helps
(a) Elementary search helps

Elementary search helps implement a search path for determining the possible entries.
(b) Collective search help

Collective search helps contain several elementary search helps. A collective search help therefore provides several alternative search
paths for possible entries.

(c) Append search helps

Append search helps can be used to enhance collective search helps delivered by SAP with customer-specific search paths without
requiring a modification.

www.sdn.sap.com/irj/scn/weblogs?bl… 1/12
9/18/2010 SAP Community Network Blogs

Give a new name of the search help which you want to create for the standard search help and create a new elementary search help in
the reference to the standard search is called as append search help.
3. Scope of the document:
Scope of this document is to explain the use of search help exits in the search help, we can apply the search help exit on both
collective and elementary search helps.
But in this knowledge view we will take an example of an elementary search help.
4. Search Help Exit:
Search Help Exit: A search help exit is a function module which is used to make search help more flexible and we can code a single
search help exit in such a way so that is can be used in various search helps.
We will explain the use of search help exit by taking an example of collective search help:
(a) Creating a new elementary search help:
Run T-Code: SE11

www.sdn.sap.com/irj/scn/weblogs?bl… 2/12
9/18/2010 SAP Community Network Blogs
Press Create Button.
Specify search help selection method, for example EKKO (PO Header table)
Specify the search help parameters.
Do not specify the name of the search help exit for the time being.
Now active and execute the search help, you will see all the records form the table EKKO, but now if you want to control/ Manipulate
the value of the search help output list. Then you need to use search help exit.

(b) Run T-Code: SE37


Create a Function module say YSUN_F4_SHLP_EXIT as a copy of the F4IF_SHLP_EXIT_EXAMPLE

www.sdn.sap.com/irj/scn/weblogs?bl… 3/12
9/18/2010 SAP Community Network Blogs

Now create the same structure in the function module as of the search help.

Now we need to code the things under the standard IF condition given by the function module i.e. IF callcontrol-step = 'SELECT'.
Let suppose we want to see the data of only year 2003 then we can also code it as shown by using our own select statement.
There is a function module F4UT_PARAMETER_RESULTS_PUT.This is used to pass the internal table data to the output list.

www.sdn.sap.com/irj/scn/weblogs?bl… 4/12
9/18/2010 SAP Community Network Blogs

www.sdn.sap.com/irj/scn/weblogs?bl… 5/12
9/18/2010 SAP Community Network Blogs

Source Code for the search help exit as given below:

FUNCTION ysun_f4_shlp_exit.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCR_TAB_T
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR_T
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------

TYPES: BEGIN OF i_ekko,


ebeln TYPE ekko-ebeln,
bedat TYPE ekko-bedat,
END OF i_ekko.

DATA : t_ekko TYPE i_ekko OCCURS 0.

* EXIT immediately, if you do not want to handle this step


IF callcontrol-step <> 'SELONE' AND
callcontrol-step <> 'SELECT' AND
www.sdn.sap.com/irj/scn/weblogs?bl… 6/12
9/18/2010 SAP Community Network Blogs

" AND SO ON
callcontrol-step <> 'DISP'.
EXIT.
ENDIF.

*"----------------------------------------------------------------------
* STEP SELONE (Select one of the elementary searchhelps)
*"----------------------------------------------------------------------
* This step is only called for collective searchhelps. It may be used
* to reduce the amount of elementary searchhelps given in SHLP_TAB.
* The compound searchhelp is given in SHLP.
* If you do not change CALLCONTROL-STEP, the next step is the
* dialog, to select one of the elementary searchhelps.
* If you want to skip this dialog, you have to return the selected
* elementary searchhelp in SHLP and to change CALLCONTROL-STEP to
* either to 'PRESEL' or to 'SELECT'.
IF callcontrol-step = 'SELONE'.
* PERFORM SELONE .........
EXIT.
ENDIF.

*"----------------------------------------------------------------------
* STEP PRESEL (Enter selection conditions)
*"----------------------------------------------------------------------
* This step allows you, to influence the selection conditions either
* before they are displayed or in order to skip the dialog completely.
* If you want to skip the dialog, you should change CALLCONTROL-STEP
* to 'SELECT'.
* Normally only SHLP-SELOPT should be changed in this step.
IF callcontrol-step = 'PRESEL'.
* PERFORM PRESEL ..........
EXIT.
ENDIF.

*"----------------------------------------------------------------------
* STEP SELECT (Select values)
*"----------------------------------------------------------------------
* This step may be used to overtake the data selection completely.
* To skip the standard selection, you should return 'DISP' as following
www.sdn.sap.com/irj/scn/weblogs?bl… 7/12
9/18/2010 SAP Community Network Blogs
* step in CALLCONTROL-STEP.
* Normally RECORD_TAB should be filled after this step.
* Standard function module F4UT_RESULTS_MAP may be very helpful in this
* step.

IF callcontrol-step = 'SELECT'.

DATA : t_fields LIKE TABLE OF shlp_tab-fielddescr.


DATA : w_fields LIKE LINE OF shlp_tab-fielddescr.

SELECT * FROM ekko INTO CORRESPONDING FIELDS OF TABLE t_ekko


WHERE bedat LIKE '2003____'.

LOOP AT shlp_tab.
LOOP AT shlp_tab-fielddescr INTO w_fields.

DATA : l_fname TYPE dfies-lfieldname.


l_fname = w_fields-fieldname.
CALL FUNCTION 'F4UT_PARAMETER_RESULTS_PUT'
EXPORTING
parameter = w_fields-fieldname
* OFF_SOURCE =0
* LEN_SOURCE =0
* VALUE =
fieldname = l_fname
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = t_ekko
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
parameter_unknown =1
OTHERS =2
.
ENDLOOP.
ENDLOOP.

www.sdn.sap.com/irj/scn/weblogs?bl… 8/12
9/18/2010 SAP Community Network Blogs
* PERFORM STEP_SELECT TABLES RECORD_TAB SHLP_TAB
* CHANGING SHLP CALLCONTROL RC.
* IF RC = 0.
IF sy-subrc EQ 0.
callcontrol-step = 'DISP'.
ELSE.
callcontrol-step = 'EXIT'.
ENDIF.
EXIT. "Don't process STEP DISP additionally in this call.
ENDIF.

*"----------------------------------------------------------------------
* STEP DISP (Display values)
*"----------------------------------------------------------------------
* This step is called, before the selected data is displayed.
* You can e.g. modify or reduce the data in RECORD_TAB
* according to the users authority.
* If you want to get the standard display dialog afterwards, you
* should not change CALLCONTROL-STEP.
* If you want to overtake the dialog on you own, you must return
* the following values in CALLCONTROL-STEP:
* - "RETURN" if one line was selected. The selected line must be
* the only record left in RECORD_TAB. The corresponding fields of
* this line are entered into the screen.
* - "EXIT" if the values request should be aborted
* - "PRESEL" if you want to return to the selection dialog
* Standard function modules F4UT_PARAMETER_VALUE_GET and
* F4UT_PARAMETER_RESULTS_PUT may be very helpful in this step.
IF callcontrol-step = 'DISP'.
* PERFORM AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB
* CHANGING SHLP CALLCONTROL.
EXIT.
ENDIF.

ENDFUNCTION.

5. Apply Search Help Exit in the Elementary Search help:

www.sdn.sap.com/irj/scn/weblogs?bl… 9/12
9/18/2010 SAP Community Network Blogs
Now put the name of the function module in the search help exit.

Now execute the search help, you will only have the purchase order of year 2003 as shown below:

Disclaimer:
I Also hereby declare that this BLOG is based on my personal experiences and / or experiences of my project members. To the best of
my knowledge, this BLOG does not contain any material that infringes the copyrights of any other individual or organization including
the customers of SAP.

Vishal Sharma is a SAP techno-functional (ABAP-MM) at INFOSYS Technologies india Ltd.

Comment on this weblog

www.sdn.sap.com/irj/scn/weblogs?bl… 10/12
9/18/2010 SAP Community Network Blogs

www.sdn.sap.com/irj/scn/weblogs?bl… 11/12
9/18/2010 SAP Community Network Blogs

www.sdn.sap.com/irj/scn/weblogs?bl… 12/12

Вам также может понравиться