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

file donwload

Former Member
0 Likes
1,141

Hi,

I need to download a file from the application server (BW - transaction CG3Y doesn't exist). Could anyone post here the <b>complete abap source</b>?

10 REPLIES 10
Read only

Former Member
0 Likes
1,076

Hi,

Here is the code,



*&---------------------------------------------------------------------*

*&      Form  f1104_download_to_lofile

*&---------------------------------------------------------------------*

*       Download to data from internal table to Logical File/application server

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

FORM f1104_download_to_lofile.

* Open the file in application server

  OPEN DATASET v_filepht FOR OUTPUT IN TEXT MODE.

  IF sy-subrc <> 0.

    MESSAGE s185 WITH v_filepht.           

    LEAVE LIST-PROCESSING.

  ENDIF.

  LOOP AT i_logfile INTO w_logfile.

    TRANSFER w_logfile TO v_filepht.

    CLEAR w_logfile.

  ENDLOOP.

  IF sy-subrc = 0.

    WRITE:/ text-055, v_filepht, text-056.

  ELSE.

    WRITE:/ text-057, v_filepht.      

  ENDIF.

* Closing the file

  CLOSE DATASET v_filepht.


Regs,

Venkat

Read only

0 Likes
1,076

Yes, but because I'm newbie I need something runable, not only a part.

Read only

Former Member
0 Likes
1,076

Hey,

Just create a internal table, populate some dummy data and call this funtion with appropriate parameters. It's enough.

Regs,

Venkat

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
1,076

Hi,

Check this.May be this can help you.

http://sap.ittoolbox.com/code/d.asp?d=2285&a=s

Kindly reward points if it is useful.

Read only

0 Likes
1,076

How could it help? I don't want to download table content but a file that exists on AS (in sap/trans directory).

Read only

0 Likes
1,076

Hi ,

try that:

REPORT ztrans01 .
*Parameters(files)
PARAMETERS: ux_dir TYPE epsf-epsdirnam OBLIGATORY
            DEFAULT '/usr/sap/trans',
            filename TYPE epsf-epsfilnam OBLIGATORY DEFAULT 'test1',
            pc_dir TYPE rlgrap-filename OBLIGATORY
            DEFAULT 'c:tmp'.
*DATA(Strings)
DATA itab TYPE TABLE OF string.
DATA wa TYPE string.
DATA file TYPE string.
DATA size TYPE epsf-epsfilsiz.
DATA ux_file TYPE epsf-epspath.
DATA mode TYPE epsf-epstxtmod.
*start-of-selection
START-OF-SELECTION.


*1) transfer
  CONCATENATE ux_dir '/' filename INTO ux_file.
  OPEN DATASET ux_file FOR INPUT IN TEXT MODE.

  IF sy-subrc <> 0.
    MESSAGE i502(me) WITH ux_file.
  ENDIF.

  DO.
    READ DATASET ux_file INTO wa.
    IF sy-subrc <> 0. EXIT . ENDIF.
    APPEND wa TO itab.
  ENDDO.

  CLOSE DATASET ux_file.




*2)download
  CONCATENATE  pc_dir  '' filename  INTO file.

  CALL FUNCTION 'GUI_DOWNLOAD'
       EXPORTING
            filename = file
       TABLES
            data_tab = itab.

Andreas

Read only

0 Likes
1,076

I think it's more suitable to FTP the file from the server to your local machine.

Maybe you can give some more information about the goal you want to achieve?

Kind regards,

Peter

Read only

0 Likes
1,076

Yes, this is exactly what I wanted, but it doesn't seem to be working with binary files. 'IN TEXT MODE' isn't syntactically correct, I had to add 'ENCODING DEFAULT' and I tried 'IN BINARY MODE' as well. Inspite of this the size of the local file differs from that on AS. Any idea how to correct this?

Read only

andreas_mann3
Active Contributor
0 Likes
1,076

Hi,

and what is with func-group C13Z

and fm C13Z_APPL_TO_FRONT_END ?

regards Andreas

Read only

0 Likes
1,076

This module and group doesn't exist because the system is not R/3 but BW.