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 R
Hello 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
Similar Messages
-
In mdx how to get max date for all employees is it posible shall we use group by in mdx
in mdx how to get max date for all employees is it posible shall we use group by in mdx
example
empno ename date
1 hari 12-01-1982
1 hari 13-06-2000
by using above data i want to get max dataHi Hari3109,
According to your description, you want to get the max date for the employees, right?
In your scenario, do you want to get the max date for all the employees or for each employee? In MDX, we have the Max function to achieve your requirement. You can refer to Naveen's link or the link below to see the details.
http://www.sqldbpros.com/2013/08/get-the-max-date-from-a-cube-using-mdx/
If this is not what you want, please provide us more information about the structure of you cube, so that we can make further analysis.
Regards,
Charlie Liao
TechNet Community Support -
Select Max record for the report
Post Author: ROMZILBER
CA Forum: WebIntelligence Reporting
Hello,
Here is our problem we have history data on a table like
Example
Data:
11111 bbb 12/31/2004
11111 nnn 12/31/2005
11111 ddd 12/31/2007
On a report we only need to display the most current record (based on a date).
11111 ddd 12/31/2007
How can we do that, we have try to create subquery but it does not allowed to enter logic for the max date for the same id. So we are kind of stuck, I am more then sure this would be a very common conditions specially for data warehousing.
we are on Oracle 10g
Thank you for all your help.Post Author: ROMZILBER
CA Forum: WebIntelligence Reporting
To create a view is not a problem, supporting it is a different story
But we have find a solution, you were correct about the filter. I just did not know you can put the whole subselect in a filter
but here is a logic for the filter if someone would come up with the same problem
tablename.NNNN_PROOF_DT = (SELECT MAX(X.NNNN_PROOF_DT) FROM tablename X WHERE tablename.NNNN_CLAIM_NUMBER = X.NNNN_CLAIM_NUMBER AND tablename.NNNN_LINE_CD = X.NNNN_LINE_CD)
please let me know if you have any questions.
sorry I am new to this so please do not take any offense -
How to get the date for the first monday of each month
Dear Members,
How to get the date for the first monday of each month.
I have written the following code
SELECT decode (to_char(trunc(sysdate+30 ,'MM'),'DAY'),'MONDAY ',trunc(sysdate+30 ,'MM'),NEXT_DAY(trunc(sysdate+30 ,'MM'), 'MON')) FROM DUAL
But it look bith complex.
Abhishek
Edited by: 9999999 on Mar 8, 2013 4:30 AMUse IW format - it will make solution NLS independent. And all you need is truncate 7<sup>th</sup> day of each month using IW:
select sysdate current_date,
trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
from dual
CURRENT_D FIRST_MON
08-MAR-13 04-MAR-13
SQL> Below is list of first monday of the month for this year:
with t as(
select add_months(date '2013-1-1',level-1) dt
from dual
connect by level <= 12
select dt first_of_the_month,
trunc(dt + 6,'iw') first_monday_the_month
from t
FIRST_OF_ FIRST_MON
01-JAN-13 07-JAN-13
01-FEB-13 04-FEB-13
01-MAR-13 04-MAR-13
01-APR-13 01-APR-13
01-MAY-13 06-MAY-13
01-JUN-13 03-JUN-13
01-JUL-13 01-JUL-13
01-AUG-13 05-AUG-13
01-SEP-13 02-SEP-13
01-OCT-13 07-OCT-13
01-NOV-13 04-NOV-13
FIRST_OF_ FIRST_MON
01-DEC-13 02-DEC-13
12 rows selected.
SQL> SY. -
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) -
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 -
Tree node retrieving data for the 1st node only for 3 data blocks ?!
Hello alllll
i have 3 DATA BLOCKS MAster-Detail-Detail ; GL_TYPES -< GL_ACCOUNTS -< GL_COMPANIES
The Rel between 1 & 2 is
GL_ACCOUNTS.TYPE_ID = GL_TYPES.TYPE_IDThe Rel between 2 & 3 is
GL_COMPANIES.ACCOUNT_ID = GL_ACCOUNTS.ACCOUNT_IDi also have a Treewhich is retrieving data in the opposite data blocks the following code used in WHEN-TREE-NODE-SELECTED Trigger and it works fine but not for every node ;
the node selected shows data for the first node only; Say Assets but if i selected any other node it doesn't return any data ?
could any boady pls explain to me why is that happening ?
The following code is:
DECLARE
htree ITEM;
NODE_VALUE VARCHAR2(100);
BEGIN
IF :SYSTEM.TRIGGER_NODE_SELECTED = 'TRUE' THEN
-- Find the tree itself.
htree := FIND_ITEM ('BL_TREE.IT_TREE');
NODE_VALUE := FTREE.GET_TREE_NODE_PROPERTY( htree, :SYSTEM.TRIGGER_NODE , Ftree.NODE_VALUE );
GO_BLOCK ('GL_ACCOUNTS');
set_block_property('GL_ACCOUNTS', DEFAULT_WHERE, 'GL_ACCOUNTS.ACCOUNT_ID = ' ||
ftree.get_tree_node_property('BL_TREE.IT_TREE', :SYSTEM.TRIGGER_NODE, FTREE.NODE_VALUE));
EXECUTE_QUERY;
END IF;
END;
Regards,
Abdetu...Hello Ammad Ahmed
Thanks really for reply ,i appreciate... :)
Can you explain little more what is the meaning of this?a tree block on canvas beside 3 data blockS out of 2 tables as follows
SQL> desc GL_ACCOUNTS
Name Null? Type
ACCOUNT_ID NOT NULL NUMBER(10)
TYPE_ID NOT NULL NUMBER(1)
ACCOUNT_NAME NOT NULL VARCHAR2(100)
IS_CLOSED NOT NULL NUMBER(1)
ACCOUNT_ID_PARENT NUMBER(10)
SQL> desc GL_COMPANY_COA
Name Null? Type
ACCOUNT_ID NOT NULL NUMBER(10)
COMPANY_ID NOT NULL NUMBER(2)only table GL_ACCOUNTS has a self rel so on data blocks on forms i have out of these 2 tables 3 data blocks in the following order
GL_ACCOUNTS_PARENT on GL_ACCOUNTS has a where clause on it's property;
account_id in ( select distinct account_id_parent from gl_accounts ) on GL_ACCOUNTS_PARENT block i am displaying on 1 row:
1. the account_id ,
2. the account
3. name and account_type_name in a LOV
on the second block GL_ACCOUNTS depending on the GL_ACCOUNTS table also am displaying muti rows :
1. the account_id ,
2. the account
and a relation on form
GL_ACCOUNTS.TYPE_ID = GL_ACCOUNTS_PARENT.TYPE_ID AND
GL_ACCOUNTS.ACCOUNT_ID_PARENT = GL_ACCOUNTS_PARENT.ACCOUNT_IDon the third block GL_COMPANY_COA depending on the table GL_COMPANY_COA
am displaying the company_id & company_name in multi_rows
GL_COMPANY_COA.ACCOUNT_ID = GL_ACCOUNTS.ACCOUNT_ID
how the data will be looking in data blocksam using the following link -> Large trees - using partial tree population
http://andreas.weiden.orcl.over-blog.de/article-29307730.html
PROCEDURE PR_FILL_TREE IS
CURSOR crTop IS
SELECT ACCOUNT_ID VALUE,
ACCOUNT_NAME LABEL
FROM GL_ACCOUNTS
WHERE ACCOUNT_ID_PARENT IS NULL
ORDER BY type_id, ACCOUNT_id;
nd FTree.NODE;
BEGIN
Ftree.DELETE_TREE_NODE(itTree, FTree.ROOT_NODE);
FOR rec IN crTop LOOP
nd:=FK_ADD_NODE(Ftree.ROOT_NODE, rec.VALUE , rec.LABEL);
PR_QUERY_DETAILS(nd, rec.VALUE);
END LOOP;
END;
if any unclear... pls notify me...!
Regards,
Abdetu... -
Test data for the ABAP Function
Hello Experts,
Can you please provide me the valid test data for the function modules?
/SCA/BIF_WORKINPROCESS_BO
and
/SCA/BIF_WORKORDINF_MS
Thanks and Regards,
Kuldeep VermaHi ,
If u want to use the same data to test your function module then we can use this button. To use this button simply press F8 --> give the test data --> And then save this test in the test directory using the SAVE button.
--> Next time when retest it then their is no need to give all the other information just press Test Data directory..
Hope you understand.
Kuldeep -
Queries based on Master data for the particular periods not working
Hi,
My Queries are based on master data and for 2007 we did not have customer groups define hence for the historical also we would like to display the customer groups hence we are reproting based on master data. But when iam executing my reprots for each and every month for the 2007 , i can able to execute the reprot properly but same when iam giving the values in ranges with the help of input filed ( calender month -interval) its taking hours but unable to retrieve the data for the 6 months at a time even if iam restricting the values in the queries still the problem is same...
Can anyone has an idea what would be the problem .. its only for 6 months
ThanksHi
Master data report consumes much time. try to see the Query Statistics and make the performance tuning.
Recheck your data flow for routines at TRules/upRules level.
Recheck on the Query designer for formula/ Cmod Variables.
The report fetching time even depends on the NO.of records too.
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d06dcd70-41a8-2b10-9f8f-dc5c68769753
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6009e125-e9a3-2a10-c6a9-e1483dfa2e1b
Hope ithelps -
Selecting max date for specific 'operation' code
I have the following scenario: a history table that keeps track of the 'operation' and the date of the operation. For example, the operation field can have a code of U (for update), C (for closed), O (for re-opened), A (for approved), etc.
The goal of this history table is to keep track of all of the modifications made. Hence, a particular record of interest can have more than one 'U' operation documented, C operation, etc.
How can I choose the max date for each operation.
I was diong the following in my PL/SQL:
BEGIN
SELECT operation_code, o_date, user INTO lv_operation_code, lv_date, lv_user FROM table1 WHERE unique_id = pv_id AND operation_code = U' AND o_date = (SELECT max(o_date) FROM table1 WHERE unique_code = pv_id);
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
I then have another begin statement for the 'C' operation, etc.Hi,
OraclePolzovatel wrote:
... I was diong the following in my PL/SQL:
BEGIN
SELECT operation_code, o_date, user INTO lv_operation_code, lv_date, lv_user FROM table1 WHERE unique_id = pv_id AND operation_code = U' AND o_date = (SELECT max(o_date) FROM table1 WHERE unique_code = pv_id);
EXCEPTION
WHEN NO_DATA_FOUND THEN NULL;
END;
I then have another begin statement for the 'C' operation, etc.Are you sure that's what you're doing? There seem to be errors, such as unmatched quotes.
Instead of doing a single SELECT with something like "operation_code = 'U'" in the WHERE-clause, you could write a cursor with "GROUP BY operation_code". -
Help to get max date of the group
Hi, How I can get the max(date1) for the group on the basis of Code1,Code2,Code3.
Code1 Code2 Code3 Date1 RTCODE
A A1 A2 1/1/2012 SER
A A1 A2 1/1/2013 SER
A A1 A2 1/1/2015 TER
B B1 B2 1/1/2011 JTS
B B1 B2 1/1/2012 JTR
C C1 C2 1/1/2010 HYR
C C1 C2 1/1/2011 JST
Expected results from query should be:
Code1 Code2 Code3 Date1 RTCODE
A A1 A2 1/1/2015 TER
B B1 B2 1/1/2012 JTR
C C1 C2 1/1/2011 JSTHi,
You can try this:
CREATE TABLE #T
CODE1 VARCHAR(5),
CODE2 VARCHAR(5),
CODE3 VARCHAR(5),
DATE1 DATE,
RTCODE VARCHAR(5)
--DROP TABLE #T
INSERT INTO #T
VALUES
('A','A1','A2','20120101','SER'),
('A','A1','A2','20130101','SER'),
('A','A1','A2','20150101','TER'),
('B','B1','B2','20110101','JTS'),
('B','B1','B2','20120101','JTR'),
('C','C1','C2','20100101','HYR'),
('C','C1','C2','20110101','JST');
--TRUNCATE TABLE #T
WITH TEST AS
SELECT CODE1, CODE2, CODE3, MAX(DATE1) AS DT_MAX
FROM #T
GROUP BY CODE1, CODE2, CODE3
SELECT T.CODE1,T.CODE2, T.CODE3, T.DT_MAX,#T.RTCODE
FROM TEST AS T
INNER JOIN #T ON T.CODE1=#T.CODE1
AND T.CODE2=#T.CODE2
AND T.CODE3=#T.CODE3
AND T.DT_MAX=#T.DATE1
ORDER BY T.CODE1,T.CODE2,T.CODE3
Regards,
Reshma
Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered -
How to set the filter on a report to show the data for the Current Month
Hi all,
I am working on a report, which currently has this filter: Date First Worked is greater than or equal to 10/01/2010. This reports show the data for the current month, so at the beginning of each month we have to remember to change the date on the filter.
Does anyone know what the criteria should say, so that it automatically changes and shows the information for the current month, without us having to go in and change anything?
Any help would be greatly appreciated!
Thanks,
AAYou need to add a session variable to date fir worked assuming that this is a date field.
To do this open up the filter on the field then at then press add Variable then "session" and enter the following CURRENT_MONTH into the Server Variable section. -
Problem in retreiving data for the given user parameter year!!!
hi all,
I am working in oracle report 6i. I want to display the data for the date given in the parameter field(MM/YYYY).
For ex. Input is 07/2007 means i want to display the data from 04/2006 to 07/2007.Please guide me
to get this desire output......
Here is my query.....
select gl_code,financial_month,financial_year,division_code
from gtemp
where financial_year between to_number(to_char(:P_Date,'YYYY')) - 1 and to_number(to_char(:P_Date,'YYYY'))
and financial_month >= '04'
and financial_month < = to_char(:P_Date,'MM')
and division_code = 11
order by financial_month, financial_year
regards,
jame
Message was edited by:
JameWorks fine if u gave values instead of variables.... But if we gave 02 in place of 11 like below.Query will get
confused to take which years 02 because in both 2005 and 2006 we have 02(Feb)thats y.......
how to overcome this prob.......I think, my entire query is wrong to get this desire output....Please guide me how
to solve......
select gl_code,financial_month,financial_year,division_code
from gtemp
where financial_year between 2005 and 2006
and financial_month >= '04'
and financial_month < = '02'
and division_code = 11
order by financial_month, financial_year -
How to get correct opening blance data for the quarterly report in BOFC?
Hi all,
I have a problem with getting the opening balance for the quarterly report.
i would like to keep the beggining balance data for the end of previouse year. (eg: now is 2010, then keep the begginig balance at Dec.2009 for each quarterly reporrt through the year in 2009).
however, for example in the second quarter, if i choose the beggining balance of Dec.2009 in the Consolidation definition, there is a problem that consolidation FS does not include the manual journal entry that ive entered at the first quarter such as goodwill.
Do I need to make manual journal entry at all the quarterly reporting period if I want to set the beggining balance for the previouse year end?
Could somebody please tell me how to remediate to this issue?
Or how do you manage with the opening balance in BOFC?
Thanks & Regards,
HitomiHi Michael,
HRMS appliocation
database 10.2.0.4
windows XP
ebs 11.5.10.2
One of our user using disooverer 4i desktop and administration edition on old windows 2000 machine and connecting to schema.
We are decommision old windows 2000 machine.
I have installed disooverer 4i desktop and administration edition on new windows XP VM box and trying to connect to same schema which was used with old
desktop and asking me to create EUL. What is theat I should be doing to use new one same as old one?
Old box is still there.
Thanks. -
How to approach in getting the dates for the user given periods
Hi All,
I have areuirement where the calendar would be like as 466 for a period
for eg. period 1(Jan) has 4 weeks
period 2(Feb) has 6 weeks
period 3(Mar) has 6 weeks
again period 4(Apr) has 4 weeks
period 5(May) has 6 weeks
period 6(June) has 6 weeks
How to get the dates (from date and end date) for the periods.
Anybody's help will be appreciated
Regards
SaugataI have areuirement where the calendar would be like as 466 for a periodWhat does that mean? Is 466 the format of the data?
The end date depends on the start date. This query might be helpful for you
SQL> WITH data AS(
2 SELECT 1 period, 4 duration FROM dual UNION ALL
3 SELECT 2, 6 FROM dual UNION ALL
4 SELECT 3, 6 FROM dual UNION ALL
5 SELECT 4, 4 FROM dual UNION ALL
6 SELECT 5, 6 FROM dual UNION ALL
7 SELECT 6, 6 FROM dual)
8 SELECT
9 period,
10 duration,
11 SYSDATE + SUM(duration) OVER (ORDER BY period RANGE UNBOUNDED PRECEDING) * 7 AS end_date
12 FROM data
13 ;
PERIOD DURATION END_DATE
1 4 16-NOV-07
2 6 28-DEC-07
3 6 08-FEB-08
4 4 07-MAR-08
5 6 18-APR-08
6 6 30-MAY-08
6 rows selected.
SQL>
Maybe you are looking for
-
Looking for a mobile printer for my car/ on the road work for my IPAD2
Looking for a printer I can use in my car and where ever necessary.
-
Tag files, Lists, and object typing
I'm passing a list of objects to a custom tag, created via a tag file. I can access object properties in the jsp page like this - <c:out value="${listOfItems[0].property}" /> but inside the tag it doesn't work. It understands that its being passed a
-
Hi All, I have a pdf which is pretty much a guide. I created InDesign file with layers and exported as pdf. I'm trying to do the following: When i hit one of the navigation links, a layer associated with that link shows up. In layer that showed up, i
-
TS1702 my iphone 3gs no service
ios had the upgrade to 4.3.3 and 5.1.1 firmware is 05.16.05 and now takes service
-
HP Laserjet P2055dn prints the word JOB first
I have installed HP Laserjet P2055dn as a local printer. But when I print a document, it prints the word 'JOB' first before printing my document. I wanted to know how to stop this option. Thank you in advance.