Skip to Content
author's profile photo Former Member
Former Member

open stock and closing stock

Hi

how to findout open stock for the date and closing stock .

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 12:17 PM

    hi

    good

    DATA : it_mard LIKE mard OCCURS 0 WITH HEADER LINE.

    DATA : BEGIN OF t_mard OCCURS 0 ,

    matnr LIKE mseg-matnr,

    labst LIKE mard-labst,

    END OF t_mard.

    DATA : it_mardh TYPE mardh.

    DATA : buper LIKE t009b-poper,

    gjahr LIKE t009b-bdatj.

    DATA : p_buper LIKE t009b-poper,

    p_gjahr LIKE t009b-bdatj.

    DATA : dt LIKE sy-datum.

    *CLOSING STOCK OF PREVIOUS PERIOD

    dt = sy-datum.

    *get current period

    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'

    EXPORTING

    i_date = dt

    i_periv = 'M3' "apr to march 4 spl periods

    IMPORTING

    e_buper = buper

    e_gjahr = gjahr

    EXCEPTIONS

    input_false = 1

    t009_notfound = 2

    t009b_notfound = 3

    OTHERS = 4.

    *fetch previous period

    CALL FUNCTION 'CKML_F_GET_PREVIOUS_PERIOD'

    EXPORTING

    input_period = buper

    input_year = gjahr

    input_periv = 'M3'

    IMPORTING

    previous_period = p_buper

    previous_year = p_gjahr.

    SELECT SINGLE * FROM mardh

    WHERE matnr = p_matnr

    AND werks = p_werks

    AND lfmon = p_buper

    AND lfgja = p_gjahr.

    IF sy-subrc = 0.

    CLOSING STOCK = mardh-labst.

    ENDIF.

    *to calculate current stock-----

    SELECT * FROM mard

    INTO CORRESPONDING FIELDS OF TABLE it_mard

    WHERE matnr = it_marc-matnr

    AND werks = p_werks.

    IF NOT it_mard[] IS INITIAL.

    LOOP AT it_mard.

    t_mard-matnr = it_mard-matnr.

    t_mard-labst = it_mard-labst.

    COLLECT t_mard.

    ENDLOOP.

    READ TABLE t_mard INDEX 1.

    CURRENT STOCK= t_mard-labst.

    ENDIF.

    thanks

    mrutyun^

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 07, 2007 at 12:18 PM

    Hi,

    Try the above code written by Mrutyunjaya. It will give all the details.

    Ashven

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 07, 2007 at 12:26 PM

    It depends on the level of stock you want, most SAP MM stock files have a current stock table and an historical one. The historical has only record if it differs from the previous period (some coding to do)

    MARC MARCH	Material Master C Segment: History
    MARD MARDH	Material Master Storage Location Segment: History
    MBEW MBEWH	Material Valuation: History
    MCHB MCHBH	Batch Stocks: History
    MCSD MCSDH	Customer Stock: History

    For some of these tables SAP has written Function Modules, like MBEW_EXTEND which read the history file to complement the current one.

    Regards

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2007 at 09:20 AM

    check mb5b mb5e trans

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 08, 2007 at 11:58 AM

    Hi Mohan,

    Use a standard report MB52.

    It will fullfill your requirement.

    Yusuf

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.