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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REXX to Save in View Mode

Status
Not open for further replies.

dilipkumartr

Programmer
Feb 13, 2007
4
US
Hello Everyone,

I want to create a macro to 'Save' in view mode. Basically the macro should have the following
replace '<name of the dataset>' .zf .zl
How can this be done using rexx ?
The name of the dataset in the replace should be the name of the dataset I am viewing. Also I want to execute this more like ISREDIT Macro, where I just want to enter 'VSAVE' or TSO VSAVE on the command line and the dataset should be saved.

The macro should identify the name of the dataset and use it in the replace command.
I would like to generalize this macro for both PDS members and Sequential dataset.
I want to check the return status of the replace command, before I could send the 'data saved' message.

The below code doesn't work. I get the error message - replace command not found.

"Isredit Macro NOPROCESS"
"Ispexec Control Errors Return"
address tso
"replace 'TEST.DRY9216.ABD0100.ABEND' .zf .zl"
zedsmsg='dataset saved'
zedlmsg='dataset saved'
address ispexec "SETMSG MSG(ISRZ000)"

Thanks
Dilip
 
Dilip,

I have written an edit macro to save the changes whilst in View mode. It is invoked by typing VREP on the command line. The REXX routine has,overtime become more complex e.g. using the replace will lose the original ISPF stats.

/* REXX */
"ISREDIT MACRO (iMEMBER)"
ADDRESS ISREDIT
"(zlast) = LINENUM .ZLAST"
"(zfirst) = LINENUM .ZFIRST"
"(sSESS,sJUNK) = SESSION"
if sSESS ¬= 'VIEW' then
do
msg = 'VREP does not work within 'sSESS
x = setmsg(msg)
exit
end

if zLast = 0 | zFirst = 0 then
do
msg = 'VREP does not Cater for empty files'
x = setmsg(msg)
exit
end

"(sLIB,sJUNK,sJUNK1) = DATASET"
sFILE = "'"||sLIB||"'"
x = listdsi(sFILE)
select
when sysdsorg = 'PO' then call pdsfile
when sysdsorg = 'PS' then call seqfile
otherwise
msg = 'invalid DSORG ' sysdsorg
x = setmsg(msg)
exit
end
exit
/*******/
SEQFILE:
/*******/
"REPLACE " sFILE " .ZFIRST .ZLAST"
if rc = 0 then
do
msg = 'Dataset 'sfile' replaced'
x = setmsg(msg)
end
else do
Address ispexec "GETMSG MSG("ZERRMSG") SHORTMSG(msg)"
x = setmsg(msg)
end
return
/*******/
PDSFILE:
/*******/
if iMEMBER = '' then
do
"(iMEMBER) = MEMBER"
sSetStats = 'YES'
call GetStats
end
else do
upper iMEMBER
"(sLIB,sJUNK,sJUNK1) = DATASET"
sSetStats = 'NO'
if SYSDSN("'"sLIB"("iMEMBER")'") = "OK" then
do
msg = 'Member 'iMEMBER' already exists - not REPLACEd'
x = setmsg(msg)
exit
end
end
"REPLACE " iMEMBER ".ZFIRST .ZLAST"
if rc = 0 then
do
msg = 'Member 'iMEMBER' replaced'
x = setmsg(msg)
if sSetStats = 'YES' then call SetStats
end
else do
Address ispexec "GETMSG MSG("ZERRMSG") SHORTMSG(msg)"
x = setmsg(msg)
end
return
/**************************/
GetStats:
/**************************/
address ispexec "lminit dataid(s1) dataset("sFile") enq(shr)"
address ispexec "lmopen dataid("s1") OPTION(INPUT)"
address ispexec "lmmfind dataid("s1") MEMBER("iMember") STATS(YES)"
address ispexec "lmclose dataid("s1")" kVERS = ZLVERS
kMOD = ZLMOD
if DATATYPE(kMOD) ¬= 'NUM' then
do
sSetStats = 'NO'
return
end
if kMOD < 99 THEN kMOD = kMOD + 1
kCDATE = ZLCDATE
kINORC = ZLINORC
return
/********/
SetStats:
/********/
address ispexec "lmmstats dataid("s1") MEMBER("iMember") ,
version("kVERS") MODLEVEL("kMOD") CREATED("kCDATE") INITSIZE("kINORC")"
address ispexec "lmfree dataid("s1")"
exit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top