Bursting a report with multiple queries
Hi,
I need to set-up bursting in BIP for a report with multiple queries. The output format is pdf and delivery is through e-mail. Since the queries need to be linked, I'm trying to do this using data template. I've set-up split and burst based on a field (store_id) from the first query which is used as a bind variable in the subsequent queries. So I'd ideally want the report to be split based on store_id. The report works fine if I use a parameter for store_id and view the output by store_id. When I try to schedule the report for bursting, it generates and e-mails the reports but only the last report appears to have correct data output while the others have only the output from the first query (and all other queries appear to return nothing in the report).
Any suggestions on what could be the issue here? Thanks!
Here is the data template for the report:
<dataTemplate name="Report" description="Report" dataSourceRef="ReportDB">
<dataQuery>
<sqlStatement name="STORE_VENDOR">
<![CDATA[SELECT STORE.STORE_ID Q1_STORE_ID, VENDOR.VENDOR_ID Q1_VENDOR_ID, VENDOR.VENDOR_DESC Q1_VENDOR_DESC, PERSON.NAME Q1_NAME
FROM STORE, SERVICE_TICKET, VENDOR, ROLE, ROLE_TYPE, PERSON, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
AND (SERVICE_TICKET.SOURCE_ID = VENDOR.SOURCE_ID AND SERVICE_TICKET.VENDOR_ID = VENDOR.VENDOR_ID)
AND (STORE.SOURCE_ID = ROLE.SOURCE_ID AND STORE.STORE_ID = ROLE.STORE_ID)
AND (ROLE.SOURCE_ID = ROLE_TYPE.SOURCE_ID AND ROLE.ROLE_TYPE_ID = ROLE_TYPE.TYPE_ID AND ROLE_TYPE.TYPE_DESC = 'PIC')
AND (ROLE.SOURCE_ID = PERSON.SOURCE_ID AND ROLE.PERSON_ID = PERSON.PERSON_ID)
AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
GROUP BY STORE.STORE_ID, VENDOR.VENDOR_ID, VENDOR.VENDOR_DESC, PERSON.NAME
ORDER BY STORE.STORE_ID]]>
</sqlStatement>
<sqlStatement name="WO">
<![CDATA[SELECT STORE.STORE_ID Q3_STORE_ID, 'Nightly Cleaning' Q3_NIGHTLY_CLEANING, 'Nightly Cleaning' Q3_DESCRIPTION, SERVICE_TICKET.TICKET_ID Q3_TICKET_ID, TO_CHAR(SERVICE_TICKET.END_DATE, 'MM/DD/YYYY') Q3_END_DATE, 'Excellent' Q3_QUALITY_RATING_1, 'Satisfactory' Q3_QUALITY_RATING_2, 'Unsatisfactory' Q3_QUALITY_RATING_3
FROM SERVICE_TICKET, STORE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
WHERE (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
AND STORE.STORE_ID = :Q1_STORE_ID
AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4']]>
</sqlStatement>
<sqlStatement name="SERVC_TYPE_1">
<![CDATA[SELECT STORE.STORE_ID Q4_STORE_ID, ZONE.ZONE_DESC Q4_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q4_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q4_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q4_WO_END_DATE, 'Excellent' Q4_QUALITY_RATING_1, 'Satisfactory' Q4_QUALITY_RATING_2, 'Unsatisfactory' Q4_QUALITY_RATING_3
FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
AND SERVICE_TYPE.TYPE_DESC = 'ABC'
AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
AND STORE.STORE_ID = :Q1_STORE_ID
AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
</sqlStatement>
<sqlStatement name="SERVC_TYPE_2">
<![CDATA[SELECT STORE.STORE_ID Q5_STORE_ID, ZONE.ZONE_DESC Q5_ZONE_DESC, SERVICE_TICKET_LINE.SERVICE_COST Q5_SERVICE_COST, SERVICE_TICKET_LINE.TICKET_ID Q5_TICKET_ID, TO_CHAR(SERVICE_TICKET_LINE.WO_END_DATE, 'MM/DD/YYYY') Q5_WO_END_DATE, 'Excellent' Q5_QUALITY_RATING_1, 'Satisfactory' Q5_QUALITY_RATING_2, 'Unsatisfactory' Q5_QUALITY_RATING_3
FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
AND SERVICE_TYPE.TYPE_DESC = 'XYZ'
AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
AND STORE.STORE_ID = :Q1_STORE_ID
AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
ORDER BY SERVICE_TICKET_LINE.SOURCE_ID, SERVICE_TICKET_LINE.TICKET_ID, SERVICE_TICKET_LINE.LINE_ID]]>
</sqlStatement>
<sqlStatement name="SERVC_TYPE_3">
<![CDATA[SELECT STORE.STORE_ID Q6_STORE_ID, ZONE.ZONE_DESC Q6_ZONE_DESC, 'Excellent' Q6_QUALITY_RATING_1, 'Satisfactory' Q6_QUALITY_RATING_2, 'Unsatisfactory' Q6_QUALITY_RATING_3, 'One' Q6_QTY_MISSING_1, 'Two' Q6_QTY_MISSING_2, '3 or More' Q6_QTY_MISSING_3
FROM SERVICE_TICKET_LINE, SERVICE_TICKET, STORE, SERVICE_TYPE, ZONE, PERIOD PERIOD_FROM, PERIOD PERIOD_TO
WHERE (SERVICE_TICKET.SOURCE_ID = SERVICE_TICKET_LINE.SOURCE_ID AND SERVICE_TICKET.TICKET_ID = SERVICE_TICKET_LINE.TICKET_ID)
AND (SERVICE_TICKET.SOURCE_ID = STORE.SOURCE_ID AND SERVICE_TICKET.STORE_ID = STORE.STORE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = SERVICE_TYPE.SOURCE_ID AND SERVICE_TICKET_LINE.SERVICE_TYPE_ID = SERVICE_TYPE.TYPE_ID)
AND (SERVICE_TICKET_LINE.SOURCE_ID = ZONE.SOURCE_ID AND SERVICE_TICKET_LINE.ZONE_ID = ZONE.ZONE_ID)
AND SERVICE_TYPE.TYPE_DESC = 'PQR'
AND SERVICE_TICKET.START_DATE BETWEEN PERIOD_FROM.START_DATE AND PERIOD_TO.END_DATE
AND STORE.STORE_ID = :Q1_STORE_ID
AND PERIOD_FROM.PERIOD_DESC = 'Cal Week 1'
AND PERIOD_TO.PERIOD_DESC = 'Cal Week 4'
ORDER BY SERVICE_TYPE.TYPE_ID]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_STORE_VENDOR" source="STORE_VENDOR">
<element name="Q1_STORE_ID" value="Q1_STORE_ID"/>
<element name="Q1_VENDOR_ID" value="Q1_VENDOR_ID"/>
<element name="Q1_VENDOR_DESC" value="Q1_VENDOR_DESC"/>
<element name="Q1_NAME" value="Q1_NAME"/>
</group>
<group name="G_WO" source="WO">
<element name="Q3_NIGHTLY_CLEANING" value="Q3_NIGHTLY_CLEANING"/>
<element name="Q3_DESCRIPTION" value="Q3_DESCRIPTION"/>
<element name="Q3_TICKET_ID" value="Q3_TICKET_ID"/>
<element name="Q3_END_DATE" value="Q3_END_DATE"/>
<element name="Q3_QUALITY_RATING_1" value="Q3_QUALITY_RATING_1"/>
<element name="Q3_QUALITY_RATING_2" value="Q3_QUALITY_RATING_2"/>
<element name="Q3_QUALITY_RATING_3" value="Q3_QUALITY_RATING_3"/>
</group>
<group name="G_SERVC_TYPE_1" source="SERVC_TYPE_1">
<element name="Q4_ZONE_DESC" value="Q4_ZONE_DESC"/>
<element name="Q4_SERVICE_COST" value="Q4_SERVICE_COST"/>
<element name="Q4_TICKET_ID" value="Q4_TICKET_ID"/>
<element name="Q4_WO_END_DATE" value="Q4_WO_END_DATE"/>
<element name="Q4_QUALITY_RATING_1" value="Q4_QUALITY_RATING_1"/>
<element name="Q4_QUALITY_RATING_2" value="Q4_QUALITY_RATING_2"/>
<element name="Q4_QUALITY_RATING_3" value="Q4_QUALITY_RATING_3"/>
</group>
<group name="G_SERVC_TYPE_2" source="SERVC_TYPE_2">
<element name="Q5_ZONE_DESC" value="Q5_ZONE_DESC"/>
<element name="Q5_SERVICE_COST" value="Q5_SERVICE_COST"/>
<element name="Q5_TICKET_ID" value="Q5_TICKET_ID"/>
<element name="Q5_WO_END_DATE" value="Q5_WO_END_DATE"/>
<element name="Q5_QUALITY_RATING_1" value="Q5_QUALITY_RATING_1"/>
<element name="Q5_QUALITY_RATING_2" value="Q5_QUALITY_RATING_2"/>
<element name="Q5_QUALITY_RATING_3" value="Q5_QUALITY_RATING_3"/>
</group>
<group name="G_SERVC_TYPE_3" source="SERVC_TYPE_3">
<element name="Q6_ZONE_DESC" value="Q6_ZONE_DESC"/>
<element name="Q6_QUALITY_RATING_1" value="Q6_QUALITY_RATING_1"/>
<element name="Q6_QUALITY_RATING_2" value="Q6_QUALITY_RATING_2"/>
<element name="Q6_QUALITY_RATING_3" value="Q6_QUALITY_RATING_3"/>
<element name="Q6_QTY_MISSING_1" value="Q6_QTY_MISSING_1"/>
<element name="Q6_QTY_MISSING_2" value="Q6_QTY_MISSING_2"/>
<element name="Q6_QTY_MISSING_3" value="Q6_QTY_MISSING_3"/>
</group>
</dataStructure>
</dataTemplate>
Hello user6428199,
When you use ":Q1_STORE_ID" in your queries, BI Publisher looks for a report parameter named Q1_STORE_ID. Change all your report queries to get data for all the store_id's available. As you are bursting the report using the store_id as the bursting key, BI Publisher will split the report based on the stored_id and delivers content based on it. No matter how many queries you may have, BI Publisher will loop through all the store_id's available and all the queries will return data for that particular id in a report.
Thanks,
Machaan
Similar Messages
-
Report with Multiple queries too slow in BI Publisher 11g
Hi, I have a report in 11g where i need to create multiple queries to show them in report. I tried to combine everything in one query, but i found that the query is too huge and hard to understand and maintain. I created 3 data sets and linked them together. In SQL dev, the main query is returning about 315 records and first detail query returns less than 100 records and second detail query is returning one record which is BLOB. Each query returns data within a couple of seconds from SQL Developer. The entire report from BI Publisher should be just 21 page PDF output. Did anyone face performance issues while running reports with multiple queries in 11g? I ran reports that have single query which returned 10K pages PDF and never had an issue while everthing is in one query. This is the first time Iam attempting to create multiple queries. Can someone help me understand what i might be doing wrong or missing here. Thank you.
Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
Per the BI Publisher guide,
Following are recommended guidelines for building data models:
Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
You should only use multiquery data models in the following scenarios:
To perform functions that the query type, such as a SQL query, does not support directly.
To support complex views (for example, distributed queries or GROUP BY queries).
To simulate a view when you do not have or want to use a view.
Thanks,
Bipuser -
Single report with multiple queries OR multiple reports with single query
Hello Experts,
I have a confusion regarding Live Office connection for many days. I asked many people but did not get a concrete answer. I am re-posting this question here and expecting an answer this time.
The product versions that I am using are as follows:
FrontEnd:
BOE XI 3.1 SP4 FP 4.1
Xcelsius Enterprise 2008 SP4
Backend:
SAP BW 7.0 EHP1
I have created a dashboard which is getting data from a webi report using LO connections.
The webi report has five report parts which are populated by five different queries.
Now my question is, when the five LO connections are refreshed, is the webi report refreshed five times or just once?
If the report is refreshed five times, then I guess it is better to have five different webi reports containing single report part, because in that way we can prevent same query being executed multiple times.
SO what is the best practice- to have a single report having multiple queries - OR - to create multiple webi reports with single query?
Thanks and Regards,
PASGHI
I think Best Practice is Multiple reports with single query
Any way If LO connections refresh 5 time the query will refresh 5 timesRegards
Venkat -
Creating report with multiple queries in clear quest
Hi,
I am new to reports and currently working with creating reports that connect to clear quest(CQ).
I have successfully created several reports, that connect to the CQ, but they all have data from only one query.
Now I am trying to create a slightly complex report where I need to fetch data from multiple queries. All these queries use 2 parameter to filter their data. I have dynamic cascading parameters to get them. When just connecting they all work ok. I used the link tab to link them to two fields of one query, to make sure that they all filter to fields from same query.
The problem is when I drop the fields from the various queries on the form, the data is fetched multiple times.
I also played with links to make them outer links but in that case I get error and unable to run the report completely.
Any ideas on how to work with multiple queries and provide same parameters to all of the queries?
Thanks in advance.
-PAP- How do I make sure that the relationship is not one to many?
You don't. That's the nature of the data. For example a single person can order multiple items. A simple one to many relationship.
- In the link tab, I can only point to queries, is there a way I can point the fields to report params?
You should be seeing tables... I think you're having a tough time with the basic terminology.
- How does these Enforce Joins (4 options) work.
There is rarely if ever any reason to switch from the default "not enforced". Leave it alone. The only one you'll touch 90% of the time is the Join Type.
PAP,
Based on the questions you're asking, it sounds like you are missing some major database fundamentals. My suggestion would be to step away from CR for the time being and read a little bit about relational databases (what makes them relational) and database normalization. This will also give you an idea about the various join types and when to use one over the other.
You can know every feature and function in CR, but until you have at least a basic knowledge of how data relates, you'll never pull in the data you need.
Jason -
Matrix report with Multiple queries
I have created one cross product group containing 4 subgroups under a single query. Now I have another one query seperately to be joined with the matrix query. Also I have one formula column and summary column with this the cross product group. The logic is if formula condition is true the it should take the 2nd query value in the place holder column otherwise it should take the first query value. is it possible?
If any one knows about this update me ASAP to [email protected]Isn't there a way for you to do this via a Package/Procedure versus having multiple queries?
Per the BI Publisher guide,
Following are recommended guidelines for building data models:
Reduce the number of data sets or queries in your data model as much as possible. In general, the fewer data sets and queries you have, the faster your data model will run. While multiquery data models are often easier to understand, single-query data models tend to execute more quickly. It is important to understand that in parent-child queries, for every parent, the child query is executed.
You should only use multiquery data models in the following scenarios:
To perform functions that the query type, such as a SQL query, does not support directly.
To support complex views (for example, distributed queries or GROUP BY queries).
To simulate a view when you do not have or want to use a view.
Thanks,
Bipuser -
Hi All,
I need to develop a report with 5 big queries.. and i need to union these queries based on the parameters passed but we cannot use if condition in the report sql qurey.Also tried to use lexical parameter in the after paraform trigger but it didn't accept lexical parameter as tablename in the query..
for ex: select * from &w1 is not working.......... (say w1 is lexical parameter)
please help
thanx in advance.select * from &w1Infact, you can do so, but you have to make sure, that w1 has a valid table-name as default-value. Also, the column-name have to match in all the tables, or you have to alias. And lastly, i strongly suggest not to use SELECT *, but list all the desired columns separately.
-
Oracle Ad-hoc report with multiple queries creating issues
Hi Guys,
I have been having multiple issues (one after the other) in trying to generate a report for Business user. Let me start with my test cases and yes, this time I have made sure by testing and dirtying my hands that the test cases work properly and commit into the database (I will be more than happy to provide screen shots of the same).
Test Case:
Tables:RETURNS & RETURN_LINE_ITEMS
CREATE TABLE RETURNS
ID NUMBER(12),
PROG_PROGRAM_CD VARCHAR2(2 BYTE),
ACCT_ID NUMBER(12),
ACPE_ID NUMBER(12),
JENT_ID NUMBER(12),
PREV_RTRN_ID NUMBER(12),
ENTP_ABN NUMBER(9),
ACCT_OCCURNC_NBR NUMBER(4),
SOURCE_TYPE VARCHAR2(30 BYTE) DEFAULT 'BLANK',
RECEIVE_DATE DATE,
AMEND_IND VARCHAR2(1 BYTE) DEFAULT 'N',
CMPLT_IND VARCHAR2(1 BYTE) DEFAULT 'N',
PENALTY_OR_IND VARCHAR2(1 BYTE) DEFAULT 'N',
RETURN_STATUS VARCHAR2(12 BYTE),
STATUS_DATE DATE,
STATUS_USERID VARCHAR2(8 BYTE),
PERIOD_START_DATE DATE,
PERIOD_END_DATE DATE,
NOTICE_STATUS VARCHAR2(12 BYTE),
NOTICE_STATUS_DATE DATE,
NOTE_TEXT VARCHAR2(2000 BYTE),
PENALTY_OR_BY VARCHAR2(8 BYTE),
PENALTY_OR_TMST DATE,
FILING_ID NUMBER(12),
CASE_ID VARCHAR2(49 BYTE),
DOC_CONTRL_NBR NUMBER(29),
LOCTR_NBR NUMBER(10),
STATUTE_BARRED_DATE DATE,
MEDIA_TYPE VARCHAR2(30 BYTE),
DISPSTN_TYPE VARCHAR2(30 BYTE),
AMEND_TYPE VARCHAR2(30 BYTE),
CALC_MODE VARCHAR2(30 BYTE),
PROCESS_PASS_CNT NUMBER(1),
CONVRTD_IND VARCHAR2(1 BYTE) DEFAULT 'N',
LOSS_PERIOD_END_DATE DATE,
MF_SYNC_CD VARCHAR2(1 BYTE)
CREATE TABLE RETURN_LINE_ITEMS
ID NUMBER(12),
RTSC_ID NUMBER(12),
RTRN_ID NUMBER(12),
SCLI_ID NUMBER(12),
LITM_ID NUMBER(12),
ENTP_ABN NUMBER(9),
PROG_PROGRAM_CD VARCHAR2(2 BYTE),
ACCT_OCCURNC_NBR NUMBER(4),
ACPE_END_DATE DATE,
SCHED_NBR VARCHAR2(3 BYTE),
SCHD_VERSION_YR NUMBER(4) DEFAULT 0,
SCHD_VERSION_NBR NUMBER(3),
RTSC_OCCUR_NBR NUMBER(3),
LITM_LINE_ITEM_NBR VARCHAR2(3 BYTE),
SLIN_LINE_ITEM_ID NUMBER(12),
OCCUR_NBR NUMBER(3) DEFAULT 1,
PREV_VAL_MOD_IND VARCHAR2(1 BYTE) DEFAULT 'N',
VIABLE_IND VARCHAR2(1 BYTE) DEFAULT 'N',
ACTIVE_IND VARCHAR2(1 BYTE) DEFAULT 'Y',
ACTION_CD VARCHAR2(1 BYTE),
PREV_VAL_AMT NUMBER(15,2),
REVISE_VAL_AMT NUMBER(15,2),
PREV_VAL_TEXT VARCHAR2(100 BYTE),
REVISE_VAL_TEXT VARCHAR2(100 BYTE),
DISPLAY_SEQ_NBR NUMBER(3),
SYS_VAL_AMT NUMBER(15,2),
LITM_INNER_PASS_SEQ_NBR NUMBER(3)
Inserting data into RETURNS table
INSERT INTO RETURNS (
ID ,
PROG_PROGRAM_CD ,
ACCT_ID ,
ACPE_ID ,
JENT_ID ,
PREV_RTRN_ID ,
ENTP_ABN ,
ACCT_OCCURNC_NBR ,
SOURCE_TYPE ,
RECEIVE_DATE ,
AMEND_IND ,
CMPLT_IND ,
PENALTY_OR_IND ,
RETURN_STATUS ,
STATUS_DATE ,
STATUS_USERID ,
PERIOD_START_DATE ,
PERIOD_END_DATE ,
NOTICE_STATUS ,
NOTICE_STATUS_DATE ,
NOTE_TEXT ,
PENALTY_OR_BY ,
PENALTY_OR_TMST ,
FILING_ID ,
CASE_ID ,
DOC_CONTRL_NBR ,
LOCTR_NBR ,
STATUTE_BARRED_DATE ,
MEDIA_TYPE ,
DISPSTN_TYPE ,
AMEND_TYPE ,
CALC_MODE ,
PROCESS_PASS_CNT ,
CONVRTD_IND ,
LOSS_PERIOD_END_DATE ,
MF_SYNC_CD)
VALUES(
3715944,
'01',
139048,
3587419,
9518324,
NULL,
401377197,
1,
'TAXPAYER',
TO_DATE('4/7/2009','mm/dd/yyyy'),
'N',
'Y',
'N',
'ASSESSED',
TO_DATE('4/30/2009','mm/dd/yyyy'),
'TRAPROD2',
TO_DATE('2/1/2008','mm/dd/yyyy'),
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'PRINTED',
TO_DATE('4/30/2009' , 'mm/dd/yyyy'),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
6045574495,
NULL,
'RSI',
'NOTICE',
NULL,
NULL,
NULL,
'N',
NULL,
NULL);
NSERT INTO RETURNS (
ID ,
PROG_PROGRAM_CD ,
ACCT_ID ,
ACPE_ID ,
JENT_ID ,
PREV_RTRN_ID ,
ENTP_ABN ,
ACCT_OCCURNC_NBR ,
SOURCE_TYPE ,
RECEIVE_DATE ,
AMEND_IND ,
CMPLT_IND ,
PENALTY_OR_IND ,
RETURN_STATUS ,
STATUS_DATE ,
STATUS_USERID ,
PERIOD_START_DATE ,
PERIOD_END_DATE ,
NOTICE_STATUS ,
NOTICE_STATUS_DATE ,
NOTE_TEXT ,
PENALTY_OR_BY ,
PENALTY_OR_TMST ,
FILING_ID ,
CASE_ID ,
DOC_CONTRL_NBR ,
LOCTR_NBR ,
STATUTE_BARRED_DATE ,
MEDIA_TYPE ,
DISPSTN_TYPE ,
AMEND_TYPE ,
CALC_MODE ,
PROCESS_PASS_CNT ,
CONVRTD_IND ,
LOSS_PERIOD_END_DATE ,
MF_SYNC_CD)
VALUES(
4117092,
'01',
57794,
3864551,
10566221,
NULL,
400571410,
1,
'TAXPAYER',
TO_DATE('6/30/2010', 'mm/dd/yyyy'),
'N',
'Y',
'N',
'ASSESSED',
TO_DATE('7/27/2010','mm/dd/yyyy'),
'TRAPROD2',
TO_DATE('1/1/2009','mm/dd/yyyy'),
TO_DATE('12/31/2009','mm/dd/yyyy'),
'PRINTED',
TO_DATE('7/27/2010','mm/dd/yyyy'),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
6053117120,
NULL,
'RSI',
'NOTICE',
NULL,
NULL,
NULL,
'N',
NULL,
NULL);
INSERT INTO RETURNS (
ID ,
PROG_PROGRAM_CD ,
ACCT_ID ,
ACPE_ID ,
JENT_ID ,
PREV_RTRN_ID ,
ENTP_ABN ,
ACCT_OCCURNC_NBR ,
SOURCE_TYPE ,
RECEIVE_DATE ,
AMEND_IND ,
CMPLT_IND ,
PENALTY_OR_IND ,
RETURN_STATUS ,
STATUS_DATE ,
STATUS_USERID ,
PERIOD_START_DATE ,
PERIOD_END_DATE ,
NOTICE_STATUS ,
NOTICE_STATUS_DATE ,
NOTE_TEXT ,
PENALTY_OR_BY ,
PENALTY_OR_TMST ,
FILING_ID ,
CASE_ID ,
DOC_CONTRL_NBR ,
LOCTR_NBR ,
STATUTE_BARRED_DATE ,
MEDIA_TYPE ,
DISPSTN_TYPE ,
AMEND_TYPE ,
CALC_MODE ,
PROCESS_PASS_CNT ,
CONVRTD_IND ,
LOSS_PERIOD_END_DATE ,
MF_SYNC_CD)
VALUES(
4382179,
'01',
498210,
3957251,
11264174,
3727534,
405079963,
1,
'TAXPAYER',
TO_DATE('4/26/2011', 'mm/dd/yyyy'),
'Y',
'Y',
'N',
'ASSESSED',
TO_DATE('5/12/2011','mm/dd/yyyy'),
'LOPATS',
TO_DATE('2/1/2008', 'mm/dd/yyyy'),
TO_DATE('1/31/2009','mm/dd/yyyy'),
'PRINTED',
TO_DATE('5/12/2011','mm/dd/yyyy'),
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
6058767341,
TO_DATE('4/30/2015','mm/dd/yyyy'),
'RSI',
'NOTICE',
'LOSS CARRY BACK (SIMPLE)',
'LOSS CARRY BACK',
NULL,
'N',
TO_DATE('1/31/2011', 'mm/dd/yyyy'),
NULL
Now inserting data into 2nd table i.e. RETURN_LINE_ITEMS
RTRN_ID means RETURN ID
This is for RTRN_ID =3715944
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES(
277707088,
8022477,
3715944,
NULL,
1585,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'000',
1998,
1,
1,
'029',
23,
1,
'N',
'Y',
'Y',
NULL,
1,
1,
NULL,
NULL,
115,
1 ,
1);
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
277707106,
8022477,
3715944,
NULL,
1603,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'000',
1998,
1,
1,
'062',
40,
1,
'N',
'Y',
'Y',
NULL,
1069336,
1069336,
NULL,
NULL,
200,
1069336,
130
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
(277707109,
8022477,
3715944,
NULL,
1539,
401377197,
'01',
1,
TO_DATE('1/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'066',
43,
1,
'N',
'Y',
'Y',
NULL,
NULL,
1000,
'NULL',
'NULL',
215,
1069336,
200);Now for RTRN_ID = 4117092
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES(
319820214,
9028477,
4117092,
NULL,
1585,
400571410,
'01',
1,
TO_DATE('12/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'029',
23,
1,
'N',
'Y',
'Y',
NULL,
3,
3,
NULL,
NULL,
115,
3,
1
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES(
319820233,
9028477,
4117092,
NULL,
1603,
400571410,
'01',
1,
TO_DATE('12/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'062',
40,
1,
'N',
'Y',
'Y',
NULL,
790068,
790068,
NULL,
NULL,
200,
790068,
130
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
319820236,
9028477,
4117092,
NULL,
1539,
400571410,
'01',
1,
TO_DATE('12/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'066',
43,
1,
'N',
'Y',
'Y',
NULL,
NULL,
790,
NULL,
NULL,
215,
790068,
200
Now finally for RTRN_ID = 4382179
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
348462584,
9694297,
4382179,
NULL,
1585,
405079963,
'01',
1,
TO_DATE(1/31/2009, 'mm/dd/yyyy'),
'000'
1998,
1,
1,
'029',
23,
1,
'N',
'Y',
'Y',
NULL,
1,
1,
NULL,
NULL,
115,
NULL,
1
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
348462602,
9694297,
4382179,
NULL,
1603,
405079963,
'01',
1,
TO_DATE('1/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'062',
40,
1,
'N',
'Y',
'Y',
NULL,
672738,
643304,
NULL,
NULL,
200,
NULL,
130
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
348462605,
9694297,
4382179,
NULL,
1539,
405079963,
01,
1,
TO_DATE('1/31/2009','mm/dd/yyyy'),
'000',
1998,
1,
1,
'066',
43,
1,
'N',
'Y',
'Y',
NULL,
672738,
643304,
NULL,
NULL,
215,
643304,
200
);OK. Now once this data is all inserted, comes the real problem and that is:
a) based on the following requirements
Requirements: Adhoc Report for Audit on CIT Income Allocation
1. Select from the RETURNS table:
• Id > 3600000 and
• Prog_program_cd = '01' and
• Return_status in ('ASSESSED', 'DU") and
• Tax year ending in 2009 (i.e. year portion of the Period_end_date is in 2009)
2. Retrieve the following fields from the RETURNS table :
• Id
• Entp_abn
• Acct_id
• Prog_program_cd
• Period_start_date
• Period_end_date
• Amend_ind
• Return_status
• Status_date
• Loctr_nbr
3. If there are multiple entries from the same account and tax year, only retain the latest record: From the records selected in step 2, if there are multiple records with the same Acct_Id and Period_end_date, only retain the record with the most recent Status_date (i.e. MAX value on the date).
4. Using the results from step 3, link to the applicable RETURN_LINE_ITEMS table where:
• RETURNS.Id = RETURN_LINE_ITEMS.Rtrn_Id
5. From the selected return on RETURN_LINE_ITEMS table, retrieve records where (value on Sch 000 Line 062 > 500,000) and (value on Sch 000 Line 066 < value on Sch 000 Line 062) :
• Sched_nbr = '000', and Litm_line_item_nbr = '062', and Active_ind = 'Y', get Revise_val_amt as 'ab_taxable_income'
• Sched_nbr = '000', and Litm_line_item_nbr = '066', and Active_ind = 'Y', get Revise_val_amt as 'amt_taxable_in_ab'
• Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
I utilized the following query and I am getting 4 rows (line item numbers 062 and 066 where in ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income) and this is correct
SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
from returns r1, return_line_items rtlnms
where
r1.id = rtlnms.rtrn_id and
r1.prog_program_cd = rtlnms.prog_program_cd and
r1.entp_abn = rtlnms.entp_abn and
r1.id > 3600000 AND r1.prog_program_cd = '01' AND r1.return_status in ('ASSESSED', 'DU')
and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
and rtlnms.sched_nbr = '000'
and rtlnms.active_ind = 'Y'
and r1.id in (4117092,3715944,4382179,3691435)
and RTLNMS.LITM_LINE_ITEM_NBR IN('062')
AND nvl(decode(litm_line_item_nbr, '062', REVISE_VAL_AMT),0) > 500000
and NVL(RTLNMS.REVISE_VAL_AMT,0) >( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
FROM RETURN_LINE_ITEMS RTLNMS2
WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
AND RTLNMS2.LITM_LINE_ITEM_NBR = '066'
AND SCHED_NBR='000'
UNION
SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB
from returns r1, return_line_items rtlnms
where r1.id = rtlnms.rtrn_id
AND r1.prog_program_cd = rtlnms.prog_program_cd
AND r1.entp_abn = rtlnms.entp_abn
AND r1.id > 3600000 AND r1.prog_program_cd = '01'
AND r1.return_status in ('ASSESSED', 'DU')
and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
and rtlnms.sched_nbr = '000'
and rtlnms.active_ind = 'Y'
and r1.id in (4117092,3715944,4382179,3691435)
and RTLNMS.LITM_LINE_ITEM_NBR IN('066')
and NVL(RTLNMS.REVISE_VAL_AMT,0) <( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
FROM RETURN_LINE_ITEMS RTLNMS2
WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
AND RTLNMS2.LITM_LINE_ITEM_NBR = '062'
and NVL(RTLNMS2.REVISE_VAL_AMT,0)>500000
AND SCHED_NBR='000'
order by IDHowever there is another condition after "5c" i.e. after Retain the return only if (ab_taxable_income > 500,000) and (amt_taxable_in_ab < ab_taxable_income)
and that is:
For those returns meeting the criteria in step 5, also retrieve the following from RETURN_LINE_ITEMS table and that is:
sched_nbr = '000' and Litm_line_item_nbr = '029' and ACTIVE_IND ='Y', get Revise_val_amt as "corp_type"
and in order to go about this, I utilised the following query:
SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB,
decode(rtlnms.litm_line_item_nbr, '029', RTLNMS.REVISE_VAL_AMT)CORP_INCOME
from returns r1, return_line_items rtlnms
where
r1.id = rtlnms.rtrn_id and
r1.prog_program_cd = rtlnms.prog_program_cd and
r1.entp_abn = rtlnms.entp_abn and
r1.id > 3600000 AND r1.prog_program_cd = '01' AND r1.return_status in ('ASSESSED', 'DU')
and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
and rtlnms.sched_nbr = '000'
and rtlnms.active_ind = 'Y'
and r1.id in (4117092,3715944,4382179,3691435)
and RTLNMS.LITM_LINE_ITEM_NBR IN('062')
AND nvl(decode(litm_line_item_nbr, '062', REVISE_VAL_AMT),0) > 500000
and NVL(RTLNMS.REVISE_VAL_AMT,0) >( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
FROM RETURN_LINE_ITEMS RTLNMS2
WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
AND RTLNMS2.LITM_LINE_ITEM_NBR IN( '066')
AND SCHED_NBR='000'
UNION
SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd, r1.period_start_date, r1.period_end_Date, r1.amend_ind, r1.return_status, r1.status_date, r1.loctr_nbr,
rtlnms.sched_nbr, rtlnms.litm_line_item_nbr,
decode(rtlnms.litm_line_item_nbr, '062', RTLNMS.REVISE_VAL_AMT)AB_TAXABLE_INCOME,
decode(rtlnms.litm_line_item_nbr, '066', RTLNMS.REVISE_VAL_AMT)AMT_TAXABLE_IN_AB,
decode(rtlnms.litm_line_item_nbr, '029', RTLNMS.REVISE_VAL_AMT)CORP_INCOME
from returns r1, return_line_items rtlnms
where r1.id = rtlnms.rtrn_id
AND r1.prog_program_cd = rtlnms.prog_program_cd
AND r1.entp_abn = rtlnms.entp_abn
AND r1.id > 3600000 AND r1.prog_program_cd = '01'
AND r1.return_status in ('ASSESSED', 'DU')
and r1.period_end_Date between to_date('01-01-2009','DD-mm-YYYY') and to_date ('31-12-2009', 'DD-mm-YYYY')
and r1.status_date = (select max (status_date) from returns r2 where r2. acct_id= r1.acct_id and r2.period_end_date = r1.period_end_date)
and rtlnms.sched_nbr = '000'
and rtlnms.active_ind = 'Y'
and r1.id in (4117092,3715944,4382179,3691435)
and RTLNMS.LITM_LINE_ITEM_NBR IN('066','029')
and NVL(RTLNMS.REVISE_VAL_AMT,0) < ( select NVL(RTLNMS2.REVISE_VAL_AMT,0)
FROM RETURN_LINE_ITEMS RTLNMS2
WHERE RTLNMS2.RTRN_ID=RTLNMS.RTRN_ID
AND RTLNMS2.LITM_LINE_ITEM_NBR='062'
and NVL(RTLNMS2.REVISE_VAL_AMT,0)>500000
AND SCHED_NBR='000'
order by ID
My output is: 7 rows i.e.
3 rows of return id = 3715944,
3 rows of return id = 4117092
and 1 row of return id = 4382179
It should only retrieve rows for 3715944 and 4117092; not for row =4382179 and this is because based on question in 5 "c", rows retrieved were for return ids' = 3715944 and 4117092
I know where the problem is:
As soon as it retrieves rows for returns 3715944 and 4117092 (because REVISE_VAL_AMT is greater than 500,000), it also finds another record with return id = 4382179 with greater than 500,000 and it blindly brings that as well.
Is there a way around to ensure that I my results are compared only against the return id's retrieved from 5 "c" = 3715944 and 4117092
Believe me I have tried every option that I could think of to remove return id = 4382179 but somehow could not.
Dear Gurus @ OTN, please help me.
Thanks,
SandeepThanks for your words of wisdom guys. Appreciate it.
Anyways what ever I asked, I was able to get solution for it by using an inline query and it's as follows:
SELECT id, entp_abn, acct_id, prog_program_cd, period_start_date,
period_end_date, amend_ind, return_status, status_date, loctr_nbr,
ab_taxable_income, amt_taxable_in_ab
FROM (SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,
r1.period_start_date, r1.period_end_date, r1.amend_ind,
r1.return_status, r1.status_date, r1.loctr_nbr,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'062', rtlnms.revise_val_amt)) ab_taxable_income,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'066', rtlnms.revise_val_amt)) amt_taxable_in_ab
FROM returns r1, return_line_items rtlnms
WHERE r1.id = rtlnms.rtrn_id
AND r1.id > 3600000
AND r1.prog_program_cd = '01'
AND r1.return_status IN ('ASSESSED', 'DU')
AND r1.period_end_date BETWEEN
TO_DATE ('01-01-2009', 'DD-MM-YYYY') AND
TO_DATE ('31-12-2009', 'DD-MM-YYYY')
AND rtlnms.sched_nbr = '000'
AND rtlnms.active_ind = 'Y'
AND r1.status_date =
(SELECT MAX (status_date)
FROM returns r2
WHERE r2. acct_id= r1.acct_id
AND r2.period_end_date = r1.period_end_date)
GROUP BY r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,
r1.period_start_date, r1.period_end_date, r1.amend_ind,
r1.return_status, r1.status_date, r1.loctr_nbr)
WHERE ab_taxable_income > 500000
AND amt_taxable_in_ab < ab_taxable_income
ORDER BY id
*OUTPUT*
ID ENTP_ABN ACCT_ID PR PERIOD_ST PERIOD_EN A RETURN_STATU STATUS_DA LOCTR_NBR AB_TAXABLE_INCOME AMT_TAXABLE_IN_AB
3715944 401377197 139048 01 01-FEB-08 31-JAN-09 N ASSESSED 30-APR-09 6045574495 1069336 1000
4117092 400571410 57794 01 01-JAN-09 31-DEC-09 N ASSESSED 27-JUL-10 6053117120 790068 790
2 rows selected.Anyways I am stuck in another issue and that is:
Based on what I have received above - I have been given a new requirement and that is:
retrieve the corresponding Schedule 002 data (if exist) from the RETURN_LINE_ITEMS table:
*• Sched_nbr = ‘002’, and Litm_line_item_nbr = ‘001’, and Active_ind = ‘Y’, get Revise_val_amt as ‘special_allocation’*
*• Sched_nbr = ‘002’, and Litm_line_item_nbr = ‘002’, and Active_ind = ‘Y’, get Revise_val_amt as ‘ab_salaries_wages’*
So in order to do this, I committed 5 additional rows with schedule number 002 and they are as follows:
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
626121,
118320,
3715944,
NULL,
2322,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'002',
1981,
1,
1,
'001',
78,
1,
'N',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL,
NULL,
5,
NULL,
40
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
626121,
118320,
3715944,
NULL,
2322,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'002',
1981,
1,
1,
'002',
78,
1,
'N',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL,
NULL,
5,
NULL,
40
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
626121,
118320,
3715944,
NULL,
2322,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'002',
1981,
1,
1,
'004',
78,
1,
'N',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL,
NULL,
5,
NULL,
40
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
626121,
118320,
3715944,
NULL,
2322,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'002',
1981,
1,
1,
'006',
78,
1,
'N',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL,
NULL,
5,
NULL,
40
INSERT INTO RETURN_LINE_ITEMS (
ID ,
RTSC_ID ,
RTRN_ID ,
SCLI_ID ,
LITM_ID ,
ENTP_ABN ,
PROG_PROGRAM_CD ,
ACCT_OCCURNC_NBR ,
ACPE_END_DATE ,
SCHED_NBR ,
SCHD_VERSION_YR ,
SCHD_VERSION_NBR ,
RTSC_OCCUR_NBR ,
LITM_LINE_ITEM_NBR ,
SLIN_LINE_ITEM_ID ,
OCCUR_NBR ,
PREV_VAL_MOD_IND ,
VIABLE_IND ,
ACTIVE_IND ,
ACTION_CD ,
PREV_VAL_AMT ,
REVISE_VAL_AMT ,
PREV_VAL_TEXT ,
REVISE_VAL_TEXT ,
DISPLAY_SEQ_NBR ,
SYS_VAL_AMT ,
LITM_INNER_PASS_SEQ_NBR
VALUES
626121,
118320,
3715944,
NULL,
2322,
401377197,
'01',
1,
TO_DATE('1/31/2009', 'mm/dd/yyyy'),
'002',
1981,
1,
1,
'008',
78,
1,
'N',
'Y',
'Y',
NULL,
NULL,
NULL,
NULL,
NULL,
5,
NULL,
40
); So based on the requirement I ran the following query in the hope that I should see 8 records but unfortunately I saw none, Can any one help again please??? The query is as follows:
SELECT id, entp_abn, acct_id, prog_program_cd, period_start_date,
period_end_date, amend_ind, return_status, status_date, loctr_nbr,
ab_taxable_income, amt_taxable_in_ab,
CORP_INCOME, AB_ALLOC_FACTOR, AB_TAX_PAYABLE,
special_allocation, ab_salaries_wages
FROM (SELECT r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,
r1.period_start_date, r1.period_end_date, r1.amend_ind,
r1.return_status, r1.status_date, r1.loctr_nbr,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'062', rtlnms.revise_val_amt)) ab_taxable_income,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'066', rtlnms.revise_val_amt)) amt_taxable_in_ab,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'029', rtlnms.revise_val_amt)) CORP_INCOME,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'065', rtlnms.revise_val_amt)) AB_ALLOC_FACTOR,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'080', rtlnms.revise_val_amt)) AB_TAX_PAYABLE,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'001', rtlnms.revise_val_amt)) SPECIAL_ALLOCATION,
SUM
(DECODE
(rtlnms.litm_line_item_nbr,
'002', rtlnms.revise_val_amt)) AB_SALARIES_WAGES
FROM returns r1, return_line_items rtlnms
WHERE r1.id = rtlnms.rtrn_id
AND r1.id > 3600000
AND r1.prog_program_cd = '01'
AND r1.return_status IN ('ASSESSED', 'DU')
AND r1.period_end_date BETWEEN
TO_DATE ('01-01-2009', 'DD-MM-YYYY') AND
TO_DATE ('31-12-2009', 'DD-MM-YYYY')
AND rtlnms.sched_nbr = '000'
AND(rtlnms.sched_nbr = '002' and rtlnms.litm_line_item_nbr in ('001','002','004','006','008') )
AND rtlnms.active_ind = 'Y'
AND r1.status_date =
(SELECT MAX (status_date)
FROM returns r2
WHERE r2. acct_id= r1.acct_id
AND r2.period_end_date = r1.period_end_date)
GROUP BY r1.id, r1.entp_abn, r1.acct_id, r1.prog_program_cd,
r1.period_start_date, r1.period_end_date, r1.amend_ind,
r1.return_status, r1.status_date, r1.loctr_nbr, rtlnms.sched_nbr)
WHERE ab_taxable_income > 500000
AND amt_taxable_in_ab < ab_taxable_income
strangely it's not retrieving any row where as it should have retrieved one row atleast and that is all records pertaining to return_id (return id ) = 3715944
Can any of the Gurus' please help me out? As said I am really having a bad day on this. Many thanks to any one who can help me see the light today :-) -
How to mass print a report with multiple queries?
Dear All,
i want to precalclate a report (which includes 4 queries) to pdf for printing. Because i have to print it for all profitcenter (~200), i want to use the filter navigation.
Because this isn't possible for reports, i inserted my report using a report item to a web template.
When i call the web template direct, everything works fine, but if i precalculate the web template using the bex broadcaster, only one query is parameterized. The second one seems to use the global variant (the sum of all profitcenter).
Any Idea? Do i have to change an export web template and add some data provider? I am not absolutely sure which is the right export template for an report in a web template...
Thanks in advance,
ThomasHey all,
nobody an idea of a possible approach.
Greetz,
Thomas -
Hints on building a report with multiple queries
Hi all,
I know this is not the best forum to address this question, but i know
a lot of people here are using XML publisher with jdev to produce reports.
any help is appreciated.
Im a begginner with XML publisher and i am facing a problem!
I had no troubles with reports containing one query but when i need more than
one query inside my report I really dont know how to manage the whole thing
I would love to know if someone could guide to some steps or to web site explaining
the method to follow.
I am using word to build my templates ---- if you could help towards this direction or
tell what to use instead I would greatly appreciate
Best Regards,
Carlrepost anyone?..
-
BI+ Reporting With Multiple Data Sources
Hi -
We've been using BI+ Reports with multiple data sources on separate grids. We are wondering if there is a better way to ensure the user has their point of view bar in sync between the the data sources. In our case, both Data Sources are separate HFM applications with all the dimensions identical except the account which is defined on the report. We are not using Metadata Management.
I'm aware of the "Merge Equivalent Prompts" in the Preferences > Financial Reporting window, but this does not always ensure the users have the same point of view.
What practice are other companies using to make sure the user runs the reports accurately with both point of view bars pulling the same entity/year/period.
Thanks in advance.Thanks for your answer, however my question - I know it looks quite messy - is not directly related to data templates, my problem is that at the moment I am using a stored procedure following - almost exactly - what another procedure does in oracle EBS to call a BI publisher report.
1. This procedure populates some temporary table with the xml data where the concurrent request picks it up and uses it to populate the BI publisher template.
2. However I can't go and specify the XML location in my data template as this is not an option for us (i.e. reading the xml from the temporary table), so I am looking for another way to populate the BI publisher template (Note: I can't as well include the SQL queries in my Data template).
Thanks ;) -
Report with multiple Detail Area
Hi All,
Please see the Report pointed to the link below:
[Report with multiple Detail Area|http://us.share.geocities.com/felix5ac/fairway.jpg]
Some Explanations:
========================
(1) The line with "ABCDEFGH..." is variable data coming from the database in the Detail Area
(2) The lines with "WBLNX'" "123, 123.12",
"WBLNX'"
are variable data associated with the same Heading: "ABCDEFGH..."
(2b) There can be multiple lines of data in the detail area (i.e. 1 or more "ABCDEFGH..." and the associated WBLNX and numbers...)
(3) Item Code Descriptions ==> is a Header Info
(4) ARL ... and FPHI... ==> are variable data and lines in these area can be 1 line; it can be 4 lines; it can be 10 lines...
(5) Lines FROM "Artwork Procedures..." to the the end of the page are static.
QUESTION:
===================
How do I best design these Report with the multiple detail areas? Again, please see link of the Report above...
Thanks and Best regards,
FelixHi Felix
You can place the less detailed fields in the regular sections of the report and wherever you require multiple lines you can use the subreports.
Hope this helps.
Regards
Nikhil -
Report with multiple dimensions in Row and Column with EvEXP
Hi
We are currently running BPC 7.0 SP3 and try to create the report(or schedule) with more 2 x 2 dimensions in the row and column.
e.g.
row dimension : Outer row is Entity, Inner row is Account
column dimension : Outer column is Time, Inner row is Category
We created the report with 2 x 2 dimensions like above e.g. with EvEXP and EvNXP, NOT EvDRE
based on default dynamic template:Template13.xlt(Nested Row, 2 x 1 dimensions defined by EvEXP and EvNXP formula).
However, when expanding the dimension with double click these dimensions or change CV of the report with 2 x 2 dimensions defined by EvEXP and EvNXP formula,
error occurs on EvEXP and EvNXP formula and can't retrieve the result correctly.
[Question]
Can't we create the report with more 2 x 2 dimensions in the row and column using EvEXP and EvNXP function ?
We understand that we can make the report with more 2 x 2 dimensions in the row and column if using EvDRE.
Thank You in advance
KenyaThank you for your advice.
I understand that we should use EvDRE when creating the report with multiple dimension in the row/column because EvEXP have some erros, poor performance, etc.
Then, we have two questions.
1)
>plus they had some errors in the designs.
what kind of errors they have as an example?
2)
>If you must build the EVEXP and EVNXP, I would suggest building the template from scratch
We built the simple template with just 2 x 2 dimension from scratch.
But this report doesn't work well when double-click the dimension or changing CV...
Would you please check the following template?
<https://sapmats-de.sap-ag.de/download/download.cgi?id=RCZE1ME4YSORY3DCDO4NNMANZLBL1L5ZBUOB2F71YVNVS8XDJW>
It would be greatly appreciated if you could give me your advice for the template.
Thank you again
And my best regards,
Kenya -
Hi,
I have a report with multiple tabs in selection screen. Say material number is mandatory in the first tab. But we don't need material number in the second tab. But if I want to go to the 2nd tab, i get the error message 'Please enter the material number'. Can this be avoided?
Thanks in advance.Hi Paromita,
If I understand your problem correctly then, here is the summary of your problem -
a) There are multiple tabs on selection screen. Out of which the first tab has a mandatory field i.e., Material Number. And then there are other tabs.
b) So, unless and until you provide the value in first tab for the material number(which is a mandatory field), you cannot navigate to the second tab or any other tab for that matter.
So, ideally the second and rest of other tabs are mutually dependent on the first tab's information as it has a mandatory field. Unless and until you make the first tab inactive it will not let you enter data in the second tab and so on.
So, to ideally enable input in second tab, make the first tab inactive. Try this and let me know if it works.
BR,
Ravi -
Poor Performance 7.0 Workbook with multiple queries
Hi all,
I've got the following issue. Our users have workbooks which contain serveral queries on different sheets. (One on each workbook sheet)
When a workbook contains 5 or more queries, the overall workbook performance will decrease drastically. Workbook with 8 or more queries result in time-outs and messages like unsufficient shared memory.
Does anyone have the same kind of problems with multiple queries in a Bex 7.0 workbook? Do any one have a solution?
Any suggestions are welcome.
Thanks!
Cheers,
RonBill,
Tried to make a workbook according to your advise. It certainly makes a difference in workbook size. The new workbook is 50% smaller than the older version based on the standard SAP template.
However, my workbook contains 17 queries, and after 5 minutes it breaks the BW connection. So basic conclusion is that BW 7.0 workbook can't work with a large number of dataproviders/ queries. This did work in BEx BW 3.x.
If any one has any other suggestion, more than welcome.
Cheers,
Ron -
Workbook with multiple queries on multiple tabs
Scenario: There is a workbook with multiple queries on multiple tabs.
In 3.x, it was possible to refresh only a select query within the WB but I'm not finding this to be the case in the NW04s BEx Analyzer. It seems that it will always refresh all queries on all tabs.
Do any of you know a way around this?Hi Bigtoja (and others).
This is not possible in BI/2004s.
Please refer to https://websmp106.sap-ag.de/~sapidb/011000358700004483762006E page 23. It seems that it will be implemented in a stack sometime in 2008.
BR
Stefan
Maybe you are looking for
-
I got a new PC. I have an iTunes account on my iPod as well but I set it up properly on here as well this is a Pavilion HP G6 it has windows 8. I dowloaded iTunes onit, it works fine. I bought "We're the Millers" today on iTunes and it gets me upset
-
My phone is saying that it can not be activated
What can I do?
-
Hi, I've just purchased the Adobe® Creative Suite® Design & Web Premium CS6 (to upgrade from 5.5). It claims that I don't own a qualifying product, I do though, and have entered the serial number several times without success... Help?
-
FEATURE REQUEST: Preserve Transparency of Files when Opening As Layers in Photoshop
I am a digital scrapbooker and I have begun using Lightroom to organize my digital scrapbooking supplies. A file format that is very common in digital scrapbooking is PNG format. However, PNG is not setup to accept metadata so part of my workflow i
-
Don't buy U330! Wifi 'Local Only' Issue can't connect to internet anywhere!
If you are familiar with the local only problem, like I have become in recent weeks, you know the frustration of not being able to connect to the internet with your brand new computer when your ten year old laptop can surf the web with no problem. No