‎2008 Aug 19 4:25 PM
Hi.
I have this FM created by me.
FUNCTION z_ricerca_ara_ofi.
*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCR_TAB_T
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR_T
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
DATA DECLARED ... :P
* 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.
*"----------------------------------------------------------------------
* STEP SELONE (Select one of the elementary searchhelps)
*"----------------------------------------------------------------------
* This step is only called for collective searchhelps. It may be used
* to reduce the amount of elementary searchhelps given in SHLP_TAB.
* The compound searchhelp is given in SHLP.
* If you do not change CALLCONTROL-STEP, the next step is the
* dialog, to select one of the elementary searchhelps.
* If you want to skip this dialog, you have to return the selected
* elementary searchhelp in SHLP and to change CALLCONTROL-STEP to
* either to 'PRESEL' or to 'SELECT'.
IF callcontrol-step = 'SELONE'.
* PERFORM SELONE .........
EXIT.
ENDIF.
*"----------------------------------------------------------------------
* STEP PRESEL (Enter selection conditions)
*"----------------------------------------------------------------------
* This step allows you, to influence the selection conditions either
* before they are displayed or in order to skip the dialog completely.
* If you want to skip the dialog, you should change CALLCONTROL-STEP
* to 'SELECT'.
* Normaly only SHLP-SELOPT should be changed in this step.
IF callcontrol-step = 'PRESEL'.
* PERFORM PRESEL ..........
EXIT.
ENDIF.
*"----------------------------------------------------------------------
* STEP SELECT (Select values)
*"----------------------------------------------------------------------
* This step may be used to overtake the data selection completely.
* To skip the standard seletion, you should return 'DISP' as following
* step in CALLCONTROL-STEP.
* Normally RECORD_TAB should be filled after this step
IF callcontrol-step = 'SELECT'.
LOOP AT shlp-selopt INTO ls_interface.
APPEND ls_interface TO lt_interface.
ENDLOOP.
....
STUFF DONE HERE :P.
....
LOOP AT lt_matnr INTO ls_matnr.
APPEND ls_matnr TO record_tab.
ENDLOOP.
ENDIF.
*"----------------------------------------------------------------------
* STEP DISP (Display values)
*"----------------------------------------------------------------------
* This step is called, before the selected data is displayed.
* You can e.g. modify or reduce the data in RECORD_TAB
* according to the users authority.
* If you want to get the standard display dialog afterwards, you
* should not change CALLCONTROL-STEP.
* If you want to overtake the dialog on you own, you must return
* the following values in CALLCONTROL-STEP:
* - "RETURN" if one line was selected. The selected line must be
* the only record left in RECORD_TAB. The corresponding fields of
* this line are entered into the screen.
* - "EXIT" if the values request should be aborted
* - "PRESEL" if you want to return to the selection dialog
IF callcontrol-step = 'DISP'.
* PERFORM AUTHORITY_CHECK TABLES RECORD_TAB USING SHLP.
EXIT.
ENDIF.
ENDFUNCTION. My questions is:
Do i have to write something else in some of the STEPS ?
Because i receive the message that the list is empty, but lt_matnr has 397 lines.
I saw that in some further steps, outside my FM, record_tab is refreshed.
There seams to be something missing from my FM, but i can't figure it out.
Can someone help?
Thanks.
‎2008 Aug 19 4:34 PM
Exit Function starts with F4UT
function f4ut_shlp_ext_lgobe.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRLand second when you are using exit function for search help that means using this function we add some extra fields display logic etc.
in the below example i am just showing the search help for LGOBE Text in different language along with other fields so i coded in the DISP step..
if callcontrol-step = 'DISP'.
perform authority_check tables record_tab shlp_tab
changing shlp callcontrol.
exit.
endif.form authority_check tables record_tab structure seahlpres
shlp_tab type shlp_desct
changing p_shlp type shlp_descr
p_callcontrol type ddshf4ctrl.
data: wa_shlp type dfies,
v_lgobe type zt001l-zlgobe_de,
lt_record type seahlpres occurs 0 with header line.
read table shlp_tab index 1.
loop at record_tab.
read table shlp_tab-fielddescr into wa_shlp with key tabname = 'T001L'
fieldname = 'WERKS'.
*if record_tab-string+3(4) = 1000.
lt_record-string = record_tab-string.
select single zlgobe_de
from zt001l
into v_lgobe
where werks = record_tab-string+3(4) and
lgort = record_tab-string+7(4).
if sy-subrc eq 0.
lt_record-string+11(16) = v_lgobe.
clear v_lgobe.
append lt_record.
endif.
endloop.even if you don't do any thing in the exit, but make sure that you have created the Function starts with F4UT*
‎2008 Aug 19 4:34 PM
Exit Function starts with F4UT
function f4ut_shlp_ext_lgobe.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCT
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRLand second when you are using exit function for search help that means using this function we add some extra fields display logic etc.
in the below example i am just showing the search help for LGOBE Text in different language along with other fields so i coded in the DISP step..
if callcontrol-step = 'DISP'.
perform authority_check tables record_tab shlp_tab
changing shlp callcontrol.
exit.
endif.form authority_check tables record_tab structure seahlpres
shlp_tab type shlp_desct
changing p_shlp type shlp_descr
p_callcontrol type ddshf4ctrl.
data: wa_shlp type dfies,
v_lgobe type zt001l-zlgobe_de,
lt_record type seahlpres occurs 0 with header line.
read table shlp_tab index 1.
loop at record_tab.
read table shlp_tab-fielddescr into wa_shlp with key tabname = 'T001L'
fieldname = 'WERKS'.
*if record_tab-string+3(4) = 1000.
lt_record-string = record_tab-string.
select single zlgobe_de
from zt001l
into v_lgobe
where werks = record_tab-string+3(4) and
lgort = record_tab-string+7(4).
if sy-subrc eq 0.
lt_record-string+11(16) = v_lgobe.
clear v_lgobe.
append lt_record.
endif.
endloop.even if you don't do any thing in the exit, but make sure that you have created the Function starts with F4UT*
‎2008 Aug 19 6:05 PM
So it's ok to use record_tab as the result table, right ?
I only need to add something after
if callcontrol-step = 'DISP'.regarding record_tab (assuming i did the "f4ut*" change)?
‎2008 Aug 19 4:39 PM
Hi,
create one sample program and try to use the search help created by you, if you directly execute the function module it will not give desired results.
Thanks,
Sreeram.
‎2008 Aug 19 4:42 PM
Test the search help without the search help exit "z_ricerca_ara_ofi"
confirm whether you are getting 397 or more records?
and also check your selection method (may be view) is correct?
a®
‎2008 Aug 19 6:03 PM
It's too complicated to do it without the exit. I haven't got it yet. 😄
BUT searching by hand in those tables, i get to the same result as the program. So i guess i'm right about those 397 records.
‎2008 Aug 19 6:24 PM
What i am suggesting is for testing purpose just remove the function exit and check whether you are getting the records.
another way is to create a database view for that table with filtered records and apply that database view in the "selection method" in the search help.
a®
‎2008 Aug 19 7:12 PM
Hi there guys.
Thanks for the help and for the ideas.
The answer was allot simpler. It was only needed to add one line
callcontrol-step = 'DISP'.before the corresponding ENDIF of
IF callcontrol-step = 'SELECT'..
Here is what I did:
FUNCTION z_ricerca_ara_ofi.
*"----------------------------------------------------------------------
*"*"Interfaccia locale:
*" TABLES
*" SHLP_TAB TYPE SHLP_DESCR_TAB_T
*" RECORD_TAB STRUCTURE SEAHLPRES
*" CHANGING
*" VALUE(SHLP) TYPE SHLP_DESCR_T
*" VALUE(CALLCONTROL) LIKE DDSHF4CTRL STRUCTURE DDSHF4CTRL
*"----------------------------------------------------------------------
DATA: BEGIN OF ls_cawnt,
atinn TYPE atinn,
spras TYPE spras,
adzhl TYPE adzhl,
atzhl TYPE atzhl,
END OF ls_cawnt.
DATA: BEGIN OF ls_cawn,
atwrt TYPE atwrt,
atflv TYPE atflv,
END OF ls_cawn.
DATA: BEGIN OF ls_cabn,
atfor TYPE atfor,
anzst TYPE anzst,
anzdz TYPE anzdz,
END OF ls_cabn.
DATA: BEGIN OF lt_ausp OCCURS 0,
objek TYPE objnum,
cuobf TYPE cuobm,
END OF lt_ausp,
ls_ausp LIKE LINE OF lt_ausp.
DATA: lt_interface TYPE STANDARD TABLE OF ddshselopt,
ls_interface LIKE LINE OF lt_interface,
strwhere TYPE string,
strwhere2 TYPE string
.
TYPES: BEGIN OF gs_matnr,
matnr TYPE matnr,
END OF gs_matnr.
DATA: lt_matnr TYPE TABLE OF gs_matnr,
ls_matnr TYPE gs_matnr.
DATA: BEGIN OF s_matnr OCCURS 0,
sign(1),
option(2),
low TYPE matnr,
high TYPE matnr,
END OF s_matnr.
DATA: BEGIN OF s_maktg OCCURS 0,
sign(1),
option(2),
low TYPE maktg,
high TYPE maktg,
END OF s_maktg.
DATA: BEGIN OF s_spras OCCURS 0,
sign(1),
option(2),
low TYPE spras,
high TYPE spras,
END OF s_spras.
DATA: BEGIN OF s_zzcodara OCCURS 0,
sign(1),
option(2),
low TYPE zzcodara,
high TYPE zzcodara,
END OF s_zzcodara.
DATA: BEGIN OF s_zzcodofi OCCURS 0,
sign(1),
option(2),
low TYPE zzcodofi,
high TYPE zzcodofi,
END OF s_zzcodofi.
DATA: BEGIN OF s_carat1 OCCURS 0,
sign(1),
option(2),
low TYPE zcarat,
high TYPE zcarat,
END OF s_carat1.
DATA: BEGIN OF s_carat2 OCCURS 0,
sign(1),
option(2),
low TYPE zcarat,
high TYPE zcarat,
END OF s_carat2.
DATA: BEGIN OF s_carat3 OCCURS 0,
sign(1),
option(2),
low TYPE zcarat,
high TYPE zcarat,
END OF s_carat3.
DATA: BEGIN OF s_categ OCCURS 0,
sign(1),
option(2),
low TYPE zcateg,
high TYPE zcateg,
END OF s_categ.
* 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.
*"----------------------------------------------------------------------
* STEP SELONE (Select one of the elementary searchhelps)
*"----------------------------------------------------------------------
* This step is only called for collective searchhelps. It may be used
* to reduce the amount of elementary searchhelps given in SHLP_TAB.
* The compound searchhelp is given in SHLP.
* If you do not change CALLCONTROL-STEP, the next step is the
* dialog, to select one of the elementary searchhelps.
* If you want to skip this dialog, you have to return the selected
* elementary searchhelp in SHLP and to change CALLCONTROL-STEP to
* either to 'PRESEL' or to 'SELECT'.
IF callcontrol-step = 'SELONE'.
* PERFORM SELONE .........
EXIT.
ENDIF.
*"----------------------------------------------------------------------
* STEP PRESEL (Enter selection conditions)
*"----------------------------------------------------------------------
* This step allows you, to influence the selection conditions either
* before they are displayed or in order to skip the dialog completely.
* If you want to skip the dialog, you should change CALLCONTROL-STEP
* to 'SELECT'.
* Normaly only SHLP-SELOPT should be changed in this step.
IF callcontrol-step = 'PRESEL'.
* PERFORM PRESEL ..........
EXIT.
ENDIF.
*"----------------------------------------------------------------------
* STEP SELECT (Select values)
*"----------------------------------------------------------------------
* This step may be used to overtake the data selection completely.
* To skip the standard seletion, you should return 'DISP' as following
* step in CALLCONTROL-STEP.
* Normally RECORD_TAB should be filled after this step
IF callcontrol-step = 'SELECT'.
LOOP AT shlp-selopt INTO ls_interface.
APPEND ls_interface TO lt_interface.
ENDLOOP.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'MATNR'.
IF sy-subrc = 0.
s_matnr-sign = ls_interface-sign.
s_matnr-option = ls_interface-option.
s_matnr-low = ls_interface-low.
APPEND s_matnr.
CONCATENATE strwhere ' mara~matnr IN s_matnr AND' INTO strwhere.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'MAKTG'.
IF sy-subrc = 0.
s_maktg-sign = ls_interface-sign.
s_maktg-option = ls_interface-option.
s_maktg-low = ls_interface-low.
APPEND s_maktg.
CONCATENATE strwhere ' MAKTG IN s_maktg AND' INTO strwhere.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'SPRAS'.
IF sy-subrc = 0.
s_spras-sign = ls_interface-sign.
s_spras-option = ls_interface-option.
s_spras-low = ls_interface-low.
APPEND s_spras.
CONCATENATE strwhere ' spras IN s_spras AND' INTO strwhere.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'ZZCODARA'.
IF sy-subrc = 0.
s_zzcodara-sign = ls_interface-sign.
s_zzcodara-option = ls_interface-option.
s_zzcodara-low = ls_interface-low.
APPEND s_zzcodara.
CONCATENATE strwhere ' zzcodara IN s_zzcodara AND' INTO strwhere.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'ZZCODOFI'.
IF sy-subrc = 0.
s_zzcodofi-sign = ls_interface-sign.
s_zzcodofi-option = ls_interface-option.
s_zzcodofi-low = ls_interface-low.
APPEND s_zzcodofi.
CONCATENATE strwhere ' zzcodofi IN s_zzcodofi AND' INTO strwhere.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'CARAT1'.
IF sy-subrc = 0.
s_carat1-sign = ls_interface-sign.
s_carat1-option = ls_interface-option.
s_carat1-low = ls_interface-low.
APPEND s_carat1.
CONCATENATE strwhere2 ' ATWTB IN s_carat1 AND' INTO strwhere2.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'CARAT2'.
IF sy-subrc = 0.
s_carat2-sign = ls_interface-sign.
s_carat2-option = ls_interface-option.
s_carat2-low = ls_interface-low.
APPEND s_carat2.
CONCATENATE strwhere2 ' ATWTB IN s_carat2 AND' INTO strwhere2.
CLEAR ls_interface.
ENDIF.
READ TABLE lt_interface INTO ls_interface WITH KEY shlpfield = 'CARAT3'.
IF sy-subrc = 0.
s_carat3-sign = ls_interface-sign.
s_carat3-option = ls_interface-option.
s_carat3-low = ls_interface-low.
APPEND s_carat3.
CONCATENATE strwhere2 ' ATWTB IN s_carat3 AND' INTO strwhere2.
CLEAR ls_interface.
ENDIF.
IF ( NOT strwhere2 IS INITIAL ).
SHIFT strwhere2 RIGHT DELETING TRAILING 'AND'.
SELECT SINGLE atinn spras adzhl atzhl
FROM cawnt
INTO CORRESPONDING FIELDS OF ls_cawnt
WHERE (strwhere2).
SELECT SINGLE atwrt atflv
FROM cawn
INTO CORRESPONDING FIELDS OF ls_cawn
WHERE atinn EQ ls_cawnt-atinn
AND atzhl EQ ls_cawnt-atzhl.
SELECT SINGLE atfor anzst anzdz
FROM cabn
INTO CORRESPONDING FIELDS OF ls_cabn
WHERE atinn EQ ls_cawnt-atinn
AND adzhl EQ ls_cawnt-adzhl.
IF ls_cabn-atfor = 'CHAR'.
SELECT objek
FROM ausp
INTO CORRESPONDING FIELDS OF TABLE lt_ausp
WHERE atinn EQ ls_cawnt-atinn
AND adzhl EQ ls_cawnt-adzhl
AND atwrt EQ ls_cawn-atwrt.
ENDIF.
IF ls_cabn-atfor = 'NUM'.
SELECT objek
FROM ausp
INTO CORRESPONDING FIELDS OF TABLE lt_ausp
WHERE atinn EQ ls_cawnt-atinn
AND adzhl EQ ls_cawnt-adzhl
AND atflv GE ls_cawn-atflv
AND atflb LE ls_cawn-atflv.
ENDIF.
LOOP AT lt_ausp INTO ls_ausp.
MOVE ls_ausp-objek+0(18) TO ls_ausp-cuobf.
MODIFY lt_ausp INDEX sy-tabix FROM ls_ausp
TRANSPORTING cuobf.
ENDLOOP.
IF sy-subrc = 0.
SELECT matnr
FROM mara
INTO CORRESPONDING FIELDS OF TABLE lt_matnr
FOR ALL ENTRIES IN lt_ausp
WHERE cuobf EQ lt_ausp-cuobf.
ENDIF.
ENDIF.
SHIFT strwhere RIGHT DELETING TRAILING 'AND'.
IF NOT s_matnr-low IS INITIAL.
SELECT mara~matnr
FROM mara
JOIN makt ON mara~matnr = makt~matnr
INTO CORRESPONDING FIELDS OF TABLE lt_matnr
WHERE (strwhere) " mara~prdha IN s_categ AND spras IN s_spras "
.
ENDIF.
LOOP AT lt_matnr INTO ls_matnr.
APPEND ls_matnr TO record_tab.
ENDLOOP.
callcontrol-step = 'DISP'.
CLEAR s_categ.
CLEAR lt_matnr. REFRESH lt_matnr.
CLEAR ls_matnr.
ENDIF.
*"----------------------------------------------------------------------
* STEP DISP (Display values)
*"----------------------------------------------------------------------
* This step is called, before the selected data is displayed.
* You can e.g. modify or reduce the data in RECORD_TAB
* according to the users authority.
* If you want to get the standard display dialog afterwards, you
* should not change CALLCONTROL-STEP.
* If you want to overtake the dialog on you own, you must return
* the following values in CALLCONTROL-STEP:
* - "RETURN" if one line was selected. The selected line must be
* the only record left in RECORD_TAB. The corresponding fields of
* this line are entered into the screen.
* - "EXIT" if the values request should be aborted
* - "PRESEL" if you want to return to the selection dialog
IF callcontrol-step = 'DISP'.
* PERFORM authority_check TABLES record_tab shlp_tab
* CHANGING shlp callcontrol.
* EXIT.
ENDIF.
ENDFUNCTION.It's true that it was not obligatory to do something in that perform (that's why it's still commented), but still I did not have to change the name in F4UT*.
If there is a special reason i have to change it in F4UT* pls tell me.
Thanks again for you help.
Edited by: Marius Cosmin Stoica on Aug 19, 2008 8:13 PM
‎2008 Aug 19 7:17 PM
The search help exit function will always be identified with F4UT* this is the general convention.
it is documented By SAP in the Search help exit Documentation.