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

Split files based on a String.


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

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Tue Aug 11, 2015 12:56 am
Reply with quote

Hi,

I have requirement to split single file into multiple files, the input file is 80 byte EDI file and input file looks like below

Code:
ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000001*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*1*X*00305
7*U*00305*000000001*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*1*X*00305
0~ST*997*000000001~AK1*RA*250~AK9*A*1*1*1~SE*4*000000001~GE*1*1~IEA*1*000000001~
ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000002*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*2*X*00305
0~ST*997*000000002~AK1*RA*252~AK9*A*1*1*1~SE*4*000000002~GE*1*2~IEA*1*000000002~
ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000003*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*3*X*00305
0~ST*997*000000003~AK1*RA*251~AK2*820*000001730~AK3*BPR*2~AK4*14*569*2~AK5*R*5~A
K9*R*1*1*0~SE*8*000000003~GE*1*3~IEA*1*000000003~                       



Whenever it encounters a string 'ISA*' at position 1,4 it has to put it into the next file and so on... So the output file should looks like below

File 1
Code:
ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000001*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*1*X*00305
7*U*00305*000000001*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*1*X*00305
0~ST*997*000000001~AK1*RA*250~AK9*A*1*1*1~SE*4*000000001~GE*1*1~IEA*1*000000001~



File2
Code:

ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000002*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*2*X*00305
0~ST*997*000000002~AK1*RA*252~AK9*A*1*1*1~SE*4*000000002~GE*1*2~IEA*1*000000002~


File3
Code:
ISA*00*          *00*          *16*055169452TST2  *12*8006670959T    *150602*091
7*U*00305*000000003*0*P*:~GS*FA*055169452TST2*NIUS271JDWRA*150602*0917*3*X*00305
0~ST*997*000000003~AK1*RA*251~AK2*820*000001730~AK3*BPR*2~AK4*14*569*2~AK5*R*5~A
K9*R*1*1*0~SE*8*000000003~GE*1*3~IEA*1*000000003~     


Could you please proivde the either a sort card or Filemgr step to do this through JCL.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Aug 11, 2015 1:02 am
Reply with quote

Do you know how many files you want ?

What is your approach ?

Have you searched the forum first?

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

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Tue Aug 11, 2015 2:33 am
Reply with quote

The number of files is based on the ISA records presented in input file. So in the above sample file there are 3 ISA records, hence I need three output files.

I already search it in the forum for similar discussion and did not find it.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Tue Aug 11, 2015 2:50 am
Reply with quote

Ok. So, do you think that Sort can actually create output files through JCL depending on the number of your input *ISA records ?

Have you really thought about it ?

Did you read this : ibmmainframes.com/about60113.html

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

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Wed Aug 12, 2015 9:34 pm
Reply with quote

Hi,

Could some please provide solution for this
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Wed Aug 12, 2015 9:44 pm
Reply with quote

Quote:
The number of files is based on the ISA records presented in input file.

What is the maximum number of ISA records that your file can have? (if there is any)

1000, 2000, .. , 10000 ?

.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 12, 2015 9:48 pm
Reply with quote

You've not really given very good answers to what you were asked.

How many ISA can there be, as a maximum? No-one is asking how many are in your example.

The principle is simple. Use WHEN=GROUP to identify your groups of records, and PUSH an ID. In OUTFIL, INCLUDE for the particular ID for each group.

However, you may be meaning you need something much more complex. We're not going to produce something and have you say "No, because...". You have to tell us everything first.
Back to top
View user's profile Send private message
krsenthil85

New User


Joined: 31 Aug 2007
Posts: 55
Location: bangalore

PostPosted: Wed Aug 12, 2015 9:52 pm
Reply with quote

Hi,

Maximum it can have upto 10 ISA in input file.
Back to top
View user's profile Send private message
RahulG31

Active User


Joined: 20 Dec 2014
Posts: 446
Location: USA

PostPosted: Wed Aug 12, 2015 10:02 pm
Reply with quote

Quote:
Ok. So, do you think that Sort can actually create output files through JCL depending on the number of your input *ISA records ?

Have you really thought about it ?

Did you read this : ibmmainframes.com/about60113.html

.

The link in my earlier post should have given you enough hints on how to proceed. If you had thought/worked on it then, you would have got the solution by now. Asking for a solution before even trying yourself (even after hints were given) is not good on your part (to put it mildly).
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Wed Aug 12, 2015 10:05 pm
Reply with quote

Code:
 OPTION COPY
 INREC IFTHEN=(WHEN=GROUP,
            BEGIN=(1,7,CH,EQ,C'ISA*00*'),
            PUSH=(81:ID=2))
 OUTFIL FNAMES=X1,INCLUDE=(81,2,CH,EQ,C'01'),
          BUILD=(1,80)
 OUTFIL FNAMES=X2,INCLUDE=(81,2,CH,EQ,C'02'),
          BUILD=(1,80)
 ...
 OUTFIL FNAMES=X9,INCLUDE=(81,2,CH,EQ,C'09'),
          BUILD=(1,80)
 OUTFIL FNAMES=XX,
          SAVE,
          BUILD=(1,80)


When you have three ISAs, you'll have seven empty files. You can delete those. There are examples of that here.

If you know how many groups there are, you can generate the code and JCL.
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 How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts PARSE Syntax for not fix length word ... JCL & VSAM 7
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
Search our Forums:

Back to Top