Skip to Content
author's profile photo Former Member
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 a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on 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 a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on 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 a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.