Opening Stock+InwardQty+OutwardQty-Closing Stock from OINM

Can any SQL Expert can rectify my following query
Select DocDate,Dscription,SUM(InQty) as 'Inward Quantity',SUM(OutQty) as 'Outward Quantity',
(Select SUM(InQty)-SUM(OutQty)
from OINM where Itemcode='ACID BOTTLE - HCL' And DocDate
BETWEEN '2008-03-01 00:00:00.000' AND '2008-03-01 00:00:00.000') 'Closing Stock'
from OINM
where Itemcode='ACID BOTTLE - HCL' And DocDate BETWEEN '2008-03-01 00:00:00.000' AND
'2008-03-31 00:00:00.000'
Group by DocDate,Dscription
I am able to retrieve the SQL Query mentioned in above subject datewise but not able to add Closing Stock of Previous Row to Inward Qty of Next Row..........

Hi,
I think you have been wrong in the setting of the date. Using your query, the system will not include the data of 31.03.2008 since the date condition you have made is between 2008-03-01 and 2008-03-01. It should as same as the 2nd date condition you have made i.e. 2008-03-01 and 2008-03-31.
if you still keep the fquery you have made previously, the result will be as same as you have written in your reply to me.
Select DocDate,Dscription,SUM(InQty) as 'Inward Quantity',SUM(OutQty)
as 'Outward Quantity', (select SUM(InQty)-SUM(OutQty) from OINm
where Itemcode='A1000' And DocDate BETWEEN '2008-03-01 00:00.000' AND
'2008-03-30 00:00:00.000') as 'closing stock'
from OINM
where Itemcode='a1000' And DocDate BETWEEN '2008-03-01 00:00:00.000' AND
'2008-03-30 00:00:00.000'
Group by DocDate,Dscription, OutQty, InQty
The result will be like this follows:
#     Posting Date     Item Description     Inward Quantity     Outward Quantity     closing stock
1     06.03.2008     Boxing Gloves     0     1     329
2     26.03.2008     Boxing Gloves     101     0     329
3     29.03.2008     Boxing Gloves     1     0     329
4     29.03.2008     Boxing Gloves     0     1     329
5     30.03.2008     Boxing Gloves     2     0     329
6     30.03.2008     Boxing Gloves     14     0     329
7     30.03.2008     Boxing Gloves     6     0     329
8     30.03.2008     Boxing Gloves     8     0     329
9     30.03.2008     Boxing Gloves     35     0     329
10     30.03.2008     Boxing Gloves     6     0     329
11     30.03.2008     Boxing Gloves     50     0     329
12     30.03.2008     Boxing Gloves     20     0     329
13     30.03.2008     Boxing Gloves     30     0     329
14     30.03.2008     Boxing Gloves     100     0     329
15     30.03.2008     Boxing Gloves     0     2     329
16     30.03.2008     Boxing Gloves     0     10     329
17     30.03.2008     Boxing Gloves     0     10     329
18     30.03.2008     Boxing Gloves     0     20     329
                                               373     44     329

Similar Messages

  • Opening Stock + InwardQty + OutwardQty + Price and Closing Balance

    Hi Members,
    needs an SQL query for the " Stock Statement " From OINM Table to display opening stock , InwardQty as 'Receipts', OutwardQty as 'Issue', Price using Date and WareHouse as selection criteria.
    Kindly Help me in this regard,
    Thanks and Regards,
    Venkatesh.R

    used function in sql

  • Opening Stock + InwardQty + OutwardQty + Price_ OINM

    Hi Members,
    I need an SQL query for the " Stock Statement " From OINM Table to display opening stock , InwardQty as 'Receipts', OutwardQty as 'Issue', Price using Date and WareHouse as selection criteria.
    Kindly Help me in this regard,
    Thanks and Regards,
    Venkatesh.R
    Edited by: Venkatesh R on Mar 3, 2010 6:55 AM

    Hi this is query for stock for perticular warehouse on a given date
    SELECT T0.ItemCode, T0.Dscription, sum(T0.InQty- T0.OutQty) FROM
    OINM T0 WHERE T0.DocDate <=getdate()
    and T0.Warehouse =1
    GROUP BY T0.ItemCode, T0.Dscription
    for opening of stock please filter the transtype = -2 for Opening Stock in the same table
    Best Regards

  • Opening and closing stock figure

    Hi Experts,
    How can i get the opening stock figure and closing stock figure for one month in SAP Buiness one 8.8?

    Hi,
    I found this on the forum; try this:
    DECLARE @FromDate DateTime
    DECLARE @ToDate DateTime
    /* SELECT T0.DocDate FROM OINM T0 where T0.DocDate >=[%0] */
    SET @FromDate = [%0]
    /* SELECT T0.DocDate FROM OINM T0 where T0.DocDate <=[%0] */
    SET @ToDate = [%1]
    Select X.DocDate, X.ItemCode,
    ((Select isnull(sum(InQty-OutQty),'0')From OINM T0 Where T0.ItemCode=X.ItemCode And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate < X.DocDate)) As 'OpeningStock',
    IsNull(max(X.price),0) as 'OpeningUnitPrice',
    ((Select isnull(sum(InQty-OutQty),'0')From OINM T0 Where T0.ItemCode=X.ItemCode And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate < X.DocDate)) *
    IsNull(max(X.price),0) AS 'OPENING VALUE',
    IsNull(sum(X.InQty),0) As 'Received Qty',
    IsNull(max(X.price),0) as 'Purchase  Unit Price',
    IsNull(sum(X.InQty),0) *
    IsNull(max(X.price),0) as 'PURCHASE VALUE',
    IsNull(sum(X.OutQty),0) As 'Consumed Qty',
    IsNull(max(X.price),0) as 'Sale Unit Price',
    IsNull(sum(X.OutQty),0) *
    IsNull(max(X.price),0) AS 'SALE VALUE',
    ((Select isnull(sum(InQty-OutQty),'0') From OINM T0 Where T0.ItemCode=X.ItemCode And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate < X.DocDate)+
    (Select isNULL(sum(T0.InQty),'0') From OINM T0 Where T0.ItemCode=X.ItemCode And T0.DocDate<=X.DocDate And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate = X.DocDate)-
    (Select isNULL(sum(T0.OutQty),'0') From OINM T0 Where T0.ItemCode=X.ItemCode And T0.DocDate<=X.DocDate And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate = X.DocDate)) As 'ClosingStock',
    ((((Select isnull(sum(InQty-OutQty),'0')From OINM T0 Where T0.ItemCode=X.ItemCode And
    (T0.DataSource='I' or T0.DataSource='N') And T0.DocDate < X.DocDate)) *
    IsNull(max(X.price),0)) + (IsNull(sum(X.InQty),0) * IsNull(max(X.price),0)) - (IsNull(sum(X.OutQty),0) *
    IsNull(max(X.price),0))) as 'Final Balance Value'
    FROM OINM X Where ItemCode=X.ItemCode And
    (X.DataSource='I' or X.DataSource='N')
    Group by X.DocDate,X.ItemCode
    Order by X.DocDate
    Hope this helps.
    Thanks,
    Joseph

  • Opening and closing stock report

    Hi,
    i have to develop  a report in abap of stock (Opening and closing stock) with each material, plant, business area & monthly date wise. I got some fields from mseg like material number, plant, business area but i didnt get fileds like opening stock, purchase, consumption & closing stock
    in report fileds should be like
    material number
    plant
    business area
    posting date
    opening stock
    purchase
    consumption
    closing stock
    kinldy help <removed by moderator>
    Moderator message: Welcome to SCN!
    Moderator message: please search for available information, ask a functional consultant near you.
    [Rules of engagement|http://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement]
    [Asking Good Questions in the Forums to get Good Answers|Asking Good Questions in the SCN Discussion Spaces will help you get Good Answers]
    Edited by: Thomas Zloch on Nov 21, 2011 3:35 PM

    Yes umesh from external 99% of your stock from mvt 101, 501 is very rare case & 561 is not from external source it is initial stock updation which will be done only once when you are going live & later 561 mvt will be normally blocked for use.
    You can also sort in MB5B more than one movement type click on multiple selection (that is on yellow arrow icon) & in single value tab enter mvt 101 below that 501.
    This will give you report for mvt types 101 & 501 in this way you can also sort reports for more than one mvt type.
    Regards
    Rang
    Message was edited by:
            Ranganath Mysore

  • Regaring opening stock and closing stock in MM

    hi guys,
    can any body plzz tell me what exactly do u mean by
    1) opening stock (OS)
    2) closing stock (CS)
    3) credit indicator
    4) debit indicator
    in MM, i actually checked bseg table for documentation of these fields but could not understand can any one plzz help me.
    thanks very much
        pavan

    Hello Pavan
    What exactly do you wish to know the definitions or calculation.
    Opening stock : It is the initial stock available for a particular material at a particular plant/sloc (when the sku was created).
    Closing stock : It is the current stock available, basically Opening stock + receipts - issue.
    Credit/Debit indicator : Basically, they indicate whether the stock was received at the location or issued from the location.
    Regards
    Anurag

  • Opening stock will be the closing stock of previous date

    Hi All,
    Good day. I am developing an ALV report that will show opening stock(LABST) as well as closing stock(Calculated) for a range of date and materials. Problem here is that from MARD table I am getting only the last opening stock, because it has no common date field with MSEG table. So, I have to calculate the opening stock as the closing stock of previous date. How can I calculate this? Is there any FM to get the opening stock ?
    Date          Material            Opening St       Closing St
    27.03.2009     2100002          91.000          191.00
    28.03.2009     2100002          191.000          123.00
    29.03.2009     2100002          123.000          103.00
    With regards,
    Tripod.
    Edited by: Tripod on Aug 23, 2011 12:13 PM

    Try not only to use MARD and MKPF/MSEG but also MARDH which contains closing stock of period preceding periods where movements happened. (ie. there is a record for May if a movement happened in June, and none for June if there was no movement in July, and no record exists for August as this is current period) - First look for MARD, MARDH records; and then only read MKPF/MSEG from last MARDH record found. (created back to 4.5A - [Material Master (Industry/Retail): Enhancements to Period Closing|http://help.sap.com/saphelp_45b/helpdata/en/35/b0e7ef87a62488e10000009b38f9b7/content.htm])
    Regards,
    Raymond

  • Bapi/function module to get opening or closing stock for a posting date

    I am creating a report where i need to get the opening stock value and closing stock value  for the given starting date and ending date respectively for the PP report.
    The T-code for that is MB5B.
    So,can any1 plzz tell me how i can get the stock value for a starting date/ending date...
    Is there any BAPI or function module to find this out..
    or any logic?
    Thanks.

    Hi Kiran,
    You would like to findout opening and closing stock of a particular period and of a particular period....
    If we would like to findout opening and closing stock of material A as of 18 / 8 / 2008,
    then do like this.
    go to MBEW table .. there u get opening stock as on today. Today the date is 20/8/2008. from today's opening stock if we add / subtract the movements which have happened on 19/8/2008 and 18/8/2008 u'll get opening and closing stock as on 18/8/2008.
    U get the movements from MKPF ( material doc header) and MSEG (material doc item ) based on posting date. In MSEG u get movement type.
    If the movement type is 101, it means the stock is added.
    If the movement type is 102, it means the added stock is reversed.
    from today's opening stock deduct the stock with moverment type 101 and add the stock with movement type 102.
    This will give u opening stock as on 18/8/2008.
    To get closing stock of 18/8/2008 ..... the opening stock of 19/8/2008 is 18/8/2008's closing stock.

  • Opening and closing stock with sales order and with out sales order

    hello,
    any body please help me my client want to check opening stock and and closing stock in areport.
    material contains batch and some material with sales order and some are with out sales order. my client is asking this in a single layout. please tell me isthere any teport or bapi or function module to get this report.
    this is very uregent. and layout is requesting like opening stock, production stock, sales stock and closing stock.
    please guide me to get this report.
    Thanks & Regads
    Bhakta

    Transaction MB5B
    For sales order related use specila stock as E and use radio button indicator in stock type
    For stock w/o sales order, use special stock indiactor as "space' and stock type valuated stock.
    to get a perticular month,opening stock/closing stock enter the start date/end date as month start and end date.
    See the o/p which will give the stock as required by you

  • Calculating opening and closing stocks at a plant (on specific dates)

    Hi,
    I am to develop an ABAP-report. On the selection screen, I'll have plant, material, and a date range (date_1 and date_2). The report should show opening stock on date_1, closing stock on date_2, and then there is more segregation based on movement types (along with both stock-quantity and stock-value). I am stuck at how-to's around calculating opening (and closing) stock on a particular date.
    Secondly, transaction MB5B has 3 options : batch stock, valuated stock, special stock ... One of these options uses table MBEW and other uses table MARD ... Which (all) tables will I need to use so as to get both stock-quantities and stock-values ?
    Please advise. Thank you.
    Regards,

    Hi
    for second question answer is
    you need to consider all batch stock, valuated stock, special stock ... One of these options uses table MBEW and other uses table MARD to get both stock-quantities and stock-values
    hope it helps
    Edited by: ppkk on Dec 10, 2008 10:58 AM

  • Inventory Opening and Closing Stock

    Hello Experts,
    How can i get the inventory opening stock  and inventory closing stock in SAP business One so as to reflect the same in the Profit and Loss Statement and  Balance sheet..
    Divya Chaudhary

    Hey
    First create a P&L template
    2)add child level as assign name "Opening Stock" LEVEL=4
    2)add child level as assign name "Stock Detail" LEVEL=8
    2)add child level as assign name "stock value" LEVEL=12
    now double click on "stock value" and assign GL which u made in Chart of account as Assest e.g hardware,software
    *note at level 12 only we can assign GL so it necessary to move hirearchy upto level=12
    and then update yr template
    Thanks
    King Kevin

  • Report on pending order qty,opening stock, and closing stock

    Any standard Report available on pending order qty against opening stock, and closing stock.
    Points assured
    Mohan

    Hi Mohan
    There is no report in standard SAP for stock in transit that is what you are refering to Pending order Qty & opening stock.
    You can get report in ME2M, ME2L for pending PO's.
    In MD04 you will get all these stock, PO Qty, & Closing stock but this is for individual material this has to be made customized report in reporting format same thing we have done in one of our project.
    Regards

  • 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
    Srini

    Dear 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

  • Standard reports for materials begning,purchase,sale,closing stock

    Dear Experts,
    Is there any standard report for
    Opening stock
    Purchase
    Sale
    Closing stock
    in terms of QTY and value for all materials.
    regards
    RR

    Hi
    you can use MB5B (with Non hierarchial Display) and MB5L
    br, Ajay M

  • Report of daywise Material/Vendor closing stock

    Dear Friends,
    there is a requirement of stock report of closing stocks for each day in a month. Suppose a month has 31 days then the report will show 31 lines for each day closing stock in one go for a single material.
    Similar to vendor also. If we select a vendor for a particular period it should show 31 entries for each day's closing stock at vendor level.
    Rquest to find some ways for the report.
    Regards,
    ASK

    Try to create a custom Report as per your requriment , also check the std report ME80FN it may help you.

Maybe you are looking for