Midrange News for the IBM i Community


Posted by: sarge
Citizen/Soldier
U.S. Army
United States
Using Parameters with Esend
has no ratings.
Published: 22 Jun 2012
Revised: 23 Jan 2013 - 1729 days ago
Last viewed on: 17 Oct 2017 (4016 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Using Parameters with Esend Published by: sarge on 22 Jun 2012 view comments(2)

if anybody out here uses Esend for email reports, i have a question for you.

i have set up two parameters for my Esend command. the first is the receiving email address &ADDR and second is the ATTLIST parameter &AttList.

the &Addr works fine, but whenever i use a "built parameter" for the ATTLIST((&AttList)) parm, the program blows chunks.

ESndMail Recipient(&Addr) Subject('Email Report') +
 Msg('Attached is your report') AttList((&AttList))

has anybody successfully used a PARM for the ATTLIST parameter?

thanks.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: DaleB
Premium member *
Reading, PA
Comment on: Using Parameters with Esend
Posted: 5 years 3 months 27 days 22 hours 17 minutes ago
Edited: Fri, 22 Jun, 2012 at 13:19:37 (1944 days ago)

I'm not familiar with your command, but based on what you're showing, I can hazard a guess. From the double parentheses it looks like ATTLIST is expecting a list of values, as in ATTLIST((x) (y)). Furthermore, from an example I found via Google, each list item has multiple elements, as in ATTLIST((* *PDF *N QPSUPRTF)).

When the keyword is expecting any kind of list, you must pass a list. If you have CHGVAR &ATTLIST '* *PDF *N QPSUPRTF', it won't work. ATTLIST((&ATTLIST)) is equivalent to ATTLIST(('* *PDF *N QPSUPRTF')), which is a list that contains a single nested item that consists of a single character string, which is not the same as a nested item that consists of 4 elements.

What you'll probably need to do is build the entire command string in a single large *CHAR field, then pass that to QCMDEXC (or equivalent). Most of it, command name, keywords, parentheses, and so on, are fixed, so you can concatenate literals with your existing variables:

CHGVAR &CMD VALUE('ESndMail Recipient(' *CAT &Addr *TCAT ')' +
       *CAT ' SUBJECT(''Email Report'')' +
       *CAT ' MSG(''Attached is your report'')' +
       *CAT ' ATTLIST((' *CAT &ATTLIST *CAT '))')

CALL QCMDEXC(&CMD 1024) /* or whatever the length of &CMD is */

I'm doing this off the cuff, so that concatenate may not be 100% valid as is, but you get the idea.

Posted by: neilrh
Premium member *
Jackson, MI
Comment on: Using Parameters with Esend
Posted: 5 years 3 months 27 days 20 hours 24 minutes ago

oh, I remember that one, we had it at Borders - I wrote a procedure for entry to the command program.  But the corporation no longer exists, and I have no idea what happened to the source I wrote there.