Query for Opening Stock + Purchase Qty + Sales Qty

Hi ,
Can anyboday help me by how to develop a query for the following requirement. If any custom query is available please provide me .We are working on SBO 2007B PL 8. The required report structure is 
    ItemNo ***OpeningStock**** Purchase ********* Sales****
(Batchwise)** Qty*** Value ****Qty** Value ***Qty***Value
Thanks & Regards
Srini

Hi Srini,
I found this on the forum, see if it helps you;
select b.Itemcode,b.Item_Description,b.UOM, b.rate as Rate,b.Opening_Stock,b.Receipt,b.Issue, b.Material_Revalue,b.Closing_Stock,b.Closing_Value from (select *,(case closing_stock when 0 then 0 else(Closing_Value/Closing_Stock)end) as Rate from( SELECT T0.Itemcode as 'Itemcode' ,min(T0.Dscription) as 'Item_Description', max(T1.InvntryUom) as UOM, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<'[%0]' and O1.transtype in (58,59,20,16,67,-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<'[%0]' and O1.transtype in (58,21,19,60,15,67,-2,13)),0)+ (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.transtype in (-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.transtype in (-2)),0)))as Opening_Stock, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (20,18)),0) + isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (67)),0) + isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.inqty>0 and O1.transtype in (58,59,16,14)),0)) as Receipt, (isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (13,15)),0) + isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (67)),0)+ isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate>='[%0]' and O1.docdate<='[%1]' and O1.outqty>0 and O1.transtype in (58,60,21,19)),0)) as Issue, isnull((select sum(Transvalue) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (162)),0) as Material_Revalue, (isnull((Select sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,59,20,16,14,19,67,-2)),0) - isnull((Select sum(isnull(outqty,0)) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,21,19,60,15,67,-2,13)),0))as Closing_Stock, isnull((select sum(Transvalue) from OINM O1 where O1.itemcode=T1.itemcode and O1.docdate<='[%1]' and O1.transtype in (58,18,-2,67,59,20,16,14,15,13,21,19,60,69,162)),0) as Closing_Value 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 where ((B1.ItmsGrpNam>='[%2]' and B1.ItmsGrpNam<='[%3]') or ('[%2]'='' and '[%3]'='')) GROUP BY T1.itemcode,T0.Itemcode )a Where (a.Opening_Stock + a.Receipt + a.Issue + a.Material_Revalue + a.Closing_Stock + a.Closing_Value) <> 0 )b 
Thanks,
Joseph

Similar Messages

  • Opening Stock+Purchase-Closing stok ,how to fetch in P&L Statement

    HI! All,
    In Schedule 15 in India showing the opening Stock+Purchases-Closing Stock .In FSV or in report painter how to fetch these figure  to prepair in the P&L Statement.
    Thanks & Regards
    Archana

    Hi,
    You need to use FSI3. The opening balance will be the last month's as off. Create a formula for the Purchases where it will be the stock balance as of the current period less the balance in previous period.

  • Table name for opening stock value

    Hi,
    Can some body tell me the table name & the field name for opening stock value,
    (This is when you pass the date through LSMW at initial stage and it gets sits in which table)
    For ex. MB5B
    rgds
    Sonu

    There are many stock tables in SAP.
    if you load unrestricted use stock with value, then the quantity is going to MARD, quantity and value to MBEW.
    if material is batch managed, then stock per batch is going to MCHB, but still MARD and MBEW are updated.
    if you load non-valuated stock (material type UNBW), then only MARD is updated, no MBEW entry.
    and much more cases for consignment, sales order stock etc etc.
    If you try to find the values more than a month after the upload, and your materials had movements, then the old stock quantity at period closing is transfered to the history tables MARDH, MBEWH.
    If you load in the beginning of a month, then SAP calculates the opening stock by using the end of period stock and add/subs the material movements.Then you will not find the opening stock as a single number in any table.

  • Report for shedule vs supply and report for opening stock at back date.

    Dear All Guru,
    please can anybody reply me is there any standard report is available for
    1) Report for shedule vs supply
    2) and report for opening stock at back date.(ex- opening stock at last month 16th july or two months back on 10th may
    pl suggest if any standard report is available or how we can data for this
    Regards,
    Vimlesh

    Hi,
    To see the opening stock at a particular date use T.Code: MB5B,
    To see the scheduled quantity & delivered quantity use table EKET with the filed names MENGE & WEMNG.
    Regards,
    Prabu

  • Can we combine Query for cancelled requisitions and query for internal requisitions without internal sales order into a single query

    Hi All,
    Greetings.
    I have two queries namely,
    1.Query for cancelled requisitions and
    2.Query for Internal Requisitions without Internal Sales Orders.
    I was on a task to combine those two queries..
    Can we do that? if so, please help me do that..
    Thanks in Advance,
    Bhaskar.

    Hi All,
    Greetings.
    I have two queries namely,
    1.Query for cancelled requisitions and
    2.Query for Internal Requisitions without Internal Sales Orders.
    I was on a task to combine those two queries..
    Can we do that? if so, please help me do that..
    Thanks in Advance,
    Bhaskar.

  • Stock Ledger Report in Day Wise not giving correct values for Opening Stock

    Dear Experts,
    I m working on Sock ledger report to give the day wise data.
    since yesterdays closing Stock will become opening stock of today,
    To get Opening Stock,
    I have restricted the stock key figure with 2 variables on calday        
                                  (DATE FROM var with <=(Lessthan or equal to) and offset -1
                                   DATE TO      var with <=(Lessthan or equal to) and offset -1)
    To get Closing Stock,
    I have restricted the Stock key figure with 2 variables on calday        
                                  (DATE FROM var with <=(Lessthan or equal to)
                                   DATE TO      var with <=(Lessthan or equal to) )
    But in the output Opening stock values are not coming correctly and for given range of dates,
    for last date, opening stock is showing as Zero.
    Could you please tell me how can I achieve the correct values for opening stock.
    Thanks in advance.

    Hi Arjun,
    Seems like you are making it more complicated. What is your selection screen criteria?
    Ideally you should only use the offset.
    You will have say Calday in rows and stock in Column
    ____________Opening Stock_____________Closing Stock
    01/06/2009___(Closing stock of 31/05/2009)_(Stock of 01/06/2009)
    02/06/2009___(Closing stock of 01/06/2009)_(Stock of 02/06/2009)
    03/06/2009___(Closing stock of 02/06/2009)_(Stock of 03/06/2009)
    So, from above scenario, create one RKFs and include Calday in it. Create a replacement path variable on calday and apply the offset as -1.
    So, your Opening Stock will be calculated by closign stock of previous day.
    - Danny

  • Query for Monthwise & Statewise Purchase

    Hi Experts
    I need query for monthwise & statewise purchase
    Purchase - A/P Credit Memo like in matrix
    BR
    Manish Pandey

    Hi Manish Pandey
    Welcome To SAP Community Network Forum
    Try This
    SELECT P.[STATE],
    [1] as [Jan],
    [2] as [Feb],
    [3] as [Mar],
    [4] as [Apr],
    [5] as [May],
    [6] as [Jun],
    [7] as [Jul],
    [8] as [Aug],
    [9] as [Sep],
    [10] as [Oct],
    [11] as [Nov],
    [12] as [Dec]
    FROM (SELECT Left(T0.CardCode,2) as [State],
    T0.DocTotal as [DocTotal],
    MONTH(T0.docdate) as [month]
    FROM dbo.OPCH T0
    WHERE Year(T0.docdate)=2011
    UNION
    SELECT Left(T0.CardCode,2) as [State],
    -T0.DocTotal as [DocTotal],
    MONTH(T0.docdate) as [month]
    FROM dbo.ORPC T0
    WHERE Year(T0.docdate)=2011 )  S
      PIVOT  (SUM(DocTotal) FOR [month] IN
    ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])) P
    ORDER BY P.[State]
    Thanks,
    Srujal Patel

  • Query for Opening And  Closing Stock

    Hi Experts...
    I need a report for Opening and Closing stocks and Goods Receipt and Goods Issue for Raw Materials and Finished Goods and Consumbles ..instead of going for different reports for each we need a combined report which can display for all Raw Materials, Finished Goods and Consumbles and we need it for a specific date range Material type(Raw MAterials,Finished Goods, Consumbales)
    and below is the format i needed.
                                                                           RAW MATERIALS /FINISHED GOODS/CONSUMBALES
                            Opening Stock                      Closing Stock         Goods Receipt                  Goods Issue
                             Qty   Value                             Qty   Value                     Qty   Value                      Qty   Value
    Item Name
    Regards,
    Vamsi.

    Hi Guys.
    I need an Inventory stock report with Item name, Opening Stock,Goods issue Quantity,Goods Received ,Item Price,Location ,(Closing Stock)Total Value.
    We need the input by Date Range and Item Group and Location(if Possible) Below is the Code i used to run the report.
    Pls Update the Query...
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    Declare @Group nvarchar(10)
    Declare @Whse nvarchar(10)
    Set @FromDate = (Select min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >='[%0]')
    Set @ToDate = (Select max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <='[%1]')
    Set @Group = (Select Max(s2.ItmsGrpCod) from dbo.OITB S2 Where S2.ItmsGrpNam = '[%2]')
    Set @Whse = (Select Max(s3.Warehouse) from dbo.OINM S3 Where S3.Warehouse = '[%3]')
    Select @Whse as 'Warehouse', a.Itemcode, max(a.Dscription), sum(a.[Opening Balance]) as [Opening Balance], sum(a.[IN]) as [IN], sum(a.OUT) as OUT,max(a.Price) as 'Price', ((sum(a.[Opening Balance]) + sum(a.[IN])) - Sum(a.OUT)) as Closing from dbo.OITM I1
    Left JOIN (Select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.Price, (sum(N1.inqty)-sum(n1.outqty)) as [Opening Balance], 0 as [IN], 0 as OUT
    From dbo.OINM N1
    Where N1.DocDate < @FromDate and N1.Warehouse = @Whse
    Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.Price
    Union All
    select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], sum(N1.inqty) as [IN], 0 as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <= @ToDate and N1.Inqty >0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price
    Union All
    select N1.Warehouse, N1.Itemcode, N1.Dscription,N1.price, 0 as [Opening Balance], 0 as [IN], sum(N1.outqty) as OUT From dbo.OINM N1 Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate and N1.OutQty > 0 and N1.Warehouse = @Whse Group By N1.Warehouse,N1.ItemCode,N1.Dscription,N1.price) a ON a.ItemCode=I1.ItemCode
    where  I1.ItmsGrpCod = @Group
    Group By a.Itemcode
    Order By a.Itemcode
    Regards,
    Vamsi.

  • Report for open and shipped qty

    hi,
    any standard report to show open and shipped qty by SO no.?
    pls advice. thanks

    Hi jojo
    For list of open orders t.code is VA05
    Incomplete delivery - V_UC 
    Reward if useful
    Regards
    Srinath
    Edited by: sri nath on Apr 16, 2008 10:31 PM

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

    try 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 

  • Query For Open Items

    Hi,
    We are trying to create a query for the open items (purchase orders ) in order to add some fields useful for users.
    Would you be able to advise with the query needed to show us only the open items?
    Best regards,
    MB

    Hi,
    Try this one:
    Select distinct t1.cardcode as Vendor, t1.CardName as Name, t1.docnum as PO#, t0.itemcode, t0.Dscription, t0.OpenQty as 'Open Qty', t0.linenum Row#, t1.DocCur as Currency, t0.price as 'Purchase Price', t0.whscode, t1.taxdate as "PO Date"
    from dbo.por1 t0
    inner join dbo.opor t1 on t1.docentry = t0.docentry
    where t1.DocType = 'I' and t0.linestatus = 'O'
    order by t1.docnum Desc, t0.linenum
    Thanks,
    Gordon

  • SAP Tables  for Open Customer Orders and Sales History

    Dear Experts.
    I am looking to get SAP SD related tables for the following,
    1) SAP tables for Open Customer Orders     
    From SAP, I need to get all tables that Contain all open customer orders for products.
    2) Sales History
    From SAP, I need to get all tables that contain the previous month's sales history (shipped customer orders).
    Please Help!!

    hi
    check the following link
    http://www.erpgenie.com/abap/tables_sd.htm
    hope it will help you
    regards,
    sreelatha gullapalli

  • Auto update of Profit Centre in JE for Opening Stock

    Hi Experts,
          I am using SAP B1 2007B Version and Patch level 15 and  entering the Opening Stock of  Items in Initial quantities,inventory tracking and Stock posting window and updating the profit centre in distribution rule but the problem is it is not getting updated in the Journal Entry when the back end JE is posting accordingly and for that again we need to update it manually. can any please help me regarding this..
    Thanks,
    Narsing

    Profit Centres are generally applicable only for Revenue & Expense accounts.
    When you load the opening balances, it affect the Inventory Account which is an Account Account and that is why there is no Profit Centre marked in the JE.

  • Query  for  Closing Stock goes beyond a particular value.

    Hi,
    The query for the following requirement:
    The Closing Stock goes beyond a particular value. The Closing Value of items crosses the pre-defined value.

    Hi,
    Yes it is related to the user selected date and stock level. Not answered Closing the thread.
    Edited by: Neela M B on Aug 28, 2010 3:08 PM

  • Query for quotes not converted to Sales Orders

    Hello,
    I am relatively new to SAP B1 (little over a year now) and I am trying to build a query but I have no idea how to approach this one.
    I am trying to find Sales Quotes not converted to a Sales Order.  Sounds simple but here is where they start getting complicated.  I need to specify a date range (normally a year but could be quarterly).  Need to specify one or more items, groups, or vendors.  Need to display our cost for each item on the quote(s).
    Any help on this would be great.  I have used the query wizard in the past with some success but this one is getting way out of my comfort zone. 
    Many thanks to all who have contributed to these discussions.  It is nice knowing that I am not the only newbie around.
    Keith H

    Hi Keith.
    Following a little query for your request.
    Take note that query return only the ROWS of sales quote which are never converted in a sales order.
    It means that if you have a sales quote whit 1 rows and 1000 unit, and you convert the quote in a order for 500 unit, the quote is considered converted in a order and not displayed
    The cost is the price set in PRICE LIST 23 as you say in a your previous post.
    SELECT
    a.DocDate ,
    a.DocNum,
    a.CardCode,
    b.ItemCode,
    b.Quantity,
    d.ItmsGrpNam,
    b.Price as 'QUOTE_PRICE',
    e.Price as 'COST'
    FROM
    inner join QUT1 b on a.DocEntry = b.DocEntry
    inner join OITM c on b.ItemCode = c.ItemCode
    inner join OITB d on c.ItmsGrpCod = d.ItmsGrpCod
    inner join ITM1 e on b.itemcode = e.ItemCode
    where
    a.DocDate between [%0] and[%1]
    and b.TargetType <> '17'
    and b.ItemCode Like '%[%2]%'
    and e.PriceList = '23'
    EDIT:
    In your first post you say
    Need to specify one or more items, groups, or vendors.
    Please explain what you means for
    => one or more items
    in this point you can have some problem with the query manager...
    Hope that help
    --LUCA

Maybe you are looking for

  • Problem with IE8 and Flash on LL Bean website

    My desktop machine is running XP SP3 with all updates and the latest Flash Player. When visiting the LL Bean online catalog you view the products which have small pictures associated with them. If you click on a picture a larger window opens up with

  • Where do I put my slide show photos

    I am working on a slideshow. I do NOT want the photos to be contained in my MobileMe gallery. My host is 1and1. My question is this: do I have to put the folder containing the slideshow photos on 1and1's server, or can I use flickr, etc. Currently, w

  • Pdf file thats too large to send via email

    I have created a PDF file that is too large to send via e-mail, does anyone know how I can separate it into 2 or 3 files so I can send it?

  • How do I send a gift voucher overseas?

    We're in Australia, our nephew is in America. We want to email him a gift voucher for the itunes store for Christmas but itunes says the voucher is only valid in Australian stores. How can I arrange an email voucher for my nephew in America?

  • HTML5 video inside iweb not playing online

    Hi everyone. This is the first time I post something on this forum. I´m having problems with posting a html 5 video online from my iwebsite. I´m new to html so I might very well have done some simple thing wrong in the code. It looks good inside iweb