39: p_proc_name VARCHAR2,
40: p_return_status OUT NOCOPY VARCHAR2
41: ) IS
42: BEGIN
43: IF (g_logLevel <= wip_constants.trace_logging) THEN
44: wip_logger.entryPoint(p_procName => p_proc_name,
45: p_params => p_params,
46: x_returnStatus => p_return_status);
47:
49: RAISE fnd_api.g_exc_unexpected_error;
50: END IF;
51: END IF;
52:
53: IF (g_logLevel <= wip_constants.trace_logging) then
54: wip_logger.exitPoint(p_procName => p_proc_name,
55: p_procReturnStatus => p_return_status,
56: p_msg => 'procedure success.',
57: x_returnStatus => p_return_Status);
63: l_return_status varchar2(1);
64: BEGIN
65: wip_ws_util.trace_log('Error in ' || p_proc_name);
66: p_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
67: IF (g_logLevel <= wip_constants.trace_logging) then
68: wip_logger.exitPoint(p_procName => p_proc_name,
69: p_procReturnStatus => l_return_status,
70: p_msg => 'unexpected error: ' || SQLERRM,
71: x_returnStatus => l_return_Status);
82: l_params wip_logger.param_tbl_t;
83:
84: BEGIN
85:
86: IF (g_logLevel <= wip_constants.trace_logging) THEN
87:
88: l_params(1).paramName := 'p_execution_date';
89: l_params(1).paramValue := p_execution_date;
90: l_params(2).paramName := 'p_cutoff_date';
157: wop.wip_entity_id,
158: wop.operation_seq_num,
159: NVL(SUM(wmt.primary_quantity *
160: DECODE(SIGN(wmt.to_operation_seq_num -wmt.fm_operation_seq_num),
161: 0,DECODE(SIGN(wmt.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
162: 0,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
163: -1,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
164: 1,-1),
165: 1, 1,
158: wop.operation_seq_num,
159: NVL(SUM(wmt.primary_quantity *
160: DECODE(SIGN(wmt.to_operation_seq_num -wmt.fm_operation_seq_num),
161: 0,DECODE(SIGN(wmt.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
162: 0,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
163: -1,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
164: 1,-1),
165: 1, 1,
166: -1,-1)
159: NVL(SUM(wmt.primary_quantity *
160: DECODE(SIGN(wmt.to_operation_seq_num -wmt.fm_operation_seq_num),
161: 0,DECODE(SIGN(wmt.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
162: 0,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
163: -1,DECODE(SIGN(wmt.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
164: 1,-1),
165: 1, 1,
166: -1,-1)
167: ),0) quantity_compelted
191: wip_operations wop
192: WHERE
193: wop.organization_id = p_org_id
194: AND wop.wip_entity_id = wmt.wip_entity_id
195: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
196: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
197: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
198: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
199: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
192: WHERE
193: wop.organization_id = p_org_id
194: AND wop.wip_entity_id = wmt.wip_entity_id
195: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
196: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
197: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
198: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
199: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
200: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
195: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
196: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
197: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
198: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
199: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
200: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
201: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
202: OR wop.operation_seq_num = wmt.fm_operation_seq_num
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
196: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
197: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
198: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
199: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
200: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
201: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
202: OR wop.operation_seq_num = wmt.fm_operation_seq_num
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
204: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
197: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
198: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
199: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
200: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
201: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
202: OR wop.operation_seq_num = wmt.fm_operation_seq_num
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
204: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
205: OR
200: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
201: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
202: OR wop.operation_seq_num = wmt.fm_operation_seq_num
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
204: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
205: OR
206: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
207: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
202: OR wop.operation_seq_num = wmt.fm_operation_seq_num
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
204: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
205: OR
206: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
207: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
209: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
203: OR (wop.operation_seq_num = wmt.to_operation_seq_num
204: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
205: OR
206: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
207: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
209: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
211: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
206: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
207: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
209: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
211: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
212: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
213: OR (wop.operation_seq_num = wmt.to_operation_seq_num
214: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
207: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
209: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
211: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
212: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
213: OR (wop.operation_seq_num = wmt.to_operation_seq_num
214: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
215: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
208: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
209: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
211: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
212: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
213: OR (wop.operation_seq_num = wmt.to_operation_seq_num
214: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
215: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
216: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
210: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
211: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
212: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
213: OR (wop.operation_seq_num = wmt.to_operation_seq_num
214: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
215: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
216: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
217: GROUP BY wop.department_id, wmt.shift_start_date, wmt.shift_num, wop.wip_entity_id, wop.operation_seq_num
218:
212: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
213: OR (wop.operation_seq_num = wmt.to_operation_seq_num
214: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
215: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
216: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
217: GROUP BY wop.department_id, wmt.shift_start_date, wmt.shift_num, wop.wip_entity_id, wop.operation_seq_num
218:
219: ) completed_info,
220: WIP_DISCRETE_JOBS wdj
277: post_cal.wip_entity_id,
278: post_cal.operation_seq_num,
279: NVL(SUM(post_cal.primary_quantity *
280: DECODE(SIGN(post_cal.to_operation_seq_num -post_cal.fm_operation_seq_num),
281: 0,DECODE(SIGN(post_cal.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
282: 0,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
283: -1,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
284: 1,-1),
285: 1, 1,
278: post_cal.operation_seq_num,
279: NVL(SUM(post_cal.primary_quantity *
280: DECODE(SIGN(post_cal.to_operation_seq_num -post_cal.fm_operation_seq_num),
281: 0,DECODE(SIGN(post_cal.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
282: 0,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
283: -1,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
284: 1,-1),
285: 1, 1,
286: -1,-1)
279: NVL(SUM(post_cal.primary_quantity *
280: DECODE(SIGN(post_cal.to_operation_seq_num -post_cal.fm_operation_seq_num),
281: 0,DECODE(SIGN(post_cal.fm_intraoperation_step_type -WIP_CONSTANTS.RUN),
282: 0,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
283: -1,DECODE(SIGN(post_cal.to_intraoperation_step_type -WIP_CONSTANTS.RUN),1,1,-1),
284: 1,-1),
285: 1, 1,
286: -1,-1)
287: ),0) quantity_compelted
319: wmt.transaction_date >= p_cutoff_date
320: AND wmt.organization_id = p_org_id
321: AND wop.organization_id = p_org_id
322: AND wop.wip_entity_id = wmt.wip_entity_id
323: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
324: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
325: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
326: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
327: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
320: AND wmt.organization_id = p_org_id
321: AND wop.organization_id = p_org_id
322: AND wop.wip_entity_id = wmt.wip_entity_id
323: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
324: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
325: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
326: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
327: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
328: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
323: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
324: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
325: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
326: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
327: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
328: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
329: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
330: OR wop.operation_seq_num = wmt.fm_operation_seq_num
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
324: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
325: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
326: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
327: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
328: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
329: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
330: OR wop.operation_seq_num = wmt.fm_operation_seq_num
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
332: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
325: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
326: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
327: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
328: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
329: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
330: OR wop.operation_seq_num = wmt.fm_operation_seq_num
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
332: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
333: OR
328: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
329: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
330: OR wop.operation_seq_num = wmt.fm_operation_seq_num
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
332: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
333: OR
334: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
335: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
330: OR wop.operation_seq_num = wmt.fm_operation_seq_num
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
332: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
333: OR
334: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
335: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
337: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
331: OR (wop.operation_seq_num = wmt.to_operation_seq_num
332: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
333: OR
334: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
335: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
337: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
339: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
334: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
335: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
337: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
339: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
340: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
341: OR (wop.operation_seq_num = wmt.to_operation_seq_num
342: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
335: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
337: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
339: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
340: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
341: OR (wop.operation_seq_num = wmt.to_operation_seq_num
342: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
343: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
336: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
337: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
339: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
340: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
341: OR (wop.operation_seq_num = wmt.to_operation_seq_num
342: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
343: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
344: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
338: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
339: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
340: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
341: OR (wop.operation_seq_num = wmt.to_operation_seq_num
342: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
343: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
344: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
345: ) pre_cal
346: ) post_cal
340: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
341: OR (wop.operation_seq_num = wmt.to_operation_seq_num
342: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
343: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
344: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
345: ) pre_cal
346: ) post_cal
347: GROUP BY post_cal.department_id, post_cal.shift_start_date, post_cal.shift_num, post_cal.wip_entity_id, post_cal.operation_seq_num
348: ) completed_info,
357: wip_ws_fpy fpy
358: SET
359: QUANTITY_SCRAPPED =
360: nvl((SELECT
361: NVL(SUM(DECODE(wop.operation_seq_num,wmt.to_operation_seq_num,DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.SCRAP, wmt.primary_quantity,0),0)
362: - DECODE(wop.operation_seq_num, wmt.fm_operation_seq_num,DECODE(wmt.fm_intraoperation_step_type,WIP_CONSTANTS.SCRAP,wmt.primary_quantity,0),0)),0) as quantity_scrap
363: FROM
364: (
365: SELECT
358: SET
359: QUANTITY_SCRAPPED =
360: nvl((SELECT
361: NVL(SUM(DECODE(wop.operation_seq_num,wmt.to_operation_seq_num,DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.SCRAP, wmt.primary_quantity,0),0)
362: - DECODE(wop.operation_seq_num, wmt.fm_operation_seq_num,DECODE(wmt.fm_intraoperation_step_type,WIP_CONSTANTS.SCRAP,wmt.primary_quantity,0),0)),0) as quantity_scrap
363: FROM
364: (
365: SELECT
366: (case when (shift_info is not null) then transaction_date+ mod(shift_info,1)*1000 else trunc(transaction_date) end )as shift_start_date,
374: FROM
375: (
376: SELECT
377: wip_ws_embedded_analytics_pk.get_shift_info(wmt.organization_id
378: ,(case when wmt.to_intraoperation_step_type = WIP_CONSTANTS.SCRAP then wmt.to_department_id else wmt.fm_department_id end)
379: ,wmt.transaction_date) as shift_info,
380: transaction_date,
381: wip_entity_id,
382: primary_quantity,
388: wip_move_transactions wmt
389: WHERE
390: transaction_date >= p_cutoff_date
391: AND wmt.organization_id = p_org_id
392: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.SCRAP
393: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.SCRAP)
394: ) wmt_raw_shift_info
395: ) wmt,
396: wip_operations wop
389: WHERE
390: transaction_date >= p_cutoff_date
391: AND wmt.organization_id = p_org_id
392: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.SCRAP
393: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.SCRAP)
394: ) wmt_raw_shift_info
395: ) wmt,
396: wip_operations wop
397:
397:
398: WHERE
399: wop.wip_entity_id = wmt.wip_entity_id
400: AND wop.organization_id = p_org_id
401: AND ((wmt.fm_intraoperation_step_type = WIP_CONSTANTS.SCRAP AND wmt.fm_operation_seq_num = wop.operation_seq_num)
402: OR (wmt.to_intraoperation_step_type = WIP_CONSTANTS.SCRAP AND wmt.to_operation_seq_num = wop.operation_seq_num))
403:
404: AND fpy.wip_entity_id = wop.wip_entity_id
405: AND fpy.operation_seq_num = wop.operation_seq_num
398: WHERE
399: wop.wip_entity_id = wmt.wip_entity_id
400: AND wop.organization_id = p_org_id
401: AND ((wmt.fm_intraoperation_step_type = WIP_CONSTANTS.SCRAP AND wmt.fm_operation_seq_num = wop.operation_seq_num)
402: OR (wmt.to_intraoperation_step_type = WIP_CONSTANTS.SCRAP AND wmt.to_operation_seq_num = wop.operation_seq_num))
403:
404: AND fpy.wip_entity_id = wop.wip_entity_id
405: AND fpy.operation_seq_num = wop.operation_seq_num
406: AND fpy.shift_num = wmt.shift_num
412: wip_ws_util.trace_log('Finish Updating QUANTITY_SCRAPPED');
413:
414: /* This QUERY works too, if the above SQL turn bad in performance try this one
415: SELECT
416: NVL(SUM(DECODE(operation_seq_num,to_operation_seq_num,DECODE(to_intraoperation_step_type,WIP_CONSTANTS.SCRAP, primary_quantity,0),0)
417: - DECODE(operation_seq_num, fm_operation_seq_num,DECODE(fm_intraoperation_step_type,WIP_CONSTANTS.SCRAP,primary_quantity,0),0)),0) as quantity_scrap
418: FROM (
419: SELECT
420: transaction_date,primary_quantity,to_intraoperation_step_type,fm_intraoperation_step_type,fm_operation_seq_num,to_operation_seq_num,
413:
414: /* This QUERY works too, if the above SQL turn bad in performance try this one
415: SELECT
416: NVL(SUM(DECODE(operation_seq_num,to_operation_seq_num,DECODE(to_intraoperation_step_type,WIP_CONSTANTS.SCRAP, primary_quantity,0),0)
417: - DECODE(operation_seq_num, fm_operation_seq_num,DECODE(fm_intraoperation_step_type,WIP_CONSTANTS.SCRAP,primary_quantity,0),0)),0) as quantity_scrap
418: FROM (
419: SELECT
420: transaction_date,primary_quantity,to_intraoperation_step_type,fm_intraoperation_step_type,fm_operation_seq_num,to_operation_seq_num,
421: transaction_date+ mod(shift_info,1)*1000 as shift_start_date,
423: wip_entity_id,operation_seq_num
424: FROM (
425: SELECT
426: wip_ws_embedded_analytics_pk.get_shift_info(wmt.organization_id,(
427: case when (wmt.TO_DEPARTMENT_ID =WIP_CONSTANTS.SCRAP AND wop.operation_seq_num = wmt.fm_operation_seq_num) then wmt.to_department_id else wmt.fm_department_id end),wmt.transaction_date) as shift_info,
428: wop.wip_entity_id, wop.operation_seq_num,
429: wmt.transaction_date,wmt.primary_quantity,wmt.to_intraoperation_step_type,wmt.fm_intraoperation_step_type,fm_operation_seq_num,to_operation_seq_num
430: FROM
431: wip_move_transactions wmt,
454: -- OUT BW = Move backword from REJECT except moving to the 'TOMOVE' within the same opeation
455:
456: nvl((SELECT
457: NVL(SUM(DECODE(wop.operation_seq_num,wmt.to_operation_seq_num,
458: DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.REJECT, wmt.primary_quantity,0),0)
459: ),0)
460: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
461: DECODE(wmt.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
462: DECODE(SIGN(wmt.fm_operation_seq_num-wmt.to_operation_seq_num),
457: NVL(SUM(DECODE(wop.operation_seq_num,wmt.to_operation_seq_num,
458: DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.REJECT, wmt.primary_quantity,0),0)
459: ),0)
460: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
461: DECODE(wmt.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
462: DECODE(SIGN(wmt.fm_operation_seq_num-wmt.to_operation_seq_num),
463: 1,wmt.primary_quantity, -- Out Backward different operation seq
464: 0,DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.TOMOVE,0,wmt.primary_quantity),0) -- Out Backward within same operation seq
465: ),0)
460: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
461: DECODE(wmt.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
462: DECODE(SIGN(wmt.fm_operation_seq_num-wmt.to_operation_seq_num),
463: 1,wmt.primary_quantity, -- Out Backward different operation seq
464: 0,DECODE(wmt.to_intraoperation_step_type,WIP_CONSTANTS.TOMOVE,0,wmt.primary_quantity),0) -- Out Backward within same operation seq
465: ),0)
466: ),0) as quantity_reject
467: FROM
468: (
478: FROM
479: (
480: SELECT
481: wip_ws_embedded_analytics_pk.get_shift_info(wmt.organization_id
482: ,(case when wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT then wmt.to_department_id else wmt.fm_department_id end)
483: ,wmt.transaction_date) as shift_info ,
484: wmt.*
485: FROM
486: wip_move_transactions wmt
486: wip_move_transactions wmt
487: WHERE
488: transaction_date > p_cutoff_date
489: AND wmt.organization_id = p_org_id
490: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
491: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
492: ) wmt_raw_shift_info
493: ) wmt,
494: wip_operations wop
487: WHERE
488: transaction_date > p_cutoff_date
489: AND wmt.organization_id = p_org_id
490: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
491: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
492: ) wmt_raw_shift_info
493: ) wmt,
494: wip_operations wop
495:
495:
496: WHERE
497: wop.wip_entity_id = wmt.wip_entity_id
498: AND wop.organization_id = p_org_id
499: AND ((wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT AND wmt.fm_operation_seq_num = wop.operation_seq_num )
500: OR (wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT AND wmt.to_operation_seq_num = wop.operation_seq_num))
501: AND fpy.wip_entity_id = wop.wip_entity_id
502: AND fpy.operation_seq_num = wop.operation_seq_num
503: AND fpy.shift_num = wmt.shift_num
496: WHERE
497: wop.wip_entity_id = wmt.wip_entity_id
498: AND wop.organization_id = p_org_id
499: AND ((wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT AND wmt.fm_operation_seq_num = wop.operation_seq_num )
500: OR (wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT AND wmt.to_operation_seq_num = wop.operation_seq_num))
501: AND fpy.wip_entity_id = wop.wip_entity_id
502: AND fpy.operation_seq_num = wop.operation_seq_num
503: AND fpy.shift_num = wmt.shift_num
504: AND fpy.shift_date = wmt.shift_start_date
509: /*
510: Wrong SQL
511: nvl((SELECT
512: NVL(SUM(DECODE(wop.operation_seq_num,post_cal.to_operation_seq_num,
513: DECODE(post_cal.to_intraoperation_step_type,WIP_CONSTANTS.REJECT, post_cal.primary_quantity,0),0)
514: ),0)
515: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
516: DECODE(post_cal.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
517: DECODE(SIGN(post_cal.fm_operation_seq_num-post_cal.to_operation_seq_num),
512: NVL(SUM(DECODE(wop.operation_seq_num,post_cal.to_operation_seq_num,
513: DECODE(post_cal.to_intraoperation_step_type,WIP_CONSTANTS.REJECT, post_cal.primary_quantity,0),0)
514: ),0)
515: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
516: DECODE(post_cal.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
517: DECODE(SIGN(post_cal.fm_operation_seq_num-post_cal.to_operation_seq_num),
518: 1,post_cal.primary_quantity, -- Out Backward different operation seq
519: 0,DECODE(post_cal.to_intraoperation_step_type,WIP_CONSTANTS.TOMOVE,0,post_cal.primary_quantity),0) -- Out Backward within same operation seq
520: ),0)
515: - NVL(SUM(DECODE(wop.operation_seq_num,fm_operation_seq_num,
516: DECODE(post_cal.fm_intraoperation_step_type,WIP_CONSTANTS.REJECT,
517: DECODE(SIGN(post_cal.fm_operation_seq_num-post_cal.to_operation_seq_num),
518: 1,post_cal.primary_quantity, -- Out Backward different operation seq
519: 0,DECODE(post_cal.to_intraoperation_step_type,WIP_CONSTANTS.TOMOVE,0,post_cal.primary_quantity),0) -- Out Backward within same operation seq
520: ),0)
521: ),0) as quantity_reject
522:
523: FROM
554: wmt.transaction_date >= p_cutoff_date
555: AND wmt.organization_id = p_org_id
556: AND wop.organization_id = p_org_id
557: AND wop.wip_entity_id = wmt.wip_entity_id
558: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
559: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
560: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
555: AND wmt.organization_id = p_org_id
556: AND wop.organization_id = p_org_id
557: AND wop.wip_entity_id = wmt.wip_entity_id
558: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
559: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
560: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
556: AND wop.organization_id = p_org_id
557: AND wop.wip_entity_id = wmt.wip_entity_id
558: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
559: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
560: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
564: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
557: AND wop.wip_entity_id = wmt.wip_entity_id
558: AND (wmt.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT
559: OR wmt.to_intraoperation_step_type = WIP_CONSTANTS.REJECT)
560: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
564: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
565: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
560: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
564: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
565: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
566: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
567: OR wop.operation_seq_num = wmt.fm_operation_seq_num
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
561: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
564: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
565: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
566: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
567: OR wop.operation_seq_num = wmt.fm_operation_seq_num
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
569: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
562: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
563: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
564: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
565: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
566: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
567: OR wop.operation_seq_num = wmt.fm_operation_seq_num
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
569: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
570: OR
565: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
566: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
567: OR wop.operation_seq_num = wmt.fm_operation_seq_num
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
569: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
570: OR
571: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
572: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
567: OR wop.operation_seq_num = wmt.fm_operation_seq_num
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
569: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
570: OR
571: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
572: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
574: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
568: OR (wop.operation_seq_num = wmt.to_operation_seq_num
569: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
570: OR
571: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
572: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
574: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
576: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
571: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
572: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
574: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
576: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
577: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
578: OR (wop.operation_seq_num = wmt.to_operation_seq_num
579: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
572: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
574: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
576: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
577: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
578: OR (wop.operation_seq_num = wmt.to_operation_seq_num
579: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
580: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
573: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
574: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
576: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
577: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
578: OR (wop.operation_seq_num = wmt.to_operation_seq_num
579: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
580: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
581: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
575: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
576: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
577: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
578: OR (wop.operation_seq_num = wmt.to_operation_seq_num
579: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
580: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
581: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
582: ) pre_cal
583: ) post_cal,
577: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
578: OR (wop.operation_seq_num = wmt.to_operation_seq_num
579: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
580: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
581: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))))
582: ) pre_cal
583: ) post_cal,
584: wip_operations wop
585: WHERE
584: wip_operations wop
585: WHERE
586: wop.wip_entity_id = post_cal.wip_entity_id
587: AND wop.organization_id = p_org_id
588: AND ((post_cal.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT AND post_cal.fm_operation_seq_num = wop.operation_seq_num )
589: OR (post_cal.to_intraoperation_step_type = WIP_CONSTANTS.REJECT AND post_cal.to_operation_seq_num = wop.operation_seq_num))
590:
591: AND fpy.wip_entity_id = wop.wip_entity_id
592: AND fpy.operation_seq_num = wop.operation_seq_num
585: WHERE
586: wop.wip_entity_id = post_cal.wip_entity_id
587: AND wop.organization_id = p_org_id
588: AND ((post_cal.fm_intraoperation_step_type = WIP_CONSTANTS.REJECT AND post_cal.fm_operation_seq_num = wop.operation_seq_num )
589: OR (post_cal.to_intraoperation_step_type = WIP_CONSTANTS.REJECT AND post_cal.to_operation_seq_num = wop.operation_seq_num))
590:
591: AND fpy.wip_entity_id = wop.wip_entity_id
592: AND fpy.operation_seq_num = wop.operation_seq_num
593: AND fpy.shift_num = post_cal.shift_num
609: wip_ws_util.trace_log('Finish Updating QUANTITY_FIRST_PASS');
610: */
611: -------------------------------------- end of population logic -------------------------------------------------------
612:
613: IF (g_logLevel <= wip_constants.trace_logging) then
614: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.populate_fpy_raw_data',
615: p_procReturnStatus => l_return_status,
616: p_msg => 'procedure success.',
617: x_returnStatus => l_return_Status);
620: EXCEPTION
621: WHEN others THEN
622: wip_ws_util.trace_log('Error in populate_fpy_raw_data');
623: x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
624: IF (g_logLevel <= wip_constants.trace_logging) then
625: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.populate_fpy_raw_data',
626: p_procReturnStatus => l_return_status,
627: p_msg => 'unexpected error: ' || SQLERRM,
628: x_returnStatus => l_return_Status);
2277: AND wmt.organization_id = p_org_id
2278: AND wop.organization_id = p_org_id
2279: AND ROWNUM = 1
2280: AND wop.wip_entity_id = wmt.wip_entity_id
2281: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2282: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2283: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
2284: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
2285: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
2278: AND wop.organization_id = p_org_id
2279: AND ROWNUM = 1
2280: AND wop.wip_entity_id = wmt.wip_entity_id
2281: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2282: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2283: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
2284: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
2285: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
2286: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
2281: AND ((wop.operation_seq_num >= wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2282: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2283: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
2284: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
2285: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
2286: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
2287: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2288: OR wop.operation_seq_num = wmt.fm_operation_seq_num
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2282: AND (wop.operation_seq_num < wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2283: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
2284: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
2285: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
2286: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
2287: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2288: OR wop.operation_seq_num = wmt.fm_operation_seq_num
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2290: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
2283: AND (wmt.to_operation_seq_num > wmt.fm_operation_seq_num
2284: OR (wmt.to_operation_seq_num = wmt.fm_operation_seq_num
2285: AND wmt.fm_intraoperation_step_type <= WIP_CONSTANTS.RUN
2286: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
2287: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2288: OR wop.operation_seq_num = wmt.fm_operation_seq_num
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2290: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
2291: OR
2286: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN))
2287: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2288: OR wop.operation_seq_num = wmt.fm_operation_seq_num
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2290: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
2291: OR
2292: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2293: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2288: OR wop.operation_seq_num = wmt.fm_operation_seq_num
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2290: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
2291: OR
2292: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2293: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2295: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2289: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2290: AND wmt.to_intraoperation_step_type > WIP_CONSTANTS.RUN)))
2291: OR
2292: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2293: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2295: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2297: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
2292: (wop.operation_seq_num < wmt.fm_operation_seq_num + DECODE(SIGN(wmt.fm_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0)
2293: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2295: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2297: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
2298: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2299: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2300: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
2293: AND (wop.operation_seq_num >= wmt.to_operation_seq_num + DECODE(SIGN(wmt.to_intraoperation_step_type - WIP_CONSTANTS.RUN),1,1,0))
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2295: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2297: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
2298: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2299: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2300: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
2301: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
2294: AND (wmt.fm_operation_seq_num > wmt.to_operation_seq_num
2295: OR (wmt.fm_operation_seq_num = wmt.to_operation_seq_num
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2297: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
2298: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2299: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2300: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
2301: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
2302: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))));
2296: AND wmt.to_intraoperation_step_type <= WIP_CONSTANTS.RUN
2297: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))
2298: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2299: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2300: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
2301: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
2302: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))));
2303: */
2304:
2298: AND (wop.count_point_type < WIP_CONSTANTS.NO_MANUAL
2299: OR (wop.operation_seq_num = wmt.to_operation_seq_num
2300: AND wop.count_point_type < WIP_CONSTANTS.NO_MANUAL )
2301: OR (wop.operation_seq_num = wmt.fm_operation_seq_num
2302: AND wmt.fm_intraoperation_step_type > WIP_CONSTANTS.RUN))));
2303: */
2304:
2305:
2306:
2485: ELSE
2486: wip_ws_util.trace_log('populate_fpy_raw_data is successfull');
2487: END IF;
2488:
2489: IF (g_logLevel <= wip_constants.trace_logging) then
2490: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.wip_ws_fpykpi_conc_prog',
2491: p_procReturnStatus => l_return_status,
2492: p_msg => 'processed successfully',
2493: x_returnStatus => l_return_status);
2655: BEGIN
2656:
2657: l_concurrent_execution_date := SYSDATE;
2658:
2659: IF (g_logLevel <= wip_constants.trace_logging) THEN
2660:
2661: l_params(1).paramName := 'p_org_id';
2662: l_params(1).paramValue := p_org_id;
2663:
2711: ELSE
2712: wip_ws_util.trace_log('populate_fpy_raw_data is successful');
2713: END IF;
2714:
2715: IF (g_logLevel <= wip_constants.trace_logging) then
2716: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.wip_ws_ppmdkpi_conc_prog',
2717: p_procReturnStatus => l_return_status,
2718: p_msg => 'processed successfully',
2719: x_returnStatus => l_return_status);
2724:
2725: WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2726: wip_ws_util.trace_log('Came to unexpected error in wip_ws_ppmdkpi_conc_prog');
2727:
2728: IF (g_logLevel <= wip_constants.trace_logging) then
2729: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.wip_ws_ppmdkpi_conc_prog',
2730: p_procReturnStatus => 2,
2731: p_msg => 'unexpected error FND_API.G_EXC_UNEXPECTED_ERROR' || SQLERRM,
2732: x_returnStatus => l_return_status);
2735: retcode := 2; -- End with error
2736: WHEN FND_API.G_EXC_ERROR THEN
2737: retcode := 1;
2738: wip_ws_util.trace_log('Came to expected error in wip_ws_ppmdkpi_conc_prog');
2739: IF (g_logLevel <= wip_constants.trace_logging) then
2740: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.wip_ws_ppmdkpi_conc_prog',
2741: p_procReturnStatus => 1,
2742: p_msg => 'unexpected error FND_API.G_EXC_ERROR' || SQLERRM,
2743: x_returnStatus => l_return_status);
2746: ROLLBACK TO wip_ws_ppmdkpi_calc;
2747: WHEN others THEN
2748: wip_ws_util.trace_log('Came to others error in wip_ws_ppmdkpi_conc_prog');
2749:
2750: IF (g_logLevel <= wip_constants.trace_logging) then
2751: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.wip_ws_ppmdkpi_conc_prog',
2752: p_procReturnStatus => 2,
2753: p_msg => 'unexpected error OTHERS' || SQLERRM,
2754: x_returnStatus => l_return_status);
2766: l_return_status VARCHAR2(1);
2767:
2768: BEGIN
2769:
2770: IF (g_logLevel <= wip_constants.trace_logging) THEN
2771:
2772: l_params(1).paramName := 'p_start_date';
2773: l_params(1).paramValue := p_start_date;
2774: l_params(2).paramName := 'p_org_id';
2829: wdj1.*
2830: from wip_discrete_jobs wdj1
2831: where wdj1.date_completed > p_start_date
2832: and wdj1.organization_id = p_org_id
2833: and wdj1.status_type in (WIP_CONSTANTS.CLOSED, WIP_CONSTANTS.COMP_CHRG, WIP_CONSTANTS.COMP_NOCHRG)
2834: and wdj1.quantity_completed > 0) wdj;
2835:
2836: IF (g_logLevel <= wip_constants.trace_logging) then
2837: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.populate_ppm_defects_data',
2832: and wdj1.organization_id = p_org_id
2833: and wdj1.status_type in (WIP_CONSTANTS.CLOSED, WIP_CONSTANTS.COMP_CHRG, WIP_CONSTANTS.COMP_NOCHRG)
2834: and wdj1.quantity_completed > 0) wdj;
2835:
2836: IF (g_logLevel <= wip_constants.trace_logging) then
2837: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.populate_ppm_defects_data',
2838: p_procReturnStatus => l_return_status,
2839: p_msg => 'processed successfully',
2840: x_returnStatus => l_return_status);
2844:
2845: WHEN others THEN
2846: wip_ws_util.trace_log('Error in populate_ppm_defects_data');
2847:
2848: IF (g_logLevel <= wip_constants.trace_logging) then
2849: wip_logger.exitPoint(p_procName => 'wip_ws_embedded_analytics_pk.populate_ppm_defects_data',
2850: p_procReturnStatus => l_return_status,
2851: p_msg => 'processed error' || SQLERRM,
2852: x_returnStatus => l_return_status);