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
Elton
Hi 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
Similar Messages
-
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] -
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 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 -
Select query for sales order for particular customer oder text and storage
Hi All,
I am trying to retriev customer order text and customer storage bin from the following select query, but it's giving huge number of records, I want to restrict the number of records.
Select customer order text, customer storage bin
Select STXHTDOBJECT, STXHTDID
Where TDOBJECT = VBBP
TDID = Y001
TDID = Y007
Please let me know how to restirct the number of records.
Thanks,
RanjanTry using the FM 'READ_TEXT'.
NAME will be the order number concatenated with the item number.
And you have the ID and OBJECT. You may also need to use the LANGUAGE.
Message was edited by:
Matt Nagel -
Impact Analysis: Business Area, Profit Center changed for Sales Order type
Hi All,
Can you please let me know the impact of changing the Business Area and Profit Center for Sales Order Document types.
Scenario:
Let's say that sales document type ZOR has been used for sometime. On this document x number of sales orders have been raised, delivered and invoiced over the years.
Now, if you change the Business Area and Profit Center what would be the business impact.
thanks,Hi,
First of all itu2019s not a good business practice to change the Business area and Profit Centre.
However if at all l you change the Business area and Profit centre the following is the impact::
Business Area: effects the sales order in accounts assignment at Header level.
Profit centre: effects the accounting part at Item level
Overall in MIS reporting w.r.t Profit and Business Analysis in Finance will be affected.
Thanks and regards
DSR -
Results analysis for sales orders- actual costs/ revenues - (kka3-kkak)
Hi, i have a problem when I execute the individual results analysis for sales orders (kka3) I can see actual revenues and actual costs, however when I execute the collective processing (kkak) for the results analysis I don´t see these (actual revenues and costs). Is it normal? How can I see these in the collective processing?
Could be one of these possibilities:
1) Controlling Area set is wrong
2) You're input parameters are insufficient to get that sales order. Check Order Type etc you input in the main screen
3) The master data is wrong which is not allowing the link to the Sales Order. You would have to check each field thoroughly.
You will have to probably do a lot of checks before you resolve this. This isn't normal btw....you should see all Sales Orders
Assign Points if useful.... -
Results Analysis for Sales Orders
Hi
When i am calculting Results Analysis for Sales Orders as a part of Month End Closing Activities there are some errors for few orders...
Msg Type: E
AppAr: KJ
MsgNo: 216
Message Text: Planned Cost for Valuation are 0. Please Check the Object.
Can any one tell me what might be the error..
Thanks in Advance..
SivaramHi,
The error is offen caused by one or possible more than one of following statements:
- the delivery block of the order is set
- the billing block is set
- the schedule line ( confirmed quantity ) is missing
- the position has been cancelled
- price condition is missing
In case no one of the mentioned options wouldn''t help, set the position status to technically completed, if the position is processed as well ( delivery, invoice, etc. ).
We often face this kind of issue
Good luck
Marian -
Dynamic Credit Checks - Different Horizon for Sales Order & Delivery
Hi Experts ,
had a query . I am testing a scenario for Dynamic credit Check where the Horizon is ZERO for Sales Order & 3 Months Horizon for deliveries. How should the system behave in such a case. What would be the best way to test whether system behaviour is ok as per this expectations.
Also I would like to know whether "0" horizon for sales order means that system looks into the entiire list of open sales orders or the horizon of check is only upto the end of the current month . In FD32 the curent date is indiacted as the horizon date. While creating sales orders today I found dynamic block for 0 horizon is only working for sales orders with availabilty date upto 7th July '10 which neither covers the existing month-June & neither full of July. Beyond that there is no dynamic block soccuring.That made me a bit confused .
Please advice with you valuable inputs.
Thanking You.Hello Sai ,
thank you for the response. Had already checked note . But this does not speak about the implication "0" M horizon of dynamic credit check . What is coverage for that ? -
Copy 0CO_OM_WBS_5 to get variances for Sale Order / Item
Hi ,
I copied the existing 0CO_OM_WBS_5 extractor and modified it with a logic to bring the Result Analysis numbers for Sales Orders. But when trying to create a normal generic datasource with the FM it is not allowing and giving me an error "E_T_DATA is not present in the the Function Module " The same is not available in standard datasource FM as well for 0CO_OM_WBS_5 .Do we need to maintain any table for mapping the datasource with FM and Extract Structure specific to the CO-OM Extractors.
Help will be greatly appreciated.
Regards,
VSKThanks.
-
Error reading material cost estimate for sales order (KE292)
Dear All,
I have an issue with billing. we are posting july month transactions, the material cost is maintained through MR21. When releasing billing document for accounting we are getting error message like"Error reading the material cost estimate for sales order "11"
Message no. KE292
Diagnosis
In Profitability Analysis (CO-PA), the system tried to valuate item 000010 of sales order 11 by reading the corresponding product cost estimate.
However, no product cost estimate could be found for this sales order item.
The system accessed product costing for product AMLFP011011XX00P using costing key YB3 as defined in the
CO-PA Customizing settings.
System Response
The system cannot process the document any further.
Procedure
Check your Customizing settings."
We cross checked with other client as a current date and we ran cost estimate through CK40N with same material. and we posted entries. Here it is working fine. but in above process it is not working. Can you pls guide me where i missed.
Regards,
Nagaraju,Hi,
When the Costing Key is assigned to the material types in the COPA customizing, then system expects Cost estimation when billing is released to Accounts.
If you dont run cost estimation but update the material master through MR21, system will not accept as in the Costing key configuration you must have selected the Current Standard price field for the valuation.
Hence, try to run cost estimation and then do releasing.
Thanks & Regards
Ravi Kumar -
How settlement rule will be created for Sales order with cost object
Dear Experts,
We are using product cost by sales order with valuated stock. In addition we are not using COPA
We also consume some materials at sales order level and at the end of month we want to do the result analysis and settlement for the same amount. In this case can any on explain how system will behave regarding settlement of sales order cost and what entries will get pass in the system.
In our case we have done below activities...
we have created sales order,
All production order activities completed till final GRN including month end activities
Material consumption against sales order
Result analysis executed
At the time of sales order settlement, system throwing error (Sender doesn't have valid receiver, please create settlement rule for sender object)
Then i checked in sales order there sales order settlement rule not defined.
I guess this settlement rule need be generated by system automatically. If not, please let me know the process of it.HI kishore
the reason is that sale order always carry the revenue and production order and production period carry the cost .
cost you can settle to the Material and even management want to be settle the cost to material only in production order OR period
but in sales order when u sell the product it carry the revenue not the cost and management want see and analysis based on profitability segment are profit center level .
Prerequisites
If CO-PA is active, the system generates a settlement rule when you create the sales order. The settlement rule determines whether data is settled to other objects or other areas in Controlling. In accordance with this settlement rule, the relevant data is settled to CO-PA.
If CO-PA is not active, create a settlement rule. This settlement rule that you create manually normally contains a G/L account as a receiver (such as 399999). You can also settle costs and revenues or results analysis data to objects with revenue.
You can also settle the cost of sales calculated in results analysis to a fixed asset or a cost center. To do this, you must add to the allocation structure the results analysis cost elements under which the cost of sales is updated to the order.
The settlement rule includes a distribution rule for the sales order item. The distribution rule is made up of a settlement receiver, a settlement share, and a settlement type:
The settlement receiver (such as profitability segment or G/L account) specifies the object to which the actual costs and revenue of the sales order item are settled. The settlement receiver can be proposed through the settlement profile.
The settlement share defines the percentage or the equivalence numbers used to distribute the costs to the individual settlement receivers. The settlement share for sales order items is usually 100%. A settlement share of 100% is preset in the system.
The settlement type specifies full settlement of the sales order item. This ensures that all the data on the sales order is available for results analysis.
Settlement still takes place in each period. The revenues and the cost of sales are transferred to CO-PA by period, and the work in process and the reserves are transferred to FI. -
Stock reserver for sales order
Dear All
1. MMBE-Check the stock with batch no 6000000340 with 200 qty
2. Sale Order Created-
3. MB1B - Used Movement type 412 E with Inputs such as Sales Order,[warning message: sales order is not provided for this goods movement] after pressing the document is posted
4. In MMBE When i check the stock under batch no 6000000340 with 150 qty in unrestricted stock and Sales order Stock i can see the 50 quantity stock
Query is
1. Why the 50 quantity stock which is reserved for Sales order stock is seen under unrestricted stock and not under Reserved tab
2. When i create delivery with the same material and batch no, the stock is reduced from unrestricted stock[150 -10delivery qty] = its showing 140 qty, but stock should be reduced from 50 quantity which i have reserved for Sales order.
Please guide
Regards
Sandeep BhowmickHi Sandeep
Visualize this scenario
Material is pen in MMBE unrestricted stocks is 100
Sales order created with item cat TAN with special stock indicator E not marked and the order no is say 55 for 10 qty
Now you are reserving stocks in t code MB1B with movement type 412 E inputting the order no xx and saving it
Now in MMBE put the material as pen and input plant and storage location etc press F8
unrestricted stocks will be 90
Sales order stocks will be 10
If you click on the details of this sales order stocks you will see the order no xx and qty will be 10
(read your first post exactly the same of this)
now are delivering the sales order and doing the pgi
Now in MMBE
unrestricted stocks will be 80
Sales order stocks will be 10 (this exactly is your problem)
that means the system having a reservation in MMBE for a particular sales order xx not utilizing those stocks and still takes the stocks from the unrestricted and this is wrong
This is happening because the item cat TAN is not marked with special stock indicator E during order creation of xx
Now mark the item cat TAN with special stock indicator E and create a fresh cycle say order no yy
When you do PGI for order no yy the unrestricted will be 90 and there wont be any sales order stocks as the stocks are already PGIed
That means the system picks up the correct stocks for delivery
The system behaves very perfectly When there is sales order stocks in MMBE i dont understand ,what is the reservation you are talking about
Regards
Raja -
TABLE/FIELD FOR SALES ORDER'S SHIP TO LOCATION
Hi everyone,
Does anyone tell me what is the related tables/fields for Sales Order's Ship To Location? Since I want to display the Ship To Location information in the Oracle Report in Oracle Apps R11i.
I tried to use the following SQL select statement to retrieve the Ship to address:-
-- SHIP TO LOCATION
select a.address_id, c.customer_name, C.CUSTOMER_ID, A.SITE_USE_ID from ra_Site_uses_all a, ra_addresses_all b, ra_customers c
where a.site_use_code = 'SHIP_TO' and
a.status = 'A' and
b.address_id = a.address_id and
c.CUSTOMER_ID = b.CUSTOMER_ID and
b.status = 'A' and
c.customer_id in (select customer_id from ra_customers) and
c.status = 'A' and
c.customer_name like 'CLARION (H.K.)%'
But I found that the data is BILL TO address. Can anyone help me? Thanks.Hi all, I managed to solve my problem. Here's the query in case someone need it. Thanks
SELECT party.party_name "Send to" (SELECT party.party_name
FROM hz_cust_site_uses_all bill_su,
hz_cust_acct_sites_all bill_cas,
hz_party_sites bill_ps,
hz_locations bill_loc,
hz_parties party,
oe_order_headers_all h
WHERE h.invoice_to_org_id = bill_su.site_use_id
AND bill_su.cust_acct_site_id = bill_cas.cust_acct_site_id
AND bill_cas.party_site_id = bill_ps.party_site_id
AND bill_loc.location_id = bill_ps.location_id
AND bill_cas.party_site_id = bill_ps.party_site_id
AND bill_ps.party_id = party.party_id
AND h.order_number = 'your_order_number') "Invoice to"
FROM oe_order_headers_all h,
hz_cust_site_uses_all ship_su,
hz_cust_acct_sites_all ship_cas,
hz_party_sites ship_ps,
hz_locations ship_loc,
hz_parties party
WHERE h.ship_to_org_id = ship_su.site_use_id
AND ship_cas.party_site_id = ship_ps.party_site_id
AND ship_su.cust_acct_site_id = ship_cas.cust_acct_site_id
AND ship_cas.party_site_id = ship_ps.party_site_id
AND ship_ps.party_id = party.party_id
AND ship_loc.location_id = ship_ps.location_id
AND h.order_number = 'your_order_number';
Maybe you are looking for
-
I have a YouTube/google account, but when I tried to sign in it said I had an incorrect password. I tried again and it gave me the same message. However, when I sign in using safari, it works just fine. Then I found out it was because of the new 2-st
-
March 2015 TechNet Guru Awards! See who's boss in Windows Server! It could be YOU!
The results for March's TechNet Guru competition were posted! http://blogs.technet.com/b/wikininjas/archive/2015/04/17/the-microsoft-technet-guru-awards-march-2015.aspx Below is a summary of the medal winners for December. The last column being a few
-
Auto populate for fields in ZTable
Hi I created a Z Table with 10 Fields,Out of those 2 fields are timestamp and Created by. Timestamp and Created by are made Output only fields in Table Maintenance Generator SE11> ZTable>Table Maintenance Generator>Environment>Modifications-->Events
-
DPS6: Unable to retrieve a backend SEARCH connection to process the search
I have installed and configured DPS 6 but I cannot get it to proxy through to our back-end Sun DS 5.2 servers. The error message I get is: Error while reading entry [LDAP: error code 1 - Unable to retrieve a backend SEARCH connection to process the
-
Hi, experts I would like to know how to deal with over delivery to customer in sap as standard process?