Skip to Content
0
Former Member
Sep 23, 2011 at 04:05 AM

SODIS, email disclosure documents not appearing in emails... SOLVED

169 Views

Hi all,

recently uncovered a useful item to make note of, while trying to modify email headers, previously posted in .

In this instance, I was sending email with ABAP code using classes cl_bcs, cl_document_bcs, etc. and setting up email disclosure documents through tx SODIS. I set up disclosure documents for individual users (notably, our workflow user WF-BATCH and my User ID), but when sending email in code using those users (sender and recipient), noticed that only the Standard/Default email disclosure statement was being appended to emails as they were released from SOST.

The problem appeared to be the manner in which I was creating the sender and recipient objects in my code. I was using cl_cam_address_bcs to create a sender and receiver (note, I have used USERNAME_FROM and USERNAME_TO to demonstrate the different users and their role in sending/receiving emails...):

data:
    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 = 'USERNAME_FROM' ).
lo_bcs->set_sender( i_sender = lo_sender ).

lo_recipient = cl_cam_address_bcs=>create_user_home_address( i_user = 'USERNAME_TO' ).
lo_bcs->add_recipient(
    i_recipient = lo_recipient
    i_copy = '' " CC indicator
).

* create document and add to lo_bcs with lo_bcs->set_document( lo_doc )

lv_ret = lo_bcs->send( ).

This is fine and will work to send to external addresses (i.e. to send an email to Outlook) but if the sender is WF-BATCH, it will not find the correct disclosure document I created for WF-BATCH.

After much debugging, I noticed that the address type of the sender had to be 'B' (SAP User) when the disclosure document was selected, but the cl_cam_address_bcs doesn't allow creation of SAP User addresses. It only allows the six (6) external comm. types INT, X400, RML, PRT, PAG and FAX. No 'B'. Problem.

I found it here:

FG SOE2

FM SO_OBJECT_MIME_GET

FORM GET_MIME

Class method cl_bcs_send_request->as_mime_message( )

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

Class method cl_disclosure_bcs->get_disclosure( )

Class method cl_disclosure_bcs->resolve( )

(Here you can see the try statement and a case statement - this is where the action happens)

However, this class cl_cam_address_bcs does implement interface if_sender_bcs, so it was relatively easy to find out what other classes implement if_sender_bcs. Turns out, cl_sapuser_bcs does this and it defaults to the address type 'B' - SAP User. So I replaced the above code in my program, with the following:

data:
    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( 'USERNAME_FROM' ).
lo_bcs->set_sender( i_sender = lo_sender ).

lo_recipient = cl_sapuser_bcs=>create( 'USERNAME_TO' ).
lo_bcs->add_recipient(
    i_recipient = lo_recipient
    i_copy = '' " CC indicator
).

* create document and add to lo_bcs with lo_bcs->set_document( lo_doc )

lv_ret = lo_bcs->send( ).

Et voila! The disclosure statement for USERNAME_FROM was applied perfectly.

Now there are other ways to achieve this, such as using the email address filter when creating the disclosure document, but I like to keep it to the system-used username rather than an ambiguous email address that could potentially change.

So if you find that your disclosure documents aren't being applied correctly in code-generated emails, there's your answer. Hope that little break-down helps someone.

Hagen