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

Similar Messages

  • One of my stocks will have a reverse stock split tomorrow. how do it do that

    One of my stocks will have a reverse stock split tomorrow. How do I make this change on my portfolio in Firefox. The name of the stock is Citigroup Inc.
    Thank you
    Bob

    This probably is a feature of your stock tracking site (for example, Yahoo finance) or portfolio management tool. Or maybe you have an add-on I don't have?? Since your financial data is sensitive, you may want to contact your site directly rather than posting about it here.

  • HT1338 I can't final close Safari with control Q. It just open next time on the closed page.

    I can't final close Safari with control Q. It just open next time on the closed page.

    To prevent Safari opening your last closed pages again you can do one of three things.
    1. Close the pages before closing Safari (eg. open homepage before closing Safari)
    2. Hold Shift while opening Safari (this will start Safari from homepage)
    3. Browse in 'Private Browsing'.

  • If I change my Apple ID for iMessage, will all the iMessages under my previous Apple ID be deleted off my phone?

    If I change my Apple ID for iMessage, will all the iMessages under my previous Apple ID be deleted off my phone?

    No, not unless you delete them.

  • Qulaity stock included in the Plant stock -MD04

    Dear All ,
                      I am having  following stock for the Material A ,
    Unrestricted Stock  =  0
    Quality Stock           =  10
    When i check in the T-code :MD04 , System shows the Plant Stock as 10 , and this stock is included in MRP also ..
    I have checked the Checking Rule assignment in the configuration  plant parameters under MRP .
    How the Quality stock is included in the plant stock and the same considered for MRP .
    Is this logic is correct one ...
    I am expecting some replies from you all

    hi,
    What you notice is standard SAP behavior. QC stock is considered in plant stock & same is available during MRP run. However for Av. Check you can exclude QC stock in the checking rule.
    If your business need is not to include QC stock in MRP run, then create a SLoc which is not MRP relevant & maintain the stock in this location. In MRP - 4 view you need to maintain the value 1 for Sloc MRP indicator. You can get this value defaulted for all newly created materials in OMIR. For mass changes of existing materials you can use MM17.
    Regards,
    Vivek

  • How do you start the computer from a previous date.

    I overloaded my desktop and now the computer is frozen. It will turn on but none of the applictions work. I can pull up preferences. I would like to start my computer with a previous date when everything is working.  Please tell me how to do that. I know how to put it in safe boot.
    Thanks,

    To return your computer to a previous date you have to have been doing backups with the Application called TimeMachine.  It is turned off, by default.   TimeMachine automatically backs-up your user files to another disk or to rounter with a backup disk.  When TimeMachine is enabled, you can return to any time or date in the past by running the TimeMachine application and doing a Restore on the date and time you choose.
    If you didn't have TimeMachine running or a current backup....
    FYI:  Microsoft's Windows has a feature to restore it's Registry to a previous date, but that is not backup of the user files.   It allows the system to replace the Registry database back to a point where it was not corrupted. 
    A similar fix for the Mac OS is to reboot the computer and hold down 4 keys to reset the PRAM (that is your system Preferences).  This is a very quick fix and it should be the first thing you try.   As the system is restarting, hold down the OPTION- COMMAND-P-R keys all that the same time.
    Failing that, you can boot the system up in SAFE mode, which brings up the Mac OS without enabling any of the extensions.   It requires a wired USB keyboard and mouse - won't work with a wireless keyboard or mouse. Cycle power and hold down COMMAND-S keys on reboot.  This will allow you basic access to your system and you can reomove or delete any application that you suspect is causing a problem.
    If none of your applications work on the Mac, you can boot up from the gray repair disk (or boot up Disk Warrior or Tech Tools).   All of them will clean up the file systems and that is usually all you need to fix things. Insert the disk. cycle the power button (hold it for 11 seconds) and hold Command Key+C (for CD) on your keyboard while it boots back up. 
    The most common cause for persistient hangs is too little memory (RAM) or the harddisk is full.   The RAM problem can be minimized by not running other big applications.   If the harddisk is over 80% full, you will see significant slowing.  At 90-95% full, the system can barely run.   Run Disk Utitliy from the APPLICATIONS / UTLILITIES Folder, as The Hatter suggested (above).  Disk Repair is the option.
    Note: If any recovery works with a wireless keyboard and mouse, I am not aware of that new functionality.   Also, any USB keyboard and mouse will work, even if it's from a PC.

  • Ok. Add me to the moron list. I guess I am an over zealous trash emptier. Can I retrieve those images from the vastness by entering my time machine and restore the library from a previous date (when I wasn't a moron?)

    Ok. Add me to the moron list. I guess I am an over zealous trash emptier. Can I retrieve those images by entering my time machine and restoring the Iphoto library from a previous date (when I wasn't a moron?)

    Masters is where you want to be. They'll be in there in folders based on the date and time they were imported.
    Regards
    TD

  • I always have many tabs open in FF, and rely on it restoring them each time I close/open it again. Sometimes I'll have a second window open and will close the main window first, losing a record of tabs I had open. Is there a way around this?

    Seems like when FF restores a session, it restores the session of the last window open. If you use tabs as a way of keeping a list of things to do or look at, you have to be careful if you have a second window open to close the second window before your main one, or you will lose your list. I'm absent minded though and do this all the time. The only way to prevent this is bookmark all my tabs once a day, but I tend to forget to do even that. Any workaround for this?

    When you re-open Firefox and choose Restore Session, by default it picks up your most-recently-open window, and the other windows should then show up in Recently Closed Windows.
    The Firefox add-on Session Manager lets you manage how many closed windows and closed tabs are saved, in case it's not enough.

  • How do I access technical support. There is something wrong with my program - it gvies and error message - can't open but will fix the problem the next time it opens.  Which it does not do.  I uninstalled and reinstalled the program, but the same error ap

    How do I access someone for technical support?  what telephone number can I use?

    Find the LR cache folder and delete it. Find the LR preview folder and delete it. Then try opening LR.

  • Why can't I open "I Will" by the Beatles on my Mac Mini?

    I downloaded this song on my iPad on iTunes.  Now when I try to play it on my Mac Mini, it keeps asking me to authorize the computer, then tells me it is authorized ad infinitum.  What to do?  Is there some special copyright issue with a Beatles Song?

    Delete and redownload it if doing so is free in your country.
    (87463)

  • What happens when I remove my sim card? Can I put my sim back in and it will remain the same or is my data deleted?

    If I was to remove my sim from my iPhone 6 and put it into another phone to use for the night, what happens to my data on my iPhone 6?
    Will everything remain the same (e.g. photos, messages) when I put my sim card back in my iPhone?

    Nothing will happen if you remove your sim card from your iPhone 6.  The only thing that will happen is that you will not be able to use it as a phone - you will have no service.
    Nothing is stored on a sim card of an iPhone - iPhones cannot store data on a sim card - everything is stored on the phone itself, with syncing via iTunes.
    You can take the sim card out and nothing will happen to your data - it is all stored on the phone.

  • Will using the Recover HD Erase my data

    I am using OSX Mavericks 10.9.2 and after my computer crashed, undertook a Vertify Disk to see if there were any issues. I received a message on Verify Disk telling me "incorrect number of extended attributes" and "Error: this disk needs to be repaired..."
    I then received a message telling me to repair the Recovery HD by restarting the computer holding down the Command and R Key.
    Being a very basic user, this freaked me out - will this format my disk and erase my data?
    I already have a support call to Apple given that my thunderbolt ports (and hence thunderbolt backup device) aren't working and I only have a non-bootable time machine backup on a time capsule.

    Follow the instructions. When the recovery HD is up, you will have an option to use disk utility. Run repair disk from there.
    Barry

  • Closing Stock Of material

    Dear all
          Using MC.9 transaction we will get the closing stock of a material in any date directly.I want to know that from which table we will closing stock of a material in a particular date.From MBEW we will get current stock only but ieed the closing stock of a particular date..Help me if u have any idea..
    Regards BIJU K SHARMA

    closing stock showing in MB5B report for that date with the same filter conditions.
    In closing stock u have to consider Stock.Avail. @ my hands
    search for  table MARD in that MB5B
    refer.
    Re: closing stock of a particular date

  • Closing stock value

    Hi SAP Gurus,
    how will get the closing stock value for datewise in month.
    Thanks
    Shri..

    Hi,
    i am getting values of all the material which is not required.
    I required total closing stock date wise with stock value flat figure.Is there any standard report for that.
    Thanks
    Shri....

  • Closing stock by using opening sock

    Hi All,
    I got opening stock by using this how can I calculate closing stock,pls help me.
    REPORT   zhzl_material_analysis_gb LINE-SIZE 1000.
    tables:mara,mseg,s034.
    TYPE-POOLS: slis.
    DATA: budat TYPE budat.
    DATA: v_fieldcat TYPE slis_fieldcat_alv,
    v_t_fieldcat TYPE slis_t_fieldcat_alv.
    *Internal Tables for Opening Stock Calculation
    DATA : BEGIN OF t_mbew OCCURS 0,
    matnr LIKE mbew-matnr,
    bwkey LIKE mbew-bwkey,
    lbkum LIKE mbew-lbkum,
    salk3 LIKE mbew-salk3,
    END OF t_mbew.
    DATA: BEGIN OF i_mbew OCCURS 0,
    mblnr LIKE mseg-mblnr,
    mjahr LIKE mseg-mjahr,
    menge LIKE mseg-menge,
    meins TYPE meins,
    bwart LIKE mseg-bwart,
    matnr LIKE mseg-matnr,
    *REP werks as bwkey
    bwkey LIKE mseg-werks,
    shkzg LIKE mseg-shkzg,
    dmbtr LIKE mseg-dmbtr,
    zeile LIKE mseg-zeile,
    smbln LIKE mseg-smbln,
    smblp LIKE mseg-smblp,
    sjahr LIKE mseg-sjahr,
    kunnr LIKE mseg-kunnr,
    mblnr1 LIKE mkpf-mblnr,
    mjahr1 LIKE mkpf-mjahr,
    budat LIKE mkpf-budat,
    taxkd LIKE knvi-taxkd,
    END OF i_mbew.
    DATA: BEGIN OF i_mara OCCURS 0,
    matnr LIKE mara-matnr,
    matkl LIKE mara-matkl,
    spart LIKE mara-spart,
    END OF i_mara.
    DATA: i_makt TYPE TABLE OF makt WITH HEADER LINE.
    DATA: BEGIN OF i_collect OCCURS 0,
    matnr LIKE mara-matnr,
    bwkey LIKE mbew-bwkey,
    menge LIKE bsim-menge,
    dmbtr LIKE bsim-dmbtr,
    END OF i_collect.
    DATA: BEGIN OF i_op_stock OCCURS 0,
    matnr LIKE mara-matnr,
    maktx LIKE makt-maktx,
    matkl LIKE mara-matkl,
    bwkey LIKE mbew-bwkey,
    menge LIKE bsim-menge,
    dmbtr LIKE bsim-dmbtr,
    spart LIKE mara-spart,
    END OF i_op_stock.
    *The Selection-Screen Construction
    SELECTION-SCREEN: BEGIN OF BLOCK sel_block WITH FRAME.
    PARAMETER: p_werks LIKE mseg-werks.
    *PlantCompany Code
    SELECT-OPTIONS : s_date FOR budat,
                     p_spart for mara-spart,
    *Division
                     p_bukrs for mseg-bukrs .
    SELECTION-SCREEN: END OF BLOCK sel_block .
    START-OF-SELECTION.
    PERFORM opening_stock.
    PERFORM alv.
    *FORM opening_stock *
    *Calculates stock for date value in the low field of the *
    *select-options.
    FORM opening_stock.
    CLEAR t_mbew.
    SELECT * FROM mbew INTO CORRESPONDING FIELDS OF TABLE t_mbew
    WHERE bwkey = p_werks .
    SORT t_mbew BY matnr.
    REFRESH i_mbew.
    CLEAR i_mbew.
    LOOP AT t_mbew.
    i_mbew-matnr = t_mbew-matnr.
    i_mbew-bwkey = t_mbew-bwkey.
    i_mbew-dmbtr = t_mbew-salk3.
    i_mbew-menge = t_mbew-lbkum.
    APPEND i_mbew.
    CLEAR i_mbew.
    ENDLOOP.
    SELECT
    mseg~mblnr
    mseg~mjahr
    mseg~bwart
    mseg~menge
    mseg~matnr
    mseg~shkzg
    mseg~werks AS bwkey
    mseg~zeile
    mseg~smbln
    mseg~smblp
    mseg~sjahr
    mseg~kunnr
    mkpf~mblnr AS mblnr1
    mkpf~mjahr AS mjahr1
    mkpf~budat
    FROM mseg AS mseg INNER JOIN
    mkpf AS mkpf ON
    msegmblnr = mkpfmblnr
    AND
    msegmjahr = mkpfmjahr
    APPENDING CORRESPONDING FIELDS OF TABLE i_mbew
    WHERE mkpf~budat > s_date-low
    AND mseg~bukrs in p_bukrs
    AND mseg~werks = p_werks
    AND mseg~kzvbr = ' '
    AND mseg~bustw NE ' '.
    SORT i_mbew BY matnr budat mblnr.
    SORT i_mara BY matnr.
    SORT i_makt BY matnr.
    LOOP AT i_mbew.
    IF i_mbew-shkzg = 'S'.
    i_mbew-dmbtr = i_mbew-dmbtr * ( - 1 ).
    i_mbew-menge = i_mbew-menge * ( - 1 ).
    ENDIF.
    MODIFY i_mbew TRANSPORTING dmbtr menge.
    ENDLOOP.
    CLEAR i_collect.
    LOOP AT i_mbew.
    i_collect-matnr = i_mbew-matnr.
    i_collect-bwkey = i_mbew-bwkey.
    i_collect-dmbtr = i_mbew-dmbtr.
    i_collect-menge = i_mbew-menge.
    COLLECT i_collect.
    ENDLOOP.
    CLEAR: i_collect,i_op_stock.
    LOOP AT i_collect.
    MOVE-CORRESPONDING i_collect TO i_op_stock.
    APPEND i_op_stock.
    CLEAR i_op_stock.
    ENDLOOP.
    CHECK NOT i_op_stock[] IS INITIAL.
    LOOP AT i_op_stock.
    DELETE i_op_stock WHERE menge = 0.
    ENDLOOP.
    SORT i_op_stock BY matnr.
    SELECT * FROM mara INTO CORRESPONDING FIELDS OF TABLE i_mara
    FOR ALL ENTRIES IN i_op_stock
    WHERE matnr = i_op_stock-matnr
    AND spart in p_spart.
    SELECT * FROM makt INTO TABLE i_makt
    FOR ALL ENTRIES IN i_mara
    WHERE matnr = i_mara-matnr
    AND spras = 'EN'.
    LOOP AT i_op_stock.
    CLEAR i_mara.
    READ TABLE i_mara WITH KEY matnr = i_op_stock-matnr.
    IF sy-subrc = 0.
    i_op_stock-matkl = i_mara-matkl.
    i_op_stock-spart = i_mara-spart.
    MODIFY i_op_stock TRANSPORTING matkl spart.
    ELSE.
    DELETE i_op_stock.
    ENDIF.
    ENDLOOP.
    LOOP AT i_op_stock.
    CLEAR i_makt.
    READ TABLE i_makt WITH KEY matnr = i_op_stock-matnr.
    IF sy-subrc = 0.
    i_op_stock-maktx = i_makt-maktx.
    MODIFY i_op_stock TRANSPORTING maktx.
    ELSE.
    DELETE i_op_stock.
    ENDIF.
    ENDLOOP.
    ENDFORM.
    FORM alv.
    CLEAR v_fieldcat.
    v_fieldcat-col_pos = 1.
    v_fieldcat-fieldname = 'MATNR'.
    v_fieldcat-seltext_m = 'Material code'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 2.
    v_fieldcat-fieldname = 'MAKTX'.
    v_fieldcat-seltext_m = 'Description'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 3.
    v_fieldcat-fieldname = 'MATKL'.
    v_fieldcat-seltext_m = 'Material Group'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 4.
    v_fieldcat-fieldname = 'SPART'.
    v_fieldcat-seltext_m = 'Division'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 5.
    v_fieldcat-fieldname = 'BWKEY'.
    v_fieldcat-seltext_m = 'Plant'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 6.
    v_fieldcat-fieldname = 'DMBTR'.
    v_fieldcat-seltext_m = 'Amount'.
    APPEND v_fieldcat TO v_t_fieldcat.
    v_fieldcat-col_pos = 7.
    v_fieldcat-fieldname = 'MENGE'.
    v_fieldcat-seltext_m = 'Quantity'.
    APPEND v_fieldcat TO v_t_fieldcat.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    it_fieldcat = v_t_fieldcat
    TABLES
    t_outtab = i_op_stock.
    ENDFORM.
    Thanks&regds,
    Sree.

    Hi,
    Please note that MBEW contains the stock position as of now. MBEWH contains the closing stock of all the previous periods. However if there is no transaction in a particular period you may not find a record in MBEWH for that period.
    Please refer to SAP documentation:
    [Back To Resultlist]
    Material Master (Industry/Retail): Enhancements to Period Closing
    Description
    In Release 4.5A, the period closing function has been redesigned to eliminate or at least alleviate the following problems:
    Long runtime if there are very many stock segments
    Locking of all materials while the period closing program is run
    Data inconsistencies in stock segments due to incorrect operation of the period closing program by users
    The enhancements made to eliminate or alleviate these problems affect the way in which period closing is performed technically and particularly the data design. As a result, the following information is intended primarily for the following persons:
    System administrators
    Developers (for example, in customer projects)
    Other persons in IT departments or systems departments
    Runtime
    The runtime of the period closing program has been improved substantially since no stock tables (such as MBEW, MARD, or MCHB) are updated any longer for the change in period, unless the change in period is a change in fiscal year. Only the material ledger tables are updated.
    If the change in period coincides with the end of a fiscal year, the program also updates the physical inventory indicators and thus those tables relevant to physical inventory management; that is, even in this case, table MBEW in particular is no longer updated.
    Locking of materials
    The materials are locked by the period closing program only if the material ledger is used.
    In the case of a change in fiscal year, no physical inventory transactions can be performed when running the period closing program.
    Ease of use
    As of Release 4.5A, period closing is performed in inventory management or invoice verification; that is, whenever, for example, a goods movement is made, the period is updated in the relevant stock segments of the material if the material is moved for the first time in this period.
    Changes to the interface
    There have been no changes to the interface.
    Changes in procedure
    The implementation of the above enhancements has required the data design to be changed as follows:
    Stock tables MBEW, EBEW, QBEW, MARC, MARD, MCHB, MKOL, MSKA, MSSA, MSKU, MSLB, MSPR, and MSSQ now have history tables, for example, MBEWH is the history table for MBEW, and EBEWH the history table for EBEW. For each period, these history tables can contain an entry with the corresponding stock information, and are created for the previous period whenever there is a change in period-relevant information such as unrestricted-use stock. This means that the information for the previous period can no longer be read directly from tables MBEW, EBEW, and so on, but that tables MBEWH, EBEWH, etc. have to be read and interpreted.
    The point in time at which the system is upgraded to Release 4.5A is important for interpreting the history tables. If the period has been closed at least once after the upgrade, the stocks for the previous period are contained, for example, in history table MARDH. If this table does not contain a corresponding entry, the previous period stock for the corresponding stock fields is the same as the current stock.
    Fields LFMON/LFGJA of the stock tables no longer contain the current period, but one of the following periods, depending on when the upgrade took place:
    Period of the last goods movement, invoice verification, price change, or other function that has resulted in period-specific information being updated
    Period of the release upgrade if no such function has been performed since the system was upgraded
    The current period is still recorded (as prior to Release 4.5A) in table MARV.
    Planning
    In a future release, it is planned for the data in the material ledger to no longer be updated by the period closing program. This will further increase the speed of the program.
    [Back To Resultlist]
    Regards
    Raju Chitale

Maybe you are looking for