Page 1 of 1

creating a new member in existing pds

PostPosted: Thu Aug 27, 2009 5:25 pm
by srn123
Hi All,

I am new to rexx coding.
Could you please give me an example of how to create a new member in an existing pds and copy the contents of one pds member to the newly created pds member?

eg. I need to create a member mem1 in pds userid.rexx.exec(already exisiting pds) and copy the contents of userid.rexx.exec(mem2) to userid.rexx.exec(mem1).

Thanks!

Re: creating a new member in existing pds

PostPosted: Thu Aug 27, 2009 8:18 pm
by expat
LMCOPY expertly detailed in the ISPF manuals will do it for you.

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 10:09 am
by srn123
Thanks. It is working fine. However I have one more question. I get a ISPF Dialog error when the new member already exists in the pds. If I use the replace keyword, it is working fine but I do not want to use it as I need to show an error message if the member already exists. Please find the code below to copy mem1 to mem2 -
ADDRESS ISPEXEC
"LMINIT DATAID(INDD1) DATASET('userid.rexx.exec')"
"LMINIT DATAID(OUTDD1) DATASET('userid.rexx.exec')"
"LMCOPY FROMID("INDD1") TODATAID("OUTDD1") FROMMEM(MEM1)
TOMEM(MEM2) "
IF RC\=0 THEN
SAY 'FAILED TO COPY'
ELSE
SAY 'COPIED'
"LMFREE DATAID("INDD1")"
"LMFREE DATAID("OUTDD1")"

Could you please let me know why a ispf dialog error comes and also how to eliminate it so that I get only the message 'FAILED TO COPY'

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 11:53 am
by expat
What happens when you hit an error with your current code.

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 3:24 pm
by srn123
Below is the error screen that I get -


ISPF Dialog Error
Command ===>

******************************************************************************************
* ISRU115 *
* *
* REXX3 not replaced *
* Like-named member already exists in "to" data set. *
* *
* *
* *
* *
* *
* *
* Current dialog statement: *
* LMCOPY FROMID(ISR00002) TODATAID(ISR00003) FROMMEM(MEM1) *
* *
* Enter HELP command for further information regarding this error. *
* Press ENTER key to terminate the dialog. *
* *
* *
* *
* *
*******************************************************************************************

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 3:27 pm
by srn123
In the above post, REXX3 is actually MEM2(the member that exists already in the pds) according to my second post

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 4:59 pm
by expat
Put this at the top of your code
"ISPEXEC CONTROL ERRORS RETURN"

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 5:18 pm
by srn123
Thanks expat! it worked. Could you please let me know why the dialog error comes instead of the message 'FAILED TO COPY' and how the above line of code eliminates this?

Re: creating a new member in existing pds

PostPosted: Fri Aug 28, 2009 5:54 pm
by expat
Works OK with my code
"ISPEXEC LMCOPY FROMID("INLIB") FROMMEM("ZLMEMBER") ,   
                TODATAID("OULIB")"                       
IF RC = 0                                               
   THEN  SAY ZLMEMBER "SUCCESSFUL COPY"                 
   ELSE  SAY ZLMEMBER "COPY FAILED - RETURN CODE "RC     


Or do you mean why does the previous code eliminate the ISPF error messages.
Because it returns control to the ISPF function being actioned when an error is encountered to allow for user written error handling routines.