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: 

PDF attachment is not opening in Email

Former Member
0 Kudos

Hi Experts,

I am sending an email with PDF attachment . When try to open the attachment it shows a error like wasnt decoded correctly.

I am using FM ARCHIVOBJECT_GET_TABLE to get the binary data of images stored as pDF in archivelink.

this binary data is passing to the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send the Email.

Can anybody suggest a solution .

Regards,

Ratheesh

4 REPLIES 4

SuhaSaha
Advisor
Advisor
0 Kudos

Hello Rateesh,

Can you please share the code with us?

Suhas

Former Member
0 Kudos

Hi Suhas,

Please see the code .

CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'

EXPORTING

archiv_id = 'Z1'

document_type = 'PDF'

archiv_doc_id = '48EBB2D928F15388E10000000A3597E9'

  • ALL_COMPONENTS =

SIGNATURE = 'X'

COMPID = 'DATA'

IMPORTING

LENGTH = LENGTH

BINLENGTH = BINLENGTH

TABLES

ARCHIVOBJECT = ARCHIVOBJECT

BINARCHIVOBJECT = BINARCHIVOBJECT

EXCEPTIONS

ERROR_ARCHIV = 1

ERROR_COMMUNICATIONTABLE = 2

ERROR_KERNEL = 3

OTHERS = 4

.

IF sy-subrc <> 0.

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

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

ENDIF.

LOOP AT BINARCHIVOBJECT INTO ls_binarchivobject.

CONCATENATE lv_buffer ls_binarchivobject-line INTO lv_buffer

IN BYTE MODE.

ENDLOOP.

x = 0.

DO.

objbin1-line = lv_buffer+x.

append objbin1 to objbin.

*

* objhex1-line = lv_buffer+x.

*

* APPEND objhex1 to objhex.

x = x + 255.

IF x GT BINLENGTH. EXIT.

ENDIF.

ENDDO.

REFRESH i_objtxt[].

wa_objtxt = 'Test Mail'.

APPEND wa_objtxt TO i_objtxt.

CLEAR wa_doc_chng.

wa_doc_chng-obj_name = 'Invoice Details'.

wa_doc_chng-obj_descr = 'Invoice Details'.

DESCRIBE TABLE i_objtxt LINES w_l1.

READ TABLE i_objtxt INTO wa_objtxt INDEX w_l1.

wa_doc_chng-doc_size = ( w_l1 - 1 ) * 255 + STRLEN( wa_objtxt ).

CLEAR wa_objpack-transf_bin.

wa_objpack-HEAD_START = 1.

wa_objpack-HEAD_NUM = 0.

wa_objpack-BODY_START = 1.

wa_objpack-BODY_NUM = w_l1.

wa_objpack-DOC_TYPE = 'RAW'.

APPEND wa_objpack TO i_objpack.

CLEAR wa_objpack.

wa_objpack-transf_bin = 'X'.

wa_objpack-head_start = 1.

wa_objpack-head_num = 1.

wa_objpack-doc_type = 'DOC'.

wa_objpack-body_num = w_l1 .

wa_objpack-doc_size = w_l1 * 255 .

wa_objpack-obj_name = 'TEST'.

wa_objpack-obj_descr = 'Ratheesh'.

APPEND wa_objpack TO i_objpack.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = wa_doc_chng

PUT_IN_OUTBOX = 'X'

COMMIT_WORK = 'X'

  • IMPORTING

  • SENT_TO_ALL =

  • NEW_OBJECT_ID =

tables

packing_list = i_objpack

  • OBJECT_HEADER =

CONTENTS_BIN = objbin

CONTENTS_TXT = i_objtxt

  • CONTENTS_HEX = objhex

  • OBJECT_PARA =

  • OBJECT_PARB =

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.

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

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

ENDIF.

Regards,

Ratheesh BS

Former Member
0 Kudos

Solved

0 Kudos

Hi Ratheesh,

I am working on similar requirment and facing similar problem.

will you please tell me how it was solved?

Thanks in advanced.

Regards,

Dhanashree