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

problem with checkig alphanumeric values


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

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 2:47 pm
Reply with quote

Hi ...all

Iam facing some compiling problem while checking a varible for a alphanumeric value in it

IF ZW-KOOP-SCHL(4:1)= '/'
AND ZW-ALPHA1 IS ALPHANUMERIC
AND ZW-ALPHA2 IS ALPHANUMERIC
CONTINUE
ELSE
PERFORM U3000-WRITE-CAPLIST2
PERFORM U4000-WRITE-LIST
GO TO F05Z
END-IF


the above thing is my code...

iam getting compile time severe kind error

this is my error message
"ALPHANUMERIC" was found in a conditional expression. The "IF" statement was discarded.
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 Apr 20, 2010 2:56 pm
Reply with quote

You can test a variable for ALPHABETIC, or you can test the variable for NUMERIC. Since every variable is ALPHANUMERIC, there is no condition test in COBOL for this.

Perhaps if you explain just what it is you are wanting to do, we can provide assistance?
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Apr 20, 2010 3:05 pm
Reply with quote

Hi lmuvalla,

Please have a look into the manuals for Coding Conditional Expressions.

Hope this is what you were looking for ....
Back to top
View user's profile Send private message
lmuvalla

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 3:25 pm
Reply with quote

thanx for replies..

iam jus searching for a alphanumeric value in that iam expecting date there in the for mat of mmm/yyyyyyy...

alphanumeric check is working outside the IF condition..

and it is not working in IF condition

as of now i jus replaced my statement iam now checking that variable with numeric and alphabetic...values...
Back to top
View user's profile Send private message
lmuvalla

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 3:25 pm
Reply with quote

Thanx...Binop...n robert
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Apr 20, 2010 3:48 pm
Reply with quote

Hi lmuvalla,

As Robert has mentioned all variables are alphanumeric. Am a bit curious reading your replies...
Quote:
iam jus searching for a alphanumeric value in that iam expecting date there in the format of mmm/yyyyyyy...
Am a little concerned from this statement because it gives me a feeling you have misinterpreted the meaning of alphanumeric. And anyway if you want to verify the format, why do you want a "alphanumeric" check ? Could you please post how you are doing now ?
Back to top
View user's profile Send private message
lmuvalla

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 4:14 pm
Reply with quote

Hi binop

Na iam not misinterpreted...about alphanumeric values...

actually while defining we are using pix X alphanumeric for defining...

now i jus searching for a thing whether any check is there for alphanumeric...


now iam clear about using alphanumeric in conditional statements
Back to top
View user's profile Send private message
lmuvalla

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 4:18 pm
Reply with quote

yes its look like i misunderstood alphanumeric...

i have one more qn is all special charachters comes under alphanumeric category...
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Tue Apr 20, 2010 4:32 pm
Reply with quote

Yes.

You can refer the link, if you need more information regarding the alphanumeric literals.
Back to top
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Apr 20, 2010 5:02 pm
Reply with quote

Have you got this simple rule: in alphanumeric, "alpha" stands for alphabet (a-z, A-Z) and "numeric" stands for numeric (0-9)
So it doesn't fit for checking dates. That should answer your 2nd question too.

Additionally, the word ALPHANUMERIC cannot be used in conditions. Only in the INITIALIZE statement.

If you want to check a string against a set of characters of your choice, use the SPECIAL-NAMES paragraph.
Also search for SPECIAL-NAMES in the forum. There are lots of answers.
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 Apr 20, 2010 5:23 pm
Reply with quote

Alphanumeric means the character is any one of the 256 valid characters in the EBCDIC collating sequence -- which includes numbers, letters (both lower and upper case), punctuation symbols, and non-printing characters.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Tue Apr 20, 2010 5:27 pm
Reply with quote

Possibly, another method. Your COBOL version/release must be COBOL II or greater.

Code:

03  WS-ZW-KOOP-SCHL PIC  X(???).
03  WS-SUB PIC  9(08) COMP.
03  WS-SUB-X REDEFINES WS-SUB PIC  X(04).
03  WS-XLATE-FROM-TBL PIC  X(256).
03  WS-XLATE-TO-TBL PIC  X(256).

MOVE 1 TO TALLY.
MOVE ZERO TO WS-SUB.
MOVE ZW-KOOP-SCHL TO WS-ZW-KOOP-SCHL.
MOVE SPACES TO WS-XLATE-TO-TBL.

* BUILD THE 'FROM' TRANSLATE-TBL. WHEN COMPLETE, BYTES 001-256 WILL CONTAIN X'00' THROUGH X'FF'.

PERFORM UNTIL TALLY > LENGTH OF WS-XLATE-FROM-TBL
    MOVE WS-SUB-X (4:) TO WS-XLATE-FROM-TBL (TALLY:1)
    ADD 1 TO TALLY
    ADD 1 TO WS-SUB
END-PERFORM.

* NOW, BECAUSE THE 'TO-TBL' HAS BEEN CLEARED TO SPACES, MOVE ONLY THE DATA-BYTES FROM THE 'FROM'  TRANSLATE-TBL TO THE 'TO' TRANSLATE-TBL THAT YOU CONSIDER VALID. THEN CONVERT ALL BYTES IN WS-ZW-KOOP-SCHL USING AN 'INSPECT'. NOTE THAT WS-ZW-KOOP-SCHL AND ZW-KOOP-SCHL MUST BE THE SAME LENGTH AND IS A TEMPORARY WORK-AREA.

INSPECT WS-ZW-KOOP-SCHL CONVERTING WS-XLATE-FROM-TBL TO WS-XLATE-TO-TBL.

* SET TALLY TO ZERO AND USE IT TO DETERMINE WS-ZW-KOOP-SCHL IS VALID, BY TESTING TALLY AFTER THIS INSPECT FOR A VALUE GREATER THAN ZERO.

MOVE ZERO TO TALLY.

INSPECT WS-ZW-KOOP-SCHL TALLYING TALLY FOR ALL SPACE.

When you're done with the second INSPECT and TALLY exceeds ZERO then there are bytes in WS-ZW-KOOP-SCHL that you've determined (by virtue of the 'XLATE-TO-TBL' contents) to be invalid.

Bill
Back to top
View user's profile Send private message
lmuvalla

New User


Joined: 27 Nov 2009
Posts: 7
Location: chennai

PostPosted: Tue Apr 20, 2010 6:16 pm
Reply with quote

thank u all....
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Null values are considered in Total c... DFSORT/ICETOOL 6
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top