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 data at presentation layer in csv format

Former Member
0 Likes
1,340

hai..

can anyone tel me how to download data into csv file at presentation layer.

Is gui_upload works ?

Pleae tell me the procedure to do this?

1 ACCEPTED SOLUTION
Read only

athavanraja
Active Contributor
0 Likes
1,158

use GUI_DOWNLOAD to do this.

     call function 'GUI_DOWNLOAD'
        exporting
*   BIN_FILESIZE                  =
          filename                      = 'c:/ddd/abc.xsl'
        <b>  filetype                      = 'DAT'</b>
*   APPEND                        = ' '
<b>   WRITE_FIELD_SEPARATOR         = ','</b>
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   col_select                    = 
*   col_select_mask               = 
*   DAT_MODE                      = ' '
*   CONFIRM_OVERWRITE             = ' '
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
        tables
          data_tab                      = <itab iwth data>
       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
                .

Regards

Raja

hai..

can anyone tel me how to download data into csv file at presentation layer.

Is gui_upload works ?

Pleae tell me the procedure to do this?

6 REPLIES 6
Read only

athavanraja
Active Contributor
0 Likes
1,159

use GUI_DOWNLOAD to do this.

     call function 'GUI_DOWNLOAD'
        exporting
*   BIN_FILESIZE                  =
          filename                      = 'c:/ddd/abc.xsl'
        <b>  filetype                      = 'DAT'</b>
*   APPEND                        = ' '
<b>   WRITE_FIELD_SEPARATOR         = ','</b>
*   HEADER                        = '00'
*   TRUNC_TRAILING_BLANKS         = ' '
*   WRITE_LF                      = 'X'
*   col_select                    = 
*   col_select_mask               = 
*   DAT_MODE                      = ' '
*   CONFIRM_OVERWRITE             = ' '
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
        tables
          data_tab                      = <itab iwth data>
       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
                .

Regards

Raja

Read only

0 Likes
1,158

Hi

If you want to create a CSV file you need to create an ASCII file where the fields are separated by semicolon.

So you need a piece of code that inserts the separator (like this):

DATA BEGIN OF RECORD,

FIELD1 LIKE .....,

FIELD2 LIKE .....,

FIELD3 LIKE .....,

.................,

FIELDN LIKE .....,

END OF RECORD.

DATA: T_FILE TYPE STANDARD TABLE OF STRING WITH HEADER LINE.

After filling the structure RECORD with the data to

transfer to file, it appends to file table:

FIELD-SYMBOLS: <FIELD> TYPE ANY.

DATA: OFFSET TYPE I.

CLEAR

DO.

ASSIGN COMPONENT SY-INDEX OF STRUCTURE RECORD TO <FIELD>.

IF SY-SUBRC <> 0. EXIT. ENDIF.

WRITE: <FIELD> TO T_FILE+OFFSET.

OFFSET = STRLEN(T_FILE).

WRITE: ';' TO T_FILE+OFFSET.

OFFSET = OFFSET + 1.

ENDDO.

IF NOT T_FILE IS INITIAL.

APPEND T_FILE.

ENDIF.

call function 'GUI_DOWNLOAD'

exporting

filename = 'c:\ddd\abc.csv'

filetype = 'ASC'

tables

data_tab = T_FILE

......

Max

Hi Raja

On my release (4.70), the FM GUI_DOWNLOAD can use only the types ASC (ASCII) and BIN (binary), not DAT and the parameter WRITE_FIELD_SEPARATOR (it can be SPACE or X)is only to insert the TAB like separator in ASCII file.

So in your release is it different?

Max

Read only

0 Likes
1,158

hi Max we are on ECC5.0 (WAS6.4) and you can use DAT there

check out the following line of code taken from the FM

case prc_filetype.
    when 'BIN' or 'ASC' or 'DAT' or 'DBF' or 'WK1'.
    when 'IBM'.
      prc_filetype = 'ASC'.
      prc_codepage = '1103'.
    when others.
      message id 'FES' type 'E' number '004' raising invalid_type.
  endcase.

and you are right about

parameter WRITE_FIELD_SEPARATOR (it can be SPACE or X). sorry about the mistake,

Regards

Raja

Read only

0 Likes
1,158

Thanks Raja

but I believe I'll have to wait for your relase, infact in my relase the code is that:

  • Filetype parameter valid ?

case prc_filetype.

when 'BIN' or 'ASC' or 'DBF'.

when 'IBM'.

prc_filetype = 'ASC'.

prc_codepage = '1103'.

when others.

message id 'FES' type 'E' number '004' raising invalid_type.

endcase.

I've just forgotten the type DBF and IBM.

Anyway it's good to know on greater release other type of file are managed by that fm.

Thanks

Max

Message was edited by: max bianchi

Read only

andreas_mann3
Active Contributor
0 Likes
1,158

Hi,

or look hers:

Andreas

Read only

Former Member
0 Likes
1,158

Hi,

Chek this post too:

Best Regards,

Anjali