‎2013 Nov 26 1:08 PM
Hello Masters,
I have a query that i want to execute Smartform(which is in o/p typ in NACE) within Z program and Convert it into PDF and send attachment via mail.
Is it possible that within the Z program We can call that SMARTFORM by passing parameters with in our program and with out the output window for smartform, We convert this output into PDF and next we can send the mail.
Regards,
Nishant Singh
‎2013 Nov 26 1:18 PM
Hi,
did you have search a little bit into the forum before asking this question ?
regards
Fred
‎2013 Nov 26 1:30 PM
Do a good search buddy before you post , there are no.of discussions and blogs available on this content.
One of them :
http://wiki.scn.sap.com/wiki/display/Snippets/Smartform+as+a+PDF+to+Mail+id
Thanks
Saikrishna
‎2013 Nov 26 1:33 PM
Hi ,
Yes it is possible.Follow the steps,
I) Get the data from nast table by passing objky or other parameters.
II) CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Your Smartform'
IMPORTING
fm_name = lv_fm_name.
III) Immediately call passing nast table , control parameters and the data
for your smartform.
ls_ctrl_par-no_dialog = abap_true.
ls_ctrl_par-preview = abap_false.
ls_ctrl_par-getotf = abap_true.
PERFORM get_pdf_from_output TABLES lt_pdf_mail
USING lv_fm_name
ls_ctrl_par
ls_bil_invoice
ls_nast
lv_filesize.
FORM get_pdf_from_output TABLES ct_pdf_mail TYPE solix_tab
USING value(iv_fm_name) TYPE rs38l_fnam
value(is_ctrl_par) TYPE ssfctrlop
value(is_bil_invoice) TYPE lbbil_invoice
value(is_nast) TYPE nast
ev_filesize TYPE i.
DATA: lt_pdf TYPE TABLE OF tline,
ls_output_data TYPE ssfcrescl,
ls_composer_param TYPE ssfcompop,
lv_pdfsize TYPE sytabix,
lv_xpdf TYPE xstring.
CLEAR: ls_output_data,
ls_composer_param,
lv_pdfsize,
lv_xpdf.
REFRESH: lt_pdf.
ls_composer_param-tddest = 'LOCL'.
ls_composer_param-tdprinter = 'SWIN'.
CALL FUNCTION iv_fm_name
EXPORTING
control_parameters = is_ctrl_par
is_bil_invoice = is_bil_invoice
is_nast = is_nast
output_options = ls_composer_param
IMPORTING
job_output_info = ls_output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdfsize
bin_file = lv_xpdf
TABLES
otf = ls_output_data-otfdata
lines = lt_pdf
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = lv_xpdf
IMPORTING
output_length = ev_filesize
TABLES
binary_tab = ct_pdf_mail.
ENDFORM. " GET_PDF_FROM_OUTPUT
IV )ls_attachment-doc_type = 'PDF'.
ls_attachment-filename = 'TEST'.
CONCATENATE ls_attachment-filename
'.pdf' INTO ls_attachment-subject.
ls_attachment-cont_hex = lt_pdf_mail.
ls_attachment-docsize = lv_filesize.
APPEND ls_attachment TO lt_attachments.
V)Follow the same steps if you have more attachments.
VI) For sending mail Pls refer to the following SCN Link.
http://scn.sap.com/thread/3455913
BR.