Application Development and Automation 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: 
Read only

how to validate this through coding

Former Member
0 Likes
712

Hi Friend:

I've 10 fields on selection screen. All are select options.Out of that 3 are mandatory. Based on that I've fetched data in different internal tables. Now I've to put a validation for the case when the user might enter data in non mandatory select options. say. for S_matnr. Should I put a check on the final table or on itab_mara (in which I fectehd data related to MARA table). Please give me the code as well.

Thanks

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
687

Hi,

Try using the Validation for the field and giving an error if theres an invalid input,


AT SELECTION-SCREEN.

  IF NOT s_matnr IS INITIAL.

    SELECT SINGLE
           matnr
      FROM mara
      INTO (w_matnr)
     WHERE matnr IN s_matnr.

    IF sy-subrc NE 0.
      MESSAGE e888(sabapdocu)
         WITH 'Invalid Material number'.
    ENDIF.

  ENDIF.

This code checks for values entered into S_MATNR. If all the values entered are invalid it will throw up an error on the selection screen.

This restricts the execution of the program until a valid input is provided by the user on the screen.

5 REPLIES 5
Read only

Former Member
0 Likes
687

Hi,

Put a validation,

If not s_matnr-low is initial or
   not s_matnr-high is initial.

select * from mara 
         into itab_mara
where matnr in s_matnr.

endif.

Best regards,

Prashant

Read only

Former Member
0 Likes
687

Hi change below as per requirement

END-OF-SELECTION

Loop at s_matnr.

If s_matnr-LOW eq it_final-matnr.

endif.

endloop.

rgds

rajesh

Read only

Former Member
0 Likes
687

validate all your select-options in

AT SELECTION SCREEN events.

if s_matnr is not initial.

select single matnr
from mara
into w_matnr
where matnr in s_matnr.

if sy-subrc NE 0.
  message.....
endif.

endif.

With luck,

Pritam.

Read only

Former Member
0 Likes
687

When selecting data from database tables pass all select-options in the where clause using in operator.

Ex:

Select fld1...fldn

from <table>

into table i_tab

where fld1 in s_fld1

and fld2 in s_fld2

and ......

and fld10 in s_fld10.

For non-mandatory select-options in no value is given in the selection screen then it will fetch all the records.otherwise it will fetch only the record that is present in the select-option.

Regards,

JOy.

Read only

Former Member
0 Likes
688

Hi,

Try using the Validation for the field and giving an error if theres an invalid input,


AT SELECTION-SCREEN.

  IF NOT s_matnr IS INITIAL.

    SELECT SINGLE
           matnr
      FROM mara
      INTO (w_matnr)
     WHERE matnr IN s_matnr.

    IF sy-subrc NE 0.
      MESSAGE e888(sabapdocu)
         WITH 'Invalid Material number'.
    ENDIF.

  ENDIF.

This code checks for values entered into S_MATNR. If all the values entered are invalid it will throw up an error on the selection screen.

This restricts the execution of the program until a valid input is provided by the user on the screen.