|
View previous topic :: View next topic
|
| Author |
Message |
shriya reddy Warnings : 1 New User

Joined: 05 Jun 2004 Posts: 43
|
|
|
|
I need to count the a records in a file base on my sort criteria. I have the input file as below
AAAA 1234
AAAA 2345
BBBB 2345
BBBB 4556
BBBB 5566
I need to get an output as below
AAAA 2
BBBB 3
Thanks,
Shriya |
|
| Back to top |
|
 |
ssmukul
New User
Joined: 22 Jan 2008 Posts: 19 Location: India
|
|
|
|
Hi Shriya,
Please try below jcl.
| Code: |
//ICETOOL1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//INFILE DD *
AAAA 1234
AAAA 2345
BBBB 2345
BBBB 4556
BBBB 5566
//OUFILE DD SYSOUT=*
//TOOLIN DD *
OCCURS FROM(INFILE) LIST(OUFILE) NOHEADER ON(1,4,CH) ON(VALCNT)
/* |
Thanks |
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi,
The other way to do it is -
| Code: |
SORT FIELDS=COPY
INREC OVERLAY=(10:C'01')
OUTFIL REMOVECC,NODETAIL,
BUILD=(1,13),
SECTIONS=(01,04,
TRAILER3=(01,05,06:TOT=(10,02,ZD,LENGTH=08)))
|
Thanks,
Anshul.[/quote] |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Anshul,
You don't need to "set up" your own counter like that - you can use DFSORT's built-in COUNT function like this:
| Code: |
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(1,4,
TRAILER3=(1,5,COUNT=(EDIT=(IIT))))
|
|
|
| Back to top |
|
 |
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
Hello
If in the same example if we want the output as
AAAA,3579,2
BBBB,12467,3
How would we do this ? Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ? |
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Hi,
You can do using below sort card -
| Code: |
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(01,04,
TRAILER3=(01,05,TOT=(06,04,ZD,LENGTH=08),COUNT=(EDIT=(IIT)))) |
Frank,
Hope I am correct this time. correct if there is a better way. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
No, you're not correct. If you had run your job you would see that it produces this output:
| Code: |
AAAA 3579 2
BBBB 12467 3
|
whereas the original poster asked for this output:
| Code: |
AAAA,3579,2
BBBB,12467,3
|
Do those look the same to you?
Please spend a little more time understanding what is wanted and checking your result vs what was asked for before posting. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Shriya,
What is the RECFM and LRECL of your input file?
| Quote: |
| Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ? |
Please give the starting position and length of the CH key field. Please give the starting position and length of the PD amount field.
Do you want the output as CSV (comma delimited value) records as you show in your post - can that be uploaded to an excel file? If not, show exactly what you want the output records to look like. |
|
| Back to top |
|
 |
himanshupant
New User
Joined: 21 Mar 2007 Posts: 46 Location: India
|
|
|
|
| Frank Yaeger wrote: |
Shriya,
What is the RECFM and LRECL of your input file?
| Quote: |
| Furthermore if the numric fields were in COMP-3 (packed format) and we wanted the output in simple numeric format( which can be uploaded to an excel file) how would we do this ? |
Please give the starting position and length of the CH key field. Please give the starting position and length of the PD amount field.
Do you want the output as CSV (comma delimited value) records as you show in your post - can that be uploaded to an excel file? If not, show exactly what you want the output records to look like. |
The starting position of CH key field is 1 and length is 4.
The starting position of PD field is 5 and length is 4.
I want the output file in csv format as I have shown in output and the sum fields in zoned decimal format which can be uploaded to excel document. |
|
| Back to top |
|
 |
Frank Yaeger
DFSORT Developer

Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT job like the following to do what you asked for:
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=... input file (FB)
//SORTOUT DD DSN=... output file (FB)
//SYSIN DD *
INREC OVERLAY=(9:C'00001')
SORT FIELDS=(1,4,CH,A)
SUM FIELDS=(5,4,PD,9,5,ZD)
OUTREC IFOUTLEN=18,
IFTHEN=(WHEN=INIT,
BUILD=(1,4,X,5,4,PD,EDIT=(IIIIIIT),X,9,5,ZD,EDIT=(IIIIT))),
IFTHEN=(WHEN=INIT,BUILD=(1,18,SQZ=(SHIFT=LEFT,MID=C',')))
/*
|
|
|
| Back to top |
|
 |
anshul_gugnani
New User

Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
Frank,
Will keep in mind.  |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|