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

split n files dynamically


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

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 2:16 am
Reply with quote

I have a FB file with 200 bytes length with say 100 records. I have to split the into many.

I/P file:
col1
51
51
51
52
52
53
54
54
55

o/p file1:
51
51
51

o/p file2:
52
52

o/p file3:
53

o/p file 4:
54
54

o/p file 5:
55

It is not necessary that always there would be 5 output files. it depends on the number of distinct records in the i/p file.
Could some one help me with this?

regars, MS
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Apr 08, 2010 3:11 am
Reply with quote

of the 200 bytes, which constitute the same key? first 2 bytes?

by the way,
the number of distinct records in a file
is equal to
the number of records in the file.
Back to top
View user's profile Send private message
Madhu_1929

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 3:30 am
Reply with quote

dbzTHEdinosauer wrote:
of the 200 bytes, which constitute the same key? first 2 bytes?

by the way,
the number of distinct records in a file
is equal to
the number of records in the file.


Yes, the first 2 bytes is the key. What I meant by distinct records is with respect to the first 2 bytes only.
I am sorry for the confusion. In my case as explained in my first post, there should be 5 files written as we have 5 distinct col1 values.

regards, MS
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 3:40 am
Reply with quote

Will the values in the two bytes be 00 to 99 or can they be anything?

Show an example of the DD statements you want to use for the first two output files, e.g.

//OUT00 DD DSN=MYOUT00,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5)),UNIT=SYSDA
//OUT01 DD DSN=MYOUT01,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5)),UNIT=SYSDA

Are you allowed to have a job submit another job to the internal reader?
Back to top
View user's profile Send private message
Madhu_1929

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 3:49 am
Reply with quote

Frank Yaeger wrote:
Will the values in the two bytes be 00 to 99 or can they be anything?

Show an example of the DD statements you want to use for the first two output files, e.g.

//OUT00 DD DSN=MYOUT00,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5)),UNIT=SYSDA
//OUT01 DD DSN=MYOUT01,DISP=(NEW,CATLG,DELETE),
// SPACE=(CYL,(5,5)),UNIT=SYSDA

Are you allowed to have a job submit another job to the internal reader?


Hi Frank,

The values for the first two bytes will be within 00 and 99.
today my i/p file may start with 00 till 10. tomorow it may be from 44 till 77.


DD stmnts will as you have in your example. Just that it may or may not stop at OUT02, as I am not sure of the number of output files created.

We are NOT allowed to submit a job through a program or another job as OPS cannot keep track of it!

thanks, MS
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 4:12 am
Reply with quote

If you can't submit a job dynamically, then you can't allocate only the ddnames you need dynamically, so the best you can do is have DD statements for OUT00 to OUT99 hardcoded. You can use a DFSORT job like this, but you will end up with empty data sets (e.g. if there's no record with a key of 08, OUT08 will be empty).

Code:

/S1 EXEC PGM=SORT
/SYSOUT DD SYSOUT=*
/SORTIN DD DSN=...  input file (FB/200)
/OUT00 DD DSN=name00,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
/OUT01 DD DSN=name01,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
 ... repeat for 02 through 98
/OUT99 DD DSN=name99,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
/SYSIN DD *
 OPTION COPY
 OUTFIL FNAMES=OUT00,INCLUDE=(1,2,CH,EQ,C'00')
 OUTFIL FNAMES=OUT01,INCLUDE=(1,2,CH,EQ,C'01')
 ... repeat for 02 through 98
 OUTFIL FNAMES=OUT99,INCLUDE=(1,2,CH,EQ,C'99')
/*
Back to top
View user's profile Send private message
Madhu_1929

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 4:15 am
Reply with quote

Thanks Frank.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 4:46 am
Reply with quote

Does that do what you wanted?
Back to top
View user's profile Send private message
Madhu_1929

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 5:03 am
Reply with quote

It does, but just got to know that the definition of the key is 9(09) and not restricted to only 2bytes.
Also, we should not be having any empty datasets as outputs as they are FTPd to UNIX and they dont want empty files!! - this i guess can be handles through IDCAMS/DFSORT i suppose.
So, with this new requirement I am not sure how to proceed.
I suppose, this should be handled outside mainframes!
Please advice.

regards, MS
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 08, 2010 5:17 am
Reply with quote

Hello,

What might you do "outside mainframes" that cannot be accomplished on the mainframe?

How many is the maximum files that would be created in a single execution?
Back to top
View user's profile Send private message
Madhu_1929

New User


Joined: 25 May 2009
Posts: 6
Location: india

PostPosted: Thu Apr 08, 2010 5:25 am
Reply with quote

That depends on the input file. It could be 5, 10 etc..
Our guess is it should not exceed 100.
I am not sure how to get this done in mainframes!!

regards, Madhu
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 2146
Location: At my coffee table

PostPosted: Thu Apr 08, 2010 6:00 am
Reply with quote

[humor]
Dang PC bigots..... icon_cool.gif

MF ASM can do dang near anything you think your glorious small box can do, and with reliability and security unheard of on your infernal platform..... icon_evil.gif
[/humor]
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 6:12 am
Reply with quote

9(09)

So the range can be 000000000 to 999999999?

To do it with that range and to not have empty data sets, you would have to be able to dynamically create a job and submit it to the internal reader.

I could probably show you a way to create the 100 data sets, some of which could be empty. But it's quitting time here, so if you want me to show you that tomorrow, let me know. However, I don't know how you'd get rid of the empty data sets in a way that would work for you.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Apr 08, 2010 7:03 am
Reply with quote

Hello,

Quote:
I am not sure how to get this done in mainframes!!

To repeat:
Quote:
What might you do "outside mainframes" that cannot be accomplished on the mainframe?


Or do you simply mean that you don't know how to do this regardless of the environment? If you know an acceptable way to accomplish this "outside mainframes" post that solution and possibly someone can post a mainframe alternative.

If your organization prefers scheduled jobs be run rather than via the internal reader, you could create the specific jcl (i'd use a PROCedure) needed to write the files that have data. The jcl creation job and the data creation jobs would be defined as predecessor/successor jobs.
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Developer


Joined: 15 Feb 2005
Posts: 7129
Location: San Jose, CA

PostPosted: Thu Apr 08, 2010 9:56 pm
Reply with quote

Madhu,

Assuming RECFM=FB and LRECL=200 (as stated earlier) and the key is in positions 1-9, here's a DFSORT job that will split the input file into output files. However, there may be empty files.

Code:

//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//CTL2CNTL DD DSN=&&C2,UNIT=SYSDA,SPACE=(TRK,(5,5)),DISP=(,PASS)
//IN DD DSN=...  input file (FB/200)
/OUT00 DD DSN=name00,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
/OUT01 DD DSN=name01,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
 ... repeat for 02 through 98
/OUT99 DD DSN=name99,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//TOOLIN DD *
SELECT FROM(IN) TO(CTL2CNTL) ON(1,9,ZD) FIRST USING(CTL1)
COPY FROM(IN) USING(CTL2)
/*
//CTL1CNTL DD *
  OUTFIL FNAMES=CTL2CNTL,
    BUILD=(C'  OUTFIL FNAMES=OUT',SEQNUM,2,ZD,START=0,
     C',INCLUDE=(1,9,ZD,EQ,',1,9,C')',80:X)
/*


If the input records were:

Code:

999999999 R1   
000000001 R2   
000000001 R3   
000000002 R4   
000000002 R5   
999999999 R6   
000000001 R7   
000000001 R8   
999999999 R9   


OUT00 would have the 000000001 records, OUT01 would have the 000000002 records and OUT02 would have the 999999999 records. DFSORT would not write to any of the other OUTnn files.
Back to top
View user's profile Send private message
sqlcode1

Active Member


Joined: 08 Apr 2010
Posts: 577
Location: USA

PostPosted: Sat Apr 10, 2010 1:37 am
Reply with quote

Madhu,
Unless you really really want this be accomplished via ICETOOl or DFSort, why can't you use Dynamic Allocation via Cobol. You can even add some logic in cobol code to check for empty files.

You could either use PUTENV or BPXWDYN.

BPXWDYN is IBM link.
For PUTENV I have an external link and I am not sure but if I am allowed to post it here but there is plenty of material and sample code available on internet.
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 Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts Compare 2 files(F1 & F2) and writ... JCL & VSAM 8
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
Search our Forums:

Back to Top