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

Download from TemSe using OPEN DATASET - Codepage problem

0 Likes
1,097

Hi community,

I want to download data from temse.

Using the method cl_gui_frontend_services=>gui_download it's working fine, but only to presentation server. But the download should be performed by the system.

Therefore I wanted to use OPEN DATASET.

This also works, but with restrictions.

The format of the downloaded file is incorrect.

For example the contet should be 341, but in front of every digit there is an additional digtit. In this case 3. So the output is 333431, not the expected 341.

I assume this is a codepage problem, but I do not know how to solve it.

Here is a piece of code:


 IF p_file IS NOT INITIAL.

    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        bin_filesize         = filesize
        filename             = filename_string
        filetype             = 'BIN'
        no_auth_check        = 'X'
      IMPORTING
        filelength           = after_download_length
      CHANGING
        data_tab             = tab_x
      EXCEPTIONS
        file_not_found       = 91
        file_write_error     = 92
        filesize_not_allowed = 93
        invalid_type         = 95
        no_batch             = 96
        OTHERS               = 97.

    IF sy-subrc NE 0.                              "download error
      result = sy-subrc.
    ELSEIF after_download_length EQ 0.             "nothing written
      result = 97.
    ENDIF.

  ELSE.

    IF wa_regut-codepage = '4102' OR wa_regut-codepage = '4103'.
      OPEN DATASET filename_string IN BINARY MODE FOR OUTPUT.
    ELSEIF wa_regut-codepage = '4110'.
      OPEN DATASET filename_string IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
    ELSEIF wa_regut-codepage IS NOT INITIAL.
      OPEN DATASET filename_string FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE out_codepage.
    ELSE.
      OPEN DATASET filename_string FOR OUTPUT IN LEGACY BINARY MODE.
    ENDIF.

    LOOP AT tab_x INTO str_line.
      TRANSFER str_line TO wa_regut-dwnam.
    ENDLOOP.
    CLOSE DATASET wa_regut-dwnam.

  ENDIF.

The strange thing is, that inside the method gui_download there is no codepage conversion. This method and the transfer statement are using the same table, but the output is different.

Any ideas what could solve this?

Your help is highly appreciated!

Is there another possibility to download a file in backgroud processing?

Best regards

Tobias

Hi community,

I want to download data from temse.

Using the method cl_gui_frontend_services=>gui_download it's working fine, but only to presentation server. But the download should be performed by the system.

Therefore I wanted to use OPEN DATASET.

This also works, but with restrictions.

The format of the downloaded file is incorrect.

For example the contet should be 341, but in front of every digit there is an additional digtit. In this case 3. So the output is 333431, not the expected 341.

I assume this is a codepage problem, but I do not know how to solve it.

Here is a piece of code:


 IF p_file IS NOT INITIAL.

    CALL METHOD cl_gui_frontend_services=>gui_download
      EXPORTING
        bin_filesize         = filesize
        filename             = filename_string
        filetype             = 'BIN'
        no_auth_check        = 'X'
      IMPORTING
        filelength           = after_download_length
      CHANGING
        data_tab             = tab_x
      EXCEPTIONS
        file_not_found       = 91
        file_write_error     = 92
        filesize_not_allowed = 93
        invalid_type         = 95
        no_batch             = 96
        OTHERS               = 97.

    IF sy-subrc NE 0.                              "download error
      result = sy-subrc.
    ELSEIF after_download_length EQ 0.             "nothing written
      result = 97.
    ENDIF.

  ELSE.

    IF wa_regut-codepage = '4102' OR wa_regut-codepage = '4103'.
      OPEN DATASET filename_string IN BINARY MODE FOR OUTPUT.
    ELSEIF wa_regut-codepage = '4110'.
      OPEN DATASET filename_string IN TEXT MODE FOR OUTPUT ENCODING DEFAULT.
    ELSEIF wa_regut-codepage IS NOT INITIAL.
      OPEN DATASET filename_string FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE out_codepage.
    ELSE.
      OPEN DATASET filename_string FOR OUTPUT IN LEGACY BINARY MODE.
    ENDIF.

    LOOP AT tab_x INTO str_line.
      TRANSFER str_line TO wa_regut-dwnam.
    ENDLOOP.
    CLOSE DATASET wa_regut-dwnam.

  ENDIF.

The strange thing is, that inside the method gui_download there is no codepage conversion. This method and the transfer statement are using the same table, but the output is different.

Any ideas what could solve this?

Your help is highly appreciated!

Is there another possibility to download a file in backgroud processing?

Best regards

Tobias

3 REPLIES 3
Read only

Former Member
0 Likes
731

Hi,

UPLOADING AND DOWNLOADING FILE FROM/TO APPLICATION SERVER TO/FROM WORKSTATION

Use the Function Module ARCHIVFILE_CLIENT_TO_SERVER.

Use the function Module ARCHIVFILE_SERVER_TO_CLIENT.

Give file path in PATH and Destination Path

OR

GET THE FILE IN AN INTERNAL TABLE AND USE DATASET COMMANDS TO WRITE THE FILE IN APPLICATION SERVER

Hope this helps...

Manish

Read only

0 Likes
731

Hi Manish,

I'm already using dataset commands. But the content in the file is not correct . I have the strong supposition that there is a problem with the codepage. And the strange thing is, that there is no codepage conversion in gui_download (which is working fine)

Read only

0 Likes
731

It's working now.

tab_x was type x , str_line was typ string. It is neccessary that tab_x is looped into xstring. After that xstring has to be converted into string.

Thanks for your help.