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
 

 

Padding to packed decimal field using OUTREC in sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
rajendraa

New User


Joined: 22 Dec 2006
Posts: 7
Location: Bangalore

PostPosted: Tue May 10, 2011 11:02 pm    Post subject: Padding to packed decimal field using OUTREC in sort
Reply with quote

Hi,

I have a requirement to unload data from DB2 table to flat file and use the file in one of our existing production program.

Following are the field descriptions of the amount field in DB2 table, unload file and production program.

DB2 Field DECIMAL(15,2)
Field in DB2 Unload File PIC S9(13)V9(2) USAGE COMP-3 (1-8 bytes)
Field in Program PIC S9(16)V99 COMP-3. (1-10 bytes)

When I downloaded the data from DB2 table for one of amount column (which is of DECIMAL(15,2)), it was stored in the flat file as packed decimal (PIC S9(13)V9(2) USAGE COMP-3).

Since my production program will accept only PIC S9(16)V99 COMP-3, I am trying to edit the field using sort.

I tried with the following option in my outrec field

OUTREC FIELDS=(1:X'0000',3:1,8)

The results seem to be correct. Can some one let me know if this is correct approach or not.

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

Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Tue May 10, 2011 11:27 pm    Post subject:
Reply with quote

rajendraa,

Well that is one of the right approach. However you can use Z for binary zeroes like this
Code:

OUTREC FIELDS=(2Z,1,8)


On the other hand I wonder why you need an additional sort pass to pad the zeroes when the same can be done in the unload step itself like this?

Code:

SELECT CAST(your_dec(15,2)_column AS DECIMAL(18,2)) 
   FROM TABLE;
Back to top
View user's profile Send private message
rajendraa

New User


Joined: 22 Dec 2006
Posts: 7
Location: Bangalore

PostPosted: Wed May 11, 2011 2:19 am    Post subject: Reply to: Padding to packed decimal field using OUTREC in so
Reply with quote

Thank you Skolusu
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts INVALID FIELD OR CONSTANT IN SORTOF ?? Ron Klop DFSORT/ICETOOL 8 Wed Jan 11, 2017 3:44 pm
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 31 Tue Dec 06, 2016 8:04 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


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