<<

SYSTEM BY THOMAS BRYANT & JEFFREY CELANDER STRATEGIES ISPF/PDF Edit Macros By Example

SPF/PDF contains a useful feature that allows you to write and execute macros for use with the PDF editor. To a user, there is little difference between an ISPF edit command and an edit macro. In fact, edit macros Iare executed the same way as edit commands. You type the macro name in the command field on the edit display, along with any operands that are This article examines required, then press the ENTER key. some simple ISPF/PDF edit macros that will Edit macros allow you to create your own ■ Use the CLIST &STR function if string allow you to create your editor commands or replace existing editor data contains arithmetic or logical own editor commands commands. An extremely useful feature operators. allows an initial macro to be executed when ■ If a variable containing leading/trailing or replace existing ones. edit is invoked. This type of macro receives blanks is used in a comparison, the control after the editor has read the data, but blanks are ignored. prior to the display of the data. ■ Use the variable &LASTCC to check Inside macros, you have access to the data the return code of the previous lines being edited. You have access to cursor command. Remember that its value position and screen window locations at your is changed at the end of each command. fingertips. You can access edit modes and ■ CLIST statements must be written other related editor information. Within edit in uppercase. macros, you can access data contained outside ■ A variable must be assigned a value of the edit session using ISPF file services. before it can be used. ISPF dialog services are also available. Edit ■ A “+” or “-” at the end of a line serves macros provide raw editing power just waiting as a character. The “+” to be tapped. What makes them even more deletes leading blanks from the following powerful is that they are simple to write. line. A “-” leaves the leading blanks. This article examines some simple edit macros that can save you time. This article Macros can be written in , CLIST, assumes that you are familiar with the CLIST or compiled or assembled languages. If you language, since most elementary ISPF/PDF don’t understand everything contained in the edit macros are created using CLIST. We will macros that follow, additional information save the use of REXX and PROGRAM edit is provided in the IBM Interactive Productivity macros for a future article. Facility/Program Development Facility The following helpful hints will save the (ISPF/PDF) Edit Macros Guide. inexperienced CLIST edit macro writer from Macro lines that begin with ISREDIT are the pain and suffering we have experienced. edit commands, and are documented in the reference manual. Every edit macro must ■ CLIST does not allow mixed strings include an ISREDIT MACRO statement. The (strings with EBCDIC and DBCS CLIST PROC statement should not be coded characters). at the beginning of your macros. The last ■ The CLIST ERROR statement can be statement should be the CLIST EXIT state- used to capture any non-zero return code. ment. The EXIT statement is not required, but ■ The CLIST interprets we include it to clearly identify the end of the each statement before the statement macro. Indentation should always be used to is handed over to the editor. show the structure of the macro.

TECHNICAL SUPPORT FEBRUARY 1996 SYSTEM STRATEGIES

Figure 1: Edit Macro to Convert Figure 3: Edit Macro to Find and Highlight Words Figure 4: SB: Edit Macro to Lowercase to Uppercase Perform a Full-Screen Submit ISREDIT MACRO (WORD1 WORD2) ISREDIT EXCLUDE ALL ISREDIT MACRO ISREDIT MACRO ISREDIT RESET IF &STR(&WORD1) ^= THEN ISREDIT FIND ALL `&WORD1’ CONTROL NOFLUSH ISREDIT CAPS=ON IF &STR(&WORD2) ^= THEN ISREDIT FIND ALL `&WORD2’ ISREDIT P’<` P’>` ALL SET &ZEDSMSG = &STR(Scan Completed) ISREDIT SAVE EXIT CODE(0) SET &ZEDLMSG = &STR(Lines with &WORD1, &WORD2 remain displayed) ISREDIT (DSN) = DATAS E T ISPEXEC SETMSG MSG(ISRZ000) ISREDIT (MBR) = MEMBER EXIT CODE(0) Figure 2: Edit Macro to Convert SET &SUBDSN = &STR(&DSN.(&MBR.)) Blank Lines to Comments IF &STR(&MBR) = &STR() THEN + Figure 5: Using the SB Edit Macro SET &SUBDSN = &STR(&DSN) ISREDIT MACRO SET SYSOUTTRAP = 1 EDIT PDTOMB.UTILITY.JCL(DELETEIT) - 01.04 JOB SUBMITTED SET &XX = N SUBMIT ‘&SUBDSN’ DO WHILE &XX = N Command ===> Scroll ===> PAGE ISREDIT FIND ` 40 spaces ‘ 1 40 IKJ56250I JOB PDTOMBB(JOB04416) SUBMITTED SET &SUBRC EQ &STR(&LASTCC) SET &RETCODE = &LASTCC 000001 //PDTOMBB JOB (XXXX-XXX-XXX),’IEFBR14’,CLASS=A,MSGCLASS=X, SET SYSOUTTRAP = 0 IF &RETCODE = 0 THEN + 000002 // MSGLEVEL=(1,1),NOTIFY=PDTOMB,TYPRUN=HOLD SET &ZEDSMSG = &STR(JOB SUBMITTED) 000003 //* ISREDIT CHANGE ` ` `*’ 1 SET &ZEDLMSG = &STR(&SYSOUTLINE1) ELSE + 000004 //STEP01 EXEC PGM=IEFBR14 SET &XX = Y 000005 //SYSUT1 DD DSN=PDTOMB.OLD.FILE, ISPEXEC SETMSG MSG(ISRZ000) END 000006 // DISP=(MOD,DELETE,DELETE) EXIT CODE(1) EXIT CODE(0) 000016 // ***************************** Bottom of Data ***************************

General purpose macros are often required.These macros are IKJ56250I JOB YOURJOB(J????) passed parameters to indicate data to be processed.The macro will SUBMITTED *** generally retrieve or change information known to the editor.The ma c r o may ret u r n a simple message back to the user or alter the editor We decided to write a edit macro to do a full-screen submit. This screen display. required a bit of experimenting with the TSO SUBMIT command to The macro in Figure 1 is a classic example of a simple general see how it works. Figure 4 presents the small, but effective, edit macro p u rpose macro. Shops that use the IBM high-level A s s e m bl e r we ended up with. (ASM90) and As s e m b ler H (IEV90) sometimes run into compati b i l i t y For Figure 4, we want to sure the edit macro does not problems. The ASM90 assembler accepts lowercase characters in prematurely end due to a non-zero return code.We supply the non-comment words while the IEV90 assembler does not. CONTROL NOFLUSH to prevent flushing of the TSO input stack in Getting a program written to use the ASM90 assembler to run on this case.We will discuss the ISREDIT SAVE a little later. the IEV90 assembler requires some editing.The edit The edit macro facilities for DATASET and MEMBER will extract macro in Figure 1 does the job.The ISREDIT MACRO statement the current data set and member you are editing to build the data set starts the macro. The ISREDIT RESET statement performs the same name for the TSO SUBMIT. TSO SYSOUT trapping is used to get the function as the editor RESET command.This command will reset the JOB SUBMITTED message. The ISPF/PDF defined the short message status of all lines and delete special non-data lines. Line labels are not (&ZEDSMSG) to JOB SUBMITTED and the long message removed.The ISREDIT CAPS=ON command sets the CAPS mode to (&ZEDLMSG) to the SYSOUTLINE1 is trapped. If the user pressed ON.The next line issues a CHANGE command against all data lines HELP (PF1), see Figure 5. to convert lowercase characters to uppercase.The last line is the We prefer to set the EXIT return code to 1 so the cursor will be CLIST EXIT statement that signals the end of the macro. placed at the command line and the command line will be blanked. The macro in Fig u r e 2 illustrates the use of control logic in an edit The ISREDIT SAVE must be issued since the TSO SUBMIT goes ma c r o. This macro was crea ted to assist program m e r s to conver t bla n k against the disk copy of the data set and not the in-memory copy. lines contained in ASM90 assembler programs to comment lines for use Just recently, Tom Bryant had to edit out an ascending number by the IEV90 assemble r . The function of this macro can be rever sed to sequence.This sequence had the same column numbers for each co n ver t “ * ”o n ly lines to blank lines by simply cha n g ing the FIND com- occurrence of the .SYNC character string we use for our Platinum mand and CHANGE command arguments. This macro could also be batch processor command. All .SYNC XXX (where xxx is the mo d i f ied to conver t assembler SPACE commands to blank lines. ascending number sequence) was to be changed to QQQQ. Once this The macro in Figure 3 shows how you can use an edit macro to is done, some simple editing could be performed to change all occur- accept parameters. The EXCLUDE ALL command is also used to rences of this value. See Figures 6 and 7. illustrate how all lines in an edit session can be excluded from the dis- E a ch time we find a .SYNC stri n g, we take the current line play then included on the display by a FIND command positive ( rep resented by the .ZCSR va ri able) and use a templat e. The match. This technique shows how to center the focus on the data the t e m p l ate will unconditionally ch a n ge the four ch a ra c t e rs fro m user wants to see. columns 7 through 10 to the ch a racter string ‘QQQQ’. The fi n a l The SET &ZEDSMSG = ... statement sets the edit short message ISREDIT UP MAX command was add e d, since this data went variable, and the SET &ZEDLMSG = ... statement sets the edit long on for 10 pages or so. message variable.These two variables make up the short and long The r e are many helpful edit macros on the CBT utilities tape avai l a ble message for ISRZ000, which is used in the dialog manager service from NaSPA. Figure 8 presents a chart of all of these macros (at the SETMSG.When the macro is exited, the short message is displayed. 329 tape level). When the HELP key is pressed, the long message is displayed. On FILE 15 of the tape there is an extremely useful RESTORE Many people are annoyed by what the TSO SUBMIT command macro which will restore your pds member from disk. It is much does to their terminal screen. Most people do most things in full- q u i cker than issuing a CANCEL in your EDIT session and screen mode using ISPF/PDF.When a job is submitted for execution, re-EDITing the member. See Figure 9. the user is put into line mode while TSO submits the job and displays The tri ck to this ISPF/PDF edit macro is the query of the the three asterisks at the end. For example: DATA_CHANGED status. If this indicator is YES, then the in-storage SYSTEM STRATEGIES

Figure 6: Test Data for the Figure 7: SYNCMAC m a c ros for time-consuming SYNCMAC Edit Macro everyday tasks. In addition, the This macro changes columns 7 through 10 of .SYNC lines to QQQQ. edit macros on File 95 use many .SYNC 5 ‘COMMENTS’ of the diffe rent edit macro OTHER STATEMENTS ISREDIT MACRO OTHER STATEMENTS CONTROL NOFLUSH NOMSG NOLIST options which fit into the title of OTHER STATEMENTS LOOP: ISREDIT FIND ‘.SYNC’ this article. .SYNC 10 ‘COMMENTS’ SET CC EQ &STR(&LASTCC) The MSTATS edit macro IF &CC EQ 0 THEN + OTHER STATEMENTS (Figure 11) will place the ISPF OTHER STATEMENTS DO OTHER STATEMENTS ISREDIT LINE .ZCSR = LINE + <7,’&STR(QQQQ)’> statistics of the member you are .SYNC 15 ‘COMMENTS’ GOTO LOOP editing wherever you desire. You ETC. END indicate this by placing the letter ETC. IF &CC GT 0 THEN ISREDIT UP MAX ‘A’ after the line where you want EXIT CODE(0) the ISPF member statistics mes- s age. This is accomplished Figure 8: All CBT V329 Files that Figure 9: RESTORE through the initial use of the Contain Edit Macros This edit macro restores the disk version of the data set member being edited. ISREDIT NOPROCESS, which CBT a l l ows the user to enter line FILE ITEMS OF NOTE ISREDIT MACRO commands to be processed by a # CONTROL NOFLUSH NOLIST NOMSG f u t u re ISREDIT PRO C E S S 15 File contains some edit macros. ISREDIT (MEMBER) = MEMBER s t atement. Without using the 22 File contains some edit macros. IF &MEMBER = THEN DO 47 File contains some edit macros. SET ZEDSMSG = &STR(DATASET NOT PDS) NOPROCESS operand, you are 71 File contains some edit macros. SET ZEDLMSG = &STR(RESTORE MACRO ONLY WORKS ON PDS MEMBERS) unable to use line commands 95 This PDS is ALL edit macros! END with an edit macro. 103 File contains some edit macros. ISREDIT (CHANGED) = DATA_CHANGED Once we obtain the curren t 108 Program edit macros! IF &CHANGED = YES THEN DO 124 File contains some edit macros. ISREDIT EXCLUDE ALL da ta set and member inform at i o n , 148 File contains some edit macros. ISREDIT COPY &MEMBER BEFORE .ZFIRST we issue the ISREDIT PROC E S S 168 File contains some edit macros. ISREDIT DELETE ALL EXCLUDED DE S T to ask the user to specify 172 File contains some edit macros. SET ZEDSMSG = &STR(MEMBER RESTORED) A (after line) or B (before line). 182 File contains some edit macros. SET ZEDLMSG = &STR(MEMBER &MEMBER RESTORED FROM DISK) This indicates where the edit 270 File contains some edit macros. END 325 File contains some edit macros. ELSE DO macro output is to be placed. If 369 File contains some edit macros. SET ZEDSMSG = &STR(RESTORE NOT REQUIRED) the user does not specify A or B, 392 File contains some edit macros. SET ZEDLMSG = &STR(MEMBER &MEMBER NOT CHANGED FROM DISK) a short message is displayed. If 434 File contains some edit macros. END help is entered (PF1), a long 435 Program edit macros! ISPEXEC SETMSG (MSG(ISRZ000) 437 Program edit macros! EXIT CODE(0) message is also displayed.This 438 Program edit macros! edit macro does a LOCAT E 441 File contains some edit macros. command on the .ZDEST vari- 443 File contains some edit macros. Figure 10: TRAP able (where A or B is pointing 462 File contains some edit macros. 464 Program edit macros! Take the output of any TSO command and place it in the current edit member. to). If we have a return code of 8, we can issue short and long ISREDIT MACRO (CMDNAME) messages to the user indicating editing copy of the member is ISREDIT EXCLUDE ALL that we have an empty data set. ISREDIT LINE_AFTER .ZLAST = ‘> OUTPUT FROM TSO COMMAND : &CMDNAME <’ different from the disk copy and CONTROL ASIS We now use ISPF/PDF library a restore is required. SET &I = 1 m a n agement services (the We exclude all data lines and SET &SYSOUTTRAP = 400 ISPEXEC LM-pre fi xed com- copy in our member after the TSOEXEC &CMDNAME mands to read through our data .ZFRIRST variable (which indi- SET &BOT = &SYSOUTLINE set directory; and find our mem- DO WHILE &BOT >= &I cates the top of the data set after SET &TEMP = &&SYSOUTLINE&I ber using LMMFIND with the the ISREDIT EXCLUDE ALL ISREDIT LINE_AFTER .ZLAST = “&TEMP” STATS(YES) option). Our two operation). SET &I = &I + 1 m e s s age lines are displaye d Another method we could use END after the destination message EXIT CODE(0) to delete all lines befo re the we set (the A or B line com- copy of our disk member would mand) using the edit macro be to delete all displayed data FILE 15 of the NaSPA CBT want to up the 400 value) and a LINE_AFTER command. lines (ISREDIT DELETE ALL tape.The TRAP edit macro will small loop is crea ted to write out This last edit macro may .ZFIRST .ZLAST) and then t a ke the output of any TSO e a ch SYSOUTLINE? vari a bl e re q u i re some study to fully copy in our member from disk command and stuff it into your (wh e r e ? is 1,2,3, et c .). That ’ s all understand how it works. With a (ISREDIT COPY &MEMBER edit member.This makes JCL th e r e is to it. This edit macro may little practice, you will create BEFORE .ZFIRST). As you can creation easier. See Figure 10. be small, ne ver theless we use it ma n y new edit macros to rem o ve see, there are several ways to do The output of the TRAP edit often. Function, not size, co u n t s the drudgery involved in editing. the same thing.We encourage ma c r o will be placed at the end of in edit macros . You will also have some fun! ts you to ex p e riment with each the data due to the .ZLAST edit The last macro we will addre s s method. ma c r o keywo rd ’ s designation to is on File 95 of the tape. File 95 Another interesting edit place this line. TSO SYSOUT contains all edit macros and has macro is the TRAP macro on tr apping is used again (you might m a ny examples of using edit SYSTEM STRATEGIES

Figure 11: MSTATS Thomas Bryant was recently elected to the NaSPA This edit macro provides ISPF stats on member without leaving EDIT. Board of Directors. Additionally, he will be speaking ISREDIT MACRO NOPROCESS at NaSTEC ’96. Thomas is currently employed by ISREDIT (WORKDSN) = DATASET PLATINUM technology, inc., the open enterprise ISREDIT (MEMBER) = MEMBER SET PDSDSN = &WORKDSN management company. He has more than 18 years ISREDIT PROCESS DEST of experience in data processing, with 15 of those SET &RC = &LASTCC years as an MVS/XA/ESA systems programmer. IF &RC = 8 THEN DO SET ZEDSMSG = &STR(INDICATE POSITION) SET ZEDLMSG = &STR(MARK ‘A’ OR “B” ON LINE WHERE STAT LINE SHOULD BE INSERTE D ) ISPEXEC SETMSG MSG(ISRZ000) EXIT CODE(4) END Jeffrey Celander is a product developer for PL AT I N U M IF &LASTCC = 0 THEN DO technology, inc., the open enterprise management ISREDIT LOCATE .ZDEST SET &RC = &LASTCC co m p a n y . He has 20 years of software product devel- IF &RC = 8 THEN DO opment experience in aerospace, health care, and SET ZEDSMSG = &STR(EMPTY DATA SET ) database management. He has published articles SET ZEDLMSG = &STR(MSTATS WORKS ONLY WHEN DATA SET HAS VALID DATA AND + LINE NUMBERS) and given presentations on table-based programming. ISPEXEC SETMSG MSG(ISRZ001) EXIT CODE(12) END /* INITIALIZE DATASET */ ISPEXEC LMINIT DATAID(PDSID) DATASET(‘&PDSDSN’) ENQ(SHRW) ORG(PDSORG) ©1996 Technical Enterprises,Inc. Reprinted with permission of SET LMRC = &LASTCC IF &LMRC˜= 0 THEN DO Technical Supportma gaz i n e . For subscription inform at i o n , em a i l WRITE LMINIT FAILED - RETURN CODE &LMRC [email protected] or call 414-768-8000,Ext. 116. WRITE DATA SET IS NOT ALLOCATED OR NOT PARTITIONED EXIT CODE(8) END /* OPEN DATA SET */ ISPEXEC LMOPEN DATAID(&PDSID) OPTION(INPUT) SET LMRC = &LASTCC /* CALL EDIT WITH EACH MEMBER OF THE DATA SET AND SPECIFY THE */ /* INITIAL EDIT MACRO. */ /* BUILD MEMBER LIST AND RETURN NEXT MEMBER */ ISPEXEC LMMFIND DATAID(&PDSID) MEMBER(&MEMBER) STATS(YES) SET &P = &STR(.) SET &M1 = &STR(&MEMBER) SETIT: IF &LENGTH(&M1) LT 8 THEN DO SET &M1 = &STR(&M1&STR(_)) GOTO SETIT END SET &ST =+ &STR(&M1)&STR( &ZLVERS&P&ZLMOD &ZLCDATE + &ZLMDATE &ZLMTIME &ZLCNORC+ &ZLINORC &ZLMNORC &ZLUSER) SET &S1 = &STR( + NAME VV.MM CREATED CHANGED SIZE INIT MOD ID) SET &TLINE = &STR(MSGLINE “&S1”) SET &LLINE = &STR(MSGLINE “&ST”) ISREDIT LINE_AFTER .ZDEST = &LLINE ISREDIT LINE_AFTER .ZDEST = &TLINE END /* FREE MEMBER LIST */ ISPEXEC LMMLIST DATAID(&PDSID) OPTION(FREE) /* CLOSE DATA SET */ ISPEXEC LMCLOSE DATAID(&PDSID) /* FREE DATA ID */ ISPEXEC LMFREE DATAID(&PDSID) EXIT CODE(0)

TECHNICAL SUPPORTFEBRUARY 1996