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

Former Member
0 Likes
800

hi sir

how to do the validation in select options screen.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
744

hi,

The AT SELECTION-SCREEN event is triggered in the PAI of the selection screen once the ABAP runtime environment has passed all of the input data from the selection screen to the ABAP program. If an error message occurs in this processing block, the selection screen is redisplayed with all of its fields ready for input. This allows you to check input values for consistency.

The program below is connected to the logical database F1S:

REPORT EVENT_DEMO.

NODES SPFLI.

AT SELECTION-SCREEN.
  IF CARRID-LOW IS INITIAL 
    OR CITY_FR IS INITIAL 
    OR CITY_TO IS INITIAL. 
    MESSAGE E000(HB). 
  ENDIF.

If the user does not enter values in all of the fields on the selection screen, an error message appears in the status line. This makes all of the input fields mandatory, even though they are not defined as such in the logical database.

<b>follow this link for more information.</b>

http://help.sap.com/saphelp_nw2004s/helpdata/en/79/34a234d9b511d1950e0000e8353423/frameset.htm

regards,

Ashok Reddy

5 REPLIES 5
Read only

Former Member
0 Likes
744
Validation for Material Number

AT SELECTION-SCREEN ON s_matnr.
IF NOT s_matnr[] IS INITIAL.
SELECT SINGLE matnr
FROM mara
INTO v_matnr
WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
MESSAGE e000 WITH text-032. "Invalid Material Number
ENDIF.
ENDIF.
Read only

Former Member
0 Likes
744

Hi

selections screen declaration

select-options:s_bukrs for t001-bukrs ,

s_vkorg for tvko-vkorg ,

s_vtweg for tvtw-vtweg ,

s_spart for tspa-spart ,

s_werks for t001w-werks ,

s_kunag for kna1-kunnr,

s_vbeln for vbuk-vbeln.

*******At Selection Screen********************************************

at selection-screen.

  • Checking for the input values of selection screen.

perform screen_check.

&----


*& Form screen_check

&----


  • Ckecking for Selection Screen fields Validation

----


form screen_check.

  • Validation of Sales Organization

clear tvko.

if not s_vkorg-low is initial.

select vkorg from tvko up to 1 rows

into tvko-vkorg

where vkorg in s_vkorg.

endselect.

if sy-subrc ne 0.

message e009. " Invalid Sales Organization

endif.

endif.

  • Validation of Distribution Channel

clear tvtw.

if not s_vtweg-low is initial.

select vtweg from tvtw up to 1 rows

into tvtw-vtweg

where vtweg in s_vtweg.

endselect.

if sy-subrc ne 0.

message e010. " Invalid Distribution Channel

endif.

endif.

  • Validation of Division

clear tspa.

if not s_spart-low is initial.

select spart from tspa up to 1 rows

into tspa-spart

where spart in s_spart.

endselect.

if sy-subrc ne 0.

message e011. " Invalid Division

endif.

endif.

  • Validation for company code

clear t001.

if not s_bukrs-low is initial.

select single bukrs from t001

into t001-bukrs

where bukrs in s_bukrs.

if sy-subrc <> 0.

message e007. " Enter valid Company Code

endif.

endif.

  • Validation of billing Document Type

clear tvfk.

if not s_fkart is initial.

select fkart from tvfk up to 1 rows

into tvfk-fkart

where fkart in s_fkart.

endselect.

if sy-subrc ne 0.

message e012. " Invalid Billing Document Type

endif.

endif.

  • Validation of Billing Document Number

clear vbuk.

if not s_vbeln is initial.

select vbeln from vbuk up to 1 rows

into vbuk-vbeln

where vbeln in s_vbeln and

vbtyp = 'M'.

endselect.

if sy-subrc ne 0.

message e013. " Invalid Billing Doc Number

endif.

endif.

  • Validation of Customer

clear kna1.

if not s_kunag is initial.

select kunnr from kna1 up to 1 rows

into kna1-kunnr

where kunnr in s_kunag.

endselect.

if sy-subrc ne 0.

message e014. " Invalid Customer Number

endif.

endif.

  • Validation of Plant

clear t001w.

if not s_werks is initial.

select werks from t001w up to 1 rows

into t001w-werks

where werks in s_werks.

endselect.

if sy-subrc ne 0.

message e004. " Invalid Plant Number

endif.

endif.

endform. "screen_check

<b>Reward points for useful Answers</b>

Regards

Anji

Read only

S0025444845
Active Participant
0 Likes
744

Hi,

take help of the below code,

FORM f_validations .

TYPES:

BEGIN OF typ_matnr,

matnr TYPE matnr,

END OF typ_matnr,

BEGIN OF typ_lifnr,

lifnr TYPE elifn,

END OF typ_lifnr,

BEGIN OF typ_lgort,

lgort TYPE lgort_d,

END OF typ_lgort,

BEGIN OF typ_werks,

werks TYPE werks_d,

END OF typ_werks,

BEGIN OF typ_mblnr,

mblnr TYPE mblnr,

END OF typ_mblnr.

*//Local Work areas

DATA:

l_wa_matnr TYPE typ_matnr,

l_wa_lifnr TYPE typ_lifnr,

l_wa_lgort TYPE typ_lgort,

l_wa_werks TYPE typ_werks,

l_wa_mblnr TYPE typ_mblnr.

*//To clear local workareas

CLEAR:l_wa_matnr,l_wa_lifnr,

l_wa_lgort,l_wa_werks ,

l_wa_mblnr.

*//To perform validation on material document

SELECT SINGLE mblnr

FROM mseg

INTO l_wa_mblnr

WHERE mblnr IN s_mblnr. "#EC *

IF sy-subrc NE 0.

MESSAGE e063(m7) WITH s_mblnr-low.

ENDIF.

*//To perform validation on material Number

SELECT SINGLE matnr

FROM mara

INTO l_wa_matnr

WHERE matnr IN s_matnr. "#EC *

IF sy-subrc NE 0.

MESSAGE e305(m3) WITH s_matnr-low.

ENDIF.

*//To perform validation on plant

SELECT SINGLE werks

FROM t001w

INTO l_wa_werks

WHERE werks IN s_werks. "#EC *

IF sy-subrc NE 0.

MESSAGE e102(m3) WITH s_werks-low.

ENDIF.

*//To perform validation on vendor

SELECT SINGLE lifnr

FROM lfa1

INTO l_wa_lifnr

WHERE lifnr IN s_lifnr. "#EC *

IF sy-subrc NE 0.

MESSAGE e163(f2) WITH s_lifnr-low.

ENDIF.

*//To perform validation on storage location

SELECT SINGLE lgort

FROM t001l

INTO l_wa_lgort

WHERE lgort IN s_lgort. "#EC *

IF sy-subrc NE 0.

MESSAGE e348(m7) WITH s_lgort-low.

ENDIF.

ENDFORM. " f_validations

regards,

sudha

Read only

Former Member
0 Likes
744

Hi Raj,

In the select option structure, obtain the boundary values into an internal table.

Now loop at this internal table validating each entry in one loop execution.

<b>Reward points, if helpful.</b>

Regards,

Atin

Read only

Former Member
0 Likes
745

hi,

The AT SELECTION-SCREEN event is triggered in the PAI of the selection screen once the ABAP runtime environment has passed all of the input data from the selection screen to the ABAP program. If an error message occurs in this processing block, the selection screen is redisplayed with all of its fields ready for input. This allows you to check input values for consistency.

The program below is connected to the logical database F1S:

REPORT EVENT_DEMO.

NODES SPFLI.

AT SELECTION-SCREEN.
  IF CARRID-LOW IS INITIAL 
    OR CITY_FR IS INITIAL 
    OR CITY_TO IS INITIAL. 
    MESSAGE E000(HB). 
  ENDIF.

If the user does not enter values in all of the fields on the selection screen, an error message appears in the status line. This makes all of the input fields mandatory, even though they are not defined as such in the logical database.

<b>follow this link for more information.</b>

http://help.sap.com/saphelp_nw2004s/helpdata/en/79/34a234d9b511d1950e0000e8353423/frameset.htm

regards,

Ashok Reddy