Stock on particular date (performance issue)

Hi Folks,
I m calculating stock at all vendor on a particular date.
But it takes very long and time_out occurs.
I m calculating opening closing provided return and rejection based on movement types.
The report hangs up at following particular Join.
SELECT MKPFBUDAT MSEGBWART MSEGMATNR MSEGLIFNR SUM( MSEG~MENGE )
              AS MENGE
                  INTO CORRESPONDING FIELDS OF TABLE IT_OPEN
                  FROM
                     MKPF INNER JOIN MSEG ON
                           MKPFMBLNR = MSEGMBLNR AND
                           MKPFMJAHR = MSEGMJAHR
                   WHERE MKPF~MJAHR = D_YEAR AND
                         MKPF~BUDAT GE D_DATE AND
                         MKPF~BUDAT LT S_BUDAT-LOW AND
                MSEG~BWART IN ('541','542','543','544','551','702') AND
                         MSEG~XAUTO NE 'X' AND
                         MSEG~MATNR IN S_MATNR AND
                         MSEG~WERKS IN P_WERKS AND
                         MSEG~LIFNR IN P_LIFNR
              GROUP BY LIFNR MATNR BUDAT BWART.
Is there any way to increase performance by breaking this inner join into select statements or anyhow.
Regards
Sachin

HI,
On seeing your code, it seems like,
SELECT MKPFBUDAT MSEGBWART MSEGMATNR MSEGLIFNR SUM( MSEG~MENGE )
AS MENGE
INTO CORRESPONDING FIELDS OF TABLE IT_OPEN
FROM
MKPF INNER JOIN MSEG ON
MKPFMBLNR = MSEGMBLNR AND
MKPFMJAHR = MSEGMJAHR
WHERE MKPF~MJAHR = D_YEAR AND
MKPF~BUDAT GE D_DATE AND
MKPF~BUDAT LT S_BUDAT-LOW AND
MSEG~BWART IN ('541','542','543','544','551','702') AND
MSEG~XAUTO NE 'X' AND
MSEG~MATNR IN S_MATNR AND
<b>MSEG~WERKS EQ P_WERKS</b> AND
<b>MSEG~LIFNR EQ P_LIFNR</b>
GROUP BY LIFNR MATNR BUDAT BWART.
Please see the code marked with bold as parameter passing in the select statement must be EQ and not IN.
Secondly, remove the aggregate function SUM from the select. First select all the records into an internal table and either use control break statements or Collect to sum up the entries.
Next, while selecting from the database use INTO TABLE IT_OPEN rather than into corresponding fields of table.
Also remove the movement types from the select and restrict it inside the Loop and Endloop.
Lakshminarayanan
Please mark all helpful answers for points

Similar Messages

  • Functional Specification For Opening And closing stock On Particular Date

    Dear Gurus,
    I am creating report for opening and closing stock on particular date in which batch and storage location should also be included. I want to know the tables and fields for the same.I have searched the forum and got report on month basis but I want this report on posting day basis.kindly suggest tables and fields. Thanks in Advance

    Dear sir,
    There are many other colums that client wants to add which are not present in MB5B transaction.columns which client wants to add are as follows...
    Material Number                                                   
    Material Description                                       
    Material Type                                                                        
    Material Group                                                                     
    External material Group                                                            
    Movement Type     
    Plant     
    Storage Location     
    Customer Number     
    Customer Name     
    Vendor Number     
    Vendor Name     
    Posting Date     Receipt Doc. Number
    Issue Doc. Number     
    Reference Issue Document Number     
    Opening Stock Quanity     
    Material Receipt Quantity     
    Material Issue Quantity     
    Material Closing Stock Quantity      
    Value Of Closing Stock
    And for this I want  tables and logic for the same. kindly provide the solution for the same.

  • Need stock on particular date entered on selection screen

    I am creating a stock in transit report and need stock on particular date entered by the user on selection screen.How do I calculate stock on a particular date?

    same thread...
    Re: Stock on a particulare date

  • Vendor stock on particular date

    vendor stock on particular date..any std Tcode
    plz help
    mb5b,mblb,mc.9 wont work
    thanks
    ramesh reddy(vallur)

    ME2O
    Or
    ME2M & ME2L, choose , Item Category L, and choose selection parameter of your requirement.
    Choose MB5B,
    Choose radio Button Special stock and give special stock as O.It may help u.
    Edited by: sudhansu satapathy on Dec 16, 2011 11:46 AM
    Edited by: sudhansu satapathy on Dec 16, 2011 11:49 AM

  • Closing Stock on Particular Date(MB5B Tcode)

    Hi Experts,
    I need closing stock as on some particular date. For e.g. closing stock as on 28.02.2014.
    In my requirement i have to use that closing stock value for further calculations in a new customized report.I can see closing stock value by using MB5B tcode.
    Please suggest some way to get closing stock as on some date so that i can use that in my Report.
    Can i directly call MB5B transaction in my Report and get closing stock value?
    Thanks & Regards,
    Pankaj

    Hello Pankaj,
    In your Customised Report use MKPF and MSEG table
    MKPF ----->  Material and date range as the input
    Then Pass Material document number from MKPF to MSEG table
    MSEG ----->  based on material document number from mkpf
    Create Temporary  variable
    values comes from the mseg where have credit and debit entries
    if debit entry "S" then subtract the values of the Mseg table from the temporary variable1
    if credit entry "H" then Add the values of the mseg table to the temporary variable2
    finally Add the temporary variable1 and temporary variable 2 and get the total stock.

  • Table to see stock on particular date

    Hello SAP Gurus,
       I know that through mb5b report you can see the stock on posting date.But guys can u  tell me that from which table and field it takes the data?

    Please look at transactions MCBE and MCBR.  They are part of the inventory standard analysis.  These will show total consumption for the selected time periods.
    There is a ton of data availablie via the Logistics Information System and I think it is the most under utilized functionality in SAP.  If consultants and users really learned how to use this functionality you could probably do away with 80% of your custom reports.
    You can also use flexiblie analysis against structure/table S032, (not S039), and create your own analysis and reports.  These can be highly customized and saved and reused.  Variants can be created and the results can be saved in personal reports, emailed or downloaded.
    Other structures you might find of use in your particular query would be
    S031 - Movements
    S032 - Stocks
    S033 - Movements (indiv. records)
    S034 - Movements (batches)
    S035 - Stocks (batches)
    S039 as suggested above provides primarily averages which is not what your looking for.
    Craig
    Edited by: Craig Snyder on Apr 30, 2008 1:26 AM

  • Inventory cube 0IC_C03 ,Stock on particular date

    Hi All,
       We are trying to get the stock on a particular date using cube 0IC_C03 ,but we are unable to get the total stock on a given date.
    1)Ex: I want stock on 01.12.2009 ,but in the query output I am getting  null values.
      I am only getting the total stock quantity on the loaded date for ex:04.01.2010(which is my data loading date in to the cube).
    2)And when we restrict 0calday with <=01.12.2009 ,i have to get the total stock till 01.12.2009
    Thanks&regards,
    Sunitha

    Hi,
    Check
    Treatment of historical full loads with Inventory cube
    Setting up material movement/inventory with limit locking time
    1)Ex: I want stock on 01.12.2009 ,but in the query output I am getting null values.
       I am only getting the total stock quantity on the loaded date for ex:04.01.2010(which is my data loading date in to the cube).
    For 2LIS_03_BX it will give the extracted date only
    2)And when we restrict 0calday with <=01.12.2009 ,i have to get the total stock till 01.12.2009
    try with below options.
    Use :
    0VALSTCKVAL   " for Value
    0VALSTCKQTY   " for Qty
    0CALMONTH        " for Month
    Use the above combinations in New Selections in columns and go it.
    For Qty Opening:
    New Selection bad drag abd drop following things
    0VALSTCKQTY   " for Qty
    0CALMONTH        " for Month and restrict with less then or equalto option variable (single value, user input)  and set the offeset
                                   value = -1 bcoz if user will give 12.2009 , so it will display 11.2009 closing stock, this is opening for 12.2009.
    For Qty Closing:
    New Selection bad drag abd drop following things
    0VALSTCKQTY   " for Qty
    0CALMONTH        " for Month and restrict with less then or equalto option variable (single value, user input) .
    In the same way build for Value and other Keyfigures on 0IC_C03.
    And
    Drag & drop
    0MATERAIL
    0PLANT  " Give some Input Variable.
    See the steps.
    Treatment of historical full loads with Inventory cube
    Setting up material movement/inventory with limit locking time
    If it is BI 7 then for BX in in DTP in Extraction Tab you need to select Extacrion mode = NON-Cumulative option.
    Thanks
    Reddy

  • Date Performance issue

    hi Guru's,
    I am using 11.1.6.8 OBIEE. One of my report is having performance issue when i dig into that i found that the date filter not applied in the SQL generated to send DB, due to that it is doing table scan, But strange thing is that when it displaying  data based on the Date range filter. It is only happening with the date dimension all other dimensions are working fine. I am not sure what it is missing.
    Thanks In advance.
    regards
    Mohammed.

    hi Saichand,
    Thanks for taking time and looking into.
    The filter is applied on the logical query but the physical query send to the DB is not having the filter. Due to that it is doing full table scan of the fact table and almost 30 minutes to display data. I am not sure why the physical query is not having the date filter. when i add the location or other type of filter it added to the Physical Query send to DB.
    regards
    @li

  • Stock on particular date

    How the system finds stock of material on specified date .
    Example In report MB5b system gives stock of material on date we have selected . If I select date 31 Mar 2010 then system displays stock as on 31 Mar . From which table it comes ?
    (In table MBEW we can get stock as on todays date)

    Hi,
    In MB5B, the system will first take in to account of all total valuated stock for the particular valuation area on system date.  This will be in the table S032.  Then it will take in to account total issues and receipts during the back date.  Then the difference will be added or subtracted accordingly from the present stock and value.
    Regards

  • Value Mapping Replication for Mass Data - Performance Issues

    Hi All,
    We are looking into Value Mapping Replication for Mass Data. We have done this for less number of fields.
    Now we might have to have 15,000 records in the cache for the Value Mapping. I am not sure how this would effect the Java Cache and Java Engine as a whole.
    There might be a situation where we will have to leave the 15K records in the cache table on Java Engine...
    Are there any parameters that we can look into just to see how this hits the performance.
    Any links/ guidance in the right direction might help me..
    reg

    Naveen,
    Check jins reply in this thread (they have done with API and without API using graphical but still some issues):
    Value mapping performance using LookUp API
    ---Satish

  • Regarding Stock on Particular Date

    hi all,
         I am getting Current Stock through MARD table but when i am going to Previous date i am getting Current Stock only.
    How can we calculate Previous day Stock.
    Please suggest solution.
    Regards
    Reddy

    RM,
    Why you not using SAP standard report.i guess there is hell lot of reports on stock already in System.
    use them for less error risk.
    MB51,MB5B,MMBEthere all ares tock report which build by system only.
    Amit.

  • Stock as on particular date

    Hi guys,
    Can we get stock of any material as on a specified date without using mb5b?  Which table will store this data?
    Please help me out on this
    thanks in advance
    sai

    Hello Chintu,
    MB5B is the best report to get material stock on specific date.
    There is no direct table which stores stock on particular date, but SAP system calculates strategically with GR, GI and material transfers to get this data. If you want report on that then I think need to develop it.
    Does MB5B not meet your requirement? Pl. explain the requirement so we can suggest accordingly.
    Regards
    Arif Mansuri

  • FG stock on a particular date for a specific customer

    Hi all,
    I need to develop one report in which i need FG stock for a particular customer on a particular date. For ex on 5/11/11 what was the FG stock against xyz customer.
    Is there any logic available for this requirement. can you please tell me which tables i should look for?
    Thanks

    FG stock for a particular customer on a particular date.
    Is it Make to Order stock? If it is not, then you may not find the details. If it is MTO, then use t.code MB5B. Using this, you can find stock on particular date.
    Regards,

  • Stock at subcontractor for Particular Date

    Dear Experts
    There is a t-code to get the Stk at subcontractor for a particular date .MBLB will show only current Stk, i need it for Particular date.
    Rgds
    Pankaj Agarwal

    Hi,
    There's no standard report for this.
    You can develop you own report using current stock level (MARD, MSPR, MSKA, EKBE (stock in transit), etc) and goods movement (MKPF, MSEG) data.
    Regards,
    Csaba
    remark:
    ME2O won't provide information on stock on particular date. The date field is "requirement date".
    Edited by: Csaba Szommer on Jul 24, 2009 7:51 AM

  • Logic to build report to get the stock on a particular date

    Dear Guru's,
    We are trying to build a report for getting the stock on a particular date. It is not possible to copy MB5B that option is ruled out. We have also tried to get the data from MBEWH but that is also  not helping as the table is not updated for all the periods.
    Please advice
    Thanks,
    Sam

    Dear Sameer,
    You can copy MB5B report and can modify as per your reuirement.
    If you want get stock a paticular date.It is hard to get, why because you have to fetch all the Material documents
    and you have to use MBEW table to get the current date stock and you have to do add/subtract from calculated stock.
    Due to this there will performance issues also.
    So try to copy MB5B and change as per your requirement.
    regards
    Subhash

Maybe you are looking for

  • Close Open PR Line Items

    Hi , There is a PR with 2 line items. Line Item 1 qnty is 100 Line Item 2 qnty is 25 A PO has been created with reference to above PR For Line Item 1 qnty is 50 For Line Item 2 qnty is 15 GRN has been done for the above PO. Now it has been decided th

  • How can I recover photos that have become corrupt

    Hi guys, having some trouble with old photos on my pc (windows 7), any help would be much appreciated. I have some old holiday photos on my pc in a specific folder . I had downloaded a password protection application and had set it up so that i had t

  • Applications won't open after error in a update using a Apple G4

    Apple G4 wont open applications, it says application switcher error or error type 3, everthing used to work until when updating the mac a error accured it restarted, now it won't open an application without saying error type 3, or when it boots a bom

  • Finite Pulse Train TIO-Timing Specs

    Howdy everyone, Got a question regarding the pulse specs of finite pulse generation with a 6602 (TIO chip). I'm using a slightly modified version of the Finite Pulse Train (NI_TIO).vi found in the examples directory to produce finite pulses. The slig

  • PSE5.0 problem with e-mailing photos

    about a week ago my PSE e-mail stopped working for photo attachments on Vista. I select the photo, the "attach to email" screen comes up, I attach and hit send and I get the hour glass and it freezes. help! what service does everyone else use to e-ma