Skip to Content
0

Problem with SO_DOCUMENT_SEND_API1 in txt attachment with '#'

Mar 06, 2017 at 02:11 PM

299

avatar image

Hi experts,

I have a report that was going well until some weeks ago, I don't know if it's due to migration to hana or to unicode.

We we're using fm SO_DOCUMENT_SEND_API1 to send a mail with an attachment .TXT. We used

CONSTANTS: crlf TYPE c VALUE cl_abap_char_utilities=>cr_lf.

to separate lines and it was working fine but now it doesn't work anymore. When I debug the code I see in each line '#' indicating the new line. When I open the file attached to the mail there is no format as you can see in my attach.

contrato.jpg

That's how I call the fm


call function 'SO_DOCUMENT_SEND_API1'
exporting
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = 'X'
SENDER_ADDRESS = LD_SENDER_ADDRESS
SENDER_ADDRESS_TYPE = LD_SENDER_ADDRESS_TYPE
COMMIT_WORK = 'X'
importing
SENT_TO_ALL = W_SENT_ALL
tables
PACKING_LIST = T_PACKING_LIST
CONTENTS_BIN = T_ATTACHMENT
CONTENTS_TXT = IT_MESSAGE
RECEIVERS = T_RECEIVERS
exceptions
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.

T_ATTACHMENT contains the text attached, should I convert this internal table to binary mode ? At this moment it looks like:

atta.jpg

Thanks in advance !!

María

contrato.jpg (65.7 kB)
atta.jpg (44.3 kB)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sandra Rossi Mar 06, 2017 at 08:24 PM
3

Why are you passing a "text" via the "binary" parameter (reserved for images, PDFs, ZIPs, etc., but NOT text), why don't you use the "text" parameter? It used to work because in the past, before Unicode, a character was a byte and vice versa. If you pass your text as a text, make sure to pass packing_list-transf_bin = abap_false. Moreover, why not using CL_BCS? See the many sample programs BCS_EXAMPLE_*.

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

Absolutely. SO_DOCUMENT_SEND_API1 is not only obsolete but was always problematical. The OP should take the time to redevelop the program using CL_BCS classes.

1

This report has been working for years, it's not me who developped it, but it's me who has to solve the problem. I've been thinking on using CL_BCS but before doing that I want to understand the problem.

Sandra, I'll change the parameter and tell you if it works. Thanks !

0
Pablo Casamayor Mar 06, 2017 at 02:17 PM
1

Hi,

check this blog:

ABAP and Line Feeds

Best regards,

Pablo

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

Thanks for the answer Pablo, but I don't find any solution for my problem in this link.

María

0

I'd imagine Pablo is referring to the following passage from the blog:

First, where to use it not. You cannot use a line feed character or any other control character in classical list programming. The following line

WRITE |aaaa\nbbbbb|.

produces an output like aaaa#bbbbb. The classical list processor does not recognize the control character and it does not treat it as a whitespace. It is an unknown character that is displayed as #. In classical list programming you have to use two (chained) WRITE-Statements:

WRITE: |aaaa|, / |bbbbb|.

0