Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Warning
  • fix links
  • check tables
  • replace "ZSENDMAIL" with "ZSENDMAIL2"
  • how to send HTML message using "ZSENDMAIL2"

Table of Contents

Table of Contents
minLevel2
maxLevel4

...

The majority of SMTP (internet) email sent from the MIT R/3 systems is sent via the custom function module Z_SENDMAILSENDMAIL2. This function has been modified from its original state to enable programmers to instruct Z_SENDMAIL SENDMAIL2 to intercept and/or log outgoing email that it processes.

...

Interception of email is useful for debugging, testing, validating, and for providing training. The original motivation for adding this feature to Z_SENDMAIL SENDMAIL2 was to provide a method of preventing email from being sent from non-production systems. When a new R/3 system is set up or refreshed, two entries should be established in custom table ZEHCAT to initially discard all email sent via Z_SENDMAILSENDMAIL2. Later, changes can be made as needed to support specific tests.

...

3.  How Interception and Logging

WorksEach call to Z_SENDMAIL SENDMAIL2 is associated with an email handling category taken either from parameter P_HNCAT or, if this parameter is not included in the function call, from table ZEMCTRL (see below for details on this distinction). The handling category is referenced in control table ZEHCAT, which contains the following instructions for processing the Z_SENDMAIL SENDMAIL2 call based on the assigned handling category:

  1. Whether to log the call to Z_SENDMAILSENDMAIL2.
  2. Whether to intercept the email message, and if so, whether to:
    1. Discard the message.
    2. Redirect the message to alternate "To" and "Cc" addresses.
      (The alternate addresses are provided by ZEHCAT).
    3. Write the message to a UNIX file.
      (The UNIX path suffixed after "/usr/bridges/<system>/saptmp/" is supplied by ZEHCAT).
    4. Write the message to an SAP printer spool file.
      (The printer name and spool settings are provided by ZEHCAT).

Email handling categories are assigned based on the type of email and the class of recipient to receive the email. The table of current handling category assignments can be found here. Requests for the assignment of an additional handling category should be directed to SAIS SAP Technical Service.There are currently two ways to specify the handling category associated with a call to Z_SENDMAILSENDMAIL2:

1. Explicitly pass an email handling category as parameter P_HNCAT.

Every new call to Z_SENDMAIL SENDMAIL2 should pass an explicit email handling category as parameter P_HNCAT. Because many programs that call Z_SENDMAIL SENDMAIL2 pre-date the intercepting and logging modifications, the P_HNCAT parameter is currently optional so that such programs do not require modification simply to add a handling category to the function call. It is intended, however, that every existing call to Z_SENDMAIL SENDMAIL2 will eventually be modified to pass an explicit email handling category.

...


The most direct way to associate a handling category with an existing call to Z_SENDMAIL SENDMAIL2 is to modify the calling program to explicitly pass an email handling category as parameter P_HNCAT, and then transport the modified program to the R/3 test and other environments. 

call function 'Z_SENDMAILSENDMAIL2'

 

exporting

 

p_to

=  <TO ADDRESS>

p_cc

=  <CC ADDRESS>

p_bcc

=  <BCC ADDRESS>

p_from

=  <FROM ADDRESS>

p_reply_to

=  <REPLY-TO ADDRESS>

p_subject

=  <SUBJECT LINE>

p_hncat

= <HANDLING CATEGORY> 

tables

 

message

=  <MESSAGE TABLE>

exceptions

 

error_in_send

=  1

spaces_in_req_params

=  2

invalid_email_address_syntax

=  3

unable_to_open_unix_file

=  4

unable_to_write_to_unix_file

=  5

unable_to_execute_unix_program

=  6

interception_control_tables

=  7

interception_to_spool

=  8

interception_process

=  9.

...

If a program that calls Z_SENDMAIL SENDMAIL2 pre-dates the intercepting and logging modifications, such programs do not require modification simply to add a handling category to the function call. Although it is intended that every existing call to Z_SENDMAIL SENDMAIL2 will eventually be modified to pass an explicit email handling category, programmers have the option of using table ZEMCTRL to map such programs to the appropriate handling category.

...

The handling category (either passed as parameter P_HNCAT or retrieved from table ZEMCTRL) is referenced in table ZEHCAT, and the following instructions for processing the Z_SENDMAIL SENDMAIL2 call are retrieved:

  1. Whether to log the call to Z_SENDMAILSENDMAIL2.
  2. Whether to intercept the email message, and if so, whether to:
    1. Discard the message.
    2. Redirect the message to alternate "To" and "Cc" addresses.
      (The alternate addresses are provided by ZEHCAT).
    3. Write the message to a UNIX file.
      (The UNIX path suffixed after "/usr/bridges/<system>/saptmp/" is supplied by ZEHCAT).
    4. Write the message to an SAP printer spool file.
      (The printer name and spool settings are provided by ZEHCAT).

...

  1. To whom will the E-Mail be addressed? (This is usually answered with the person's role, not their name. Some example answers are "Card holders", "SAP users entering work orders", "Training & Events administrators", "Requisition approver", "HR Service Center", "Employee timesheet user", "Payroll distribution support", and "User who created the journal voucher")
  2. The subject of the E-Mail? (Some example answers are "Staff out of balance report", "Problem with Lincoln HR feed to campus", "Purchase order is approved", "Duplicate MIT-IDs", "Leave balance status", and "Mass. Health Insurance report".)
  3. What is the name of the ABAP source object containing the call to Z_SENDMAILSENDMAIL2?
  4. What is the value of SY-CPROG when Z_SENDMAIL SENDMAIL2 gets control?

    Special Handling Categories

...

Handling category <space><space> is imposed upon all email sent via Z_SENDMAIL SENDMAIL2 for which no handling category is specified for the calling program (neither explicitly as parameter P_HNCAT nor mapped via an entry in table ZEMCTRL).

...

Handling category ++ is imposed upon all email sent via Z_SENDMAIL SENDMAIL2 for which a handling category is specified (either explicitly as parameter P_HNCAT or mapped via an entry in table ZEMCTRL), but no corresponding entry is found in table ZEHCAT.

How the imposed handling category is then processed depends on the contents of table ZEHCAT. If there are no entries in table ZEHCAT for the current R/3 system, all email sent via Z_SENDMAIL SENDMAIL2 will be delivered normally, that is, will neither be intercepted nor logged. Table ZEHCAT in the production system, for instance, should typically contain no entries to allow for normal email delivery. If table ZEHCAT contains only the entries shown below for the <space><space> and ++ handling categories, all email sent via Z_SENDMAIL SENDMAIL2 will be intercepted and discarded. Upon creating or refreshing a non-production R/3 system, these entries should be established in table ZEHCAT so that all email is discarded. Changes can later be made to support specific testing.

...

For a program that does not pass an explicit P_HNCAT parameter in its call to Z_SENDMAILSENDMAIL2, custom table ZEMCTRL is used to map the calling program to its assigned email handling category. (If the P_HNCAT parameter is passed, ZEMCTRL is not referenced.) Eventually, all calls to Z_SENDMAIL SENDMAIL2 will pass the P_HNCAT parameter and, at that time, table ZEMCTRL will no longer be needed.

...

For a program that passes an explicit P_HNCAT parameter in its call to Z_SENDMAILSENDMAIL2, custom table ZEHCAT is referenced to determine how the call should be processed. This determination is made by reading the control field settings that correspond to the email handling category specified in the P_HNCAT parameter.

...

  1. LOG  Whether to log the call to Z_SENDMAILSENDMAIL2.
  2. CMODE  Whether to intercept the email message.
    ACTION## Discard the message.
    1. Redirect the message to alternate "To" and "Cc" addresses.
      (The alternate addresses are provided by MAILTO and CCTO, respectively).
    2. Write the message to a UNIX file.
      (The UNIX path suffixed after "/usr/bridges/<system>/saptmp/" is supplied by MAILTO).
    3. Write the message to an SAP printer spool file.
      (The printer name is provided by PDEST, and the spool settings by PRIMM, PRREL, and PRNEW).

...