Code: Alles auswählen.
* event handler for data retrieval
* parameters for generated function module
data: l_function_module_name type rs38l_fnam,
ls_output_options type ssfcompop,
ls_control_parameters type ssfctrlop,
ls_output_data type ssfcrescl,
l_devtype type rspoptype.
* generated result: HTML with embedded CSS
data: ls_xmloutput type ssfxmlout,
lt_html_raw type tsfixml,
l_xstring type xstring, "needed for HTTP response
l_html_xstring type xstring,
l_xlength type i.
* generated result: PDF format
data: l_pdf_xstring type xstring,
lt_lines type table of tline,
ls_line type tline,
l_pdf_len type i.
* Cookie mit Eingabewerten holen
cl_bsp_server_side_cookie=>get_server_cookie(
EXPORTING
name = 'lt_fields'
application_namespace = 'NONE'
application_name = 'NONE'
username = 'NONE'
session_id = 'NONE'
data_name = 'NONE'
"IMPORTING
"expiry_date = date
"expiry_time = time
CHANGING
data_value = lt_fields ).
* Cookie mit Equipmentdaten holen
cl_bsp_server_side_cookie=>get_server_cookie(
EXPORTING
name = 'ums_equip_ges'
application_namespace = 'NONE'
application_name = 'NONE'
username = 'NONE'
session_id = 'NONE'
data_name = 'NONE'
"IMPORTING
"expiry_date = date
"expiry_time = time
CHANGING
data_value = ums_equip ).
*-----------------------------------------------------------------------
* Get name of generated function module
*-----------------------------------------------------------------------
call function 'SSF_FUNCTION_MODULE_NAME'
exporting formname = 'Z_REPKOST_GES'
* variant = ' '
* direct_call = ' '
importing fm_name = l_function_module_name
exceptions no_form = 1
no_function_module = 2
others = 3.
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.
exit.
endif.
*---------------------------------------------------------------------------
* get device type from language
*---------------------------------------------------------------------------
call function 'SSF_GET_DEVICE_TYPE'
exporting
i_language = sy-langu
* i_application = 'SAPDEFAULT'
importing
e_devtype = l_devtype
exceptions
no_language = 1
language_not_installed = 2
no_devtype_found = 3
system_error = 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 device type in output options
ls_output_options-tdprinter = l_devtype.
*-----------------------------------------------------------------------
* Call the generated function module
*-----------------------------------------------------------------------
call function l_function_module_name
exporting
* archive_index =
* archive_parameters =
control_parameters = ls_control_parameters
* mail_appl_obj =
* mail_recipient =
* mail_sender =
output_options = ls_output_options
user_settings = space
UMS_EQUIP = UMS_EQUIP
LT_FIELDS = LT_FIELDS
importing
* document_output_info =
job_output_info = ls_output_data
* job_output_options =
* tables
* zsystems = lt_sys
exceptions formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 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.
*-----------------------------------------------------------------------
* Conversion of output format OTF into PDF format
*-----------------------------------------------------------------------
* now convert the final document (OTF format) into PDF format
call function 'CONVERT_OTF'
exporting
format = 'PDF'
* MAX_LINEWIDTH = 132
* ARCHIVE_INDEX = ' '
* COPYNUMBER = 0
importing
bin_filesize = l_pdf_len
bin_file = l_pdf_xstring " binary file
tables
otf = ls_output_data-otfdata
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.
DATA: cached_response TYPE REF TO if_http_response.
DATA: guid TYPE guid_32.
DATA: fileUpload TYPE REF TO CL_HTMLB_FILEUPLOAD.
if sy-subrc EQ 0.
CREATE OBJECT cached_response TYPE CL_HTTP_RESPONSE EXPORTING add_c_msg = 1.
l_pdf_len = xstrlen( l_pdf_xstring ).
cached_response->set_data( data = l_pdf_xstring
length = l_pdf_len ).
cached_response->set_header_field( name = if_http_header_fields=>content_type
value = 'application/pdf' ).
cached_response->set_status( code = 200 reason = 'OK' ).
cached_response->server_cache_expire_rel( expires_rel = 180 ).
CALL FUNCTION 'GUID_CREATE'
IMPORTING
ev_guid_32 = guid.
CONCATENATE runtime->application_url '/' guid '.pdf' INTO display_url.
cl_http_server=>server_cache_upload( url = display_url
response = cached_response ).
ENDIF.
RETURN.