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

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

Post Reply
ambilileela
Member
Posts: 11
Joined: Tue Jun 06, 2006 2:12 pm

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

Post by ambilileela » Thu Sep 28, 2006 1:33 pm

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.

User avatar
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Variable length files

Post by Krishna » Thu Sep 28, 2006 3:50 pm

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

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Thu Sep 28, 2006 9:12 pm

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))
/*
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
Krishna
Site Admin
Posts: 1052
Joined: Fri Jan 27, 2006 7:50 am

Post by Krishna » Fri Sep 29, 2006 10:38 am

Thanks Frank.


Thanks,
Krishna

ambilileela
Member
Posts: 11
Joined: Tue Jun 06, 2006 2:12 pm

Post by ambilileela » Fri Sep 29, 2006 11:56 am

It is a VB file only. So, please let me know the code for a VB file.

Thanks,
Ambili

User avatar
Frank Yaeger
Moderator
Posts: 812
Joined: Sat Feb 18, 2006 5:45 am
Location: San Jose, CA
Contact:

Post by Frank Yaeger » Fri Sep 29, 2006 8:40 pm

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' '
/*
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

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Jan 25, 2016 11:08 pm

<< Content deleted By Admin >>

academyindia4

Topic deleted by Admin

Post by academyindia4 » Wed Feb 03, 2016 1:07 am

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others