Subtotal of quantity in cust wise sales register
Hi Experts....................
please ref to the following query which provides customer wise sales register report, now what we require is sum total of quantity of a particular item code for particular customer
e.g:- if on 01/04/09 customer A purchase 100 items of item code i1
and on 06/04/09 customer A purchase 275 items of item code i1
in the required report should display 100 + 275 = 375 for item code i1 & for same customer.......................................................................................................................................
SELECT distinct
1 as sr,'Invoice' [Document Type],
t0.docentry,
T0.[CardCode] as 'BP Number',
T0.[CardName] as 'BP name',
t0.numatcard as 'Vendor reference No.',
t0.u_loc as 'Location name' ,
t4.state,
T0.[DocNum] as 'Document Number',
--T0.[DocType],
t0.docdate,
ISNULL(T1.ItemCode,'Service Item') AS 'Item Code',
T1.[Dscription],
T1.[Quantity] AS 'Quantity',
t3.name as 'MAG',
t1.linetotal as 'Net Amount',
t1.vatsum as 'Tax Amount',
(t1.linetotal + t1.vatsum) as 'Invoice Value'
FROM [dbo].[OINV] T0
INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry = T1.DocEntry left outer join owhs t4 on t1.whscode = t4.whscode
LEFT JOIN [dbo].[OITM] T2 ON T1.ItemCode = T2.ItemCode
LEFT JOIN [dbo].[@ITMG] T3 ON T2.U_itmg = T3.Code
WHERE
T0.[DocType] = 'I'
and t0.cardcode between [%3] and [%4] and t0.docdate >= [%1]and t0.docdate <=[%2]
union
SELECT distinct 2,'Credit Memo' [Document Type],
t0.docentry,
T0.[CardCode] as 'BP Number',
T0.[CardName] as 'BP Name',
t0.numatcard as 'Vendor reference No.',
t0.u_loc as 'Location name' ,
t4.state,
T0.[DocNum] as 'Document Number',
--T0.[DocType],
t0.docdate,
ISNULL(T1.ItemCode,'Service Item') AS 'Item Code',
T1.[Dscription],
-T1.[Quantity] AS 'Quantity',
t3.name as 'MAG',
-t1.linetotal as 'Net Amount',
-t1.vatsum as 'Tax Amount',
-(t1.linetotal + t1.vatsum) as 'Invoice Value'
FROM [dbo].[ORIN] T0
INNER JOIN [dbo].[RIN1] T1 ON T0.DocEntry = T1.DocEntry left outer join owhs t4 on t1.whscode = t4.whscode
LEFT JOIN [dbo].[OITM] T2 ON T1.ItemCode = T2.ItemCode
LEFT JOIN [dbo].[@ITMG] T3 ON T2.U_itmg = T3.Code
WHERE
T0.[DocType] = 'I'
and t0.cardcode between [%3] and [%4] and t0.docdate >= [%1]and t0.docdate <=[%2]
union
SELECT distinct
1 as sr,'Invoice' [Document Type],
t0.docentry,
T0.[CardCode] as 'BP Number',
T0.[CardName] as 'BP name',
t0.numatcard as 'Vendor reference No.',
t0.u_loc as 'Location name' ,
t4.state,
T0.[DocNum] as 'Document Number',
--T0.[DocType],
t0.docdate,
ISNULL(T1.ItemCode,'Service Item') AS 'Item Code',
T1.[Dscription],
T1.[Quantity] AS 'Quantity',
t3.name as 'MAG',
t1.linetotal as 'Net Amount',
t1.vatsum as 'Tax Amount',
(t1.linetotal + t1.vatsum) as 'Invoice Value'
FROM [dbo].[OINV] T0
INNER JOIN [dbo].[INV1] T1 ON T0.DocEntry = T1.DocEntry left outer join owhs t4 on t1.whscode = t4.whscode
LEFT JOIN [dbo].[OITM] T2 ON T1.ItemCode = T2.ItemCode
LEFT JOIN [dbo].[@ITMG] T3 ON T2.U_itmg = T3.Code
WHERE
T0.[DocType] = 'S'
and t0.cardcode between [%3] and [%4] and t0.docdate >= [%1]and t0.docdate <=[%2]
union
SELECT distinct
2,'Credit Memo' [Document Type],
t0.docentry,
T0.[CardCode] as 'BP Number',
T0.[CardName] as 'BP Name',
t0.numatcard as 'Vendor reference No.',
t0.u_loc as 'Location name' ,
t4.state,
T0.[DocNum] as 'Document Number',
--T0.[DocType],
t0.docdate,
ISNULL(T1.ItemCode,'Service Item') AS 'Item Code',
T1.[Dscription],
-T1.[Quantity] AS 'Quantity',
t3.name as 'MAG',
-t1.linetotal as 'Net Amount',
-t1.vatsum as 'Tax Amount',
-(t1.linetotal + t1.vatsum) as 'Invoice Value'
FROM [dbo].[ORIN] T0
INNER JOIN [dbo].[RIN1] T1 ON T0.DocEntry = T1.DocEntry left outer join owhs t4 on t1.whscode = t4.whscode
LEFT JOIN [dbo].[OITM] T2 ON T1.ItemCode = T2.ItemCode
LEFT JOIN [dbo].[@ITMG] T3 ON T2.U_itmg = T3.Code
WHERE
T0.[DocType] = 'S'
and t0.cardcode
between [%3] and [%4] and t0.docdate >= [%1]and t0.docdate <=[%2]
ketan....
Edited by: ketan.k.pande on Dec 22, 2009 7:53 AM
Hi Ketan,
If you want to get those sub totals, you have to create a new query to omit all details. You could only leave few fields like:
T0.[CardCode] as 'BP Number',
T0.[CardName] as 'BP name',
ISNULL(T1.ItemCode,'Service Item') AS 'Item Code',
MAX(T1.[Dscription] ),
SUM(T1.[Quantity])
Group By T0.[CardCode], T0.[CardName],T1.ItemCode
Thanks,
Gordon
Similar Messages
-
Customer wise sales register-ALL
hi experts,
i want a report to show 'item' wise, 'service' wise n both item n service combine whn user select 'I' , 'S' or null
and date range thn it shud pic up data from below query
Select t.cardcode, cardname, sum(Quantity) as Quantity, sum(Value) as Value, sum(Tax) as Tax,
sum(Total) as Total, sum(materialvalue) as 'Material Value',sum(CM) as CM, (sum(CM)/SUM(VALUE)*100) as 'CM%' from
(SELECT (T0.CardCode) as cardcode,t0.cardname as cardname, sum(T1.Quantity) as Quantity,
sum(T1.[LineTotal]) as Value, sum(T1.[VatSum]) as Tax, sum( T1.[LineTotal] + T1.[VatSum]) as Total,
isnull(sum(T1.Quantity * t2.u_cmmc),'00')as materialvalue ,
isnull ((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) ,
sum(T1.[LineTotal])) as CM ,
ISNULL((((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) )/(sum(T1.[LineTotal]))*100),'100') as cm_perc
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry left outer join oitm t2
on t1.itemcode = t2.itemcode
*where T0.[DocType] = [%0] OR* t0.docdate >= [%1] and t0.docdate <= [%2]
group by T0.CardName,T0.CardCode
union
SELECT (T0.[CardCode]) as cardcode, T0.[CardName], -sum(T1.[Quantity]) as Quantity,
-sum(T1.[LineTotal]) as Value, -sum(T1.[VatSum]) as Tax, -sum( T1.[LineTotal] + T1.[VatSum]) as Total, isnull(-sum(T1.Quantity * t2.u_cmmc),'00') as materialvalue,
isnull((-sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) ,
-sum(T1.[LineTotal])) as CM ,
ISNULL((((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum]))) / -(-sum(T1.[LineTotal]))*100),'100') as cm_perc
FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry left outer join oitm t2
on t1.itemcode = t2.itemcode
*where T0.[DocType] = [%0] OR* t0.docdate >= [%1] and t0.docdate <= [%2]
group by T0.CardName,T0.CardCode) as t
group by t.cardname,t.cardcode
it get fails whn i giv where T0.[DocType] = [%0] AND t0.docdate >= [%1] and t0.docdate <= [%2]
for AND it takes 'I' and 'S' but null codition fails
& for OR null codition wrkng rest are not
ketan.....Hi!
Try this
Select t.cardcode, cardname, sum(Quantity) as Quantity, sum(Value) as Value, sum(Tax) as Tax,
sum(Total) as Total, sum(materialvalue) as 'Material Value',sum(CM) as CM, (sum(CM)/SUM(VALUE)*100) as 'CM%' from
(SELECT (T0.CardCode) as cardcode,t0.cardname as cardname, sum(T1.Quantity) as Quantity,
sum(T1.[LineTotal]) as Value, sum(T1.[VatSum]) as Tax, sum( T1.[LineTotal] + T1.[VatSum]) as Total,
isnull(sum(T1.Quantity * t2.u_cmmc),'00')as materialvalue ,
isnull ((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) ,
sum(T1.[LineTotal])) as CM ,
ISNULL((((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) )/(sum(T1.[LineTotal]))*100),'100') as cm_perc
FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry left outer join oitm t2
on t1.itemcode = t2.itemcode
Where (T0.[DocType] = [%0] OR [%0] = '' ) and t0.docdate >= [%1] and t0.docdate <= [%2]
group by T0.CardName,T0.CardCode
union
SELECT (T0.[CardCode]) as cardcode, T0.[CardName], -sum(T1.[Quantity]) as Quantity,
-sum(T1.[LineTotal]) as Value, -sum(T1.[VatSum]) as Tax, -sum( T1.[LineTotal] + T1.[VatSum]) as Total, isnull(-sum(T1.Quantity * t2.u_cmmc),'00') as materialvalue,
isnull((-sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum])) ,
-sum(T1.[LineTotal])) as CM ,
ISNULL((((sum( T1.[LineTotal] + T1.[VatSum]) - sum(T1.Quantity * t2.u_cmmc)- sum(T1.[VatSum]))) / -(-sum(T1.[LineTotal]))*100),'100') as cm_perc
FROM ORIN T0 INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry left outer join oitm t2
on t1.itemcode = t2.itemcode
where (T0.[DocType] = [%0] OR [%0] = '' ) and t0.docdate >= [%1] and t0.docdate <= [%2]
group by T0.CardName,T0.CardCode) as t
group by t.cardname,t.cardcode -
Query for Item wise sales report
Hi Guys,
Below is the query i have used to run Sales Register.
But we need Item wise sales register and those Excise Duty calculations are needed for item wise instead of total document wise. Pls update the query ...
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
(SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ', L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotalHi experts..
Pls Update the Query -
Query for Item wise Sales.......
*Hi Guys, Below is the query i have used to run Sales Register. But we need Item wise sales register and those Excise Duty calculations are needed for item wise instead of total document wise.
Pls update the query ...*
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price, (Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)', (SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ', (SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ', (SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ', (SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ', (SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ', (SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ', (SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ', (SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ', (SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ', (SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ', (SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ', (SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ', (SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ', (SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ', L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total' FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14 GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal ORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotalClosing this ...
Edited by: Parimis on Jun 25, 2010 5:44 PM -
hi All,
I have this query which is working fine as desired. I want to include selection criteria of "FROM" to "To" date in this query.
SELECT DISTINCT T0.Docentry, T0.[U_ManualInvoiceNum] as 'Bill No.', CONVERT(VARCHAR(10), T0.[DOCDATE], 3) AS DOCDATE, T0.[CardName] as 'Customer Name' , T1.[Dscription] as 'Item Description', T1.[Quantity], T1.[Price] as 'Price', T1.[TaxCode],
( T1.LineTotal ) as 'Basic' ,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-90 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum )BED,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-60 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum)Cess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=9 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)HeCess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=1 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)VAT,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=8 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)CST,
T0.[Comments] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry --INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode inner join INV4 T3 on T1.Docentry =T3.docentry and T1.LineNum=T3.LineNum inner join CRD7 T4 on T0.cardcode = T4.Cardcode
For browse
I tried using the below mentioned query to get the date selection but it still shows all the invoices created in the system and not between specified dates.
DECLARE @FromDate DateTime
DECLARE @ToDate DateTime
/* SELECT T0.DocDate FROM OINV T0 where T0.DocDate >=[%0] */
SET @FromDate = [%0]
/* SELECT T0.DocDate FROM OINV T0 where T0.DocDate <=[%0] */
SET @ToDate = [%1]
Thanks,
JosephHi,
I have these two reports for Sale register which may be useful to many so pasting it here,
BILL WISE SALE REGISTER
DECLARE @startDate DATETIME, @endDate DATETIME, @dummy INTEGER
SELECT TOP 1 @dummy = DocNum from OINV T0 where T0.DocDate >=[%1] and T0.DocDate <= [%2]
Select @startDate='[%1]' ,@endDate = '[%2]'
SELECT DISTINCT T0.Docentry, T0.[DocNum], T0.[DOCDATE] as 'Bill Date', T0.[CardName] as 'Customer Name' ,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-90 and INV4.docentry=T0.Docentry )BED,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-60 and INV4.docentry=T0.Docentry )Cess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=9 and INV4.docentry=T0.Docentry )HeCess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=1 and INV4.docentry=T0.Docentry )VAT,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=8 and INV4.docentry=T0.Docentry )CST,
T0.[Comments] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry and T1.Targettype <> 14
WHERE T0.DocDate >=@startDate and T0.DocDate <= @endDate
For Browse
Item Wise Sale Register
DECLARE @startDate DATETIME, @endDate DATETIME, @dummy INTEGER
SELECT TOP 1 @dummy = DocNum from OINV T0 where T0.DocDate >=[%1] and T0.DocDate <= [%2]
Select @startDate='[%1]' ,@endDate = '[%2]'
SELECT DISTINCT T0.Docentry, T0.[DocNum] as 'Bill No.', CONVERT(VARCHAR(10), T0.[DOCDATE], 3) AS 'Bill date', T0.[CardName] as 'Customer Name' , T1.[Dscription] as 'Item Description', T1.[Quantity], T1.[Price] as 'Price', T1.[TaxCode],
( T1.LineTotal ) as 'Basic' ,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-90 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum )BED,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-60 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum)Cess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=9 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)HeCess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=1 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)VAT,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=8 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)CST,
T0.[Comments] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
WHERE T0.DocDate >=@startDate and T0.DocDate <= @endDate and T1.TargetType <> 14
For Browse
Thanks,
Joseph -
URGENT : REPORT for sales register
Hi Guys,
Anybody is having the report on sales register? logic follows like this:-
The logic which needs to be developed is, as per input criteria given by user, which will be sales organization, plant & date range.Program needs to pick all the billing document which will satisfy the above criteria.
Except for document cateroty N i.e. invoice cancellation (VBRK -VBTYP not equal to N) and which are marked for cancellation (VBRK-FKSTO not equal to
X)
From the VBRK table pick up the document condition number (VBRk-KNUMV) and then go to KONV table you will find all condition with value over their. Pick up the values as per condition type and print it. (Condition types are already mentioned in format attached).
Their are 3 different format they have asked for, the format types will depend on the plant i.e. if plant start with 21 then it is RMC plant and accordingly appropriate format needs to be picked. Please check config for plant descrption.
By looking at format, i feel that some changes needs to be done into it like their is no material number or descprtion mentioned in format but qty & base rate fields their. Now whether register needs to printed for every line item in invoice or ony one line item for every invoice i.e.
consoliadted per invoice number. If it is consolidated then what about base rate which can be different for each line item. In this case what rate needs to be print.
Always print the invoice values line item by line item, giving each line item quantity, base price, and other pricing conditions but should have facility to sum up fields like Quantity, Base price, all pricing conditions each customer wise.
I have to get this report in ALV format.
I will reward points for useful answers.
My mail id is [email protected]
Waiting for reply...
Thanks,
Sundeep.Hi
If you are using sales and operation planning in make to stock scenario its simple . As You input target sale plan and target production plan for whole one year (MC84) . So this data can be pulled out from the tables .
For Action Need to be taken and revision you may need to have new table .
Neal -
Query for Itemwise Sales Register
Hi Guys,
Below is the query i have used to run Sales Register.But we need the sales register based on item wise and those Excise Duty calculations are needed for item wise instead of total document wise.
Pls update the query ...
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',L.Dscription,L.Quantity,L.Price,
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
(SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ',
L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
GROUP BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
ORDER BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal
Regards, Vamsi.Hi Guys, Below is the query i have used to run Sales Register.But we need the sales register based on item wise and those Excise Duty calculations are needed for item wise instead of total document wise. Pls update the query ...
SELECT M.DocNum AS 'Inv.No ', M.DocDate as 'Date', M.CardName as 'Customer Name',
L.Dscription,L.Quantity,L.Price, (Select Sum(LineTotal)
FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)', (SELECT Avg(TaxRate)
FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=7 and DocEntry=M.DocEntry) as ' TAXEXEMPT ',
(SELECT Avg(TaxRate) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as ' VAT% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=8 and DocEntry=M.DocEntry) as 'VAT12.5 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST 2% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=9 and DocEntry=M.DocEntry) as ' CST @2 ',
(SELECT Avg(TaxRate) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=11 and DocEntry=M.DocEntry) as ' CENVCST ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as ' BED ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess% ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as ' Cess ',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' HCess % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as ' Hcess ',
L.LineTotal as 'Row Total (Rs.)',M.DocTotal as 'Doc Total'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]') AND TargetType ! = 14
GROUP BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotalORDER BY M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,L.Dscription,L.Quantity,L.Price,L.LineTotal,M.DocTotal -
hai,
i m working on sales report where in i need to get month wise sales of the products and the related cost incured to company by the sales in the matrix form as shown below can u help me in which way can i get this monthly report
march april may june july......feb
mtrl 25 30 0 19 23 ........(mtrl quantity)
cost 30000 15000 0 45000 ..........(amt in rs)
where in the above i m able to get yearly sales in one column (i.e i m able to show for one particular customer total sales in one column) but i m unable to split sales monthly and unable to show in a report so how can i able to sow in this matrix formDear Raj,
Please find the code for monthly wise report in PA0001 Table for calculation of Administrator time Recording.
http://scn.sap.com/message/14216250#14216250 -
HI Experts,
We need a Sales report at the end of everymonth.
Below is the query i run to get the sales register.
SELECT M.DocNum AS ' Inv No. #', M.DocDate as 'Posting Date', M.CardName as 'Customer Name',
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'BaseAmt.(Rs.)',
M.VatSum as 'Tax (Rs.)',
M.DocTotal as 'Total (Rs.)',
(M.DocTotal-M.[PaidToDate]) as 'BalanceDue (Rs.)'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE M.DocDate BETWEEN '[%0]' AND '[%1]'
GROUP BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,
M.WTSum,M.DocTotal,M.PaidToDate,M.VatSum
ORDER BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,
M.WTSum,M.DocTotal,M.PaidToDate,M.VatSum
But i need the sales report by TAX Wise As we are having different types of tax.i need a a report on tax wise..
Pls provide me some solution.
Thanx in advance.Hi
U can try this:
SELECT M.DocNum AS 'AR Inv. #', M.DocDate as 'Date', M.CardName as 'Customer Name',M.NumAtCard as 'Customer Ref',
(Select Sum(LineTotal) FROM INV1 L Where L.DocEntry=M.DocEntry) as 'Base Amt.(Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as 'ED %',
(SELECT Sum(TaxSum) FROM INV4 where statype=-90 and DocEntry=M.DocEntry) as 'ED (Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS %',
(SELECT Sum(TaxSum) FROM INV4 where statype=-60 and DocEntry=M.DocEntry) as 'EDCS (Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as 'HECS %',
(SELECT Sum(TaxSum) FROM INV4 where statype=-55 and DocEntry=M.DocEntry) as 'HECS (Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=1 and DocEntry=M.DocEntry) as ' VAT (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=4 and DocEntry=M.DocEntry) as ' CST (Rs.) ',
(SELECT Sum(TaxSum) FROM INV4 where statype=-40 and DocEntry=M.DocEntry) as ' CVD (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax % ',
(SELECT Sum(TaxSum) FROM INV4 where statype=5 and DocEntry=M.DocEntry) as ' Ser.Tax (Rs.) ',
(SELECT Avg(TaxRate) FROM INV4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax %',
(SELECT Sum(TaxSum) FROM INV4 where statype=6 and DocEntry=M.DocEntry) as 'CS on Ser.Tax (Rs.)',
(SELECT Avg(TaxRate) FROM INV4 where statype=-10 and DocEntry=M.DocEntry) as 'HECS_ST %',
(SELECT Sum(TaxSum) FROM INV4 where statype=-10 and DocEntry=M.DocEntry) as 'HECS_ST (Rs.)',
(Select Sum(LineTotal) From INV3 Q Where Q.DocEntry=M.DocEntry) AS 'Freight (Rs.)',
M.WTSum AS 'TDS (Rs.)',
M.DocTotal as 'Total (Rs.)'
FROM OINV M LEFT OUTER JOIN INV1 L on L.DocEntry=M.DocEntry
LEFT OUTER JOIN INV4 T on T.DocEntry=L.DocEntry and L.LineNum=T.LineNum
LEFT OUTER JOIN INV5 J ON M.DocEntry = J.AbsEntry
LEFT OUTER JOIN INV3 Q ON M.DocEntry = Q.DocEntry
WHERE (M.DocDate >= '[%0]' AND M.DocDate <= '[%1]')
GROUP BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal
ORDER BY
M.DocNum,M.DocDate,M.CardName,M.NumAtCard,M.DocEntry,M.DiscSum,M.WTSum,M.DocTotal
Giri -
Problem in Sales Register in XL Reporter
Hi Experts
I have a problem in Sales Register. It show double quantity and linetotal in most of invoices. I search a lot but could not find the problem. When I compose a new sales report from Sales AR module , here it show the same error, double qty and amount. Anyone who is using this report plz tell me the problem.
problem is like this
correct Report
Doc number docdate Item qty linetotal
1 10/4/2009 p001 2 2000
2 12/4/2009 p002 3 2500
But XL Report show like this
1 10/4/2009 p001 4 4000
2 12/4/2009 p002 6 5000
Plz give your views
Regards
GorgeHi Gorge,
I am facing the same problem with stabdard report on SAP B1 2007 b, PL 10
even a thread is posted in the forum (reports and printing) but got no solution
Can you tell me how you have solved the problem
I would appreciate if you can share the solution.
thanks and regards
Kumar -
user raised directly invoice from the plant , when executinng sales register in Z report user want plant wise sales report .and in report they want profit center field in report , for this what settings we have to do in Z report.
Hi,
Basically, a Z report is a custom development made to meet the specific Business needs of an Organization.
You need to understand, the functional design of the report and modify with the new requirements. Once, the changes are made in function design you need to discuss with ABAP Consultant for making the changes.
As this is not a generic / SAP standard report - it is difficult to give a reply to resolve your issues.
Thanks
Murali. -
Hi Friends,
Can anyone provide the Tables and fields for general sales register. this report we would like to take from billing document.This regiseter is for material items, not for service items.
It would be more helpful for me if u can provide information about capturing of reversal(Cancellation) documents also
Following are the fields which iam using in the report.
Input
Document Dates
Bill to Party
Material
Output
Doc No
Sr.No (Sr.No with in the document items)
Bill to Party
Sales Type
Sales org
Distri Chl
Division
Delivery Plant
Material
Description
Quantity
Rate (Excl Taxes)
Gross Total (NetTax-DisExp)
Net Amount (Qty X Rate)
Tax Column1
Tax Column2
Tax Column3
Discount
Expenses
Round OffHi
the values you are required you can get from the following tables
VBRK - Header data for billing documents
VBRP - Item data for billing documents
KONV - Condition types table for billing documents and sales document
you have to take the link between VBRK and KONV tables then you will get all the condition types
Regards
vardhan -
Hi,
I want to create Sales register for all the taxes like BED, VAT etc... What are the tables from which the data need to picked?
KalliHi Kalli,
I have this which uses OINV (invoice as a base for sale register).
DECLARE @FromDate DateTime
DECLARE @ToDate DateTime
/* SELECT T0.DocDate FROM OINV T0 where T0.DocDate >=[%0] */
SET @FromDate = [%0]
/* SELECT T0.DocDate FROM OINV T0 where T0.DocDate <=[%0] */
SET @ToDate = [%1]
SELECT DISTINCT T0.Docentry, T0.[DocNum], T1.[Dscription],T1.[ItemCode], CONVERT(VARCHAR(10), T0.[DOCDATE], 3) AS DOCDATE, T1.[Quantity], T1.[Price], T1.[TaxCode],( T1.LineTotal ) as 'Basic' , T1.[VatSum]as 'Total Tax',
( T1.LineTotal +T1.[VatSum]) as 'INCLUDING TAX', T0.[CardCode] as 'Customer Code',T0.[CardName] as 'Customer Name' ,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-90 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum )BED,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=-60 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum)Cess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=8 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum)HCess,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=10 and INV4.docentry=T0.Docentry and INV4.linenum = T1.Linenum )SAD,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=4 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)CST,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=1 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)VAT,
(Select distinct isnull(Sum(INV4.taxsum),0) from INV4 where INV4.statype=8 and INV4.docentry=T0.Docentry and INV4.linenum = T1.linenum)SURCHARGE,
Discsum, T0.[Comments] FROM OINV T0 INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry --INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode inner join INV4 T3 on T1.Docentry =T3.docentry and T1.LineNum=T3.LineNum inner join CRD7 T4 on T0.cardcode = T4.Cardcode
Thanks,
Joseph -
Sales planning as per sales person wise/Sales group wise/Sales office wise
we are having a querry like Sales Planning in Sales & Distribution:
Company need's to set targets based on Sales Office wise/Sales group Wise/Sales Person wise. Later on company will check target Sales, Planned Sales, Achieved Sales. So how can we achieve in Sales and distribution module wise.
Regardsno my question is not related to PA
Suppose a sales person is there in my company name as:X. His target for this financial year is Rs.10 Crores. For that he will give list of materials to achieve this target and quantities and tentative dates also for which materials he needs. So that my company will do proper planning for production also to supply these materials timely. for this Company needs to analyse what is the given target and acheved target and what are all the materials are sold with respect to quantity. what materials are not sold means dead stock. So that how can we solve this solution in SAP.
Regards,
Venkat -
Hi Expert,
Client requirement is like this
Client procure "Article-ABC"from different vendors like Vendor 1, vendor 2, Vendor 3
and client do the sale to his customers
now client want to know how much "Article-ABC" sold from with respect to vendor1, and vendor 2 , vendor 3
Note:-
1) client raise @ 50 PO everyday to different different vendor
2) and each PO contain minimum 300 to 500 different- different Articles
if we generate the batch for each Articlel w.r.t vendor then @ 25000 batches will be generate everyday
please suggest
Edited by: Hanumant Nimbalkar on Jun 23, 2009 2:16 PMDear Hanumant,
You have to use Consulting Skills here; Vendor identify looses as soon as GRN done.
Option No. 1 : Since you are using SAP IS Retail, you can use Vendor Consignment to track Vendor wise sales
Option No. 2: You can develop customized report using following (suggested) logic;
(a) Vendor A - Article A - EAN Code 1
(b) Vendor B - Article A - EAN Code 2
(c) Vendor C - Article A - EAN Code 3
Since, Sales are happening through POS using EAN Code, you can extract all relevant information including EAN Code from POS System.
I hope this will suffice.
Regards - Muralidhara
Maybe you are looking for
-
So my cinema display will not turn back on if I have it on, remove the cord from computer then try to put the cord back in. However if I put the usb back in and put my mouse in the cinema usb port the mouse still works. I restarted my computer and th
-
How do i delete an App for re-installing
Hi all, i have a few App's that are for editing images, i wanted to use one of them yesterday, the first two i tried to open both came up with the same message, the message was telling me i had purchased it on another computer and i should sign in us
-
My pages templates are all in French. How do I switch to English?
-
Transactional Iview Error when displaying
Hi all , I have created a transactional Iview. It is working fine. I could see the preview of that .But the same is not getting displayed when I assigned to the portal it is showing Portal Runtime Error. Need help. Thanks. Krishna
-
How to convert a row value in CSV file to column value
Hi We have one requirement where we have to show the row value to column level value for Example: Source file will be in below format Component Name :101 **Batch # **100% Mod 200% Mod 300% Mod 400% Mod Tensile Elongation