I frequently write and use ISPF edit macros. However, invoking them in foreground is time consuming. Can I use a Rexx program to run the edit macros against all, or a selection of, members of a PDS via batch?
You can use Library Management functions.
You use LMINIT to get a DATA ID for the dataset to be edited and then use the LMOPEN function to open the dataset.
- You could then use LMMLIST if you want to perform the macro on a member or members of a PDS or PDSE.
- You can then use the EDIT function specifying the macro to use/invoke, which should have an ISREDIT END or ISREDIT CANCEL.
- If LMMLIST was used the list should be freed using LMMLIST with OPTION(FREE)
- LMCLOSE should then be used to close the dataset.
- LMFREE should then be used to free the DATA ID.
The above could be done in various programming languages, although REXX would probably be the simplest.
Here's an edit macro that will run another macro against all members of a PDS:
/*REXX - Edit macro to invoke the same macro against all members */
/* in the data set being edited. */
/* Syntax: */
/* ALLMEM macro prefix */
/* macro is the name of a macro to execute. If it */
/* is a program macro, remember to specify the */
/* exclamation point before the name. */
/* */
/* prefix is an optional prefix to use when selecting */
/* members to process. for example, ISR will */
/* process all members starting with ISR. */
/* */
/* Note that the macro which this calls can have an */
/* ISREDIT END or ISREDIT CANCEL in it to avoid the display */
/*------------------------------------------------------------------*/
Address 'ISPEXEC'
'ISREDIT MACRO (WORKMAC,PREFIX)'
'ISREDIT (DATA1) = DATAID'
'ISREDIT (THISONE) = MEMBER '
Address 'ISPEXEC' 'LMOPEN DATAID('data1') OPTION(INPUT)'
parse upper var prefix prefix .
member1=''
Do Until lmrc\=0
Address 'ISPEXEC' 'LMMLIST DATAID('data1') OPTION(LIST)',
'MEMBER(MEMBER1) STATS(YES)'
lmrc = rc
If lmrc = 0 ,/* if member name returned */
& member1\=thisone ,/* and it isn't this member */
& ( ,/* and prefix check is ok... */
prefix='' ,/* No prefix specified */
| substr(member1,1,length(prefix))=prefix,/* or prefix match*/
) Then
Do /* invoke edit with specified initial macro*/
Address 'ISPEXEC' 'CONTROL ERRORS CANCEL'
Address 'ISPEXEC' 'EDIT DATAID('data1')',
'MEMBER('member1') MACRO('workmac')'
Address 'ISPEXEC' 'CONTROL ERRORS CANCEL'
End
End
Address 'ISPEXEC' 'LMMLIST DATAID('data1') OPTION(FREE)'
Address 'ISPEXEC' 'LMCLOSE DATAID('data1')'
'ISREDIT DEFINE 'workmac' MACRO CMD'
If prefix='' ,/* No prefix specified */
| substr(thisone,1,length(prefix))=prefix, /* or prefix match*/
then
'ISREDIT 'workmac /* perform macro for this member */
It's for use under ISPF View or Edit, but could be made to work in batch, but you can also fire it off and sit back whilst it runs your macro against all of a PDS, saving you from having to run it on each member manually.
来源:https://stackoverflow.com/questions/38932438/how-can-i-run-ispf-edit-macros-in-batch