on 12-15-2008 10:11 AM
Hi all..
I am trying to convert smartform's output in PDF file..
I am able to convert smartforms's output in PDF but after that i can't see Print Preview..
Code is following...
REPORT ZMM_R402_FORM_TEST11.
TABLES : VBRK,J_1IEXCHDR.
SELECTION-SCREEN : BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-000.
*PARAMETERS : EXNUM TYPE EXNUM OBLIGATORY.
SELECT-OPTIONS : EXNUM FOR J_1IEXCHDR-EXNUM NO-EXTENSION OBLIGATORY.
PARAMETERS : EXDAT LIKE J_1IEXCHDR-EXDAT OBLIGATORY.
PARAMETERS : KUNNR LIKE VBRK-KUNAG OBLIGATORY.
PARAMETERS : SR_NO(12) TYPE C.
PARAMETERS : DATE1 TYPE EXDAT.
SELECTION-SCREEN : END OF BLOCK BLK.
DATA : FM_NAME(30) TYPE C.
DATA : SR(12) TYPE C.
UNPACK EXNUM-LOW TO EXNUM-LOW.
UNPACK EXNUM-HIGH TO EXNUM-HIGH.
***********
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 = ' '.
st_control_parameters-getotf = 'X'.
***********
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = 'ZMM_402_FORM'
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
FM_NAME = FM_NAME
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.
**WRITE:/ FM_NAME.
************
*************
CALL FUNCTION FM_NAME
EXPORTING
control_parameters = st_control_parameters
output_options = st_output_options
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
CONTROL_PARAMETERS =
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
OUTPUT_OPTIONS =
USER_SETTINGS = 'X'
EXNUM = EXNUM-LOW
EXNUM1 = EXNUM-HIGH
DATE = EXDAT
KUNNR = KUNNR
SR = SR_NO
DATE1 = DATE1
IMPORTING
document_output_info = st_document_output_info
job_output_info = st_job_output_info
job_output_options = st_job_output_options
DOCUMENT_OUTPUT_INFO = W_RETURN
JOB_OUTPUT_INFO =
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR = 3
USER_CANCELED = 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.
.........................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.
........................GET THE FILE NAME TO STORE....................
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
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
ENDIF.
Please Help me ..
How can i see print preview..
if u want to see preview instead of getting the smartform output as otf get it as spool then convert it to pdf.
use this report to convert to pdf
SUBMIT rstxpdft4 AND RETURN
WITH spoolno = v_rspoid
WITH p_file = v_file_name.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
use like this:
call function lf_fm_name
exporting
archive_index = toa_dara
archive_parameters = arc_params
control_parameters = ls_control_param "Smart Forms: Control structure
mail_recipient = ls_recipient
mail_sender = ls_sender "Structure for Object ID
output_options = ls_composer_param "SAP Smart Forms: Smart Composer (transfer) options
user_settings = ' '
is_dlv_delnote = ls_dlv_delnote "Delivery Note Data: Transfer-Structure for Smartform
is_nast = nast "Nast
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
others = 5.
if sy-subrc <> 0.
error handling
cf_retcode = sy-subrc.
perform protocol_update.
get SmartForm protocoll and store it in the NAST protocoll
perform add_smfrm_prot. "INS_HP_335958
endif.
*To read the Spool Number generated
read table it_job_output_info-spoolids into v_rspoid index 1.
concatenate 'aBC.pdf' into v_file_name.
submit rstxpdft4 and return
with spoolno = v_rspoid
with p_file = v_file_name.
clear: v_rspoid.
Hi,
After GUI_DOWNLOAD,
call
CL_GUI_FRONTEND_SERVICES=>execute
....
Pass the file & path name which you had passed to gui_download.
Best regards,
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
When do you expect to see the print preview?
In the generation of the OTF, there's a control setting of preview that must be set to 'X'. However, if you are generating the OTF file as output, this is of no use to you since the output will just be the OTF file.
You are then converting the OTF to PDF and saving.
When do you want the print preview?
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.