COGS details

Dear All,
Need some clarification on Sales Processu2026
We have F.G. which has a cost of 7400/- (as per Material Master & Std Cost estimation).
PGI (sales delivery) FI document the entry was COGS Dr 9800/-  F.G. 9800/- 
Billing (sales Billing) FI document..Entry was Customer Dr. 11000/- and Revenue Cr 11000/-.
Now question is how the system does calculated the COGS value and where can I find the logic & value (stored in any document)  for the system to calculate the COGS.
Do suggest.

Hi,
Can you check that following steps are followed. In MTO will follow the below steps,
1. Create a Sale order for the Header Material.
2. Run MRP for the Header Material, so the procurement proposals will generate for the BOM items.
3. Do the procurement for the components.
4. Once all the component stock is in place, convert the Header Material Planned order to Production order through MD04/CO08.
5. Issue the components from Inventory to Shop floor (261).
6. Confirm the Production order and receive to stock (101).
7. Now the assembly is in sale order stock.
8. Create delivery to the customer (VL02N).
9. Create billing (VF01).
10. Close the order (TECO).
For MTO the cycle will start from Customer order / Sale order and end with the same.
Check out ur scenario and u shuld be able to get cost
Regards,
Atul

Similar Messages

  • External Inventory Feed - Wish to Exclude Customer Order Stock

    We have an hourly inventory job, which writes available inventory to an external file.  Recently, we learned that the report is including material which has already been reserved for future customer orders (see for example in MD04).  We do not have an ABAP programmer on staff so I am posting our existing code below and would appreciate hugely an updated script.
    I've seen references in other searches to MD04 and use of function 'MD_MPS_READ_STOCK_REQMTS' as well as 'BAPI_MATERIAL_STOCK_REQ_LIST', but do not know how to incorporate this into the hourly job.
    As you can see, the report output is being pulled from MARD-LABST, unrestricted, but it needs to also exclude allocated customer order stock.
    Thank you in advance for looking.
    *& Report  ZMM_INVENTORY_FEED*&*&---------------------------------------------------------------------**&*&*&---------------------------------------------------------------------*
    REPORT  zmm_inventory_feed NO STANDARD PAGE HEADING.
    TABLES:mara,marc,mard,mvke.
    *-------------Types Declaration----------------------------------------*TYPES:BEGIN OF ty_file,
          text(500),
          END OF ty_file,
          BEGIN OF ty_mard,
          matnr    TYPE mard-matnr,
          werks    TYPE mard-werks,
          lgort    TYPE mard-lgort,
          labst    TYPE mard-labst,
          mstae    TYPE mara-mstae,
          maktx    TYPE makt-maktx,
          mvgr2    TYPE mvke-mvgr2,
          END OF ty_mard,
          BEGIN OF ty_final,
          supplier TYPE lfa1-lifnr,   "Supplierid
          matnr    TYPE mard-matnr,   "Item no
          labst    TYPE char13,       "Qty
          qtyback  TYPE char13,       "Qtyback
          qtyorder TYPE char13,       "Qtyorder
          itemav   TYPE c,            "Itemavdate
          itemdis  TYPE char13,       "Discount
          desc     TYPE makt-maktx,   "Description
          END OF ty_final.
    *----------Internal Table Declaration---------------------------------*DATA:it_mard   TYPE TABLE OF ty_mard,
         it_final  TYPE TABLE OF ty_final,
         it_file   TYPE TABLE OF ty_file,*----------Work Area Declaration--------------------------------------*
         wa_mard   TYPE ty_mard,
         wa_temp   TYPE ty_mard,
         wa_final  TYPE ty_final,
         wa_file   TYPE ty_file.
    *----------Local variable Declaration---------------------------------*DATA: lv_labst   TYPE char13,
          lv_labst_i TYPE i,
          lv_labst1  TYPE char13,
          lv_labst2  TYPE j_1itaxvar-j_1itaxam1,
          lv_mess    TYPE string.DATA lv_filename TYPE char100.*----------Selection-Screen Declaration-------------------------------*SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:s_mstae  FOR mara-mstae OBLIGATORY,                     "Material Status
                   s_mvgr2  FOR mvke-mvgr2 OBLIGATORY,                     "Material Group
                   s_matnr  FOR mara-matnr,                                "Material Number
                   s_werks  for mard-werks,
                   s_lgort  FOR mard-lgort.PARAMETERS:    p_per(3) TYPE n DEFAULT 20,                             "Percentage
                   p_appl   TYPE rlgrap-filename DEFAULT '\\Appsrv02\Datadown\DropShip_SAP_Test\'. "File Path
    SELECTION-SCREEN END OF BLOCK b1.*----------End Of Declarations----------------------------------------*
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_appl.*  PERFORM f4_filename.                     "F4 help for file path
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM process_data.
      PERFORM file_export.*&---------------------------------------------------------------------**&      Form  GET_DATA*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM get_data .
      SELECT a~matnr
             a~werks
             a~lgort
             a~labst
             b~mstae
             c~maktx
             d~mvgr2 INTO CORRESPONDING FIELDS OF TABLE  it_mard
                           FROM mard AS a
                     INNER JOIN mara AS b
                             ON b~matnr = a~matnr
                     INNER JOIN makt AS c
                             ON c~matnr = a~matnr
                     INNER JOIN mvke AS d
                             ON d~matnr = a~matnr
                          WHERE mstae   in s_mstae              "Exclude Material Status Filteration
                            AND a~werks IN ('1100','1200')        "Plant in 1100 and 1200
                            AND mvgr2   IN s_mvgr2              "Exclude Material group
                            AND a~matnr IN s_matnr
                            and a~werks in s_werks
                            AND a~lgort in s_lgort.
      SORT it_mard BY matnr werks lgort.
      DELETE ADJACENT DUPLICATES FROM it_mard COMPARING matnr werks lgort.ENDFORM.                    " GET_DATA*&---------------------------------------------------------------------**&      Form  PROCESS_DATA*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM process_data .
    *--------------File Header Information --------------------------------*
      wa_final-supplier    = 'Supplier Id'.
      wa_final-matnr       = 'Item Number'.
      wa_final-labst       = 'Total Qty'.
      wa_final-qtyback     = 'Qty Backordered'.
      wa_final-qtyorder    = 'Qty on Order'.
      wa_final-itemav      = 'Item NextAvdate'.
      wa_final-itemdis     = 'ItemDiscont'.
      wa_final-desc        = 'Description'.
      CONCATENATE  wa_final-supplier
                   wa_final-matnr
                   wa_final-labst
                   wa_final-qtyback
                   wa_final-qtyorder
                   wa_final-itemav
                   wa_final-itemdis
                   wa_final-desc    INTO wa_file
                                    SEPARATED BY ','." RESPECTING BLANKS.
      APPEND wa_file TO it_file.
      CLEAR :wa_final,
             wa_file.*------------------End File Header---------------------------------------*
    *------------------File Item Data----------------------------------------*
      LOOP AT it_mard INTO wa_temp.
        wa_mard = wa_temp.
        MOVE:wa_mard-matnr TO wa_final-matnr,  "Item No
             wa_mard-maktx TO wa_final-desc.   "Description
        IF wa_mard-werks     = '1100'.
          wa_final-supplier  = '6476'.         "Supplierid
        ELSEIF wa_mard-werks = '1200'.
          wa_final-supplier  = '6477'.
        ENDIF.
        IF wa_mard-labst IS NOT INITIAL.
          lv_labst1 = lv_labst1 + wa_mard-labst.
        ENDIF.
        AT END OF werks.
          IF wa_mard-mstae = 'AE'.
            wa_final-itemdis = '0'.        "Item Discontinued
          ELSEIF wa_mard-mstae = 'CM' OR wa_mard-mstae = 'DR'.
            wa_final-itemdis = '1'.
          ENDIF.
          IF lv_labst1 IS NOT INITIAL AND p_per IS NOT INITIAL.
            lv_labst = lv_labst1 * p_per / 100. "Qty
            lv_labst = lv_labst1 - lv_labst.
            IF lv_labst LT 0.                    "If Qty less than Zero Make it as Zero
              lv_labst = 0.
            ENDIF.
          ELSE.
            lv_labst = lv_labst1.
          ENDIF.
          lv_labst2 = lv_labst.                  "Rounding to Nearest Qty
          CALL FUNCTION 'J_1I6_ROUND_TO_NEAREST_AMT'
            EXPORTING
              i_amount = lv_labst2
            IMPORTING
              e_amount = lv_labst2.
          lv_labst_i = lv_labst2.
          lv_labst = lv_labst_i.
          CONDENSE lv_labst.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
            EXPORTING
              input         = wa_final-matnr
           IMPORTING
             OUTPUT        = wa_final-matnr
          CONCATENATE wa_final-supplier
                      wa_final-matnr
                      lv_labst
                      wa_final-qtyback
                      wa_final-qtyorder
                      '          '"'00/00/0000' "wa_final-itemav
                      wa_final-itemdis
                      wa_final-desc INTO wa_file
                                    SEPARATED BY ','." RESPECTING BLANKS.
          APPEND wa_file TO it_file.
          CLEAR:lv_labst1,
                lv_labst,
                lv_labst2,
                wa_file.
        ENDAT.
        CLEAR:wa_mard,
              wa_temp,
              wa_final.
      ENDLOOP.*---------------------------End  File Item data----------------------*ENDFORM.                    " PROCESS_DATA*&---------------------------------------------------------------------**&      Form  FILE_EXPORT*&---------------------------------------------------------------------**       text*----------------------------------------------------------------------*FORM file_export

    What you said is exactly what I want! Very thankful for your help.
    Yes, I have found that in EBEW table that standard price is valuated with preliminary cost estimate because I don't give a sales order cost estimate but I give an sales order stock in the customizing - requirement class. So, I have this question that how the sales order stock is determined.
    In COPA customizing (COprofitability analysismaster datavaluationSet up valuation using material cost estimate), standard cost estimate or sales order cost estimate can be transferred into COPA value fields in our system.
    But, I have still have a question: I found in our system, preliminary cost estimate in the linked production order is determined for valuation of sales order stock in EBEW table. As sap online help says, cost component splits can not be transferred to COPA.
    So, according to SAP online help, I think what you said u201Cu2026..However , when we start thinking about the result of this cost to flow into COPA , this cannot happen as the Inventory was valued with a Preliminary csot estimate. So , the Online help says that it will not be able to transfer Result of Preliminary cost estimate into COPA for transferrring COGS details. System would always require a Standard cost estimate or a Sales order Cost estimate to flow Cost details into COPAu201D is correct.
    But, in our system, cost component can be transferred into COPA!? When I create a sales billing (invoice) with tcode VF01, it can create a profitability analysis document (shown in VF03) which it had a cost component split for that material in the sales order stock valuated with the preliminary cost estimate. Or where is stored for the Make-to-Order materialu2019s cost component split in COPA?
    That is the real point that confused me. Hope you can help me. Thanks very much.

  • Grahical reports in abap how to devlop

    hi all
    can u please tell me how to display reports in graphical form 2d or 3d using abap programming

    Hi ,
    Paste this code in se38,
    PERFORM create_chart is important for you.
    *& Report  ZMM_INV_TURNS_REPORT                                       *
    *& Author  Vijay Babu Dudla                                           *
    *& Date    25th April 2008                                            *
    Description :  Inventory Turns Report                               *
    Inputs:                                                             *
      Tables:                                                           *
        ECMT  -  COGS data                                              *
        GLTO  -  Inventory Data                                         *
    Parameters:                                                        *
    From Period                                                        *
          Year                                                          *
    To   Period                                                        *
          Year                                                          *
          Company Code
      Parameters:                                                       *
        N/A                                                             *
    Outputs: A ALV report is generated to display the Inventory Turns   *
    External Routines                                                   *
      Classes: CL_GUI_ALV_GRID                                          *
               CL_IGS_CHART                                             *
      Transactions    : No                                              *
      Programs        : No                                              *
    Return Codes: No                                                    *
    Ammendments:                                                        *
       Programmer        Date     Req. #            Action              *
    ================  ==========  ======  ==============================*
    Vijay Dudla     04/15/2008   RD4K900255  Initial Development       *
    RMANDAL         05/18/2008   RD4K900419  1) Getting COGS values    *
                                                  from ZSCOMMON         *
                                              2) Displying values in    *
                                                 Graph                  *
    REPORT  zmm_inv_turns_report MESSAGE-ID zi.
    *-TYPES Declaration
    *- Period Details
    TYPES: BEGIN OF ty_period,
            perid TYPE fc_perid,           " Period
           END OF ty_period.
    *-Year Details
    TYPES: BEGIN OF ty_year,
            gjahr TYPE gjahr,              " Year
           END OF ty_year.
    *-Final Display Table
    TYPES: BEGIN OF ty_data,
            texts(20),                     " Col Value
            per01(20),                                          " Period1
            per02(20),                                          " Period2
            per03(20),                                          " Period3
            per04(20),                                          " Period4
            per05(20),                                          " Period5
            per06(20),                                          " Period6
            per07(20),                                          " Period7
            per08(20),                                          " Period8
            per09(20),                                          " Period9
            per10(20),                                          " Period10
            per11(20),                                          " Period11
            per12(20),                                          " Period12
            year TYPE gjahr,
          END OF ty_data.
    *-Period Balance information
    TYPES: BEGIN OF ty_balance,
             period TYPE fc_perid,         " Period
             gjahr TYPE gjahr,             " Year
             tslvt TYPE tslxx,             " Balance
           END OF ty_balance.
    *- Period and Year info
    TYPES: BEGIN OF ty_per_year,
             period TYPE fc_perid,         " Period
             gjahr TYPE gjahr,             " Year
           END OF ty_per_year.
    *- Field Symbols
    FIELD-SYMBOLS: <fs> TYPE ANY.
    *- Data Declarations
    *- Internal Table Decleations
    DATA: it_fieldcat TYPE lvc_t_fcat,     " Fieldcatalog
          it_per      TYPE STANDARD TABLE OF zmm_year_period,
          it_year_per TYPE zmm_t_inv_period,
          it_final    TYPE STANDARD TABLE OF ty_data,
          it_year     TYPE STANDARD TABLE OF ty_year,
          it_period   TYPE STANDARD TABLE OF ty_period,
          it_common   TYPE STANDARD TABLE OF zscommon,
    BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
          it_common1  TYPE STANDARD TABLE OF zscommon,
    END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
          it_inv      TYPE STANDARD TABLE OF glt0,
          it_cogs     TYPE STANDARD TABLE OF ecmct,
         it_inv_data TYPE STANDARD TABLE OF zfi_year_period,
          it_balance  TYPE STANDARD TABLE OF ty_balance,
          it_peryear  TYPE STANDARD TABLE OF ty_per_year
                           WITH HEADER LINE.
    *- Work Area declarations
    DATA: wa_fieldcat TYPE lvc_s_fcat,
          w_per       TYPE zmm_year_period,
          w_period    TYPE zmm_inv_period,
          wa_final    TYPE ty_data,
         wa_inv      TYPE zfi_year_period,
          wa_per      TYPE ty_period,
          wa_balance  TYPE ty_balance.
    *- Range table Declations
    DATA: return  TYPE TABLE OF ddshretval WITH HEADER LINE,
          r_year  TYPE RANGE OF gjahr WITH HEADER LINE,
          r_yr    TYPE RANGE OF gjahr WITH HEADER LINE,
          r_per   TYPE RANGE OF fc_perid WITH HEADER LINE,
          r_saknr TYPE RANGE OF racct.
    *- Variable to Period and Year
    DATA: perid   TYPE fc_perid,
          year    TYPE gjahr,
          w_bukrs TYPE glt0-bukrs.
    *- Graph Display
    DATA:  g_html  TYPE w3htmltabtype,
           g_url   TYPE w3url.
    *-Controls for Displaying the Grpah and ALV Report
    DATA: grid    TYPE REF TO cl_gui_alv_grid,
          split   TYPE REF TO cl_gui_splitter_container,
          cont    TYPE REF TO cl_gui_custom_container,
          gridcon TYPE REF TO cl_gui_container,
          htmlcon TYPE REF TO cl_gui_container,
          html_control TYPE REF TO cl_gui_html_viewer.
    *&     Selection Screen                                               *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-ttl.
    SELECT-OPTIONS:  s_per FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
                                         " Period
                     s_year FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
                                         " Year
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-tt2.
    SELECT-OPTIONS:  s_per2 FOR perid NO-EXTENSION NO INTERVALS OBLIGATORY,
                                         " Period
                     s_year2 FOR year NO-EXTENSION NO INTERVALS OBLIGATORY.
                                         " Year
    SELECTION-SCREEN END OF BLOCK b2.
    SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE text-tt3 .
    PARAMETERS: p_rep RADIOBUTTON GROUP g1 DEFAULT 'X',
                p_grp RADIOBUTTON GROUP g1,
                p_bot RADIOBUTTON GROUP g1.
    SELECTION-SCREEN END OF BLOCK b3.
    PARAMETERS: p_bukrs LIKE glt0-bukrs DEFAULT '3000' OBLIGATORY.
    *&     AT SELECTION-SCREEN ON VALUE REQUEST                           *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_year-low.
    *-Value help for year
      PERFORM get_hlp_for_year.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_per-low.
    *-Value help for Period
      PERFORM get_hlp_for_period.
    *&     AT SELECTION-SCREEN                                            *
    AT SELECTION-SCREEN .
    *-Validations
    *- Per Period should be 1 to 12
      LOOP AT s_per.
        IF s_per-low GT 12 OR s_per-low LT 1.
          MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
        ENDIF.                             " IF s_per-low GT 12 OR s_per-low
        IF NOT s_per-high IS INITIAL.
          IF s_per-high GT 12 OR s_per-high LT 1.
            MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
          ENDIF.                           " IF s_per-high GT 12 OR
        ENDIF.                             " IF NOT s_per-high IS INITIAL
      ENDLOOP.                             " LOOP AT s_per
      IF s_per-low GE sy-datum+4(2) AND
         s_year-low GE sy-datum+0(4).
        MESSAGE e000(zi) WITH text-002 text-003.
      ENDIF.                               " IF s_per-low GE sy-datum+4(2)
      LOOP AT s_per2.
        IF s_per2-low GT 12 OR s_per2-low LT 1.
          MESSAGE e000(zi) WITH 'Enter Period between 1 and 12'.
        ENDIF.                             " IF s_per2-low GT 12 OR
      ENDLOOP.                             " LOOP AT s_per2.
      IF s_per2-low GE sy-datum+4(2) AND
         s_year2-low GE sy-datum+0(4).
        MESSAGE e000(zi) WITH text-002 text-003.
      ENDIF.                               " IF s_per2-low GE sy-datum+4(2)
    Company Code Validation
      IF p_bukrs IS NOT INITIAL.
        SELECT
        SINGLE  bukrs                      " Company Code
          FROM  t001
          INTO  w_bukrs
         WHERE  bukrs = p_bukrs.
        IF sy-subrc NE 0.
          MESSAGE e000(zi) WITH 'Enter Valid Company code '.
        ENDIF.                             " IF sy-subrc NE 0.
        CLEAR w_bukrs.
      ENDIF.                               " IF p_bukrs IS NOT
    *&     START OF SELECTION                                             *
    START-OF-SELECTION.
    *-Get the GL Accounts from table ZSCOMMON
      PERFORM get_gl_information.
    *-Get the Inventory Details
      PERFORM get_inventory_data.
    *-Get the COGS details
      PERFORM get_cogs_data.
    *-Population of Period Table
      PERFORM populate_period_data.
    *-Populate the Final Data
      PERFORM populate_final_data.
    *&     END OF SELECTION                                               *
    END-OF-SELECTION.
    *-Display the Output
      PERFORM display_inv_turn_data.
    *&      Form  get_hlp_for_year
          Get the Value help for Year
    FORM  get_hlp_for_year.
    *-Populate the F4 Values for Year
      SELECT  pabrj
        FROM  t549q
        INTO
       TABLE  it_year.
      IF sy-subrc EQ 0.
        SORT it_year.
        DELETE it_year WHERE gjahr = ''.
        DELETE ADJACENT DUPLICATES FROM it_year
                                COMPARING gjahr.
    *-Attaching the F4 Help to The Selection parameter
        CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
          EXPORTING
            retfield        = 'GJAHR'
            dynpprog        = sy-repid
            dynpnr          = sy-dynnr
            value_org       = 'S'
          TABLES
            value_tab       = it_year
            return_tab      = return
          EXCEPTIONS
            parameter_error = 1
            no_values_found = 2
            OTHERS          = 3.
        IF sy-subrc EQ 0.
          READ TABLE return INDEX 1.
          s_year-low = return-fieldval.
        ENDIF.                             " IF sy-subrc EQ 0
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " get_hlp_for_year
    *&      Form  get_hlp_for_period
          Get the Search help for Period
    FORM get_hlp_for_period.
    *-Population of Period to Display the F4 values
      CLEAR return[].
      wa_per-perid = '001'.
      DO 12 TIMES.
        APPEND wa_per TO it_period.
        wa_per-perid = wa_per-perid + 1.
      ENDDO.                               " DO 12 TIMES.
    *-Attaching the F4 values to the selection parameter
      CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
        EXPORTING
          retfield        = 'PERID'
          dynpprog        = sy-repid
          dynpnr          = sy-dynnr
          value_org       = 'S'
        TABLES
          value_tab       = it_period
          return_tab      = return
        EXCEPTIONS
          parameter_error = 1
          no_values_found = 2
          OTHERS          = 3.
      IF sy-subrc EQ 0.
        READ TABLE return INDEX 1.
        s_per-low = return-fieldval.
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " get_hlp_for_period
    *&      Form  GET_GL_INFORMATION
          Get the GL account Information from ZSCOMMON table
    FORM get_gl_information .
      DATA: wa_common TYPE zscommon,
            wa_saknr  LIKE LINE OF r_saknr.
    *-GL Accounts from ZSCOMMON
      SELECT  *
        FROM  zscommon
        INTO
       TABLE  it_common
       WHERE  programm  =  sy-repid AND
              code      = 'GLAC'.
      IF sy-subrc EQ 0.
        wa_saknr-sign   = 'I'.
        wa_saknr-option = 'EQ'.
        LOOP AT it_common INTO wa_common.
          wa_saknr-low = wa_common-valuestrng.
          CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
            EXPORTING
              input  = wa_saknr-low
            IMPORTING
              output = wa_saknr-low.
          APPEND wa_saknr TO r_saknr.
        ENDLOOP.                           " LOOP AT it_common
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " GET_GL_INFORMATION
    *&      Form  GET_INVENTORY_DATA
          Get the Inventory Data
    FORM get_inventory_data .
      REFRESH r_year.
      r_year-sign = 'I'.
      r_year-option = 'EQ'.
    *-Populate the Year from Selection Parameters
      LOOP AT s_year.
        r_year-low = s_year-low.
        APPEND r_year.
        r_year-low = r_year-low - 1.
        APPEND r_year.
        r_year-low  = s_year-low.
        IF s_year2-low IS NOT INITIAL.
          DO.
            r_year-low = r_year-low + 1.
            IF r_year-low GT s_year2-low.
              EXIT.
            ENDIF.                         " IF r_year-low GT
            APPEND r_year.
          ENDDO.                           " DO
        ENDIF.                             " IF s_year2-low IS NOT
      ENDLOOP.                             " LOOP AT s_year
      CLEAR r_year.
      SORT r_year BY low.
      DELETE ADJACENT DUPLICATES FROM r_year COMPARING low.
      r_yr-sign = 'I'.
      r_yr-option = 'EQ'.
      LOOP AT s_year.
        r_yr-low = s_year-low.
        APPEND r_yr.
        IF s_year2-low IS NOT INITIAL.
          DO.
            r_yr-low = r_yr-low + 1.
            IF r_yr-low GT s_year2-low.
              EXIT.
            ENDIF.                         " IF r_yr-low GT s_year2-low
            APPEND r_yr.
          ENDDO.                           " DO
        ENDIF.                             " IF s_year2-low IS NOT
      ENDLOOP.                             " LOOP AT s_year
    *-Get the Inventory Data
      SELECT *
        FROM glt0
        INTO TABLE it_inv
        WHERE bukrs = p_bukrs AND
              ryear IN r_year AND
              racct IN r_saknr.
    ENDFORM.                               " GET_INVENTORY_DATA
    *&      Form  GET_COGS_DATA
          Get the COGS data
    FORM get_cogs_data .
      DATA: s_item TYPE RANGE OF fc_item,
            wa_item LIKE LINE OF s_item.
    BEGIN OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
      data: wa_common1 TYPE zscommon.
      SELECT  *
        FROM  zscommon
        INTO
       TABLE  it_common1
       WHERE  programm  =  sy-repid AND
              code      = 'CCOA'.
      IF sy-subrc EQ 0.
        wa_item-sign   = 'I'.
        wa_item-option = 'EQ'.
        LOOP AT it_common1 INTO wa_common1.
          wa_item-low = wa_common1-valuestrng.
          APPEND wa_item TO s_item.
        ENDLOOP.                           " LOOP AT it_common1
      ENDIF.                               " IF sy-subrc EQ 0
    wa_item-sign = 'I'.
    wa_item-option  = 'EQ'.
    wa_item-low = '0000005000'.
    APPEND wa_item TO s_item.
    wa_item-low = '0000006100'.
    APPEND wa_item TO s_item.
    wa_item-low = '0000007900'.
    APPEND wa_item TO s_item.
    END OF INSERT BY RMANDAL ON - 05/19/2008- RD4K900419
    *-Population of COGS information
      SELECT *
        FROM ecmct
        INTO TABLE it_cogs
        WHERE ryear IN r_year AND
              rbunit EQ '000000000000003000' AND
              ritem IN s_item  AND
          ( ( sityp EQ '2  ' AND
              subit EQ '0100      ')
              OR
            ( sityp EQ ' ' AND
              subit EQ ' ') ).
      IF sy-subrc EQ 0.
      ENDIF.                               " IF sy-subrc EQ 0
    ENDFORM.                               " GET_COGS_DATA
    *&      Form  POPULATE_FINAL_DATA
          Population of final Data
    FORM populate_final_data .
      DATA: inc(2) TYPE n,
            w_pert(15),
            col(5).
    *Field catalog population.
      wa_fieldcat-fieldname = 'TEXTS'.
      wa_fieldcat-outputlen = 20.
      wa_fieldcat-coltext = 'Info'.
      APPEND wa_fieldcat TO it_fieldcat.
      inc = 1.
      DO 12 TIMES.
        CONCATENATE 'PER' inc INTO wa_fieldcat-fieldname.
        CONCATENATE 'PER' inc INTO wa_fieldcat-coltext.
        wa_fieldcat-outputlen = 20.
        wa_fieldcat-just = 'R'.
        APPEND wa_fieldcat TO it_fieldcat.
        CLEAR wa_fieldcat .
        inc  = inc + 1.
      ENDDO.                               " DO 12 TIMES.
      SORT it_per BY year period.
      inc = 1.
    *-Final Internal table formation
      LOOP AT it_per INTO w_per.
        READ TABLE it_final WITH KEY year = w_per-year
                                  TRANSPORTING NO FIELDS.
        IF sy-subrc NE 0.
          wa_final-texts = w_per-year.
          wa_final-year = w_per-year.
          inc = 1.
          DO 12 TIMES.
            CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
            ASSIGN (w_pert) TO <fs>.
            <fs> = inc.
            inc = inc + 1.
          ENDDO.                           " DO 12 TIMES
          APPEND wa_final TO it_final.
          CLEAR wa_final.
          inc = w_per-period+1(2).
          wa_final-year = w_per-year.
          wa_final-texts = 'COGS Tot(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-cogs.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Inv Total(12 months)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invtot.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Inv Avg(monthly)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invavg.
          APPEND wa_final TO it_final.
          wa_final-texts = 'Turns(COGS/Inv.Avg)'.
          wa_final-year = w_per-year.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invturn.
          APPEND wa_final TO it_final.
          CLEAR wa_final.
          APPEND wa_final TO it_final.
        ELSE.
          inc = w_per-period+1(2).
         wa_final-texts = 'COGS Total(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-cogs.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'COGS Tot(12 months)'
                           AND  year = w_per-year.
          wa_final-texts = 'Inv Total(12 months)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invtot.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Inv Total(12 months)'
                           AND  year  = w_per-year .
          wa_final-texts = 'Inv Avg(monthly)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invavg.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Inv Avg(monthly)'
                           AND  year  =  w_per-year
          wa_final-texts = 'Turns(COGS/Inv.Avg)'.
          CONCATENATE 'WA_FINAL-PER' inc INTO w_pert.
          CONCATENATE 'PER' inc INTO col.
          ASSIGN (w_pert) TO <fs>.
          <fs> = w_per-invturn.
          MODIFY it_final FROM  wa_final TRANSPORTING (col)
                         WHERE  texts = 'Turns(COGS/Inv.Avg)'
                           AND  year = w_per-year .
          CLEAR wa_final.
        ENDIF.                             " IF sy-subrc NE 0
      ENDLOOP.                             " LOOP AT it_per INTO
    ENDFORM.                               " POPULATE_FINAL_DATA
    *&      Form  DISPLAY_INV_TURN_DATA
          Display Inventory Turns Report
    FORM display_inv_turn_data .
      IF NOT it_final IS INITIAL.
    *-Save the Data
       PERFORM save_data.
        CALL SCREEN 100.
      ELSE.
        MESSAGE s000(zi) WITH 'No data for selection'.
      ENDIF.                               " IF NOT it_final
    ENDFORM.                               " DISPLAY_INV_TURN_DATA
    *&      Form  POPULATE_PERIOD_DATA
          Populate the Period Data
    FORM populate_period_data .
    *- Work Variables
      DATA: wa_inv     TYPE glt0,
            wa_cog     TYPE ecmct,
            w_amt(12),
            w_debit    TYPE tslxx,
            w_credit   TYPE tslxx,
            w_invtot   TYPE tslxx,
            w_cogstot  TYPE tslxx,
            w_bal1     TYPE tslxx,
            w_bal2     TYPE tslxx,
            w_total    TYPE tslxx,
            w_inc(2)   TYPE n,
            w_perd     TYPE fc_perid,
            w_bal(12),
            lv_period  TYPE fc_perid,
            lv_year    TYPE gjahr,
            w_change.
    *- Field Symbols
      FIELD-SYMBOLS: <fs> TYPE ANY,
                     <fs_bal> TYPE ANY.
    *-Population of Balance for all Periods.
      SORT it_inv BY ryear.
      LOOP AT r_year.
        CLEAR: w_debit,w_credit,
               w_bal1,w_bal2,w_total.
        wa_balance-gjahr = r_year-low.
        LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                         drcrk = 'S' .
          w_bal1 = w_bal1 + wa_inv-tslvt.
          CLEAR wa_inv-tslvt.
        ENDLOOP.                           " LOOP AT it_inv
        LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                         drcrk = 'H' .
          wa_inv-tslvt = wa_inv-tslvt * -1.
          w_bal2 = w_bal2 + wa_inv-tslvt.
          CLEAR wa_inv-tslvt.
        ENDLOOP.                           " LOOP AT it_inv INTO wa_inv
        w_total = w_bal1 - w_bal2.
        w_inc = 1.
        DO 12 TIMES.
          LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                           drcrk = 'S' .
            CLEAR: w_bal.
            CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
            ASSIGN (w_bal) TO <fs_bal>.
            w_debit = w_debit + <fs_bal>.
            UNASSIGN <fs_bal>.
          ENDLOOP.                         " LOOP AT it_inv INTO wa_inv
          LOOP AT it_inv INTO wa_inv WHERE ryear = r_year-low AND
                                       drcrk = 'H' .
            CLEAR: w_bal.
            CONCATENATE 'WA_INV-TSL' w_inc INTO w_bal.
            ASSIGN (w_bal) TO <fs_bal>.
            <fs_bal> = <fs_bal> * -1.
            w_credit = w_credit + <fs_bal>.
            UNASSIGN <fs_bal>.
          ENDLOOP.                         "  LOOP AT it_inv INTO wa_inv
          wa_balance-tslvt = w_debit - w_credit + w_total.
          wa_balance-period = w_inc.
          APPEND wa_balance TO it_balance.
          w_inc = w_inc + 1.
        ENDDO.                             " DO 12 TIMES
      ENDLOOP.                             " LOOP AT r_year
      CLEAR: w_credit,w_debit.
      r_per-sign = 'I'.
      r_per-option = 'EQ'.
      CLEAR it_peryear[].
    *-Populate the periods
      r_per-low = s_per-low.
      lv_year = s_year-low.
      DO .
        it_peryear-period = r_per-low.
        it_peryear-gjahr = lv_year.
        APPEND it_peryear.
        IF r_per-low GE s_per2-low AND
           lv_year EQ s_year2-low.
          EXIT.
        ENDIF.                             " IF r_per-low GE s_per2
        IF r_per-low = 12.
          r_per-low = 1.
          lv_year = lv_year + 1.
        ELSE.
          r_per-low = r_per-low + 1.
        ENDIF.                             " IF r_per-low = 12
      ENDDO.                               " DO
      CLEAR: r_per,r_year,w_change.
    *-Population of the Turns information based on Period and year
      LOOP AT it_peryear.
        w_perd = it_peryear-period.
        LOOP AT r_yr WHERE low = it_peryear-gjahr.
          w_per-period = it_peryear-period.
          IF w_change = ''.
            w_per-year = r_yr-low.
          ENDIF.                           " IF w_change = ''
          IF w_per-period = 12.
            IF  s_per-low <> w_per-period.
            r_yr-low = r_yr-low - 1.
              w_change = 'X'.
            ENDIF.                         " IF  s_per-low <> w_per-period
            w_per-year = r_yr-low.
          ENDIF.                           " IF w_per-period = 1
          CLEAR: w_invtot,
                 w_cogstot.
    *-For each period populate the Credit and Debit info
          DO 12 TIMES.
            w_period-period = it_peryear-period.
            w_period-year = r_yr-low.
            CLEAR: w_amt,w_debit,w_bal1.
            CONCATENATE 'WA_INV-TSL' w_period-period+1(2) INTO w_amt.
            LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
                                             drcrk = 'S' .
              ASSIGN (w_amt) TO <fs>.
              w_debit = w_debit + <fs>.
              UNASSIGN <fs>.
              CLEAR wa_inv-tslvt.
            ENDLOOP.                       "  LOOP AT it_inv INTO wa_inv
            CLEAR: w_credit,w_bal2.
            LOOP AT it_inv INTO wa_inv WHERE ryear = w_period-year AND
                                             drcrk = 'H' .
              ASSIGN (w_amt) TO <fs>.
              <fs> = <fs> * -1.
              w_credit = w_credit + <fs>.
              UNASSIGN <fs>.
              CLEAR wa_inv-tslvt.
            ENDLOOP.                       " LOOP AT it_inv INTO wa_inv
            w_period-tsl01 = w_debit - w_credit.
            CLEAR w_amt.
            CONCATENATE 'WA_COG-TSL' w_period-period+1(2) INTO w_amt.
            LOOP AT it_cogs INTO wa_cog WHERE ryear = w_period-year.
              ASSIGN (w_amt) TO <fs>.
              w_period-tsl02 = w_period-tsl02 + <fs>.
              UNASSIGN <fs>.
            ENDLOOP.                       " LOOP AT it_cogs INTO wa_cog
    *-Calculate the total amounts
            w_invtot  =  w_invtot + w_period-tsl01.
            w_cogstot =  w_cogstot + w_period-tsl02.
            APPEND w_period TO it_year_per.
            CLEAR: w_period-tsl02,w_period-tsl01.
            IF it_peryear-period EQ 1.
              it_peryear-period = 12.
              r_yr-low = r_yr-low - 1.
            ELSE.
              it_peryear-period = it_peryear-period - 1.
            ENDIF.                         " IF it_peryear-period
          ENDDO.                           " DO 12 TIMES.
          lv_period = w_per-period.
          lv_year =  w_per-year.
          DO 12 TIMES.
            READ TABLE it_balance INTO wa_balance
                                  WITH KEY period = lv_period
                                           gjahr  = lv_year.
         w_per-invtot = w_invtot .+ wa_balance-tslvt.
            w_per-invtot = w_per-invtot + wa_balance-tslvt.
            IF lv_period = 1.
              lv_period = 12.
              lv_year = lv_year - 1.
            ELSE.
              lv_period = lv_period - 1.
            ENDIF.                         " IF lv_period = 1
            CLEAR wa_balance-tslvt.
          ENDDO.                           " DO 12 TIMES
          w_per-cogs = w_cogstot.
          w_per-invavg = w_per-invtot / 12.
          IF w_per-invavg NE 0.
            w_per-invturn = w_per-cogs / w_per-invavg.
          ENDIF.                           " IF w_per-invavg NE 0
          w_per-year = it_peryear-gjahr.
          w_per-info = it_year_per.
          APPEND w_per TO it_per.
          CLEAR: w_per-period,
                 w_per-invtot,
                 w_per-invavg,
                 w_per-cogs,
                 w_per-invturn,
                 w_per-info,it_year_per.
        ENDLOOP.                           " LOOP AT r_yr WHERE
      ENDLOOP.                             " LOOP AT it_peryear
    ENDFORM.                               " POPULATE_PERIOD_DATA
    *&      Form  create_chart
          Display the Chart
    FORM create_chart USING p_html TYPE w3htmltabtype p_real.
      DATA:
        igs_chart       TYPE REF TO cl_igs_chart,
        line            TYPE igs_data,
        data            TYPE igs_data_tab,
        ext_line        TYPE igs_ext,
        extension       TYPE igs_ext_tab,
        mime            TYPE w3mimetabtype,
        html            TYPE w3htmltabtype,
        html_line       TYPE w3html,
        url             TYPE w3url,
        content_length  TYPE i,
        content_type    TYPE w3param-cont_type,
        content_subtype TYPE w3param-cont_type.
      DATA: val TYPE char30.
    empty result table
      REFRESH p_html.
    create chart object
      CREATE OBJECT igs_chart.
    set chart type
      igs_chart->type = cl_igs_chart=>co_type_lines.
    set picture size
      igs_chart->width = 640.
      igs_chart->height = 480.
    igs_chart->width = 1024.
    igs_chart->height = 680.
    data to be displayed in the form of Graph
      SORT it_per BY period.
      LOOP AT it_per INTO w_per.
        line-groupid = w_per-year.
        line-x = w_per-period.
        IF w_per-invturn < 0.
          w_per-invturn = w_per-invturn * -1.
          CLEAR val.
          val = w_per-invturn .
          CONCATENATE '-' val INTO line-y.
        ELSE.
          line-y = w_per-invturn.
        ENDIF.                             " IF w_per-invturn < 0
    BEGIN OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
    To dislay the values in Graph
        line-DATALABEL = line-y.
        condense line-datalabel.
    END OF INSERT BY RMANDAL - 19/05/2008 - RD4K900419
        APPEND line TO data.
        CLEAR line.
      ENDLOOP.                             " LOOP AT it_per INTO w_per
    *-Populate the IGS data
      igs_chart->data = data.
    set titles
      igs_chart->title = 'Inventory Turns'.
      igs_chart->title_values = 'No of Turns'.
      igs_chart->title_categories = 'Period'.
    create picture
      CALL METHOD igs_chart->send
        IMPORTING
          content_type            = content_type
          content_length          = content_length
          content                 = mime
          imagemap                = html
        EXCEPTIONS
          rfc_communication_error = 1
          rfc_system_error        = 2
          internal_error          = 3
          OTHERS                  = 4.
      IF sy-subrc IS INITIAL AND p_real NE space.
        SPLIT content_type AT '/' INTO content_type content_subtype.
        CALL METHOD html_control->load_data
          EXPORTING
            type         = content_type
            subtype      = content_subtype
            size         = content_length
          IMPORTING
            assigned_url = url
          CHANGING
            data_table   = mime.
        CONCATENATE
          '<HTML><HEAD><TITLE>SAP IGS Chart</TITLE></HEAD>'
          '<BODY BGCOLOR=#DEDEC8>'
          '<MAP NAME=chart>'
          INTO html_line-line.
        APPEND html_line TO p_html.
        APPEND LINES OF html TO p_html.
        CONCATENATE
          '</MAP>'
          '<IMG SRC="' url '" USEMAP=#chart BORDER=0>'
          '</BODY></HTML>'
          INTO html_line-line.
        APPEND html_line TO p_html.
      ENDIF.                               "  IF sy-subrc IS INITIAL AND..
    ENDFORM.                               " create_chart
    *&      Module  STATUS_0100  OUTPUT
          Status and Controls Initialzation
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZTURN'.
      SET TITLEBAR 'ZTURN'.
      DATA: layout TYPE lvc_s_layo.
    *-Create the Container
      CREATE OBJECT cont
         EXPORTING
           container_name              = 'CONT'
         EXCEPTIONS
           cntl_error                  = 1
           cntl_system_error           = 2
           create_error                = 3
           lifetime_error              = 4
           lifetime_dynpro_dynpro_link = 5
           OTHERS                      = 6
      IF sy-subrc NE 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                   WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.                               " IF sy-subrc NE 0
    *-If Report option
      IF p_rep EQ 'X'.
    *-Creation of Grid Object
        CREATE OBJECT grid
          EXPORTING
            i_parent          = cont
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc NE 0
        layout-zebra = 'X'.
        layout-no_headers = 'X'.
        layout-cwidth_opt = 'X'.
        layout-grid_title = 'Inventory Turns Report'.
    *-Display the ALV
        grid->set_table_for_first_display(
           EXPORTING
             is_layout                     =  layout
           CHANGING
             it_outtab                     = it_final
             it_fieldcatalog               = it_fieldcat
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
        IF sy-subrc  NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc  NE 0
    *-If Graph Option selected
      ELSEIF p_grp EQ 'X'.
      set rfc destination
        cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
      create hmtl control
        CREATE OBJECT html_control
          EXPORTING parent = cont.
        PERFORM create_chart USING g_html 'X'.
      get url of output data
        CALL METHOD html_control->load_data
          EXPORTING
            type         = 'text'
            subtype      = 'html'
          IMPORTING
            assigned_url = g_url
          CHANGING
            data_table   = g_html.
      Load the picture by using the url generated by the data .
        CALL METHOD html_control->show_url
          EXPORTING
            url = g_url.
    *-If Both Report and Graph Selected
      ELSE.
      set rfc destination
        cl_gfw=>its_rfc_dest = 'IGS_RFC_DEST'.
    Create Splitter for custom_container
        CREATE OBJECT split
           EXPORTING
              parent  = cont
              rows    = 2
              columns = 1.
        CALL METHOD split->get_container
          EXPORTING
            row       = 1
            column    = 1
          RECEIVING
            container = htmlcon.
        CALL METHOD split->get_container
          EXPORTING
            row       = 2
            column    = 1
          RECEIVING
            container = gridcon.
      create hmtl control
        CREATE OBJECT html_control
          EXPORTING parent = htmlcon.
        PERFORM create_chart USING g_html 'X'.
      get url of output data
        CALL METHOD html_control->load_data
          EXPORTING
            type         = 'text'
            subtype      = 'html'
          IMPORTING
            assigned_url = g_url
          CHANGING
            data_table   = g_html.
      Load the picture by using the url generated by the data .
        CALL METHOD html_control->show_url
          EXPORTING
            url = g_url.
        CREATE OBJECT grid
          EXPORTING
            i_parent          = gridcon
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            OTHERS            = 5
        IF sy-subrc NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc NE 0
        layout-zebra = 'X'.
        layout-no_headers = 'X'.
        layout-cwidth_opt = 'X'.
        layout-grid_title = 'Inventory Turns Report'.
        grid->set_table_for_first_display(
           EXPORTING
             is_layout                     =  layout
           CHANGING
             it_outtab                     = it_final
             it_fieldcatalog               = it_fieldcat
         EXCEPTIONS
           invalid_parameter_combination = 1
           program_error                 = 2
           too_many_lines                = 3
        IF sy-subrc  NE 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                     WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.                             " IF sy-subrc  NE 0
      ENDIF.                               " IF p_rep EQ 'X'
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          User Action Handling
    MODULE user_command_0100 INPUT.
      CASE sy-ucomm.
    *-Handling the User actions
        WHEN 'BACK' OR 'CANC' OR 'EXIT'.
          LEAVE TO SCREEN 0.

  • Error in Invoice process

    Hello Experts,
    I need your help.
    I had an requirement from the client to capture the COGS details are in transit.
    Created new condition type ZVRS, copy of VPRS. Assigned the Account key and G/L accounts in VKOA.
    Created the order and ZVRS value calculated and marked as a statistical in order process.
    Created the invoice, but ZVRS value is "0" and the error message is 217
    ZVRS 217 Error in quantity/value determination.
    Verified the settings in OMS2 and its ok.
    Can you please let me know any thing to check?
    Regards,
    SK

    Hi mastan
    Please check below details
    VPRS should have subtotal as B and requirement as 4 and also should be statistical in your pricing procedure
    Moreover the item category of the sales order Determine cost should be marked in VOV7 and also check in Material Master what is the Price(Standard Price) you maintained.
    Then it will flow in sales order
    Regards,
    mahabooba shaik

  • Different Method to valuate sales order stock

    Dear expert,
         I came across a problem and I need your help:
         Scenario: Make-To-Order production without sales order controlling.  Uses standard price in material master record.
         As we know, There are a predefined sequence to valuate sales order stock: First, The system uses the standard price on the basis of your customer exit COPCP002 Material valuation for valuated sales order stock. If not defined COPCP002, Then, the system uses sales order costing.  Then, the system determines the standard price using the production order cost estimate. At the end,  the system determines that If you manufacture a material both for the make-to-stock-inventory and for the valuated sales order stock, the system reads the material master record of the collective requirements material.
         In SAP online Help, there is a note that: If you calculate the standard price of sales order stock in a preliminary cost estimate for the manufacturing order or use the price in the material master record, you cannot transfer cost component splits into COPA. This is my doubt: I don't know exactly where are the differences between sales orde costing and standard price in material mater to determine sales order stock.
         So, I have a question:  What are the extract diffences between using sale order cost estimate and the standard price in the material master record to determine valuated sales order stock?
         Thanks for your help.  Best regards,

    What you said is exactly what I want! Very thankful for your help.
    Yes, I have found that in EBEW table that standard price is valuated with preliminary cost estimate because I don't give a sales order cost estimate but I give an sales order stock in the customizing - requirement class. So, I have this question that how the sales order stock is determined.
    In COPA customizing (COprofitability analysismaster datavaluationSet up valuation using material cost estimate), standard cost estimate or sales order cost estimate can be transferred into COPA value fields in our system.
    But, I have still have a question: I found in our system, preliminary cost estimate in the linked production order is determined for valuation of sales order stock in EBEW table. As sap online help says, cost component splits can not be transferred to COPA.
    So, according to SAP online help, I think what you said u201Cu2026..However , when we start thinking about the result of this cost to flow into COPA , this cannot happen as the Inventory was valued with a Preliminary csot estimate. So , the Online help says that it will not be able to transfer Result of Preliminary cost estimate into COPA for transferrring COGS details. System would always require a Standard cost estimate or a Sales order Cost estimate to flow Cost details into COPAu201D is correct.
    But, in our system, cost component can be transferred into COPA!? When I create a sales billing (invoice) with tcode VF01, it can create a profitability analysis document (shown in VF03) which it had a cost component split for that material in the sales order stock valuated with the preliminary cost estimate. Or where is stored for the Make-to-Order materialu2019s cost component split in COPA?
    That is the real point that confused me. Hope you can help me. Thanks very much.

  • Query for details of  Sale order , Invoice and COGS

    I Need the report cointing following based on month & Business partner
    Sale order, Sale Amount, Due date, Invoice Amount, Last Invoice date, COGS amount

    Hi Anantha,
    Please check below link and modify according to your requirement.
    Sales Order Query for  in SAP B1
    Query - Sales Orders linked to Deliveries
    My Top SQL Queries for SAP Business One
    Hope this helps
    Regards::::
    Atul Chakraborty

  • COGS (Cost of the Goods Sold) in OPM reg.

    Hi
    Can anyone provide the details about COGS (Cost of the goods sold) documents/set up in R12.
    This is very urgent.
    Kindly do the needful.
    Mail id : [email protected]
    Regards
    Raj

    Hi,
    1. Cost of manufacture of a Product is what the value of goods sold or Cost of Goods sold (COGS). Either, you use the SAP Costing module (CO-PC) to let SAP determine COGS or you can manullay input COGS into material master fields (Standard or Moving Average) in Accounting view of Material master. In either case, COGS is stored in the material master valuation (Accounting) view.
    2. You mean in a COGS? Whatever costs it takes to manufacture a product is included in COGS, for instance Material cost, Labor cost etc.,
    Hope this helps.
    PS: There is lot of documentation available online SAP help protals and please refrain from using this forum for asking such basic questions and restrict to only questions of clarificatory in nature or issue based questions.
    Make an effort to read the SAP help documentation for all your basic questions.
    http://help.sap.com/saphelp_erp60_sp/helpdata/en/80/ea89395eb58c4f9d0c3e837cf0909d/frameset.htm
    Mods (Moderators) will lock your threads, if you continue to ask such basic questions, so no one can reply to it.
    Edited by: Pradeep kumar Athmakur on Feb 27, 2010 12:41 AM

  • Report for inventory , COGS at plant / GL account level

    Hi,
    We have a need to develop a BI report for pulling out the following information :
    1) Inventory at plant level
    2) COGS value for a plant
    3) The above detail would be needed at account level.
    Any table/SAP report from where we can pull these data.
    Thanks in advance.
    Regards,
    Karthik

    Hi
    Can i know if your plants are defined as profit centers.  I guess they are
    if so, you can use simple report painter report to derive plant wise values which you are looking for
    Let me know if you wish to use the report painter option

  • Error in COGS report

    Hello,
    I have a weird error coming up. I have a COGS report in my company. It shows COGS amt, profit ctr, material # and qty. For a particular material #, the COGS amt is popping but the qty is zero. What does this mean? If there exist qty, then only should an amt pop up. Why is amount showing in COGS with qty '0'.
    Any clue anyone???
    Thanks,
    Akanksha

    Hi,
    It is a custom report. I went through the sales order and all delivery details and tables associated with the report. It has 2 different quantities mentioned. Not sure why...
    Akanksha

  • Change Qty to 0 to clear COGI errors

    Hello everyone,
    I've been giving a temp job as a sort of MRP Controller for a materials handling company in the UK and have been given the task to clear the COGI errors. I'm new to this part of SAP as I used to work as an operator so never used any logistic or sales modules. Basically I think I have worked out what a COGI is and in princible about how to clear them. The orders have finshed and it is trying to backflush the material stock levels. The problem I am encoutering is this materials were used in orders early last year. The product has been made and shipped off to the vendor. I can see the stock being removed from the system months later in a stock check. The original backflush never happened as a lot or Materials never had the corect storage location. Anyhow, Can I clear these COGI's and the relevenant OrdRes on the materials by changing the COGI qty to 0 and then processing them? When I check the component list for the production order they go through as finialised (FLS is ticked), the OrdRes is removed however will this cause problems I'm unware of? I need to know if doing this right otherwise I need to get people to add the stock back in to clear the backlog and I have many to do and the process is painful and I want to sort this ASAP as the system is raising purshase requitions for parts need nearly a year ago and been built and sent off site!
    Any help would be great...
    Adam

    Hi,
    To do this you have to do following steps,
    1. In the COGI list go to Edit - > Replace -> Date.(CtrlShiftF10)
    2. Change the date to current date. This is required because the old posting periods will not be open for postings.
    3. Select the line & click on Change details (F5).
    4. Change the quantity to 0 (Zero).
    5. Post the document.
    Thanks,
    Navin

  • Automatic creation of requirement for extra consumption in COGI

    Dear.
    For a production order with a component totally consumed during the backflushing of CO11N I run a new confirmation. The component isnu2019t available , the confirmation is done and the system create for the component an error movement in COGI.
    If I see MD04 for this component I donu2019t see any production order requirement for the extra consumption quantity in COGI.
    But the planner need to know the quantity that remain to withdrawn.
    Which is the reason for the missing automatic creation of requirement for extra consumption in COGI ?
    Thanks.

    Dear Cris,
    Have you manually edited and input extra qty in CO11N
    When backflush is activated and Full qty is confirmed
    Then if you perform confirmation second time then form where system will again pick the component
    Once again check in production order BOM over view and also in BOM what is the qty given
    Can you eloborate more in detail what you have performed ( steps required )
    Dear Siva,
    Just correct me if i am wrong
    Regards
    Madhu
    Edited by: K.Madhu Kumar on Sep 30, 2010 1:10 PM

  • Cost of good sold (COGS) in planning

    Hi,
    Can someone please guide me how to estimate COGS for a product? Thank you

    Hi Pramila,
    Please click on below link for concepts and details of COGS and its functionalities.
    [COGS|
    Appreciate if it is helpful to you
    Thanks
    Vetri
    Edited by: Virendra Pal on Mar 8, 2010 9:16 AM
    SAP Help link removed

  • Cost of Good Sold (COGS) in Project

    Dear All
    What is concept of COGS calculate in Project? How it calculate for Material & Services? When the order is complete, the Material stock is transfer to the customer site at this point no COGS should be recognized. When the installation is complete for services, customer will recognize the COGS and the Revenue in my books.
    Regards

    Hi Pramila,
    Please click on below link for concepts and details of COGS and its functionalities.
    [COGS|
    Appreciate if it is helpful to you
    Thanks
    Vetri
    Edited by: Virendra Pal on Mar 8, 2010 9:16 AM
    SAP Help link removed

  • Cost of sales flow in COPA and its detailed breakdown cost component f

    Hi ,
    we have a requirement that we need details about what makes cost of sales numbers in COPA.
    i know the our VPRS value is flowing into COPA as COGS but now we want that we should have ite detailed breakdown as per cost components.
    can you please tell me detailed configuration steps to make this happen so that we can create a new COPA ke30 report which gives us the breakdown of the COGS numbers.
    one more requirement is that for purchase parts our client is maintaing price PB00 condition and some other conditions like brokerage, freight etc in the info record for those materials and they want that all these conditions value should add up to show the COGS value for these purchase parts in the COPA report.. how do we do that?
    please reply soon...
    Thanks in advance,
    Gurjit

    Hi Balaji
    Which cost elements are you talking about? You can directly make FI postings to COPA in F-02 by clicking on "Prf Seg"
    Note that a cost element will either be posted to COPA or Cost Center or Internal order or WBS element... Real posting happens only to one of these...
    Out of these, some Cost Centers merge into COGM/COGS i.e. Std cost and this is reflected as COGS.... The variance is posted as variance in COPA
    Some cost centers like Marketing which do not form part of COGM/COGS, can be allocated from CO to COPA using KEU5...
    This is how the values flow to COPA
    Regards
    Ajay M

  • COGS value should not be updated in COPA

    Hi Experts,
    Greeting from day!!!!
    One of my client is having 2 Plants (Ex 1000,1100) from there they are making billing to customers. and the requirement is while making billing to customers from 1100 they want update COGS values in COPA where as from 1000 they don't want update COGS value in COPA.
    In my mind standard SAP it won't possible.
    Is there any user exist or any other solution for the above requirement.
    Thanks in advance,
    chandu.

    Hi Ajay,
    Thanks for prompt replay!!!!!!
    I mean COGS value from VPRS condition type.
    ###1. If VPRS - You will have to write a routine (Exit) in SD whereby they make the Value of VPRS to zero if the Plant = 1000###
    Can you explain in detailed i.e. which Exit i need to use? where i need to maintain exit for the same?.
    Regards,
    chandu.

Maybe you are looking for

  • Error while slecting member from dimension

    Hi All, When I open the dimension list in BPC for Excel, I am getting the following error: "A member could not be found in this search criteria."

  • Employee role is missing in BP roles

    Hi, Employee role is missing in BP roles what would be the problem? Thanks in advance

  • Reports 6 - Attached Libraries.

    Am currently developing a report using Oracle Report Builder 6.0 - which has an attached library containing a specific program unit. When compiled on my machine (win2000), no errors are encountered. But during runtime, we receive the error "ORA-06508

  • Unable to access WEB UI of WiSM2

    Bear with me as this is my first install of a 6500 and WiSM module. The backgroud is that we are small, but management used to be in networking and basically forced the the purchase of a 6509E.  Most of my experience is with 3560X and 2950 switches.

  • What is the Windows equivalent of DiskWarrior or TechTool Pro?

    Hi - I'm looking for admin/troubleshooting/defragging software for the Windows subsystem of my Mac - basically, the equivalent of DiskWarrior, or TechTool Pro? Let me know. Peter