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
 

 

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: 8055
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: 6967
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: 6967
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
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm


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