Skip to Content
avatar image
Former Member

Retrieve Planned Cost in Maintenance order

Hello everyone,

I need to apply a enhancement - copy planned cost to estimated cost while saving a maintenance order .

I know we can use user exit IWO0009 but we haven't achieved the desired results. We are unable to retrieve the planned cost in maintenance order in create mode.

Please provide your valuable answers.

Thanks,

Ashish Singhal

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Feb 08, 2017 at 04:34 PM

    The planned/actual costs can be accessed in IWO10009 by looking at the following data:

    (SAPLICO1)N_PMCO.

    Alternatively, have a look at the function modules in function group ICO1.

    the pseudo code would be:

    if sy-tcode = 'IW31'. 
      if CAUFVD_IMP-IPHAS = 2. "Released     
        Get (SAPLICO1)N_PMCO values      
        Move PMCO value to CAUFVD_IMP-USER4.      
        perform caufv_upd(saplcobh) using lv_caufvd.  "read data back to header  endif.
    endif.


    PeteA

    Add comment
    10|10000 characters needed characters exceeded

    • Hello @peter.atkin,

      Thanks for replying, I am working with Ashish on this enhancement.

      I have checked all internal tables/structures from Function Group ICO1, but none of them seems to be populated with the recent value in IW31/32.

      We need to trigger this enhancement whenever the user is SAVING the WO (before RELEASE is pressed). User needs flexibility to trigger this custom functionality whenever he/she does changes at Operation/Component level, which might change the planned cost.

      Also I noticed that if I navigate to Operation Tab and change the cost for one of the operations and simply press SAVE (without opening the COST tab), none of the ICO1 structures are populated. Which is why we are facing an issue to determine the Planned Cost.

      Kindly suggest.

      Thanks,

      Tarun

  • Feb 09, 2017 at 08:37 AM

    There are two internal tables to checks:

    (SAPLICO1)N_PMCO (new values i.e. any cost updated in the current transaction)
    (SAPLICO1)O_PMCO (old values i.e. previously saved values)

    You may also need to force a recosting of the order using:

    perform fcode_koer_nomsg in program saplcoih using 'X'.

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Peter,

      We were able to achieve the complete requirement. I debugged the code with in the sub-routine:-

      perform fcode_koer_nomsg in program saplcoih using 'X'.

      and then figured out only the required function module which could force the determine cost functionality. Executing these FM's didn't create any issue while saving the WO.

      Below is the completed solution -

      Implement the customer exit IWO10009 (PM Order: Customer Check for 'Save' Event) and write the below code in include ZXWOCU07-

      DATA lw_caufvd TYPE caufvd.
      FIELD-SYMBOLS <lx_trtyp> TYPE any.
      
      lw_caufvd = caufvd_imp.
      
      *populate WO structures
      CALL FUNCTION 'CK_F_ORDER_COSTING'
        EXPORTING
          caufvd_imp      = lw_caufvd
          no_info_message = space
        EXCEPTIONS
          no_costing      = 1.
      
      *get the transaction type (Create/Change)
      ASSIGN ('(SAPLCOIH)TC10-TRTYP') TO <lx_trtyp>.
      CHECK <lx_trtyp> IS ASSIGNED.
      
      *set the planned cost
      CALL FUNCTION 'PM_WORKORDER_PLAN_COSTS_SET'
        EXPORTING
          workorder      = lw_caufvd
          post_indicator = space
          activity       = <lx_trtyp>.
      
      
      *copy the planned cost to estimated cost
      CALL FUNCTION 'PM_WORKORDER_COPY_PLAN_TO_EST'
        EXPORTING
          caufvd_imp        = lw_caufvd
        EXCEPTIONS
          no_plancost       = 1
          no_operation      = 2
          no_estcostversion = 3
          OTHERS            = 4.
      IF sy-subrc = 0.
        MESSAGE 'Success' TYPE 'I'.
      ENDIF.

      Using this code, whenever the save is triggered, the "Determine Cost" + "Copy Planned Cost to Estimated Cost" functionalities are achieved.

      Regards,

      Tarun Gambhir

  • Feb 10, 2017 at 08:39 AM

    Thanks Tarun,

    It looks like these FMs are new to HANA, which is possibly why the "perform" option no longer works..

    Just make sure this works when creating orders in background (e.g. from a maintenance plan or sales order).

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

    • Hello @peter.atkin,

      We are using MSSQL as the DB.

      This enhancement is working properly in IW31/32, but when a Maintenance Plan is creating a WO in background, the copy of planned cost to estimated cost isn't done. It seems like that the enhancement is not being triggered - though I am not very sure.

      The possible reason can be that the functions I have used, aren't working as per required in this background job.

      Any suggestions on the same?

      Regards,

      Tarun

  • Feb 15, 2017 at 01:54 PM

    Are you using a BAPI to create the order, is so, then which one?

    Also try moving the development to BADI WORKORDER_UPDATE.

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 17, 2017 at 07:28 AM

    Tarun,

    Ensure user-exit IWO10009 is activated in transaction CMOD.

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 17, 2017 at 04:27 PM

    I put a breakpoint in include LCOIHF05 (form USER_EXITS_SAVE) and then created an order via IP10 and IP30 and it stops at IWO10009.

    So do you have any enhancements in the IP10/30 process? if so, then deactivate them and retest.

    PeteA

    Add comment
    10|10000 characters needed characters exceeded

    • Hello @peter.atkin,

      I debugged the manual call for creating a work order using t-code IP10. The control stops at the WO save enhancement IWO10009, but unfortunately the code written in the enhancement isn't working. I tried using your method of calling the external sub-routine as well, but that also didn't fulfill the requirement.

      The main issue I noticed in debugging either of the cases is - the internal table O_PMCO[] or N_PMCO[] were not updated with suitable entries. Since neither of these internal tables were updated with data, the planned cost isn't calculated, thus beating our purpose of copy code.

      That's one issue.

      In addition to this, there is a new scenario that has come up -

      When the WO creation call is made from the Maintenance Plan, I need to force the WO to be set to RELEASE status.

      Please note - this should be done without the configuration settings. We will be using a custom table to maintain order types for which the force REL functionality should work.

      Regarding this functionality I got a post on SDN:-

      https://archive.sap.com/discussions/thread/3807627

      Here the resolution is explained with a code snippet, but using this way, I am getting a short dump.

      Exception condition "DUMP_STATUS_INCONSYSTENCY_ERO" triggered

      So concluding on this - I am still struggling to find a way out.

      But my first priority is to achieve the Copy Cost functionality when the WO is saved using Maintenance Plan Call.

      Suggestion please.!!

      Thanks in advance. Appreciate all your help in this context.

      Regards,

      Tarun