Sitemap

Amicuk Programming Answers

Sending PDF forms (created using SFP) as Email Attachment

2015-10-11   Views:11

Advertisement

Hi,      I have created bunch of ADOBE forms using SFP. They are not interactive forms. created using ADOBE Live cycle designer. I have the Function module and by executing I can view the PDF form in print preview mode. But I have to save this in bac

Hi,
     I have created bunch of ADOBE forms using SFP. They are not interactive forms. created using ADOBE Live cycle designer.
I have the Function module and by executing I can view the PDF form in print preview mode. But I have to save this in backend and attach to email.
I have a program that have to send one of the forms created in SFP as email attachment to outside SAP.
Please advice how to achieve this.
Thanks,
Sanjeev

The replay answer
Advertisement
Hi ,
Please find below a code sample for your requirement
*& Report  ZENVOI_PDF_MAIL
REPORT  zenvoi_pdf_mail MESSAGE-ID ad.
TYPE-POOLS : abap .
DATA : data_for_update TYPE zdemopdf ,
       hexa            TYPE solix_tab.
DATA : fm_name   TYPE funcname ,
       param     TYPE sfpoutputparams,
       doc_param TYPE sfpdocparams ,
       output    TYPE fpformoutput .
param-nodialog = abap_true. " suppress printer dialog popup
param-getpdf = abap_true.
doc_param-langu = sy-langu.
doc_param-country = 'FR'.
doc_param-fillable = abap_true.
doc_param-dynamic = abap_true.
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
  EXPORTING
    i_name     = 'ZDEMO_PDF'
  IMPORTING
    e_funcname = fm_name.
CALL FUNCTION 'FP_JOB_OPEN'
  CHANGING
    ie_outputparams = param
  EXCEPTIONS
    cancel          = 1
    usage_error     = 2
    system_error    = 3
    internal_error  = 4.
CHECK sy-subrc EQ 0.
CALL FUNCTION fm_name
  EXPORTING
    /1bcdwb/docparams  = doc_param
    data_for_update    = data_for_update
  IMPORTING
    /1bcdwb/formoutput = output
  EXCEPTIONS
    usage_error        = 1
    system_error       = 2
    internal_error     = 3.
CALL FUNCTION 'FP_JOB_CLOSE'
  EXCEPTIONS
    usage_error    = 1
    system_error   = 2
    internal_error = 3
    OTHERS         = 4.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
  EXPORTING
    buffer     = output-pdf "PDF file from function module
  TABLES
    binary_tab = hexa.
* Envoi du mail
** CLASS-DEFINITIONS
DATA: send_request       TYPE REF TO cl_bcs.
DATA: document           TYPE REF TO cl_document_bcs.
*DATA: sender             TYPE REF TO cl_sapuser_bcs.
data: sender            TYPE REF TO if_sender_bcs.
DATA: recipient          TYPE REF TO if_recipient_bcs.
** INTERNAL TABLES
DATA: l_mailtext TYPE soli_tab.
DATA: iaddsmtp   TYPE TABLE OF bapiadsmtp.
DATA: ireturn    TYPE TABLE OF bapiret2.
** VARIABLES
DATA: mail_line  LIKE LINE OF l_mailtext.
DATA: bapiadsmtp         TYPE bapiadsmtp.
DATA: subject    TYPE so_obj_des.
DATA : att_subject TYPE so_obj_des.
DATA : w_except TYPE REF TO cx_root .
CONSTANTS : c_defmail TYPE ad_smtpadr VALUE
                 '[email protected]' .
FIELD-SYMBOLS : <smtp> TYPE bapiadsmtp.
*Set subject of the mail
subject = 'Exemple de PDF interactif'.
* Set text of the mail
mail_line = 'Merci de remplir le formulaire et nous le retourner'.
APPEND mail_line TO l_mailtext .
att_subject = 'Template du PDF'.
TRY.
* Create persistent send request
    send_request = cl_bcs=>create_persistent( ).
* Get sender object
    sender = cl_sapuser_bcs=>create( sy-uname ).
*    sender =
*      cl_cam_address_bcs=>create_internet_address( '[email protected]' ) .
* Add sender
    CALL METHOD send_request->set_sender
      EXPORTING
        i_sender = sender.
* Read the E-Mail address for the user
*    CALL FUNCTION 'BAPI_USER_GET_DETAIL'
*      EXPORTING
*        username = sy-uname
*      TABLES
*        return   = ireturn
*        addsmtp  = iaddsmtp.
*    LOOP AT iaddsmtp ASSIGNING <smtp> WHERE std_no = 'X'.
*      CLEAR bapiadsmtp.
*      MOVE <smtp> TO bapiadsmtp.
*    ENDLOOP.
*    CASE bapiadsmtp-e_mail.
*      WHEN space.
        recipient =
     cl_cam_address_bcs=>create_internet_address( c_defmail ).
*      WHEN OTHERS.
*        recipient =
*     cl_cam_address_bcs=>create_internet_address( bapiadsmtp-e_mail ).
*    ENDCASE.
* Add recipient with its respective attributes to send request
    CALL METHOD send_request->add_recipient
      EXPORTING
        i_recipient  = recipient
        i_express    = 'X'
        i_copy       = space
        i_blind_copy = space
        i_no_forward = space.
* Set that you don't need a Return Status E-mail
    CALL METHOD send_request->set_status_attributes
      EXPORTING
        i_requested_status = 'E'
        i_status_mail      = 'E'.
* set send immediately flag
    send_request->set_send_immediately( 'X' ).
*Build Document
    document = cl_document_bcs=>create_document(
                        i_type    = 'RAW'
                        i_text    = l_mailtext
                        i_subject = subject ).
*     add attachment to document
    CALL METHOD document->add_attachment
      EXPORTING
        i_attachment_type    = 'PDF'
        i_attachment_subject = att_subject
        i_att_content_hex    = hexa.
* Add document to send request
    CALL METHOD send_request->set_document( document ).
* Send document
    CALL METHOD send_request->send( ).
    COMMIT WORK.
  CATCH cx_send_req_bcs INTO w_except.
  CATCH cx_address_bcs INTO w_except.
  CATCH cx_document_bcs INTO w_except.
ENDTRY.
Hope this help you .
Best regards

Go to See the other 10 answers

Sending PDF forms (created using SFP) as Email Attachment

Category:DefaultRelease time:2015-10-11Views:130

Hi,      I have created bunch of ADOBE forms using SFP. They are not interactive forms. created using ADOBE Live cycle designer. I have the Function module and by executing I can view the PDF form in print preview mode. But I have to save this in bac[More]

Need to send my spool in HTML format as Email attachment

Category:DefaultRelease time:2015-10-11Views:130

Hi All,     Can anyone let me know how to send a HTML attachment in a mail. I have a ALV Report, when i execute, my report should pick the ALV Report output from spool, and should send a mail with spool output as HTML attachment. Please explain me ho[More]

I want to send my output of report as an email attachment

Category:DefaultRelease time:-0001-11-30Views:130

i am having internal table contains values. i want that output should be send as an email attachment to email id given in selection screen. help me how to pass that internal table to the parameters of SO_DOCUMENT_SEND_API1 function module should i ca[More]

PDF file created from Oracle Report is attached wrongly

Category:DefaultRelease time:2015-10-11Views:130

Hi, Please help. It is very urgent. I am using Oracle Developer 10gR2, Oracle Report 10.1.2 on Windows 2000. I would like to attach the PDF file created by Oracle Report to the Notification sent from Workflow. I use the following package procedure in[More]

How to send pdf files from local dir through emails attachments

Category:DefaultRelease time:2015-10-11Views:130

I have some pdf documents in some directory, I want to send those pdf's as an attachment throu emails to the concerned person. Please let me know how to attach the files and send through email. Thanks.You are using Forms 4.5, which is a client/server[More]

Sending PDF file in presentation layer as a attachment to Email

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a PDF file in my Presentation layer, I want to send it as a attachment to Email. Is there any Function Module or sample code to it. Regards, Adithya M.Hi Maha, Go through this hope u can understand. also check this link http://abapcode.blo[More]

Pdf file increases when printing from email attachment

Category:DefaultRelease time:2015-10-11Views:130

We are using Windows XP and acrobat 7.0 professional. We are receiving files with a PDF attachment which is only about 1 MB When we send to the printer it then says the file is now approx 36mb and therefore crashes the printer and we can't print the[More]

PDF file is blank in external email attachment

Category:DefaultRelease time:2015-10-11Views:130

Dear all, I have successfully convert a SAPScript to PDF file and then attach in email to be sent to customer externally. However, the contents in the attachment is blank. It works properly if I remove the email function, and download it to front end[More]

Adobe pdf does not fully download from mail.  Is there an adobe application that will do the job fully? The pdf is a download from an email attachment.

Category:DefaultRelease time:-0001-11-30Views:130

A friend sent a pdf to me attached to an email.  I looked at it with my pc; the mac only shows a portion of the file.  It is an adobe file.  Is this common?  Is there a fix?  Is preview not capable of fully opening an adobe file?  Has anyone else had[More]

Sending PDF + Excel as Email attachments in Unicode System

Category:DefaultRelease time:2015-10-11Views:130

Hi, I have a problem in sending mails having 2 attachments. one with PDF and another Excel. I use SO_DOCUMENT_SEND_API1 by populating contents_bin table. PDF attachment is fine (PDF is created from spool), but excel attachment fails to open correctly[More]

TS3276 Can't send PDF files by email

Category:DefaultRelease time:-0001-11-30Views:130

I can't send PDF files of photo from my email. ??Dropbox A simple and popular way to copy files and share files amoung your devices. https://www.dropbox.com/ copy to Share folder & email them that they have access copy to Public folder & email the[More]

Hot
hi friends,        I am creating sales order with reference contract using "BAPI_SALESORDER_CREATEFROMDAT1" my issue is with quantity field when i am entering quantity as  1 then it is taking as 0.001 i am also declaring its unit field too but t [More]
Dear all, After MIRO the accounting entry should be:- GR/IR Clearing account Dr. Vendor A/c Cr. But in my case the accounting entry that is getting generated is : GR/IR Clearing account Dr. Inventory Difference -Semi Finished Goods A/c Cr. Because of [More]
Hi there, I just got my iMac few days ago. I have install Mac OS X Server v10.5 Leopard problem. Its any could teach me how can I spare my Hard Drive to show 2 in my desktop, one will be Application App & another will be Storage.. Its "Mac OS X S [More]
Help.. After update to IOS 7 on my Iphone, and Itunes update to 11.1.1... I am unable to sync my Iphone 4. Itunes detects my iphone and does a clean backup. It also starts sync and shows upto 5 steps. Reaches the last step and keeps on working on tha [More]
I need to see the contact number who's calling me not only his nameUnfortunately, your "need" is not supported in iOS. ** Make use of "labels" in order to differentiate between the numbers of the same contact.Read other 2 answers [More]
Hi Gurus I've applied the SAP GUI 7.10 Final release Patch 6 but I am facing this error below THREAD_GLOBALDATA when tried to login to any system through logon pad. I got windows XP professional version 2002 SP 2 Please help me out thanks in advance [More]
Hi Experts, I am implementing the SAP Leqarning solutions for a cleint. For the rescheduling process, in the portal , for the Course administrator role, I try to change the course dates and save then changes. A message "Course changed successfully&qu [More]
So i don't know what i did but my skype message are just in the middle i can't move it back... i redownload skype and look in settings how do i fix this?  Mod Edit: Edited post to comply with the Skype Community Guidelines and Skype EtiquetteI firgur [More]
Hi all, Is it possible to import an image sequence in Media Encoder CS4 to export it in FLV? In the documentation, it's said in "File formats supported for import" that it supports jpg sequence (not png!?), but I don't know how to add an image s [More]
My problem occurs when zoom out of a gradient mesh effect and it bocomes something cloudy or in snatches but when zooming in, the problem no longer exists and everything become smooth again. What's the problem? pleaseWhich version of Illustrator are [More]