Page 1 of 1

SORT JCL - SORTING A VB FILE - INREC OUTREC PARSE BUILD

Posted: Thu Sep 28, 2006 1:33 pm
by ambilileela
Hi,

I want to sort a VB formatted file and remove the duplicates after summing up the amount. For e.g.. I have a file having 4 fields in it. Lets say Emp#, Empname, Account, Salary. The records are like:

36,sar,rte,456
45,amb,,698
36,sar,rte,400
45,amb,rte,600

I want to sort the above file so that my O/P looks like :

36,sar,rte,856
45,amb,,698
45,amb,rte,600

So, basically I want to get a sum of the amount fileds of the records that has the same value for all other fields.
It is easy for FB file but since my VB file does not have the same length for all the records, I am not able to do it :( . Please help.

Thanks,
Ambili.

Variable length files

Posted: Thu Sep 28, 2006 3:50 pm
by Krishna
Hi ambilileela,


My suggestion is to use cobol program to create FB file and then use SORT to get result.

we can sort VB file by giving starting position as actual starting pos + 4 in sort card.


Following Link may be useful to you

Smart DFSORT Tricks
http://www.ibm.com/servers/storage/supp ... vs/tricks/

Thanks,
Krishna

Posted: Thu Sep 28, 2006 9:12 pm
by Frank Yaeger
Actually, this is a comma separated value (CSV) file. It has fields with variable positions. It might also be a VB file but I'm guessing it's really an FB file.

You can use the following DFSORT job to do what you asked for. However, you'll need z/OS DFSORT V1R5 PTF UK90007 or DFSORT R14 PTF UK90006 (April, 2006) in order to use DFSORT's PARSE and SQZ functions. If you don't have the April, 2006 PTF, ask your System Programmer to install it (it's free). For complete details on all of the new DFSORT and ICETOOL functions available with the April, 2006 PTF, see:

www.ibm.com/servers/storage/support/sof ... /mvs/peug/

If the input file is actually VB, let me know and I'll show you how to change the job to handle that.

Code: Select all

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
36,sar,rte,456
45,amb,,698
36,sar,rte,400
45,amb,rte,600
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  INREC PARSE=(%01=(ENDBEFR=C',',FIXLEN=5),
               %02=(ENDBEFR=C',',FIXLEN=5),
               %03=(ENDBEFR=C',',FIXLEN=5),
               %04=(FIXLEN=5)),
        BUILD=(1:%01,C',',
               7:%02,C',',
              13:%03,C',',
              19:%04,UFF,TO=ZD,LENGTH=5)
  SORT FIELDS=(1,5,CH,A,7,5,CH,A,13,5,CH,A)
  SUM FIELDS=(19,5,ZD)
  OUTREC OVERLAY=(19:19,5,ZD,TO=FS,LENGTH=5,
        1:1,23,SQZ=(SHIFT=LEFT))
/*

Posted: Fri Sep 29, 2006 10:38 am
by Krishna
Thanks Frank.


Thanks,
Krishna

Posted: Fri Sep 29, 2006 11:56 am
by ambilileela
It is a VB file only. So, please let me know the code for a VB file.

Thanks,
Ambili

Posted: Fri Sep 29, 2006 8:40 pm
by Frank Yaeger
This version of the DFSORT job will work for a VB file. Remember that you need the April, 2006 DFSORT PTF. The job won't work without it.

Code: Select all

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD DSN=...    input file (VB)
//SORTOUT DD DSN=...   output file (VB)
//SYSIN    DD    *
  INREC PARSE=(%01=(ABSPOS=5,ENDBEFR=C',',FIXLEN=5),
               %02=(ENDBEFR=C',',FIXLEN=5),
               %03=(ENDBEFR=C',',FIXLEN=5),
               %04=(FIXLEN=5)),
        BUILD=(1,4,
               5:%01,C',',
              11:%02,C',',
              17:%03,C',',
              23:%04,UFF,TO=ZD,LENGTH=5)
  SORT FIELDS=(5,5,CH,A,11,5,CH,A,17,5,CH,A)
  SUM FIELDS=(23,5,ZD)
  OUTREC OVERLAY=(23:23,5,ZD,TO=FS,LENGTH=5,
        5:5,23,SQZ=(SHIFT=LEFT))
  OUTFIL VLTRIM=C' '
/*

Topic deleted by Admin

Posted: Mon Jan 25, 2016 11:08 pm
by academyindia4
<< Content deleted By Admin >>

Topic deleted by Admin

Posted: Wed Feb 03, 2016 1:07 am
by academyindia4
<< Content deleted By Admin >>