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

selection screen validation

Former Member
0 Likes
1,976

Hi experts,

below is my report (selection screen part).

since i am new to abap i do not knopw how to validate them. If the user enters wrong value in any of these selection criteria then a message will flash. By wrong valur i mean he/she should not be able to input any value that is not present in my internal table.

pls help. its really urgent.

SELECTION-SCREEN : BEGIN OF BLOCK bl1

WITH FRAME TITLE text-001.

SELECT-OPTIONS :

s_aufnr FOR afru-aufnr ,

s_kdauf FOR afpo-kdauf ,

s_budat FOR afru-budat .

SELECTION-SCREEN : END OF BLOCK bl1.

SELECTION-SCREEN : BEGIN OF BLOCK bl2

WITH FRAME TITLE text-002.

SELECT-OPTIONS : s_werks FOR afru-werks ,

s_plnbez FOR afko-plnbez,

s_shift FOR afru-zzshift,

s_equnr FOR afru-zzequnr,

s_pernr FOR afru-pernr.

SELECTION-SCREEN : END OF BLOCK bl2.

-


regards,

Rohan Das

Deloitte

+919932511468

Edited by: Rohan Das on Jan 10, 2008 10:46 AM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,417

Hi Rohan,

u can write select statement ina form or just continuation to cde without using form.

FORMs are nothing but they are like functions in "C".

FORM validate_s_aufnr.

SELECT aufnr FROM afru /* validation of aufnr*/

INTO TABLE <table name>

WHERE aufnr IN s_aufnr.

IF sy-subrc <> 0. /* display error message*/

MESSAGE e000(message-class).

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. "validate_s_aufnr

create ur own error message in SE91 .

LEAVE LIST-PROCESSING is nothing but skip the screen .

REWARD IF USEFUL

thanks and regards

suma sailaja

13 REPLIES 13
Read only

Former Member
0 Likes
1,417

Hi Rohan ,

Selection screen validation is done using the event

AT SELECTION SCREEN ,

Please see the help for it to get more info on the same.

Regards

Arun

Read only

0 Likes
1,417

I know that the event is at selection screen.

But i am not being able to understnd how to code it.

can u pls code it for me?

Read only

former_member632991
Active Contributor
0 Likes
1,417

Hi Rohan,

U an validate these in

At Selection screen or at selection screen on parameter event.

write the necessray code in these events.

Regards,

Sonika

Read only

0 Likes
1,417

thnx sonika. it was of real help

Read only

Former Member
0 Likes
1,417

Hi Rohan

For validation you need to check the data you hav eneterd is there in your database

Suppose you want to check for Aufnr

Then put all the data into internal table abd check the data which you have eneterd is there or

not if not then show the error message

Regards

Hitesh

Read only

Former Member
0 Likes
1,417

Hi,

As you are using select-options , use the below logic to validate.

AT SELECTION-SCREEN ON <FIELD>

REQUIRED LOGIC

Ex1: Best logic:

AT SELECTION-SCREEN ON so_vbeln . " Delivery document

PERFORM validate_vbeln .

FORM validate_vbeln.

DATA : l_t_vbeln TYPE TABLE OF vbuk-vbeln WITH HEADER LINE ,

l_f_vbeln TYPE vbuk-vbeln .

RANGES ra_vbeln FOR vbuk-vbeln.

LOOP AT so_vbeln.

IF NOT so_vbeln-low IS INITIAL.

ra_vbeln-sign = 'I'.

ra_vbeln-option = 'EQ'.

ra_vbeln-low = so_vbeln-low.

APPEND ra_vbeln.

ENDIF.

IF NOT so_vbeln-high IS INITIAL.

ra_vbeln-sign = 'I'.

ra_vbeln-option = 'EQ'.

ra_vbeln-low = so_vbeln-high..

APPEND ra_vbeln.

ENDIF.

ENDLOOP .

IF NOT so_vbeln[] IS INITIAL.

SELECT vbeln INTO TABLE l_t_vbeln

FROM vbuk

WHERE vbeln IN ra_vbeln.

ENDIF.

LOOP AT so_vbeln.

IF so_vbeln-low <> space.

READ TABLE l_t_vbeln WITH KEY = so_vbeln-low.

IF sy-subrc <> 0.

SET CURSOR FIELD 'SO_vbeln-LOW'.

MESSAGE e001(vb) WITH so_vbeln-low.

ENDIF.

ENDIF.

IF so_vbeln-high <> space.

READ TABLE l_t_vbeln WITH KEY = so_vbeln-high.

IF sy-subrc <> 0.

SET CURSOR FIELD 'SO_vbeln-HIGH'.

MESSAGE e001(vb) WITH so_vbeln-high.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " validate_vbeln

Ex2 : Simplified logic:

AT SELECTION-SCREEN ON so_werks.

PERFORM validate_plant.

FORM validate_plant.

DATA: BEGIN OF l_t_werks OCCURS 0,

werks LIKE t001w-werks,

END OF l_t_werks.

IF NOT so_werks[] IS INITIAL.

SELECT werks INTO TABLE l_t_werks

FROM t001w

WHERE werks IN so_werks.

ENDIF.

LOOP AT so_werks.

IF so_werks-low <> space.

READ TABLE l_t_werks WITH KEY werks = so_werks-low.

IF sy-subrc <> 0.

MESSAGE e892(m7) WITH so_werks-low.

ENDIF.

ENDIF.

IF so_werks-high <> space.

READ TABLE l_t_werks WITH KEY werks = so_werks-high.

IF sy-subrc <> 0.

MESSAGE e892(m7) WITH so_werks-high.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM.

Edited by: Ramesh Hirial on Jan 10, 2008 2:27 PM

Read only

Former Member
0 Likes
1,417

Hi Rohan,

I will send a sample code for this check it once.It will helpful to u.Plz change the fileds according on the fileds pesent on the selection screen ok..

tables: vbak.

at selection-screen.

SELECT SINGLE kunnr

FROM vbak

INTO vbak-kunnr

WHERE kunnr IN s_kunnr.

IF sy-subrc NE 0.

message e001.

ENDIF.

ELECT SINGLE vbeln

FROM vbak

INTO vbak-kunnr

WHERE vbeln IN s_vbeln.

message e002.

ENDIF.

DONT FORGET TO GIVE VBAK TABLES IN THE BEGINING OK..

we have to chage filds according to ur reruirement ok.

Award points if helpful.

Kiran Kumar.G.A

Have a Nice Day..

Read only

0 Likes
1,417

thnx kiran

Read only

Former Member
0 Likes
1,417

Hi Rohan,

U an validate these in

At Selection screen or at selection screen on parameter event.

write the necessray code in these events.

Regards,

Sonika

Read only

Former Member
0 Likes
1,418

Hi Rohan,

u can write select statement ina form or just continuation to cde without using form.

FORMs are nothing but they are like functions in "C".

FORM validate_s_aufnr.

SELECT aufnr FROM afru /* validation of aufnr*/

INTO TABLE <table name>

WHERE aufnr IN s_aufnr.

IF sy-subrc <> 0. /* display error message*/

MESSAGE e000(message-class).

LEAVE LIST-PROCESSING.

ENDIF.

ENDFORM. "validate_s_aufnr

create ur own error message in SE91 .

LEAVE LIST-PROCESSING is nothing but skip the screen .

REWARD IF USEFUL

thanks and regards

suma sailaja

Read only

0 Likes
1,417

thnx suma.. it was of gud help

Read only

Former Member
0 Likes
1,417

Hi Rohan

For validation you need to check the data you hav eneterd is there in your database

Suppose you want to check for Aufnr

Then put all the data into internal table abd check the data which you have eneterd is there or

not if not then show the error message

Read only

0 Likes
1,417

thnx ashutosh