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: 

How to upload for download file using GUI_UPLOAD & GUI_DOWNLOAD

Former Member
0 Kudos

hi

how to use GUI_UPLOAD to uplaod a file with extension ".XLS" ? I have used the function module to upload file in .CSV and .TXT format. I want to upload a file in .XLS format.

~ Suresh

1 ACCEPTED SOLUTION

Former Member
0 Kudos

for uploading .XLS file dont use GUI_UPLOAD.....Use ....

CREATE OBJECT OB_GUI_FRONTEND

EXCEPTIONS

NOT_SUPPORTED_BY_GUI = 1

CNTL_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CALL METHOD OB_GUI_FRONTEND->GUI_UPLOAD

EXPORTING

FILENAME = W_FNAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • DAT_MODE = SPACE

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • READ_BY_LINE = 'X'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

CHANGING

DATA_TAB = IT_UPLOAD

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

NOT_SUPPORTED_BY_GUI = 17

ERROR_NO_GUI = 18

OTHERS = 19

.

*************************************

else try using ALSM_EXCEL_TO_INTERNAL_TAB which uploads excel data to internal table.

*FM to upload excel sheet in the format row col and value

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TAB'

EXPORTING

FILENAME = <input file name>

I_BEGIN_COL = <begin column>

I_BEGIN_ROW = <end column>

I_END_COL = <total columns>

I_END_ROW = <total rows>

TABLES

INTERN = <internal table>

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

Message was edited by:

Ramesh Babu Chirumamilla

6 REPLIES 6

Former Member
0 Kudos
try..

DATA : gv_file TYPE string.

DATA : BEGIN OF it_fcdata1 OCCURS 0,
product(10),
fc_qty(22),
END OF it_fcdata1.

PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.

gv_file = P_FILE.


CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = gv_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'
tables
data_tab = it_fcdata1
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Former Member
0 Kudos

for uploading .XLS file dont use GUI_UPLOAD.....Use ....

CREATE OBJECT OB_GUI_FRONTEND

EXCEPTIONS

NOT_SUPPORTED_BY_GUI = 1

CNTL_ERROR = 2

OTHERS = 3

.

IF SY-SUBRC <> 0.

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

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

ENDIF.

CALL METHOD OB_GUI_FRONTEND->GUI_UPLOAD

EXPORTING

FILENAME = W_FNAME

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • DAT_MODE = SPACE

  • CODEPAGE = SPACE

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • READ_BY_LINE = 'X'

  • IMPORTING

  • FILELENGTH =

  • HEADER =

CHANGING

DATA_TAB = IT_UPLOAD

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

INVALID_TYPE = 5

NO_AUTHORITY = 6

UNKNOWN_ERROR = 7

BAD_DATA_FORMAT = 8

HEADER_NOT_ALLOWED = 9

SEPARATOR_NOT_ALLOWED = 10

HEADER_TOO_LONG = 11

UNKNOWN_DP_ERROR = 12

ACCESS_DENIED = 13

DP_OUT_OF_MEMORY = 14

DISK_FULL = 15

DP_TIMEOUT = 16

NOT_SUPPORTED_BY_GUI = 17

ERROR_NO_GUI = 18

OTHERS = 19

.

*************************************

else try using ALSM_EXCEL_TO_INTERNAL_TAB which uploads excel data to internal table.

*FM to upload excel sheet in the format row col and value

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TAB'

EXPORTING

FILENAME = <input file name>

I_BEGIN_COL = <begin column>

I_BEGIN_ROW = <end column>

I_END_COL = <total columns>

I_END_ROW = <total rows>

TABLES

INTERN = <internal table>

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

Message was edited by:

Ramesh Babu Chirumamilla

anversha_s
Active Contributor
0 Kudos

hi,

chk this.

types: begin of ttab,
       rec(1000) type c,
       end of ttab.
 
types: begin of tdat,
       fld1(10) type c,
       fld2(10) type c,
       fld3(10) type c,
       end of tdat.
 
data: itab type table of ttab with header line.
data: idat type table of tdat with header line.
 
data: file_str type string.
 
parameters: p_file type localfile.
 
at selection-screen on value-request for p_file.
  call function 'KD_GET_FILENAME_ON_F4'
       exporting
            static    = 'X'
       changing
            file_name = p_file.
 
start-of-selection.
 
  file_str = p_file.
 
  call function 'GUI_UPLOAD'
       exporting
            filename                = file_str
       tables
            data_tab                = itab
       exceptions
            file_open_error         = 1
            file_read_error         = 2
            no_batch                = 3
            gui_refuse_filetransfer = 4
            invalid_type            = 5
            no_authority            = 6
            unknown_error           = 7
            bad_data_format         = 8
            header_not_allowed      = 9
            separator_not_allowed   = 10
            header_too_long         = 11
            unknown_dp_error        = 12
            access_denied           = 13
            dp_out_of_memory        = 14
            disk_full               = 15
            dp_timeout              = 16
            others                  = 17.
 
 
delete itab index 1.
 
  loop at itab.
    clear idat.
    split itab-rec at cl_abap_char_utilities=>horizontal_tab
                          into idat-fld1
                               idat-fld2
                               idat-fld3.
    append idat.
 
  endloop.
 
 
  loop at idat.
    write:/ idat-fld1, idat-fld2, idat-fld3.
  endloop.

Regards

Anver

Former Member
0 Kudos

Hi Vijayendra,

you can use function module 'TEXT_CONVERT_XLS_TO_SAP', 'KCD_EXCEL_OLE_TO_INT_CONVERT'

or 'ALSM_EXCEL_TO_INTERNAL_TABLE' to upload the .xls file.

Refer the below link for code example.

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

Regards,

Bhavana

Former Member
0 Kudos

Hi,

In GUI_UPLOAD use filetype as ASC and give the value for field separator as X. then you can upload excel file. You can also use ALSM_EXCEL_TO_INTERNAL_TABLE to upload a excel file into an internal table

Former Member
0 Kudos

Hi Vijayendra,

The easiest way to upload a file (with any extension) into Application server (AL11) is to use the transaction CG3Z.

1. Goto transaction CG3Z

2. Specify the source file directory (path in presentation)

3. Specify the target file directory (on application server)

4. Press the transfer button.

This will upload the file.

However if you want to upload through your program, make use of Function modules like GUI_UPLOAD or ALSM_EXCEL_TO_INTERNAL_TABLE (for xls).

PLZ REWARD POINTS