FM Create URL For PDF Display in UI5
FM Create URL For PDF Display in UI5
com/2014/02/03/display-smartform-pdf-in-sapui5/
FUNCTION z_test_pdf_display.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(I_CUSTOMER) TYPE S_CUSTOMER
*" EXPORTING
*" REFERENCE(E_URL) TYPE STRING
*"----------------------------------------------------------------------
* Data Declaration
DATA :
lv_fm_name TYPE rs38l_fnam,
ls_output_options TYPE ssfcompop,
lv_language TYPE tdspras,
ls_control_parameters TYPE ssfctrlop,
ls_output_data TYPE ssfcrescl,
lv_pdf_len TYPE i,
lv_pdf_xstring TYPE xstring,
lt_lines TYPE TABLE OF tline,
lv_devtype TYPE rspoptype,
lv_app_type TYPE string,
lv_guid TYPE guid_32,
lo_cached_response TYPE REF TO if_http_response,
ls_customer TYPE scustom,
lt_bookings TYPE ty_bookings,
lt_connections TYPE ty_connections,
lt_tstotf TYPE tsfotf.
* language
lv_language = sy-langu.
* set control parameters to get the output text format (OTF) from Smart Forms
ls_control_parameters-no_dialog = 'X'.
ls_control_parameters-getotf = 'X'.
ls_control_parameters-preview = space. "No preview
* Convert to OTF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_pdf_len
bin_file = lv_pdf_xstring " binary file
TABLES
otf = lt_tstotf
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.
* error handling
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
* WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
****Set the Cache Timeout - 60 seconds - we only need this in the cache
****long enough to build the page
lo_cached_response->server_cache_expire_rel( expires_rel = 60 ).
ENDFUNCTION.