Use Your PDM Options with RSE
August 4, 2004 Hey, Ted
Like many other iSeries programmers and operations people, I have for years created PDM options to improve my work life. I was delighted to learn that the WebSphere Development Studio client, which I now use for program development, includes a counterpart to PDM options. In WDSc, they’re known as user actions. Here’s an illustration.
One of my common tasks is creating a backup copy of a source physical file member before making any modifications to it. I usually rename the member, then copy it to a new member of the original name. In this way, the backup member keeps the time stamp of last modification.
To carry out the backup, I threw together a simple CL program (NEWVERC) and a command (NEWVERSION). This utility is not robust, but it serves my purpose. Here is the source code for NEWVERC.
/* This program renames a file member, then creates a new */ /* copy under the original name. */ /* CRTCLPGM PGM(xxx/NEWVERC) */ /* SRCFILE(xxx/QCLSRC) */ /* SRCMBR(NEWVERC) */ PGM PARM(&FILE &MBR &NEWNAME) DCL VAR(&FILE) TYPE(*CHAR) LEN(20) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&NEWNAME) TYPE(*CHAR) LEN(10) DCL VAR(&FILENAME) TYPE(*CHAR) LEN(10) DCL VAR(&FILELIB) TYPE(*CHAR) LEN(10) DCL VAR(&ABENDING) TYPE(*LGL) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(256) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGFLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) DCL VAR(&MSGKEY) TYPE(*CHAR) LEN(4) DCL VAR(&MSGTYPE) TYPE(*CHAR) LEN(10) DCL VAR(&PGMNAME) TYPE(*CHAR) LEN(10) DCL VAR(&RTNTYPE) TYPE(*CHAR) LEN(2) DCL VAR(&SENDER) TYPE(*CHAR) LEN(80) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ABEND)) /* Determine the name of this program. */ SNDPGMMSG MSG('Dummy message') TOPGMQ(*SAME) + MSGTYPE(*INFO) KEYVAR(&MSGKEY) RCVMSG PGMQ(*SAME) MSGTYPE(*INFO) MSGKEY(&MSGKEY) + RMV(*YES) SENDER(&SENDER) CHGVAR VAR(&PGMNAME) VALUE(%SST(&SENDER 27 10)) /* Split the qualified name */ CHGVAR VAR(&FILENAME) VALUE(%SST(&FILE 1 10)) CHGVAR VAR(&FILELIB) VALUE(%SST(&FILE 11 10)) /* Rename the member to the backup name */ RNMM FILE(&FILELIB/&FILENAME) MBR(&MBR) + NEWMBR(&NEWNAME) /* Create a new version of the member */ CPYF FROMFILE(&FILELIB/&FILENAME) + TOFILE(&FILELIB/&FILENAME) + FROMMBR(&NEWNAME) TOMBR(&MBR) MBROPT(*ADD) /* Normal end of program. Send a completion message. */ SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) + MSGDTA('Program' *BCAT &PGMNAME *BCAT + 'completed normally') MSGTYPE(*COMP) RETURN /* * Routine to handle unexpected errors */ ABEND: /* Don't let this program go into a loop here. */ IF COND(&ABENDING) THEN(RETURN) CHGVAR VAR(&ABENDING) VALUE('1') /* Look for an error message to send back to the caller. */ RCVMSG MSGTYPE(*LAST) MSGDTA(&MSGDTA) MSGID(&MSGID) + RTNTYPE(&RTNTYPE) MSGF(&MSGF) + SNDMSGFLIB(&MSGFLIB) /* Resend an error message to the caller as a diagnostic message. */ IF COND((&RTNTYPE *EQ '02') *OR (&RTNTYPE *EQ + '15') *OR (&RTNTYPE *EQ '17')) THEN(DO) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*DIAG) ENDDO /* Send an escape message to end the program abnormally */ SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) + MSGDTA('Program' *BCAT &PGMNAME *BCAT + 'ended abnormally') MSGTYPE(*ESCAPE) ENDPGM
Here is the command source code.
..+....2....+....3....+....4....+....5....+....6....+....7....+....8....+ /* =================================================================== */ /* CREATE A NEW VERSION OF A FILE MEMBER */ /* =================================================================== */ /* CRTCMD CMD(XXX/NEWVERSION) */ /* PGM(*LIBL/NEWVERC) */ /* SRCFILE(XXX/QCMDSRC) */ /* SRCMBR(NEWVERSION) */ /* =================================================================== */ CMD PROMPT('New version of a file member') PARM KWD(FILE) TYPE(QUALFILE) MIN(1) PROMPT('File') PARM KWD(MBR) TYPE(*CHAR) LEN(10) MIN(1) + PROMPT('Existing member') PARM KWD(NEWNAME) TYPE(*CHAR) LEN(10) MIN(1) + PROMPT('New name of existing member') QUALFILE: QUAL TYPE(*NAME) MIN(1) EXPR(*YES) QUAL TYPE(*NAME) MIN(1) EXPR(*YES) PROMPT('Library')
To run this command within PDM, I created PDM option NV.
|NV||?NEWVERSION FILE(&L/&F) MBR(&N)|
When I began to develop with the Remote Systems Explorer, I did not lose this utility, because I was able to create a user action to run the NEWVERSION command.
There are several places from which you can create a user action. One way is to right-click a member name under a member filter and choose User Actions, then Work with User Actions. You will be presented with the Work with User Actions dialog box. Since this user action is to work with file members, click Member action, under the New subtree. Fill in the entry blanks, and click the Create button.
If you are familiar with PDM substitutions, you will recognize the &F, &L, and &N tokens, which stand for file, library, and name. Using these substitutions causes RSE to pass the proper values for your selection to the NEWVERSION command when you run the user action.
Notice the Prompt first and Refresh after options. You need to check the Prompt first option in order to be prompted for the new member name. Clicking Refresh after causes RSE to refresh lists in which this member appears in the Remote systems navigation pane.
To execute the user action, right-click the name of the member to be backed up and choose User Actions. The defined user actions will appear in the top portion of the expanded menu. When you select the New version action, you will be prompted to fill in the parameters of the NEWVERSION command. You will be allowed to continue execution or to cancel.
Isn’t it nice to know that all that effort to create useful PDM options isn’t lost when moving development to RSE?
Thanks to Lynn for yet another tip for those of us whose WDSc skills aren’t yet what they need to be. Here are links to Lynn’s two previous tips.