cancel
Showing results for 
Search instead for 
Did you mean: 

To send the generated PDF as an email

rakesh_m2
Contributor
0 Kudos

Hello Gurus,

I have created a form based on Shipment Data, which will be working from VT02N transaction. Now, the generated form should be send as an email to different users. I could find several ways to send an email with pdf file as attachment. Now, i need to send the generated pdf form as an attachment to different users. I have written a custom program as the driver program which is used to configure this form in nace. I need to extend this logic so as to send an email also.

Please help me in solving this issue.

Thanks,

Rakesh.

Edited by: rakhi966 on Aug 19, 2011 10:08 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It is a serious pain to code in ABAP to send a pdf attachment.

We generate forms in the background and attach them to send to who ever requested them.

We use FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' - you have to convert your pdf to binary and pass it in along with all the other require information.

rakesh_m2
Contributor
0 Kudos

I have been trying using the function module you have suggested. Could you please help me in convering the pdf into binary string and passing it as attachment.

Please help me in solving this issue.

Thanks,

Rakesh.

Former Member
0 Kudos

when you receive your form data, run it through FM 'SCMS_XSTRING_TO_BINARY' to convert it.

here's a code snippet of converting to binary and attaching it.


*------Convert xstring to binary
  CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
    EXPORTING
      buffer     = output-pdf
    TABLES
      binary_tab = lt_bcs_pdf.

*-----packing list for attachment
  CLEAR ls_packlist.
  ls_packlist-head_start = '1'.
  ls_packlist-head_num   = '1'.
  ls_packlist-body_start = '1'.
  lv_line = lines( lt_bcs_pdf ).
  ls_packlist-body_num   = lv_line.
  ls_packlist-doc_type   = 'BIN'.
  ls_packlist-transf_bin = 'X'.
  ls_packlist-obj_name   = 'Attachment'(006).
  ls_packlist-obj_descr  = 'Form Name.pdf'.
  ls_packlist-doc_size   = lv_pdf_size.
  APPEND ls_packlist TO lt_packlist.

*----send the email out
  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = ls_docdata
      commit_work                = 'X'
    TABLES
      packing_list                 = lt_packlist
      object_header             = lt_objhead
      contents_txt               = lt_cont_text
      contents_bin               = lt_bcs_pdf
      receivers                    = lt_receiver
    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.

rakesh_m2
Contributor
0 Kudos

Hello Robert,

I got another problem while configuring the form for the output. When I directly execute the program, mail is being sent directly along with attachment, but when I confiure the output and send from there, it is failing at commit work. It is saying "Output Terminated" when I check the same in ST22 it is giving me the detail as "COMMIT IN POSTING".

could you please help me in solving this issue. Hope my question is clear.

Thanks,

Rakesh.

Answers (1)

Answers (1)

rakesh_m2
Contributor
0 Kudos

I got another error while configuring the form as "COMMIT IN POSTING" and it is going into dump.

could any one please help me in resolving the issue

Former Member
0 Kudos

hmm.. i haven't run into that. I'll keep an eye out though.

rakesh_m2
Contributor
0 Kudos

Hello All,

I could solve the question by myself. Error "COMMIT_IN_POSTING" comes when another commit occurs in between a commit(probably commit used while saving standard transaction).

I could write a customize program with out commit and later allowed standard transaction to commit my work.

Thanks,

Rakesh