Executable SAP Office Mails - Sharing the love

Mark Pyc markpyc at hotmail.com
Thu Jan 13 03:54:44 EST 2005


G'day Wuggers,

I've been meaning to figure out how to send executable SAP Office Mails, 
such as the WF errors sent to WF admin, for a long time and finally pulled 
my finger yesterday.

It's pretty straight forward. I've attached a couple of text files that 
contain a function module to call SO_OBJECT_SEND and a function module that 
gets called when Document > Execute is selected. I've also included the text 
directly below in case attachments don't work (pretty sure they do with this 
new WUG).

Where I see these being useful is in notifications where you want to allow 
the user to keep the link to the document but don't want an open Workitem 
left around for performance or reporting reasons. The obvious limitation is 
that the link is only usable from the Office Inbox and not an external mail 
client. Still, someone may find it useful.

Please insert your own disclaimers about the reliabilty and usability of the 
following code. This code is from a 4.6C system.

Have fun!
Mark

~~~~~~~~~~~~~~~~~~~~~~~
FUNCTION Z_PYC_CREATE_MAIL_WITH_DISP_PO .
*"----------------------------------------------------------------------
*"*"Local interface:
*"  IMPORTING
*"     REFERENCE(PO) TYPE  EKKO-EBELN
*"     REFERENCE(RECIPIENT) TYPE  SO_REC_NAM
*"----------------------------------------------------------------------

* data for call of so_object_send
  DATA: OBJ_TYPE    LIKE SOOD-OBJTP VALUE 'RAW'.
  DATA: BEGIN OF RECEIVERS OCCURS 1.
          INCLUDE STRUCTURE SOOS1.
  DATA: END OF RECEIVERS.
  DATA: BEGIN OF OBJHEAD OCCURS 1.
          INCLUDE STRUCTURE SOLI.
  DATA: END OF OBJHEAD.
  DATA: BEGIN OF OBJCONT OCCURS 10.
          INCLUDE STRUCTURE SOLI.
  DATA: END OF OBJCONT.
  DATA: BEGIN OF OBJECT_ID_NEW.
          INCLUDE STRUCTURE SOODK.
  DATA: END OF OBJECT_ID_NEW.
  DATA: BEGIN OF OBJPARB OCCURS 1.
          INCLUDE STRUCTURE SOOP1.
  DATA: END OF OBJPARB.
  DATA: BEGIN OF OBJECT_HD_CHANGE.
          INCLUDE STRUCTURE SOOD1.
  DATA: END OF OBJECT_HD_CHANGE.

* fill mail header.
  CLEAR OBJECT_HD_CHANGE.
  OBJECT_HD_CHANGE-OBJLA    = SY-LANGU.
  OBJECT_HD_CHANGE-OBJNAM   = 'PO_MAIL'.
  OBJECT_HD_CHANGE-OBJSNS   = 'F'.     "functional mail
  OBJECT_HD_CHANGE-VMTYP    = 'F'.     "execution via fm SWW_WI_DISPLAY
  OBJECT_HD_CHANGE-ACNAM    = 'Z_PYC_MAIL_EXEC_PO_DISPLAY'.

* create the message title
  CONCATENATE 'Mail with link to PO' PO INTO OBJECT_HD_CHANGE-OBJDES
      SEPARATED BY SPACE.

* create the message body
  APPEND 'This is an executable mail linked to a PO!' TO OBJCONT.
  APPEND 'With the mail open, choose "Document > Execute".' TO OBJCONT.

* set parameters for PO Display
  CLEAR OBJPARB. REFRESH OBJPARB.
  OBJPARB-NAME = 'PO'.
  OBJPARB-VALUE = PO.
  APPEND OBJPARB.

* set the recipients
  MOVE RECIPIENT TO RECEIVERS-RECNAM.
  MOVE 'B' TO RECEIVERS-RECESC.
  APPEND RECEIVERS.

* Call to Create the Office Mail
  CALL FUNCTION 'SO_OBJECT_SEND'
       EXPORTING
            OBJECT_HD_CHANGE = OBJECT_HD_CHANGE
            OBJECT_TYPE      = OBJ_TYPE
       TABLES
            OBJCONT          = OBJCONT
            OBJHEAD          = OBJHEAD
            OBJPARB          = OBJPARB
            RECEIVERS        = RECEIVERS
       EXCEPTIONS
            OTHERS           = 1.

ENDFUNCTION.

~~~~~~~~~~~~~~~~~~~~~~~~~

FUNCTION Z_PYC_MAIL_EXEC_PO_DISPLAY.
*"----------------------------------------------------------------------
*"*"Local interface:
*"       TABLES
*"              MSGDIAL STRUCTURE  SOOP1
*"----------------------------------------------------------------------
  DATA: PO_NUM type ekko-ebeln.

  LOOP AT MSGDIAL.
    IF MSGDIAL-NAME EQ 'PO'.
      PO_NUM = MSGDIAL-VALUE.
      SET PARAMETER ID 'BES' FIELD PO_NUM.
      CALL TRANSACTION 'ME23' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDLOOP.
ENDFUNCTION.

~~~~~~~~~~~~~~~~~~~~

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Z_PYC_CREATE_MAIL_WITH_DISP_PO.txt
Url: http://mailman.mit.edu/pipermail/sap-wug/attachments/20050113/520e7661/attachment.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Z_PYC_MAIL_EXEC_PO_DISPLAY.txt
Url: http://mailman.mit.edu/pipermail/sap-wug/attachments/20050113/520e7661/attachment-0001.txt


More information about the SAP-WUG mailing list