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 

Reformat to PD using OUTREC

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


Joined: 22 Jun 2004
Posts: 10
Topics: 4

PostPosted: Mon Sep 06, 2004 11:27 am    Post subject: Reformat to PD using OUTREC Reply with quote

Hi All,

There is an input file with the following format :

1,9 - PD
10,29 - CHAR

Now I want to sort the file based on the following criteria :

1) Expand 1-9 Packed decimal fields into ZD
2) Sort the 15th byte of the expanded record,
3) Reformat the expanded ZD fields into original PD and write an sorted o/p file that has the same record structure as i/p file.

Summed up as : Want to sort the PD field based on the 15th digit and write it back as it was.

Actually Step1 & Step2 worked fine with the Hex Trick (i.e) :

Code:
//SYSIN    DD *
    INREC FIELDS=(1,1,HEX,2,8,PD,TO=ZD,18:10,29)
    SORT FIELDS=(1,15,CH,A,19,1,CH,A,16,2,CH,A)
/*


But I am stuck in Step 3. i.e to reformat the expanded 9byte PD (17 digits) back to its original format.

Is there any way that the input file format remains intact after sorting?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon Sep 06, 2004 12:23 pm    Post subject: Reply with quote

Hariharan,

I really don't get what you are trying to do. If your intention is to sort the PD fields ignoring the sign bit , then you can simply use the PD0 Format.

For the PD0 format (packed decimal, with sign and first digit ignored). The PD0 format can be represented as follows:
Code:
 xddd...ds

x is hexadecimal 0-F and is ignored.
d is hexadecimal 0-9 and represents a decimal digit.
s is hexadecimal 0-F and is ignored.

PD0 can be used for parts of PD fields. For example, in the PD field P'mmddyy' (hexadecimal 0mmddyyC), PD0 can be used separately for 0mmd (mm), mddy (dd) and dyyC (yy).

Hope this helps...

Cheers

kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
hari haran
Beginner


Joined: 22 Jun 2004
Posts: 10
Topics: 4

PostPosted: Mon Sep 06, 2004 2:04 pm    Post subject: Reply with quote

Hi Kolusu,

Thanks for the reply.

The problem is that the sort should be done on a single digit of a COMP-3 record. Ex. to sort the 17th digit of a PD record having 9 Bytes storage space.

For ex :

Input file :

12345678901234563
12345678901234562
12345678901234566
12345678901234567
12345678901234568

Output file should be:

12345678901234562
12345678901234563
12345678901234566
12345678901234567
12345678901234568

If this is possible using PD0 could you give some code sample for the sort card as my knowledge of sorting using PD is quite limlited.
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: Mon Sep 06, 2004 2:23 pm    Post subject: Reply with quote

Quote:
But I am stuck in Step 3. i.e to reformat the expanded 9byte PD (17 digits) back to its original format.

Is there any way that the input file format remains intact after sorting?


I'm not sure what you're trying to do either, but ...

Yes, you could get the PD value back by a trick involving converting the first 4 ZD bytes to two PD bytes and only using the first PD byte (2 digits), but you're really taking the entirely wrong approach here. Rather than transforming the ZD field back to a PD field, it makes more sense to keep the original record intact and just add on the ZD key, sort on it and remove it.

Here's a DFSORT job that shows what I mean:

Code:

//S2    EXEC  PGM=ICEMAN                                           
//SYSOUT    DD  SYSOUT=*                                           
//SORTIN DD DSN=...  input file                                                     
//SORTOUT DD DSN=...  output file                                             
//SYSIN    DD    *                                                 
  INREC FIELDS=(1,29,   ORIGINAL FIELDS                             
    30:1,1,HEX,2,8,PD,TO=ZD)  Add ZD field converted from PD field 
  SORT FIELDS=(30,15,CH,A,   Sort on ZD field
            11,1,CH,A,   Sort on original field
            45,2,CH,A)   Sort on ZD field                     
  OUTREC FIELDS=(1,29)  Remove ZD field         
/*             

_________________
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
Frank Yaeger
Sort Forum Moderator
Sort Forum Moderator


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

PostPosted: Mon Sep 06, 2004 2:30 pm    Post subject: Reply with quote

Well, I just read your post on what you really want to do. You can sort on the 17th digit by using bytes.bit notation for the DFSORT SORT statement like this:

Code:

 SORT FIELDS=(9,0.4,BI,A)       


9 says to start at the first bit of position 9.
0.4 gives the length as 4 bits.
The format must be BI.

Note that if all of the PD values had the same sign (e.g. C), you could just sort on the last byte (digit+sign = 9,1,BI,A) as binary. And if the sign mattered, you could sort on the last byte (digit+sign = 9,1,PD,A) as PD.

It helps us to help you if you give us ALL the information about what you're trying to do.
_________________
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
hari haran
Beginner


Joined: 22 Jun 2004
Posts: 10
Topics: 4

PostPosted: Tue Sep 07, 2004 7:39 am    Post subject: Reply with quote

Hi Frank,

Yes Frank I needed to sort on one particular digit of a PD field.

Thanks for both the answers. Both of them worked fine.

Great solutions......
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