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

downloading file from application server

Former Member
0 Likes
5,834

Hi abapers ,

My requirement is ,I want to create and download file from appication server in excel format.

I have created a file on application server , but i am facing problem while downloading file from application server to presentation server .

I have downloaded file into 'CSV ' format from application server to presentation server for required o/p.

Please suggest on file format to getting download into excel format.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
4,065

Hi,

To download file from application server to presentation server, Just Goto CG3Y Tcode and do follow the following steps:

1) Source file on application server: Give your Unix path(application server) name (ex: usr\sap\R3X\SYS\file)

2) Target file on front end: Give your PC path (ex: c:\temp\substanc.dat )

3) Now select the Transfer format for data type (ex: BIN, ASC)

4) Check the box Overwrite the file to overwrite the file if the file exist with the same name in the presentation server.

5) The last step is click on Download (SHIFT+F1) button to dowload to your PC path.

Hope this will help...

Regards,

Nitin.

Hi abapers ,

My requirement is ,I want to create and download file from appication server in excel format.

I have created a file on application server , but i am facing problem while downloading file from application server to presentation server .

I have downloaded file into 'CSV ' format from application server to presentation server for required o/p.

Please suggest on file format to getting download into excel format.

7 REPLIES 7
Read only

Former Member
0 Likes
4,066

Hi,

To download file from application server to presentation server, Just Goto CG3Y Tcode and do follow the following steps:

1) Source file on application server: Give your Unix path(application server) name (ex: usr\sap\R3X\SYS\file)

2) Target file on front end: Give your PC path (ex: c:\temp\substanc.dat )

3) Now select the Transfer format for data type (ex: BIN, ASC)

4) Check the box Overwrite the file to overwrite the file if the file exist with the same name in the presentation server.

5) The last step is click on Download (SHIFT+F1) button to dowload to your PC path.

Hope this will help...

Regards,

Nitin.

Read only

Former Member
0 Likes
4,065

Could you plz make it clear from where you are downloading the file either from appl server or from presentation server?or better way paste your code here.following are some solutions:

1.for application server you can directly upload file by OPEN_DATASET,READ_DATASET,CLOSE_DATASET

2.for presentation server use GUI_UPLOAD

3.for tab separated file use ASC format with separator = 'X'

4.for excel yopu can straightway use 'ALSM_EXCEL_... function module.

Edited by: prachi s on Aug 19, 2008 10:35 AM

Read only

0 Likes
4,065

OPEN DATASET p_path_temp FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

IF sy-subrc = 0.

LOOP AT itab .

TRANSFER itab-text1 TO p_path_temp.

ENDLOOP.

ELSEIF sy-subrc NE 0.

MESSAGE text-107 TYPE c_i.

ENDIF.

CLOSE DATASET p_path_temp.

I have transfered data(itab-text1) on application server in csv format.

Now ,i want to store data (which is on application server) into xls format on presentation server.

but while doing this ,i am not getting exact format in excel sheet,so i have stored that data in csv format on presentation server to get required format. what to do to store that data or file in xls on presentation server?

Read only

0 Likes
4,065

Use this FM, giving Field separater as SPACE

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'D:\EX\ABC.XLS'

  • FILETYPE = 'ASC'

  • APPEND = ' '

write_field_separator = ' '

  • HEADER = '00'

  • TRUNC_TRAILING_BLANKS = ' '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

TABLES

data_tab = it_emp.

  • 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 = 22

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

former_member386202
Active Contributor
0 Likes
4,065

Hi,

Save the file on application server as format dat n use transaction CG3Y to transfer it from application server to presentation server.

Regards,

Prashant

Read only

Former Member
0 Likes
4,065

Hi,

Syntax For Download File From Applicatipon Server

OPEN DATASET p_path_temp FOR OUTPUT IN TEXT MODE ENCODING DEFAULT .

IF sy-subrc = 0.

LOOP AT itab .

TRANSFER itab-text1 TO p_path_temp.

ENDLOOP.

ELSEIF sy-subrc NE 0.

MESSAGE text-107 TYPE c_i.

ENDIF.

CLOSE DATASET p_path_temp.

Thanks&Regards,

Naresh.

Read only

Former Member
0 Likes
4,065

Hi,

Check this sample code


REPORT  z_file_download.
DATA: w_name(90) TYPE c.
DATA:
  BEGIN OF fs_flight,
    carrid   LIKE sflight-carrid,
    connid   LIKE sflight-connid,
    fldate   LIKE sflight-fldate,
    price    LIKE sflight-price,
    currency LIKE sflight-currency,
  END OF fs_flight.
DATA:
  BEGIN OF fs_head,
    carrid(10) TYPE c,
    connid(10) TYPE c,
    fldate(10) TYPE c,
    price(10) TYPE c,
    curr(10) TYPE c,
  END OF fs_head.
DATA:
  t_head LIKE
   TABLE OF
         fs_head.
DATA:
  t_flight LIKE
     TABLE OF
           fs_flight.

fs_head-carrid = 'CARRID'.
fs_head-connid = 'CONNID'.
fs_head-fldate = 'FLDATE'.
fs_head-price  = 'PRICE'.
fs_head-curr   = 'CURRENCY'.
APPEND fs_head TO t_head.
SELECT-OPTIONS:
  s_carrid FOR fs_flight-carrid.



START-OF-SELECTION.
  SELECT carrid
         connid
         fldate
         price
         currency
    FROM sflight
    INTO TABLE t_flight
   WHERE carrid IN s_carrid.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                  =
    filename                      = 'D:\flight1.xls'
   FILETYPE                      = 'ASC'
*   APPEND                        = ' '
    WRITE_FIELD_SEPARATOR         = 'X'
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   COL_SELECT                    = ' '
*   COL_SELECT_MASK               = ' '
*   DAT_MODE                      = ' '
*   CONFIRM_OVERWRITE             = ' '
*   NO_AUTH_CHECK                 = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   WRITE_BOM                     = ' '
* IMPORTING
*   FILELENGTH                    =
  tables
    data_tab                      = t_head
 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                        = 22
          .
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.



  CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
      filename                = 'D:\flight1.xls'
      filetype                = 'ASC'
      append                  = 'X'
      write_field_separator   = 'X'
    TABLES
      data_tab                = t_flight
    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                  = 22.
  IF sy-subrc EQ 0.
    MESSAGE 'Download successful' TYPE 'I'.
  ELSE.
  *  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

Regards

Abhijeet