Page 1 of 2

COUNTING records based on group

PostPosted: Tue Sep 30, 2008 12:35 pm
by SANDHYA BUDHI
My input file have records sorted by Group ID.

Please find the format of the Input file :

Group ID      Error Code
100             00
100             00
100             01
100             02
100             02
101             00
101             00
101             02


The output file should have the count of each error id for the Group

100
00       2
01       1
02       2
101
00       2
02       1


Please help me in processing this

Re: COUNTING records based on group

PostPosted: Tue Sep 30, 2008 8:46 pm
by Frank Yaeger
You can use a DFSORT job like the following to do what you asked for:

//S1    EXEC  PGM=ICEMAN
//SYSOUT    DD  SYSOUT=*
//SORTIN DD *
100             00
100             00
100             01
100             02
100             02
101             00
101             00
101             02
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
  OPTION COPY
  OUTFIL REMOVECC,NODETAIL,
   SECTIONS=(1,3,HEADER3=(1,3),
    17,2,TRAILER3=(17,2,7:COUNT=(EDIT=(IIIT))))
/*

Re: COUNTING records based on group

PostPosted: Mon Oct 06, 2008 7:50 pm
by SANDHYA BUDHI
Thanks Frank.. :)

Re: COUNTING records based on group

PostPosted: Tue Oct 07, 2008 6:12 pm
by SANDHYA BUDHI
I got my output fine with your Sort card.. Can you explain the sort card..How it is calculating the count.
It would be very helpful for me when the same can be used in different file layouts :)

Re: COUNTING records based on group

PostPosted: Tue Oct 07, 2008 8:39 pm
by Frank Yaeger
SECTIONS=(1,3,HEADER3=(1,3),
    17,2,TRAILER3=(17,2,7:COUNT=(EDIT=(IIIT))))


SECTIONS divides the records into groups by the value in positions 1-3. TRAILER3 creates a "trailer record" for each group. COUNT gives the count of records in each group.

If you're not familiar with DFSORT and DFSORT's ICETOOL, I'd suggest reading through "z/OS DFSORT: Getting Started". It's an excellent tutorial, with lots of examples, that will show you how to use DFSORT, DFSORT's ICETOOL and DFSORT Symbols. You can access it online, along with all of the other DFSORT books, from:

http://www.ibm.com/servers/storage/supp ... tmpub.html

Re: COUNTING records based on group

PostPosted: Fri Oct 17, 2008 4:39 pm
by SANDHYA BUDHI
My input file has a LRECL "94". for the above example i have to append the count to my output file then my LRECL will change. Suppose say my count length is 9. Then my output LRECL will be "103".

When I tried excuting using the file I am getting Error.

Please find the Sort step I used:

INREC FIELDS=(1,94,9C'1')
SORT FIELDS=(11,9,ZD,A,9,2,ZD,A)
SUM FIELDS=(95,9,ZD)
OUTREC FIELDS=(1,94,95,9,ZD,TO=ZDF,94:X)

Please help me how can I solve this..

In my output file I need the details from my Input file + my count of the Error code.

Input File

20081017140000001010000002301800908294822G908294822071549431
20081017110000001010000010292100974742881G974742881867886788
20081017150000001010000260567500904605439G904605439102107687
20081017140000001010000266623500971166637G971166637002666235
20081017110000001010000472016000997166054G997166054004720160
20081017150000001010000654654700957355466E957355466100633687

In the output file i required: <count>
200810171400000010A0000002301800908294822G9082948220715494312
200810171100000010A0000010292100974742881G9747428815474747472
200810171500000010A0000260567500904605439G9046054391021077472

The count should be based on Group ID and Error code. The blue one is the count of the Errorcodes.

In the Input File for the Group ID 101 we have different Error codes 11,15,and 14.
The count should be based on Group ID and Erorr code.

Please help me in solving this..

Re: COUNTING records based on group

PostPosted: Sat Oct 18, 2008 12:22 am
by dick scherrer
Hello,

When I tried excuting using the file I am getting Error.
When an error is encountered, the diagnostic info containing the error including the message id should be posted.

Re: COUNTING records based on group

PostPosted: Sat Oct 18, 2008 2:51 am
by Frank Yaeger
OUTREC FIELDS=(1,94,95,9,ZD,TO=ZDF,94:X)


This statement is causing the error message. You are building an output record like this:

1-94: input record positions 1-94
95-103: count

But then you have 94:X but 94 is lower than the previous position of 103 which isn't allowed so that causes the error message.

Just remove 94:X, or if you want a record larger than 103 specify n:X where x is > 103.

Note: I didn't check to see if your control statements actually do what you want.

Re: COUNTING records based on group

PostPosted: Sat Oct 18, 2008 11:39 am
by SANDHYA BUDHI
Hi frank,

As you have said I removed the 94:X from the Outrec and executed the sort.

In the my output file I am getting

200810170000000010A0002732743800965347555E965347555027327438 222222222
200810171100000010A0000010292100974742881G974742881889898899 555555555
200810171200000010A0000752281500953487748G953487748101003090 222222222

I require my output file as

200810170000000010A0002732743800965347555E96534755502732743823
200810171100000010A0000010292100974742881G9747428818898988995
200810171200000010A0000752281500953487748G9534877481010030902

23,5,2 are the counts..

For group ID 101 and Error code 0 the count is 23
For Group ID 101 and Error code 11 the count is 5
For Group ID 101 and Error code 12 the count is 2
It is possible getting like this.

My input file is will be

20081017140000001010000002301800908294822G908294822071549431
20081017110000001010000010292100974742881G974742881867886788
20081017150000001010000260567500904605439G904605439102107687
20081017140000001010000266623500971166637G971166637002666235
20081017110000001010000472016000997166054G997166054004720160
20081017150000001010000654654700957355466E957355466100633687

Based on the Group ID and Error code the count should be calculated.

Please help me regarding this..

Re: COUNTING records based on group

PostPosted: Mon Oct 20, 2008 2:31 am
by Frank Yaeger
   INREC FIELDS=(1,94,9C'1')


9C'1' is '111111111'. You want C'000000001'. So your INREC statement should be:

   INREC FIELDS=(1,94,C'000000001')


But you could do the same thing more simply with these DFSORT control statements:

  OPTION ZDPRINT
  INREC OVERLAY=(95:C'000000001')     
  SORT FIELDS=(11,9,ZD,A,9,2,ZD,A)   
  SUM FIELDS=(95,9,ZD)