In Oracle EBS Asset Management, Work Order is the foundation for all maintenance organizations. Work orders define the resources and items that are needed to conduct work. Enterprise Asset Management Work Orders are created for assets and rebuildable inventory items. They are defined manually, or generated automatically based on a scheduled Activity. Sometimes we want to create follow-up work orders based on the data entered on the work order or from other applications. We can use APIs provided by Oracle to create these follow-up work order. You can manually create the follow-up work order on the Work Order’s tab of the Asset Management application as show in the user’s guide screen.
To create these Follow-up Work Orders using the API, you need to make sure that you have relation attributes set properly to establish the relation setup correctly between the parent and child Work Orders.
Here are the few details about the API and how to use this API.
- The EBS API, we use for this is EAM_PROCESS_WO_PUB
- The procedure is PROCESS_MASTER_CHILD_WO
- You need to make sure initialize user for a database session using the FND_GLOBAL.APPS_INITIALIZE procedure before invoking the EAM API.
Fnd_global.apps_initialize(user_id => p_user_id, resp_id => p_resp_id, resp_appl_id => p_appl_id)
- The tricky part is setting the relation attributes properly as described below:
- Set PARENT_RELATION_TYPE of relation record as desired (4 for Follow-up)
l_EAM_WO_RELATIONS_REC.PARENT_RELATIONSHIP_TYPE := 4;
- Set the Header Id of Work Order record and Parent Header Id of relation record different numbers. You can set Parent Header Id as WIP_ENTITY_ID of the parent work order and +1 to the new Work Order record
l_EAM_WO_REC.HEADER_ID := p_PARENT_WIP_ENTITY_ID + 1; l_EAM_WO_RELATIONS_REC.PARENT_HEADER_ID := p_PARENT_WIP_ENTITY_ID;
- Set same Header value for Work Order record and CHILD_HEADER_ID of relations record
l_EAM_WO_REC.HEADER_ID := p_PARENT_WIP_ENTITY_ID + 1; l_EAM_WO_RELATIONS_REC.CHILD_HEADER_ID := l_EAM_WO_REC.HEADER_ID;
- Set PARENT_OBJECT_ID of relation record to parent WO WIP_ENTITY_ID
l_EAM_WO_RELATIONS_REC. PARENT_OBJECT_ID := p_PARENT_WIP_ENTITY_ID;
- Set the TRANSA CTION_TYPE for both WO record and relations record to 1 (create new)
l_EAM_WO_RELATIONS_REC.TRANSACTION_TYPE := 1; l_EAM_WO_REC.TRANSACTION_TYPE := 1;
- set OBJECT_TYPE for both WO record and relations record to 1
l_EAM_WO_RELATIONS_REC. OBJECT_TYPE := 1; l_EAM_WO_REC. OBJECT_TYPE := 1;
- Invoke the PROCESS_MASTER_CHILD_WO API
EAM_PROCESS_WO_PUB.PROCESS_MASTER_CHILD_WO ( P_BO_IDENTIFIED => ‘EAM’, P_API_VERSION_NUMBER => 1.0, P_INIT_MST_LIST => TRUE, P_EAM_WO_RELATIONS_TBL => l_EAM_WO_RELATIONS_TBL P_EAM_WO_TBL => l_EAM_WO_TBL, ... ... );
That’s it. If you get these correct, the relationship would be established properly. Below are the queries to verify the relations. You need to make sure both the queries return results and relationships query shows correct details.
SELECT * FROM APPS.EAM_WO_RELATIONSHIPS WHERE PARENT_OBJECT_ID = :p_PARENT_WIP_ENTITY_ID SELECT PARENT_WIP_ENTITY_ID from APPS.EAM_WORK_ORDERS_V where WIP_ENTITY_ID= :p_CHILD__WIP_ENTITY_ID;