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: 

problem opening attached pdf file

Former Member
0 Kudos

Hi everybody,

I'm trying to open a pdf file attached in a mail, but when i try to open it adobe acrobat gives me this error.

Adobe Reader could not open <doc1.pdf> because it is either not a supported file type or the file has been damaged (for eg:it was sent as an email attachment and wasn't correctly decoded.)

I've read many posts related to this problem but i haven't found the solution yet.

Can anyone help me?

Thanx!!

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

can you show how did you create the pdf as attachment.

Did you fill the lenght of the attachment correct?

Regards, Dieter

6 REPLIES 6

Former Member
0 Kudos

Hi,

can you show how did you create the pdf as attachment.

Did you fill the lenght of the attachment correct?

Regards, Dieter

0 Kudos

Hi Dieter,

Here is the code,

doc_chng-obj_name = 'Nomina'.

doc_chng-obj_descr = 'Nomina de empleado'.

objtxt = '<html><body>Reserve price : <b>$250000</b>'.

APPEND objtxt.

objtxt = 'A reproduction of the painting to be auctioned'.

APPEND objtxt.

objtxt = 'is enclosed as an attachment.</body></html>'.

APPEND objtxt.

DESCRIBE TABLE objtxt LINES tab_lines.

READ TABLE objtxt INDEX tab_lines.

doc_chng-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).

  • Creating the entry for the compressed document

CLEAR objpack-transf_bin.

objpack-head_start = 1.

objpack-head_num = 0.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'PDF'.

APPEND objpack.

  • Crecion de attachments

  • (Assume the data in OBJBIN are given in PDF format)

DESCRIBE TABLE data_tab LINES tab_lines.

objhead = 'nomina.pdf'. APPEND objhead.

  • Creating the entry for the compressed attachment

objpack-transf_bin = 'X'.

objpack-head_start = 1.

objpack-head_num = 1.

objpack-body_start = 1.

objpack-body_num = tab_lines.

objpack-doc_type = 'PDF'.

objpack-obj_name = 'ATTACHMENT'.

objpack-obj_descr = 'Nomina Empleado'.

objpack-doc_size = tab_lines * 255.

APPEND objpack.

  • Entering names in the distribution list

reclist-receiver = 'kkkkkkkkk'.

reclist-rec_type = 'U'.

append reclist.

  • Sending the document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

document_data = doc_chng

put_in_outbox = 'X'

commit_work = 'X'

TABLES

packing_list = objpack

object_header = objhead

contents_bin = objbin

contents_txt = objtxt

receivers = reclist

EXCEPTIONS

too_many_receivers = 1

document_not_sent = 2

operation_no_authorization = 4

OTHERS = 99.

Former Member
0 Kudos

Hi,

There is a simillar thread posted ,gothrough the below thread you will find the solution.

https://forums.sdn.sap.com/click.jspa?searchID=16029226&messageID=3918233

Best WIshes,

Raj.

0 Kudos

Hi Raja,

I've tried to do the same as the code you post me in the link but i still have the same problem.

Thanx

Former Member
0 Kudos

Hi,

I am also facing the same problem ...any answers ??

thanks

0 Kudos

Hi everybody, finally i was able to solve my problem. here is the source code.

bye


call function fm_name
  EXPORTING
    /1bcdwb/docparams  = fp_docparams
    param              = wa_form1
    param1             = wa_form1_mes
    iv_image_url       = gv_image_url
  IMPORTING
    /1BCDWB/FORMOUTPUT = fp_result
  EXCEPTIONS
    usage_error        = 1
    system_error       = 2
    internal_error     = 3
    others             = 4.


call function 'FP_JOB_CLOSE'
  EXCEPTIONS
    usage_error    = 1
    system_error   = 2
    internal_error = 3
    others         = 4.

data: pdf type fpformoutput-pdf.
pdf = fp_result-pdf.


data: bcs_exception type ref to cx_bcs.
try.

  l_subject = 'Ikastaroen finantzaketa'.
  concatenate 'XXXXXXXXXXXXXXXXXX'
  'YYYYYYYYYYYYYYYYY'
  into l_bodytext_row.
  append l_bodytext_row to lt_bodytext.


* Create the email document object
  data: document TYPE REF TO cl_document_bcs,
  num_rows type i,
  textlength type so_obj_len.
  describe table lt_bodytext lines num_rows.
  num_rows = num_rows * 255.
  move num_rows to textlength.
  document = cl_document_bcs=>create_document(
    i_type = 'RAW'
    i_text = lt_bodytext
    i_length = textlength
    i_subject = l_subject ).


*   Add attachment
  data: attdoctype type soodk-objtp,
  atttitle type SOOD-OBJDES,
  attsize type SOOD-OBJLEN,
  pdftab type SOLIX_TAB.
  attdoctype = 'pdf'.
  atttitle = 'XXXXX'.
  attsize = xstrlen( pdf ).
  pdftab = cl_document_bcs=>xstring_to_solix(
  ip_xstring = pdf ).
  document->add_attachment( exporting I_ATTACHMENT_TYPE = attdoctype
    I_ATTACHMENT_SUBJECT = atttitle
    I_ATTACHMENT_SIZE = attsize
    I_ATTACHMENT_LANGUAGE = sy-langu
    I_ATT_CONTENT_HEX = pdftab ).

*   Create persistent send request
    data:send_request TYPE REF TO cl_bcs.
    send_request = cl_bcs=>create_persistent( ).
*    Add document to send_request.
    send_request->set_document( document ).

* Create sender
DATA:
  lo_sender TYPE REF TO if_sender_bcs VALUE IS INITIAL,
  l_send type ADR6-SMTP_ADDR value 'email address'.
  lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
* Set sender
  send_request->set_sender(
    EXPORTING
  i_sender = lo_sender ).

  p_email = 'XXXXXXXX'.

*   Create recipient.
* Create recipient.
data: recipient TYPE REF TO if_recipient_bcs.
      recipient = cl_cam_address_bcs=>create_internet_address( p_email ).
  send_request->add_recipient(
    EXPORTING
      i_recipient = recipient
      i_express = 'X' ).

*   Set send immediately
    send_request->set_send_immediately( 'X' ).
*   Send document
    send_request->send( ).
    COMMIT WORK.
message 'E-Maila bidalia izan da' type 'I'.
catch cx_bcs into bcs_exception.
  data: ex_msg type string.
  ex_msg = bcs_exception->get_text( ).
  write: 'Caught exception.', ex_msg.

Edited by: Jon Azkorra Olano on May 21, 2010 1:25 PM

Edited by: Jon Azkorra Olano on May 21, 2010 1:26 PM