MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

converting from S9(20)V9(2) comp-3 to S9(14)V9(3) comp-3

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities
View previous topic :: View next topic  
Author Message
dohellwithmf
Beginner


Joined: 12 Jul 2007
Posts: 55
Topics: 23

PostPosted: Wed Feb 13, 2008 8:09 am    Post subject: converting from S9(20)V9(2) comp-3 to S9(14)V9(3) comp-3 Reply with quote

Hi,

I have one field in my file which is defined as Decimal(22,2) in the table. So it is showing 12 dots(packed decimal format) in the file. I need to load another table using this file but the corresponding field in target table is defined as Decimal(17,3).

Can I use sort utility to convert it? Please help me and also give me pointer to some useful document on sort.

TIA, Mayank
Back to top
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Feb 13, 2008 8:23 am    Post subject: Reply with quote

Mayank,

You have to provide the starting and ending positions of the filed in the input file which has declaration as S9(20)V9(2) comp-3.
Back to top
View user's profile Send private message Send e-mail
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Wed Feb 13, 2008 12:13 pm    Post subject: Reply with quote

An S9(20)V9(2) value has 20 digits to the left of the decimal point and 2 digits to the right of the decimal point. An S9(14)V9(3) value has 14 digits to the left of the decimal point and 3 digits to the right of the decimal point. (Of course, the decimal point is not actually carried internally for comp-3 = PD values.)

So you're asking to convert a value like:

12345678901234567890.12

to a value with 14 digits to the left of the decimal point and 3 digits to the right of the decimal point. How exactly would you want to do that conversion? What would you want the value above to look like with 14 digits to the left of the decimal point and 3 digits to the right of the decimal point? Would you just truncate the rightmost 6 digits and add a 0 at the end to get:

78901234567890.120

or would you want some other result?

Quote:
give me pointer to some useful document on sort


You can find all of the DFSORT books at:

www.ibm.com/servers/storage/support/software/sort/mvs/srtmpub.html

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols.
_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dohellwithmf
Beginner


Joined: 12 Jul 2007
Posts: 55
Topics: 23

PostPosted: Wed Feb 13, 2008 11:10 pm    Post subject: Reply with quote

Frank,

Thanks for ur reply.....
yes the value would get truncated. Actually the maximum significant digits in source field are only 14 left to the decimal. But i need to increase one digit right to the decimal and the would be ZERO of course.

For example source field has values: 00000012345678901234.25 then i need to convert it to 12345678901234.250.

Problem is that in the file the value is in PD format.....
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Thu Feb 14, 2008 11:31 am    Post subject: Reply with quote

Here's a DFSORT job that will do what you asked for. I assumed that your 12-byte input PD field is in positions 1-12 and you want the 9-byte output PD field in positions 1-9. Adjust as needed.

Code:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...  input file
//SORTOUT DD DSN=...  output file
//SYSIN    DD    *
  OPTION COPY
  INREC IFTHEN=(WHEN=INIT,
    BUILD=(1,12,PD,MUL,+10,TO=PD,LENGTH=12)),
   IFTHEN=(WHEN=INIT,BUILD=(4,9))
/*


If the input records were as follows in hex:

Code:

01234567890123456789012C   
00000001234567890123425C   
01234567890123456789012D   
00000001234567890123425D   


The corresponding output records would be as follows in hex:

Code:

78901234567890120C 
12345678901234250C 
78901234567890120D 
12345678901234250D 

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dohellwithmf
Beginner


Joined: 12 Jul 2007
Posts: 55
Topics: 23

PostPosted: Fri Feb 15, 2008 12:06 am    Post subject: Reply with quote

Hi Frank,

Thanks. Sort card is working fine.
Can you plz explain this Sort card....what's the use of MUL and what's +10 for?
Second BUILD is also no clear to me.

please help me understanding this so that I can use it appropriately in my job.

TIA, Mayank
Back to top
View user's profile Send private message
dohellwithmf
Beginner


Joined: 12 Jul 2007
Posts: 55
Topics: 23

PostPosted: Fri Feb 15, 2008 1:01 am    Post subject: Reply with quote

Frank,

truncation of bytes (12 to 9 in above example) can be done using OUTREC also but if need to truncate odd numbers of nibble then how can do using above sortcard?

for ex: we have number written as following using hex on-

024680246802
13579135791C

and I want to keep the output as below-

____0246802
___9135791C

means I need to convert 01234567890123456789012C to 90123456789012C then how can modify my sort card please tell me.

TIA
Back to top
View user's profile Send private message
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


Joined: 02 Dec 2002
Posts: 1618
Topics: 31
Location: San Jose

PostPosted: Fri Feb 15, 2008 12:36 pm    Post subject: Reply with quote

Quote:
what's the use of MUL and what's +10 for?


MUL,+10 means multiply by 10. This give us the extra 0 at the end for three digits after the decimal point rather than 2 (e.g. from .12 to .120).

Quote:
Second BUILD is also no clear to me.


The first BUILD multiplies the PD value by 10 to a 12-byte PD value. The second BUILD takes the last 9 bytes of that value to get the 9-byte PD value you want.

Quote:
to convert 01234567890123456789012C to 90123456789012C then how can modify my sort card


If the PD value is always positive, you can use these DFSORT control statements:

Code:

  OPTION COPY                         
  INREC BUILD=(5,8,PD0,TO=PD,LENGTH=8)


If the PD values can be positive or negative, you can use these DFSORT control statements:

Code:

  OPTION COPY                                                 
  INREC IFTHEN=(WHEN=INIT,                                   
    BUILD=(1,12,PD,MUL,+10,TO=PD,LENGTH=12)),                 
   IFTHEN=(WHEN=INIT,BUILD=(5,8)),                           
   IFTHEN=(WHEN=INIT,BUILD=(1,8,PD,DIV,+10,TO=PD,LENGTH=8))   

_________________
Frank Yaeger - DFSORT Development Team (IBM)
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
DFSORT is on the Web at:
www.ibm.com/storage/dfsort
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dohellwithmf
Beginner


Joined: 12 Jul 2007
Posts: 55
Topics: 23

PostPosted: Sun Feb 17, 2008 11:14 pm    Post subject: Reply with quote

thanks Frank.... Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Utilities All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group