Online Tutorials & Training Materials | STechies.com
Register Login

Attach Search Help to Selection Screen Field

|| || 1

Attach Search Help to Selection Screen Field
Stechies

There are many ways using which we can add a Search Help to a field on Selection Screen in ABAP. Two of them are as follows:

Adding Search help to a Selection screen using Search help Object & function module 'F4IF_INT_TABLE_VALUE_REQUEST'

Using Search Help object

  1. Enter the transaction code as SE11 in the command field.
  2. Select the radio button for Search help and enter a name for the custom Search help. And click on Create button. 
  3. On the next screen select the option 'Elementary search help'.
  4. Give some description for the search help.
  5. In the field Selection method, the database table name should be entered. This table is the one from which we are going to pick values for the field Infotype number. Table T582S can be used for this purpose.
  6. Select the dialog type :

Related: What is Search Help & How to create Search Help

A – Dialog depends on set of values. If there are more than 100 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.

  1. In the Parameters structure below enter the fields required for selection criteria and displaying on value help.
  2. The various options in this section are:

IMP: Check this box to indicate that the field is an input field, that is, to be passed to the search help.

EXP: Check this box to indicate that the field is an output field, that is, to be passed from the search help to the screen.

LPOS: The position of the as it appears in the hit list.

SPOS: The position of the field as it appears in the selection screen.

SDIS: Causes the field to be “display only” in the selection screen.

Data element: Sets the attributes of the search help parameter. Normally filled in by the system.

MOD: Check this box to assign a different data element than the one supplied by the system.

Default value: Specify the default value in one of 3 ways: a ‘literal’(in quotes), a parameter

ID (ZRD), or a system field (SY-UNAME).

  1. You can provide a default value to the field used for selection. For e.g. here SPRSL is given the default value as SY_LANGU. This means whenever this search help is used for any Infotype Number field on screen, all the infotypes and there texts will be displayed in the system language. Likewise any selection criteria can be used.
  2. Once the Search Help is ready check it and activate it.

Related: Difference between Elementary Search Helps and Collective Search Help

This newly created Search Help can be used in report program as below:

SELECTION-SCREENBEGINOFLINE.
SELECTION-SCREENcomment(30)text-001.
PARAMETERS:infty_no(4)MATCHCODEOBJECTZHR_INFTY.
SELECTION-SCREENENDOFLINE.

The statement MATCHCODE OBJECT can be used to assign a Search Help to a field.

The name of the search help is to be provided after this statement WITHOUT quotes.

Using the function module 'F4IF_INT_TABLE_VALUE_REQUEST'

  1. Along with the call to this Function module, following code should also be added:

PARAMETERS:infty_no(4).

ATSELECTION-SCREENONVALUE-REQUESTFORinfty_no.

  1. While calling the FM, we need to pass three itabs. These are as explained below:

DeclarationofInternaltables
DATA:it_returnTYPEddshretvalOCCURS0WITHHEADERLINE,
it_f4_fieldsLIKEdfiesOCCURS0WITHHEADERLINE,
it_dselcLIKEdselcOCCURS0WITHHEADERLINE.

Declarationsoflocalvariables
DATA:wa_retfieldTYPEdfies-fieldname,
wa_fieldsLIKELINEOFit_f4_fields.

DATA:it_f4_varTYPETABLEOFzhr_infty_f4.

Here the custom table used to supply input values for INFTY_NO is zhr_infty_f4.

REFRESH:it_f4_fields.

CALLFUNCTION'DDIF_FIELDINFO_GET'

EXPORTING
tabname='ZHR_INFTY_F4'
fieldname='INFTY'
langu=sy-langu
lfieldname='INFTY'

IMPORTING

dfies_wa=wa_fields.

APPENDwa_fieldsTOit_f4_fields.

Get the fields from table zhr_infty_f4 which will be displayed in the F4 help. Append these to table it_f4_fields.

In this example, two fields INFTY and INFTY_TEXT are displayed.

CALLFUNCTION'DDIF_FIELDINFO_GET'

EXPORTING

tabname='ZHR_INFTY_F4'
fieldname='INFTY_TEXT'
langu=sy-langu
lfieldname='INFTY_TEXT'

IMPORTING

dfies_wa=wa_fields.

APPENDwa_fieldsTOit_f4_fields.

Provide the fieldname from custom table and screen field name to respective fields of table it_dselc

it_dselc-fldname='INFTY'.
it_dselc-dyfldname='INFTY_NO'.
APPENDit_dselc.

In this field (wa_retfield), the name of the screen field should be passed.

wa_retfield='INFTY_NO'.

Select the entries to be added to the search help using a system table and store in it_f4_var , even custom table can be created for this purpose.

This function module can be used as below:

CALLFUNCTION'F4IF_INT_TABLE_VALUE_REQUEST'

EXPORTING

retfield=wa_retfield
dynpprog=sy-repid
dynpnr='1000'
dynprofield='INFTY_NO'
value_org='S'

TABLES

value_tab=it_f4_var
field_tab=it_f4_fields
return_tab=it_return
dynpfld_mapping=it_dselc

EXCEPTIONS

parameter_error=1
no_values_found=2
OTHERS=3.

IFsy-subrcEQ0.

IFit_return[]ISNOTINITIAL.

READTABLEit_returnINDEX1.
WRITE:it_return-fieldval.

ENDIF.

ENDIF.

3. lv_retfield (type DFIES-FIELDNAME) is used to provide the structure of fields for Search help value display.

ld_f4_var is the internal table used to store input values. You can fill this table with required values providing n number of conditions in the select statement.

li_return (internal table of type ddshretval) used to store return parameter.

Advantages of Method 1 on Method 2 are

  1. You can adjust the structure of the Search Help display conveniently, keeping only the fields required and their position. If you want to do this in Method 2, you have to create a new custom table with required structure and provide it in RETFIELD.
  2. If you attach Search help to a data element or a table field, it will be useful for all report, programs, etc. wherever this data element or table field is used.

Advantage, of Method 2 on Method 1 is you can dynamically provide n number of conditions through the program and restrict the values accordingly. If you need to do this in method 1 you have to create different Search helps with different conditions.


Comments

  • 18 Jan 2018 10:40 pm

     Can we use this search help method to chose the file from presentation server to application server?

Related Articles

0.0135 seconds.