When I work at a client's location, I am often restricted to only one display device. If I am editing a source member and realize I forgot to create a printer file, for example, my choices for creating the new member are limited: I can exit the source member I am currently working on and start a new edit session for the new member, I can press the F21 key to get a command line and start SEU or PDM, or I can use the System Request menu to start a second display session and start SEU from there.
No matter which way I go, it's easy to get distracted and forget where I was in the first edit session while I'm taking care of the problem in the second. When I am exceptionally busy, I sometimes forget I even had a previous SEU edit session going and attempt to start SEU on the same member I am already editing.
To avoid this problem, I created the Edit Source (EDTSRC) utility. It allows me to run multiple SEU sessions from a command line. As I am editing one member, I can press the F21 key to get a command line, run this utility, and start editing a second member. When I exit the second member, my session resumes at the command line activated in the first member.
The EDTSRC command (Figure 9) prompts for the name of a source file, the library, the source member, the member type, and an SEU option. This utility lets me edit, browse, or print a source member. EDTSRC's command processing program (CPP), EDT01C, is shown in Figure 10.
If the member name I enter does not exist in the source file, a new member is added to the source file, and SEU starts with a blank member. If the member name I enter is already in use, SEU starts in BROWSE mode.
When I exit the SEU session, the Create Object (CRTOBJ) command is called. Source code for CRTOBJ and its CPP, CRT01C, is in Figures 11 and 12.
The relevant source file, library, and member name are passed to CRTOBJ, and I am prompted to create the object. If I specify *NO on the create parameter, control returns to EDTSRC and
then back to the original edit session. If I specify *YES on the create parameter, the appropriate CRTOBJ command, based on the source member type, is executed and sent to batch.
I added only the most commonly used CRTOBJ commands to this utility. You can easily expand this utility if you need to create other object types, such as panel groups.
Both CL programs use the Forward Program Message (FWDPGMMSG) utility, which was presented in "How to Forward Messages in CL," MC, January 1998.
- Shannon O'Donnell
This email address is being protected from spambots. You need JavaScript enabled to view it.
Figure 9: The Edit Source (EDTSRC) command
/*==============================================================*/
/* To Compile: */
/* */
/* CRTCMD CMD(XXX/CRTOBJ) PGM(XXX/CRT01C) + */
/* SRCFILE(XXX/QCLSRC) */
/* */
/*==============================================================*/
CMD PROMPT('Create Object')
PARM KWD(OBJECT) TYPE(QUAL1) MIN(1) +
PROMPT('Object Lib/Name')
PARM KWD(SRCFIL) TYPE(QUAL1) MIN(1) +
PROMPT('Source File')
PARM KWD(MEMBER) TYPE(*NAME) MIN(1) +
PROMPT('Source Member')
PARM KWD(TYPE) TYPE(QUAL2) MIN(1) PROMPT('Object +
Type')
PARM KWD(CREATE) TYPE(*CHAR) LEN(4) RSTD(*YES) +
VALUES(*YES *NO) MIN(1) PROMPT('Create +
Object')
QUAL1: QUAL TYPE(*NAME)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL)) CHOICE('Name, *LIBL, +
*CURLIB') PROMPT('Library name')
QUAL2: QUAL TYPE(*NAME) RSTD(*YES) SPCVAL((RPG) (CLP) +
(CBL) (RPGLE) (CBLLE) (PF) (LF) (CMD) (DSPF)) /*==================================================================*/
/* To Compile: */
/* */
/* CRTCLPGM PGM(XXX/CRT01C) SRCFILE(XXX/QCLSRC) */
/* */
/*==================================================================*/
PGM PARM(&OBJ_LIB &SRC_LIB &MEMBER &TYPE &CREATE)
DCL VAR(&CREATE) TYPE(*CHAR) LEN(4)
DCL VAR(&SRC_LIB) TYPE(*CHAR) LEN(20)
DCL VAR(&OBJ_LIB) TYPE(*CHAR) LEN(20)
DCL VAR(&MEMBER) TYPE(*CHAR) LEN(10)
DCL VAR(&OBJNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&OBJLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCFIL) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&TYPE) TYPE(*CHAR) LEN(10)
MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(ERROR))
Figure 10: The Edit Source (EDTSRC) command processor, EDT01C
/*===================================================================*
/* Extract Object Name and Object Library From Command Parms */
/*===================================================================*
CHGVAR VAR(&OBJNAM) VALUE(%SST(&OBJ_LIB 1 10))
CHGVAR VAR(&OBJLIB) VALUE(%SST(&OBJ_LIB 11 10))
/*===================================================================*
/* Extract Source File and Library Name From Command Parms */
/*===================================================================*
CHGVAR VAR(&SRCFIL) VALUE(%SST(&SRC_LIB 1 10))
CHGVAR VAR(&SRCLIB) VALUE(%SST(&SRC_LIB 11 10))
/*===================================================================*
/
/
/
/
/
/
/* Create Object If Selected */
/*===================================================================*
IF COND(&CREATE *EQ '*YES') THEN(DO)
IF COND(&TYPE *EQ 'RPG') THEN(SBMJOB +
CMD(CRTRPGPGM PGM(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'RPGLE') THEN(SBMJOB +
CMD(CRTBNDRPG PGM(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'CBL') THEN(SBMJOB +
CMD(CRTCBLPGM PGM(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'CBL') THEN(SBMJOB +
CMD(CRTBNDCBL PGM(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'CLP') THEN(SBMJOB +
CMD(CRTCLPGM PGM(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'PF') THEN(SBMJOB CMD(CRTPF +
FILE(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER)) +
JOB(&MEMBER))
IF COND(&TYPE *EQ 'LF') THEN(SBMJOB CMD(CRTLF +
FILE(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER)) +
JOB(&MEMBER))
IF COND(&TYPE *EQ 'DSPF') THEN(SBMJOB +
CMD(CRTDSPF FILE(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
IF COND(&TYPE *EQ 'PRTF') THEN(SBMJOB +
CMD(CRTPRTF FILE(&OBJLIB/&OBJNAM) +
SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
REPLACE(*YES)) JOB(&MEMBER))
ENDDO
RETURN /* Normal end of program */
/*===================================================================*
/*==============================================================*/
/* To compile: */
/* */
/* CRTCMD CMD(XXX/EDTSRC) PGM(XXX/EDT01C) + */
/* SRCFILE(XXX/QCMDSRC) */
/* */
/*==============================================================*/
CMD PROMPT('Edit Source Member')
PARM KWD(SRCFIL) TYPE(QUAL1) MIN(1) +
PROMPT('Source File')
PARM KWD(MEMBER) TYPE(*CHAR) LEN(10) MIN(1) +
PROMPT('Source Member')
PARM KWD(TYPE) TYPE(*CHAR) LEN(10) RSTD(*YES) +
VALUES('CMD' 'CLP' 'RPG' 'RPGLE' 'CBL' +
'CBLLE' 'DSPF' 'PF' 'LF') MIN(1) +
EXPR(*YES) CHOICE('Member Type') +
PROMPT('Source Member Type')
PARM KWD(OPTION) TYPE(*CHAR) LEN(1) RSTD(*YES) +
VALUES('2' '5' '6') MIN(1) EXPR(*YES) +
PROMPT('Edit Option')
QUAL1: QUAL TYPE(*NAME) LEN(10) RSTD(*NO)
QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) +
SPCVAL((*LIBL)) CHOICE('Name, *LIBL, +
*CURLIB') PROMPT('Library name') /*==================================================================*/
/* To Compile: */
/* */
/* CRTCLPGM PGM(XXX/EDT01C) SRCFILE(XXX/QCLSRC) */
/* */
/*==================================================================*/
PGM PARM(&SRC_LIB &MEMBER &TYPE &OPTN)
DCL VAR(&CREATE) TYPE(*CHAR) LEN(4)
DCL VAR(&SRC_LIB) TYPE(*CHAR) LEN(20)
DCL VAR(&OBJ_LIB) TYPE(*CHAR) LEN(20)
DCL VAR(&OBJNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&OBJLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCFIL) TYPE(*CHAR) LEN(10)
DCL VAR(&SRCLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&MEMBER) TYPE(*CHAR) LEN(10)
DCL VAR(&TYPE) TYPE(*CHAR) LEN(10)
DCL VAR(&OPTION) TYPE(*CHAR) LEN(6)
DCL VAR(&OPTN) TYPE(*CHAR) LEN(1)
MONMSG MSGID(CPF0000 MCH0000) EXEC(GOTO CMDLBL(ERROR))
/*===================================================================*
/* EXTRACT SOURCE FILE AND LIBRARY NAME FROM COMMAND PARMS. */
/*===================================================================*
CHGVAR VAR(&SRCFIL) VALUE(%SST(&SRC_LIB 1 10))
CHGVAR VAR(&SRCLIB) VALUE(%SST(&SRC_LIB 11 10))
/*===================================================================*
/
ERROR: FWDPGMMSG
MONMSG MSGID(CPF0000 MCH0000)
EXIT:
ENDPGM
Figure 11: The Create Object (CRTOBJ) command
Figure 12: The Create Object (CRTOBJ) command processor, CRT01C
/
/
/
/
/
/* VERIFY EXISTENCE OF SOURCE LIBRARY/SOURCE FILE */
/*===================================================================*
CHKOBJ OBJ(&SRCLIB/&SRCFIL) OBJTYPE(*FILE)
/*===================================================================*
/* VERIFY EXISTENCE OF SOURCE LIBRARY/SOURCE FILE/MEMBER */
/*===================================================================*
CHKOBJ OBJ(&SRCLIB/&SRCFIL) OBJTYPE(*FILE) +
MBR(&MEMBER)
MONMSG MSGID(CPF9815) EXEC(DO)
ADDPFM FILE(&SRCLIB/&SRCFIL) MBR(&MEMBER)
ENDDO
/*===================================================================*
/* EDIT SOURCE MEMBER */
/*===================================================================*
/
CHGVAR VAR(&OPTION) VALUE(&OPTN)
STRSEU:
STRSEU SRCFILE(&SRCLIB/&SRCFIL) SRCMBR(&MEMBER) +
TYPE(&TYPE) OPTION(&OPTION)
MONMSG MSGID(EDT9007) EXEC(DO) /* +
Source Member In Use. Use Browse Mode. */
CHGVAR VAR(&OPTION) VALUE('5')
GOTO CMDLBL(STRSEU)
ENDDO
/*===================================================================*
/
/
IF COND(&OPTION *EQ '2') THEN(DO)
CRTOBJ ??OBJECT(&SRCLIB/&MEMBER) +
??SRCFIL(&SRCLIB/&SRCFIL) +
??MEMBER(&MEMBER) ??TYPE(&TYPE) +
??CREATE(*YES) /* Only Prompt For +
Create Object If Source Member Was In +
Edit Mode.' */
ENDDO
RETURN
ERROR:
FWDPGMMSG
MONMSG MSGID(CPF0000 MCH0000)
EXIT:
ENDPGM
/* PROMPT FOR CREATE OBJECT */
/*===================================================================*
LATEST COMMENTS
MC Press Online