2009 Feb 02 10:50 AM
Hi,
I have a requirement to create a PDF form that can be printed or sent as an attachment by mail depending on the user requirement. I have created the form. I am able to go into the preview and am able to print the form. However there is no option to email it as an attachment.
Could you please let me know how to get this done? The email id has to be entered by the user. This form is triggered from a CRM application.
Thanks
Nandini
2009 Feb 02 10:55 AM
hi,
for mail send may be u can refer to the follwing wiki
https://wiki.sdn.sap.com/wiki/x/MYOmAw
regards,
prashanti
2009 Feb 02 11:01 AM
Hi Prashanti,
Thanks for the link. However my issue is not solved with it. I have an adobe form that has to be sent as an email. I am unable to get any option where the user can select whether to print or email the form. Is there any way of getting the send as email attachment option in the preview of the form?
Thanks
Nandini
2009 Mar 28 7:07 AM
hi.
my dear dont wory. i had the same problem.now listen
steps.
1. install a pdf writer.( which also create a pdf printer)
2.then when u send print.user should select pdf printer, and just below printer selection.user have an text box by default with named as Email.
so user enter email address and click to print.
after printing request complete,u see your email hasbeen send.
note::
printer installation and email parameter setting is task of your Basis concern person.
2009 Jun 17 9:01 PM
Hello Nandini
We have the Packing List in PDF form that is sending by email as attachment. I hope that can help you.
Here is the code.
***********************************
*Process Packlist PDF Form
***********************************
data: fm_pack_name TYPE FUNCNAME,
fp_pack_outputparams TYPE SFPOUTPUTPARAMS,
fp_pack_docparams type SFPDOCPARAMS,
FP_pack_FORMOUTPUT type FPFORMOUTPUT.
data lt_att_pack_content_hex type SOLIX_TAB.
call function 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = 'ZPACKLIST_FORM'
IMPORTING
e_funcname = fm_pack_name.
* Set output parameters and open spool job
fp_pack_outputparams-nodialog = 'X'. " suppress printer dialog popup
fp_pack_outputparams-GETPDF = 'X'. " launch print preview
* fp_pack_outputparams-XFP = ''.
* fp_pack_outputparams-XFPTYPE = 'R'.
call function 'FP_JOB_OPEN'
CHANGING
ie_outputparams = fp_pack_outputparams
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
others = 5.
* Set form language and country (->form locale)
fp_pack_docparams-langu = 'E'.
fp_pack_docparams-country = 'US'.
fp_pack_docparams-FILLABLE = ' '.
fp_pack_docparams-dynamic = ''.
CALL FUNCTION fm_pack_name
EXPORTING
/1BCDWB/DOCPARAMS = fp_pack_docparams
PACK_LIST_ITEMS = lt_packlist_items
PACK_LIST_HDR = ls_packlist_hdr
IMPORTING
/1BCDWB/FORMOUTPUT = fp_pack_formoutput
EXCEPTIONS
USAGE_ERROR = 1
SYSTEM_ERROR = 2
INTERNAL_ERROR = 3
OTHERS = 4.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Close spool job
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 = fp_pack_formoutput-PDF "PDF file from function module
TABLES
binary_tab = lt_att_pack_content_hex.
*********************************************
*End of Packlist Processing
***************************************
**************************************
*Prepare Mail Object
*************************************
CLASS cl_bcs DEFINITION LOAD.
DATA:
lo_send_request TYPE REF TO cl_bcs VALUE IS INITIAL.
lo_send_request = cl_bcs=>create_persistent( ).
* Message body and subject
DATA:
lt_message_body TYPE bcsy_text VALUE IS INITIAL,
lo_document TYPE REF TO cl_document_bcs VALUE IS INITIAL.
APPEND 'Dear Partner,' TO lt_message_body.
append ' ' to lt_message_body.
APPEND 'Please find the attached Packing list.'
TO lt_message_body.
append ' ' to lt_message_body.
if l_text is not initial.
append 'Comments:' to lt_message_body.
append ' ' to lt_message_body.
append l_text to lt_message_body.
endif.
if l_text1 is not initial.
append l_text1 to lt_message_body.
append ' ' to lt_message_body.
endif.
APPEND 'Thank You,' TO lt_message_body.
lo_document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = lt_message_body
i_subject = 'Packing List' ).
DATA: lx_document_bcs TYPE REF TO cx_document_bcs VALUE IS INITIAL.
*Send Packlist Form as attachment
TRY.
lo_document->add_attachment(
EXPORTING
i_attachment_type = 'PDF'
i_attachment_subject = 'Packing List'
* I_ATTACHMENT_SIZE =
* I_ATTACHMENT_LANGUAGE = SPACE
* I_ATT_CONTENT_TEXT =
* I_ATTACHMENT_HEADER =
i_att_content_hex = lt_att_pack_content_hex ).
CATCH cx_document_bcs INTO lx_document_bcs.
ENDTRY.
* Add attachment
* Pass the document to send request
lo_send_request->set_document( lo_document ).
* lo_sender = cl_cam_address_bcs=>create_internet_address( l_send ).
lo_sender = cl_sapuser_bcs=>create( sy-uname ).
* Set sender
lo_send_request->set_sender(
EXPORTING
i_sender = lo_sender ).
* Create recipient
*lo_recipient = cl_sapuser_bcs=>create( sy-uname ).
lo_recipient = cl_cam_address_bcs=>create_internet_address( l_rec ).
** Set recipient
lo_send_request->add_recipient(
EXPORTING
i_recipient = lo_recipient
i_express = 'X' ).
*lo_send_request->add_recipient(
*EXPORTING
*i_recipient = lo_sender
*i_express = 'X' ).
** Send email
DATA: lv_sent_to_all(1) TYPE c VALUE IS INITIAL.
lo_send_request->send(
EXPORTING
i_with_error_screen = 'X'
RECEIVING
result = lv_sent_to_all ).
COMMIT WORK.
message 'Mail has been sent successfully!!!' type 'S'.
****************************************************************
*End of Mail Sending
***************************************************************
Regards
dstj
2009 Jul 23 6:14 PM
Thanks your post helped me out. I was able to send and existing PDF form as an attachment.