Does anyone have any idea how this TOINTNET parameter should be formatted? I think if I could just get the CLP to not enclose the passed address list in quotes, it would work.
When you try to execute a command in a CL program and that command has an unknown number of parameters, you usually have to execute that command using the QCMDEXC API. Following is a program that accepts a message and a message description. The program will then send that message to multiple e-mail addresses that are contained in a file by building the command in the CL program.
/* ***********************************************************
/* SEND E-MAIL TO MULTIPLE E-MAIL ADDRESSES
/* ***********************************************************
PGM PARM(&MSG &DESC)
DCLF FILE(EMAILIDS)
DCL VAR(&DESC) TYPE(*CHAR) LEN(20)
DCL VAR(&MSG) TYPE(*CHAR) LEN(20)
DCL VAR(&CMDLEN) TYPE(*DEC) LEN(15 5) VALUE(2500)
DCL VAR(&CMD) TYPE(*CHAR) LEN(2500)
DCL VAR(&BLANKSTR) TYPE(*CHAR) LEN(2500)
BEGIN:
/* CLEAR OUT VARIABLES */
CHGVAR VAR(&CMD) VALUE(&BLANKSTR)
BUILD:
/* BUILD THE FIRST PART OF THE COMMAND STRING */
CHGVAR VAR(&CMD) VALUE('SNDDST TYPE(*LMSG) +
TOINTNET(')
READ:
/* ADD ALL E-MAIL ADDRESSES TO RECIPIENT LIST */
RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(FINISH))
CHGVAR VAR(&CMD) VALUE(&CMD *TCAT '(' *TCAT &NAME +
*TCAT ') ')
GOTO READ
FINISH:
/* CLOSE E-MAIL ADDRESS PARM */
CHGVAR VAR(&CMD) VALUE(&CMD *TCAT ')')
/* ADD DESCRIPTION & MESSAGE (ENCLOSE THEM IN QUOTES) */
CHGVAR VAR(&CMD) VALUE(&CMD *BCAT 'DSTD(' *TCAT +
'''' *TCAT &DESC *TCAT '''' *TCAT ') ')
CHGVAR VAR(&CMD) VALUE(&CMD *BCAT 'LONGMSG(' *TCAT +
'''' *TCAT &MSG *TCAT '''' *TCAT ') ')
/* EXECUTE THE COMMAND */
CALL PGM(QCMDEXC) PARM(&CMD &CMDLEN)
ENDPGM: ENDPGM ================================== MORE INFORMATION ON THIS TOPIC ==================================
The Best Web Links: tips, tutorials and more.
Ask your programming questions--or help out your peers by answering them--in our live discussion forums.
This was first published in August 2001