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.
cancel
Showing results for 
Search instead for 
Did you mean: 

Attachment size in CL_document_bcs->send

0 Kudos

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.

1 ACCEPTED SOLUTION

Jelena
Active Contributor

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.

7 REPLIES 7

Jelena
Active Contributor

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.

0 Kudos

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.

Jelena
Active Contributor
0 Kudos

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
Active Contributor

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.

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!

0 Kudos

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?

0 Kudos

Yes, it fills the solix-line.