Skip to Content

Attachment size in CL_document_bcs->send

Jul 18, 2017 at 12:02 PM


avatar image

Hello Experts,

In a customized function we are using cl_document_bsc->add_attachment to attach documents and then cl_document_bsc->send to send email with attachments.

Some times we are not able to open the documents attached in the emails.

Following attributes are used for building the attachment.

lwa_inv_attach-type = c_pdf

lwa_inv_attach-sub = lv_subject.

lwa_inv_attach-content = it_soli.

lwa_inv_attach-size = 0.

and here it was commented as "Size of attachment should be 0, if you do try to get the size and pass it, the attachment won't open"

Could you please help me understand what is the significance of the size attribute here. We are not able to open the documents only in some instances. Is that because of this size attribute.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jelena Perfiljeva
Jul 19, 2017 at 07:20 PM

Where did you find this comment? In my experience, it's exactly the opposite - you need to fill in size otherwise you'll get an error when opening.

E.g. in one program I use size = XSTRLEN( lv_xstring ) (where lv_xstring is binary content) and then pass that value. Don't remember if I tried it with 0 but it seems totally possible that you'd end up with a wrong size then which would lead to the problem you've described.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

thanks for your answer!

That comment was mentioned in the custom function module where this code was written and I was also surprised by seeing that. I wasn't able to open the document even if I try to pass initial or some size.


It won't work with "some size". You need the correct number. Or, as Raymond's comment suggests, this should work with 0 size too. Either way, the comment "put 0 or it won't work" seems inaccurate to me. I wouldn't rely on it - the functionality could've changed since it was made. Or maybe the comment's author just ran into one case and made an incorrect assumption. Anyone can make a mistake.

Raymond Giuseppi
Jul 20, 2017 at 07:51 AM

If you pass an initial I_ATTACHMENT_SIZE the class will compute it itself, so that should usually not be a problem. You could check method COUNT_DOC_SIZE of the class.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

If you don't specify the attachment size, there is a risk of extra x00 being added to the end of the attachment file which can cause problems for the receiver of the email. I speak from recent experience!


Agree, for 'text' attachment the internal method COUNT_DOC_SIZE uses full line size for first lines and actual text width for last line, but for binary it always uses full line, so some x'00' are transfered at end, to a full SOLIX-LINE?


Yes, it fills the solix-line.