Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File operations in REXX 1

Status
Not open for further replies.

leo6

Programmer
Mar 2, 2005
22
0
0
US
I was facing a problem while executing a small piece of code written in REXX on Mainframes which had file operation functions like LINES(),LINEIN() and CHAROUT()

HERE is the REXX CODE :
-------------------------------------------------
parse upper arg inpf
i=1
say i
say "dsname passed from jcl is:"
say inpf
Do while LINES(inpf)
st.i= LINEIN(inpf)
rc=CHAROUT(inpf," ",3)
if rc<> 0 then
say "Failed to replace characters"
i=i+1
End
say i-1 "lines were replaced with spaces"
exit
---------------------------------------------------


And, the JCL used to execute the REXX throws error ,
---------------------------------------------------
READY
CHREXX1 TP.ECRM.GDGDATE1
1
dsname passed from jcl is:
TP.ECRM.GDGDATE1
9 +++ Do while LINES(inpf) /**/
Error running CHREXX1, line 9: Routine not found
READY
END
----------------------------------------------------

I dont know why file functions are not recognised...
Please help !!!!
 
This is because you are trying to use desktop REXX commands on a mainframe and it doesn't like it. I think you need something like this (assuming you're changeing the first 3 characters to blanks);
Code:
parse upper arg inpf
i=1
say i
say "dsname passed from jcl is:"
say inpf
[COLOR=blue]"Alloc Fi(IO) Da('"inpf"') Shr Reu"
"Execio * DiskRU IO (Stem IO.)"[/color]
Do [COLOR=blue]i = 1 to IO.0
   IO.i = overlay('   ', IO.i, 1)[/color]
End
[COLOR=blue]"Execio * DiskW IO (Stem IO. Finis)"
"Free Fi(IO)"[/color]
say [COLOR=blue]IO.0[/color] "lines were replaced with spaces"
exit

Changes;
1 - allocate (Alloc) the file to your session
2 - read the contents (Execio DiskRU) into a stem (IO.) but leave the file open
3 - loop through total lines read (IO.0)
4 - change each line (IO.i) by overlaying 3x blank
5 - re-write the file (Execio DiskW) - this also reduces I/O by doing 1x write as CharOut writes each line individually based on the line pointer
6 - free (Free) the file from your session
7 - display total lines (IO.0) changed
 
My intention was to write

1. 2 space characters from column 3 for all records in the file.(ie, write space at column 3 and 4 in the file.)

2. 4 space characters from column 8 for all records in the file.(ie, write space at column 8,9,10,11 in the file.)

could you please help,me??

Thank you for your response.

Also,now I get the following error when I tried to execute the code,

-----------------------------------------------------
READY
CHREXX4 TP.ECRM.GDGDATE1
1
dsname passed from jcl is:
TP.ECRM.GDGDATE1
Record cannot be updated. No record from file IO has been read for update.
EXECIO error while trying to GET or PUT a record.
FILE IO NOT FREED, DATA SET IS OPEN
5 lines were replaced with spaces
READY
END ------------------------------------------------------
I would be the happiest man, if this gets done....
THANK YOU...
 
I am not sure what this error is;

"Record cannot be updated. No record from file IO has been read for update."

Is there a TSO message id associated with it? You can do a "PROF MSGID" before the "Alloc" to get an IKJ message.

Instead of this;

IO.i = overlay(' ', IO.i, 1)

you need;

IO.i = overlay(' ', IO.i, 3)
IO.i = overlay(' ', IO.i, 8)


which corrects the spaces placement, but your main problem seems to be opening the file for I/O.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top