BP Turnover Query by Sales Emp
Hi Experts,
I am trying to run this query to show in 3 columns the turnover over 3 years per sales employee for each of their customers.
SELECT T1.[CardCode], T1.[CardName],
(select Sum(T2.DocTotal) where T2.[Docdate] between '20110101' and '20111231') 'Turnover 2011',
(select Sum(T2.DocTotal) where T2.[Docdate] between '20100101' and '20101231') 'Turnover 2010',
(select Sum(T2.DocTotal) where T2.[Docdate] between '20090101' and '20091231') 'Turnover 2009'
FROM OSLP T0 INNER JOIN OCRD T1 ON T0.SlpCode = T1.SlpCode INNER JOIN OINV T2 ON T1.CardCode = T2.CardCode WHERE T0.[SlpName] Like '[%2]%%' group by t1.cardcode, t1.cardname, t2.docdate
The problem I am getting is that there are multiple entries for each BP - whereas I only need to see one. Also I would like to know if it it possible to only show BPs where there has been activity for the sales emp which should cut down the results.
Many Thanks
Geoff
Hi Geoff........
Please try this.......
Select T0.CardCode, T0.CardName, (IsNull((Select Sum(T4.DocTotal) From ORDR T4 Where T4.CardCode=T0.CardCode And T4.DocDate Between '20110101' And '20111231'),0)) '2011',
(IsNull((Select Sum(T4.DocTotal) From ORDR T4 Where T4.CardCode=T0.CardCode And T4.DocDate Between '20100101' And '20101231'),0)) '2010',
(IsNull((Select Sum(T4.DocTotal) From ORDR T4 Where T4.CardCode=T0.CardCode And T4.DocDate Between '20090101' And '20091231'),0)) '2009'
From OCRD T0 Inner Join OSLP T1 On t0.SlpCode=T1.SlpCode
Where T1.SlpName Like ''[%2]'%%'
Regards,
Rahul
Similar Messages
-
Query for Sales Order Analysis
Dear Experts
I have written a Query for Sales Order Analysis and would like to have help on this.
The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum] ORDER BY T0.[DocNum]
where U_Total_GP is a UDF for storing the GP of each order.
After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. However, the query does not calculate column total for total amount and total GP. Although I know the total for each column can be displayed by pressing "Ctrl" + Click on the column title, it would have to be done from time to time.
Therefore, I would like to modify my query in order to calculate the column totals when executed. Are there any suggestions for this?
Thank you
Regards
EltonHi Elton,
Try this:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0]
ORDER BY T0.[DocNum]
Thanks,
Gordon -
Dear Experts
I have written a Query for Sales Order Analysis and would like to have help on this.
The query is used for generating daily report for Sales Order on number of documents (Sales Order), total amount of sales orders and total GP of Sales Order. The query is written as below:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT '', SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0]
After executing the query, a selection criteria of date appears and after a date is selected, the report shown information required. Everything is fine with this query except I would also like to incdude the total number of Sales Order (per day) right below the column "DocNum".
Is it possible to achieve this?
Thank You
Regards
EltonTry this:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT count(DocDate), SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] -
Error when trying to run the Inventory Turnover query
When I try to run the Inventory Turnover query I get the following error message (I can run other queries that I checked):
<internal error> Receiving from the BW server failed
BW server raised exception: SYSTEM_FAILURE
Do you want to see more information
When I click to see more information the message is
INCLUDE INCL_INSTALLATION_ERROR
Error Group
RFC_ERROR_SYSTEM_FAILURE
Message
&INCLUDE INCL_INSTALLATION_ERROR
Can someone advise? ThanksThanks for that the note was not relevant in this case but ST22 dump indicated:
The current program had to be terminated because of an
error when installing the R/3 System.
The program had already requested 275725392 bytes from the operating
system with 'malloc' when the operating system reported after a
further memory request that there was no more memory space
available.
Thanks have awarded points -
I am trying to run the Inventory Turnover Query and get the following messages:
Warning maximum number of rows (65535) exceeded. Result is incomplete
There is not enough space to display all the rows of the query results
How can I overcome this? Thankshi Niten,
run the query in browser ('display query on the web'),
or use web tempate / web reporting.
ms-excel has limitation max 65535 rows.
hope this helps. -
BP Master Window, Sales Emp Code used to display Sales Empl Name now displ
BP Master Window, Sales Emp Code used to display Sales Empl Name now displays Sales Emp Code
Our customer has noticed that when they do a search in the BP Master window that one of the
columns that is displayed called the Sales Emplyoyee code s not bringing up the Sales Employee Name
as it once was...
I have checked my local version and in the sales employee code column the name of the sales
employee is displayed NOT the code.
sales employee code column is displaying the code number where once it displayed the name and
even in the play system and in our local version it is displaying the name
as above
Nothing has changed on the system. We have not done any upgrades.
I have checked in SAP notes and could not find any information
Thanks for your help in advance
DHi
There is no option for Sales Employee Name.
However on my system if i select Sales Employee Code it actually shows me the Sales Employee Name.
Which is what my customer orginally had .
For my customer it is now showing Sales Employee Code as Sales Employee Code
However it was previously showing Sales Employee Code and giving a Sales Employee Name instead.
They need the Sales Employee Name not Code
Thanks
D -
In query display sales negative values
Hi Friends
Iam Exicuting query based on these selection parameters
Sales Org: 5360
cal Month/Year: 04.2007 to 04.2008
When am exucuting the query above parameters some values display negative values like
04.2007 month display -39
07.2007 month display -253
the key-fig is sales turnover Qty display negative values
in BW side cube also display negative values
why display the negative values
anybody help meCheck the Source where data is coming if it is negative value. If source has positive value, in Cube also it should be positive.
Whatever value you have in your infoprovider, it will display in query. -
I have a query to do a sales analysis and look at both inv and credit notes:
The query runs and pulls out both the inv and credit notes i want it to then deduct the quantity and 'Sales Amt' from the first part any ideas?
SELECT
T1.ItemCode, T1.ItemName, SUM(T0.Price * T0.Quantity) AS turnover,SUM(T0.Quantity) AS QTY,
Sum(IsNull(T0.LineTotal,0)) 'Sales Amt',
SUM(IsNull(T0.GrssProfit,0)) 'Gross Profit',
Case WHEN Sum(Isnull(T0.LineTotal,0)) = 0 THEN 0 ELSE
SUM(IsNUll(T0.GrssProfit,0))/Sum(Isnull(T0.LineTotal,0)) * 100 END 'Gross Profit %'
FROM INV1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN OINV T3 ON T3.DocEntry = T0.DocEntry INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode
WHERE T3.DocDate Between [%1] AND [%2]
GROUP BY T1.ItemCode, T1.ItemName
UNION ALL
SELECT
T1.ItemCode, T1.ItemName, SUM(-T0.Price * T0.Quantity) AS turnover,SUM(-T0.Quantity) AS QTY,
Sum(IsNull(-T0.LineTotal,0)) 'Sales Amt',
SUM(IsNull(-T0.GrssProfit,0)) 'Gross Profit',
Case WHEN Sum(Isnull(-T0.LineTotal,0)) = 0 THEN 0 ELSE
SUM(IsNUll(-T0.GrssProfit,0))/Sum(Isnull(-T0.LineTotal,0)) * 100 END 'Gross Profit %'
FROM RIN1 T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode INNER JOIN OITB T2 ON T2.ItmsGrpCod = T1.ItmsGrpCod INNER JOIN ORIN T3 ON T3.DocEntry = T0.DocEntry INNER JOIN OCRD T4 ON T1.CardCode = T4.CardCode INNER JOIN OCRG T5 ON T4.GroupCode = T5.GroupCode
WHERE T3.DocDate Between [%1] AND [%2]
GROUP BY T1.ItemCode, T1.ItemNameTry this:
SELECT T0.[DocNum], SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] GROUP BY T0.[DocNum]
Union ALL
SELECT count(DocDate), SUM(T0.DocTotal) AS 'Total', SUM(T0.U_Total_GP) AS 'Total GP'
FROM ORDR T0 WHERE T0.[DocDate] =[%0] -
Query For Sales Order Amendments
Hi,
Does anyone have a query that lists the amendments to a Sales Order?
I basically want to create an alert that runs this query once a day and shows me the sales orders that have been amended that particular day.
Any help on this would be gratefully received.
Regards
DavidHi..
Try These Query in Alert you will get your req. fulfill
SELECT T0.[DocNum], T0.[DocStatus], T0.[DocDate], T0.[DocDueDate], T0.[CardCode], T0.[CardName] FROM ADOC T0 WHERE T0.[ObjType] = 17 AND T0.[UpdateDate] = GETDATE()
Regards,
Bhavank
Edited by: Bhavank on Sep 28, 2010 5:50 PM -
Query for Sales order and corr.AR Invoice Info
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
There are some issues that must be defined before you have the exact query.
Do you have freight charges or non-inclusive tax? If you have, freight charges and tax amounts must be included?
Depending on you grouping rule, you can have lines from more than one order in a single invoice. In this case, as invoice amount you want the sum of all lines, or only the lines from that order?
Below is an example using two views. It assumes that grouping rules split lines from different order into different invoices.
Hope it helps,
Ketter Ohnes
create or replace view order_summary as
select oh.org_id,
oh.ORDER_NUMBER,
oh.header_id,
ott.name tt_name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code,
sum(ol.ordered_quantity*ol.unit_selling_price) total,
sum(ol.tax_value) tax,
(select sum(operand)
from OE_PRICE_ADJUSTMENTS_v x
where x.header_id = oh.header_id
and x.adjustment_type_code='FREIGHT_CHARGE') freight_charge
from oe_order_headers_all oh,
oe_order_lines_all ol,
hz_cust_accounts ca,
hz_parties p,
oe_transaction_types_tl ott
where ol.header_id=oh.header_id
and oh.sold_to_org_id = ca.cust_account_id
and ca.party_id = p.party_id
and oh.order_type_id = ott.transaction_type_id
and ott.language =
(select language_code
from fnd_languages
where installed_flag = 'B')
group by oh.org_id,
oh.header_id,
oh.ORDER_NUMBER ,
ott.name,
ca.account_number,
p.party_name,
oh.ordered_date,
oh.flow_status_code;
create or replace view invoice_summary as
select a.interface_header_context,
a.trx_date,
a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2 tt_name,
a.customer_trx_id,
sum(b.extended_amount) invoice_total
from ra_customer_trx_all a,
ra_customer_trx_lines_all b
where a.customer_trx_id = b.customer_trx_id
and b.interface_line_context = 'ORDER ENTRY'
and b.line_type in ('LINE','FREIGHT')
group by a.interface_header_context,
a.trx_date, a.trx_number,
b.interface_line_attribute1,
b.interface_line_attribute2,
a.customer_trx_id;
select *
from order_summary o,
invoice_summary i
where o.order_number between :1 and :2
and o.order_number = i.interface_line_attribute1
and o.tt_name = i.tt_name; -
Query for Sales Order and AR Invoice Information
Hi,
I need to write a query which gives the flollowing sales order info along with the coressponding AR invoices info
Sales Order columns reqd:
OPERATING_UNIT
ORDER_NUMBER
CUSTOMER_NUM
CUSTOMER_NAME
ORDERED_DATE
FLOW_STATUS_CODE
TOTAL_ORDER_AMOUNT
AR invoice columns reqd for the sales orders:
Invoice number,
Invoice date,
Invoice Total.
Can anyone help me out with this?
Thanks,
AshHi Ash,
Table RA_CUSTOMER_TRX_ALL can be joined to RA_CUSTOMER_TRX_LINES_ALL table through CUSTOMER_TRX_ID column. The table RA_CUSTOMER_TRX_LINES_ALL.INTERFACE_LINE_ATTRIBUTE6 = OE_ORDER_LINES_ALL.LINE_ID. And from the LineId, you can get the HeaderId os the OE_ORDER_HEADERS_ALL table.
You must have visualized the query by now.
Thanks
Sumit -
Query vs Sales Analysis Report
I wrote a query that does virtually the same thing as a sales analysis report -- add up all invoice totals and calculate a gross sales number.
In the sales analysis report ItemXXX has a total sales of $1456.94
My query ItemXXX has a total sales of $1457.73
A $.79 discrepancy which I assumed was a result of the fact that my query doesn't include A/R Credit Memos. Only some items have this discrepancy.
The problem is that if I do an inventory posting list on the item there are no A/R Credit Memos listed. Only A/R Invoices, A/P Invoices, and A/P Goods Receipts.
What other documents could be affecting this number? Any other things that could be causing this?
Thanks,
-SteveHi Nagarajan,
Im user of Sap Business One, i need the completly query for obtain the Sales Analysis Report
i have this but in some items dont match
SELECT ItemCode,
Sum(TotFac) - SUM(TotNC) as 'FacturadoNeto',
Sum(GBrutaFac)-SUM(GbrutaNC) as 'GBruta',
Round((Sum(GBrutaFac)-SUM(GbrutaNC))/case when (Sum(TotFac) - SUM(TotNC))= 0 then 1 else (Sum(TotFac) - SUM(TotNC)) end *100,2) as '% Margen'
FROM (
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = Sum(T1.Linetotal),
GBrutaFac = SUM(T1.GrssProfit),
TotNc= 0,
GbrutaNC = 0
FROM OINV T0 (NOLOCK) INNER JOIN INV1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo facturas por articulos
Group by T1.ItemCode
Union
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = 0,
GBrutaFac = 0,
TotNc= Sum(T1.LineTotal),
GbrutaNC = SUM(T1.GrssProfit)
FROM ORIN T0 (NOLOCK) INNER JOIN RIN1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo NC por articulos
Group by T1.ItemCode
Union
SELECT
ItemCode = T1.ItemCode,
Marca = (Select T2.FirmName from OMRC T2 JOIN OITM T3 on T2.FirmCode = T3.FirmCode where T3.ItemCode=T1.Itemcode),
TotFac = 0,
GBrutaFac = 0,
TotNc= Sum(T1.LineTotal),
GbrutaNC = SUM(T1.GrssProfit)
FROM ODPI T0 (NOLOCK) INNER JOIN DPI1 T1 (NOLOCK) ON T0.DocEntry = T1.DocEntry
WHERE (T0.[DocDate] >='20140101' AND T0.[DocDate] <='20141231')
and T0.DocType = 'I' -- solo Fact Anticipos por articulos
Group by T1.ItemCode
) T
Group by ItemCode, Marca -
Change in an LOV query of Sales Order Form not working
Hi,
I wish to change the the Order Type (in the Sales Header) displayed in the Sales Order Form when viewed from a particular Responsibility.(11i Instance)
To be specific only certain order types should be displayed in the LOV when the User tries to create Order from that Responsibility.
In that process I created an FP with Action --> Builtin -->Create Record Group From Query
Then in Property-->Object Type-->LOV and Target Object -->ORDER_TYPE Value-->Name of my Query Group
I downloaded the Sales Order Form and modified the Query of the Group keeping the columns selected and the view used same and added in the Group I created.
But it didn't work out.
I tried out by changing my Target Object to SRV_ORDER_TYPE and its corresponding query from the Oracle Form.
But still it didn't work.
Please tell me where I'm going wrong.
Am I not choosing the correct target record group LOV?Hi Robert,
I have successfully accessed a matrix using Visual Basic .Net. It has been quite a challenge while I was at it.
One important thing to understand is that (unless you access the datasource) in order to access a particular control in a matrix object, this control needs to be visible and enabled. It is like simulating a user accessing the matrix via GUI... if a control is not enabled, you cannot access it (as said via control). That might explain question 1.
Short sample on matrix handling is here:
http://www.itwiki.net/ow.asp?SboHowToReadFromAndWriteIntoMatrix
<b>Q2 - Cell count:</b>
I have personally never used the Cells count method. It should always return the number of rows. My only guess here is that you are using an old reference on the matrix object in which the rows are not there yet.
Dim oMatrix As SAPbouiCOM.Matrix
Dim oColumn As SAPbouiCOM.Column
Dim oEditText as SAPbouiCOM.EditText
oMatrix=YourSboForm.Items.Item(38).Specific
oColumn=oMatrix.columns.item(strColumnname).specific
oEditText=oColumn.items.Item(1).specific
Msgbox(oEditText.String)
The above code should get you the first cell of the first row of the given matrix.
HTH Lutz Morrien
P.S.: If you need any more sample code, check with the SAP matrix sample or send me a mail (adress see Http://www.itwiki.net) -
Problem with bex query listing sales "this month" and "same month last year
Hi,
I've created a query in BW BEx, where I have a mandatory variable for 0calmonth, and I list 0material and sales (in volume, liter). And I have a restricted key figure giving me sales (volume in liter) restricted with 0calmonth = variable - 12, to give me the sale for the same month the user select, previous year.
This seems to be working, the sum is correct, but when adding up the number for the sales in the month previous year, the numbers does not fit the sum in the end.
I think the report only lists materials with sales the month selected in the variable, if a material has not been sold that month, but in the same month last year, it's not listed in the reports, but it's added in the sum in the end.
Example.
We have three records like this:
material - calmonth - volume
101 - 01.2010 - 5
101 - 01.2011 - 8
201 - 01.2010 - 7
The report will give the following (calmonth variable = 01.2011)
Material - volume this month - volume same month last year
101 - 8 - 5
Sum 8 - 12
Any way to solve this issue? We noticed because we run BO - Webi on top of the BEx query, and BO sum's the values per material, and in webi the report would give us the sum 8 and 5.
Any input is appreciated.
Regards,
ØysteinHi,
thanks for your reply.
The error is that the report only seems to list materials that has been sold "this month", and if the same material was sold the same month last year, it will also list the volume for this.
But if the material is only sold in the same month last year, it's not listed in the report, but it's calculated into the sum at the end.
The report is listing material, which is why the error presents itself, as you said
Getting 8 minus 12 is correct unless you drill down by material. In that case, it should be 8 minus 5 and 0 minus 7.
The row with 0 - 7 is not shown, and my guess is that the report will only list materials that has sales this month (which has been selected in the variable)
Regards,
Øystein
Edited by: Oystein Gundersen on Mar 21, 2011 4:36 PM -
How to Create Specific SAP Query for Sales BOM
Dear All Salute !!
How I can create a SAP Query which provide information from the Sales Order-Line Item, this specific material is having any BOM or not?
Suppose, user want Input,
Sales Order No., Product Category, Duration of Sales Order Release.
want Output,
Sales Order No., Customer No., Customer Description, Sales Order Line Item, Material No., Material Description, Delivery Date, Quantity, Sales Order release Date
Users requirement is, List of All Line Items for which BOM is yet to be Uploaded in the System.
Please provide complete detail with Table & field by using SAP Query.
Rgds
Srivastav
+91-9973504950If I am correct, in table KDST, you can see the details of Sales BOM with sale order. Since right now, I dont have access to SAP, I am unable to confirm this. You have to consider this table and develop on your own logic with the help of ABAPer.
thanks
G. Lakshmipathi
Maybe you are looking for
-
Extracting Mp3 files in a word document
Since I have a MacBook Pro, thought this was the forum to ask the question. I use Word for Mac. Just received a word document with embedded mp3 files. I have no idea how to extract the files or export them to iTunes, maybe? Want to listen to them.
-
Intercompany customer/vendor netting
Can someone pls share what is the IHC config steps required for intercompany Customer/vendor netting. is there a way to make payment from F110 run from Intercompany vendor, clears receivale balance by Financial statement posting to the intercompany
-
Fake text message hack going around?
A few minutes ago I received, what appears to be, a fake text message. My phone vibrated, I didn't grab for it right away. It vibrated again so I picked up and hit the Home button to turn the screen on. There was a popup that looked mostly like a nor
-
Upgrade Oracle Database Express Edition to (10.2.0.4 OR 11g) Release
hello I plan to install the SOA, but need more than the database version 10.2.0.4. How to upgrade Oracle Database Express Edition to (10.2.0.4 OR 11g) Release?Thank you!!
-
Hi, Ive been doing Photoshop work for some time and am now looking into doing some flash for my website. If you look at my header on my site http://www.monsterfishing.co.uk it is a Jpeg at the momment for the title. What I want to know is that if i r