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
 

 

How to sort using COMP-3 variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Tue Feb 10, 2009 1:22 pm    Post subject: How to sort using COMP-3 variable
Reply with quote

Hi,

I have a 12 byte COMP-3 field from byte 230-235 as shown below. i need to sort the records based on the 5-7 bytes of the field, ie with the value 302, in the given record. The input file is of 403 byte length.

[img]C:\Documents and Settings\169685\Desktop\record[/img]

Thanks in advance.[/img]
Back to top
View user's profile Send private message

vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Tue Feb 10, 2009 1:36 pm    Post subject: Re: How to sort using COMP-3 variable
Reply with quote

vinodkumarrs wrote:
Hi,

I have a 12 byte COMP-3 field from byte 230-235 as shown below. i need to sort the records based on the 5-7 bytes of the field, ie with the value 302, in the given record. The input file is of 403 byte length.

[img]C:\Documents and Settings\169685\Desktop\record[/img]

Thanks in advance.[/img]
Back to top
View user's profile Send private message
Girish Firke

New User


Joined: 04 Feb 2009
Posts: 5
Location: Mumbai

PostPosted: Tue Feb 10, 2009 3:36 pm    Post subject: Reply to: How to sort using COMP-3 variable
Reply with quote

Hi Vinod,

Sort control card syntax for packed decimal values will be
SORT FIELDS=(Starting Position, Length, PD,A)

By looking at your question I am getting that you want to sort the 3 bytes from 5 character of a comp-3 field. If that is the case then please try below control card and let me know whether it works fine or not.


In your case

SORT FIELDS=(232,02,PD,A)
Back to top
View user's profile Send private message
vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Tue Feb 10, 2009 3:41 pm    Post subject:
Reply with quote

Hi Girish,

The SORT FIELDS=(232,02,PD,A), will take 4 bytes to check. In my case it will take the value '3021' for sorting, I need only upto '302'.

Thanks,
Vinod
Back to top
View user's profile Send private message
Girish Firke

New User


Joined: 04 Feb 2009
Posts: 5
Location: Mumbai

PostPosted: Tue Feb 10, 2009 4:16 pm    Post subject: Reply to: How to sort using COMP-3 variable
Reply with quote

Hi,

Your screenshot shows the hexa-decimal value of the record.

The hex-decimal value X'30' represent one ascii character and X'21' represents another ascii character.

I am not sure whether we can sort those as per your requirement.
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 992
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Feb 10, 2009 4:23 pm    Post subject:
Reply with quote

Also, since you are not checking the entire packed field, specifying PD for the sort is invalid.

You could try INREC processing to expand the COMP-3 field into an appended work field and sort based on the expanded 3 characters in that field. Then use OUTREC processing to drop the work field.

Garry.
Back to top
View user's profile Send private message
vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Tue Feb 10, 2009 6:13 pm    Post subject:
Reply with quote

I tried the above mentioned logic and it worked. thanks
Code:
//STEP01   EXEC  PGM=SORT                                         
//SYSOUT   DD  SYSOUT=*                                           
//SORTIN   DD DSN=------
//*                                                               
//SORTOUT  DD DSN=------               
//SYSIN    DD    *                                               
  OPTION EQUALS                                                   
  INREC OVERLAY=(404:230,6,PD,TO=ZD,LENGTH=11)                   
  SORT FIELDS=(408,3,ZD,A)                                       
  OUTREC BUILD=(1,403)                                           
/*                                                               
Back to top
View user's profile Send private message
Garry Carroll

Active Member


Joined: 08 May 2006
Posts: 992
Location: Dublin, Ireland / Edinburgh, Scotland

PostPosted: Tue Feb 10, 2009 6:20 pm    Post subject:
Reply with quote

Thanks for letting us know, Vinod.

Glad to have been able to help.

Garry.
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 Feb 10, 2009 10:09 pm    Post subject:
Reply with quote

Here's a much easier way to do this using DFSORT's bit notation for the length:

Code:

//S2  EXEC  PGM=SORT
//SYSOUT   DD  SYSOUT=*
//SORTIN   DD DSN=...  input file
//SORTOUT  DD DSN=...  output file
//SYSIN    DD    *
  OPTION EQUALS
  SORT FIELDS=(232,1.4,BI,A)
/*


For example, if the value at 232-233 is X'3021', this tells DFSORT to sort on 1 byte and 4 bits, e.g. on 302.
Back to top
View user's profile Send private message
vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Wed Feb 11, 2009 10:56 am    Post subject:
Reply with quote

This also works fine.
Since I need 3 bytes to compare I modified as below.
Code:
//STEP01   EXEC  PGM=SORT                                         
//SYSOUT   DD  SYSOUT=*                                           
//SORTIN   DD DSN=------
//*                                                               
//SORTOUT  DD DSN=------               
//SYSIN    DD    *                                               
  OPTION EQUALS                                                   
  SORT FIELDS=(232,1.3,BI,A)                                 
/*


Thank you very much for the help.

Regards,
Vinod
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: Wed Feb 11, 2009 9:47 pm    Post subject:
Reply with quote

Huh? You are dealing with 2 bytes (232-233), not 3 bytes.

1.4 for the length means 1 byte and 4 bits. 1.3 for the length means 1 byte and 3 bits. 1.4 for the length would give the correct results for all cases whereas 1.3 for the length wouldn't.

As an example, if 232-233 had records with these hex values:

3010
3000
3030
3020

Using 232,1.4 you would correctly get these output records:

3000
3010
3020
3030

Using 232,1.3, you would incorrectly get these output records:

3010
3000
3030
3020

As you can see, that fourth bit does matter.
Back to top
View user's profile Send private message
vinodkumarrs

New User


Joined: 31 Mar 2008
Posts: 8
Location: india

PostPosted: Thu Feb 12, 2009 9:51 am    Post subject:
Reply with quote

Hi,

I got the same results when I tried with 232,1.3 as well as 232,1.4 bytes.
Anyway I got the point that Frank mentioned above. Hence I will follow with the 232,1.4 option. Thanks for the clear explanation.

Regards,
Vinod
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: Thu Feb 12, 2009 10:10 am    Post subject:
Reply with quote

Hello,

Quote:
I got the same results when I tried with 232,1.3 as well as 232,1.4 bytes.
That was due to fortune rather than proper code. . .

At some point the output would have not been the same and that could be an ugly surprise icon_confused.gif

Using the nnn,1.4 will ensure the proper bits are used for sorting.

Thanks for the update icon_smile.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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm


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