Page 1 of 2

copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 11:38 am
by ravindran.d
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

Re: copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 11:43 am
by ravindran.d
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

Re: copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 12:04 pm
by expat
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.

Re: copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 12:10 pm
by ravindran.d
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

Re: copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 3:14 pm
by MrSpock
- 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.

Re: copy the maultiple files in Rexx

PostPosted: Wed Jul 29, 2009 8:44 pm
by ravindran.d
Thnks Myspock

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

Thnks in advance
ravi

Re: copy the maultiple files in Rexx

PostPosted: Thu Jul 30, 2009 12:13 am
by MrSpock
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"

Re: copy the maultiple files in Rexx

PostPosted: Thu Jul 30, 2009 3:58 pm
by expat
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

Re: copy the maultiple files in Rexx

PostPosted: Thu Jul 30, 2009 4:34 pm
by ravindran.d
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

Re: copy the maultiple files in Rexx

PostPosted: Thu Jul 30, 2009 4:36 pm
by ravindran.d
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