cancel
Showing results for 
Search instead for 
Did you mean: 

Error while openeing PDF attachment sent thru smartform

Former Member
0 Kudos

Hi,

I have tried all the options and also gone thru all the quries and replies in SDN but could not find answer for this.

I have developed a smart from with some table fetch data from PAYR. Now i have written an ABAP code to sent the output of a smartform as PDF in the email.

Im getting an error "There was an error openeing htis doc and file is damaged and coul dnot be repaired".

Here is my code.

CLEAR WA_BUFFER.

LOOP AT I_TLINE.

TRANSLATE I_TLINE USING '~'.

CONCATENATE WA_BUFFER I_TLINE INTO WA_BUFFER.

ENDLOOP.

TRANSLATE WA_BUFFER USING '~'.

CLEAR: I_RECORD. REFRESH: I_RECORD.

DO.

I_RECORD = WA_BUFFER.

APPEND I_RECORD.

SHIFT WA_BUFFER LEFT BY 255 PLACES.

IF WA_BUFFER IS INITIAL.

EXIT.

ENDIF.

ENDDO.

I_OBJBIN] = I_RECORD[.

I_OBJPACK-TRANSF_BIN = 'X'.

I_OBJPACK-HEAD_START = 1.

I_OBJPACK-HEAD_NUM = 1.

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-DOC_SIZE = ( v_lines_bin - 1 ) * 255 + strlen( i_objbin ).

I_OBJPACK-BODY_NUM = V_LINES_BIN.

I_OBJPACK-DOC_TYPE = 'PDF'.

I_OBJPACK-OBJ_NAME = 'smart'.

I_OBJPACK-OBJ_DESCR = 'test'.

APPEND I_OBJPACK.

I_RECLIST-RECEIVER = 'ABC.gmail.com'.

I_RECLIST-REC_TYPE = 'U'.

APPEND I_RECLIST.

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.

IF SY-SUBRC 0.

WRITE:/ 'Error When Sending the File', SY-SUBRC.

ELSE.

WRITE:/ 'Mail sent'.

ENDIF.

Pls help me in sloving out this.

Thanks.

Accepted Solutions (0)

Answers (1)

Answers (1)

Sm1tje
Active Contributor
0 Kudos

Sounds familiar but not sure. Have you tried using OTF format in stead of PDF and in the file name use document.pdf??