ADF Report output from PL\SQL Table
Hi,
I am some complex calcualtions in the report and the report has a fixed number of columns and reports. Is there any way i can do all the programming in pl\sql and call this procedure/package from ADF and return the pl\sql table type?
Can i create a VO from pl\sql table?
Thanks,
Lakshmi.
On Database
create or replace type empRow as object (
Employee_ID Number,
First_Name Varchar2(20),
Last_name Varchar2(25)
create or replace type empTable as table of empRow;
create or replace function getEmployees
(aDepartmentID Number)
return empTable
PIPELINED
as
begin
for rec in (select Employee_ID, First_Name, Last_name
from employees
where Department_ID = aDepartmentID) loop
pipe row(new empRow(rec.Employee_ID, rec.First_Name, rec.Last_name));
end loop;
return;
end;
THEN create a VO based on this Query below:
select * from table(getEmployees(:deptid)
and you are ready to Go.
Similar Messages
-
Thanks for answer to my first question. Now I have another problem.
Is there any way to print a report based on virtual table, which is created during some Pl/SQL procedure and can't be easily decribed by Select statementSELECT FROM PL/SQL TABLE IN ORACLE REPORTS 6I
The requirement is to populate a table and then select from that table in a report. The typical solution is to
populate a database table, but for situations where that is undesirable there is a way to select from a PL/SQL
table.
For example - for each employee we want to populate a PL/SQL table and then select from that table.
I used the following records in the emp table:
INSERT INTO Emp VALUES(123,'Bob','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(321,'Sue','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(234,'Mary','Account',555,'14-AUG-82',33000,12,20);
INSERT INTO Emp VALUES(623,'Joe','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(621,'Jim','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(634,'Jane','Account',555,'14-AUG-82',33000,12,20);
INSERT INTO Emp VALUES(723,'Fred','Sales',555,'28-JAN-79',35000,12,30);
INSERT INTO Emp VALUES(721,'Meg','Finance',555,'12-MAY-83',42000,12,10);
INSERT INTO Emp VALUES(734,'Jill','Account',555,'14-AUG-82',33000,12,20);
=============================================================================================
Step 1: Create a package spec in the report:
PACKAGE pkg_table IS
TYPE t_rec IS RECORD (
field1 NUMBER(6),
field2 VARCHAR2(30));
TYPE t_tab IS TABLE OF t_rec INDEX BY BINARY_INTEGER;
gv_tab t_tab;
FUNCTION populate (
p_empno NUMBER) RETURN NUMBER;
END;
Step 2: Create the package body:
PACKAGE BODY pkg_table IS
FUNCTION populate (
p_empno NUMBER) RETURN NUMBER IS
BEGIN
gv_tab.DELETE;
-- populate table as required - for demo purposes put in anything
FOR lv_ind IN 1..MOD(p_empno,20) LOOP
gv_tab(lv_ind).field1 := lv_ind;
gv_tab(lv_ind).field2 := 'row '||TO_CHAR(lv_ind)||' for emp '||TO_CHAR(p_empno);
END LOOP;
RETURN gv_tab.COUNT;
END populate;
END;
Step 3: Create the master query:
SELECT empno,
ename
FROM emp
Step 4: Add a formula column CF_populate to the master query that does:
function CF_populateFormula return Number is
-- for each emp fetched this formula will repopulate the PL/SQL table
-- and return the number of records in the table
begin
return pkg_table.populate(:empno);
end;
Step 5: Create the detail query:
-- we need to join this to the master and then ensure that for each
-- empno there are as many records fetched as there will be
-- records in the PL/SQL table
SELECT e1.empno,rownum
FROM emp e1, emp e2, emp e3
WHERE rownum <= :CF_populate
Step 6: Add formula columns to the detail query for each of the fields in the
PL/SQL table we want to display:
CF_Field1:
function CF_field1Formula return Number is
begin
return pkg_table.gv_tab(:rownum).field1;
end;
CF_Field2:
function CF_field2Formula return Varchar2 is
begin
return pkg_table.gv_tab(:rownum).field2;
end;
Step 7: Create the repeating frame and layout items to display the formula columns.
=============================================================================================
The same technique can be used to populate a master query. In a report level formula column
CF_Populate populate the PL/SQL table as required. In the master query we just need the rownum:
SELECT rownum
FROM emp, emp, emp
WHERE rownum <= :CF_Populate
Add the formula columns to display Field1 and Field2.
=============================================================================================
Hugh Nelson
26/04/2005 -
Can I use Reports Server Queue PL/SQL Table API to retrieve past jobs ?
Hi all,
Can I use Reports Server Queue PL/SQL Table API to retrieve past jobs using WEB.SHOW_DOCUMENT from Forms ?
I have reviewed note 72531.1 about using this feature and wonder if i can use this metadata to retrieve past jobs submitted by a user.
The idea would be to have a form module that can filter data from the rw_server_queue table, say, base on user running the form, and be able to retrieve past jobs from Report Server Queue. For this, one would query this table and use WEB.SHOW_DOCUMENT.
Is this possible ...?
Regards, Luis ...!Based on that metalink note and the code in the script rw_server.sql, I am pretty sure that by querying the table you would be able accomplish what you want... I have not tested it myself... but it looks that it will work... you have the jobid available from the queue, so you can use web.show_document to retrieve the output previously generated...
ref:
-- Constants for p_status_code and status_code in rw_server_queue table (same as zrcct_jstype)
UNKNOWN CONSTANT NUMBER(2) := 0; -- no such job
ENQUEUED CONSTANT NUMBER(2) := 1; -- job is waiting in queue
OPENING CONSTANT NUMBER(2) := 2; -- opening report
RUNNING CONSTANT NUMBER(2) := 3; -- running report
FINISHED CONSTANT NUMBER(2) := 4; -- job has finished
TERMINATED_W_ERR CONSTANT NUMBER(2) := 5; -- job has terminated with -
Reading Data from a SQL table to a Logical file on R/3 appl. Server
Hi All,
We would like to create Master Data using LSMW (direct Input) with source files from R/3 Application Server.
I have created files in the'/ tmp/' directory however I do not know how to read data from the SQL table and insert it into the logical file on the R/3 application server.
I am new to ABAP , please let me know the steps to be done to acheive this .
Regards
- AjayHi,
You can find lot of information about Datasets in SCN just SEARCH once.
You can check the code snippet for understanding
DATA:
BEGIN OF fs,
carrid TYPE s_carr_id,
connid TYPE s_conn_id,
END OF fs.
DATA:
itab LIKE
TABLE OF fs,
w_file TYPE char255 VALUE 'FILE',
w_file2 TYPE char255 VALUE 'FILE2'.
SELECT carrid connid FROM spfli INTO TABLE itab.
OPEN DATASET w_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" Server to write data
LOOP AT itab INTO fs.
TRANSFER fs TO w_file. "" Writing the data into the Application server file
ENDLOOP.
CLOSE DATASET w_file.
OPEN DATASET w_file FOR INPUT IN TEXT MODE ENCODING DEFAULT. "Opening a file in Application
" server to read data
FREE itab.
DO.
READ DATASET w_file INTO fs.
IF sy-subrc EQ 0.
APPEND fs TO itab.
OPEN DATASET w_file2 FOR APPENDING IN TEXT MODE ENCODING DEFAULT. "Appending more data to the file in the
" application server
TRANSFER fs TO w_file2.
CLOSE DATASET w_file2.
ELSE.
EXIT.
ENDIF.
ENDDO.
Regards
Sarves -
How to caputre report output into an internal table?
Hi,
Is there a way to capture report output into one internal table?
Regards,
AmruthHi Amruth,
Use SUBMIT.. EXPORTING LIST TO MEMORY.
It saves the output of a report into memory. Use the function modules LIST_FROM_MEMORY. WRITE_LIST & DISPLAY_LIST to retrieve the data.
All these function modules belongs to function group 'SLST'.
However the submit does not display hte output list of the called report, but saves it in ABAP memory & leaves the called report immediately. Since the calling program can read the list from memory & process it furthe, you need to use the addition ..AND RETURN.
Regards,
Chandru -
Discoverer report - Output from Discoverer plus is not the same as Discoverer desktop
As a part of Upgrade project we are migrating the discoverer reports from 11i (11.5.10.2) to R12 (12.1.3) .After migrating to R12, for a custom discoverer report the output given by discoverer desktop is correct (24 rows for a scenario). But the report output from Discoverer plus does not show the credit transactions (2 rows). The output from Discoverer plus shows only 22 rows (24 - 2), which is incorrect. The query is the same in Discoverer desktop and Discoverer plus.
Please let me know why these transactions that are appearing when the report is run from discoverer desktop are not appearing in discoverer plus. Is there any setup in discoverer plus for this?
Regards,
BrajeshPretty hard to answer a question like this. Best bet would be to copy the existing discoverer plus book and start removing conditions, fields, etc until those two rows from desktop show up and see if you can work it out.
-
How to retrieve the values from PL/SQL table types.
Hi Every one,
I have the following procedure:
DECLARE
TYPE t1 IS TABLE OF emp%ROWTYPE
INDEX BY BINARY_INTEGER;
t t1;
BEGIN
SELECT *
BULK COLLECT INTO t
FROM emp;
END;
This procedure works perfectly fine to store the rows of employee in a table type. I am not able to retrieve the values from Pl/SQL table and display it using dbms_output.put_line command.
Can anybody help me please!!!!!
Thanks
Ahmed.You mean, you can't add this
for i in t.first..t.last loop
dbms_output.put_line(t(i).empno||' '||t(i).ename||' '||t(i).job);
end loop;or you can't add this
set serveroutput onor maybe, you are working in third party application where dbms_output is not applicable at all?
You see, not able like very similar it is not working - both are too vague...
Best regards
Maxim -
Changing the seeded rdf report output from text to PDF
Hi All,
I am trying to change the seeded report "Print Requisition Report" output from text to PDF. I changed the output format in the concurrent program definition from text to pdf. The report is now getting displayed in pdf format, but the alignment of the fields are changed. The output is not printing as it was printing while in the text output format. The output looks very sloppy, with uneven fonts and too much of text wrapping.
I tried some formatting and fields are somehow getting displayed but doesnt look in proper format. I am not able to change the font style in the report builder 6i, even if i change it is printing in the same font style with uneven font size. I think reducing the font size might help, but i am unable to change.We are on 11.5.10.2. Please provide your valuable suggestions on how to go about.
Thanks
SarveshHi Hussein,
Thanks for the information. After the adjustments in the layout and the font change the report is now getting displayed without any clipping when clicked on view output. But when the same report is printed some characters on the left and and right side is getting clipped. Please help on how to solve this issue.
Thanks,
Sarvesh -
Hi Friends,
I am using Oracle 8.1.6 Server, & facing problems while retrieving data from a PL/SQL Table:
CREATE or REPLACE PROCEDURE test_proc IS
TYPE tP2 is TABLE of varchar2(10); --declared a collection
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST(dt2 as tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
While executing the above procedure, I encountered foll. error:
ERROR at line 1:
ORA-00600: internal error code, arguments: [15419], [severe error during PL/SQL execution], [], [],
ORA-06544: PL/SQL: internal error, arguments: [pfrrun.c:pfrbnd1()], [], [], [], [], [], [], []
ORA-06553: PLS-801: internal error [0]
Can anyone please help me, where the problem is??
Is it Possible to retrieve data from PL/SQL TABLE using SELECT statement? & How ?
Thanks in advance.
Best Regards,
Jay Raval.Thanks Roger for the Update.
It means that have to first CREATE TYPE .. TABLE in database then only I can fire a Select statement on that TYPE.
Actually I wanted to fire a Select statement on the TABLE TYPE, defined & declared in PLSQL stored procedure using DECLARE TYPE .. TABLE & not using CREATE TYPE .. TABLE.
I was eager to know this, because my organization is reluctant in using CREATE TYPE .. TABLE defined in the database, so I was looking out for another alternative to access PL/SQL TABLE using Select statement without defining it database. It would have been good if I could access a PLSQL TABLE using Select statement Declared locally in the stored procedure.
Can I summarize that to access a PL/SQL TABLE using SELECT statement, I have to first CREATE TYPE .. TABLE?
If someone have any other idea on this, please do let me know.
Thanks a lot for all help.
Best Regards,
Jay Raval.
You have to define a database type...
create type tP2 is table of varchar2(10)
CREATE OR REPLACE PROCEDURE TEST_PROC
IS
dt2 tP2 := tP2('a','b','c');
i NUMBER(8);
begin
SELECT COUNT(*) INTO i FROM TABLE(CAST (dt2 AS tP2));
DBMS_OUTPUT.PUT_LINE('**'||i);
end;
This will work.
Roger -
Scheduling Report output to a Database Table
Hi,
Scenario:
I have a RPT - loaded on the BO server (BO XI R2) - (which uses a stored procedure and a formula to populate the report) which generates the data in a tabular format.
Requirement:
I would like to insert the resultant rows generated in the report to a database.
Is there a possibility to schedule a report output to a database table?It seems that what you want to do is some kind of ETL, you should consider a right tool for doing this. For example, BusinessObjects Data Integrator. By BODI, you can directly transform the source data to what you need to the destination.
If you still need the report for presentation, rather than purely using it as a transformation tool, I suggest you do this. Implement a Java program (.NET is also possible) to implement the Program interface, so that you Java program can be added to BusinessObjects Enterprise as a program object. In this Java program, what you do is: first, schedule the report, and then open the report, read the row sets and insert them to the destination table. This process involves the Business Objects Enterprise SDK and the Report Application Server SDK.
Finally, you can in turn schedule this program objects, so that it will periodically run the report and output to the destination table. -
EM12c User Reported Event from PL/SQL
Hi,
Is there a way to create a user reported event from PL/SQL (similar to emcli publish_event) ?
ThanksCan you describe your use case? Maybe there are other ways to address the issue.
-Mughees -
Report output from memory to internal table (corresponding fields)
How can we pick any standard report output such as
RM07DOCS on to memory and from memory to an internal
table.Here by internal table ,i do not mean of type c
containing complete report but data should go from output to corresponding fields of internal table structure of whom is defined as same of the output.SUBMIT rfbila00 AND RETURN
EXPORTING LIST TO MEMORY
WITH sd_ktopl-low = ' '
WITH sd_bukrs IN s_bukrs
WITH sd_prctr IN s_prctr
WITH bilavers = p_fsv
WITH bilaspra = 'EN'
WITH bilbjahr = p_fyear
WITH b-monate IN s_per
WITH bilvjahr = v_cfyear
WITH v-monate = l_per
WITH bilagvar = P_LAYOUT
WITH bilagrid = 'X'
WITH bilabkon = '2'
WITH bilagkon = '3'
WITH bilasumm = '0'
WITH bilavart = '1'
WITH bilaskal = '3/0'.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_list
EXCEPTIONS
not_found = 1.
REFRESH t_ascii.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_ascii " list converted to ASCII
listobject = t_list
EXCEPTIONS
empty_list = 1
list_index_invalid = 2
OTHERS = 3.
u will get the output in t_list...u have to split as per ur requir......
this will help u.....
Reward IF...........
Regards
Anbu -
How to fetch the data from pl/sql table dynamically
Hi All, I have the requirement of comparing two db views data in pl/sql. So, I have bulk collect the view into pl/sql table. But, the issue is, It is expecting to provide the column name for comparison. But, in my case, column name is dynamic. So, i cannot provide the column name directly for comparison.
For eg: In my view t1_VW, i have 4 columns. stid, c1,c2,c3,c4 and similar structure for t2_vw
my code
TYPE v1_type IS TABLE OF t1_vw%ROWTYPE;
l_data v1_type;
TYPE v1_type1 IS TABLE OF t2_vw%ROWTYPE;
l_data1 v1_type1;
test varchar2(1000);
test1 varchar2(1000);
temp1 number;
begin
SELECT * Bulk collect into l_data
FROM T1_VW;
SELECT * Bulk collect into l_data1
FROM T2_VW;
select l_data(1).stid into temp1 from dual; -- It is working fine and gives me the value properly
-- But, in my case, we are reading the column names from array, i am constructing the query dynamically and execute it.
test :='select l_data(1).stid into temp1 from dual';
execute immediate test into temp1;
-- I am getting error as follows:
Error report:
ORA-00904: "L_DATA": invalid identifier
ORA-06512: at "SYSTEM.BULKCOMPARISON", line 93
ORA-06512: at line 2
00904. 00000 - "%s: invalid identifier"
*Cause:
*Action
end;
- Please help me to get rid of this issue. Is it possible to construct the query dynamically and fetch the data?. If not, is there any other better approach to compare the data between two views?.Output should display what are all columns changed and its old value and new value.
For eg., output should be
COLUMNNAME OLD_VALUE NEW_VALUE STID
C1 20 10 1
C2 50 40 2
C3 60 70 2
C2 80 90 3Why no do this only via a simple sql ?
create table a (STID number, C1 number, C2 number, C3 number);
insert into a values (1, 20, 30, 40)
insert into a values (2, 40, 50, 60);
insert into a values (3, 90, 80, 100);
create table b as select *
from a where 1 = 0;
insert into b values (1, 10, 30, 40)
insert into b values (2, 40, 40, 70);
insert into b values (3, 90, 90, 100);
commit;And now you can issue such a kind of select
SELECT stid , c1, c2, c3
FROM
( SELECT a.*,
1 src1,
to_number(null) src2
FROM a
UNION ALL
SELECT b.*,
to_number(null) src1,
2 src2
FROM b
GROUP BY stid , c1, c2, c3
HAVING count(src1) <> count(src2)
order by stid;I would then create a new table a_b_difference having the same structure as a or b and insert into it like this
create table a_b_diff as select * from a where 1 = 0;
insert into a_b_diff
SELECT stid , c1, c2, c3
FROM
( SELECT a.*,
1 src1,
to_number(null) src2
FROM a
UNION ALL
SELECT b.*,
to_number(null) src1,
2 src2
FROM b
GROUP BY stid , c1, c2, c3
HAVING count(src1) <> count(src2)
order by stid
;Then each time there is a difference between a column in a and its equivalente one in b (per unique stid ) a record will be inserted in this table.
You can do more by adding the name of the table in front of each record in this table to see exactly where the data comes from
Best Regards
Mohamed Houri -
How to send report output from SUBMIT statement
Hi,
I need to develop one report whcih can be use to send any report output in mail as attachment in txt of execl format. So i will be using SUBMIT statement to execute the report in my new report and i need to convert the reportout in txt or excel format and need to send as attachment in mail. This new report can be use to execute any report which may have ALV GRid, Normal outout screen. So what could be the best way to develop this kind of report.
Br,
Piyush>
piyush mathur wrote:
> Hi Suhas,
>
> LIST_TO_ASCI will give me data in lines. and its difficult to separate the columns in another internal table for attachment file. As this report is going to use to send any report output so i can not fixed the delimiter. So i am looking some function which can split the data in columns when I am reading from List.
> Br,
> Piyush
No need to seperate nothing additionally, this will come automatically in the attached file. Draft below
DATA list_tab TYPE TABLE OF abaplist.
SUBMIT your_report EXPORTING LIST TO MEMORY
AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = list_tab
EXCEPTIONS
not_found = 1
OTHERS = 2.
DATA string_tab TYPE list_string_table.
"use table type appropriate for attchement
DATA ascii_tab TYPE soli_tab.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = ascii_tab
listobject = list_tab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'C:\test.txt'
filetype = 'ASC'
TABLES
data_tab = ascii_tab.
DATA go_email_doc TYPE REF TO cl_document_bcs.
go_email_doc = cl_document_bcs=>create_document(
i_type = 'TXT'
go_email_doc->add_attachment( i_attachment_type = 'TXT'
i_attachment_subject = 'My Attachment'
i_att_content_text = ascii_tab ).
Regards
Marcin -
Ref Cursor from PL/SQL Table
I'm building a complex report in which the information cames from a lot of tables and needs complex formatting. I'd like to base my report in a table returned by a stored procedure (like you can do in Forms). Is there any way to convert an PL/SQL table in a Ref Cursor?
Why don't you process the data in procedure and dump into temporary table. And base your report on that temporary table.
it may simplify your report.
Atul
Maybe you are looking for
-
How to use RESTFUL web services in SMP 3.0 Appbuilder?
Hi All, I want to develop an application using RESTfull service. I have already developed REST service,I want to use that service in Appbuilder Application for SMP3.0. How can I call the REST services into our SMP 3.0 Appbuilder application? If
-
I am very new to java and working on a program for class.... The program must take a variable x and run it through a given function and the output is a number such as 8.234141... In the end i have to take that result and have two statements print to
-
Problems with Winclone/Partition space
hello, I have a MBpro 08 edition and have a partitioned disk that is running XP. It is running really low on space, so I downloaded Winclone and made an image of the partition. The problem is that whenever I restore the image to the new partition whi
-
Linux-3.6.10-1 diff from 3.6.9-1
Stupid question, but is there a way I can see the diff between these two? https://mailman.archlinux.org/pipermail - 24142.html
-
Script change for rich text use
I am using the script below to add user instructions to Textfields. I would like to do the same thing with textfields formatted for rich text but this script stops working when i set the field to accept rich text. Can you tell me how to modify the sc