Opening Closing Stock in transit Report
Hi,
I have to get the ABAP development of Stock Report. Report would have following fields
Opening Stock
Opening Stock in Transit Quantity
GR Quantity
Purchase Value
Sold Quantity
Rejection Quantity
Closing Quantity
Closing Stock in Transit Quantity
Consumption Quantity
In Closing quantity , It should be without stock in transit quantity.
Could you please help me to understand ,Exact Opening Stock ,Closing sock, In Transit Stock etc? How would these be calculated? from which tables all these data would come from. Thanks in advance.
Regarda,
Santosh
SantoshArya wrote:
Hi,
>
> I have to get the ABAP development of Stock Report. Report would have following fields
>
> Opening Stock
> Opening Stock in Transit Quantity
> GR Quantity
> Purchase Value
> Sold Quantity
> Rejection Quantity
> Closing Quantity
> Closing Stock in Transit Quantity
> Consumption Quantity
>
> In Closing quantity , It should be without stock in transit quantity.
>
> Could you please help me to understand ,Exact Opening Stock ,Closing sock, In Transit Stock etc? How would these be calculated? from which tables all these data would come from. Thanks in advance.
> Regarda,
> Santosh
Hi,
You can also check these standard reports before you proceed to develop a report..
MB52 - List of Warehouse Stocks on Hand
MB53 - Display Plant Stock Availability
MB5B - Stocks for Posting Date
MB5C - Pick-Up List
MB5L - List of Stock Values: Balances
MB5W - List of Stock Values
MB5T - Stock in transit CC
MC.9 - INVCO: Material Analysis Selection, Stock
MC.A - INVCO: Material Analysis Selection, Rec/Iss
MC.B - INVCO: Material Analysis Selection, Turnover
You can also consider building a query report which wil also serve your purpose quickly...
Regards
Shiva
Similar Messages
-
Opening & Closing Stock in transit
Hi All,
I Developed an abap report for Yield Statement with opening & closing Stock Quantities.
How to Find opening & Closing For transit Stock for 641 movement.I mean how to display the current transit stocks date wise at plant level without SLOC.
I Knew that current transit stock would be in Marc Table & previous closings in March Tables.
I'm looking for the date logic with respect to displaying opening & closing dates of transit stock.Be it Date Wise Or Month Wise.
Any help would be greatly appreciated.
Thanks & Regards,
Ravi SHi Ravi,
Please find the Link below hope they are very useful to you
[Stock|Re: closing stock of a particular date]
[Stock|Tables/FM for opening/closing stock for material on given posting date]
Thanks
kalyan -
Storage location wise Opening/Closing Stock on posting date (mb5b)
Hi,
Report mb5b gives opening stock and closing stock as on date. In the selection screen, if we do not enter specific storage location then the opening/closing stock is displayed as sum of all storage location stocks for a given material.
Where as if we enter storage location, it gives storage location specific output. (with Storage loc/batch stock radio button)
My requirement is - without entering storage location in the initial screen, the system should display storage location specific opening/closing stock.
To get this, presently I need to execute mb5b transaction individually for every storage location.
Warm regards,
MSHi Madhavi
This report you can have in T code MC.6 and another t code for opening and closing stock in t code MC.9
Regards
Vivek
-- Reward if helpful
Edited by: Supergene on Feb 28, 2008 3:17 PM -
Tables/FM for opening/closing stock for material on given posting date
Hi All,
I had requirement of find the opening/closing stock for material on given posting date. The values we can find out using TCode - MB5B.
But I cannt use MB5B to extract data because I need to find detials for thousands of material.
Can you please adivce if their is any FM or tables through which i can find this detial on any given date apart from current date.
Thanks & Regards,Hi,
[https://forums.sdn.sap.com/click.jspa?searchID=19631709&messageID=6593903]
[https://forums.sdn.sap.com/click.jspa?searchID=19631709&messageID=6630975] -
Stock In Transit report at document level (STN)
Is there a standard report for goods in transit as at a stock transfer documment level (STN)? I know transaction MB5T/MB5TD will show stock in transit with reference to Stock Transport order, There can be multiple STNs created with reference to a STO hence STN document stock in transit report is required?
Any ideas would be appreciated.Hi
Check MBSU for stock in transit with respect to material document..
and please go through this link .. i hope it will be helpfull
http://www.easymarketplace.de/transactions-m.php
Thanks.. -
I want to Take Stock in Transit Report
Hai,
I want to Take Stock in Transit Report for a plant with Qty & Value with Posting Date..
So I can get the report Ex: Before April 1 2009.
MM5t & MC.9 Not upto my requirement.. Any table or tcode is there.?Hi ,
In MB51 you can ehter the posting date
plz follow the following step
SPRO -- Materials Management --Inventory Management and Physical Inventory -- Reporting - - Define Field Selection for Material Document List-- enter RM07DOCS -- and field and table name MKPF --BUDAT and activate the check box
hope this will help u -
Inventory opening and closing stock with value report
Hi All,
Is it possible to get details of both opening and closing stock with value of each items of last financial year (2009-10) in inventory report?
MizanHi..
you can try this query
Declare @FromDate Datetime
Declare @ToDate Datetime
set @FromDate =
(Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
set @ToDate =
(Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
select * from
SELECT T0.itemcode,
min(T0.Dscription) as 'Item Description',
min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
(isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate ),0)-
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate<@FromDate),0)
) as [Opening Stock],
isnull((
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode
and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate
and O1.docdate<=@ToDate and O1.inqty>0
and O1.transtype in (20,18)),0
) as [Purchase Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate
and O1.outqty>0 and O1.transtype in (21,19)),0
) as [Purchase Return Quantity],
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
and O1.transtype in (13,15)),0
) as [sale Quatity],
(isnull
Select sum(isnull(inqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0
isnull((
Select sum(isnull(outqty,0))
from OINM O1
where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
and O1.docdate<=@ToDate),0)
) as [Closing Stock]
FROM OINM T0
INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode
INNER JOIN OITW T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OITB B1 ON T1.ItmsGrpCod=B1.ItmsGrpCod
INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
INNER JOIN OLCT C1 ON W1.Location=C1.Code
Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
) a
where (a.[Opening Stock]
+a.[Purchase Quantity]
+ a.[Purchase Return Quantity]
+a.[sale Quatity]+a.[Closing Stock]
) !=0
Regards,
Bhavank -
Hi all Experts,
I am at client site and hav to provide a report containing opening, and closing stock (and issue qty if possible) storage location wise and date option wise.pls help
regards
vikas chhabraHi,
Use MB51 for date wise report
OR
Use MCL1, MCL5, MCL9, MCLD (If Warehouse Management you are using)
OR
You have to develop an own ABAP report.
Regards,
Biju K -
Opening & Closing Stock in P&L Statement
Dear All,
My client is using Tally software preior to SAP B1 Implementation. In Tally the P/L satatment shows Opening Stock , purchases and Closing Stock ledgers.We are not using Purchase Accounts posting system. How to map the existing SAP Ledgers according to Tally. We are using SAP B1 2007 B.
Please help me to map the G/L accoring to the above requirements.
Thanks
SriniDear Srini,
Yes of-course Tally shows OB,and Closing balance at a particular time, SAP B1 Shows them too, but in a different manner.
1. Suppose , you have given OB to SAP on 01/04/10.(which is actually the closing balance of Tally as on 31/03/10).
Under trial balance report OB Column is there.
If you are trying to populate Tally's OB of 01/04/09, You Can't.
2. Getting the OB at a particular time in SAP, depends how you are maintaining your Posting Periods.
For Closing balance in SAP, The last column -'Balance' is actually the Closing balance as on the date for you are running Trial Balance Report.
Hope this will help you.
Best Regards
Ashutosh T -
Hi Expert,
I am developing one zreport . i want to know how to calculate
opening and closing stock using mb5b standard report.
Thanks
DineshHi,
I would be really thankful if you could send me a couple of z_reports with the input parameters and output parameters, as we too are going for implementation project. Kindly send it to [email protected]
Your help would really be appreciated.
Regards. -
Stock in transit report with delivery # and date included
I need a report similar to MB5T that will also show the delivery number and goods issue date. I couldn't find anything standard and was going to ask an ABAPer to create something. When researching where stock in transit is stored, I keep finding that the value should be in MARC-TRAME; however, in our system that value is blank (even for a material that shows stock in transit in MB5T.) Is this value stored in another location as well?
Thanks in advance for your help.Thanks for the response. I know that I can view the PO history by going into the individual POs, but we want something that will show all of the POs at once without having to click in each individual one.
Thanks! -
How to get Opening /Closing stock value of Non Valuated stock materails
Hello,
We would like to know since 95% of our procurement will be for Projects and since the stock is u201CNon-Valuatedu201D stock, is there any method by which we will be in a position to get the details of Opening Stock, Purchases & Closing Stock?
Regards
Sapman manhi
try mb52
enter maerial type for nonvaluated stock
then
execute
you will get output
regards
vijay -
Opening & closing stock like in tally in sql
i have multiple table . i want to calculate opening and closing stock like in tally in sql with fifo method.
i have make query.
select dd.Date,dd.VoucherNumber,dd.Name,dd.OpeningBalance OpeningBal,
dd.OpeningQty,dd.OpeningRate,
InwardQty=sum(case when dd.Amount >0 then dd.Quantity else 0 end),
InwardRate=sum(case when dd.Amount >0 then dd.Rate else 0 end),
InwardValue= sum(case when dd.Amount >0 then dd.Amount else 0 end),
OutwardQty=sum(case when dd.Amount <0 then dd.Quantity else 0 end ),
OutwardRate=sum(abs(isnull((case when dd.Amount <0 then dd.Amount else 0 end)/ nullif((case when dd.Amount <0 then dd.Quantity else 0 end),0),0))),
OutwardValue= Sum(abs(case when dd.Amount <0 then dd.Amount else 0 end)),
ClosingQty=dd.OpeningQty+ sum(case when dd.Amount >0 then dd.Quantity else 0 end)-sum(case when dd.Amount <0 then dd.Quantity else 0 end ) ,
closingRate=dbo.fnGetClosingRate(dd.OpeningBalance,sum(case when dd.Amount >0 then dd.Amount else 0 end),
Sum(abs(case when dd.Amount <0 then dd.Amount else 0 end)),dd.OpeningQty+ sum(case when dd.Amount >0 then dd.Quantity else 0 end)-
sum(case when dd.Amount <0 then dd.Quantity else 0 end )),
ClosingAmout=(dd.OpeningQty+ sum(case when dd.Amount >0 then dd.Quantity else 0 end)-
sum(case when dd.Amount <0 then dd.Quantity else 0 end ))*(dbo.fnGetClosingRate(dd.OpeningBalance,sum(case when dd.Amount >0 then dd.Amount else 0 end),
Sum(abs(case when dd.Amount <0 then dd.Amount else 0 end)),dd.OpeningQty+ sum(case when dd.Amount >0 then dd.Quantity else 0 end)-
sum(case when dd.Amount <0 then dd.Quantity else 0 end )))
from
SELECT [Transaction].Date, [Transaction].VoucherNumber,
Items.Name,OpeningBalance,ItemOpening.Quantity as OpeningQty,ItemOpening.Rate as OpeningRate,
SalesItem.FirstQty as Quantity, SalesItem.Rate ,
SalesItem.Amount
FROM ItemOpening INNER JOIN
Items ON ItemOpening.Items = Items.Oid INNER JOIN
SalesItem ON Items.Oid = SalesItem.Item INNER JOIN
Sales ON SalesItem.Source = Sales.Oid INNER JOIN
[Transaction] ON Sales.Oid = [Transaction].Oid
--where [Transaction].Date>='2012-05-19' and [Transaction].Date<='2012-05-31'
--and Items.Name='Bidi: 96/19x20x80 HL'
-- group by Items.Name,[Transaction].Date,SalesItem.Rate,
-- SalesItem.Amount
union all
select [Transaction].Date,[Transaction].VoucherNumber, Items.Name,
OpeningBalance,ItemOpening.Quantity as OpeningQty,ItemOpening.Rate as OpeningRate,
PurchaseItem.FirstQty ,
PurchaseItem.Rate,
PurchaseItem.Amount
FROM PurchaseItem INNER JOIN
Purchase ON PurchaseItem.Source = Purchase.Oid INNER JOIN
Items on Items.Oid= PurchaseItem.Item inner join
ItemOpening on ItemOpening.Items= Items.Oid inner join
[Transaction] ON Purchase.Oid = [Transaction].Oid
--where [Transaction].Date>='2012-05-18' and [Transaction].Date<='2012-05-31'
--and Items.Name='Bidi: 96/19x20x80 HL'
) as dd where dd.Date>='2012-04-01' and dd.Date<='2012-04-05'
and dd.Name='Bidi: 96/19x20x80 HL'
group by dd.Date,dd.VoucherNumber,dd.Name,dd.OpeningBalance,dd.OpeningQty,dd.OpeningRate,dd.Rate
order by dd.Date
but it is not give correct output. its giving result .
Date
Name
OpeningBal
OpeningQty
OpeningRate
InwardQty
InwardRate
InwardValue
OutwardQty
OutwardRate
OutwardValue
ClosingQty
closingRate
ClosingAmout
4/1/2012
A
62909.22
22
2859.51
0
0
0
10
3584.8
35848
12
2255.1
27061.2
4/5/2012
A
62909.22
22
2859.51
0
0
0
20
3584.8
71696
2
-4393.39
-8786.78
4/5/2012
A
62909.22
22
2859.51
20
3360
67200
0
0
0
42
3097.84
130109.28
expected format as
Date
Name
OpeningBal
OpeningQty
OpeningRate
InwardQty
InwardRate
InwardValue
OutwardQty
OutwardRate
OutwardValue
ClosingQty
closingRate
ClosingAmout
4/1/2012
A
62909.22
22
2859.51
0
0
0
10
3584.8
35848
12
2255.1
27061.2
4/5/2012
A
27061.2
12
2255.1
0
0
0
20
3584.8
71696
-8
0
-8786.78
4/5/2012
A
-8786.78
-8
-4393.39
20
3360
67200
0
0
0
12
3097.84
130109.28
please give solutionSuppose my view like View_itm
Date
Item
openingItem
OpnRate
OpnAmt
ReceiveItm
Issue
ClosingQty
closingRate
ClosnigAmt
1/4/2012
A
10
5
15
5
2
13
23.1
299
1/4/2012
B
20
2
40
10
15
15
43
643
i have make above query for access data but it not give expected result
Date
Name
OpeningBal
OpeningQty
OpeningRate
InwardQty
InwardRate
InwardValue
OutwardQty
OutwardRate
OutwardValue
ClosingQty
closingRate
ClosingAmout
4/1/2012
A
62909.22
22
2859.51
0
0
0
10
3584.8
35848
12
2255.1
27061.2
4/5/2012
A
62909.22
22
2859.51
0
0
0
20
3584.8
71696
2
-4393.39
-8786.78
4/5/2012
A
62909.22
22
2859.51
20
3360
67200
0
0
0
42
3097.84
130109.28
expected result need like
Date
Name
OpeningBal
OpeningQty
OpeningRate
InwardQty
InwardRate
InwardValue
OutwardQty
OutwardRate
OutwardValue
ClosingQty
closingRate
ClosingAmout
4/1/2012
A
62909.22
22
2859.51
0
0
0
10
3584.8
35848
12
2255.1
27061.2
4/5/2012
A
27061.2
12
2255.1
0
0
0
20
3584.8
71696
-8
0
-8786.78
4/5/2012
A
-8786.78
-8
-4393.39
20
3360
67200
0
0
0
12
3097.84
130109.28
please give solution as per possible -
Crystal Query for Opening / Closing Stock
Hi Experts,
i need a query in crystal for Opening and Closing total Stock per date..
i found this querys and need to join them, but o dont now how...
thanks for any tips..
Query 1
=======================
SELECT distinct
T0.[TransType], T0.[DocDate], T0.[InQty], T0.[OutQty], T0.[Dscription], T0.[CalcPrice], T0.[ItemCode] FROM [dbo].[OINM] T0 INNER JOIN OITM T1 ON T0.ItemCode = T1.ItemCode WHERE T0.[DocDate] >= {?DateInicial} and T0.[DocDate] <= {?DateFinal} and T1.[Canceled] = 'N'
Query 2
=========================
Declare @FromDate Datetime
Declare @ToDate Datetime
select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >={?Data1}
select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <={?Data2}
Select a.Itemcode, max(a.Dscription) as ItemName,
sum(a.OpeningBalance) as OpeningBalance, sum(a.INq) as 'IN', sum(a.OUT) as OUT,
((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM
from( Select N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
as OpeningBalance, 0 as INq, 0 as OUT
From dbo.OINM N1try this
Declare @ItmsGrpNam varchar(100)
Declare @Whse nvarchar(10)
Declare @Fromdate Datetime
Declare @Todate DateTime
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 @Whse = Max(s3.Warehouse) from dbo.OINM S3 Where S3.Warehouse = [%2]
Select a.Itemcode, max(a.Dscription) as ItemName,
(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,
sum(a.OpeningBalance) as OpeningBalance,
((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing
from( Select N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
as OpeningBalance, 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
Where N1.DocDate < @FromDate and N1.Warehouse = @Whse and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,
N1.Dscription Union All select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,
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
Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate
and N1.Inqty >0 and N1.Warehouse = @Whse and b.ItmsGrpNam = @ItmsGrpNam Group By N1.ItemCode,N1.Dscription
Union All select N1.Itemcode, N1.Dscription, 0 as OpeningBalance, 0 , sum(N1.outqty) as OUT
From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
Where N1.DocDate >= @FromDate
and N1.DocDate <=@ToDate and N1.OutQty > 0 and N1.Warehouse = @Whse and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription) a, dbo.OITM I1 ,OITB b1
where a.ItemCode=I1.ItemCode
and I1.ItmsGrpCod = b1.ItmsGrpCod
Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam
Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
Order By a.Itemcode -
Opening & Closing Stock - Query Correction
Dear Experts,
Please find the below query, where I need IN quantity & values , OUT quantity& values should pick only from Standard Production Order , whereas it should not pick from special Production Order. Rest all in the same is sufficient for me.
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 a.Itemcode, max(a.Dscription) as ItemName,
(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,
sum(a.OpeningBalance) as OpeningBalance,
sum(a.OpeningValue) as OpeningValue,
sum(a.INq) as 'IN',
(select SUM(ISNULL(T100.TRANSVALUE,0)) from oinm T100 WHERE T100.ITEMCODE = A.ITEMCODE
AND T100.DOCDATE >= @FROMDATE
AND T100.DOCDATE <= @TODATE AND T100.INQTY <> 0) AS [IN Stock Value],
sum(a.OUT) as OUT,
(select SUM(ISNULL(T100.TRANSVALUE,0)) from oinm T100 WHERE T100.ITEMCODE = A.ITEMCODE
AND T100.DOCDATE >= @FROMDATE
AND T100.DOCDATE <= @TODATE AND T100.OUTQTY <> 0)*-1 AS [OUT Stock Value],
((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,
(select SUM(T100.TRANSVALUE) from oinm T100 WHERE
T100.ITEMCODE = A.ITEMCODE AND T100.DOCDATE < @TODATE) AS [Closing Value Transaction],
(((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT))*
ISNULL((SELECT CASE WHEN
X.PRICE = 0
THEN
(SELECT DISTINCT MAX(ISNULL(P.PRICE,0)) AS PRICE FROM ITM1 P WHERE PRICELIST = 1 )
ELSE
X.PRICE
END
FROM (SELECT
DISTINCT MAX(ISNULL(B.PRICE,0)) AS PRICE
FROM OITM T
LEFT JOIN PCH1 B ON T.ITEMCODE = B.ITEMCODE
INNER JOIN OPCH C ON B.DOCENTRY = C.DOCENTRY
WHERE B.DOCENTRY = (SELECT DISTINCT (MAX(D.DOCENTRY)) FROM OPCH D WHERE C.DOCENTRY = D.DOCENTRY
AND C.DOCDATE <= @ToDate )
AND A.ITEMCODE = T.ITEMCODE) X ),0))
--(Select i.LstEvlPric from OITM i where i.ItemCode=a.Itemcode))
as 'Closing Value',
(Select i.LastPurDat from OITM i where i.ItemCode=a.Itemcode) as 'Last Purchase Date',
--(Select i.LstEvlDate from OITM i where i.ItemCode=a.Itemcode) as 'Last Issue Date',
--(Select i.ItmsGrpCod from OITM i where i.ItemCode=a.Itemcode) as 'Group code',
(Select b.ItmsGrpNam from OITB b where b.ItmsGrpCod = I1.ItmsGrpCod) as 'Group Name'
from( Select N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
as OpeningBalance,
(sum(N1.Transvalue))
as OpeningValue,
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
Where N1.DocDate <@FromDate and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription
Union All
select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,
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
Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate
and N1.Inqty >0 and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription
Union All
select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue, 0 , sum(N1.outqty) as OUT
From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
Where N1.DocDate >= @FromDate and N1.Transtype != 67
and N1.DocDate <=@ToDate and N1.OutQty > 0 and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription) a, dbo.OITM I1 ,OITB b1
where a.ItemCode=I1.ItemCode
and I1.ItmsGrpCod = b1.ItmsGrpCod
Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam
Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
Order By a.Itemcode
Thanks in Advance,
Bhoopathi.KHi,
Try this:
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 a.Itemcode, max(a.Dscription) as ItemName,
(Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,
sum(a.OpeningBalance) as OpeningBalance,
sum(a.OpeningValue) as OpeningValue,
sum(a.INq) as 'IN',
(select SUM(ISNULL(T100.TRANSVALUE,0)) from oinm T100 WHERE T100.ITEMCODE = A.ITEMCODE
AND T100.DOCDATE >= @FROMDATE
AND T100.DOCDATE <= @TODATE AND T100.INQTY <> 0) AS [IN Stock Value],
sum(a.OUT) as OUT,
(select SUM(ISNULL(T100.TRANSVALUE,0)) from oinm T100 WHERE T100.ITEMCODE = A.ITEMCODE
AND T100.DOCDATE >= @FROMDATE
AND T100.DOCDATE <= @TODATE AND T100.OUTQTY <> 0)*-1 AS [OUT Stock Value],
((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT)) as Closing ,
(select SUM(T100.TRANSVALUE) from oinm T100 WHERE
T100.ITEMCODE = A.ITEMCODE AND T100.DOCDATE < @TODATE) AS [Closing Value Transaction],
(((sum(a.OpeningBalance) + sum(a.INq)) - Sum(a.OUT))*
ISNULL((SELECT CASE WHEN
X.PRICE = 0
THEN
(SELECT DISTINCT MAX(ISNULL(P.PRICE,0)) AS PRICE FROM ITM1 P WHERE PRICELIST = 1 )
ELSE
X.PRICE
END
FROM (SELECT
DISTINCT MAX(ISNULL(B.PRICE,0)) AS PRICE
FROM OITM T
LEFT JOIN PCH1 B ON T.ITEMCODE = B.ITEMCODE
INNER JOIN OPCH C ON B.DOCENTRY = C.DOCENTRY
WHERE B.DOCENTRY = (SELECT DISTINCT (MAX(D.DOCENTRY)) FROM OPCH D WHERE C.DOCENTRY = D.DOCENTRY
AND C.DOCDATE <= @ToDate )
AND A.ITEMCODE = T.ITEMCODE) X ),0))
--(Select i.LstEvlPric from OITM i where i.ItemCode=a.Itemcode))
as 'Closing Value',
(Select i.LastPurDat from OITM i where i.ItemCode=a.Itemcode) as 'Last Purchase Date',
--(Select i.LstEvlDate from OITM i where i.ItemCode=a.Itemcode) as 'Last Issue Date',
--(Select i.ItmsGrpCod from OITM i where i.ItemCode=a.Itemcode) as 'Group code',
(Select b.ItmsGrpNam from OITB b where b.ItmsGrpCod = I1.ItmsGrpCod) as 'Group Name'
from( Select N1.Itemcode, N1.Dscription, (sum(N1.inqty)-sum(n1.outqty))
as OpeningBalance,
(sum(N1.Transvalue))
as OpeningValue,
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
Where N1.DocDate <@FromDate and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription
Union All
select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,
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
Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate
and N1.Inqty >0 and b.ItmsGrpNam = @ItmsGrpNam
Group By N1.ItemCode,N1.Dscription
Union All
select N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue, 0 , sum(N1.outqty) as OUT
From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod left join OWOR t0 on t0.docentry = N1.[AppObjAbs]
Where N1.DocDate >= @FromDate and N1.Transtype != 67
and N1.DocDate <=@ToDate and N1.OutQty > 0 and b.ItmsGrpNam = @ItmsGrpNam and T0.[Type] = 's'
Group By N1.ItemCode,N1.Dscription) a, dbo.OITM I1 ,OITB b1
where a.ItemCode=I1.ItemCode
and I1.ItmsGrpCod = b1.ItmsGrpCod
Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam
Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
Order By a.Itemcode
Thanks & Regards,
Nagarajan
Maybe you are looking for
-
Creation Profile in Scheduling Agreement
Dear Experts, Currently I'm working on Scheduling Agreement and Schedule Line.In standard SAP gives the provision of creation profile.I've gone through the SAP help documentation but I'm not clear on that.I've few doubts on creation profile. 1. I've
-
Hello, I am trying to call a RFC from my WebDynpro application. The RFC has a mandatory input structure called PERSDATA. I am using the following test code to call the RFC: IWDMessageManager manager = wdComponentAPI.getMessageManager(); try
-
I have been successfully using Yahoo imap mail within Mac Mail for years, but now it won't work. What's changed? How can I use Yahoo mail in my mail program??
-
Individually numbering copies of a document
I have one very large document that I need to produce 25 copies of. However, my client is requesting I number each copy at the bottom of each page (i.e. "Copy 1, Page 1" ... "Copy 1, Page 2"... etc.) Is there an easy way to do this? I could print the
-
Not able to return value for pl/sql to shell
Hi, I'm calling pl/sql script from my shell script. Have set a flag in the pl/sql. Trying to return the value of the flag back to the shell script, but it is not working. My shell is ksh Please help.... SHELL code trysnir.sh file---> <code> #!/bin/ks