Hi,
Are you working with SAP Business one? If no, please find correct forum and repost above discussion to get quick response.
Thanks & Regards,
Nagarajan
Hi,
Are you working with SAP Business one? If no, please find correct forum and repost above discussion to get quick response.
Thanks & Regards,
Nagarajan
Hi,
Yes possible by using PIVOT function to get total at end of column.
Thanks & Regards,
Nagarajan
Hi,
How did you get sum in words from QPLD? I don't think it is possible to such description from query result.
Thanks & Regards,
Nagarajan
The user does not have excel on his node. Hence cannot use pivot. However Mr.Kennedy's solution has worked for us. Thanks for the input.
Thanks.Your solution has worked for us.
Close the thread with the correct answer..
Rgds
Kennedy
Hi,
try this query:
Declare @FromDate Datetime
Declare @ToDate Datetime
Declare @ItmsGrpNam varchar(100)
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >= '[%0]'
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <= '[%1]'
select @ItmsGrpNam = max(s2.ItmsGrpNam) from dbo.OITB S2 Where S2.ItmsGrpNam = '[%2]'
Select distinct a.Itemcode, max(a.Dscription) as ItemName, (Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,a.InvntAct,
(isnull(( Select distinct sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.DocDate<=@FromDate ),0)- isnull(( Select sum(isnull(outqty,0)) from OINM O1
where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.DocDate<=@FromDate),0)) as [Opening Stock],
(isnull((Select distinct isnull(sum(round(TransValue,0)),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.DocDate<=@FromDate ),0)) as [Opening Stock Value],
isnull((Select ISNULL((sum(isnull(inqty,0))),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.transtype in (20,18)),0) as [Purchase Quantity],
isnull((Select isnull(sum(round(TransValue,0)),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.InQty>=0 and O1.JrnlMemo not like '%cancellation%'
and O1.transtype in (20,18)),0 ) as [Purchase Value],
isnull((Select sum(isnull(OutQty,0))from OINM O1 left join OWOR ta on Ta.docentry = O1.[AppObjAbs] where O1.itemcode=a.ItemCode AND O1.InvntAct = a.InvntAct
and O1.ApplObj = '202' and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.OutQty>0 and Ta.[Type] = 'S' and
O1.transtype = '60'),0) as [Production Issue Quantity],
isnull((Select isnull(sum(round(TransValue,0)),0)from OINM O1 left join OWOR ta on Ta.docentry = O1.[AppObjAbs] where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.ApplObj = '202' and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.OutQty>0 and Ta.[Type] = 'S'
and O1.transtype = '60'),0) as [Production Issue Value],
isnull((Select sum(isnull(Inqty,0)) from OINM O1 inner join OIGN G1 on O1.BASE_REF = G1.DocNum inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = G2.ItemCode
and G2.BaseType = '202' and G2.TranType is null and O1.docdate>=@FromDate
and O1.docdate<=@ToDate and O1.Inqty>0 and O1.transtype = '59'),0) as [Goods Receipt Return Quantity],
isnull((Select sum(isnull(Inqty,0)) from OINM O1
inner join OIGN G1 on O1.BASE_REF = G1.DocNum
inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
--inner join OITM a on a.itemcode= o1.ItemCode
--inner join OACT c on c.AcctCode = o1.InvntAct
where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = a.ItemCode
and G2.LineNum = O1.DocLineNum and G2.BaseType = '202' and g2.TranType is null
and O1.docdate >= @FromDate and o1.DocDate <= @ToDate
and O1.Inqty>0 and O1.transtype = '59'),0)as [Goods Receipt Return Quantity_1],
isnull((Select sum(round(TransValue,0))from OINM O1 inner join OIGN G1 on O1.BASE_REF = G1.DocNum inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = G2.ItemCode
and G2.BaseType = '202' and G2.TranType is null and O1.docdate>=@FromDate
and O1.docdate<=@ToDate and O1.Inqty>0 and O1.transtype = '59'),0) as [Goods Receipt Return Value],
(isnull((Select distinct isnull(sum(isnull(inqty,0)),0)from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.DocDate<=@ToDate),0)- isnull((Select isnull(sum(isnull(outqty,0)),0) from OINM O1
where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and
O1.DocDate<=@ToDate),0)) as [Closing Stock],
(isnull (( Select distinct isnull(sum(round(TransValue,0)),0)from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
and O1.DocDate<=@ToDate),0)) as [Closing Stock Value],
(Select distinct i.LastPurDat from OITM i where i.ItemCode=a.Itemcode) as 'Last Purchase Date',
(Select distinct b.ItmsGrpNam from OITB b where b.ItmsGrpCod = I1.ItmsGrpCod) as 'Group Name'
from (Select distinct N1.Itemcode, N1.Dscription, isnull((sum(N1.inqty)),0)-isnull((sum(n1.outqty)),0) as OpeningBalance,
isnull((sum(N1.Transvalue)),0) as OpeningValue,n1.InvntAct,0 as INq,
0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
inner join OACT c on c.AcctCode = n1.InvntAct
Where N1.DocDate <=@FromDate and i.ItemCode = n1.ItemCode and b.ItmsGrpNam = @ItmsGrpNam and N1.Transtype <> '67'
Group By N1.ItemCode,N1.Dscription,n1.InvntAct
Union
select distinct N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,
n1.InvntAct,sum(N1.inqty) , 0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
inner join OACT c on c.AcctCode = n1.InvntAct
Where N1.DocDate >= @FromDate and N1.DocDate<= @ToDate and N1.Inqty >0 and n1.ItemCode = i.ItemCode
and b.ItmsGrpNam = @ItmsGrpNam and N1.Transtype <> '67'
Group By N1.ItemCode,N1.Dscription,n1.InvntAct
Union
select distinct N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,n1.InvntAct,0,sum(N1.outqty) as OUT
From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode left join OWOR t0 on t0.docentry = N1.[AppObjAbs]
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate
and N1.OutQty > 0 and b.ItmsGrpNam = @ItmsGrpNam and n1.itemcode = i.itemcode and N1.Transtype <> '67' and T0.[Type] = 'S'
Group By N1.ItemCode,N1.Dscription,n1.InvntAct)a,dbo.OITM I1 ,OITB b1
where a.ItemCode=I1.ItemCode and I1.ItmsGrpCod = b1.ItmsGrpCod
Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam,a.InvntAct
Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
Order By a.Itemcode
Thanks & Regards,
Nagarajan
Hi,
FYI:
In SAP B1, you can use pivot function to get document total. It is not necessary to do it in Excel.
Thanks & Regards,
Nagarajan
could you tell us how can we use pivot in SAP B1
I have a list of items in the details section of the main report which are numbered 1,2,3.......etc.
The numbers in this list correspond to the treetype and item number defined in the sales order.
The sequence or incremental number is not applicable for all BOM components in the sales order and only to BOM parent item and non BOM items.
E.g :
Main report - details section:
No. Item Number (code)
1. Item BOM sales
BOM component
2. Item non BOM sales
3. Item non BOM sales
4. Item BOM sales
BOM component #1
BOM component #2
I am using command in the report. Here is the command:
SELECT
ISNULL((dbo.db_category_FN(SUBSTRING(T1.ItemCode, 1, 3))), '') AS categorysub
, T0.Address, T0.Address2, T0.CardCode, T0.CardName, T0.Comments, T0.DocCur,
T0.TaxDate, T0.DocEntry, T0.DocNum, T0.DpmAmnt, T0.DiscSum AS DiscSumDoc,
T0.RoundDif,T0.VatSum AS VatSumDoc, T0.DocTotal, T0.DiscPrcnt AS DiscPrcntDoc,
T1.ItemCode, T1.LineTotal, T1.Price AS PriceAfterDiscount, T1.PriceBefDi AS PriceBeforeDiscount,
T1.PriceBefDi - T1.Price AS DiscAmntRow,
T1.PriceAfVAT AS PriceAfterVAT, T1.Quantity, T1.DiscPrcnt AS DiscPrcntRow,
T1.TreeType, T1.U_udf AS UdfName, UPPER(T1.UnitMsr) AS UnitMsr,
T1.U_udf2, T1.Dscription, T1.U_udf3 AS UdfModelName,
T2.FrgnName,
CASE WHEN CharIndex('|', T3.U_UDF_MOD_NAME) <> ''
THEN Substring(T3.U_UDF_MOD_NAME, CharIndex('|', T3.U_UDF_MOD_NAME) + 2, 100000)
ELSE T3.U_UDF_MOD_NAME End As TblModName,
T4.Name AS TblColName,
T5.SlpName,
T6.SeriesName,
T7.PymntGroup,
T9.[U_UDF_DEST] AS Rute, ISNULL(T9.LineTotal, 0) AS ShippingCost, ISNULL(T9.VatSum, 0) AS SCTax
FROM ORDR T0
INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
LEFT JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
LEFT JOIN [dbo].[@UDT_MOD] T3 ON SUBSTRING(T1.ItemCode, 4, 4) = T3.Code
LEFT JOIN [dbo].[@UDT_COL] T4 ON T4.Code = T1.U_UDF5
LEFT JOIN OSLP T5 ON T5.SlpCode = T0.SlpCode
LEFT JOIN NNM1 T6 ON T6.Series = T0.Series
LEFT JOIN OCTG T7 ON T7.GroupNum = T0.GroupNum
LEFT JOIN OCRD T8 ON T8.CardCode = T0.CardCode
LEFT JOIN RDR3 T9 ON ISNULL(T9.DocEntry, '') = ISNULL(T0.DocEntry, '')
WHERE T0.[DocEntry] = 1
Any suggestions would be much appreciated. I am relatively new to Crystal Reports and know very little about generating formula.
Thank you.
Regards,
STeve
Hi,
Try this query for only for quantity change:
SELECT T2.DocNum,T2.[DocStatus], T2.[CardName],T2.[NumAtCard], T1.LineNum+1 as 'Line', 'Qty' as 'Field',
cast(T1.Quantity as varchar(18)) as 'OldValue', cast(T0.Quantity as varchar(18)) as 'NewValue', T2.UpdateDate, T4.[U_Name] as 'UpdatedBy', T2.[DocTime] FROM adoc T2
JOIN ado1 T1 ON T2.docentry = T1.docentry AND T2.Objtype = T1.Objtype and T1.Loginstanc = T2.LogInstanc-1
JOIN ado1 T0 ON T2.docentry = T0.docentry AND T2.Objtype = T0.Objtype AND T1.LineNum = T0.LineNum
INNER JOIN OUSR T4 ON T2.UserSign2 = T4.INTERNAL_K
AND T0.LogInstanc = T2.Loginstanc WHERE T0.Quantity<>T1.Quantity AND T2.[DocStatus] = 'O' AND DateDiff(d,T2.UpdateDate,GETDATE()) =5
Thanks & Regards,
Nagarajan
Hi,
There is no direct interpretation of system variable with corresponding field name. You have insert the variable into PLD and preview the layout to view name of filed.
Please refer below threads for more explanation:
http://scn.sap.com/thread/642764
http://scn.sap.com/message/15067983#15067983
Thanks & Regards,
Nagarajan
Hi Sean Martin..
Hope doing Good..
Try This
Select T0.DocNum, Max(T1.UpdateDate) 'Last Update', T0.DocDueDate
from ADOC T0
JOIN ADOC T1 on T1.DocNum = T0.DocNum AND T1.ObjType = '17'
where T0.ObjType = '17' and DateDiff(d,T1.UpdateDate,GETDATE()) =5
Group By T0.DocNum, T0.DocDueDate
Hope helpful
Regards
Kennedy
Hi Sean..
If you need by the sales order number wise try this
SELECT * from adoc t0 inner join ado1 t1 on t0.docentry=t1.docentry
WHERE t0.objtype='17' and t0.DocNum = [%0]
Regards
Kennedy
Hi Nicolas Constant...
Try This
Declare @FromDate Datetime
Declare @ToDate Datetime
Set @FromDate = (Select min(T0.[TaxDate]) from OPCH T0 where T0.[TaxDate]>='[%1]')
Set @ToDate = (Select max(T0.[TaxDate]) from OPCH T0 where T0.[TaxDate] <='[%2]')
SELECT T0.[CardCode], T0.[CardName], T0.[NumAtCard], T0.[DocNum], T0.[TaxDate], T1.[ItemCode], T1.[Dscription],
T2.[groupmask], T2.[FatherNum],t3.AcctName As FatherActName, t4.AcctName As MaskName, T1.[AcctCode], T2.[AcctName], T1.[OcrCode], T1.[Project], T1.[TotalSumSy], T0.[Comments]
FROM
OPCH T0 INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OACT T2 ON T1.AcctCode = T2.AcctCode
inner join OACT t3 on t2.FatherNum=t3.AcctCode
inner join OACT t4 on t4.groupmask=t3.GroupMask and t4.Levels='1'
WHERE
T0.[TaxDate] >= @FromDate
AND T0.[TaxDate] <= @ToDate
AND T2.[groupmask] >= 4
Hope helpful
Regards
Kennedy
HI Wagner..
By Standard it is not possible to modify... you can develop on your own for the same..
Hope helpful
Regards,
Kennedy
Hi Wagner...
Check with the following link i think the same question
http://scn.sap.com/thread/3585633
Regards,
Kennedy
Hi Nishit Makadia...
Check with the following links
http://scn.sap.com/thread/3226349
Crystal Reports Dynamic Parameters with SAP Business One
crystal reports parameters problem in sap business one environment
Hope Helpful
Regards
Kennedy
Hi Guys,
Thanks for that, I thought I was on the right path, building a bigger query now
Thanks again
Hi,
Check this link:
http://www.pioneerb1.com/wp-content/uploads/2012/04/HowTo_PrintLayouts_PLD_88.pdf
Thanks & Regards,
Nagarajan