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: 

Email attachment corrupt

Former Member
0 Kudos

Greetings,

I am working on a program to send an email with an attachment from an SAP ECC6 Unicode system. I have used this same program in other versions of SAP, including ECC6, without a problem. Currently it uses the function so_object_send. But I have also tested using the class and methods for cl_bcs as well as function so_new_document_att_send_api1. All have the same issue where the attachment is corrupted. Instead of seeing the binary data for a pdf or tif. It looks like every other character within the attachment is a null or space. Has anyone else seen this happen with email attachments? Any help is greatly appreciated.

Thank You,

Alec

9 REPLIES 9

Former Member
0 Kudos

Welcome to SCN.

There are a number of recent notes about this. You can start with 787418.

Rob

0 Kudos

Hi,

We have applied all the recent notes including the one you referenced here. Email with attachment works out of the business workplace but just not with any variation of using so_object_send, so_new_document_att_send_api1 or cl_bcs. They test out fine on a 4.7 system but when tested on ECC6 with Unicode the attachment is corrupted.

Thank you,

alec

Former Member
0 Kudos

Hi,

Use this below logic to convert attachment data to hex instead of binary

CALL FUNCTION 'SO_RAW_TO_RTF'
    TABLES
      objcont_old = lt_objbin
      objcont_new = lt_objbin.

  LOOP AT lt_objbin INTO l_line.
   conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'B').
    CALL METHOD conv->write( data = l_line ).
    l_buffer = conv->get_buffer( ).
    MOVE l_buffer TO l_hexa.
    MOVE l_hexa TO l_hex-line.
    APPEND l_hex TO lt_contents_hex.
  ENDLOOP.

Refer to this link how this FM and class is used ..http://docs.google.com/Doc?id=dfv2hmgs_0fm22tggx&hl=en

I'm using this FM SO_NEW_DOCUMENT_ATT_SEND_API1

0 Kudos

Hi Avinash,

I will try this as soon as possible and post an update.

Thank You!

--alec

0 Kudos

Hi Alec,

U can go for class CL_BCS for attachment.

Also u can check the package SBCOMS for demo programs

Hope it helps

0 Kudos

Hello All,

Again thank you for all the help. The answer seems to lay in oss note 1151258 and bcs_example_7. Had to treat the attachment as binary all through out the process and use cl_bcs to send the attachment as i_att_content_hex. Only then would a scanned or pdf document work. Could not even get it it work even with so_new_document_att_send_api1.

Thank You,

Alec

Former Member
0 Kudos

Welcome to SDN Forum,

I have used email with PDF Attachment recently in ECC 6.0 Version.

Please use below code for your referenece.

REFRESH: I_RECLIST,

I_OBJTXT,

I_OBJBIN,

I_OBJPACK.

CLEAR WA_OBJHEAD.

I_OBJBIN[] = I_RECORD[].

  • Create Message Body Title and Description

loop at MAIL_CONTENT.

I_OBJTXT-line = MAIL_CONTENT-LINE.

APPEND I_OBJTXT.

clear : mail_content,

i_objtxt.

endloop.

DESCRIBE TABLE I_OBJTXT LINES V_LINES_TXT.

READ TABLE I_OBJTXT INDEX V_LINES_TXT.

WA_DOC_CHNG-OBJ_NAME = SUBJECT_LINE.

WA_DOC_CHNG-EXPIRY_DAT = SY-DATUM + 10.

WA_DOC_CHNG-OBJ_DESCR = SUBJECT_LINE.

WA_DOC_CHNG-SENSITIVTY = 'F'.

WA_DOC_CHNG-DOC_SIZE = V_LINES_TXT * 255.

  • Main Text

CLEAR I_OBJPACK-TRANSF_BIN.

I_OBJPACK-HEAD_START = 1.

I_OBJPACK-HEAD_NUM = 0.

I_OBJPACK-BODY_START = 1.

I_OBJPACK-BODY_NUM = V_LINES_TXT.

I_OBJPACK-DOC_TYPE = 'RAW'.

APPEND I_OBJPACK.

clear I_OBJPACK.

  • Attachment (pdf-Attachment)

I_OBJPACK-TRANSF_BIN = 'X'.

I_OBJPACK-HEAD_START = 1.

I_OBJPACK-HEAD_NUM = 0.

I_OBJPACK-BODY_START = 1.

DESCRIBE TABLE I_OBJBIN LINES V_LINES_BIN.

READ TABLE I_OBJBIN INDEX V_LINES_BIN.

I_OBJPACK-DOC_SIZE = V_LINES_BIN * 255 .

I_OBJPACK-BODY_NUM = V_LINES_BIN.

I_OBJPACK-DOC_TYPE = 'PDF'.

I_OBJPACK-OBJ_NAME = 'smart'.

I_OBJPACK-OBJ_DESCR = V_VBELN.

APPEND I_OBJPACK.

clear i_objpack.

CLEAR I_RECLIST.

refresh I_RECLIST.

LOOP AT T_EMAIL.

TRANSLATE T_EMAIL-EMAIL TO UPPER CASE.

I_RECLIST-RECEIVER = T_EMAIL-EMAIL.

I_RECLIST-REC_TYPE = 'U'.

APPEND I_RECLIST.

clear I_RECLIST.

ENDLOOP.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = WA_DOC_CHNG

PUT_IN_OUTBOX = 'X'

  • COMMIT_WORK = 'X'

TABLES

PACKING_LIST = I_OBJPACK

OBJECT_HEADER = WA_OBJHEAD

CONTENTS_BIN = I_OBJBIN

CONTENTS_TXT = I_OBJTXT

RECEIVERS = I_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.

Thank you

Seshu

0 Kudos

Hi Seshu,

This seems to have the same problem. Can you verify it was in a pure unicode ECC6 system?

Thank You,

Alec

0 Kudos

Hello Alec,

It is unicode ecc version.

Thank you

Seshu