2022 Sep 23 2:42 PM
Hello everyone,
I have created a search help exit and have assigned it to the field.
ISSUE :
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.
2022 Sep 25 3:48 PM
If you want your search help exit to filter the records specifically and return the requested number of records, you must:
2022 Sep 23 3:33 PM
A few things.
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.
2022 Sep 23 4:51 PM
2022 Sep 25 11:14 AM
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
2022 Sep 26 10:54 AM
2022 Sep 25 11:16 AM
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*
2022 Sep 25 12:14 PM
Please debug yourself, then when you understand what happens, refine your question.
2022 Sep 25 12:20 PM
i have debugged it i am just not understanding that whenever i am restricting it to 500 then i get only 8 values
2022 Sep 25 1:05 PM
2022 Sep 25 1:16 PM
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?
2022 Sep 25 1:25 PM
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.
2022 Sep 25 2:02 PM
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' )
2022 Sep 25 3:48 PM
If you want your search help exit to filter the records specifically and return the requested number of records, you must:
2022 Sep 26 6:19 AM
2022 Sep 26 6:44 AM
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.
2022 Sep 26 2:39 PM
Did you select everything, filtered according to "va*" and you didn't need to use CALLCONTROL-MAXRECORDS ?