Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

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

Table of Contents

Table of Contents
minLevel2
maxLevel34

1.  Abstract

To view an abstract of this document, click here.

...

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.

Two custom tables, ZEHCAT and ZEMCTRL are used to control both interception and logging of email, and the log is written to a third custom table, ZEMLOG.

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.

Logging of email, while useful for debugging purposes, particularly for intermittent problems or problems that occur in the R/3 production system, is intended to be used solely for short-term debugging purposes and should only be enabled when attempting to track down a problem. Logging is not intended, nor should it be used, as an audit trail of messages sent.

3.  How To setup ZSENDMAIL2 for 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 table of current email handling category assignments can be found here.


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 table of current email handling category assignments can be found here.


When a chain of programs is called, care should be taken in determining the value for field PROG, the calling program name as it appears in SY-CPROG. It is the first program within a chain of calls that is the calling program.

...

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).

The table of current email handling category assignments can be found here.

If there are no existing handling category assignments for a program or if the existing assignments are not suitable, a request may be sent to the SAIS SAP Technical Service for the assignment of a new handling category.

...

  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).

2. ++

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.

...

View the ZBRSMAIL selection screen for the ZEMCTRL or the ZEHCAT tables.

A separate utility program is currently under development that will enable programmers to selectively display or delete entries in the ZEMLOG table. Until that utility is available, transaction SE16 may be used to view email log entries in table ZEMLOG.

...

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).

...

Email logging uses the same email handling categories as interception and, while logging is controlled by table ZEHCAT, the email data to be logged is written to custom table ZEMLOG.

...

ZEMLOG

Field Name

Data Element

Data Type

Length

Description

 

MANDT

MANDT

CLNT

3

Client

 

HOST

SYHOST

CHAR

8

Host
(system name, e.g. MAPLE, PINE, etc)

 

UNAME

UNAME

CHAR

12

User name

 

CPROG

SYCPROG

CHAR

40

Calling program name (SY-CPROG)

 

TMSTPT

ZNTSTMPL

DEC

21

UTC time stamp in long decimal form
(a number like YYYYMMDDhhmmss.mmmuuun)

 

EXCEP

RS38L_EXCN

CHAR

30

Name of function module exception

 

ERTXT

ZERTXT

CHAR

240

Error text (or a statement of success)

 

RECIP

ZEMAILTO

CHAR

80

Email "To:" address
(first 80 char)

 

SBJCT

ZSUBJECT

CHAR

80

Subject line of Email
(first 80 char)

 

ACTION

ZACTION

CHAR

1

Email processing action
(from ZEHCAT)



 | E-MAIL HANDLING CATEGORIES | DEVELOPMENT RESOURCES |

6. How To Send HTML Messages Using ZSENDMAIL2

To send HTML message, add the following header texts into the "header" table in ZSENDMAIL2:

      MIME-Version: 1.0
      Content-Type: text/html; charset=us-ascii

In the message body, you can then enter HTML tags.

...