Splitting files using sort in JCL



IBM's flagship sort product DFSORT for sorting, merging, copying, data manipulation and reporting. Includes ICETOOL and ICEGENER

Splitting files using sort in JCL

Postby Dhamodharan K » Sat Sep 20, 2014 3:02 pm

Hi all,

I would like to know how to split records using JCL.
Scenario is below,

I have a dataset which has students records of each exam like,

     JAY ANNUALEXAM     7.9 FIRSTCLASS
     RAM QUARTEREXAM  7.0 FIRSTCLASS
     RAM HALFYRLYEXAM 7.6 FIRSTCLASS
     RAM ANNUALEXAM    8.3 FIRSTCLASS
     SAM QUARTEREXAM  6.5 FIRSTCLASS
     SAM ANNUALEXAM    7.3 FIRSTCLASS
     RAJ QUARTEREXAM  6.7 FIRSTCLASS
     RAJ HALFYRLYEXAM 5.6 SECONDCLASS
     DAV ANNUALEXAM    6.4 FIRSTCLASS     


the above nine records are in one single dataset. I need to split it into 2 records by using col(1,3) as key in runtime.
The key value should not be hard coded in the sort card.

The output files should like below,

File 1:

     JAY ANNUALEXAM     7.9 FIRSTCLASS
     RAM QUARTEREXAM  7.0 FIRSTCLASS
     RAM HALFYRLYEXAM 7.6 FIRSTCLASS
     RAM ANNUALEXAM    8.3 FIRSTCLASS

File 2:

     SAM QUARTEREXAM  6.5 FIRSTCLASS
     SAM ANNUALEXAM    7.3 FIRSTCLASS
     RAJ QUARTEREXAM  6.7 FIRSTCLASS
     RAJ HALFYRLYEXAM 5.6 SECONDCLASS
     DAV ANNUALEXAM    6.4 FIRSTCLASS


Regards,
Dhamodharan K

Code'd
Dhamodharan K
 
Posts: 2
Joined: Sat Sep 20, 2014 2:49 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Splitting files using sort in JCL

Postby BillyBoyo » Sat Sep 20, 2014 4:06 pm

Have a look at WHEN=GROUP with KEYBEGIN and PUSH an ID (a sequence number which only changes when the group definer changes) then use OUTFIL with INCLUDE= for the ID field being less-than-or-equal-to two.

These users thanked the author BillyBoyo for the post:
Dhamodharan K (Mon Sep 22, 2014 3:19 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Splitting files using sort in JCL

Postby Dhamodharan K » Sat Sep 20, 2014 4:20 pm

Hi Billy,

Could you please elaborate more.

Regards,
Dhamodharan K
Dhamodharan K
 
Posts: 2
Joined: Sat Sep 20, 2014 2:49 pm
Has thanked: 1 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post