Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
splitting a file into n number of files

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Tue Jan 10, 2006 2:37 pm    Post subject: splitting a file into n number of files
Reply with quote

Hi all,
I have one input file. The layout is in ...
01AGIA 010406
50HSN6516069S1T010804D
50HSN6516411S1T032604D
50KSN9999999S1T090905S
99000019000000000000000000000019
01PROINS010406
50ESN1040243S1T020102L
50ESN1040319S1T020188L
50ESN1040403S1T061103D
99000089000000000000000000000089
01RSC 010406
50KSN6100191S1T063003D
50KSN6201240S1T022996D
50KSN6201942S1T103103D
50PSN7604468S1T073197D
99000009000000000000000000000009

The 01 level is the HEADER for each TPA....(TPA is the field AGIA..PROINS...RSC).....now how many times we have 01 level is not sure. It can be in any numbers...say just once or thrice..or anything.What I wnt to do is ...I wnt to split this file into as many files as there are 01 levels. say if there are two 01 then this input file should get split into two files as:
1.) 01AGIA 010406
50HSN6516069S1T010804D
50HSN6516411S1T032604D
50KSN9999999S1T090905S
99000019000000000000000000000019
2) 01PROINS010406
50ESN1040243S1T020102L
50ESN1040319S1T020188L
50ESN1040403S1T061103D
99000089000000000000000000000089

else if three 01 then 3 files....i wnt to split files in such a way tht the records from 01 to 99 should come in each file of a particular TPA. Please let me know if i can do it using JCL..SORT..using some function SPLIT or something...or thru COBOL....but in cobol...plz note tht u dnt know the number of output files to be created.Also how many records are there from 01 -99 also differs...so we cant say SPLIT BY...OR COUNT AFTER....something of this sort.....

ideas are most welcome........thnks in advance...


Thanks & Regards,
Parul Dixit
Back to top
View user's profile Send private message

mak_tcs

New User


Joined: 23 Nov 2005
Posts: 69
Location: Minneapolis, MN USA

PostPosted: Tue Jan 10, 2006 3:45 pm    Post subject:
Reply with quote

Hi,

Your problem can be easily solved using REXX. Are you aware of Rexx?

you can dynamically generate as many output files as the number of 01 levels.

Just try it out. I am ready to help you further.

Thanks,
Mani
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Tue Jan 10, 2006 4:48 pm    Post subject:
Reply with quote

Thnks Mani..
But i have never used REXX....nor do i have any idea of using it..please help me out...i have one document...jst gng thru it....
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Tue Jan 10, 2006 7:38 pm    Post subject: Re: splitting a file into n number of files
Reply with quote

Hi Parul,

Hope it can be done with DFSORT... One doubt, is number of rows are fixed between two header ?

Regards,

Priyesh.
Back to top
View user's profile Send private message
MichaelKBS

New User


Joined: 10 Jan 2006
Posts: 24
Location: Germany

PostPosted: Tue Jan 10, 2006 8:10 pm    Post subject: Re: splitting a file into n number of files
Reply with quote

Hi,

you can use the IEBUPDTE-Utility to split the sequential dataset into
PDS library members.

//IEBUPD EXEC PGM=IEBUPDTE,PARM=NEW
//SYSIN DD DISP=SHR,DSN=seq-input-file
//SYSUT2 DD DISP=SHR,DSN=output-library
//SYSPRINT DD DUMMY

Before running the utility you have to insert records
into the sequential input file that separates the members to generate.
These records have to beginn like this:
./ ADD NAME=xxxxx
(where xxxxx is for the member name).

You also could change your 01-beginning records to
./ ADD NAME=01.....

I hope this will help you.
Michael
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


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

PostPosted: Tue Jan 10, 2006 9:44 pm    Post subject:
Reply with quote

You could use DFSORT's IFTHEN function to group each set of records together and then use an OUTFIL INCLUDE for each group number to write the records of that group to an output file. But if you don't know in advance how many groups you'll have, you'd need to generate the OUTFIL statements and DD statements dynamically. Though possible, this can get tricky.

For an example of using DFSORT's IFTHEN to group records, see this Smart DFSORT Trick:

http://www.ibm.com/servers/storage/support/software/sort/mvs/tricks/srtmtrck.html#d01
Back to top
View user's profile Send private message
sbalajibe

New User


Joined: 15 Aug 2005
Posts: 62

PostPosted: Wed Jan 11, 2006 9:32 am    Post subject:
Reply with quote

Hi Parul,
do u want to do it only through JCL

Balaji
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Wed Jan 11, 2006 9:49 am    Post subject: do u wnt it to do thru jcl
Reply with quote

Hi Balaji...
its not hard and fast tht i wnt to do it thru JCL only..i think i can do it thru cobol also...but again i dnt know how many output files to define...so using some VSAM logic i think i can do it..jst planing to do it thru jcl...but if u have soem other idea..please go ahead...
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Wed Jan 11, 2006 9:56 am    Post subject: Is number of rows are fixed between two header
Reply with quote

Hi Priyesh,

No nothing is fixed..neither the number of records b/w two headers...
nor the number of headers...as the number of headers depends on the number of TPA we get ....TPA...(i have mentioned in my query)....its can bbe 2...3...4...nething....
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Wed Jan 11, 2006 10:13 am    Post subject: DFSORT's IFTHEN
Reply with quote

Hi Frank,
I had a look on the doc, for the link given ..but the first example is not splitting the input file..instead it is selecting a particular type of records with required Headers......my case is different...I want all the headers...with there records ..but in different files....thnks a lot...as definetely these examples help me out to solve some of my other similar kind of problems...

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

DFSORT Moderator


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

PostPosted: Wed Jan 11, 2006 9:39 pm    Post subject:
Reply with quote

The example shows how to group the records and then do INCLUDE on the groups. Once you get the records grouped, you can split them using OUTFIL statements with INCLUDEs, e.g.



Code:

...
//GP1 DD DSN=...  output file1
//GP2 DD DSN=...  output file2
...
  OUTFIL FNAMES=GP1,INCLUDE=(p,m,ZD,EQ,+1)
  OUTFIL FNAMES=GP2,INCLUDE=(p,m,ZD,EQ,+2)
  ...


You can use IFTHEN to group the records you show.

The hard part is setting up the ddnames and OUTFIL statements for the unknown number of output files = groups. You'd need to do that dynamically and set up a job for the internal reader.

I can show you how to do it all, but I'll need some more information as follows:

1) Show me a model DD statement for your output files
2) Tell me the RECFM and LRECL of your input file
3) Run the following job and post the //SYSOUT messages:

Code:

//S1 EXEC PGM=ICEMAN
//SYSOUT DD SYSOUT=*
//SORTIN DD *
//SORTOUT DD DUMMY
//SYSIN DD *
   OPTION COPY
   INREC OVERLAY=(5:C'A')
/*
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Wed Jan 11, 2006 10:09 pm    Post subject: Re: splitting a file into n number of files
Reply with quote

Hi Parul,

Quote:
its not hard and fast tht i wnt to do it thru JCL only..i think i can do it thru cobol also...but again i dnt know how many output files to define


From COBOL way, you can read records, & raed yntil you find next header then as soon as you find next header record, insert one line (the one shown by Mr. Michael in his reply above).

Next step with the code shown by Mr. Michael, you can achieve desired results.

Regards,

Priyesh.
Back to top
View user's profile Send private message
parul

New User


Joined: 08 Apr 2005
Posts: 11
Location: mumbai

PostPosted: Thu Jan 12, 2006 5:18 pm    Post subject:
Reply with quote

Hi Frank,

1) Show me a model DD statement for your output files.
Ans) TPACSV DD DSN=QAE5.AUTOTPA.INPUT,DISP=SHR
OUTFILE DD DSN=QAE5.AUTOTPA.OUTPUT,
DISP=(NEW,CATLG,DELETE),
SPACE=(CYL,(5,1),RLSE),
DCB=(LRECL=80,RECFM=FB,BLKSIZE=0)

QAE5.AUTOTPA.OUTPUT is the file which is having the records as i have mentioned in my query..i mean records for each TPA(with multiple headers and footers). i wnt to split this file.

2) Tell me the RECFM and LRECL of your input file
Ans) LRECL is 80 and RECFM is FB.

3) Run the following job and post the //SYSOUT messages:
Ans) It gives me the following message, also it gt abend with
ABENDU0016.
SYSIN :
OPTION COPY
INREC OVERLAY=(5:C'A')
*
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000

Please let me know where I am mistaken.
Thanks!!!
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Thu Jan 12, 2006 6:39 pm    Post subject: Re: splitting a file into n number of files
Reply with quote

parul,

Quote:
WER268A INREC STATEMENT : SYNTAX ERROR
WER211B SYNCSMF CALLED BY SYNCSORT; RC=0000


Message flashed indicates you are using SYNCSORT, not DFSORT.

IFTHEN and OVERLAY are DFSORTs features not available in SYNCSORT.

Regards,

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

DFSORT Moderator


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

PostPosted: Thu Jan 12, 2006 9:26 pm    Post subject:
Reply with quote

As Priyesh says, the WER messages indicate you're using Syncsort, not DFSORT. DFSORT supports IFTHEN - Syncsort doesn't.

I'm a DFSORT developer. DFSORT and Syncsort are competitive products. I'm happy to answer questions on DFSORT and DFSORT's ICETOOL, but I don't answer questions on Syncsort.
Back to top
View user's profile Send private message
mak_tcs

New User


Joined: 23 Nov 2005
Posts: 69
Location: Minneapolis, MN USA

PostPosted: Fri Jan 13, 2006 4:03 pm    Post subject:
Reply with quote

Hi Parul,

Here is the REXX solution to your problem;

After changing the input and Output file name, just execute the following rexx.

You r only specifying the Output dataset string and actual output file will be generated as Output dataset string which you specify .num1, num2 etc.,


Code:
/***REXX****/                                             
inpdset = 'DV19.INPUT.FILE'                               
outdset = 'DV19.OUTPUT.FILE'                             
count=1                                                   
temp=1                                                   
"alloc ddn(infile) dsn('"inpdset"') shr reuse"           
"execio * diskr  infile(stem recd. finis)"               
"free ddn(infile)"                                       
do rx=1 to recd.0                                         
   lrec=recd.0                                           
   currec=recd.rx                                         
   out.temp=recd.rx                                       
   rnext=rx+1                                             
   nexrec=recd.rnext                                     
   nexrec=strip(nexrec)                                   
   lev=substr(nexrec,1,2)                                 
   lev=strip(lev)                                         
   if lev='01' | rx=lrec then                             
   do                                               
      outds=outdset||'.NUM'||count                 
      outds=strip(outds)                           
      say 'outds' outds                             
      "alloc ddn(ofile) dsn('"outds"')new ",       
      "like('"inpdset"')"                           
      "free ddn(ofile)"                             
      "alloc ddn(ofile) dsn('"outds"') shr reuse"   
      "execio * diskw  ofile(stem out. finis)"     
      "free ddn(ofile)"                             
      drop out.                                     
      temp=0                                       
      count=count+1                                 
   end                                             
   temp=temp+1                                     
end                                                 
say 'done'   
exit       


My input file:

DV19.INPUT.FILE----------------------------------------------------------

01AGIA 010406
50HSN6516069S1T010804D
50HSN6516411S1T032604D
50KSN9999999S1T090905S
99000019000000000000000000000019
01PROINS010406
50ESN1040243S1T020102L
50ESN1040319S1T020188L
50ESN1040403S1T061103D
99000089000000000000000000000089
01RSC 010406
50KSN6100191S1T063003D
50KSN6201240S1T022996D
50KSN6201942S1T103103D
50PSN7604468S1T073197D
99000009000000000000000000000009

My Output files:

DV19.OUTPUT.FILE.NUM1--------------------------------------------------------------------------
01AGIA 010406
50HSN6516069S1T010804D
50HSN6516411S1T032604D
50KSN9999999S1T090905S
99000019000000000000000000000019


DV19.OUTPUT.FILE.NUM2 --------------------------------------------------------------------------
01PROINS010406
50ESN1040243S1T020102L
50ESN1040319S1T020188L
50ESN1040403S1T061103D
99000089000000000000000000000089


DV19.OUTPUT.FILE.NUM3
------------------------------------------------------------------------
01RSC 010406
50KSN6100191S1T063003D
50KSN6201240S1T022996D
50KSN6201942S1T103103D
50PSN7604468S1T073197D
99000009000000000000000000000009



Just tell me if U face any problem with this rexx.

Thanks,
Mani
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts ISSUE IN copying Sequential file reco... thesumitk JCL & VSAM 2 Wed Dec 13, 2017 3:07 pm
No new posts File Tailoring -- Temporary dataset i... samzee71 CLIST & REXX 3 Fri Dec 01, 2017 3:12 am
No new posts Rexx - File tailoring samzee71 CLIST & REXX 10 Thu Nov 30, 2017 10:47 pm
No new posts Compare VSAM files using DFSORT pshongal DFSORT/ICETOOL 5 Thu Nov 23, 2017 10:24 am
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us