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

Problem with SO_DOCUMENT_SEND_API1 in txt attachment with '#'

maria_merino
Active Participant
0 Likes
4,246

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

1 ACCEPTED SOLUTION
Read only

Sandra_Rossi
Active Contributor
3,085

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_*.

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

6 REPLIES 6
Read only

former_member182371
Active Contributor
3,085

Hi,

check this blog:

ABAP and Line Feeds

Best regards,

Pablo

Read only

0 Likes
3,085

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

María

Read only

0 Likes
3,085

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|.

Read only

Sandra_Rossi
Active Contributor
3,086

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_*.

Read only

matt
Active Contributor
3,085

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.

Read only

0 Likes
3,085

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 !