on 05-15-2012 5:40 AM
Dear SDNers,
I want to display a smartform in PDF Format. To display in pdf format, I need to create a spool request. I wrote below code. But spool request is not creating.
I tried so many ways by chaing output options and control paramters as well. But not success. Please help me out regarding the same.
Here is the xode.
w_cparam-no_dialog = 'X'.
w_cparam-preview = 'X'. " Suppressing the dialog box for print preview
w_cparam-getotf = 'X'.
w_cparam-DEVICE = 'PRINTER'.
w_cparam-langu = sy-langu.
w_cparam-no_open = 'X'.
w_cparam-no_close = 'X'.
* Printer name to be used is provided in the export parameter
* OUTPUT_OPTIONS
w_outoptions-tdprinter = 'PDF1'.
w_outoptions-tddest = 'LP01'.
w_outoptions-tdnewid = 'X'.
w_outoptions-TDIMMED = 'X'.
w_outoptions-tdnoprint = 'X'."
w_outoptions-tdarmod = 1.
w_outoptions-tdcopies = 001.
w_outoptions-tdlifetime = 1.
w_outoptions-tddelete = space.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = w_form_name
* VARIANT = ' '
* DIRECT_CALL = ' '
IMPORTING
FM_NAME = w_fmodule
EXCEPTIONS
NO_FORM = 1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
data:t_otf_from_fm TYPE SSFCRESCL ,
DOCUMENT_OUTPUT_INFO type SSFCRESPD,
JOB_OUTPUT_OPTIONS type SSFCRESOP.
CALL FUNCTION w_fmodule"'/1BCDWB/SF00000004'
EXPORTING
* ARCHIVE_INDEX =
* ARCHIVE_INDEX_TAB =
* ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS = w_cparam
* MAIL_APPL_OBJ =
* MAIL_RECIPIENT =
* MAIL_SENDER =
OUTPUT_OPTIONS = w_outoptions
USER_SETTINGS = 'X'
DOCU_NO = P_DOCUNO
COMP_CD = P_COMPCD
YEAR = P_YEAR
IMPORTING
DOCUMENT_OUTPUT_INFO = DOCUMENT_OUTPUT_INFO
JOB_OUTPUT_INFO = t_otf_from_fm
JOB_OUTPUT_OPTIONS = JOB_OUTPUT_OPTIONS
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
Regards,
Venkat
Hi,
You just follow the code,
TABLES SFLIGHT.
SELECT-OPTIONS S_CARRID FOR SFLIGHT-CARRID.
DATA: it_otf TYPE STANDARD TABLE OF itcoo,
it_docs TYPE STANDARD TABLE OF docs,
it_lines TYPE STANDARD TABLE OF tline.
* Declaration of local variables.
DATA:
st_job_output_info TYPE ssfcrescl,
st_document_output_info TYPE ssfcrespd,
st_job_output_options TYPE ssfcresop,
st_output_options TYPE ssfcompop,
st_control_parameters TYPE ssfctrlop,
v_len_in TYPE so_obj_len,
v_language TYPE sflangu VALUE 'E',
v_e_devtype TYPE rspoptype,
v_bin_filesize TYPE i,
v_name TYPE string,
v_path TYPE string,
v_fullpath TYPE string,
v_filter TYPE string,
v_uact TYPE i,
v_guiobj TYPE REF TO cl_gui_frontend_services,
v_filename TYPE string,
v_fm_name TYPE rs38l_fnam.
CONSTANTS c_formname TYPE tdsfname VALUE 'ZTEST'.
CALL FUNCTION 'SSF_GET_DEVICE_TYPE'
EXPORTING
i_language = v_language
i_application = 'SAPDEFAULT'
IMPORTING
e_devtype = v_e_devtype.
st_output_options-tdprinter = v_e_devtype.
st_control_parameters-no_dialog = 'X'.
st_control_parameters-getotf = 'X'.
*.................GET SMARTFORM FUNCTION MODULE NAME.................*
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = c_formname
IMPORTING
fm_name = v_fm_name
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
*...........................CALL SMARTFORM............................*
CALL FUNCTION v_fm_name
EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
TABLES
so_carrid = S_CARRID
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
*.........................CONVERT TO OTF TO PDF.......................*
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = v_bin_filesize
TABLES
otf = st_job_output_info-otfdata
doctab_archive = it_docs
lines = it_lines
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
CONCATENATE 'smrt' '.pdf' INTO v_name.
CREATE OBJECT v_guiobj.
CALL METHOD v_guiobj->file_save_dialog
EXPORTING
default_extension = 'pdf'
default_file_name = v_name
file_filter = v_filter
CHANGING
filename = v_name
path = v_path
fullpath = v_fullpath
user_action = v_uact.
IF v_uact = v_guiobj->action_cancel.
EXIT.
ENDIF.
*..................................DOWNLOAD AS FILE....................*
MOVE v_fullpath TO v_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = v_bin_filesize
filename = v_filename
filetype = 'BIN'
TABLES
data_tab = it_lines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You can check the below link:
http://wiki.sdn.sap.com/wiki/display/ABAP/PDF+Downlaod+By+Creating+Spool+Request
Hope it serves useful to you.
Try using this code,
tables sflight.
select-options s_carrid for sflight-carrid.
DATA:w_form_name type tdsfname, "Smartform name
r_options type ssfcompop, "Print option
r_control type ssfctrlop, "Print control
w_function type rs38l_fnam.
r_options-tddest = 'LOCL'. "Spool: Output device
r_options-tdimmed = 'X'. "Print Immediately
r_options-tddelete = space. "Delete After Printing
r_options-tdnewid = 'X'. "New Spool Request
r_control-device = 'PRINTER'.
r_control-no_dialog = 'X'.
r_control-langu = sy-langu.
call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZADEV_FLIGHT_DETAILS'
importing
fm_name = w_function.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
call function w_function
exporting
control_parameters = r_control
output_options = r_options
user_settings = ' '
TABLES
so_carrid = s_carrid.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Hi ,
Change your medium NAST-NACHA = 1.
Regards,
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.