Page 1 of 1

Select group of records based on the key

PostPosted: Mon Jul 20, 2009 7:02 pm
by Irene Ioujanina
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.

Re: Select group of records based on the key

PostPosted: Mon Jul 20, 2009 9:20 pm
by Frank Yaeger
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)
/*

Re: Select group of records based on the key

PostPosted: Mon Jul 20, 2009 10:52 pm
by Irene Ioujanina
Thank you thak you so much :)