View previous topic :: View next topic
|
Author |
Message |
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi All,
I have a file created with a copy book defined as below
01 a-comp PIC 9(11) COMP-3.
01 a-char PIC X(69).
I want to sort this file according to a-comp(4:8).
Could you please suggest a method using a single sort card. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
I don't know what you mean by a-comp(4:8).
Your a-comp field is a 6-byte PD field that might look like this in hex X'1234567890C'. What do you want to sort on in that hex field? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Or maybe X'01234567890C'. . . |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Dick,
You're right - I meant to show X'12345678901C' (11 digits). Thanks for the correction. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Frank,
You're welcome - didn't mean it as a correction as much as a just a silly
Been a goofy day and it just bubbled over. . . . |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi Dick and Franks,
Thanks for your comments.
don't know what you mean by a-comp(4:8).
What I mean was positions from 4 to 8 bytes when You read a comp-3 field in COBOL.
Your a-comp field is a 6-byte PD field that might look like this in hex X'01234567890C'. What do you want to sort on in that hex field?
Say the Hex field I want to sort is 34567890. I think you got the problem.
[/left][/quote] |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
abin wrote: |
01 a-comp PIC 9(11) COMP-3.
01 a-char PIC X(69).
I want to sort this file according to a-comp(4:8). |
If your pic 9(11) was reprenented by X'12345678901F' you want to sort on the fourth thru eleventh digit of the packed number (345678901)? |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
your pic 9(11) was reprenented by X'12345678901F' you want to sort on the fourth thru eleventh digit of the packed number (345678901)?
Yes Will thats correct. here I want to sort on (45678901) |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Could you just convert from packed to zoned decimal on input and sort on the digits you want? |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Hi Will,
this is exactly I want. But is there any way to do it in a sort step(Not in COBOL code).
I thought about doing it using INREC. But in that way I need some space (6 bytes -> 11 bytes) to store the new value. My input file is full with data and I cannot spare a bit of it. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Using INREC, expand the record by 11 bytes, sort on the portion of the additional area and using outrec, shorten it back to the original size. |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Ok Will I Got what you mean. But, it is my understanding that when we reformat input using INREC we need to specify the positions to which reformated input be written.
Here in my case if I give inrec as follows,
INREC(1:1,6,PD,TO=ZD,12:7,69).
In these i may lose data in position 6 to 12. Please correct me if I am in wrong. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Why not just INREC(1:1,6,PD,TO=ZD,12:1,69)? |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Why not just INREC(1:1,6,PD,TO=ZD,12:1,69)?
In this way I'll get COMP-3 in positions 1 to 11 and all the data at position in 1 to 69 in input on 12 to 80. What will happen to data in position 69 to 80 in input. I will loose it?. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Not quite sure what you are asking, but use OUTREC to put the record back to its original zise.
I understood the your record was only 75 bytes long, is it longer? |
|
Back to top |
|
|
abin
Active User
Joined: 14 Aug 2006 Posts: 198
|
|
|
|
Sorry Will,
Mistake from my part I meant to say data position in 69 to 75. Its 75 in length. Actually The layout I gave was to simplify things my actuall layout is 5000 bytes long Any way thanks for your comments I'm trying what you proposed. I'll get back to you later. |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Abin,
At this point, I don't know where your PD field starts or how long it is. But going back to your original post, I'll assume it's in positions 1-6.
You don't need to do any conversion. You can use DFSORT's PD0 format to SORT the field directly like this:
Code: |
SORT FIELDS=(2,5,PD0,A)
|
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hi Frank,
Sorry to be a pain, but if i read the earlier posts correctly the sorting needs to start on a "half-byte". . .
Quote: |
your pic 9(11) was reprenented by X'12345678901F' you want to sort on the fourth thru eleventh digit of the packed number (345678901)?
Yes Will thats correct. here I want to sort on (45678901) |
If the sort really does need to start with the "4". . .? |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Yes, and that's what PD0 format does. It ignores the first nibble and the last nibble. So for X'12345678901F', 2,5,PD0,A would operate on positions 2-6. It would ignore the first nibble (3) and the last nibble (F). You can look up PD0 in "z/OS DFSORT Application Programming Guide" to see how it operates. Note that I did a test before posting to verify that it does what was requested. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Cool
We don't have DFSORT here, so i'm not able to try some of the neater solutions. . . |
|
Back to top |
|
|
|