Skip to Content
0
Former Member
Nov 15, 2006 at 08:24 AM

BSP to PDF

53 Views

Hi

I have a requirement where in I need to convert the BSP page to PDF.

I have created a smartform and caaled in BSP and then used FM 'CONVERT_OTF' .But it is not printing anything on the page. Please help.

Here is the code I have tried out:

CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'

EXPORTING

FORMNAME = 'ZUPI2C_OPEN_ORDER_SUMMARY'

  • VARIANT = ' '

  • DIRECT_CALL = ' '

IMPORTING

FM_NAME = L_FNAME.

  • EXCEPTIONS

  • NO_FORM = 1

  • NO_FUNCTION_MODULE = 2

  • OTHERS = 3

call function L_FNAME "'/1BCDWB/SF00000196'

EXPORTING

user_settings = space

control_parameters = control_parameters

output_options = output_options

TRUE = TRUE

P_ALL_L = TRUE

IMPORTING

job_output_info = output_data

TABLES

lt_output = lt_output

LT_TOTALS = LT_TOTALS

EXCEPTIONS

formatting_error = 1

internal_error = 2

send_error = 3

user_canceled = 4

others = 5.

call function 'CONVERT_OTF'

EXPORTING

format = 'PDF'

IMPORTING

bin_filesize = l_pdf_len

bin_file = l_pdf_xstring

TABLES

OTF = 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 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.

ENDIF.

It is giving error in FM 'GUID_CREATE' as invalid URL