How to Attach Executable SAP Transaction Links to E-Mails

DevWorkbench    Tuesday August 12th, 2014   

Today, I’ll be looking at e-mail sending features in SAP ERP for the last time and demonstrate how you can attach executable transaction links to e-mails sent from SAP. This is a very useful feature that is often used in a business workflow environment.

Let’s take a look at the possibilities we have. There are two ways to send executable links to receivers in SAP. One is easy and only works if you’re using SAPOffice (transaction SBWP), the other is a bit harder to implement, but more flexible; it will work with both SAPOffice and external e-mail, which is more common.

Sending executable SAPOffice messages

Let’s look at the simple way first. We can mark a SAPOffice document as executable by simply setting a few parameters in the document properties. Consider the e-mail program you already know from the last articles about e-mails. When working with the receiver type B, we can do the following:

* Attach a transaction
ls_document_data-proc_type 'T'.
* Name the transaction
ls_document_data-proc_name 'MM03'.
* Skip first screen
ls_document_data-skip_scren 'X'.

If the recipient of this message now right-clicks it in his inbox, he can choose Execute to call the transaction given here. It is also possible to execute reports and other callable objects by setting the proc_type parameter to other values (see the documentation of SO_NEW_DOCUMENT_SEND_API1 for a list).

Of course, we want to pass the transaction a parameter since we already instructed it to skip the first screen. This is done by using the table parameter object_para.

* Set the parameters for the TA
ls_object_para-name 'MAT'.
ls_object_para-low 'MAT001'.
APPEND ls_object_para TO lt_object_para.

As you can see, I provided the name of a SPA/GPA parameter and a value for it. When the user now chooses Document > Execute in his SBWP inbox, the transaction MM03 will be opened with the material MAT001 already pre-selected. To send the document now, call the function module you already know.

    document_data              ls_document_data
    document_type              'RAW'
    put_in_outbox              'X'
    commit_work                'X'
    object_content             lt_object_content
    object_para                lt_object_para
    receivers                  lt_receivers.

That’s it! Easy, but it has one massive caveat: it does not work for e-mail. The execute functionality is simply not available and unfortunately, the SAP system doesn’t convert it automatically to a SAP shortcut. So let’s look at how we make that work on the next page.