Skip to Content
0
Former Member
Mar 09, 2004 at 03:36 PM

Problems with PDF display...

57 Views

Hi @ all,

I have a stupid problem that makes me confused.

I have stored some file attachments in SAP System via GOS

that works fine (some ppt, some pdf and so on) and I can see the attachments their and can also open them.

Now I would like to display them in my webside this works like following:

DATA l_filesize TYPE i.

DATA l_filesize_string TYPE string.

DATA l_mimetype_string TYPE string.

DATA ls_phio TYPE sdokobject.

DATA ls_file_info TYPE sdokfilaci.

DATA ls_xdata TYPE xstring.

DATA lt_file_info TYPE TABLE OF sdokfilaci.

DATA lt_content_binary TYPE sdokcntbins.

DATA lt_content_ascii TYPE sdokcntascs.

data lf_filename type string .

ls_phio = request->get_form_field( name = 'phio' ).

CALL FUNCTION 'SDOK_PHIO_LOAD_CONTENT'

EXPORTING

object_id = ls_phio

TABLES

file_access_info = lt_file_info[]

file_content_ascii = lt_content_ascii[]

file_content_binary = lt_content_binary[]

EXCEPTIONS

not_existing = 1

not_authorized = 2

no_content = 3

bad_storage_type = 4

OTHERS = 5.

CHECK sy-subrc EQ 0.

READ TABLE lt_file_info INTO ls_file_info INDEX 1.

CHECK sy-subrc EQ 0.

l_filesize = ls_file_info-file_size.

l_mimetype_string = request->get_form_field( name

= 'mimetype' ).

  • set file size

l_filesize_string = l_filesize.

response->set_header_field( name = 'Content-Length'

value = l_filesize_string ).

  • set MIME-type

response->set_header_field( name = 'Content-Type'

value = l_mimetype_string ).

response->set_header_field( name = 'Cache-Control'

value = 'max-age=0' ).

lf_filename = ls_file_info-file_name.

response->set_header_field( name = 'Content-

disposition'

value = lf_filename ).

IF NOT ls_file_info-binary_flg IS INITIAL.

CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'

EXPORTING

input_length = l_filesize

IMPORTING

buffer = ls_xdata

TABLES

binary_tab = lt_content_binary[]

EXCEPTIONS

failed = 1

OTHERS = 2.

CHECK sy-subrc EQ 0.

response->delete_header_field( 'Cache-Control' ).

response->delete_header_field( 'Expires' ).

response->delete_header_field( 'Pragma' ).

  • send content data in the xstring to response object:

response->set_data( ls_xdata ).

ENDIF.

navigation->response_complete( ).

--> It works wih any kind of file (Office, Pictures...) just when I have pdf it brings me back a initial web side... anyone a idea whats wrong??

Thanks Matthias