During the implementation of SAP-PM years ago, one of the several questions arose in our minds was ‘Why SAP allows Technical Completion, before all Operations attain a CNF status, as whole the Order itself attains a CNF status?’. We began to understand later that this flexibility might have been provided to facilitate several other business requirements. At the same time SAP has provided Enhancements to customize specific business needs of the end-user.
The present subject is a kind of very frequently asked requirement. So it is though a documented reference would be better serving the forum members.
Here it is about how we achieve it.
The user-exit we use for this purpose is: IWO10004 – Maintenance order: Customer check for order completion.
Put the following lines in the include ZXWO1U03 (of Function Exit EXIT_SAPLCOIH_004)
IF caufvd_imp-auart = 'ZM03'. DATA:i_stat LIKE jstat OCCURS 0 WITH HEADER LINE, l_objnr TYPE j_objnr, v_cnf(1). SELECT SINGLE objnr FROM aufk INTO l_objnr WHERE aufnr = caufvd_imp-aufnr. CALL FUNCTION 'STATUS_READ' EXPORTING objnr = l_objnr only_active = 'X' TABLES status = i_stat. LOOP AT i_stat. IF i_stat-stat = 'I0009'. v_cnf = 'X'. ENDIF. ENDLOOP. IF v_cnf <> 'X'. MESSAGE: 'Order can not be completed before reaching CNF status' TYPE 'I'. RAISE completion_rejected. ENDIF. ENDIF.
With this code in the include, whenever user tries to Technically Complete an Order before one or many operations are not confirmed, in other words before the Order itself reaches the CNF status, he will be getting this pop-up.
(You may customize the above message as per your requirement in the line no.18 of the code)
So TECOing of non-CNF order is stopped. Once the Order attains the CNF status, it will be ready for TECO, the user-exit code allows it for TECO.
Observe Line1 of the code, this line confines this restriction to one Order type i.e., ZM03. In case of generalized use remove the Code lines 1 and 21.
In case of specific Order type usage then replace ZOM03 by your Order type.
Hope members will be benefited by this blog too.