Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

manipulating AlphaNumeric string

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: manipulating AlphaNumeric string
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    Post subject:
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    Post subject: manipulating AlphaNumeric string
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    Post subject: Re: manipulating AlphaNumeric string
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    Post subject:
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: 1226
Location: Israel

PostPosted: Sun Jun 25, 2006 4:41 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
This topic is locked: you cannot edit posts or make replies. Checking wether a string starts from ... sundaram.naveen CLIST & REXX 9 Thu Oct 06, 2016 11:56 am
No new posts Random Password (in string format) ge... ezhavendhan COBOL Programming 10 Mon Aug 29, 2016 3:18 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us