Data for query
Hi guys,
I need to write a query that shows the average cost of an item before a landed costs document is posted, and then after the landed costs document is posted.
I know I can get the after by just retrieving avgprice from OITM, but how can I get the before cost?
I'm guessing something using OINM, perhaps distinguishing between document types and dates to pick up the last entry's average costs before the latest landed costs document was posted?
Any tips would be greatly appreciated.
Thanks,
Michael
Hi Michael,
This query is not that simple because it will be difficult to find the right time to calculate that cost and match all system calculations for item histories till that date.
What kind of time frame you are looking for this particular query? I mean: Do you want it on any dates no matter how long times ago?
Thanks,
Gordon
Similar Messages
-
Dear All,
I have created a customer exit variable on key date of a query.
With this input variable i am first asking user to input one particular date say he enters 31.12.2010 then i am trying to add 1 more day to it and making it 01.01.2011.
I have put a break point in the code but it does not stop the processing there.. report executes directly taking the first user input.
I want to add 1 more day to the user entered date and this modifiied date should be the input date for key date field.
Below is my code.
WHEN 'ZCAL_DAY_EXT'.
IF I_STEP = 2. "after the popup
LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
WHERE VNAM = 'ZCAL_DAY_EXT'.
CLEAR L_S_RANGE.
ENDLOOP.
DATA: v_temp like sy-datum.
v_temp = loc_var_range-low.
v_temp = v_temp + 1.
L_S_RANGE-LOW = v_temp.
L_S_RANGE-SIGN = 'I'.
L_S_RANGE-OPT = 'EQ'.
APPEND L_S_RANGE TO E_T_RANGE.
ENDIF.
Do let me know where am i going wrong? Or is it we cannot use customer exit with Key date.
Thanks & Regards,
Anup
Edited by: Anup Chaudhari on Aug 2, 2011 7:16 AMHi Anup,
Basically I_STEP = 1 is used for populating the default value which will be shown on selection screen and I_STEP = 2 is the step in which you does the processing on variable values which are entered on selection screen.
I am surprised that your internal table is empty, actually it is supposed to contain all the variable values which are entered in I_STEP = 1.
Can you try to add some more variables along with the current variable and check whether their value is coming in the internal table or not?
Finally what you can try is get the user input date in one variable and then create another customer exit variable in which you will calculate the new value and use this variable in Key date, the problem might be that we are trying to modify the same variable, actually it should not be the problem but I have no clue what is happening and you can just try this alternative.
Regards,
Durgesh. -
How to Get Missing Dates for Each Support Ticket In My Query?
Hello -
I'm really baffled as to how to get missing dates for each support ticket in my query. I did a search for this and found several CTE's however they only provide ways to find missing dates in a date table rather than missing dates for another column
in a table. Let me explain a bit further here -
I have a query which has a list of support tickets for the month of January. Each support ticket is supposed to be updated daily by a support rep, however that isn't happening so the business wants to know for each ticket which dates have NOT been
updated. So, for example, I might have support ticket 44BS which was updated on 2014-01-01, 2014-01-05, 2014-01-07. Each time the ticket is updated a new row is inserted into the table. I need a query which will return the missing dates per
each support ticket.
I should also add that I DO NOT have any sort of admin nor write permissions to the database...none at all. My team has tried and they won't give 'em. So proposing a function or storable solution will not work. I'm stuck with doing everything
in a query.
I'll try and provide some sample data as an example -
CREATE TABLE #Tickets
TicketNo VARCHAR(4)
,DateUpdated DATE
INSERT INTO #Tickets VALUES ('44BS', '2014-01-01')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-05')
INSERT INTO #Tickets VALUES ('44BS', '2014-01-07')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-03')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-09')
INSERT INTO #Tickets VALUES ('32VT', '2014-01-11')
So for ticket 44BS, I need to return the missing dates between January 1st and January 5th, again between January 5th and January 7th. A set-based solution would be best.
I'm sure this is easier than i'm making it. However, after playing around for a couple of hours my head hurts and I need sleep. If anyone can help, you'd be a job-saver :)
Thanks!!CREATE TABLE #Tickets (
TicketNo VARCHAR(4)
,DateUpdated DATETIME
GO
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-01'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-05'
INSERT INTO #Tickets
VALUES (
'44BS'
,'2014-01-07'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-03'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-09'
INSERT INTO #Tickets
VALUES (
'32VT'
,'2014-01-11'
GO
GO
SELECT *
FROM #Tickets
GO
GO
CREATE TABLE #tempDist (
NRow INT
,TicketNo VARCHAR(4)
,MinDate DATETIME
,MaxDate DATETIME
GO
CREATE TABLE #tempUnUserdDate (
TicketNo VARCHAR(4)
,MissDate DATETIME
GO
INSERT INTO #tempDist
SELECT Row_Number() OVER (
ORDER BY TicketNo
) AS NROw
,TicketNo
,Min(DateUpdated) AS MinDate
,MAx(DateUpdated) AS MaxDate
FROM #Tickets
GROUP BY TicketNo
SELECT *
FROM #tempDist
GO
-- Get the number of rows in the looping table
DECLARE @RowCount INT
SET @RowCount = (
SELECT COUNT(TicketNo)
FROM #tempDist
-- Declare an iterator
DECLARE @I INT
-- Initialize the iterator
SET @I = 1
-- Loop through the rows of a table @myTable
WHILE (@I <= @RowCount)
BEGIN
-- Declare variables to hold the data which we get after looping each record
DECLARE @MyDate DATETIME
DECLARE @TicketNo VARCHAR(50)
,@MinDate DATETIME
,@MaxDate DATETIME
-- Get the data from table and set to variables
SELECT @TicketNo = TicketNo
,@MinDate = MinDate
,@MaxDate = MaxDate
FROM #tempDist
WHERE NRow = @I
SET @MyDate = @MinDate
WHILE @MaxDate > @MyDate
BEGIN
IF NOT EXISTS (
SELECT *
FROM #Tickets
WHERE TicketNo = @TicketNo
AND DateUpdated = @MyDate
BEGIN
INSERT INTO #tempUnUserdDate
VALUES (
@TicketNo
,@MyDate
END
SET @MyDate = dateadd(d, 1, @MyDate)
END
SET @I = @I + 1
END
GO
SELECT *
FROM #tempUnUserdDate
GO
GO
DROP TABLE #tickets
GO
DROP TABLE #tempDist
GO
DROP TABLE #tempUnUserdDate
Thanks,
Shridhar J Joshi
<If the post was helpful mark as 'Helpful' and if the post answered your query, mark as 'Answered'> -
Query returns data from previous month. Need to have it return data for the entire year
This is the part of the query that returns data by month:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)AND MONTH(`rereport`.`market_reports_5`.start_date) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH))
How can I get it to return data for the year.
TIYHow about omitting the MONTH part:
(YEAR(`rereport`.`market_reports_5`.start_date) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Are Cube organized materialized view with Year to Date calculated measure eligible for Query Rewrite
Hi,
Will appreciate if someone can help me with a question regarding Cube organized MV (OLAP).
Does cube organized materialized view with calculated measures based on time series Year to date, inception to date eg.
SUM(FCT_POSITION.BASE_REALIZED_PNL) OVER (HIERARCHY DIM_CALENDAR.CALENDAR BETWEEN UNBOUNDED PRECEDING AND CURRENT MEMBER WITHIN ANCESTOR AT DIMENSION LEVEL DIM_CALENDAR."YEAR")
are eligible for query rewrites or these are considered advanced for query rewrite purposes.
I was hoping to find an example with YTD window function on physical fact dim tables with optimizer rewriting it to Cube Org. MV but not much success.
Thanks in advanceI dont think this is possible.
(My own reasoning)
Part of the reason query rewrite works for base measures only (not calc measures in olap like ytd would be) is due to the fact that the data is staged in olap but its lineage is understandable via the olap cube mappings. That dependency/source identification is lost when we build calculated measures in olap and i think its almost impossible for optimizer to understand the finer points relating to an olap calculation defined via olap calculation (olap dml or olap expression) and also match it with the equivalent calculation using relational sql expression. The difficulty may be because both the olap ytd as well as relational ytd defined via sum() over (partition by ... order by ...) have many non-standard variations of the same calculation/definition. E.g: You can choose to use or choose not to use the option relating to IGNORE NULLs within the sql analytic function. OLAP defn may use NASKIP or NASKIP2.
I tried to search for query rewrite solutions for Inventory stock based calculations (aggregation along time=last value along time) and see if olap cube with cube aggregation option set to "Last non-na hierarchical value" works as an alternative to relational calculation. My experience has been that its not possible. You can do it relationally or you can do it via olap but your application needs to be aware of each and make the appropriate backend sql/call. In such cases, you cannot make olap (aw/cubes/dimensions) appear magically behind the scenes to fulfill the query execution while appearing to work relationally.
HTH
Shankar -
Query for onhand qunatity with particular date for eam
hi all ,
following query are showing wrong value for on hand quantity with particular date mean work order issue date for quantity .
can u show me where is problem in this query.
SELECT ood.organization_name, wrov.concatenated_segments item_number,
wrov.item_description description, wrov.item_primary_uom_code uom,
-- SUM (on_hand.on_hand) quantity_in_stock,
SUM (on_hand.on_hand) + wrov.quantity_issued quantity_in_stock,
we.wip_entity_name work_order_number,
TRUNC (we.creation_date) work_order_date,
fu.user_name work_order_made_by, wrov.quantity_issued,
trunc(cic.material_cost,2) issue_rate_per_qty,
wrov.quantity_issued * trunc(cic.material_cost,2) quantity_value,
--SUM (on_hand.on_hand) - wrov.quantity_issued balace_qty,
SUM (on_hand.on_hand) balace_qty,
SUM (on_hand.on_hand)
* trunc(cic.material_cost,2) COST,
eam.ATTRIBUTE1 EQUIPEMENT_NO
-- gcc.SEGMENT6 equipement_no
FROM wip_entities we,
wip_requirement_operations_v wrov,
org_organization_definitions ood,
mtl_onhand_total_mwb_v on_hand,
fnd_user fu,
cst_item_costs cic,
eam_work_orders_v eam
-- gl_code_combinations gcc,
-- WIP_TRANSACTION_ACCOUNTS wta ,
-- WIP_TRANSACTIONS wt
WHERE wrov.wip_entity_id = we.wip_entity_id
AND ood.organization_id = wrov.organization_id
AND wrov.inventory_item_id = on_hand.inventory_item_id
AND on_hand.organization_id = ood.organization_id
AND we.created_by = fu.user_id(+)
AND cic.inventory_item_id = wrov.inventory_item_id
AND cic.organization_id = wrov.organization_id
--AND we.wip_entity_name = '179542'
AND wrov.organization_id = nvl(:organization_id,wrov.organization_id)
AND (we.wip_entity_name = :job_order_No OR :job_order_No IS NULL)
and trunc(we.creation_date) between nvl(:from_date ,trunc(we.creation_date)) and nvl(:too_date ,trunc(we.creation_date))
and eam.WIP_ENTITY_NAME=we.wip_entity_name
and eam.WORK_ORDER_STATUS in('Complete','Complete - No Charges' ,'Released')
-- and gcc.CODE_COMBINATION_ID =wta.REFERENCE_ACCOUNT
-- and wta.TRANSACTION_ID =wt.TRANSACTION_ID
-- and we.wip_entity_id =wta.WIP_ENTITY_ID
GROUP BY ood.organization_name,
wrov.concatenated_segments,
wrov.item_description,
wrov.item_primary_uom_code,
we.wip_entity_name,
we.creation_date,
fu.user_name,
wrov.quantity_issued,
cic.material_cost,
eam.ATTRIBUTE1
-- gcc.SEGMENT6
order by we.wip_entity_nameI don't think there is any special predicate to do that, Code is simply getting all children of given asset and returning them (Offcource there is some ordering logic). If You want exact informaiton I would suggest to use json call that DAM is making i.e.
HOST:POST/<PATH OF DAM>.assets.json
Or decompile AssetListServlet.java ans see how it is implemeted
Yogesh
www.wemblog.com -
Can we create range variable for Query Key Date
Hello Gurus,
Can we create a range variable for Query Key Date ? when I tried to give a range of values for Query Key Date, I am unable to find Range Values option. I found only Single Values.
so, Please let me know if we can use Range variables for Query Key Date ??
Thanks in advance,
Regards,
AarthiHi Aarthi,
This is relevant for the time dependant master data that is being pulled in thw query. Like if you are using a nav attr in the query and this nav attr is time dependant, then which record (from the char master data) is to be pulled into the report, depends upon the key date that you specify.
The default key date value is the date on which the query is executed, that is <Today>.
Hope this helps... -
Hi All,
I am using time dependent master data, i want to count number of employees on particular key date for diffferent Orgunits. So i created variable in the query properties for dynamic date selection .I also have other variable - Calendar month.
If the user enters particular Calendar Day (21.03.2008), then the report should show the total number of employees for that particular day.
If the user chooses Cal Year/month then the report should show the total number of employees for that time frame (12.2007-12.2008).
When i enter Cal Year/month and execute the system not allowing to execute the report. It says Calender Day is mandatory.
How can i bypass the calenderday when i choose calyear/month.
Variable for Key date :
Char - Calender Day
Mandatory
Ready for Input
Regards
A.VasisterHi,
For this work you have to create another 2 variable.
1. Make your both user entry variables as optional.
2. Create another 2 variables processing type as user exit.
3. In the CMOD program, identify which variable contains data.
- If the user entered month, then in the user exit of Calender day's from date should be
first day of the month parameter and to date should be the last date of the month parameter.
- If the user entered date, then pass corresponding month&year value of the date to calmonth variable.
Let me know the position.
Vivek -
Query picking data for the running request
Hi Guyz,
Am working on BW 3.5,
We run a query on a Multicube on daily basis, the scenario here is when we ran a query during one of the infocube load which was not activated and not ready for reporting (Request for reporting available symbol is missing), even then the query picked data for the request which was still running.
Cheers!
Ravi
Edited by: Ravi Srinivas on Aug 18, 2009 1:20 PMGood to know that your doubts are cleared...
For more information browse through SDN and have a look at these notes:
Note 411725 - Questions regarding transactional InfoCubes
Note 1063466 - Transactional request is not set to qualok
Hope it helps...
Regards,
Ashish -
No data Found for Query with hierarchy in 2004S SP10 in JAVA Stack
Hello,
I have typical issue while running the simple query in ABAP Web and JAVA Web (RSRT) with One row and one column. The char in the row is restricted with external hierarchy.
If I run in ABAP web, I get the results.
If I run in JAVA Web, No data found message displayed.
Does any one come across this issue. Tried to get SAP note but not clear solution.
If any one give me information where I can find the values used for query variable in the dictionary tables I might help in my investigation.
Advanced thanks.
RamanaHello,
Sorry I missed a point.
The char on which the hierarchy is resferencing char. Effectively using the hierarchy of referenced char.
Thanks. -
Maintaining Text data for IT0102 in Ad Hoc Query
We use the "Maintain Text" function to store comments and additional data for Grievance information on IT0102. I need these comments to be included in a query for IT0102, however I only see the indicator for if text exists...there's no "field" to select to show the actual text - mainly because it's a note and not a field.
Any suggestions???Hi,
you could make a custom field in your infoset for infotyp 0012. Then you could append code to this field and read the text with function module
HR_ECM_READ_TEXT_INFOTYPE into this field.
Regards Bernd -
Data Blocks - Different data source for Query and DML
Would anyone please tell me if it is possible in a BLOCK to define a stored procedure for queriying and a table for DML operations or vice-versa at the SAME time.
If possible how do you do it using DATA BLOCK WIZARD? If you select your block to be based on stored procedure then it gives only stored procedure options for Querying and DML operations in next few screens.
Also, suppose I used a stored procedure defined in a block for insert operations, is it implicitly called by INSERT RECORD function key in default menu? How does it take values from different fields on its own?Hi Deepon,
We get data from both BSIK(open items)and BSAK (cleared items). Obviously if a accounting doc is not cleared it would be in open items and vice versa..
Go through the help link for more information..
http://help.sap.com/saphelp_bw33/helpdata/en/90/10e73a86e99c77e10000000a114084/frameset.htm
Regards
Manga(Assign points if it helps)
Message was edited by: Manga -
Abap query : retrieve max date for the each unique material
Hi
I am facing problem formulating an ABAP query to retrieve records of table1 - material , table2 - doc no , table2 - doc date.
I need records having maximum doc date for each material.
I have used inner join on doc no on both tables.
Please help.
Thanks in advance
Ash RHello Mr.Ravi,
I have used descending for "date" but i want single record for each material.
it is like this:
SELECT AMATNR EMBLNR E~BUDAT
INTO CORRESPONDING FIELDS OF TABLE IT_FSN
FROM MSEG AS A INNER JOIN MKPF AS E ON EMBLNR = AMBLNR
UP TO 1 ROWS
WHERE AWERKS = P_PLANT AND ABWART IN S_MTYPE AND E~BUDAT IN S_DATE
GROUP BY AMATNR EBUDAT E~MBLNR
ORDER BY E~BUDAT DESCENDING.
I'm not able to get what i'm missing.
please help.
Regards,
Ash R -
Bulk request for query creation date
Hello community,
I have a list of technical names for 300+ queries, and I've been asked to provide the creation date for each one.
I can find the creation dates one at a time using the BEx query properties. But can someone tell me which table of the database this information is stored in ?
I would like to run a single search and pull the creation date for all 300+ queries at one time.
Thanks!
Take care.
Keithhi,
hope this link will help
http://help.sap.com/saphelp_erp2005/helpdata/en/85/44df3d0eb8af5ee10000000a114084/frameset.htm
regards
Varun -
Sql query to get Thursday (Date) for the year 2014
Hello All,
I want to get the date for all the Thursdays in the year 2014. How can I achieve this using SQL query? Can anybody give me a hand with this? Thanks.
AmolHi,
Check if this can help you
DECLARE @counter INT
DECLARE @Date Date
SELECT @counter = 0
Select @Date = '20131226'
WHILE @counter <= 52
BEGIN
select Thursday = convert(varchar(10),DATEADD(WEEK,1, @Date),120)
SELECT @counter = @counter + 1
Select @Date = DATEADD(WEEK,1, @Date)
END
Regards
Prasad Tandel
Please dont forget to mark as answer if this helps you :)
Maybe you are looking for
-
Multiple VI on a Single Front Panel
Probably a simple question but I'm having trouble figuring out how to do it. First, I have LabView 2010, Professional Development System I have been trying to learn LabView the hard way. I've been reading the documentation, starting with Getting Sta
-
Installed Libraries and Solo Instruments
Hi My son and I have been teaching ourselves how to use this software and are having some great results with it. However, I am not sure whether all the libraries have installed properly as we do not seem to have a solo trumpet or trombone for example
-
Hi, the CSV output link is now shown in Easy- and SQL report. How to ? - I did check Yes and named it in the report attributes page.(1.5.0.00.33 - IE6.0) TIA brgds Bernhard
-
Navigation problem in using ITS
I have one created one module pool program for goods movement. its having 6 screens. in order to get this program in the mobile divice i have configured ITS. I have created Internet Service is se80 and in SICF. Now i am getting the first screen in th
-
Make separate pages in Number '09
I am creating a Table of Contents; would like each letter of the alphabet to be a new page. How do I create 26 separate pages without adding/deleting rows? I will be adding new entries constantly so adding/deleting rows would be too cumbersome.