Page 1 of 1

editing datasets behind the scenes

PostPosted: Wed Mar 17, 2010 9:24 pm
by meowmeow
I'm trying to edit datasets using a REXX program, ISPF Services and an ISPF Edit macro but I'm not getting the desired results:
here's my calling rexx:
/*REXX*/                                                                                                 
DATASET = "my.dataset"                     
STRING = 'ABC'                                             
SAY "CALLING CHGALL MACRO"                               
ADDRESS ISPEXEC "VPUT STRING"
ADDRESS ISPEXEC "EDIT DATASET("DATASET") MACRO(CALLED)"


CALLED:
/*REXX*/                     
ADDRESS ISREDIT             
MACRO(CALLED)               
ADDRESS ISPEXEC "VGET STRING"
"C ALL STRING 'DEF'"         
"SAVE"                       
"END"                       
RETURN


I wanted to edit the dataset without actually opening it, plus it's not actually executing my macro. I'm still figuring it out but cant seem to find the answer.

Re: editing datasets behind the scenes

PostPosted: Thu Mar 18, 2010 2:13 am
by Pedro
Show us your trace information. Are there any error messages?

Re: editing datasets behind the scenes

PostPosted: Thu Mar 18, 2010 2:59 am
by dick scherrer
Hello,

i wanted to edit the dataset without actually opening it(dunno if that's possible though),
Well, if it is going to be edited, it will have to be opened one way or another. . . :)

Re: editing datasets behind the scenes

PostPosted: Thu Mar 18, 2010 8:55 am
by MrSpock
I don't know what you're using for a reference, but I've seen that code before elsewhere and it's not right. Who told you to VPUT the string? That would only be necessary in the rarest of circumstances.

Here's how I would code both the REXX exec and the ISPF Edit Macro:

/*REXX CALLING*/
dataset = "MY.DATA"
string = "ABC"
"ISPEXEC EDIT DATASET("dataset") MACRO(CALLED) PARM(string)"
Exit 0


/*REXX CALLED*/
"ISREDIT MACRO (str)"
"ISREDIT C ALL '"str"' 'DEF'"
"ISREDIT SAVE"
"ISREDIT END"
Return


or, I'd use my preferred method and save some coding:

/*REXX CALLING*/
dataset = "MY.DATA"
string = "ABC"
Queue "TOP"
Queue "C * 999999 /"string"/DEF/ ALL"
Queue "TOP"
Queue "END SAVE"
"EDIT "dataset" DATA ASIS NONUM"
Exit 0


or just use the IPOUPDTE program in batch.

Re: editing datasets behind the scenes

PostPosted: Fri Mar 19, 2010 7:49 pm
by meowmeow
Hi Mr. Spock :)
Trace Result:
3 *-* DATASET = "my.dataset"
>>> "my.dataset"
4 *-* STRING='ABC'
>>> "ATT"
5 *-* SAY "CALLING CHGALL MACRO"
>>> "CALLING CHGALL MACRO"
CALLING CHGALL MACRO
6 *-* "ISPEXEC EDIT DATASET("DATASET") MACRO(CALLED) PARM(STRING)"
>>> "ISPEXEC EDIT DATASET(my.dataset) MACRO(CALLED) PARM
(STRING)"
***
ERROR:
ISRD028
Data set not cataloged
'xx1234.my.dataset' was not found in catalog.
----------------------------------------
it is saying that is not existing coz its adding my ID to the dataset name

when i changed it to DATASET('"DATASET"'), having it enclosed in single quotes, the (my.dataset)dataset is opening(literally opened) and won't do the editing portion of the macro even if i press f3 which will take me out of the dataset. its just opening the dataset and does not do editing.

i also tried using your preferred method and here's what i got:
/*REXX*/
TRACE R
DATASET = "CA1373.EZ500B1K.ICUIIRFL"
STRING = "ABC"
ADDRESS ISPEXEC
QUEUE "TOP"
QUEUE "C * 999999 /"STRING"/DEF/ ALL"
QUEUE "TOP"
QUEUE "END SAVE"
"EDIT "DATASET" DATA ASIS NONUM"
EXIT 0


TRACE RESULT:
3 *-* DATASET = "my.dataset"
>>> "my.dataset"
4 *-* STRING = "ABC"
>>> "ABC"
5 *-* ADDRESS ISPEXEC
6 *-* QUEUE "TOP"
>>> "TOP"
7 *-* QUEUE "C * 999999 /"STRING"/DEF/ ALL"
>>> "C * 999999 /ABC/DEF/ ALL"
8 *-* QUEUE "TOP"
>>> "TOP"
9 *-* QUEUE "END SAVE"
>>> "END SAVE"
10 *-* "EDIT "DATASET" DATA ASIS NONUM"
>>> "EDIT my.dataset DATA ASIS NONUM"
***


ERROR
ISPS108

Invalid length
Parameter 'my.dataset' exceeds the allowable length.

Re: editing datasets behind the scenes

PostPosted: Fri Mar 19, 2010 8:15 pm
by MrSpock
Does the ISPF Edit macro work by itself? If you manually use ISPF Edit to edit that dataset, and then execute your macro, does it work?

As far as issues with TSO EDIT, yes, it has limitations, but it has the benefit of begin natively available in a batch environment, which is usually where you've probably used it more. As you can tell from looking at the HELP text for using it, it is meant to be user for your standard types of source libraries (JCL, PROC, ASM, COBOL, CNTL, CLIST, etc.) and doesn't work too well for data that's outside of those norms. But, you know what your data is like better than I do, so you can make your own judgement on it's usefulness to you in your environment.