Page 1 of 1

Copying Distinct Records

PostPosted: Mon Dec 17, 2012 6:55 pm
by shiitiizz
Hi All,

I need help with below Sort:
Input data will be of this format:

"1234"||"567"||"gtyhjgdgh"||" " ||" " ||"y"||
"4"||"5"||"hj8bjh"||" "||" " ||"y"||
"4"||"6"||"hj8bjh"||" "||" " ||"y"||
"1"||"7"||"98bjh"||" "||" " ||"y"||
"9"||"6"||"gtyhh"||" " ||"Y " ||"y"||
"4"||"4"||"hj8bjh"||" "||" " ||"y"||


and o/p should be
1234
4
1
9


i.e. it should eliminate the " and || and should also stop copying when it hits | in the first line and move to next line.

With FINDREP option I am able to remove " and || but how to stop copying once it has encountered | and move copy to next line.

//STEP0001 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=FILE1,DISP=SHR
//SORTOUT DD DSN=FILE2,DISP=SHR
//SYSIN DD *
OPTION COPY
INREC FINDREP=(INOUT=(C'"',C'',C'|',C''))

is giving me

1234567GTYHJGDGH    Y 
45HJ8BJH   Y           
46HJ8BJH   Y           
1798BJH   Y           
96GTYHH  Y  Y         
44HJ8BJH   Y         


which is working as FINDREP is coded.

Regards..

Re: Copying Distinct Records

PostPosted: Mon Dec 17, 2012 9:09 pm
by Pandora-Box
Why nor use PARSE ? If it supports your level

Re: Copying Distinct Records

PostPosted: Mon Dec 17, 2012 9:12 pm
by shiitiizz
Hi All,

A small update:

I used PARSE to edit the data required, ( have removed quotes from i/p file using FINDREP in STEP001)...this is
working fine...
//STEP0002 EXEC  PGM=SORT                               
//SYSOUT   DD SYSOUT=*                                   
//SORTIN   DD DSN=FILE1,DISP=SHR                         
//SORTOUT  DD DSN=FILE2,DISP=SHR                         
//SYSIN    DD *                                         
        INREC PARSE=(%01=(ENDBEFR=C'|',FIXLEN=16)),     
        BUILD=(1:%01)                                   
        SORT FIELDS=(1,16,FI,A)                           
        SUM FIELDS=NONE                                 
//*                                                     


Where File1 looks like
----+----1----+----2----+----3----+----4-
1234||567||GTYHJGDGH||  ||  ||Y||       
4||5||HJ8BJH|| ||  ||Y||                 
4||6||HJ8BJH|| ||  ||Y||                 
1||7||98BJH|| ||  ||Y||                 
9||6||GTYHH||  ||Y  ||Y||               
4||4||HJ8BJH|| ||  ||Y||                 


and File 2 as
----+----1---
1           
1234         
4           
9           


However, the SORT FIELDS=(1,16,FI,A) is not working as I expected..
The result I was expecting was
1
4
9
1234

and am getting is
1
1234
4
9

Kindly correct me where I am going wrong.

Re: Copying Distinct Records

PostPosted: Mon Dec 17, 2012 11:25 pm
by dick scherrer
Hello,

Suggest you use UFF.

Re: Copying Distinct Records

PostPosted: Tue Dec 18, 2012 4:19 am
by skolusu
use the following DFSORT JCL which will give you the desired results

//STEP0100 EXEC PGM=SORT                                             
//SYSOUT   DD SYSOUT=*                                               
//SORTIN   DD *                                                       
"1234"||"567"||"GTYHJGDGH"||" " ||" " ||"Y"||                         
"4"||"5"||"HJ8BJH"||" "||" " ||"Y"||                                 
"4"||"6"||"HJ8BJH"||" "||" " ||"Y"||                                 
"1"||"7"||"98BJH"||" "||" " ||"Y"||                                   
"9"||"6"||"GTYHH"||" " ||"Y " ||"Y"||                                 
"4"||"4"||"HJ8BJH"||" "||" " ||"Y"||                                 
//SORTOUT  DD SYSOUT=*                                               
//SYSIN    DD *                                                       
  INREC PARSE=(%01=(STARTAFT=C'"',ENDBEFR=C'"',FIXLEN=16)),BUILD=(%01)
  SORT FIELDS=(1,16,UFF,A)                                           
  SUM FIELDS=NONE                                                     
//*

Re: Copying Distinct Records

PostPosted: Tue Dec 18, 2012 12:46 pm
by shiitiizz
Thanks Kolusu .. It worked ! I got my mistake :-/
Cheers :)