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: 

at- selection screen

Former Member
0 Kudos

Hi Experts,

I have a select-option in my selection screen.

Ex: s_vstel for likp-vstel.

I want to validate the values entered in the selection-screen for the field vstel.

What is the efficient way to do it? I want to check both low and high and rane values exists in database..

Regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

at selection-screen.

select single field from databasetable where field in s_field.

if sy-subrc <> 0.

*invalid values

endif.

This is best way to do validation.....!!!

Regards

vasu

8 REPLIES 8

Former Member
0 Kudos

at selection-screen.

select single field from databasetable where field in s_field.

if sy-subrc <> 0.

*invalid values

endif.

This is best way to do validation.....!!!

Regards

vasu

abdulazeez12
Active Contributor
0 Kudos

AT SELECTION-SCREEN ON S_VSTEL.

select count(*) from LIKP into gv_count where VSTEL eq S_VSTEL-low.

select count(*) from LIKP into gv_count where VSTEL eq S_VSTEL-high.

If gv_count > 0.

then valid..

otherwise throw an error message stating invalid

Reward if useful.

Former Member
0 Kudos

hi,

write a select query

table: likp.

select * from likp where vstel in s_vstel.

if sy-subrc <> 0.

error.

endif.

gopi_narendra
Active Contributor
0 Kudos

It seems you want to check the low and high values individually

Check this sample code

TABLES : vbak.
SELECT-OPTIONS : so_vbeln FOR vbak-vbeln.

AT SELECTION-SCREEN.

  IF NOT so_vbeln-low IS INITIAL.
    SELECT SINGLE * FROM vbak WHERE vbeln = so_vbeln-low.
    IF sy-subrc NE 0.
      MESSAGE e000(ztest_gopi) WITH 'Low value not avaialble'.
    ENDIF.
  ENDIF.
  IF NOT so_vbeln-high IS INITIAL.
    SELECT SINGLE * FROM vbak WHERE vbeln = so_vbeln-high.
    IF sy-subrc NE 0.
      MESSAGE e000(ztest_gopi) WITH 'High value not avaialble'.
    ENDIF.
  ENDIF.

Regards

Gopi

0 Kudos

Hi all,

Thanks.

Former Member
0 Kudos

In Main program

  • Validation Shipping Point/Receiving Point

AT SELECTION-SCREEN ON s_vstel.

PERFORM sub_valid_Point.

______________________________________________________

Inside the subroutine

&----


*& Form sub_valid_point

&----


  • Validation for Point

----


FORM sub_valid_point .

  • Validation for Shipping Point/Receiving Point

TYPES: BEGIN OF lty_vstel,

vstel TYPE tvst-vstel, " Shipping Point/Receiving Point

END OF lty_vstel.

DATA: ls_svstel LIKE LINE OF s_vstel,

ls_vstel TYPE lty_vstel,

ls_vstel_n TYPE lty_vstel,

lt_vstel TYPE TABLE OF lty_vstel,

lt_vstel_n TYPE TABLE OF lty_vstel.

  • Build internal table with all values in S_vstel

IF NOT s_vstel[] IS INITIAL.

LOOP AT s_vstel INTO ls_svstel.

  • FROM value

IF NOT ls_svstel-low IS INITIAL.

ls_vstel = ls_svstel-low.

APPEND ls_vstel TO lt_vstel.

CLEAR ls_vstel.

ENDIF.

  • TO Value

IF NOT ls_svstel-high IS INITIAL.

ls_vstel = ls_svstel-high.

APPEND ls_vstel TO lt_vstel.

CLEAR ls_vstel.

ENDIF.

ENDLOOP.

ENDIF.

  • Get data from table TVST

IF NOT lt_vstel[] IS INITIAL.

SORT lt_vstel BY vstel.

SELECT vstel

INTO TABLE lt_vstel_n

FROM tvst

FOR ALL ENTRIES IN lt_vstel

WHERE vstel = lt_vstel-vstel.

IF sy-subrc <> 0.

MESSAGE e019 WITH space.

  • Shipping Point/Receiving Point & not found, Please enter the valid Number

ENDIF.

SORT lt_vstel_n BY vstel.

  • Validate Payer

LOOP AT lt_vstel INTO ls_vstel.

CLEAR ls_vstel_n.

READ TABLE lt_vstel_n INTO ls_vstel_n WITH KEY vstel = ls_vstel-vstel

BINARY SEARCH.

IF ls_vstel-vstel <> ls_vstel_n-vstel.

MESSAGE e019 WITH ls_vstel-vstel.

  • Shipping Point/Receiving Point & not found, Please enter the valid Number

ENDIF.

ENDLOOP.

ENDIF.

ENDFORM. " sub_valid_point

Rewards if useful..............

Minal

Former Member
0 Kudos

Hi

Validation means "checking whether the input which u are gining to the selection secreen is valid or not". means...

Lets take your example only...

parameters:p_vkorg like vbak-vkorg.

in selection screen you will give inout in that parameter....

users can give any input... lets suppose I'll give input as ABC... which is not in the table VBAK. No need to excute the code once we came to know that the input is not there in the table. So we will do validation like...

at selection-screen on p_vkorg.

select * from vbak where vkorg = p+vkorg. " This is the case with Parameter.

at selection-screen on p_vkorg.

Select * from vbak where vkorg = p+vkorg. " This is the case with Selct-option.

if the input that u r giving is present in the table... the above stmt will execute successfully, otherwise not.

You can make use of System variable SY-SUBRC and you can go ahead with ur coding...

<b>Reward If Helpful</b>