Working on Pre-query
Hi Gurus,
While using a pre-query,can data of more than one field be passed from control-query to display-query?
How can we do that?
Thanks in advance
Walker
A prequery is usually used to send back filter values to another query based on comples selection conditions - I am not sure if a prequery can return multiple fields - even if it did - the replacement path variable is attached to a characteristic and in that case only the relevant characteristic should get passed on.
Arun
Similar Messages
-
Pre-Query - Modifying the default_where
Hi,
I'm trying to get the value of the default_where clause to modify it (with set_block_property) after the user has entered the ENTER QUERY MODE and decides to RUN QUERY. I'm creating a Pre-Query event for the module component where the search criteria are entered, but it doesn't seem to work; the where_clause (l_old_where) I retrieve is always empty. My code to retrieve the default_where is:
BEGIN
DECLARE
l_block VARCHAR2(32) := name_in('system.trigger_block');
l_old_where VARCHAR2(2000);
BEGIN
l_old_where := get_block_property(l_block, default_where);
message('l_old_where =' || l_old_where); --unfortunately this message always returns an empty value
EXCEPTION
WHEN VALUE_ERROR THEN
qms$forms_errors.push(QMS$FORMS_ERRORS.MSGGETTEXT(33, 'Query criteria too complex - simplify and re-query'), 'E', 'OFG', 33);
qms$forms_errors.raise_failure;
END;
END;
Does anybody know what I am doing wrong? Do you have a better way to retrieve the default_where value?
Thanks,
Denis.Denis,
The DEFAULT_WHERE is part of all queries. It is set either in the property palette at design time, or programatically at runtime. If a user does an enter query and specifies some criteria, that criteria is appended to the DEFAULT_WHERE. Thus, interrogating the DEFAULT_WHERE won't help you in this case.
There is no "nice" way to do this. You have about three triggers you can choose from, that get fired after the users has entered their criteria, but before the query is executed. One is PRE-QUERY, and I forget the other two. One of them is SET-QUERY or something like that.
What you do is interrogate the fields themselves. For example, if you have two fields: NAME and SALARY, and the user entered the criteria "A%" and ">5000", then it's up to you to examine those fields to see what the user typed. Then you can do with them what you will.
So you don't get the SQL that Forms generates, but you do get the same info that Forms uses to generate the SQL.
There is also a gotcha to look out for. When referring to fields in a block that are active during enter-query mode, use the NAME_IN builtin. For example, the SALARY field is of type number, but the criteria is ">5000". That ">" is not acceptable (normally) to a NUMBER field, so you will get errors if you do something like "message('Salary criteria: '||:block.salary);"
I hope this helps.
Regards,
Robin Zimmermann
Forms Product Management -
Pre query , post query where date = mon-yyyy
I have a tabular block B2 with many records
this block items are vouhcerno, voucherdate. voucherno number(6) and voucherdate date.
when new form instance i execute query it shows me all the records working fine.
I add one list item here when new form instance this list item got record like
Jan-2009
Feb-2009
Mar-2009
so on...
I want that when i select Jan-2009 from list item and press button
block B2 only show my January 2009 records.
I tried to this in pre query and also post query trigger but not successful.
Kindly guide me .Arun really tnx, you are helping me.
I m sorry Your this code also not working.
i want to add one more condition in this code
SET_BLOCK_PROPERTY('b2',DEFAULT_WHERE, 'to_char(voucherdate,''fmmon-fmYyyy'')= ''' || Lower(:vdate ) || '''' );
And :vtype = "PV'
{code}
I m using this
{code}
SET_BLOCK_PROPERTY('b2',DEFAULT_WHERE, 'to_char(voucherdate,''fmmon-fmYyyy'')= ''' || Lower(:vdate ) || 'and :B2.vtype = PV'|| '''' );
{code}
but Not return query. -
I have a Form that has 4 cascading List Item after you make a chose on the Bpost_Tag (4th) you press the Button Execute Query. On the Data Block I have PRE-QUERY as shown below! What I’m trying to get in return is if you chose Bpost_Tag 100 you will get all Bpost_Tags 100 and greater on the Form. Right now all I’m getting in return is one Bpost_Tag of 100.
Data Block
PRE-QUERY
DECLARE
wh_clause VARCHAR2(200);
BEGIN
IF :PMISCURR.SYSTEM is not null then
wh_clause := 'SYSTEM = '||:PMISCURR.SYSTEM;
END IF;
IF :PMISCURR.COUNTY is not null then
wh_clause := wh_clause ||' AND COUNTY = '||:PMISCURR.COUNTY;
END IF;
IF :PMISCURR.ROUTE is not null then
wh_clause := wh_clause ||' AND ROUTE = '||:PMISCURR.ROUTE;
END IF;
IF :PMISCURR.BPOST_TAG is not null then
wh_clause := wh_clause ||' AND BPOST_TAG >= '||''''||:PMISCURR.BPOST_TAG ||'''';
END IF;
Set_Block_Property ('PMISCURR', DEFAULT_WHERE, wh_clause);
END;
The Go_Block ('PMISCURR'); is on the Execute Query Button.
Edited by: Monty on May 13, 2011 12:06 PMAndreas
Based on the same Table!*
DATA BLOCKS:
PMISCURR
..........SYSTEM
..........ROUTE
..........COUNTY
..........BPOST_TAG
PMISCURR1
..........SYSTEM_1
..........ROUTE_1
..........COUNTY_1
..........BPOST_TAG_1
I moved the PRE-QUERY as is to PMISCURR1 still got all the values from the Database Table/PMISCURR_BPOST_TAG. I changed the SQL to point to PMISCURR1 and got the same results. I’m just having hard understanding what is wrong. I have asked several coworkers to take a look at it and all they say is it should work my guess is they don’t know either!
Changed POST-QUERY on PMISCURR!
DECLARE
wh_clause VARCHAR2(200);
BEGIN
IF :PMISCURR1.SYSTEM_1 is not null then
wh_clause := 'SYSTEM_1 = '||:PMISCURR1.SYSTEM_1;
END IF;
IF :PMISCURR1.COUNTY_1 is not null then
wh_clause := wh_clause ||' AND COUNTY_1 = '||:PMISCURR1.COUNTY_1;
END IF;
IF :PMISCURR1.ROUTE_1 is not null then
wh_clause := wh_clause ||' AND ROUTE_1 = '||:PMISCURR1.ROUTE_1;
END IF;
IF :PMISCURR1.BPOST_TAG_1 is not null then
wh_clause := wh_clause ||' AND BPOST_TAG_1 >= '||''''||:PMISCURR1.BPOST_TAG_1 ||'''';
END IF;
Set_Block_Property ('PMISCURR1', DEFAULT_WHERE, wh_clause);
END;
Monty -
Can't make simple 'IF' statement work in MS Query!?
I have read the existing threads on the subject but can't seem to make a simple 'IF' statement work in MS Query with a single table. I always get the following error:
Returns error message:
"Incorrect syntax near the keyword 'if'
Incorrect syntax near ','.
Statement(s) could not be prepared.
Here's my query (simplified, but not much):
select *
from table t
where t.modifieddate > if(t.active=0, date1, date2)
Just to see if I could get AN if statement to work, I've also tried:
SELECT t.active, if(t.active=0,2,3)
FROM CdmsTimeSheet.dbo.Registrations t
And
SELECT t.active, if(t.active='0','2','3')
FROM CdmsTimeSheet.dbo.Registrations t
And
SELECT t.active,
FROM CdmsTimeSheet.dbo.Registrations t
where datemodified>if(t.active='0',3/1/2014,1/1/2014)
and
SELECT t.active,
FROM CdmsTimeSheet.dbo.Registrations t
where datemodified>if(t.active='0',#3/1/2014#,#1/1/2014#)
I've been using excel/ms query for many years but not in the last year or two and am wondering if this was somehow removed? I tried using decode but then get a "not built-in function" error.
Please help! ThanksNot sure what kind of database you are using. In SQL Server, you should use 'Case when' Statement Or 'IIF' function instead of if.
e.g.
select
top (10) BusinessEntityID,iif( BusinessEntityID=1 , 'true' , 'false') as test
from HumanResources.Employee
order by BusinessEntityID
Wind Zhang
TechNet Community Support -
Why is the GROUP BY clause not working in my Query?
Dear All,
Below is the Query for a Summary Debtors Aged Analysis.
The GROUP BY clause does not seem to be working.
The Query returns all the unpaid invoices, instead of a single total row for each Customer.
If a Customer X has 10 unpaid invoices, 10 rows are displayed - one for each invoice.
I was expecting only 1 row for Customer X, 1 for Customer Y, etc.
This is what GROUP BY is supposed to do, but it is not doing its work.
What has gone wrong?
Thanks
Leon Lai
Here's my Query:
declare @taxdt datetime
set @taxdt
/*select 1 from jdt1 t0 where t0.TaxDate*/ = [%1]
SELECT
CASE
WHEN T0.Account = 1220101 THEN 'Prim Cust'
WHEN T0.Account = 1220102 THEN 'Fgn Cust'
WHEN T0.Account = 1220103 THEN 'Local Cust'
WHEN T0.Account = 1220104 THEN 'Staff Loan'
WHEN T0.Account = 1220105 THEN 'Dep with TP'
WHEN T0.Account = 1220106 THEN 'Adv to Cust'
WHEN T0.Account = 1220108 THEN 'Sund Drs'
ELSE 'Error ! ! !'
END AS 'Control A/c',
T1.CardCode AS 'BP Code',
T2.Notes2 AS 'BP Name',
SUM ((T0.Debit - T0.Credit)) AS 'Orig. Rs',
SUM ((T0.BalDueDeb - T0.BalDueCred)) AS 'Bal. Rs',
((SELECT SUM(T0.BalDueDeb) - Sum(T0.BalDueCred)
WHERE DateDiff(mm, T0.TaxDate, @taxdt) = 1))
AS '1 Mth Ago'
/* Similarly for other age brackets*/
FROM JDT1 T0
INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
LEFT OUTER JOIN OCPR T2 ON T1.CardCode = T2.Cardcode
LEFT OUTER JOIN OJDT T3 ON T0.TransID = T3.TransID
LEFT OUTER JOIN OINV T4 ON T3.TransID = T4.TransID
LEFT OUTER JOIN ORIN T5 ON T3.TransID = T5.TransID
WHERE
T1.CardType = 'C'
and (Balance) != 0
and (T0.BalDueDeb - T0.BalDueCred) != 0
GROUP BY T0.Account, T1.CardCode, T2.Notes2, T0.TaxDateDear Neetu,
Thanks for your reply.
This Query is a modification of the Query you posted in SAP B1 SQL TIPS & TRICKS
http://wiki.sdn.sap.com/wiki/display/B1/SAPB1SQLB-FNDebtorsAgingReportbydate
So, maybe instead of referring to my Query, let's refer to yours. It may be easier for you to understand me.
Once I understand the problem, I can adapt your query to suit my requirements
So, let's start with a clean slate:
The Query you have posted is for a DETAILED Debtors Aging Report.
This lists all outstanding invoices, and ages them in the Age Brackets.
What I want is a SUMMARY Debtors Aging Report.
This will give the total amount owed by each Customer, and this amount is broken down in the Age Bracket Columns
There will be a single row listed for each customer, something like this:
Customer Total Due Current 1 Mth 2 Mth 3 Mth etc
Alfred 500,000 300,000 200,000
Charles 800,000 100,000 300,000 400,000
How can you modify your query to make it become a Summary Report (1 line for each customer even if he has many invoices)?
Thanks
Leon Lai
Here's your code
SELECT T1.CardCode, T1.CardName, T1.CreditLine, T0.RefDate, T0.Ref1 'Document Number',
CASE WHEN T0.TransType=13 THEN 'Invoice'
WHEN T0.TransType=14 THEN 'Credit Note'
WHEN T0.TransType=30 THEN 'Journal'
WHEN T0.TransType=24 THEN 'Receipt'
END AS 'Document Type',
T0.DueDate, (T0.Debit- T0.Credit) 'Balance'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')<=-1),0) 'Future'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=0 and DateDiff(day, T0.DueDate,'[%1]')<=30),0) 'Current'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>30 and DateDiff(day, T0.DueDate,'[%1]')<=60),0) '31-60 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>60 and DateDiff(day, T0.DueDate,'[%1]')<=90),0) '61-90 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>90 and DateDiff(day, T0.DueDate,'[%1]')<=120),0) '91-120 Days'
,ISNULL((SELECT T0.Debit-T0.Credit WHERE DateDiff(day, T0.DueDate,'[%1]')>=121),0) '121+ Days'
FROM JDT1 T0 INNER JOIN OCRD T1 ON T0.ShortName = T1.CardCode
WHERE (T0.MthDate IS NULL OR T0.MthDate > [%1]) AND T0.RefDate <= [%1] AND T1.CardType = 'C'
ORDER BY T1.CardCode, T0.DueDate, T0.Ref1 -
LIKE operator is not working in SQL Query in XML file
Hi Gurus,
LIKE operator is not working in SQL query in XML template.
I am creating a PDF report in ADF using Jdeveloper10g. The XML template is as follows
<?xml version="1.0" encoding="WINDOWS-1252" ?>
<dataTemplate name="catalogDataTemplate" description="Magazine
Catalog" defaultPackage="" Version="1.0">
<parameters>
<parameter name="id" dataType="number" />
<parameter name="ename" dataType="character" />
</parameters>
<dataQuery>
<sqlStatement name="Q1">
<![CDATA[
SELECT ename, empno, job, mgr from EMP where deptno=:id and ename LIKE :ename || '%']]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="EmployeeInfo" source="Q1">
<element name="EmployeeName" value="ename" />
<element name="EMPNO" value="empno" />
<element name="JOB" value="job"/>
<element name="MANAGER" value="mgr" />
</group>
</dataStructure>
</dataTemplate>
if i pass the parameter value of :ename from UI, it doesn't filter. But if I give ename = :ename it retrieves the data. Can anyone help me why LIKE operator doesn't work here?
Appreciate your help,
Shyamal
email: [email protected]Hi
Well for a start, you are doing some very strange conversions there. For example...
and to_char(a.msd, 'MM/DD/YYYY') != '11/11/2030'
and to_char(a.msd, 'MM/DD/YYYY') != '10/10/2030'If a.msd is a date then you should e converting on the other side ie.
and a.msd != TO_DATE('11/11/2030', 'MM/DD/YYYY')
and a.msd != TO_DATE('10/10/2030', 'MM/DD/YYYY')Also, you may want to take into consideration nothing being input in :P2_ITEM_NUMBER like this...
AND INSTR(a.item_number,NVL(:P2_ITEM_NUMBER,a.item_number)) > 0Is item number actually a number or char field? If it's a number, you want to explicitly convert it to a string for using INSTR like this...
AND INSTR(TO_CHAR(a.item_number),NVL(TO_CHAR(:P2_ITEM_NUMBER),TO_CHAR(a.item_number))) > 0?
Cheers
Ben -
Windows 7 crashed after Creative Suite 6 Design and Web Premium completed an update. The only Windows restore point that worked was pre-installation of CS6 software. Now when trying to reinstall I get the 'installer failed to initialize' message. Have tried using the CC Cleaner Tool but nothing works? Any solution please. Was new computer and newly purchased CS6 software downloaded 2 days prior to the upgrade.
make sure you follow all the steps here, Use the CC Cleaner Tool to solve installation problems | CC, CS3-CS6
-
What is a pre query and in what circumstances it is used?
Please explain what is a pre query in BW mean,and when is it used...thank you for your answers...
Hi,
There is also a possibility to feed a variable with replacement path with a query result and use this variable for restriction in another query:
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/579b3c494d8e15e10000000a114084/frameset.htm
Best regards,
Eugene -
Can't work with the Query after I save a 3.5 Query in 7.0 Query Designer
Hello,
my Problem is, I open a 3.5 Query in a 7.0 Query Designer. Then I save as another name. When i Open the Query
i can't change things... WHY ? A Standart Transport is OK in RSA1, Transport, BexTransport. all ok..
can't work with the Query after I save a 3.5 Query in 7.0 Query Designer
Best RegadrsHi,
I cant click on it. It is grey..
I open the 3.x Query in a 7.0 Query Designer and save as another name.. Then I try to open it with the 7.0 tool. The Query is displayed. But I cant change something...
thnx -
Finding number of working days during query execution
Hi ,
We have a requirement to calculate number of working days during query execution. In the cube we got "received date", this will be used as a variable in the query. Based on the received date value entered, query needs to display number of products received from past 1, 2,3,4 days (working days should include weekends or public holidays).
1day 2 days 3 days 4 days 5 days
10 12 20 15 20
to me it appears as I need to create virtual key figures.
Regards,
RamzHi ramesh,
First try to create formula variables for start data and end date to calculate the no of working days.
Create a Variable ZSTDT --of type replacement path.
Type of Variable = Formula
Variable Name = ZSTDT
Characteristic = <info object>
For Intervals Use = Select From Value
Offset Start = 0000 Offset Length = 0000
Replacement var with : key
use the same steps to create one more formula variable to get end date.
Now create a formula to get the No of days.
once after getting no of days you can create buckets as per your need.
for more info check the below links
http://www.sd-solutions.com/SAP-HCM-BW-Replacement-Path-Variables.html
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/30f15839-0cf1-2b10-c6a7-ebe68cc87cdc?quicklink=index&overridelayout=true -
Building Query in Pre-Query. How to make it more Memory Efficient
Hello all,
I have a form with 2 Data Blocks.
First Block is used for giving query Parameters and second one returns the results based on a View.
I build the Select Clause in the pre-query based on the Parameters. So every time I have a Different Query.
Could that create problem in the Database Server due to parsing queries again and again?
Would using a Different approach (i.e. ref Cursors) be more memory Efficient?
ThanksThe pre-query is quite Large so I am pasting only a part of the Code (the rest of it Is Identical).
In the selects v is the alias of the View of the Second Data Block.
The :qf_ bind variables are fields of the First block where I give the Parameters.
IF :QF_IS_DISPLAYED=1 THEN
L_WHERE := L_WHERE || ' AND V.IS_DISPLAYED =''1''';
END IF;
IF :qf_colour IS NOT NULL THEN
L_WHERE := L_WHERE || ' AND item_colour=''' ||:qf_colour ||'''';
END IF;
IF :qf_product_item_colour IS NOT NULL THEN
L_WHERE := L_WHERE || ' AND product_item_colour=''' ||:qf_product_item_colour ||'''';
END IF;
IF :qf_product_length IS NOT NULL THEN
L_WHERE := L_WHERE || ' AND product_length=''' ||:qf_product_length ||'''';
END IF;
IF :qf_apf_batch_id IS NOT NULL THEN
L_WHERE := L_WHERE || ' AND apf_batch_id=' ||:qf_apf_batch_id;
END IF;
if :qf_prod_resource is not null then
L_WHERE := L_WHERE ||' AND v.resources = ''' ||:qf_prod_resource ||'''';
end if;
if :qf_customer_number is not null then
L_WHERE := L_WHERE || ' AND FACTORY_ORDER_ID IN (SELECT FA.FACTORY_ORDER_ID
FROM OE_ORDER_HEADERS_ALL OH,
RA_CUSTOMERS RA,
XXSC_DEMAND_LINES DL,
XXSC_FACTORY_ORDERS FA
WHERE OH.SOLD_TO_ORG_ID = RA.CUSTOMER_ID
AND DL.SOURCE_HEADER_ID = OH.HEADER_ID
AND DL.FACTORY_ORDER_ID = FA.FACTORY_ORDER_ID
AND RA.CUSTOMER_NUMBER = ''' ||:qf_customer_number ||''')';
end if; -
4.0 EA2 - Autofit not working properly in Query Result grid
Hi,
in 4.0 EA2 the Autofit isn't working properly in Query Result grid.
Rather than shrinking columns to the narrowest size that accommodates headings and contents (as per 3.2), it auto-expands to fit the whole data query grid.
It looks worse, and makes it harder to see results at a glance.Bug and will be fixed for v4 release.
-
Urgent please _ pre query
Dear Experts,
I have a query based on a Multiprovider with 2 cubes (inventory cube and sales order cube). I need extra information of material like material size, season and colour. So I have been advised to include an Ods/DSO in order to get this information as it is not available in the above cubes an to write a pre query for size, season, colour . I never done this before.
Could you please guide me, urgent please? Do I need to add ods as I added the cubes before to Multiprovider and identify chars and keyfigures and then activate?
How should I write pre query? How can I link the query I have with the pre query? Please help me
Thanks,
RiyaActually the fastest and most efficient way of doing will be adding the requested fields in the cube and load the data from DSO to cube, if the DSO is feeding data to the cube. If you don't want to go that route, then you need to include the DSO in your multiprovider and identify the fields you need, since all the cube fields are already in the DSO, then there is no need to keep the cube in the multiprovider. Now you will have one dso and one cube in the multiprovider and in identification you specify all the fields as it is in the cube you had removed.
Hope I am clear.
thanks.
Wond -
Hi,
I have a datablock in the form that is based on a DB table. There are few queriable fields in the block including begin and end dates. If i dont use any pre-query trigger, the records are queried fine. But I want to do a range selection between begin and end_Date fields. Therefore I created a pre-query trigger and set a new_where_clause with all my query_fields and set that as defualt where for my DB block.
SET_BLOCK_PROPERTY (block_id,default_where, where_clause);
But when I see the query in toad session , the query looks like
WHERE (field_1 = :1) and field_1 = :1
that means its running the defualt where clause on the block and the new_where clause at the same time.
I checked the form and I dont have any calls to execute query....
what can be the problem?1. What is your new_where_clause? (example, please)It's hard to read. Use the \{code\} tag.
FUNCTION get_comparison_phrase (database_column_name VARCHAR2,
relational_operator VARCHAR2,
selection_field_name VARCHAR2)
RETURN VARCHAR2 IS
BEGIN
RETURN CASE
WHEN NAME_IN (selection_field_name) IS NOT NULL THEN
' AND '
|| database_column_name
|| relational_operator
|| ' :'
|| selection_field_name
ELSE
NULL
END;
END get_comparison_phrase;
where_clause := 'WHERE (1=1)';
if NAME_IN (selection_field_name) IS NOT NULL THEN ' AND '
|| database_column_name
|| relational_operator
|| ' :'
|| selection_field_name
ELSE
NULL
END;
where_clause :=
where_clause
|| get_comparison_phrase (
'screening_group_num',
'=',
'EXCEPTIONAL_EVENTS.screening_group_num'
WHERE (field_1 = :1) and field_1 = :1I do not see 'WHERE (1=1)'; there.
Edited by: Michael Roy on Oct 21, 2009 9:47 AM
Maybe you are looking for
-
How to extract data from an arbitrary xml file and export in a nice csv file?
Hallo, I'm facing big problems in the use of XML files. I have an application which generates XML files with clusters containing arrays and scalars like in the example pasted below. My task is to read it and export the data in a human-friendly CSV do
-
Firefox 5 screwed up a lot of my computer ,How can I remove it ??
'''bold text'''HOW TO GET RID OF FIREFOX 5 , SLOWS MY COMPUTER DOWN
-
Need help in the dessert here!!!!
i cant get videos to show up on my iPod ever since i made the mistake to upgrade to the iTunes 7. its working fine with all the videos and movies i had from before the upgrade but now whatever i put on my iPod shows as being there in iTunes but doesn
-
How to display the HTML pages in RRC/RQM dashboard using OpenSocial gadget
Hi, I have a requirement as below: 1. I have couple of HTML pages which are hosted in the sharepoint site and I would like to display the HTML pages 2. I would like to have an OpenSocial gadget in the RRC/RQM dashboard that will display the HTML page
-
CIMC on C210 server throws Error 2001: Service not available message
I am trying to configure vmware on a brand new C210 server for the first time and the directions say to access the CIMC and load the vmware media. Sounds easy enough except every time I go to the CIMC webpage I recieve an " error 2001: Service not av