Skip to Content
0

Retrieve Planned Cost in Maintenance order

Feb 08, 2017 at 02:27 PM

310

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

6 Answers

Peter Atkin Feb 08, 2017 at 04:34 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Peter Atkin Feb 09, 2017 at 08:37 AM
0

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello Peter,

Thanks for replying.

I tried forcing the determine cost functionality using the external subroutine as suggested by you.

It does helps me in populating the updated cost information, but the transaction ends in an error after the enhancement is executed.

Here is the message I see:-

"Scheduling not yet carried out - update not possible", and then "Save rejected by system"

After this the saving is aborted and the transaction is terminated, and control comes back to SAP initial screen.

Can you please suggest on the same.

Regards,

Tarun Gambhir

0
Former Member

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

0
Peter Atkin Feb 10, 2017 at 08:39 AM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0
Peter Atkin Feb 15, 2017 at 01:54 PM
0

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

Also try moving the development to BADI WORKORDER_UPDATE.

PeteA

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello @peter.atkin,

We are not using any custom code for creation of the WO.

We have a setup a Maintenance Plan and this plan is dispatching WO in background in REL Status. And we are expecting the SAVE enhancement to be triggered, but I think this enhancement is not working.

Which is why we are looking for an alternate enhancement point.

Thanks,

Tarun

0
Former Member

Hello @peter.atkin,

There are no methods in this BADI which are exporting or changing in behavior. So any suggestions which method should I code in?

Regards,

Tarun

0
Peter Atkin Feb 17, 2017 at 07:28 AM
0

Tarun,

Ensure user-exit IWO10009 is activated in transaction CMOD.

PeteA

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hello @peter.atkin,

Yes its activated and is working when I am creating/changing a work order in IW31/32.

0
Peter Atkin Feb 17, 2017 at 04:27 PM
0

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

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

0