Sending email to trading partner after a T/E
(Document Level User Exit)
Subscribe to keep this site alive! Under new management but as always, still 100% FREE. Anyone with the IBM i is a friend of ours.
(Document Level User Exit)
The Challenge: How can I send an email automatically to my trading partner on a T/E?
The Solution: There are three things we need to setup to achieve this:
1)When are we sending it? - To setup when: Populate the Document Level User Exit Name and Library and check the [X] T/E Translation with Errors box of "Run if document status is:' option. The DOCLVLEXIT is needed to grab the erring mailbox number.
2)To whom are we sending it? - Since we need to send the email to a particular trading partner, we would need at least the internal trading partner id (36 thru 50 of Parameter One of UGETMBXE) and/or other values from the mailbox that would be needed to fetch the record from the reference file (which will contain the email). Retrieval of these is made possible by the GETMBXEx commands or the UGETMBXE API. Sending it to several email addresses is also possible including cc/bcc footers: check this idea here.
3)What information are we sending them? - Now we have the recipient email, we would need to get what we need to send. The document control number (623 thru 636 of Parameter One of UGETMBXE) is available in the uGETMBXEx programs. Or the mailbox itself has a spooled error report (like PED354) that can be copied to a file (using CPYSPLF) and sent to the IFS (using CPYTOSTMF) and attached to the email (SNDSMTPEMM).
Note: Since the error report is in the same job, the job attributes of the report can be derived from the Program Status Data Structure (SDS) for RPG or RTVJOBA for a CLP.
Do you have a new CHALLENGE? Let us know HERE.