View previous topic :: View next topic
|
Author |
Message |
Ensign
New User
Joined: 19 May 2009 Posts: 9 Location: Spain
|
|
|
|
I need to validate the first 4 positions in a field.
WK-FIELD is defined as 9(8) in a copybook
IF WK-FIELD(1:4) = 8223
MOVE 1 TO WK-FIELD-2
END-IF
But surprisingly compilation gives an error, as it takes the WK-FIELD as indexed...
"WK-FIELD" WAS SUBSCRIPTED OR INDEXED, BUT WAS NOT DEFINED WITH AN "OCC... UBORDINATE TO AN ITEM WITH AN "OCCURS" CLAUSE. THE SUBSCRIPTS OR INDICES WER...
What should I do?
Thank you very much. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Please cut & past the definition of wk-field. What version of COBOL are you using? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
If the field is subscripted or indexed, you must specify the subscript or index as well as the reference modification location in your variable reference. Use the manuals link at the top of the page to find the details. |
|
Back to top |
|
|
Ensign
New User
Joined: 19 May 2009 Posts: 9 Location: Spain
|
|
|
|
Craq Giegerich wrote: |
Please cut & past the definition of wk-field. What version of COBOL are you using? |
The definition of the field:
10 WK-SALES.
15 WK-FIELD PIC 9(08).
I'm not sure about the Cobol version, but I think it's VS Cobol II
Robert Sample wrote: |
If the field is subscripted or indexed, you must specify the subscript or index as well as the reference modification location in your variable reference. Use the manuals link at the top of the page to find the details. |
but the field is not indexed at all.... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
Post everything from the 01 level down to WK-FIELD. And contrary to your statement, COBOL thinks the field is indexed or subscripted (hence the error message) -- so posting everything from the 01 level down will let us see why COBOL thinks this. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Instead of
IF WK-FIELD(1:4) = 8223
try
IF WK-FIELD(1:4) = '8223'
I never trust numeric display fields. they are too much like alphanumeric. |
|
Back to top |
|
|
Ensign
New User
Joined: 19 May 2009 Posts: 9 Location: Spain
|
|
|
|
Solved. Thank you for all your responses.
The fact was the program was coded in 1992 and has some compilation options coded in the header that didn't allow (1:4) and treated them as index:
CBL CMPR2
*P-COMPI CICS=NO DLI=NO
Just removing these two lines (or mark them), and the problem got solved:
**CBL CMPR2
*P-COMPI CICS=NO DLI=NO
I guess they are old compilation parameters. |
|
Back to top |
|
|
Aaru
Senior Member
Joined: 03 Jul 2007 Posts: 1287 Location: Chennai, India
|
|
|
|
Ensign,
Quote: |
CBL CMPR2 guess they are old compilation parameters. |
Yes, This is a compiler option and CBL is used to override the default settings of the compiler option .
So it all depends on what the site has coded for this compiler option. |
|
Back to top |
|
|
|