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
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
Hi,
Code:
OCCUR FROM(IN)
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).
Code:
LIST(RPT)
RPT is the ddname for the list data set in which you want the report to be printed.
Code:
NOHEADER BLANK -
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
Code:
ON(VALCNT,U04)
to
Code:
ON(VALCNT,U01)
& check what happens, you'll get the meaning of U0*.
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 ?
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
Code:
ON(VALCNT,U01)
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
Code:
ON(VALCNT,U03)
with the input which contains 105 records, you'll get the desired output.
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.
Joined: 22 Apr 2006 Posts: 6248 Location: Mumbai, India
Hi,
Quote:
clear now
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.
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...
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
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.
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
Code:
ON(11,5,CH)
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 )