Simpler Navigation coming for Servers and Operating Systems
Coming soon: a much simpler Servers and Operating Systems section of the Community. We will combine many of the older boards, and you won't have to click through so many levels to get at the information you need. If you are looking for an older board and do not find it, check the consolidated boards, as the posts are still there.
Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

Cobol variable truncated to 30 characters

Wijnand van Riel
Occasional Visitor

Cobol variable truncated to 30 characters

Hi,
We are using a new cobol compiler, but now the names of variables are truncated to 30 characters. So the cobol compiler is giving the following message:
F-VOR-VOORWAARDE-CRITERIUM-COD IN
........^
%COBOL-F-UNDEFSYM, Undefined name
because it has to be F-VOR-VOORWAARDE-CRITERIUM-CODE
Where can we change the lengthvalue of variables?

Wijnand van Riel
10 REPLIES
Peter Godron
Honored Contributor

Re: Cobol variable truncated to 30 characters

Hi,
can you please provide:
Operating System Version
Compiler name and version
Thanks
Peter Godron
Honored Contributor

Re: Cobol variable truncated to 30 characters

Winjnand,
for example:
http://docs.hp.com/cgi-bin/doc3k/B3150090013.11820/14

states for HP COBOL II/XL on MPE:
"Each word is limited to a maximum length of 30 characters. Certain types
of words, such as user-defined words, may be restricted to a shorter
length."

More documents halfway down the page at:
http://docs.hp.com/en/dev.html

Regards
Wijnand van Riel
Occasional Visitor

Re: Cobol variable truncated to 30 characters

Sorry for not giving enough information.
Our operating system is OpenVMS 7.3
We used Pro*COBOL: Release 1.8.4 with
COBOL V2.5-980. With those compilers we didn't get truncated variables.

Now we are testing Pro*COBOL 9.2.0.5 with COBOL V2.7-1209. Is the length of words changed with the newer version, and what can we do as workaround without changing our sourcecode?

greetings
Wijnand
Peter Godron
Honored Contributor

Re: Cobol variable truncated to 30 characters

Ok,
can we establish whether the variable is truncated by the Pro*Cobol pre-compiler?
Have a look for the file after the SQL has been translated. In Pro*C the file extension would change from '.pc' to '.c'.

If the varibale name is complete there we can eliminate the pre-compiler.

Please let us know what you find.

Regards
harry d brown jr
Honored Contributor

Re: Cobol variable truncated to 30 characters

From the pro cobol manual:

Declaring and Referencing Host Variables
Every program variable used in a SQL statement must be declared according to the
rules of the COBOL language. Normal rules of scope apply. COBOL variable names
can be any length, but only the first 30 characters are significant for Pro*COBOL..
Any valid COBOL identifier can be used as host variables, including those beginning with
digits.
The external datatype of a host variable and the internal datatype of its source or
target database column need not be the same, but they must be compatible.
Table 4â 6, â Conversions Between Internal and External Datatypesâ shows the compatible
datatypes between which Oracle8 converts automatically when necessary.


live free or die
harry d
Live Free or Die
Wijnand van Riel
Occasional Visitor

Re: Cobol variable truncated to 30 characters

This is what we find:
In the .PCO we have following:
05 F-VOR-VOORWAARDE-CRITERIUM-CODE
and
MOVE F-VOR-VOORWAARDE-CRITERIUM-CODE(VOR-INDEX)

In the .COB the last statement is generated by the Pro*COBOL compiler (notice the missing -E at COD)
05 F-VOR-VOORWAARDE-CRITERIUM-CODE
MOVE F-VOR-VOORWAARDE-CRITERIUM-CODE(VOR-INDEX)
CALL "SQLADR" USING
F-VOR-VOORWAARDE-CRITERIUM-COD IN

regards,

Wijnand
Peter Godron
Honored Contributor

Re: Cobol variable truncated to 30 characters

So the pre-compiler seems to be at fault here.
If Harry was right I would expect the pre-compiler to leave the statement as is and only use the first 30 chars. This may result in a duplicate varibale declaration if two variables were used with the first 30 characters mathing.

What seems to happen here is that SOME of the variables are truncated,while elsewhere the same variable is left as is.

Any Pro*Cobol gurus present to confirm?
harry d brown jr
Honored Contributor

Re: Cobol variable truncated to 30 characters


fyi for those that didn't know that pro*cobol is an oracle precompiler.

Do you have any other variables that start with F-VOR-VOORWAARDE-CRITERIUM-COD ? (note I didn't say F-VOR-VOORWAARDE-CRITERIUM-CODE)

If you do, then you need to make some variable name changes.

If you don't, then I would report this as a BUG to Oracle.

btw, I remember the the 30 character limit from my youthful programming days in the late 70's early 80's.

live free or die
harry d brown jr

Live Free or Die
Peter Godron
Honored Contributor

Re: Cobol variable truncated to 30 characters

Wijnand van Riel
Occasional Visitor

Re: Cobol variable truncated to 30 characters

I've reported the BUG at Oracle. Thanks for your help. We will change shorten the names of our variables