Page 1 of 1

Using DFSORT for sorting, counting, writing in trailer

PostPosted: Sat Nov 20, 2010 2:29 am
by yogeshvalhe
Hello,

I have a requirement. I have two files having the data as below:
File 1 -
A 02------------------
A 02-----------------
A 01--------
A 03000000002
B 02------------------
B 02-----------------
B 02-----------------
B 01--------
B 03000000003
C 02------------------
C 02-----------------
C 02------------------
C 02-----------------
C 02------------------
C 02-----------------
C 01--------
C 03000000006
D 02------------------
D 01--------
D 03000000001

File 2 -

D 02------------------
D 01--------
D 03000000001
B 02------------------
B 02-----------------
B 02-----------------
B 01--------
B 03000000003
F 02------------------
F 01--------
F 03000000001


here 02 is detail record, 01 is header record, 03 is trailer record
I want use DFSORT / ICETOOL to sort and sum in such a way that -
1) Merge the two files in a single file
2) The header can be used from file 1, if particular record are absent (e.g. F) in file 1 then use the header from file 2
3) From the merged file, put the total count of records for each type (e.g.A, B, C, D, F etc.) in trailer

Please let me know, how this can be done.

Thank you in advance for your help.

Thanks,
Yogi

Re: Using DFSORT for sorting, counting, writing in trailer

PostPosted: Sat Nov 20, 2010 2:50 am
by dick scherrer
Hello,

You need to show the output you want from the sampel input.

You also need to post the dsorg and lrecl of all files.

Re: Using DFSORT for sorting, counting, writing in trailer

PostPosted: Sat Nov 20, 2010 2:58 am
by yogeshvalhe
sample output

A 02------------------
A 02-----------------
A 01--------
A 03000000002
B 02------------------
B 02-----------------
B 02-----------------
B 02------------------
B 02-----------------
B 02-----------------
B 01--------
B 03000000006
C 02------------------
C 02-----------------
C 02------------------
C 02-----------------
C 02------------------
C 02-----------------
C 01--------
C 03000000006
D 02------------------
D 02------------------
D 01--------
D 03000000002
F 02------------------
F 01--------
F 03000000001

Re: Using DFSORT for sorting, counting, writing in trailer

PostPosted: Sat Nov 20, 2010 2:59 am
by yogeshvalhe
dsorg and lrecl is same for all three files.

GDG and lrecl=503

Re: Using DFSORT for sorting, counting, writing in trailer

PostPosted: Sat Nov 20, 2010 4:09 am
by Frank Yaeger
Here's a DFSORT job that will do what I think you're asking for. I assumed the files have RECFM=FB.

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file1 (FB/505)
//       DD DSN=...  input file2 (FB/505)
//SORTOUT DD DSN=...  output file (FB/505)
//SYSIN DD *
  OPTION EQUALS
  OMIT COND=(3,2,ZD,EQ,3)
  INREC IFTHEN=(WHEN=(3,2,ZD,EQ,1),OVERLAY=(506:C'99999999')),
         IFTHEN=(WHEN=(3,2,ZD,EQ,2),OVERLAY=(506:SEQNUM,8,ZD))
  SORT FIELDS=(1,1,CH,A,506,8,ZD,A)
  SUM FIELDS=NONE
  OUTFIL REMOVECC,
    BUILD=(1,505),
    SECTIONS=(1,1,
      TRAILER3=(1,1,X,C'03',COUNT-1=(M11,LENGTH=9)))
/*