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

What are validations?Can you give explanation with sample code?

Former Member
0 Likes
948

Hi,

What are validationsand validation types?Can you give explanation with sample code?

Give more sample code of validation .

Regards,

Chow.

Hi,

What are validationsand validation types?Can you give explanation with sample code?

Give more sample code of validation .

Regards,

Chow.

6 REPLIES 6
Read only

Former Member
0 Likes
896

At selection-screen - normal validation

at selection-screen output.dynamic validation

see ABAPDOCU Example transaction

Read only

Former Member
0 Likes
896

hi

Validations are nothing but checking for the values that u have entered i can differnet validations like when we enter values the values shoud be under this range if it voilets than it should trigger some messages so that basing on that mesage the user can decide whether he enter correcot values or not.

sample code:

if cno-low < 100 and cno-high > 1000

message e000.

else.

message s001.

endif.

this is simple validation for select-options.

reward points if helpful

Regards,

srinivas.

Read only

Former Member
0 Likes
896

Validations can basically on the screen elements .

consider the selection screen which has company code on the screen . The validation is checkw whether the company code entered exists in the master table (t001) .

code :

parameter : p_bukrs type bukrs

at selection-screen .

peform validate_Cocode.

form validate_cocode.

select * from t001 into ls_t001 where bukrs = p_bukrs.

if sy-subrc ne 0

company code doesnt exists,

endif.

endform.

Read only

Former Member
0 Likes
896

Hi

For example you have a requirement to divide two numbers and display the result,

if the end user wants to divide the first number by 0, i.e., num2 = 0, in this case,

if you execute the program it goes for a dump.... so restrict the user by giving an error message... or according to the requirement...

It allows solid data entry regarding special rules. According to previous rules, the system can evaluate an entry and a message can appear on the user's terminal if a check statement is not met. A validation step contains prerequisite statement and check statement. Both of them are defined using Boolean Logic or calling an ABAP/4 form.

chk this:

http://www.is-edu.hcmuns.edu.vn/WebLib/Books/Database/0-672-31217-4/ch21/ch21.htm#DataValidationUsin...

Reward All the helpfull answers......

Read only

aris_hidalgo
Contributor
0 Likes
896

Hi,

Please take a look at my example below.


REPORT  z_aris_test_15
        MESSAGE-ID zsd.

TABLES: t001.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_bukrs TYPE t001-bukrs.
SELECTION-SCREEN END OF BLOCK b1.

AT SELECTION-SCREEN ON p_bukrs.
  SELECT SINGLE bukrs butxt
    FROM t001
    INTO (t001-bukrs, t001-butxt)
   WHERE bukrs = p_bukrs.

  IF sy-subrc = 0.
    MESSAGE s000 WITH 'You have selected company' t001-butxt.
  ELSE.
    MESSAGE e000 WITH p_bukrs 'is not defined as a company code'.
  ENDIF.

What it does is to validate the company code entered by the user.

Hope it helps...

P.S. Please award points if it helps...

Read only

Former Member
0 Likes
896

Hi,

Also Look at the below links