You are on page 1of 20

Search Helps

Or
The Possibilities oI Possible Values
by
Allan Davidson
DiIIerent types oI value help
A Simple list
From check table / text table - used Ior value list that changes by application or by conIiguration
2 From domain Iixed value list - doesn't change except by development
3 Programmed using an internal table and Iunction module TRF4HELP (or others)
B Search help ( Formerly matchcode )
Elementary search help - list oI values
2 Collective search help (set oI elementary helps)
2 Using search helps
A Help settings (Menu path Help/Settings)
B Shortcuts
C Personal help lists - these are generated and handled by the system They show when no
matches are Iound or iI you leave the Iield blank
D Tips & Tricks
3 Programming search helps
A Creating search helps with SE
B Programming in reports
C Programming in screens
Overview
Example: Table T00 is a list oI company codes maintained by conIiguration
The check table is linked to the Iield in the dictionary by maintaining the
Ioreign key relationship (Shown here linked to BKPF-BUKRS)
Simple list: check table
Example: Field BKPF-BSTAT is linked to data element BSTATD,
which is linked to domain BSTAT, which has a Iixed list oI values
Simple list: domain
Internal table T_CECAT has already been filled with a list of legend codes and descriptions. See program , screen
parameter Legend Code
form f4_legend_code changing p_lc.
data: begin of w_title,
code(2) type c value 'LC',
descr(20) type c value 'Description`(053),
end of w_title.
data sel_idx like sy-tabix.
call function 'TR_F4_HELP'
exporting
iv_title = 'Select Legend Code'(054)
is_sel_title1 = w_title
iv_number_of_rows = 12
iv_no_of_key_columns = 1
iv_with_printer_icon = 'X'
tables
it_sel_table = t_cecat
changing
cv_selected_index = sel_idx
exceptions
no_lines = 1
no_line_picked = 2
others = 3.
check sy-subrc = 0.
read table t_cecat index sel_idx.
p_lc = t_cecat-cecat.
endform. " F4_LEGEND_CJDE
Simple list: programmed
An elementary search help provides the list oI values
Search help: elementary
A collective search help is the object that holds a set oI elementary search helps
Search help: collective
Menu path: HelpSettings
Using search helps: Help settings
Using search helps: shortcuts
The short cut Ior the input help permits you to restrict the hit list and reduce the number oI dialog steps even beIore selecting the input help (F4)
The short cut permits you to select an elementary search help Irom a collective search help and to assign the selection Iields in the dialog box Ior restricting values
Your entry must have the Iollowing pattern in the input Iield beIore you press F4 or call the input help
Pattern oI the short notation:
HKSS2S3 etc
where:
HK: short cut oI the elementary search help It does not have to be speciIied iI only one elementary search help is assigned to the Iield or
iI the elementary search help stored as deIault search help should be used The separator '' Iollowing the short cut can be omitted iI S
consists oI more than one character
S to S3 are the restrictions that are entered in this order in the corresponding dialog box Ior restricting values Each entry is considered
to be a pattern with a Iinal '*' Restrictions Ior Iields that could not accept input are ignored
Example:
blhIrankIurt is entered in the input Iield There is a collective search help with several elementary search helps Ior the Iield II you
press F4, the hit list is displayed immediately
The search help with short cut B is selected invisibly Ior the user The hit list is selected with the restriction 'LH*' Ior the Iirst Iield and
'FRANKFURT*' Ior the second Iield oI the dialog box Ior restricting values
Note
When you select an elementary search help with the short cut, no new deIault search help is stored The deIault search help stored Ior each
user and collective search help is only reset when you select an elementary search help using the selection dialog box
Using search helps: personal help lists
These are generated and handled by the system They show
when no matches are Iound or iI you leave the Iield blank
Example: ABAP editor search help Ior program name
You can delete entries Irom this list or navigate to other search helps
Using search helps: tips & tricks
Pressing F4 even when there is no down arrow sometimes gets you value help
2 In technical inIo Ior a Iield, when you see "" Ior the search help, it means that
the search help Ior that Iield is used To Iind the name oI the search help used,
double-click the Iield name in the popup, which takes you to the dictionary
Then double-click on the table Iield, which gives you the Iield details
Creating search helps
Description oI Iields:
Selection method: name oI table or view where the data is
stored
Text table: Filled in by system, iI a text table is attached to
the selection method
Dialog type:: Determines whether the user is presented with
a selection screen beIore the hit list is displayed Possible
values:
A Dialog depends on set oI values II there are more than
00 hits, a selection screen is displayed Otherwise, the hit
list is displayed immediately
D - Display values immediately
C Dialog with value restriction A selection screen is
always displayed
Hot key: allows user to type a shortcut into the Iield to
bypass selection oI elementary search help
Search help exit: - speciIy the name oI a Iunction module
to be called during the search help process (more later)
Search help parameters: SpeciIy the names oI parameters to be passed in / out, or additional Iields to be used as Iilters Ior data
IMP: Check this box to indicate that the Iield is an input Iield, that is, to be passed to the search help
EXP: Check this box to indicate that the Iield is an output Iield, that is, to be passed Irom the search help to the screen
LPOS: The position oI the as it appears in the hit list
SPOS: The position oI the Iield as it appears in the selection screen
SDIS: Causes the Iield to be 'display only in the selection screen
Data element: Sets the attributes oI the search help parameter Normally Iilled in by the system
MOD: Check this box to assign a diIIerent data element than the one supplied by the system
Default value: SpeciIy the deIault value in one oI 3 ways: a literal`(in quotes), a parameter ID(ZRD),
or a system Iield (SY-UNAME)
You create search helps in the data dictionary
Search Help Hierarchy
About the Parameter D - it looks like you just create a name and description (via transaction SE80, Edit Object soft button).
You define the data type via the command "SET PARAMETER D." Later you can use this Parameter D, 'KRD' to set a date.
w_date = sy-datum.
SET PARAMETER D 'ZRD' FELD w_date.
Today's date will appear in the transport request field
Parameter ID
Search help exits -
Callcontrol-step: This Iield is set by the system and can be changed by your code The Iunction
module will be called once Ior each step oI the process, with some conditional exceptions
noted below
SELONE beIore selecting an elementary search help
2 PRESEL aIter selecting an elementary search help
3 PRESEL beIore sending the dialog box Ior restricting values
4 SELECT - beIore selecting the values
DISP - beIore displaying the hit list
RETURN - set by your code iI one hit was Iound during selection
RETTOP Iollows RETURN iI called Irom a collective search help
8 EXIT set by your code Terminates the search help process
9 CREATE - iI the user selects the Iunction 'Create new values"
You can change the behavior oI search helps with a search help exit Copy the
SAP supplied Iunction module F4IFSHLPEXITEXAMPLE This module is
well documented (Ior a change!), but here are some highlights:
TABLE parameters:
SHLPTAB - contains inIormation about the search help Iields and structures
RECORDTAB contains the hit list
CHANGING parameters:
SHLP additional inIormation about the parameters (Deep structure)
CALLCONTROL instructions Ior controlling the search help process
CALLCONTROL-STEP
. SELONE
Call before selecting an elementary search help. The possible elementary search helps are already in SHLP_TAB. This timepoint
can be used in a search help exit of a collective search help to restrict the selection possibilities for the elementary search helps.
Entries that are deleted from SHLP_TAB in this step are not offered in the elementary search help selection. f there is only one entry
remaining in SHLP_TAB, the dialog box for selecting elementary search helps is skipped. You may not change the next timepoint.
The timepoint is not accessed again if another elementary search help is to be selected during the dialog.
2. PRESEL
After selecting an elementary search help. Table NTERFACE has not yet been copied to table SELOPT at this timepoint in the
definition of the search help (type SHLP_DESCR_T). This means that you can still influence the attachment of the search help to the
screen here. (Table NTERFACE contains the information about how the search help parameters are related to the screen fields).
3. PRESEL
Before sending the dialog box for restricting values. This timepoint is suitable for predefining the value restriction or for completely
suppressing or copying the dialog.
4. SELECT
Before selecting the values. f you do not want the default selection, you should copy this timepoint with a search help exit. DSP
should be set as the next timepoint.
5. DSP
Before displaying the hit list. This timepoint is suitable for restricting the values to be displayed, e.g. depending on authorizations.
CALLCONTROL-STEP 2
. RETURN (usually as return value for the next timepoint)
The RETURN timepoint should be returned as the next step if a single hit was selected in a search help exit.
t can make sense to change the F4 flow at this timepoint if control of the process sequence of the Transaction should depend on the
selected value (typical example: setting SET/GET parameters). However, you should note that the process will then depend on
whether a value was entered manually or with an input help.
7. RETTOP
You only go to this timepoint if the input help is controlled by a collective search help. t directly follows the timepoint RETURN. The
search help exit of the collective search help, however, is called at timepoint RETTOP.
8. EXT (only for return as next timepoint)
The EXT timepoint should be returned as the next step if the user had the opportunity to terminate the dialog within the search help
exit.
9. CREATE
The CREATE timepoint is only accessed if the user selects the function "Create new values". This function is only available if field
CUSTTAB of the control string CALLCONTROL was given a value not equal to SPACE earlier on.
The name of the (customizing) table to be maintained is normally entered there. The next step returned after CREATE should be
SELECT so that the newly entered value can be selected and then displayed.
0. APP, APP2, APP3
f further pushbuttons are introduced in the hit list with function module F4UT_LST_EXT, these timepoints are introduced. They are
accessed when the user presses the corresponding pushbutton.
Search help exits - 2
This function is a search help exit for Z_TRKJRR - search
help for transport request number. It's purpose is to limit the
hit list to transports released within the last 90 days, and to
sort the hit list in descending order.
data delete_date like sy-datum.
data w_selopt like line of shlp-selopt.
Default the selection date to ( sy-datum - 90 ) ~ today.
Also filter out blank target systems to filter out tasks.
if callcontrol-step = 'PRESEL1'.
delete_date = sy-datum - 90.
w_selopt-shlpfield = 'AS4DATE'.
w_selopt-sign = 'I'.
w_selopt-option = 'GT'.
w_selopt-low = delete_date.
append w_selopt to shlp-selopt.
w_selopt-shlpfield = 'TARSYSTEM'.
w_selopt-sign = 'E'.
w_selopt-option = 'EQ'.
w_selopt-low = space.
append w_selopt to shlp-selopt.
endif.
Sort the hit list.
if callcontrol-step = 'DISP'.
sort record_tab descending.
callcontrol-sortoff = 'X'.
endif.
Sample code Irom Iunction
module
ZUTF4TRKORRSHEXIT
Programming in reports
II there is a search help linked to a dictionary Iield (either directly to the Iield or to its data element), then deIining
a report parameter LIKE the dictionary Iield will bring in the search help Iunctionality Ior you You might
want to speciIy the search help yourselI Ior the Iollowing reasons:
There is no search help attached to the dictionary Iield
2 You want to use a diIIerent search help than the one attached to the dictionary Iield
3 You want to speciIy which elementary search help to use, rather than allow the user to see the collective
search help
This example Iorces the selection screen to adopt the elementary search help ZMIDA, rather than use the
collective search help ZMID, which is attached to the dictionary Iield
Parameters: pmitid like zmitid-mitid Parameters: pmitid like zmitid-mitid matchcode object ZMIDA
You can program your own possible values directly Code the event AT SELECTION-SCREEN ON VALUE
REQUEST FOR Iield name~, then write the code to produce the list The system creates the possible values button
Ior you
Programming in screens
SpeciIy the search help name in the screen element list II you speciIy a reIerence Iield which has a search help
attached, leave the search help Iield blank and the system will use the attached search help
You can also code your own value-help DeIine the screen Iield with a possible entries key (set in Iield
attributes) Then code a module Ior the Iield under PROCESS ON VALUE-REQUEST You can use the Iunction
modules DYNPVALUESREAD and DYNPVALUESUPDATE to eIIect Iield transIer to / Irom the screen,
since this is not done during value request

You might also like