cancel
Showing results for 
Search instead for 
Did you mean: 

selection screen - search help with dynamic sql query

Former Member
0 Kudos

hey ,

is it possible to change the search help of the selection field ?

when i create the range table i put a data element :

create a range table that consists of this new data element

LT_RANGE_TABLE = WD_THIS->M_HANDLER->CREATE_RANGE_TABLE( I_TYPENAME = 'S_CARR_ID' ).

can i control the search help via the the data element or by other methods ?

i want that when the user press F4 the values that will show is the result of a sql query that i will write .

is it possible ?

thanks

ASA.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

yes it is possible...

This is my test code for say personal number select options...

lt_range_table = wd_this->m_handler->create_range_table(

i_typename = 'PERSNO' ).

  • add a new field to the selection

wd_this->m_handler->add_selection_field(

i_id = 'PERSNO'

I_VALUE_HELP_TYPE = if_wd_value_help_handler=>CO_PREFIX_SEARCHHELP

I_VALUE_HELP_ID = 'ZHELP_WDA_PERNR' "this is the custom search help we need to create

I_NO_INTERVALS = abap_true

it_result = lt_range_table

i_read_only = read_only ).

do the following:

1) copy the std function module: F4IF_SHLP_EXIT....to ZF4IF_SHLP_EXIT_pernr (in my case i am testing for pernr so my fm

name is like that....obviously it can be anything you want...under the recommended naming convention)

2) look for "STEP SELECT"

*"----


  • STEP SELECT (Select values)

*"----


3)write the code as follows:

"NOTE: this is my testing code...but you can build your logic on it....

IF CALLCONTROL-STEP = 'SELECT'.

types: begin of zpri_listing,

pernr type PERSNO,

end of zfund_listing.

DATA: lo_syuname TYPE sy-uname.

data itab type standard table of Zpri_LISTING.

data wa type zpri_listing.

DATA : t_fields LIKE TABLE OF shlp_tab-fielddescr.

DATA : w_fields LIKE LINE OF shlp_tab-fielddescr.

DATA : l_fname TYPE dfies-lfieldname.

IF lo_syuname <> sy-uname. "means we were here before and ITAB is filled...fm retains its data values...unless refresh happens

"this if condition make sure that we do not do this select all the time as long as the same user is logged in...

"a user can press f4 many times...you might want to enhance this logic a little bit more for performance

lo_syuname = sy-uname.

))))))))))))))HERE DO YOUR SELECT(((((((((((((((((((((

select pernr from "sometable" into table itab.

ENDIF.

LOOP AT shlp_tab.

LOOP AT shlp_tab-fielddescr INTO w_fields.

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 = itab

CHANGING

shlp = shlp

callcontrol = callcontrol

EXCEPTIONS

parameter_unknown = 1

OTHERS = 2

.

ENDLOOP.

ENDLOOP.

IF sy-subrc EQ 0.

callcontrol-step = 'DISP'.

ELSE.

callcontrol-step = 'EXIT'.

ENDIF.

EXIT. "Don't process STEP DISP additionally in this call.

ENDIF.

4) save and activate this function module...

5) go to se11 and create "Elementary srch hlp"....

6) fill out all the necessary fields...i am assuming that you already know how to create the search helps...

look for this field: "Search help exit" and put your function name which you created in the above steps...

in this example i have: ZF4IF_SHLP_EXIT_pernr....

7) create and activate the search help....

hope this helps...i just tested this and it is working for me....

Thanks..

AS...

Answers (0)