Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
verify the STRING in COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
kumar_jalluri

New User


Joined: 02 Jun 2005
Posts: 24
Location: PUNE

PostPosted: Tue Jun 08, 2010 4:12 pm    Post subject: verify the STRING in COBOL
Reply with quote

Hi,

I need to verify a string for characters 0 1 2 3 4 5 6 7 8 9 A B C D E F.

If the string is having other than this characters, I have some processing. other wise I have different process.

Could you please let me know how to do it in COBOL


Thanks
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8201
Location: East Dubuque, Illinois, USA

PostPosted: Tue Jun 08, 2010 4:29 pm    Post subject:
Reply with quote

Your first problem is that COBOL does not have strings. COBOL has variables that can be numeric, alphanumeric, national, DBCS ... but never string. Terminology is critical in IT where similar sounding terms may mean very different things -- so you need to use appropriate terminology first.

Assuming you meant an alphanumeric variable, you have two choices:
1) redefine as an array of one-byte variables and check each byte individually.
2) use reference modification to check each individual byte of the variable.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 4:48 pm    Post subject:
Reply with quote

you could also, within the SPECIAL-NAMES paragraph
use the CLASS clause
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6970
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 5:15 pm    Post subject:
Reply with quote

miss-reading of the manuals is the root cause of this.

string
array
are two examples.

always in the manuals:
string data items refer to java or c items
array is a java-array-object.

yet when the word (string-data-item and java-array-object) is used without
the full qualifier,
people tend to think that it is ok to use the abbreviation to refer to COBOL objects:

noncobol - cobol
string - alphanumeric data item
array - cobol internal table

as with so many other terms (jcl for example),
people tend to use what is convenient for them,
until they try searching on a term that does not exist.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Tue Jun 08, 2010 7:56 pm    Post subject:
Reply with quote

just an idea :

Code:
move invar to testvar
INSPECT Testvar CONVERTING " 0123456789ABCDEF"               
                     TO    "X                "
if testvar <> spaces
  display "error"
end-if
Back to top
View user's profile Send private message
kumar_jalluri

New User


Joined: 02 Jun 2005
Posts: 24
Location: PUNE

PostPosted: Wed Jun 09, 2010 2:31 pm    Post subject:
Reply with quote

Thanks... It is working for above logic.
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
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am
No new posts line 52: Name or string > 250 char... Ashishpanpaliya CLIST & REXX 5 Sat Oct 14, 2017 2:29 am
No new posts IEW2456E error when link-editing a C ... Senthilraj JCL & VSAM 0 Fri Oct 13, 2017 3:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us