View previous topic :: View next topic
|
Author |
Message |
chiru_sh
New User
Joined: 21 Feb 2008 Posts: 18 Location: Mumbai
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
chiru_sh
New User
Joined: 21 Feb 2008 Posts: 18 Location: Mumbai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
chiru_sh
New User
Joined: 21 Feb 2008 Posts: 18 Location: Mumbai
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
You've got it -- sometimes there's shortcuts, and sometimes there's not. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Quote: |
I need to invidually go in all the programs |
If that is hectic, take your colleague along with you... |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
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 |
|
|
|