Skip to Content
author's profile photo
Former Member

Data download from SAP to a PC local file using BSP.

I call a RFC SAP Back-end function from my WAS server that return me a internal table with data.

I want to download these data of this internal table on a PC local file (text file for exemple).

But i want this in just one action: the user click on a button then the RFC function is called and the file is downloaded in the same time.

How can i do that ?

Thank in advance,

Eric.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Jun 07, 2004 at 03:49 PM

    If you are talking about using the RFC call in context of BSP (which I am not sure about from your question), then please read:

    BSP Programming: Handling Of Non-HTML Documents

    /people/mark.finnern/blog/2003/09/23/bsp-programming-handling-of-non-html-documents

    Ignore the upload parts (you already have the text). Look specifically at how you place the content into the response object and also set the Content-Disposition header.

    ++bcm

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Jun 07, 2004 at 03:56 PM

    Hi Eric,

    you need only to set a few header field on the server response:

    Content-type: text/plain

    Content-Disposition: attachment; filename="readme.txt"

    strem out internal table content and "stop" the response.

    To do this, you can simply use a page flow logic.

    onInitialization:

    call method response->set_header_field

    exporting

    name = 'Content-type'

    value = 'text/plain'

    .

    call method response->set_header_field

    exporting

    name = 'Content-Disposition'

    value = 'attachment; filename="readme.txt"'

    .

    loop at itab

    into wa_itab

    .

    page->write( wa_itab ).

    endloop."at itab into wa_itab

    navigation->response_complete().

    This should work with an standard HTTP client, so you can encounter some problems using IE... 😊

    Some HTTP GURU says to use:

    Cache-Control: no-store, no-cache, must-revalidate

    Cache-Control: pre-check=0, post-check=0, max-age=0

    Content-Transfer-Encoding: none

    Content-Type: application/octetstream; name="readme.txt" #For IE

    Content-Type: application/octet-stream; name="readme.txt" #For others

    Content-Disposition: inline; filename="readme.txt"

    Content-length: file_lenght_in_bytes

    No more I know.

    Dany 😊

    Add comment
    10|10000 characters needed characters exceeded