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

FIELD(1:4): compilation is indexing the field?


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

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Mon Jun 22, 2009 5:24 pm
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Mon Jun 22, 2009 5:35 pm
Reply with quote

Please cut & past the definition of wk-field. What version of COBOL are you using?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 22, 2009 5:39 pm
Reply with quote

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
View user's profile Send private message
Ensign

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Mon Jun 22, 2009 5:48 pm
Reply with quote

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.... icon_confused.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Mon Jun 22, 2009 5:57 pm
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 22, 2009 6:16 pm
Reply with quote

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
View user's profile Send private message
Ensign

New User


Joined: 19 May 2009
Posts: 9
Location: Spain

PostPosted: Mon Jun 22, 2009 10:26 pm
Reply with quote

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
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Tue Jun 23, 2009 9:19 am
Reply with quote

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
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 Help required to reset decimal points... DFSORT/ICETOOL 10
No new posts Sorting Date Field DFSORT/ICETOOL 4
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Join 2 files according to one key field. JCL & VSAM 3
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
Search our Forums:

Back to Top