Duplicate Entries in query Selection Criteria
Hi,
I am having Infoobject 'period' in Query Filter,in drop down of selection it is showing Two values for each period.
This infoobject is fetching data from master table T009B,This table is having Two calenders for period.
Please let me know what can I do to restrict to single entry for each period.
Thanjks
Sudhakar
Hi Sudhakar
You can use Customer exit variable if not already using. That way you can remove duplicate entries via little ABAP.
You can go through the following link for the steps involved in creating a Customer Exit variable.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d09d4588-3832-2c10-e185-f778d9dbea85?quicklink=index&overridelayout=true
Regards,
Kush Kashyap
Similar Messages
-
Query selection criteria - changing description field..?
Hi Experts,
i want to change description filed in user query selection criteria form..
i have 3 fileds :
docdate - this filed i want to chage 'Document First'
docdate - This filed i want to change 'Document Last'
name -
my problem: screenshot
[Click Here|http://img638.imageshack.us/img638/3466/userqueris.jpg]The system always asks with the description of the field you refer to with the parameter variable in the select statement.
I sometimes defined a UDT only for getting the appropriate title in the parameter entering window. The table has no data; I used it only for its field names.
(The parameter request can be placed inside a comment and the entered value is used setting an SQL variable like this:
declare @d datetime
/*select t.createdate from ordr t where t.createdate=[%0]*/
set @d=[%0]
This SQL variable can be used later in the real query.)
(But then you loose the possibility to choose from the u2018List of existing valuesu2019 -
Hi Gurus,
In the cube we have Valid from and Valid To date. in the Selection Criteria user needs to select Period (mm/yyyy) valid from and validto i e Start date and End date. If I am using intrvel in Valid from variable definition i .e selection criteria we are selecting the valid from start date and end date. We need to select valid from Start date and Valid to End date. how will we do this in the query.
proper response will be rewarded with points.
Thanks
RKHi,
Create a variable and select the options as per your requirement wheather single value or multiple single values or interval range etc on the infoobject in the query which you want to see.
Cheers,
Malli......... -
Hi all experts,
I have a problem making my selection criteria on this query for the user to input the numbers 1 to 10 variables
is there anything that can help me to resolve this
I have tried many times but it just does not work
Query me this:
SELECT
T1.[DocEntry], T0.[CardCode], T0.[CardName], T0.[DocDate], T1.[ItemCode], T1.[Dscription], T1.[Price], T2.[LastPurPrc]T1.[NumPerMsr] AS 'Last Purchase Price', (T1.[Price] - (T2.[LastPurPrc]T1.[NumPerMsr])) AS 'Variance', (((T1.[Price] - (T2.[LastPurPrc]T1.[NumPerMsr]))/(T2.[LastPurPrc]T1.[NumPerMsr]))*100) AS 'Variance%', T3.[SlpName]
FROM
OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode
WHERE
(T2.[LastPurPrc] > 0) AND Month(T0.[DocDate]) = Month(Getdate()) AND Year(T0.[Docdate]) = Year(Getdate()) AND ((((T1.[PriceBefDi] - (T2.[LastPurPrc]T1.[NumPerMsr]))/(T2.[LastPurPrc]T1.[NumPerMsr]))*100) Between >= '[%0]'AND <= '[%1]')
ThanksTry this:
SELECT
T1.DocEntry, T0.CardCode, T0.CardName, T0.DocDate,
T1.ItemCode, T1.Dscription, T1.Price,
T2.LastPurPrc*T1.NumPerMsr AS 'Last Purchase Price',
(T1.Price - (T2.LastPurPrc*T1.NumPerMsr)) AS 'Variance',
(((T1.Price - (T2.LastPurPrc*T1.NumPerMsr))/(T2.LastPurPrc*T1.NumPerMsr))*100) AS 'Variance%',
T3.SlpName
FROM
OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OSLP T3 ON T0.SlpCode = T3.SlpCode
WHERE
(T2.LastPurPrc > 0) AND Month(T0.DocDate) = Month(Getdate())
AND Year(T0.Docdate) = Year(Getdate())
AND ((((T1.PriceBefDi - (T2.LastPurPrc*T1.NumPerMsr))/(T2.LastPurPrc*T1.NumPerMsr))*100)
Between [%0] AND [%1]) -
Check the user's entry from query selection screen
Hi,
Is there a way to check the user's entry at the selection screen? I created an exit variable and did some code to default a date to the selection screen. What if the user enters some other date, and I would want to check the value of this entry, where would I do this?
Thanks,
RTRT,
This can easily be done. You can read the variable after the user has entered some different value.
I_STEP = 2.
Read table i_t_var_range with key vnam =<your variable name >
Hope it helps.
Thx,
Soumya -
Can we use Selection Criteria Screen to tell Query which SQL script to run?
Dear All,
When I run this code, it gives me the screen below:
declare @ScanOp4 nvarchar (30)
set @ScanOp4=
/*select T3.U_ScanOp4 from [dbo].[@SCANNING] T3 where T3.U_ScanOp4*/ '[%0]'
I have used Tools -> Customization to define a UDT and UDF
Query - Selection Criteria
Invoice / Credit Note? [----------------- ]
(there's a drop-down arrow with 2 choices:
Inv = Invoice
CN = Credit Note
[OK] [Cancel]
Now, I have 2 very similar queries; the only difference is that they use different tables because one is for
Purchases (OPCH/PCH1), and the other is for Credit Memos (ORPC/RPC1)
I want to put the above declaration together with my 2 queries all in a single query so that:
(a) If I select 'Invoice', the Invoice part is executed and only invoices are displayed,
(b) If I select 'Credit Note', the Credit Note part is executed and only Credit Notes are displayed.
Do you think such a Query is possible? If yes, please give me an idea how I can achieve it.
I don't want to use UNION ALL because one of my fields is a LINK field to which I have linked all PDF Scanned documents.
I want to preserve the links, since this is the reason I'm writing the query.
Thanks
Leon Lai
Here are my skeleton codes
1st Query: User selects 'Invoice' -
SELECT
T0.[TaxDate] AS 'Doc Dt',
T5.[TransType] AS 'Txn Type',
T0.[DocNum] AS 'Doc No.',
T0.[DocTotal] AS 'Amount'
FROM [dbo].[OPCH] T0
INNER JOIN [dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]
2nd Query: User selects 'Credit Note' -
SELECT
T0.[TaxDate] AS 'Doc Dt',
T5.[TransType] AS 'Txn Type',
T0.[DocNum] AS 'Doc No.',
T0.[DocTotal] AS 'Amount'
FROM [dbo].[ORPC] T0
INNER JOIN [dbo].[RPC1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]Try this:
declare @ScanOp4 nvarchar (30)
set @ScanOp4=
/*select T3.U_ScanOp4 from [dbo].[@SCANNING] T3 where T3.U_ScanOp4*/ '[%0]'
If @ScanOp4='Inv'
SELECT
T0.[TaxDate] AS 'Doc Dt',
T5.[TransType] AS 'Txn Type',
T0.[DocNum] AS 'Doc No.',
T0.[DocTotal] AS 'Amount'
FROM [dbo].[OPCH] T0
INNER JOIN [dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID]
If @ScanOp4='CN'
SELECT
T0.[TaxDate] AS 'Doc Dt',
T5.[TransType] AS 'Txn Type',
T0.[DocNum] AS 'Doc No.',
T0.[DocTotal] AS 'Amount'
FROM [dbo].[ORPC] T0
INNER JOIN [dbo].[RPC1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OJDT] T5 ON T0.[TransID] = T5.[TransID] -
BEx Selection Criteria need to be change
Hi friends,
I need to change the Bex Query Selection Criteria from Date to Year.
Kindly Help me out on this Issue.
Thanks in Advance
PriyankaHi,
Let the variable for 0CALDAY be ZVARDAY of Processing type Customer Exit Interval
Let the variable for 0CALYEAR be ZVARYER of User Entry single value
Add the 0CALYEAR to the Filter and attach the variable ZVARYER
Go to Cmod transaction and add the code to the variable exit
check the code with an Abap Consultant.
WHEN 'ZVARDAY'.
IF i_step = 2.
READ TABLE i_t_var_range INTO zrange
WITH KEY vnam = 'ZVARYER'.
lyear = zrange-low+0(4).
CONCATENATE lyear '0101' INTO l_s_range-low.
CONCATENATE lyear '1231' INTO l_s_range-high.
APPEND l_s_range TO e_t_range.
regards
Happy Tony -
Can we make the SELECTION CRITERIA BOX act as a Menu / Submenu system?
Dear All,
I have written several queries.
For user convenience, I wish to combine all related queries in a single Query and use the Selection Criteria box as a Menu System to select which Query script to run.
I can already do this by the use of variables.
But all variables are shown in the Selection Criteria Box, and users must fill in only the relevant boxes.
It's not a problem, but as the number of Queries grows, the Selection box becomes quite long and distracting.
I wonder if it is possible to create a sub-menu?
Example
Let's say: When you run the Query, it gives this Selection Box:
Query - Selection Criteria
Choose a Report [ ]
There are 2 choices:
(a) AP Aging by Document Date
(b) AP Aging by Posting Date
[OK] [Cancel]
When you choose AP Aging by Doc Date, this Selection Box should pop up:
Query - Selection Criteria
Document Date [ ]
[OK] [Cancel]
And when you choose AP Aging by Posting Date, this Selection Box should pop up:
Query - Selection Criteria
Posting Date [ ]
[OK] [Cancel]
Please let me know if this kind of menu / sub-menu system is possible using SQL only?
I tried (see code below), but all variables appear on the initial screen (not what I expect) - like this:
Query - Selection Criteria
Choose a Report [ ]
Document Date [ ]
Posting Date [ ]
[OK] [Cancel]
Thanks
Leon Lai
Here's a test code: (not exactly for the illustration above)
declare @apaging1 varchar(max)
set @apaging1 =
/*select T6.U_apaging1 from [dbo].[@APAGING] T6 where T6.U_apaging1*/ '[%0]'
/* @apaging1 : [0 = Summary] [Detailed] */
If @apaging1 = ' ' set @apaging1 = 'Sum'
If @apaging1 = 'Sum'
GOTO Screen1
If @apaging1 = 'Det'
GOTO Screen2
Screen1:
begin
declare @aptxn nvarchar (30)
set @aptxn =
/*select T9.U_aptxn from [dbo].[@APTRXNS] T9 where T9.U_aptxn*/ '[%9]'
/*@aptxn: [0 = PU] [PC] [Both]*/
If @aptxn = ' ' set @aptxn = 'PU'
end
Screen2:
begin
declare @taxdt1 date
set @taxdt1=
/*select T1.[TaxDate] from [dbo].[OPCH] T1 where T1.[TaxDate]*/ '[%5]'
endDear István Korös
Thanks a lot.
Sad
At least, your answer will save me a lot of time searching for the unattainable.
Best Regards
Leon Lai -
How to count no. of days from selection criteria in BEx
hi,
I need to do some calculations in query and one of requirements is to count number of days for which query was executed (day period is in query selection criteria)
I would like to use it for calculated KF definition.
Does somebody knows how to get this number?
Regards,
AndrzejHi Andrzej,
The answer is correct - you have to do it in user-exit. You have to learn it becouse its a very powerfull solution and is very ofen used in reporting.
See help ... http://help.sap.com/saphelp_nw04/helpdata/en/f1/0a56f5e09411d2acb90000e829fbfe/content.htm
In the interface of this exit you will find all query selections + sy-datum = what you need.
Pozdrowka
Wojtek -
Can we change parameter descriptions in Selection Criteria. YES we can!
Dear All,
I have been struggling some time on some way to change the parameter descriptions in the Query - Selection Criteria screen.
While doing numerous tests on trial-and-error, I accidentally hit upon a solution which appears to work!
To change a parameter description, we simply have to reverse the order in which the WHERE clause is written.
Please refer to the Query below:
I used Customization Tools to create a UDT called @SCANNING
and a UDF called U_ourref
Title : ourref
Description : Our Reference
If I use WHERE clause the conventional way, ie
WHERE
T1.[ImportLog] = @ourref
I get the following Selection Criteria screen:
Query - Selection Criteria Screen
Import Log .........................
[OK] [Cancel]
If I write WHERE clause by interchanging the 2 sides of the equality, i.e
WHERE
@ourref = T1.[ImportLog]
I get this screen:
Query - Selection Criteria Screen
Our Reference .........................
[OK] [Cancel]
Well! Is this not a way of changing the parameter description?
And it works!
My Problem
The solution is nice. However, I wanted to use LIKE instead of EQUAL TO
in order to allow Query to search for similar items.
With the conventional clause, I can use '%[%1]%' in declaration and LIKE in the WHERE clause.
With the reverse clause, I cannot figure out how to do it.
Could anybody help?
Thanks
Leon Lai
declare @ourref nvarchar (30)
set @ourref =
/*select T2.U_ourref FROM [dbo].[@SCANNING] T2 where T2.U_ourref*/ '[%1]'
SELECT
T0.[TaxDate] AS 'Doc Dt',
T0.[DocNum] AS 'SAP Ref.',
T0.[CardName] AS 'Supplier Name',
T0.[DocTotal] AS 'Amount',
T1.[ImportLog] AS 'Our Ref',
T1.[BlockNum] AS 'Reqn No.'
FROM [dbo].[OPCH] T0
INNER JOIN [dbo].[PCH1] T1 ON T0.[DocEntry] = T1.[DocEntry]
INNER JOIN [dbo].[OJDT] T2 ON T0.[TransID] = T2.[TransID]
WHERE
@ourref = T1.[ImportLog]Dear István Korös ,
My main concern was modifying the Parameter Description in the Selection Criteria Screen.
I certainly tried your suggestion, and it works, but unless I modified the WHERE Clause
from :
T1.[ImportLog].@ourref
to:
@ourref = T1.[ImportLog]
the Selection Criteria screen shows:
Query - Selection Criteria Screen
Import Log .........................
[OK] [Cancel]
It is only after I have 'primed' the system by using:
WHERE
@ourref = T1.[ImportLog]
that the Parameter Description changes to:
Query - Selection Criteria Screen
Our Reference .........................
[OK] [Cancel]
I can then use your line:
WHERE T1.[ImportLog] like '%'@ourref'%'
without any problem. The amended Parameter Description remains!
I noticed something strange:
Once I have 'primed' the system, it always shows the amended description on the Selection screen!
Before priming, it always showed the system description.
Don't know why?
Anyway, I found a trick to 'prime' the system in all my queries to make sure the amended name appears
on the Selection screen. I write:
WHERE
(@ourref = T1.[ImportLog] OR
T1.[ImportLog] like '%'@ourref'%')
The first line is just for priming to ensure the Parameter Name will be changed.
The 2nd line is the correct code to use.
With this trick, we can change the Parameter Descriptions to whatever name we want.
The only problem is that you lose the function List of available values.
Thanks a lot,
Leon Lai -
Duplicate entries missing using for all entries in select query.
Hi Gurus,
Is there any way to avoid missing duplicate entries in an internal table if you use for all entries in select statement?
Note : i am selecting two tables using non key fields and i have to aggregate the data. I want only 2 data fields and one amount field in my final internal table. I can add all the primary key fields into my internal table and collect my required fields in another table, but I just want to know is there any other way to avoid missing duplicate entries without adding all the key fields?
Regards,
RaghavendraHi,
Just check what are the other possible fields in the table which may be having
duplicate entries and make use of them in the selection accordingly.
You may not miss any entries unless there is any restriction on them.
You can better judge that in debugging mode while selecting data from that table. -
FOR ALL ENTRIES stmnt. in SELECT query is not running properly
Hello experts,
In my report program, I write one query on table BSIS.
Internal table declaration -
DATA : BEGIN OF DLC_BSIS OCCURS 0,
BUKRS LIKE BSIS-BUKRS,
GJAHR LIKE BSIS-GJAHR,
BELNR LIKE BSIS-BELNR,
SHKZG LIKE BSIS-SHKZG,
BSCHL LIKE BSIS-BSCHL,
AUFNR LIKE BSIS-AUFNR,
HKONT LIKE BSIS-HKONT,
QSSKZ LIKE BSIS-QSSKZ,
DMBTR LIKE BSIS-DMBTR,
END OF DLC_BSIS.
Query as follows --
SELECT BUKRS
GJAHR
BELNR
AHKZG
BSCHL
AUFNR
HKONT
QSSKZ
DMBTR FROM BSIS
INTO TABLE DLC_BSIS
FOR ALL ENTRIES IN IT_BKPF2
WHERE BELNR = IT_BKPF2-BELNR
AND BUKRS = IT_BKPF2-BUKRS
AND GJAHR = IT_BKPF2-GJAHR.
IT_BKPF2 internal table having -- BUKRS - LT01
BELNR - 6400000061
GJAHR - 2009.
And in BSIS database table -- 3 entries are there for the above documnet.
But, in my internal only one entry has come for the same above document.
I think For all entries stmnt. is not running properly. But Why it's not running properly.??
What would be the reason..??
Thanks in advance....!!
Regards,
Poonam.>
Poonam Patil wrote:
> Hello experts,
> In my report program, I write one query on table BSIS.
>
> Internal table declaration -
>
> DATA : BEGIN OF DLC_BSIS OCCURS 0,
> BUKRS LIKE BSIS-BUKRS,
> GJAHR LIKE BSIS-GJAHR,
> BELNR LIKE BSIS-BELNR,
> SHKZG LIKE BSIS-SHKZG,
> BSCHL LIKE BSIS-BSCHL,
> AUFNR LIKE BSIS-AUFNR,
> HKONT LIKE BSIS-HKONT,
> QSSKZ LIKE BSIS-QSSKZ,
> DMBTR LIKE BSIS-DMBTR,
> END OF DLC_BSIS.
>
> Query as follows --
>
> SELECT BUKRS
> GJAHR
> BELNR
> AHKZG
> BSCHL
> AUFNR
> HKONT
> QSSKZ
> DMBTR FROM BSIS
> INTO TABLE DLC_BSIS
> FOR ALL ENTRIES IN IT_BKPF2
> WHERE BELNR = IT_BKPF2-BELNR
> AND BUKRS = IT_BKPF2-BUKRS
> AND GJAHR = IT_BKPF2-GJAHR.
>
> IT_BKPF2 internal table having -- BUKRS - LT01
> BELNR - 6400000061
> GJAHR - 2009.
>
> And in BSIS database table -- 3 entries are there for the above documnet.
>
> But, in my internal only one entry has come for the same above document.
>
> I think For all entries stmnt. is not running properly. But Why it's not running properly.??
> What would be the reason..??
>
>
> Thanks in advance....!!
>
> Regards,
> Poonam.
include the buzei field in selection criteria i have faced the same situation earlier.
always select all the key fields.
varun -
SQ01 query on LDB BRF with selection criteria on BSEG
Dear all,
we built an inofset on LDB BRF (BKPF - BSEG) and a query with selection criteria based on both BKPF and BSEG tables.
My proble : when the query select a posting fullfilling header data selection criteria but not line item criteria, it still displayed the header data in the layout.
We set up a filter on the account to hide results where account is blank but we loss the filter exporting the result on access. So if anyome has a better idea, we'll be very thankfull.
Br,Hi Rick,
What Edan proposed will work as logical AND (both filters on dates will be checked simultaneously).
Here is a solution.
Youll have a user entry variable on 0CALDAY.
- Create a new variable on 0CALDAY, customer exit, mandatory, not ready for input. This variable should return the date entered in user entry variable.
- Create a structure in columns.
- New selection (lets name it chg). Put there your KF and your Change date char. Restrict it by the user entry var. Hide it.
- New selection (lets name it crt). Put there your KF and your Created on date char. Restrict it by the customer exit var. Hide it.
New formula (lets name it FilteredAmount):
( 'chg' <> 0 ) * 'chg' + ( 'crt' <> 0 ) * 'crt'
Create a condition:
FilteredAmount <> 0.
Best regards,
Eugene -
How to call the same query more than once with different selection criteria
Hi,
Please do anybody know how to solve this issue? I need to call one query with the fixed structure more than once with different selection criteria. For example. I have following data
Sales organization XX
Income 2008 Income 2009
Customer A 10 20
Customer B 30 0
Sales organization YY
Income 2008 Income 2009
Customer A 20 5
Customer B 50 10
Now, I need this. At the selection screen of query, user fill variable charakteristic "Sales organization" with interval XX - YY, than I need to generate two separate results per sales organization, one for Sales Organization XX and the second for SO YYwhich will be displayed each on separate page, where result for SO YY will be dispayed under result for SO YY. Are there some options how to do it for example in Report Designer or WAD or with programming? In Report Designer is possible to use one query more than once, but I dont know how to force each query in RD to display result only for one Sales Organization, which will be defined in selection screen.
Thank you very much
J.Hello,
thanks to all for cooperation. Finally we solved this issue with the following way..
User fill appropriate SO on the selection screen, which is defined as range. This will resulte, that selected SO are listed in report below each othe (standard behavior). Required solution we achieved with the Report Designer, we set page break under each Result row of RD. This caused, that report is divided into required part per SO, which are stated each on separate page.
J. -
A/r Invoice report query based on posting date selection criteria
Hi experts,
I am trying to write a query to get the A/r invoice report including Docnum, Docdate, cardname, project, linetotal, taxcode, taxtotal.
and i tried the below query
SELECT T0.[DocNum], T0.[DocDate], T0.[CardCode], T0.[CardName],T1.[LineTotal] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1]
In this query ,
1) i am unable to sum up the linetotal( total before tax)
2) also unable to fetch the sum of taxamount.
3) its more important , the above query will me docnum , when i try to open that doc, it opens the 2007 docments. whereas the other details are correct like docdate, amount and all.
example: from date: 1/04/2011 to date: 28/07/2011
Docnum Docdate cardname linetotal.... etc
2 1/04/11 XYZ 5000
when i click the 2 (docnum) it opens me the 04/04/2007 documents.
how to limit the doc within the periods given?
thanks in advance
DwarakHi Rahul/Gordon,
thanks for your query's .
additionally, i want this query without the A/r invoices whichever having credit memo as target doc.
and
i have selection criteria as T0.[U_Sec_Category] = '[%2]' and this has 3 values like 1)CIM 2)BIN 3)DMP
among these CIM should be seen only only user1 and BIN & DMP only by user2.
can u plz get me this
thanks,
Dwarak
Maybe you are looking for
-
How do I change the text color in a call out box?
How do I change the text color in a call out box?
-
i have a to create a work book in which sheet1 of work book must show some 6 query results and there summary must come in sheet2 of same work book in barchart manner so can any body help me in how to show query result in second sheet of same work boo
-
How to export my ABAP web dynpro content to another server
Hi, I need to export my ABAP webdynpro application from one server to New server. Can any one please guide me how to do this. Regards, SPK.
-
Blackberry issues with WebDynpro application
We are testing a webdynpro application via a blackberry. The webdynpro application works fine from IE. With the blackberry, we see the following: - User logs into the application. After user's first access attempt, they no longer have to log in. We
-
Initial Service script in Endeca Application
Hi All, Agter creating the Endeca Application, there is a step that tells , to run initial-servies.sh, what is the exact use of this is given below, but where can i see these files ?? where is the location??Can you polease tell me the exact use oif t