Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Get PDF from base64Binary

MKusters
Explorer
0 Likes
19,375

Hi all,

I am trying to implement a webservice. I receive an answer (XML) with a PDF encoded in a tag the tag starts with <getVerzendlijstResult xsi:type="xsd:base64Binary">.

But now the problem.... how can I extract the PDF from here.

I tried a lot of possibilities and searched on the forum here, but can not find an answer... Every PDF document I download is not readable.

DATA out TYPE xstring.

     DATA lt_bintab TYPE TABLE OF x255.

     DATA: str3 TYPE string,

                str4 TYPE string.


CALL METHOD cl_http_utility=>if_http_utility~decode_base64

       EXPORTING

         encoded = str3 " RAWSTRING from webservice

       RECEIVING

         decoded = str4.

     CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

       EXPORTING

         text     = str4

         mimetype = 'APPLICATION/PDF'

       IMPORTING

         buffer   = out.

CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'

   EXPORTING

     buffer                = out

*   APPEND_TO_TABLE       = ' '

* IMPORTING

*   OUTPUT_LENGTH         =

   tables

     binary_tab            = lt_bintab.

     CALL FUNCTION 'GUI_DOWNLOAD'

       EXPORTING

         filename = '<path>\Desktop\file.pdf'

         filetype = 'BIN'

       TABLES

         data_tab = lt_bintab.


Can anybody help me??

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
17,251

Hi,

Try this version:

REPORT  y_r_eitan_test_40_09 .

*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME .

PARAMETERS: p_debug TYPE debug_flg .

SELECTION-SCREEN END OF BLOCK block04 .

AT SELECTION-SCREEN .

  PERFORM at_selection_screen_input .

*----------------------------------------------------------------------*

FORM at_selection_screen_input .

  DATA: data_set_name_1 TYPE pathextern .

  data_set_name_1 = '\\<yourpath>\xml6.XML' .

  DATA: it_data_1 TYPE soli_tab .

  PERFORM upload_file_1

    USING

      data_set_name_1

    CHANGING

      it_data_1.

  DATA: xml_string TYPE string .

  CALL METHOD cl_bcs_convert=>txt_to_string

    EXPORTING

      it_soli   = it_data_1

    RECEIVING

      ev_string = xml_string.

  DATA: ob_ixml TYPE REF TO if_ixml.

  ob_ixml = cl_ixml=>create( ).

  DATA: streamfactory TYPE REF TO if_ixml_stream_factory.

  streamfactory = ob_ixml->create_stream_factory( ).

  DATA: istream TYPE REF TO if_ixml_istream.

  istream  = streamfactory->create_istream_string( string = xml_string ).

  DATA: document TYPE REF TO if_ixml_document.

  document = ob_ixml->create_document( ) .

  DATA: parser TYPE REF TO if_ixml_parser.

  parser = ob_ixml->create_parser( stream_factory = streamfactory

                                  istream        = istream

                                  document       = document ).

  parser->parse( ).

  DATA: nodes  TYPE REF TO if_ixml_node_collection.

  DATA: node   TYPE REF TO if_ixml_node .

  nodes = document->get_elements_by_tag_name( name = 'getVerzendlijstResult' ).

  node = nodes->get_item( 0 ).

  DATA: string_1  TYPE string .

  DATA: string_2  TYPE string .

  string_1 = node->get_value( ) .

  CALL METHOD cl_http_utility=>decode_base64

    EXPORTING

      encoded = string_1

    RECEIVING

      decoded = string_2.

  DATA: decoded TYPE xstring .

  CALL METHOD cl_http_utility=>decode_x_base64

    EXPORTING

      encoded = string_2

    RECEIVING

      decoded = decoded.

  DATA: data_set_name_2 TYPE pathextern .

  data_set_name_2 = '\\<yourpath>\result.pdf' .

  DATA: mess TYPE string .

  OPEN DATASET data_set_name_2 FOR OUTPUT IN BINARY MODE MESSAGE mess .

  IF sy-subrc NE 0.

    MESSAGE e306(f7) WITH data_set_name_2 .

    RETURN .

  ENDIF.

  TRANSFER decoded TO data_set_name_2 NO END OF LINE .

  CLOSE DATASET data_set_name_2 .

  MESSAGE s640(ms) WITH data_set_name_2 .

ENDFORM.                    "do_xml_parse_1

*----------------------------------------------------------------------*

FORM upload_file_1

  USING

    p_path TYPE pathextern

  CHANGING

    it_data_1 TYPE soli_tab .

  DATA: filename   TYPE string ,

        filelength TYPE i .

  filename = p_path .

  CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

      filename                = filename

      filetype                = 'ASC'

*     has_field_separator     = abap_false

      read_by_line            = abap_false

*     dat_mode                = abap_false

*     codepage                = space

*     ignore_cerr             = abap_true

    IMPORTING

      filelength              = filelength

    CHANGING

      data_tab                = it_data_1

    EXCEPTIONS

      file_open_error         = 1

      file_read_error         = 2

      no_batch                = 3

      gui_refuse_filetransfer = 4

      invalid_type            = 5

      no_authority            = 6

      unknown_error           = 7

      bad_data_format         = 8

      header_not_allowed      = 9

      separator_not_allowed   = 10

      header_too_long         = 11

      unknown_dp_error        = 12

      access_denied           = 13

      dp_out_of_memory        = 14

      disk_full               = 15

      dp_timeout              = 16

      not_supported_by_gui    = 17

      error_no_gui            = 18

      OTHERS                  = 19.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF .

ENDFORM .                    "upload_file_1

*----------------------------------------------------------------------*

30 REPLIES 30
Read only

rosenberg_eitan
Active Contributor
0 Likes
17,251

Hi,

 

I think that first of all you need to get just the PDF node.

You can to parse the xml using Class CL_IXML  .

See program y_r_eitan_test_40_05 at:

see FORM do_xml_parse_1 as a sample of parsing xml.

                  

Regards.

Read only

0 Likes
17,251

Hi,

Reading the XML isn't the issue. I have the node transfered into XML and extracted the PDF node into a string. But now..... everything I try, I can't get a readable PDF

Read only

Former Member
0 Likes
17,251

Hi brother, in this example, I Had to decodify a ".ZIP" file that was codificated in Base 64:

REPORT  zteste_64.

TYPES: t_xline(2048) TYPE x, “BINARY FILES

BEGIN OF t_line,
line(1024) TYPE c,
END OF t_line. “CONTENT

DATA: obj    TYPE REF TO cl_http_utility,
cref   TYPE REF TO if_http_utility,
cl_zip TYPE REF TO cl_abap_zip .

DATA: z        TYPE string,
decodex  TYPE xstring,
files    LIKE LINE OF  cl_abap_zip=>files,
name     TYPE string,
output_x TYPE xstring, “BINARY OUTPUT OUTPUT
size     TYPE i,
data_tab TYPE STANDARD TABLE OF t_xline,
text_tab TYPE STANDARD TABLE OF t_line.

CREATE OBJECT : obj.
cref = obj.

“A variável Z contém um arquivo .CSV zipado e codificado em base 64 ;D
CONCATENATE
‘UEsDBBQACAgIALJUl0cAAAAAAAAAAAAAAAAZAAAAUkZYQXdhcmRfRG9jNjQ1MTQyODYwLmNzdu1X’
‘UW/bNhB+768g/NQBbkvSkizvaa4TowZix7OK7nFgJM7hKpEqSTlN0X+zhz7tV+SP7UhJtpw6KVxs’
’69IlIGLe8Xi8++47QuxNVFGoTNjrXr830ZxZoSQ6YZaDvNTqd55aNMs6wvmV5LojvxY2d8ZzZcVG’
‘oUwhv2KVc1hpzWXqfJ9uuATj65JvhdZTLflDGqvGZVKVZS64RgtW7MnLSyX3FOMs09yYrupcr5kU’
‘H+qEbjvYW/QnJ2wj5NqgJdcpxMDWNQAidb8rJt/CTxP9S5E10cqMa55C0hyteAEBMJc0bNcu+9li’
‘cv76dDVPYH7CMmVQyTRDU2YrDfFID9HM8gItquKihuK95eA0Q+3J9XId/c8Vk7auVALIQ+gvzpR1’
‘cfH3VqGXmm/8lqJUxsJpHI1z8a5SlhkkZJpXhnmEUqU5esPyyqfItBWpKME1SAsNibyrhBEpU02q’
‘iYWATWO6C3WiZOasXPJLtt4mtJjMPdIXhTCmQybYyLVCLiGHBzep9tuBgGXOLXPMaRaXmn3wfk8B’
‘Sb52oM7BiRYsb2LqEMuJLVpu/hmE4yumM4AiV2ld770SJzBlWiiUCFuxm083fyhkAHN786etctV7’
‘0nMAX1Z9FKKF2vQRxSQE1S9JFAzwKBpFgSc6IA75IccwBTCNs0JIXxpjOZozWbEcYUzRM4RDQhon’
‘S56JzOO8OnM0my59qhBe7rQnKo2CkAQ0jrBH3DKHGHZbPx+0UZ8JyVskZyfBcEDDIcExSNzz9eaT’
‘QnrLVoIxRq+A2LqAc4EpyYuxO2u6glB9Wo5IU819ETNP49/2GBz6s12AmS9qjeFFw0aC66is52ir’
‘nSXzCfgn9MlsOXOTxuqMswza0O2jgyCMXPnSlJeWu34bUFCSYABThjbCWJdAENIwCmN/A8k+Gu1V’
‘idwOK23Y5rzh7THDeLQtAt3l48bDqX/8jervikT6Q3wXA+hhBkzmyfEM2Op29Y9D0FASHCYA/RIB’
‘RvEwCoMBJdsqeBzbhB4WBe4gQBBAi+B/9AI4qvvrMZPC1jf6oUp3x31dfLCHd+Oxdl9u3qP69tja’
‘3deAB9vve6sduWV1T7fcGq/ghlPwEVNLd+DbHf8PAO+h7COAhwCkX83AFTdctwuP+B1NwO8Vv6nS’
‘Eu1MSfMH06JWPl+z/JLB++8nw8rncOV3oml3SW6vlH4rsh+ZxARTGgVDMsDP7MeL6pprcw3mhVtN’
‘i19pPCKUxPFHoyqdwvfhnZtr5PxHPDlUURzGOHgYj6E9wJ52Mf+h9994IBHc/n9k6lcyNf5WTP17’
‘n23Hc/Vff8p1yPoXUEsHCBH4k+/XAwAA9hQAAFBLAQIUABQACAgIALJUl0cR+JPv1wMAAPYUAAAZ’
‘AAAAAAAAAAAAAAAAAAAAAABSRlhBd2FyZF9Eb2M2NDUxNDI4NjAuY3N2UEsFBgAAAAABAAEARwAA’
‘AB4EAAAAAA==’ INTO z.

decodex = obj->if_http_utility~decode_x_base64( z ).

CREATE OBJECT cl_zip.

CALL METHOD cl_zip->load( EXPORTING zip = decodex ).

LOOP AT cl_zip->files INTO files.

CLEAR output_x.
MOVE files–name TO name.

cl_zip->getEXPORTING name    = name
IMPORTING content = output_x ).

REFRESH data_tab.

CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY’
EXPORTING
buffer        = output_x
IMPORTING
output_length = size
TABLES
binary_tab    = data_tab.

CALL FUNCTION ‘SCMS_BINARY_TO_TEXT’
EXPORTING
input_length = size
TABLES
binary_tab   = data_tab
text_tab     = text_tab.

“Salva o arquivo descompactado em diretório local
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
bin_filesize = size
filename     = ‘C:\Temp\teste.csv’
filetype     = ‘BIN’
CHANGING
data_tab     = data_tab.

ENDLOOP.

Hope it could help, regards,

Alysson Dias

Read only

0 Likes
17,251

Unfortunally that is also not the solution. I still get the message the file is not supported or damaged after the download.

Read only

rosenberg_eitan
Active Contributor
0 Likes
17,251

Hi,

I think I got it .

Some code:

REPORT  y_r_eitan_test_40_09 .

*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME .

PARAMETERS: p_debug TYPE debug_flg .

SELECTION-SCREEN END OF BLOCK block04 .

AT SELECTION-SCREEN .

  PERFORM at_selection_screen_input .

*----------------------------------------------------------------------*

FORM at_selection_screen_input .

  DATA: data_set_name_1 TYPE pathextern .

  data_set_name_1 = '\\<yourpath>\ChartDesigner.Base64.xml' .

  DATA: it_data_1 TYPE soli_tab .

  PERFORM upload_file_1

    USING

      data_set_name_1

    CHANGING

      it_data_1.

  DATA: xml_string TYPE string .

  CALL METHOD cl_bcs_convert=>txt_to_string

    EXPORTING

      it_soli   = it_data_1

    RECEIVING

      ev_string = xml_string.

  DATA: ob_ixml TYPE REF TO if_ixml.

  ob_ixml = cl_ixml=>create( ).

  DATA: streamfactory TYPE REF TO if_ixml_stream_factory.

  streamfactory = ob_ixml->create_stream_factory( ).

  DATA: istream TYPE REF TO if_ixml_istream.

  istream  = streamfactory->create_istream_string( string = xml_string ).

  DATA: document TYPE REF TO if_ixml_document.

  document = ob_ixml->create_document( ) .

  DATA: parser TYPE REF TO if_ixml_parser.

  parser = ob_ixml->create_parser( stream_factory = streamfactory

                                  istream        = istream

                                  document       = document ).

  parser->parse( ).

  DATA: nodes  TYPE REF TO if_ixml_node_collection.

  DATA: node   TYPE REF TO if_ixml_node .

  nodes = document->get_elements_by_tag_name( name = 'pdfData' ).

  node = nodes->get_item( 0 ).

  DATA: value  TYPE string .

  value = node->get_value( ) .

  DATA: ob_http_utility TYPE REF TO cl_http_utility .

  DATA: decoded TYPE xstring .

  CALL METHOD cl_http_utility=>if_http_utility~decode_x_base64

    EXPORTING

      encoded = value

    RECEIVING

      decoded = decoded.

  DATA: data_set_name_2 TYPE pathextern .

  data_set_name_2 = '\\<yourpath>\ChartDesigner.pdf' .

  DATA: mess TYPE string .

  OPEN DATASET data_set_name_2 FOR OUTPUT IN BINARY MODE MESSAGE mess .

  IF sy-subrc NE 0.

    MESSAGE e306(f7) WITH data_set_name_2 .

    RETURN .

  ENDIF.

  TRANSFER decoded TO data_set_name_2 NO END OF LINE .

  CLOSE DATASET data_set_name_2 .

  MESSAGE s640(ms) WITH data_set_name_2 .

ENDFORM.                    "do_xml_parse_1

*----------------------------------------------------------------------*

FORM upload_file_1

  USING

    p_path TYPE pathextern

  CHANGING

    it_data_1 TYPE soli_tab .

  DATA: filename   TYPE string ,

        filelength TYPE i .

  filename = p_path .

  CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

      filename                = filename

      filetype                = 'ASC'

*     has_field_separator     = abap_false

      read_by_line            = abap_false

*     dat_mode                = abap_false

*     codepage                = space

*     ignore_cerr             = abap_true

    IMPORTING

      filelength              = filelength

    CHANGING

      data_tab                = it_data_1

    EXCEPTIONS

      file_open_error         = 1

      file_read_error         = 2

      no_batch                = 3

      gui_refuse_filetransfer = 4

      invalid_type            = 5

      no_authority            = 6

      unknown_error           = 7

      bad_data_format         = 8

      header_not_allowed      = 9

      separator_not_allowed   = 10

      header_too_long         = 11

      unknown_dp_error        = 12

      access_denied           = 13

      dp_out_of_memory        = 14

      disk_full               = 15

      dp_timeout              = 16

      not_supported_by_gui    = 17

      error_no_gui            = 18

      OTHERS                  = 19.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF .

ENDFORM .                    "upload_file_1

*----------------------------------------------------------------------*

The xml

Read only

0 Likes
17,251

I'am getting a little bit desperate.... . It still doesn't work. For a moment I was hopefull because I don't took the open dataset in consideration. But unfortunally....

Can you help me if I send you my XML?

Read only

0 Likes
17,251

Hi,

Yes please send the xml . (upload limit is 1 MB)


Very odd

The program is tested and works here .

I created the xml file using Java.

Have you tried my code (with modification of file path) .

                 

Regards.

Read only

0 Likes
17,251

Hi Eitan,

Yes, I tried your program. and changed the paths. After closing the dataset. I tried to download it as a BIN file with CG3Y to my local desktop to check if it works.

Attached the XML file. Thanks in advance!

Regards

Read only

0 Likes
17,251

Hi,

I am at home at the moment so I will try to do it using java.

If this will work ok next sunday I will try it at the office.

Lets hope for the best

Regards.

Read only

0 Likes
17,251

Hi,

After converting the getVerzendlijstResult I am not getting a valid PDF file.

Is there a chance that the file is encrypted ?

Do you have the original ?

If yes convert it to base64 file is the result the same as the one you have inthe XML ?

Regards

Read only

0 Likes
17,251

Hi,

You can also use Base64: Encode and Decode Base64 Files

Regards.

Read only

0 Likes
17,251

This is the answer I receive after calling the webservice method.

I suppose that in the string there another XML is coded. Because if I transform this string to XML I get a tag called <PDF>.

I tried 2 alternatives: - first decode the getVerzendlijstResult string and then transform to XML I get the tag <PDF> => convert to readable PDF fails

                                          - first transform the getVerzendlijstResult string to XML and then decode the <PDF> tag => convert to readable PDF fails

Read only

0 Likes
17,250

Hi,

Is this a public webservice ?

Any way I sugest you get in tuch with the people who run the webservice and ask how to use the site ?

Try with the attached file .

When I crated the xml I simply encode the file and the put the result string in xml node .

I use JDOM for the xml JDOM

Read only

0 Likes
17,250

When I do

I get

This is the pdf .

In this case it is blank.

Regards.

Read only

0 Likes
17,250

I don't really get what you are trying to say: In this case it is naturally I don't get a readable PDF in ABAP? I expect if the PDF is empty, I get a empty/blank PDF.... or am I wrong?

Read only

0 Likes
17,250

Hi,

I means that I am getting a valid 1 page PDF (not a corruptible one) .

It seems that it is blank (no data).

Is this what you expected ?

do you have a copy of the original PDF ?

                 

Regards.

looks like this:

Read only

0 Likes
17,250

Hi,


Is this a public web service ?


Regards.


Read only

0 Likes
17,250

No it is not a public WS. You need login credentials.

It can be a empty PDF in this case (I had no orders to display).

Attached a new XML, with one order. I tried it with your ABAP, but unfortunally this also wasn't successfull.

I also attached the PDF (downloaded directly from the website) like the PDF in the XML should look like.

Read only

0 Likes
17,250

Hi,

I have a better result.....

Java steps:

@Test

    public void test_1() throws Exception {

        final String parseXML = parseXML(Paths.get("xml6.XML"));

        final String string_1 = new String(Base64.getDecoder().decode(parseXML));

        final byte[] decode = Base64.getDecoder().decode(string_1);

        Files.newOutputStream(Paths.get("xml6.pdf")).write(decode);

    }

and I have:

Regards.

Read only

0 Likes
17,250

That's a lot better.... But i need a ABAP solution

Read only

0 Likes
17,250

Hi,

Trying now......

Regards.

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
17,250

Very basic mistake when working with binary data.

You need to provide size of file when downloading!

You will get size from

SCMS_XSTRING_TO_BINARY

*   OUTPUT_LENGTH

And use it in:

GUI_DOWNLOAD

Hope it helps

-- Tomas --
Read only

0 Likes
17,250

I already tried this after the post of Alysson Dias da Silva

Read only

0 Likes
17,250

OK. I do not know what is your current testing code.

But looking on first post I think you are converting too much.

Did you tried Alyssons method of decode?

cl_http_utility=>decode_x_base64( ).

It has direct output in xstring so you have binary data right there. Without other conversions which might corrupt file data.

-- Tomas --
Read only

0 Likes
17,250

Hi,

If you look at this post this is what I used and it works with no problem.

Regards.

Read only

rosenberg_eitan
Active Contributor
17,252

Hi,

Try this version:

REPORT  y_r_eitan_test_40_09 .

*----------------------------------------------------------------------*

SELECTION-SCREEN BEGIN OF BLOCK block04 WITH FRAME .

PARAMETERS: p_debug TYPE debug_flg .

SELECTION-SCREEN END OF BLOCK block04 .

AT SELECTION-SCREEN .

  PERFORM at_selection_screen_input .

*----------------------------------------------------------------------*

FORM at_selection_screen_input .

  DATA: data_set_name_1 TYPE pathextern .

  data_set_name_1 = '\\<yourpath>\xml6.XML' .

  DATA: it_data_1 TYPE soli_tab .

  PERFORM upload_file_1

    USING

      data_set_name_1

    CHANGING

      it_data_1.

  DATA: xml_string TYPE string .

  CALL METHOD cl_bcs_convert=>txt_to_string

    EXPORTING

      it_soli   = it_data_1

    RECEIVING

      ev_string = xml_string.

  DATA: ob_ixml TYPE REF TO if_ixml.

  ob_ixml = cl_ixml=>create( ).

  DATA: streamfactory TYPE REF TO if_ixml_stream_factory.

  streamfactory = ob_ixml->create_stream_factory( ).

  DATA: istream TYPE REF TO if_ixml_istream.

  istream  = streamfactory->create_istream_string( string = xml_string ).

  DATA: document TYPE REF TO if_ixml_document.

  document = ob_ixml->create_document( ) .

  DATA: parser TYPE REF TO if_ixml_parser.

  parser = ob_ixml->create_parser( stream_factory = streamfactory

                                  istream        = istream

                                  document       = document ).

  parser->parse( ).

  DATA: nodes  TYPE REF TO if_ixml_node_collection.

  DATA: node   TYPE REF TO if_ixml_node .

  nodes = document->get_elements_by_tag_name( name = 'getVerzendlijstResult' ).

  node = nodes->get_item( 0 ).

  DATA: string_1  TYPE string .

  DATA: string_2  TYPE string .

  string_1 = node->get_value( ) .

  CALL METHOD cl_http_utility=>decode_base64

    EXPORTING

      encoded = string_1

    RECEIVING

      decoded = string_2.

  DATA: decoded TYPE xstring .

  CALL METHOD cl_http_utility=>decode_x_base64

    EXPORTING

      encoded = string_2

    RECEIVING

      decoded = decoded.

  DATA: data_set_name_2 TYPE pathextern .

  data_set_name_2 = '\\<yourpath>\result.pdf' .

  DATA: mess TYPE string .

  OPEN DATASET data_set_name_2 FOR OUTPUT IN BINARY MODE MESSAGE mess .

  IF sy-subrc NE 0.

    MESSAGE e306(f7) WITH data_set_name_2 .

    RETURN .

  ENDIF.

  TRANSFER decoded TO data_set_name_2 NO END OF LINE .

  CLOSE DATASET data_set_name_2 .

  MESSAGE s640(ms) WITH data_set_name_2 .

ENDFORM.                    "do_xml_parse_1

*----------------------------------------------------------------------*

FORM upload_file_1

  USING

    p_path TYPE pathextern

  CHANGING

    it_data_1 TYPE soli_tab .

  DATA: filename   TYPE string ,

        filelength TYPE i .

  filename = p_path .

  CALL METHOD cl_gui_frontend_services=>gui_upload

    EXPORTING

      filename                = filename

      filetype                = 'ASC'

*     has_field_separator     = abap_false

      read_by_line            = abap_false

*     dat_mode                = abap_false

*     codepage                = space

*     ignore_cerr             = abap_true

    IMPORTING

      filelength              = filelength

    CHANGING

      data_tab                = it_data_1

    EXCEPTIONS

      file_open_error         = 1

      file_read_error         = 2

      no_batch                = 3

      gui_refuse_filetransfer = 4

      invalid_type            = 5

      no_authority            = 6

      unknown_error           = 7

      bad_data_format         = 8

      header_not_allowed      = 9

      separator_not_allowed   = 10

      header_too_long         = 11

      unknown_dp_error        = 12

      access_denied           = 13

      dp_out_of_memory        = 14

      disk_full               = 15

      dp_timeout              = 16

      not_supported_by_gui    = 17

      error_no_gui            = 18

      OTHERS                  = 19.

  IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF .

ENDFORM .                    "upload_file_1

*----------------------------------------------------------------------*

Read only

0 Likes
17,250

You are great!!! So the string was 2 times encoded....

Thank you very much!!!

Read only

0 Likes
17,250

Hi,

You are welcome.

It was intriguing.

Regard.

Read only

rosenberg_eitan
Active Contributor
0 Likes
17,250

Hi,

I found out that xml4.XML was OK after all .

we can also use cl_gui_frontend_services=>gui_download .

Note the

Regards.

*----------------------------------------------------------------------*

FORM dnload_1_file_1

  USING

    pathextern   TYPE pathextern

    bin_filesize TYPE i

  CHANGING

    it_solix TYPE solix_tab .

  DATA: filename TYPE string .

  filename = pathextern .

  CALL METHOD cl_gui_frontend_services=>gui_download

    EXPORTING

      filename                = filename

      filetype                = 'BIN'

      bin_filesize            = bin_filesize

    CHANGING

      data_tab                = it_solix

    EXCEPTIONS

      file_write_error        = 1

      no_batch                = 2

      gui_refuse_filetransfer = 3

      invalid_type            = 4

      no_authority            = 5

      unknown_error           = 6

      header_not_allowed      = 7

      separator_not_allowed   = 8

      filesize_not_allowed    = 9

      header_too_long         = 10

      dp_error_create         = 11

      dp_error_send           = 12

      dp_error_write          = 13

      unknown_dp_error        = 14

      access_denied           = 15

      dp_out_of_memory        = 16

      disk_full               = 17

      dp_timeout              = 18

      file_not_found          = 19

      dataprovider_exception  = 20

      control_flush_error     = 21

      not_supported_by_gui    = 22

      error_no_gui            = 23

      OTHERS                  = 24.

  IF sy-subrc NE 0 .

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

               WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

  ENDIF.

ENDFORM.                    "dnload_1_file_1

*----------------------------------------------------------------------*

Read only

0 Likes
17,249

Yes, I already found that.

I only had another challange yesterday. We don't get a formated XML from the webservice as we used for your solution/tests. But we get a structure with only a XSTRING in it (not XML).

Now I transform this to XML with a Call Transformation. I get a XML, but.... The problem is, in the xml string there are horizontal tabs (#) wich I can not delete with a REPLACE. So I first get the PDF tag, then loop over the string and concatenate the string without the hashtags. So I get a clean PDF string which I can decode.

I think there is a easier solution.... but this one works.

I tried with  "streamfactory->create_istream_xstring( string = xml_xstring ).", but this doesn't generate a XML with items I can read (for sure not the elementtag 'getVerzendlijstResult').