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

Query on COBOL compiler option


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

New User


Joined: 21 Feb 2008
Posts: 18
Location: Mumbai

PostPosted: Wed Sep 02, 2009 2:14 pm
Reply with quote

Hi,

My program looks as below.

Code:


DATA DIVISION.

01  WS-NAME          PIC X(10) VALUE 'ROBERT TED'.

01  RPT-NAME         PIC X(05).

PROCEDURE DIVISION.

MOVE  WS-NAME TO RPT-NAME.



In the above case, the value of WS-NAME will get truncated when moved to RPT-NAME.

But compiler is not giving any warning for this case.

Do we have any compiler option from which I can get Warning messages when there are chances of truncating.

In real screnario, I have copybook changes. I need to find
in all the programs, if there is any truncation because of these copybook changes.

Can any tell me the compiler option for the same.

Thanks in advance.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


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

PostPosted: Wed Sep 02, 2009 3:00 pm
Reply with quote

The analysis
(such as looking at the two lines of code and actually realizing that one field is larger than the other)
is done ahead of compilation; it is done during copybook creation.

unfortunately there is no - i did not bother to look - compiler option.
Back to top
View user's profile Send private message
chiru_sh

New User


Joined: 21 Feb 2008
Posts: 18
Location: Mumbai

PostPosted: Wed Sep 02, 2009 3:20 pm
Reply with quote

dbzTHEdinosauer wrote:
The analysis
(such as looking at the two lines of code and actually realizing that one field is larger than the other)
is done ahead of compilation; it is done during copybook creation.

unfortunately there is no - i did not bother to look - compiler option.


I know of copybook creation. But I am not concerned of it.

Is there any option while compiling which from which we can get compiler warnings whenever there is mismatch in the size of the sending and receiving fields.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Sep 02, 2009 3:43 pm
Reply with quote

COBOL expects you, when writing the MOVE statement, to know the size of the sending and receiving variables. So as far as I know there is no way to get mismatch messages from the compiler since it believes you know what you are doing if you move a 10-character variable to a 5-character variable.
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: Wed Sep 02, 2009 3:47 pm
Reply with quote

Unfortunately, you won't get any message of truncation when the compiler is dealing with character moves. There aren't any compiler options for that either.

The only compiler option that I recall which will inform you of high-order truncation during compilation is TRUNC(OPT).

Click below for some previous discussions on COBOL "Signature Bytes" -

www.ibmmainframes.com/viewtopic.php?p=190386&highlight=#190386

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

New User


Joined: 21 Feb 2008
Posts: 18
Location: Mumbai

PostPosted: Wed Sep 02, 2009 4:09 pm
Reply with quote

Thanks all of you for reply.

For any changes in the size of a variable in copybook. I need to invidually go in all the programs and check if the receiving field length needs to be increased. This is the only solution left. Am I right??
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Sep 02, 2009 4:29 pm
Reply with quote

You've got it -- sometimes there's shortcuts, and sometimes there's not.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Wed Sep 02, 2009 6:42 pm
Reply with quote

Quote:
I need to invidually go in all the programs
If that is hectic, take your colleague along with you... icon_biggrin.gif
Back to top
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Sep 02, 2009 7:43 pm
Reply with quote

If I remember correctly, one of the very old compilers (maybe the one for OS/VS COBOL (1968 standards)) gave you a warning but that was a long, long time ago. As stated, it's up to the programmer to check for possible truncation.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Sep 03, 2009 12:32 am
Reply with quote

Hello,

Quote:
In real screnario, I have copybook changes. I need to find
in all the programs, if there is any truncation because of these copybook changes.
Proper testing of all of the code using the modified copybook(s) will identify this. . .
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Thu Sep 03, 2009 1:11 am
Reply with quote

Terry Heinze wrote:
If I remember correctly, one of the very old compilers (maybe the one for OS/VS COBOL (1968 standards)) gave you a warning but that was a long, long time ago. As stated, it's up to the programmer to check for possible truncation.

Sheesh, am I glad that I use Enterprise PL/I...
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts How I Found a Bug in a FORTRAN Compiler All Other Mainframe Topics 4
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top