|
View previous topic :: View next topic
|
| Author |
Message |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi all
My requirement is like this :
I have an input file (LRECL =15) which has records like
A $$$$$
B $$$$$
C $$$$$
D $$$$$
E $$$$$
I have to count the number of records in the input and write it to the out put file (LRECL=13 as 8 char count and 5 char value of '$$$$$') in the form like ( in this case )
5 $$$$$
I am not able to put the '$$$$$' field from the input to the output
PS : This value '$$$$$' will be different for different files but will be the same for all records in any given file
I tried using
| Code: |
OPTION COPY
OUTFIL NODETAIL,REMOVECC,
TRAILER1=(COUNT=(M10,LENGTH=8))
OUTREC FIELDS=(9,5)
|
but I get an error saying SORTOUT has incompatible LRECL
Can anyone help me on this ? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Try this:
| Code: |
//IN DD *
A $$$$$
B $$$$$
C $$$$$
D $$$$$
E $$$$$
//RPT DD SYSOUT=*
//TOOLIN DD *
OCCUR FROM(IN) LIST(RPT) NOHEADER BLANK -
ON(3,5,CH) ON(VALCNT,U04)
/* |
|
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi Anuj could you explain a little on the TOOLIN statement ?
Thanks! |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
I think if code worked for you, i would be keen to explain, please let me know.. |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Yes Anuj
This code worked just fine with ICETOOL utility.
But I am stumped about
Kindly explain about the control card.
Thanks a lot! |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Prints each unique value for specified numeric or character fields and how many times it occurs in a separate list data set. Simple or tailored reports can be produced. The values printed can be limited to those for which the value count meets specified criteria (for example, only duplicate values or only non-duplicate values).
RPT is the ddname for the list data set in which you want the report to be printed.
No header for the report being produced is required.
| Code: |
| ON(3,5,CH) ON(VALCNT,U04) |
ON(VALCNT,U04) is a special ON field used with OCCUR to print the count of occurrences. U04 is a formatting item used to set the number of digits for the count to 4, overriding the default of 15 digits for VALCNT.
For an experiment make >=10 occurences of records in input & chnage
to
& check what happens, you'll get the meaning of U0*.
Further, you might like to visit this link in the DFSORT book ...
publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/ICE1CA10/6.9?DT=20050222160456 |
|
| Back to top |
|
 |
kalukakkad
New User
.jpg)
Joined: 10 Mar 2005 Posts: 81
|
|
|
|
This also works
//STEP01 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A $$$$$
B $$$$$
C $$$$$
D $$$$$
E $$$$$
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
INREC FIELDS=(1:C'00000001',9:1,7)
SORT FIELDS=(11,5,CH,A)
SUM FIELDS=(1,8,ZD)
OUTREC FIELDS=(1:1,8,9:11,5)
How it works
Assuming the input character positions are as follows
1234567
A $$$$$
B $$$$$
C $$$$$
D $$$$$
E $$$$$
I am adding '1' to each record at the begining in INREC and then summing up on '$$$$$'.
You get output as
00000005$$$$$ |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi Anuj
| Quote: |
| make >=10 occurences of records in input & check what happens, you'll get the meaning of U0*. |
I tried with 100 odd records in the input file but the job returned zero records in the output file . Doesnt make sense. Could you explain why so. |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Thanks kalukakkad for your solutions.
I found another way to tackle this using SORT utility
| Code: |
//SYSIN DD *
OUTFIL NODETAIL,REMOVECC,TRAILER1=(COUNT=(M11,LENGTH=8),9:3,5) |
Thank you for all your inputs. Anuj, still waiting for your reply.  |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| ramangouda patil wrote: |
I tried with 100 odd records in the input file but the job returned zero records in the output file . Doesnt make sense. Could you explain why so. |
Please show the JCL you used and the messages you received. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
| kalukakkad wrote: |
| This also works |
There can be many solutions..one such solution is
| Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
A $$$$$
B $$$$$
C $$$$$
D $$$$$
E $$$$$
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL REMOVECC,NODETAIL,
SECTIONS=(3,5,
TRAILER3=(3,6,COUNT=(EDIT=(T))))
/* |
if you modify your code as shown below, it would provide a little neat output, for the OPs' request..
| Code: |
INREC FIELDS=(1:C'01',3:1,7)
SORT FIELDS=(5,5,CH,A)
SUM FIELDS=(1,2,ZD)
OUTREC FIELDS=(1:1,2,5:5,5) |
|
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi Anuj
| Quote: |
Please show the JCL you used and the messages you received.
|
| Code: |
//PS038 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=DUPBAKER.TEST.FULLDUP,DISP=SHR
//OUT DD DSN=DUPBAKER.TEST.FULLDUP.RPT,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=15,BLKSIZE=1500),
// SPACE=(TRK,(10,5),RLSE),UNIT=TSTDA
//TOOLIN DD * OCCUR FROM(IN) LIST(OUT) NOHEADER BLANK -
ON(11,5,CH) ON(VALCNT,U01)
/*
|
And these are the messages:
| Code: |
SYNCTOOL RELEASE 1.5.3 - COPYRIGHT 2004 SYNCSORT INC.
INITIAL PROCESSING MODE IS "STOP"
"TOOLIN" INTERFACE BEING USED
OCCUR FROM(IN) LIST(OUT) NOHEADER BLANK -
ON(11,5,CH) ON(VALCNT,U01)
SYNCSORT CALLED WITH IDENTIFIER "0001"
DATA DISPLAYED ON DDNAME: OUT
DATA EXCEEDS U01 DIGITS
NUMBER OF RECORDS PROCESSED: 000000000000105
NUMBER OF SELECTED RECORDS: 000000000000001
OPERATION COMPLETED WITH RETURN CODE 0
SYNCTOOL PROCESSING COMPLETED WITH RETURN CODE 0
|
Also please note that my input may have duplicate records. Is that fine while using OCCUR ? |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Well, You are in the right direction but couldn't get the essence of
| Quote: |
| For an experiment make >=10 occurences of records in input & chnage |
Your input file contains 105 records, per this statement of SYSOUT
| Code: |
| NUMBER OF RECORDS PROCESSED: 000000000000105 |
while the code line
can deal with maximum 9 records. U01 can display upto "maximum single digit (9)" numbers of records, U02 can display upto "maximum two digit (99)" numbers of records.. & so on.
So if You use
with the input which contains 105 records, you'll get the desired output. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
| Quote: |
| Also please note that my input may have duplicate records. |
Please show the definition of duplicate by an example. What is there in input & what do you expect in output would help better. |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi Anuj
is clear now
| Quote: |
| Please show the definition of duplicate by an example |
I will have inputs like
1234 $$$$$
1234 $$$$$
3456 $$$$$
3456 $$$$$
3456 $$$$$
My output would have to be
0005 $$$$$
Well I have got the output as expected though the only concern is whether OCCUR clause has any issues with duplicate values in input. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Good, that's like My boy...
| Quote: |
| whether OCCUR clause has any issues with duplicate values in input. |
That depends on how many times "different ON field values" occur. Values that occur only once are called non-duplicate values and values that occur more than once are called duplicate values.
For the input:
| Code: |
1234 $$$$$
1234 $$$$$
3456 $$$$$
3456 $$$$$
3456 $$$$$ |
if You use
you would get
| Quote: |
| the output as expected though |
but if You change above ON as
You would get output "with duplicates", because when I 'count' on (6,5) I don't care about what is there in position 1 to 4 (no consideration for dupicatea, I'm just counting); however, for the length (1,10) the whole "OCCURence" is duplicate, and so a different output; try it...  |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi Anuj to cite my control card again
| Code: |
OCCUR FROM(IN) LIST(OUT) NOHEADER BLANK -
ON(11,5,CH) ON(VALCNT,U02)
|
Thus I think what is happening here is I put in the 'OUT' file what is present in 11:5 and I also put the count of all records (i.e., VALCNT in the format U02) from the 'IN' file.
Now as I am counting all the records from say 1:15 there will be many occurances of there being duplicates.
Quoting from ur post
| Quote: |
ON(1,10,CH)
for the length (1,10) the whole "OCCURence" is duplicate, and so a different output |
this doesnt seem to be so. Any ideas  |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Hi,
Sorry, I did not get the 'message' of your previous post, please show input/ouput & the control cards. |
|
| Back to top |
|
 |
ramangouda patil
New User

Joined: 09 Apr 2008 Posts: 39 Location: India
|
|
|
|
Hi, the input(IN) is
300000000011899
300000000011899
300000000011899
300000000111899
300000000111899
300000000511899
300000000511899
Output(OUT) is
11899 7
And control card is as in my preceding post.
As you can see rec 1,2,3 are dups as well as 4&5 and 6&7. So OCCUR clause does seem to be working perfectly for duplicates as well. |
|
| Back to top |
|
 |
Anuj Dhawan
Superior Member

Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
|
|
|
|
Well,
In the example shown above, values in position 11 to 5 are always same (11899), so for the control card
dulicates don't make any difference.
| Quote: |
| rec 1,2,3 are dups as well as 4&5 and 6&7. |
Records are duplicate only when you talk about "full length" of records, from the position 11 to 5 'point of view' nothing is duplicated; OCCUR was instructed to count the occurences for the values which 'falls' in position 11 to 5. And it did it (Output(OUT) is 11899 7 )
If you use
instead of previous control card, you would get
| Code: |
011899 3
111899 2
511899 2 |
which is same as this statement..
| Quote: |
| rec 1,2,3 are dups as well as 4&5 and 6&7. |
|
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|