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

Email Attachment Format Error

Former Member
0 Likes
544

hi frn's ,

i am sending an email with text attachment ....but not getting in desired format in text attachment....

please help

Itab value:

abcdefdfldjfñlkdsjfñldsjfdsñljñla

fdsljfñldskjfldsñkjfñldsjfñldsajñld

vcxusfcxusfcusafcxusafcusafcdsauc

Actual result currently coming in text file:

abcdefdfldjfñlkdsjfñldsjfdsñljñlafdsljfñldskjfldsñkjfñldsjfñldsajñldvcxusfcxusfcusafcxusafcusafcdsauc

Desired format should be

abcdefdfldjfñlkdsjfñldsjfdsñljñla

fdsljfñldskjfldsñkjfñldsjfñldsajñld

vcxusfcxusfcusafcxusafcusafcdsauc

Thanks and Regards

Priyank

4 REPLIES 4
Read only

Former Member
0 Likes
497

Hi!

I think what is missing in your output file is a new line character. While creating the internal table concatenate hex value '0D0A' after every line. This will put text in a new line. Alternately you can use CL_ABAP_CHAR_UTILITIES=>CR_LF in ECC 6.

This should resolve the problem.

Cheers!

Read only

0 Likes
497

Hi Anurag ,

now i am using your trick ....like this

loop at it_error into wa_error.

CONCATENATE wa_error CL_ABAP_CHAR_UTILITIES=>CR_LF INTO it_attach_error.

  • move wa_error to it_attach_error.

APPEND it_attach_error.

ENDLOOP.

the out attchment changed from the previous one ....but not like that as i want ....

it is now comming ike the below one ...(leading space are there in second line )

internal table...

.

abcdefghijkl...

1234567899....

output comming ....

abcdefghijkl

1234567890

desired output is ...

abcdefghijkl

1234567890

Thanks and Regards ..

Priyank

Read only

sreeramkumar_madisetty
Active Contributor
0 Likes
497

Hi

Before Post the Attchment Function Module,Use the FM: QCE1_CONVERT to get the attachment data in a proper format.

Regards,

Sreeram

Read only

Former Member
0 Likes
497

i give some coding below

DATA: it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0

WITH HEADER LINE.

data :con_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab ,

con_cret TYPE c VALUE cl_abap_char_utilities=>cr_lf.

LOOP AT i_mail_sent.

CONCATENATE

i_mail_sent-prueflos

i_mail_sent-lifnr

i_mail_sent-werk

i_mail_sent-lagortchrg

i_mail_sent-matnr

i_mail_sent-ebeln

i_mail_sent-ebelp

i_mail_sent-mblnr

i_mail_sent-losmenge

i_mail_sent-mengeneinh

i_mail_sent-vname

i_mail_sent-vdatum

i_mail_sent-dec INTO it_attach SEPARATED BY con_tab

.

CONCATENATE con_cret it_attach INTO it_attach.

APPEND it_attach.

CLEAR : it_attach.

ENDLOOP.

FORM sendmail TABLES p_it_message

p_it_attach

USING p_mtitle

p_format

p_filename

p_attdescription

p_sender_address

p_sender_addres_type.

REFRESH : docdata,docdata[].

docdata-doc_size = 1.

docdata-obj_langu = sy-langu.

docdata-obj_name = 'SAPRPT'.

docdata-obj_descr = p_mtitle.

docdata-sensitivty = 'F'.

  • Fill the document data and get size of attachment

CLEAR docdata.

READ TABLE it_attach INDEX tab_lines.

docdata-doc_size =

( tab_lines - 1 ) * 255 + STRLEN( it_attach ).

docdata-obj_langu = sy-langu.

docdata-obj_name = 'SAPRPT'.

docdata-obj_descr = p_mtitle.

  • 'Pending Call List.xls Format'.

docdata-sensitivty = 'F'.

t_attachment[] = p_it_attach[].

REFRESH : objpack,objpack[].

CLEAR objpack.

REFRESH objpack.

objpack-transf_bin = space.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

DESCRIBE TABLE it_message LINES objpack-body_num.

objpack-doc_type = 'RAW'.

APPEND objpack.

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

DESCRIBE TABLE t_attachment LINES objpack-body_num.

objpack-doc_type = p_format." 'XLS'. "ld_format.

objpack-obj_descr = 'Lot Details.'.

  • objpack-obj_descr = p_attdescription. "'Pending Call List.'.

"ld_attdescription.

objpack-obj_name = 'Lot Details' ." p_filename.

"'filename'."ld_attfilename.

objpack-doc_size = objpack-body_num * 255.

APPEND objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = docdata

put_in_outbox = 'X'

commit_work = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

TABLES

packing_list = objpack

  • OBJECT_HEADER =

contents_bin = t_attachment

contents_txt = it_message

  • CONTENTS_HEX =

  • OBJECT_PARA =

  • OBJECT_PARB =

receivers = reclist

  • 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

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

MESSAGE ' Records Successfully Send' TYPE 'I'.

ENDIF.