Skip to Content
0
Former Member
Apr 29, 2009 at 02:03 PM

Strange inserts in attachement file

20 Views

Hi,

I am making a program with send an email with attachement file. Everything works well except data in the attachement file.

Code:

REPORT ZTEST.

DATA: DOCUMENT_DATA LIKE SODOCCHGI1 OCCURS 5 WITH HEADER LINE.

DATA: PACKING_LIST LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: RECEIVER LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE.

DATA: CONTENTS_TXT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

DATA: CONTENTS_BIN LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE.

DATA: LINES TYPE I.

DATA: DOC_TYPE LIKE SOODK-OBJTP VALUE 'txt'.

DOCUMENT_DATA-OBJ_DESCR = 'subject'.

DOCUMENT_DATA-OBJ_NAME = 'subject'.

DOCUMENT_DATA-SENSITIVTY = 'P'.

DOCUMENT_DATA-OBJ_LANGU = SY-LANGU.

DOCUMENT_DATA-OBJ_EXPDAT = sy-datum + 31.

CONTENTS_TXT = 'Hello'.

APPEND CONTENTS_TXT.

DESCRIBE TABLE CONTENTS_TXT LINES lines.

READ TABLE CONTENTS_TXT INDEX lines.

DOCUMENT_DATA-DOC_SIZE = ( lines - 1 ) * 255 + STRLEN( CONTENTS_TXT ).

CLEAR PACKING_LIST-TRANSF_BIN.

PACKING_LIST-HEAD_START = 1.

PACKING_LIST-HEAD_NUM = 0.

PACKING_LIST-BODY_START = 1.

PACKING_LIST-BODY_NUM = lines.

PACKING_LIST-DOC_TYPE = 'RAW'.

APPEND PACKING_LIST.

receiver-rec_type = 'U'. "Internet address

receiver-express = 'X'. "Express

receiver-receiver = 'user_email_address'.

append receiver.

APPEND 'Hey' TO CONTENTS_BIN.

APPEND 'How do you do CHRIS?' TO CONTENTS_BIN.

DESCRIBE TABLE CONTENTS_BIN LINES lines.

  • write : / lines.

PACKING_LIST-TRANSF_BIN = 'X'.

PACKING_LIST-HEAD_START = 1.

PACKING_LIST-HEAD_NUM = 0.

PACKING_LIST-BODY_START = 1.

PACKING_LIST-BODY_NUM = lines.

PACKING_LIST-DOC_TYPE = DOC_TYPE.

PACKING_LIST-OBJ_NAME = 'Attachment'.

PACKING_LIST-OBJ_DESCR = 'Attachment'.

PACKING_LIST-DOC_SIZE = ( lines - 1 ) * 255 + STRLEN( CONTENTS_BIN ).

APPEND PACKING_LIST.

CALL FUNCTION 'SO_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOCUMENT_DATA

SENDER_ADDRESS_TYPE = 'U'

COMMIT_WORK = 'X'

TABLES

PACKING_LIST = PACKING_LIST

CONTENTS_TXT = CONTENTS_TXT

CONTENTS_BIN = CONTENTS_BIN

RECEIVERS = RECEIVER

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

Problem:

The text in the attachement file should be like

Hey

How do you do CHRIS?

but it appears like

H e y H o w d o y o u d o C H R I S ?

I have noticed that if i want to display the first line "Hey", I have to set doc_size to 6.

I also got the same problem using the code from sap documentation of the function SO_DOCUMENT_SEND_API1.

Somebody know why it adds too much space in the attachement file ? And why it put the 2 lines on the same line ?

Thank you.

Best regards.