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
 

 

Some funny COBOL 'PIC'tures

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7253

PostPosted: Tue Dec 13, 2011 9:49 pm    Post subject: Some funny COBOL 'PIC'tures
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7253

PostPosted: Tue Dec 13, 2011 11:25 pm    Post subject: Reply to: Some funny PICtures
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7253

PostPosted: Wed Dec 14, 2011 12:03 am    Post subject: Reply to: Some funny PICtures
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    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
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts OO COBOL compile error Virendra Shambharkar COBOL Programming 3 Tue Jan 10, 2017 6:05 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm


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