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
 

 

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
No new posts RULES(NOEVENPACK) in cobol jackzhang75 COBOL Programming 5 Wed Mar 29, 2017 12:47 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 5 Mon Mar 27, 2017 9:58 pm
No new posts Export flat file data into excel sheet murali.andaluri DFSORT/ICETOOL 2 Mon Mar 20, 2017 5:39 pm
No new posts Formatting VB File Learncoholic DFSORT/ICETOOL 3 Mon Mar 20, 2017 12:29 pm
No new posts Append data from two files into a sin... Praveen04 DFSORT/ICETOOL 5 Thu Mar 16, 2017 7:29 pm


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