Cost estimate REM

Hi,
  GURUS,
I donot have PP knowledge(I m into QM),and I am trying to run production cycle in rem.I have creatd the master data by opying from other..I have reached backflush stage,but system is saying no cost estimate available for period. Can somebody suggest what steps to do next.Or am i missing some master data.
Pls asssist
THANK you in advance
GR

Hi,
  Hi assume u have created required master data,however pls reconfirm whether
a)u r MM mrp profile has rem profile and rem allowed indicator.
b)do u have a valid poduction version
c)in the P>V tab have u CHECKED teh Run shedule header tab.
  Next, step will be to create Run schedule header.(3.1i) ,t code: MF01.or product cost collector as our PP guru suggested.The Run Scedule header is basically an object that collects all the Costing data related to u r product(inclusive of P.V,therefore BOM,Pr line,Routing,Validilty dates for RSh,etc).So when u run a cost estimate for this product the system will pick data with reference to RSh.This RSH is like a cost collector for updating or collecting the costs for this product.
Cost estimate(3.1 i),since our guru has suggested for laetr verison)
--CK11 run cost estimate(pls check status or error logs,and clear error logs with ur CO consultants help)
--CK20 for marking cost estinmate
--ck21 for releasing cost estimate.
Once it is succesfully done,check u r material master for FERT if the Std Cost estimate has updated.
Then u shud not have problem running backflush,since the system will now know where to credit or debit the costs .
GURUS,Pls update on this.
THNX
HKR

Similar Messages

  • Material cost estimate with quantity structure (tcode: CK11N)

    Hey dear friends.
    I donu2019t know in which forum I should put my question above.
    In fact, Iu2019m new to SAP PM module.
    Iu2019m trying to create material cost estimate with quantity structure (tcode: CK11N) for a material u201CXu201D.
    This material is manufactured.
    While running the transaction CK11N, I got an error message.
    After analyzing this error message, Iu2019ve realised that somebody had assigned wrong activity types to cost centers which are linked to this material in tcode: CR03, tab: costing.
    So Iu2019ve changed and assigned the right activity types.
    Then, Iu2019ve tried to run the tcode CK11N again. But the system still brings the wrong activity types and seems to ignore the ones that Iu2019ve assignedu2026
    It seems like the old activity types still linked to the cost centers somewhere else than in tcode CR03u2026
    Any idea about what am I mising ?
    Thank's in advance.
    Bahia.

    Dear Bahia,
    If its rate routing means,i guess you must be working in REM scenario.
    So goto CA22,delete the existing operation and then assign the same work center in a new
    operation,check what activity types is it proposing in the rate routing,if its reflecting correctly means
    save the datas.
    Also goto KKF6N--->click the change mode icon and then calculator button to create a preliminary cost
    estimate and then save the datas.
    One of our forum friend has asked you to check the production order read PP master data once
    again,but understand there is no production order concept in REM scenario,only planned orders.
    Then come back with your queries.
    Regards
    Mangalraj.S
    Edited by: Mangalraj.S on Jun 17, 2009 12:05 PM

  • Error determing cost estimate

    Hi Experts,
       When i am trying to backflush planned order type PE  in open period its giving following error
    Error determining the cost estimate
    Message no. RM078
    I tried to do cost estimate in KKF6N, it doesnt show any error, and save successfully butt again when i am coming back to mfbf its throwing same error, what is the reason behind that, i am doing mfbf in march 2009 because its open period here.
    Please help me in this regards.
    Thanks & Regards,
    Karad D D

    Dear Devidas,
    check what type of REM profile you have assigned to the material master.
    Check the setting of the REM profile in OSP2,whether under cost accounting the check box is set for backflush using
    preliminary cost estimate or else using standard cost estimate.
    If it's having std cost estimate check box means,execute CK40N and then only you will be able to backflush in MFBF.
    Check and revert back.
    Regards
    Mangalraj.S

  • Significance of Preliminary cost estimate,

    Hi experts,
    My clinet is using REM scenairo and in REM profile we have maintained "Backflush using standard cost estimate". My question is in this case what is the significance of preliminary cost estimate(PCE)? and I would able to confirm (MFBF) without running
    PCE.
    Please let me know is it mandatory to run PCE in this case.
    Thanks in advance.
    Purushotham...

    Dear Puru,
    WIP in REM is calculated at Target Cost. Valuation variant for target cost is generally preliminary cost estimate for the material and production version combination. However, if you want to valuate the work in process and scrap at the target costs calculated on the basis of a standard cost estimate, do not create a valuation variant for work in process and scrap. But it is always advisable to preliminary cost estimate in the target cost valuation strategy, because that is more accurate.
    To conclude, you can always do away with creating a PCE for backflushing, but that is not what SAP suggests.
    Regards,
    Hasan

  • Prelimanery cost estimate

    Dear Gurus,
                  There is price diffrence between the valus of (Prelimanery cost estimete ) MF30 and standard cost estimate ( CK11n) for the same material. What is the reason behind that. And i am stucking on a error in prelimanery cost estimate, that after running mf30 system shows me error message "No cost field for fixed costs has been defined'
    Thanks in advance
    ACP

    Dear ACP,
    I guess you are working in a REM scenario involving product cost collector and preliminary cost
    estimate.
    Prelimary cost estimate is calculating the planned costs for a business objest such as orders.
    Where it sums the material cost,activity cost and the overhead cost.This will not reflect anywhere in the
    material master.
    But a standard cost estimate which is carried out using CK11N can be marked and released by using
    CK24.This will reflect in the material master.
    This can be performed using CK40N also.
    Check and revert back.
    Regards
    Mangalraj.S

  • Costing in rem scenario

    Hai gurus,
    i have one small problem in rem costing.
    1) i am having the job flow as Roh to halb to fert.
    2) I had initially done standard cost estimate for fert using T.C CK11n and CK24, on doing this
        cost is updated in costing view 2 under future cost.
    3) The problem now is ,when i am doing  MFBF for the fert the system through the error as
        " No active standard cost estimate exist".
    NOTE;
    i had already done standard cost estimate for halb and also done MFBF for halb and the required qty
        is available at storage location.
    waiting for the positive feed  back.
    with regards,
    sekar chand

    Dear,
    This error is dur to there is no standard cost estimate for current period of material.
    I think u have not released the Std cost for Current period.
    1. in CK11N , please ensure that the cost estimate is without errors (check the log and ensure that green colour light is turned on).
    2. In CK24 , first mark the estimate.( ensure that the costing variant used in CK11N is the same used here for marking also) .Once the estimate is marked (check the status: Marked without errors)
    then , release the estimate.(check the status: Released without errors)
    3. Now check whether the price has been updated in Material master , in Costing2 view. (Only when mark & release is successful in CK24 , the price will be updated here).
    Or for all material go ahead with CK40N
    Regards,
    R.Brahmankar

  • Cost estimates

    Hi: All,
    Can any one Please explain the following with its applications
    1) Standard Cost Estimate for material
    2)Priliminary cost estimate for Product Cost COllector.
    please explain them with example.
    your help will be rewarded.
    Cheers,
    Nagesh.

    Dear Nagesh,
    1.Standard Cost Estimate for a material or product  is made up of Materials cost,Over head cost & the activity cost(oparation cost).
    Standard Cost estimate which is done using T code CK40N  is for the Finished product so that it automatcially calculates the HALB
    materials cost also.Product Cost = Material's Cost (Raw Materials & Semi-finished product's ) + Activity Cost (operation cost) +
    Overhead cost,if an overhead group is assigned in the material master of Finished product.
    For Raw-materials Planned price's are given in the material master in Costing 2 view & the price control indicator will be V.
    For In-house manufactured Semi-finished & Finished products the price control indicator will be S.
    Activity cost is calculated as per the operation time maintained in Routing or Rate routing(A Cost center & activity type will be
    assigned to the work center and a rate should be existing for that activity type & cost center combination in KP26).
    Once after standard cost estimate is completed the calculated cost is printed in the material master for FERT & HALB products.
    This is carried out using t code CK40N.
    2.Preliminary Cost estimate is carried out using T code KKF6N for Inhouse manufactured HALB & FERT's which comes under REM
    scenario.Its only a cost calculation but this value does not gets updated in the material master.
    3.SO in REM scenario as per the setting in control data 1 for cost accouting post activities it can be using standard cost estimate or
    else using data from pre.cost estimate for product cost collector confirmation can be carried out that's MFBF can be carried out.
    I hope this will clear your doubts.
    Regards
    Mangalraj.S

  • Eroor detrmining the cost estimate

    Dear all
    the standard price has already been released for a product
    but in MFBf it gives error detrmining the cost estimate

    We no longer use REM, but my thought is that each order, when created, calculaes a preliminary cost estimate, for the order base on the current BOM and Routing.  You get errors in the cost of orders when "something" has changed since the release of the cost estimate and would cause an error if costed "now".
    1 - a change has been made to a BOM or Routing or MAterial, and if you ran CK11n now, you will get an error.
    2 - the materials and activities of the order were changed and are causing the error.
    Go to the order, open it up and click on a button or menu that says: calculate costs.  a meessage log should result and tell you what the problem is

  • Primary cost estimate/ stad. cost estimate

    Hi gurus,
    Please advise in REM, what is the difference between std cost estimate and preliminary cost estimate. when we should go for preliminary cost estimate and in which scenario should we go for std? please advise.

    Hi
    To make things simple, please note the below difference.
    Standard cost estimate: -
    If you select this in REM profile, then if u make any changes in routing or BOM which could have impact in material cost, then the costing run and updating the assembly with new cost is mandatory beofre MFBF could be done.
    Preliminary cost estimate: -
    Here once Preliminary cost estimate is done then the back flush could be done with preliminary cost and costing run is not mandatory.
    The scenario depends on situation where company does chnages in routing or BOM frequently but it has no or negligible impact in final costing of material.

  • Backflush with Prel cost estimate still considering standard cost estimate

    Hi,
    Trying to do back flush with Prel cost estimate . Flagged in REM profile " Post Activities " / Using Data from Preliminary Costing".
    However,  FG rate is considred as per standard cost estimate and not as per preliminary cost estimate.
    Kindly advise whether any other specific setting is needed.
    Regards,
    Mrinal

    HI
    check these links:
    standard / preliminary cost estimate
    Significance of Preliminary cost estimate,
    preliminary cost estimate for product cost collector
    Hope it clarifies.
    Regards
    Anupam Sharma

  • Material Cost estimate modification

    Hi Experts
    I want to modified this report and add cost estimate value from MBEW (field is STPRS) for each material  to this report. I have used the table MBEW but unable to locate where to start.
    Can anyone have a look and comment on this report
    REPORT  command_extract                    .
    *CLASS cl_gui_control DEFINITION LOAD.
    *CLASS cl_gui_frontend_services DEFINITION LOAD.
    Tables
    TABLES:
      kna1,
      knb1,
      knvv,
      mara,
      mast,                                       "JPC20061107
      marc,
      makt,
      sscrfields.
    CONSTANTS: BEGIN OF gc_status,
                 acc  TYPE zcrstat1 VALUE ' ACC',
                 hol  TYPE zcrstat1 VALUE ' HOL',
                 sto  TYPE zcrstat1 VALUE ' STO',
                 ok   TYPE zcrstat1 VALUE '  OK',
                 hold TYPE zcrstat1 VALUE 'HOLD',
               END OF gc_status.
    CONSTANTS: BEGIN OF gc_reason,
                 000 TYPE zreason VALUE '000',
                 001 TYPE zreason VALUE '001',
                 002 TYPE zreason VALUE '002',
                 003 TYPE zreason VALUE '003',
                 004 TYPE zreason VALUE '004',
                 005 TYPE zreason VALUE '005',
                 006 TYPE zreason VALUE '006',
                 007 TYPE zreason VALUE '007',
                 008 TYPE zreason VALUE '008',
                 010 TYPE zreason VALUE '010',
                 011 TYPE zreason VALUE '011',
                 021 TYPE zreason VALUE '021',
                 022 TYPE zreason VALUE '022',
                 023 TYPE zreason VALUE '023',
                 024 TYPE zreason VALUE '024',
                 025 TYPE zreason VALUE '025',
                 026 TYPE zreason VALUE '026',
                 999 TYPE zreason VALUE '999',
               END OF gc_reason.
    TYPES: BEGIN OF ty_kna1_fields,
             kunnr TYPE kna1-kunnr,
             sperr TYPE kna1-sperr,
             aufsd TYPE kna1-aufsd,
             lifsd TYPE kna1-lifsd,
             faksd TYPE kna1-faksd,
             loevm TYPE kna1-loevm,
           END OF ty_kna1_fields.
    TYPES: BEGIN OF ty_knb1_fields,
             kunnr TYPE knb1-kunnr,
             bukrs TYPE knb1-bukrs,
             sperr TYPE knb1-sperr,
             loevm TYPE knb1-loevm,
           END OF ty_knb1_fields.
    TYPES: BEGIN OF ty_knvv_fields,
             kunnr TYPE knvv-kunnr,
             vkorg TYPE knvv-vkorg,
             vtweg TYPE knvv-vtweg,
             spart TYPE knvv-spart,
             aufsd TYPE knvv-aufsd,
             lifsd TYPE knvv-lifsd,
             faksd TYPE knvv-faksd,
           END OF ty_knvv_fields.
    TYPES: BEGIN OF ty_knkk_fields,
             kunnr TYPE knkk-kunnr,
             kkber TYPE knkk-kkber,
             ctlpc TYPE knkk-ctlpc,
             crblb TYPE knkk-crblb,
             knkli TYPE knkk-knkli,
             klimk TYPE knkk-klimk,
             skfor TYPE knkk-skfor,
             ssobl TYPE knkk-ssobl,
           END OF ty_knkk_fields.
    TYPES: BEGIN OF ty_cust_stat_output,
             kunnr(10) TYPE c, "Customer #
             stat(4)   TYPE c, "Customer status
           END OF ty_cust_stat_output.
    TYPES:
      BEGIN OF ty_customers,
        kunnr(10)  TYPE c,  " Customer #
        div1(1)    TYPE c,  " Pipe delimiter
        name1(32)  TYPE c,  " Customer name
        div2(1)    TYPE c,  " Pipe delimiter
        altkn(8)   TYPE c,  " Old Customer #
        div3(1)    TYPE c,  " Pipe delimiter
        stras(30)  TYPE c,  " Street
        div4(1)    TYPE c,  " Pipe delimiter
        ort01(20)  TYPE c,  " City
        div5(1)    TYPE c,  " Pipe delimiter
        regio(3)   TYPE c,  " State
        div6(1)    TYPE c,  " Pipe delimiter
        pstlz(4)   TYPE c,  " Postcode
        div7(1)    TYPE c,  " Pipe delimiter
        telf1(14)  TYPE c,                                      " Phone 1
        div8(1)    TYPE c,  " Pipe delimiter
        telf2(14)  TYPE c,                                      " Phone 2
        div9(1)    TYPE c,  " Pipe delimiter
        erdat(10)  TYPE c,  " date
        div10(1)   TYPE c,  " Pipe delimiter
        splant(2)  TYPE c,  " plant
        div11(1)   TYPE c,  " Pipe delimiter
      END OF ty_customers,
      it_ty_customers TYPE ty_customers OCCURS 0,
      BEGIN OF ty_custstat,
        kunnr(11)  TYPE c,  " Customer #
        company(2) TYPE c,  " #
        status(3)  TYPE c,  " acc,cod,hol,
      END OF ty_custstat,
      it_ty_custstat TYPE ty_custstat OCCURS 0.
    TYPES:
      BEGIN OF ty_materialm,
        matnr(12)  TYPE c,  " Material #
        maktx2(40) TYPE c,  " Command sales desc.
        maktx(16)  TYPE c,  " Basic description
        extwg(6)   TYPE c,  " External Material Group
        flag1(1)   TYPE c,  "
        flag2(1)   TYPE c,  "
        flag3(1)   TYPE c,  "
        flag4(1)   TYPE c,  "
      END OF ty_materialm,
      it_ty_materialm TYPE ty_materialm OCCURS 0,
      BEGIN OF ty_materialp,
        matnr(12)  TYPE c,  " Material #
        werks(4)   TYPE c,  " plant
        batch(1)   TYPE c,  " download to batch
      END OF ty_materialp,
      it_ty_materialp TYPE ty_materialp OCCURS 0.
    TYPES:
      BEGIN OF ty_bom,
        matnr(12)  TYPE c,  " Material #
        werks(4)   TYPE c,  " Plant
        posnr(3)   TYPE c,  " position
        idnrk(12)  TYPE c,  " BOM material #
        menge(10)  TYPE c,  " Quantity
        meins(3)   TYPE c,  " Unit of Measure
      END OF ty_bom,
      it_ty_bom TYPE ty_bom OCCURS 0,
    *Start of block of changes for JPC20061107
      BEGIN OF ty_bom_sapfmt,
        matnr   TYPE MAST-MATNR,  " Material #
        werks   TYPE MAST-WERKS,  " Plant
        posnr   TYPE STPO-POSNR,  " position
        idnrk   TYPE STPO-IDNRK,  " BOM material #
        menge   TYPE STPO-MENGE,  " Quantity
        meins   TYPE STPO-MEINS,  " Unit of Measure
        potx1   TYPE STPO-POTX1,  " Text description for BOM
      END OF ty_bom_sapfmt.
    BEGIN OF ty_bomlist,
       matnr      LIKE mast-matnr,  " Material #
       stlnr      LIKE mast-stlnr,  " BOM #
       posnr      LIKE stpo-posnr,  " BOM item#
       idnrk      LIKE stpo-idnrk,  " BOM material #
       menge      LIKE stpo-menge,  " BOM material qty
       meins      LIKE stpo-meins,  " BOM material uom
    END OF ty_bomlist,
    it_ty_bomlist TYPE ty_bomlist OCCURS 0.
    *Ending block of changes for JPC20061107
    Selection screen definition
    SELECTION-SCREEN: BEGIN OF BLOCK gen WITH FRAME TITLE text-001.
    PARAMETERS:
    p_dir like rlgrap-filename obligatory, " extract directory
      p_ccust TYPE c DEFAULT ' ' AS CHECKBOX,   " Check box customers
      p_cmatm TYPE c DEFAULT ' ' AS CHECKBOX,   " Check box Materials
      p_cbom  TYPE c DEFAULT ' ' AS CHECKBOX,   " Check box BOMs
      p_ccst  TYPE c DEFAULT ' ' AS CHECKBOX.   " Check box credit stat
    SELECTION-SCREEN BEGIN OF BLOCK a WITH FRAME TITLE text-006.
    PARAMETERS:
      p_gui RADIOBUTTON GROUP rg1 USER-COMMAND u01,
      p_svr RADIOBUTTON GROUP rg1 DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK a.
    SELECTION-SCREEN: END OF BLOCK gen.
    SELECTION-SCREEN: BEGIN OF BLOCK cust WITH FRAME TITLE text-002.
    PARAMETERS:
      p_dcust LIKE filepath-pathintern DEFAULT 'Z_COMMAND_CUST_EXTRACT',
      p_fcust LIKE rlgrap-filename,
      p_dcomp LIKE knb1-bukrs,
      p_dsale LIKE knvv-vkorg,
      p_dwerk(3) TYPE c.
    SELECTION-SCREEN: END OF BLOCK cust.
    SELECTION-SCREEN: BEGIN OF BLOCK matnr WITH FRAME TITLE text-003.
    PARAMETERS:
      p_dmatm LIKE filepath-pathintern
                   DEFAULT 'Z_COMMAND_MATERIAL_EXTRACT',
      p_fmatm LIKE rlgrap-filename,
      p_fmatp LIKE rlgrap-filename,
      p_dwerks LIKE marc-werks,
      p_dspras LIKE makt-spras,
      p_dbatch(1) TYPE c,
      p_dflag1(1) TYPE c,
      p_dflag2(1) TYPE c,
      p_dflag3(1) TYPE c,
      p_dflag4(1) TYPE c.
    SELECT-OPTIONS:
      s_dextwg FOR mara-extwg.
    SELECTION-SCREEN: END OF BLOCK matnr.
    SELECTION-SCREEN: BEGIN OF BLOCK bom WITH FRAME TITLE text-004.
    PARAMETERS:
      p_dbom LIKE filepath-pathintern DEFAULT 'Z_COMMAND_BOM_EXTRACT',
      p_fbom LIKE rlgrap-filename.
    p_bwerks LIKE mast-werks.          "Made a select-optoin JPC20061107
    SELECT-OPTIONS:
      s_bmatnr FOR MARA-MATNR,                                "JPC20061107
      s_bwerks FOR MAST-WERKS no-extension no intervals,      "JPC20061107
      s_bextwg FOR mara-extwg.
    SELECTION-SCREEN: END OF BLOCK bom.
    SELECTION-SCREEN: BEGIN OF BLOCK ccst WITH FRAME TITLE text-005.
    PARAMETERS:
      p_dccst LIKE filepath-pathintern
                   DEFAULT 'Z_COMMAND_CUST_STAT_EXTRACT',
      p_fccst LIKE rlgrap-filename,
      p_fccst2 LIKE rlgrap-filename,
      p_fccstl LIKE rlgrap-filename.
    SELECTION-SCREEN BEGIN OF BLOCK b WITH FRAME TITLE text-007.
    PARAMETERS: p_csall RADIOBUTTON GROUP gp2.
    PARAMETERS: p_csdlt RADIOBUTTON GROUP gp2 DEFAULT 'X'.
    PARAMETERS: p_append RADIOBUTTON GROUP GP3 DEFAULT 'X', "Append files output to server for cust credit data ?
                p_owrite RADIOBUTTON GROUP GP3.
    SELECTION-SCREEN END OF BLOCK b.
    SELECT-OPTIONS:
      s_kunnr FOR kna1-kunnr.
    SELECTION-SCREEN: END OF BLOCK ccst.
    DATA: clsdir TYPE REF TO cl_gui_frontend_services.
    DATA: strfolder TYPE string.
    DATA: folderln TYPE i.
    DATA: gva_error(1) TYPE c VALUE ' '.
    Initial procedure on START ***************
    INITIALIZATION.
      p_fcust = 'CUST.prn'.
      p_fmatm = 'MATM.prn'.
      p_fmatp = 'MATP.prn'.
      p_fbom  = 'BOM.prn'.
      p_fccst = 'CCSTAT.prn'.
      p_fccst2 = 'CCSTATC.prn'.
      p_fccstl = 'CCSTATL.prn'.
      s_dextwg-option = 'BT'.
      s_dextwg-low = '1'.
      s_dextwg-high = '8'.
      APPEND s_dextwg.
      s_bextwg-option = 'BT'.
      s_bextwg-low = '1'.
      s_bextwg-high = '1'.
      APPEND s_bextwg.
    AT SELECTION-SCREEN.
      IF p_ccust EQ 'X' AND ( p_fcust IS INITIAL OR p_dcust IS INITIAL ).
        MESSAGE s000(zppu)
        WITH 'You must specify the file details for the customer data'.
        gva_error = 'X'.
      ENDIF.
      IF p_cmatm EQ 'X' AND ( p_fmatm IS INITIAL OR
                              p_fmatp IS INITIAL OR
                              p_dmatm IS INITIAL ).
        MESSAGE s001(zppu)
        WITH 'You must specify the file details for the material data'.
        gva_error = 'X'.
      ENDIF.
      IF p_cbom EQ 'X' AND ( p_fbom IS INITIAL OR p_dbom IS INITIAL ).
        MESSAGE s002(zppu)
        WITH 'You must specify the file details for the BOM data'.
        gva_error = 'X'.
      ENDIF.
      IF p_cbom EQ 'X'.
        IF s_bwerks-low is initial.
          MESSAGE s002(zppu)
            WITH 'You must specify a plant to run BOM extract for'.
          gva_error = 'X'.
        ENDIF.
        IF LINES( s_bwerks ) > 1.
          MESSAGE s002(zppu)
            WITH 'You can only specify 1 plant for BOM extract'.
          gva_error = 'X'.
        ENDIF.
      ENDIF.
      IF p_ccst EQ 'X' AND ( p_fccst IS INITIAL OR
                             p_fccst2 IS INITIAL OR
                             p_fccstl IS INITIAL OR
                             p_dccst IS INITIAL ).
        MESSAGE s002(zppu)
        WITH 'You must specify the file details for the customer'
             'status data'.
        gva_error = 'X'.
      ENDIF.
    AT SELECTION-SCREEN OUTPUT.
      PERFORM user_command.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fcust.
      PERFORM get_gui_filename USING p_dcust p_fcust.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatm.
      PERFORM get_gui_filename USING p_dmatm p_fmatm.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fmatp.
      PERFORM get_gui_filename USING p_dmatm p_fmatp.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fbom.
      PERFORM get_gui_filename USING p_dbom p_fbom.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst.
      PERFORM get_gui_filename USING p_dccst p_fccst.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccst2.
      PERFORM get_gui_filename USING p_dccst p_fccst2.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fccstl.
      PERFORM get_gui_filename USING p_dccst p_fccstl.
    END-OF-SELECTION.
    Data selection execution.
      DATA: lwa_kna1 TYPE kna1,
            lwa_knb1 TYPE knb1,
            lwa_knvv TYPE knvv.
      DATA: lwa_marc TYPE marc,
            lwa_mara TYPE marav,
            lwa_makt TYPE makt.
      DATA: lit_marav TYPE marav OCCURS 0.
      DATA: lit_customers TYPE it_ty_customers,
            lwa_customers TYPE ty_customers.
      DATA: lit_custstat  TYPE it_ty_custstat,
            lwa_custstat  TYPE ty_custstat.
      DATA: lit_materialm TYPE it_ty_materialm,
            lwa_materialm TYPE ty_materialm.
      DATA: lit_materialp TYPE it_ty_materialp,
            lwa_materialp TYPE ty_materialp.
    *(del)DATA: lwa_bomlist TYPE ty_bomlist,           "JPC20061107
    *(del)  lit_bomlist TYPE it_ty_bomlist.            "JPC20061107
      DATA: lwa_bom TYPE ty_bom_sapfmt,
            lit_bom TYPE it_ty_bom WITH HEADER LINE.   "JPC20061107
          lit_bom TYPE it_ty_bom.                    "JPC20061107
      DATA: output_file   TYPE string.
      DATA: lock_file     TYPE string.
      DATA: lva_mssage    TYPE string.
      DATA: lva_matnr(18) TYPE n.
      DATA: lva_date      TYPE datum.
      DATA: txtper(3)     TYPE c.
      DATA: custper       TYPE i.
      DATA: custcount     TYPE i.
      DATA: itemnum       TYPE i.
      CHECK gva_error <> 'X'.
      IF p_ccust EQ 'X'. " Do the customer file extract
        PERFORM extract_customer_details.
      ENDIF.
      IF p_cmatm EQ 'X'. " Do the Material file extract
        PERFORM extract_material_details.
      ENDIF.
      IF p_cbom EQ 'X'. " Do the BOM file extract
        PERFORM extract_bom_details.
      ENDIF.
      IF p_ccst EQ 'X'.  " Do the customer credit status file extract
        PERFORM extract_credit_status_details.
      ENDIF.
    *&      Form  extract_customer_details
          text
    -->  p1        text
    <--  p2        text
    FORM extract_customer_details.
      SELECT * FROM knb1
      INTO lwa_knb1
      WHERE bukrs = p_dcomp.
        MOVE-CORRESPONDING lwa_knb1 TO lwa_customers.
        MOVE-CORRESPONDING lwa_knb1 TO lwa_custstat.
        MOVE '#' TO lwa_custstat-company.
        MOVE p_dwerk TO lwa_customers-splant.
    WG1K903075: Start Delete---*
         move: '|' to lwa_customers-div1,
               '|' to lwa_customers-div2,
               '|' to lwa_customers-div3,
               '|' to lwa_customers-div4,
               '|' to lwa_customers-div5,
               '|' to lwa_customers-div6,
               '|' to lwa_customers-div7,
               '|' to lwa_customers-div8,
               '|' to lwa_customers-div9,
               '|' to lwa_customers-div10,
               '|' to lwa_customers-div11.
    WG1K903075: End Delete-----*
    WG1K903075: Start Insert---*
        MOVE: ' ' TO lwa_customers-div1,
              ' ' TO lwa_customers-div2,
              ' ' TO lwa_customers-div3,
              ' ' TO lwa_customers-div4,
              ' ' TO lwa_customers-div5,
              ' ' TO lwa_customers-div6,
              ' ' TO lwa_customers-div7,
              ' ' TO lwa_customers-div8,
              ' ' TO lwa_customers-div9,
              ' ' TO lwa_customers-div10,
              ' ' TO lwa_customers-div11.
    WG1K903075: End Insert-----*
        APPEND lwa_customers TO lit_customers.
        APPEND lwa_custstat TO lit_custstat.
      ENDSELECT.
      DESCRIBE TABLE lit_customers LINES custcount.
      LOOP AT lit_customers INTO lwa_customers.
        txtper = 100 * sy-tabix / custcount.
        custper = txtper.
        SELECT SINGLE * FROM kna1
        INTO lwa_kna1
        WHERE kunnr = lwa_customers-kunnr.
        MOVE-CORRESPONDING lwa_kna1 TO lwa_customers.
        lva_date = lwa_customers-erdat.
        CALL FUNCTION 'CONVERT_DATE_TO_EXTERNAL'
          EXPORTING
            date_internal            = lva_date
          IMPORTING
            date_external            = lwa_customers-erdat
          EXCEPTIONS
            date_internal_is_invalid = 1
            OTHERS                   = 2.
        REPLACE ALL OCCURRENCES OF '.'
        IN lwa_customers-erdat WITH '/'.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = lwa_customers-kunnr
          IMPORTING
            output = lwa_customers-kunnr.
        WRITE: lwa_customers-kunnr RIGHT-JUSTIFIED TO lwa_customers-kunnr.
        MODIFY lit_customers FROM lwa_customers.
    Percentage indicator display
        lva_mssage = 'Extracting customers'.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage = custper
            text       = lva_mssage.
      ENDLOOP.
      IF p_gui IS INITIAL.
        PERFORM get_file_path USING p_dcust p_fcust output_file.
        OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          LOOP AT lit_customers INTO lwa_customers.
            TRANSFER lwa_customers TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
      ELSE.
        MOVE p_fcust TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename = output_file
            filetype = 'ASC'
          TABLES
            data_tab = lit_customers
          EXCEPTIONS
            OTHERS   = 11.
      ENDIF.
      output_file = custcount.
      CONCATENATE
        output_file
        ' Customers extracted'
      INTO
        lva_mssage.
       message lva_mssage type 'I'.
    ENDFORM.                    " extract_customer_details
    *&      Form  extract_material_details
          text
    -->  p1        text
    <--  p2        text
    FORM extract_material_details.
       select maramatnr maramaktx
              maramatkl marcwerks
      SELECT *
      FROM marav AS mara
        INNER JOIN marc AS marc
          ON marc~matnr EQ mara~matnr
      INTO CORRESPONDING FIELDS OF lwa_mara
      WHERE marc~werks = p_dwerks
        AND mara~spras = 'EN'
        AND mara~extwg IN s_dextwg.
        MOVE-CORRESPONDING lwa_mara TO lwa_materialm.
        WRITE: lwa_mara-matnr TO lwa_materialm-matnr.
        MOVE: p_dflag1 TO lwa_materialm-flag1,
              p_dflag2 TO lwa_materialm-flag2,
              p_dflag3 TO lwa_materialm-flag3,
              p_dflag4 TO lwa_materialm-flag4.
        APPEND lwa_materialm TO lit_materialm.
      ENDSELECT.
      DESCRIBE TABLE lit_materialm LINES custcount.
      LOOP AT lit_materialm INTO lwa_materialm.
        txtper = 100 * sy-tabix / custcount.
        custper = txtper.
        CLEAR lwa_materialp.
        CLEAR lwa_mara.
        MOVE: lwa_materialm-matnr TO lwa_materialp-matnr,
              p_dwerks            TO lwa_materialp-werks,
              p_dbatch            TO lwa_materialp-batch.
        APPEND lwa_materialp TO lit_materialp.
        MOVE: lwa_materialm-matnr TO lva_matnr.
        MOVE: lva_matnr TO lwa_mara-matnr.
        SELECT SINGLE maktx FROM makt
        INTO lwa_materialm-maktx2
        WHERE matnr = lwa_mara-matnr
        AND spras = p_dspras.
        IF lwa_materialm-maktx2 IS INITIAL.
          lwa_materialm-maktx2 = lwa_materialm-maktx.
        ENDIF.
        MODIFY lit_materialm FROM lwa_materialm.
    Percentage indicator display
        lva_mssage = 'Extracting materials'.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage = custper
            text       = lva_mssage.
      ENDLOOP.
      IF p_gui IS INITIAL.
        PERFORM get_file_path USING p_dmatm p_fmatm output_file.
        OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          LOOP AT lit_materialm INTO lwa_materialm.
            TRANSFER lwa_materialm TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
      ELSE.
        MOVE p_fmatm TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = output_file
            filetype              = 'ASC'
            write_field_separator = ' '
          TABLES
            data_tab              = lit_materialm
          EXCEPTIONS
            OTHERS                = 11.
      ENDIF.
      IF p_gui IS INITIAL.
        PERFORM get_file_path USING p_dmatm p_fmatp output_file.
        OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          LOOP AT lit_materialp INTO lwa_materialp.
            TRANSFER lwa_materialp TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
      ELSE.
        MOVE p_fmatp TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = output_file
            filetype              = 'ASC'
            write_field_separator = ' '
          TABLES
            data_tab              = lit_materialp
          EXCEPTIONS
            OTHERS                = 11.
      ENDIF.
      REFRESH lit_materialm.
    ENDFORM.                    " extract_material_details
    *&      Form  extract_bom_details
          text
    -->  p1        text
    <--  p2        text
    FORM extract_bom_details.
    Lines below commented out and replaced with SELECT from ABAP Query run from
    transaction ZBOM.  Previously duplicate materials were selected. JPC20061107
    REFRESH lit_materialm.
    SELECT *
    FROM marav AS mara
       INNER JOIN marc AS marc
         ON marcmatnr EQ maramatnr
    INTO CORRESPONDING FIELDS OF lwa_mara
    WHERE marc~werks = p_bwerks
       AND mara~spras = 'EN'
       AND mara~extwg IN s_bextwg.
       APPEND lwa_mara TO lit_marav.
    ENDSELECT.
    DESCRIBE TABLE lit_marav LINES custcount.
    LOOP AT lit_marav INTO lwa_mara.
    Percentage indicator calculation
       txtper = 100 * sy-tabix / custcount.
       custper = txtper.
       SELECT
         mast~matnr
         mast~stlnr
         stpo~posnr
         stpo~idnrk
         stpo~menge
         stpo~meins
       FROM mast AS mast
         LEFT OUTER JOIN stpo AS stpo
           ON stpostlnr EQ maststlnr
    INTO lwa_bomlist
    WHERE mast~matnr = lwa_mara-matnr.
         CLEAR lwa_bom.
         MOVE-CORRESPONDING lwa_bomlist TO lwa_bom.
         WRITE: lwa_bomlist-matnr TO lwa_bom-matnr.
         IF lwa_bomlist-idnrk IS INITIAL.
           WRITE: 'BACKBIN' TO lwa_bom-idnrk.
         ELSE.
           WRITE: lwa_bomlist-idnrk TO lwa_bom-idnrk.
         ENDIF.
         MOVE: lwa_bomlist-posnr TO itemnum.
         WRITE: itemnum TO lwa_bom-posnr RIGHT-JUSTIFIED.
           write: lwa_bomlist-menge
           to lwa_bom-menge
           decimals 2.
         MOVE: p_bwerks TO lwa_bom-werks.
         APPEND lwa_bom TO lit_bom.
       ENDSELECT.
    Percentage indicator display
       lva_mssage = 'Extracting material B.O.Ms'.
       CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
         EXPORTING
           percentage = custper
           text       = lva_mssage.
    ENDLOOP.
      select MASTMATNR MASTWERKS STPOPOSNR STPOIDNRK STPOMENGE STPOMEINS            "JPC20061220
        select MAST~MATNR MAST~WERKS STPO~POSNR STPO~IDNRK STPO~MENGE STPO~MEINS STPO~POTX1 "JPC20061220
          into lwa_bom
          from ( MAST
               inner join STKO
               on  STKO~STLAL = MAST~STLAL
               and STKO~STLNR = MAST~STLNR
               and STKO~WRKAN = MAST~WERKS
               inner join MARA  as MARA_H
               on  MARA_H~MATNR = MAST~MATNR
               left outer join STAS
               on  STAS~STLAL = STKO~STLAL
               and STAS~STLNR = STKO~STLNR
               and STAS~STLTY = STKO~STLTY
               inner join STPO
               on  STPO~STLKN = STAS~STLKN
               and STPO~STLNR = STAS~STLNR
               and STPO~STLTY = STAS~STLTY
             inner join MARA                   JPC20061220
               left outer join MARA             "JPC20061220
               on  MARA~MATNR = STPO~IDNRK )
             where MARA_H~MATNR in s_bmatnr
               and MAST~WERKS   in s_bwerks
               and MARA_H~EXTWG in s_bextwg.
        clear lit_bom.
        WRITE lwa_bom-matnr TO lit_bom-matnr.
        MOVE  lwa_bom-werks TO lit_bom-werks.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
          EXPORTING
            input  = lwa_bom-posnr
          IMPORTING
            output = lit_bom-posnr.
        SHIFT lit_bom-posnr right deleting trailing space.
        IF lwa_bom-idnrk IS INITIAL.
        WRITE 'BACKBIN'     TO lit_bom-idnrk.               JPC20061220
          WRITE lwa_bom-potx1 TO lit_bom-idnrk.              "JPC20061220
        ELSE.
          WRITE lwa_bom-idnrk TO lit_bom-idnrk.
        ENDIF.
        MOVE: lwa_bom-menge TO lit_bom-menge,
              lwa_bom-meins TO lit_bom-meins.
        APPEND lit_bom.
      ENDSELECT.
      SORT lit_bom ascending.
    Ending for lines inserted for change 20061107
      IF p_gui IS INITIAL.  "write to server
        PERFORM get_file_path USING p_dbom p_fbom output_file.
        OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc EQ 0.
          custcount = lines( lit_bom ).
          LOOP AT lit_bom.
            txtper = 100 * sy-tabix / custcount.
            custper = txtper.
            lva_mssage = 'Extracting material B.O.Ms'.
            CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
              EXPORTING percentage = custper
                        text       = lva_mssage.
            TRANSFER lit_bom TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
      ELSE.
        MOVE p_fbom TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename              = output_file
            filetype              = 'ASC'
            write_field_separator = ' '
          TABLES
            data_tab              = lit_bom
          EXCEPTIONS
            OTHERS                = 11.
      ENDIF.
    ENDFORM.                    " extract_bom_details
    *&      Form  get_file_path
          text
         -->P_LOGICAL_PATH_NAME   text
         -->P_FILENAME            text
         -->P_FILENAME_WITH_PATH  text
    FORM get_file_path USING p_logical_path_name p_filename
                             p_filename_with_path.
      DATA: l_opsys TYPE sy-opsys,
            l_blank_filename TYPE c,
            l_filename TYPE string.
      IF p_gui IS INITIAL.
        MOVE 'WN32' TO l_opsys.
      ELSE.
        MOVE 'WN' TO l_opsys.
      ENDIF.
      IF p_filename IS INITIAL.
        MOVE 'XXX' TO l_filename.
        MOVE 'X' TO l_blank_filename.
      ELSE.
        MOVE p_filename TO l_filename.
      ENDIF.
      CALL FUNCTION 'FILE_GET_NAME_USING_PATH'
        EXPORTING
          logical_path               = p_logical_path_name
          operating_system           = l_opsys
          file_name                  = l_filename
        IMPORTING
          file_name_with_path        = p_filename_with_path
        EXCEPTIONS
          path_not_found             = 1
          missing_parameter          = 2
          operating_system_not_found = 3
          file_system_not_found      = 4
          OTHERS                     = 5.
      IF NOT l_blank_filename IS INITIAL.
        REPLACE ALL OCCURRENCES OF 'XXX' IN p_filename_with_path WITH space.
      ENDIF.
    ENDFORM.                    "get_file_path
    *&      Form  value_request_p_fcust
          text
    -->  p1        text
    <--  p2        text
    FORM get_gui_filename USING p_path p_filename.
      DATA: l_fdir TYPE string.
      CHECK NOT p_gui IS INITIAL.
      PERFORM get_file_path USING p_path space
                                  l_fdir.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_path         = l_fdir
          mask             = ',.prn,.prn.'
          title            = 'Select Excel file for download'
        IMPORTING
          filename         = p_filename
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
    ENDFORM.                    " value_request_p_fcust
    *&      Form  extract_credit_status_details
          text
    -->  p1        text
    <--  p2        text
    FORM extract_credit_status_details .
      DATA: lt_credit_stat   TYPE STANDARD TABLE OF zint_credit_stat,
            l_credit_stat    TYPE zint_credit_stat,
            l_current_stat1  TYPE zcrstat1,
            l_current_stat2  TYPE zcrstat2,
            l_current_reason TYPE zreason,
            lt_output_stat   TYPE STANDARD TABLE OF zint_credit_stat,
            l_output_stat    TYPE zint_credit_stat,
            lt_output1       TYPE STANDARD TABLE OF ty_cust_stat_output,
            lt_output2       TYPE STANDARD TABLE OF ty_cust_stat_output,
            l_output         TYPE ty_cust_stat_output.
      SELECT a~mandt a~kunnr a~name1 b~curstat1 b~curstat2 b~curtimestamp
             b~curreason b~prevstat1 b~prevstat2 b~prvtimestamp
             b~prevreason
        INTO TABLE lt_credit_stat
        FROM kna1 AS a
        LEFT OUTER JOIN zint_credit_stat AS b
        ON a~kunnr = b~kunnr
        WHERE a~kunnr IN s_kunnr.
      DESCRIBE TABLE lt_credit_stat LINES custcount.
      LOOP AT lt_credit_stat INTO l_credit_stat.
        txtper = 100 * sy-tabix / custcount.
        custper = txtper.
        PERFORM determine_current_status USING l_credit_stat-kunnr
                                               l_current_stat1
                                               l_current_stat2
                                               l_current_reason.
        IF NOT p_csdlt IS INITIAL.
        Only do delta download
          IF  l_current_stat1 NE l_credit_stat-curstat1 OR
              l_current_stat2 NE l_credit_stat-curstat2.
            PERFORM add_record_to_output TABLES lt_output_stat
                                         USING  l_current_stat1
                                                l_current_stat2
                                                l_current_reason
                                                l_credit_stat.
          ENDIF.
        ELSE.
        Download all records
          PERFORM add_record_to_output TABLES lt_output_stat
                                       USING  l_current_stat1
                                              l_current_stat2
                                              l_current_reason
                                              l_credit_stat.
        ENDIF.
      Percentage indicator display
        lva_mssage = 'Extracting customer status'.
        CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
          EXPORTING
            percentage = custper
            text       = lva_mssage.
      ENDLOOP.
    Create output table
      LOOP AT lt_output_stat INTO l_output_stat.
        CLEAR l_output.
        WRITE l_output_stat-kunnr TO l_output-kunnr.
        SHIFT l_output-kunnr RIGHT DELETING TRAILING space.
        MOVE l_output_stat-curstat1 TO l_output-stat.
        APPEND l_output TO lt_output1.
        MOVE l_output_stat-curstat2 TO l_output-stat.
        APPEND l_output TO lt_output2.
      ENDLOOP.
      SORT lt_output1.
      SORT lt_output2.
      IF p_gui IS INITIAL.
      Lock File
        PERFORM get_file_path USING p_dccst p_fccstl lock_file.
      If the file already exists then abort processing
        OPEN DATASET lock_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 8.
          MESSAGE s002(zppu)
            WITH 'Lock file' lock_file 'already exists on server,'
                 'processing aborted'.
          LEAVE PROGRAM.
        ENDIF.
        OPEN DATASET lock_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
          MESSAGE s002(zppu)
            WITH 'Lock file' lock_file 'cannot be opened on the server,'
                 'processing aborted'.
          LEAVE PROGRAM.
        ENDIF.
      File 1
        PERFORM get_file_path USING p_dccst p_fccst output_file.
    If user requests cust status data to be appended use different OPEN
        IF p_append is initial.
          OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        ELSE.
          OPEN DATASET output_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
        ENDIF.
        IF sy-subrc EQ 0.
          LOOP AT lt_output1 INTO l_output.
            TRANSFER l_output TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
      File 2
        PERFORM get_file_path USING p_dccst p_fccst2 output_file.
    If user requests cust status data to be appended use different OPEN
        IF p_append is initial.
          OPEN DATASET output_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
        ELSE.
          OPEN DATASET output_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT.
        ENDIF.
        IF sy-subrc EQ 0.
          LOOP AT lt_output2 INTO l_output.
            TRANSFER l_output TO output_file.
          ENDLOOP.
          CLOSE DATASET output_file.
        ELSE.
          MESSAGE s002(zppu)
            WITH 'Dataset' output_file 'cannot be opened on the server'.
        ENDIF.
        DELETE DATASET lock_file.
      ELSE.
        MOVE p_fccst TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename = output_file
            filetype = 'ASC'
          TABLES
            data_tab = lt_output1
          EXCEPTIONS
            OTHERS   = 11.
        MOVE p_fccst2 TO output_file.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename = output_file
            filetype = 'ASC'
          TABLES
            data_tab = lt_output2
          EXCEPTIONS
            OTHERS   = 11.
      ENDIF.
      IF NOT p_svr IS INITIAL.
        PERFORM update_status_table TABLES lt_output_stat.
      ENDIF.
      output_file = custcount.
      CONCATENATE
        output_file
        ' Customers extracted'
      INTO
        lva_mssage.
    ENDFORM.                    " extract_credit_status_details
    *&      Form  user_command
          text
    -->  p1        text
    <--  p2        text
    FORM user_command .
      LOOP AT SCREEN.
        IF screen-name EQ 'P_DCUST' OR
           screen-name EQ '%_P_DCUST_%_APP_%-TEXT' OR
           screen-name EQ 'P_DMATM' OR
           screen-name EQ '%_P_DMATM_%_APP_%-TEXT' OR
           screen-name EQ 'P_DBOM' OR
           screen-name EQ '%_P_DBOM_%_APP_%-TEXT' OR
           screen-name EQ 'P_DCCST' OR
           screen-name EQ '%_P_DCCST_%_APP_%-TEXT' OR
           screen-name EQ 'P_FCCSTL' OR
           screen-name EQ '%_P_FCCSTL_%_APP_%-TEXT'.
          IF p_gui IS INITIAL.
            screen-input = 1.
            screen-output = 1.
            screen-invisible = 0.
            screen-active = 1.
          ELSE.
            screen-input = 0.
            screen-output = 0.
            screen-invisible = 1.
            screen-active = 0.
          ENDIF.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " user_command
    *&      Form  determine_current_status
          text
         -->P_L_CREDIT_STAT_KUNNR  text
         -->P_L_CURRENT_STAT1  text
         -->P_L_CURRENT_STAT2  text
    FORM determine_current_status USING p_kunnr p_stat1 p_stat2 p_reason.
      STATICS: lt_kna1 TYPE STANDARD TABLE OF ty_kna1_fields,
               lt_knb1 TYPE STANDARD TABLE OF ty_knb1_fields,
               lt_knvv TYPE STANDARD TABLE OF ty_knvv_fields,
               lt_knkk TYPE STANDARD TABLE OF ty_knkk_fields.
      DATA: l_kna1  TYPE ty_kna1_fields,
            l_knb1  TYPE ty_knb1_fields,
            l_knvv  TYPE ty_knvv_fields,
            l_knkk  TYPE ty_knkk_fields,
            l_faedt TYPE rfpos-faedt,
            l_days  TYPE p,
            l_used  TYPE rf02l-klprz.
      IF lt_kna1[] IS INITIAL.
        PERFORM load_kna1 TABLES lt_kna1.
      ENDIF.
      IF lt_knb1[] IS INITIAL.
        PERFORM load_knb1 TABLES lt_knb1.
      ENDIF.
      IF lt_knvv[] IS INITIAL.
        PERFORM load_knvv TABLES lt_knvv.
      ENDIF.
      IF lt_knkk[] IS INITIAL.
        PERFORM load_knkk TABLES lt_knkk.
      ENDIF.
      MOVE gc_status-acc TO p_stat1.
      MOVE gc_status-ok  TO p_stat2.
      MOVE gc_reason-000 TO p_reason.
    Customer Block/Unblock
      READ TABLE lt_kna1 INTO l_kna1 WITH KEY kunnr = p_kunnr BINARY SEARCH.
      IF sy-subrc EQ 0.
        IF NOT l_kna1-sperr IS INITIAL.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-001  TO p_reason.
        ENDIF.
        IF l_kna1-aufsd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-002  TO p_reason.
        ENDIF.
        IF l_kna1-lifsd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-003  TO p_reason.
        ENDIF.
        IF l_kna1-faksd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-004  TO p_reason.
        ENDIF.
        IF NOT l_kna1-loevm IS INITIAL.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-999  TO p_reason.
        ENDIF.
      ENDIF.
      CHECK p_stat1 NE gc_status-sto.
      LOOP AT lt_knb1 INTO l_knb1 WHERE kunnr EQ p_kunnr.
        IF NOT l_kna1-sperr IS INITIAL.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-005  TO p_reason.
        ENDIF.
        IF NOT l_knb1-loevm IS INITIAL.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-999  TO p_reason.
        ENDIF.
        IF p_stat1 EQ gc_status-sto.
          EXIT.
        ENDIF.
      ENDLOOP.
      CHECK p_stat1 NE gc_status-sto.
      LOOP AT lt_knvv INTO l_knvv WHERE kunnr EQ p_kunnr.
        IF l_knvv-aufsd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-006  TO p_reason.
        ENDIF.
        IF l_knvv-lifsd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-007  TO p_reason.
        ENDIF.
        IF l_knvv-faksd EQ '01'.
          MOVE gc_status-sto  TO p_stat1.
          MOVE gc_status-hold TO p_stat2.
          MOVE gc_reason-008  TO p_reason.
        ENDIF.
        IF p_stat1 EQ gc_status-sto.
          EXIT.
        ENDIF.
      ENDLOOP.
      CHECK p_stat1 NE gc_status-sto.
      READ TABLE lt_knkk INTO l_knkk WITH KEY kunnr = p_kunnr
                                              kkber = 'BP01'
                                     BINARY SEARCH.
      IF sy-subrc EQ 0.
      Exceeded Trading Terms
        IF l_knkk-ctlpc EQ 'Z03' OR
           l_knkk-ctlpc EQ 'Z04' OR
           l_knkk-ctlpc EQ 'Z05'.
          CALL FUNCTION 'CUSTOMER_OLDEST_OPEN_ITEM'
            EXPORTING
              i_kkber      = l_knkk-kkber
              i_kunnr      = l_knkk-kunnr
            IMPORTING
              e_faedt      = l_faedt
            EXCEPTIONS
              invalid_call = 1
              no_bukrs     = 2
              no_items     = 3
              OTHERS       = 4.
          IF sy-subrc EQ 0.
            l_days = sy-datum - l_faedt.
          ELSE.
            l_days = 0.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z03' AND l_knkk-crblb IS INITIAL AND
             l_days GT 45.
            MOVE gc_status-hol  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-021  TO p_reason.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z04' AND l_knkk-crblb IS INITIAL AND
             l_days GT 40.
            MOVE gc_status-hol  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-022  TO p_reason.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z05' AND l_knkk-crblb IS INITIAL AND
             l_days GT 30.
            MOVE gc_status-hol  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-023  TO p_reason.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z03' AND NOT l_knkk-crblb IS INITIAL AND
             l_days GT 45.
            MOVE gc_status-sto  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-024  TO p_reason.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z04' AND NOT l_knkk-crblb IS INITIAL AND
             l_days GT 40.
            MOVE gc_status-sto  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-025  TO p_reason.
          ENDIF.
          IF l_knkk-ctlpc EQ 'Z05' AND NOT l_knkk-crblb IS INITIAL AND
             l_days GT 30.
            MOVE gc_status-sto  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-026  TO p_reason.
          ENDIF.
          CHECK p_stat1 NE gc_status-sto.
      Exceeded Credit Limit Checks
          PERFORM get_credit_exposure USING l_knkk-knkli l_knkk-kkber
                                            l_knkk-ctlpc l_knkk-klimk
                                            l_knkk-skfor l_knkk-ssobl
                                            l_used.
          IF l_used GE 95 AND l_knkk-crblb IS INITIAL.
            MOVE gc_status-hol  TO p_stat1.
            MOVE gc_status-hold TO p_stat2.
            MOVE gc_reason-010  TO p_reason.
          ENDIF.
          IF l_used GE 95 AND NOT l_knkk-crblb IS INITIAL.
            MOVE gc_status-

    Yes thread closed
    Prioz

  • Cost component not splitting at the time of Rune the tine of Cost Estimate

    http//
    Hi,
    We are in developing phase for Product costing for coal mine project ,
    we have raise coal material with Non component BOM , and Routing is only one activity with 400- Raised Coal Qty-MT ,
    We upload the plan with Production cost center -activity type and cost element ( as per cost component -we have 10 cost component  as per below )
    RM - Blasting
    Production Overhead
    Power - Main
    Stores,Spare,Consum
    Repairs & Maint
    Lease & Hire Char-PM
    Power - Auxiliary
    Depreciation
    Over Burden
    Development
    we done the plan for Amount and Qty by KP06,KP26  and update plan price but system not calculate the cost component splitting in cost estimate as per planning while only one item showing for all cost to Production Overhead cost component
    Production Overhead cost component which assign the secondary cost element which is assign to activity type 400
    can any one help me to how we can resolve this issue
    Please find attached document

    Hi,
    Here I am providing the necessity and importance of splitting structure, will share the configuration steps once you go through the following and get the comfort level.
                        Expense Analysis and Splitting in Manufacturing Cost Centers
    Introduction In SAP Cost center work as a cost responsibility center, where all the expenses and cost are stored and analyzed for the purpose of management decision making.
    The cost could be fixed or variable in nature. The difference between variable and fixed costs can be made in various ways in product costing in CO module.
    Fixed costs represent the static costs incurred by the organization, which doesn’t change on the basis on manufacturing activities, which remain constant irrespective of production activities like rent for the premises, salaries of office staff etc.
    On the other hand, variable cost varies based on the level of production activities; if production activities increase then variable cost also increased like electricity consumes raw material charges etc.
    However all the variable cost doesn’t vary in direct proportion by quantity of goods produced.
    In this document will try to define; how the Expenses analysis and splitting of cost done in manufacturing cost centers.
    From controlling prospective, fixed cost remain constant regardless of operating activities, but if these factor changes, variable cost will fluctuate.
    Basically raw material costs represent variable cost, but in this document main focused will be given to distinguish fixed and variable activity cost.
    The segregation between fixed and variable cost is optional and is derived from the configuration and master data configured in cost center accounting and overhead accounting.
    Activity Price:
    There are different methods that could be used in cost center accounting to determine the activity price. The simple way is the manually enter “Fixed” and “Variable” Activity cost (KP26).
    However there are other methods used in Cost center Planning and Budgeting that automatically calculate the fixed and variable activity price.
    Here the focused will be given on Planning and Budgeting activity and automatic calculation of plan activity rate in cost center.
    This method aggregate planned costs by cost element and capacity by plan unit to calculate the activity price.
    Activity independent costs are segregated among different activities based on Splitting Structure, while activity dependent cost directly used for the purpose of variable activity rate calculation.   
    Fixed Activity Cost:
    In product costing all those cost, which doesn’t vary based on the activities in manufacturing cost will represent fixed cost.
    In a manufacturing cost centers there may be two or more activities performed.
    To calculate the activities rate, the fixed costs are distributed to various activities on the basis of Splitting Structure defined for cost center.  
    Variable Activity Cost:
    Variable activity cost, which directly depend upon the activity type and fluctuate based on increase or decrease in manufacturing activities. In SAP variable activity cost are directly linked to the respective activity.
    Activity Prices: Fixed and Variable Split
    In Cost Center Accounting dividing the cost between Fixed and Variable requires appropriate split to be made in the cost entered for the activity. The process is described below:
    i.  Variable cost would be planned at activity level and expenses should be maintained at cost element in the manufacturing cost center by assigning activity and cost element combination.
    In other word, the expenses should be planned on Activity type at the time of primary cost planning (KP06).
    Then the variable activity rates are calculated on Total cost planned at Activity divided by Total number of activity planned at that cost center (i.e. capacity in KP26)
    ii. Fixed cost would be planned at independent of activity type. These costs are maintained in KP06 at cost element level on manufacturing cost center.
    Then the fixed costs are distributed on various activity types on the basis of Splitting structure defined at OKEW.
    In Splitting Structure we define the rules, how the fixed cost will be distributed to Activities. For the purpose of this document, considering split of fixed cost on the basis of Capacity maintained in KP26.
    Regards,
    Pavan kumar Arvapally

  • Report for Material Cost Estimate

    Hi Everyone,
    Is there any way that I could download a report from the SAP showing all the material cost estimates? Hope someone could help me. When I try using CK11n, there is no tab there for report downloads and it only shows one material.
    Thank you in advance
    Jahziel

    Dear Jahziel,
    In standard SAP the following reports are available:
    T Code : CK84_99 : COST_ELEMENT - Cost Elements
                 CK80_99 - Cost Components
                 CK84_99 - Itemization
    These reports will provide you the information at individual material level.
    Regards,
    Pavan Kumar Arvapally

  • User Exit or BADI on saving of Sales order cost estimate (CK51N)

    Hi,
    Can any one share with me what are the User Exit or BADI that gets triggered on saving of Sales order cost estimate (CK51N).
    Regards,
    Bijay

    Hi
    Check the link
    Need Enhancement Spot or BADI for transaction ck51n
    Regards
    Sanil

  • Sales Order Cost Estimates -- Versions?

    In our MTS plant we are creating cost estimates each month with different version numbers so they can easily be compared to review cost changes.
    This concept in our MTO plant is (of course) a problem.
    We would like to create a dummy sales order and on each line list a KMAT and build an "average" configuration.  We use variant config, so the sales order bom is built automatically.  It also costs automatically.  We would like to save this cost estimate and compare it with a cost estimate of the same configuration next month.   I do not have an option for version CK51n, nor do I see a Costing Date in KEKO table.  Either of these items for MTS would create a second cost estimat and allow comparison.
    Is there a way to compare Sale Order Cost Estimates across periods?
    Any other suggestions as to how to obtain the required data??
    Thank you for all suggestions!!

    Any one think of a solution?
    thanks

Maybe you are looking for