Friday, June 6, 2008

Smartform

Download Smartform output in PDF format

Report zsmart_form2.
*******DECLARATIONS********************************
data w_fm_name type rs38l_fnam.
data itab type table of ztest1.
data w_itab like line of itab.
data w_rad type char3.
data: tab_otf_data type ssfcrescl.
data: tab_otf_final type itcoo occurs 0 with header line.
data: bin_filesize type i,file_size type i.
data: pdf_tab like tline occurs 0 with header line.
data: cparam type ssfctrlop,outop type ssfcompop.

***** selection screen********************************
parameters p_workct like crhd-arbpl.
select-options: so_date for sy-datum.
parameters: rad1 radiobutton group radi,
rad2 radiobutton group radi,
rad3 radiobutton group radi.

******************Start-of-selection ****************
Start-of-selection.
refresh itab.
w_itab-name = 'name1'.
w_itab-age = '20'.
w_itab-mark1 = '123'.
w_itab-mark2 = '124'.
w_itab-mark3 = '125'.
append w_itab to itab.

w_itab-name = 'name2'.
w_itab-age = '21'.
w_itab-mark1 = '223'.
w_itab-mark2 = '224'.
w_itab-mark3 = '225'.
append w_itab to itab.

w_itab-name = 'name3'.
w_itab-age = '22'.
w_itab-mark1 = '323'.
w_itab-mark2 = '324'.
w_itab-mark3 = '325'.
append w_itab to itab.

**** to supress the dialog box of printer
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.

call function 'SSF_FUNCTION_MODULE_NAME'
exporting
formname = 'ZFORM_SAMPLE1'
importing
fm_name = w_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-msgnowith sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.

call function w_fm_name
exporting
control_parameters = cparam
output_options = outop
user_settings = space
importing
job_output_info = tab_otf_data
tables
itab1 = itab[]
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

******* appending the otf data into the final table **************
tab_otf_final[] = tab_otf_data-otfdata[].

*converting OTF data into pdf data**************************
call function 'CONVERT_OTF'
exporting
format = 'PDF'
max_linewidth = 132
importing
bin_filesize = bin_filesize
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.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.

*************downloading the converted PDF data to your local PC********
call function 'GUI_DOWNLOAD'
exporting
bin_filesize = bin_filesize
filename = 'D:\TEST.PDF'
filetype = 'BIN'
importing
filelength = file_size
tables
data_tab = pdf_tab

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.

No comments: