Sending SAPOffice mail
By Sudarshan Karkada

SAP supplies a function module 'SO_OBJECT_SEND' to allow you to send SAPOffice mails from within your ABAP programs. However, using that function module

    Requires Free Membership to View

is complex and takes a lot of time to understand.

The following function module is just a wrap around for SO_OBJECT_SEND and takes much of the complexity out of the process. This function module not only sends a SAPOffice mail but also points to the current spool list. As you can see, many of the parameters have their defaults.

Parameter Descriptions
Either RECEPIENT or DLI must be specified. If the mail should be sent to several people, create a distribution list and supply its name for DLI.
Internal table TEXT should contain the body of the mail message.

While this function module can be used as it is, it is just an example. SO_OBJECT_SEND is very comprehensive and many of the features are omitted from this example. You are encouraged to examine SO_OBJECT_SEND, see all the available features, and change this function module to suit your requirements.


FUNCTION Z_SEND_MAIL_FOR_SPOOLLIST.
*"----------------------------------------------------------------------
*"*"Local interface:
*"       IMPORTING
*"             VALUE(SPOOLNUMBER) LIKE  SY-SPONO DEFAULT SY-SPONO
*"             VALUE(MAILNAME) LIKE  SOOD1-OBJNAM DEFAULT 'NOTE'
*"             VALUE(SUBJECT) LIKE  SOOD1-OBJDES
*"             VALUE(RECEPIENT) LIKE  SY-UNAME OPTIONAL
*"             VALUE(DLI) LIKE  SOOS1-DLINAM OPTIONAL
*"       TABLES
*"              TEXT STRUCTURE  SOLI OPTIONAL
*"       EXCEPTIONS
*"              ERROR
*"----------------------------------------------------------------------

DATA: OBJECT_HD_CHANGE LIKE SOOD1 OCCURS 0 WITH HEADER LINE,
      OBJPARA          LIKE SELC  OCCURS 0 WITH HEADER LINE,
      RECEIVERS        LIKE SOOS1 OCCURS 0 WITH HEADER LINE.


OBJECT_HD_CHANGE-OBJLA  = SY-LANGU.
OBJECT_HD_CHANGE-OBJNAM = MAILNAME.
OBJECT_HD_CHANGE-OBJDES = SUBJECT.
OBJECT_HD_CHANGE-OBJSNS = 'F'.
OBJECT_HD_CHANGE-VMTYP  = 'T'.
OBJECT_HD_CHANGE-SKIPS  = 'X'.
OBJECT_HD_CHANGE-ACNAM  = 'SP01'.
OBJECT_HD_CHANGE-OBJCP  = 'X'.

RECEIVERS-RCDAT  = SY-DATUM.
RECEIVERS-RCTIM  = SY-UZEIT.
IF DLI IS INITIAL.
    RECEIVERS-RECNAM = RECEPIENT.
    RECEIVERS-RTUNAM = RECEPIENT.
ELSE.
    RECEIVERS-RECNAM = DLI.
    RECEIVERS-ADR_NAME = DLI.
    RECEIVERS-RECESC = 'C'.
ENDIF.
RECEIVERS-SNDEX  = 'X'.     " Express-Mail
APPEND RECEIVERS.

OBJPARA-NAME = 'SPI'.
OBJPARA-LOW  = SPOOLNUMBER.
APPEND OBJPARA.


 CALL FUNCTION 'SO_OBJECT_SEND'
      EXPORTING
           OBJECT_HD_CHANGE           = OBJECT_HD_CHANGE
           OBJECT_TYPE                = 'RAW'
           OWNER                      = SY-UNAME
      TABLES
           OBJCONT                    = TEXT
           OBJPARA                    = OBJPARA
           RECEIVERS                  = RECEIVERS
      EXCEPTIONS
           OTHERS                     = 01.

IF SY-SUBRC NE 0.
   RAISE ERROR.
ENDIF.

ENDFUNCTION.

Visit Sudarshan Karkada's website for more great ABAP programs.

Did you like this tip? Send us an email to let us know what you think.

This was first published in July 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.