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: 

how to disply error messages if values not available fpr F4 help

Former Member
0 Kudos

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

4 REPLIES 4

former_member183990
Active Contributor
0 Kudos

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

Vijay
Active Contributor
0 Kudos

hi,

if you have used FM 'F4IF_INT_TABLE_VALUE_REQUEST' to display f4.

then before calling this fm check if the data table u r passing is initial or not.

if that is initail through your msg instead of calling FM.

regards

Vj

Former Member
0 Kudos

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

Mohamed_Mukhtar
Active Contributor
0 Kudos

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