Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
COBOL data formatting using PIC clause

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
simimathew

New User


Joined: 26 Jan 2006
Posts: 23
Location: London

PostPosted: Wed May 10, 2006 6:24 pm    Post subject: COBOL data formatting using PIC clause
Reply with quote

Can somebody please tell me the difference between the following data declarations?

1. 03 ZB-COMMA-SI-LIMITS PIC -(3)9.99.
2. 03 ZB-COMMA-SI-LIMITS PIC Z(3)9.99.

What will happen if a decimal number, 0017.45, is moved to the field ZB-COMMA-SI-LIMITS in both cases? As per my understanding both will suppress the preceeding zeros (if the declaration had been 9(4).99, there would have been preceeding zeros) and replace them with spaces.

Please let me know the difference, if any.

Also is a declaration

03 ZB-COMMA-SI-LIMITS PIC Z,ZZZ,ZZZ,ZZZ,ZZ9.99.

valid????

Many Thanks,
Simi
Back to top
View user's profile Send private message

DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Wed May 10, 2006 10:20 pm    Post subject: Re: COBOL data formatting using PIC clause
Reply with quote

Quote:

1. 03 ZB-COMMA-SI-LIMITS PIC -(3)9.99.
2. 03 ZB-COMMA-SI-LIMITS PIC Z(3)9.99.

What will happen if a decimal number, 0017.45, is moved to the field ZB-COMMA-SI-LIMITS in both cases? As per my understanding both will suppress the preceeding zeros (if the declaration had been 9(4).99, there would have been preceeding zeros) and replace them with spaces.

Please let me know the difference, if any.


The output from both these are identical.



Quote:
03 ZB-COMMA-SI-LIMITS PIC Z,ZZZ,ZZZ,ZZZ,ZZ9.99.

valid????


Yes, this is valid.

Dave
Back to top
View user's profile Send private message
simimathew

New User


Joined: 26 Jan 2006
Posts: 23
Location: London

PostPosted: Thu May 11, 2006 2:43 pm    Post subject: Re: COBOL data formatting using PIC clause
Reply with quote

Thanks, Dave.

But I have one more clarification to make regarding the formatting.

If a field is declared as

03 DL6140-DAYS-OS PIC -(5)9.

What will be the output when u move a negative number -12345 to thsi field? Actually my question is, are we using this PIC clause to show the -ve sign as well. So in that case will PIC-(5)9 and PIC Z(5)9 be the same?

Please help me out.

Thanks in advance,
Simi
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu May 11, 2006 7:41 pm    Post subject: Re: COBOL data formatting using PIC clause
Reply with quote

Simi,

In this case you will get different results.

The PIC -(5)9 will result in "-12345"
and the PIC Z(5)9 will result in " 12345"

Both of these reserve 6 bytes, the -(5)9 is signed and will place a "-" as the leading byte if the value is negative. The Z(5)9 is unsigned and no sign, +/- will appear.

If you were to move a -123456 to both of these fields, the Z(5)9 will result in "123456" where the -(5)9 will truncate the Most Significant Byte and result in "-23456"

Dave
Back to top
View user's profile Send private message
simimathew

New User


Joined: 26 Jan 2006
Posts: 23
Location: London

PostPosted: Thu May 11, 2006 7:56 pm    Post subject: Re: COBOL data formatting using PIC clause
Reply with quote

Thanks Dave.
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 -> Mainframe Interview Questions 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. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Question related to Data dictionary f... rexx77 SYNCSORT 3 Thu Aug 31, 2017 7:23 am
No new posts Extract Data till prev hour balaji81_k DB2 16 Fri Aug 25, 2017 9:25 pm
No new posts FTP data transfer from PC to Mainfram... AJAYREDDY All Other Mainframe Topics 8 Wed Aug 23, 2017 9:59 pm
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us