0
votes

I'm currently trying to send the results of a selection via E-Mail, more precisely as an attachment. My goal is to create a XML-File (which works so far) and a PDF, both fed from the internal table in which the selected data is held. The internal table is declared with a custom type. My current code for sending the E-Mail with the XML attachment looks like following:

lr_send_request = cl_bcs=>create_persistent( ).

lr_document = cl_document_bcs=>create_document( i_type    = 'HTM'
                                                i_text    = lt_text
                                                i_subject = lv_subject ).

* ----- converting data of internal table so it is suitable for XML
    ...
* -----

lr_document->add_attachment( i_attachment_type     = 'BIN'
                             i_attachment_subject  = 'output.xml'
                             i_attachment_size     = xml_size
                             i_attachment_language = sy-langu
                             i_att_content_hex     = xml_content ).

lr_send_request->set_document( lr_document ).

On the web I was only able to find how to convert spooljob (whatever that is :/) into PDF. With functions like that I may be able to solve my problem but then I can't attach the XML anymore.

How can I convert the data of the internal table into a PDF file to attach it to the E-Mail in the same way I do with the XML?

1

1 Answers

4
votes

There are multiple way to create PDF:

  1. Create report with Smartform and get output in PDF format. Sample code
  2. If your system has adobe form license create with adobe form.
  3. Use zcl_pdf class for creating native pdf file.
  4. Using CONVERT_ABAPSPOOLJOB_2_PDF FM for getting printer spool as pdf (thanks @Sandra Rossi).

If your PDF is simple (not include complex table, vertical text, images, etc) use third option, otherwise try first or second.