Newsletters   Subscriptions  Forums  Store  Media Kit  About Us  Contact  Search   Home 
fhg
Volume 4, Number 26 -- August 4, 2004

Use Your PDM Options with RSE

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.


Option Command
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?

--Lynn


Dear Readers:

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.

Sponsored By
GUILD COMPANIES

Special: iSeries Pocket Guide Promotion

Line your pockets with iSeries knowledge!

For a limited time, you can acquire three of Brian Kelly's popular iSeries Pocket Guides as a bundle with a 20 percent discount off list price.

The bundle includes:

  • The iSeries Pocket Database Guide, a big pocket book on native AS/400 and iSeries database development that is tutorial in nature. The book provides many valuable examples. You won't want to put down this comprehensive guide to DB2/400 when you get your hands on it.

  • The iSeries Pocket Developers' Guide, for learning and using the standard development tools available with just about every AS/400 and iSeries server.

  • The iSeries Pocket Query Guide, which has an example for just about every type of query you can imagine--from major result fields to file joins. You'll see how to do it with examples that you'll use over and over again.

These three books represent a $167 value, and this
wealth of knowledge is yours for $134.

Buy this book bundle from our online store today.


Editors: Howard Arner, Joe Hertvik, Ted Holt,
Shannon O'Donnell, Kevin Vandever
Managing Editor: Shannon Pastore
Contributing Editors: Joel Cochran, Wayne O. Evans, Raymond Everhart,
Bruce Guetzkow, Marc Logemann, David Morris
Publisher and Advertising Director: Jenny Thomas
Advertising Sales Representative: Kim Reed
Contact the Editors: To contact anyone on the IT Jungle Team
Go to our contacts page and send us a message.


THIS ISSUE
SPONSORED BY:

Advanced Systems Concepts
Guild Companies
WorksRight Software


BACK ISSUES

TABLE OF
CONTENTS
Create Your Own Compile Commands in WDSC

Use Your PDM Options with RSE

Admin Alert: Shutting Down OS/400 User Profiles with Activation Entries


The Four Hundred
There's a New iSeries General Manager in Town

Sun Solaris on the eServer i5?

Migration Time: Emulator Vendors Square Off

Four Hundred Stuff
Fujitsu Siemens Adds OS/400 Support to Virtual Tape Library

MAPICS to Integrate Windows-Based CRM with ERP for iSeries

Intentia Encourages Best Practices with New 'Opportunity Analyzer'

Four Hundred Monitor


Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.
Guild Companies, 50 Park Terrace East, Suite 8F, New York, NY 10034
Privacy Statement