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

Uploading Data From Excel Sheet to SAP Database Tables

Former Member
0 Likes
1,471

Dear Friends,

We are having an Excel Sheet with 90 different columns. Now we want only 2 of the columns to be uploaded in the database tables. So, Plz tell me which function module will be suitable for this. And plz help me with the code also.

Thanks,

Nishant Jain

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
916

HI Nishu,

As suggested you can use ALSM_EXCEL_TO_INTERNAL_TABLE..

specify the filename..

the return internal table of type ALSMEX_TABLINE

WHICH HAS A FIELD <b>COL</b> which indicates the column

just loop at that itab chack if COL is <= 2 and put it into another itab..

this will have only first 2 columns from the excel..

if you dont get it .. just reply i'll get some sample code..

regards

satesh

HI Nishu,

As suggested you can use ALSM_EXCEL_TO_INTERNAL_TABLE..

specify the filename..

the return internal table of type ALSMEX_TABLINE

WHICH HAS A FIELD <b>COL</b> which indicates the column

just loop at that itab chack if COL is <= 2 and put it into another itab..

this will have only first 2 columns from the excel..

if you dont get it .. just reply i'll get some sample code..

regards

satesh

6 REPLIES 6
Read only

hymavathi_oruganti
Active Contributor
0 Likes
916

check ALSM_EXCEL_TO_INT_TABLE

Read only

Former Member
0 Likes
916

Hello Nishu,

As want to update SAP tables from excel sheet then you need to write your custom code to do this. For uploading excel sheet into internal table you can use function modules 'WS_UPLOAD' or 'GUI_UPLOAD' depends on your SAP version. Then using UPDATE query you can updated that required 2 columns based on your requirements.

I hope this will help you to fix your issue.

Read only

Former Member
0 Likes
916

hi

good

it is not possible to upload only 2 columns from an excel sheed.You can create another excel sheet for that 2 column and you can upload them using BDC call transation or session method or you can use GUI_UPLOAD function module.

Thanks

mrutyun

Read only

Former Member
0 Likes
917

HI Nishu,

As suggested you can use ALSM_EXCEL_TO_INTERNAL_TABLE..

specify the filename..

the return internal table of type ALSMEX_TABLINE

WHICH HAS A FIELD <b>COL</b> which indicates the column

just loop at that itab chack if COL is <= 2 and put it into another itab..

this will have only first 2 columns from the excel..

if you dont get it .. just reply i'll get some sample code..

regards

satesh

Read only

0 Likes
916

Hi Nishu,

A sample for the same..

data it_excel like table of ALSMEX_TABLINE with header line.

here we retrieve only 2 cols directly..

now itab will contain only 2 cols of all rows seperated by comma ..

data str(1000).
data itab like table of str with  header line.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
  EXPORTING
    filename                      = 'C:sample1.xls'
    i_begin_col                   = 1
    i_begin_row                   = 1
    i_end_col                     = 2
    i_end_row                     = 100
  tables
    intern                        =  it_excel
.

  LOOP AT it_excel.
    AT NEW row.
      CLEAR itab.
    ENDAT.
    IF itab IS INITIAL.
      MOVE it_excel-value TO itab.
    ELSE.
      CONCATENATE itab ',' it_excel-value INTO itab.
    ENDIF.

    AT END OF row.
      APPEND itab.
    ENDAT.
  ENDLOOP.

regards

satesh

Read only

0 Likes
916

Hi Satesh,

I tried your coding, however, function module 'ALSM_EXCEL_TO_INTERNAL_TABLE' is not available in our current CRM 4.0 system.

On which systems is this FM available?

Thanks & regards

Wolfgang