Subscribe

RSS Feed (xml)

Powered By

Skin Design:
Free Blogger Skins

Powered by Blogger

Friday, April 18, 2008

Check Length and Alpha Numeric Variable SAP ABAP INTERVIEW Questions

*

* Program to Check Length and Alpha Numeric Variable
*
* Is there any simple way or FM to check the string contains other

* than alphanumeric(A-Z and 0-9) and give an error message.
*
* How to check the length size of a variable?

*
* Written by : SAP Basis, ABAP Programming and Other IMG Stuff
* http://www.voiceofabap.blogspot.com

*

REPORT ZCHECK_ALPHA_NUMERIC.


* Declare the variable


* For Length
data: serial_length type i.


* For Alpha numeric
data: str type string.
data: valid_characters type string.


* Fill in those valid characters you need to check
concatenate '0123456789' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
'abcdefghijklmnopqrstuvwxyz' into valid_characters.


* User Input
parameters testchar(10) default '12345abc'.


* Get User Input
str = testchar.


* The Checks
if str co valid_characters.
write: / str, 'Characters are OK'.
else.
write: / str, 'Characters are NOT OK'.
endif.


* Check if length is equal to 10 characters
serial_length = strlen( str ).
if serial_length <> 10.
write: / str, 'Not 10 Digit'.
endif.


*-- End Program

No comments:

Post a Comment

Content

Recent Topics