View previous topic :: View next topic
|
Author |
Message |
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
I want to count the number of records in a file using JCL sort and need to copy them to a specific position in a file.
Please suggest how can this be done. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Welcome...
show sample records and expected output.
Quote: |
count no. of records in a file using JCL sort and need to copy them to a specific position in a file |
Your wording is not clear to me.
What is LRECL\RECFM of the file?
What is the sort product you are using? |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
I want to use simple sort to count number of records in a file. And then want to copy that count in a file at a specific position. |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
Input file: Has 11 records
Output file needs to be in the format:
TRAILER 'some date' 'some date' 000000011(this is the count of records) |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Still did not understand what is 'some date' 'some date' but below step will assist you.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
/*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,
TRAILER1=('NUMBER OF RECORDS ARE:
',COUNT=(M11,LENGTH=8))
/* |
Output
Code: |
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
NUMBER OF RECORDS ARE:00000005
|
|
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
In the output i do not want:
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
NUMBER OF RECORDS ARE:00000005
I only want:
NUMBER OF RECORDS ARE:00000005
Please tell me what changes to be made for expected output. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
use..
Code: |
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('NUMBER OF RECORDS ARE:
',COUNT=(M11,LENGTH=8))
/*
|
|
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
just change to
Code: |
OUTFIL REMOVECC,NODETAIL,
|
Gerry |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
THANKS, it is working, i am placing total count into a file. Now the requirement is to place that count at 30th position in the file. Can this sort card be changed to add the specific position? Also can i specify two files in sortin? |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Change this to....
Code: |
TRAILER1=(30:'NUMBER OF RECORDS ARE:',COUNT=(M11,LENGTH=8)) |
How many files do you have? Did you try concatenating all of them? |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
actually, i have two files........
one contain data as:
000000011
and other contain data as:
TRAILER 20100202 20100202
The output file i require is
TRAILER 20100202 20100202 000000011.
Please tell me how can i concatenate these two files in the format which is needed in output file.
Thanks
Ankita |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Ankita Maheshwari,
You have not shown how your input records look like. Now it looks like a change in requirement. Till now it was like you are trying to count the records in the input file, but it looks like the input file itself has the 'COUNT'.
Tell exactly what you're trying to do if you are looking for some useful suggestions. |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
ok.....
i count no. of records and placed them in a input file.
Now i need to concat that input file to another file.
Formats of all the file are:
File with count:
000000011
File with other data:
TRAILER 20100202 20100202
The output file should look like:
TRAILER 20100202 20100202 000000011
Please help. |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Code: |
TRAILER 20100202 20100202 |
Where is this data coming from? Looks like date fields. How do you generate this file? There may be a possiblity where you can get your final output file from your original input file itself rather than concatenating intermediate outputs.(Only if you are willing to explain more) |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
As you can see there are two files from where i am recieving the data, and the dates can only be taken from the file i have mentioned. Date file is generated after running a SQL query. This SQL query fetches the date from a table. The two input files are:
File with count:
000000011
File with other data:
TRAILER 20100202 20100202
I am not finiding a way to concat both the files this way:
TRAILER 20100202 20100202 000000011 |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
Code: |
//******************************************************
//* STEP TO COUNT NO. OF RECORDS IN A FILE
//*
//***********************************************************
//S002 EXEC PGM=ICETOOL
//IN3 DD DSN=PFC0010.EXTRACT.REPROCES.BLANK,
// DISP=SHR
//CT3 DD DSN=PFC0010.EXTRACT.REPROCES.BLANK1,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(80,(100,50),RLSE),
// AVGREC=K,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD *
COUNT FROM(IN3) WRITE(CT3)
/*
//***********************************************************
//* GENERATE OUTPUT HEADER FILE
//***********************************************************
//S004 EXEC PGM=SORT
//SORTIN DD DSN=PFC0010.EXTRACT.REPROCES.DATE,
// DISP=SHR
//SORTOUT DD DSN=PFC0010.EXTRACT.REPROCES.BLANK3.HEADER,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(80,(100,50),RLSE),
// AVGREC=K,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(3:C'HEADER',11:1,8,20:9,8,29:C'SBT')
/*
//***********************************************************
//* GENERATE OUTPUT TRAILER FILE
//*********************************************************** |
In this step i want to add one more file which contain the counts and then want to merge the file.
Code: |
//S005 EXEC PGM=SORT
//SORTIN DD DSN=PFC0010.EXTRACT.REPROCES.BLANK3.HEADER,
// DISP=SHR
//SORTOUT DD DSN=PFC0010.EXTRACT.REPROCES.TRAILER,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(80,(100,50),RLSE),
// AVGREC=K,
// DCB=(RECFM=FB,LRECL=80,BLKSIZE=0,DSORG=PS)
//SYSOUT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTREC FIELDS=(4:C'TRAILER',12:11,8,21:20,8)
/*
//********************************************************** |
Please refer this JCL |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10889 Location: italy
|
|
|
|
if You will learn to use the code tags people willing to answer will have less trouble in understanding You JCLs |
|
Back to top |
|
|
sril.krishy
Active User
Joined: 30 Jul 2005 Posts: 183 Location: hyderabad
|
|
|
|
Hi,
Search for SYMNAMES in the forum. It may help to get the desired results.
Thanks
Krishy |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Ankita Maheshwari wrote: |
As you can see there are two files from where i am recieving the data, and the dates can only be taken from the file i have mentioned. Date file is generated after running a SQL query. This SQL query fetches the date from a table. The two input files are:
File with count:
000000011
File with other data:
TRAILER 20100202 20100202
I am not finiding a way to concat both the files this way:
TRAILER 20100202 20100202 000000011 |
Ankita, there is no need of two step solution for this.
Concatenate both files(one with data, other with one record with date)
Use below step to to get desired result.
Code: |
//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD * *THIS IS YOUR DATA FILE
DETAIL RECORD 1
DETAIL RECORD 2
DETAIL RECORD 3
DETAIL RECORD 4
DETAIL RECORD 5
/*
// DD * *THIS IS YOUR DATE FILE WITH ONE RECORD
TRAILER 20100202 20100202
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=(1,26,COUNT-1=(M11,LENGTH=8)) *NOTE HERE COUNT IS SUBTRACTED
/* *BY 1
|
Output will be
Code: |
TRAILER 20100202 20100202 00000005
|
|
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Ankita Maheshwari,
SyncSort provides DB2 SQL query support since its 1.2 release. May be if you let us know what is this all about, we can offer some useful suggestions. Show us the SQL which you are running. And how are these dates related to the count which you obtain from the other file? |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
thanks, it worked fine
Just a question.................
why did we used : OUTFIL REMOVECC,NODETAIL,
Thanks
Ankita |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Ankita Maheshwari wrote: |
thanks, it worked fine
Just a question.................
why did we used : OUTFIL REMOVECC,NODETAIL,
Thanks
Ankita |
because you did not wanted detail records to come in output.. |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
thanks |
|
Back to top |
|
|
donateeye
New User
Joined: 01 Jun 2007 Posts: 62 Location: chennai
|
|
|
|
Why not try writing a simple program available in your installation (COB or PL/1) which could do the trick for you. |
|
Back to top |
|
|
Ankita Maheshwari
New User
Joined: 12 May 2010 Posts: 23 Location: Pune
|
|
|
|
actually the requirement is to do it from the JCL.......... so no need to write a COBOL program nyways.......... |
|
Back to top |
|
|
|