Select group of records based on the key



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

Select group of records based on the key

Postby Irene Ioujanina » Mon Jul 20, 2009 7:02 pm

Good morning,
May I please ask if it's possible to do the following using the SORT. We have one or more group of records. The only we need to do is to select group/s of records (without changing order of records) based on the key value which is NOT in the header. The key value is included let's say in every 3rd record of the group pos 8thru 10.
The header is absolutely the same for all the groups.
HDR
line 1
line 2
line 3 KEY
line 4
HDR
line 3434
line 232
line 9 009
line 5
HDR
line1
line 2
line 3 939
line4
line5

after the sort is done, - I would like to get the group with the value let's say as '009':
HDR
line 3434
line 232
line 9 009
line 5

Thanking you so much in advance,
Irene.
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Select group of records based on the key

 

Re: Select group of records based on the key

Postby Frank Yaeger » Mon Jul 20, 2009 9:20 pm

You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

//S1    EXEC  PGM=ICETOOL
//TOOLMSG   DD  SYSOUT=*
//DFSMSG    DD  SYSOUT=*
//IN DD DSN=...  input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT DD DSN=...  output file (FB/80)
//TOOLIN   DD    *
SORT FROM(IN) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
/*
//CTL1CNTL DD *
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,3,CH,EQ,C'HDR'),
    PUSH=(81:ID=8,89:SEQ=8,97:SEQ=8)),
   IFTHEN=(WHEN=(89,8,ZD,EQ,4),OVERLAY=(97:8C'0'))
  SORT FIELDS=(81,8,ZD,A,97,8,ZD,A)
  OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(97,8,ZD,EQ,0),
    PUSH=(105:8,3))
  OUTFIL FNAMES=T1,INCLUDE=(105,3,CH,EQ,C'009')
/*
//CTL2CNTL DD *
  SORT FIELDS=(81,8,ZD,A,89,8,ZD,A)
  OUTREC BUILD=(1,80)
/*
Frank Yaeger - DFSORT Development Team (IBM) - yaeger@us.ibm.com
Specialties: JOINKEYS, FINDREP, WHEN=GROUP, ICETOOL, Symbols, Migration
=> DFSORT/MVS is on the Web at http://www.ibm.com/storage/dfsort
User avatar
Frank Yaeger
Global moderator
 
Posts: 1080
Joined: Sat Jun 09, 2007 8:44 pm
Has thanked: 0 time
Been thanked: 14 times

Re: Select group of records based on the key

Postby Irene Ioujanina » Mon Jul 20, 2009 10:52 pm

Thank you thak you so much :)
Irene Ioujanina
 
Posts: 27
Joined: Thu Feb 21, 2008 6:42 pm
Has thanked: 0 time
Been thanked: 0 time


Return to DFSORT/ICETOOL/ICEGENER

 


  • Related topics
    Replies
    Views
    Last post