Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Sort on part of COMP-3 fields

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Sort on part of COMP-3 fields
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 Moderator


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

PostPosted: Fri Mar 02, 2007 9:43 pm    Post subject:
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

Site Director


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

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

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

DFSORT Moderator


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

PostPosted: Sat Mar 03, 2007 12:49 am    Post subject:
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

Site Director


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

PostPosted: Sat Mar 03, 2007 3:23 am    Post subject:
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    Post subject: Re: Sort on part of COMP-3 fields
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:16 pm    Post subject: Re: Sort on part of COMP-3 fields
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    Post subject: Re: Sort on part of COMP-3 fields
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:37 pm    Post subject:
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    Post subject: Re: Sort on part of COMP-3 fields
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 2:53 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 3:16 pm    Post subject:
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    Post subject:
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: 3158
Location: Tucson AZ

PostPosted: Mon Mar 05, 2007 3:41 pm    Post subject:
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    Post subject:
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 Moderator


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

PostPosted: Mon Mar 05, 2007 9:55 pm    Post subject:
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

Site Director


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

PostPosted: Mon Mar 05, 2007 11:07 pm    Post subject:
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 Moderator


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

PostPosted: Tue Mar 06, 2007 12:45 am    Post subject:
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

Site Director


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

PostPosted: Tue Mar 06, 2007 1:25 am    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm
No new posts Access SQLCA fields inside a stored p... gangapd DB2 4 Thu Oct 27, 2016 10:20 am
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts How to delete second instance from Fl... Gunapala CN DFSORT/ICETOOL 6 Tue Oct 18, 2016 11:42 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us