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

bdc upload from excel

Former Member
0 Likes
1,691

hai Experts ,

pls tell me how to upload data coming in excel file ,

pls send me the Code and Test data .

Regards ,

Nagendra.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,260

Hi,

hi all,

There is a standard function which does the job (OLE).

ALSM_EXCEL_TO_INTERNAL_TABLE

This will return the data in a structure like

Row No. Column No. Value

We can then manipulate this and populate our itab depending on the requirement.

Look at the below thread also

Regards

Sudheer

7 REPLIES 7
Read only

Former Member
0 Likes
1,260

change the format of file from excel to txt and upload it

Read only

Former Member
0 Likes
1,261

Hi,

hi all,

There is a standard function which does the job (OLE).

ALSM_EXCEL_TO_INTERNAL_TABLE

This will return the data in a structure like

Row No. Column No. Value

We can then manipulate this and populate our itab depending on the requirement.

Look at the below thread also

Regards

Sudheer

Read only

Former Member
0 Likes
1,260

Hi nagendra,

use the following simple code for upload from excel to sap.

TYPE-POOLS:TRUXS.

DATA: i_raw TYPE truxs_t_text_data.

parameter: P_FILE LIKE RLGRAP-FILENAME .

CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'

EXPORTING

I_TAB_RAW_DATA = I_RAW

I_FILENAME = P_FILE

TABLES

I_TAB_CONVERTED_DATA = RECORD[].

hope this helps u a bit,

all the best,

regards,

sampath

  • mark helpful answers

Read only

Former Member
0 Likes
1,260
Read only

jyotheswar_p2
Active Participant
0 Likes
1,260

we have to use a function module named "ALSM_EXCEL_TO_INTERNAL_TABLE" with the help of this we can upload a excel file to internal table in bdc.

Read only

0 Likes
1,260

It is advicable to use a TXT file instead of an excel file. An excel file could be converted to tab delimited, csv or a fixed width file and can be uploaded. These can be done by doing the save as function and save it as the appropratiate file type

If you requirement can be only fulfiled by uploading from an excel file you may use the function module for the same

Read only

Former Member
0 Likes
1,260

hi,

To transfer an excel file u can use either normal BDC or LSMW.

I am giving one example regarding this,i used recording for this using XK01.

u have to use 'ALSM_EXCEL_TO_INTERNAL_TABLE' fn module.

check below program.

report z_bdcp_xk

no standard page heading line-size 255.

tables : lfa1,rf02k.

data : begin of itab occurs 0,

lifnr like rf02k-lifnr,

ktokk like rf02k-ktokk,

name1 like lfa1-name1,

sortl like lfa1-sortl,

land1 like lfa1-land1,

spras like lfa1-spras,

end of itab.

data : itab1 like alsmex_tabline occurs 0 with header line.

data : b1 type i value 1,

c1 type i value 1,

b2 type i value 10,

c2 type i value 99.

include bdcrecx1.

start-of-selection.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = 'C:\EXCEL.XLS'

i_begin_col = b1

i_begin_row = c1

i_end_col = b2

i_end_row = c2

tables

intern = itab1

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.

perform organize_uploaded_data.

----


perform open_group.

loop at itab.

perform bdc_dynpro using 'SAPMF02K' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF02K-KTOKK'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RF02K-LIFNR'

itab-lifnr.

perform bdc_field using 'RF02K-KTOKK'

itab-ktokk.

perform bdc_dynpro using 'SAPMF02K' '0110'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-SPRAS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'LFA1-NAME1'

itab-name1.

perform bdc_field using 'LFA1-SORTL'

itab-sortl.

perform bdc_field using 'LFA1-LAND1'

itab-land1.

perform bdc_field using 'LFA1-SPRAS'

itab-spras.

perform bdc_dynpro using 'SAPMF02K' '0120'.

perform bdc_field using 'BDC_CURSOR'

'LFA1-KUNNR'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMF02K' '0130'.

perform bdc_field using 'BDC_CURSOR'

'LFBK-BANKS(01)'.

perform bdc_field using 'BDC_OKCODE'

'=ENTR'.

perform bdc_dynpro using 'SAPLSPO1' '0300'.

perform bdc_field using 'BDC_OKCODE'

'=YES'.

perform bdc_transaction using 'XK01'.

perform close_group.

endloop.

form organize_uploaded_data .

sort itab1 by row

col.

loop at itab1.

case itab1-col.

  • ....................................................

when 1.

itab-lifnr = itab1-value.

when 2.

itab-ktokk = itab1-value.

when 3.

itab-name1 = itab1-value.

when 4.

itab-sortl = itab1-value.

when 5.

itab-land1 = itab1-value.

when 6.

itab-spras = itab1-value.

  • ....................................................

endcase.

at end of row.

  • wa_tabdata-mandt = sy-mandt.

  • APPEND wa_tabdata TO it_tabdata.

  • CLEAR: wa_tabdata.

append itab.

clear itab.

endat.

endloop.

IF U WANT TO UPLOAD DATA USING LSMW,then u have to save excel file as .CSV FORMAT AND REMAINING STEPS ARE SAME.

if useful reward some points.