Split an input file into n output file dynamically

In this Mainframe Forum - You can post your queries on DFSORT, ICETOOL , SyncSort & JCL Utilities

Moderators: Frank Yaeger, Moderator Group

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Split an input file into n output file dynamically

Post by sharmi » Wed Jul 17, 2013 3:46 pm

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.

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Tue Jul 23, 2013 5:06 pm

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.

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Tue Jul 23, 2013 5:47 pm

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

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed Jul 24, 2013 12:29 am

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.
Have a good one

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jul 24, 2013 2:14 am

Have you considered SPLITBY or SPLIT1R with SORT. Define more OUTFILs that you need, and delete the datasets which contain no data.

S0C3. I've never seen that one....

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed Jul 24, 2013 2:28 am

The SPLIT wanted is:
If input = 21 million records,
1st output file = 10 million
2nd output file = 10 million
3rd output file = 1 million
rather than 3 files of 7 million each.

I'd like to see the diagnostic info from the abend. . .
Have a good one

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jul 24, 2013 4:17 am

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.
SPLIT will get the 7m per.

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.

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Wed Jul 24, 2013 5:51 pm

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.. :cry:
Hi William Collins,
I tried using split1R..But my lead doesn't want files to be created and deleted unneccesarily

Thanks in advance

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Jul 24, 2013 11:29 pm

:-)

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.

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Thu Jul 25, 2013 9:45 am

Ya...You are right..Almost my requirement is complete by using splitby but with small problem..Files which i mention in outfil need not be created unless records are going to be written in it..But they are getting created..
Is there any way to avoid this..

Thanks a lot..

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Fri Jul 26, 2013 12:50 am

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 . . . :?
Have a good one

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Tue Jul 30, 2013 11:46 am

DikDude wrote: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.
This is the method i followed and it is working very fine...
Thanks a lottt...

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Wed Jul 31, 2013 1:29 am

Good to hear it is working! Thanks for the update :)

dd

sharmi
Member
Posts: 13
Joined: Wed Jul 17, 2013 3:23 pm

Post by sharmi » Wed Aug 14, 2013 12:07 pm

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.

William Collins
Active Member
Posts: 732
Joined: Thu May 24, 2012 4:07 am

Post by William Collins » Wed Aug 14, 2013 1:57 pm

Of course it is possible. Save the key of th 10,000,000th (or whatever) record, and keep writing to that output file when the key is equal to the saved key.

Post Reply

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



Other References
Mainframe Tools and others