Skip to Content
Author's profile photo Former Member

The full disclosure – SODIS, email disclosure documents and ABAP

A quick intro

On a recent undertaking to implement email disclosure documents on external communications (i.e. email out of SAP), a problem arose in that emails generated from custom ABAP did not have the expected disclosure documents attached. We had implemented multiple disclosure documents, added conditions to ensure certain users had certain disclosures, but something wasn’t working… turns out that while there may be many ways to send email in the SAP development world (FMs, ABAP Objects, Workflow, etc.) there are additional requirements when working with disclosure documents.

Before getting underway, I’d recommend you read up on transaction SODIS and get a few disclosure statements set up. Run through the content at this link:

SAP Documentation – Maintaining Disclosures for External Communication

Right… now that you’re familiar with SODIS, let’s push on.

Diving in

As mentioned earlier, there are a few ways of generating emails in your ABAP code. SO_DOCUMENT_SEND_API1 is a popular function module for those procedural ABAPers out there, while the ABAP Objects path would lead you toward Business Communication Services (BCS) and the BCS classes, cl_bcs, cl_document_bcs, cl_send_request_bcs, and so on. As this is 2011, we’ll go with ABAP Objects.

…on to the problem at hand!

I have the users ‘WF-BATCH’ and ‘USER_TO’, who will be my sender and receiver users respectively (most should be familiar with WF-BATCH already). I have also created a disclosure document in SODIS and applied a rule so that it is appended only to emails from user WF-BATCH. What I’m expecting then, is that the disclosure document is applied to all external communications from WF-BATCH.

Creating the disclosure document in SODIS.

Remeber to activate or we won’t see any disclosures.

Code it up

So I created emails in my program in the following manner:

    lo_bcs type ref to cl_bcs,
    lo_sender type ref to cl_cam_address_bcs,
    lo_recipient type ref to cl_cam_address_bcs,
    lv_ret type os_boolean.
lo_bcs = cl_bcs=>create_persistent( ).
lo_sender = cl_cam_address_bcs=>create_user_home_address( i_user = 'WF-BATCH' ).
lo_bcs->set_sender( i_sender = lo_sender ).
lo_recipient = cl_cam_address_bcs=>create_user_home_address( i_user = 'USER_TO' ).
    i_recipient = lo_recipient
* create document and add to lo_bcs with lo_bcs->set_document( lo_doc )
lv_ret = lo_bcs->send( ).

Now this code will indeed create and send an email (it will be waiting for you in SOST to be released). However, if you have configured a disclosure document for user WF-BATCH, you may be a little disappointed – the disclosure will not be appended. You’ll get the standard disclosure document (if you’ve created one), but alas, the specific disclosure for WF-BATCH is missing in action. What to do then?

Great Scott Marty! To the Deloria… Debugger! For convenience, here are a selection of screens I prepared earlier – I’ve tracked code execution from the point of releasing the email in SOST, through to the selection and appending of the email disclosure document.

1. Function group SOE2, Function module SO_OBJECT_MIME_GET.


2. Subroutine GET_MIME.


3. Class method cl_bcs_send_request->as_mime_message( ).


4. Class method cl_bcs_send_request->add_disclosure_to_mime( )  [added as part of OSS Note 1086090].


5. Class method cl_disclosure_bcs->get_disclosure( ).


6. Class method cl_disclosure_bcs->resolve( ).

Here we see execution arriving at method cl_disclosure_bcs->resolve( ) where a CASE statement tries to identify the address type of the user sending this email. As you can see, it has arrived at an address type of ‘INT’ (Internet). Seems correct, makes sense, let’s keep rolling.

No disclosure document found – defaults to standard disclosure.

A few more taps of F6 and… whoa! This select statement just executed but it didn’t get our disclosure. Yikes, now what? Well, code execution continues and we get… the standard disclosure. What we wanted was WF-BATCH’s disclosure. Fail.

Standard disclosure applied to email.

Lifting the fog

So what’s going on here? We have configured the disclosure for WF-BATCH and checked the routing rule works in SODIS. Where are we going wrong?

CASE statement in method RESOLVE( ).

We’re back in cl_disclosure_bcs->resolve( ) and as you see in the CASE statement above, there is a case condition for l_addr_type being ‘B’ (SAP User); remebering that just before, ours was ‘INT’. So what happens if execution goes into this code block? What if the address type is ‘B’? Let’s try manipulating variables during debugging. Go ahead and whack a break point in method cl_disclosure_bcs->resolve( ), as I’ve done below.

Debugging breakpoint – line 19 TRY statement.


  1. Run our program to generate an email. 
  2. Email is waiting for us in SOST. Good.
  3. Release said email from SOST. Better.
  4. We hit the breakpoint and make our switch – the address type (l_addr_type) is changed to B. Brilliant.
  5. Continue execution (F8).
  6. Check Outlook and…

WF-BATCH disclosure appended to email.

Hey presto! Our disclosure for ‘WF-BATCH’ is there!

That suggests then, that in order for email disclosures to be applied the address type of the sender needs to be SAP User, or ‘B’.

[A small note – if you change the configuration of disclosure documents in SODIS to apply to email domains, then you can overcome this in part (provided you have different domains) but I like to use the most system-relevant means of identifying a sender, and to me, that’s a username. A username is also safest, as it’s rare for these to change, whereas an email address is ambiguous, non-identifying and subject to change].

Doing the hard yards

New task: to determine how we go about using SAP User address types to send emails in our ABAP code instead of Internet address types. So firstly, we need to acknowledge the class cl_cam_address_bcs doesn’t allow creation of SAP User address types. It only allows the six (6) external communication types INT, X400, RML, PRT, PAG and FAX. No ‘B’. Problem.

Here we get to put our OO cunning into practice – bring on the interface class.

Looking a little more closely at the section of code (method cl_disclosure_bcs->resolve) selecting disclosures, we can see that the import paramter ip_sender is an object of type ref if_sender_bcs – an interface class.

Parameter i_sender of type ref to if_sender_bcs.

Right, perfect! Now we just go and find all the other classes that implement this interface! There can’t be many right?! Breath a sigh of releif – the digging is done.

Meandering through some ABAP Objects classes, we come across a class cl_sapuser_bcs that implements interface class if_sender_bcs. If my eyes do not deceive me, that class name – cl_sapuser_bcs – looks suspiciously like something we’re after (remember, address type ‘SAP User’).

Interfaces implemented by cl_sapuser_bcs.

Interrogating the class a little further – specifically, the implemented method if_sender_bcs~address_type – we see… adress type… wait-for-it… B.

Address type ‘B’ returned in class method cl_sapuser_bcs->if_sender_bcs~address_type

B-B-Bingo! It appears then, that we need to be using this class to create our sender address.

Code incorporated

Now, to the code:

    lo_bcs type ref to cl_bcs,
    lo_sender type ref to cl_sapuser_bcs,
    lo_recipient type ref to cl_sapuser_bcs,
    lv_ret type os_boolean.
lo_bcs = cl_bcs=>create_persistent( ).
lo_sender = cl_sapuser_bcs=>create( 'WF-BATCH' ).
lo_bcs->set_sender( i_sender = lo_sender ).
lo_recipient = cl_sapuser_bcs=>create( 'USER_TO' ).
    i_recipient = lo_recipient
* create document and add to lo_bcs with lo_bcs->set_document( lo_doc )
lv_ret = lo_bcs->send( ).

Et voilà! Run our program, release the email from SOST and our email disclosure document is there, in all its glory!

WF-BATCH email disclosure document appended!

So if you find that your disclosure documents aren’t being applied correctly in code-generated emails, it may be that you need to change the type of sender and receiver objects you’re using.


Assigned tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      What more could I want?  Very nice blog.  It's another bookmark for me.  I have a lot of favorites and a lot of folders.

      Thank you!


      Author's profile photo Trond Stroemme
      Trond Stroemme
      Great blog! I'll try to incorporate these elements into my Code Exchange project "ABAP e-mails made easy", in which I've set up a class that uses the BCS framework to handle all mail-related functionality. You might want to have a look!


      Author's profile photo Former Member
      Former Member
      Great blog Hagen.
      Taught us something new as we were not using it till now.
      However we are noticing that the email text is going as attachment, whereas whatever is in the disclosure (SODIS)is going as inline text.
      I read a similar problem here:
      Problems with tcode SODIS and external Email (contents as attachment)
      The reply posted in the end is that SAP claims it is standard behaviour.
      Is this really the case? If so, any way to bypass it, otherwise the use of it will become very limited.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi all,
      There’ve been a couple of emails regarding what appears to be odd behaviour when adding disclosure documents to emails - the email body becomes an attachment, but the disclosure is displayed inline. It would appear that this is indeed standard behaviour.

      In the next few days, I'll dive in to email sending again and try to work out if we can't - with an enhancement or the like - work around this so as to keep the body of the email in tact and inline.

      I think this happens because the content of your email will either be HTM or TXT (RAW), but the disclosure is always RAW text - subsequently, it's safest to simply move the email body into an attachment, rather than trying to build a disclosure in html and append that. Once HTML is in the mix, then we have to worry about styles and rendering in the various recipient email clients.

      More on this later…

      Thanks all for commenting - glad you've found the blog useful. Couple of ideas for the next one.

      Author's profile photo Raquel Pereira da Cunha
      Raquel Pereira da Cunha
      really useful blog, very detailed and, as Michelle said, easy to follow.


      Author's profile photo Former Member
      Former Member

      Just ran across your blog while doing a search for wf-batch and the sending email address.  This is a great, detailed entry.  Another reason why I use SCN.  Thanks for this.


      Author's profile photo Vipin Nagpal
      Vipin Nagpal

      Hi, I have selected a radio button as Application driven instead of disclosures always appended. What extra setting I need to do to enable this setting.