Split an input file into n output file dynamically
Moderators: Frank Yaeger, Moderator Group
Split an input file into n output file dynamically
Hi,
I have an input file with 21 million records.I need to split these records by 10 million records in each output file.
I have already read the posts related to this query and it worked fine.
But i need to create output file dynamically.
Ex:
If input = 21 million records,
1st output file = 10 million
2nd output file = 10 million
3rd output file = 1 million
If input = 20 million records,
1st output file = 10 million
2nd output file = 10 million
Only 2 files are created here.
And my output file naming convention is like
psa.prod.output.cyc01
psa.prod.output.cyc02
When the output file is created the file name should be cyc03,cyc04,etc..
Note:
1.The number of records in input file is unknown.
2.The number of ouput files to be created is unknown.
Thanks.
I have an input file with 21 million records.I need to split these records by 10 million records in each output file.
I have already read the posts related to this query and it worked fine.
But i need to create output file dynamically.
Ex:
If input = 21 million records,
1st output file = 10 million
2nd output file = 10 million
3rd output file = 1 million
If input = 20 million records,
1st output file = 10 million
2nd output file = 10 million
Only 2 files are created here.
And my output file naming convention is like
psa.prod.output.cyc01
psa.prod.output.cyc02
When the output file is created the file name should be cyc03,cyc04,etc..
Note:
1.The number of records in input file is unknown.
2.The number of ouput files to be created is unknown.
Thanks.
HI,
I have tried my requirement in the following way,
JCL:
1)chk whether my inp file is empty or not
2)If not empty, exec cobol pgm
COBOL:
1)open input file
2)read first record
3)perform dynamic allocation para
4)where i will move my value to the sub program
5)if allocation is success
open output file
6)increment counter by 1
7)chk if record count is < limit
8)If yes read second record.
9)If no,perform dynamic allocation para again.
I have tried my requirement in the following way,
JCL:
1)chk whether my inp file is empty or not
2)If not empty, exec cobol pgm
COBOL:
1)open input file
2)read first record
3)perform dynamic allocation para
4)where i will move my value to the sub program
5)if allocation is success
open output file
6)increment counter by 1
7)chk if record count is < limit
8)If yes read second record.
9)If no,perform dynamic allocation para again.
HI,
But i got the following error while executing the jcl
ENTERING PROCEDURE DIVISION
===== START OF PROGRAM - SAPSPL =====
ENTERING 00100-OPEN-INPUT-FILE.
EXITING 00100-OPEN-INPUT-FILE-EXIT.
ENTERING 00500-MAIN-PROCESS-PARA.
ENTERING 00600-READ-UNLD-FILE.
EXITING 00600-READ-UNLD-FILE-EXIT.
ENTERING 00700-OPEN-SPLIT-FILE-PARA.
CEE3203S The system detected an execute exception (System Completion Code=0C3). From compile unit SAPSPL at entry point SAPSPL at statement 491 at compile unit offset +00000EE2 at entry offset +00000EE2 at address 26200EE2.
491:
CALL WS77-DNALLOC-PGM USING DYNALLOC-PARMS
Can anyone guide me in this abend
Thanks,
Sharmi
But i got the following error while executing the jcl
ENTERING PROCEDURE DIVISION
===== START OF PROGRAM - SAPSPL =====
ENTERING 00100-OPEN-INPUT-FILE.
EXITING 00100-OPEN-INPUT-FILE-EXIT.
ENTERING 00500-MAIN-PROCESS-PARA.
ENTERING 00600-READ-UNLD-FILE.
EXITING 00600-READ-UNLD-FILE-EXIT.
ENTERING 00700-OPEN-SPLIT-FILE-PARA.
CEE3203S The system detected an execute exception (System Completion Code=0C3). From compile unit SAPSPL at entry point SAPSPL at statement 491 at compile unit offset +00000EE2 at entry offset +00000EE2 at address 26200EE2.
491:
CALL WS77-DNALLOC-PGM USING DYNALLOC-PARMS
Can anyone guide me in this abend
Thanks,
Sharmi
We will have trouble helping you with what you have posted. . .
Suggest you set this program aside and write a tiny program that only allocates a file dynamically.
If that fails, post the code and the failure. Someone should be able to clarify.
Once the dynamic allocation works correctly, write 1 record, clost that file, and open a second file dynamically. Write 1 reord to the second file.
Once this works, go back to the actual program.
Suggest you set this program aside and write a tiny program that only allocates a file dynamically.
If that fails, post the code and the failure. Someone should be able to clarify.
Once the dynamic allocation works correctly, write 1 record, clost that file, and open a second file dynamically. Write 1 reord to the second file.
Once this works, go back to the actual program.
Have a good one
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
SPLIT will get the 7m per.Example 6
OPTION COPY
OUTFIL FNAMES=(A1,A2,A3),SPLIT
OUTFIL FNAMES=(B1,B2,B3),SPLITBY=25
OUTFIL FNAMES=(C1,C2,C3),SPLIT1R=25
This example illustrates different ways to split 77 input records among three
OUTFIL data sets.
The first OUTFIL statement uses SPLIT to rotate the records among the three
OUTFIL data sets one record at a time. A1 will have records 1, 4, ...,76. A2 will
have records 2, 5, ...,77. A3 will have records 3, 6, ...,75. A1 will have 26 records. A2
will have 26 records. A3 will have 25 records. A1, A2 and A3 will each have
non-contiguous records.
The second OUTFIL statement uses SPLITBY=25 to rotate the records among the
three OUTFIL data sets 25 records at a time. B1 will have records 1-25 and 76-77.
B2 will have records 26-50. B3 will have records 51-75. B1 will have 27 records. B2
will have 25 records. B3 will have 25 records. B1 will have non-contiguous records.
B2 and B3 will have contiguous records.
The third OUTFIL statement uses SPLIT1R=25 to rotate the records once among the
three OUTFIL data sets 25 records at a time. C1 will have records 1-25. C2 will
have records 26-50. C3 will have records 51-77. C1 will have 25 records. C2 will
have 25 records. C3 will have 27 records. C1, C2 and C3 will have contiguous
records.
SPLITBY=10000000 will get 10m, 10m, 1m
SPLIT1=10000000 will get 10m, 10m, 1m
The difference between SPLITBY and SPLIT1 is where any surplus goes. If enough OUTILs are specified to ensure no surplus, then they will be the same. Output datasets with no data can be deleted, ADRDSSU for instance.
Thank you all for your replies.
Sorry for late reply..
Hi DikDude,
I face problem while allocating file dynamically.I am calling a utility specific in CTS..Whenever it hits CALL statement it is getting abended with S0C3..
Hi William Collins,
I tried using split1R..But my lead doesn't want files to be created and deleted unneccesarily
Thanks in advance
Sorry for late reply..
Hi DikDude,
I face problem while allocating file dynamically.I am calling a utility specific in CTS..Whenever it hits CALL statement it is getting abended with S0C3..
Hi William Collins,
I tried using split1R..But my lead doesn't want files to be created and deleted unneccesarily
Thanks in advance
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
Your lead would prefer you to spend time writing programs (which don't work yet) than using a standard utility.
If you know the number of records that are on the file, from earlier processing, then you can use that information to generate the JCL and Control Cards. I guess you can't use the INTRDR either.
If the problem with creating/deleting is the tying-up of DASD during the step, you could specify a nominal amount for the primary SPACE, and use the secondary, as though it were the primary, for the actual allocation.
SORT IO is going to be much faster than IO in a COBOL program. Client pays, I suppose.
What is CTS? What utility is being called?
Is there some reason no one is willing (or able) to get the dynamic allocation for a single file working? Is there no technical support?
The files are being created because the JCL says to create them. . . ?
Obviously, i am missing something . . .
Is there some reason no one is willing (or able) to get the dynamic allocation for a single file working? Is there no technical support?
The files are being created because the JCL says to create them. . . ?
Obviously, i am missing something . . .
Have a good one
Hi DikDude,
One more requirement to add with this..
As i said I need to split records based on the count 10 million..To add with that,
If the first 3 fields of my input say,
9999999 th record- 1 sharmi cse
1000000 th record- 1 sharmi cse
10000001 th record- 1 sharmi cse
are same then i need to write all these 3 records in my second output file. It is not fixed that only 3 records will be same.It might be any number of number of records which are same.
Please help me in this..Let me know if it is possible to do this..
Thanks a lot in advance.
One more requirement to add with this..
As i said I need to split records based on the count 10 million..To add with that,
If the first 3 fields of my input say,
9999999 th record- 1 sharmi cse
1000000 th record- 1 sharmi cse
10000001 th record- 1 sharmi cse
are same then i need to write all these 3 records in my second output file. It is not fixed that only 3 records will be same.It might be any number of number of records which are same.
Please help me in this..Let me know if it is possible to do this..
Thanks a lot in advance.
-
- Active Member
- Posts: 732
- Joined: Thu May 24, 2012 4:07 am
FREE TUTORIALS
Tutorials
Free tutorials from mainframegurukul
- JCL Tutorial
Covers all important JCL concepts. - Cobol Tutorial
This tutorials covers all Cobol Topics from STRING to COMP-3. - DB2 Tutorial
DB2 Tutorial focuses on DB2 COBOL Programming. - SORT Tutorial
This Tutorial covers all important aspects of DFSORT with examples - CICS Tutorial
This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page