Query to show BP year to date sales minus credits
Hi Experts,
I would like a query which will show me a single line for each BP:
BP Code, Salesperson, BP Name, Sales Group, Sales YTD (ex vat)
I want the Sales YTD to be be calculated as total invoiced sales less any credits,
Thanks in advance for any help..
regards
Geoff
Hi,
Check this if it helps :
select t0.cardcode as 'Business Partner Code' ,t2.slpname as 'Sales Person Name',
t0.cardname as 'Business Partner Name', t0.GroupCode as 'Sales Group',
sum(t3.doctotal)- sum(t3.vatsum) as 'YTD Sales',
sum(t4.doctotal) - sum(t4.vatsum) as 'YTD Credit Memo',
sum(t5.doctotal) as 'YTD Payments'
from OCRD t0
inner join JDT1 t1 on t0.cardcode = t1.shortname
inner join OSLP t2 on t0.slpcode = t2.slpcode
left join OINV t3 on t3.objtype = t1.transtype and t3.docdate >= '2011.01.01' and t3.docdate <= '2011.12.31'
left join ORIN t4 on t4.objtype = t1.transtype and t0.slpcode = t4.slpcode and t4.docdate >= '2011.01.01' and t4.docdate <= '2011.12.31'
left join ORCT t5 on t5.transid = T1.transid and t5.docdate >= '2011.01.01' and t5.docdate <= '2011.12.31'
where
cardtype = 'C' and t1.refdate >= '2011.01.01' and t1.refdate <= '2011.12.31'
group by t0.cardcode, t2.slpname,t0.cardname,t0.groupcode
order by t0.cardcode
Kind Regards,
Jitin
SAP Business One Forum Team
Similar Messages
-
YTD(year to date) Sales [List Price/ Gross Sales ]
How to create YTD(year to date) Sales [List Price/ Gross Sales ] depending on the selection in filter
Do you have the measure names as list of values in prompt?
Rgds,
Dpka -
I'm trying to calculate year to date sales value. If I have more than one packet size my values do not match expected results. Is there a way I can have all data in single packet in start routine or end routine. I don't want to make cahnge to setting in DTP. My initial package should pick all values.
For example:
Comp Month Sales
A 1 1
A 2 2
A 3 3
A 4 4
A 5 5
A 6 6
A 7 7
A 8 8
My expected result should be:
A 1 1
A 2 1 + 2 = 3
A 3 3 + 3 = 6
A 4 6 + 4 = 10
A 5 10 + 5 = 15
A 6 15 + 6 = 21
A 7 21 + 7 = 28
A 8 28 + 8 = 36
If I have two packets ( size 4each) then my calculation doesn't match the expected results
A 1 1
A 2 1 + 2 = 3
A 3 3 + 3 = 6
A 4 6 + 4 = 10
A 5 5
A 6 5 + 6 = 11
A 7 11 + 7 = 18
A 8 18 + 8 = 26
Can any one hlep me to resolve this issue.Hi,
The best way is....
Create a report and calculate it in Report like below.
Create a Customer Exit Variable called FMYEAR on 0CALMONTH and then write code like below.
DATA : l_s_range TYPE rsr_s_rangesid,
loc_var_range LIKE rrrangeexit,
zbdatj LIKE t009b-bdatj,
zbuper LIKE t009b-poper,
First Month Of Current Fiscal year comment*
WHEN 'FMYEAR'.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
I_MONMIT = 00
i_periv = 'V3'
IMPORTING
e_buper = zbuper
e_gjahr = zbdatj.
CLEAR: l_s_range.
l_s_range-low+4(2) = '04'.
l_s_range-low+0(4) = zbdatj.
l_s_range-sign = 'I'.
l_s_range-opt = 'EQ'.
APPEND l_s_range TO e_t_range.
and then create a restricted Kefigure with 0CALMONTH and value, and restrict calmonth with FMYEAR;0CALMONTH (there are variables and the values are in between FMYEAR;0CALMONTH)
Thanks
Reddy -
Year-To-Date Sales by month calculation in cube
Hi everyone,
I want to already calculate the 'YTD Sales'by month in my cube, so I increase performance when the user is running his report. YTDSALES = Actual Month Total Sales + Previous month YD Total Sales.
Not sure how to implement it in the update rule. Looks like a lt of coding. Any suggestions would be greatly appreciated.
Thanks, RLYou should do a little loop in the start routine and write all the monthly values into any periods up to period 12. The coding could look like:
data: l_d_data_package like line of data_package,
l_t_data_package TYPE STANDARD TABLE OF
DATA_PACKAGE_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0.
loop at data_package into l_d_data_package.
l_d_data_package-/bic/ytdsales =
l_d_data_package-/bic/sales. "or other keyfig
while l_d_data_package-calmonth+4(2) <= '12'.
append l_d_data_package to l_t_data_package.
clear l_d_data_package-/bic/sales. "or other keyfig
l_d_data_package-calmonth+4(2) =
l_d_data_package-calmonth+4(2) + 1.
* If you have fiscper or fiscper3 or
* calquarter you may need to adjust it here too.
endwhile.
endloop.
data_package[] = l_t_data_package[].
But you should first check if aggregates or precalculated web templates are better.
Best regards
Dirk -
Any query to get 10 years data from tables of hundreds of schemas?
Hi,
Is there any query to extract 10 years of data from schema ( may be 100 in number) and then export that data to some other database.
THanks982955 wrote:
Hi,
Is there any query to extract 10 years of data from schema ( may be 100 in number) and then export that data to some other database.
THanksYES, it depends
How do I ask a question on the forums?
SQL and PL/SQL FAQ -
Hello experts,
I have installed the variable : Current Year From Start, Range to Current date(Sap Exit) with tech name 0I_IPMD7. How do i know which time infoObject it is applicable to?
i want to use this in the year to date sales calculation. But cannot see this available in any of the time infoobjects in the present 0sd_c03 cube!!
please guide..
regards,Hi Aby,
Please look at RSZGLOBV table. You'll see that this variable is based on 0IPM_BEGDATE characteristic.
You can also look in SE37 at the FM RSVAREXIT_0I_IPMD7 to figure out what the code is doing.
Best regards,
Eugene -
Hi,
I use this query to get the previous month's data
select product_name,total from inventory where TRUNC(START_DATE, 'MONTH') = TRUNC(ADD_MONTHS(SYSDATE, -1), 'MONTH');
Can some one help me enhance this query to get the year to date count with year starting from April
I'm trying for an output like
product_name,total,ytd_total
Bat,10(For May),20(Grouped for april and may)Perhaps this
SELECT product_name,
SUM(total)
FROM inventory
WHERE start_date > DECODE( SIGN( TO_NUMBER( TO_CHAR( sysdate, 'mm') ) - ), -1,
TO_DATE( '04-APR-'||TO_CHAR( TO_NUMBER( TO_CHAR( sysdate, 'yyyy' ) ) -1 , '0000'), 'dd-MON-yyyy'),
TO_DATE( '04-APR-'||TO_CHAR( TO_NUMBER( TO_CHAR( sysdate, 'yyyy' ) ) , '0000'), 'dd-MON-yyyy') )
GROUP
BY product_name; -
Discoverer Parameters: Year to Date
Hi guys,
At the moment im working on a database warehousing project. I'm using discoverer as a front end for a user friendly environment. Does anyone know how i can create a parameter to show the year to date? i need to put the following condition into the paramater:
FULL_DATE BETWEEN =add_months(sysdate,-12) AND =sysdate
However, as im sure you'll find, you cannot use the 'BETWEEN' function when using parameters :( - Ideally i'd like the user to be able to choose between two buttons, one showing all the data and one showing year to date. I would prefer to use a parameter to do this rather than the user adding/removing conditions from worksheet.
Thanks in advance,
Chris.Hi Chris
Take a close look at Rod's answer because you can use BETWEEN when using parameters. Rod's answer looks for the code YTD and if found uses the full year to date.
Another solution would be to use a parameter that asks the user whether they want to see the year to date, receiving Y or N. Having got the answer you then create a suitable DECODE, like this:
FULL_DATE BETWEEN DECODE(:YTD_QUESTION,'Y',ADD_MONTHS(SYSDATE,-12), FULL_DATE) AND SYSDATE
This solution works when the datatype that you are checking for will not allow a user to type characters, so can be used when a date or number is being checked.
Best wishes
Michael -
Creating Query to show items from open sales orders with a/p invoice
Hi experts,
I am trying to create a query that will show what items/quantities are still in open sales orders that can now be filled by an incoming shipment of goods, processed through the a/p invoice.
This needs to be done using subqueries, which I have no experience with. I am trying to do this using the ORDR and RDR1 tables to show the open items from the sales orders and the OPOR and POR1 tables to show items just received in to inventory. I would like the query to show exactly the open item's, their quantities, the posting date from the sales order and the customer name that can now be filled from the new shipment through the a/p invoice.
I appreciate the assistance,
Hayden (on behalf of Todd)Hello,
try this
SELECT T0.[DocDate], T1.[ItemCode], T1.[Dscription],( T1.[Quantity] - T1.[DelivrdQty]) As "Open Qty" FROM ORDR T0 INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.[DocDueDate] <= [%0]And ( T1.[Quantity] - T1.[DelivrdQty]) != 0
Try this query in query manager.
Thanks
Manvendra Singh Niranjan
Edited by: Manvendra Singh Niranjan on Jul 13, 2011 6:27 AM -
How to show current year and last year sales in a WEBI Report
Hi Guys
How can show current YEar Sales in one column and Last YEar Sales in the other column based on a user prompt for the Current YEar Column.
For Example is user enter 2010 for Year how can i show a Column for Sales-2010 and Sales 2009.
ThanksIf you can modify your Universe add an object named New Object Last Year whose SQL is:( yourTableName.Year + 1)
Then in WebI create two distinct queries in your query Pane. In the first one you could do this:
Query 1:
objects: Year, Sales ... etc.
filters: Year Equal to '1. Prompt Year'
Query 2:
objects: Year, Sales ... etc.
filters: New Object Last Year Equal to '1.Prompt Year'
Then in your report you can drag each object on their respective columns.
If you don't want to use two distinct queries, use one like this:
Query 1:
objects: Year, Sales ... etc.
filters: Year Equal to '1. Prompt Year'
Or
New Object Last Year Equal to '1.Prompt Year'
Edited by: PadawanGirl on Jun 23, 2011 6:28 PM -
Getting Turnover Year to Date amount in Sales Order
Hi Experts
I would like to be able to have a UDF on Sales Order which shows Sales the Turnover Year to Date for the BP.
I have created a UDF which is formatted as an amount field and a formatted search with the following syntax. it is essentially a calculation of the total of all invoices minus credit notes:
(select (select sum(t1.doctotal) - sum(t1.vatsum) from oinv t1 where (t1.cardcode = t0.cardcode) AND ((T1.[docdate]>='01.01.09') AND (T1.[docdate]<=GETDATE())))
- (select sum(t2.doctotal) - sum(t2.vatsum) from orin t2 where (t2.cardcode = t0.cardcode) AND ((T2.[docdate]>='01.01.09') AND (T2.[docdate]<=GETDATE()))))
from OCRD T0 INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
WHERE T0.[CardCode] = $[$4.1.0]
it is working for me unfortunately and I hope one of the experts can tell me where I am going wrong?
Thanks
JonHi
Try this,
DECLARE @a Numeric(19,6)
DECLARE @b Numeric(19,6)
Set @a = Select (SUM(T1.DocTotal) - SUM(T1.VATSUM))
FROM OCRD T0
INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
WHERE T0.CardCode = $[$4.0.0]
AND
T1.DocDate '01/01/2009' AND T1.DocDate<= 'GETDATE()'
Set @B = Select SUM(T2.DocTotal) - SUM(T2.VATSUM)
FROM OCRD T0
INNER JOIN OINV T1 ON T0.CardCode = T1.CardCode
INNER JOIN ORIN T2 ON T0.CardCode = T2.CardCode
WHERE T0.CardCode = $[$4.0.0]
AND
T2.DocDate>= '01/01/2009' AND T2.DocDate<= 'GETDATE()'
SELECT (@a-@b)
Regards,
Madhan. -
SQL date query problem with century/ year
We have an oracle database with about 6 million records. There is a date field called Entered Date that ranges from 1985 to the present.
The majority of these records were entered prior to Jan 1 2000.
If I run a query like
select count(*) from (tablename) where entered_date < '01-JAN-00' I get 0
if I do
select count(*) from (tablename) where entered_date < '31-DEC-99' I get 0
BUT IF I DO
select count(*) from (tablename) where entered_date < '01-JAN-00' I get 6 million records
or
select count(*) from TREASURY.ctrc where entrydate > '31-DEC-99' I get 6 million records
I've tried the same queries using 4 digit years but get the same results; it thinks that 2000 is the less than 1999
How do I get around this?
thanksHi,
975204 wrote:
there are 6 million records on the table
about two thirds have a date prior to Jan 1 , 2000How do you know that? From knowledge of the application, you may know that two thirds of them are supposed to have dates prior to 2000, but if
SELECT COUNT (*)
FROM TABLE_NAME
WHERE ENTRYDATE < TO_DATE ( '01-JAN-2000'
, 'DD-MON-YYYY'
;returns 0, that's pretty strong proof that none of them actually do.
When I look at the dates , they display as 31-DEC-86Another example of why using 2-digit years is such a bad idea.
I cant actually provide dump of this clients confidential dataSeriously; you can't provide one DUMP output? You've already said that it displays as 31-DEC-86, so even if the fact that 1 entry in the 6-million row table was done on December 31, 1986 was such a big secret, it's already out, and you won't be causing any more harm by showing the DUMP results.
I ran the query with the same format as the date ie
SELECT COUNT(*) FROM TREASURY.CTRC WHERE ENTRYDATE < TO_DATE ( '31-DEC-99'
, 'DD-MON-YY'
but same results
if the column is defined as a DATE type, does Oracle make a distinction based on how the data displays, meaning does it think that 31-DEC-86 is different than 31-DEC-1986?No, all DATE columns have the same format. A DATE may be displayed one way of the other, but it is stored as neither.
Do I need to convert all the data to a 4 digit year? You should always display dates with a 4-digit year.
Run an update query that says if year >= 80 and <= 99 add 19 in front of the year, else add 20 in front of the yearLet's find out exactly what the problem is, first.
Did you see Ascheffer's message? ^1^ It was dated just a couple of minutes before your last message, so you might not have noticed it. Run it to see what the actual 4-digit years are.
If it shows, for example, that there are a lot of entrydates in the years 2080 to 2099, and you decide that all of those really should be 100 years earlier, then use ADD_MONTHS to correct them:
UPDATE table_name
SET entrydate = ADD_MONTHS ( entrydate
, -100 * 12
WHERE entrydate >= TO_DATE ( '01-JAN-2080'
, 'DD-MON-YYYY'
AND entrydate < TO_DATE ( '01-JAN-2100'
, 'DD-MON-YYYY'
;Edited by: Frank Kulash on Mar 15, 2013 6:09 PM
^1^ Obviously, you did see Ascheffer's message; I was still typing the message above when you posted another one. -
Report showing items without transaction data (materials without sales)
Hi,
I need to create a report (in BW for retail), listing all the articles that has not been sold for a given month and store (plant). My thought was to create a report, setting a condition listing quantity = 0 and set Access type for result values to Master data. But this is not working.
Having tried the standard SAP slow seller query on the material movements qube (0IC_C03), I did not see this giving me materials with no movement.
Anybody have any tips how to solve a query where you need to list master data that does not have any transactional data in the cube?
My only thought is to create a new cube, and fill by looping on my material master and looking to the transactional data and if there is not hit, the material has not been sold that month, but I'm hoping for a smoother solution.
Any help is much appreciated.
Regards,
ØysteinHi,
thanks for you reply.
I have tried the query with show all master data and condition quantity = 0, and this list a huge list of articles, (to me it seems like the whole material master). Luckily it's not a huge retailer, the material master is aprox 50k records. But the output did not seem to be correct. And it was slow. And again, no store will be keeping the whole material master for sale, so this will list everything, not just the ones relevant to the store.
My second option will require more work, by updating a "no sale" cube/dso and loop on all master data, but this will be done once a month, and then the work is done at evening/nights, and the report should be fast. It's not to much work to create the routine, but running it I assume will be time consuming.
Regards,
Øystein -
Can I build a query to show monthly sales by item by business partner?
Hi all
Is it possible to build a query to show monthly sales (quantity not value) by item by business partner?
So the table would look something like this.
Jan Feb Mar Apr
Item 1 10 4 8 7
Item 2 4 3 5 6
Item 3 4 12 9 3
Item 4 1 0 1 2
Etc...
As you can see, the monthly figure needs to be quantity of the item and not sales value.
Would be grateful for any help.
Many thanks.
WendyHi,
Try this:
declare @code as varchar(15)
set @code = ( select max(ta.cardcode) from OINV ta where ta.cardcode = [%0])
Select [a] as Cardcode, [B] as Cardname, [c] as Item#, [D] as Descr,[1] as Jan,[2] as Feb,[3]as Mar,[4] as April,[5] as May,[6] as June,[7] as July ,[8] as Aug,[9] as Sept,[10] as Oct ,[11]as Nov,[12] as Dec
from(
SELECT T0.[CardCode] as A , T0.[CardName] as B, T1.[ItemCode] as C, T1.[Dscription] as D, sum(T1.[Quantity]) as t,month(T0.[DocDate]) as month FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry WHERE year( T0.[DocDate]) = 2014 and t0.cardcode = @code GROUP BY T0.[CardCode], T0.[CardName], T1.[ItemCode], T1.[Dscription],T0.[DocDate] ) S
pivot
(sum(t) for month IN ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
Thanks & Regards,
Nagarajan -
On iCal this year the date of shrove tuseday is showing on Tuesday 13 of February witch for a start is wrong coz it's a Thursday and wrong because its meant to be in march
kaeandcolesmon,
If you open the recovery drive (partition) it should only have a single folder (Recovery).
To make sure that your not saving restore points to that drive.
See:
Start, Control Panel, System, System Protection tab. Make sure the D drive partition is set to OFF so that it does not save there.
I am a volunteer. I am not an HP employee.
To say THANK YOU, press the "thumbs up symbol" to render a KUDO. Please click Accept as Solution, if your problem is solved. You can render both Solution and KUDO.
The Law of Effect states that positive reinforcement increases the probability of a behavior being repeated. (B.F.Skinner). You toss me KUDO and/or Solution, and I perform better.
(2) HP DV7t i7 3160QM 2.3Ghz 8GB
HP m9200t E8400,Win7 Pro 32 bit. 4GB RAM, ASUS 550Ti 2GB, Rosewill 630W. 1T HD SATA 3Gb/s
Custom Asus P8P67, I7-2600k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX660 2GB, 750W OCZ, 1T HD SATA 6Gb/s
Custom Asus P8Z77, I7-3770k, 16GB RAM, WIN7 Pro 64bit, EVGA GTX670 2GB, 750W OCZ, 1T HD SATA 6Gb/s
Both Customs use Rosewill Blackhawk case.
Printer -- HP OfficeJet Pro 8600 Plus
Maybe you are looking for
-
Can't login with Microsoft account
My company blocks logging in to Skype on our laptops (as well as Onenote, One drive etc.) Is there a way to find my 'skype name' and log in with that instead? When I installed and setup skype I just used my outlook account but now I'm stuck and can't
-
I installed a Dell OS disk onto my Satellite Pro L350-107
Call me an idiot, but i don't know much about drivers or installing vista. I'll tell you guys everything in order to make as much sense as possible: On my Toshiba Satellite Pro L350-107, i was simply watching a .MKV file on a program called "Zoom Pla
-
After latest update total system slowdown
After installing the latest security update my system has slowed dramatically. The mouse pointer is jerky and sound stops and starts every operation has a time lag. I've repaired the permissions but this hasn't helped. Anybody else have this issue or
-
6.0.5 introduces CC-level lost render files to CS6
With 6.0.5, CS6 has joined the ranks of CC, in not being able to retain links to rendered areas of the t-l when warp stabilization is applied to the footage (there may be other conditions as well which cause lost renders, haven't tested) -- not occas
-
Convert program in 4.7 to 4.6c
hi friends, my functional requirement is ME2N program in 4.7 version he is asking this program is convert into 4.6c in Zprogram. there is any tcode for uploading and downloading in this program. This is standard program.