Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Split files based on a String.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
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    Post subject: Split files based on a String.
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: 331
Location: USA

PostPosted: Tue Aug 11, 2015 1:02 am    Post subject: Reply to: Split files based on a String.
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    Post subject:
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: 331
Location: USA

PostPosted: Tue Aug 11, 2015 2:50 am    Post subject: Reply to: Split files based on a String.
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 : http://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    Post subject: Reply to: Split files based on a String.
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: 331
Location: USA

PostPosted: Wed Aug 12, 2015 9:44 pm    Post subject: Reply to: Split files based on a String.
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Aug 12, 2015 9:48 pm    Post subject: Reply to: Split files based on a String.
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    Post subject: Reply to: Split files based on a String.
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: 331
Location: USA

PostPosted: Wed Aug 12, 2015 10:02 pm    Post subject: Reply to: Split files based on a String.
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 : http://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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Wed Aug 12, 2015 10:05 pm    Post subject: Reply to: Split files based on a String.
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    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us