Load details into a Sheet to run in subquery
Hi guys
Is there a way to get a list of values i.e. references from a column in excel into a Disco sheet to run them as a subquery on a 2nd sheet?
I have stacks of references and need to do a select for the values in that custom table.
Thank
Johan
Hi,
Your best option is to save the Excel sheet as a csv file and map the file into the database as an external table. You will need to have a shared drive between the desktop and the server (a samba drive is OK) and some DBA input to set up the external table and database directory.
One set up it works well since you can change and save the excel sheet and then just refresh the Discoverer worksheet to see the new content.
Rod West
Similar Messages
-
I am having issues loading CR2 into my LightRoom, I am currently running Lightroom 4.4, Camera Raw 7.4
What camera model took the pictures? It is a question of when your camera was added for support. Check the following list and find your model. That will tell you what is required to work with your files.
Camera Raw plug-in | Supported cameras -
I am running Mac OS 10.10 and trying to run Illustrator CS4. CS4 says it needs Java SE 6 Run Time, but I can not load that into OS 10.10. What to do?
Jacob,
You are genius! I search all over the net and had a long chat with Apple without success. 30 minutes after posting the Abobe Illustrator forum, I have a link that works!! Many thanks.
Jim -
I used to shoot video in my Powershot S3 IS (Format MVI_.AVI) and load them into iPhoto, I used quicktime pro so I could convert for emailing to family members. That was when I was running Leopard now with Mt. Lion nothing works. Videos do not open at all. Any simple suggestions, I am not real keen on iMovie Productions and not real certain how they compress for emailing attachments. Something simple here that I am missing? Thanks so much. I am a grandpa trying to share with family members far away (quickly & simply).
I am surprised that Apple did not build a converter into Mt. Lion.
Apple does have a converter built into Mountain Lion. It is call "Quicktime." However, in order to use this converter, you must first make sure the compression formats are playback compatible with QT. Basically, there are three levels of QT compatibility. The lowest is "Playback." These file can be played by QT but may not be conversion or edit compatible with QT. The second level is QT "Conversion" compatible. These files are playback compatible and can be converted to other compression formats using QT. "Edit" compatible media files are "Fully" compatible with QT since the can be played, converted and/or edited by QT. The main problem here is that AVI is a "legacy" file format that has not been officially supported by Microsoft for more than 11 years when it was replaced by Windows Media multimedia file/compression formats. Many of the original compression formats used in AVI files have never been transcoded for the Mac platform, use beyond system 9, or use beyond PPC platforms. In addition, some commonly used AVI codecs are proprietary or use non-standard (hybrid) profile and level combinations. In short, there is little wonder that Apple has been distancing itself from this outdated file type as it re-writes and upgrades its own QT structure to support more standardized, more scalable, more modern high definition file types and compression formats. It is really unfortunate that users continue to use this outmoded file type simply because it is freely available, easy to use, or they are simply too lazy to move on to a more modern or more efficient file types and/or compression formats.
I tested Wondershare Video Converter Ultimate for the Mac, which seems to be the "state of the art". I may be purchasing a new camera which might create a whole new set of variables. This program seems to cover all bases and is great for novices.
There are many third-party apps available if you wish to search for them. Many are even available in the App Store. Most do their job well and it is usually a matter of personal user preference as to which is best.
HandBrake seems more suited to folks with more experience and knowledge.
I mentioned Handbrake primarily because it is free and easy to use when you employ the included conversion presets options. (The TV options can normally be used for almost any situation depending on the source file and output requirements.) It is also excellent for more experienced users, but has a somewhat limited choice of output options as it does not access the user's system QT codec component configuration. -
Initial Loading of User Details into OIM 11g from Peoplesoft
Hi,
I wanted to pull user both (employee/contractor) details into OIM from People Soft. Which connector should i use.?
PSFT User Management? or PSFT Employee Recon?
Initially the users doesn't exist in OIM. I am looking for something like initial loading.
Regards,
AshokHi Kevin
As per earlier version of PS ER connector, Oracle® Identity Manager Connector Guide for PeopleSoft Employee Reconciliation, Release 9.1.0, on section 3 Extending the Functionality of the Connector, there is guide on how to extend the connector to pull additional attributes from PS , by using peoplecode..
But in Oracle® Identity Manager Connector Guide for PeopleSoft Employee Reconciliation,Release 11.1.1, am not able to find this information anymore.
On how to pull additional attributes from PS like department, division and location, which is custom attributes in PS
Please help !
Many thanks -
Se16 down load into excel sheet problem with PO number
Dear All,
While I download vbak table data using se16 from table VBAK ( using System > List> save --> local File --> Spreadsheet ), I get the PO number converted as error like at it's end, the last digit is becoming zero when po number is of 16 digits. means only the last digit is converted to 0.
For example : se16 -> vbak table -> the po numbers
1238643210249039, when I down load in the excel sheet it is appearing as 1238643210249030
(I means the last digit of the PO number is downloaded with error, it is always a u201C0u201D.
if the PO number is of less than 16 digits... the above problem is not there )
How to correct the error ? How to tell solution to functional consultant ? Can you please suggest me
Do we need to apply any OSS message ?
Thanks in ADVANCE.
Edited by: sam kumar on Dec 8, 2008 5:40 PMHi,
Just found that 'Numbers in Microsoft Excel can never have more than 15 significant digits'.
check this link from Microsoft: [http://support.microsoft.com/kb/158071|http://support.microsoft.com/kb/158071]
check this [http://office.microsoft.com/en-us/excel/HA102748231033.aspx|http://office.microsoft.com/en-us/excel/HA102748231033.aspx]
[http://office.microsoft.com/en-us/excel/HA102748231033.aspx#5|http://office.microsoft.com/en-us/excel/HA102748231033.aspx#5]
What i can suggest is, put a apostrophe (') for the value of first cell content at the beginning.
Use Format painter to apply the same for all values in that column.
Regards
Raj
Edited by: Rajasekhar Dinavahi on Dec 8, 2008 10:59 PM
Edited by: Rajasekhar Dinavahi on Dec 8, 2008 11:00 PM
Edited by: Rajasekhar Dinavahi on Dec 8, 2008 11:05 PM -
SSIS package to load Source Control Explorer details into a table
Hi Guys,
We are maintaining our code in Source control explorer,TFS.
We have created a table in our database which will have columns like names, latest, last_checkin.
I like to read from TFS those values and load it into database.
We need to create reports based on the locations and send it to our client.
Any ideas or path i have to take in order to achieve this, will be very grateful.
Cheers!!!!!Why would you use SSIS to read from TFS?
And then create a report?
Wrong design to my taste.
You need a lot of .Net code as you need TFS APIs used this way.
var server = RegisteredTfsConnections.GetProjectCollection(new Uri("http://hostname:8080/"));
var projects = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(server);
var versionControl = (VersionControlServer)projects.GetService(typeof(VersionControlServer));
var newestDate = DateTime.MinValue;
Item newestItem = null;
var items = versionControl.GetItems("$/theproject/trunk/setup/*.msi");
foreach (var item in items.Items)
if (item.ItemType != ItemType.File)
continue;
if (item.CheckinDate > newestDate)
newestItem = item;
newestDate = item.CheckinDate;
newestItem.DownloadFile("C:\\temp\\" + Path.GetFileName(newestItem.ServerItem));
this still can be done in a Script Task, but defeats the purpose of using ETL.
Arthur My Blog -
How can i load file into database from client-side to server-side
i want to upload file from client-side to server-side, i use the following code to load blob into database.
if the file is in the server-side, it can work, but if it in the client-side, it said that the system cannot find the file. i think it only will search the file is in the server-side or not, it will not search the client-side.
how can i solve it without upload the file to the server first, then load it into database??
try
ResultSet rset = null;
PreparedStatement pstmt =
conn.prepareStatement ("insert into docs values (? , EMPTY_BLOB())");
pstmt.setInt (1, docId);
pstmt.execute ();
// Open the destination blob:
pstmt.setInt (1, docId);
rset = pstmt.executeQuery (
"SELECT content FROM docs WHERE id = ? FOR UPDATE");
BLOB dest_lob = null;
if (rset.next()) {
dest_lob = ((OracleResultSet)rset).getBLOB (1);
// Declare a file handler for the input file
File binaryFile = new File (fileName);
FileInputStream istream = new FileInputStream (binaryFile);
// Create an OutputStram object to write the BLOB as a stream
OutputStream ostream = dest_lob.getBinaryOutputStream();
// Create a tempory buffer
byte[] buffer = new byte[1024];
int length = 0;
// Use the read() method to read the file to the byte
// array buffer, then use the write() method to write it to
// the BLOB.
while ((length = istream.read(buffer)) != -1)
ostream.write(buffer, 0, length);
pstmt.close();
// Close all streams and file handles:
istream.close();
ostream.flush();
ostream.close();
//dest_lob.close();
// Commit the transaction:
conn.commit();
conn.close();
} catch (SQLException e) {Hi,
Without some more details of the configuration, its difficult to know
what's happening here. For example, what do you mean by client side
and server side, and where are you running the upload Java application?
If you always run the application on the database server system, but can't
open the file on a different machine, then it sounds like a file protection
problem that isn't really connected with the database at all. That is to
say, if the new FileInputStream (binaryFile) statement fails, then its not
really a database problem, but a file protection issue. On the other hand,
I can't explain what's happening if you run the program on the same machine
as the document file (client machine), but you can't write the data to the
server, assuming the JDBC connection string is set correctly to connect to
the appropriate database server.
If you can provide some more information, we'll try to help.
Simon
null -
Displaying different sheets at run time based on value of the parameter
Hi,
I've a query regarding displaying two different sheets at run time in Oracle discoverer based on the value of the parameter that i give.
I've a parameter Summary_flag.
If the value of the parameter is 'Y',then it should display a sheet,say for example it should display Sheet1.
If the value is 'N',then it should display another sheet, say for example it should display Sheet2.
Is there any way in which i can accomplish this?
I went through the Format and Tools menus but couldnt find anything regarding this aspect.
Can you help me out?
Thanks,Having a Disco parameter dictate which worksheet is displayed is not an option that is available. There are a few workarounds, though:
1. Have a portlet (or some other web interface) accept your parameters, and then call the appropriate worksheet.
2. Have 2 worksheets, and have it devolve into a training issue (for a summary run this, for all the details run this).
3. Create calculations that will show or hide column data depending on the parameter selected - the columns will still be there, and you can fill them in with blanks, or a message like "N/A for Summary".
4. Create a report that will allow the users to drill between the summary and detail data - I'm not sure whether you could use a parameter to then say whether the report should open up summarized or expanded. -
Error while exporting data into Excel Sheet
Hi All,
I have created a VO which is based on Query(Not based on EO) and the Query is as follows:
select f.user_name ,
f.description ,
a.currency_code,
a.amount_to ,
a.amount_from
from seacds.ar_approval_user_limits_nv a , seacds.fnd_user_nv f
where f.user_id = a.user_id
and a.document_type = 'CM'
order by 2;
Based on this VO I have created a search page which will search and returns data from the table and finally standard export button will export the data into excel sheet.
In this am searching the data based on above 5 attributes. Without entering anything in the messageTextInput if i am clicking GO button, it is returning all the data into the table region. After this if i click on Export Button, data are getting exported into Excel Sheet. It is fine.
But if i am searching the data by entering any value in any of the messageTextInput, it is returning data. But if i am clicking the Export Button then it is throwing the following error:
Exception Details.
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: JBO-27122: SQL error during statement preparation. Statement: SELECT * FROM (select f.user_name ,
f.description ,
a.currency_code,
a.amount_to ,
a.amount_from
from seacds.ar_approval_user_limits_nv a , seacds.fnd_user_nv f
where f.user_id = a.user_id
and a.document_type = 'CM'
order by 2) QRSLT WHERE (( UPPER(CURRENCY_CODE) like UPPER(:1) AND (CURRENCY_CODE like :2 OR CURRENCY_CODE like :3 OR CURRENCY_CODE like :4 OR CURRENCY_CODE like :5))) ORDER BY DESCRIPTION asc
at oracle.apps.fnd.framework.OAException.wrapperException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(Unknown Source)
at OA.jspService(_OA.java:71)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:59)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:462)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:594)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:713)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:370)
at com.evermind.server.http.HttpRequestHandler.doProcessRequest(HttpRequestHandler.java:871)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:453)
at com.evermind.server.http.HttpRequestHandler.serveOneRequest(HttpRequestHandler.java:221)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:122)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:111)
at oracle.oc4j.network.ServerSocketReadHandler$SafeRunnable.run(ServerSocketReadHandler.java:260)
at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:303)
at java.lang.Thread.run(Thread.java:595)
## Detail 0 ##
java.sql.SQLException: Invalid column type
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:138)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:175)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:240)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:7895)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:7572)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8183)
at oracle.jdbc.driver.OraclePreparedStatement.setObjectAtName(OraclePreparedStatement.java:8206)
Kindly give me any idea to clear this error.
Thanks and Regards,
MyvizhiHi Myvizhi ,
Did you try running the query from back end that got generated in the error trace ? see if that query is returning desired
output .
Also would like to know if you are using oracle standard search mode i.e result based search / auto customization search ?
--Keerthi -
Regarding Downloading of Report[List] output into Excel Sheet
Hi All,
Hi i have written one Classical report. I got the output Correctly.
Now i want to download that data into Excel Sheet in excatly the way it displayed in List[Report] output.
I had followed the path <b>System->List->Save->LocalFile->Spread Sheet</b> and tried to download the same.
Though it is downloaded it has not come in exact format.
Now what i want is to add a button above that report & write a program in that to download that data into Excel Sheet.
Can anybody tell me how can solve this issue. If i follow above procedure will the data[List Output] be downloaded into exact format into excel.
If anybody knows other way please sujjest.
Thanks in advance.
Thanks & Regards,
Prasad.Hi Prasad,
I have done a program which downloads the output in the excel sheet in the correct format.
Just check the program. The code given in bold is what you have to use.
REPORT zexp MESSAGE-ID f4 LINE-SIZE 195.
Tables Used ***********************************
TABLES : bseg, bkpf, bsak, lfa1, payr .
Declaring Internal Tables **************************
DATA :
Internal table to hold header data *************
BEGIN OF header OCCURS 0,
ext_date(10) TYPE c,
delimit(1) TYPE c,
ext_time(8) TYPE c,
END OF header,
Internal table to hold detail info **************
BEGIN OF i_data OCCURS 0,
belnr LIKE bsak-belnr,
gjahr LIKE bsak-gjahr,
bukrs LIKE bsak-bukrs,
bldat LIKE bsak-bldat,
xblnr LIKE bsak-xblnr,
blart LIKE bsak-blart,
augdt LIKE bsak-augdt,
augbl LIKE bsak-augbl,
wrbtr LIKE bsak-wrbtr,
shkzg LIKE bsak-shkzg,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
chect LIKE payr-chect,
status(1) TYPE c,
END OF i_data,
Internal table to to collect *****************
BEGIN OF i_data1 OCCURS 0,
belnr LIKE bsak-belnr,
gjahr LIKE bsak-gjahr,
bukrs LIKE bsak-bukrs,
bldat LIKE bsak-bldat,
xblnr LIKE bsak-xblnr,
blart LIKE bsak-blart,
augdt LIKE bsak-augdt,
augbl LIKE bsak-augbl,
wrbtr LIKE bsak-wrbtr,
shkzg LIKE bsak-shkzg,
lifnr LIKE bsak-lifnr,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
chect LIKE payr-chect,
status(1) TYPE c,
END OF i_data1,
String variables for formatting file data *************
fidoc_year TYPE string,
comp_code TYPE string,
check_numbr TYPE string,
vendor TYPE string,
inv_date TYPE string,
inv_nbr TYPE string,
paid_dat TYPE string,
inv_amt TYPE string,
status TYPE string,
ref_doc TYPE string,
************Internal table to store the file contents **************
BEGIN OF i_final_file OCCURS 0,
record(300) TYPE c,
END OF i_final_file,
Internal table to store the list of allowed document types ****
BEGIN OF i_doctype OCCURS 0,
blart LIKE bsak-blart,
END OF i_doctype,
Internal table to hold vendor information ************
BEGIN OF i_lfa1 OCCURS 0,
lifnr LIKE lfa1-lifnr,
name1 LIKE lfa1-name1,
sortl LIKE lfa1-sortl,
END OF i_lfa1,
Internal table to hold check information *************
BEGIN OF i_payr OCCURS 0,
chect LIKE payr-chect,
vblnr LIKE payr-vblnr,
gjahr LIKE payr-gjahr,
zbukr LIKE payr-zbukr,
END OF i_payr.
Data declarations **************************
DATA : ws_stblg TYPE bkpf-stblg,
todate TYPE bsak-augdt,
fromdate TYPE bsak-augdt,
w_day LIKE dtresr-weekday,
day LIKE scal-indicator,
d TYPE n,
e_date LIKE sy-datum,
e_time LIKE sy-uzeit,
dd(2) TYPE c,
mm(2) TYPE c,
yy(4) TYPE c,
hh(2) TYPE c,
min(2) TYPE c,
sec(2) TYPE c.
DATA : wa_filepath(50) TYPE c,
wa_filename(50) TYPE c,
wa_c_filename(100) TYPE c,
arch_path(50) TYPE c.
<b>* Data for downloading to list
DATA : list LIKE TABLE OF abaplist WITH HEADER LINE.
DATA : BEGIN OF list_asc OCCURS 0,
msg(300) TYPE c,
END OF list_asc.
DATA: BEGIN OF i_invoiceheader OCCURS 0,
name(30) TYPE c,
END OF i_invoiceheader.
RANGES dates FOR bkpf-budat.</b>
Selection Screen ************************
SELECTION-SCREEN SKIP 2.
SELECT-OPTIONS:
s_bukrs FOR bkpf-bukrs ,
s_blart FOR bkpf-blart ,
s_augdt FOR bsak-augdt. " memory id todat TO fromdat.
PARAMETERS :submit AS CHECKBOX DEFAULT ' ' .
<b>* Download list to file.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'LIST'.
PERFORM download.
WHEN 'BACK'.
EXIT.
ENDCASE.</b>
<b>----
FORM download *
FORM download.
if s_augdt is initial.
dates-sign = 'I'.
dates-option = 'BT'.
dates-low = '20050901'.
dates-high = '20050920'.
APPEND dates.
else.
dates = s_augdt.
append dates.
endif.
/* Submit the same program .
SUBMIT zexp WITH s_augdt IN dates
EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list
EXCEPTIONS
not_found = 1.
CALL FUNCTION 'LIST_TO_ASCI'
EXPORTING
LIST_INDEX = -1 "LIST_INDEX SY-LSIND.
TABLES
listasci = list_asc
listobject = list.
PERFORM download_file.
ENDFORM.
FORM download_file *
FORM download_file.
DATA fname TYPE rlgrap-filename VALUE 'c:\audit_report.xls'.
DATA ftype TYPE rlgrap-filetype VALUE 'DAT'.
DATA numeric_data(10) TYPE c VALUE '0123456789'.
*Table structure should match with list output.
DATA : BEGIN OF i_data1 OCCURS 0,
belnr(12) TYPE c,
gjahr(6) TYPE c,
bukrs(8) TYPE c,
chect(13) TYPE c,
lifnr(12) TYPE c,
name1(37) TYPE c,
bldat(14) TYPE c,
xblnr(18) TYPE c,
augdt(14) TYPE c,
wrbtr(17) TYPE c,
status(4) TYPE c,
augbl(18) TYPE c,
sortl(17) TYPE c,
END OF i_data1.
Header record of the excel sheet.
PERFORM fill_header.
LOOP AT list_asc.
Reads lines starting from the first record in the report. All informatory statements in the report are not read.
IF list_asc+1(10) CO numeric_data.
i_data1 = list_asc .
APPEND i_data1.
ENDIF.
ENDLOOP.
Call the download function.
CALL FUNCTION 'DOWNLOAD'
EXPORTING
filename = fname
filetype = ftype
TABLES
data_tab = i_data1
FIELDNAMES = i_invoiceheader.
ENDFORM.
FORM fill_header *
FORM fill_header.
i_invoiceheader-name = 'Doc Number'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Fsc Year'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Cmp Code'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Check No'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Vendor No'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Entered by'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Doc Date'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Ref Doc No'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Clearing Date'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Amount'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Status'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Clearing Doc No'.
APPEND i_invoiceheader.
i_invoiceheader-name = 'Sort field'.
APPEND i_invoiceheader.
ENDFORM. " fill_header</b>
Initialization *************************
INITIALIZATION.
To initialize the date parameter on the selection screen.
The date by default ranges from previous Monday to Sunday.
todate = sy-datum.
CALL FUNCTION 'DATE_COMPUTE_DAY'
EXPORTING
date = todate
IMPORTING
day = day.
d = day.
if d < 4.
todate = sy-datum - d - 4 .
else.
todate = sy-datum - d + 3 .
endif.
fromdate = todate - 6.
MOVE: 'BT' TO s_augdt-option,
fromdate TO s_augdt-low,
todate TO s_augdt-high.
APPEND s_augdt.
Start of Selection **************************
START-OF-SELECTION.
Checking the validity of the inputted dates ****************
IF s_augdt-low > sy-datum OR s_augdt-high > sy-datum.
MESSAGE i999 WITH 'You cannot input future date'.
EXIT.
ENDIF.
IF NOT s_bukrs IS INITIAL.
MESSAGE i999 WITH 'Program will run with input parameters in screen!!'.
ENDIF.
Initialize the header data ***********************
e_time = sy-uzeit.
MOVE e_time+0(2) TO hh.
MOVE e_time+2(2) TO min.
MOVE e_time+4(2) TO sec.
CONCATENATE hh min sec INTO header-ext_time SEPARATED BY ':'.
e_date = sy-datum.
MOVE e_date+0(4) TO yy.
MOVE e_date+4(2) TO mm.
MOVE e_date+6(2) TO dd.
CONCATENATE mm dd yy INTO header-ext_date SEPARATED BY '/'.
header-delimit = '~'.
APPEND header.
List allowed document types **********************
PERFORM fill_doc_types.
**To select the documents within the range of week or as inputted **
IF s_augdt IS INITIAL.
MOVE: 'I' TO s_augdt-sign,
'BT' TO s_augdt-option,
fromdate TO s_augdt-low,
todate TO s_augdt-high.
APPEND s_augdt.
ENDIF.
Selecting the records from the database ****************
IF s_bukrs IS INITIAL AND s_blart IS INITIAL.
Select all documents of company code 1000, *********
4200 and 8000, and allowed document types *********
SELECT belnr gjahr augdt augbl bukrs
blart bldat xblnr lifnr wrbtr shkzg
FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
FOR ALL ENTRIES IN i_doctype
WHERE blart EQ i_doctype-blart
AND augdt IN s_augdt
AND ( bukrs = '1000' OR bukrs ='4200' OR
( bukrs = '8000' AND blart NE 'ZP' ) ).
loop at i_data.
Exclude reversed documents
select single stblg into ws_stblg
from bkpf
where bukrs = i_data-bukrs
and gjahr = i_data-gjahr
and belnr = i_data-belnr.
if not ws_stblg is initial.
delete i_data.
endif.
endloop.
ELSEIF s_blart IS INITIAL.
Select all documents of allowed document types ******
and inputted company code ************
SELECT belnr gjahr augdt augbl bukrs
blart bldat xblnr lifnr wrbtr shkzg
FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
FOR ALL ENTRIES IN i_doctype
WHERE blart EQ i_doctype-blart
AND augdt IN s_augdt
AND bukrs IN s_bukrs .
LOOP AT i_data.
Exclude documents of type ZP
for company code 8000.
IF i_data-bukrs = '8000' AND i_data-blart = 'ZP'.
DELETE i_data.
continue.
ENDIF.
Exclude reversed documents
select single stblg into ws_stblg
from bkpf
where bukrs = i_data-bukrs
and gjahr = i_data-gjahr
and belnr = i_data-belnr.
if not ws_stblg is initial.
delete i_data.
continue.
endif.
ENDLOOP.
READ TABLE i_data INDEX 1.
IF sy-subrc NE 0.
MESSAGE i999 WITH 'No records have been selected'.
EXIT.
ENDIF.
ELSE.
Select the documents matching the company codes *****
and document types inputted in the selection screen ****
SELECT belnr gjahr augdt augbl bukrs bldat xblnr
blart lifnr wrbtr shkzg
FROM bsak INTO CORRESPONDING FIELDS OF TABLE i_data
WHERE bukrs IN s_bukrs AND blart IN s_blart
AND augdt IN s_augdt.
SORT i_data BY blart.
LOOP AT i_data.
Filtering the records selected
based on the document type
READ TABLE i_doctype WITH KEY blart = i_data-blart.
IF sy-subrc NE 0.
DELETE i_data.
continue.
ENDIF.
Exclude documents of type ZP
for company code 8000.
IF i_data-bukrs = '8000' AND i_data-blart = 'ZP'.
DELETE i_data.
continue.
ENDIF.
Exclude reversed documents.
select single stblg into ws_stblg
from bkpf
where bukrs = i_data-bukrs
and gjahr = i_data-gjahr
and belnr = i_data-belnr.
if not ws_stblg is initial.
delete i_data.
continue.
endif.
ENDLOOP.
READ TABLE i_data INDEX 1.
IF sy-subrc NE 0.
MESSAGE i999 WITH 'No records have been selected'.
EXIT.
ENDIF.
ENDIF.
IF sy-subrc NE 0.
MESSAGE i999 WITH 'No records have been selected'.
EXIT.
ENDIF.
credit/debit identification ***********************
LOOP AT i_data.
IF i_data-shkzg EQ 'H'.
i_data-wrbtr = i_data-wrbtr * 1.
ELSEIF i_data-shkzg EQ 'S'.
i_data-wrbtr = i_data-wrbtr * -1.
ENDIF.
MODIFY i_data.
ENDLOOP.
for summarizing ******************************
LOOP AT i_data.
MOVE-CORRESPONDING i_data TO i_data1.
COLLECT i_data1.
ENDLOOP.
Vendor informations and Check Informations *****************
SELECT lifnr name1 sortl
FROM lfa1
APPENDING CORRESPONDING FIELDS OF TABLE i_lfa1
FOR ALL ENTRIES IN i_data1
WHERE lifnr = i_data1-lifnr.
SELECT chect vblnr gjahr zbukr FROM payr APPENDING CORRESPONDING
FIELDS OF TABLE i_payr FOR ALL ENTRIES
IN i_data1 WHERE vblnr = i_data1-augbl
AND gjahr = i_data1-augdt(4)
AND zbukr = i_data1-bukrs.
SORT i_data1 BY augbl gjahr bukrs lifnr.
SORT i_payr BY vblnr gjahr zbukr.
SORT i_lfa1 BY lifnr.
LOOP AT i_data1.
READ TABLE i_payr WITH KEY vblnr = i_data1-augbl
gjahr = i_data1-gjahr
zbukr = i_data1-bukrs.
IF sy-subrc EQ 0.
i_data1-chect = i_payr-chect.
ENDIF.
READ TABLE i_lfa1 WITH KEY lifnr = i_data1-lifnr.
IF sy-subrc EQ 0.
i_data1-name1 = i_lfa1-name1.
i_data1-sortl = i_lfa1-sortl.
ENDIF.
i_data1-status = 'X'.
MODIFY i_data1.
ENDLOOP.
**The records are sorted by clearing date, check number and doc type**
SORT i_data1 BY augdt chect blart.
**********The header record is outputted on the screen****************
PERFORM write_header.
********Data is moved to internal table in the file format *************
PERFORM move_data.
Line items are outputted on the screen *********************
PERFORM write_output.
*& Form write_header &*
*& This outputs the header information to screen &*
FORM write_header.
SKIP.
SET PF-STATUS 'LIST'.
Outputting the header information *********************
WRITE : / 'Extraction Date : ' , header-ext_date.
WRITE : / 'Extraction Time : ' , header-ext_time.
FORMAT COLOR 1." INTENSIFIED.
SKIP.
ULINE AT 0(190) NO-GAP.
Outputting line level information **********************
WRITE:/ sy-vline NO-GAP,
(10) 'DOC NUMBER',
sy-vline NO-GAP,
(4) 'F-YR',
sy-vline NO-GAP,
(6) 'C-CODE',
sy-vline NO-GAP,
(10) 'CHECK NUM',
sy-vline NO-GAP,
(10) 'VENDOR NUM',
sy-vline NO-GAP,
(35) 'VENDOR NAME',
sy-vline NO-GAP,
(12) 'INVOICE DATE',
sy-vline NO-GAP,
(16) 'INVOICE NUMBER',
sy-vline NO-GAP,
(12) 'PAID DATE',
sy-vline NO-GAP,
(15) 'INVOICE AMOUNT',
sy-vline NO-GAP,
(2) 'SC',
sy-vline NO-GAP,
(16) 'REFERENCE FI DOC',
sy-vline NO-GAP,
(15) 'SORT FIELD',
sy-vline NO-GAP.
ULINE AT 0(190) NO-GAP.
ENDFORM. " write_header
*& FORM MOVE_DATA &*
*& Formats data in internal table as is required in the file &*
FORM move_data.
LOOP AT i_data1.
Document number and fiscal year should be separted by '|' *****
CONCATENATE i_data1-belnr i_data1-gjahr INTO fidoc_year
SEPARATED BY '|'.
MOVE i_data1-bukrs TO comp_code.
MOVE i_data1-chect TO check_numbr.
Vendor number and vendor name should be separted by '|' *****
CONCATENATE i_data1-lifnr i_data1-name1 INTO vendor
SEPARATED BY '|'.
SHIFT vendor LEFT DELETING LEADING '0'.
SHIFT vendor RIGHT DELETING TRAILING space.
Date fields converted to MM/DD/YYYY format ****************
MOVE i_data1-bldat+0(4) TO yy.
MOVE i_data1-bldat+4(2) TO mm.
MOVE i_data1-bldat+6(2) TO dd.
CONCATENATE mm dd yy INTO inv_date SEPARATED BY '/'.
MOVE i_data1-xblnr TO inv_nbr.
SHIFT inv_nbr RIGHT DELETING TRAILING space.
MOVE i_data1-augdt+0(4) TO yy.
MOVE i_data1-augdt+4(2) TO mm.
MOVE i_data1-augdt+6(2) TO dd.
CONCATENATE mm dd yy INTO paid_dat SEPARATED BY '/'.
MOVE i_data1-wrbtr TO inv_amt.
CONDENSE inv_amt.
SHIFT inv_amt RIGHT DELETING TRAILING space.
MOVE i_data1-status TO status.
MOVE i_data1-augbl TO ref_doc.
CONCATENATE fidoc_year
comp_code
check_numbr
vendor
inv_date
inv_nbr
paid_dat
inv_amt
status
ref_doc
INTO i_final_file-record SEPARATED BY '~'.
APPEND i_final_file.
ENDLOOP.
ENDFORM. " MOVE_DATA
*& Form write_output &*
*& Outputs all data to screen &*
FORM write_output.
LOOP AT i_data1.
FORMAT COLOR 2 INTENSIFIED.
Outputting line level information *******************
WRITE : / sy-vline NO-GAP,
(10) i_data1-belnr,
sy-vline NO-GAP,
(4) i_data1-gjahr,
sy-vline NO-GAP,
(6) i_data1-bukrs,
sy-vline NO-GAP,
(10) i_data1-chect,
sy-vline NO-GAP,
(10) i_data1-lifnr,
sy-vline NO-GAP,
(35) i_data1-name1,
sy-vline NO-GAP,
(12) i_data1-bldat MM/DD/YYYY,
sy-vline NO-GAP,
(16) i_data1-xblnr,
sy-vline NO-GAP,
(12) i_data1-augdt MM/DD/YYYY,
sy-vline NO-GAP,
(15) i_data1-wrbtr,
sy-vline NO-GAP,
(2) i_data1-status,
sy-vline NO-GAP,
(16) i_data1-augbl,
sy-vline NO-GAP,
(15) i_data1-sortl,
sy-vline NO-GAP.
ENDLOOP.
ULINE AT 0(190) NO-GAP.
ENDFORM. " write_output
In the program, I am downloading only the list.. The description of report outputted in the beginning of the report is not downloaded to excel.
What has to be taken into consideration is that, the structure of the table i_data1 which contains the data to be downloaded to the table.
I hope that this will help you.
Regards,
Susmitha -
How to Convert Report into Excel Sheet when Sending Mail.
Dear Friends,
i want to send mail to HOD of Product with an Excel Sheet .
i want to send Pending Issue details to HOD in Excel Sheet attachment .
here i have pending issue report now i need to send it in Excel Sheet attachment .
i have table where i have manage Product ID and HOD OF PRODUCT.
CREATE TABLE "MAP_USER_PRODUCT_DTL"
( "ID" NUMBER NOT NULL ENABLE,
"PRODUCT_ID"NUMBER,
"USER_ID" VARCHAR2(5) NOT NULL ENABLE,
"HOD_PROD" VARCHAR2(100)========================================Value is Y OR N IF HOD then Y else N
CONSTRAINT "MAP_USER_PRODUCT_DTL_PK" PRIMARY KEY ("ID") ENABLE
/i have one more table where all complete issue detail insert.
CREATE TABLE "CRM_ISSUE_PROBLEM"
( "ID" NUMBER,
"SUBJECT" VARCHAR2(255) NOT NULL ENABLE,
"CLIENT_ID" NUMBER,
"ASSIGNED_TO_ID" VARCHAR2(100),
"ASSIGNED_ON" DATE,
"DESCRIPTION" VARCHAR2(4000),
"PRODUCT_ID" NUMBER NOT NULL ENABLE,
"STATUS_ID" NUMBER NOT NULL ENABLE,
CONSTRAINT "CRM_ISSUE_PROBLEM_PK" PRIMARY KEY ("ID") ENABLE
Here STATUS_ID is Like Pending ISsue,Open Issue and Close Issue .i want to send mail to HOD with Pending Issue Report convert into Excel Sheet and send to HOD?
How can i do this.
Thanks
Edited by: Vedant on Oct 12, 2011 12:36 AM
Edited by: Vedant on Oct 12, 2011 2:22 AMHello Vedant,
Would it suffice if you send a CSV file?
If yes, then see following code.. run the code under APEX > Home > SQL Workshop > SQL Commands
DECLARE
ln_id NUMBER;
lc_clob CLOB;
lb_blob BLOB;
li_in PLS_INTEGER := 1;
li_out PLS_INTEGER := 1;
li_lang PLS_INTEGER := 0;
li_warning PLS_INTEGER := 0;
lv_mail_rcpts VARCHAR2(2000) := '[email protected]';
lv_mail_from VARCHAR2(100) := '[email protected]';
lv_clmn_separator VARCHAR2(1) := ',';
BEGIN
-- Build file content as CLOB
-- Replace with your query
FOR i IN (select object_id A, object_name B, object_type C, status D, temporary E, generated F, secondary G,namespace H from user_objects where rownum < 10)
LOOP
IF lc_clob IS NULL THEN
lc_clob := i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
ELSE
lc_clob := lc_clob||CHR(10)||i.A||lv_clmn_separator||i.B||lv_clmn_separator||i.C||lv_clmn_separator||i.D||lv_clmn_separator||i.E||lv_clmn_separator||i.F||lv_clmn_separator||i.G||lv_clmn_separator||i.H;
END IF;
END LOOP;
-- Convert CLOB to BLOB
DBMS_LOB.CREATETEMPORARY(lb_blob,TRUE);
DBMS_LOB.convertToBlob(lb_blob,lc_clob,DBMS_LOB.LOBMAXSIZE,li_in,li_out,DBMS_LOB.DEFAULT_CSID,li_lang,li_warning);
-- Send mail
ln_id:= APEX_MAIL.SEND(
p_to => lv_mail_rcpts,
p_from => lv_mail_from,
p_subj => 'Subject Goes here',
p_body => 'Body goes here'
-- add CSV file as attachment
APEX_MAIL.ADD_ATTACHMENT
p_mail_id => ln_id,
p_attachment => lb_blob,
p_filename => 'filename.csv',
p_mime_type => 'application/csv'
-- push mail queue
APEX_MAIL.PUSH_QUEUE;
-- empty temporary space
DBMS_LOB.FREETEMPORARY ( lob_loc => lb_blob);
COMMIT;
END;Regards,
Hari -
Export SQL Server Table into Multiple Sheets in Excel
I'm trying to understand the example here.
http://visakhm.blogspot.in/2013/09/exporting-sqlserver-data-to-multiple.html
Basically, I'm up to step #5.
5. Data Flow Task to populate the created sheet with data for that subject. The Data Flow looks like below
I don't understand this part. Has anyone worked with this sample before? Has anyone gotten this to work? I'm trying to learn SSIS better, but I'm finding it hard to get started with this stuff. I guess if I get a couple projects under
my belt, I'll be fine. The hardest part is getting started.
If anyone feels really ambitions today, maybe you can assist me with two other projects as well.
#1)
http://visakhm.blogspot.in/2011/12/simulating-file-watcher-task-in-ssis.html
#2)
http://sqlage.blogspot.in/2013/12/ssis-read-multiple-sheets-from-excel.html
http://beyondrelational.com/modules/24/syndicated/398/Posts/18163/ssis-how-to-loop-through-multiple-excel-sheets-and-load-them-into-a-sql-table.aspx
I'd greatly appreciate any help I can get with this.
Thanks!!
Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.Hi Ryguy72,
The solution introduced in Visakh’s blog does work. I have written the detailed steps for you:
1. Create an Excel file (Des.xls) as the destination file, rename the Sheet1 to “Excel Destination”, and add four columns: ID, Name, Subject, and Marks.
2. Create an Object type variable Subject, a String type variable SheetName, and a String type variable WorkSheetQuery.
3. Set the value of variable SheetName to “Excel Destination$”, and set the expression of variable WorkSheetQuery to:
"CREATE TABLE `" + @[User::SheetName] + "` (
`ID` Long,
`Name` LongText,
`Subject` LongText,
`Marks` Long
4. In the Execute SQL Task outside the Foreach Loop Container, set its General tab as follows:
ResultSet: Full result set
ConnectionType: OLE DB
Connection: LocalHost.TestDB (e.g. an OLE DB Connection to the source SQL Server table)
SQLSourceType: Direct input
SQLStatement: SELECT DISTINCT [Subject] FROM [TestDB].[dbo].[DynamicExcelSheetDemo]
5. In the Result Set tab of this Execute SQL Task, map result “0” to variable “User::Subject”.
6. In the Collection page of the Foreach Loop Container, set the Enumerator option to “Foreach ADO Enumerator”, and set the “ADO object source variable” to “User::Subject”.
7. In the Variable Mapping page of the container, map variable “User::SheetName” to index “0”.
8. Create an OLE DB Connection Manager to connect to the destination Excel file. Choose the provider as Native OLE DB\Microsoft Jet 4.0 OLE DB Provider, specify the fully qualified path of the Excel file (such as C:\Temp\Des.xls), and set the Extended Properties
option of the Connection Manager to “Excel 8.0”. Click “Test Connection” button to make sure the connection is established successfully.
9. Set the General page of the Execute SQL Task inside the container as follows:
ResultSet: None
ConnectionType: OLE DB
Connection: Des (e.g. the OLE DB Connection to the destination Excel file we create above)
SQLSourceType: Variable
SQLStatement: User::WorkSheetQuery
10. In the Data Flow Task, add an OLE DB Source component, set the connection manager to “LocalHost.TestDB”, set “Data access mode” to “SQL command”, and set the “SQL command text” to:
SELECT * FROM [TestDB].[dbo].[DynamicExcelSheetDemo] WHERE [Subject]=?
11. Click the “Parameters…” button, and map Parameter0 to variable “User::SheetName”.
12. Add an Excel Destination component, setup an Excel Connection Manager to the destination Excel file, set the data access mode to “Table name or view name variable”, and select variable name as “User::SheetName”. In this way, the OLE DB Provider can get
the Excel metadata and enable us to finish the column mappings correctly.
13. Since the Microsoft Jet 4.0 has only 32-bit driver, please make sure to set the Run64BitRuntime property of the IS project to False.
In addition, please note that there will be one useless worksheets “Excel Destination” in the Excel file. We can remove them manually or use a Script Task to delete this worksheet programmatically (need to install .NET Programmability Support feature during
Office installing).
Regards,
Mike Yin
TechNet Community Support -
Open an Excel file to read and load it into Oracle - Oracle COM Automation
Hello All,
Please I need your help for this problem:
I need to load Excel sheet data (read the data) and load it into Oracle database (insert into a table), the excel file created and has data before, and saved with xls format. and I need to do that using the Oracle® COM Automation (ordcom package). The examples I found open and create a new workbook and deletes the old saved data, so I need to open (edit) the sheet just for reading.
I appreciate ans sample code to help me do that, Please help me out. This is very urgent.
Thanks alot and best regards,
NabilFor reading from Excel, there are some easy ways like Oracle Heterogenious Services. If you want to use COM then:
My orawpcom.dll file exists in the directory C:\oracle\product\10.2.0\db_2\bin
C:\oracle\product\10.2.0\db_2\bin>dir orawpco*.dll
Volume in drive C is C_Drive
Volume Serial Number is 8A93-1441
Directory of C:\oracle\product\10.2.0\db_2\bin
03/20/2006 05:06 PM 61,440 orawpcom.dll
10/11/2006 03:20 PM 81,920 orawpcom10.dll
2 File(s) 143,360 bytes
0 Dir(s) 65,407,717,376 bytes free
C:\oracle\product\10.2.0\db_2\bin>Information about my database version.
SQL> /* My databaser version */
SQL> SELECT * FROM v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
SQL> Preparing the user SCOTT for COM automation.
Now, I will run comwrap.sql from scott user. I have edited the comwrap.sql to adjust my library path here:
create library utils_lib as 'C:\oracle\product\10.2.0\db_3\bin\orawpcom.dll';Running comwrap.sql and ExcelSolution.sql .....
SQL> conn scott@orclsb
Enter password: *****
Connected.
SQL> @c:\comwrap.sql
drop library utils_lib
ERROR at line 1:
ORA-04043: object UTILS_LIB does not exist
Library created.
drop package ORDCOM
ERROR at line 1:
ORA-04043: object ORDCOM does not exist
drop TYPE OAArgTable
ERROR at line 1:
ORA-04043: object OAARGTABLE does not exist
Type created.
drop TYPE OAArgTypeTable
ERROR at line 1:
ORA-04043: object OAARGTYPETABLE does not exist
Type created.
drop function OAgetNumber
ERROR at line 1:
ORA-04043: object OAGETNUMBER does not exist
Function created.
drop function OAgetStr
ERROR at line 1:
ORA-04043: object OAGETSTR does not exist
Function created.
drop function OAgetBool
ERROR at line 1:
ORA-04043: object OAGETBOOL does not exist
Function created.
drop function OAsetNumber
ERROR at line 1:
ORA-04043: object OASETNUMBER does not exist
Function created.
drop function OAsetString
ERROR at line 1:
ORA-04043: object OASETSTRING does not exist
Function created.
drop function OAsetBoolean
ERROR at line 1:
ORA-04043: object OASETBOOLEAN does not exist
Function created.
drop function OAInvokeDouble
ERROR at line 1:
ORA-04043: object OAINVOKEDOUBLE does not exist
Function created.
drop function OAInvokeBoolean
ERROR at line 1:
ORA-04043: object OAINVOKEBOOLEAN does not exist
Function created.
drop function OAInvokeString
ERROR at line 1:
ORA-04043: object OAINVOKESTRING does not exist
Function created.
drop function OACreate
ERROR at line 1:
ORA-04043: object OACREATE does not exist
Function created.
drop function OADestroy
ERROR at line 1:
ORA-04043: object OADESTROY does not exist
Function created.
drop function OAGetLastError
ERROR at line 1:
ORA-04043: object OAGETLASTERROR does not exist
Function created.
drop function OAQueryMethods
ERROR at line 1:
ORA-04043: object OAQUERYMETHODS does not exist
Function created.
Package created.
Package body created.
SQL>
SQL> @c:\ExcelSolution.sql
drop package ORDExcel
ERROR at line 1:
ORA-04043: object ORDEXCEL does not exist
Package created.
Package body created.
SQL>
I have modified ORDExcel a little bit and renamed it as ORDExcelSB. You need this version for reading the excel.
SQL> @C:\ExcelSolutionSB.sql
Package dropped.
Package created.
Package body created.
SQL> The actual code of ORDExcelSB (ExcelSolutionSB.sql) Is:
set serveroutput on;
drop package ORDExcelSB;
CREATE PACKAGE ORDExcelSB AS
/* Declare externally callable subprograms. */
FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer;
FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2) RETURN binary_integer;
FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer;
FUNCTION InsertData(range varchar2, data binary_integer, type varchar2) return binary_integer;
FUNCTION InsertDataReal(range varchar2, data double precision, type varchar2) return binary_integer;
FUNCTION GetDataNum(range varchar2) return binary_integer;
FUNCTION GetDataStr(range varchar2) return varchar2;
FUNCTION GetDataReal(range varchar2) return double precision;
FUNCTION GetDataDate(range varchar2) return date;
FUNCTION InsertData(range varchar2, data varchar2, type varchar2) return binary_integer;
FUNCTION InsertData(range varchar2, data Date, type varchar2) return binary_integer;
FUNCTION InsertChart(xpos binary_integer, ypos binary_integer, width binary_integer,
height binary_integer, range varchar2, type varchar2) return binary_integer;
FUNCTION SaveExcelFile(filename varchar2) return binary_integer;
FUNCTION ExitExcel return binary_integer;
END ORDExcelSB;
CREATE PACKAGE BODY ORDExcelSB AS
DummyToken binary_integer;
applicationToken binary_integer:=-1;
WorkBooksToken binary_integer:=-1;
WorkBookToken binary_integer:=-1;
WorkSheetToken binary_integer:=-1;
WorkSheetToken1 binary_integer:=-1;
RangeToken binary_integer:=-1;
ChartObjectToken binary_integer:=-1;
ChartObject1 binary_integer:=-1;
Chart1Token binary_integer:=-1;
i binary_integer;
retNum binary_integer;
retReal double precision;
retStr varchar2(255);
retDate DATE;
error_src varchar2(255);
error_description varchar2(255);
error_helpfile varchar2(255);
error_helpID binary_integer;
FUNCTION CreateExcelApplication(servername VARCHAR2) RETURN binary_integer IS
BEGIN
dbms_output.put_line('Creating Excel application...');
i := OrdCOM.CreateObject('Excel.Application',
0,
servername,
applicationToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Workbooks...');
i := ORDCOM.GetProperty(applicationToken,
'WorkBooks',
0,
WorkBooksToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
RETURN i;
END CreateExcelApplication;
FUNCTION OpenExcelFile(filename VARCHAR2, sheetname VARCHAR2)
RETURN binary_integer IS
BEGIN
dbms_output.put_line('Opening Excel file ' || filename || ' ...');
ORDCOM.InitArg();
ORDCOM.SetArg(filename, 'BSTR');
i := ORDCOM.Invoke(WorkBooksToken, 'Open', 1, DummyToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Opening WorkBook');
i := ORDCOM.GetProperty(applicationToken,
'ActiveWorkbook',
0,
WorkBookToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheets..');
i := ORDCOM.GetProperty(applicationToken,
'WorkSheets',
0,
WorkSheetToken1);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheet');
ORDCOM.InitArg();
ORDCOM.SetArg(sheetname, 'BSTR');
i := ORDCOM.GetProperty(WorkBookToken, 'Sheets', 1, WorkSheetToken);
IF (i != 0) THEN
ORDCOM.GetLastError(error_src,
error_description,
error_helpfile,
error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Opened ');
RETURN i;
END OpenExcelFile;
* Invoke the Excel Automation Server and create a Workbook object as
* well as a worksheet object
FUNCTION CreateExcelWorkSheet(servername varchar2) return binary_integer IS
BEGIN
dbms_output.put_line('Creating Excel application...');
i:=ORDCOM.CreateObject('Excel.Application', 0, servername,applicationToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Workbooks...');
/*i:=ORDCOM.Invoke(applicationToken, 'WorkBooks',0, WorkBooksToken);*/
i:=ORDCOM.GetProperty(applicationToken, 'WorkBooks', 0, WorkBooksToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking Add to WorkBooks...');
ORDCOM.InitArg();
ORDCOM.SetArg(-4167,'I4');
i:=ORDCOM.Invoke(WorkBooksToken, 'Add', 1, WorkBookToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
dbms_output.put_line('Invoking WorkSheets..');
ORDCOM.InitArg();
ORDCOM.SetArg('Sheet 1','BSTR');
/* i:=ORDCOM.Invoke(applicationToken, 'WorkSheets', 1, WorkSheetToken);*/
i:=ORDCOM.GetProperty(applicationToken, 'WorkSheets', 0, WorkSheetToken1);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.Invoke(WorkSheetToken1, 'Add', 0, WorkSheetToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
return i;
END CreateExcelWorkSheet;
* Invoke the Range method to obtain a range token. Then set the property value
* at the specified range to the data required
FUNCTION InsertData( range varchar2,
data binary_integer,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
IF (i=0) THEN
i:=ORDCOM.SetProperty(RangeToken, 'ColumnWidth', 15, 'I2');
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
* Invoke the Range method to obtain a range token. Then set the property value
* at the specified range to the data required
FUNCTION GetDataNum( range varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retNum);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retNum;
END GetDataNum;
FUNCTION GetDataReal( range varchar2)
RETURN double precision IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retReal);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retReal;
END GetDataReal;
FUNCTION GetDataStr( range varchar2)
RETURN varchar2 IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retStr);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retStr;
END GetDataStr;
FUNCTION GetDataDate( range varchar2)
RETURN Date IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(RangeToken, 'Value', 0, retDate);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(RangeToken);
RETURN retDate;
END GetDataDate;
FUNCTION InsertData( range varchar2,
data DATE,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
FUNCTION InsertDataReal( range varchar2,
data double precision,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertDataReal;
FUNCTION InsertData( range varchar2,
data varchar2,
type varchar2)
RETURN binary_integer IS
BEGIN
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken, 'Range', 1, RangeToken);
i:=ORDCOM.SetProperty(RangeToken, 'Value', data, type);
i:=ORDCOM.DestroyObject(RangeToken);
RETURN i;
END InsertData;
* Insert a chart at the x and y position of the spreadsheet with the desired
* height and width. Then also uses the ChartWizard to draw the graph with data
* in a specified range area with a specified charting type.
FUNCTION InsertChart(xpos binary_integer, ypos binary_integer,
width binary_integer, height binary_integer,
range varchar2, type varchar2) RETURN binary_integer IS
charttype binary_integer:= -4099;
BEGIN
ORDCOM.InitArg();
i:=ORDCOM.GetProperty(WorkSheetToken, 'ChartObjects', 0, ChartObjectToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
ORDCOM.InitArg();
ORDCOM.SetArg(xpos,'I2');
ORDCOM.SetArg(ypos,'I2');
ORDCOM.SetArg(width,'I2');
ORDCOM.SetArg(height,'I2');
i:=ORDCOM.Invoke(ChartObjectToken, 'Add', 4, ChartObject1);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.GetProperty(ChartObject1, 'Chart', 0,Chart1Token);
ORDCOM.InitArg();
ORDCOM.SetArg(range, 'BSTR');
i:=ORDCOM.GetProperty(WorkSheetToken,'Range', 1, RangeToken);
ORDCOM.InitArg();
ORDCOM.SetArg(RangeToken, 'DISPATCH');
IF type='xlPie' THEN
charttype := -4102;
ELSIF type='xl3DBar' THEN
charttype := -4099;
ELSIF type='xlBar' THEN
charttype := 2;
ELSIF type='xl3dLine' THEN
charttype:= -4101;
END IF;
ORDCOM.SetArg(charttype,'I4');
i:=ORDCOM.Invoke(Chart1Token,'ChartWizard', 2, DummyToken);
i:=ORDCOM.DestroyObject(RangeToken);
i:=ORDCOM.DestroyObject(ChartObjectToken);
i:=ORDCOM.DestroyObject(ChartObject1);
i:=ORDCOM.DestroyObject(Chart1Token);
RETURN i;
END InsertChart;
* Save the Excel File. WARNING: Do not specify a filename that already exist
* since there is no graphical context, Oracle would not be able to pop
* out a warning message for existing file. This causes Excel to hang
FUNCTION SaveExcelFile(filename varchar2) return binary_integer IS
BEGIN
dbms_output.put_line('Saving Excel file...');
ORDCOM.InitArg();
ORDCOM.SetArg(filename,'BSTR');
i:=ORDCOM.Invoke(WorkBookToken, 'SaveAs', 1, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
RETURN i;
END SaveExcelFile;
* Close the Excel spreadsheet and exit from it
FUNCTION ExitExcel return binary_integer is
BEGIN
dbms_output.put_line('Closing workbook and quitting...');
ORDCOM.InitArg();
ORDCOM.InitArg();
ORDCOM.SetArg(FALSE,'BOOL');
dbms_output.put_line('Closing workbook...');
i:=ORDCOM.Invoke(WorkBookToken, 'Close', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkBookToken);
ORDCOM.InitArg();
dbms_output.put_line('Closing workbooks...');
i:=ORDCOM.Invoke(WorkBooksToken, 'Close', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkBooksToken);
i:=ORDCOM.Invoke(applicationToken, 'Quit', 0, DummyToken);
IF (i!=0) THEN
ORDCOM.GetLastError(error_src, error_description, error_helpfile, error_helpID);
dbms_output.put_line(error_src);
dbms_output.put_line(error_description);
dbms_output.put_line(error_helpfile);
END IF;
i:=ORDCOM.DestroyObject(WorkSheetToken);
i:=ORDCOM.DestroyObject(WorkSheetToken1);
i:=ORDCOM.DestroyObject(applicationToken);
i:=ORDCOM.DestroyObject(ChartObjectToken);
i:=ORDCOM.DestroyObject(Chart1Token);
i:=ORDCOM.DestroyObject(ChartObject1);
i:=ORDCOM.DestroyObject(dummyToken);
RETURN i;
END ExitExcel;
END ORDExcelSB;
/I have created an excel named as C:\Example.xls.
Name SlNo Job Dept Salary Bonus
Saubhik Banerjee 706090 IT Specialist GBS 100 10
Partha S Mohanty 706091 Pogrmmer APPS 70 20
Partha Sarkar 889300 Condultant FIN 200 30
Useless 98009 PM PM 900 90
SQL> SET SERVEROUT ON
SQL> DECLARE
2
3 v_Name varchar2(90);
4 v_SlNo varchar2(100);
5 v_Job varchar2(200);
6 v_Dept varchar2(100);
7 v_recon_remark varchar2(50);
8 v_sal_amt_usd number;
9 v_Bonus_amt_usd number;
10
11 result INTEGER;
12
13 i binary_integer;
14 filename varchar2(255);
15
16 BEGIN
17
18 filename := 'C:\Example.xls';
19
20 result := ORDExcelSB.CreateExcelApplication('');
21 result := ORDExcelSB.OpenExcelFile(filename, 'Sheet1');
22
23 /* Excluding the header row and reading the first 5 row */
24 FOR n in 2 .. 5 LOOP
25
26 v_Name := ORDExcelSB.GetDataStr('A' || n);
27 v_SlNo := ORDExcelSB.GetDataReal('B' || n);
28 v_Job := ORDExcelSB.GetDataStr('C' || n);
29 v_Dept := ORDExcelSB.GetDataStr('D' || n);
30 v_sal_amt_usd := ORDExcelSB.GetDataNum('E' || n);
31 v_Bonus_amt_usd := ORDExcelSB.GetDataNum('F' || n);
32
33 dbms_output.put_line(v_Name || ' ' || v_SlNo || ' ' || v_Job || ' ' ||
34 v_Dept || ' ' || v_sal_amt_usd || ' ' ||
35 v_Bonus_amt_usd);
36
37 END LOOP;
38
39 result := ORDExcelSB.ExitExcel();
40 EXCEPTION
41 WHEN OTHERS THEN
42 result := ORDExcelSB.ExitExcel();
43 RAISE;
44 END;
45 /
Creating Excel application...
Invoking Workbooks...
Opening Excel file C:\Example.xls ...
Opening WorkBook
Invoking WorkSheets..
Invoking WorkSheet
Opened
Saubhik Banerjee 706090 IT Specialist GBS 100 10
Partha S Mohanty 706091 Pogrmmer APPS 70 20
Partha Sarkar 889300 Condultant FIN 200 30
Useless 98009 PM PM 900 90
Closing workbook and quitting...
Closing workbook...
Closing workbooks...
PL/SQL procedure successfully completed.
SQL> Although, You haven't asked, but you can use this code to write to excel file (.xls)
DECLARE
CURSOR c1 IS
SELECT empno, ename, dname, sal, hiredate
FROM emp e, dept d
WHERE e.deptno = d.deptno;
error_message varchar2(1200);
n binary_integer:=2;
i binary_integer;
filename varchar2(255);
cellIndex varchar2(40);
cellValue varchar2(40);
cellColumn varchar2(10);
returnedTime varchar2(20);
currencyvalue double precision;
datevalue DATE;
empno binary_integer;
looptext varchar2(20);
error_src varchar2(255);
error_description varchar2(255);
error_helpfile varchar2(255);
error_helpID binary_integer;
begin
filename:='c:\example2.xls';
i:=ORDExcel.CreateExcelWorkSheet('');
i:=ORDExcel.InsertData('A1', 'EmpNo', 'BSTR');
i:=ORDExcel.InsertData('B1', 'Name', 'BSTR');
i:=ORDExcel.InsertData('C1', 'Dept', 'BSTR');
i:=ORDExcel.InsertData('D1', 'Salary', 'BSTR');
i:=ORDExcel.InsertData('E1', 'HireDate', 'BSTR');
For c1_rec IN c1 LOOP
cellColumn:=TO_CHAR(n);
cellIndex:=CONCAT('A',cellColumn);
cellValue:=TO_CHAR(c1_rec.empno);
empno:=cellValue;
i:=ORDExcel.InsertData(cellIndex, empno, 'I2');
cellIndex:=CONCAT('B',cellColumn);
cellValue:=c1_rec.ename;
i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
cellIndex:=CONCAT('C',cellColumn);
cellValue:=c1_rec.dname;
i:=ORDExcel.InsertData(cellIndex, cellValue, 'BSTR');
cellIndex:=CONCAT('D',cellColumn);
cellValue:=c1_rec.sal;
currencyValue:=cellValue;
i:=ORDExcel.InsertData(cellIndex, currencyValue, 'CY');
cellIndex:=CONCAT('E',cellColumn);
dateValue:=c1_rec.hiredate;
i:=ORDExcel.InsertData(cellIndex, dateValue, 'DATE');
n:=n+1;
END LOOP;
i:=ORDExcel.SaveExcelFile(filename);
i:=ORDExcel.ExitExcel();
EXCEPTION
WHEN OTHERS THEN
i:=ORDExcel.ExitExcel();
RAISE;
END; -
Hey !
I finished creating a repository using Oracle BI administration tool .
How to load this into BI server so that it is available in the subject area of the Dash board answers ?????The OBE for [Creating a Repository Using the Oracle Business Intelligence Administration Tool|http://www.oracle.com/technology/obe/obe_bi/bi_ee_1013/bi_admin/biadmin.html#t4] contains this:
- Run a Consistency Check
- Enable Query Logging
- Modify NQSConfig.ini
- Start Oracle BI Services
- Use Oracle BI Answers to Execute Queries
- Use Query Log to Verify Queries
Check the links for the details.
Cheers,
C.
Maybe you are looking for
-
Hi Experts, I have a scenario wherein,a General project is created followed by sub folders containing .hbdprocedures,.hdbtables,schemas etc. I had created a similar folder inside the project which was blank but later deleted it .After that activated
-
Screen Exit in Transaction LM50
Hi Experts, I created a screen exit for transaction LM50 (Count Inventory By System Guided). I created the subscreen SAPLXLRF 7152 because i need to add a field, this screen replace screen 2152. In transaction CMOD i created and activated a new proje
-
HI freinds I Have to create Dynamic actions when ever employee location has been changed suppose in infotype 0001 if employee location changed i need to update a record in IT0588 Subtype As '0003' and PTXEL = 1. Pls help me with the above requirement
-
IBook Doesn't "Feel" Like A Book
So played around with iBooks Author for the last few hours and I've come to the conclusion the iBook doesn't feel like a book. Where is the standard book "layout"?? You get a page of text and when you get to the bottom you "turn/flip" the page? I re
-
Cannot edit or view site in iWeb.
When I open iWeb, nothing opens. The icon appears in the dock, but nothing opens. Any ideas? Most of the menu options are also unavailable.