Need to send a memo? You don't have to leave your terminal!
Everyone I've talked to likes the ability to send messages to another user. This feature has been in existence so long on midrange computers that it is hard to imagine not having it. As far as I know, all message commands and all message-producing user utilities send the message to the screen. Why not? That is where people are most likely to become aware of the message.
This article presents an alternative: sending the message to a printer. The message is not displayed anywhere, but printed on the device you designate. This has some immediate uses:
You can send a message to the operator of the system printer, alerting him that the Profit and Loss report is to be delivered immediately to the CFO instead of placing it outside of the computer room, as usual.
If you need to send a message to someone who has a PC and an attached PC printer, you can send a message to that person through the printer. This would work even if the recipient was momentarily switched out of PC Support and working on a PC spreadsheet program.
No more typing up a memo and faxing it to another office. If the other office has a printer device that is configured on your AS/400, you can send the memo using a printed message.
The SNDPRTMSG Command
The Send a Printed Message (SNDPRTMSG) command has four para-meters: RECEIVER, SUBJECT, PRTDEV and COPY.
The name of the person who is to receive the printed message goes in the RECEIVER parameter. You can enter up to 30 characters and the text does not have to match a user profile. This allows you to specify the person's name on the RECEIVER parameter instead of the user profile. In the SUBJECT parameter, type a brief description of the message. SUBJECT accepts a maximum of 50 characters.
The PRTDEV parameter receives the name of the printer device (as configured on the AS/400) where you want to send your message. For instance, if the printer in the Marketing office is named PRT03, that's the name you need to key in to send a message there. PRTDEV also accepts *SYSVAL (to send the message to the system printer) or *JOB (which causes the message to be printed on your job's default printer).
Finally, the COPY parameter indicates whether to print a copy of the message for your own records. The default is *NONE (no copy), but you can enter a printer device name, *SYSVAL or *JOB-the meanings are the same as in the PRTDEV parameter.
The Message
Once the preliminaries are dispensed with, the system presents a data entry subfile where you can enter up to 100 lines of text. Each line has a maximum length of 77 characters. Since each subfile page holds 20 lines, the message can span up to five screenfuls of text. Simply type in your message (rolling if you have to, to keep entering more text) and press Enter. The message (and optional copy) are printed immediately.
The Clockwork Inside
The source code for the SNDPRTMSG utility is in1 to 5. It consists of a command (1), a CL program (2), a display file (3), two printer files (4) and an RPG program (5).
The source code for the SNDPRTMSG utility is in Figures 1 to 5. It consists of a command (Figure 1), a CL program (Figure 2), a display file (Figure 3), two printer files (Figure 4) and an RPG program (Figure 5).
The SNDPRTMSG utility uses a data entry subfile to accept the message text. There's nothing mysterious about this subfile-I've made it as simple as it can get. Notice, however, that the utility can use one or two printer files, depending on whether you have requested a copy for your own records. If you do, external switch number 2 turns on. This switch is used in the RPG program to determine whether to open, write to and close the second printer file, PRT001P2.
Both printer files share the same record format names and field names so I've provided only one version of the source code. The compile instructions direct you to create both printer files from the source in 4. Since the field names present no problem (after all, we would be printing the same message via both printer files), we don't worry about renaming them within the RPG program. The record format names, on the other hand, need to be renamed or the program will not compile.
Both printer files share the same record format names and field names so I've provided only one version of the source code. The compile instructions direct you to create both printer files from the source in Figure 4. Since the field names present no problem (after all, we would be printing the same message via both printer files), we don't worry about renaming them within the RPG program. The record format names, on the other hand, need to be renamed or the program will not compile.
The rest of the RPG program is pretty self-evident and requires no additional explanation. When you stop to think about it, SNDPRTMSG is a short and uncomplicated utility that shows off the sophistication of the operating system. And it's a useful utility, to boot. I have used it myself many times in the past few years, and I'm sure that you'll put it to good use in your organization.
Ernie Malaga has been working with and writing about midrange computers for 10 years.
Telegram/400
Figure 1 Command SNDPRTMSG
/*===================================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/SNDPRTMSG) PGM(XXX/PRT001CL) + */ /* SRCFILE(XXX/QCMDSRC) ALLOW(*INTERACT + */ /* *IPGM *IREXX) */ /* */ /*===================================================================*/ SNDPRTMSG: CMD PROMPT('Send a Printed Message') PARM KWD(RECEIVER) TYPE(*CHAR) LEN(30) MIN(1) + EXPR(*YES) PROMPT('Name of receiver') PARM KWD(SUBJECT) TYPE(*CHAR) LEN(50) MIN(1) + EXPR(*YES) PROMPT('Subject') PARM KWD(PRTDEV) TYPE(*NAME) LEN(10) DFT(*SYSVAL) + SPCVAL((*SYSVAL) (*JOB)) EXPR(*YES) + PROMPT('Destination printer') PARM KWD(COPY) TYPE(*NAME) LEN(10) DFT(*NONE) + SPCVAL((*NONE) (*JOB) (*SYSVAL)) + EXPR(*YES) PROMPT('Printer for your copy')
Telegram/400
Figure 2 CL Program PRT001CL
/*===================================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/PRT001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===================================================================*/ PRT001CL: + PGM PARM(&RECEIVER &SUBJECT &PRTDEV ©) DCL VAR(&RECEIVER) TYPE(*CHAR) LEN(30) DCL VAR(&SUBJECT) TYPE(*CHAR) LEN(50) DCL VAR(&PRTDEV) TYPE(*CHAR) LEN(10) DCL VAR(©) TYPE(*CHAR) LEN(10) DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(132) DCL VAR(&MSGF) TYPE(*CHAR) LEN(10) DCL VAR(&MSGLIB) TYPE(*CHAR) LEN(10) DCL VAR(&MSGID) TYPE(*CHAR) LEN(7) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) CHGJOB SWS(X0XXXXXX) OVRPRTF FILE(PRT001P1) DEV(&PRTDEV) OUTQ(*DEV) USRDTA(SNDPRTMSG) IF COND(© *NE '*NONE') THEN(DO) CHGJOB SWS(X1XXXXXX) OVRPRTF FILE(PRT001P2) DEV(©) OUTQ(*DEV) + USRDTA(SNDPRTMSG) ENDDO CALL PGM(PRT001RG) PARM(&RECEIVER &SUBJECT) RETURN ERROR: + RCVMSG MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) MSGF(&MSGF) + MSGFLIB(&MSGFLIB) SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(&MSGDTA) + MSGTYPE(*ESCAPE) ENDPGM
Telegram/400
Figure 3 Display File PRT001DF
*==============================================================* * To compile: * * * * CRTDSPF FILE(XXX/PRT001DF) SRCFILE(XXX QDDSSRC) * * * *==============================================================* A DSPSIZ(24 80 *DS3) A PRINT A CA03(03 'Exit') A CA12(12 'Cancel') * A R MSGRCD SFL A LINE 77A B 3 2CHECK(LC) * A R MSGCTL SFLCTL(MSGRCD) A SFLSIZ(0100) A SFLPAG(0020) A BLINK A OVERLAY A 80 SFLDSP A 80 SFLDSPCTL A N80 SFLINZ A N81 SFLEND(*MORE) A 1 30'Send a Printed Message' A DSPATR(HI) * A R FKEYS A 24 2'F3=Exit F12=Cancel E- A nter=Send Message' A COLOR(BLU)
Telegram/400
Figure 5 RPG Program PRT001RG
*================================================================ * * To compile: * * CRTRPGPGM PGM(XXX/PRT001RG) SRCFILE(XXX/QRPGSRC) * *================================================================ FPRT001DFCF E WORKSTN F RRN KSFILE MSGRCD FPRT001P1O E 91 PRINTER F HEADER KRENAMEHDR1 F DETAIL KRENAMEDTL1 FPRT001P2O E 92 PRINTER U2 F HEADER KRENAMEHDR2 F DETAIL KRENAMEDTL2 * I SDS I 254 263 MYSELF * C *ENTRY PLIST C PARM RCVR C PARM SUBJ * C MOVE *OFF *IN80 C WRITEMSGCTL C WRITEFKEYS C MOVE *ON *IN80 C EXFMTMSGCTL C *IN03 IFEQ *OFF C *IN12 ANDEQ*OFF C EXSR PRTMSG C ENDIF C MOVE *ON *INLR * C PRTMSG BEGSR C Z-ADD100 R 30 C DO 100 C R CHAINMSGRCD 99 C LINE IFNE *BLANKS C LEAVE C ENDIF C SUB 1 R C ENDDO C MOVE *ALL'-' DASHES C WRITEHDR1 C U2 WRITEHDR2 C 1 DO R RRN 40 C RRN CHAINMSGRCD 99 C *IN99 IFEQ *OFF C *IN91 IFEQ *ON C WRITEHDR1 C U2 WRITEHDR2 C MOVE *OFF *IN91 C U2 MOVE *OFF *IN92 C ENDIF C WRITEDTL1 C U2 WRITEDTL2 C ENDIF C ENDDO C ENDSR
Telegram/400
Figure 4a Printer Files PRT001P1
*==============================================================* * To compile: * * * * CRTPRTF FILE(XXX/PRT001P1) SRCFILE(XXX/QDDSSRC) * * * *==============================================================* A R HEADER SKIPB(1) A 33'PRINTED MESSAGE' UNDERLINE A SPACEA(2) A 1'From:' A MYSELF 10A 10 A 65'Date:' A 71DATE EDTCDE(Y) SPACEA(1) A 1'To:' A RCVR 30A 10 A 65'Time:' A 71TIME SPACEA(1) A 1'Subject:' A SUBJ 50A 10 A 65'Page:' A 71PAGNBR EDTCDE(3) SPACEA(1) A DASHES 80A 1SPACEA(1) * A R DETAIL SPACEA(1) A LINE 77A 1
Telegram/400
Figure 4b Printer Files PRT001P2
*==============================================================* * To compile: * * * * CRTPRTF FILE(XXX/PRT001P2) SRCFILE(XXX/QDDSSRC) * * * *==============================================================* A R HEADER SKIPB(1) A 33'PRINTED MESSAGE' UNDERLINE A SPACEA(2) A 1'From:' A MYSELF 10A 10 A 65'Date:' A 71DATE EDTCDE(Y) SPACEA(1) A 1'To:' A RCVR 30A 10 A 65'Time:' A 71TIME SPACEA(1) A 1'Subject:' A SUBJ 50A 10 A 65'Page:' A 71PAGNBR EDTCDE(3) SPACEA(1) A DASHES 80A 1SPACEA(1) * A R DETAIL SPACEA(1) A LINE 77A 1
LATEST COMMENTS
MC Press Online