View previous topic :: View next topic
|
Author |
Message |
Subhu_Chatterbox
New User
Joined: 25 Feb 2010 Posts: 12 Location: Hyd
|
|
|
|
Hi all,
My requirement is to count number of records from a file (GDG) and write it into a report file.
Like if input file is having 500 data it should come like, in the output file.
Date: 23/05/2010
No of records found in file : 00000500
Also for empty files it should come as 0
for counting I have used the below code.But can anyone help me to show the text 'No of records found in file' before the count?Can I use outfil for this?also I need help for the date,date could be in any format no problem.
Code i am using for count is as below,
//CTRCDS EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=Input.DATA.G0005V00,DISP=SHR
//SORTOUT DD DSN=OUTPUT.REPORT,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(10,10),RLSE,,ROUND),
// UNIT=SYSDA
//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) DIGITS(8)
/* |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hi Subhu,
You can achieve it by using below sort card:
Code: |
OPTION COPY
OUTFIL FNAMES=output1,NODETAIL,REMOVECC,
TRAILER1=(C'NO OF RECORDS FOUND IN FILE :',COUNT=(TO=ZD,LENGTH=8)) |
|
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hello Subhu,
If you need Date as well as first line you can use below sort card
Code: |
OPTION COPY
OUTFIL FNAMES=OUTPUT1,NODETAIL,REMOVECC,
TRAILER1=(C'DATE:',DATE,/,C'NO OF RECORDS FOUND IN FILE :',
COUNT=(TO=ZD,LENGTH=10)) |
|
|
Back to top |
|
|
Subhu_Chatterbox
New User
Joined: 25 Feb 2010 Posts: 12 Location: Hyd
|
|
|
|
Thanks a lot Ekta!!!
I was trying the beow one:
//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) TEXT('COUNT OF RECORDS IS ')-
DIGITS(8)
/*
for the text i want to enter and its working fine,for date I will try your code and let you know..
Regards,
Subhamita |
|
Back to top |
|
|
Subhu_Chatterbox
New User
Joined: 25 Feb 2010 Posts: 12 Location: Hyd
|
|
|
|
Hi is there any way to keep appending data in this file which I have donethe count. Because, I have to do the same for many GDG's and make a report, so the report should contain like
File 1 number of records : 500
file 2 number of records : 400
.....
......
.....
file n number of records :100
Is it possible to do this in JCL without writing a cobol program? |
|
Back to top |
|
|
guptae
Moderator
Joined: 14 Oct 2005 Posts: 1208 Location: Bangalore,India
|
|
|
|
Hello Subhu,
You can achieve it by using MOD Status Subparamter for your output file as
-The data set exists and records are to be added to the end of it. The data set must be sequential.
-A new data set is to be created. |
|
Back to top |
|
|
Subhu_Chatterbox
New User
Joined: 25 Feb 2010 Posts: 12 Location: Hyd
|
|
|
|
I have some additional requirements, I need to mention database name and table name in the same report. I am using a procedure here which looks like,
//MY PROC DB=,N=,T=
//STEP1 EXEC PGM=TEST,
// PARM='SELECT * FROM &DB..&T;'
--
--
--
//CTRCDS EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SORTIN DD DSN=myprefix.&DB..&N..DATA.G0007V00,DISP=SHR
//SORTOUT DD DSN=report file,DISP=MOD
//TOOLIN DD DSN=Toolin hardcoded input,DISP=OLD
--
PEND
Now in toolding file I have written like
//TOOLIN DD *
COUNT FROM(SORTIN) WRITE(SORTOUT) TEXT('COUNT OF RECORDS IS ')-
DIGITS(8)
/*
As in procedure TOOLIN DD * could not be used directly. Now can anyone tell me how to pass database name that is &DB,Table name &T etc dynamically..
SO that the input would be ike,
Number of output in Database.Table is 500...
Please let me know if further details are required.
Thanks in advance!!! |
|
Back to top |
|
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Subhu_Chatterbox,
Why can't you do the count of records in the Unload step itself? You are just wasting resources to spin thru the whole file once again just to get the counts where it is a just a single sql statement |
|
Back to top |
|
|
Subhu_Chatterbox
New User
Joined: 25 Feb 2010 Posts: 12 Location: Hyd
|
|
|
|
But I need to make one separate file containing report for all the databases. Also I need to print the databse and table name in the output.Please suggest how can I do this. |
|
Back to top |
|
|
|