‎2008 Jan 10 5:16 AM
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
‎2008 Jan 10 5:32 AM
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
‎2008 Jan 10 5:19 AM
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
‎2008 Jan 10 5:22 AM
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?
‎2008 Jan 10 5:22 AM
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
‎2008 Jan 10 5:39 AM
‎2008 Jan 10 5:23 AM
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
‎2008 Jan 10 5:25 AM
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
‎2008 Jan 10 5:26 AM
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..
‎2008 Jan 10 5:41 AM
‎2008 Jan 10 5:26 AM
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
‎2008 Jan 10 5:32 AM
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
‎2008 Jan 10 5:39 AM
‎2008 Jan 10 5:35 AM
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
‎2008 Jan 10 5:41 AM