Creating a link to an SAP object in Outlook

Tisch, Brad brad.tisch at teldta.com
Wed Apr 21 10:38:19 EDT 2004


The previous bit of code I gave you places the content of an SAP shortcut
into an internal table. Here is some additional code for converting the
internal table into a SOFM object that can be used as an attachment. I have
used the below code to create attachments in the background (I haven't
created the SAP shortcut attachment this way, but don't see why it wouldn't
work. I created the SAP shortcut attachment using classes available in 4.7 -
I forwarded you that code.)
 
Method CreateAttachment.
Import Contents type SOLI-Line (multiline)
Export Attach type SOFM (Object)
** declare local variables and move container elements to variables
swc_container l_cont.
 
Swc_create_object Attach 'SOFM' ''.
Swc_set_element l_cont 'NO_DIALOG' 'X'.
Swc_set_element l_cont 'DOCUMENTTITLE' 'SAP Shortcut'. "Some Title
Swc_set_table   l_cont 'DocumentContent' contents.
Swc_set_element l_cont 'DOCUMENTTYPE' 'SAP'.
Swc_call_method Attach 'Create' l_cont.
 
Swc_get_element l_cont '_Result' Attach.
 
Endmethod.
 
This is the basic framework. After calling this method, the object Attach
will be passed back to your workflow container. The Attach object can then
be passed along with a sendmail via attachments. (Attachments is a table -
so select the binding that allows you to append to the table.)
 
 
 
 
 
-----Original Message-----
From: Richard Marut [mailto:rvmarut at earthlink.net]
Sent: Wednesday, April 21, 2004 1:57 AM
To: SAP-WUG at MITVMA.MIT.EDU
Subject: Re: Creating a link to an SAP object in Outlook
 
Tisch,
 
I decided to implement your create_shortcut form and used sofm.create to
create the attachment. When I test at the object using the test feature and
no_dialog = 'X', everything thing is fine. When I execute within the
workflow I get incorrect results. In other words, I get the wrong data for
the attachment. I debugged through the code and don't see anywhere that
would dictate getting different results in background execution. I even went
as far as extending SOFM, creating a new method to be non-dialog and
duplicated the code into a new method and pulled out any unneccessary code
but still ended up with the same results.
 
Were you able to successfully execute sofm.create in the background? And if
so, how?
 
Richard...
 
-----Original Message-----
From: SAP Workflow [mailto:Owner-SAP-WUG at MITVMA.MIT.EDU] On Behalf Of Tisch,
Bradley
Sent: Monday, April 05, 2004 10:06 AM
To: SAP-WUG at MITVMA.MIT.EDU
Subject: Re: Creating a link to an SAP object in Outlook
 
Hi,
 
The basic premise is you're attaching a SAP shortcut file to a sap mail.
(Your shortcut functionality needs to be working via your SAPGui.) You
should create your own shortcut file first, by clicking on the 'Generate
Shortcut Icon', part of the standard SAP menu bar, available on all screens.
After creating the shortcut on your desktop, you want to view the shortcut
file's contents with Notepad (or some type of editor). You will use the
shortcut file contents as the basis for your attachment. Here is some sample
code where I use a combination of hardcoded text and parameters to build an
internal table that mimics the content of the shortcut file.
 
FORM create_shortcut.
  DATA: lt_short TYPE soli OCCURS 0,
        l_short  TYPE soli.
 
  APPEND '[System]' TO lt_short.
  CONCATENATE 'Name=' a_syst INTO l_short.
  APPEND l_short TO lt_short.
  CONCATENATE 'Description=' a_desc INTO l_short.
  APPEND l_short TO lt_short.
  CONCATENATE 'Client=' a_mandt INTO l_short.
  APPEND l_short TO lt_short.
  APPEND '[User]' TO lt_short.
  APPEND 'Name=<USERID>' TO lt_short.
  APPEND '[Function]' TO lt_short.
  APPEND 'Title=Collective Release of Purchase Requisitions'
    TO lt_short.
  CONCATENATE 'Command=' a_trans INTO l_short.
  APPEND l_short TO lt_short.
 
  CALL FUNCTION 'SO_RAW_TO_RTF'
    TABLES
      objcont_old = lt_short
      objcont_new = gt_attach.
 
ENDFORM.                    "create_shortcut
 
 
After you execute the above form, the contents of you SAP shortcut are
contained within the internal table gt_attach (type table of soli). You now
have several options. Using business object sofm and the create method, you
can create a office document supplying gt_attach as the content and set the
office document type to 'SAP'. This office document can then be used as an
attachment to other office documents, i.e. Workflow Sendmail. Or if you're
into the new object oriented development, you can do what I did in the below
code.
 
FORM distribute_message USING p_user p_key.
  DATA: l_subject TYPE so_obj_des.
  DATA: l_sender             TYPE REF TO cl_sapuser_bcs.
  DATA: l_recipient          TYPE REF TO if_recipient_bcs.
  DATA: l_msg                TYPE soli.
  DATA: l_notify             TYPE zpr_notify.
  DATA: lt_short             TYPE soli OCCURS 0,
        l_short              TYPE soli.
 
    TRY.
        send_request = cl_bcs=>create_persistent( ).
        l_subject = text-h01.
        document = cl_document_bcs=>create_document(
                        i_type    = 'RAW'
                        i_text    = gt_text
                        i_subject = l_subject ).
 
        IF a_short = 'X'.
          lt_short[] = gt_attach[].
          LOOP AT lt_short INTO l_short.
            REPLACE '<USERID>' IN l_short WITH p_user.
            IF sy-subrc EQ 0.
              MODIFY lt_short FROM l_short.
              EXIT.
            ENDIF.
          ENDLOOP.
          CALL METHOD document->add_attachment
            EXPORTING
              i_attachment_type     = 'SAP'
              i_attachment_subject  = 'Shortcut'
              i_attachment_language = 'E'
              i_att_content_text    = lt_short.
        ENDIF.
 
        CALL METHOD send_request->set_document( document ).
        l_sender = cl_sapuser_bcs=>create( p_user ).
        l_recipient = l_sender.
        CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient = l_recipient
            i_express   = a_expres.
 
        CALL METHOD send_request->send
          EXPORTING
            i_with_error_screen = 'X'
          RECEIVING
            result              = sent_to_all.
        IF sent_to_all = 'X'.
**  Success
        ENDIF.
 
        COMMIT WORK.
      CATCH cx_bcs INTO bcs_exception.
        WRITE: text-e01, bcs_exception->error_type.
        EXIT.
    ENDTRY.
ENDFORM.                    " distribute_message
 
 
 
 
 
-----Original Message-----
From: SAP Workflow [mailto:Owner-SAP-WUG at MITVMA.MIT.EDU]On Behalf Of
Hoodak, Anthony J.
Sent: Friday, April 02, 2004 5:53 AM
To: SAP-WUG at MITVMA.MIT.EDU
Subject: Re: Creating a link to an SAP object in Outlook
 
 
Bradley -
 
That's great news. Now how do I do this?
 
Tony
 
-----Original Message-----
From: Tisch, Bradley [mailto:Bradley.Tisch at kraft.com]
Sent: Thursday, April 01, 2004 2:32 PM
To: SAP-WUG at MITVMA.MIT.EDU
Subject: Re: Creating a link to an SAP object in Outlook
 
 
Hi,
 
You can include a SAPShort cut as an attachment within the mail. Within the
shortcut you can specify the transaction to be executed.
 
-----Original Message-----
From: SAP Workflow [mailto:Owner-SAP-WUG at MITVMA.MIT.EDU]On Behalf Of
Hoodak, Anthony J.
Sent: Thursday, April 01, 2004 11:57 AM
To: SAP-WUG at MITVMA.MIT.EDU
Subject: Creating a link to an SAP object in Outlook
 
 
Greetings fellow workflowers -
 
I have created a WF that monitors the creation of purchase orders and sends
an Outlook email to someone in Finance when a specific condition is met.
What I would like to do is in addition to sending the Outlook email, I would
also like to send a link back to the object in question from within Outlook
(so that the user can go directly from Outlook back into SAP to view the
purchase order). I know that the provisions are there to do this directly
from within SAP (and the SAP inbox), but how do I accomplish this from
outside SAP (in Outlook)?
 
We are using 4.7, and I am using the Send Mail task to send the Outlook
email to the user.
 
Thanks in advance for anything on this issue!
 
Tony Hoodak
Gleason Works
 


More information about the SAP-WUG mailing list