View previous topic :: View next topic
|
Author |
Message |
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
Back to top |
|
|
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
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 |
|
|
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
Thanx...Binop...n robert |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
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 |
|
|
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
yes its look like i misunderstood alphanumeric...
i have one more qn is all special charachters comes under alphanumeric category... |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
lmuvalla
New User
Joined: 27 Nov 2009 Posts: 7 Location: chennai
|
|
|
|
thank u all.... |
|
Back to top |
|
|
|