Return to vendot fron SAP opening stock

Hi Friends,
We want to return few raw material with excise to the vendor, the problem is the receipts are made before the go-live and shown as opening stock in SAP. What will be the procedure to return to vendor and how to nullify the cenvat credits already availed.
Pls reply asap.
Ajit patro

Hi,
Since you have posted the EI (excise invoice), perform vendor returns (use transaction migo,select return delivery from the drop down) which creates a new material document and then post the EI again whose status will be set to 'In process'.
Hope it suffices.
Cheers,
Satish

Similar Messages

  • Negative Balance in Opening Stock & Closing Stock

    Dear Experts,
                        Below the query which i used to get the Opening Stock,Purchase,Issue,Return and closing stock. Here i face some problem that i get negative inventory for some items and the same has been checked in inventory audit report but there it is showing correct value.And also i understand that those items which shows negative inventory in Opening and closing is previously got changed in Item group after some transactions.Can any one help me to sort out this issue ?
    Declare @FromDate Datetime
    Declare @ToDate Datetime
    Declare @ItmsGrpNam varchar(100)
    select @FromDate = min(S0.Docdate) from dbo.OINM S0 where S0.Docdate >= '[%0]'
    select @ToDate = max(S1.Docdate) from dbo.OINM s1 where S1.Docdate <= '[%1]'
    select @ItmsGrpNam = max(s2.ItmsGrpNam) from dbo.OITB S2 Where S2.ItmsGrpNam = '[%2]'
    Select distinct a.Itemcode, max(a.Dscription) as ItemName, (Select i.InvntryUom from OITM i where i.ItemCode=a.Itemcode) as UOM,a.InvntAct,
    (isnull(( Select distinct sum(isnull(inqty,0)) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.DocDate<=@FromDate ),0)- isnull(( Select sum(isnull(outqty,0)) from OINM O1
      where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.DocDate<=@FromDate),0)) as [Opening Stock],
    (isnull((Select distinct isnull(sum(round(TransValue,0)),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.DocDate<=@FromDate ),0)) as [Opening Stock Value],
    isnull((Select ISNULL((sum(isnull(inqty,0))),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.transtype in (20,18)),0) as [Purchase Quantity],
      isnull((Select isnull(sum(round(TransValue,0)),0) from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.InQty>=0 and O1.JrnlMemo not like '%cancellation%'
      and O1.transtype in (20,18)),0 ) as [Purchase Value],
    isnull((Select sum(isnull(OutQty,0))from OINM O1 where O1.itemcode=a.ItemCode AND O1.InvntAct = a.InvntAct
      and  O1.ApplObj = '202' and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.OutQty>0 and
      O1.transtype = '60'),0) as [Production Issue Quantity],
    isnull((Select isnull(sum(round(TransValue,0)),0)from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
            and  O1.ApplObj = '202' and O1.docdate>=@FromDate and O1.docdate<=@ToDate and O1.OutQty>0
             and O1.transtype  = '60'),0) as [Production Issue Value],
    isnull((Select sum(isnull(Inqty,0)) from OINM O1 inner join OIGN G1 on O1.BASE_REF = G1.DocNum inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
            where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = G2.ItemCode
            and  G2.BaseType = '202' and G2.TranType is null and O1.docdate>=@FromDate
            and O1.docdate<=@ToDate and O1.Inqty>0 and O1.transtype = '59'),0) as [Goods Receipt Return Quantity],
    isnull((Select sum(isnull(Inqty,0)) from OINM O1
      inner join OIGN G1 on O1.BASE_REF = G1.DocNum
      inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
      --inner join OITM a on a.itemcode= o1.ItemCode
      --inner join OACT c on c.AcctCode = o1.InvntAct
      where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = a.ItemCode
      and G2.LineNum = O1.DocLineNum and G2.BaseType = '202' and g2.TranType is null
      and O1.docdate >= @FromDate and o1.DocDate <= @ToDate
      and O1.Inqty>0 and O1.transtype = '59'),0)as [Goods Receipt Return Quantity_1],
    isnull((Select sum(round(TransValue,0))from OINM O1 inner join OIGN G1 on O1.BASE_REF = G1.DocNum inner join IGN1 G2 on G1.DocEntry=G2.DocEntry
            where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and O1.ItemCode = G2.ItemCode
            and  G2.BaseType = '202' and G2.TranType is null and O1.docdate>=@FromDate
            and O1.docdate<=@ToDate and O1.Inqty>0 and O1.transtype = '59'),0) as [Goods Receipt Return Value],
    (isnull((Select distinct isnull(sum(isnull(inqty,0)),0)from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.DocDate<=@ToDate),0)- isnull((Select isnull(sum(isnull(outqty,0)),0) from OINM O1
      where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct and
      O1.DocDate<=@ToDate),0)) as [Closing Stock],
    (isnull (( Select distinct isnull(sum(round(TransValue,0)),0)from OINM O1 where O1.itemcode=a.itemcode AND O1.InvntAct = a.InvntAct
      and O1.DocDate<=@ToDate),0)) as [Closing Stock Value],
    (Select distinct i.LastPurDat from OITM i where i.ItemCode=a.Itemcode) as 'Last Purchase Date',
    (Select distinct b.ItmsGrpNam from OITB b where b.ItmsGrpCod = I1.ItmsGrpCod) as 'Group Name'
      from (Select distinct N1.Itemcode, N1.Dscription, isnull((sum(N1.inqty)),0)-isnull((sum(n1.outqty)),0) as OpeningBalance,
      isnull((sum(N1.Transvalue)),0) as OpeningValue,n1.InvntAct,0 as INq,
      0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
      inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
      inner join OACT c on c.AcctCode = n1.InvntAct
      Where N1.DocDate <=@FromDate and i.ItemCode = n1.ItemCode and b.ItmsGrpNam = @ItmsGrpNam and N1.Transtype <> '67'
      Group By N1.ItemCode,N1.Dscription,n1.InvntAct
    Union
      select distinct N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,
      n1.InvntAct,sum(N1.inqty) , 0 as OUT From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
      inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
      inner join OACT c on c.AcctCode = n1.InvntAct
      Where N1.DocDate >= @FromDate and N1.DocDate<= @ToDate and N1.Inqty >0 and n1.ItemCode = i.ItemCode
      and b.ItmsGrpNam = @ItmsGrpNam and N1.Transtype <> '67'
      Group By N1.ItemCode,N1.Dscription,n1.InvntAct
    Union
      select distinct N1.Itemcode, N1.Dscription, 0 as OpeningBalance,0 as OpeningValue,n1.InvntAct,0,sum(N1.outqty) as OUT
      From dbo.OINM N1 inner join OITM i on i.ItemCode = N1.ItemCode
      inner join OITB b on b.ItmsGrpCod = i.ItmsGrpCod
      Where N1.DocDate >= @FromDate and N1.DocDate <=@ToDate
      and N1.OutQty > 0 and  b.ItmsGrpNam = @ItmsGrpNam and n1.itemcode = i.itemcode and N1.Transtype <> '67'
      Group By N1.ItemCode,N1.Dscription,n1.InvntAct)a,dbo.OITM I1 ,OITB b1
      where a.ItemCode=I1.ItemCode and I1.ItmsGrpCod = b1.ItmsGrpCod
      Group By a.Itemcode ,I1.ItmsGrpCod , b1.ItmsGrpNam,a.InvntAct
      Having sum(a.OpeningBalance) + sum(a.INq) + sum(a.OUT) > 0
      Order By a.Itemcode
    Thanks & Regads,
    Bhoopathi.K

    Hi,
    Please check SAP notes for why negative values appeared above report.
    2003493 - Stock Ageing Report Displays Negative Inventory
    Values
    1407192 - Negative Stock Handling
    Thanks & Regards,
    Nagarajan

  • Opening stock and closing stock required

    hi experts,
                  i am preparing daily report for material consumption .where i am getting BOM consumption for each material .
    material    opening-stock      issues      closing-stock
    material1
    item1       1000                    1                    999
    item2        10                       2                      8
    material2
    item1        999                   2                    997
    item2        20                     3                     17
    material3
    item1       997                   2                     995
    item3       30                    5                        25
    this is a report for daily consumption of material.
    but i want report for each material like this
    item1             1000           5ie(221)         995
    item2               20              3                         17
    item3              30                5                      25
    what is the logic for getting thsi output.
    thanks
    mani

    check this sample code.
    https://wiki.sdn.sap.com/wiki/pages/viewpage.action?pageId=15856
    Regards
    Peram

  • Opening Stock and Closing Stock

    Hi,
      I have one requirement to get a opening stock and closing stock of all materials,  based on the plant date and mat type.
    Could u tell me the flow of tables one by one
    Its is possible to get the opening stock and closing stock of all materials.
    Please Guide Me.
    Thanks & Regards,
        Dhanush.S.T

    go through this....
    *& Report  Z_OPEN_CLOSE                                                *
    REPORT  Z_OPEN_CLOSE MESSAGE-ID YW2 LINE-SIZE 231 LINE-COUNT 45
    NO STANDARD PAGE HEADING.
    Type Declaration *
    TYPE-POOLS SLIS.
    Tables *
    TABLES: MKPF, " Material Document: Header Data
            MSEG, " Material Document: Item Data
            MARA,
            MARD,
            S031,
            EKKO,
            EKPO,
            LIKP,
            MAKT,
            J_1IWRKCUS,
            T001W,
            WB2_V_MKPF_MSEG2,
            MMIM_REP_PRINT,
            YW2_STKMOVEMENTS,
            YPLNT,
            MARDH.
    Internal Tables *
    DATA: I_WERKS LIKE J_1IWRKCUS OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_YPLNT OCCURS 0,
             PPLNT LIKE YPLNT-PPLNT,
             WPLNT LIKE YPLNT-WPLNT,
          END OF I_YPLNT.
    DATA: BEGIN OF I_MKPF OCCURS 0,
            MBLNR LIKE MKPF-MBLNR,
            MJAHR LIKE MKPF-MJAHR,
            BUDAT LIKE MKPF-BUDAT,
            VGART LIKE MKPF-VGART,
            BWART LIKE MSEG-BWART,
            MATNR LIKE MSEG-MATNR,
            WERKS LIKE MSEG-WERKS,
            LGORT LIKE MSEG-LGORT,
            MENGE LIKE MSEG-MENGE,
            MEINS LIKE MSEG-MEINS,
            KUNNR LIKE MSEG-KUNNR,
            ZEILE LIKE MSEG-ZEILE,
            XAUTO LIKE MSEG-XAUTO,
            SHKZG LIKE MSEG-SHKZG,
            MATNR1 LIKE MSEG-MATNR,
          END OF I_MKPF.
    DATA: BEGIN OF I_MARDH OCCURS 0,
           WERKS LIKE MARDH-WERKS,
           MEINS LIKE MARA-MEINS,
           MATNR LIKE MARDH-MATNR,
           LGORT LIKE MARDH-LGORT,
           LABST LIKE MARDH-LABST,
           LFGJA LIKE MARDH-LFGJA, "Added -MB
           LFMON LIKE MARDH-LFMON, "Added -MB
           PERIO(6),
           INSME LIKE MARDH-LABST,
           EINME LIKE MARDH-LABST,
           SPEME LIKE MARDH-LABST,
           RETME LIKE MARDH-LABST,
           O_STK LIKE MARDH-LABST, " Opening Stock
           C_STK LIKE MARDH-LABST, " Closing Stock
          END OF I_MARDH.
    DATA: BEGIN OF I_MARD OCCURS 0,
           WERKS LIKE MARD-WERKS,
           MATNR LIKE MARD-MATNR,
           LGORT LIKE MARD-LGORT,
           LABST LIKE MARD-LABST,
           INSME LIKE MARD-LABST,
           MEINS LIKE MARA-MEINS,
           EINME LIKE MARD-LABST,
           SPEME LIKE MARD-LABST,
           RETME LIKE MARD-LABST,
          END OF I_MARD.
    DATA: I_MARD1 LIKE I_MARD OCCURS 0 WITH HEADER LINE.
    DATA: I_MARDH1 LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_MKPF1 OCCURS 0,
            MBLNR LIKE MKPF-MBLNR,
            WERKS LIKE MSEG-WERKS,
            MATNR LIKE MSEG-MATNR,
            BUDAT LIKE MKPF-BUDAT,
            BWART LIKE MSEG-BWART,
            MJAHR LIKE MKPF-MJAHR,
            VGART LIKE MKPF-VGART,
            LGORT LIKE MSEG-LGORT,
            MENGE LIKE MSEG-MENGE,
            MEINS LIKE MSEG-MEINS,
            XAUTO LIKE MSEG-XAUTO,
            SHKZG LIKE MSEG-SHKZG,
          END OF I_MKPF1.
    DATA: BEGIN OF I_MKPF2 OCCURS 0,
           WERKS LIKE MSEG-WERKS,
           MATNR LIKE MSEG-MATNR,
           BUDAT LIKE MKPF-BUDAT,
           BWART LIKE MSEG-BWART,
           MJAHR LIKE MKPF-MJAHR,
           VGART LIKE MKPF-VGART,
           LGORT LIKE MSEG-LGORT,
           MENGE LIKE MSEG-MENGE,
           MEINS LIKE MSEG-MEINS,
           XAUTO LIKE MSEG-XAUTO,
         END OF I_MKPF2.
    DATA: BEGIN OF I_FINAL5 OCCURS 0,
           WERKS LIKE MSEG-WERKS, " Plant
           MATNR LIKE MSEG-MATNR, " Material
           LGORT LIKE MSEG-LGORT, " Storage Location
           BUDAT LIKE MKPF-BUDAT, " Posting Date
           MTART LIKE MARA-MTART, " Material Type
           SPMON LIKE S031-SPMON, " Month
           MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TLOSS LIKE MARDH-LABST, " Total Loss
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            TRFSTK LIKE MARDH-LABST, "Transfer stock
            MENGE LIKE MSEG-MENGE,
            OTHADJ LIKE MARDH-LABST,
          END OF I_FINAL5.
    DATA: BEGIN OF I_FINAL OCCURS 0,
            WERKS LIKE MSEG-WERKS, " Plant
            MATNR LIKE MSEG-MATNR, " Material
            BUDAT LIKE MKPF-BUDAT, " Posting Date
            MTART LIKE MARA-MTART, " Material Type
            SPMON LIKE S031-SPMON, " Month
            MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TRFSTK LIKE MARDH-LABST, "Material Transfer stock
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            TLOSS LIKE MARDH-LABST, " Total Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            OTHADJ LIKE MARDH-LABST,
           END OF I_FINAL.
    DATA: I_FINAL1 LIKE I_FINAL OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_FINAL_TEMP OCCURS 0,
            WERKS LIKE MSEG-WERKS, " Plant
            MATNR LIKE MSEG-MATNR, " Material
            MTART LIKE MARA-MTART, " Material Type
            MAKTX LIKE MAKT-MAKTX, " Description
            MEINS LIKE MSEG-MEINS,
            O_STK LIKE MARDH-LABST, " opening stock
            TRECEP LIKE MARDH-LABST, " total receipts
            PRODU LIKE MARDH-LABST, " Net Receipts - Production
            RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
            SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
            TDISP LIKE MARDH-LABST, " total dispatches
            CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
            OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
            TRFSTK LIKE MARDH-LABST, "Material Transfer stock
            TRLOSS LIKE MARDH-LABST, " Transit Loss
            WHLOSS LIKE MARDH-LABST, " Warehouse Loss
            TLOSS LIKE MARDH-LABST, " Total Loss
            C_STK LIKE MARDH-LABST, " Closing Stock
            OTHADJ LIKE MARDH-LABST,
          END OF I_FINAL_TEMP.
    For Materials
    DATA: BEGIN OF I_MARA OCCURS 0,
           MATNR TYPE MARA-MATNR,
           MTART TYPE MARA-MTART,
           MEINS LIKE MARA-MEINS,
           LABST TYPE MARD-LABST,
           MAKTX LIKE MAKT-MAKTX,
          END OF I_MARA.
    DATA: BEGIN OF I_STKMVMNTS OCCURS 0,
           BWART LIKE MSEG-BWART,
           SHKZG LIKE MSEG-SHKZG,
           VZBEW LIKE YW2_STKMOVEMENTS-VZBEW,
          END OF I_STKMVMNTS.
    DATA: BEGIN OF I_FINALT OCCURS 0,
           WERKS LIKE MSEG-WERKS, " Plant
           MATNR LIKE MSEG-MATNR, " Material
           BUDAT LIKE MKPF-BUDAT, " Posting Date
           MTART LIKE MARA-MTART, " Material Type
           SPMON LIKE S031-SPMON, " Month
           MAKTX LIKE MAKT-MAKTX, " Description
    meins(3), " UOM
           MEINS LIKE MSEG-MEINS,
           O_STK LIKE MARDH-LABST, " opening stock
           TRECEP LIKE MARDH-LABST, " total receipts
           PRODU LIKE MARDH-LABST, " Net Receipts - Production
           RECEP LIKE MARDH-LABST, " Net Receipts - Receipts
           SAL_RET LIKE MARDH-LABST, " Net Receipts - Sales Return
           TDISP LIKE MARDH-LABST, " total dispatches
           CUSTMR LIKE MARDH-LABST, " Net Dispatches - Customers
           OPLANT LIKE MARDH-LABST, " Net Dispatches - To Other Plant
           TRFSTK LIKE MARDH-LABST, "Material Transfer stock
           TRLOSS LIKE MARDH-LABST, " Transit Loss
           WHLOSS LIKE MARDH-LABST, " Warehouse Loss
           TLOSS LIKE MARDH-LABST, " Total Loss
           C_STK LIKE MARDH-LABST, " Closing Stock
           OTHADJ LIKE MARDH-LABST,
           MONTH(8) ,
          END OF I_FINALT.
    DATA: IMKPFT LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    DATA: IMKPFT1 LIKE I_MKPF1 OCCURS 0 WITH HEADER LINE.
    DATA: IMARDT LIKE I_MARD OCCURS 0 WITH HEADER LINE.
    DATA: IMARDHT LIKE I_MARDH OCCURS 0 WITH HEADER LINE.
    DATA: T_FINAL LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    DATA: IMKPFT2 LIKE I_MKPF OCCURS 0 WITH HEADER LINE.
    FCAT is used for the field catalog
    DATA: FCAT TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
                      WITH HEADER LINE INITIAL SIZE 0,
    for excluding the ICONs from the application toolbar
          FEXC TYPE TABLE OF SLIS_EXTAB WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    FS_LAYO is used for Grid Layout
          FS_LAYO TYPE SLIS_LAYOUT_ALV,
    FEVENTS to handle the events TOP OF PAGE & USER_COMMAND
          FEVENTS TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    FHEADER is used for List header
          FHEADER TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
    sort is used for sorting
          FSORT TYPE TABLE OF SLIS_SORTINFO_ALV WITH NON-UNIQUE DEFAULT KEY
                     WITH HEADER LINE INITIAL SIZE 0,
          FCAT1 TYPE TABLE OF SLIS_FIELDCAT_ALV WITH NON-UNIQUE DEFAULT KEY
                    WITH HEADER LINE INITIAL SIZE 0,
          FS_LAYO1 TYPE SLIS_LAYOUT_ALV,
          GT_LIST_TOP_OF_PAGE1 TYPE SLIS_T_LISTHEADER,
          FEVENTS1 TYPE TABLE OF SLIS_ALV_EVENT WITH NON-UNIQUE DEFAULT KEY
                 WITH HEADER LINE INITIAL SIZE 0,
           FHEADER1 TYPE TABLE OF SLIS_LISTHEADER WITH NON-UNIQUE DEFAULT  
                  KEY WITH HEADER LINE INITIAL SIZE 0,
           G_STATU_071 TYPE SLIS_FORMNAME VALUE 'Z_PFSTATUS',
           ALV_VARIANT1 LIKE DISVARIANT.
    Variable Declaration *
    TYPES: TRFF_TYPE_DEC_6_5(6) TYPE P DECIMALS 5.
    DATA: FYEAR(4),
          MON(2),
          FYEAR1(4),
          MON1(2),
          OBAL LIKE MARD-LABST,
          CBAL LIKE MARD-LABST,
          INDEX TYPE I,
          COUNT,
          COUNT1 TYPE I,
          O_STK TYPE P DECIMALS 3,
          C_STK TYPE P DECIMALS 3,
          V_MJAHR LIKE MKPF-MJAHR,
          MONTHS TYPE TRFF_TYPE_DEC_6_5,
          MONTH TYPE I.
    Global variables for handling ALV functionality
    DATA: ALV_KEYINFO TYPE SLIS_KEYINFO_ALV,
          ALV_VARIANT LIKE DISVARIANT,
          ALV_LAYOUT TYPE SLIS_LAYOUT_ALV,
          ALV_REPID LIKE SY-REPID,
          ALV_PRINT TYPE SLIS_PRINT_ALV,
          ALV_DETAIL_FUNC(30),
          ALV_DEFAULT_VARIANT LIKE DISVARIANT-VARIANT,
          ALV_COLOURIZE_FIELDS LIKE MMIM_REP_PRINT-COLOR.
    RANGES: R_BUDAT FOR MKPF-BUDAT.
    *Added by Prabhu for year on 26.4.05.
    DATA: IDATE LIKE R_BUDAT OCCURS 0 WITH HEADER LINE.
    Selection Screen Elements *
    SELECTION-SCREEN BEGIN OF BLOCK BLK WITH FRAME TITLE TEXT-001.
      SELECT-OPTIONS: S_WERKS FOR MARD-WERKS OBLIGATORY NO INTERVALS.
      PARAMETER: P_SPMON LIKE S031-SPMON NO-DISPLAY .
      SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
                      S_LGORT FOR MSEG-LGORT NO-EXTENSION NO INTERVALS,
                      S_MBLNR FOR MKPF-MBLNR,
                      S_BUDAT FOR MKPF-BUDAT OBLIGATORY .
    SELECTION-SCREEN END OF BLOCK BLK.
    SELECTION-SCREEN BEGIN OF BLOCK BLK3 WITH FRAME TITLE TEXT-004.
          PARAMETER : MTART LIKE MARA-MTART DEFAULT 'FERT' NO-DISPLAY.
    SELECTION-SCREEN END OF BLOCK BLK3.
    SELECTION-SCREEN BEGIN OF BLOCK BLK2 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN END OF BLOCK BLK2.
    ADDED BY PRABHU FOR DAY-WISE REPORT.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-007.
      PARAMETERS: D1 RADIOBUTTON GROUP P1 DEFAULT 'X',
                  M1 RADIOBUTTON GROUP P1,
                  Y1 RADIOBUTTON GROUP P1.
    SELECTION-SCREEN END OF BLOCK B3.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-006.
    PARAMETERS: ALV_DEF LIKE DISVARIANT-VARIANT.
    SELECTION-SCREEN END OF BLOCK B2.
    DATA: S_BUDAT1 LIKE S_BUDAT OCCURS 0 WITH HEADER LINE."prabhu
    Initialization *
    INITIALIZATION.
      PERFORM ALV_INIT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR ALV_DEF.
      PERFORM ALV_F4.
    At Selection Screen
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_spmon.
    PERFORM monat_f4.
    At Selection Screen *
    AT SELECTION-SCREEN.
    checking for the layout
      PERFORM ALV_CHECK.
    authorisation check for the Plant
    PERFORM auth_check.
    Validation for the Plant
      PERFORM VALIDITY_CHECK.
      IF MTART NE 'FERT'.
        MESSAGE E041 WITH 'Material Type must be FERT Only...'.
      ENDIF.
      IF D1 = 'X'." On 26.4.05.
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
      ELSE.
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
      ENDIF.
      LOOP AT S_BUDAT.
        IF S_BUDAT-HIGH IS INITIAL.
          S_BUDAT-HIGH = S_BUDAT-LOW.
          MODIFY S_BUDAT.
        ENDIF.
      ENDLOOP.
      IDATE-LOW = S_BUDAT-LOW.
      IDATE-HIGH = S_BUDAT-HIGH.
      CALL FUNCTION 'FIMA_DAYS_AND_MONTHS_AND_YEARS'
        EXPORTING
           I_DATE_FROM = IDATE-LOW
           I_DATE_TO = IDATE-HIGH
       IMPORTING
    E_DAYS =
          E_MONTHS = MONTH
    E_YEARS =
      DATA: I(3) TYPE C.
      I = S_BUDAT-LOW+4(2).
      CLEAR: R_BUDAT.
      REFRESH: R_BUDAT.
    *added by Prabhu for Only for Oneday.on 18.5.5
      IF MONTH EQ '0'.
        MONTH = MONTH + 1.
      ENDIF.
    *added by Prabhu for Only for Oneday.on 18.5.5
      DO MONTH TIMES.
        R_BUDAT-LOW = S_BUDAT-LOW.
        APPEND R_BUDAT.
      ENDDO.
      I = 0.
      LOOP AT R_BUDAT.
        R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2) + I.
        I = I + 1.
        R_BUDAT-LOW+6(2) = '01'.
        MODIFY R_BUDAT.
      ENDLOOP.
      LOOP AT R_BUDAT.
        CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
           EXPORTING
             DAY_IN = R_BUDAT-LOW
           IMPORTING
             LAST_DAY_OF_MONTH = R_BUDAT-HIGH
          EXCEPTIONS
            DAY_IN_NO_DATE = 1
            OTHERS = 2
        MODIFY R_BUDAT.
      ENDLOOP.
      LOOP AT R_BUDAT.
        IF R_BUDAT-LOW4(2) = S_BUDAT-LOW4(2).
          R_BUDAT-LOW = S_BUDAT-LOW.
          MODIFY R_BUDAT.
        ENDIF.
        IF R_BUDAT-HIGH4(2) = S_BUDAT-HIGH4(2).
          R_BUDAT-HIGH = S_BUDAT-HIGH.
          MODIFY R_BUDAT.
        ENDIF.
    For Summary on 26.4.05.
        IF Y1 = 'X'.
          CLEAR R_BUDAT.
          REFRESH R_BUDAT.
          R_BUDAT-LOW = S_BUDAT-LOW.
          R_BUDAT-HIGH = S_BUDAT-HIGH.
          APPEND R_BUDAT.
          CLEAR R_BUDAT.
        ENDIF.
      ENDLOOP.
    At Selection Screen *
    AT SELECTION-SCREEN OUTPUT.
    Start of Selection *
    START-OF-SELECTION.
      V_MJAHR = P_SPMON+0(4).
    Get plant distinction warehouse/production
      PERFORM GET_PLANT_DISTINCTION.
    Collect the data from various tables
      PERFORM GETDATA_FG_STOCK.
    here the number of rows in the output table is found
      PERFORM OUTPUT_TABLE_CHECK.
    here the top of the page code is written, that is to be displayed
    in the output
      PERFORM Z_TOP_OF_PAGE.
    here ALV layout properties are set
      PERFORM Z_LAYOUT_SETTINGS.
    ALV EVENTS for TOP OF PAGE and for USER COMMAND
      PERFORM Z_ALV_EVENTS.
    The field catalog is defined for the Primary List is defined in
    the subroutine CREATE_FIELD_CATALOG include program ZPRRDOCR_FCAT
      PERFORM Z_CREATE_FIELD_CATALOG.
    This is for displaying the output
      PERFORM Z_REUSE_ALV_GRID_DISPLAY.
    *& Form getdata_fg_stock
    Getting data from standard tables
    FORM GETDATA_FG_STOCK.
    For getting the Start date & end date of the month
    PERFORM get_month_dates.
    Getting the Opening Stock from MARDH table
      IF MON EQ '01'.
        MON1 = MON.
        FYEAR1 = FYEAR.
        MON = '12'.
        FYEAR = FYEAR - 1.
      ELSE.
        MON1 = MON.
        FYEAR1 = FYEAR.
        MON = MON - 1.
        FYEAR = FYEAR.
      ENDIF.
      PERFORM GET_RECORDS_FROM_DB.
    *added for Month Summary on 26.4.05.
      LOOP AT R_BUDAT.
        S_BUDAT-LOW = R_BUDAT-LOW.
        S_BUDAT-HIGH = R_BUDAT-HIGH.
    *for Month
        P_SPMON0(4) = S_BUDAT-LOW0(4).
        P_SPMON4(2) = S_BUDAT-LOW4(2).
    *for summary.
        IF Y1 = 'X'.
          LOOP AT S_BUDAT.
            S_BUDAT1-SIGN = 'I'.
            S_BUDAT1-OPTION = 'NB'.
            S_BUDAT1-LOW = S_BUDAT-LOW.
            S_BUDAT1-HIGH = S_BUDAT-HIGH.
            APPEND S_BUDAT1.
            CLEAR S_BUDAT1.
          ENDLOOP.
        ENDIF.
        IMKPFT[] = I_MKPF[].
        IMKPFT2[] = I_MKPF[].
        IMARDT[] = I_MARD[].
        IMARDHT[] = I_MARDH[].
        PERFORM MONTH_WISE.
        PERFORM PROCESS_MOVEMENTS.
        PERFORM CALCULATE_OPENING_STOCK.
        PERFORM UPDATE_NON_TRANSACTION_ITMS.
        PERFORM DELETE_EMPTY_RECORDS.
        CLEAR: IMARDHT,IMARDT,IMKPFT1,IMKPFT,I_FINAL,I_FINAL5.
        REFRESH: IMARDHT,IMARDT,IMKPFT1,I_FINAL,I_FINAL5,IMKPFT.
      ENDLOOP.
      CLEAR: R_BUDAT.
      REFRESH: R_BUDAT.
    *end of changes for month.
    ENDFORM. " getdata_fg_stock
    FORM MONAT_F4 *
    F4-Hilfe für Monat *
    FORM MONAT_F4.
      DATA: BEGIN OF MF_DYNPFIELDS OCCURS 1.
              INCLUDE STRUCTURE DYNPREAD.
      DATA: END OF MF_DYNPFIELDS.
      DATA: MF_RETURNCODE LIKE SY-SUBRC,
             MF_MONAT LIKE ISELLIST-MONTH,
             MF_HLP_REPID LIKE SY-REPID.
      FIELD-SYMBOLS: .
    Wert von Dynpro lesen
      GET CURSOR FIELD MF_DYNPFIELDS-FIELDNAME.
      APPEND MF_DYNPFIELDS.
      MF_HLP_REPID = SY-REPID.
      DO 2 TIMES.
        CALL FUNCTION 'DYNP_VALUES_READ'
          EXPORTING
            DYNAME               = MF_HLP_REPID
            DYNUMB               = SY-DYNNR
          TABLES
            DYNPFIELDS           = MF_DYNPFIELDS
          EXCEPTIONS
            INVALID_ABAPWORKAREA = 01
            INVALID_DYNPROFIELD  = 02
            INVALID_DYNPRONAME   = 03
            INVALID_DYNPRONUMMER = 04
            INVALID_REQUEST      = 05
            NO_FIELDDESCRIPTION  = 06
            UNDEFIND_ERROR       = 07.
        IF SY-SUBRC = 3.
    Aktuelles Dynpro ist Wertemengenbild
          MF_HLP_REPID = 'SAPLALDB'.
        ELSE.
          READ TABLE MF_DYNPFIELDS INDEX 1.
    Unterstriche durch Blanks ersetzen
          TRANSLATE MF_DYNPFIELDS-FIELDVALUE USING '_ '.
          EXIT.
        ENDIF.
      ENDDO.
      IF SY-SUBRC = 0.
    Konvertierung ins interne Format
        CALL FUNCTION 'CONVERSION_EXIT_PERI_INPUT'
          EXPORTING
            INPUT         = MF_DYNPFIELDS-FIELDVALUE
          IMPORTING
            OUTPUT        = MF_MONAT
          EXCEPTIONS
            ERROR_MESSAGE = 1.
        IF MF_MONAT IS INITIAL.
    Monat ist initial => Vorschlagswert aus akt. Datum ableiten
          MF_MONAT = SY-DATLO(6).
        ENDIF.
        CALL FUNCTION 'POPUP_TO_SELECT_MONTH'
          EXPORTING
            ACTUAL_MONTH               = MF_MONAT
          IMPORTING
            SELECTED_MONTH             = MF_MONAT
            RETURN_CODE                = MF_RETURNCODE
          EXCEPTIONS
            FACTORY_CALENDAR_NOT_FOUND = 01
            HOLIDAY_CALENDAR_NOT_FOUND = 02
            MONTH_NOT_FOUND            = 03.
        IF SY-SUBRC = 0 AND MF_RETURNCODE = 0.
    ASSIGN (MF_DYNPFIELDS-FIELDNAME) TO <MF_FELD>. " ==>> note 148804
    <MF_FELD> = MF_MONAT.
          CALL FUNCTION 'CONVERSION_EXIT_PERI_OUTPUT'
            EXPORTING
              INPUT  = MF_MONAT
            IMPORTING
              OUTPUT = MF_DYNPFIELDS-FIELDVALUE.
          COLLECT MF_DYNPFIELDS.
          CALL FUNCTION 'DYNP_VALUES_UPDATE'
            EXPORTING
              DYNAME               = MF_HLP_REPID
              DYNUMB               = SY-DYNNR
            TABLES
              DYNPFIELDS           = MF_DYNPFIELDS
            EXCEPTIONS
              INVALID_ABAPWORKAREA = 01
              INVALID_DYNPROFIELD  = 02
              INVALID_DYNPRONAME   = 03
              INVALID_DYNPRONUMMER = 04
              INVALID_REQUEST      = 05
              NO_FIELDDESCRIPTION  = 06
              UNDEFIND_ERROR       = 07. "<<== note 148804
        ENDIF.
      ENDIF.
    ENDFORM.                                                    "MONAT_F4
    *& Form get_month_dates
    Calculating the Month Start & End Date
    FORM GET_MONTH_DATES.
      IF M1 = 'X'.
        FYEAR = P_SPMON+0(4).
        MON = P_SPMON+4(2).
        CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
        R_BUDAT-SIGN = 'I'.
        R_BUDAT-OPTION = 'BT'.
        CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
          EXPORTING
            I_DATE = R_BUDAT-LOW
          IMPORTING
            E_DATE = R_BUDAT-HIGH.
        APPEND R_BUDAT.
        CLEAR S_BUDAT.
        REFRESH S_BUDAT.
        S_BUDAT-SIGN = 'I'.
        S_BUDAT-OPTION = 'BT'.
        S_BUDAT-LOW = R_BUDAT-LOW.
        S_BUDAT-HIGH = R_BUDAT-HIGH.
        APPEND S_BUDAT.
      ELSE.
        FYEAR = P_SPMON+0(4).
        MON = P_SPMON+4(2).
        CONCATENATE FYEAR MON '01' INTO R_BUDAT-LOW.
        R_BUDAT-SIGN = 'I'.
        R_BUDAT-OPTION = 'BT'.
        CALL FUNCTION 'BKK_GET_MONTH_LASTDAY'
          EXPORTING
            I_DATE = R_BUDAT-LOW
          IMPORTING
            E_DATE = R_BUDAT-HIGH.
        APPEND R_BUDAT.
      ENDIF.
    ENDFORM. " get_month_dates
    *& Form output_table_Check
    checking for records for output
    FORM OUTPUT_TABLE_CHECK .
      DESCRIBE TABLE I_FINALT LINES INDEX.
      IF INDEX EQ 0.
        MESSAGE I041 WITH TEXT-005.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM. "OUTPUT_TABLE_CHECK
    *& Form Z_TOP_OF_PAGE
    for setting the details in the top of page *
    has no formal paramters *
    FORM Z_TOP_OF_PAGE.
      DATA: V_MON(2),
      V_YR(40),
      V_FIN(18),
      V_FIN1(48),
      LOW(10),
      HIGH(10).
      V_MON = P_SPMON+4(2).
      V_YR = P_SPMON+0(4).
      FHEADER-TYP = 'H'.
      FHEADER-INFO = 'Stock Register Report (FG Stock)'.
      APPEND FHEADER.
      CLEAR FHEADER.
    *if m1 = 'X'.
    CONCATENATE 'Month = ' v_mon '.' v_yr INTO v_fin.
    fheader-typ = 'H'.
    fheader-info = v_fin.
    APPEND fheader.
    CLEAR fheader.
    *endif."prabhu on 18.5.5
      IF D1 = 'X'.
        CLEAR S_BUDAT.
        LOOP AT S_BUDAT.
          CONCATENATE S_BUDAT-LOW6(2) '/' S_BUDAT-LOW4(2) '/'
          S_BUDAT-LOW+0(4) INTO LOW.
          CONCATENATE S_BUDAT-HIGH6(2) '/' S_BUDAT-HIGH4(2) '/'
          S_BUDAT-HIGH+0(4) INTO HIGH.
          CONCATENATE 'Date = ' LOW ' - ' HIGH INTO V_FIN1.
          FHEADER-TYP = 'H'.
          FHEADER-INFO = V_FIN1.
          APPEND FHEADER.
          CLEAR FHEADER.
        ENDLOOP.
      ENDIF.
    ENDFORM. " Z_TOP_OF_PAGE
    *& Form Z_LAYOUT_SETTINGS
    this is done for setting the properties for the layout of the *
    grid *
    has no formal paramters *
    FORM Z_LAYOUT_SETTINGS.
      FS_LAYO-ZEBRA = 'X'. " Output in Zebra pattern
      FS_LAYO-DETAIL_POPUP = 'X'. " A popup window appears to give
      FS_LAYO-DETAIL_TITLEBAR = TEXT-022.
      FS_LAYO-COLWIDTH_OPTIMIZE = 'X'.
    ENDFORM. " Z_LAYOUT_SETTINGS
    *& Form Z_ALV_EVENTS
    This is used for handling the events TOP OF PAGE and the USER *
    COMMAND event *
    has no formal paramters *
    FORM Z_ALV_EVENTS.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          I_LIST_TYPE = 0
        IMPORTING
          ET_EVENTS   = FEVENTS[].
      READ TABLE FEVENTS WITH KEY NAME = 'TOP_OF_PAGE'.
      IF SY-SUBRC = 0.
        FEVENTS-FORM = 'Z_TOPOFPAGE'.
        MODIFY FEVENTS INDEX SY-TABIX.
        CLEAR FEVENTS.
      ENDIF.
      READ TABLE FEVENTS WITH KEY NAME = 'USER_COMMAND'.
      IF SY-SUBRC = 0.
        FEVENTS-FORM = 'Z_USER_COMMAND'.
        MODIFY FEVENTS INDEX SY-TABIX.
        CLEAR FEVENTS.
      ENDIF.
    ENDFORM. "Z_ALV_EVENTS
    *& Form Z_CREATE_FIELD_CATALOG
    here the field catalog is created for the primary list *
    no formal parameters *
    FORM Z_CREATE_FIELD_CATALOG.
    for the Plant
      FCAT-FIELDNAME = 'WERKS'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '000005'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Plant'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material Type
      FCAT-FIELDNAME = 'MTART'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '000006'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'MatTyp'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material No.
      FCAT-FIELDNAME = 'MATNR'.
      FCAT-KEY = 'X'.
    fcat-hotspot = 'X'.
      FCAT-OUTPUTLEN = '000018'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Material'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Material Description
      FCAT-FIELDNAME = 'MAKTX'.
      FCAT-KEY = ''.
      FCAT-OUTPUTLEN = '000040'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Description'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Unit of Measure
      FCAT-FIELDNAME = 'MEINS'.
      FCAT-KEY = ''.
      FCAT-OUTPUTLEN = '03'.
      FCAT-JUST = 'C'.
      FCAT-SELTEXT_M = 'UOM'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'UNIT'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Plant
      FCAT-FIELDNAME = 'MONTH'.
      FCAT-KEY = 'X'.
      FCAT-OUTPUTLEN = '08'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'MONTH'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'C'.
      FCAT-DATATYPE = 'CHAR'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Opening Stock
      FCAT-FIELDNAME = 'C_STK'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Opening Stock'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
    fcat-do_sum = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Total Receipts
      FCAT-FIELDNAME = 'TRECEP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Total Receipts'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Production
      FCAT-FIELDNAME = 'PRODU'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Production'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    for the Other Plant Receipts
      FCAT-FIELDNAME = 'RECEP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Othr Plnt Recpts'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    Sales Return
      FCAT-FIELDNAME = 'SAL_RET'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Sales Return'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.
    Total Dispatches
      FCAT-FIELDNAME = 'TDISP'.
      FCAT-HOTSPOT = ' '.
      FCAT-OUTPUTLEN = '000016'.
      FCAT-JUST = 'L'.
      FCAT-SELTEXT_M = 'Total Dispatches'.
      FCAT-DDICTXT = 'M'.
      FCAT-INTTYPE = 'Q'.
      FCAT-DATATYPE = 'QUAN'.
      FCAT-DO_SUM = 'X'.
      FCAT-JUST = 'R'.
      FCAT-NO_ZERO = 'X'.
      APPEND FCAT.
      CLEAR FCAT.

  • How to create a query to see Opening stock and closing stock as on particul

    Hi All,
    How to create a query to see Opening stock and closing stock as on particul.
    Regards
    Albaik

    Hi,
    In BI 0IC_C03 will provide u the  required information and also having standard queries provided by the SAP.
    Plz find the list of Queries provided by the SAP.
    =======================================================================================================
    Inventory turnover      0IC_C01_Q0001
    Range of coverage - quantity      0IC_C01_Q0002
    Range of Coverage - Value      0IC_C01_Q0003
    Range of coverage of finished goods - quantity      0IC_C01_Q0004
    Range of Coverage of Finished Goods - Value      0IC_C01_Q0005
    Range of coverage of raw materials - quantity      0IC_C01_Q0006
    Range of Coverage of Raw Materials - Value      0IC_C01_Q0007
    Obsolete Stock on Hand      0IC_C01_Q0008
    Period-dependent requirement coverage      0IC_C01_Q0009
    Value of stock on hand      0IC_C01_Q0010
    Quantity of stock on hand      0IC_C01_Q0011
    Material consumption      0IC_C01_Q0012
    Material Movements      0IC_C01_Q0013
    Consignment stock: receipts and issues      0IC_C01_Q0014
    Valuated stock: receipts and issues      0IC_C01_Q0015
    Material stock and movements      0IC_C01_Q0016
    Material Movements (Healthcare)      0IC_C01_Q0020
    Material Consumption (Healthcare)      0IC_C01_Q0021
    Material Availability      0IC_C01_Q0022
    Inventory Turnover Frequency (Value)      0IC_C01_Q0023
    Consignment Stock Received and Issued per Unit      0IC_C01_Q0024
    Material Consumption (Quantity)      0IC_C02_Q0001
    Valuated Stock Receipts and Issues (Quantity)      0IC_C02_Q0002
    Range of Valuated Stock (Quantity)      0IC_C02_Q0003
    Inventory Turnover      0IC_C02_Q0004
    Receipt and Issue Consignment Stock at Customer      0IC_C03_Q0001
    Receipt and Issue Quality Inspection Stock      0IC_C03_Q0002
    Vendor Consignment Stock Receipt and Issue      0IC_C03_Q0003
    Receipt and Issue Stock in Transit      0IC_C03_Q0004
    Receipt and Issue of Blocked Stock      0IC_C03_Q0005
    Valuated Stock      0IC_C03_Q0006
    Stock in Quality Inspection      0IC_C03_Q0007
    Stock in Transit      0IC_C03_Q0008
    Blocked Stock      0IC_C03_Q0009
    Vendor Consignment Stock      0IC_C03_Q0010
    Consignment Stock at Customer      0IC_C03_Q0011
    Stock Overview      0IC_C03_Q0012
    Stock Overview (as of 3.1 Content)      0IC_C03_Q0013
    Quantities of Valuated Project Stock (as of 3.1 Content)      0IC_C03_Q0014
    Valuated Stock (as of 3.1 Content)      0IC_C03_Q0015
    Quantities of Valuated Sales Order Stock (as of 2.1 Cont.)      0IC_C03_Q0016
    Inventory Turnover      0IC_C03_Q0017
    Days' Supply      0IC_C03_Q0018
    SUS: Vendor Consignment Stock      0IC_C03_Q0019
    Scrap      0IC_C03_Q0020
    Inventory Aging      0IC_C03_Q0021
    Stock Overview - extended      0IC_C03_Q0022
    Demand Supply Match      0IC_C03_Q0023
    Warehouse Stock Analytics – Inventory Turnover      0IC_C03_Q0024
    Warehouse Analytics - Obsolescence and Variance      0IC_C03_Q0025
    Stock Overview: Materials      0IC_C03_Q0030
    Average Stock Value Over Time      0IC_C03_Q0031
    Stock Overview Over Time      0IC_C03_Q0032
    Range of Coverage Over Time      0IC_C03_Q0033
    ==================================================================================================
    Regards
    Ram.
    Edited by: Ramakanth Deepak Gandepalli on Jan 18, 2010 8:06 AM

  • Report on pending order qty,opening stock, and closing stock

    Any standard Report available on pending order qty against opening stock, and closing stock.
    Points assured
    Mohan

    Hi Mohan
    There is no report in standard SAP for stock in transit that is what you are refering to Pending order Qty & opening stock.
    You can get report in ME2M, ME2L for pending PO's.
    In MD04 you will get all these stock, PO Qty, & Closing stock but this is for individual material this has to be made customized report in reporting format same thing we have done in one of our project.
    Regards

  • 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

  • Inventory management opening stock querry

    Hi,
    In the material movement report, it needs Opening stock, closing stock and the End Value.
    Can you please guide how I could Calculate.
    Though I calculate it by valuated stock and -1  day interval, but not getting proper value.
    Iz that necessery to append the field LABST(opening stock) and LBKUM (end Value),
    then remodeling the inventory cube 0ic_c03.
    So what will be the cmod include progame for that?
    regards,
    Balaram

    HI balaram,
    for enhancing the datasource refer the below How to - doc
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0eade6c-692a-2c10-ac86-80f6b2157791?QuickLink=index&overridelayout=true
    I have a note from the forums on the opening and Closing balance , may be you can give a try
    0VALSTCKQTY gives  Closing Balance.
    0VALSTCKQTY + Issues - Receipts = Opening Balance
    Regards,
    Sathya

  • Opening Stock calculation

    Hello Experts,
    I am doing a report on Opening and closing stock with the subcontractors...
    My report's requirement is..
    Mat. No. - ekpo-matnr
    Part No. - resb-matnr
    Opeining stock (for Resb-matnr) - ( movement type 541542543+544 from Mseg)
    Please advice me how to calculate opening stock for the Parts as ekpo-matnr is linked to ekbe-budat
    and I have to take the opening stock by linking mkpf-budat. And for single material (ekpo-matnr)
    there will be multiple part no (resb-matnr) and I want the openinig stock for each part no.
    Please advice...your help would be highly appreciable.
    Thanks
    R.Karthik.

    Hi Karthik,
    Opening stock can be directly seen in LBKUM field, which is valuated stock.
    this is available in MSEG, i am not sure how accurate it is,
    and MBEWH, MARDH, MCHBH.
    T.code:MB5B
    & CKM3 Sometimes..
    and check this link.
    link: [ Opening Stock |
    http://help.sap.com/bp_bblibrary/470/Documentation/J33_BPP_32_CHEM_EN_IN.doc ]
    Best Regards ,
    Dileep .C

  • Calculation of Opening Stock

    Hello Gurus,
    I am using 0IC_C03 for stocks. Infosource 2LIS_03_BX, 2LIS_03_BF & 2LIS_03_UM is populating data to the cube.
    How do I calculate Opening stock values. I need a column for displaying op. stock.
    pls guide.
    thanks in advance..

    Hi,
    You can check business content query 0IC_C03_Q0012.
    Just to be clear, you want to display opening stock (as on each day, or month, or ??).
    I would think using the keyfigure 0TOTALSTCK (Total stock) or other such KF (for other categories of stocks) would do. System would do the calculation for you as I understand.
    This may also help if you have not looked at it yet
    <i>"How-to..." Paper for Inventory Management Scenarios in SAP BW: SAP offers a document dealing with the special features in implementing SAP BW in the Inventory Management area.
    To display this document, in the SAP Service Marketplace (http://service.sap.com), select the Quick Link /bw, then choose SAP BW InfoIndex in the Navigation area and follow the Non-cumulatives link in the list. The document is named How to...Handle inventory management scenarios in SAP BW 3.x (pdf).</i>
    cheers,

  • Regardig opening stock

    hi experts,
    i m an abaper ,i dnt have a functional consultant rt now.i have to develope a report on opening stock of raw materials on date wise basis..which table sud i use so that i can get the date wise opening stock or will i use some logic for that ...plz help me with eg. if possible.
    plz dnt gve this type of answer like tc mb5b and tc mb51.
    null

    Hi,
    SAP does not maintain day wise stock tables. It maintains period closing stock in tables like MBEWH, MARDH, MCHB and current stock in tables like MBEW, MARD, MCHB.
    These tables provide various views stock
    Mard, Mardh - plant,Storage location, material
    Mbew, Mbewh - Plant, material, valuation type
    Mchb, mchbh - Plant, material, storagelocation, batch.
    If you want to calculate stock for a given date, possible approach would be to find the period closing stock(1) relative to the given date(A), and net the material movements(2) from MSEG and MKPF from next day(A+1) to the given date and add the net to closing stock (1) + (2).
    For example if plant = 1000, material is 100000
    given date is 2.3.2007.
    See in history stock whether there is a latest closing stock.
    if your latest closing is Jan 2007. Have this stock as (1).
    Net of quantities(2) from MSEG and MKPF stock movement from 1.2.2007 to 2.3.2007. Add this with (1) and you will have stock on that day.
    Hope this helps.
    Thanks and regards,
    S. Chandra Mouli.

  • Auto update of Profit Centre in JE for Opening Stock

    Hi Experts,
          I am using SAP B1 2007B Version and Patch level 15 and  entering the Opening Stock of  Items in Initial quantities,inventory tracking and Stock posting window and updating the profit centre in distribution rule but the problem is it is not getting updated in the Journal Entry when the back end JE is posting accordingly and for that again we need to update it manually. can any please help me regarding this..
    Thanks,
    Narsing

    Profit Centres are generally applicable only for Revenue & Expense accounts.
    When you load the opening balances, it affect the Inventory Account which is an Account Account and that is why there is no Profit Centre marked in the JE.

  • Problem connecting to SAP Open Hub

    Hi, I am trying to set up a SSIS job  connecting to SAP Open Hub and have with support from the SAP guys been able to get some progress, but it has now stopped up on a error message we're not able to solve. Any suggestion on what can be wrong and
    how to solve this? When I run the package I get the following error message:
    SSIS package "D:\Source\MSBI\SapLoadStaging\Package3.dtsx" starting.
    Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
    Information: 0x4004300A at Data Flow Task, SSIS.Pipeline: Validation phase is beginning.
    Information: 0x40043006 at Data Flow Task, SSIS.Pipeline: Prepare for Execute phase is beginning.
    Information: 0x40043007 at Data Flow Task, SSIS.Pipeline: Pre-Execute phase is beginning.
    Information: 0x4004300C at Data Flow Task, SSIS.Pipeline: Execute phase is beginning.
    Information: 0x3E8 at Data Flow Task, SAP BW Source: Process Start Process, variant has status Completed (instance DH88PUV2SZBIFKMIF48K3USME)
    Error: 0x3E8 at Data Flow Task, SAP BW Source: Process Data Transfer Process, variant /CPMB/HMIJYDZ -> ZOH_VPL has status Ended with errors (instance DTPR_DH88PUV2SZCA46Y9QNO66A6W6)
    Error: 0x3E8 at Data Flow Task, SAP BW Source: The component is stopping because the Request ID is "0".
    Error: 0x3E8 at Data Flow Task, SAP BW Source: No data was received.
    Error: 0xC0047062 at Data Flow Task, SAP BW Source [41]: System.Exception: No data was received.
       at Microsoft.SqlServer.Dts.SapBw.Components.SapBwSourceOHS.PrimeOutput(Int32 outputs, Int32[] outputIDs, PipelineBuffer[] buffers)
       at Microsoft.SqlServer.Dts.Pipeline.ManagedComponentHost.HostPrimeOutput(IDTSManagedComponentWrapper100 wrapper, Int32 outputs, Int32[] outputIDs, IDTSBuffer100[] buffers, IntPtr ppBufferWirePacket)
    Error: 0xC0047038 at Data Flow Task, SSIS.Pipeline: SSIS Error Code DTS_E_PRIMEOUTPUTFAILED.  The PrimeOutput method on SAP BW Source returned error code 0x80131500.  The component returned a failure code when the pipeline engine called PrimeOutput().
    The meaning of the failure code is defined by the component, but the error is fatal and the pipeline stopped executing.  There may be error messages posted before this with more information about the failure.
    Information: 0x40043008 at Data Flow Task, SSIS.Pipeline: Post Execute phase is beginning.
    Information: 0x4004300B at Data Flow Task, SSIS.Pipeline: "OLE DB Destination" wrote 0 rows.
    Information: 0x40043009 at Data Flow Task, SSIS.Pipeline: Cleanup phase is beginning.
    Task failed: Data Flow Task
    Warning: 0x80019002 at Package3: SSIS Warning Code DTS_W_MAXIMUMERRORCOUNTREACHED.  The Execution method succeeded, but the number of errors raised (5) reached the maximum allowed (1); resulting in failure. This occurs when the number of errors reaches
    the number specified in MaximumErrorCount. Change the MaximumErrorCount or fix the errors.
    SSIS package "D:\Source\MSBI\SapLoadStaging\Package3.dtsx" finished: Failure.
    The program '[6916] DtsDebugHost.exe: DTS' has exited with code 0 (0x0)
    Regards
    Paal

    Hi Paleri,
    According to the
    thread which has the same error message, the issue may be caused by incorrect RCF settings. Could you double check your RCF connection configurations such as DNS settings?
    If it is not the case, please also make sure you have installed the correct version of Microsoft Connector for SAP BW.
    Reference:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/e2fbafe5-d9df-490a-bfad-3d4b9784a8ea/sap-bi-connector-for-ssis-2008?forum=sqlintegrationservices
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • How to loading the opening stock balance into Infocube 0IC_C03

    Dear Expers,
    I have referenced SDN a expert's documentation, but I canu2019t go on at page 10 .
    Check: How Tou2026 [Handle Inventory Management Scenarios in BW|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f83be790-0201-0010-4fb0-98bd7c01e328]
    (1)original text:
    Loading the opening stock balance (InfoSource 2LIS_03_BX) into InfoCube
    0IC_C03. In the InfoPackage, choose the upload mode u201CCreate opening balanceu201D
    (see screenshot).
    Question:
    How to find option that upload mode u201CCreate opening balanceu201D?
    i'm  use to customize infopackage.  i  can not use default infopackage, when i click the defualt infopackage, will error prompt: Data target '0DF_C07' removed from list of loadable targets; not loadable
    (2) I actived BI Contnet (0IC_C03), I seen that the data flow  as following:
    Datasource(2LIS_03_BX)->transformation->Infosource(2LIS_03_BX_TR)-> transformation->Infocube(0IC_C03)
    Datasource(2LIS_03_BF)->transformation->Infosource(2LIS_03_ BF TR)-> transformation->Infocube(0ICC03)
    Datasource(2LIS_03_UM)->transformation->Infosource(2LIS_03_UM TR)-> transformation->Infocube(0ICC03)
    Quesiton: I donu2019t  know whatu2019s version, neither like BW 7.X nor like BW 3.X,
    Why have infosource in BW 7.X, how to use infosource load data to target?
    Currently, I canu2019t create transfer rule and upate rule for this datasource & infosource.
    Do  I  need to create a  customize ODS?
    Thank you very much , if you will answer me above two questions.
    Best Regards
    Steve

    >
    stevezhuang wrote:
    > Dear Expers,
    >
    > I have referenced SDN a expert's documentation, but I canu2019t go on at page 10 .
    >
    > Check: How Tou2026 [Handle Inventory Management Scenarios in BW|http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f83be790-0201-0010-4fb0-98bd7c01e328]
    >
    > (1)original text:
    > Loading the opening stock balance (InfoSource 2LIS_03_BX) into InfoCube
    > 0IC_C03. In the InfoPackage, choose the upload mode u201CCreate opening balanceu201D
    > (see screenshot).
    >
    > Question:
    > How to find option that upload mode u201CCreate opening balanceu201D?
    >  i'm  use to customize infopackage.  i  can not use default infopackage, when i click the defualt infopackage, will error prompt: Data target '0DF_C07' removed from list of loadable targets; not loadable
    >
    >
    >
    > (2) I actived BI Contnet (0IC_C03), I seen that the data flow  as following:
    > Datasource(2LIS_03_BX)->transformation->Infosource(2LIS_03_BX_TR)-> transformation->Infocube(0IC_C03)
    >
    > Datasource(2LIS_03_BF)->transformation->Infosource(2LIS_03_ BF TR)-> transformation->Infocube(0ICC03)
    >
    > Datasource(2LIS_03_UM)->transformation->Infosource(2LIS_03_UM TR)-> transformation->Infocube(0ICC03)
    >
    > Quesiton: I donu2019t  know whatu2019s version, neither like BW 7.X nor like BW 3.X,
    > Why have infosource in BW 7.X, how to use infosource load data to target?
    > Currently, I canu2019t create transfer rule and upate rule for this datasource & infosource.
    > Do  I  need to create a  customize ODS?
    >
    >
    > Thank you very much , if you will answer me above two questions.
    >
    >
    > Best Regards
    > Steve
    You don't need to worry about 0DF_C07 as it was defence cube not activated during your Business Content Activaiton.
    YOu can create your own infopackage for 2LIS_03_BX and there will be option generate intial status.
    This loading will create your Opening Balance.
    you need to compress this with NO Marker UPDATE option unchecked(as you will have to update hte marker).
    After this load movements 2LIS_03_BF and reval 2LIS_03_UM. Compress this with NO MARKER UPDATE option checked.
    Regards,
    RK

  • Query:Opening STock value

    hi all,
    we want to get the value of opening stock
    opening stock value on 1st of each month.
    for e.g
    Goods are received and issued upto 10th of september.stock is updated.
    on 10th sep we want to get the opening stock for 1st sep.
    report fileds that client want are:
    Month Opening        Received                Issued               Qty        Value         Qty    Value          Qty      Val                
    120         200            50     70                40       30                
    How to get such report.
    Thanks
    Neetu

    I started query Profiler,clicked on run....
    but it is showing many lines.
    how i can find the appropriate sql query.
    For eg. I started SQL profiler,then i run sap-->>Inventory Adut report.
    from where to get the query running behind Inventory adit report in SQL profiler
    Thanks,
    Neetu

Maybe you are looking for