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: 

Create file from internal table and save in Presentation Server

Former Member
0 Kudos

I had a internal table with some data in it. Now i want to create a file with the contents of internal table and store in presentation server.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

this is the example which i created

reward if usefull

REPORT  zsd_excel1.

tables : lfa1.


data : it_lfa1 type lfa1 occurs 1,
       wa_lfa1 type lfa1.


select-options : ven_no for lfa1-lifnr.



select lifnr
       name1
       ort01
       ort02
       begru  from lfa1 into corresponding fields of table it_lfa1 where lifnr in ven_no.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = 'C:sashisecel.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                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
  tables
    data_tab                        = it_lfa1
*   FIELDNAMES                      =
* 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.


if sy-subrc = 0.
 message i001(zsd_mes).
endif.

5 REPLIES 5

Former Member
0 Kudos

Hi

this is the example which i created

reward if usefull

REPORT  zsd_excel1.

tables : lfa1.


data : it_lfa1 type lfa1 occurs 1,
       wa_lfa1 type lfa1.


select-options : ven_no for lfa1-lifnr.



select lifnr
       name1
       ort01
       ort02
       begru  from lfa1 into corresponding fields of table it_lfa1 where lifnr in ven_no.


CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = 'C:sashisecel.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                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
  tables
    data_tab                        = it_lfa1
*   FIELDNAMES                      =
* 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.


if sy-subrc = 0.
 message i001(zsd_mes).
endif.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Its as easy as this.



data: it001 type table of t001 with header line.

select * into table it001 from t001.

call function 'GUI_DOWNLOAD'
     exporting
          filename              = 'C:test.xls'
          write_field_separator = 'X'
     tables
          data_tab              = it001.

Regards,

Rich Heilman

Former Member
0 Kudos

hi,

check the function module

gui_download

regards,

Navneeth K.

Former Member
0 Kudos

Hi Praveen,

To do this you need to use FM.

File Type is ASC for Text File

As i want it tab seperated i used WRITE_FIELD_SEPARATOR.

if you comment it it will be space seperated.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = 'c:\test.txt'

FILETYPE = 'ASC'

WRITE_FIELD_SEPARATOR = 'X'

  • APPEND = ' '

tables

data_tab = it_student

Reward points if useful.

Regards,

Sachin.

Former Member
0 Kudos

Hi Praveen,

Use GUI_DOWNLOAD function moduel to have internal table contents onto presentation server.

Check this link for code.

http://www.sapdevelopment.co.uk/file/file_updownpop.htm

Thanks,

Vinay