A new method CRM_SRVORDER_EXEC_SMART_FORM_A is created in Class Z_CL_DOC_PROCESSING_CRM_ORDER. The Method is linked to a new Action Definition in transaction SPPFCADM and called 'E-mail with Attachments'.
The code is based on the template attachment to Note 935670 - PPF: Sending an SF output with a main document and uses some parts of the BCS_EXAMPLE_4 program.
The first part of the code is the same as descibed in the previous blog.
When the send request is created, recipients and customer name are read from the businesspartner function in the transaction (tables CRMV_LINKPARTNER, BUT000 and ADR6).
With Function 'READ_TEXT' the long-text is read and the variables between '&' are replaced with proper values.
The mail subject is built from the object_id and description of the transqaction.
the retrieved OTF data is converted to PDF with function 'CONVERT_OTF' and attached to the send request with method 'add_attachment' from the CL_BCS Class.
The other attachments are retrieved from table SKWG_BREL and also attached to the send request.
The long text is added to the send request with method set_note from the CL_BCS class and finally the send request can be edited after the method edit is called from the same class.
A window pops up were the body text can be edited, attachments can be added and/or deleted, recipient can be added and/or deleted etc.