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

How i can sort on a field whose position is not fixed


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

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Thu Nov 29, 2007 6:00 pm
Reply with quote

Thanks to all for the response.
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: Thu Nov 29, 2007 8:39 pm
Reply with quote

Hello abhay,

You could always write program code to accomplish what you want. . .

You might also talk with the system support people to see if there is some other utility available on your system that would provide the functionality you want.

I still believe that your environment would be better served by installing the current release of your sort product.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 30, 2007 10:53 am
Reply with quote

abhay pratap singh,
Quote:
Can you provide me solution according to version 1.2.0

Please check with the following code for your requirement.
Code:
//S EXEC PGM=SORT                                           
//SORTIN DD *                                               
DR-APS                                                     
DOCTOR-XYZ                                                 
DOC-ABC                                                     
DOCT-BAC                                                   
/*                                                         
//O1 DD DSN=&&O1,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O2 DD DSN=&&O2,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O3 DD DSN=&&O3,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O4 DD DSN=&&O4,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O5 DD DSN=&&O5,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O6 DD DSN=&&O6,DISP=(,PASS),SPACE=(CYL,(1,1))             
//O7 DD DSN=&&O7,DISP=(,PASS),SPACE=(CYL,(1,1))             
//SYSOUT DD SYSOUT=*                                       
//SYSIN DD *                                               
 OPTION COPY                                               
 OUTFIL FNAMES=O1,INCLUDE=(1,1,CH,EQ,C'-'),OUTREC=(1,80,2,3)
 OUTFIL FNAMES=O2,INCLUDE=(2,1,CH,EQ,C'-'),OUTREC=(1,80,3,3)
 OUTFIL FNAMES=O3,INCLUDE=(3,1,CH,EQ,C'-'),OUTREC=(1,80,4,3) 
 OUTFIL FNAMES=O4,INCLUDE=(4,1,CH,EQ,C'-'),OUTREC=(1,80,5,3) 
 OUTFIL FNAMES=O5,INCLUDE=(5,1,CH,EQ,C'-'),OUTREC=(1,80,6,3) 
 OUTFIL FNAMES=O6,INCLUDE=(6,1,CH,EQ,C'-'),OUTREC=(1,80,7,3) 
 OUTFIL FNAMES=O7,INCLUDE=(7,1,CH,EQ,C'-'),OUTREC=(1,80,8,3) 
/*                                                           
// EXEC PGM=SORT                                             
//SORTIN DD DSN=*.S.O1,DISP=(OLD,DELETE),VOL=REF=*.S.O1       
//       DD DSN=*.S.O2,DISP=(OLD,DELETE),VOL=REF=*.S.O2       
//       DD DSN=*.S.O3,DISP=(OLD,DELETE),VOL=REF=*.S.O3       
//       DD DSN=*.S.O4,DISP=(OLD,DELETE),VOL=REF=*.S.O4       
//       DD DSN=*.S.O5,DISP=(OLD,DELETE),VOL=REF=*.S.O5       
//       DD DSN=*.S.O6,DISP=(OLD,DELETE),VOL=REF=*.S.O6       
//       DD DSN=*.S.O7,DISP=(OLD,DELETE),VOL=REF=*.S.O7       
//SORTOUT DD SYSOUT=*                                         
//SYSOUT DD SYSOUT=*                                         
//SYSIN DD *                                                 
 SORT FIELDS=(81,3,CH,A)                                     
 OUTREC FIELDS=(1,80)
/*                   
//

Output:
Code:
DOC-ABC   
DR-APS     
DOCT-BAC   
DOCTOR-XYZ
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Nov 30, 2007 11:19 am
Reply with quote

Shankar,

Quote:
Please check with the following code for your requirement.


This should work perfectly with that version icon_biggrin.gif . But what if "-" is present somewhere between column 8 till 80 (assuming the LRECL to be 80) as you have taken into consideration only the first 7 bytes. Guess you will have to add few more DD steps.

abhay,

What is the LRECL?
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 30, 2007 11:55 am
Reply with quote

Aaru,
Quote:
But what if "-" is present somewhere between column 8 till 80 (assuming the LRECL to be 80) as you have taken into consideration only the first 7 bytes.

As sorting is happening on field with length 3, the possibility of string "-" should be present somewhere between column 1 and 77 and not in column 78, 79 and 80. Please correct me if i am wrong.
Quote:
Guess you will have to add few more DD steps.

That's true for your point.
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 30, 2007 11:56 am
Reply with quote

abhay pratap singh,

what is the mininum and maximum length of the field that occur before string "-"?
What is the LRECL and RECFM of your input file?
If you provide the above information it will be easy to provide you the exact solution accoring to the version available in your shop.
Back to top
View user's profile Send private message
Aaru

Senior Member


Joined: 03 Jul 2007
Posts: 1287
Location: Chennai, India

PostPosted: Fri Nov 30, 2007 12:14 pm
Reply with quote

shankar,

Quote:
column 1 and 77 and not in column 78, 79 and 80. Please correct me if i am wrong.


You are correct. We are assuming that "-" will always be followed by 3 bytes on which we should sort.

Let us wait for the OP to respond with the Record length details.
Back to top
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Fri Nov 30, 2007 1:06 pm
Reply with quote

[quote="shankar.v"]abhay pratap singh,
Quote:
OUTREC=(1,80,2,3),OPTION COPY


Thanks a lot shankar.Code is working and i have got the expected result.
But i have 2 doubts--
1) Whats the meaning of the outrec statement we are using in first sort.I am not getting the meaning of numbers we are using after 80.
2) Use of "OPTION COPY" in sysin card of first sort. Can we use SORT FIELDS=COPY here.
Back to top
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Fri Nov 30, 2007 1:14 pm
Reply with quote

shankar.v wrote:


what is the mininum and maximum length of the field that occur before string "-"?
What is the LRECL and RECFM of your input file?


Maximum length = 78,Minimum length=2
LRECL=80,RECFM=FB
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 30, 2007 1:14 pm
Reply with quote

abhay pratap singh,
Quote:
Whats the meaning of the outrec statement we are using in first sort.I am not getting the meaning of numbers we are using after 80.

Three bytes after the string "-" is placed in 81st postion.
Quote:
Use of "OPTION COPY" in sysin card of first sort. Can we use SORT FIELDS=COPY here.

yes, you can use. OPTION COPY and SORT FIELDS=COPY are same.
Quote:
abhay pratap singh,

what is the mininum and maximum length of the field that occur before string "-"?
What is the LRECL and RECFM of your input file?
If you provide the above information it will be easy to provide you the exact solution accoring to the version available in your shop.

?????
Back to top
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Fri Nov 30, 2007 1:17 pm
Reply with quote

shankar.v wrote:
abhay pratap singh,

what is the mininum and maximum length of the field that occur before string "-"?
What is the LRECL and RECFM of your input file?


Maximum length = 78,Minimum length=2
LRECL=80,RECFM=FB
Back to top
View user's profile Send private message
shankar.v

Active User


Joined: 25 Jun 2007
Posts: 196
Location: Bangalore

PostPosted: Fri Nov 30, 2007 1:33 pm
Reply with quote

Quote:
Maximum length = 78,Minimum length=2
LRECL=80,RECFM=FB
.
As sorting is going to happen on three bytes, the maximum length of the field before string "-" should be 76. So that "-" will present in 77th column and we will get the last three bytes(78th byte, 79th byte and 80th byte) of the file for sorting.

In your case as the maximum length of the field before string "-" is 78,
if string "-" is present on 78, we will get last two bytes(79th byte and 80th byte) of the file for sorting, instead of three and
if string "-" is present on 79, we will get last one byte(80th byte) of the file for sorting, instead of three.

What you want to do in the above case?
Back to top
View user's profile Send private message
abhay pratap singh

New User


Joined: 22 Nov 2007
Posts: 77
Location: noida

PostPosted: Fri Nov 30, 2007 3:00 pm
Reply with quote

shankar.v wrote:
Quote:
Maximum length = 78,Minimum length=2
LRECL=80,RECFM=FB
.

In your case as the maximum length of the field before string "-" is 78,
if string "-" is present on 78, we will get last two bytes(79th byte and 80th byte) of the file for sorting, instead of three and
if string "-" is present on 79, we will get last one byte(80th byte) of the file for sorting, instead of three.

What you want to do in the above case?


Both the cases are fine because if i am having 78 bytes before "-" then only two bytes i will have after "-" and similarly in the second case.So that is not a problem.

Thanks a lot.......
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
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 INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Pulling a fixed number of records fro... DB2 2
Search our Forums:

Back to Top