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 Excel to internal table without using Screen

Former Member
0 Kudos

Hi,

My reqirment is to read the excel input data and then upload it to internal table for further proceeing but without using selection input screen. I mean can I mention the fixed file name and the path in the function module iself for the input file.

5 REPLIES 5

former_member588853
Active Contributor
0 Kudos

Hi,

I f not using the selection screen..

you can directly fix the file name and the path..

regards,

nazeer

Former Member
0 Kudos

Please dont create duplicate threads for the same problem. Plesae check answers of the previous thread.

Best Regards,

Vibha

Former Member
0 Kudos

Hi,

Yes

You can hardcode the filename, if needed, if you doesn't wants to use selection screen,

for the fun module

ASLM_EXCEL_TO_INTERNAL_TABLE

reward if useful

regards,

Anji

former_member632991
Active Contributor
0 Kudos

Hi,

Use FM

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = <b>p_file</b> "give file name

I_BEGIN_COL = 1

I_BEGIN_ROW = 2

I_END_COL = 10

I_END_ROW = p_lineno

TABLES

INTERN = asset_excel

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 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.

Regards,

Sonika

Former Member
0 Kudos

Hi Vamsi,

Try this Sample Code. I used the custom table for this Example.

TABLES: ZVIJ.

DATA : BEGIN OF WA,

NAME(6) TYPE C,

AGE(3) TYPE C,

DES(5) TYPE C,

SALARY(3) TYPE C,

INCENT(3) TYPE C,

END OF WA,

IT LIKE TABLE OF WA WITH HEADER LINE.

DATA : BEGIN OF WA1,

NAME(6) TYPE C,

AGE TYPE I,

DES(4) TYPE C,

SALARY TYPE I,

INCENT TYPE I,

END OF WA1,

IT1 LIKE TABLE OF WA1 WITH HEADER LINE.

OPEN DATASET 'SAMP' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\Desktop\BOOK6.XLS'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = IT.

.

IF sy-subrc <> 0.

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

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

ENDIF.

LOOP AT IT .

IT1-NAME = IT-NAME.

IT1-AGE = IT-AGE.

IT1-DES = IT-DES.

IT1-SALARY = IT-SALARY.

IT1-INCENT = IT-INCENT.

APPEND IT1.

ENDLOOP.

LOOP AT IT1.

ZVIJ-NAME = IT1-NAME.

ZVIJ-AGE = IT1-AGE.

ZVIJ-DES = IT1-DES.

ZVIJ-SALARY = IT1-SALARY.

ZVIJ-INCENT = IT1-INCENT.

INSERT ZVIJ.

ENDLOOP.

Thanks.

reward If Helpful.