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

Some funny COBOL 'PIC'tures


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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Dec 13, 2011 9:49 pm
Reply with quote

This topic from the PL/I/Assembler forum yesterday got me thinking.

The original PIC was not destined for Cobol. However, the piece without the T does compile in Cobol, giving a field length of three as Robert pointed out. dbz wondered why...

Code:

       01  W-WEIRD-000001 PIC (10)999.         
       01  W-WEIRD-000002 PIC (1)(2)(50)(2)999.
       01  W-WEIRD-000004 PIC (134217727)9.     
       01  W-WEIRD-000011 PIC (13)(4217)(727)9.
       01  W-WEIRD-000022 PIC 0(2)(4)(8)9.     
       01  W-WEIRD-000023 PIC 0(1)(1)(1)9.     
       01  W-WEIRD-000024 PIC 9(3)(1).         
       01  W-WEIRD-000025 PIC (2)S9.           
       01  W-WEIRD-000026 PIC (2)V9.           
       01  W-WEIRD-000028 PIC (3)V9(2).         
       01  W-WEIRD-000029 PIC (3)9(2)(1).       
       01  W-WEIRD-000031 PIC (3)-(2)(1).   
       01  W-WEIRD-000033 PIC (1)$9.99.
       01  W-WEIRD-000034 PIC (4)-$$9.99.


Would anyone like to guess which, if any, of the above will compile, with no diagnostic message at all.

If any do compile, how long are the fields according to the Compiler?

25 amd 33 and 34 are for things the manual (Language Reference) says. An S must be left-most, a currency left-most unless preceded by + or -. Arguably the manual is correct, as the "repetition factor" is not described as actually part of the PICture character string.

Is it a Bug? Or only an Undocumented IBM Extension?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Tue Dec 13, 2011 11:25 pm
Reply with quote

Mutually exclusive.

Code:

PIC 9(5)V9(4).

PIC (5)V9(4).


I think Bug now. If you intended the first and manged the second through fat-fingers you'd reasonably expect the compiler to give you a bit of a hint.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Dec 14, 2011 12:03 am
Reply with quote

Thanks Robert. I should have made three of the fields smaller, to be within ARITH(COMPAT) rather than ARITH(EXTEND).

If you get three compile errors, reduce by 13 the bits that made it go wrong, or use ARITH(EXTEND).

Subject to the ARITH, they all compile.
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 COBOL sorting, with input GDG base COBOL Programming 7
No new posts Need help with ADABAS query (COBOL-AD... All Other Mainframe Topics 0
No new posts Replacing FILLER with FILLER<SeqNu... DFSORT/ICETOOL 2
No new posts Compile Sp Cobol base COBOL Programming 1
No new posts SQLCODE=-311 in Cobol SP-DB2. COBOL Programming 2
Search our Forums:

Back to Top