<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: PDF download froM HTTPS URL in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771269#M227293</link>
    <description>&lt;P&gt;Tried using this code to transfrom the XSTRING to string .. with no success / errors:
&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;        DATA: xcontent TYPE xstring .
        DATA: content TYPE string .
        DATA: conv   TYPE REF TO cl_abap_conv_in_ce.
        conv = cl_abap_conv_in_ce=&amp;gt;create( input = lv_responsex ).
        conv-&amp;gt;read( IMPORTING data = content ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 07 Jan 2019 14:50:03 GMT</pubDate>
    <dc:creator>MariusStoica</dc:creator>
    <dc:date>2019-01-07T14:50:03Z</dc:date>
    <item>
      <title>PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaq-p/771259</link>
      <description>&lt;P&gt;Hi guys,&lt;/P&gt;
  &lt;P&gt;I'm trying to download a PDF created by a third party from an API. I'm in a EHP4 FOR SAP ERP 6.0 / NW7.01 environment.&lt;/P&gt;
  &lt;P&gt;I created using SM50 a HTTP destination (type G and default SSL client) that I use to do POST and GET requests, and everything goes well, unless I try to download a PDF file.&lt;/P&gt;
  &lt;P&gt;Using: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;* Create HTTP client object
    CALL METHOD cl_http_client=&amp;gt;create_by_destination
      EXPORTING
        destination           = 'HTTPS'
      IMPORTING
        client                = lcl_client
      EXCEPTIONS
        destination_not_found = 1
        internal_error        = 2.
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I get a correct response:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;IF lv_status = 200.
 lv_response = lcl_client-&amp;gt;response-&amp;gt;get_cdata( ).
ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;And although "lv_response" has the data that looks correct:&lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;Field    LV_RESPONSE
Data Type          CString{26202}
Absolute Type      \TYPE=STRING

View
      %PDF-1.4##%����##7 0 obj##&amp;lt;&amp;lt;/Type /XObject /Subtype /Image /Width 152 /Height &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;When I try to transfer the string to the "file" something goes wrong. Here is the code I use to write the file: &lt;/P&gt; 
  &lt;PRE&gt;&lt;CODE&gt;DATA: ls_string             TYPE lvc_s_1022,
      lt_string             TYPE lvc_t_1022.

        DO .
          lv_len = STRLEN( lv_response ).
          IF lv_len &amp;lt;&amp;gt; 1022.
            ls_string-line = lv_response+0(lv_len).
          ELSE.
            ls_string-line = lv_response+0(1022).
          ENDIF.
          APPEND ls_string TO lt_string.
          SHIFT lv_response BY 1022 PLACES.
          IF lv_response IS INITIAL.
            EXIT.
          ENDIF.
        ENDDO.

        CONCATENATE lv_file '\' lv_filename '.pdf' INTO lv_file.

        CALL FUNCTION 'SCMS_DOWNLOAD'
          EXPORTING
            filename = lv_file
            binary   = 'X'
            frontend = 'X'
            mimetype = 'charset=UTF8'
          TABLES
            data     = lt_string
          EXCEPTIONS
            error    = 1
            OTHERS   = 2.

        IF sy-subrc &amp;lt;&amp;gt; 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                  WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I tried playing with the MIMETYPE parameter and BINARY paratemer, with no success. When opening the file with Acrobat Reader I get the error that the file is corrupt.&lt;/P&gt;
  &lt;P&gt;Any idea why this doesn't work ?&lt;/P&gt;
  &lt;P&gt;Kind regards,&lt;/P&gt;
  &lt;P&gt;Marius&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 12:37:50 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaq-p/771259</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T12:37:50Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771260#M227284</link>
      <description>&lt;P&gt;You didn't fill the FILESIZE parameter?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:01:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771260#M227284</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2019-01-07T13:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771261#M227285</link>
      <description>&lt;P&gt;Hi Giuseppi, &lt;/P&gt;&lt;P&gt;No. I didn't. How would I calculate that ?&lt;BR /&gt;Marius.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:17:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771261#M227285</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T13:17:53Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771262#M227286</link>
      <description>&lt;P&gt;Try first value of STRLEN( lv_response )&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:22:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771262#M227286</guid>
      <dc:creator>RaymondGiuseppi</dc:creator>
      <dc:date>2019-01-07T13:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771263#M227287</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;That didn't work. Same error.&lt;/P&gt;&lt;P&gt;I never tried using FM "SCMS_HTTP_GET_FILE" instead of the class. Do you think it might work ?&lt;/P&gt;&lt;P&gt;Or should I use another function to "download" the file ?&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Marius&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:30:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771263#M227287</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T13:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771264#M227288</link>
      <description>&lt;P&gt;1) You work with file = binary data. So do not get HTTP response as character data (get_cdata), but i think this metod:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;response-&amp;gt;get_data&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2) You work with binary data so always keep in mind binary data size as &lt;SPAN class="mention-scrubbed"&gt;raymond.giuseppi&lt;/SPAN&gt; suggested.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 13:58:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771264#M227288</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-01-07T13:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771265#M227289</link>
      <description>&lt;P&gt;Hi Thomas,&lt;/P&gt;&lt;P&gt;Already tried that. It doesn't work &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;1. I used &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lv_response = lcl_client-&amp;gt;response-&amp;gt;get_data( ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to read the response, and used the exact FM with the same parameters and have the same error message in Adobe. As a difference the string looks like :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;255044462D312E340D0A25A2A38F930D0A372030206F626A0D0A3C3C2F54797065202F584F626A656374202F53756274797065202F496D616765202F576964746820313532202F486569676874203433202F436F6C6F725370616365202F44657669636547726179202F42697473506572436F6D706F6E656E742038202F446&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;2. The parameter "binary" is checked in both cases.&lt;/P&gt;&lt;P&gt;Kind regards,&lt;BR /&gt;Marius&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:04:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771265#M227289</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T14:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771266#M227290</link>
      <description>&lt;P&gt;Aaaaand,&lt;/P&gt;&lt;P&gt;if I use the type XSTRING for the table &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;lt_string&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;to store the data in, I get an short dump.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt; Error in ASSIGN statement in program "SAPLSFES".&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:19:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771266#M227290</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T14:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771267#M227291</link>
      <description>&lt;P&gt;Well, I guess you have bugs like using string instead of xstring type and same for data table in SCMS_DOWNLOAD, it should be "binary data" table. For example existing type SOLIX_TAB.&lt;/P&gt;&lt;P&gt;TIP: CL_BCS_CONVERT is very handy class for converting xstring to solix_tab etc...&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:19:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771267#M227291</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-01-07T14:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771268#M227292</link>
      <description>&lt;P&gt;Use for example SOLIX_TAB type for SCMS_DOWNLOAD data table.&lt;/P&gt;&lt;P&gt;xstring is not table...&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:27:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771268#M227292</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-01-07T14:27:41Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771269#M227293</link>
      <description>&lt;P&gt;Tried using this code to transfrom the XSTRING to string .. with no success / errors:
&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;        DATA: xcontent TYPE xstring .
        DATA: content TYPE string .
        DATA: conv   TYPE REF TO cl_abap_conv_in_ce.
        conv = cl_abap_conv_in_ce=&amp;gt;create( input = lv_responsex ).
        conv-&amp;gt;read( IMPORTING data = content ).&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 07 Jan 2019 14:50:03 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771269#M227293</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T14:50:03Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771270#M227294</link>
      <description>&lt;P&gt;Issue solved ...&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;DATA: lv_responsex          TYPE xstring,
      ls_string             TYPE solix,
      lt_string             LIKE STANDARD TABLE OF ls_string.

        lv_responsex = lcl_client-&amp;gt;response-&amp;gt;get_data( ).

        CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
          EXPORTING
            buffer     = lv_responsex
          TABLES
            binary_tab = lt_string.

        CALL FUNCTION 'SCMS_DOWNLOAD'
          EXPORTING
            filename = lv_file
            binary   = 'X'
            frontend = 'X'
          TABLES
            data     = lt_string
          EXCEPTIONS
            error    = 1
            OTHERS   = 2.&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Finaly works like a charm &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:11:26 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771270#M227294</guid>
      <dc:creator>MariusStoica</dc:creator>
      <dc:date>2019-01-07T15:11:26Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771271#M227295</link>
      <description>&lt;P&gt;Nonono... &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt; You are still going wrong way.&lt;/P&gt;&lt;P&gt;From HTTP client you should have XSTRING. This XSTRING you can convert to SOLIX_TAB (I already gave you a tip how to do it). And this SOLIX_TAB you will use (with file size) in SCMS_DOWNLOAD (or GUI_DOWNLOAD - not sure why you selected to use SCMS_DOWNLOAD ???). &lt;/P&gt;&lt;P&gt;It is quite easy, basic ABAP handling of files...&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 15:11:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771271#M227295</guid>
      <dc:creator>Tomas_Buryanek</dc:creator>
      <dc:date>2019-01-07T15:11:45Z</dc:date>
    </item>
    <item>
      <title>Re: PDF download froM HTTPS URL</title>
      <link>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771272#M227296</link>
      <description>&lt;P&gt;Use released APIs as far as possible, i.e. use CL_GUI_FRONTEND_SERVICES=&amp;gt;GUI_DOWNLOAD instead of SCMS_DOWNLOAD. And better name lt_solix instead of lt_string ("string" is misleading!) and data lt_solix type table of solix (or type solix_tab)&lt;/P&gt;</description>
      <pubDate>Mon, 07 Jan 2019 19:35:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/pdf-download-from-https-url/qaa-p/771272#M227296</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2019-01-07T19:35:20Z</dc:date>
    </item>
  </channel>
</rss>

