on 07-23-2009 4:39 PM
Hi Experts
I really hope that you can help me.
I have a dynamic form embedded in my view and I need to email this form as an attachment to a list of participants.
I already use the class cl_bcs for sending email, but how do I retrieve the form parameters (on button click within WD ABAP) and then convert them to the correct format so that they can be included in the cl_bcs class for sending?
Thanks in advance
I'll award points to helpful answers.
Anton Kruse
HI,
To send mail with PDF attachement,
U have to specify the emporting and exporting parameters for the Interactive Form in the SFP transaction.
Then add the below coding,
*Send mail in PDF format
Funtion module to get the generated FM name
TRY.
CALL FUNCTION 'FP_FUNCTION_MODULE_NAME'
EXPORTING
i_name = lc_formname
IMPORTING
e_funcname = lv_fmname.
CATCH cx_fp_api_repository. "#EC NO_HANDLER
CATCH cx_fp_api_usage. "#EC NO_HANDLER
CATCH cx_fp_api_internal. "#EC NO_HANDLER
ENDTRY.
ls_param-nodialog = 'X'." suppress printer dialog popup
ls_param-getpdf = 'X'." launch print preview
CALL FUNCTION 'FP_JOB_OPEN'
CHANGING
ie_outputparams = ls_param
EXCEPTIONS
cancel = 1
usage_error = 2
system_error = 3
internal_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
Do Nothing
ENDIF.
ls_fp_doc-langu = lc_sprsl.
ls_fp_doc-country = lc_country.
ls_fp_doc-fillable = 'X'.
Mail Format /1BCDWB/SM00000091
CALL FUNCTION lv_fmname
EXPORTING
/1bcdwb/docparams = ls_fp_doc
empno = ls_emp_det-empno
empname = ls_emp_det-empname
state = ls_emp_det-state
location = ls_emp_det-location
organisation = ls_emp_det-organisation
position = ls_emp_det-position
mailid = ls_emp_det-mailid
actual_date = ls_emp_det-actual_date
likely_date = ls_emp_det-likely_date
resig_date = ls_emp_det-resig_date
generic_det = lt_generic
bond_det = lt_bond
IMPORTING
/1bcdwb/formoutput = ls_formout
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
*do nothing.
ENDIF.
CALL FUNCTION 'FP_JOB_CLOSE'
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
Do Nothing
ENDIF.
*Function call to get the xstring value.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = ls_formout-pdf
TABLES
binary_tab = lt_att_content_hex."PDF file from function module
lv_bodytext_row-line = lc_subject.
APPEND lv_bodytext_row TO lt_bodytext.
APPEND ' ' TO lt_bodytext.
lv_bodytext_row-line = text-001.
APPEND lv_bodytext_row TO lt_bodytext.
APPEND ' ' TO lt_bodytext.
DESCRIBE TABLE lt_bodytext LINES lv_num_rows.
lv_num_rows = lv_num_rows * 255.
MOVE lv_num_rows TO lv_textlength.
TRY.
lv_attdoctype = lc_pdf.
lv_atttitle = text-000.
lc_document = cl_document_bcs=>create_document(
i_type = lc_raw
i_text = lt_bodytext
i_length = lv_textlength
i_subject = lv_subject ).
lc_document->add_attachment( EXPORTING
i_attachment_type = lv_attdoctype
i_attachment_subject = lv_atttitle
i_attachment_language = sy-langu
i_att_content_hex = lt_att_content_hex ). This will attach ur PDF to mail
Create persistent send request
lv_send_request = cl_bcs=>create_persistent( ).
Add document to send request
lv_send_request->set_document( lc_document ).
lv_sender = cl_sapuser_bcs=>create( sy-uname ).
Add sender
CALL METHOD lv_send_request->set_sender
EXPORTING
i_sender = lv_sender.
CLEAR : ls_smtp_addr.
READ TABLE lt_mailid INTO ls_mailid WITH KEY pernr = ls_0001-pernr.
IF sy-subrc = 0.
ls_smtp_addr = ls_mailid-usrid_long.
ENDIF.
Create recipient.
lv_recipient = cl_cam_address_bcs=>create_internet_address(
ls_smtp_addr ).
Add recipient with its respective attributes to send request
lv_send_request->add_recipient( EXPORTING
i_recipient = lv_recipient
).
Set send immediately
lv_send_request->set_send_immediately( 'X' ).
Send document
lv_send_request->send( ).
CATCH cx_root INTO lv_oref. "#EC NO_HANDLER
ENDTRY.
Hope this ll help u!!
Thanks,
Divya.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Divya
That looks like just what I need.
Kind Regards
Anton Kruse
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
For more understanding,
refer to the blog posetd by Vani,
/people/vani.krishnamoorthy/blog/2006/05/17/fillable-adobe-forms-using-abap
and
Regards,
Divya.S
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.