IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Need to count Records and also display one field in output


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Thu Apr 24, 2008 8:06 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Fri Apr 25, 2008 4:32 am
Reply with quote

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
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Fri Apr 25, 2008 11:18 am
Reply with quote

Hi Anuj could you explain a little on the TOOLIN statement ?
Thanks!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Fri Apr 25, 2008 1:01 pm
Reply with quote

Hi,

I think if code worked for you, i would be keen to explain, please let me know..
Back to top
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Fri Apr 25, 2008 1:12 pm
Reply with quote

Yes Anuj
This code worked just fine with ICETOOL utility.
But I am stumped about
Code:
ON(VALCNT,U04)

Kindly explain about the control card.
Thanks a lot!
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Fri Apr 25, 2008 1:47 pm
Reply with quote

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*.


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
View user's profile Send private message
kalukakkad

New User


Joined: 10 Mar 2005
Posts: 81

PostPosted: Fri Apr 25, 2008 2:13 pm
Reply with quote

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
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Fri Apr 25, 2008 4:33 pm
Reply with quote

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 icon_cry.gif . Doesnt make sense. Could you explain why so.
Back to top
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Fri Apr 25, 2008 7:28 pm
Reply with quote

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. icon_smile.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Fri Apr 25, 2008 8:43 pm
Reply with quote

ramangouda patil wrote:
I tried with 100 odd records in the input file but the job returned zero records in the output file icon_cry.gif . Doesnt make sense. Could you explain why so.
Please show the JCL you used and the messages you received.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Sat Apr 26, 2008 2:43 am
Reply with quote

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
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Sat Apr 26, 2008 5:30 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Mon Apr 28, 2008 11:56 pm
Reply with quote

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.
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Apr 29, 2008 12:13 am
Reply with quote

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
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Tue Apr 29, 2008 9:08 am
Reply with quote

Hi Anuj
Code:
On(VALCNT,U0*)
is clear now icon_biggrin.gif

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Apr 29, 2008 11:42 am
Reply with quote

Hi,
Quote:
clear now
Good, that's like My boy... icon_smile.gif

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
Code:
ON(6,5,CH)
you would get
Quote:
the output as expected though

but if You change above ON as
Code:
ON(1,10,CH)

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... icon_smile.gif
Back to top
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Tue Apr 29, 2008 12:51 pm
Reply with quote

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 icon_idea.gif
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Apr 29, 2008 1:59 pm
Reply with quote

Hi,

Sorry, I did not get the 'message' of your previous post, please show input/ouput & the control cards.
Back to top
View user's profile Send private message
ramangouda patil

New User


Joined: 09 Apr 2008
Posts: 39
Location: India

PostPosted: Tue Apr 29, 2008 2:10 pm
Reply with quote

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
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6248
Location: Mumbai, India

PostPosted: Tue Apr 29, 2008 11:40 pm
Reply with quote

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 )

If you use
Code:
ON(10,6,CH)

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Help required to reset decimal points... DFSORT/ICETOOL 8
No new posts REXX/CMS How to place command console... CLIST & REXX 4
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Reroute print output via REXX/SDSF TSO/ISPF 6
No new posts Sorting Date Field DFSORT/ICETOOL 4
Search our Forums:

Back to Top