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

Count from a file


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Subhu_Chatterbox

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Mar 23, 2010 5:33 pm
Reply with quote

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

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 23, 2010 5:53 pm
Reply with quote

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

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Tue Mar 23, 2010 6:09 pm
Reply with quote

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

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Mar 23, 2010 6:16 pm
Reply with quote

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

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Wed Mar 24, 2010 11:55 am
Reply with quote

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

Moderator


Joined: 14 Oct 2005
Posts: 1208
Location: Bangalore,India

PostPosted: Wed Mar 24, 2010 12:03 pm
Reply with quote

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

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Thu Apr 01, 2010 6:33 pm
Reply with quote

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

Senior Member


Joined: 07 Dec 2007
Posts: 2205
Location: San Jose

PostPosted: Thu Apr 01, 2010 9:41 pm
Reply with quote

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

New User


Joined: 25 Feb 2010
Posts: 12
Location: Hyd

PostPosted: Tue Apr 06, 2010 1:53 pm
Reply with quote

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
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Binary File format getting change whi... All Other Mainframe Topics 7
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
Search our Forums:

Back to Top