REPORT zsmart_form2.
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 l_v_date LIKE sy-datum.
DATA: cparam TYPE ssfctrlop,
outop TYPE ssfcompop.
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.
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 for printer
outop-tddest = 'LP01'.
cparam-no_dialog = 'X'.
cparam-preview = space.
cparam-getotf = 'X'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = 'ZFORM_SAMPLE1'
* VARIANT = ' '
* DIRECT_CALL = ' '
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-msgno
WITH 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
* DOCUMENT_OUTPUT_INFO =
job_output_info = tab_otf_data
* JOB_OUTPUT_OPTIONS =
TABLES
itab1 = itab[]
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.
*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
* FIELDNAMES =
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.
.