Application Development 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: 

Download and upload of file to server dir (AL11)

jepi_flanders
Participant
0 Kudos

Hello,

I have a custom program that is downloading files from application server directory (they are like templates) to user local pc. User is then modifying such files and finally upload them in another AS directory.

The program is currently making use of FM's C13Z_FILE_DOWNLOAD_BINARY and  C13Z_FILE_UPLOAD_BINARY.

There was no problem until hot packages have been implemented: now such FM's are returning an error saying:

Internal program error; (YDOWNLOAD SAPLC13Z 0 C13Z_RAWDATA_WRITE)

When in debug, it appears that the FM C13Z_RAWDATA_WRITE (called by the above mentioned FM's) is checking the calling program (sy-cprog) and if this latter is not within a list of standard programs (hardcoded), then the error is thrown.

My question is: Is there another way to download and upload files without such error? Could you please share the code?

Thanks a lot for help and suggestions!

Best regards,

JFlanders

1 ACCEPTED SOLUTION

Flavio
Active Contributor

Hello,


Please see note   1809258 - Internal program error; ( <program name> SAPLC13Z 0 C13Z_RAWDATA_READ )


A possibile solution is to use cl_gui_frontend_services class methods like gui_download and gui_upload, for instance:


TYPES: t_line(1) type x.
DATA: i_tab TYPE STANDARD TABLE OF t_line,
    i_wa(1) type x.

OPEN DATASET lv_file_appl FOR INPUT IN BINARY MODE.
DO.
  CLEAR i_wa.
  READ DATASET lv_file_appl INTO i_wa.
  IF SY-SUBRC <> 0.
    EXIT.
  ELSE.
    APPEND i_wa TO i_tab.
  ENDIF.
ENDDO.
CLOSE DATASET lv_file_appl.
DATA: lv_fn TYPE string.

lv_fn = lv_file_name.
CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                = lv_fn
    filetype                = 'BIN'
    append                  = ' '
  CHANGING
    data_tab                = i_tab
  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
    OTHERS                  = 24.


* old functioanlity
*    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
*      EXPORTING
*        i_file_front_end       = lv_file_name
*        i_file_appl            = lv_file_appl
*        i_file_overwrite       = 'X'
** IMPORTING
**    E_FLG_OPEN_ERROR          =  false
**    E_OS_MESSAGE              =  lv_message
*    EXCEPTIONS
*      fe_file_open_error       = 1
*      fe_file_exists           = 2
*      fe_file_write_error      = 3
*      ap_no_authority          = 4
*      ap_file_open_error       = 5
*      ap_file_empty            = 6
*      OTHERS                   = 7
*              .

This is for the download, similarly should be done for the upload.

Hope this could help. Let me know if further details are needed.

Thank you and bye,

Flavio

9 REPLIES 9

Former Member
0 Kudos

Hi,

Have you tried uploading file by using CG3Z transaction? If not try it

Regards,

0 Kudos

Hi Chandra,

Yes, I saw that transaction, but unfortunately it seems it cannot be called from within a custom program (ABAP). Do you confirm?

Thanks and best regards,

JF

0 Kudos

In your custom program , you can directly call transaction using CALL TRANSACTION

For Upload:

CALL TRANSACTION 'CG3Z'.

For Download:

CALL TRANSACTION 'CG3Y'.

Regards

0 Kudos

The point is that those transactions come out with default values for files path / names that cannot be controlled by the custom program (ABAP), at least as far as I have seen.

So, the user shall manage them, and we don't want that.

Thanks anyway.

Best regards

Former Member
0 Kudos

Hi,

You can use Dataset statement for uploading and downloading file.

Flavio
Active Contributor

Hello,


Please see note   1809258 - Internal program error; ( <program name> SAPLC13Z 0 C13Z_RAWDATA_READ )


A possibile solution is to use cl_gui_frontend_services class methods like gui_download and gui_upload, for instance:


TYPES: t_line(1) type x.
DATA: i_tab TYPE STANDARD TABLE OF t_line,
    i_wa(1) type x.

OPEN DATASET lv_file_appl FOR INPUT IN BINARY MODE.
DO.
  CLEAR i_wa.
  READ DATASET lv_file_appl INTO i_wa.
  IF SY-SUBRC <> 0.
    EXIT.
  ELSE.
    APPEND i_wa TO i_tab.
  ENDIF.
ENDDO.
CLOSE DATASET lv_file_appl.
DATA: lv_fn TYPE string.

lv_fn = lv_file_name.
CALL METHOD cl_gui_frontend_services=>gui_download
  EXPORTING
    filename                = lv_fn
    filetype                = 'BIN'
    append                  = ' '
  CHANGING
    data_tab                = i_tab
  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
    OTHERS                  = 24.


* old functioanlity
*    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'
*      EXPORTING
*        i_file_front_end       = lv_file_name
*        i_file_appl            = lv_file_appl
*        i_file_overwrite       = 'X'
** IMPORTING
**    E_FLG_OPEN_ERROR          =  false
**    E_OS_MESSAGE              =  lv_message
*    EXCEPTIONS
*      fe_file_open_error       = 1
*      fe_file_exists           = 2
*      fe_file_write_error      = 3
*      ap_no_authority          = 4
*      ap_file_open_error       = 5
*      ap_file_empty            = 6
*      OTHERS                   = 7
*              .

This is for the download, similarly should be done for the upload.

Hope this could help. Let me know if further details are needed.

Thank you and bye,

Flavio

0 Kudos

Hi Flavio!

Use the FM ARCHIVFILE_SERVER_TO_CLIENT, like this:

Regards.

0 Kudos

Thank you, it's working!

Best regards.

JF

jandrivay
Participant
0 Kudos

Hi jepi.flanders ,
i need this way too,

can u show your code upload / download file using dataset ??

Thank you