Page 1 of 1

Extraction of set / group of records based on condition.

PostPosted: Wed Mar 23, 2011 11:01 am
by dam_chandu
Hi All,

I have a input file (FB, LRECL: 10). Alphabets F or K or M at the first byte are the delimiters for the group or set of records.

Sample Input File

A -> First set of records.
1
2
F -> Start of new set i.e. second set of records.
1
2
3
F -> Start of new set i.e. third set of records.
1
2
F -> Start of new set i.e. fourth set of records.
1
K -> Start of new set i.e. firth set of records.
1
2
3
K -> Start of new set i.e. sixth set of records.
1
M -> Start of new set i.e. seventh set of records and so on...
1
2
3

Requirement:

Would wish to split the above input file into two files using Sort / Icetool.

1) File 1, where we have all records which are "F delimited" record along with dependents 1,2,3 records.
2) File 2, where we have all records which are NOT "F delimited" record along with dependents 1,2,3 records.

Output File 1

F
1
2
3
F
1
2
F
1

Output File 2

A
1
2
K
1
2
3
K
1
M
1
2
3

Regards,
Anand.

Re: Extraction of set / group of records based on condition.

PostPosted: Wed Mar 23, 2011 9:34 pm
by skolusu
dam_chandu,

Use the following DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT       
//SYSOUT   DD SYSOUT=*         
//SORTIN   DD DSN=your input FB 10 byte file,DISP=SHR
//FILEF    DD SYSOUT=*                                             
//OTHER    DD SYSOUT=*                                             
//SYSIN    DD *                                                     
  SORT FIELDS=COPY                                                 
  INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,1,SS,EQ,C'F,K,M'),PUSH=(11:1,1))
  OUTFIL FNAMES=FILEF,BUILD=(1,10),INCLUDE=(11,1,CH,EQ,C'F')       
  OUTFIL FNAMES=OTHER,SAVE,BUILD=(1,10)                             
//*

Re: Extraction of set / group of records based on condition.

PostPosted: Fri Mar 25, 2011 10:05 am
by dam_chandu
Hi Skolusu,

Thanks a ton. It worked. Appreciate your timely response.

Anand.