2007 Feb 27 12:27 PM
hai Experts ,
pls tell me how to upload data coming in excel file ,
pls send me the Code and Test data .
Regards ,
Nagendra.
2007 Feb 27 12:32 PM
2007 Feb 27 12:31 PM
2007 Feb 27 12:32 PM
2007 Feb 27 12:50 PM
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
2007 Feb 27 12:52 PM
2007 Feb 27 1:34 PM
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.
2007 Feb 27 3:51 PM
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
2007 Feb 28 4:10 AM
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.