cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with PDF display...

Former Member
0 Kudos

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

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi all,

I got some trouble with PDF or EXCEL file when I want to display them. To solve this I store the file in the ICM cache , generate a dynamic URL then launch the generated's url. With this method you won't get problem links with version of I.E or Acrobat or EXCEL ......

Perhaps that will solve your problem .

Regards.

Bertrand.

Former Member
0 Kudos

you said it works with everything EXCEPT pdf... have you checked your Adobe Acrobat settings?

I had a similar problem, in Acrobat Reader use Edit->Preferences, then Internet, uncheck 'Display PDF in Browser.' You must be an administrator to do this. Also check Help->Online Support which has a lot of good information.

Now Acrobat Reader should launch automatically...

Former Member
0 Kudos

Hello Matthias,

check out if you use HTML-code compression on your html-page/view.

This raises often problems with PDF.

Regards, Bernd

Former Member
0 Kudos

I made a work around - save xstring under a url in http header and call on page side this url in an iframe - this may only works within IE but thats okay for me...

Former Member
0 Kudos

Hi Matthias,

congratulations.

What about the excel-thing as promised in Thread Calling GUI_DOWNLOAD function from BSP (last change March 13th).

We tried out ',' and ';' but that didn't work.

What did you use as "tab delimeter"?

Regards, Bernd

Former Member
0 Kudos

*Positionsdaten

LOOP AT t_excel INTO ls_excel.

DO .

ASSIGN COMPONENT sy-index OF STRUCTURE ls_excel TO <ls_field>.

IF NOT sy-subrc IS INITIAL.

EXIT.

ENDIF.

CALL METHOD z_convert_string_to_excel

EXPORTING

data = <ls_field>

IMPORTING

stringline = stringline

linesize = linesize.

ENDDO.

CONCATENATE stringline cl_abap_char_utilities=>cr_lf

INTO stringline.

linesize = linesize + 2.

ENDLOOP.

--> Methodenparameter

DATA Importing Type ANY

STRINGLINE Exporting Type STRING

LINESIZE Exporting Type I

--> Methodencoding

METHOD z_convert_string_to_excel.

DATA: prc_field_char(8096) TYPE c,

prc_data_type TYPE c,

prc_blanks_length TYPE c,

prc_field_string TYPE string,

prc_line_string TYPE string,

prc_tab_string TYPE string,

prc_blanks TYPE string.

DATA: par_write_field_seperator(1) VALUE ';'.

FIELD-SYMBOLS: <f> TYPE ANY.

class cl_abap_char_utilities definition load.

prc_tab_string = cl_abap_char_utilities=>horizontal_tab.

ASSIGN data TO <f>.

DESCRIBE FIELD <f> TYPE prc_data_type.

MOVE <f> TO prc_field_char.

*Condense for type <> Char and String

IF prc_data_type <> 'C' AND prc_data_type <> 'g'.

CONDENSE prc_field_char.

ENDIF.

prc_field_string = prc_field_char.

*Add tab character between fields

CONCATENATE prc_line_string prc_field_string prc_tab_string

INTO prc_line_string.

linesize = linesize + STRLEN( prc_line_string ).

CONCATENATE stringline prc_line_string INTO stringline.

ENDMETHOD.

---> das ganze als Xstring

*XSTRING erzeugen

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = stringline

IMPORTING

buffer = xstring

EXCEPTIONS

failed = 1

OTHERS = 2.

und ausgeben...

CREATE OBJECT ref_bsp_utility.

CONCATENATE 'attachment; filename=' survey '.xls' INTO lf_filename.

  • xstring downloaden

CALL METHOD ref_bsp_utility->download

EXPORTING

object_s = xfeld

content_type = 'application/download'

content_disposition = lf_filename

response = response

navigation = navigation.

  • Seite aufrufen

navigation->response_complete( ).