Smartforms in BSP Applikation nach PDF konvertieren

BusinessServerPages; Erstellung von Webapplikationen.

Smartforms in BSP Applikation nach PDF konvertieren

Postby Leah824 » Fri May 30, 2008 1:45 pm

Hallo zusammen,

ich habe eine BSP Applikation in der ich eine Tabelle und verschiedene andere Daten als PDF ausgeben will. Das Smartforms wurde im ersten Schritt erzeugt und generiert.
Über einen Button soll man in der BSP Appliokation auf die PDF Ansicht gelangen.

Mein Problem hierbei ist, dass ich im Browser lediglich ein leeres Dokument angezeigt wird.

In Smartforms ist das Ausgabeformat:XSF Ausgabe und der Ausgabe modus Anwendung.

Hier mein Quellcode, der auf der BSP Seite pdf_gesamt zum initialisierungsevent implementiert ist.

Hoffe mir kann jemand helfen.

* 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 = 'D'
* 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 =
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.



*-----------------------------------------------------------------------
* Fill HTTP request
*-----------------------------------------------------------------------
response->set_header_field( name = 'content-type'
value = 'application/pdf' ).

* response->delete_header_field( name = 'pragma' ).
* response->delete_header_field( name = 'expires' ).
* response->delete_header_field( name = 'cache-control' ).

* some Browsers have caching problems when loading PDF format
response->set_header_field(
name = 'cache-control'
value = 'max-age=0' ).

* start PDF viewer either in the Browser or as a separate window
*response->set_header_field(
* name = 'content-disposition'
* value = 'attachment; filename=webforms.pdf' ).


* finally display PDF format in Browser
l_pdf_len = xstrlen( l_pdf_xstring ).
response->set_data( data = l_pdf_xstring
length = l_pdf_len ).

navigation->response_complete( ).


Danke im Voraus
Leah824
..
..
 
Posts: 35
Joined: Mon Oct 22, 2007 8:29 am

Return to BSP + BHTML

Who is online

Users browsing this forum: No registered users and 2 guests

cron