Application Development and Automation 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: 
Read only

method add_attachment

Former Member
0 Likes
5,081

Hi,

I use method add_attachment of class cl_document_bcs to add an attachement. The problem is:

when I use the method with


            CALL METHOD document->add_attachment
              EXPORTING
                i_attachment_type    = documents_line-type
                i_attachment_subject = documents_line-subject
                i_att_content_text   = documents_line-content_text.

documents_line-content_text is an internal table with several lines, but when I look to the attachment after running it, I get no internal table, what I get is a long row.

Did someone has an idea how to get the same internal table which I habe in documents_line-content_text???

1 ACCEPTED SOLUTION
Read only

matt
Active Contributor
0 Likes
2,394

What do you mean by: "but when I look to the attachment after running it" ?

i_att_content_text is an internal table of a 255 char field. What are you getting, and where, and what do you expect to get?

matt

8 REPLIES 8
Read only

Former Member
0 Likes
2,394

did someone has an idea?

Read only

matt
Active Contributor
0 Likes
2,395

What do you mean by: "but when I look to the attachment after running it" ?

i_att_content_text is an internal table of a 255 char field. What are you getting, and where, and what do you expect to get?

matt

Read only

Former Member
0 Likes
2,394

Hello Matt,

when I have following in my internal table:

Line 1

Line 2

I get in the attachment

Line 1 Line 2

I set the type of the attachment to csv but everything is in one line

Read only

matt
Active Contributor
0 Likes
2,394

You need to put in your own carriage return/line feeds. CL_ABAP_CHAR_UTILITIES=>CR_LF

Read only

venkat_o
Active Contributor
0 Likes
2,394

<li>Please go through the below std demo programs

BCS_EXAMPLE_5                          BCS Use, Example 5 (Winword Attachment)                      
BCS_EXAMPLE_7                          BCS: Send E-Mail with Self-Created Excel Attachment (Example)
Thanks Venkat.O

Read only

Former Member
0 Likes
2,394

coding caused following problem

Read only

0 Likes
2,394

Hi,

I also faced the same problem.

use i_attachment_type = 'RAW' in add_attachment method.

It'll work.

Thanks,

Surajit

Read only

Former Member
0 Likes
2,394

HI,

Try this code it will definitely work

data: gv_document type ref to cl_document_bcs.

data: gv_mail_text type bcsy_text,

gv_mail_text_row type soli.

data: gv_attachment type solix_tab.

try.

gv_mail_text_row = text-001.

append gv_mail_text_row to gv_mail_text.

clear gv_mail_text_row.

describe table gv_mail_text lines gv_num_rows.

gv_num_rows = gv_num_rows * 255.

move gv_num_rows to gv_text_length.

try.

call method cl_document_bcs=>create_document

EXPORTING

i_type = 'RAW'

i_subject = l_subject2

i_length = gv_text_length

i_text = gv_mail_text

RECEIVING

result = gv_document.

catch cx_document_bcs .

endtry.

gv_attachment = cl_document_bcs=>xstring_to_solix( ip_xstring = l_pdf_xstring ).

  • Define File Name

attcdoctype = 'pdf'.

atttitle = vbco3-vbeln.

  • Create Document

gv_document->add_attachment( exporting i_attachment_type = attcdoctype

i_attachment_subject = atttitle

i_attachment_language = sy-langu

i_att_content_hex = gv_attachment ).

catch cx_bcs into bcs_exception.

ENDTRY.

Regards,

Manesh.R