05-21-2009 7:43 AM
Hi,
I have implemented F4 help for a selection screen field using function module.
I want to throw a customized error message if no value is available.
In my case if no value is available it gives standard message no value available.
I have tried but it gives a dump.
Please suggest.
Thanks and Regards
Shraddha
05-21-2009 7:48 AM
for F4 help defenitely you will be having a select query to populate into internal table
if it is so
after the select query with sy-subrc check
if yes
then it will proceed with the function module
if no then throw error message
message
use this code
form f_f4help .
data : begin of it_itab occurs 1,
username type usr02-bname,
end of it_itab.
select bname from usr02 into table it_itab.
if sy-subrc = 0
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'BNAME'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'P_USER'
value_org = 'S'
tables
value_tab = it_itab[]
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc ne 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
else.
message with error.
endif.
endform.
cheers
s.janagar
05-21-2009 7:48 AM
05-21-2009 7:53 AM
Hi Shradhha,
If you are using 'F4IF_INT_TABLE_VALUE_REQUEST' function module for F4 help then after calling the FM check for sy-subrc. If sy-subrc = 2 then give your message there as the FM returns 2 when no values found. Hope this will solve your problem.
regards
Amarendra
05-21-2009 7:56 AM
hi,
DATA : fld(18).
PARAMETERS p_matnr LIKE fld.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_matnr.
DATA : BEGIN OF it_itab OCCURS 1,
matnr TYPE mara-matnr,
meins TYPE mara-meins,
END OF it_itab.
SELECT matnr
meins FROM mara INTO TABLE it_itab UP TO 10 ROWS.
IF it_itab[] IS NOT INITIAL.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'MATNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'S_MATNR'
value_org = 'S'
TABLES
value_tab = it_itab[]
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ELSE.
MESSAGE 'Custom Message' TYPE 'S'.
ENDIF.
Thanks & Regards