Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Query on COBOL compiler option

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Query on COBOL compiler option
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    Post subject:
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    Post subject:
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: 7997
Location: Bellevue, IA

PostPosted: Wed Sep 02, 2009 3:43 pm    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Sep 02, 2009 3:47 pm    Post subject: Reply to: Query on COBOL compiler option
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" -

http://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    Post subject:
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: 7997
Location: Bellevue, IA

PostPosted: Wed Sep 02, 2009 4:29 pm    Post subject:
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

Senior Member


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

PostPosted: Wed Sep 02, 2009 6:42 pm    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Thu Sep 03, 2009 12:32 am    Post subject:
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: 1002
Location: Oostende, Belgium

PostPosted: Thu Sep 03, 2009 1:11 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Who can recomend or to know a PL1 com... Miguel Fernandez DB2 0 Tue Feb 14, 2017 1:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us