SAP Note 2897493 Example Implementation - Lean Services

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

CUSTOMER

1 October 2021

Implementing Lean Service Procurement for


Maintenance Orders
This document is a supplement to SAP Note 2897493 and provides consulting on how customers can
implement lean service procurement in maintenance orders in SAP S/4HANA on-premise editions which do
not support this functionality. The reader should have advanced SAP NetWeaver knowledge with regards to
ABAP OO development, extensibility, and the involved SAP ERP modules. Information is provided as-is and
to the best of our knowledge at time of writing. No claims are made to completeness and full functioning of
the features described.
Note that as of SAP S/4HANA 2021, lean service procurement is supported by the standard solution and the
procedure described here will only work if the “Compatibility Mode” is activated in Customizing for Plant
Maintenance and Customer Service under Maintenance and Service Processing → Maintenance and
Service Orders → Functions and Settings for Order Types → Procurement → Activate Enhanced
Procurement Mode.

INITIAL SYSTEM BEHAVIOR


You add a material/product to a Maintenance order which according to its material type is a non-stock
component and will therefore be procured directly. Additionally, the material type indicates that it refers to a
service and the product type group is therefore “2”. Any of the following system behaviors can be observed:
- Message “Lean service procurement is not active in this system” (EAM_SERVPROC/003)
- Message “Select a valid material or service for the product type group.” (APPL_MM_PUR_PO/063)
- Message “Purchase requisition could not be generated for component ...” (IW/196)
- No message is raised initially, but the generated purchase requisition item does not reflect the
correct product type group. When the purchase requisition item is converted to a purchase order,
error message “Product type group of item … deviates from purchase requisition …”
(MMPUR_SPROC/024) occurs.

PROCEDURE

From S/4HANA On-Premise 1909 onwards, SAP blocks the procurement of lean services from a
Maintenance Order. This is to avoid the inconsistent processing of procurement documents and the resulting
extra efforts for purchasing departments. By implementing a Business Add-In (BAdI), you can disable this
blocking.

1. Create an implementation of BADI_EAM_ORD_LEAN_SERVICE.

2. Implement method SKIP_PROCESSING so that it returns abap_true if the blocking of lean service
procurement shall be disabled in Maintenance orders:

METHOD if_badi_eam_ord_lean_service~skip_processing.
result = abap_true.
ENDMETHOD.

With the blocking of lean service procurement disabled, the system will pass components referring to lean
service components to the purchase requisition generation. When a purchase requisition item refers to a
lean service, the system requires additional information which need to be provided in the purchase
requisition item:
- The product type group must be “2” (PRODUCTTYPE)
- Start and end date of the service performance (STARTDATE, ENDDATE)
- Business partner acting as the service performer (SERVICEPERFORMER, optional)

It will be your responsibility to provide the additional aforementioned information into structure EBAN. User
exit COZF0002 can be used for influencing the data which is passed to the purchase requisition.

3. Start transaction SE11 and navigate to structure EBAN_ORD_CUST

4. Choose Go To → Append Structure... to create an append structure in customer namespace.

5. Add the following fields to the append structure:

Field Name Data Type

PRODUCTTYPE PRODUCT_TYPE

SERVICEPERFORMER SERVICEPERFORMER

STARTDATE MMPUR_SERVPROC_PERIOD_START

ENDDATE MMPUR_SERVPROC_PERIOD_END

Note: The system will warn that these fields are not in customer namespace (“Field … does not lie
within customer namespace”). If SAP chooses to add these fields to the same structure in a later
release, a syntax error will occur at time of upgrade and you will have to delete your append
structure. See SAP Note 3048858 for details and restrictions.

6. Activate your changes.

7. Create include ZXCOZU02 in function group XCOZ if it doesn’t exist already. You can do so by right-
clicking on the include in transaction SE80 and choosing “Create”.

8. Implement your custom code in include ZXCOZU02. Your code will be executed whenever the data of
a non-stock order component is transferred to the purchase requisition. This data transfer occurs
when the component is created and whenever it is changed, either by the user or by the system, e.g.
when re-scheduling the Maintenance order. Refer to the documentation of the exit to understand
what data is available to you at runtime. Also keep in mind that this exit is called for other kinds of
orders, e.g. production orders.

The following logic is proposed:


i. Check that the order category is “30” for Maintenance orders, and that the order
component refers to a material.
ii. Check that the material type refers to product type group “2”.
iii. Assign product type group “2”.
iv. Assign the service start date as the requirement date of the component.
v. Assign the service end date as the scheduled end date of the order. If you want to use
operation-level data, e.g. operation scheduled end date, you can call an API, e.g.
BAPI_ALM_OPERATION_GET_DETAIL, to retrieve the operation details.

The listing below shows an example implementation.

IF caufvd_imp-autyp = '30'
AND resbd_imp-matnr IS NOT INITIAL.

" privileged access: authorization was already checked.


SELECT SINGLE \_ProductType-ProductTypeCode
FROM I_Product WITH PRIVILEGED ACCESS
WHERE Product = @resbd_imp-matnr
INTO @DATA(producttypecode).

IF producttypecode = '2'.
eban_ord_cust_chg-producttype = '2'.
eban_ord_cust_chg-startdate = resbd_imp-bdter.
IF caufvd_imp-gltrs IS NOT INITIAL.
eban_ord_cust_chg-enddate = caufvd_imp-gltrs.
ELSE.
" No schedule finish date yet- set same as start date
eban_ord_cust_chg-enddate = eban_ord_cust_chg-startdate.
ENDIF.
ENDIF.
ENDIF.

9. Activate the user exit COZF0002. You do so by adding the exit to an enhancement project in
transaction CMOD and clicking “Activate”.

ADDITIONAL SUGGESTION
Like non-stock components, lean services can also be ordered without a material master being present. In
this case, you cannot derive a product type group. Instead, you could define an item category dedicated to
lean service procurement. Then, whenever you are processing this item category (RESB-POSTP) in above
code extension, populate the PRODUCTTYPE field accordingly.

Copyright/Trademark

You might also like