on 08-30-2010 5:49 PM
Hi
I want to download a smartform to PDF file.
Can anyone post the code please from calling the FM of smartforms to the call of
cl_wd_runtime_services=>attach_file_to_response
Best regards
Hi,
As i cant paste entire thing one go ...i am pasting parts of it
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring " binary file
TABLES
otf = ls_output_data-otfdata
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Thanks,
Shailaja Ainala.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi !
Your code is very helpfull , even if there is some options that canot provide the export of OTF DATA !
For me its resolved now and here is the final Code :
DATA: fm_name TYPE rs38l_fnam, " Used to get the function module of Smartform
ls_control_parameters TYPE ssfctrlop, " Smart Forms: Control structure
ls_output_options TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options
ls_output_data TYPE ssfcrescl, " Smart Forms: Return value at end of form printing
tab_otf_final TYPE TABLE OF itcoo.
DATA : bin_filesize TYPE i,
bin_file TYPE xstring,
pdf_tab TYPE TABLE OF tline.
* Set the output parameters
ls_output_options-tdprinter = 'PDF1'.
* set control parameters to get the output format (OTF) from Smart Forms
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
ls_control_parameters-preview = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_TAD_PAP'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
.
CALL FUNCTION fm_name
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
user_settings = space
IMPORTING
job_output_info = ls_output_data
TABLES
z_tad_pap_data = lt_table
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
tab_otf_final[] = ls_output_data-otfdata[].
" Convert OTF data into PDF data
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
max_linewidth = 132
IMPORTING
bin_filesize = bin_filesize
bin_file = bin_file
TABLES
otf = tab_otf_final
lines = pdf_tab
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'mail.pdf'
i_content = bin_file
i_mime_type = '/Desktop').
Hope it s help others ! and thank everybody for replyes
I'm sharing my code to call smartforms and pass value through internal table. Enjoy guys.
...
DATA lt_c_et_result TYPE STANDARD TABLE OF WD_THIS->Element_et_result .
DATA wa_et_result LIKE LINE OF lt_c_et_result .
DATA lo_nd_et_result TYPE REF TO if_wd_context_node.
DATA lo_el_et_result TYPE REF TO if_wd_context_element.
DATA ls_et_result TYPE wd_this->element_et_result.
* navigate from <CONTEXT> to <ET_RESULT> via lead selection
lo_nd_et_result = wd_context->get_child_node( name = wd_this->wdctx_et_result ).
* @TODO handle not set lead selection
IF lo_nd_et_result IS INITIAL.
ENDIF.
lo_nd_et_result->get_static_attributes_table(
IMPORTING
table = lt_c_et_result ).
DATA it_sfaktviti TYPE TABLE OF ZPM_AKTIVITI_STRUC.
DATA wa_sfaktviti LIKE LINE OF it_sfaktviti.
LOOP AT lt_c_et_result INTO wa_et_result.
MOVE-CORRESPONDING wa_et_result TO wa_sfaktviti .
* MODIFy it_sf_et_result FROM wa .
* APPEND wa_sf_result TO it_sf_et_result.
APPEND wa_sfaktviti TO it_sfaktviti.
ENDLOOP.
DATA: l_pdfstring TYPE xstring.
DATA: lv_buffer TYPE xstring.
DATA: lv_string TYPE string.
DATA: lv_fnam TYPE rs38l-NAME.
DATA: lv_bytecount TYPE i.
DATA: l_xline TYPE xstring.
DATA: lt_lines TYPE TABLE OF tline,
ls_line TYPE tline.
DATA: ls_ssfctrlop TYPE ssfctrlop,
ls_output_options TYPE ssfcompop,
ls_job_output_info TYPE ssfcrescl,
ls_job_output_options TYPE ssfcresop.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZPM_KERJA'
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = lv_fnam
* EXCEPTIONS
* NO_FORM = 1
* NO_FUNCTION_MODULE = 2
* OTHERS = 3
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ls_ssfctrlop-no_dialog = 'X'.
ls_ssfctrlop-getotf = 'X'.
ls_ssfctrlop-preview = 'X'.
" Call smartforms
call function lv_fnam
EXPORTING
control_parameters = ls_ssfctrlop
output_options = ls_output_options
IMPORTING
job_output_info = ls_job_output_info
job_output_options = ls_job_output_options
TABLES
IT_Aktiviti = lt_c_et_result
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
" Convert to PDF
call function 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_bytecount
TABLES
otf = ls_job_output_info-otfdata
lines = lt_lines
EXCEPTIONS
err_conv_not_possible = 1
err_bad_otf = 2.
loop at lt_lines into ls_line. "into l_line.
lv_string = ls_line.
export my_data = lv_string to data buffer lv_buffer.
import my_data to l_xline from data buffer lv_buffer in char-to-hex mode.
concatenate l_pdfstring l_xline into l_pdfstring in byte mode.
endloop.
* p_pdf = l_pdfstring.
" Call print
cl_wd_runtime_services=>attach_file_to_response(
i_filename = 'AktivitiKerja.pdf'
i_content = l_pdfstring
i_mime_type = 'application/pdf'
i_in_new_window = abap_false
i_inplace = abap_false ).
Hi,
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = l_devtype
EXCEPTIONS
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 4
OTHERS = 5.
IF sy-subrc <> 0.
error handling
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = '/SAPCDPT2/SECONDARY_STATUS_RPT'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = fm_name
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3
.
CALL FUNCTION fm_name
EXPORTING
control_parameters = ls_control_parameters
output_options = ls_output_options
user_settings = space
i_prj_hdr = i_prj_hdr
i_prj_sta = i_prj_sta
i_prj_cmt_list = i_prj_cmt_list
i_tprupt = i_tprupt
i_prj_budget = i_prj_budget
i_milestone = i_milestone
i_prj_erc = i_prj_erc
i_team = i_prj_tm
i_prj_sts = i_prj_sts
i_sec_org = i_sec_org
i_prj_org = ls_org
i_prj_bgtimp = ls_budgetimpact
IMPORTING
job_output_info = ls_output_data
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
ENDIF.
Edited by: Shailaja Ainala on Aug 31, 2010 2:12 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
ls_output_options-xsf = space. " XSF Output active
ls_output_options-xsfcmode = 'X'.
ls_output_options-xdfcmode = 'X'.
ls_output_options-xdf = space. " 'X' Get XSF params from program
ls_output_options-xsfoutmode = space. " A:Application
ls_output_options-xsfformat = 'X'. " 'X' Formatting ON
ls_output_options-xsfaction = space. " Action URL for submit btn.
language = sy-langu.
TRANSLATE language TO UPPER CASE. "#EC SYNTCHAR
ls_control_parameters-langu = language.
set control parameters to get the output format (OTF) from Smart Forms
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
ls_control_parameters-preview = ' '.
Thanks,
Shailaja Ainala.
Edited by: Shailaja Ainala on Aug 31, 2010 2:10 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jcrios,
I think you can do as follows:
- Create a new class implement inteface IF_HTTP_EXTENSION, put the code in the HANDLE_REQUEST method,
- Inside the method, get form fields and create PDF from smartfrom, pass those form field to smartform if needed.
- Create a new service in SICF, you class will be the handler for the service.
- From Web Dynpro create link to link to this service: http://host:port/this_service?field=abcd&field2=.
You can refer to this:
Hope it helps!
Duy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Kindly refer the below link which may helps you.
http://wiki.sdn.sap.com/wiki/display/ABAP/PDFfilesin+SAP#PDFfilesinSAP-HowtoconvertSmartFormoutputintoPDFbinary%3F
https://wiki.sdn.sap.com/wiki/display/Snippets/SmartformoutputtoPDFformat
Regards,
Amarnath S
Hi thank you for repliying !
Actually im using this code
DATA: form_name TYPE rs38l_fnam, " Used to get the function module of Smartform
wa_ctrlop TYPE ssfctrlop, " Smart Forms: Control structure
wa_outopt TYPE ssfcompop, " SAP Smart Forms: Smart Composer (transfer) options
t_otfdata TYPE ssfcrescl. " Smart Forms: Return value at end of form printing
Data: t_pdf_tab type table of tline, " SAPscript: Text Lines
t_otf TYPE table of itcoo. " OTF Structure
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'Z_TEMPLATE1' "p_name
IMPORTING
fm_name = form_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
wa_ctrlop-getotf = 'X'.
wa_ctrlop-no_dialog = 'X'.
wa_outopt-tdnoprev = 'X'.
CALL FUNCTION form_name
EXPORTING
control_parameters = wa_ctrlop
output_options = wa_outopt
user_settings = 'X'
IMPORTING
job_output_info = t_otfdata
TABLES
z_tad_pap_data = lt_table
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
But when i debug this code the t_otf_data does not have any data ..
ANd i ll need to convert OTF DATA to type FPCONTENT in orther to pass it as a parameter in cl_wd_runtime_services=>attach_file_to_response . what did i miss in the code ? and how can i make the conversion work .
Best regards
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.