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

Probl. in attachment using FM 'SO_DOCUMENT_SEND_API1'

Former Member
0 Likes
1,123

I have used FM 'SO_DOCUMENT_SEND_API1' for email with attachment.

I am getting the mail also the attachment ...

But the data in attachment is not proper .. its like

Test Data for attachment1.

Test Data for attachment2.

Test data for attchment3.

Instead of ........

Test Data for attachment1.

Test Data for attachment2.

Test data for attchment3.

9 REPLIES 9
Read only

Former Member
0 Likes
986

The data in attachment is

Test Data for attachment1.

' SPACES 'Test Data for attachment2.

' SPACES 'Test data for attchment3.

Message was edited by:

Omkar Mirvankar

Message was edited by:

Omkar Mirvankar

Read only

0 Likes
986

Hi,

What attachment are you trying to send??

Read only

0 Likes
986

I am sending table details in a text file as attachment

Message was edited by:

Omkar Mirvankar

Read only

0 Likes
986

Give a line feed (cl_abap_char_utilities=>cr_lf) at the end of each line while preparing the attachment.

Regards,

Pankaj

Read only

0 Likes
986

Hi,

You have to handle TXT or CSV attachment differently.

You may need to add a Carriage Return Line Feed at the end of your 255 character string....like:

data: w_CR(2) type x value '0D0A'.

........

concatenate <field_name>

w_CR into <field_name>.

You can Also try FM SO_RAW_TO_RTF.

Read only

0 Likes
986

can u elaborate a bit more on this line feed ...

i didnt get this ' cl_abap_char_utilities=>cr_lf '

Read only

0 Likes
986

When u r populating the table to pass as attachment ... concatenate line feed at the end of each row of internal table

concatenate "data" <Line feed> into workarea.

append workarea to internatable

Regards,

Pankaj

Read only

0 Likes
986

I tried using line feed but ..

it didnt wrk ...

the number of characters is not greater than 255 characters ..

Read only

Former Member
0 Likes
986

Hi Omkar,

You have to concatenate evrey field with the unicode form of TAB for notepad and every new line with the unicode character for NEWLINE of notepad.

Try using this,

LOOP AT gt_itab INTO gs_itab.

CONCATENATE gv_content

gs_itab-key_desc

c_separator

gs_itab-keyword_id

c_separator

gs_itab-class_descr

c_separator

gs_itab-class

INTO gv_content.

IF sy-subrc = 0.

CONCATENATE gv_content c_delimit INTO gv_content.

ENDIF.

CLEAR gs_key_class.

ENDLOOP.

lv_content_len = strlen( gv_content ).

IF lv_content_len <> 0.

lv_increment = 255.

WHILE lv_num <= lv_content_len.

gv_total = gv_total + 1.

gs_email_content-line = gv_content+lv_num(lv_increment).

lv_num = lv_num + 255.

lv_sum = lv_num + lv_increment.

  • Check if the offset length should be less than 255 characters.

IF ( lv_sum > lv_content_len ).

lv_increment = lv_content_len - lv_num.

ENDIF.

APPEND gs_email_content TO gt_email_content.

CLEAR: gs_email_content.

ENDWHILE.

ELSE.

MESSAGE e000(mc) WITH text-002.

ENDIF.

Now you should know the unicode for c_seperator and c_delimit for notepad.

For CSV file 'C_SEPERATOR' = '~',

'C_DELIMIT' = 'ODOA'.

I think the usage of function module is simple as you have implemented it.

Hope this helps,

Paul.