Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
Showing results for 
Search instead for 
Did you mean: 

How to send a document using CL_BCS instead of using a the function SO_NEW_DOCUMENT_ATT_SEND_API1

0 Kudos

Hi, I was having an issue when sending a document which is an excel file when I'm using the function module SO_NEW_DOCUMENT_ATT_SEND_API1. The chinese and japanese characters turns into special unreadable characters. Is there a way to send use CL_BCS instead of using this FUNCTION MODULE?

document_data = lx_mail_title
commit_work = abap_true
sent_to_all = l_sent_to_all
packing_list = lt_objpack
object_header = lt_objhead
contents_bin =
contents_txt =
receivers =
too_many_receivers = 1
document_not_sent = 2
document_type_not_exist = 3
operation_no_authorization = 4
parameter_error = 5
x_error = 6
enqueue_error = 7
others = 8

Active Contributor
0 Kudos

Your issue about characters is not related to using SO_NEW_DOCUMENT_ATT_SEND_API1 or CL_BCS.

Your issue is about how you encode the characters (I guess your "Excel" file is format CSV or tab-delimited values). The best character set supported by Microsoft Excel is UTF16-LE, you should add a BOM so that to help Excel recognize it.

0 Kudos

sandra.rossi Actually I'm also using the SO_NEW_DOCUMENT_ATT_SEND_API1 so I will receive a SEND REQUEST in SOSA and a document in SBWP. However, when I use the FM, the document which is an excel fill gets sent to SBWP and I will receive a send request in SOSA. The excel file attachement in SBWP will have a special characters.

However, when I don't use the FM, the document will be sent to the SBWP bbecause I have a code but I will not receive a send request in SOSA or others call SOST(I can't access this)

"Set the recipient
lo_sender = cl_sapuser_bcs=>create( s_inbox-low ).

lo_send_request->add_recipient( lo_sender ).


Hi Wane,

Yes you can, although that is probably not going to solve your encoding issue as Sandra Rossi said above. That is probably an encoding issue that you have on your file. In any case, to answer your question, if you make a quick search in SAP you will find many examples. This is one I just found:

      document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = body
i_subject = subject).

* add the spread sheet as attachment to document object
i_attachment_type = 'xls'
i_attachment_subject = filename
i_attachment_size = size
i_att_content_hex = binary_content ).

* add document object to send request
send_request->set_document( document ).

Now you only have to send it and you will receive an email with the attached file.

Active Contributor

The fact that you see the outbound message in SOSA, SOST, SBWP or whatever, doesn't depend on using the FM or the class, but on the sender parameter you pass. In my system, if I use CL_BCS, I can see the message in SOSA/SOST (both run exactly the same program/same data is displayed). CL_BCS is just the latest API that is recommended officially by SAP.

My comment was more about to point out that you are trying another solution without understanding the actual issue. With CL_BCS, that will be the same issue. I hope you understand. If not, I'd be happy to clarify.

0 Kudos

sandra.rossi Thanks! I was able to figure out how to receive a SEND request in SOSA/SOST. However I was having issues in which the recipient is SAP User ID instead of the email equivalent of the SAP User ID. Also, I'm receiving the send request by BY REMOTE SAP instead of BY EMAIL.

Expected send method: By Email instead of by remote sap

Expected Recipient: but it shows the sap user of john carter which is johncar12

Active Contributor
0 Kudos

You can send to JOHNCAR12, and the user will see the message in the inbox (SOIN/SBWP).

As SAP user JOHNCAR12 is assigned to an email address, the user will also receive an email.

Maybe there's a little configuration needed in SCOT (the general SAPconnect transaction).

SAP Remote Mail is just sending the message through RFC.

You are exploring many things, but don't you just want to send an email (through internet)?

0 Kudos

sandra.rossi The user wants this setup so I have no say. The only issue is they want in the recipient column It has to show the internet email address instead of its SAP USER ID.

Active Contributor
0 Kudos

Okay. So, it's 2 different requirements:

  1. They want to receive emails in their mail client (Outlook and so on).
  2. They want to enhance SOST/SOSA to see the email address instead of SAP user.

I guess you know how to do number 1. You should ask a question for number 2. The requirement should be precisely described: What do they want to see if there are several recipients? What if one SAP user doesn't have an email address? etc. And most importantly: is there any interest to pay for that?