Thanks Chuck and the rest of the gang for all the input.
Yes - the QCMDEXC sorted the problem out. For some reason the SNDEMAIL
command fails if any of the variables has blanks, however if these same
varibales are passed to an RPGLE which builds the string and executes
the CLE request - it works! Here's what we did:

/* loop the email file to send e-mails to relevant people
*/
READLOOP: RCVF RCDFMT(METEMLFR)



/* monitor for end of file
*/
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(END))



/* call the rpgle to dynamically build the sndemail command
*/
CALL PGM(REDIOO0215) PARM(&EMLADREM1 &EMLADREM2 +

&EMLADREM3 &EMLADREM4 &EMLADREM5 &EMLADREM6
+
&EMLADREM7)



GOTO CMDLBL(READLOOP)



END: ENDPGM


REDIOO0215:
* COPY BOOKS
* ~~~~~~~~~~
* copy book for smollan prototypes
/copy bsmo610/qcpysrc,smstdprot

dcommand s 1000a
dlength s 15p 5
dpaddr1 s 50
dpaddr2 s 50
dpaddr3 s 50
dpaddr4 s 50
dpaddr5 s 50
dpaddr6 s 50
dpaddr7 s 50

c *entry plist
c parm paddr1
c parm paddr2
c parm paddr3
c parm paddr4
c parm paddr5
c parm paddr6
c parm paddr7

c eval command = 'SNDEMAIL TYPE(*IFS) SMTPID(' +

c %TRIM(PADDR1) + ' ' + %TRIM(PADDR2) +

c ' ' + %TRIM(PADDR3) + ' ' + %TRIM(PADDR4)
+
c ') SUBJECT(TEST) IFS((' + '''' +

c '/kunip/8798_______000879__.xls' +'''' +
'))'
c eval length = %len(%trim(command))



c callp execcmd(command:length)



c endsr


c/copy bsmo610l/qcpysrc,smstdexit

prototype for command

**********************************************************************
* ExecCommand: Execute an AS/40 Command.
*

**********************************************************************
*

DExecCmd Pr ExtPgm('QCMDEXC')

D Command 500A Const Options(*VarSize)

D Length 15P 5 Const

D Optional 3A Const Options(*NoPass)




Prevesh Kuni
RPG Developer
Smollan Group SA (Pty) Ltd
(011) 640 8154
kunip@xxxxxxxxxxxxx


crp@xxxxxxxxxxxxxxxxxxxx 2008/02/19 09:55 PM >>>
Since I do not have the definition of the command, I can not be sure
this is the best answer, but I offer...

Before the SNDEMAIL, include the following:

If Cond(&EMLADREM4 *EQ ' ') Then(ChgVar &EMLADREM4 '*N')
If Cond(&EMLADREM3 *EQ ' ') Then(ChgVar &EMLADREM4 '*N')
If Cond(&EMLADREM2 *EQ ' ') Then(ChgVar &EMLADREM4 '*N')
If Cond(&EMLADREM1 *EQ ' ') Then(ChgVar &EMLADREM4 '*N')

If all are blank, similar error to seen now will occur. Could test
additionally something like the following, and send a specific error
or just let it fail as it does now:
If Cond(&EMLADREM1 *TCAT &EMLADREM2 *TCAT +
&EMLADREM3 *TCAT &EMLADREM4) *EQ ' ') Then(+
SNDPGMMSG...)

If the first is required to be non-blank, for example a CHECK
CONSTRAINT is enforced, then the above four tests, where the last check

sends an error instead of doing the CHGVAR.

The other resolution is by using the QCMDEXC [or QCAPCMD] API to send
the dynamically built command string as a CL request, thus changing the

SNDEMAIL to something like the following:

ChgVar &CmdStr ('SNDEMAIL TYPE(*IFS) SMTPID(' +
*CAT &EMLADREM1 *CAT ' ' *CAT &EMLADREM2 +
*CAT &EMLADREM3 *CAT ' ' *CAT &EMLADREM4 +
*CAT ') SUBJECT(''MetCash Orders'') ' +
*CAT 'IFS(('''/kunip/'' *CAT *FILE))'
CALL QSYS/QCMDEXC (&CmdStr &CmdStrLen) /* len init in DCL */

Regards, Chuck

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.