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

validation on screen select-options

Former Member
0 Likes
2,181

Hi ,

In my selection-screen one select-option is there.i want to validate my select-option field.

i have written the query like

select single * from ekpo into ekpo where ebeln in s_ebeln.

if sy-subrc ne 0.

message e999 with 'enter the valid po'.

endif.

but in my selection screen i want to enter 2 correct values and 2 wrong values.

it has to stop while the wrong values execution.but i am not getting that.i am getting the correct 2 values.

how can i validate & what is the perfect validation procedure during the select-option?

Please help me.

Thanks in advance.

Regards,

Venkat.

7 REPLIES 7
Read only

former_member156446
Active Contributor
0 Likes
1,233

[check this post|http://www.sap-img.com/abap/difference-between-select-options-ranges.htm]

Read only

Former Member
0 Likes
1,233

You need to loop the select options table and validate. but this should be avoided. but select option entries can be single, multiple, patterns, includes, excludes. so it is not a good idea to loop the selection table. the way you coded will give error when all the entries are wrong. if one entry is correct then it will not give the error. it is up to you how you validate using loop or with out loop.

Read only

Former Member
0 Likes
1,233

Hi Vnekat,

You can do this if you are considering only Multiple Values and no ranges ....but in case there are ranges, Excludes, it becomes really difficult, confusing and complex.....

Anyway as per standards, there is no use of validating each & Every Valur in Select Options.....

Just keep going as you are doing.....

You can refer to any standard SAP report for the same and you will find that SAP is also doing the same way.

Read only

0 Likes
1,233

Hi,

Please tell me the package name for watching the sap standard code.

Regards,

Venkat.

Read only

0 Likes
1,233

BC* in se38 will take you to the Standard SAP code

Read only

Former Member
0 Likes
1,233

Hi,

You can code this way:-

IF s_bukrs-sign EQ 'I' AND s_bukrs-option EQ 'EQ'.

LOOP AT S_BUKRS.

Do the select single from database using s_bukrs-low and give error message.

ENDLOOP.

ENDIF.

IF s_bukrs-sign EQ 'I' AND s_bukrs-option EQ 'BT'.

If it is arange, Do the select single from database using s_bukrs-low and su_bukrs-high and store in another internal table, loop through this internal table and repeart above procedure...

ENDIF.

Read only

Former Member
0 Likes
1,233

Hi,

Check this code....


DATA: r_ebeln TYPE RANGE OF ekpo-ebeln WITH HEADER LINE.

SELECT-OPTIONS:  s_ebeln FOR ekpo-ebeln.


AT SELECTION-SCREEN ON s_ebeln.
  LOOP AT s_ebeln.
    APPEND s_ebeln TO r_ebeln.
    SELECT *
           FROM ekpo
           WHERE ebeln IN r_ebeln.
    ENDSELECT.
    
    IF sy-subrc NE 0.
      MESSAGE 'Wrong Entry' TYPE 'E'.
    ENDIF.
    
    REFRESH r_ebeln.
  ENDLOOP.