Report for stock statement

hi guy's,
   i am doing report for the stock statement .... my issue is in MB5B if i reverse some document it shows as it move's to issue QTY and my receipt is same but my closing stock is correct ...is there any std report avalible ....
thank's in advance

Use this code :
TABLES : MSEG,MKPF,MARA,MAKT,BEWART,MSLB,BSIM.
TYPE-POOLS : SLIS.
DATA : IT_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
       IT_LIST_HEADER TYPE SLIS_T_LISTHEADER,
       IT_EVENTS TYPE SLIS_T_EVENT,
       GS_LAYOUT TYPE SLIS_LAYOUT_ALV,
       WA_SORT TYPE SLIS_SORTINFO_ALV,
       IT_SORT TYPE SLIS_T_SORTINFO_ALV,
       REPID LIKE SY-REPID,
       FRM_DATE(10),TO_DATE(10),
       DISPTEXT(255),DISPTEXT2(255).
TYPES : BEGIN OF ST_OPBAL,
         MATNR LIKE MSEG-MATNR,
         MAKTX LIKE MAKT-MAKTX,
         BATCH LIKE MSEG-CHARG,
         BWART LIKE MSEG-BWART,
         MENGE LIKE MSEG-MENGE,
         ZEILE LIKE MSEG-ZEILE,
         WERKS LIKE MSEG-WERKS,
         SOBKZ LIKE MSEG-SOBKZ,
         BUDAT LIKE MKPF-BUDAT,
         SHKZG LIKE MSEG-SHKZG,
         DMBTR LIKE MSEG-DMBTR,
         MBLNR LIKE MSEG-MBLNR,
         LGORT LIKE MSEG-LGORT,
       END OF ST_OPBAL.
DATA : OPBAL TYPE ST_OPBAL OCCURS 0 WITH HEADER LINE,
       TMP_OPBAL TYPE ST_OPBAL OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF BAL_NOREF OCCURS 0,
          MATNR LIKE MARA-MATNR,
          SHKZG LIKE MSEG-SHKZG,
          DMBTR LIKE MSEG-DMBTR,
       END OF BAL_NOREF.
DATA : BEGIN OF OPBAL2 OCCURS 0,
         SNO(3)      TYPE N,
         MATNR       LIKE MSEG-MATNR,
         MAKTX       LIKE MAKT-MAKTX,
         OP_BAL      LIKE MSEG-MENGE,
         OP_STKVAL   LIKE MSEG-DMBTR,   "NEW
         REC         LIKE MSEG-MENGE,
         T_OPBAL_REC LIKE MSEG-MENGE,
         REC_STKVAL  LIKE MSEG-DMBTR,   "NEW
         ISS         LIKE MSEG-MENGE,
         ISS_STKVAL  LIKE MSEG-DMBTR,   "NEW
         SALES       LIKE MSEG-MENGE,
         T_ISS       LIKE MSEG-MENGE,
         CL_BAL      LIKE MSEG-MENGE,
         BATCH       LIKE MSEG-CHARG,
         SUBCON      LIKE MSEG-MENGE,
         CL_STKVAL   LIKE MSEG-DMBTR,
       END OF OPBAL2.
DATA  SERNO(4) TYPE C.
DATA OPTOT  TYPE P DECIMALS 3.
DATA RECTOT TYPE P DECIMALS 3.
DATA ISSTOT TYPE P DECIMALS 3.
DATA TOTALL TYPE P DECIMALS 3.
DATA FLG        TYPE N.
DATA FLAG       TYPE N.
DATA STOCKVAL        TYPE MSEG-DMBTR.
DATA REC_STOCKVAL    TYPE MSEG-DMBTR.
DATA ISS_STOCKVAL    TYPE MSEG-DMBTR.
DATA CL_STKVAL       TYPE MSEG-DMBTR.
SELECTION-SCREEN BEGIN OF BLOCK X WITH FRAME.
     SELECT-OPTIONS: P_MATNR FOR MSEG-MATNR,
                     P_MGRP  FOR MARA-MATKL,
                     P_DATE FOR MKPF-BUDAT,
     P_PLANT FOR MSEG-WERKS DEFAULT  'NB01' OBLIGATORY NO INTERVALS
                                                NO-EXTENSION .
     SELECT-OPTIONS: P_STLOC FOR MSEG-LGORT NO INTERVALS NO-EXTENSION.
SELECTION-SCREEN END OF BLOCK X.
INITIALIZATION.
   REPID = SY-REPID.
   PERFORM FILL_FLDCAT USING IT_FLDCAT.
   PERFORM FILL_EVENTS USING IT_EVENTS.
   PERFORM FILL_LAYOUT USING GS_LAYOUT.
START-OF-SELECTION.
  CONCATENATE P_DATE-LOW6(2) '.' P_DATE-LOW4(2) '.' P_DATE-LOW+0(4)
  INTO FRM_DATE.
  CONCATENATE P_DATE-HIGH6(2) '.' P_DATE-HIGH4(2) '.' P_DATE-HIGH+0(4)
  INTO TO_DATE.
  CONCATENATE TEXT-003 FRM_DATE' TO : ' TO_DATE INTO DISPTEXT.
  CONCATENATE TEXT-004 P_PLANT-LOW ' Storage Location : ' P_STLOC-LOW
  INTO DISPTEXT2.
  PERFORM FILL_HEADER USING IT_LIST_HEADER.
  SELECT  A~MATNR
          F~MAKTX
          A~CHARG
          A~BWART
          A~MENGE
          A~ZEILE
          A~WERKS
          A~SOBKZ
          D~BUDAT
          A~SHKZG
          A~DMBTR
          A~MBLNR
          A~LGORT
          INTO TABLE OPBAL
   FROM MKPF AS D JOIN MSEG AS A
           ON DMBLNR = AMBLNR  AND
              DMJAHR = AMJAHR
        JOIN MARA AS E
           ON EMATNR = AMATNR
        JOIN MAKT AS F
           ON FMATNR = AMATNR
   WHERE   A~MATNR IN P_MATNR
     AND   A~WERKS IN P_PLANT
     AND   A~KZBEW IN (' ','B')
     AND   E~MATKL IN P_MGRP
     AND   A~BWART NOT IN ('541','542','321','322','121')
     AND   A~KZVBR NOT IN ('A')
     AND   D~BUDAT LE P_DATE-HIGH.
LOOP AT OPBAL WHERE BWART EQ '544' AND LGORT EQ ''.
   TMP_OPBAL = OPBAL.
   APPEND TMP_OPBAL.
ENDLOOP.
DELETE OPBAL WHERE ( BWART EQ '309' AND DMBTR EQ 0  ).
DELETE OPBAL WHERE ( BWART NE '543' AND LGORT EQ '' ).
LOOP AT TMP_OPBAL.
   OPBAL = TMP_OPBAL.
   APPEND OPBAL.
ENDLOOP.
STOCKVAL = 0.
SORT OPBAL BY MATNR BATCH BUDAT.
LOOP AT OPBAL.
  SELECT SINGLE LBLAB INTO MSLB-LBLAB FROM MSLB
                        WHERE MATNR = OPBAL-MATNR.
  IF OPBAL-BUDAT LT P_DATE-LOW.
     IF OPBAL-SHKZG = 'H'.
        OPTOT = OPTOT - OPBAL-MENGE.
     ELSEIF OPBAL-SHKZG = 'S'.
        OPTOT = OPTOT + OPBAL-MENGE.
     ENDIF.
For the duration   II part  *****************
  ELSEIF OPBAL-BUDAT IN P_DATE.
     IF OPBAL-SHKZG = 'H'.
        ISSTOT      = ISSTOT + OPBAL-MENGE.
     ELSEIF OPBAL-SHKZG = 'S'.
        RECTOT = RECTOT + OPBAL-MENGE.
     ENDIF.
  ENDIF.
AT END OF BATCH. " modified for chek
   READ TABLE OPBAL INDEX SY-TABIX.
   CLEAR BAL_NOREF. REFRESH BAL_NOREF.
   SELECT MATNR SHKZG SUM( DMBTR )
     INTO TABLE BAL_NOREF
     FROM BSIM
    WHERE BUDAT LT P_DATE-LOW  AND
          MATNR EQ OPBAL-MATNR AND
          BWTAR EQ OPBAL-BATCH AND
          BWKEY IN P_PLANT     AND
          BLART IN ('RE','WE','WA','PR')
    GROUP BY MATNR SHKZG.
   LOOP AT BAL_NOREF.
      IF BAL_NOREF-SHKZG = 'H'.
         STOCKVAL = STOCKVAL - BAL_NOREF-DMBTR.
      ELSE.
         STOCKVAL = STOCKVAL + BAL_NOREF-DMBTR.
      ENDIF.
   ENDLOOP.
   CLEAR BAL_NOREF. REFRESH BAL_NOREF.
   SELECT MATNR SHKZG SUM( DMBTR )
     INTO TABLE BAL_NOREF
     FROM BSIM
    WHERE BUDAT IN P_DATE AND
          MATNR EQ OPBAL-MATNR AND
          BWTAR EQ OPBAL-BATCH AND
          BWKEY IN P_PLANT     AND
          BLART IN ('RE','WE','WA','PR')
    GROUP BY MATNR SHKZG.
   LOOP AT BAL_NOREF.
      IF BAL_NOREF-SHKZG = 'H'.
         ISS_STOCKVAL = ISS_STOCKVAL + BAL_NOREF-DMBTR.
      ELSE.
         REC_STOCKVAL = REC_STOCKVAL + BAL_NOREF-DMBTR.
      ENDIF.
   ENDLOOP.
   " MSLB-LBLAB (STOCK WITH SUBCONTRACTOR).
   CL_STKVAL       = STOCKVAL + REC_STOCKVAL - ISS_STOCKVAL.
   TOTALL =  OPTOT + RECTOT - ISSTOT.
   IF OPTOT = '0'   AND RECTOT = '0'  AND ISSTOT = '0'.
      FLG = 1.
   ENDIF.
   IF FLG = 1.
      CLEAR FLG.
   ELSE.
      SERNO = SERNO + 1.
      OPBAL2-SNO         = SERNO.
      OPBAL2-MATNR       = OPBAL-MATNR.
      OPBAL2-MAKTX       = OPBAL-MAKTX.
      OPBAL2-OP_BAL      = OPTOT.
      OPBAL2-REC         = RECTOT.
      OPBAL2-T_OPBAL_REC = OPTOT + RECTOT.
      OPBAL2-ISS         = ISSTOT.
      OPBAL2-T_ISS       = ISSTOT.
      OPBAL2-CL_BAL      = TOTALL.
      OPBAL2-BATCH       = OPBAL-BATCH.
      OPBAL2-SUBCON      = MSLB-LBLAB.
      OPBAL2-OP_STKVAL   = STOCKVAL.
      OPBAL2-ISS_STKVAL  = ISS_STOCKVAL.
      OPBAL2-REC_STKVAL  = REC_STOCKVAL.
      OPBAL2-CL_STKVAL   = CL_STKVAL.
      APPEND OPBAL2.
   ENDIF.
  OPTOT = 0.
  RECTOT = 0.
  ISSTOT = 0.
  STOCKVAL = 0.
  ISS_STOCKVAL = 0.
  REC_STOCKVAL = 0.
  CL_STKVAL    = 0.
ENDAT.
ENDLOOP.
  WA_SORT-SPOS = 1.
  WA_SORT-FIELDNAME = 'MATNR'.
  WA_SORT-UP = 'X'.
WA_SORT-SUBTOT = 'X'.
APPEND WA_SORT TO IT_SORT.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_CALLBACK_PROGRAM = REPID
      IT_FIELDCAT        = IT_FLDCAT
      IT_EVENTS          = IT_EVENTS
      IS_LAYOUT          = GS_LAYOUT
      IT_SORT            = IT_SORT
    TABLES
      T_OUTTAB           = OPBAL2.
FORM FILL_FLDCAT USING P_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
   PERFORM FILL_PARAM_FLDCAT USING  1 'SNo'          'SNO'       ' ' 'X'
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  2 'Material No.' 'MATNR'     ' ' 'X'
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  3 'Description'  'MAKTX'     ' ' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  4 'Op.Bal'      'OP_BAL'     'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  5 'Op.Stock Val' 'OP_STKVAL' 'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  6 'Receipts'     'REC'       'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  7 'Total'     'T_OPBAL_REC'  'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  8 'Rect.Val.' 'REC_STKVAL'   'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING  9 'Issues'    'ISS'          'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING 10 'Iss. Val.' 'ISS_STKVAL'   'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING 11 'Cl. Bal.'     'CL_BAL'    'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING 12 'Cl.Stock Val' 'CL_STKVAL' 'X' ' '
   'OPBAL2' P_FLDCAT.
   PERFORM FILL_PARAM_FLDCAT USING 13 'BATCH '       'BATCH'     ' ' ' '
   'OPBAL2' P_FLDCAT.
ENDFORM.
FORM FILL_PARAM_FLDCAT USING VALUE(P_COL) VALUE(P_TEXT) VALUE(P_FLDNAME)
                       VALUE(P_DOSUM) VALUE(P_NOZERO) VALUE(P_TABNAME)
                       PP_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
   DATA : WA_FLDCAT TYPE SLIS_FIELDCAT_ALV.
   CLEAR WA_FLDCAT.
     WA_FLDCAT-COL_POS   = P_COL.
     WA_FLDCAT-SELTEXT_M = P_TEXT.
     WA_FLDCAT-FIELDNAME = P_FLDNAME.
     WA_FLDCAT-TABNAME   = P_TABNAME.
     WA_FLDCAT-DO_SUM    = P_DOSUM.
     WA_FLDCAT-NO_ZERO   = P_NOZERO.
   APPEND WA_FLDCAT TO PP_FLDCAT.
ENDFORM.
FORM FILL_HEADER USING P_IT_LIST_HEADER TYPE SLIS_T_LISTHEADER.
  DATA: LS_LINE TYPE SLIS_LISTHEADER.
  CLEAR LS_LINE.
  LS_LINE-TYP = 'S'.
  LS_LINE-INFO = TEXT-002.
  APPEND LS_LINE TO P_IT_LIST_HEADER.
  CLEAR LS_LINE.
  LS_LINE-TYP = 'S'.
  LS_LINE-INFO = DISPTEXT.
  APPEND LS_LINE TO P_IT_LIST_HEADER.
  CLEAR LS_LINE.
  LS_LINE-TYP = 'S'.
  LS_LINE-INFO = DISPTEXT2.
  APPEND LS_LINE TO P_IT_LIST_HEADER.
ENDFORM.
FORM FILL_EVENTS USING P_IT_EVENTS TYPE SLIS_T_EVENT.
   DATA LS_EVENT TYPE SLIS_ALV_EVENT.
   MOVE 'TOP_OF_PAGE' TO LS_EVENT-FORM.
   MOVE 'TOP_OF_PAGE' TO LS_EVENT-NAME.
   APPEND LS_EVENT TO P_IT_EVENTS.
ENDFORM.
FORM TOP_OF_PAGE.
  CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
   EXPORTING
     IT_LIST_COMMENTARY       = IT_LIST_HEADER.
ENDFORM.
FORM FILL_LAYOUT USING P_GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
   P_GS_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.
   P_GS_LAYOUT-ZEBRA             = 'X'.
   P_GS_LAYOUT-FLEXIBLE_KEY      = 'X'.
ENDFORM.
FOR TESTING PURPOSE.
*SORT OPBAL BY BUDAT.
*CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
   EXPORTING
     I_CALLBACK_PROGRAM = REPID
     IT_FIELDCAT        = IT_FLDCAT
     IT_EVENTS          = IT_EVENTS
   TABLES
     T_OUTTAB           = OPBAL.
*FORM FILL_FLDCAT USING P_FLDCAT TYPE SLIS_T_FIELDCAT_ALV.
  PERFORM FILL_PARAM_FLDCAT USING  1 'MBLNR'        'MBLNR'
  'OPBAL' P_FLDCAT.
  PERFORM FILL_PARAM_FLDCAT USING  2 'CREDIT/DEBIT' 'SHKZG'
  'OPBAL' P_FLDCAT.
  PERFORM FILL_PARAM_FLDCAT USING  3 'MOV.TYP.'     'BWART'
  'OPBAL' P_FLDCAT.
  PERFORM FILL_PARAM_FLDCAT USING  4 'ST.LOC.'     'LGORT'
  'OPBAL' P_FLDCAT.
  PERFORM FILL_PARAM_FLDCAT USING  5 'STOCK VAL'    'DMBTR'
  'OPBAL' P_FLDCAT.
  PERFORM FILL_PARAM_FLDCAT USING  6 'POS.DATE'     'BUDAT'
  'OPBAL' P_FLDCAT.
*ENDFORM.

Similar Messages

  • Report for stock in transit datewise

    I need stock in transit datewise. Is there any report possible for that ? Which table and fields should I refer. please revert.
    Regs,
    Appie

    Hi,
    T.Code: MB5T can be used for Report for stock in transit, but date wise u can't get here. U have to develop areport or by querry u can develop a report.
    U can get date (MKPF-BUDAT) wise details by giving movement type in MSEG table u get all the details in the tables.
    Regards,
    Chinna

  • PR and PO should be display in IWBK report for stock item.

    Hi Exterts,
    Our client requirement is to display PR and PO number in IWBK report for stock item as well.
    I know PR and PO can be display in IWBK report for non-stock item but how we can display PR and PO for stock item,as PR is generated through MRP for stock item.
    Please share your ideas on this.
    Regards
    Vishu

    Vishu,
    In typical MRP settings you "procure to stock" not "procure to order".
    This means that there is no direct link between the PM/CS orders and any PR/POs created via MRP.
    Subsequently you will not be able to show this data in IWBK.
    However, we are currently designing a customer-specific report similar to IWBK that also counts the number of open POs for a given material on a PM/CS work order. The user can then navigate to ME2M (PO list) or MD04 (stock requirements list) to get further details.
    PeteA

  • MULTI LEVEL REPORT FOR STOCK TRANSPORT PURCHASE ORDER

    Hi,
    I will have lot of stock transport purchase orders,like md4c transaction where we get multilevel report for sale order/production order,is there any report for stock transport purchase orders.its urgent kindly help

    goto purchase order history tab
    you can see all the details of PO-deluvery-GI, GR, imvoice. Click on delivery, you can see the billing document throughdocument flow button.
    This function is not availilable for production order, hence we have MD4c.

  • Report for stock transfer from plant to plant

    Hi,
      Is there any standard report for  stock transfer from plant to plant .
      If not is there any enhancements to get the above report.
    Regards,
    Ravindranath.

    Hi Ravi,
    U can use the tcode MB51 and their u can give the input as 301 if it is 1 step in the mvt type or use 303 and 305 for 2 step transfer. and generate the report.
    if u want the list of stock transport orders then use tcode ME2N and the input parameter as  item category "U" and generate the report.
    hope it wud have answered ur question
    Reward if useful
    Shawn

  • Standard Report for stock Aging

    Hello all,
    can anyone plz let us know that is there any standard report in SAP for stock aging? actually i have to see the materials quantity whose 311 movement not done after 321 and also from how many days it is pending.
    Kindly help and tell how can i find those materials quantity, while user also do 311 for partial quantity?
    Regards.

    Hi  @ABAP@
    Check the followings...
    MB24 - Reservations for Material
    MB25 - Reservations for Account Assignment
    MB51 - Material Document List
    MB52 - List of Warehouse Stocks on Hand MB53 - Display Plant Stock Availability
    MB54 - Consignment Stocks
    MB56 - Analyze Batch Where-Used List
    MB57 - Build Up Batch Where-Used List
    MB58 - Consgmt and Ret. Packag. at Customer
    MB59 - Material Document List
    MB5B - Stocks for Posting Date
    MB5C - Pick-Up List
    MB5L - List of Stock Values: Balances
    MB5M - ShL.exp/prod.date
    MB5S - Display List of GR/IR Balances
    MB5W - List of Stock Values
    MB9A - Analyze Archived Material Documents
    MBAL - Material Documents: Read Archive
    MBGR - Display Material Documents by Movement Reason
    MBSI - Find Inventory Sampling
    MBSM - Display Cancelled Material Documents
    MMBE - Stock Overview
    MD07 - Current Material Overview
    MR51 - Material Line Items
    MRKO - Settle Consignment/Pipeline Liabilities
    MB5T - Stock in transit CC

  • SAP Standard Report for Stock Balances

    Hi All,
    Do we have a standard SAP report that gives the output in this format (or something close to this)
    Date     Stock     Plant 1               Plant 2          
              Material 1     Material 2     Material 3     Material 1     Material 2     Material 3
    1/1/2008     Opening Stock                              
         GR                              
         GI                              
         Closing Stock                              
    1/2/2008     Opening Stock                              
         GR                              
         GI                              
         Closing Stock                              
    1/3/2008     Opening Stock                              
         GR                              
         GI                              
         Closing Stock                              
    Regards
    Tom

    Hi Jack,
    As per your report requirement, there is no standard transaction available in SAP.
    You have develop Z- Report for your requirement.
    But keeping in mind the follwoing constarints
    1) If it is a huge number of materials, Then the report will hours together. It may be lead to performance issue of the System. Because it has to get huge data from different tables as per you logic.
    2) The report is not suitable for print. Because it will run pages together.Since you are including Opening balance, GR details, GI details and Closing balance for each materail.
    Thanks & Best Regards
    Girisha M S

  • Standard stock report for Stock Commitments

    Hi gurus,
    Is there any standard report available to see the  Stock  like Reserved qty,stock transfer,scheduled for delivery against each batch in a same transaction like MMBE.
    In MMBE by selecting the Read Stock Commitments indicator we can get.
    the constrain is here we can able to see against only one material.
    if i goto MB52 i am not getting the above said stock type.
    Expecting Your Valuable Suggestions!
    Regards,
    D.K.Vijaya Bhaskar

    MMBE can be used as a report for individual material & MB5B is very useful Transaction Code as stock report for multiple material. It requires to be explored more & more, so that most of the stock report as per requirement is avialble.
    Regards,
    Rajesh Banka
    Reward points if helpful.

  • Reg :  Z report for Stock on given date

    Dear ABAP Guru's,
                                   Iam in need of urgent report inorder to find Stock on given(particular) single date but not SAP standard report.That Stock Value should match the MC.9 value.Pls help me

    Hi,
    This code may help you.
    *& Report  ZDH_ITC_STOREP
    REPORT  ZDH_ITC_STOREP.
    TABLES: T001L.
    type-pools slis.
    DATA: GT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
    DATA: GT_HEADER TYPE SLIS_T_LISTHEADER.
    DATA: GS_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DATA: GT_EVENTS TYPE SLIS_T_EVENT.
    TYPES: BEGIN OF TY_FINAL,
           MATNR TYPE MCHB-MATNR,
           MATDES TYPE MAKT-MAKTX,
           BATNO TYPE MCHB-CHARG,
           UMIL TYPE MCHB-CLABS,
           UCFC TYPE MCHB-CLABS,
           BMIL TYPE MCHB-CSPEM,
           BCFC TYPE MCHB-CLABS,
           TMIL TYPE MCHB-CLABS,
           TCFC TYPE MCHB-CLABS,
           END OF TY_FINAL.
    TYPES: BEGIN OF TY_MCHB,
          MATNR TYPE MCHB-MATNR,      " Material Number
          CHARG TYPE MCHB-CHARG,      " Batch Number
          CLABS TYPE MCHB-CLABS,      " Valuated Unrestricted-Use Stock
          CSPEM TYPE MCHB-CSPEM,      " Blocked Stock
          UCFC TYPE MCHB-CLABS,
          bcfc TYPE MCHB-CLABS,
          END OF TY_MCHB.
    *TYPES: BEGIN OF TY_MARA,
    *     MATNR TYPE MARA-MATNR,
    *     END OF TY_MARA.
    TYPES: BEGIN OF TY_MAKT,
         MATNR TYPE MAKT-MATNR,       " Material Number
         MAKTX TYPE MAKT-MAKTX,       " MATERIAL DESCRIPTION
         END OF TY_MAKT.
    TYPES:BEGIN OF TY_MARM,
         MATNR TYPE MARM-MATNR,       "MATERIAL NUMBER
         UMREN TYPE MARM-UMREN,       "Denominator for conversion to base units of measure
         UMREZ TYPE MARM-UMREZ,       "Numerator for Conversion to Base Units of Measure
       END OF TY_MARM.
    DATA: IT_FINAL TYPE STANDARD TABLE OF TY_FINAL,
          WA_FINAL TYPE TY_FINAL.
    DATA: IT_MCHB TYPE STANDARD TABLE OF TY_MCHB,
          WA_MCHB TYPE TY_MCHB.
    *DATA: IT_MARA TYPE STANDARD TABLE OF TY_MARA,
    *      WA_MARA TYPE TY_MARA.
    DATA: IT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
          WA_MAKT TYPE TY_MAKT.
    DATA: IT_MARM TYPE STANDARD TABLE OF TY_MARM,
          WA_MARM TYPE TY_MARM.
    data: atot, btot type MCHB-CLABS.
    PARAMETERS: PA_FACT TYPE T001W-WERKS OBLIGATORY,                  "FACTORY
                PA_DATE TYPE SY-DATUM OBLIGATORY.                     "DATE
    SELECT-OPTIONS: SO_STLO FOR T001L-LGORT OBLIGATORY.               " STORAGE LOCATION
    * GETTING THE MATERIALS
    SELECT MATNR CHARG CLABS CSPEM
      FROM MCHB
      INTO TABLE IT_MCHB
      WHERE WERKS = PA_FACT
      AND LGORT IN SO_STLO.
    * GETTING THE BRAND DESCRIPTION FROM THE ABOVE SELECTED MATERIAL
    SELECT MATNR MAKTX
      FROM MAKT
      INTO TABLE IT_MAKT
      FOR ALL ENTRIES IN IT_MCHB
      WHERE MATNR = IT_MCHB-MATNR
      AND SPRAS = 'EN'.
    * GETTING THE BATCH CODE FOR THE ABOVE MATERIAL AND BRAND
    SELECT MATNR UMREN UMREZ
      FROM MARM
      INTO TABLE IT_MARM
      FOR ALL ENTRIES IN IT_MCHB
      WHERE MATNR = IT_MCHB-MATNR.
    * CALCULATING THE TOTALS OF BLOCKED AND UNRESTRICTED QTY
    LOOP AT IT_MCHB INTO WA_MCHB.
      READ TABLE IT_MARM INTO WA_MARM WITH KEY MATNR = WA_MCHB-MATNR.
      WA_MCHB-ucfc  = ( ( WA_MARM-UMREN / WA_MARM-umrez ) * wa_mchb-clabs ).
        WA_MCHB-bcfc = ( ( wa_marm-umren / wa_marm-umrez ) * wa_mchb-cspem ).
    *  WA_MCHB-ucfc = atot.
    *  WA_MCHB-bcfc = btot.
      modify IT_MCHB from WA_MCHB TRANSPORTING ucfc bcfc WHERE MATNR = WA_MCHB-MATNR.
      READ TABLE it_makt into wa_makt with key MATNR = WA_MCHB-matnr.
      WA_FINAL-matnr = WA_MCHB-MATNR.
      WA_FINAL-MATDES = wa_makt-maktx.
      WA_FINAL-BATNO = wa_mchb-CHARG.
      WA_FINAL-UMIL = wa_MCHB-CLABS.
      wa_final-UCFC = WA_MCHB-ucfc.
      wa_final-bcfc = WA_MCHB-bcfc.
      wa_final-bmil = WA_MCHB-CSPEM.
      WA_FINAL-tmil = WA_MCHB-clabs + WA_MCHB-CSPEM.
      WA_FINAL-tcfc = WA_MCHB-ucfc + WA_MCHB-bcfc.
    append wa_final to IT_FINAL.
    ENDLOOP.
    perform buildheader USING GT_HEADER[].
    PERFORM FIELDCATINIT USING GT_FIELDCAT[].
    perform alvdisplay.
    PERFORM build_layout USING GS_LAYOUT.
    *&      Form  buildheader
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM buildheader USING RT_HEADER TYPE SLIS_T_LISTHEADER..
    DATA: TP TYPE SLIS_LISTHEADER.
      DATA: TEXT(20) TYPE C,
            DT TYPE SY-DATUM.
      TP-TYP = 'H'.
      TP-INFO = 'STOCK REPORT '.
      APPEND TP TO RT_HEADER.
      CLEAR TP.
      WRITE SY-DATUM TO DT DD/MM/YYYY.
      CONCATENATE 'DATE :' DT INTO TEXT.
      TP-TYP = 'S'.
      TP-INFO = TEXT.
      APPEND TP TO RT_HEADER.
      CLEAR TP.
    ENDFORM.                    " buildheader
    *&      Form  alvdisplay
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM alvdisplay .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                 = 'ZDH_ITC_STOREP'
    *   I_CALLBACK_PF_STATUS_SET          = ' '
    *   I_CALLBACK_USER_COMMAND           = ' '
    *   I_CALLBACK_TOP_OF_PAGE            = ' '
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
    *   I_GRID_TITLE                      =
    *   I_GRID_SETTINGS                   =
       IS_LAYOUT                          = GS_LAYOUT
       IT_FIELDCAT                        = GT_FIELDCAT[]
    *   IT_EXCLUDING                      =
    *   IT_SPECIAL_GROUPS                 =
    *   IT_SORT                           =
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
    *   I_SAVE                            = ' '
    *   IS_VARIANT                        =
    *   IT_EVENTS                         =
    *   IT_EVENT_EXIT                     =
    *   IS_PRINT                          =
    *   IS_REPREP_ID                      =
    *   I_SCREEN_START_COLUMN             = 0
    *   I_SCREEN_START_LINE               = 0
    *   I_SCREEN_END_COLUMN               = 0
    *   I_SCREEN_END_LINE                 = 0
    *   I_HTML_HEIGHT_TOP                 = 0
    *   I_HTML_HEIGHT_END                 = 0
    *   IT_ALV_GRAPHICS                   =
    *   IT_HYPERLINK                      =
    *   IT_ADD_FIELDCAT                   =
    *   IT_EXCEPT_QINFO                   =
    *   IR_SALV_FULLSCREEN_ADAPTER        =
    * IMPORTING
    *   E_EXIT_CAUSED_BY_CALLER           =
    *   ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = IT_FINAL
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.                    " alvdisplay
    *&      Form  FIELDCATINIT
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM FIELDCATINIT USING FINIT TYPE SLIS_T_FIELDCAT_ALV.
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
      LS_FIELDCAT-FIELDNAME       =  'MATNR'.
      LS_FIELDCAT-SELTEXT_L       =  'MATERIAL NO'.
      LS_FIELDCAT-KEY        =  'X'.
      LS_FIELDCAT-JUST = 'L'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'MATDES'.
      LS_FIELDCAT-SELTEXT_L       =  'BRAND'.
      LS_FIELDCAT-KEY        =  'X'.
      LS_FIELDCAT-JUST = 'L'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'BATNO'.
      LS_FIELDCAT-SELTEXT_L       =  'BATCH NO'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'UMIL'.
      LS_FIELDCAT-SELTEXT_L       =  'RESTRICTED'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'UCFC'.
      LS_FIELDCAT-SELTEXT_L       =  'UCFC'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'BMIL'.
      LS_FIELDCAT-SELTEXT_L       =  'BLOCKED'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'BCFC'.
      LS_FIELDCAT-SELTEXT_L       =  'BCFC'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'TMIL'.
      LS_FIELDCAT-SELTEXT_L       =  'TOTAL MIL'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME       =  'TCFC'.
      LS_FIELDCAT-SELTEXT_L       =  'TCFC'.
      APPEND LS_FIELDCAT TO FINIT.
      CLEAR LS_FIELDCAT.
    ENDFORM.                    " FIELDCATINIT
    *&      Form  BUILDLAYOUT
    *       text
    *      -->P_GS_LAYOUT[]  text
    FORM BUILD_LAYOUT USING RS_LAYOUT TYPE SLIS_LAYOUT_ALV.
      RS_LAYOUT-NO_INPUT = 'X'.
      RS_LAYOUT-ZEBRA = 'X'.
      RS_LAYOUT-COLWIDTH_OPTIMIZE = ' '.
      RS_LAYOUT-NO_COLHEAD = ' '.
      RS_LAYOUT-NO_VLINE = ' '.
      RS_LAYOUT-INFO_FIELDNAME = 'WS_COLOR'.
    ENDFORM.
                        " BUILDLAYOUT
    HTH
    Regards,
    Dhruv Shah

  • Re:Query for Stock Statement for a particular item..!!!!

    Dear SAP Experts,
    I need a stock statement query  for a particular item which contains:
    1.ItemCode
    2.Item Description
    3.Item Price
    4.Opening
    5.Receipts
    6.Issues
    7.Closing
    8. Value
    The selection criteria are:
    1.Warehouse code
    2.Item Name
    3.Posting Date
    Plz give me a good solution for this issue.
    With Regards,
    Revathy

    Check this
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    set @FromDate =
        (Select min(S0.Docdate) from OINM S0 where S0.Docdate >='[%0]')
    set @ToDate =
        (Select max(S1.Docdate) from OINM S1 where S1.Docdate <='[%1]')
    select * from
        SELECT T0.itemcode,
        min(T0.Dscription) as 'Item Description',
        min(B1.ItmsGrpNam) as 'Item Group', W1.Whscode, C1.Location,
        (isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate ),0)-
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate<@FromDate),0)
        ) as [Opening Stock],
        isnull((
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode
            and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate
            and O1.docdate<=@ToDate and O1.inqty>0
            and O1.transtype in (20,18)),0
        ) as [Purchase Quantity],
        isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate
            and O1.outqty>0 and O1.transtype in (21,19)),0
        ) as [Purchase Return Quantity],
       isnull((
            Select sum(isnull(outqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.outqty>0
            and O1.transtype in (13,15)),0
        ) as [sale Quatity],
        (isnull
            Select sum(isnull(inqty,0))
            from OINM O1
            where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
            and O1.docdate<=@ToDate),0
            isnull((
                Select sum(isnull(outqty,0))
                from OINM O1
                where O1.itemcode=T1.itemcode and O1.Warehouse=W1.Whscode
                and O1.docdate<=@ToDate),0)
        ) as [Closing Stock]
        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
        INNER JOIN OWHS W1 ON T2.WhsCode = W1.WhsCode
        INNER JOIN OLCT C1 ON W1.Location=C1.Code
        Group by T1.itemcode, T0.Itemcode, W1.WhsCode, C1.Location
    ) a
    where (a.[Opening Stock]
            +a.[Purchase Quantity]
            + a.[Purchase Return Quantity]
            +a.[sale Quatity]+a.[Closing Stock]
           ) !=0
    Regards,
    Bala

  • Inventory report for stock category B

    Hi everyone,
    We are trying to generate a customer stock inventory report with stock category B. The table MARD is not displaying any values annwe also looked at table MKOL. Its not giving us any. How do i get the inventory report for this stock type B. Kindly Advise.

    it is customer owned stock. We receiver materials from customer for repair and we recondition them and we give it back. for this we maintain it in stock type B. it is specifically used in aerospace industries. We want to make an inventory report for this customer owned stock in our inventory . i am unable to get the table. Kindly advise

  • Query for Stock Statement

    Hi Members,
    My customer needs an report "Stock Statement" with selection criteria as Date, ItemGroupwise and warehouse wise with following columns namely.
    Itemcode
    ItemName
    Opening Stock Qty
    Receipt Qty
    Issue Qty.
    Price.
    Kindly help me in this regard,
    Thanks in advance,
    Venkatesh.R

    Hi!
    Check these threads
    Re: Item Stock Report (2nd page)
    Item Stock Report

  • Report for stock value at Warehouselevel

    Hi
    I need to generate  a report of stock value at the warehouse level.
    please let me know the tables to be linked to get the report.
    Thanks

    Hi Nainar,
    You can use MB52 and if you get the list you can use 'sum' icon to get the total value (on the selection screen you can set wether SAP should display values or not).
    You can also use MB5L, MC.A transactions. If you want to check the stock only for one material you can check it in material master record on Accounting1.
    BR
    Csaba

  • Z report for Stock agening

    Hi Expert
    i need to create a new Zreport for Stock Agening  that i have input.
    Material
    Posting Date
    Batch
    storage Location
    Plant
    Company code.
    but i dont know which output must come.
    Regard
    Nabil
    Edited by: sayednabil on Dec 10, 2010 8:28 AM

    Hi Rakesh,
    I Have got the same requirements As u got                                                                               
    Plant  St Loc-- batch--material-Posting Date( QTY)closing stock- 0-30 30-60 90-180 
    I am struggling from last 1 week i am stuck at getting posting date of the batch if i get posting date of the batch then i dont get total QTy of stock of that particular Batch.
    Client Requirement is to capture batch created date and get the qty of that batch till date (user entry date) and  calculate  age of stock from batch created date (batch)
    Batch                       qty         movement                  posting date       
    100000785             100           101                      21.02.2011
    100000785              50              261                     29.05.2011
    on 30th may stock should be 50 in hand   and age of the stock till today is 3months approx(from first posting date of batch created
    If u can help me out on hot to design please step by step   will be much appericated
    CoCdPlantStoLoc-Batch-Material-DateClsStk- 0-90-91-180 181-360-->360
    10001100-1000-----0001 -1234--31.12.1010243--
    1
    10001100-1000-----0002 -1234--31.12.1010332--
    2
    thanks
    Pavan

  • WM - Report for stock with storage time

    Hi Guru,
    How can I get a report with material_name, quantity, and their storage time?
    e.g. part A putaway on 2008/1/1,  100 EA
    The report will show:
    material    Qty          storage time
    part A     100 EA     (2008/12/10 - 2008/1/1)
    We want to find out the stock which have a long storage time - dead stock.
    Thanks,

    Hi,
    Information that comes from WM can be misleading. Even if you have the stock long ago, WM movements may happen within the WH for that material (and this does not mean IM movement but the quant-data in WM may change).
    I think you should consider the use of dead stock and slow moving stock reports (MC46 , MC50). MC.A report can also be used to get information on goods movements.
    Of course, depending on your WM strategy and processes you can extract the necessary information. E.g. in LX02 you can see the GR date, SLED/BBD, the already mentioned last movement, last removal, etc - check the layout.
    Regards,
    Csaba

Maybe you are looking for

  • I can't get my TC to connect to the Internet

    I just bought a new time capsule to back up my macs, well I can't get it to connect to the internet to send out wireless internet signal. Both my networks appear, 1. "actiontec" which is my qwest gt701-wg wireless internet signal I am using right now

  • How to save files on the server?

    I want to save a log on the server, how can I do this using Oracle? In SQL Server I used the "bcp" command. Thanks.

  • Recovering from a stolen laptop.

    Hi all, I'm posting this on my wife's account, since she owns the iPod in question, yet I'm lumped with trying to fix the thing. For the fourth time, we've been broken into and on this occasion lost the laptop to which her iPod (which was not stolen)

  • Oracle Time and Labor

    We are in the process in implementing Oracle Time and labor to integrate with Oracle Project.I need some information on the Key immplemenation steps especcially with the steps to recoord Time in hours and time in Days Keep requirement as per how Pref

  • IPod Sync Problems after trying iCloud

    I tried iCloud but decided not to use it. After I cancelled it, my ipods will not sync with my PC or iTunes. The computer doesn''t recoginze them. Does anyone know the solution to this problem? I have tried many of the proposed solutions posted. My i