AR INVOICE QUERY
Hi Experts,
I want a query that will pick all AR invoices that meet the following conditions:-
The card code belongs to a particular customer group, in this case the group code is 108
The invoice posting date is after 21/05/2012
The invoice status is open
The invoice is more than 15 days old
The invoice contains items that have certain properties, in this case the [QryGroup are 8,9,13,14,15,16,17,26,27,28] (Item can and must have any of this 10 properties)
I have come up with the following query
SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup8] = 'y' and T0.[DocDate] <= getdate()-15
I have then joined several of these queries using union all to include the 10 different qryGroup. The complete query is as follows:-
SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup8] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup9] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup13] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup14] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup15] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup16] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup17] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup26] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup27] = 'y' and T0.[DocDate] <= getdate()-15 UNION ALL SELECT T0.[DocNum], T0.[U_CXS_TRID], T0.[DocDate], T0.[CardCode], T0.[CardName], T0.[DocTotal], T0.[PaidToDate],(T0.DocTotal - T0.PaidToDate) AS 'Open Inv/Bal', DATEDIFF (DD,T0.DocDate, GETDATE ( ) ) AS 'Days To/Past' FROM [dbo].[OINV] T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN OCRD T2 ON T0.CardCode = T2.CardCode INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode WHERE T0.[DocDate] >=[%0] AND T0.[DocStatus]= 'O' and T2.[GroupCode] = '108' and T3.[QryGroup28] = 'y' and T0.[DocDate] <= getdate()-15
The query gives me the results i want but i would like to refine it such that a document number appears onlt once in the output whenever there are 2 or more items in it that satisfy the conditions. Secondly i would like to make the doc date 21/05/2012 static in the query rather than T0.[DocDate] >=[%0]
Thanks for your help
George Njuguna
Hi George
Try this query
Select InvoiceHD.[DocNum], InvoiceHD.[DocDate], InvoiceHD.[CardCode], InvoiceHD.[CardName], InvoiceHD.[DocTotal],
InvoiceHD.[PaidToDate],(InvoiceHD.DocTotal - InvoiceHD.PaidToDate) AS 'Open Inv/Bal', DATEDIFF(DAY,InvoiceHD.CreateDate,GetDate()) AS 'Days To/Past' From OINV InvoiceHD
Inner Join INV1 InvoiceLine1 ON InvoiceHD.DocEntry = InvoiceLine1.DocEntry
Inner Join OITM ItemMaster ON ItemMaster.ItemCode = InvoiceLine1.ItemCode
Where InvoiceHD.DocStatus = 'O' AND
InvoiceHD.DocDate >'20120521' AND
DATEDIFF(DAY,InvoiceHD.CreateDate,GetDate())>=15 AND
'Y' In (ItemMaster.QryGroup8,ItemMaster.QryGroup9,ItemMaster.QryGroup13,ItemMaster.QryGroup14,
ItemMaster.QryGroup15,ItemMaster.QryGroup16,ItemMaster.QryGroup17,ItemMaster.QryGroup26,
ItemMaster.QryGroup27,ItemMaster.QryGroup28)
Regards
Vivek
Similar Messages
-
INcoming Excises Invoice Query
SELECT DISTINCT (T0.[DocNum]) AS 'INVOICE NUMBER', T0.[DocDate] AS 'INVOICE DATE',T0.[CardName], T1.[ItemCode] AS 'PART NO', T1.[Dscription] AS 'PART DESCRIPTION', T1.[Quantity], T1.[Price], T1.[LineTotal] AS 'BASE AMOUNT',
(SELECT sum(TaxSum) FROM IEI4 where statype=-90 and DocEntry=T0.DocEntry and LineNum=t1.LineNum) as 'BED 10%',
(SELECT sum(TaxSum) FROM IEI4 where statype=-60 and DocEntry=T0.DocEntry and LineNum=t1.LineNum) as 'ECESS 2%',
(SELECT sum(TaxSum) FROM IEI4 where statype=-55 and DocEntry=T0.DocEntry and LineNum=t1.LineNum) as 'HSCESS 1%',
(SELECT sum(TaxSum) FROM IEI4 where statype=4 and DocEntry=T0.DocEntry and LineNum=t1.LineNum) as 'CST',
(SELECT sum(TaxSum) FROM IEI4 where statype=1 and DocEntry=T0.DocEntry and LineNum=t1.LineNum) as 'VAT',
T1.[LineTotal]+t1.[VatSum] as'TOTAL'
FROM OIEI T0 INNER JOIN IEI1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN IEI4 T2 ON T0.DocEntry = T2.DocEntry
INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode
WHERE T0.[DocDate] >=[%0] AND T0.[DocDate] <=[%1]
above this queriry is incoming Excise invoice warhouse and Busniess Partner mingle, so now i want to need only BP wise Incoming Excises Invoice Query , How do i Negligble? pls help me and reply soon , How Do i change the Query?Hi Rakan.......
Sorry. Your way of telling requirement is bit Ambiguous.......
Please correct me what I understood from your requirement is.\
Generally incoming Excise Invoice is made from GRPO/ORDN/ORIN and base on Inventory Transfer.
So you want only those Incoming Excise Invoice which is based on GRPO that is BP wise.
Am I correct now?
If yes the try this......
SELECT DISTINCT (T0.DocNum) AS 'INVOICE NUMBER', T0.DocDate AS 'INVOICE DATE',T0.CardName, T1.ItemCode AS 'PART NO', T1.Dscription AS 'PART DESCRIPTION', T1.Quantity, T1.Price, T1.LineTotal AS 'BASE AMOUNT',
(SELECT sum(TaxSum) FROM IEI4 where statype=-90 and DocEntry=T0.DocEntry ) as 'BED 10%',
(SELECT sum(TaxSum) FROM IEI4 where statype=-60 and DocEntry=T0.DocEntry ) as 'ECESS 2%',
(SELECT sum(TaxSum) FROM IEI4 where statype=-55 and DocEntry=T0.DocEntry ) as 'HSCESS 1%',
(SELECT sum(TaxSum) FROM IEI4 where statype=4 and DocEntry=T0.DocEntry ) as 'CST',
(SELECT sum(TaxSum) FROM IEI4 where statype=1 and DocEntry=T0.DocEntry ) as 'VAT',
T1.LineTotal+t1.VatSum as'TOTAL'
FROM OIEI T0 INNER JOIN IEI1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN IEI4 T2 ON T0.DocEntry = T2.DocEntry
INNER JOIN OITM T3 ON T1.ItemCode = T3.ItemCode
WHERE T0.DocDate >= '%0' AND T0.DocDate <= '%1' AND T1.BaseType in (20,16,14)
Above will give you the details of Excise Invoice BP wise....
Regards,
Rahul -
Hi B1 Experts
Kindly help me....
I need A/R invoice query report which will give me the Daily, monthly and yearly total invoicing as on date in a single screen also without using XL reporter.
I am using SAP B1 version 2005B PL36.
Thx in advance.
Rozario.SELECT DISTINCT T0.CardCode [Customer],
(SELECT ISNULL(SUM(I1.LineTotal),0) FROM INV1 I1 INNER JOIN OINV I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode AND Day(I1.DocDate) = Day(GetDate())) [Daily],
(SELECT ISNULL(SUM(I1.LineTotal),0) FROM INV1 I1 INNER JOIN OINV I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode AND Month(I1.DocDate) = Month(GetDate())) [Monthly],
(SELECT ISNULL(SUM(I1.LineTotal),0) FROM INV1 I1 INNER JOIN OINV I ON I1.DocEntry = I.DocEntry WHERE I.CardCode = T0.CardCode AND Year(I1.DocDate) = Year(GetDate())) [Yearily]
FROM [dbo].[OINV] T0
GROUP By T0.CardCode -
Hello All,
Can one give me MATCHING Invoice Query (AP) for both 2-way and 3-way matching.
I would like to have a report which gives whther a particluar invoice is matching or not.
Thanks,
KumarIf any of the distribution is matched, the invoice should be taken as matched. Here is the modified query:
select ai.*
from ap_invoices_all ai
where not exists (select "matched"
from ap_invoice_distributions_all aid
where aid.invoice_id = ai.invoice_id
and aid.po_line_location_id is not null); -
Hi
Please send the sales order invoice query as basic columns.. Further I will modify the query according to the requirement.
Pleas send to my personal ID: [email protected]
Thanks
SreeThanks. There's a few problems though.
1) It seems that OINV DocTotal != Balance Due. I'm seeing a number of invoices where there was a balance due, but we applied additional money (either we took another incoming payment and applied it or applied money from the account balance, etc.) and yet it still shows a total.
2) It's pulling incoming payments from different customers. I think this is because the table was joined based on "RCT2 T4 on T4.[DocEntry] = T3.[DocNum] and T4.[InvoiceId] = T2.[LineNum]" In one example I have 2 incoming payments 446 and 614. Both have the DocEntry 542, but one relates to A/R Invoice 542 (for a different client) while the other relates to Down Payment Invoice 542. *I was able to fix this by adding WHERE T5.CardCode = [%0]*
3) I'm going to work with this a little bit and see if I can alter it to make it work for me. Basically this query falls a little short on the following:
- Doesn't include incoming payments that aren't linked to a down payment invoice.
- Does not give the Invoice Total (I'd like to know how much of the SO was invoiced. DocTotal seems to give me Amount Invoiced - Down Payments. I'm not sure the best way to get this number. Maybe I could do the sum of each line * tax + freight)
- Does not give the outstanding amount on an invoice. The ARtotal [DocTotal] column gives me how much was owed when the invoice was created, but it doesn't tell me what is currently owed.
- Lastly it may complicate the query too much and could be left off, but it would be nice to see if they have any money from credits or incoming payments that has not been applied. Perhaps this would be easily accomplished by simply pulling in their account balance. -
Hello,
I want to come up with a Query to track pricing changes done for items on the A/P Invoice before it's added.
For instance: in the GRPO, Bread = 2$
in the target A/P invoice, Bread = 3$
At times, the users have to change these prices to correct any pricing errors that might have occurred in the GRPO. I need to trace any price changes done in the A/P invoices (i.e. from price A to price B) as well as display the name of the user who did the modification. Seems a bit difficult because the changes in the A/P are done before the A/P is added.
Is there a way that the A/P prices can be compared to the GRPO prices, especially given that the prices from the 'system information' appear as variables?
Rgds,
HenryHai try this....
select * from (
SELECT *,isnull((INV_Price - GRN_Price),0) as 'Price_Diff' from (
select pc1.Docnum as 'INV_No',pc1.Docdate,pc2.Itemcode, pc2.Quantity as 'INV_Qty',pc2.Price as 'INV_Price',
pc2.Discprcnt as 'INV_Discount%',
pc2.Baseref as 'GRN_No' ,
(Select isnull(op2.quantity ,0) from pdn1 op2 where op2.docentry = pc2.baseentry
and op2.linenum = pc2.baseline and op2.itemcode= pc2.itemcode) as 'GRN_Qty',
(Select isnull(op3.price ,0) from pdn1 op3 where op3.docentry = pc2.baseentry
and op3.linenum = pc2.baseline) as 'GRN_Price',
(Select isnull(op4.Discprcnt ,0) from pdn1 op4 where op4.docentry = pc2.baseentry
and op4.linenum = pc2.baseline) as 'GRN_Discount%'
from opch pc1 inner join pch1 pc2 on pc1.docentry = pc2.docentry
where pc1.doctype <> 'S') a ) b
where b.Price_Diff <> 0
order by Price_Diff desc,Docdate,INV_No -
Credit Memo and AR Invoice Query
Hi Everyone,
I'm fairly new to query writing and need to write a query that would list all of the credit memos and invoices. I was able to write the following query that pulls just the AR Invoice info. How do I also pull the AR Credit Memo info?
SELECT T0.[CardCode], T0.[DocNum], T0.[DocDate], T1.[Quantity], T1.[ItemCode], T1.[PriceBefDi], T1.[StockPrice] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry ORDER BY T0.[CardCode], T0.[DocNum]
When using the generator it does not link the tables together in any fashion. I tried to just add the ORIN and RIN1 tables to it (as I can just have them listed below the invoices), but SAP appears to just lock up and I end up closing the application.
I searched the forum as well and found that there is a link between the two and it is:
RIN1.BaseEntry = OINV.DocEntry
and
INV1.TrgetEntry = ORIN.DocEntry
However, when I try to add these joins to the query, it ends up showing a credit memo for every single line, and I know that is not correct. I know there are different types of joins, so perhaps I'm using the wrong join or something?
I appreciate anybody's help.
Thank you,
AmandaHi Amanda,
Try this one:
SELECT T0.CardCode, T0.DocNum, T0.DocDate, T1.Quantity, T1.ItemCode, T1.PriceBefDi,
T1.StockPrice FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
UNION ALL
SELECT T0.CardCode, T0.DocNum, T0.DocDate, T1.Quantity, T1.ItemCode, T1.PriceBefDi,
T1.StockPrice FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
ORDER BY T0.CardCode, T0.DocNum
Thanks,
Gordon -
Hi Experts,
How to link a sales invoice to its base sale order in a query
I want to know the qty commited in the sales order is fully invoiced (billed) in invoice level to a customer or not for this i need a query
Regards
SundarHi,
In RDR1 --> Target Type - contains the Delivery Object Type (ObjType = 15) and Target Entry contains Delivery Document Number.
In DLN1 --> Base Type - Contains Sales Order (Base Document's) Document's Object Type (ObjType = 17 and Base entry and BaseRef contains Sales Order (Base Document) Document Number.
In DLN1 --> Target Type - contains Invoice (Target Document's) Document's Object Type (ObjType = 13) and Target Entry (Target Document's) Document number.
In INV1 --> Base Type - contains Base document's type and Base Ref contains Base Document's Document Number.
I hope this could help.
Regards
Raja.S -
Query of 3 Way match ( Invoice-Receipt)
Hi All,
Can Someone please give me Matching Invoice Query (AP) / Steps for 3-way matching. I have requirement wherein I have to match Invoice with Receipt but I don't know how should i do that through coding or required steps.
As I know I know below conditions are required for 3 way match but dont know how should I get all these individual data from AP tables.
Invoice price <= Purchase order price
Quantity billed <= Quantity Ordered
Quantity billed <= Quantity received
Can you please help me to get this information.
Thanks.I have prepared queries based on d 3-way match functionality .. Can some one please verify this, if I am missing anything here -
-- Invoice price <= Purchase order price
SELECT sum((NVL(poll.quantity, 0) - NVL(poll.quantity_cancelled, 0)) *
NVL(pol.unit_price, 0)) "PO PRICE",
sum(apd.quantity_invoiced * apd.unit_price) "INVOICE PRICE"
FROM po_headers_all poh,
po_lines_all pol,
po_line_locations_all poll,
po_distributions_all pd,
ap_invoice_distributions_all apd
WHERE poh.po_header_id = pol.po_header_id AND
pol.po_line_id = poll.po_line_id AND
poll.po_header_id = pol.po_header_id AND
poh.authorization_status = 'APPROVED' AND
poh.type_lookup_code = 'STANDARD' AND
NVL(poh.cancel_flag, 'N') = 'N' AND POL.ITEM_ID IS NOT NULL AND
apd.unit_price < pol.unit_price AND
-- AND NVL (poll.quantity, 0) > (NVL (poll.Quantity_received,0) + NVL (poll.Quantity_cancelled,0))
poll.inspection_required_flag = 'N' AND
poll.receipt_required_flag = 'Y' and
pd.po_header_id = poh.po_header_id(+) AND
poll.po_header_id = pd.po_header_id AND
pd.po_line_id = pol.po_line_id AND
pd.line_location_id = poll.line_location_id AND
apd.po_distribution_id = pd.po_distribution_id AND
POH.po_header_id = ? AND apd.po_distribution_id is not null
-- Quantity billed <= Quantity Ordered
SELECT sum(pd.quantity_ordered) "Quantity Ordered",
sum(pd.quantity_billed) "Quantity Billed"
--sum(apd.quantity_invoiced) "Quantity billed"
FROM po_headers_all poh,
po_lines_all pol,
po_line_locations_all poll,
po_distributions_all pd,
ap_invoice_distributions_all apd
WHERE poh.po_header_id = pol.po_header_id AND
pol.po_line_id = poll.po_line_id AND
poll.po_header_id = pol.po_header_id AND
poh.authorization_status = 'APPROVED' AND
poh.type_lookup_code = 'STANDARD' AND
NVL(poh.cancel_flag, 'N') = 'N' AND POL.ITEM_ID IS NOT NULL AND
apd.unit_price < pol.unit_price
-- AND NVL (poll.quantity, 0) > (NVL (poll.Quantity_received,0) + NVL (poll.Quantity_cancelled,0))
and POH.po_header_id = ? and poll.inspection_required_flag = 'N' AND
poll.receipt_required_flag = 'Y' and
pd.po_header_id = poh.po_header_id(+) AND
poll.po_header_id = pd.po_header_id AND
pd.po_line_id = pol.po_line_id AND
pd.line_location_id = poll.line_location_id and
apd.po_distribution_id = pd.po_distribution_id and
apd.po_distribution_id is not null
--Quantity billed <= Quantity received
SELECT sum(rsl.QUANTITY_RECEIVED) "Quantity received"
from rcv_transactions rct,
rcv_shipment_headers rsh,
rcv_shipment_lines rsl,
po_lines pol,
po_line_locations pll
where rct.po_line_location_id = pll.line_location_id and
rct.po_line_id = pol.po_line_id and
nvl(pol.order_type_lookup_code, 'QUANTITY') NOT IN
('RATE', 'FIXED PRICE') and
rct.shipment_line_id = rsl.shipment_line_id and
rsl.shipment_header_id = rsh.shipment_header_id and
transaction_type = 'RECEIVE' and pol.po_header_id = ?
order by rct.transaction_id -
Relation between Ap down payment invoice and Ap invoice
Hi sap members
pls help in this scenario what is the query relation for ap down payment invoice and ap invoice solution given vilbe appreciated
regards
Jenny
Edited by: Jennifer Anderson on May 3, 2010 11:02 AMhi Gordon
can u write a query and send regarding this relation i need fields like
SELECT Distinct T0.[DocNum][Invoice No ], T0.[CardName], T0.[DocTotal], T1.[DocNum][Ap Down Payment No],T1.[CardName], T1.[DocTotal]
FROM OPCH T0 , ODPO T1
WHERE T0.[CardName] = T1.[CardName]
and T0.[DpmAmnt] = T1.[DocTotal]
GROUP BY T0.[DocNum], T0.[CardName], T0.[DocTotal], T1.[DocNum],
T1.[CardName], T1.[DocTotal]
in Ap invoice Query i need Ap down payment Docnum
Regards
Jenny -
Returned records different in query to workbook
We are using Bex Analyser version 7.
I have a pending invoices query embedded in a workbook. If I refresh the query within the workbook, I get 3 fewer records than if I run the same query on its own.
When I identified the 3 invoices concerned I could see that they have a zero key figure values. I haven't suppressed zero records in the query but they appear to be suppressed in the workbook.
Has anybody got any suggestions for amending my workbook so that I get all the records?
Many thanks,
Positive ParrotHi,
Can you check in this way.
Right click on a particular record in workbook-> properties> calculation---> calculate single value as.
Thanks,
Ashok -
I am based in the UK, My company received an invoice for server support for IBM servers, I have a query regarding this invoice, I have been tying for over a month to establish how to go about logging this query by email or phone, I emailed [email protected] on many occasions but never get a reply, I have scanned just about every web page but no phone number ???How the hell do you log an invoice query?
SWW, Please try calling the number listed on this site: http://shop.lenovo.com/gb/en/systems/servers/ The contact on this site is listed: Kasandra Arapovic 0800 9175020 Please let me know if this information was not helpful.
-
Hello All,
Can one give me MATCHING Invoice Query (AP) for both 2-way and 3-way matching.
I would like to have a report which gives whther a particluar invoice is matching or not.
Reoprt should be as follows.
Invocie number Matching Status.
Thanks,
KumarDear Thomas,
In order to get this information you need a query that would work out the values in the ar down payment invoice.
This can be a beginning. However, some values must be calculated in the query because they are not in the table.
SELECT T0.DocNum, T0.CardCode, T1.VatSum, T1.LineTotal, (T1.LineTotal * T0.DpmPrcnt/100) as DPM, (t1.LineTotal - (T1.LineTotal * T0.DpmPrcnt/100) - T1.VatSum) as PAYM_LEFT FROM ODPI T0 INNER JOIN DPI1 T1 ON T0.DocEntry = T1.DocEntry WHERE T0.DocNum = '1'
Please, let me know if this is sufficient or you need some more information from the query.
Kind Regards,
Marcella Rivi
SAP Business One Forums Team -
Hi All,
This is Sales order with return, delivery, AR invoice query.....Query is working but it shows repetative records..pls check the query below......and just copy and paste it and give AR Invoice document no ...plz check query for minimum two item Nos...then you will understand it shows 8 records instead of 2 records(line items)........pls tell me what to do to show only 2 line items........
And one more doubt..if AR invoice does not have sales order or return or delivery then also it should show AR invoice details or other respective details........query is below
SELECT b.Doc_Num1 as 'SO. No.',
b.DocDate1 as 'SO. Date',
b.Doc_Num2 AS 'Del.Doc.No.',
b.DocDate2 AS 'Delivery Date',
b.Doc_Num3 as 'A/R Invoice No.',
b.DocDate3 as 'Inv. Date',
b.Doc_Num4 AS 'RETURN Doc.No.',
b.DocDate4 as 'Ret.Date',
b.CardName as 'Vendor Name',
b.NumAtCard as 'Bill No. & Date',
b.ItemCode as 'Item Code',
b.Dscription as 'Dscription',
b.Quantity1 as 'AR Invoice Quantity',
b.Quantity2 as 'Sales Order Quantity',
b.Quantity3 as 'Delivery Quantity',
b.Quantity4 as 'Return Quantity',
b.LineTotal as 'Base Amt.(Rs.)',
b.WTSum AS 'TDS (Rs.)',
b.DocTotal as 'Total (Rs.)',
sum(b.BED) as 'Bed Value',
sum(b.EDCS) as 'EDCS Value',
sum(b.HECS) as 'HECS Value',
sum(b.VAT) as 'VAT Value',
sum(b.CST) as 'CST Value',
sum(b.CVD) as 'CVD Value',
sum(b.SerTax) as 'SERTAX Value',
sum(b.CSonSerTax) as 'CS Value',
sum(b.HECS_ST) as 'HESC Value'Hi Sonal,
Try this,
SELECT b.Doc_Num1 as 'SO. No.',
b.DocDate1 as 'SO. Date',
b.Doc_Num2 AS 'Del.Doc.No.',
b.DocDate2 AS 'Delivery Date',
b.Doc_Num3 as 'A/R Invoice No.',
b.DocDate3 as 'Inv. Date',
b.Doc_Num4 AS 'RETURN Doc.No.',
b.DocDate4 as 'Ret.Date',
b.CardName as 'Vendor Name',
b.NumAtCard as 'Bill No. & Date',
b.ItemCode as 'Item Code',
b.Dscription as 'Dscription',
b.Quantity1 as 'SO_Qty',
b.Quantity2 as 'DLN_Qty',
b.Quantity3 as 'A/R Inv_Qty',
b.Quantity4 as 'Return_Qty',
b.LineTotal as 'Base Amt.(Rs.)',
b.WTSum AS 'TDS (Rs.)',
b.DocTotal as 'Total (Rs.)',
sum(b.BED) as 'Bed Value',
sum(b.EDCS) as 'EDCS Value',
sum(b.HECS) as 'HECS Value',
sum(b.VAT) as 'VAT Value',
sum(b.CST) as 'CST Value',
sum(b.CVD) as 'CVD Value',
sum(b.SerTax) as 'SERTAX Value',
sum(b.CSonSerTax) as 'CS Value',
sum(b.HECS_ST) as 'HESC Value'
from (
select *,( a.Bed + a.EDCS + a.HECS + a.VAT + a.CST +a.CVD + a.SerTax + a.CSonSerTax + a.HECS_ST ) as Filter from (SELECT distinct
T0.DocNum as 'Doc_Num1',
T0.DocDate as 'DocDate1',
T2.DocNum as 'Doc_Num2',
T2.DocDate as 'DocDate2',
M.DocNum as 'Doc_Num3',
M.DocDate as 'DocDate3',
M.CardName,
M.NumAtCard,
L.ItemCode,
L.Dscription,
T1.Quantity as 'Quantity1',
T3.Quantity as 'Quantity2',
L.Quantity as 'Quantity3',
X.Quantity as 'Quantity4',
S.DocNum 'Doc_Num4',
S.DocDate as 'DocDate4',
L.LineTotal ,
M.DocEntry,
M.[DiscSum],
M.WTSum,
M.DocTotal,
Regards,
Madhan.
Edited by: Madhan Babu C on Aug 28, 2009 2:12 PM -
Approval Template based on overdue invoices for a Region
Hi,
We have set an approval template for all overdue invoices which should go to the repsective sales managers for approval.
We have setup two approval templates one for Central region and one for NES region.
The template involves running of the following query and going to the respective manager for approval, however this does not work.
When we create a seperate location wise approval template it works:
Please check and let me know the error if any:
SELECT DISTINCT 'TRUE' FROM OINV T0 and OCRD T1 WHERE T1.CardCode =
$[$4.0.0] and T1.U_AT_PC = 'NES' and T0.DocDueDate <= Getdate() AND T0.DocStatus !='C' AND $[ORDR.CARDCODE] = T0.CARDCODE
Regards,Hi Gordon,
Thanks for your reply!
Actually, we had created the following query as per our requirement for all overdue invoices:
SELECT DISTINCT 'TRUE' FROM OINV T0 WHERE T0.DocDueDate <= Getdate() AND T0.DocStatus !='C' AND $[ORDR.CARDCODE] = T0.CARDCODE
( here the customer name in the order should be equal to the Invoice Table Customer code )
and the location wise query:
SELECT 'TRUE' FROM OCRD T0 where T0.CardCode =
$[$4.0.0] and T0.U_AT_PC = 'NES'
When i tried using this query with the Overdue invoice query the same order had to be approved by the manager twice, which is not acceptable.
The problem in using the location wise approval template with the query, was that the "Confirm Credit Line Deviation" prompts up every time we try to enter a Sales Order.
Whereas we wanted an alert to be prompted to the sales manager once any sales order is entered however if the SO is above the credit limit the sales manager should know about it, which can be achieved if we use the overdue invoice query correctly.
I tried clubbing both the above queries together,but it doesn't work.
Is there a way where you could use one query with an IF clause saying that if the UDF field is U_AT_PC= "NES" then go to NES sales manager if U_AT_PC="Central" then go to Central sales manager.
Please revert
Regards
Maybe you are looking for
-
please does anyone knows how to delete the "others" on the iphone becuase it take me a lot of spaace and i cant have anything i have 5 GB of othres coan some one help me please?
-
I went through and did the download process and it only downloaded half of my Creative Suite 6. I REALLY need Acrobat X Pro for a project!!!
-
How to undeploy sda/sca from PI 7.1 ?
Dear SAP colleagues, I am looking a tool to undeploy sda and sca file from PI 7.1 system. From PI 7.0 or any SAP NW until 7.02, there is SDM. SDM does not exist any longer from SAP NW 7.1. Thanks for your input. Best regards SAP NetWeaverAdmin
-
Generating Dynamic form from static context.
Hi All I have static context node structure Section (Node) QuestionText (Attribute) AnsText (Attribute) I have populated the values in this node from an RFC in my code . Now i need to create a form dynamically with QuestionText as la
-
photo won't get started after installing the new update (wheel spinning under the get started button)