Splitting the files using REXX



IBM's Command List programming language & Restructured Extended Executor

Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 11:49 am

Hi all,
I'm new to REXX.
I need to split the I/P file based on a string (Policy number) in the I/P file into multiple O/P files based on the policy number. All the records pertaining to a particular policy number should get into one O/P file. But, the number of different policies is not known before the run. The O/P files need to be allocated dynamically using a suffix in the file name. The O/P files created should be equal to the number of different policies in the Input file.
Can someone help how I can do it using REXX.

Thank you.
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting the files using REXX

 

Re: Splitting the files using REXX

Postby enrico-sorichetti » Tue Mar 23, 2010 1:16 pm

where is that You are facing problems, the logic or the code ?
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2644
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 2:22 pm

Code. I'm new to REXX. Can you please help me with the code?
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting the files using REXX

Postby MrSpock » Tue Mar 23, 2010 2:54 pm

Nireesha234 wrote:Can you please help me with the code?


We should be able to. What do you have so far?
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 3:24 pm

I don't know anything about REXX. If you can provide me from scratch, it will be very very helpful. I'm a COBOL/JCL programmer. Using COBOL or JCL, it's just practically not possible to allocate O/P files dynamically. Hence, thinking of using REXX for getting this done.
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 3:30 pm

Any good docs on file manipulation using REXX will also help.
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting the files using REXX

Postby MrSpock » Tue Mar 23, 2010 4:29 pm

Nireesha234 wrote:Using COBOL or JCL, it's just practically not possible to allocate O/P files dynamically.


It's certainly doable either way, either building dynamic JCL or using dynamic allocation calls in a COBOL program.

Let me ask. Is this a one-time ad-hoc project that you won't need to use again? How much data are you talking about here (don't forget that REXX is very inefficient for large amounts of data)? Is this going to be run in the foreground or in batch? How well-versed are you with using TSO commands?
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 4:39 pm

It's not a one time project. It's going to run in batch.
We will be having huge data; more than a 100 thousand records.
I was not aware of dynamic allocation calls in COBOL and JCL. Do you know how to use it? If it is possible with COBOL/JCL, then I would go with COBOL or JCL.
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Splitting the files using REXX

Postby MrSpock » Tue Mar 23, 2010 4:45 pm

Anyway, I guess the code would go something like this (presuming REXX running in TSO/E):

Read a record: EXECIO.
Find the policy number: POS or SUBSTR or WORDPOS and store it.
Peform the allocation of the output using TSO: ALLOCATE and FREE.
Read and write until the policy number changes: EXECIO and IF and DO.
Do the new allocation, store the new policy number, and continue until EOF.
User avatar
MrSpock
Global moderator
 
Posts: 810
Joined: Wed Jun 06, 2007 9:37 pm
Location: Raleigh NC USA
Has thanked: 0 time
Been thanked: 2 times

Re: Splitting the files using REXX

Postby Nireesha234 » Tue Mar 23, 2010 5:00 pm

Thanks, MrSpock. This is more than helpful for me. I'll start working on this and let you know how it goes.
Nireesha234
 
Posts: 10
Joined: Tue Mar 23, 2010 11:25 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post