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

verify the STRING in COBOL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 08, 2010 4:29 pm
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: 6966
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 4:48 pm
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: 6966
Location: porcelain throne

PostPosted: Tue Jun 08, 2010 5:15 pm
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
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
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 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 COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top