Skip to Content
author's profile photo Former Member
Former Member

HTTP AND PDF file download

I have some problems to send a PDF FILE to a http server using if_http_client class with for example methods :

CALL METHOD client->request->set_header_field

CALL METHOD client->send

CALL METHOD client->receive

I don’t want to use FM SO_NEW_DOCUMENT_ATT_SEND_API1, SO_NEW_DOCUMENT_ATT_SEND_MAPI , SO_NEW_DOCUMENT_SEND_API1

Could someone please give me a sample abap program doing this ?

It could be great.

Thanks

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Dec 28, 2005 at 05:21 AM

    Welcome to SDN.

    1. upload the pdf file to a itab using GUI_UPLOAD (file type 'BIN') ( i assume that you are doing this abap program and not in BSP page)

    2. create a instance of cl_http_client

    call method cl_http_client=>create

    exporting

    host = 'www.server.com'

    service = '80'

    scheme = '1'

    importing

    client = http_client.

    3. set header fields.

    call method http_client->request->set_header_field

    exporting

    name = '~request_method'

    value = 'POST'.

    call method http_client->request->set_header_field

    exporting

    name = '~server_protocol'

    value = 'HTTP/1.1'.

    call method http_client->request->set_header_field

    exporting

    name = 'Content-Type'

    value = 'application/pdf' .

    call method http_client->request->set_data

    exporting

    data = <xstring holding the uploaded content>

    offset = 0

    length = rlength.

    call method http_client->request->set_header_field

    exporting

    name = 'Content-Length'

    value = txlen.

    call method http_client->send

    exceptions

    http_communication_failure = 1

    http_invalid_state = 2.

    call method http_client->receive

    exceptions

    http_communication_failure = 1

    http_invalid_state = 2

    http_processing_failed = 3.

    clear wf_string1 .

    wf_string1 = http_client->response->get_cdata( ).

    Hope this is clear.

    Regards

    Raja

    Message was edited by: Durairaj Athavan Raja

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 28, 2005 at 10:24 PM

    A snippet of code that works for me.

    response->set_header_field( name = 'content-type'

    value = 'application/pdf' ).

    • some Browsers have caching probs when loading PDF

    response->set_header_field(

    name = 'cache-control'

    value = 'max-age=0' ).

    • l_pdf_xstring contains PDF data

    l_pdf_len = XSTRLEN( l_pdf_xstring ).

    response->set_data( data = l_pdf_xstring

    length = l_pdf_len ).

    navigation->response_complete( ).

    • End of code

    I am pretty sure SAP delivers an example that runs a smartform via a BSP and reders it as a PDF. Can't seem to find it though.

    Cheers

    Graham Robbo

    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.