Uploading Data From Excel Sheet to SAP Database Tables
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
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
Similar Messages
-
Uploading data from Excel sheet into SAP.
Dear All,
I want to upload data existing in Excel sheet into SAP. Is there any possibility with the following requirements?
1) Excel file contains serial numbers with different values.Like power(230Wp),Voc,Isc,Vmp and Imp.
2) We need to upload the same data into SAP with validations.
3) Validations are like no serial number should be repeated.
4) And depending on the Power value, the serial number should be assigned to different batches.Eg:The batches are as follows:
201 - 210
210 - 220
220 - 230
and if the Pmax of the serial number is 205.It should be assigned to batch 201 - 210 .
5) At present we are using MB31 to post the serial numbers which are existing in the flat file.
Thanks and Regards,
Varun SiddharthHi,
Refer to the following code:
DATA: lv_filetype(10) TYPE c,
lv_gui_sep TYPE c,
lv_file_name TYPE string.
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The excel file must be a tab delimited file.
Hope it helps.
Regards,
Rajesh Kumar -
Uploading data from excel sheets through BDC's into sap system
hi guys,
can you please help me with this. As we use gui_upload to upload data from flat file to sap system, which function module you use to upload data from Excel sheet to sap system through bdc'shello pavan,
welcome to SDN
check the below program
REPORT ZEXCEL_TO_INTERNAL .
data: begin of itab occurs 0,
name(20) type c,
addre(20) type c,
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 100,
C2 TYPE I VALUE 9999.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME =
'C:\Documents and Settings\administrator\Desktop\ppcon001bd_24.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.
loop at itab1.
write:/ itab1.
Endlop.
Regards,
Naveen -
Uploading data from excel sheet
HI,
Can anyone provide me the details to upload vendor data from excel sheet to database through bdc?
Thankyou.upload the excel file in your internal table and then use BDC to updated the database table.
FM's to upload Excel:
GUI_UPLOAD
KCD_EXCEL_OLE_TO_INT_CONVERT
ALSM_EXCEL_TO_INTERNALTABLE
refer to the link:
http://diocio.wordpress.com/2007/02/12/sap-upload-excel-document-into-internal-table-2/
http://www.sap-img.com/abap/learning-bdc-programming.htm
With luck,
Pritam. -
Upload data from excel sheet into md61
Hi Gurus,
Can anybody please tell me the solution like how to upload the data from excel sheet into the MD61
if u suggest me to write an ABAP code then its fine or any other way would be great
and can u also send me the abap code i would be thankful to allHi,
I can be done in 2 ways.
1. Using LSMW you can upload your MD61 demand thru Excel sheet.
2. You can use BDC to upload the demand from Excel. For this you need to take help from the ABAP. You need to record the macro usinf SHDB and the table maintenance will be taken care by the developer.
For LSMW you need not depend on your developer, as a functional consultant you can do it yourself.
Regards,
V. Suresh -
Regarding uploading data from excel sheet to internal table
hi,
while executing the code im getting the output one by one but i want it to be displayed in a table format can any one help me regarding this issue.
thanks and regards,
siriHi Sirisha,
Through this FM we can't get the data in tabular format. After getting data from this FM we have to convert to tabular format. As far as i know there is no FM for Excel upload which directly gives data in tabular format.
Check below sample code which uploads 3 columns from excel file.
U can add as many case statements as the number of fields.
PARAMETERS: po_file TYPE rlgrap-filename DEFAULT 'E:test.xls'.
TYPES: BEGIN OF t_final,
empno(10) TYPE c,
name(30) TYPE c,
state(25) TYPE c,
END OF t_final.
DATA: i_tab TYPE STANDARD TABLE OF alsmex_tabline,
i_final TYPE STANDARD TABLE OF t_final,
wa_tab TYPE alsmex_tabline,
wa_final TYPE t_final.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR po_file.
PERFORM open_folder.
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = po_file
i_begin_col = 1
i_begin_row = 1
i_end_col = 3
i_end_row = 65256
TABLES
intern = i_tab
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
CHECK NOT i_tab[] IS INITIAL.
LOOP AT i_tab INTO wa_tab.
CASE wa_tab-col.
WHEN 1.
wa_final-empno = wa_tab-value.
WHEN 2.
wa_final-name = wa_tab-value.
WHEN 3.
wa_final-state = wa_tab-value.
ENDCASE.
AT END OF row.
APPEND wa_final TO i_final.
CLEAR wa_final.
ENDAT.
ENDLOOP.
FORM open_folder .
DATA: li_file TYPE TABLE OF sdokpath,
lwa_file TYPE sdokpath.
CLEAR: po_file, lwa_file.
REFRESH li_file[].
CALL FUNCTION 'TMP_GUI_FILE_OPEN_DIALOG'
TABLES
file_table = li_file
EXCEPTIONS
cntl_error = 1
OTHERS = 2.
IF sy-subrc IS INITIAL.
READ TABLE li_file INTO lwa_file INDEX 1.
IF sy-subrc IS INITIAL.
po_file = lwa_file-pathname.
ENDIF.
ENDIF.
ENDFORM. " open_folder
Just try executing above code in debug mode. U will understand the functionality.
Thanks,
Vinod. -
Reg : Error While uploading Datas from EXCEL in to SAP
Hi Experts,
Please help me with code inorder to upload EXCEL File DATA in to SAP.... I tried with FM : ALSM_EXCEL_TO_INTERNAL_TABLE & TEXT_CONVERT_XLS_TO_SAP but exception raised like UPLOAD_OLE for me..
Wat to do...?
Please help with exact data (EXCEL) and code...
regards
e arthiHi arthi
save you file as CSV file in excel.
that means your file will be coma separated,
and then use fm
GUI_UPLOAD.
This will solve your problem.
Regards,
Vijay -
Hi,
I am Using BAPI_ACC_MANUAL_ALLOC_POST (Manual cost allocation) for uploading into database. But i am getting the error "DO NOT USE COST ELEMENT xxxxxxxx FOR REPOST COSTS".
can anyone explain me the possible reasons for this error.
any help will be rewarded.
Thanks and Regards,
Gautham PaspalaHi,
Refer to the following code:
DATA: lv_filetype(10) TYPE c,
lv_gui_sep TYPE c,
lv_file_name TYPE string.
lv_filetype = 'ASC'.
lv_gui_sep = 'X'.
lv_file_name = pa_dfile.
FM call to upload file
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file_name
filetype = lv_filetype
has_field_separator = lv_gui_sep
TABLES
data_tab = gi_zhralcon_file
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
The excel file must be a tab delimited file.
Hope it helps.
Regards,
Rajesh Kumar -
Upload data from excel (not the excle file) into SAP
Guys,
how can we upload data from excel sheet into SAP? I mean just the data not the entire file,
I have a requirement where user press a button in excel sheet and the data in the sheet will get uploaded into SAP.
I am sure we have to use BAPI and some VB programming for macros, I will really appriciate if anyone can help how to achive this.
some sample code exampe will help.
Cheers!I think u r writing BDC for Uploading the data from excel flile to sap. for this is the code I am sending u can use then for Uploading data from excel to sap.
DATA: lv_filename TYPE rlgrap-filename.
FIELD-SYMBOLS : <fs>.
DATA : l_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : l_index TYPE i.
PARAMETERS : startcol TYPE i ,
startrow TYPE i ,
endcol TYPE i ,
endrow TYPE i .
PARAMETERS: p_flnam LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_flnam.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = sy-repid
FIELD_NAME = ' '
IMPORTING
file_name = p_flnam .
MOVE p_flnam TO lv_filename.
Uploading the flat file from the desktop
START-OF-SELECTION.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = lv_filename
i_begin_col = startcol
i_begin_row = startrow
i_end_col = endcol
i_end_row = endrow
TABLES
intern = l_intern
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.
SORT l_intern BY row col.
LOOP AT l_intern.
MOVE l_intern-col TO l_index.
ASSIGN COMPONENT l_index OF STRUCTURE itab TO <fs>.
MOVE l_intern-value TO <fs>.
AT END OF row.
APPEND itab.
CLEAR itab.
ENDAT.
ENDLOOP.
I hope it will help u.
Regards
Nayan -
Upload data from excel to Ztable with statistics
Hi,
I have a requirement to upload data from excel sheet to ztable .
Here i need tp provide the user with the execution statistics like
1.Number of records read from the Excel spread-sheet
2. Number records processed successfully
3. Number records with Error
4. Name and location of Error Log-file (text-file format)
5. Name and location of the file containing error records (Excel spread-sheet format)
I would appreciate if any of you have code written for the sameSee the below example code to upload from xl file to sap
REPORT ZLWMI151_UPLOAD no standard page heading
line-size 100 line-count 60.
*tables : zbatch_cross_ref.
data : begin of t_text occurs 0,
werks(4) type c,
cmatnr(15) type c,
srlno(12) type n,
matnr(7) type n,
charg(10) type n,
end of t_text.
data: begin of t_zbatch occurs 0,
werks like zbatch_cross_ref-werks,
cmatnr like zbatch_cross_ref-cmatnr,
srlno like zbatch_cross_ref-srlno,
matnr like zbatch_cross_ref-matnr,
charg like zbatch_cross_ref-charg,
end of t_zbatch.
data : g_repid like sy-repid,
g_line like sy-index,
g_line1 like sy-index,
$v_start_col type i value '1',
$v_start_row type i value '2',
$v_end_col type i value '256',
$v_end_row type i value '65536',
gd_currentrow type i.
data: itab like alsmex_tabline occurs 0 with header line.
data : t_final like zbatch_cross_ref occurs 0 with header line.
selection-screen : begin of block blk with frame title text.
parameters : p_file like rlgrap-filename obligatory.
selection-screen : end of block blk.
initialization.
g_repid = sy-repid.
at selection-screen on value-request for p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = g_repid
IMPORTING
FILE_NAME = p_file.
start-of-selection.
Uploading the data into Internal Table
perform upload_data.
perform modify_table.
top-of-page.
CALL FUNCTION 'Z_HEADER'
EXPORTING
FLEX_TEXT1 =
FLEX_TEXT2 =
FLEX_TEXT3 =
*& Form upload_data
text
FORM upload_data.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = p_file
I_BEGIN_COL = $v_start_col
I_BEGIN_ROW = $v_start_row
I_END_COL = $v_end_col
I_END_ROW = $v_end_row
TABLES
INTERN = itab
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
write:/10 'File '.
ENDIF.
if sy-subrc eq 0.
read table itab index 1.
gd_currentrow = itab-row.
loop at itab.
if itab-row ne gd_currentrow.
append t_text.
clear t_text.
gd_currentrow = itab-row.
endif.
case itab-col.
when '0001'.
t_text-werks = itab-value.
when '0002'.
t_text-cmatnr = itab-value.
when '0003'.
t_text-srlno = itab-value.
when '0004'.
t_text-matnr = itab-value.
when '0005'.
t_text-charg = itab-value.
endcase.
endloop.
endif.
append t_text.
ENDFORM. " upload_data
*& Form modify_table
Modify the table ZBATCH_CROSS_REF
FORM modify_table.
loop at t_text.
t_final-werks = t_text-werks.
t_final-cmatnr = t_text-cmatnr.
t_final-srlno = t_text-srlno.
t_final-matnr = t_text-matnr.
t_final-charg = t_text-charg.
t_final-erdat = sy-datum.
t_final-erzet = sy-uzeit.
t_final-ernam = sy-uname.
t_final-rstat = 'U'.
append t_final.
clear t_final.
endloop.
delete t_final where werks = ''.
describe table t_final lines g_line.
sort t_final by werks cmatnr srlno.
Deleting the Duplicate Records
perform select_data.
describe table t_final lines g_line1.
modify zbatch_cross_ref from table t_final.
if sy-subrc ne 0.
write:/ 'Updation failed'.
else.
Skip 1.
Write:/12 'Updation has been Completed Sucessfully'.
skip 1.
Write:/12 'Records in file ',42 g_line .
write:/12 'Updated records in Table',42 g_line1.
endif.
delete from zbatch_cross_ref where werks = ''.
ENDFORM. " modify_table
*& Form select_data
Deleting the duplicate records
FORM select_data.
select werks
cmatnr
srlno from zbatch_cross_ref
into table t_zbatch for all entries in t_final
where werks = t_final-werks
and cmatnr = t_final-cmatnr
and srlno = t_final-srlno.
sort t_zbatch by werks cmatnr srlno.
loop at t_zbatch.
read table t_final with key werks = t_zbatch-werks
cmatnr = t_zbatch-cmatnr
srlno = t_zbatch-srlno.
if sy-subrc eq 0.
delete table t_final .
endif.
clear: t_zbatch,
t_final.
endloop.
ENDFORM. " select_data
Reward Points if it is helpful
Thanks
Seshu -
Upload data from excel where one column has text of 3000 characters
Guyz,
I have a query. One of my requirments is to upload data from excel sheet & create a material. In the excel sheet one of the columns has text for BASIC DATA TEXT under ADDITIONAL DATA of a Material. This is a text of running length.
the selection screen has feature of file upload & the users will upload excel files from their respective presentation servers.
Now my problem is that I need a function module which can convert this column in excel sheet into an internal table & later call the BAPI for MM creation.
I have used TEXT_CONVERT_XLS_TO_SAP & when i read my internal table to check this column length, it shows only 255 characters where as data in the excel sheet has 3000 characters (say for eg.)
Can anybody throw some light on this.
Thanks in advance
GPKHi,
You can try using this function module and see that whether all your data is coming into the internal table properly.
MS_EXCEL_OLE_STANDARD_DAT
For the other part you needed to convert the internal table data into the structure as need by the BAPI and then call the create BAPI to create the materials in the SAP System.
Hope this helps.
Thanks,
Samantak. -
Upload data from excel file -URGENT
Hi All,
Advanced thanks to ur reply
How to upload data from excel sheet to itab
what are the functional modules we are using for that
Please help me
i look forward to ur reply
Regards
Raja Sekhar.THi,
TYPE-POOLS: truxs.
DATA: i_text_data TYPE truxs_t_text_data,
v_filename_string TYPE string.
DATA: BEGIN OF itab OCCURS 0,
Name(30),
Phone(15),
Fax(500).
DATA: END OF itab.
PARAMETERS: p_file LIKE rlgrap-filename.
START-OF-SELECTION.
v_filename_string = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_filename_string
filetype = 'ASC'
has_field_separator = 'X'
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
dat_mode = ''
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = i_text_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
I_LINE_HEADER =
i_tab_raw_data = i_text_data
i_filename = p_file
TABLES
i_tab_converted_data = itab
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.
I think this code will help u.
With Regards,
Ranganathan -
Urgent - Migrate data from Excel sheets
Hello all..
I want to move data from excel sheets into oracle9i Database
I have a bout 50 table with average of 5000 row per table
How could I do it
I will be so obligated if you could detail it for me
Thanks in advanceI want to insert data using loader in the table Tablename
Name Type
CL_CL_CODE NUMBER(3)
SUBCL_CODE VARCHAR2(50)
SUBCL_NAME NUMBER(2)
P_CODE_LENTH NUMBER(3)
SCE_NAME VARCHAR2(50)
I use this statement:
load data
infile 'D:\Sqlldr\load.dat'
replace
into table subclasses
FIELDS TERMINATED BY ";" OPTIONALLY ENCLOSED BY '"'
(CL_CL_CODE,SUBCL_CODE,SUBCL_NAME,P_CODE_LENTH SCE_NAME)
I need to use default value for the column SCE_NAME,P_CODE_LENTH
what is the formula for this
Thanks -
Upload data from Excel to Sap-Crm
Hi All,
I need to upload data from EXCEL to SAP-CRM system.The problem is in crm there is no ALSM_EXCEL_INTO_INTERNAL_TABLE or corresponding function modules exist.Using GUI_UPLOAD I can upload data from excel to CRM but the main problem with this is it supports only 255 chars for entire line, in my excel file it contains more than 255 chars.Please help me out.Try the following :
Class: CL_GUI_FRONTEND_SERVICES
Method: GUI_UPLOAD
Thanks
<b>Allot points if this helps!</b> -
Upload data from excel( XLS/xs format) in SAP CRM
Upload data from excel( XLS/xs format) in SAP CRM 7.0 as there is no *ALSM*EXCEL*ITAB* like FM there unlike ECC 6.0...?
hello Buddy,
plz go through below links
http://wiki.scn.sap.com/wiki/display/CRM/CRM+Web+UI+-+Uploading+data+from+Excel+files
http://scn.sap.com/docs/DOC-50732
http://scn.sap.com/docs/DOC-31985
Hope This will Help You...
Maybe you are looking for
-
I wonder if anyone can help. I only have the use of one hand when typing. Because of this I learned to touch type with the Dvorak layout for the right hand, which I do very effectively in English. However now that I have to use Chinese on my mac I ha
-
Restoring data from Time Machine to a replacement secondary drive
Hi all. I have a Mac Pro with 4 drives installed - one as a system drive, the others for storing project data, music sample libraries etc. They are all routinely backed up by Time Machine to a large external drive. One of the library drives has fa
-
Is there a JMS client for web logic that allows you to be a client to a topic, for example an error topic, and will let you monitor it with a web app ?? Robert Simmons Jr. Senior Software Engineer Ing
-
Estimados. tengo un problema con el telefono ip modelo 2970, el cual en algunos momentos no recibe energia y se bloque, y para resolver momentaneamente este problema si preciona 3 veces el numero 3 y vuelve a levantar,mi pregunta es ¿porque se produc
-
Keychain cant be found for 'kaDiAdIDStoragekey'
any knows how to fix this