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

Sorting only particular rows from complete file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Thu Sep 11, 2008 4:37 pm
Reply with quote

Hi,

I would like to SORT and SUM only some rows from the whole PS file.

Those particular rows have special character 'LINE' at position 4.

This file is VB file, so we can expect any different record length for each row, but 'LINE' row will have record length of 250.

Can any one tell me how can i sort only LINE rows? I can't use INCLUDE or INREC IFTHEM.

Please give me your thoughts.
Back to top
View user's profile Send private message
Aaru

Senior Member


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

PostPosted: Thu Sep 11, 2008 4:50 pm
Reply with quote

Noork,

Quote:
I can't use INCLUDE or INREC IFTHEM.


Why??

One usually would include the records with 'LINE' starting position 8(as VB) and then sort and sum the fields as per your requirement.

Quote:
I would like to SORT and SUM only some rows from the whole PS file.


You will have to be specific of what needs to be sorted and summed and how.
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Thu Sep 11, 2008 5:58 pm
Reply with quote

Hi Aaru,

Let me explain you with Example.

Let us consider there are 10 rows in a VB file.

position 4
1st row: .................... HIGHT rec length 255
2nd row: .................... LINE rec length 250
3rd row: .................... LOW rec length 120
4th row: .................... HIT rec length 130
5th row: .................... NIGHT
6th row: .................... FREIGHT
7th row: .................... HIGHT
8th row: .................... HIGYNIC
9th row: .................... LINE rec length 250
10th row: .................... HIGHT


now i would like to sort only 2 and 9th row on position 4. Can you now explain me how can i do that?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Sep 11, 2008 6:04 pm
Reply with quote

Sort in respect to what. i.e. Where will the sorted records go within this file.

And may I ask why the restriction on using INCLUDE and/or INREC ?
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Thu Sep 11, 2008 6:09 pm
Reply with quote

Hi,

and what exactly is going to be SUMmed?

and I'm assuming a row is a record ?


Gerry
Back to top
View user's profile Send private message
noorkh

New User


Joined: 06 Mar 2006
Posts: 76
Location: Chennai

PostPosted: Thu Sep 11, 2008 6:32 pm
Reply with quote

Hi Expat,

There is no restriction in using INCLUDE/INREC. i had wrongly mentioned it.

I want to sort only those 2 records because it could be duplicate. and if it is duplicate i would like to sum = none.

I would like to sort on Position 25. which has value PEOPLE. and this sorting should happen only for 2 and 9th record which has Unique value 'LINE' in position 4.

If I Sort on Position 4 and then 25.. and SUM=NONE, then these 2 rows will become single row.

I would like to write this record in the same file along with other records.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Thu Sep 11, 2008 6:41 pm
Reply with quote

If the position within the file of the records with 'LINE' in them is not important, then I would suggest splitting the file into two, those with LINE in them and those without.

Performing your SORT SUM on the LINE records and then concatenating the two files back together again.

If the record position within the file is important then I will leave this one to someone who knows and uses the sort product far better than I do. Although if you read the document for smart tricks with DFSORT I recall an example that puts seq numbers on the records and these could then be used to place the LINE record(s) back in their original places.
Back to top
View user's profile Send private message
Skolusu

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Sep 11, 2008 9:42 pm
Reply with quote

noorkh,

As expat mentioned if the position of the records is not mandatory then the following DFSORT JCL will give you the desired results

Code:

//STEP0100 EXEC PGM=ICEMAN                                 
//SYSOUT   DD SYSOUT=*                                     
//SORTIN   DD DSN=YOUR INPUT VB FILE,
//            DISP=SHR                           
//SORTOUT  DD DSN=yout output vb file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)
//SYSIN    DD *                                           
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,8,ZD,14X,5)), 
    IFTHEN=(WHEN=(30,4,CH,EQ,C'LINE'),OVERLAY=(5:C'1',30,21))
  SORT FIELDS=(5,22,CH,A)                                 
  SUM FIELDS=NONE             
  OUTFIL BUILD=(1,4,27)                                   
/*   


If you do need the records in the original order after eliminating the dups then use the following DFSORT/ICETOOL jcl

Code:

//STEP0100 EXEC PGM=ICETOOL                                         
//TOOLMSG  DD SYSOUT=*                                               
//DFSMSG   DD SYSOUT=*                                               
//IN       DD DSN=YOUR INPUT VB FILE,DISP=SHR
//T1       DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(X,Y),RLSE)
//OUT      DD DSN=yout output vb file,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=SYSDA,
//            SPACE=(CYL,(X,Y),RLSE)           
//TOOLIN   DD *                                                     
  COPY FROM(IN) USING(CTL1)                                         
  COPY FROM(T1) USING(CTL2)                                         
//CTL1CNTL DD *                                                       
  INREC IFTHEN=(WHEN=INIT,BUILD=(1,4,SEQNUM,8,ZD,SEQNUM,8,ZD,13X,5)),
    IFTHEN=(WHEN=(37,4,CH,EQ,C'LINE'),OVERLAY=(13:38,21))     
  SORT FIELDS=(13,21,CH,A)                                           
  SUM FIELDS=NONE                   
  OUTFIL FNAMES=T1,BUILD=(1,4,5,8,34)                               
//CTL2CNTL DD *                                                     
  SORT FIELDS=(5,8,CH,A)                                             
  OUTFIL FNAMES=OUT,BUILD=(1,4,13)                                   
/*

Hope this helps...

Cheers
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts To get the count of rows for every 1 ... DB2 3
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
Search our Forums:

Back to Top