Insert excel file into a table
Hi all,
I have a excel file with a lot of records. I want to insert all this records into a table without using a insert statement for every record.
Can any one help me with this?
ekas
If you have a .csv file then use an EXTERNAL TABLE so you can read the file just like it were a table...
http://www.oracle-base.com/articles/9i/SQLNewFeatures9i.php#ExternalTables
then all you have to do is simply:
insert into your_table
select ...
from your_external_table;You can find many examples on AskTom, for example:
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:6611962171229
Similar Messages
-
Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure
Please Help , Urgent Help Needed.
Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package.
Case's are :
1. Excel File is On Users/ Client PC.
2. Application is on Remote Server(Oracle Forms D2k).
3. User Is Using Application Using Terminal Server LogIn.
4. So If User Will Use to GET_FILE_NAME() function of D2K to Get Excel File , D2k Will Try to pick File from That Remote Server(Bcs User Logind from Terminal Server Option).
5. Cannot Use Util_File Package Or Oracle Directory to Place That File on Server.
6. we are Using Oracle 8.7
So Need Some PL/SQL Package or Fuction/ Procedure to Upload Excel file on User's Pc to Oracle Table.
Please Guide me wd some Code. or with Some Pl/SQL Package, or With SOme Hint. Or any Link ....
Jus help to Sort This Issue ........
you can also write me on :
[email protected], [email protected]TEXT_IO is a PL/SQL package available only in Forms (you'll want to post in the Forms forum for more information). It is not available in a stored procedure in the database (where the equivalent package is UTL_FILE).
If the Terminal Server machine and the database machine do not have access to the file system on the client machine, no application running on either machine will have access to the file. Barring exceptional setups (like the FTP server on the client machine), your applications are not going to have more access to the client machine than the operating system does.
If you map the client drives from the Terminal Server box, there is the potential for your Forms application to access those files. If you want the files to be accessible to a stored procedure in the database, you'll need to move the files somewhere the database can access them.
Justin -
Uploading excel file into internal table
Hi,
Any function module is there to upload an excel file into internal table in CRM 7.0 system?
Thanks.Hi Ginger,
If u have access to ECC R/3 make use FM 'TEXT_CONVERT_XLS_TO_SAP' source code which is existing to convert to Excel to Internal table. It will work in CRM also.
As of Now I don't have access to SAP S/m. Mean while u can try as above said.
Regards,
Lokesh B -
Upload an excel file into a table
Good Morning:
I have to upload the contents of an excel file into a table. Someone knows how to do it?
Thanks a lot.Hi,
See this sample code.
At selection-screen on value-request for p_file.
call function 'F4_FILENAME'
exporting
field_name = 'p_file'
importing
file_name = p_file.
clear itab.
call function 'WS_UPLOAD'
exporting
codepage = ' '
filename = p_file
filetype = 'DAT'
tables
data_tab = itab
exceptions
conversion_error = 1
file_open_error = 2
file_read_error = 3
invalid_type = 4
no_batch = 5
unknown_error = 6
invalid_table_width = 7
gui_refuse_filetransfer = 8
customer_error = 9
others = 10.
Here you need to save your Excel file as a 'DAT' file.
I hope this will help you.
CHEERS
Message was edited by: Deepak333 k -
Import an excel file into a table
Anybody can help me on importing a big text file (i.e. an excel file) into a table without using SQL Loader?
Thnx in advanceuser5181307 wrote:
There is another method where in you can edit the listener file to make an entry for separate service. then create a database link and tns entry to use the service to access the Excel.What you are referring to is called Heterogeneous Services and allows Oracle to treat something as an External database.
For Excel files you would do it like this...
1- Go to Control Panel>Administrative Tools>Data Sources (ODBC)>System DSN and create a data source with appropriate driver. Name it EXCL.
2- In %ORACLE_HOME%\Network\Admin\Tnsnames.ora fie add entry:
EXCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.12.0.24)(PORT = 1521))
(CONNECT_DATA =
(SID = EXCL)
(HS = OK)
Here SID is the name of data source that you have just created.
3- In %ORACLE_HOME%\Network\Admin\Listener.ora file add:
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = <hs_sid>)
(ORACLE_HOME = <oracle home>)
under SID_LIST_LISTENER like:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\ORA9DB)
(PROGRAM = extproc)
(SID_DESC =
(GLOBAL_DBNAME = ORA9DB)
(ORACLE_HOME = d:\ORA9DB)
(SID_NAME = ORA9DB)
(SID_DESC =
(PROGRAM = hsodbc)
(SID_NAME = EXCL)
(ORACLE_HOME = D:\ora9db)
Dont forget to reload the listener
c:\> lsnrctl reload
4- In %ORACLE_HOME%\hs\admin create init<HS_SID>.ora. For our sid EXCL we create file initexcl.ora.
In this file set following two parameters:
HS_FDS_CONNECT_INFO = excl
HS_FDS_TRACE_LEVEL = 0
5- Now connect to Oracle database and create database link with following command:
SQL> CREATE DATABASE LINK excl
2 USING 'excl'
3 /
Database link created.
Now you can perform query against this database like you would for any remote database.
SQL> SELECT table_name FROM all_tables@excl;
TABLE_NAME
DEPT
EMP... however, from the sounds of the original question the OP is referring to a flat file of data (like a CSV file) and not really an Excel file (.xls) which is a proprietary binary format that you won't be able to read with SQL*Loader or External Tables.
The best method for the OP's requirements would appear to be external tables which were introduced with 9i. -
How can i read local excel file into internal table in webdynpro for abap a
Could someone tell me how How can i read local excel file into an internal table in webdynpro for abap application.
thank u for your replyDeep,
File manuplations...............................
1. At the presentation level:
->GUI_UPLOAD
->GUI_DOWNLOAD
->CL_GUI_FRONTEND
2. At the application server level:
->OPEN DATASET : open a file in the application server for reading or writing.
->READ DATASET : used to read from a file on the application server that has been opened for reading
-> TRANSFER DATASET : writing data to a file.
-> CLOSE DATASET : closes the file
-> DELETE DATASET : delete file
If file is on the local PC,use the function module GUI_UPLOAD to upload it into an internal table by passing the given parameters......
call function 'GUI_UPLOAD'
exporting
filename = p_file
filetype = 'ASC'
has_field_separator = '#'
tables
data_tab = t_data
p_file : excel file path.
t_data : internal table
<b>reward points if useful.</b>
regards,
Vinod Samuel. -
Upload openoffice excel file into internal table
Hi Everyone,
I have a requirement where in we need to upload vendor master data into SAP.
The data is available in excel format. But the excel sheet was created in openoffice s/w and client is not allowing
us to install MS-Office so that we cut and paste the data by creating anexcel file.
Now there is an option of saving the excel file in openoffice s/w as MS-Excel 95 format with .xls extension.
But since we are saving this in openoffice enivoronment the FM ALSM_EXCEL..... data is not improting this excel file into
Did somebody faced this issue before. Pls share the approach to solve this issue.
Regards,
VinayHi !
you can use the Function module TEXT_CONVERT_XLS_TO_SAP to upload xcel file to internal table
please go through the code below.
REPORT zupload_excel_to_itab.
TYPE-POOLS: truxs.
PARAMETERS: p_file TYPE rlgrap-filename.
TYPES: BEGIN OF t_datatab,
col1(30) TYPE c,
col2(30) TYPE c,
col3(30) TYPE c,
END OF t_datatab.
DATA: it_datatab type standard table of t_datatab,
wa_datatab type t_datatab.
DATA: it_raw TYPE truxs_t_text_data.
At selection screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
*START-OF-SELECTION.
START-OF-SELECTION.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_raw " WORK TABLE
i_filename = p_file
TABLES
i_tab_converted_data = it_datatab[] "ACTUAL DATA
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.
END-OF-SELECTION.
END-OF-SELECTION.
LOOP AT it_datatab INTO wa_datatab.
WRITE:/ wa_datatab-col1,
wa_datatab-col2,
wa_datatab-col3.
ENDLOOP.
hope this will help you.
Regards,
Kiran -
Inserting XML file into a Table
Hello,
Can someone provide me with a sample code to load xml files into a table. Thanks a lot.
RajeeshKeeping my fingers crossed that this quote from "Building XML Oracle Applications" by Steve Muench (O'Reilly & Associates, 2000, ISBN 1-56592-691-9) falls into the "fair use" category, and that you want it in PL/SQL, here is a procedure:
PROCEDURE insertXMLFile
(dir VARCHAR2, file VARCHAR2, name VARCHAR2 := NULL) IS
theBFile BFILE;
theCLob CLOB;
theDocName VARCHAR2(200) := NVL(name,file);
BEGIN
-- (1) Insert a new row into xml_documents with an empty CLOB, and
-- (2) Retrieve the empty CLOB into a variable with RETURNING.INTO
INSERT INTO stylesheets(docname,sheet) VALUES(theDocName,empty_clob( ))
RETURNING sheet INTO theCLob;
-- (3) Get a BFile handle to the external file
theBFile := BFileName(dir,file);
-- (4) Open the file
dbms_lob.fileOpen(theBFile);
-- (5) Copy the contents of the BFile into the empty CLOB
dbms_lob.loadFromFile(dest_lob => theCLob, src_lob => theBFile, amount => dbms_lob.getLength(theBFile));
-- (6) Close the file and commit
dbms_lob.fileClose(theBFile);
COMMIT;
END; -
Uploading data from a particular column of a particular sheet from an excel file into internal table
Hi,
I have to upload data in the first coulmn of 7th sheet of an excel file.
Can anyone please help me on this.
This link works perfectly fine for excel files without Macros.
Read multiple sheets of an Excel file into SAP through ABAP - Code Gallery - SCN Wiki
But my excel file has some macros.
And after the macro enable/disable popup is cleared, the system freezes.
Can someone pease help me on this abd tell me an approach different from the one in the above link?Welcome to SCN
Please search before you post next time:BDC, upload data from multi excel sheets -
How to transfer data from excel files into z-tables
Please help me with a code which transfers data from excel file to z-table.
Thanks in advance
ShuvirHi Daniel,
Export Data
Purpose
Use this procedure to export SAP data to a local file such as Microsoft Excel.
Menu Path
Use the following menu path to begin this process:
· SystemèListèSaveèLocal File
Helpful Hints
When reviewing fields, R = Required, O = Optional and C = Conditional.
Procedure
1. Start the transaction using the menu path or transaction code.
Whatever Data You Want to Export
2. Select SystemèListèSaveèLocal File. This works well for any data in SAP. This is the only option for the top-level (first page) of a report.
In a drill-down view within a report the Local File button on the toolbar may be used and has the same options.
Choose File Format
3. Click .
4. Click to continue. If prompted for a format after choosing Spreadsheet, select Excel Table to get an Excel file that can be modified more easily.
Choose File Save Location Step 1
5. Click to the right of the Directory field to choose a different location.
Choose File Save Location Step 2
6. Click or browse your computer to locate the directory where you want to save your file.
7. Complete the following field:
· File name:
You must add the proper file extension to the name of your file (.xls for Excel, .rtf for Rich Text, .html for HTML). The file extension tells your computer what program to open the file with. If you do not have the file extension at the end, you may not be able to open it.
8. Click to continue.
Generate File in Location and Format Selected
9. Click to create the file in the location and format selected. In this example the file was named "example.xls" and saved on the desktop.
Result
You have completed the export process.
thanks
karthik -
Uploading excel file into internal table with field length more than 255
I am trying to upload the data from an excel file through function module 'TEXT_CONVERT_XLS_TO_SAP'.
I have tested by changing the field type from string, and char2000.
But it is accepting only 255 chars from the cell content.
How to get the total content of the field if it is more than 255 char.hi,
you can use any of the following procedures:
For uploading data from excel to internal table refer standard report RC1TCG3Z in se38 :
or
You can use the FM 'ALSM_EXCEL_TO_INTERNAL_TABLE' itself. Please check if you have done it this way . But, this FM can be a little time consuming if the excel has large data, so you can use the FM u2018GUI_UPLOADu2019.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file1
i_begin_col = l_b1
i_begin_row = l_c1
i_end_col = l_b2
i_end_row = l_c2
TABLES
intern = lt_data
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE e018 DISPLAY LIKE 'i'.
ENDIF.
*---Removing the first heading fields from the file.
IF NOT lt_data[] IS INITIAL.
LOOP AT lt_data INTO lwa_data WHERE row = '0001'.
DELETE lt_data.
CLEAR lwa_data.
ENDLOOP.
*---Inserting the data from file the internal table
LOOP AT lt_data INTO lwa_data.
CASE lwa_data-col.
WHEN 1.
wa_file_wicopa-serial = lwa_data-value.
WHEN 2.
wa_file_wicopa-blart = lwa_data-value.
WHEN 3.
wa_file_wicopa-bldat = lwa_data-value.
WHEN 4.
wa_file_wicopa-budat = lwa_data-value.
ENDCASE.
AT END OF row.
APPEND wa_file_wicopa TO gt_file_wicopa.
CLEAR wa_file_wicopa.
ENDAT.
CLEAR lwa_data.
ENDLOOP.
ENDIF.
ENDIF.
or
DATA: it_test TYPE STANDARD TABLE OF alsmex_tabline WITH HEADER LINE.
DATA :v_start_col TYPE i VALUE '1',
v_start_row TYPE i VALUE '1',
v_end_col TYPE i VALUE '256',
v_end_row TYPE i VALUE '65536',
v_text TYPE repti.
* Funtion Module to upload values from excel to the Internal table
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 = it_test
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.
Or
You can use FM u201CTEXT_CONVERT_XLS_TO_SAPu201D.
DATA : i_raw TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_field_seperator = 'X'
i_tab_raw_data = i_raw
i_filename = p_path
TABLES
i_tab_converted_data = itab
EXCEPTIONS
conversion_failed = 1
OTHERS = 2
hope it will help u
regards
rahul -
How to load the data from excel file into temprory table in Forms 11g?
Hi
How to Load the data from excel file(Extension is .CSV) into the temporary table of oracle in Forms11g.
My Forms Version is - Forms [64 Bit] Version 11.1.2.0.0 (Production)
Kindly Suggest the Solution.
Regards,
SachinDeclare
v_full_filename varchar2(500);
v_server_path varchar2(2000);
v_separator VARCHAR2(1);
v_filename VARCHAR2(400);
filename VARCHAR2 (100);
v_stop_load varchar2 (2000);
v_rec_error_log varchar2(4000);
v_error_log varchar2(4000);
ctr NUMBER (12);
cols NUMBER (2);
btn number;
RES BOOLEAN;
application ole2.obj_type;
workbooks ole2.obj_type;
workbook ole2.obj_type;
worksheets ole2.obj_type;
worksheet ole2.obj_type;
cell ole2.obj_type;
cellType ole2.OBJ_TYPE;
args ole2.obj_type;
PROCEDURE olearg
IS
args ole2.obj_type;
BEGIN
args := ole2.create_arglist;
ole2.add_arg (args, ctr);
ole2.add_arg (args, cols);
cell := ole2.get_obj_property (worksheet, 'Cells', args);
ole2.destroy_arglist (args);
END;
BEGIN
v_full_filename := client_get_file_name(directory_name => null
,file_name => null
,file_filter => 'Excel files (*.xls)|*.xls|'
||'Excel files (*.xlsx)|*.xlsx|'
,message => 'Choose Excel file'
,dialog_type => null
,select_file => null
If v_full_filename is not null Then
v_separator := WEBUTIL_CLIENTINFO.Get_file_Separator ;
v_filename := v_separator||v_full_filename ;
:LOAD_FILE_NAME := substr(v_filename,instr(v_filename,v_separator,-1) + 1);
RES := Webutil_File_Transfer.Client_To_AS(v_full_filename,"server_path"||substr(v_filename,instr(v_filename,v_separator,-1) + 1));
--Begin load data from EXCEL
BEGIN
filename := v_server_path||substr(v_filename,instr(v_filename,v_separator,-1) + 1); -- to pick the file
application := ole2.create_obj ('Excel.Application');
ole2.set_property (application, 'Visible', 'false');
workbooks := ole2.get_obj_property (application, 'Workbooks');
args := ole2.create_arglist;
ole2.add_arg (args, filename); -- file path and name
workbook := ole2.get_obj_property(workbooks,'Open',args);
ole2.destroy_arglist (args);
args := ole2.create_arglist;
ole2.add_arg (args, 'Sheet1');
worksheet := ole2.get_obj_property (workbook, 'Worksheets', args);
ole2.destroy_arglist (args);
ctr := 2; --row number
cols := 1; -- column number
go_block('xxx');
FIRST_RECORD;
LOOP
--Column 1 VALUE --------------------------------------------------------------------
olearg;
v_stop_load := ole2.get_char_property (cell, 'Text'); --cell value of the argument
:item1 := v_stop_load;
cols := cols + 1;
--Column 2 VALUE --------------------------------------------------------------------
olearg;
:item2 := ole2.get_char_property (cell, 'Text'); --cell value of the argument
cols := cols + 1;
--<and so on>
ole2.invoke (application, 'Quit');
ole2.RELEASE_OBJ (cell);
ole2.RELEASE_OBJ (worksheet);
ole2.RELEASE_OBJ (worksheets);
ole2.RELEASE_OBJ (workbook);
ole2.RELEASE_OBJ (workbooks);
ole2.RELEASE_OBJ (application);
END;
--End load data from EXCELPlease mark it as answered if you helped. -
How to Display the content of Excel file into Webdynpro Table
Hi Experts
I am following the Blog to upload a file in to the webdynpro context,but my problem is after uploading a excel file i need to extract the content from that Excel file and that content should be displayed in the webdynpro table.Can any body please guide me how to read the content from excel and to Display in the Table.
Thanks and Regards
KalyanHI,
Take for example, if Excel file contains 4 fields,
Add jxl.jar to JavaBuild path and Use this snippet
File f=new File("sample.xls");
Workbook w=Workbook.getWorkbook(f);
Sheet sh=w.getSheet(0);
int cols=sh.getColumns();
int rows=sh.getRows();
Cell c=null;
String s1=null;
String s2=null;
String s3=null;
String s4=null;
ArrayList al=new ArrayList();
int j=0;
for(int i=1;i<rows;i++)
ITableElement table=wdContext.createTableElementz
s1=sh.getCell(0,i).getContents();
s2=sh.getCell(1,i).getContents();
s3=sh.getCell(2,i).getContents();
s4=sh.getCell(3,i).getContents();
table.setName(s1);
table.setAddress(s2);
table.setDesignation(s3);
table.setDummy(s4);
al.add(j,table);
j++;
wdContext.nodeTable().bind(al);
Regards
LakshmiNarayana -
Uploading EXCEL file into Internal Table Using GUI_UPLOAD
Can any one please give me an example use of FM "GUI_UPLOAD" which to upload a EXCEL file????? (not .txt)
Use the forum search option [GUI_UPLOAD FOR EXCEL|https://forums.sdn.sap.com/search.jspa?threadID=&q=GUI_UPLOADFOREXCEL&objID=c42&dateRange=all&numResults=15&rankBy=10001]) or sdn wiki/code gallery ([UPLOAD EXCEL|https://wiki.sdn.sap.com/wiki/dosearchsite.action?searchQuery.queryString=upload+Excel&searchQuery.spaceKey=conf_global]) - Same question already answered many time
GUI_UPLOAD doesnt perform such conversion (Excel, Word, PDF) and wont give you a suitable result, use one of the FM mentioned above or [office integration|http://help.sap.com/saphelp_47x200/helpdata/en/21/b53138e1ba11d2bdbe080009b4534c/frameset.htm] or OLE or convert your Excel sheet to a simpler format : txt, csv, xml.
Regards,
Raymond -
Upload long text from excel file into internal table
I need to upload service master(T-code : AC02) data alongwith long text.Now i have data in excel as: Service no(ASMD-ASNUM) and corresponding long text for it.
I am facing problem in getting entire lontext from excel into my internal table.It only takes till 255 characters i think.Any help in this regard woulg be highly appreciable.hi,
what is the maximum length of your long text.
and you can try with more than 255 chars. in the internal table it will take , if you want check it.
i'm in 4.7 ,5.0 version, what about you ..
please check , you can upload even more than 255.
try
regards
vijay
Maybe you are looking for
-
Why i can't add a library with remote?
Hi everybody, i recently try to add a library to the remote app on mi ipod and it get stuck in the final step. For add a the library i opened the remote app and selected "add a library", the code apeared in the screen and i serch the remote in itunes
-
Need the latest .pdf manual for FCP X 10.0.9?
I have a friend who is stuck on FCP X 10.0.9 because he can't upgrade to Mavericks. The only old official .pdf user manual I have was produced last year for 10.0.6 Was this the last one made or is there something even more up to date . . . . no
-
I am forced to shut down iMac g5 after a few minutes of use due to pixelation which freezes up monitor. Any thoughts on solutions?
-
I am following the instructions on the Apple website to enable the root user, and it says that after you enter your admin password on the Directory Utility window, to simply pick 'Enable Root User' from the 'Edit' menu. I don't see any menu that says
-
Hi Hoping you can help with a formula column I need to create. The situation is this: It's for a HR head count report which is split by Employment category. The issue is for multiple assignments, where in this report - I only want to count each perso