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

READING EXCEL FILE USING GUI_UPLOAD

Former Member
0 Likes
9,870

HI ALL,

I NEED TO READ AN EXCEL FILE FROM THE LOCAL SYSTEM USING THE GUI_UPLOAD FUNCTION CALL IS THERE ANY WAY?

I EVEN REFFERED ALL THE THREADS BUT COUDINT FIND ONE...

I DONT WANT ANY OTHER CALL FUNCTIONS TO READ THE EXCEL FILE IS ANY ONE KNOW HOW TO READ USING GUI_UPLOAD ONLY...

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,078

Use function

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = PATH

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 6

I_END_ROW = 100

TABLES

INTERN = T_INTERN

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

LOOP AT T_INTERN INTO WA_INTERN.

CASE WA_INTERN-COL.

WHEN '0001'.

WA_SP-PSPID = WA_INTERN-VALUE.

WHEN '0002'.

WA_SP-VGSBR = WA_INTERN-VALUE.

WHEN '0003'.

WA_SP-PRCTR = WA_INTERN-VALUE.

WHEN '0004'.

WA_SP-VKGRP = WA_INTERN-VALUE.

WHEN '0005'.

WA_SP-SPART = WA_INTERN-VALUE.

ENDCASE.

AT END OF ROW.

APPEND WA_SP TO IT_SP.

ENDAT.

ENDLOOP.

6 REPLIES 6
Read only

Former Member
0 Likes
2,079

Use function

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = PATH

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 6

I_END_ROW = 100

TABLES

INTERN = T_INTERN

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

LOOP AT T_INTERN INTO WA_INTERN.

CASE WA_INTERN-COL.

WHEN '0001'.

WA_SP-PSPID = WA_INTERN-VALUE.

WHEN '0002'.

WA_SP-VGSBR = WA_INTERN-VALUE.

WHEN '0003'.

WA_SP-PRCTR = WA_INTERN-VALUE.

WHEN '0004'.

WA_SP-VKGRP = WA_INTERN-VALUE.

WHEN '0005'.

WA_SP-SPART = WA_INTERN-VALUE.

ENDCASE.

AT END OF ROW.

APPEND WA_SP TO IT_SP.

ENDAT.

ENDLOOP.

Read only

naveen_inuganti2
Active Contributor
0 Likes
2,078

Hi..

Pass the parameters like..,

>filetype = 'DAT'

>write_field_separator = 'X'

Thanks,

Naveen.I

Read only

Former Member
0 Likes
2,078

Hi

U can get file from FM:KD_GET_FILENAME_ON_F4 and upload ur file throuh gui_upload.

If u have any problem in flat file u have do excel conversion.

Regards:

Prabu

Read only

Former Member
0 Likes
2,078

Hello,

See this: [How to Read Excel file from Application or Presentation Server and Download into Internal Table|https://wiki.sdn.sap.com/wiki/x/C4CE].

Regards

Read only

Former Member
0 Likes
2,078

Hi,

Check this sample code. I have a file named flight in my D drive. This file has flight data. I'm uploading it into internal table using FM GUI_UPLOAD


REPORT  z_file_upload.

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:
  t_flight LIKE
     TABLE OF
           fs_flight.




CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename  = 'D:\flight.xls'
   filetype                      = 'ASC'
   has_field_separator           = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
  TABLES
    data_tab                      = t_flight
 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 EQ 0.
  MESSAGE 'UPLOADING SUCCESSFUL' TYPE 'S'.
ELSE.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

LOOP AT t_flight INTO fs_flight.
  WRITE: / fs_flight-carrid,
           fs_flight-connid,
           fs_flight-fldate,
           fs_flight-price,
           fs_flight-currency.
ENDLOOP.

Regards

Abhijeet

Read only

Former Member
0 Likes
2,078

Hi,

Try with abhijith answer and let me know.

Thanks,

surendra babu vemula