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: 

upload data from excelsheet to an internal table(other than FM ALSM_EXCEL_)

Former Member
0 Kudos

Hi all,

I have to upload data from an excelsheet to an internal table .

But i do not want to use the function module ALSM_EXCEL_TO_INTERNAL_TABLE since it is an unreleased FM.

Please do suggest me some other way of uploading the data

from the excelsheet to an internal table.

Please reply it is urgent.

Thanks and Regards,

Syed

1 ACCEPTED SOLUTION

huseyindereli
Active Contributor
0 Kudos

Hi ,

You can use the static method below ;

DATA: file_name TYPE string,

lt_table LIKE TABLE OF your_table.

*---

REFRESH: gt_upl.

file_name = 'file.xls'.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = file_name

filetype = 'ASC'

has_field_separator = '#'

CHANGING

data_tab = lt_table

EXCEPTIONS

file_open_error = 1

file_read_error = 2

OTHERS = 18.

11 REPLIES 11

Former Member
0 Kudos

hi,

Plz refer to this link.

regards

Sumit Agarwal

Former Member
0 Kudos

Use FM : GUI_UPLOAD

Former Member
0 Kudos

Hi,

You can also use CALL FUNCTION 'GUI_UPLOAD'

Regards,

Aditya

huseyindereli
Active Contributor
0 Kudos

Hi ,

You can use the static method below ;

DATA: file_name TYPE string,

lt_table LIKE TABLE OF your_table.

*---

REFRESH: gt_upl.

file_name = 'file.xls'.

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING

filename = file_name

filetype = 'ASC'

has_field_separator = '#'

CHANGING

data_tab = lt_table

EXCEPTIONS

file_open_error = 1

file_read_error = 2

OTHERS = 18.

Former Member
0 Kudos

Hi Srinivan,

Can you please tell me how i can use GUI_UPLOAD FM for uploading the data from an excelsheet . Because i tried but

didn't succeed . It works well when uploading the data from

a notepad file.

Thanks

Syed

Former Member
0 Kudos

hiiii

you can not use GUI_UPLOAD FM for uploading data from excel sheet.if you want to upload data from excel file then only ALSM_EXCEL is the best way or you can do the same thing by using classes like follows

CALL METHOD cl_gui_frontend_services=>gui_upload

EXPORTING
filename = file_name
filetype = 'ASC'
has_field_separator = '#'
CHANGING
data_tab = lt_table
*EXCEPTIONS
*file_open_error = 1
*file_read_error = 2
*OTHERS = 18.

regards

twinkal

Former Member
0 Kudos

Hi Syed,

you can use KCD_EXCEL_OLE_TO_INT_CONVERT.

for sample code refer to the link below:

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

With luck,

Pritam.

Former Member
0 Kudos

Hello Hussan,

u can use

GUI_UPLOAD

or

KCD_EXCEL_OLE_TO_INT_CONVERT

eg:

CALL FUNCTION 'KCD_EXCEL_OLE_TO_INT_CONVERT'

EXPORTING

filename = p_file

i_begin_col = p_scol

i_begin_row = p_srow

i_end_col = p_ecol

i_end_row = p_erow

TABLES

intern = LT_INTERN

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE:/ 'Error Uploading file'.

EXIT.

ENDIF.

Hope it helps you

Regards

Indu.

Former Member
0 Kudos

Hi,

Try out 'TEXT_CONVERT_XLS_TO_SAP'

DATA : IT_TYPE TYPE TRUXS_T_TEXT_DATA.

*P_FPATH IS THE PATH.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_FIELD_SEPERATOR = 'X'

I_LINE_HEADER = 'X'

I_TAB_RAW_DATA = IT_TYPE

I_FILENAME = P_FPATH

TABLES

I_TAB_CONVERTED_DATA = internal_Table

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2.

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

Hi all,

Again the problem with the FM KCD_EXCEL_OLE_TO_INT_CONVERT is that it is also not a released function module.

I am trying to use CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD . But it fills the internal table with hashes and not with the data.

Below is the code that i have written for my program.

DATA: file_name TYPE string.

file_name = 'C:\ZGLO_WM.XLS'.

CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD

EXPORTING

FILENAME = file_name

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_init_data

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

others = 19

.

IF SY-SUBRC <> 0.

ENDIF.

Please do suggest me where the problem really exists . Do i need to convert the file before upload?

Thanks and Regards,

Syed

0 Kudos

Hi,

Try out 'TEXT_CONVERT_XLS_TO_SAP'

DATA : IT_TYPE TYPE TRUXS_T_TEXT_DATA.

*P_FPATH IS THE PATH.

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_FIELD_SEPERATOR = 'X'

I_LINE_HEADER = 'X'

I_TAB_RAW_DATA = IT_TYPE

I_FILENAME = P_FPATH

TABLES

I_TAB_CONVERTED_DATA = internal_Table

EXCEPTIONS

CONVERSION_FAILED = 1

OTHERS = 2.

IF SY-SUBRC 0.

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

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

ENDIF.