DATE_TO_PERIOD_CONVERT

Hi All,
What is the functionality of the function module DATE_TO_PERIOD_CONVERT.
As it has no documentation I want to know the functionality. can any body explain me the use of the function module and how to execute it

Hi,
It gives you the financial fiscal year and period that relates to the given date. To call it pass in a date and the fiscal year variant (you can get this from table T001 for a given company code).
Darren

Similar Messages

  • Call Function in FOX - 'DATE_TO_PERIOD_CONVERT'

    Hi,
    I have added the FM in 'DATE_TO_PERIOD_CONVERT' in RSPLF_FDIR.
    There are 2 Date fields which the user enters based on which I need to populate another field- 'No. of Months'.
    I need to convert the dates into months before I calculate the number of months.(difference of the two periods).
    When I tried to pass the parameters to the FM, Im gettin an error as below:
    Types of parameter I_DATE () and variable CHA_ZSTCTDT(D) are inconsistent
    When I checked the domain of both the fields, both are of the same type DATS of length 8.
    Im not able to figure out what went wrong..
    Sample Code:
    DATA CHA_ZSTCTDT TYPE ZSTCTDT.
    DATA CHA_ZEDCTDT TYPE ZEDCTDT.
    DATA CHA_FISCPER3 TYPE 0FISCPER3.
    DATA CHA_FISCYEAR TYPE 0FISCYEAR.
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    EXPORTING
                I_DATE                =    CHA_ZSTCTDT
                I_MONMIT            = 00
                I_PERIV               = 'K4'
             IMPORTING
               E_BUPER               = CHA_FISCPER3
               E_GJAHR              = CHA_FISCYEAR .
    Rgds
    Shyam

    When I defined as String:
    Types of parameter I_DATE () and variable CHA_ZSTCTDT(C) are inconsistent.
    But again Bindu,
    as per Marcs document on FOX:
    Restriction on types for parameters
    – F, I, D, or STRING
    – Types of characteristics and attributes
    – No structures or tables..
    I tried all those, but stills ame error
    Rgds
    Shyam

  • FM  : DATE_TO_PERIOD_CONVERT

    Hi,
      In the FM DATE_TO_PERIOD_CONVERT 
      What is  'I_PERIV' represents
    Thanks

    Hi user,
    That representd Fiscal Year Variant ( Type PERIV in Table T009B )
    Check it in SE11 > T009B
    Regards,
    Ram.

  • Function Module 'DATE_TO_PERIOD_CONVERT'  for 0FISCPER

    hello All,
    I have a date field / infoobject ST_UP_DTE in the Transfer Rules of 2LIS_11_VAITM.
    I want write a routine for 0FISCPER to get the data from this Date Field,
    i have written code below ,
      CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
        EXPORTING
          i_date  = COMM_STRUCTURE-ST_UP_DTE
          i_periv = COMM_STRUCTURE-fiscvarnt
        IMPORTING
          e_buper = RESULT+4(3).
    But when I start data loading , the data is not loaded to infocube.
    The request is Yellow all the time.
    Please correct me if anything is wrong in this code.
    regards ,
    Amol K.

    Hello Praveen ,
    I made a slight modification to your code as below ,
    I made Fiscal year Variant = V3 as constant in the code itself.
    And now its working.
    data : zperiod like T009B-POPER,
             zyear like T009B-BDATJ.
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    EXPORTING
    i_date = COMM_STRUCTURE-ST_UP_DTE
    i_periv = 'V3'
    IMPORTING
    e_buper = zperiod
    E_GJAHR = zyear.
    Concatenate zyear zperiod into RESULT.
    Thanks for help. full ponits to you.
    regards ,
    Amol k.

  • Help with DATE_TO_PERIOD_CONVERT

    Hi,
    I would like to know if there is any function module to convert calendar month and year to Fiscal Period.
    Example: 07 month and 2005 year of calender would be Fiscal period 001 / FY05 (actually July)
    Here is my below code & problem:-
    Please let me know how do I do it for any date that a user enters & convert that to respective Fiscal Period.
    Points will be rewarded.
    CODE: There is some issue with this one.
    w_date='20060202' (I need to convert whatever user enters & not hard code it this way)
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
         EXPORTING
           I_DATE               = w_date
          I_MONMIT             = 00
           I_PERIV              = 'S1' (Fiscal period Variant)
        IMPORTING
          E_BUPER              = w_period
          E_GJAHR              = w_year
        EXCEPTIONS
          INPUT_FALSE          = 1
          T009_NOTFOUND     = 2
          T009B_NOTFOUND   = 3
          OTHERS                  = 4
    Thanks.

    Make sure w_date is declared like sy-datum:
    PARAMETERS: w_date LIKE sy-datum.
    DATA: w_period LIKE  t009b-poper,
          w_year   LIKE  t009b-bdatj.
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
      EXPORTING
        i_date         = w_date
        i_monmit       = 00
        i_periv        = 'S1'
      IMPORTING
        e_buper        = w_period
        e_gjahr        = w_year
      EXCEPTIONS
        input_false    = 1
        t009_notfound  = 2
        t009b_notfound = 3
        OTHERS         = 4.
    Rob

  • Filter in DTP load from DSO to cube by Forecast version not working ?

    Hi All
    Can any help on the below code I did to filter data update from DSO to Cube in DTP - to filter by  next period forecast version. This code is not working it is loading data pf present forecast version also  Can any one help please
    data: l_idx like sy-tabix.
    data: L_date type sy-datum,
          t_gjahr  type t009b-bdatj,
          t_buper  type t009b-poper,
          1_period(6) type c.
              read table l_t_range with key
                   fieldname = 'ZFCSTVERS'.
              l_idx = sy-tabix.
       clear: t_buper, t_gjahr.
        L_date = sy-datum.
        call function 'DATE_TO_PERIOD_CONVERT'
          EXPORTING
            i_date  = L_date
            i_periv = 'Z1'
          IMPORTING
            e_buper = t_buper
            e_gjahr = t_gjahr.
    *---> Check if the period is 012, then increase the year by 1 and set
    *period to 001.
        if t_buper = '012'.
          t_gjahr = t_gjahr + 1.
          t_buper = '001'.
        else.
    *---> Increase just the period by 1.
          t_buper = t_buper + 1.
        endif.
        concatenate t_gjahr t_buper+1(2)  into 1_period.
        l_t_range-fieldname = 'ZFCSTVERS'.
        l_t_range-low = 1_period.
        l_t_range-sign = 'I'.
        l_t_range-option = 'EQ'.
           append l_t_range.
              p_subrc = 0.
    sk
    Edited by: SK Varma Penmatsa on Jan 23, 2012 2:30 PM

    Hi Praveen/Raj,
    Basically PCS_PER_PACK is a KF i have in the DSO, which i use to calculate the total number of pieces which i store in a KF in the cube. The transformation rule to calculate TOTAL_PCS is a routine.
    within this routine i multiply PACKS * PCS_PER_PACK to calculate the figure. I do not store PCS_PER_PACK in the cube.
    is it this rule that you want me to check whether aggregation is set to SUM or overwrite? Also this rule should add up the total pcs. if I say overwrite then it might not give me the desired result?
    Thing which i cannot figure out is since the transformation rules go record by record why would it add up the PCS_PER_PACK figure before calculating?
    I cannot access the system at the moment. as soon as i can i will check on it and get back to you.
    thanks once again for you're quick response to my need.
    regards
    dilanke

  • Report needs to be corrected it is urgent

    Ageing Analysis of Inventory Material. This is a report for Inventory Ageing. The report is not giving correct result for the field Value of total valuated stock(MBEWH-SALK3). After displaying the report when we add up the field SALK3 it not the correct result which I got in transaction code MB5L. Can anyone kindly help me in correcting out this report. I am keeping the source code also.
    *& Application      :  Materials Management (MM)
    *& Description      :  Ageing Analysis of Inventory Material
    *& Transaction Code :
    *& Area Menu Code   :  ZMM
    Report ZMM0001.
    MAPPING OF MONTH AND PERIOD AS FINACIAL YEAR STARTS FROM APR - MAR. *
    just for reference.
       MONTH        PERIOD
      01.2003   -  10.2003
      02.2003   -  11.2003
      03.2003   -  12.2003
      04.2003   -  01.2003
      05.2003   -  02.2003
      06.2003   -  03.2003
      07.2003   -  04.2003
      08.2003   -  05.2003
      09.2003   -  06.2003
      10.2003   -  07.2003
      11.2003   -  08.2003
      12.2003   -  09.2003
      01.2004   -  10.2004
      02.2004   -  11.2004
      03.2004   -  12.2004
      04.2004   -  01.2004
    REPORT  ZMMR0001 MESSAGE-ID GW NO STANDARD PAGE HEADING
                                   LINE-COUNT 1000
                                   LINE-SIZE 170.
    *FLOWLOGIC
    *This Program displays the Ageing Analysis details of Material inventory
    *pick up the opening balance consider the previous month of the period
    *entered in selection screen.
    *Get the qty and value for all material types from mbew table but
    *excludeentries where no valuation type is defined
    *calculate the receipt qty pick all entries from z_mkpf_mseg where
    *date( is less that or equal to the last day of the month and movement
    *type equals '101', '561', '501', '951', '953', '955', '957', '301' *
    *into i_mseg table.
    *To calculate the reversal for  receipt qty.
    *To get the issue qty upto the date of receipt, delete the issue qty
    *fromstock to get the exact stock value on the date the receipt of
    *materials happen.
    *Calculate the difference in days and mark values based on the below
    *condition.
    *Display the output as per the user given format.
    *FLOWLOGIC
    Tables
    TABLES : S031,      " Statistics: Movements for current stocks
             S032,      " Statistics: Current Stock and Grouping Terms
             MBEW,      " Material Valuation
             MBEWH,     " Material Valuation: History
             MARC,      " Plant Data for Material
             MARA,      "material master
             T001W,     " Plant Details
             MKPF,
             V_T179.
    TYPE-POOLS
    TYPE-POOLS: SLIS.
    DATA:   IT_HEADING       TYPE SLIS_T_LISTHEADER   WITH HEADER LINE.
    DATA:   IT_FCAT          TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE.
    DATA:   LAY              TYPE SLIS_LAYOUT_ALV.
    DATA:   IT_SORT_SUBTOTAL TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE.
    DATA:   IT_EVENT         TYPE SLIS_T_EVENT        WITH HEADER LINE.
    DATA:   V_REPID LIKE SY-REPID.
    DATA:   PRDHA1(5),
            PRDHA2(10),
            LVL1(40),
            LVL2(40),
            LVL3(40).
    RANGES: S_BWTAR FOR BWTAR.
    INTERNAL Tables
    *******For Mat. Desc.************
    DATA : BEGIN OF I_MAKT OCCURS 0,
              MATNR TYPE MAKT-MATNR,    " Material Code
              MAKTX TYPE MAKT-MAKTX,    " Material Description
           END OF I_MAKT.
    DATA : BEGIN OF TEMP OCCURS 0,
    VTEXT(40),
    END OF TEMP.
    *******For Mat. No. & Type & Grp*
    DATA : BEGIN OF I_MARA OCCURS 0,
              MATNR TYPE MARA-MATNR,    " Material Code
              MATKL         TYPE MARA-MATKL,
              MTART         TYPE MARA-MTART,
              MFRNR         TYPE MARA-MFRNR,
           END OF I_MARA.
    ******For Stock******************
    DATA : BEGIN OF I_MBEWH OCCURS 0,
              MATNR TYPE MBEWH-MATNR,
              BWTAR TYPE MBEWH-BWTAR,
              LBKUM TYPE MBEWH-LBKUM,
              SALK3 TYPE MBEWH-SALK3,
              BWKEY TYPE MBEWH-BWKEY,
              VBELN TYPE EBEW-VBELN,
              POSNR TYPE EBEW-POSNR,
              SOBKZ TYPE QBEW-SOBKZ,
              PSPNR TYPE QBEW-PSPNR,
              LFGJA TYPE MBEW-LFGJA,
              LFMON TYPE MBEW-LFMON,
           END OF I_MBEWH.
    DATA: I_MBEWH1 LIKE I_MBEWH OCCURS 0 WITH HEADER LINE.
    *******For Moving Price***********
    DATA : BEGIN OF I_MBEW OCCURS 0,
              MATNR TYPE MBEWH-MATNR,
              BWTAR TYPE MBEWH-BWTAR,
              LBKUM TYPE MBEWH-LBKUM,
              VERPR TYPE MBEWH-VERPR,
              VPRSV TYPE MBEWH-VPRSV,
              STPRS TYPE MBEWH-STPRS,
           END OF I_MBEW.
    DATA : BEGIN OF I_RECIPT1 OCCURS 0,
           MATNR TYPE Z_MKPF_MSEG-MATNR,
           NAME1 TYPE LFA1-NAME1,
           MAKTX       TYPE MAKT-MAKTX,
           BWTAR TYPE Z_MKPF_MSEG-BWTAR,
           VERPR TYPE MBEWH-VERPR,
           PRDHA LIKE MARA-PRDHA,
           VTEXT(40) ,
           LBKUM TYPE MBEWH-LBKUM,
           SALK3 TYPE MBEWH-SALK3,
           QTY1 TYPE MBEWH-LBKUM,
           VAL1 TYPE P DECIMALS 2,
           QTY2 TYPE MBEWH-LBKUM,
           VAL2 TYPE P DECIMALS 2,
           QTY3 TYPE MBEWH-LBKUM,
           VAL3 TYPE P DECIMALS 2,
           QTY4 TYPE MBEWH-LBKUM,
           VAL4 TYPE P DECIMALS 2,
           QTY5 TYPE MBEWH-LBKUM,
           VAL5 TYPE P DECIMALS 2,
           QTY6 TYPE MBEWH-LBKUM,
           VAL6 TYPE P DECIMALS 2,
           QTY7 TYPE MBEWH-LBKUM,
           VAL7 TYPE P DECIMALS 2,
           END OF I_RECIPT1.
    DATA :   BEGIN OF I_MKPF_MSEG OCCURS 0,
      MATNR LIKE MARA-MATNR,
      MBLNR LIKE MSEG-MBLNR,
      ZEILE LIKE MSEG-ZEILE,
      MENGE LIKE MSEG-MENGE,
      BWART LIKE MSEG-BWART,
      BUDAT LIKE MKPF-BUDAT,
      NET_VAL LIKE MSEG-MENGE,
      EBELN LIKE MSEG-EBELN,
      EBELP LIKE MSEG-EBELP,
      LFBNR LIKE MSEG-LFBNR,
      LFPOS LIKE MSEG-LFPOS,
      SHKZG LIKE MSEG-SHKZG,
      MEINS LIKE MARA-MEINS,
      SMBLN LIKE MSEG-SMBLN,
      SMBLP LIKE MSEG-SMBLP,
      END OF I_MKPF_MSEG,
      WA_MSEG LIKE I_MKPF_MSEG.
    ********For Material Movement***
    DATA: BEGIN OF I_MSEG OCCURS 0,
            MBLNR TYPE Z_MKPF_MSEG-MBLNR,
            MATNR TYPE Z_MKPF_MSEG-MATNR,
            WERKS TYPE Z_MKPF_MSEG-WERKS,
            BWART TYPE Z_MKPF_MSEG-BWART,
            BUDAT TYPE Z_MKPF_MSEG-BUDAT,
            MENGE TYPE Z_MKPF_MSEG-MENGE,
            MEINS TYPE Z_MKPF_MSEG-MEINS,
            BWTAR TYPE Z_MKPF_MSEG-BWTAR,
            NET_VAL LIKE MSEG-MENGE,
            ZEILE TYPE MSEG-ZEILE,
          END OF I_MSEG.
    ********For Material Monvment(Reverse)***
    DATA: BEGIN OF I_MSEG1 OCCURS 0,
            MBLNR TYPE Z_MKPF_MSEG-MBLNR,
            MATNR TYPE Z_MKPF_MSEG-MATNR,
            WERKS TYPE Z_MKPF_MSEG-WERKS,
            BWART TYPE Z_MKPF_MSEG-BWART,
            BUDAT TYPE Z_MKPF_MSEG-BUDAT,
            MENGE TYPE Z_MKPF_MSEG-MENGE,
            MEINS TYPE Z_MKPF_MSEG-MEINS,
            BWTAR TYPE Z_MKPF_MSEG-BWTAR,
            SMBLN TYPE Z_MKPF_MSEG-SMBLN,
            SMBLP TYPE Z_MKPF_MSEG-SMBLP,
          END OF I_MSEG1.
    DATA: I_MSEG2 LIKE I_MSEG1 OCCURS 0 WITH HEADER LINE.
    ********For Recipt Details*******
    DATA: BEGIN OF I_RECIPT OCCURS 0,
           MATNR TYPE Z_MKPF_MSEG-MATNR,
           BWTAR TYPE Z_MKPF_MSEG-BWTAR,
           BUDAT TYPE Z_MKPF_MSEG-BUDAT,
           DAYS TYPE  P,
           QTY TYPE Z_MKPF_MSEG-MENGE,
           MONTH(3),
           YEAR(4),
           VERPR TYPE MBEWH-VERPR,
           COST TYPE P DECIMALS 2,
           MARK(1),
         END OF I_RECIPT.
    DATA: BEGIN OF I_PLANT OCCURS 0,
          WERKS  LIKE T024W-WERKS,
          EKORG  LIKE T024W-EKORG,
          BUKRS  LIKE T024E-BUKRS,
          CHK(1) TYPE C,
          END OF I_PLANT.
    DATA: BEGIN OF I_USERGRP OCCURS 0.
            INCLUDE STRUCTURE USGRP_USER.
    DATA: VKORG LIKE VBAK-VKORG,
          END OF I_USERGRP.
    DATA: MUGRP LIKE USGRP_USER-USERGROUP.
    DATA: MUNAME LIKE SY-UNAME,
          MMSGTX1(50) TYPE C.
    *********For Temp.Values*****
    *data: begin of i_temp occurs 0,
          matnr type z_mkpf_mseg-matnr,
          bwtar type z_mkpf_mseg-bwtar,
          budat type z_mkpf_mseg-budat,
          menge type z_mkpf_mseg-menge,
        end of i_temp.
    DATA: DAYS(2).
    DATA: NET_VAL LIKE MSEG-MENGE.
    DATA: DATE1 TYPE  D.
    DATA: DATE2 TYPE  D.
    DATA: MBLNR TYPE MSEG-MBLNR.
    DATA: MATNR TYPE MSEG-MATNR.
    DATA: BWTAR TYPE MSEG-BWTAR.
    DATA : V_DATE TYPE SY-DATUM.
    DATA : X(2) TYPE C VALUE '01'.
    DATA : P TYPE T009B-POPER.    " MONTH
    DATA : Q TYPE T009B-BDATJ.    " YEAR
    DATA : A TYPE T009B-POPER.  " FOR MONTH WHERE MONTH STARTS AT APRIL
    DATA : B(4) TYPE C.         " FOR YEAR
    DATA : DATE TYPE SY-DATUM.
    DATA:  NUMBER_OF_DAYS TYPE  P.
    DATA: DAT TYPE D.
    DATA : X1(2) .
    DATA: VPRSV TYPE MBEWH-VPRSV,
          STPRS TYPE MBEWH-STPRS.
    DATA: C TYPE C VALUE 0,
         S(10).
    Parameter /  Selection - screens
    SELECTION-SCREEN BEGIN OF BLOCK IND1 WITH FRAME TITLE TEXT_001.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(28) TEXT_002 FOR FIELD P_WERKS.
    PARAMETERS : P_WERKS LIKE S031-WERKS OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(28) TEXT_003 FOR FIELD P_SPMON.
    PARAMETERS : P_SPMON LIKE S031-SPMON MODIF ID ABC .
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) TEXT_004 FOR FIELD S_MATNR.
    SELECT-OPTIONS : S_MATNR FOR S031-MATNR.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK IND1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT_005.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) TEXT_006 FOR FIELD SO_MATTP.
    SELECT-OPTIONS : SO_MATTP FOR MARA-MTART.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) TEXT_007 FOR FIELD SO_MATGP.
    SELECT-OPTIONS : SO_MATGP FOR MARA-MATKL.
    SELECTION-SCREEN END OF LINE.
    begin of changes by cvns01
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) TEXT_008 FOR FIELD SO_MFRNR.
    SELECT-OPTIONS : SO_MFRNR FOR MARA-MFRNR.
    SELECTION-SCREEN END OF LINE.
    end of changes by cvns01
    *changes
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 1(25) TEXT_009 FOR FIELD SO_MFRNR.
    SELECT-OPTIONS : SO_PRDHA FOR MARA-PRDHA NO INTERVALS."NO-EXTENSION.
    SELECTION-SCREEN END OF LINE.
    *end
    SELECTION-SCREEN END OF BLOCK B2.
    Initialization
    INITIALIZATION.
      TEXT_001 = 'Required Data'.
      TEXT_002 = 'Plant'.
      TEXT_003 = 'Period to analyze - month'.
      TEXT_004 = 'Material Number'.
      TEXT_005 = 'Optional Data'.
      TEXT_006 = 'Material Type'.
      TEXT_007 = 'Material Group'.
    start of changes by cvns01
      TEXT_008 = 'Manufacturer No.'.
      TEXT_009 = 'Product Hierarchy'.
    end of changes by cvns01
      CLEAR:P,Q.
      CLEAR A.
      P = SY-DATUM+4(2).
      SHIFT P LEFT DELETING LEADING C.
      Q = SY-DATUM(4).
      IF P <= 9.
        CONCATENATE  Q '0' P INTO S. "p_spmon.
      ELSE.
        CONCATENATE  Q P INTO S. "p_spmon.
      ENDIF.
    *concatenate q p into s. "p_spmon.
      CONDENSE S.
      P_SPMON = S.
    AT SELECTION-SCREEN ON WERKS
    AT SELECTION-SCREEN ON P_WERKS.
      CHECK SY-UCOMM = 'ONLI'.
      SELECT SINGLE * FROM T001W WHERE WERKS EQ P_WERKS.
      IF SY-SUBRC NE 0.
        MESSAGE E999 WITH 'Invalid Plant'.
      ENDIF.
      SELECT T024W~WERKS T024E~EKORG T024E~BUKRS
          INTO CORRESPONDING FIELDS OF TABLE I_PLANT
          FROM T024W
          JOIN T024E ON T024E~EKORG = T024W~EKORG
          WHERE T024W~WERKS EQ P_WERKS.
      SORT I_PLANT BY WERKS.
      DELETE ADJACENT DUPLICATES FROM I_PLANT COMPARING WERKS.
      SELECT * INTO CORRESPONDING FIELDS OF TABLE I_USERGRP
            FROM USGRP_USER
            WHERE BNAME = SY-UNAME.
      IF I_USERGRP[] IS INITIAL.
        MESSAGE E208(00) WITH 'You are not authorised to view this report'.
      ENDIF.
      LOOP AT I_USERGRP.
        CONCATENATE I_USERGRP-USERGROUP(2) '00' INTO I_USERGRP-VKORG.
        MODIFY I_USERGRP.
      ENDLOOP.
      LOOP AT I_USERGRP.
        LOOP AT I_PLANT WHERE BUKRS = I_USERGRP-VKORG.
          I_PLANT-CHK = 'X'.
          MODIFY I_PLANT.
        ENDLOOP.
      ENDLOOP.
    *delete i_plant where chk = ''.
      IF NOT I_PLANT[] IS INITIAL.
        LOOP AT I_PLANT.
          IF I_PLANT-CHK = ''.
            CLEAR P_WERKS.
            CONCATENATE 'You are not authorised for plant ' I_PLANT-WERKS INTO MMSGTX1 SEPARATED BY SPACE.
            MESSAGE E208(00) WITH MMSGTX1.
          ENDIF.
        ENDLOOP.
      ENDIF.
      IF P_WERKS = ''.
        MESSAGE E208(00) WITH 'Select/Enter Plant'.
      ENDIF.
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF SCREEN-GROUP1 = 'ABC'.
          SCREEN-INPUT = '0'.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    AT SELECTION-SCREEN
    *AT SELECTION-SCREEN .
    SELECT SINGLE * FROM s031 WHERE werks EQ p_werks
                                 AND spmon EQ p_spmon
                                 AND matnr IN s_matnr.
    IF sy-subrc NE 0.
       MESSAGE e999 WITH 'NO VALUES EXIST FOR SELECTION CRITERIA'.
    ENDIF.
    START-OF-SELECTION
    START-OF-SELECTION.
      PERFORM PRDHA_INITIALIZATION.
      PERFORM FETCH_DATA.
      PERFORM DISPLAY_DATA.
    END-OF-SELECTION.
    *&      Form  FETCH_DATA
          text
    -->  p1        text
    <--  p2        text
    FORM FETCH_DATA .
      CLEAR:P,Q.
      CLEAR A.
      P = P_SPMON+4(2).
      Q = P_SPMON+0(4).
    ******Materials**********************************
    changes made by akshatha
      SELECT MARA~MATNR
             FROM MARA
             JOIN MARC
             ON MARCMATNR = MARAMATNR
             INTO CORRESPONDING FIELDS OF TABLE I_MARA
             WHERE MARA~MATNR IN S_MATNR
               AND MARC~WERKS = P_WERKS
               AND MARA~MTART IN SO_MATTP
               AND MARA~MATKL IN SO_MATGP
               AND MARA~MFRNR IN SO_MFRNR
               AND MARA~PRDHA IN SO_PRDHA.
    end of changes
    To get material description for the material
      IF NOT I_MARA[] IS INITIAL.
        SELECT MATNR
               MAKTX
               FROM MAKT
               INTO CORRESPONDING FIELDS OF TABLE I_MAKT
               FOR ALL ENTRIES IN I_MARA
               WHERE MATNR = I_MARA-MATNR
                 AND SPRAS = SY-LANGU.
    TO GET OPEN BALANCE QTY WE NEED TO CONSIDER PREVIOUS MONTH OF THE
    CORRESPONDING PERIOD
    WE WILL GET PROBLEM ONLY PROBLEM WHEN PERIOD IS '01'. THEN WE MUST
    CONSIDER FOR 12 TH MONTH OF PREVIOUS YEAR.
    ****Closing Stock as on Selection-Screen Month....
    *By Default last date of month is taken
    changed by akshatha
        CONCATENATE P_SPMON X INTO V_DATE.
        CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
          EXPORTING
            I_DATE               = V_DATE
      I_MONMIT             = 00
            I_PERIV              = 'V3'
         IMPORTING
           E_BUPER              = A
           E_GJAHR              = Q
         EXCEPTIONS
           INPUT_FALSE          = 1
           T009_NOTFOUND        = 2
           T009B_NOTFOUND       = 3
           OTHERS               = 4 .
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    to get stock quantity
        SELECT MATNR LBKUM SALK3 BWKEY LFGJA LFMON
               FROM MBEWH
               INTO CORRESPONDING FIELDS OF TABLE I_MBEWH
               FOR ALL ENTRIES IN I_MARA
               WHERE MATNR = I_MARA-MATNR
               AND BWKEY = P_WERKS           AND BWTAR IN S_BWTAR
                 AND LFGJA = Q
                 AND LFMON = A
                 AND LBKUM > '0.0'.
        SELECT MATNR LBKUM SALK3 BWKEY VBELN POSNR LFGJA LFMON
                FROM EBEWH
                APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH
                WHERE MATNR = I_MARA-MATNR
                 AND BWKEY = P_WERKS
                 AND BWTAR IN S_BWTAR
                 AND LFGJA = Q
                 AND LFMON = A
                 AND LBKUM > '0.0'.
              and VPRSV = 'S'.
        SELECT MATNR LBKUM SALK3 BWKEY SOBKZ PSPNR LFGJA LFMON
                FROM QBEWH
                APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH
                WHERE MATNR = I_MARA-MATNR
                 AND BWKEY = P_WERKS
                 AND BWTAR IN S_BWTAR
                 AND LFGJA = Q
                 AND LFMON = A
                 AND LBKUM > '0.0'.
        SELECT MATNR LBKUM SALK3 BWKEY BWTAR
                 FROM MBEW
                 INTO CORRESPONDING FIELDS OF TABLE I_MBEWH1
                 FOR ALL ENTRIES IN I_MARA
                 WHERE MATNR = I_MARA-MATNR
                 AND BWKEY = P_WERKS
                 AND LBKUM > '0.0'.
        SELECT MATNR LBKUM SALK3 BWKEY VBELN POSNR SOBKZ BWTAR
                 FROM EBEW
                 APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH1
                 FOR ALL ENTRIES IN I_MARA
                 WHERE MATNR = I_MARA-MATNR
                        AND BWKEY = P_WERKS
                        AND LBKUM > '0.0'.
        SELECT MATNR LBKUM SALK3 BWKEY BWTAR SOBKZ PSPNR
                 FROM QBEW
                 APPENDING CORRESPONDING FIELDS OF TABLE I_MBEWH1
                 FOR ALL ENTRIES IN I_MARA
                 WHERE MATNR = I_MARA-MATNR
                        AND BWKEY = P_WERKS
                        AND LBKUM > '0.0'.
        SORT I_MBEWH BY MATNR BWKEY.
        SORT I_MBEWH1 BY MATNR BWKEY.
        LOOP AT I_MBEWH.
          LOOP AT I_MBEWH1 WHERE MATNR = I_MBEWH-MATNR
                             AND BWKEY = I_MBEWH-BWKEY.
            DELETE I_MBEWH1.
          ENDLOOP.
        ENDLOOP.
        APPEND LINES OF I_MBEWH1 TO I_MBEWH.
        CLEAR : I_MBEWH1.
        REFRESH I_MBEWH1.
        SORT I_MBEWH BY MATNR.
        LOOP AT I_MBEWH .
          I_MBEWH1 = I_MBEWH.
          AT END OF MATNR.
            SUM.
            I_MBEWH1-LBKUM = I_MBEWH-LBKUM.
            I_MBEWH1-SALK3 = I_MBEWH-SALK3.
            APPEND I_MBEWH1.
          ENDAT.
        ENDLOOP.
        DELETE I_MBEWH1 WHERE LBKUM <= 0.
        I_MBEWH[] = I_MBEWH1[].
    end of changes
    loop at i_mara.
       concatenate p_spmon x into v_date.
       call function 'DATE_TO_PERIOD_CONVERT'
         exporting
           i_date               = v_date
      I_MONMIT             = 00
           i_periv              = 'V3'
        importing
          e_buper              = a
          e_gjahr              = q
        exceptions
          input_false          = 1
          t009_notfound        = 2
          t009b_notfound       = 3
          others               = 4 .
       if sy-subrc <> 0.
         message id sy-msgid type sy-msgty number sy-msgno
                 with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
       endif.
    To get STOCK QUANTITY and STOCK VALUE for All Valuation Type
       select  matnr
               bwtar
               lbkum
               salk3
              from mbewh
              into corresponding fields of i_mbewh
              where matnr = i_mara-matnr
                and bwkey = p_werks
                and lfmon = a         " 'A' IS PERIOD FOR FISCAL YR
                and lfgja = q.
           collect i_mbewh.
           clear i_mbewh.
       endselect.
       if sy-subrc ne 0.
         select       matnr
                      bwtar
                      lbkum
                      salk3
                      from mbew
                      into corresponding fields of i_mbewh
                       where matnr = i_mara-matnr
                         and bwkey = p_werks.
             collect i_mbewh.
             clear i_mbewh.
         endselect.
       endif.
    endloop.
    end of changes
    Logic: If the Val. Type is defined then for that material dont take
    the line item where Val. Type is blank......
    sort  i_mbewh by matnr bwtar.
    i_mbewh1[] = i_mbewh[].
    delete i_mbewh where bwtar = ' '.
    loop at i_mbewh1.
       read table i_mbewh with key matnr = i_mbewh1-matnr.
       if sy-subrc <> 0.
         move-corresponding i_mbewh1 to i_mbewh.
         append i_mbewh.
       endif.
    endloop.
    sort  i_mbewh by matnr bwtar.
    i_mbewh1[] = i_mbewh[].
    end of changes
    *****************Last Date of the month is Calculated to find Qty
        DAT = V_DATE.
        CALL FUNCTION 'HR_E_NUM_OF_DAYS_OF_MONTH'
          EXPORTING
            P_FECHA        = DAT
          IMPORTING
            NUMBER_OF_DAYS = NUMBER_OF_DAYS.
        X1 =  NUMBER_OF_DAYS.
        CONCATENATE P_SPMON X1 INTO DATE.
    ********RECIPT QTY FETCHING*************************
    select          mblnr
                     matnr
                     bwart
                     budat
                     menge
                     meins
                     bwtar
                     zeile
                     from z_mkpf_mseg
                     into  (i_mseg-mblnr,
                            i_mseg-matnr,
                            i_mseg-bwart,
                            i_mseg-budat,
                            i_mseg-menge,
                            i_mseg-meins,
                            i_mseg-bwtar,
                            i_mseg-zeile)
              for all entries in i_mbewh
              where matnr = i_mbewh-matnr and werks = p_werks
                and  ( budat le date or budat eq date )
                and bwart in ('101','561','501','951','953','955',
    **'957','301','105')
                and bwtar = i_mbewh-bwtar.
       append i_mseg.
       clear i_mseg.
    endselect.
    select          mblnr
                     matnr
                     bwart
                    budat
                     menge
                     meins
                     bwtar
                     zeile
                     from mseg "z_mkpf_mseg
                     into corresponding fields of table i_mseg
                           (i_mseg-mblnr,
                            i_mseg-matnr,
                            i_mseg-bwart,
                            i_mseg-budat,
                            i_mseg-menge,
                            i_mseg-meins,
                            i_mseg-bwtar,
                            i_mseg-zeile)
              for all entries in i_mbewh
              where matnr = i_mbewh-matnr and werks = p_werks
                and  ( budat le date or budat eq date )
                and bwart in ('101','561','501','951','953','955',
    ***'957','301','105')
                and bwart in ('101','561','501','951','953','955',
    *'957','301','309','105')
               and bwtar = i_mbewh-bwtar.
    loop at i_mseg.
       select single * from mkpf
              where mblnr = i_mseg-mblnr.
       if ( mkpf-budat ge date ).
         delete i_mseg where mblnr = i_mseg-mblnr.
       else.
         i_mseg-budat = mkpf-budat.
         modify i_mseg.
       endif.
    endloop.
    sort i_mseg descending by matnr bwtar budat.
    **********For Reversal FOR RECIPT(CHECK FOR REFERENCE)
    **********(102,562,502,952,954,956,958)
              select mblnr
                     matnr
                     bwart
                     menge
                     meins
                     bwtar
                     smbln
                     smblp
                     from mseg
                     into corresponding fields of table i_mseg1
              for all entries in i_mbewh
              where matnr = i_mbewh-matnr and werks = p_werks
              and bwart in ('102','562','502','952','954','956','958','302')
                and bwtar = i_mbewh-bwtar.
    loop at i_mseg1.
       select single * from mkpf
              where mblnr = i_mseg1-mblnr.
       if ( mkpf-budat ge date ).
         delete i_mseg1 where mblnr = i_mseg1-mblnr.
       else.
         i_mseg1-budat = mkpf-budat.
         modify i_mseg1.
       endif.
    endloop.
    loop at i_mseg1.
       read table i_mseg with key mblnr = i_mseg1-smbln
                                  zeile = i_mseg1-smblp.
       if  sy-subrc = 0.
         i_mseg-menge = i_mseg-menge - i_mseg1-menge.
         delete i_mseg where mblnr = i_mseg1-smbln and
                             zeile = i_mseg1-smblp.
         move-corresponding i_mseg to i_mseg2.
         append i_mseg2.
       endif.
    endloop.
    loop at i_mseg2.
       move-corresponding i_mseg2 to i_mseg.
       append i_mseg.
    endloop.
    end of changes.
        SELECT MSEGMATNR MSEGMBLNR MSEGZEILE MSEGMENGE MSEGBWART MSEGEBELN
               MSEGEBELP MSEGSMBLN MSEG~SMBLP
               MKPFBUDAT MSEGSHKZG
               FROM MKPF
               JOIN MSEG ON MSEGMBLNR = MKPFMBLNR
                        AND MSEGMJAHR = MKPFMJAHR
                          INTO CORRESPONDING FIELDS OF TABLE I_MKPF_MSEG
                              FOR ALL ENTRIES IN I_MARA
                            WHERE MSEG~MATNR = I_MARA-MATNR
                              AND MSEG~WERKS = P_WERKS
                              AND MKPF~BUDAT LE DATE
                              AND MSEG~BWART IN ('101','105','561','501','301','309','951','953','955','957','712','657','658',
                                                 '521','522','303','304','102','562','502','952','954','956','958','302').
        DELETE  I_MKPF_MSEG WHERE  ( BWART = '309' AND SHKZG = 'H' )
                                OR ( BWART = '303' AND SHKZG = 'H' )
                                OR ( BWART = '304' AND SHKZG = 'S' )
                                OR ( BWART = '657' AND SHKZG = 'H' )
                                OR ( BWART = '658' AND SHKZG = 'S' ).
        SORT I_MKPF_MSEG BY MATNR MBLNR.
        LOOP AT I_MKPF_MSEG.
       if i_mkpf_mseg-bwart = '101' or i_mkpf_mseg-bwart = '102'.
         select single * from ekpo  where ebeln = i_mkpf_mseg-ebeln
                                      and ebelp = i_mkpf_mseg-ebelp.
         if ekpo-pstyp = 7.
           delete i_mkpf_mseg where ebeln = i_mkpf_mseg-ebeln
                                and ebelp = i_mkpf_mseg-ebelp.
           CLEAR I_MKPF_MSEG-MENGE.
         endif.
       endif.
          IF ( I_MKPF_MSEG-BWART = '101' OR I_MKPF_MSEG-BWART = '105' OR I_MKPF_MSEG-BWART = '561' OR
               I_MKPF_MSEG-BWART = '501' OR I_MKPF_MSEG-BWART = '301' OR I_MKPF_MSEG-BWART = '309' OR
               I_MKPF_MSEG-BWART = '951' OR I_MKPF_MSEG-BWART = '953' OR I_MKPF_MSEG-BWART = '955' OR
               I_MKPF_MSEG-BWART = '957' OR I_MKPF_MSEG-BWART = '303' OR I_MKPF_MSEG-BWART = '521' OR
               I_MKPF_MSEG-BWART = '712' OR I_MKPF_MSEG-BWART = '657' ).
            NET_VAL = NET_VAL + I_MKPF_MSEG-MENGE.
          ENDIF.
          LOOP AT I_MKPF_MSEG WHERE MATNR = I_MKPF_MSEG-MATNR.
            IF ( I_MKPF_MSEG-BWART = '102' OR I_MKPF_MSEG-BWART = '562' OR
                 I_MKPF_MSEG-BWART = '502' OR I_MKPF_MSEG-BWART = '952' OR
                 I_MKPF_MSEG-BWART = '954' OR I_MKPF_MSEG-BWART = '956' OR
                 I_MKPF_MSEG-BWART = '958' OR I_MKPF_MSEG-BWART = '302' OR
                 I_MKPF_MSEG-BWART = '304' OR I_MKPF_MSEG-BWART = '522' OR
                 I_MKPF_MSEG-BWART = '658' ) AND
               ( I_MKPF_MSEG-MBLNR = I_MKPF_MSEG-SMBLN AND
                 I_MKPF_MSEG-ZEILE = I_MKPF_MSEG-SMBLP ).
              NET_VAL = NET_VAL - I_MKPF_MSEG-MENGE.
              DELETE I_MSEG WHERE MBLNR = I_MSEG1-SMBLN AND
                                  ZEILE = I_MSEG1-SMBLP.
            ENDIF.
          ENDLOOP.
          WA_MSEG = I_MKPF_MSEG.
          AT END OF MATNR.
            I_MSEG-MATNR  = WA_MSEG-MATNR.
            I_MSEG-MENGE = NET_VAL.
            I_MSEG-BUDAT = WA_MSEG-BUDAT.
            APPEND I_MSEG.
            CLEAR NET_VAL.
          ENDAT.
        ENDLOOP.
    end of changes
        DELETE I_MSEG WHERE MENGE = '0.000'.
        SORT I_MSEG DESCENDING BY MATNR BWTAR BUDAT.
    ***#******RECIPT COMPLETE FINAL TABLE( I_MSEG)**********
    ********IF THE VAL. TYPE IS NOT THERE THEN PUT 'X'
    loop at i_mbewh.
       if  i_mbewh-bwtar = ' '.
         i_mbewh-bwtar = 'X'.
         modify i_mbewh.
       endif.
    endloop.
    delete i_mbewh where lbkum = '0.00'.
    end of changes
    loop at i_mseg.
       if  i_mseg-bwtar = ' '.
         i_mseg-bwtar = 'X'.
         modify i_mseg.
       endif.
    endloop.
    end of changes
        DATA: MENGE TYPE MSEG-MENGE.
    start of changes by akshatha
        SORT I_MSEG BY MATNR BWTAR.
        SORT I_MBEWH BY MATNR BWTAR.
        LOOP AT I_MSEG.
    if condition, read and it_mseg-loop commented by akshatha.
       if i_mbewh-lbkum > '0.00'.
       read table i_mbewh with key matnr = i_mseg-matnr
                                  bwtar = i_mseg-bwtar.
         loop at i_mseg .
           if ( i_mseg-mblnr <> mblnr ) and ( i_mseg-matnr ne i_temp-matnr
                or i_mseg-bwtar ne i_temp-bwtar ) .
       i_temp-matnr = i_mseg-matnr.
       i_temp-bwtar = i_mseg-bwtar.
       i_temp-budat = i_mseg-budat.
       i_temp-menge = i_mseg-menge.
             mblnr = i_mseg-mblnr.
             matnr = i_mseg-matnr.
             bwtar = i_mseg-bwtar.
       append i_temp.
    end of changes
             delete i_mseg .
             loop at i_mbewh where  matnr = matnr
                                and bwtar = bwtar.
    end of changes
          LOOP AT I_MBEWH WHERE  MATNR = I_MSEG-MATNR
                             AND BWTAR = I_MSEG-BWTAR.
    FOR GETTING THE VALUES OF ISSUES ON & UPTO THE DATE OF RECIPT.
    DELETE THE ISSUE QTY FROM STOCK SO THAT WE CAN GET THE EXACT STOCK
    VALUE ON THE DATE WHEN RECIPT OF MATERIAL HAS HAPPEN
    ISSUES R NOTHING BUT TYPE OF CONSUPTION.
    commented and changed by akshatha
         if ( i_mbewh-lbkum >= i_temp-menge ).
            IF ( I_MBEWH-LBKUM >= I_MSEG-MENGE ).
              I_RECIPT-MATNR = I_MBEWH-MATNR.
              I_RECIPT-BWTAR = I_MBEWH-BWTAR.
           i_recipt-budat = i_temp-budat.
              I_RECIPT-BUDAT = I_MSEG-BUDAT.
    end of changes
    *Type Conversion From Sy-datum to type d.
              DATE1 = DATE.
              DATE2 = I_RECIPT-BUDAT.
    *Type Conversion From Sy-datum to type d.
              CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
                EXPORTING
                  DATE1    = DATE1
                  TIME1    = SY-UZEIT
                  DATE2    = DATE2
                  TIME2    = SY-UZEIT
                IMPORTING
                  DATEDIFF = I_RECIPT-DAYS.
              IF SY-SUBRC <> 0.
              ENDIF.
           i_recipt-qty   = i_temp-menge.
              I_RECIPT-QTY   = I_MSEG-MENGE.
           i_mbewh-lbkum = i_mbewh-lbkum - i_temp-menge.
              I_MBEWH-LBKUM = I_MBEWH-LBKUM - I_MSEG-MENGE.
         elseif ( i_mbewh-lbkum < i_temp-menge ).
            ELSEIF ( I_MBEWH-LBKUM < I_MSEG-MENGE ).
              I_RECIPT-MATNR = I_MBEWH-MATNR.
              I_RECIPT-BWTAR = I_MBEWH-BWTAR.
           i_recipt-budat = i_temp-budat.
              I_RECIPT-BUDAT = I_MSEG-BUDAT.
    *Type Conversion From Sy-datum to type d.
              DATE1 = DATE.
              DATE2 = I_RECIPT-BUDAT.
    *Calculation of Difference of dates
              CALL FUNCTION 'SD_DATETIME_DIFFERENCE'
                EXPORTING
                  DATE1    = DATE1
                  TIME1    = SY-UZEIT
                  DATE2    = DATE2
                  TIME2    = SY-UZEIT
                IMPORTING
                  DATEDIFF = I_RECIPT-DAYS.
              IF SY-SUBRC <> 0.
              ENDIF.
              I_RECIPT-QTY   = I_MBEWH-LBKUM.
              I_MBEWH-LBKUM = '0.00'.
            ENDIF.
            MODIFY I_MBEWH.
            APPEND I_RECIPT.
               exit.
    end of changes
          ENDLOOP.
    endif.
          IF  I_MBEWH-LBKUM <> '0.00'.
         clear i_temp.
            CLEAR I_MSEG.
          ENDIF.
         endloop.
       endif.
      end of changes
        ENDLOOP.
    **********FINAL RECIPT TABLE WITH AGE
        SORT I_RECIPT BY MATNR BWTAR DAYS.
        LOOP AT I_RECIPT.
    *Calculation of Fiscal yr for moving price.
          PERFORM PERIOD_CALCULATION USING  I_RECIPT-BUDAT+4(2)
            I_RECIPT-BUDAT+0(4)  I_RECIPT-MONTH
            I_RECIPT-YEAR.
          IF I_RECIPT-BWTAR = 'X'.
            I_RECIPT-BWTAR = ' '.
          ENDIF.
    **************Moving Price for All material for all months......
         SELECT  SINGLE VERPR
                    VPRSV
                    STPRS
                    FROM MBEWH
                    INTO  (I_RECIPT-VERPR,
                          VPRSV,
                          STPRS )
                   WHERE MATNR = I_RECIPT-MATNR
                     AND BWTAR = I_RECIPT-BWTAR
                     AND BWKEY = P_WERKS
                     AND LFMON = I_RECIPT-MONTH
                     AND LFGJA = I_RECIPT-YEAR
                     and lbkum = i_recipt-qty.
         IF SY-SUBRC <> 0.
           SELECT  SINGLE VERPR
                      VPRSV
                      STPRS
                      FROM MBEW
                      INTO  (I_RECIPT-VERPR,
                            VPRSV,
                            STPRS )
                     WHERE MATNR = I_RECIPT-MATNR
                       AND BWKEY = P_WERKS
                     and lbkum = i_recipt-qty.
         ENDIF.
         IF I_RECIPT-VERPR IS INITIAL.
           SELECT SINGLE VERPR
                      VPRSV
                      STPRS
                      FROM EBEWH
                      INTO  (I_RECIPT-VERPR,
                            VPRSV,
                            STPRS )
                     WHERE MATNR = I_RECIPT-MATNR
                       AND BWTAR = I_RECIPT-BWTAR
                       AND BWKEY = P_WERKS
                       AND LFMON = I_RECIPT-MONTH
                       AND LFGJA = I_RECIPT

    Never mind. I updated my aperture in app store and it fixed the problem. Thank you.

  • Currency Translation based on Last Day of the Acquistion month

    Dear all,
                Request to help me in understanding how we can calculate the currency translation rate as per the last day if the acquistion month..
    For Example if the  Acquistion date : 01/01/2008 (mm/dd/yyyy) the currency translation should happend based on the rate maintained as on 31/01/2008.
    Thanks
    Pavan Kumar Prakhya

    First, you will need to convert the actual acquisition date to the end date of the Fiscal Period. This can be done by using two separate Function Modules. First, get the actual Fiscal Period by entering the date and Fiscal Year Variant into the DATE_TO_PERIOD_CONVERT Function Module. Use the Fiscal Year and Fiscal Period from this and determine the end date of the Fiscal Period by using Function Module LAST_DAY_IN_PERIOD_GET with Fiscal Year, Fiscal Period and Fiscal Year Variant as your inputs.
    For the conversion, use the Function Module CONVERT_TO_LOCAL_CURRENCY. The inputs for this would be the last date of the Fiscal Period, the amount to be converted, the from currency code, the to currency code, blank in rate, AS01 in type of rate and X in read TCURR. This assumes, however, that month-end rates (rate type = AS01) have been loaded into your source system and these rates have been transferred to your BW environment.

  • Pop up message on the variable screen in portal when report is run

    Hello
    I have a requirement to pop up a message stating " Date should not be entered before 2010 "on the variable screen of the report if date is entered before 2010 by the user when the report is run.
    Please can someone tell me how to implement this?
    thanks

    Hi Tom,
    The logic could be to include code in CMOD forat variable with ISTEP=2.
    IF I_STEP = 2.
    LOOP AT i_t_var_range into wa_t_var_range where vnam = 'Date Varaible'
    <write condition to check the year entered. First, using function module DATE_TO_PERIOD_CONVERT, extract year from Date>
    <   CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
            EXPORTING
              I_DATE               = ZT_SDT
            I_MONMIT             = 00
              I_PERIV              = 'Variant'
           IMPORTING
             E_BUPER              = zbuper
             E_GJAHR              = zbdatj this is the year entered
           EXCEPTIONS
             INPUT_FALSE          = 1
             T009_NOTFOUND        = 2
             T009B_NOTFOUND       = 3
             OTHERS               = 4>
    >
    Then check the year for the condition.
    If correct.
    exit.
    else.
    CALL FUNCTION 'RRMS_MESSAGE_HANDLING'
    EXPORTING
    I_CLASS = 'RSBBS'
    I_TYPE = 'E'
    I_NUMBER = '000'
    I_MSGV1 = 'Date should not be entered before 2010'.
    raise again.
    endif.
    endif.
    endloop.
    Hope this helps you.!
    -Pradnya

  • Opening stock of a month

    Hi All,
    I got this code from SDN for closing and opening stock,but it is not showing any out put can any one check this once.
    tables:mardh.
    DATA : it_mard LIKE mard OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF t_mard OCCURS 0 ,
           matnr LIKE mseg-matnr,
           labst LIKE mard-labst,
           END OF t_mard.
    DATA : it_mardh TYPE mardh.
    DATA : buper LIKE t009b-poper,
           gjahr LIKE t009b-bdatj.
    DATA : p_buper LIKE t009b-poper,
           p_gjahr LIKE t009b-bdatj.
    DATA : dt LIKE sy-datum,
           CLOSING_STOCK type c,
           CURRENT_STOCK type c.
    parameters : P_werks like mardh-werks.
    *CLOSING STOCK OF PREVIOUS PERIOD
    dt = sy-datum.
    *get current period
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    EXPORTING
      i_date = dt
       i_periv = 'M3' "apr to march 4 spl periods
    IMPORTING
    e_buper = buper
       e_gjahr = gjahr
    EXCEPTIONS
       input_false = 1
       t009_notfound = 2
       t009b_notfound = 3
    OTHERS = 4.
    *fetch previous period
    CALL FUNCTION 'CKML_F_GET_PREVIOUS_PERIOD'
    EXPORTING
      input_period = buper
      input_year = gjahr
      input_periv = 'M3'
    IMPORTING
      previous_period = p_buper
      previous_year = p_gjahr.
    *SELECT SINGLE * FROM mardh
    *WHERE matnr = p_matnr
    *AND werks = p_werks
    *AND lfmon = p_buper
    *AND lfgja = p_gjahr.
    IF sy-subrc = 0.
    CLOSING_STOCK = mardh-labst.
    ENDIF.
    *to calculate current stock-----
    SELECT * FROM mard
    INTO CORRESPONDING FIELDS OF TABLE it_mard
    WHERE matnr = it_mard-matnr
    AND werks = p_werks.
    IF NOT it_mard[] IS INITIAL.
    LOOP AT it_mard.
    t_mard-matnr = it_mard-matnr.
    t_mard-labst = it_mard-labst.
    COLLECT t_mard.
    ENDLOOP.
    READ TABLE t_mard INDEX 1.
    CURRENT_STOCK = t_mard-labst.
    ENDIF.

    Hi,
    You can use MBEWH (history stock) and MBEW( current stock) for the valuated stock report. If you want to take details of transaction, you might have to go to MKPF+MSEG tables.
    Thanks and regards,
    S. Chandra mouli.

  • Open stock and closing stock

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

    hi
    good
    DATA : it_mard LIKE mard OCCURS 0 WITH HEADER LINE.
    DATA : BEGIN OF t_mard OCCURS 0 ,
    matnr LIKE mseg-matnr,
    labst LIKE mard-labst,
    END OF t_mard.
    DATA : it_mardh TYPE mardh.
    DATA : buper LIKE t009b-poper,
    gjahr LIKE t009b-bdatj.
    DATA : p_buper LIKE t009b-poper,
    p_gjahr LIKE t009b-bdatj.
    DATA : dt LIKE sy-datum.
    *CLOSING STOCK OF PREVIOUS PERIOD
    dt = sy-datum.
    *get current period
    CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
    EXPORTING
    i_date = dt
    i_periv = 'M3' "apr to march 4 spl periods
    IMPORTING
    e_buper = buper
    e_gjahr = gjahr
    EXCEPTIONS
    input_false = 1
    t009_notfound = 2
    t009b_notfound = 3
    OTHERS = 4.
    *fetch previous period
    CALL FUNCTION 'CKML_F_GET_PREVIOUS_PERIOD'
    EXPORTING
    input_period = buper
    input_year = gjahr
    input_periv = 'M3'
    IMPORTING
    previous_period = p_buper
    previous_year = p_gjahr.
    SELECT SINGLE * FROM mardh
    WHERE matnr = p_matnr
    AND werks = p_werks
    AND lfmon = p_buper
    AND lfgja = p_gjahr.
    IF sy-subrc = 0.
    CLOSING STOCK = mardh-labst.
    ENDIF.
    *to calculate current stock-----
    SELECT * FROM mard
    INTO CORRESPONDING FIELDS OF TABLE it_mard
    WHERE matnr = it_marc-matnr
    AND werks = p_werks.
    IF NOT it_mard[] IS INITIAL.
    LOOP AT it_mard.
    t_mard-matnr = it_mard-matnr.
    t_mard-labst = it_mard-labst.
    COLLECT t_mard.
    ENDLOOP.
    READ TABLE t_mard INDEX 1.
    CURRENT STOCK= t_mard-labst.
    ENDIF.
    thanks
    mrutyun^

  • Extract Month & Year  From Date

    Hi All,
    I have a key figure quantity and i want the data on date,for the month and for the year.
    i create the variables for the date,for the month(ie from date to date) and for the year(ie, from date to date) seperatly that means i have three input variables which may sometimes create confusion.
    My problem is that I want to enter only date and the variable itself calculate the month and year from the date so that it returns the data as desired above.
    for eg. : Now i to enter date : 3/14/2009
              enter MTD (FROM/TO) : 3/01/2009 - 3/14/2009
              enter YTD (FROM/TO) : 4/01/2008 - 3/14/2009
    I want to enter only date : 3/14/2009
    and the variable itself extract the month and year till date.
    and also the same variable calculates number of days so that need not to take the formula variable of date difference to calculate the average qty.
    Neha..

    Hi,
    1. Create User Entry Variable on 0CALDAY : Name = ZCDAY.
    2. Craete a Customer Exit Variable on 0CALDAY: Name  = ZMTD.
    3. Craete a Customer Exit Variable on 0CALDAY: Name  = YMTD.
    Properties of Customer Exit Variables.
    Variable reporesents = Single
    Variable Entry = Mandatory
    Processing By = Customer Exit.
    Character = Calender Day
    Here I'm thinking that ZKF is your key figure.
    In columns you create two selections one is for MTD and other is for YTD.
    In MTD selection, drag and drop ZKF and Drag and Drop 0CALDAY and then Right Clcik and Restrict-->
    Selection = Value Range. (In Between) and restrict with the follwoing Variables
    []ZMTD; ZCDAY.
    In YTD selection, drag and drop ZKF and Drag and Drop 0CALDAY and then Right Clcik and Restrict-->
    Selection = Value Range. (In Between) and restrict with the follwoing Variables
    []YTD; ZCDAY.
    Then write the following code in I_STEP = 2.
    DATA: ZT_DT1 TYPE SY-DATUM,
              ZT_DT2 TYPE SY-DATUM,
              ZT_SDT TYPE SY-DATUM,
              ZT_YR(4) TYPE N,
              ZT_DY(2) TYPE N,
              ZT_MT(2) TYPE N,
              ZE_TT(2) TYPE N,
              ZPOPER TYPE POPER,
             ZRELJR TYPE RELJR.
    WHEN 'ZMTD_A'.
      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
        IF sy-subrc = 0.
          CLEAR: l_s_range.
          ZT_DY = '01'.
          ZT_SDT = loc_var_range-low.
          ZT_MT = ZT_SDT+4(2).
          ZT_YR = ZT_SDT+0(4).
          CONCATENATE ZT_YR ZT_MT ZT_DY INTO ZT_DT1.
          l_s_range-low = ZT_DT1.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
      ENDLOOP.
    WHEN 'ZYTD'.
      LOOP AT i_t_var_range INTO loc_var_range WHERE vnam = 'ZCDAY'.
        IF sy-subrc = 0.
          CLEAR: l_s_range.
          ZT_DY = '01'.
          ZT_SDT = loc_var_range-low.
          CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
            EXPORTING
              I_DATE               = ZT_SDT
    *         I_MONMIT             = 00
              I_PERIV              = 'V3'
           IMPORTING
             E_BUPER              = zbuper
             E_GJAHR              = zbdatj
           EXCEPTIONS
             INPUT_FALSE          = 1
             T009_NOTFOUND        = 2
             T009B_NOTFOUND       = 3
             OTHERS               = 4
          IF SY-SUBRC <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          CALL FUNCTION 'FIRST_AND_LAST_DAY_IN_YEAR_GET'
            EXPORTING
              I_GJAHR              = zbdatj
              I_PERIV              = 'V3'
           IMPORTING
             E_FIRST_DAY          = ZT_DT2
    *         E_LAST_DAY           =
           EXCEPTIONS
             INPUT_FALSE          = 1
             T009_NOTFOUND        = 2
             T009B_NOTFOUND       = 3
             OTHERS               = 4
          IF SY-SUBRC <> 0.
             MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          l_s_range-low = ZT_DT2.
          l_s_range-sign = 'I'.
          l_s_range-opt = 'EQ'.
          APPEND l_s_range TO e_t_range.
        ENDIF.
      ENDLOOP.
    Thanks
    Reddy

  • Fiscal Period in 0PA_C01

    The cube 0PA_C01 works on the basis of calmonth and it is easy to map it to fiscal period if each fiscal period corresponds to a whole calendar month.
    But we are facing a peculiar situation where the Client's fiscal periods are irregular and do not correspond to exact calendar months.For example Fiscal Period 01.2009 corresponds to the period 02.04.2009 to 29.04.2009 and not to Calendar month April'09.
    In such a case it is becoming a challenge to extract the headcount on the basis of fiscal period from the cube 0PA_C01.
    Could any one offer a clue as to how this could possibly be achieved?

    Hello Rajeev,
    you can always use FM DATE_TO_PERIOD_CONVERT during extraction in ZXRSAU01 or in transfer/update rules on BW. Remember to transfer Global Settings from source system to BW when using second method. Don't forget about transfer data to 0FISCVARNT as well.
    Thanks = points.
    Best Regards,
    Maciej Janik

  • How to set a default value as current month in already created variable of 0fiscper

    Hi Guys,
    In my report currently we are using a variable for 0fiscper which is mandatory and selection option.
    Now there is a requirement to set current month as default value in that variable.
    Please let me know how can I do that.
    Thanks.
    Dolly

    You need to change the processing type to customer exit of that variable.
    Now in i_step = 1 write the following code:
    Data:dt LIKE sy-datum,
          zper  TYPE /bi0/oifiscper,
          YR type /bi0/oicalyear,
          per LIKE t009b-poper.
    IF i_step = 1.
    WHEN 'X_FSCPRC' .---User input variable based on cmod.
          dt = sy-datum.
          CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
            EXPORTING
              i_date         = dt
              i_periv        = 'M3'---Give the fiscal year variant                             according to your system
            IMPORTING
              e_buper        = per
              e_gjahr        = yr
            EXCEPTIONS
              input_false    = 1
              t009_notfound  = 2
              t009b_notfound = 3
              OTHERS         = 4.
          IF sy-subrc = 0.
    Concatenate YR Per into Zper.
            l_s_range-low = Zper.
            l_s_range-sign = 'I'.
            l_s_range-opt = 'EQ'.
            APPEND l_s_range TO e_t_range.
          ENDIF.
    endif.

  • Error during GR(very very urgent)

    Hi all,
    i am using a developed program for GR.i used this program before.there was no error.but now i am facing error like
    <b>PO ordered quqntity exceeded by 18,000 EA.</b>.i am using <b>BAPI_GOODSMVT_CREATE</b> for goods transfer.
    In the selection screen, i am putting
    PO number- PO1
    material number- MAT
    GR quantity- 18,000
    delivery order-111
    i want to receive the material MAT of quantity 18,000 from that PO.initially i have ordered PO quntity as 1 lakh. Till now i have received 42,000 materials,now i try to receive 18,000 materials.but it is showing this type of error.
    This error is fired from the return parameter of that BAPI only.error having message class-M7 & error no-022
    is comming.
    i am giving my coding below.plz suggest where is the problem.it is very very urgent.recently my company has added some patches to update the SAP.is this the cause for that error.plz suggest.
    any idea will be highly appreaciated.
    Regards
    REPORT zmui001
           LINE-SIZE 140
           LINE-COUNT 65
           NO STANDARD PAGE HEADING.
    *-- DATA DECLARATION--
    *-- tables
    TABLES : ekpo,
                ekbe,
             marv.
    *--Includes
    INCLUDE : <icon>.                   " Include for Icons
    *-- Types
    TYPES : BEGIN OF t_mseg,
              ebeln LIKE ekko-ebeln,
              name1 LIKE lfa1-name1,
              lifnr LIKE lfa1-lifnr,
              eknam LIKE t024-eknam,
              mblnr LIKE mkpf-mblnr,
              matnr LIKE ekpo-matnr,
              maktx LIKE makt-maktx,
              lgort LIKE mseg-lgort,
              charg LIKE mseg-charg, "chg: 10/17/2005
              menge LIKE mseg-menge,
              budat LIKE mkpf-budat,
              bldat LIKE mkpf-bldat, " chg : 08/18/2003
              xblnr LIKE mkpf-xblnr,
              END OF t_mseg.
    DATA:  BEGIN OF t_ekbe,
              ebeln LIKE ekbe-ebeln,
              ebelp LIKE ekbe-ebelp,
              bwart LIKE ekbe-bwart,
              matnr LIKE ekbe-matnr,
              menge LIKE ekbe-menge,
              END OF t_ekbe,
              BEGIN OF t_ekpo,
              ebeln LIKE ekpo-ebeln,
              ebelp LIKE ekpo-ebelp,
              matnr LIKE ekpo-matnr,
              menge LIKE ekpo-menge,
              END OF t_ekpo.
    TYPES : BEGIN OF t_options.
            INCLUDE STRUCTURE itcpo.
    TYPES : END OF t_options.
    *--Internal tables
    DATA: BEGIN OF i_item OCCURS 50.    "Create Material Document Item
            INCLUDE STRUCTURE bapi2017_gm_item_create.
    DATA: END OF i_item .
    DATA: BEGIN OF i_return OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE bapiret2.
    DATA: END OF i_return.
    DATA: BEGIN OF i_part OCCURS 0,     " Internal table for split data
            part(20),
          END OF i_part.
    DATA: BEGIN OF i_return1 OCCURS 20.  "Return parameter
            INCLUDE STRUCTURE bapiret1.
    DATA: END OF i_return1.
    *-- Work areas
    DATA: BEGIN OF wa_header .       "Material Document Header Data
            INCLUDE STRUCTURE bapi2017_gm_head_01.
    DATA: END OF wa_header .
    DATA: BEGIN OF wa_return .       "Output Structure
            INCLUDE STRUCTURE bapi2017_gm_head_ret.
    DATA: END OF wa_return .
    *-- Work areas
    DATA: wa_mseg TYPE t_mseg,
             wa_ekbe LIKE t_ekbe,
             wa_ekpo  LIKE t_ekpo,
          wa_options TYPE t_options,
           i_ekbe LIKE STANDARD TABLE OF  t_ekbe,
            i_ekbe2 LIKE STANDARD TABLE OF  t_ekbe,
           i_ekpo  LIKE STANDARD TABLE OF  t_ekpo.
    *---Variables
    DATA: v_first,         " variable to get first digit
          v_set TYPE c,
          v_found TYPE p,
          v_menge TYPE p,
          v_ebeln LIKE ekko-ebeln,
          v_lifnr LIKE ekko-lifnr,
          v_belnr LIKE ekbe-belnr,
          v_postdate LIKE mkpf-budat,
          v_bukrs LIKE marv-bukrs,
          v_datum LIKE sy-datum,
          v_lgort LIKE mard-lgort,   " Stge. location
          v_bwart LIKE mseg-bwart,   " Movement type
          v_infnr LIKE eina-infnr,   " Info record no.
          v_ltsnr LIKE eina-ltsnr.
    *---Constants
    CONSTANTS: c_comma TYPE c VALUE ',',   " For splitting data at commas
               c_01(2) TYPE c VALUE '01',  " For movement code in Bapi
               c_b     TYPE c VALUE 'B',   " For mvt. Indicator in Bapi
               c_save(4) TYPE c VALUE 'SAVE', " For button text
               c_clear(5) TYPE c VALUE 'CLEAR', " For clear button
               c_mvmt(4) TYPE c VALUE 'MVMT',
               c_ok(2)   TYPE c VALUE 'OK',
               c_error(5) TYPE c VALUE 'Error'.
    *--SELECTION SCREEN DESIGN--
    SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
    PARAMETERS:     p_bar(75) ,  " Scanned data from barcode
                p_ebeln LIKE ekko-ebeln, " PO number
                p_matnr LIKE ekpo-matnr, " Material number
                p_menge LIKE ekpo-menge, " Quantity
               p_lifnr LIKE ekko-lifnr, " Vendor code
                p_frbnr LIKE mkpf-frbnr, " Reference doc for goods mvt
                p_status(5) TYPE c.
    SELECTION-SCREEN END OF BLOCK blk1.
    SELECTION-SCREEN PUSHBUTTON 15(10) v_save USER-COMMAND mvmt.
    SELECTION-SCREEN PUSHBUTTON 40(10) v_clear USER-COMMAND clear.
      INITIALIZATION -
    INITIALIZATION.
      v_save = c_save .
      v_clear = c_clear.
    *--AT SELECTION_SCREEN--
    AT SELECTION-SCREEN .
      IF sy-ucomm = c_clear.
        PERFORM f_clear.
      ELSE.
        IF sy-ucomm <> c_mvmt.
           if not  sy-tabix is initial and  sy-ucomm <> c_mvmt.
    *--- Extracting the data by splitting the scanned values.
          PERFORM f_get_split_data.
    *--- Validating the input data.
          PERFORM f_check_inputs.
        ELSE .
    *--- Validating the input data.
          PERFORM f_check_inputs.
    *-- Determining the posting date and period check.
          PERFORM f_get_posting_date.
    *---Post goods movement
          PERFORM f_post_receipt.
        ENDIF.
      ENDIF.
               SUBROUTINES                                               *
    *&      Form  f_check_inputs
        Validating the input parameters
    FORM f_check_inputs.
    *-- Validating material no.
      SELECT SINGLE matnr INTO p_matnr
        FROM mara
          WHERE matnr = p_matnr.
      IF sy-subrc = 4.
        p_status =  c_error.
        MESSAGE e003(zm) WITH 'Material no.'.
      ENDIF.
    *-- Validating JHT reference no.
      SELECT SINGLE ebeln
                    lifnr
                    bukrs
                    INTO (p_ebeln, v_lifnr , v_bukrs)
                    FROM ekko
            where unsez = p_unsez. chg:07072003
              WHERE ebeln = p_ebeln.
      IF sy-subrc = 4.
        p_status =  c_error.
        MESSAGE e003(zm) WITH 'Purchase order no.'.
      ENDIF.
    *-- Validating material po combination
      SELECT SINGLE *
           FROM ekpo
             WHERE ebeln = p_ebeln
               AND matnr = p_matnr.
      IF sy-subrc = 4.
        p_status =  c_error.
        MESSAGE e003(zm) WITH 'Purchase order no.' ' and Material no.'.
      ENDIF.
    *--- Checking for DO entry . (chng : 30/06/2003)
      IF  p_frbnr IS INITIAL.
        MESSAGE e018(m7) WITH 'Delivery no.'.
        p_status =  c_error.
        PERFORM f_clear.
      ENDIF.
    *-- Validating material po do combination
      SELECT SINGLE a~belnr
                    INTO v_belnr
                    FROM ekbe AS a
                      INNER JOIN mkpf AS b
                       ON   abelnr = bmblnr
                       AND agjahr = bmjahr
                      WHERE a~ebeln = ekpo-ebeln
                        AND  a~ebelp = ekpo-ebelp
                        AND  b~xblnr = p_frbnr.
      IF sy-subrc = 0.
        MESSAGE e019(zm) WITH v_belnr.
        p_status = c_error.
        PERFORM f_clear.
      ENDIF.
      p_status =  c_ok.
    ENDFORM.                    " f_check_inputs
    *&      Form  f_get_split_data
       Extracting the data by splitting the Scanned data
    FORM f_get_split_data.
    *-- Splitting the data at commas
      SPLIT p_bar AT c_comma INTO TABLE i_part.
    *-- Assigning the parts to variables.
      LOOP AT i_part.
        v_first = i_part-part+0(1).
        TRANSLATE  v_first TO UPPER CASE.
        CASE v_first .
         WHEN 'V'.
           p_lifnr =  i_part-part+1(10).
          WHEN 'P'.
            p_matnr = i_part-part+1(18).
          WHEN 'Q'.
            p_menge = i_part-part+1(13).
          WHEN 'K'.
            p_ebeln = i_part-part+1(10).
          WHEN 'D'.
            p_frbnr = i_part-part+2(16).
          WHEN OTHERS.
            CONTINUE.
        ENDCASE.
      ENDLOOP.
    ENDFORM.                    " f_get_split_data
    *&      Form  f_get_posting_date
    Determing the posting date for document
    FORM f_get_posting_date.
    *-- get the current period for todays date.
      DATA: l_period LIKE t009b-poper.
      CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
        EXPORTING
          i_date               = sy-datum
          i_periv              = 'K4'
       IMPORTING
         e_buper               = l_period
      E_GJAHR              =
       EXCEPTIONS
         input_false          = 1
         t009_notfound        = 2
         t009b_notfound       = 3
         OTHERS               = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    *-- Determining whether the open period
      SELECT SINGLE *
                    FROM marv
                    WHERE bukrs = v_bukrs.
      IF sy-subrc = 0.
        IF l_period = marv-lfmon .
          v_postdate = sy-datum.
        ELSE.
          CALL FUNCTION 'BAPI_CCODE_GET_FIRSTDAY_PERIOD'
               EXPORTING
                    companycodeid       = v_bukrs
                    fiscal_period       = marv-lfmon
                    fiscal_year         = marv-lfgja
               IMPORTING
                    first_day_of_period = v_postdate
                    return              = i_return1.
          IF NOT i_return[] IS INITIAL.
            LOOP AT i_return1.
              MESSAGE i016(zm) WITH i_return-message.
            ENDLOOP.
          ENDIF.
        ENDIF.
      ENDIF.
    ENDFORM.                    " f_get_posting_date
    *&      Form  f_post_receipt
    Post the goods receipt for entered data.
    FORM f_post_receipt.
      PERFORM f_fill_item.
      PERFORM f_fill_header.
      PERFORM f_execute_transfer.
      PERFORM f_clear.
    ENDFORM.                    " f_post_receipt
    *&      Form  f_fill_item
      Updating the item data for the GR
    FORM f_fill_item.
    Checking for IQC cycle is done here.(chng : 23/07/2003)
      PERFORM f_check_iqc.
    *---- Assigning movement type as per IQC cycle.(chng : 23/07/2003)
      IF v_lgort IS INITIAL.
        MOVE '101'   TO i_item-move_type.
        SELECT SINGLE lgort INTO i_item-stge_loc
        FROM ekpo
         where ebeln  = v_ebeln and  " chg :07/07/2003
           WHERE ebeln  = p_ebeln AND
               matnr = p_matnr .
      ELSE.
        MOVE v_lgort TO i_item-stge_loc.
        MOVE v_bwart TO i_item-move_type.
      ENDIF.
      MOVE p_matnr TO i_item-material.
      MOVE p_menge TO i_item-entry_qnt.
    move v_ebeln to i_item-po_number. " 07/07/2003
      MOVE p_ebeln TO i_item-po_number.
      MOVE v_lifnr TO i_item-vendor.
      MOVE c_b TO i_item-mvt_ind.
    select single ebelp into i_item-po_item " chg :29/07/2003
       from ekpo
          where ebeln  = p_ebeln
            and   matnr = p_matnr
           and elikz = ''.
      SELECT ebeln
                ebelp
                matnr
                menge
                INTO CORRESPONDING FIELDS OF TABLE i_ekpo
                FROM ekpo
                WHERE ebeln = p_ebeln
                   AND matnr = p_matnr
                   AND loekz = '' .
      SORT i_ekpo BY ebeln ebelp matnr.
      LOOP AT i_ekpo INTO wa_ekpo.
        IF v_found = 0.
          SELECT ebeln  ebelp
                bwart  menge
                INTO CORRESPONDING FIELDS OF TABLE i_ekbe
                FROM ekbe
                WHERE ebeln = p_ebeln
                AND ebelp = wa_ekpo-ebelp
                AND matnr = p_matnr.
                          and elikz = '' .  CHG -- 03/19/2004
          IF sy-subrc = 0.
            LOOP AT i_ekbe INTO wa_ekbe .
              IF wa_ekbe-bwart = '101'.
                v_menge = v_menge + wa_ekbe-menge.
              ENDIF.
              IF wa_ekbe-bwart = '102'.
                v_menge = v_menge - wa_ekbe-menge.
              ENDIF.
              IF wa_ekbe-bwart = '122'.
                v_menge = v_menge - wa_ekbe-menge.
              ENDIF.
            ENDLOOP.
    chng: 03/19/2004 compare po qty against receipt
            v_menge = v_menge + p_menge .
            IF wa_ekpo-menge >= v_menge .
              v_found = 1.
              MOVE wa_ekpo-ebelp TO i_item-po_item.
            ENDIF.
          ELSE .
            v_found = 1.
            MOVE wa_ekpo-ebelp TO i_item-po_item.
          ENDIF.
        ENDIF.
        CLEAR : wa_ekbe, i_ekbe, v_menge.
      ENDLOOP.
      IF v_found = 0 .
        MESSAGE e003(zm) WITH ' delivery items'.
      ENDIF.
      APPEND i_item.
      CLEAR : i_item, v_found .
    ENDFORM.                    " f_fill_item
    *&      Form  f_check_iqc
    Checking the storage location for the (chng : 23/07/2003)
    FORM f_check_iqc.
      CALL FUNCTION 'Z_M_GET_IQC_STATUS'
           EXPORTING
                matnr          = p_matnr
                lifnr          = v_lifnr
           IMPORTING
                lgort          = v_lgort
                bwart          = v_bwart
                ltsnr          = v_ltsnr
                infnr          = v_infnr
           EXCEPTIONS
                non_iqc_vendor = 1
                OTHERS         = 2.
      IF sy-subrc <> 0.
        CLEAR : v_lgort , v_bwart , v_ltsnr.
      ENDIF.
    ENDFORM.                    " f_check_iqc
    *&      Form  f_fill_header
      Updating data in the header
    FORM f_fill_header.
      MOVE v_postdate TO wa_header-pstng_date.
      MOVE sy-datum TO wa_header-doc_date.
      MOVE p_frbnr TO wa_header-ref_doc_no.
    ENDFORM.                    " f_fill_header
    *&      Form  f_execute_transfer
          Executing the goods movement.
    FORM f_execute_transfer.
      CALL FUNCTION 'BAPI_GOODSMVT_CREATE'
           EXPORTING
                goodsmvt_header  = wa_header
                goodsmvt_code    = c_01
           IMPORTING
                goodsmvt_headret = wa_return
           TABLES
                goodsmvt_item    = i_item
                return           = i_return.
      IF i_return[] IS INITIAL .
        COMMIT WORK.
    *---  UPdating Info record for IQC cycle ind.(chng : 23/07/2003)
        IF NOT v_ltsnr IS INITIAL.
          UPDATE eina SET ltsnr = v_ltsnr
          WHERE infnr = v_infnr.
        ENDIF.
        REFRESH : i_item.
        CLEAR : wa_header,v_ltsnr , v_infnr,v_bwart,v_lifnr.
        MESSAGE i012(migo) WITH wa_return-mat_doc.
        PERFORM f_do_print.
      ELSE.
        REFRESH : i_item.
        CLEAR : wa_header,v_ltsnr , v_infnr,v_bwart,v_lifnr.
        PERFORM write_errors.
      ENDIF.
    ENDFORM.                    " f_execute_transfer
    FORM write_errors.
      WRITE: 0(90) sy-uline ,
             /0'|',
              3 'System messages for GR posting',
              90 '|',
             /0(90) sy-uline .
      LOOP AT i_return.
        CASE  i_return-type.
          WHEN 'E'.
            MESSAGE i016(zm) WITH i_return-message.
          WHEN 'W'.
            MESSAGE i017(zm) WITH i_return-message.
          WHEN 'I'.
           WRITE: /0'|',
                  icon_yellow_light AS ICON ,
                  '|',
                  10 i_return-message,
                  90 '|'.
            MESSAGE i018(zm) WITH i_return-message.
          WHEN 'S'.
           WRITE: /0'|',
                  icon_green_light AS ICON ,
                  '|',
                  10 i_return-message,
                  90 '|'.
            MESSAGE i018(zm) WITH i_return-message.
          WHEN OTHERS.
           WRITE: /0'|',
                  icon_red_light AS ICON ,
                  '|',
                  10 i_return-message,
                  90 '|'.
            MESSAGE e016(zm) WITH i_return-message.
        ENDCASE.
       AT LAST .
         WRITE:/0(90) sy-uline .
       ENDAT.
      ENDLOOP.
    ENDFORM.                    " write_errors
    *&      Form  f_clear
    Clearing the input parameters
    FORM f_clear.
      CLEAR : p_ebeln ,
              p_bar,
              p_matnr,
              p_frbnr,
              v_lifnr,
              p_menge,
              p_status.

    Hi all,
    can anyone suggest any idea?
    Regrds
    pabitra

Maybe you are looking for

  • Did you know-? Animation Tips & Tricks

    Did you  know that you can animate any object you create in Project ROME – and  that it's easy to do too? Just follow these quick steps (and be sure to  have your timeline showing – View > Show Timeline): 1.Select the object you want to animate 2.Cli

  • Digital Signatures - preserving throughout the process

    I have a form with 4 parts, each part requiring a digital signature. I just read the article on preserving digital signatures (http://www.adobe.com/devnet/livecycle/workflow/articles/lc_wf_preserve_digisig_tip.pdf), but I am still a little confused.

  • Connecting Hardwire IP Phone to Wireless ADSL Router

    I have a Mitel 5340 IP Phone that doesn't have wireless capability. I currently have a Westell 327W ADSL router with wireless capability. The router is in room X. The PC and IP Phone are in room Y. The PC works fine with wireless, but I can't connect

  • Considering the purchase a Dell Ultrasharp

    Displays HD resolution.  As a third monitor will I move my canvas to this monitor.  Or their away to get the HD image to display?

  • Need advice about files back up

    Could you please tell me how I can easily (I am not technically competent) backup the following: - Microsoft security updates - Norton security updates - other downloaded software program updates - emails - Internet "Favourites" list - desktop displa