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

Sort on part of COMP-3 fields


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Fri Mar 02, 2007 12:22 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Fri Mar 02, 2007 9:43 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 02, 2007 11:17 pm
Reply with quote

Or maybe X'01234567890C'. . . icon_smile.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Sat Mar 03, 2007 12:49 am
Reply with quote

Dick,

You're right - I meant to show X'12345678901C' (11 digits). Thanks for the correction.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Sat Mar 03, 2007 3:23 am
Reply with quote

Hi Frank,

You're welcome - didn't mean it as a correction as much as a just a silly icon_smile.gif

Been a goofy day and it just bubbled over. . . . icon_wink.gif
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 1:09 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:16 pm
Reply with quote

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
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 2:19 pm
Reply with 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)
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:37 pm
Reply with quote

Could you just convert from packed to zoned decimal on input and sort on the digits you want?
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 2:43 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:53 pm
Reply with quote

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
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 3:10 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 3:16 pm
Reply with quote

Why not just INREC(1:1,6,PD,TO=ZD,12:1,69)?
Back to top
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 3:37 pm
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 3:41 pm
Reply with quote

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
View user's profile Send private message
abin

Active User


Joined: 14 Aug 2006
Posts: 198

PostPosted: Mon Mar 05, 2007 3:47 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Mon Mar 05, 2007 9:55 pm
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Mon Mar 05, 2007 11:07 pm
Reply with quote

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
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Tue Mar 06, 2007 12:45 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Mar 06, 2007 1:25 am
Reply with quote

Cool icon_smile.gif

We don't have DFSORT here, so i'm not able to try some of the neater solutions. . . icon_sad.gif
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 -> JCL & VSAM

 


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 JCL sort card - get first day and las... JCL & VSAM 9
No new posts Sort First/last record of a subset th... DFSORT/ICETOOL 7
No new posts how to calculate SUM value for VB fil... DFSORT/ICETOOL 1
Search our Forums:

Back to Top