HeiDoc.net: The Technology Treasure Chest

User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active
 

SAPconnect is the interface that connecs NetWeaver to external communication servers such as SMTP (e-mail) and fax, and is also part of the NetWeaver Trial installation. Setting the interface up is quite simple. Once done, you'll be able to send e-mails from your Mini SAP.

Part 1: Configure Windows

Configuration must be done in two places, both on the Windows side, as well as on the NetWeaver side. Descriptions and screenshots in this article are based on Windows Server 2003 R2, Enterprise Edition and SAP Netweaver 7.02 SP6. Configuration on another OS and/or SAP release would be very similar.

Starter and Home editions of Windows come without any integrated SMTP server. If you want to set up SAPconnect on either of these, you'd have to install a 3rd party SMTP server, which is not focused upon any further in this article.

The Windows SMTP server is part of Internet Information Services (IIS). By default, SMTP is deactivated, and must be added as a Windows component through the control panel. Select the subcategory POP3 Service of E-Mail Services. In the description is says: "The Simple Mail Transfer Protocol (SMTP) is also insalled."

Activate POP3 Service

After activating SMTP, it can be configured through the IIS Manager. Navigate to the node Default SMTP Virtual Server, and maintain its properties.

IIS Manager

In the SMTP Server properties, navigate to the tab Access, and in Relay Restrictions press the button Relay. There you grant relay access to the server for the IP address 127.0.0.1 only. Unrestricted relay access is a severe security risk, so I strongly suggest not to leave this step out.

Configure Relay

Part 2: Configure Netweaver

On the NetWeaver side, configuration is done in transaction SCOT (SAPconnect Administration). Maintain the node SMTP to go to the detail view.

SAPconnect Administration

Enter the data as seen in the screenshot: Description Mail Server, Maximum waiting time for repeat send attempt procedure 30 minutes, tick the box Node in use, Mail Host localhost, and Mail Port 25, then press the Set button for Supported address types Internet.

General Node Data of Node SMTP

In the following screen select Address area *, and define output formats for SAP documents as follows: SAPscript/Smart Forms PDF, ABAP list HTML, and Business Object/Link, as well as RAW Text TXT.

Address Type for Node

Configuration of the SMTP is complete now. As a next step, we need to schedule a job to transmit the mails in the queue to the SMTP server. To do that, press the button job on the SCOT main screen.

Send Job: Select Variant

The following screen Active and Scheduled Send Jobs still presents an empty grid. Create a new periodic job by selecting Schedule job for INT. Assign a job name, AddrType INT, No. Work Processes 1, and assign a period, start time, and background user.

Active and Scheduled Send Jobs

The send job now is active and running.

Part 3: Test Your Settings

Before you test the configuration, maintain your user settings in transaction SU01. It's important to maintain your e-mail address, as well as set the communication method to e-mail.

Active and Scheduled Send Jobs

Afterwards, go to the SAP Business WorkPlace (transaction SBWP), and create a new document. Enter any e-mail address as recipient, and set the recipient type Internet address. Send the document, and wait for the next job run. The e-mail should then be delivered to the recipient.

Create Document and Send

To test if the document has been sent out without errors, you can check transaction SOST (SAPconnect Transmission Requests). You can check for mail status and error messages here. This is always the first place to go if you need to troubleshoot.

SAPconnect Transmission Requests

ABAP Sample Code

This programme demonstrates how to send an e-mail from ABAP.

*&---------------------------------------------------------------------*
*& Report  Y_SEND_EMAIL
*&
*&---------------------------------------------------------------------*
*& Test Report:
*& Send Test E-Mail to an Internet Address
*&---------------------------------------------------------------------*

REPORT  y_send_email.

DATA: go_message  TYPE REF TO cl_bcs_message,
      go_bcs_send TYPE REF TO cx_bcs_send,
      gv_err_text TYPE        string,
      gv_doc      TYPE        string,
      gv_date     TYPE        char10,
      gv_time     TYPE        char8,
      gv_rec      TYPE        string.

PERFORM popup_get_data CHANGING gv_rec.

WRITE: sy-datum TO gv_date,
       sy-uzeit TO gv_time.

gv_doc = `This is a test e-mail.` && ##no_text
         cl_bcs_convert=>gc_crlf &&
         cl_bcs_convert=>gc_crlf &&
         `--------------------------------------------------------` &&
         cl_bcs_convert=>gc_crlf &&
         `Created in ` && sy-sysid && `/` && sy-mandt &&
         ` by user ` && sy-uname &&
         cl_bcs_convert=>gc_crlf &&
         gv_date && ` ` && gv_time && ` (` && sy-zonlo && `)`.

TRY.
    CREATE OBJECT go_message.
    go_message->set_subject( `Test E-Mail` ) ##no_text.
    go_message->set_main_doc( gv_doc ).
    go_message->add_recipient( gv_rec ).
    go_message->send( ).
    MESSAGE s001(sbcs_send).
  CATCH cx_bcs_send INTO go_bcs_send.
    gv_err_text = go_bcs_send->get_text( ).
    MESSAGE gv_err_text TYPE `E`.
ENDTRY.

*&---------------------------------------------------------------------*
*&      Form  POPUP_GET_DATA
*&---------------------------------------------------------------------*
*       get recipient e-mail address
*----------------------------------------------------------------------*
*      <--PV_REC  E-Mail Recipient
*----------------------------------------------------------------------*
FORM popup_get_data CHANGING pv_rec TYPE string.

  DATA: ls_user_address TYPE sousradri1,
        lt_addresses    TYPE STANDARD TABLE OF sousradri1,
        ls_field        TYPE sval,
        lt_fields       TYPE sfbe_t_sval,
        lv_rcode        TYPE c.

  IF pv_rec IS INITIAL.
    ls_user_address-sapname   = sy-uname.
    ls_user_address-com_type  = `INT`.
    ls_user_address-home_addr = `X`.
    APPEND ls_user_address TO lt_addresses.

    CALL FUNCTION `SO_USER_ADDRESS_READ_API1`
      TABLES
        user_address    = lt_addresses
      EXCEPTIONS
        enqueue_errror  = 1
        parameter_error = 2
        x_error         = 3
        OTHERS          = 4.

    IF sy-subrc = 0.
      READ TABLE lt_addresses INDEX 1 INTO ls_user_address.
      pv_rec = ls_user_address-address.
    ENDIF.
  ENDIF.

  ls_field-tabname   = `BCSS_DYNP`.
  ls_field-fieldname = `RECIPIENT`.
  ls_field-field_obl = `X`.
  ls_field-value     = pv_rec.
  APPEND ls_field TO lt_fields.

  CALL FUNCTION `POPUP_GET_VALUES`
    EXPORTING
      popup_title     = `Test E-Mail`
      ##no_text

    IMPORTING
      returncode      = lv_rcode
    TABLES
      fields          = lt_fields
    EXCEPTIONS
      error_in_fields = 1
      OTHERS          = 2.

  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE `E` NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.

  IF lv_rcode = `A`.
    LEAVE PROGRAM.
  ELSE.
    READ TABLE lt_fields INTO ls_field INDEX 1.
    pv_rec = ls_field-value.
  ENDIF.

ENDFORM.                    " POPUP_GET_DATA