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

Padding to packed decimal field using OUTREC in sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top