Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

search help showing less values

former_member806481
Participant
0 Kudos

Hello everyone,

I have created a search help exit and have assigned it to the field.

ISSUE :

  • When the output entries are restricted to 500 (screenshot below) i am getting only 8 entries

  • But when i remove the restriction i am getting all entries ( I WANT 500 ENTRIES STARTING WITH VA* IF I RESTRICT ENTRIES TO 500 )

FUNCTION z_f4if_shlp_exit_example.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------

* Data Declaration
DATA: lt_shlpselop TYPE ddshselops,
ls_shlpselop LIKE LINE OF lt_shlpselop,
gd_wgbez TYPE t087s-gdlgrp_txt , "h_zmatsearch-wgbez,
gd_usrwgbez TYPE t087s-gdlgrp_txt, "h_zmatsearch-wgbez,
gd_tabix TYPE i,
lt_shlp TYPE shlp_descr-fielddescr,
ls_shlp LIKE LINE OF lt_shlp.

* EXIT immediately, if you do not want to handle this step
IF callcontrol-step <> 'SELONE' AND
callcontrol-step <> 'SELECT' AND
" AND SO ON
callcontrol-step <> 'DISP'.
EXIT.
ENDIF.
IF callcontrol-step = 'SELONE'.
* PERFORM SELONE .........
EXIT.
ENDIF.
IF callcontrol-step = 'PRESEL'.
* PERFORM PRESEL ..........
EXIT.
ENDIF.
IF callcontrol-step = 'SELECT'.
LOOP AT shlp-selopt INTO ls_shlpselop.
IF ls_shlpselop-shlpfield EQ 'GDLGRP_TXT'.
gd_usrwgbez = ls_shlpselop-low.
EXPORT gd_usrwgbez TO MEMORY ID 'ID1234'.
DELETE shlp-selopt INDEX sy-tabix.
ENDIF.
ENDLOOP.
EXIT. "Don't process STEP DISP additionally in this call.
ENDIF.
IF callcontrol-step = 'DISP'.
IMPORT gd_usrwgbez TO gd_usrwgbez FROM MEMORY ID 'ID1234'.
IF NOT gd_usrwgbez IS INITIAL.
TRANSLATE gd_usrwgbez TO UPPER CASE.
LOOP AT record_tab.
gd_tabix = sy-tabix.
READ TABLE shlp-fielddescr INTO ls_shlp
WITH KEY tabname = 'T087S'
fieldname = 'GDLGRP_TXT'.
ls_shlp-offset = ls_shlp-offset / 2.
*
gd_wgbez = record_tab-string+ls_shlp-offset(20).
TRANSLATE gd_wgbez TO UPPER CASE.
IF NOT gd_wgbez CP gd_usrwgbez.
DELETE record_tab INDEX gd_tabix.
ENDIF.
ENDLOOP.
ENDIF.
EXIT.
ENDIF.
ENDFUNCTION.
1 ACCEPTED SOLUTION

Sandra_Rossi
Active Contributor
0 Kudos

If you want your search help exit to filter the records specifically and return the requested number of records, you must:

  • Use CALLCONTROL-MAXRECORDS to know the limit chosen by the user
  • Do your own SELECT and filtering in the 'SELECT' step (if CALLCONTROL-STEP = 'SELECT') to have up to CALLCONTROL-MAXRECORDS records
    -- Better remove the view or table name from the source of the search help to not SELECT useless.
  • Update the parameter RECORDS from the SELECT using the function module F4UT_RESULTS_MAP
  • "CALLCONTROL-STEP should be changed to 'DISP' since the F4 processor will otherwise again delete the values entered in RECORD_TAB at SELECT time." (from doc of F4UT_RESULTS_MAP)
15 REPLIES 15

matt
Active Contributor

A few things.

  1. I hope that z_f4if_shlp_exit_example is not the final name of your search help function module.
  2. Don't use EXIT to quit a function module, use RETURN.

Now, have you tried debugging to see how many records the function module returns? Since nowhere do you use callcontrol-maxrecords, it seems likely the issue isn't in your FM.

Try putting an SQL trace and run the search help with and without restricting the number of records. See where the select is happening and exactly what SQL is being issued and where.

raymond_giuseppi
Active Contributor

Put a break-point at the start of the DISP step.

  1. The standard selection of data was restricted to 500 records into RECORD_TAB at the SELECT step
  2. Then your exit deleted most of those selected records at start of the DISP step.

(What was your exact requirement)

0 Kudos

i wanted to make the search help case insensetive so that whenever i give va* (small caps) i get all values of va irrespective of the case

0 Kudos

You would have to handle the SELECT step yourself for this requirement. (select the data and use a FM such as F4UT_RESULTS_MAP to pass the selected records back to search-help)

former_member806481
Participant
0 Kudos

before i put va* there are 500 values fetched and what happens is after i put va* the loop goes for the 500 values that were there and in that 500 values only 9 values are there starting with va*

Sandra_Rossi
Active Contributor
0 Kudos

Please debug yourself, then when you understand what happens, refine your question.

former_member806481
Participant
0 Kudos

i have debugged it i am just not understanding that whenever i am restricting it to 500 then i get only 8 values

Sandra_Rossi
Active Contributor
0 Kudos

Please explain what you have seen in the debug then.

Sandra_Rossi
Active Contributor

I guess you understand that you delete all lines (except 8?) because of

        IF NOT gd_wgbez CP gd_usrwgbez.
          DELETE record_tab INDEX gd_tabix.
        ENDIF.

What contain gd_wgbez and gd_usrwgbez when lines are deleted?

What contain gd_wgbez and gd_usrwgbez when lines are not deleted?

Sandra_Rossi
Active Contributor

I guess you didn't understand what Raymond told you.

If you restrict to 500, your user exit deletes 492 lines as expected, so only 8 lines are shown.

If you don't restrict, of course it works as expected.

former_member806481
Participant
0 Kudos

i see that i am looping the record_tab and comapring the values (va*) and then deleting the unmatched values.

but is there a way that i restrict the search help to 500 values and when i give (va*) i get 500 values starting with va irrespective of their cases ( 'Va' 'vA' 'va' 'VA' )

Sandra_Rossi
Active Contributor
0 Kudos

If you want your search help exit to filter the records specifically and return the requested number of records, you must:

  • Use CALLCONTROL-MAXRECORDS to know the limit chosen by the user
  • Do your own SELECT and filtering in the 'SELECT' step (if CALLCONTROL-STEP = 'SELECT') to have up to CALLCONTROL-MAXRECORDS records
    -- Better remove the view or table name from the source of the search help to not SELECT useless.
  • Update the parameter RECORDS from the SELECT using the function module F4UT_RESULTS_MAP
  • "CALLCONTROL-STEP should be changed to 'DISP' since the F4 processor will otherwise again delete the values entered in RECORD_TAB at SELECT time." (from doc of F4UT_RESULTS_MAP)

0 Kudos

i will try this approach

sandra.rossi thank you for your answer it worked for me .

Under the step 'DISP' i have written the following line of code

IF callcontrol-step = 'DISP'.

SELECT gdlgrp, gdlgrp_txt FROM t087s INTO TABLE @DATA(lt_t087s)
WHERE spras EQ @sy-langu.
IF sy-subrc = 0.
CALL FUNCTION 'F4UT_RESULTS_MAP'
EXPORTING
* SOURCE_STRUCTURE =
apply_restrictions = 'X'
TABLES
shlp_tab = shlp_tab
record_tab = record_tab
source_tab = lt_t087s
CHANGING
shlp = shlp
callcontrol = callcontrol
EXCEPTIONS
illegal_structure = 1
OTHERS = 2.
ENDIF.
* PERFORM AUTHORITY_CHECK TABLES RECORD_TAB SHLP_TAB
* CHANGING SHLP CALLCONTROL.
** EXIT.
RETURN.
ENDIF.

0 Kudos

Did you select everything, filtered according to "va*" and you didn't need to use CALLCONTROL-MAXRECORDS ?