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: 

Problem in attaching an MS word document

Former Member
0 Kudos

Hi All,

I have to send a <b>'.Doc'</b> file as attachment.

First I save the contents in a database table by uploading through BSP-upload in the form of <b>xstring</b>.

Now I perform following steps:

1. read them with a 'Select' statement

2. convert them from <b>xstring to stri</b>ng

3. fill the parameter <b>'contents_bin'</b> of the function module: <b>'SO_NEW_DOCUMENT_ATT_SEND_API1'</b>

4. set <b>transf_bin = 'X'</b> and <b>doc_type = 'DOC'</b>.

5. send mail by calling the same FM.

Now, my problem is:

If the uploaded file is '.Txt' , then the receiver gets attachment perfectly.

But if the uploaded data is '.Doc' then the attachment has some coding type text, not the original contents because of some <b>conversion error</b>.

Now my question is:

what <b>'CODDEPAGE</b>' should I use in conversion from Xstring to String so that I may avoid that error.

Currently i am using:

CALL FUNCTION <b>'HR_KR_XSTRING_TO_STRING'</b>

EXPORTING

FROM_CODEPAGE = <b>'8400'</b>

IN_XSTRING = xcontents

IMPORTING

OUT_STRING = contents

.

Can anybody help?

Thanks in advance,

Pragya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Raja,

when I convert into binary and try to send then the receiver is not able to even open the document.

it gives an error:

Document or path is not valid!

Can you help me what I am missing here.

Thanks and Regards,

pragya

6 REPLIES 6

Former Member
0 Kudos

hii

check out this link..

<b></b>

hope this helps

Thanks &Regards

Naresh

Former Member
0 Kudos

Hi Naresh,

Thanks for your response.

I have seen the thread mentioned by you. But that is also having the same query unanswered that how to attach preformatted word documnet.

I am facing the same problem as I am unable to carry out proper conversion from xstring to string.

I have tried some 'Codepage' values like : 8400, 1160, 4100, 4103 etc. But no one os working.

Hope I have described my problem clearly.

regards,

pragya

athavanraja
Active Contributor
0 Kudos

you dont need to convert xstring to string. you should convert xstring to binary

use the following code for the same.

data: xl_content type xstring .

DATA: binary_content TYPE solix_tab.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = xl_content

TABLES

binary_tab = binary_content.

now you can pass the binary_content to your email FM

Looks like you are on WAS, in such a case use CL_BCS class for email. they are much easier to handle and very flexible.

let me know if you need help with CL_BCS

Regards

Raja

Former Member
0 Kudos

Hii

convert the xstring to string using FM

<b>ECATT_CONV_XSTRING_TO_STRING</b> and then convert the string to a table format acceptable by the email FM or class using FM

<b>CALL FUNCTION 'SCMS_STRING_TO_FTEXT'

EXPORTING

text = <string>

TABLES

ftext_tab = <table>.</b>

chk out this url

Thanks&Regards

Naresh

Former Member
0 Kudos

Hi Raja,

when I convert into binary and try to send then the receiver is not able to even open the document.

it gives an error:

Document or path is not valid!

Can you help me what I am missing here.

Thanks and Regards,

pragya

0 Kudos

check out this demo program

BCS_EXAMPLE_5

copy this to your name space (y/z).

in this program read the xstring from your ztable and convert it to binary using

data: xl_content type xstring .

DATA: binary_content TYPE solix_tab.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

EXPORTING

buffer = xl_content

TABLES

binary_tab = binary_content.

and pass the binary content to add attachment method.

Regards

Raja