copy the maultiple files in Rexx



IBM's Command List programming language & Restructured Extended Executor

copy the maultiple files in Rexx

Postby ravindran.d » Wed Jul 29, 2009 11:38 am

hi,

i have one file like "proj.test .ps" . this file having number of files files for E.g four files

like 1) proj.test.ps1
2)proj.test.ps2
3) proj.test.ps3
4)proj.test.ps4
i want to copy these four files and put it in one output file.

Pls let us know how to copy these files through rexx.

if i get a program it really helpful for me

Thnks

ravi
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy the maultiple files in Rexx

 

Re: copy the maultiple files in Rexx

Postby ravindran.d » Wed Jul 29, 2009 11:43 am

for additional information the above four files, each file having some records i want to copy all the records in each file and stored in output file

Thanks
ravi
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy the maultiple files in Rexx

Postby expat » Wed Jul 29, 2009 12:04 pm

REXX is probably one of the worst options to copy datasets. However, it can be used to invoke programs such as SORT or IEBGENER to perform the copies, which have a much more efficient IO performance.
expat
 
Posts: 382
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

Re: copy the maultiple files in Rexx

Postby ravindran.d » Wed Jul 29, 2009 12:10 pm

Expact,

Thanks for ur suggestion

Each file having different length .i believ if it rexx code it will be easy to copy ..
if u give me sample program it will helpful for me
Thnks
Ravi
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy the maultiple files in Rexx

Postby MrSpock » Wed Jul 29, 2009 3:14 pm

- Read 'PROJ.TEST.PS' into a stem variable REXX EXECIO command.
- For each occurence of a dataset name in the stem variable: REXX DO instruction; REXX STRIP function.
- Use a TSO/E command to allocate the dataset TSO/E ALLOCATE command.
- Read each record into the data stack, write each record out from the data stack.
- Repeat for each dataset name in the stem variable.
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: copy the maultiple files in Rexx

Postby ravindran.d » Wed Jul 29, 2009 8:44 pm

Thnks Myspock

I am new to the Rexx if i get a sample code it really helpful for me .

Thnks in advance
ravi
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy the maultiple files in Rexx

Postby MrSpock » Thu Jul 30, 2009 12:13 am

1. Read a file into REXX Stem Variable:
...
"EXECIO * DISKR ddname (STEM stemname. FINIS"
...

2. Loop through a Stem Variable:
...
Do loop = 1 To stemname.0
Say "Processing stemname."loop" content is:"stemname.loop
End
...

3. Read/Write from the data stack:
...
Do Forever
"EXECIO 1 DISKR input_ddname"
If rc <> 0 Then Leave
Parse Pull record
Say "Processing record. Content is:"record
Push record
"EXECIO 1 DISKW output_ddname"
End
"EXECIO 0 DISKR input_ddname (FINIS"
...
"EXECIO 0 DISKW output_ddname (FINIS"
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: copy the maultiple files in Rexx

Postby expat » Thu Jul 30, 2009 3:58 pm

I still think that an invoked program is the better way to do this given that REXX is pretty inefficient with its IO processing. If the files are large it could take forever. Anyway, things are a smidgeon slow at the office :mrgreen:

If you do take a copy, run it with TRACE R and then you can see how it does what it does.
/* REXX *** COPY MULTIPLE DATASETS TO ONE OUTPUT- IEBGENER */
"FREE  FI(INFILES)"
"ALLOC FI(INFILES) DA('DSN with input file list') SHR"
"EXECIO * DISKR INFILES ( STEM INFS. FINIS"
IDSN = ""
DO AA = 1 TO INFS.0
  IDSN = STRIP(IDSN" '"STRIP(INFS.AA)"'")
END
"FREE  FI(SYSIN,SYSUT1,SYSUT2,SYSOUT,SYSPRINT)"
"DEL   'Your OUTPUT file'"
"ALLOC FI(SYSOUT)      SYSOUT(X)"
"ALLOC FI(SYSPRINT)    SYSOUT(X)"
"ALLOC FI(SYSIN)       DUMMY"
"ALLOC FI(SYSUT1) DA("IDSN") SHR"
"ALLOC FI(SYSUT2) DA('Your OUTPUT file') NEW TRACKS SPACE(3 3)
       RECFM(F B) LRECL(80)"
"CALL *(IEBGENER)"
"FREE  FI(SYSIN,SYSUT1,SYSUT2,SYSOUT,SYSPRINT,INFILES)"
EXIT
expat
 
Posts: 382
Joined: Sat Jun 09, 2007 3:21 pm
Has thanked: 0 time
Been thanked: 1 time

Re: copy the maultiple files in Rexx

Postby ravindran.d » Thu Jul 30, 2009 4:34 pm

hi thnks expact

i have tried wit ur code .. but i got a error like

FILE INFILES NOT FREED, IS NOT ALLOCATED
FILE SYSIN NOT FREED, IS NOT ALLOCATED
FILE SYSUT1 NOT FREED, IS NOT ALLOCATED
FILE SYSUT2 NOT FREED, IS NOT ALLOCATED
FILE SYSOUT NOT FREED, IS NOT ALLOCATED

pls let us knw ..i just copied ur code and run my system ..


Thnks in advance

regds
ravi
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Re: copy the maultiple files in Rexx

Postby ravindran.d » Thu Jul 30, 2009 4:36 pm

hi expact,

all the files are diifernt record format i believe thats y i got a error like

WER171A CONCAT DS, LRECLS NE OR RECFMS DIFF

pls let us know i am correct
ravindran.d
 
Posts: 7
Joined: Wed Jul 29, 2009 11:28 am
Has thanked: 0 time
Been thanked: 0 time

Next

Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post