El API EAM_PROCESS_WO_PUB.PROCESS_WO es un procedimiento para actualizar un pedido de trabajo del modulo de EAM. Usando esta API podemos cambiar el estado de un Pedido de trabajo de estado Provisorio a Cancelado o de Finalizado a Finalizar - Sin Cargos.
A continuación dejo el siguiente script para poder actualziar un Pedido de Trabajo de Finalizado a Finalizar - Sin Cargos.
DECLARE
G_EAM_WO_RELATIONS_TBL0
EAM_PROCESS_WO_PUB.EAM_WO_RELATIONS_TBL_TYPE;
G_EAM_WO_RELATIONS_REC
EAM_PROCESS_WO_PUB.EAM_WO_RELATIONS_REC_TYPE;
G_EAM_OP_REC0
EAM_PROCESS_WO_PUB.EAM_OP_REC_TYPE;
G_EAM_OP_REC1
EAM_PROCESS_WO_PUB.EAM_OP_REC_TYPE;
G_EAM_OP_NETWORK_REC0
EAM_PROCESS_WO_PUB.EAM_OP_NETWORK_REC_TYPE;
G_EAM_OP_NETWORK_REC1
EAM_PROCESS_WO_PUB.EAM_OP_NETWORK_REC_TYPE;
G_EAM_MAT_REQ_REC0 EAM_PROCESS_WO_PUB.EAM_MAT_REQ_REC_TYPE;
G_EAM_MAT_REQ_REC1
EAM_PROCESS_WO_PUB.EAM_MAT_REQ_REC_TYPE;
G_EAM_DI_REC0
EAM_PROCESS_WO_PUB.EAM_DIRECT_ITEMS_REC_TYPE;
G_EAM_DI_REC1
EAM_PROCESS_WO_PUB.EAM_DIRECT_ITEMS_REC_TYPE;
G_EAM_RES_REC0
EAM_PROCESS_WO_PUB.EAM_RES_REC_TYPE;
G_EAM_RES_REC1
EAM_PROCESS_WO_PUB.EAM_RES_REC_TYPE;
G_EAM_RES_INST_REC0
EAM_PROCESS_WO_PUB.EAM_RES_INST_REC_TYPE;
G_EAM_RES_INST_REC1 EAM_PROCESS_WO_PUB.EAM_RES_INST_REC_TYPE;
G_EAM_OP_TBL0
EAM_PROCESS_WO_PUB.EAM_OP_TBL_TYPE;
G_EAM_OP_TBL1
EAM_PROCESS_WO_PUB.EAM_OP_TBL_TYPE;
G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M_PROCESS_WO_PUB.EAM_WO_REC_TYPE;
G_EAM_WO_REC2 EAM_PROCESS_WO_PUB.EAM_WO_REC_TYPE;
G_EAM_WO_TBL0
EAM_PROCESS_WO_PUB.EAM_WO_TBL_TYPE;
G_EAM_WO_RES_USG_TBL0
EAM_PROCESS_WO_PUB.EAM_RES_USAGE_TBL_TYPE;
L_RETURN_STATUS VARCHAR2(1);
L_MSG_COUNT NUMBER;
G_EAM_WO_USG_REC1
EAM_PROCESS_WO_PUB.EAM_RES_USAGE_REC_TYPE;
G_EAM_WO_USG_REC2
EAM_PROCESS_WO_PUB.EAM_RES_USAGE_REC_TYPE;
MSG_INDEX
NUMBER;
TEMP_ERR_MESG VARCHAR2(2000);
P_WIP_ENTITY_ID WIP_DISCRETE_JOBS.WIP_ENTITY_ID%TYPE;
P_ORGANIZATION_ID
WIP_DISCRETE_JOBS.ORGANIZATION_ID%TYPE;
CURSOR C1 IS
SELECT WIP_ENTITY_ID, ORGANIZATION_ID FROM WIP_DISCRETE_JOBS WHERE
wip_entity_Id = (select WIP_ENTITY_ID from eam_work_orders_v
where wip_entity_Name='&WORKORDER');
---STATUS_TYPE
=4
BEGIN
G_EAM_WO_REC1 := NULL;
G_EAM_WO_REC1.TRANSACTION_TYPE :=
EAM_PROCESS_WO_PVT.G_OPR_UPDATE;
G_EAM_WO_REC1.BATCH_ID := 2;
G_EAM_WO_REC1.HEADER_ID := 2;
G_EAM_WO_REC1.DESCRIPTION := 'API Cambia Estado Pedido de Trabajo';
G_EAM_WO_REC1.STATUS_TYPE := WIP_CONSTANTS.COMP_NOCHRG;---cambia estados
/*Estados a tener en cuenta.
UNRELEASED CONSTANT NUMBER := 1; -- Unreleased - no charges allowed
SIMULATED
CONSTANT NUMBER := 2; --
Simulated
RELEASED
CONSTANT NUMBER := 3; -- Released
- charges allowed
COMP_CHRG
CONSTANT NUMBER := 4; -- Complete
- charges allowed
COMP_NOCHRG CONSTANT NUMBER := 5; -- Complete - no charges allowed
HOLD
CONSTANT NUMBER := 6; -- Hold -
no charges allowed
CANCELLED
CONSTANT NUMBER := 7; --
Cancelled - no charges allowed
PEND_BOM
CONSTANT NUMBER := 8; -- Pending
bill of material load
FAIL_BOM
CONSTANT NUMBER := 9; -- Failed
bill of material load
PEND_ROUT
CONSTANT NUMBER := 10; -- Pending routing load
FAIL_ROUT
CONSTANT NUMBER := 11; -- Failed routing load
PEND_REPML
CONSTANT NUMBER := 13; -- Pending - repetitively mass loaded
PEND_CLOSE
CONSTANT NUMBER := 14; -- Pending Close
FAIL_CLOSE
CONSTANT NUMBER := 15; -- Failed Close
PEND_SCHED
CONSTANT NUMBER := 16; -- Pending Scheduling
DRAFT
CONSTANT NUMBER := 17; -- Draft */
G_EAM_WO_TBL0(1) := G_EAM_WO_REC1;
OPEN C1;
LOOP
FETCH C1
INTO P_WIP_ENTITY_ID, P_ORGANIZATION_ID;
EXIT WHEN C1%NOTFOUND;
G_EAM_WO_REC1.WIP_ENTITY_ID := P_WIP_ENTITY_ID;
G_EAM_WO_REC1.ORGANIZATION_ID :=
P_ORGANIZATION_ID;
DBMS_OUTPUT.PUT_LINE('Cambiar estado para WIP_ENTITY_ID: ' ||
P_WIP_ENTITY_ID);
EAM_PROCESS_WO_PUB.PROCESS_WO(P_BO_IDENTIFIER => 'EAM',
P_API_VERSION_NUMBER => 1.0,
P_INIT_MSG_LIST => TRUE,
P_COMMIT => 'Y',
P_EAM_WO_REC =>
G_EAM_WO_REC1,
P_EAM_OP_TBL =>
G_EAM_OP_TBL0,
P_EAM_OP_NETWORK_TBL =>
G_EAM_OP_NETWORK_TBL0,
P_EAM_RES_TBL => G_EAM_RES_TBL0,
P_EAM_RES_INST_TBL =>
G_EAM_RES_INST_TBL0,
P_EAM_SUB_RES_TBL =>
G_EAM_SUB_RES_TBL0,
P_EAM_RES_USAGE_TBL => G_EAM_RES_USAGE_TBL0,
P_EAM_MAT_REQ_TBL =>
G_EAM_MAT_REQ_TBL0,
P_EAM_DIRECT_ITEMS_TBL => G_EAM_DI_TBL0,
X_EAM_WO_REC =>
G_EAM_WO_REC2,
X_EAM_OP_TBL =>
G_OUT_EAM_OP_TBL,
X_EAM_OP_NETWORK_TBL =>
G_OUT_EAM_OP_NETWORK_TBL,
X_EAM_RES_TBL => G_OUT_EAM_RES_TBL,
X_EAM_RES_INST_TBL =>
G_OUT_EAM_RES_INST_TBL,
X_EAM_SUB_RES_TBL =>
G_OUT_EAM_SUB_RES_TBL,
X_EAM_RES_USAGE_TBL => G_EAM_RES_USAGE_TBL0,
X_EAM_MAT_REQ_TBL =>
G_OUT_EAM_MAT_REQ_TBL,
X_EAM_DIRECT_ITEMS_TBL => G_OUT_EAM_DI_TBL,
X_RETURN_STATUS => L_RETURN_STATUS,
X_MSG_COUNT =>
L_MSG_COUNT
-- , P_DEBUG => 'Y'
-- , P_OUTPUT_DIR => '/SQLCOM/LOG/LV115DYP'
-- ,
P_DEBUG_FILENAME => 'DIV_EAMBO22.LOG'
-- , P_DEBUG_FILE_MODE => 'W'
);
DBMS_OUTPUT.PUT_LINE('Finalizado WIP_ENTITY_ID: ' || P_WIP_ENTITY_ID);
DBMS_OUTPUT.PUT_LINE('Status : '||L_RETURN_STATUS);
IF L_MSG_COUNT > 0 then
DBMS_OUTPUT.PUT_LINE('Error Ocurrido : '||SQLERRM||' : '||SQLCODE);
END IF;
END LOOP;
CLOSE C1;
END;