IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

manipulating AlphaNumeric string


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Wed Jun 14, 2006 11:51 am
Reply with quote

i have a variable which has some string (ex:- 12345WE)

can anybody tell me a way How to check whether the last 2 characters of this string is ALPHANUMERIC or not.. (ex:- 12345WE)
Back to top
View user's profile Send private message
sunnyk

New User


Joined: 20 Oct 2004
Posts: 59

PostPosted: Wed Jun 14, 2006 1:16 pm
Reply with quote

By using Reference modification, move the last two chars to a new working storage variable and then check whether that new variable is > spaces. If yes, then last two chars of the string is ALPHANUMERIC else not.

Regds
Sunny
Back to top
View user's profile Send private message
venkatm99

New User


Joined: 01 Jun 2006
Posts: 23
Location: Sinagpore

PostPosted: Wed Jun 14, 2006 1:56 pm
Reply with quote

hi

suppose alpha numeric varible length is 10 bytes.

01 ws-alpha pic x(10).

01 ws-alpha-r redefines ws-alpha.
05 ws-alpha-1 pic x(08).
o5 ws-alpha-2 pic 9(02).

If ws-alpha-2 is nureric
perform x
else
perform y
end-if

Hope it will clear ur doubt


cheers
venkat
Back to top
View user's profile Send private message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Wed Jun 14, 2006 3:10 pm
Reply with quote

Hey thx guys for ur replies.... was useful
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jun 25, 2006 1:40 am
Reply with quote

It's amazing how these "simple" ques can get complicated. Prodigy asked if you can test that the last 2 chars of a field are alphanuneric, but his example shows the last 2 chars as alphabetic.

Does he mean A or AN. My guess is that he meant A, else he would have used something like W6 as his last 2 chars. Also does he consider a space an alpha; the alpha class test does.

Anyway, I'd try:
Code:

IF HIS-FLD(n:2)    IS NOT ALPHABETIC
    OR 
   HIS-FLD(n:1)     = SPACE
    OR 
   HIS-FLD(n + 1:1) = SPACE
   DISPLAY 'FIELD IS NOT ALPHA AND/OR CONTAINS SPACES'
ELSE
   DISPLAY 'FIELD LOOKS OK TO ME'
END-IF
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Sun Jun 25, 2006 4:41 pm
Reply with quote

It gets even more complicated if the last 2 chars are not always in the same place.
The given example was '- 12345WE'. Now what happens if the value is '- 123WE' ?
Can this happen?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Search string in job at regular Spool... CLIST & REXX 0
Search our Forums:

Back to Top