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

Null/Zero stock report

Hi friends,

need some help with this topic:

- i am looking for a report on the number of days with null stock(=0) within a defined period of time (let's say...one month); Give me some logic or tables from where i can get this done.

Regards.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 11:54 AM

    Hi Mohsin,

    I have already done a report on this , so I am pasting my code below 4 ur reference. If u need any other clarification please ask.

    TABLES: MARA, MARC, MARD, MAKT, MCHB, MBEW.
    
    DATA: IT_MARA LIKE MARA OCCURS 0 WITH HEADER LINE.
    DATA: UPDATE, DESC LIKE MAKT-MAKTX.
    UPDATE = ' '.
    
    DATA: BEGIN OF ITAB OCCURS 0,
          MAKTX LIKE MAKT-MAKTX,           " MATERIAL DESCRIPTION
          BISMT LIKE MARA-BISMT,           " OLD MATERIAL NUMBER
          MATKL LIKE MARA-MATKL,           " MATERIAL GROUP
          MATNR LIKE MARA-MATNR,           " MATERIAL
          MEINS LIKE MARA-MEINS,           " Unit of measurement  VGS
          WERKS LIKE MARC-WERKS,           " PLANT
          LGORT LIKE MARD-LGORT,           " STORAGE LOCATION
          LGPBE LIKE MARD-LGPBE,           " STORAGE BIN
          BWTAR LIKE MCHB-CHARG,           " VALUATION TYPE
          LBKUM LIKE MCHB-CLABS,           " UNRESTRICTED STOCK
          CINSM LIKE MCHB-CINSM,           " IN. QUALITY INSPECTION
          CSPEM LIKE MCHB-CSPEM,           " BLOCKED
          VERPR LIKE MBEW-VERPR,           " Moving Average Price
          BWTTY LIKE MARC-BWTTY,
          MSTAE LIKE MARA-MSTAE,
      END OF ITAB.
    
    SELECT-OPTIONS: TMATKL FOR MARA-MATKL, "material group
                    TWERKS FOR MARC-WERKS, "plant
                    TMATNR FOR MARA-MATNR, " MATERIAL CODE
                    TMTART FOR MARA-MTART,
                    TLGORT FOR MARD-LGORT, " STORAGE LOCATION
                    TLGPBE FOR MARD-LGPBE, " STORAGE BIN
                    TBWTAR FOR MBEW-BWTAR, " VALUATION TYPE
    *                TLBKUM FOR MBEW-LBKUM, " TOTAL VALUED STOCK
                    TVERPR FOR MBEW-VERPR, " MOVING AVERAGE PRICE
                    TMAABC FOR MARC-MAABC.
    
    PARAMETERS: TNOZERO AS CHECKBOX DEFAULT 'X'.
    
    START-OF-SELECTION.
    
      WRITE SY-DATUM TO SY-TVAR1.
      WRITE SY-UZEIT TO SY-TVAR2.
      SELECT * FROM MARA INTO TABLE IT_MARA WHERE MATKL IN TMATKL AND
                                                  MATNR IN TMATNR AND
                                                  MTART IN TMTART.
      LOOP AT IT_MARA.
        CLEAR: MAKT, MARC, MARD, MBEW, MCHB, DESC.
        SELECT SINGLE * FROM MAKT WHERE MATNR EQ IT_MARA-MATNR.
        IF MAKT-MAKTX+0(1) EQ '"'.
           DESC = MAKT-MAKTX+1(39).
        ELSE.
           DESC = MAKT-MAKTX.
        ENDIF.
        SELECT * FROM MARC WHERE MATNR EQ IT_MARA-MATNR AND
                                 WERKS IN TWERKS AND
                                 MAABC IN TMAABC.
          CLEAR: UPDATE,MARD,MCHB,MBEW.
          IF MARC-BWTTY NE ' '.
            SELECT * FROM MARD WHERE MATNR EQ IT_MARA-MATNR AND
                                     WERKS EQ MARC-WERKS.
              CLEAR: UPDATE,MCHB,MBEW.
              CHECK MARD-LGORT IN TLGORT.
              CHECK MARD-LGPBE IN TLGPBE.
              SELECT * FROM MCHB WHERE MATNR EQ IT_MARA-MATNR AND
                                       WERKS EQ MARC-WERKS AND
                                       LGORT EQ MARD-LGORT.
                CLEAR: UPDATE, MBEW.
                IF SY-SUBRC EQ 0.
                  CHECK MCHB-CHARG IN TBWTAR.
                  SELECT SINGLE * FROM MBEW
                                    WHERE MATNR EQ IT_MARA-MATNR AND
                                          BWKEY EQ MARC-WERKS AND
                                          BWTAR EQ MCHB-CHARG.
                  CHECK MBEW-VERPR IN TVERPR.
                ENDIF.
                PERFORM ADD_ITAB.
              ENDSELECT.
              PERFORM ADD_ITAB.
            ENDSELECT.
          ELSE.
            SELECT * FROM MARD WHERE MATNR EQ IT_MARA-MATNR AND
                                     WERKS EQ MARC-WERKS.
              CLEAR: MBEW.
              IF SY-SUBRC EQ 0.
                CHECK MARD-LGORT IN TLGORT.
                CHECK MARD-LGPBE IN TLGPBE.
                SELECT SINGLE * FROM MBEW WHERE MATNR EQ IT_MARA-MATNR AND
                                         BWKEY EQ MARC-WERKS AND
                                         BWTAR EQ '          '.
                CHECK MBEW-VERPR IN TVERPR.
                CHECK MBEW-BWTAR IN TBWTAR.
                PERFORM ADD_ITAB1.
              ELSE.
                PERFORM ADD_ITAB1.
              ENDIF.
            ENDSELECT.
          ENDIF.
        ENDSELECT.
      ENDLOOP.
    
      SORT ITAB BY MATNR BWTAR WERKS LGORT LGPBE.
    
      FORMAT COLOR COL_NORMAL.
      LOOP AT ITAB.
        SET LEFT SCROLL-BOUNDARY COLUMN 60.
        IF NOT TNOZERO IS INITIAL AND
               ITAB-LBKUM EQ 0.
    *          ITAB-CINSM EQ 0 AND
    *          ITAB-CSPEM EQ 0.
          CONTINUE.
        ENDIF.
    
        WRITE ITAB-WERKS TO SY-TVAR3.
        WRITE ITAB-MATKL TO SY-TVAR4.
        WRITE:/(25) ITAB-MAKTX,
          (10) ITAB-MATNR,
    *           ITAB-BWTAR,
           (10) ITAB-BISMT,
    *            ITAB-WERKS,
                ITAB-LGORT,
                ITAB-LGPBE,
           (10) ITAB-LBKUM NO-ZERO.
        IF NOT ITAB-LBKUM IS INITIAL.
          WRITE: ITAB-MEINS.
        ELSE.
          WRITE:(5) SPACE.
        ENDIF.
        IF ITAB-MSTAE EQ ' '.
        SELECT SINGLE * FROM MARC WHERE MATNR = ITAB-MATNR AND WERKS =
        ITAB-WERKS.
        WRITE : MARC-MMSTA.
        ENDIF.
    
        WRITE : ITAB-MSTAE.
    *    WRITE: (13) ITAB-VERPR NO-ZERO.
    *       (13) ITAB-CINSM NO-ZERO,
    *       (13) ITAB-CSPEM NO-ZERO.
      ENDLOOP.
    
    *&---------------------------------------------------------------------*
    *&      Form  ADD_ITAB
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM ADD_ITAB.
      IF UPDATE EQ ' '.
        MOVE:DESC TO ITAB-MAKTX,
             IT_MARA-BISMT TO ITAB-BISMT,
             IT_MARA-MATKL TO ITAB-MATKL,
             IT_MARA-MATNR TO ITAB-MATNR,
             IT_MARA-MEINS TO ITAB-MEINS,  " VGS Changed on 31.12.99
             IT_MARA-MSTAE TO ITAB-MSTAE,
             MARC-WERKS TO ITAB-WERKS,
             MARC-BWTTY TO ITAB-BWTTY,
             MARD-LGORT TO ITAB-LGORT,
             MARD-LGPBE TO ITAB-LGPBE,
             MBEW-BWTAR TO ITAB-BWTAR,
             MBEW-VERPR TO ITAB-VERPR,
             MCHB-CHARG TO ITAB-BWTAR,
             MCHB-CLABS TO ITAB-LBKUM,
             MCHB-CINSM TO ITAB-CINSM,
             MCHB-CSPEM TO ITAB-CSPEM.
        APPEND ITAB.
        UPDATE = 'X'.
      ENDIF.
    ENDFORM.                               " ADD_ITAB
    *&---------------------------------------------------------------------*
    *&      Form  ADD_ITAB1
    *&---------------------------------------------------------------------*
    *       text
    *----------------------------------------------------------------------*
    *  -->  p1        text
    *  <--  p2        text
    *----------------------------------------------------------------------*
    FORM ADD_ITAB1.
      MOVE:DESC TO ITAB-MAKTX,
           IT_MARA-BISMT TO ITAB-BISMT,
           IT_MARA-MATKL TO ITAB-MATKL,
           IT_MARA-MATNR TO ITAB-MATNR,
           IT_MARA-MEINS TO ITAB-MEINS,    " VGS Changed on 31.12.99
           IT_MARA-MSTAE TO ITAB-MSTAE,
           MARC-WERKS TO ITAB-WERKS,
           MARC-BWTTY TO ITAB-BWTTY,
           MARD-LGORT TO ITAB-LGORT,
           MARD-LGPBE TO ITAB-LGPBE,
           MBEW-BWTAR TO ITAB-BWTAR,
           MBEW-VERPR TO ITAB-VERPR,
           MARD-LABST TO ITAB-LBKUM,
           MARD-INSME TO ITAB-CINSM,
           MARD-SPEME TO ITAB-CSPEM.
      APPEND ITAB.
    ENDFORM.                               " ADD_ITAB1

    Thanks

    Karthik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 12:06 PM

    Hi Mohsin,

    Sorry, I could not copy my code properly !!

    First: Take all the matnr from mara then go MARC and MARD

    SELECT * FROM MARC WHERE MATNR EQ IT_MARA-MATNR AND
                                 WERKS IN TWERKS AND
                                 MAABC IN TMAABC.
          CLEAR: UPDATE,MARD,MCHB,MBEW.

    IF MARC-BWTTY NE ' '.
            SELECT * FROM MARD WHERE MATNR EQ IT_MARA-MATNR AND
                                     WERKS EQ MARC-WERKS.
              CLEAR: UPDATE,MCHB,MBEW.
              CHECK MARD-LGORT IN TLGORT.
              CHECK MARD-LGPBE IN TLGPBE.
              SELECT * FROM MCHB WHERE MATNR EQ IT_MARA-MATNR AND
                                       WERKS EQ MARC-WERKS AND
                                       LGORT EQ MARD-LGORT.
                CLEAR: UPDATE, MBEW.

    IF SY-SUBRC EQ 0.
                  CHECK MCHB-CHARG IN TBWTAR.
                  SELECT SINGLE * FROM MBEW
                                    WHERE MATNR EQ IT_MARA-MATNR AND
                                          BWKEY EQ MARC-WERKS AND
                                          BWTAR EQ MCHB-CHARG.
                  CHECK MBEW-VERPR IN TVERPR.
                ENDIF.
                PERFORM ADD_ITAB.
              ENDSELECT.
              PERFORM ADD_ITAB.
            ENDSELECT.
          ELSE.
            SELECT * FROM MARD WHERE MATNR EQ IT_MARA-MATNR AND
                                     WERKS EQ MARC-WERKS.
              CLEAR: MBEW.
              IF SY-SUBRC EQ 0.
                CHECK MARD-LGORT IN TLGORT.
                CHECK MARD-LGPBE IN TLGPBE.
                SELECT SINGLE * FROM MBEW WHERE MATNR EQ IT_MARA-MATNR AND
                                         BWKEY EQ MARC-WERKS AND
                                         BWTAR EQ '          '.
                CHECK MBEW-VERPR IN TVERPR.
                CHECK MBEW-BWTAR IN TBWTAR.
                PERFORM ADD_ITAB1.
              ELSE.
                PERFORM ADD_ITAB1.
              ENDIF.
            ENDSELECT.
          ENDIF.
        ENDSELECT.
      ENDLOOP.

    Thanks

    Karthik

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 20, 2009 at 12:55 PM

    hi,

    you can get the stock details from the standard report MB5B itself

    regards

    Yogi

    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.