[Home] [Help]
PACKAGE BODY: APPS.ENGPKIMP
Source
1 package body ENGPKIMP as
2 /* $Header: ENGEIMPB.pls 120.70.12020000.9 2013/05/22 14:28:50 rambkond ship $ */
3
4 --##########################################################################
5 -- HISTORY :
6 --
7 -- Sept-2003 odaboval ERES_Project.
8 -- Raise child events of ERES parent event ecoImplement:
9 -- - copyToManufacturing
10 -- - transferToManufacturing
11 -- - billCreate or billUpdate
12 -- - routingCreate or routingC=Update.
13 -- These event are not attached to the parent if
14 -- it doesn't exist.
15 -- Created local procedure event_acknowledgement for
16 -- acknowledging the events in case of error.
17 --
18 -- Oct-2003 odaboval set the ERES calls as 8i Compliant.
19 -- 06/29/04 Added parameter p_revised_item_seq_id to Procedure
20 -- LOG_IMPLEMENT_FAILURE
21 --
22 -- Jul-2004 odaboval bug 3741444, added flag bERES_Flag_for_BOM.
23 -- Dec-2004 odaboval bug 3908563, added flag bERES_Flag_for_Routing.
24
25 --##########################################################################
26
27 cancelled_status constant number(1) := 5;
28 implemented_status constant number(1) := 6;
29
30 --
31 -- From domain ECG_ACTION.
32 --
33 acd_add constant number(1) := 1;
34 acd_change constant number(1) := 2;
35 acd_delete constant number(1) := 3;
36
37 -- Oracle Order Entry
38
39 G_OrderEntry constant number(3) := 300;
40 -- set new wip job name used in creating wip_job_schedule_interface
41
42 rev_op_disable_date_tbl Rev_Op_Disable_Date_Tbl_Type;
43 rev_comp_disable_date_tbl Rev_Comp_Disable_Date_Tbl_Type;
44
45 ------------------------------------------------------------------
46 -- Added for bug 3448857 --
47 -- Defining Exception if package is not found when they are --
48 -- called using dynamic sql --
49 ------------------------------------------------------------------
50 PLSQL_COMPILE_ERROR EXCEPTION;
51 PRAGMA EXCEPTION_INIT(PLSQL_COMPILE_ERROR, -6550);
52
53 ------------------------------------------------------
54 -- R12: Type declaration for Common BOM Enhancement --
55 ------------------------------------------------------
56 TYPE Common_Rev_Comp_Rec_Type IS RECORD (
57 Revised_Item_Sequence_Id NUMBER
58 , dest_bill_sequence_id NUMBER
59 , dest_old_comp_sequence_id NUMBER
60 , Component_sequence_id NUMBER
61 , common_component_sequence_id NUMBER
62 , prev_common_comp_sequence_id NUMBER
63 );
64 TYPE Common_Rev_Comp_Tbl_Type IS TABLE OF Common_Rev_Comp_Rec_Type
65 INDEX BY BINARY_INTEGER ;
66 -----------------------------------------------------------------
67 -- R12: Global variable declaration for Common BOM Enhancement --
68 -----------------------------------------------------------------
69 g_Common_Rev_Comp_Tbl Common_Rev_Comp_Tbl_Type;
70 g_common_rev_comps_cnt NUMBER;
71 isCommonedBOM VARCHAR2(1);
72 -----------------------------------------------------------------
73 -- Procedures Begin --
74 -----------------------------------------------------------------
75
76 -- Added private procedure for bug 3584193
77 -- Description: The bill with unapproved items should not be allowed to be transferred through ECO.
78 /********************************************************************
79 * API Name : UNAPPROVED_COMPONENTS_EXISTS
80 * Parameters IN : L_NEW_ASSEMBLY_ITEM_ID, VAR_ORGANIZATION_ID, VAR_SELECTION_OPTION, VAR_ALTERNATE_BOM_DESIGNATOR
81 * Parameters OUT: None
82 * Returns : Boolean 'TRUE' or 'FALSE' depending on whether bill contains any un-approved items.
83 * Purpose : For an Engineering BOM to transfer to Manufacturing, the BOM should not contain any un-approved items.
84 * This API will find if the BOM contains any un-approved items.
85 *********************************************************************/
86 FUNCTION UNAPPROVED_COMPONENTS_EXISTS (L_NEW_ASSEMBLY_ITEM_ID IN NUMBER,
87 VAR_ORGANIZATION_ID IN NUMBER,
88 VAR_SELECTION_OPTION IN NUMBER,
89 VAR_ALTERNATE_BOM_DESIGNATOR IN VARCHAR2)
90 RETURN BOOLEAN IS
91 CURSOR check_components IS
92 SELECT count(1)
93 FROM DUAL
94 WHERE EXISTS (
95 SELECT 1
96 FROM bom_bill_of_materials bbom,
97 bom_inventory_components bic,
98 mtl_system_items msi
99 WHERE bbom.assembly_item_id = L_NEW_ASSEMBLY_ITEM_ID
100 AND bbom.organization_id = VAR_ORGANIZATION_ID
101 AND ((VAR_SELECTION_OPTION = 2 AND
102 bBOM.ALTERNATE_BOM_DESIGNATOR IS NULL)
103 OR (VAR_SELECTION_OPTION = 3 AND
104 bBOM.ALTERNATE_BOM_DESIGNATOR = VAR_ALTERNATE_BOM_DESIGNATOR)
105 OR (VAR_SELECTION_OPTION = 1))
106 AND bic.bill_Sequence_id = bbom.bill_sequence_id
107 AND msi.inventory_item_id = bic.component_item_id
108 AND msi.organization_id = VAR_ORGANIZATION_ID
109 AND nvl(msi.approval_status,'A') <> 'A');
110 l_dummy number;
111 BEGIN
112 --FND_FILE.PUT_LINE(FND_FILE.LOG, 'ENGEIMPB.pls - in method UNAPPROVED_COMPONENTS_EXISTS');
113 OPEN check_components;
114 FETCH check_components INTO l_dummy;
115 CLOSE check_components;
116 IF l_dummy = 1 THEN
117 RETURN TRUE; -- This means that there is atleast one unapproved item as component
118 END IF;
119 RETURN FALSE;
120 END UNAPPROVED_COMPONENTS_EXISTS;
121
122 -- Added for bug 3482152
123 /********************************************************************
124 * API Name : check_header_impl_allowed
125 * Parameters IN : p_change_id, p_status_code
126 * Parameters OUT: None
127 * Returns : 'T' or 'F' depending on whether header can be promoted
128 * Purpose : For PLM ECOs checks the following to determine
129 * whether header can be promoted.
130 * a) Valid status
131 * b) Workflow status
132 * c) Mandatory tasks
133 *********************************************************************/
134 FUNCTION check_header_impl_allowed
135 ( p_change_id IN NUMBER
136 , p_change_notice IN VARCHAR2
137 , p_status_code IN NUMBER
138 , p_curr_status_code IN NUMBER
139 , p_plm_or_erp_change IN VARCHAR2
140 , p_request_id IN NUMBER
141 ) RETURN VARCHAR2 IS
142
143 l_mandatory_task_count NUMBER;
144 l_implement_header VARCHAR2(1) := 'F';
145 l_valid_phase NUMBER;
146 l_eco_impl_mode NUMBER := 0; -- implementation trigger point header
147
148 -- cursor to check if the implementation trigger point is not the eco header
149 -- i.e., either auto-implement or revised items promote action
150 CURSOR c_eco_impl_mode_header IS
151 SELECT 1
152 FROM fnd_concurrent_requests
153 WHERE request_id = p_request_id
154 AND ARGUMENT4 IS NOT NULL
155 AND ARGUMENT5 IS NULL;
156
157 -- Cursor to check --
158 -- if current phase of the header is the second last phase of the lifecycle of the change
159 -- and if workflow is associated to the phase then , it is in completed or approved phase
160 CURSOR c_check_phase IS
161 SELECT 1
162 FROM eng_lifecycle_statuses els
163 WHERE els.entity_id1 = p_change_id
164 AND els.entity_name = 'ENG_CHANGE'
165 AND els.status_code = p_curr_status_code
166 AND els.active_flag = 'Y'
167 AND ( 1 = l_eco_impl_mode
168 OR ( 1 = ( SELECT count(*)
169 FROM eng_lifecycle_statuses els_in
170 WHERE els_in.entity_id1 = p_change_id
171 AND els_in.entity_name = 'ENG_CHANGE'
172 AND els_in.active_flag = 'Y'
173 AND els_in.sequence_number > els.sequence_number)
174 AND (( els.change_wf_route_id IS NOT NULL
175 AND ( els.workflow_status = 'APPROVED'
176 OR els.workflow_status = 'COMPLETED')
177 )
178 OR ( els.change_wf_route_id IS NULL
179 AND els.CHANGE_WF_ROUTE_TEMPLATE_ID IS NULL)
180 )
181 )
182 );
183
184
185 BEGIN
186
187 IF (p_plm_or_erp_change = 'ERP')
188 THEN
189 l_implement_header := 'T';
190 RETURN l_implement_header;
191 ELSE
192
193 OPEN c_eco_impl_mode_header;
194 FETCH c_eco_impl_mode_header INTO l_eco_impl_mode;
195 CLOSE c_eco_impl_mode_header;
196
197 OPEN c_check_phase;
198 FETCH c_check_phase INTO l_valid_phase;
199 IF c_check_phase%NOTFOUND
200 THEN
201 l_implement_header := 'F';
202 FND_FILE.NEW_LINE(FND_FILE.LOG);
203 FND_FILE.PUT_LINE(FND_FILE.LOG, 'The header of ECO '|| p_change_notice||' will not be implemented.');
204 ELSE
205
206 l_implement_header := 'T';
207 -- check if there are any pending mandatory tasks in the ECO
208 SELECT count(1)
209 INTO l_mandatory_task_count
210 FROM eng_change_lines l,
211 eng_change_statuses s
212 WHERE l.change_id = p_change_id
213 AND s.status_code = l.status_code
214 AND l.complete_before_status_code IS NOT NULL
215 AND s.status_type NOT IN (5, 6, 11)
216 AND nvl(l.required_flag , 'Y') = 'Y';
217
218 IF(l_mandatory_task_count <> 0)
219 THEN
220 l_implement_header := 'F';
221 FND_FILE.NEW_LINE(FND_FILE.LOG);
222 FND_FILE.PUT_LINE(FND_FILE.LOG, 'The header of ECO '|| p_change_notice||' will not be implemented as '||
223 'there is at least one mandatory task which must be completed/cancelled.');
224 END IF;
225 END IF;
226 CLOSE c_check_phase;
227 RETURN l_implement_header;
228 END IF;
229 EXCEPTION
230 WHEN OTHERS THEN
231 FND_FILE.NEW_LINE(FND_FILE.LOG);
232 FND_FILE.PUT_LINE(FND_FILE.LOG,' Error in check_header_impl_allowed .. ' ||SQLERRM);
233 --do not implement the header if validation errors out
234 CLOSE c_check_phase;
235 l_implement_header := 'F';
236 RETURN l_implement_header;
237 END check_header_impl_allowed;
238 -- End changes for bug 3482152
239
240 -- Bug 6982970 vggarg code added for business event start
241 -- Internal procedure to raise cm status change events
242 PROCEDURE Raise_Status_Change_Event
243 (
244 p_change_id IN NUMBER
245 ,p_base_cm_type_code IN VARCHAR2
246 ,p_status_code IN NUMBER
247 ,p_action_type IN VARCHAR2
248 ,p_action_id IN NUMBER
249 )
250 IS
251 l_param_list WF_PARAMETER_LIST_T := WF_PARAMETER_LIST_T();
252
253 BEGIN
254
255 -- Adding event parameters to the list
256 WF_EVENT.AddParameterToList
257 ( p_name => ENG_CHANGE_BES_UTIL.G_BES_PARAM_CHANGE_ID
258 ,p_value => to_char(p_change_id)
259 ,p_parameterList => l_param_list
260 );
261 WF_EVENT.AddParameterToList
262 ( p_name => ENG_CHANGE_BES_UTIL.G_BES_PARAM_BASE_CM_TYPE_CODE
263 ,p_value => p_base_cm_type_code
264 ,p_parameterList => l_param_list
265 );
266 WF_EVENT.AddParameterToList
267 ( p_name => ENG_CHANGE_BES_UTIL.G_BES_PARAM_STATUS_CODE
268 ,p_value => to_char(p_status_code)
269 ,p_parameterList => l_param_list
270 );
271 WF_EVENT.AddParameterToList
272 ( p_name => ENG_CHANGE_BES_UTIL.G_BES_PARAM_ACT_TYPE_CODE
273 ,p_value => p_action_type
274 ,p_parameterList => l_param_list
275 );
276 WF_EVENT.AddParameterToList
277 ( p_name => ENG_CHANGE_BES_UTIL.G_BES_PARAM_ACTION_ID
278 ,p_value => to_char(p_action_id)
279 ,p_parameterList => l_param_list
280 );
281
282 -- Raise event
283 WF_EVENT.RAISE
284 ( p_event_name => ENG_CHANGE_BES_UTIL.G_CMBE_HEADER_CHG_STATUS
285 ,p_event_key => p_change_id
286 ,p_parameters => l_param_list
287 );
288 l_param_list.DELETE;
289
290 EXCEPTION
291 WHEN OTHERS THEN
292 NULL;
293 END Raise_Status_Change_Event;
294 -- Bug 6982970 vggarg end
295
296
297 -- Code changes for enhancement 6084027 start
298 PROCEDURE LOG_IMPLEMENT_FAILURE(p_change_notice IN VARCHAR2
299 ,p_org_id IN NUMBER
300 , p_revised_item_seq_id IN NUMBER
301 )
302 IS
303 l_change_id NUMBER;
304 BEGIN
305 SELECT change_id INTO l_change_id FROM eng_engineering_changes WHERE change_notice = p_change_notice AND
306 organization_id = p_org_id;
307 LOG_IMPLEMENT_FAILURE(l_change_id, p_revised_item_seq_id);
308 END;
309 -- Code changes for enhancement 6084027 end
310
311
312 -- Added for bug 6157001
313 PROCEDURE Chk_GDSN_SingleRow_Chgs_Exist ( p_change_line_id IN NUMBER,
314 p_attr_group_id IN NUMBER,
315 x_can_implement_status OUT NOCOPY VARCHAR2
316 )
317 IS
318 l_single_changes_count NUMBER;
319 l_multi_changes_count NUMBER;
320 l_inventory_item_id NUMBER;
321 l_org_id NUMBER;
322 l_single_gdsn_item_prod_rec EGO_ITEM_GTN_ATTRS_VL%ROWTYPE;
323 l_single_gdsn_item_pend_rec EGO_GTN_ATTR_CHG_VL%ROWTYPE;
324 l_multi_gdsn_item_prod_rec EGO_ITEM_GTN_ATTRS_VL%ROWTYPE;
325 l_multi_gdsn_item_pend_rec EGO_GTN_MUL_ATTR_CHG_VL%ROWTYPE;
326 abort_implementation exception;
327
328 CURSOR cur_gdsn_singlerow_attr_grps IS
329 SELECT attr_group_id, attr_group_name FROM ego_attr_groups_v WHERE attr_group_type='EGO_ITEM_GTIN_ATTRS' AND application_id=431;
330
331 BEGIN
332 l_single_changes_count := 0;
333 l_multi_changes_count := 0;
334
335 -- First Check if there are any pending changes for gdsn single or multi row attrs done through the change order.
336 SELECT count(*) INTO l_single_changes_count FROM ego_gtn_attr_chg_vl WHERE change_line_id = p_change_line_id AND implementation_date IS NULL;
337 SELECT count(*) INTO l_multi_changes_count FROM ego_gtn_mul_attr_chg_vl WHERE change_line_id = p_change_line_id AND implementation_date IS NULL;
338 -- If there are no gdsn single or multi row attrs changes return
339 IF l_single_changes_count = 0 AND l_multi_changes_count = 0 THEN
340 x_can_implement_status := 'YES';
341 RETURN;
342 END IF;
343
344 SELECT revised_item_id, organization_id
345 INTO l_inventory_item_id, l_org_id
346 FROM eng_revised_items
347 WHERE revised_item_sequence_id = p_change_line_id;
348
349 -- If gdsn single row changes exists
350 IF l_single_changes_count > 0 THEN
351 -- Get the pending and production rows for comparision
352 SELECT * INTO l_single_gdsn_item_pend_rec FROM ego_gtn_attr_chg_vl WHERE change_line_id = p_change_line_id;
353 SELECT * INTO l_single_gdsn_item_prod_rec FROM ego_item_gtn_attrs_vl WHERE inventory_item_id = l_inventory_item_id AND organization_id = l_org_id;
354
355 FOR single_attr_grps_cur IN cur_gdsn_singlerow_attr_grps
356 LOOP
357
358 -- Check if there are any pending changes done for this attribute group
359 -- Trade_Item_Description GDSN Single Row Attribute Group
360 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Trade_Item_Description' THEN
361 IF (NVL(l_single_gdsn_item_pend_rec.BRAND_NAME, NVL(l_single_gdsn_item_prod_rec.BRAND_NAME,'!')) <> NVL(l_single_gdsn_item_prod_rec.BRAND_NAME,'!'))
362 OR (NVL(l_single_gdsn_item_pend_rec.BRAND_OWNER_GLN, NVL(l_single_gdsn_item_prod_rec.BRAND_OWNER_GLN,'!')) <> NVL(l_single_gdsn_item_prod_rec.BRAND_OWNER_GLN,'!'))
363 OR (NVL(l_single_gdsn_item_pend_rec.BRAND_OWNER_NAME, NVL(l_single_gdsn_item_prod_rec.BRAND_OWNER_NAME,'!')) <> NVL(l_single_gdsn_item_prod_rec.BRAND_OWNER_NAME,'!'))
364 OR (NVL(l_single_gdsn_item_pend_rec.DESCRIPTION_SHORT, NVL(l_single_gdsn_item_prod_rec.DESCRIPTION_SHORT,'!')) <> NVL(l_single_gdsn_item_prod_rec.DESCRIPTION_SHORT,'!'))
365 OR (NVL(l_single_gdsn_item_pend_rec.EANUCC_CODE, NVL(l_single_gdsn_item_prod_rec.EANUCC_CODE,'!')) <> NVL(l_single_gdsn_item_prod_rec.EANUCC_CODE,'!'))
366 OR (NVL(l_single_gdsn_item_pend_rec.EANUCC_TYPE, NVL(l_single_gdsn_item_prod_rec.EANUCC_TYPE,'!')) <> NVL(l_single_gdsn_item_prod_rec.EANUCC_TYPE,'!'))
367 OR (NVL(l_single_gdsn_item_pend_rec.FUNCTIONAL_NAME, NVL(l_single_gdsn_item_prod_rec.FUNCTIONAL_NAME,'!')) <> NVL(l_single_gdsn_item_prod_rec.FUNCTIONAL_NAME,'!'))
368 OR (NVL(l_single_gdsn_item_pend_rec.INVOICE_NAME, NVL(l_single_gdsn_item_prod_rec.INVOICE_NAME,'!')) <> NVL(l_single_gdsn_item_prod_rec.INVOICE_NAME,'!'))
369 OR (NVL(l_single_gdsn_item_pend_rec.IS_BARCODE_SYMBOLOGY_DERIVABLE, NVL(l_single_gdsn_item_prod_rec.IS_BARCODE_SYMBOLOGY_DERIVABLE,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_BARCODE_SYMBOLOGY_DERIVABLE,'!'))
370 OR (NVL(l_single_gdsn_item_pend_rec.SUB_BRAND, NVL(l_single_gdsn_item_prod_rec.SUB_BRAND,'!')) <> NVL(l_single_gdsn_item_prod_rec.SUB_BRAND,'!'))
371 OR (NVL(l_single_gdsn_item_pend_rec.TRADE_ITEM_COUPON, NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_COUPON,-999999)) <> NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_COUPON,-999999))
372 OR (NVL(l_single_gdsn_item_pend_rec.TRADE_ITEM_DESCRIPTOR, NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_DESCRIPTOR,-999999)) <> NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_DESCRIPTOR,-999999))
373 OR (NVL(l_single_gdsn_item_pend_rec.TRADE_ITEM_FINISH_DESCRIPTION, NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_FINISH_DESCRIPTION,'!')) <> NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_FINISH_DESCRIPTION,'!'))
374 OR (NVL(l_single_gdsn_item_pend_rec.TRADE_ITEM_FORM_DESCRIPTION, NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_FORM_DESCRIPTION,'!')) <> NVL(l_single_gdsn_item_prod_rec.TRADE_ITEM_FORM_DESCRIPTION,'!'))
375 THEN
376 x_can_implement_status := 'NO';
377 EXIT;
378 END IF;
379 END IF; -- Trade_Item_Description
380
381 -- Trade_Item_Measurements GDSN Single Row Attribute Group
382 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Trade_Item_Measurements' THEN
383 IF (NVL(l_single_gdsn_item_pend_rec.DIAMETER, NVL(l_single_gdsn_item_prod_rec.DIAMETER,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DIAMETER,-999999))
384 OR (NVL(l_single_gdsn_item_pend_rec.DRAINED_WEIGHT, NVL(l_single_gdsn_item_prod_rec.DRAINED_WEIGHT,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DRAINED_WEIGHT,-999999))
385 OR (NVL(l_single_gdsn_item_pend_rec.GENERIC_INGREDIENT, NVL(l_single_gdsn_item_prod_rec.GENERIC_INGREDIENT,'!')) <> NVL(l_single_gdsn_item_prod_rec.GENERIC_INGREDIENT,'!'))
386 OR (NVL(l_single_gdsn_item_pend_rec.GENERIC_INGREDIENT_STRGTH, NVL(l_single_gdsn_item_prod_rec.GENERIC_INGREDIENT_STRGTH,-999999)) <> NVL(l_single_gdsn_item_prod_rec.GENERIC_INGREDIENT_STRGTH,-999999))
387 OR (NVL(l_single_gdsn_item_pend_rec.GROSS_WEIGHT, NVL(l_single_gdsn_item_prod_rec.GROSS_WEIGHT,-999999)) <> NVL(l_single_gdsn_item_prod_rec.GROSS_WEIGHT,-999999))
388 OR (NVL(l_single_gdsn_item_pend_rec.INGREDIENT_STRENGTH, NVL(l_single_gdsn_item_prod_rec.INGREDIENT_STRENGTH,'!')) <> NVL(l_single_gdsn_item_prod_rec.INGREDIENT_STRENGTH,'!'))
389 OR (NVL(l_single_gdsn_item_pend_rec.IS_NET_CONTENT_DEC_FLAG, NVL(l_single_gdsn_item_prod_rec.IS_NET_CONTENT_DEC_FLAG,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_NET_CONTENT_DEC_FLAG,'!'))
390 OR (NVL(l_single_gdsn_item_pend_rec.NET_CONTENT, NVL(l_single_gdsn_item_prod_rec.NET_CONTENT,-999999)) <> NVL(l_single_gdsn_item_prod_rec.NET_CONTENT,-999999))
391 OR (NVL(l_single_gdsn_item_pend_rec.PEG_HORIZONTAL, NVL(l_single_gdsn_item_prod_rec.PEG_HORIZONTAL,-999999)) <> NVL(l_single_gdsn_item_prod_rec.PEG_HORIZONTAL,-999999))
392 OR (NVL(l_single_gdsn_item_pend_rec.PEG_VERTICAL, NVL(l_single_gdsn_item_prod_rec.PEG_VERTICAL,-999999)) <> NVL(l_single_gdsn_item_prod_rec.PEG_VERTICAL,-999999))
393 OR (NVL(l_single_gdsn_item_pend_rec.UOM_NET_CONTENT, NVL(l_single_gdsn_item_prod_rec.UOM_NET_CONTENT,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_NET_CONTENT,'!'))
394 THEN
395 x_can_implement_status := 'NO';
396 EXIT;
397 END IF;
398 END IF; -- Trade_Item_Measurements
399
400 -- Gtin_Unit_Indicator GDSN Single Row Attribute Group
401 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Gtin_Unit_Indicator' THEN
402 IF (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT,'!'))
403 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_CONSUMER_UNIT,'!'))
404 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_A_VARIABLE_UNIT, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_VARIABLE_UNIT,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_A_VARIABLE_UNIT,'!'))
405 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_INFO_PRIVATE, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_INFO_PRIVATE,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_INFO_PRIVATE,'!'))
406 THEN
407 x_can_implement_status := 'NO';
408 EXIT;
409 END IF;
410 END IF; -- Gtin_Unit_Indicator
411
412 -- Price_Date_Information GDSN Single Row Attribute Group
413 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Price_Date_Information' THEN
414 IF (NVL(l_single_gdsn_item_pend_rec.CATALOG_PRICE, NVL(l_single_gdsn_item_prod_rec.CATALOG_PRICE,-999999)) <> NVL(l_single_gdsn_item_prod_rec.CATALOG_PRICE,-999999))
415 OR (NVL(l_single_gdsn_item_pend_rec.SUGGESTED_RETAIL_PRICE, NVL(l_single_gdsn_item_prod_rec.SUGGESTED_RETAIL_PRICE,-999999)) <> NVL(l_single_gdsn_item_prod_rec.SUGGESTED_RETAIL_PRICE,-999999))
416 OR (NVL(l_single_gdsn_item_pend_rec.EFFECTIVE_END_DATE, NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_END_DATE,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_END_DATE,to_date('''1''','''j''')))
417 OR (NVL(l_single_gdsn_item_pend_rec.EFFECTIVE_START_DATE, NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_START_DATE,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_START_DATE,to_date('''1''','''j''')))
418 THEN
419 x_can_implement_status := 'NO';
420 EXIT;
421 END IF;
422 END IF; -- Price_Date_Information
423
424 -- Trade_Item_Hierarchy GDSN Single Row Attribute Group
425 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Trade_Item_Hierarchy' THEN
426 IF (NVL(l_single_gdsn_item_pend_rec.QUANITY_OF_ITEM_IN_LAYER, NVL(l_single_gdsn_item_prod_rec.QUANITY_OF_ITEM_IN_LAYER,-999999)) <> NVL(l_single_gdsn_item_prod_rec.QUANITY_OF_ITEM_IN_LAYER,-999999))
427 OR (NVL(l_single_gdsn_item_pend_rec.QUANTITY_OF_COMP_LAY_ITEM, NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_COMP_LAY_ITEM,-999999)) <> NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_COMP_LAY_ITEM,-999999))
428 OR (NVL(l_single_gdsn_item_pend_rec.QUANTITY_OF_INNER_PACK, NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_INNER_PACK,-999999)) <> NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_INNER_PACK,-999999))
429 OR (NVL(l_single_gdsn_item_pend_rec.QUANTITY_OF_ITEM_INNER_PACK, NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_ITEM_INNER_PACK,-999999)) <> NVL(l_single_gdsn_item_prod_rec.QUANTITY_OF_ITEM_INNER_PACK,-999999))
430 THEN
431 x_can_implement_status := 'NO';
432 EXIT;
433 END IF;
434 END IF; -- Trade_Item_Hierarchy
435
436 -- Trade_Item_Marking GDSN Single Row Attribute Group
437 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Trade_Item_Marking' THEN
438 IF (NVL(l_single_gdsn_item_pend_rec.HAS_BATCH_NUMBER, NVL(l_single_gdsn_item_prod_rec.HAS_BATCH_NUMBER,'!')) <> NVL(l_single_gdsn_item_prod_rec.HAS_BATCH_NUMBER,'!'))
439 OR (NVL(l_single_gdsn_item_pend_rec.IS_NON_SOLD_TRADE_RET_FLAG, NVL(l_single_gdsn_item_prod_rec.IS_NON_SOLD_TRADE_RET_FLAG,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_NON_SOLD_TRADE_RET_FLAG,'!'))
440 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_MAR_REC_FLAG, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_MAR_REC_FLAG,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_MAR_REC_FLAG,'!'))
441 THEN
442 x_can_implement_status := 'NO';
443 EXIT;
444 END IF;
445 END IF; -- Trade_Item_Marking
446
447 -- Handling_Information GDSN Single Row Attribute Group
448 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Handling_Information' THEN
449 IF (NVL(l_single_gdsn_item_pend_rec.STACKING_FACTOR, NVL(l_single_gdsn_item_prod_rec.STACKING_FACTOR,-999999)) <> NVL(l_single_gdsn_item_prod_rec.STACKING_FACTOR,-999999))
450 OR (NVL(l_single_gdsn_item_pend_rec.STACKING_WEIGHT_MAXIMUM, NVL(l_single_gdsn_item_prod_rec.STACKING_WEIGHT_MAXIMUM,-999999)) <> NVL(l_single_gdsn_item_prod_rec.STACKING_WEIGHT_MAXIMUM,-999999))
451 THEN
452 x_can_implement_status := 'NO';
453 EXIT;
454 END IF;
455 END IF; -- Handling_Information
456
457 -- Packaging_Marking GDSN Single Row Attribute Group
458 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Packaging_Marking' THEN
459 IF (NVL(l_single_gdsn_item_pend_rec.IS_PACKAGE_MARKED_AS_REC, NVL(l_single_gdsn_item_prod_rec.IS_PACKAGE_MARKED_AS_REC,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_PACKAGE_MARKED_AS_REC,'!'))
460 OR (NVL(l_single_gdsn_item_pend_rec.IS_PACKAGE_MARKED_RET, NVL(l_single_gdsn_item_prod_rec.IS_PACKAGE_MARKED_RET,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_PACKAGE_MARKED_RET,'!'))
461 OR (NVL(l_single_gdsn_item_pend_rec.IS_PACK_MARKED_WITH_EXP_DATE, NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_EXP_DATE,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_EXP_DATE,'!'))
462 OR (NVL(l_single_gdsn_item_pend_rec.IS_PACK_MARKED_WITH_GREEN_DOT, NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_GREEN_DOT,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_GREEN_DOT,'!'))
463 OR (NVL(l_single_gdsn_item_pend_rec.IS_PACK_MARKED_WITH_INGRED, NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_INGRED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_PACK_MARKED_WITH_INGRED,'!'))
464 THEN
465 x_can_implement_status := 'NO';
466 EXIT;
467 END IF;
468 END IF; -- Packaging_Marking
469
470 -- Temperature_Information GDSN Single Row Attribute Group
471 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Temperature_Information' THEN
472 IF (NVL(l_single_gdsn_item_pend_rec.DELIVERY_TO_MRKT_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.DELIVERY_TO_MRKT_TEMP_MAX,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DELIVERY_TO_MRKT_TEMP_MAX,-999999))
473 OR (NVL(l_single_gdsn_item_pend_rec.DELIVERY_TO_MRKT_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.DELIVERY_TO_MRKT_TEMP_MIN,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DELIVERY_TO_MRKT_TEMP_MIN,-999999))
474 OR (NVL(l_single_gdsn_item_pend_rec.DEL_TO_DIST_CNTR_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.DEL_TO_DIST_CNTR_TEMP_MAX,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DEL_TO_DIST_CNTR_TEMP_MAX,-999999))
475 OR (NVL(l_single_gdsn_item_pend_rec.DEL_TO_DIST_CNTR_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.DEL_TO_DIST_CNTR_TEMP_MIN,-999999)) <> NVL(l_single_gdsn_item_prod_rec.DEL_TO_DIST_CNTR_TEMP_MIN,-999999))
476 OR (NVL(l_single_gdsn_item_pend_rec.STORAGE_HANDLING_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.STORAGE_HANDLING_TEMP_MAX,-999999)) <> NVL(l_single_gdsn_item_prod_rec.STORAGE_HANDLING_TEMP_MAX,-999999))
477 OR (NVL(l_single_gdsn_item_pend_rec.STORAGE_HANDLING_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.STORAGE_HANDLING_TEMP_MIN,-999999)) <> NVL(l_single_gdsn_item_prod_rec.STORAGE_HANDLING_TEMP_MIN,-999999))
478 OR (NVL(l_single_gdsn_item_pend_rec.UOM_DELIVERY_TO_MRKT_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.UOM_DELIVERY_TO_MRKT_TEMP_MAX,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_DELIVERY_TO_MRKT_TEMP_MAX,'!'))
479 OR (NVL(l_single_gdsn_item_pend_rec.UOM_DELIVERY_TO_MRKT_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.UOM_DELIVERY_TO_MRKT_TEMP_MIN,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_DELIVERY_TO_MRKT_TEMP_MIN,'!'))
480 OR (NVL(l_single_gdsn_item_pend_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MAX,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MAX,'!'))
481 OR (NVL(l_single_gdsn_item_pend_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MIN,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_DEL_TO_DIST_CNTR_TEMP_MIN,'!'))
482 OR (NVL(l_single_gdsn_item_pend_rec.UOM_STORAGE_HANDLING_TEMP_MAX, NVL(l_single_gdsn_item_prod_rec.UOM_STORAGE_HANDLING_TEMP_MAX,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_STORAGE_HANDLING_TEMP_MAX,'!'))
483 OR (NVL(l_single_gdsn_item_pend_rec.UOM_STORAGE_HANDLING_TEMP_MIN, NVL(l_single_gdsn_item_prod_rec.UOM_STORAGE_HANDLING_TEMP_MIN,'!')) <> NVL(l_single_gdsn_item_prod_rec.UOM_STORAGE_HANDLING_TEMP_MIN,'!'))
484 THEN
485 x_can_implement_status := 'NO';
486 EXIT;
487 END IF;
488 END IF; -- Temperature_Information
489
490 -- Price_Information GDSN Single Row Attribute Group
491 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Price_Information' THEN
492 IF (NVL(l_single_gdsn_item_pend_rec.RETAIL_PRICE_ON_TRADE_ITEM, NVL(l_single_gdsn_item_prod_rec.RETAIL_PRICE_ON_TRADE_ITEM,-999999)) <> NVL(l_single_gdsn_item_prod_rec.RETAIL_PRICE_ON_TRADE_ITEM,-999999))
493 THEN
494 x_can_implement_status := 'NO';
495 EXIT;
496 END IF;
497 END IF; -- Price_Information
498
499 -- Material_Safety_Data GDSN Single Row Attribute Group
500 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Material_Safety_Data' THEN
501 IF (NVL(l_single_gdsn_item_pend_rec.MATERIAL_SAFETY_DATA_SHEET_NO, NVL(l_single_gdsn_item_prod_rec.MATERIAL_SAFETY_DATA_SHEET_NO,'!')) <> NVL(l_single_gdsn_item_prod_rec.MATERIAL_SAFETY_DATA_SHEET_NO,'!'))
502 THEN
503 x_can_implement_status := 'NO';
504 EXIT;
505 END IF;
506 END IF; -- Material_Safety_Data
507
508 -- Date_Information GDSN Single Row Attribute Group
509 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Date_Information' THEN
510 IF (NVL(l_single_gdsn_item_pend_rec.CANCELED_DATE, NVL(l_single_gdsn_item_prod_rec.CANCELED_DATE,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.CANCELED_DATE,to_date('''1''','''j''')))
511 OR (NVL(l_single_gdsn_item_pend_rec.CONSUMER_AVAIL_DATE_TIME, NVL(l_single_gdsn_item_prod_rec.CONSUMER_AVAIL_DATE_TIME,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.CONSUMER_AVAIL_DATE_TIME,to_date('''1''','''j''')))
512 OR (NVL(l_single_gdsn_item_pend_rec.DISCONTINUED_DATE, NVL(l_single_gdsn_item_prod_rec.DISCONTINUED_DATE,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.DISCONTINUED_DATE,to_date('''1''','''j''')))
513 OR (NVL(l_single_gdsn_item_pend_rec.EFFECTIVE_DATE, NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_DATE,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.EFFECTIVE_DATE,to_date('''1''','''j''')))
514 OR (NVL(l_single_gdsn_item_pend_rec.END_AVAILABILITY_DATE_TIME, NVL(l_single_gdsn_item_prod_rec.END_AVAILABILITY_DATE_TIME,to_date('''1''','''j'''))) <> NVL(l_single_gdsn_item_prod_rec.END_AVAILABILITY_DATE_TIME,to_date('''1''','''j''')))
515 OR (NVL(l_single_gdsn_item_pend_rec.START_AVAILABILITY_DATE_TIME, NVL(l_single_gdsn_item_prod_rec.START_AVAILABILITY_DATE_TIME,to_date('''1''','''j'''))) <>
516 NVL(l_single_gdsn_item_prod_rec.START_AVAILABILITY_DATE_TIME,to_date('''1''','''j''')))
517 THEN
518 x_can_implement_status := 'NO';
519 EXIT;
520 END IF;
521 END IF; -- Date_Information
522
523 -- Order_Information GDSN Single Row Attribute Group
524 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Order_Information' THEN
525 IF (NVL(l_single_gdsn_item_pend_rec.ORDERING_LEAD_TIME, NVL(l_single_gdsn_item_prod_rec.ORDERING_LEAD_TIME,-999999)) <> NVL(l_single_gdsn_item_prod_rec.ORDERING_LEAD_TIME,-999999))
526 OR (NVL(l_single_gdsn_item_pend_rec.ORDER_QUANTITY_MAX, NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MAX,-999999)) <> NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MAX,-999999))
527 OR (NVL(l_single_gdsn_item_pend_rec.ORDER_QUANTITY_MIN, NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MIN,-999999)) <> NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MIN,-999999))
528 OR (NVL(l_single_gdsn_item_pend_rec.ORDER_QUANTITY_MULTIPLE, NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MULTIPLE,-999999)) <> NVL(l_single_gdsn_item_prod_rec.ORDER_QUANTITY_MULTIPLE,-999999))
529 OR (NVL(l_single_gdsn_item_pend_rec.ORDER_SIZING_FACTOR, NVL(l_single_gdsn_item_prod_rec.ORDER_SIZING_FACTOR,-999999)) <> NVL(l_single_gdsn_item_prod_rec.ORDER_SIZING_FACTOR,-999999))
530 THEN
531 x_can_implement_status := 'NO';
532 EXIT;
533 END IF;
534 END IF; -- Order_Information
535
536 -- Uccnet_Size_Description GDSN Single Row Attribute Group
537 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Uccnet_Size_Description' THEN
538 IF (NVL(l_single_gdsn_item_pend_rec.DESCRIPTIVE_SIZE, NVL(l_single_gdsn_item_prod_rec.DESCRIPTIVE_SIZE,'!')) <> NVL(l_single_gdsn_item_prod_rec.DESCRIPTIVE_SIZE,'!'))
539 THEN
540 x_can_implement_status := 'NO';
541 EXIT;
542 END IF;
543 END IF; -- Uccnet_Size_Description
544
545 -- FMCG_Measurements GDSN Single Row Attribute Group
546 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'FMCG_Measurements' THEN
547 IF (NVL(l_single_gdsn_item_pend_rec.DEGREE_OF_ORIGINAL_WORT, NVL(l_single_gdsn_item_prod_rec.DEGREE_OF_ORIGINAL_WORT,'!')) <> NVL(l_single_gdsn_item_prod_rec.DEGREE_OF_ORIGINAL_WORT,'!'))
548 OR (NVL(l_single_gdsn_item_pend_rec.FAT_PERCENT_IN_DRY_MATTER, NVL(l_single_gdsn_item_prod_rec.FAT_PERCENT_IN_DRY_MATTER,-999999)) <> NVL(l_single_gdsn_item_prod_rec.FAT_PERCENT_IN_DRY_MATTER,-999999))
549 OR (NVL(l_single_gdsn_item_pend_rec.PERCENT_OF_ALCOHOL_BY_VOL, NVL(l_single_gdsn_item_prod_rec.PERCENT_OF_ALCOHOL_BY_VOL,-999999)) <> NVL(l_single_gdsn_item_prod_rec.PERCENT_OF_ALCOHOL_BY_VOL,-999999))
550 THEN
551 x_can_implement_status := 'NO';
552 EXIT;
553 END IF;
554 END IF; -- FMCG_Measurements
555
556 -- FMCG_Measurements GDSN Single Row Attribute Group
557 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'FMCG_Measurements' THEN
558 IF (NVL(l_single_gdsn_item_pend_rec.DEGREE_OF_ORIGINAL_WORT, NVL(l_single_gdsn_item_prod_rec.DEGREE_OF_ORIGINAL_WORT,'!')) <> NVL(l_single_gdsn_item_prod_rec.DEGREE_OF_ORIGINAL_WORT,'!'))
559 OR (NVL(l_single_gdsn_item_pend_rec.FAT_PERCENT_IN_DRY_MATTER, NVL(l_single_gdsn_item_prod_rec.FAT_PERCENT_IN_DRY_MATTER,-999999)) <> NVL(l_single_gdsn_item_prod_rec.FAT_PERCENT_IN_DRY_MATTER,-999999))
560 OR (NVL(l_single_gdsn_item_pend_rec.PERCENT_OF_ALCOHOL_BY_VOL, NVL(l_single_gdsn_item_prod_rec.PERCENT_OF_ALCOHOL_BY_VOL,-999999)) <> NVL(l_single_gdsn_item_prod_rec.PERCENT_OF_ALCOHOL_BY_VOL,-999999))
561 THEN
562 x_can_implement_status := 'NO';
563 EXIT;
564 END IF;
565 END IF; -- FMCG_Measurements
566
567 -- FMCG_Identification GDSN Single Row Attribute Group
568 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'FMCG_Identification' THEN
569 IF (NVL(l_single_gdsn_item_pend_rec.ISBN_NUMBER, NVL(l_single_gdsn_item_prod_rec.ISBN_NUMBER,'!')) <> NVL(l_single_gdsn_item_prod_rec.ISBN_NUMBER,'!'))
570 OR (NVL(l_single_gdsn_item_pend_rec.ISSN_NUMBER, NVL(l_single_gdsn_item_prod_rec.ISSN_NUMBER,'!')) <> NVL(l_single_gdsn_item_prod_rec.ISSN_NUMBER,'!'))
571 THEN
572 x_can_implement_status := 'NO';
573 EXIT;
574 END IF;
575 END IF; -- FMCG_Identification
576
577 -- FMCG_MARKING GDSN Single Row Attribute Group
578 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'FMCG_MARKING' THEN
579 IF (NVL(l_single_gdsn_item_pend_rec.IS_INGREDIENT_IRRADIATED, NVL(l_single_gdsn_item_prod_rec.IS_INGREDIENT_IRRADIATED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_INGREDIENT_IRRADIATED,'!'))
580 OR (NVL(l_single_gdsn_item_pend_rec.IS_RAW_MATERIAL_IRRADIATED, NVL(l_single_gdsn_item_prod_rec.IS_RAW_MATERIAL_IRRADIATED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_RAW_MATERIAL_IRRADIATED,'!'))
581 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_GENETICALLY_MOD, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_GENETICALLY_MOD,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_GENETICALLY_MOD,'!'))
582 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_IRRADIATED, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_IRRADIATED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_IRRADIATED,'!'))
583 THEN
584 x_can_implement_status := 'NO';
585 EXIT;
586 END IF;
587 END IF; -- FMCG_MARKING
588
589 -- Uccnet_Hardlines GDSN Single Row Attribute Group
590 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Uccnet_Hardlines' THEN
591 IF (NVL(l_single_gdsn_item_pend_rec.DEPT_OF_TRNSPRT_DANG_GOODS_NUM, NVL(l_single_gdsn_item_prod_rec.DEPT_OF_TRNSPRT_DANG_GOODS_NUM,'!')) <> NVL(l_single_gdsn_item_prod_rec.DEPT_OF_TRNSPRT_DANG_GOODS_NUM,'!'))
592 OR (NVL(l_single_gdsn_item_pend_rec.IS_OUT_OF_BOX_PROVIDED, NVL(l_single_gdsn_item_prod_rec.IS_OUT_OF_BOX_PROVIDED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_OUT_OF_BOX_PROVIDED,'!'))
593 OR (NVL(l_single_gdsn_item_pend_rec.IS_TRADE_ITEM_RECALLED, NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_RECALLED,'!')) <> NVL(l_single_gdsn_item_prod_rec.IS_TRADE_ITEM_RECALLED,'!'))
594 OR (NVL(l_single_gdsn_item_pend_rec.MODEL_NUMBER, NVL(l_single_gdsn_item_prod_rec.MODEL_NUMBER,'!')) <> NVL(l_single_gdsn_item_prod_rec.MODEL_NUMBER,'!'))
595 OR (NVL(l_single_gdsn_item_pend_rec.RETURN_GOODS_POLICY, NVL(l_single_gdsn_item_prod_rec.RETURN_GOODS_POLICY,'!')) <> NVL(l_single_gdsn_item_prod_rec.RETURN_GOODS_POLICY,'!'))
596 OR (NVL(l_single_gdsn_item_pend_rec.URL_FOR_WARRANTY, NVL(l_single_gdsn_item_prod_rec.URL_FOR_WARRANTY,'!')) <> NVL(l_single_gdsn_item_prod_rec.URL_FOR_WARRANTY,'!'))
597 OR (NVL(l_single_gdsn_item_pend_rec.WARRANTY_DESCRIPTION, NVL(l_single_gdsn_item_prod_rec.WARRANTY_DESCRIPTION,'!')) <> NVL(l_single_gdsn_item_prod_rec.WARRANTY_DESCRIPTION,'!'))
598 OR (NVL(l_single_gdsn_item_pend_rec.NESTING_INCREMENT, NVL(l_single_gdsn_item_prod_rec.NESTING_INCREMENT,-999999)) <> NVL(l_single_gdsn_item_prod_rec.NESTING_INCREMENT,-999999))
599 OR (NVL(l_single_gdsn_item_pend_rec.PIECES_PER_TRADE_ITEM, NVL(l_single_gdsn_item_prod_rec.PIECES_PER_TRADE_ITEM,-999999)) <> NVL(l_single_gdsn_item_prod_rec.PIECES_PER_TRADE_ITEM,-999999))
600 THEN
601 x_can_implement_status := 'NO';
602 EXIT;
603 END IF;
604 END IF; -- Uccnet_Hardlines
605
606 -- Security_Tag GDSN Single Row Attribute Group
607 IF single_attr_grps_cur.attr_group_id = p_attr_group_id AND single_attr_grps_cur.attr_group_name = 'Security_Tag' THEN
608 IF (NVL(l_single_gdsn_item_pend_rec.SECURITY_TAG_LOCATION, NVL(l_single_gdsn_item_prod_rec.SECURITY_TAG_LOCATION,'!')) <> NVL(l_single_gdsn_item_prod_rec.SECURITY_TAG_LOCATION,'!'))
609 THEN
610 x_can_implement_status := 'NO';
611 EXIT;
612 END IF;
613 END IF; -- Security_Tag
614
615 END LOOP; -- single row attr groups cursor loop
616 END IF;
617 IF x_can_implement_status = 'NO' THEN
618 RETURN;
619 END IF;
620
621 EXCEPTION
622 WHEN OTHERS THEN
623 x_can_implement_status := 'NO';
624 RAISE abort_implementation;
625
626 END Chk_GDSN_SingleRow_Chgs_Exist;
627
628 PROCEDURE Can_Implement_Item ( p_change_line_id IN NUMBER,
629 x_implementation_status OUT NOCOPY VARCHAR2
630 )
631 IS
632 l_org_id NUMBER;
633 l_inventory_item_id NUMBER;
634 l_item_catalog_cat_id NUMBER;
635 l_item_lifecycle_id NUMBER;
636 l_item_current_phase_id NUMBER;
637 l_current_attr_group_id NUMBER;
638 l_can_implement_status VARCHAR2(30);
639 l_pending_changes_count NUMBER;
640 l_attribute_group_type VARCHAR2(50);
641 l_concatenated_segments VARCHAR2(100);
642 abort_implementation exception;
643
644 Cursor cur_item_change_not_allowed IS
645 SELECT pv.policy_char_value, r.attribute_number_value, ra.attribute_code
646 FROM eng_change_policies p, eng_change_policy_values pv, eng_change_rules r, eng_change_rule_attributes_vl ra
647 WHERE p.policy_object_pk1_value = l_item_catalog_cat_id
648 and p.policy_object_pk2_value = l_item_lifecycle_id
649 and p.policy_object_pk3_value = l_item_current_phase_id
650 AND pv.POLICY_CHAR_VALUE='NOT_ALLOWED'
651 and pv.change_rule_id = r.change_rule_id
652 and r.attribute_object_name = ra.attribute_object_name
653 and r.attribute_code = ra.attribute_code
654 AND p.change_policy_id = pv.change_policy_id
655 AND p.policy_object_name = 'CATALOG_LIFECYCLE_PHASE'
656 and p.policy_code= 'CHANGE_POLICY'
657 and ra.attribute_object_name = 'EGO_CATALOG_GROUP';
658 BEGIN
659 l_can_implement_status := 'YES';
660 /*
661 PROMOTE_DEMOTE 1
662 PROMOTE_DEMOTE 2
663 PROMOTE_DEMOTE 3
664 AML_RULE 1 AML
665 AML_RULE 2 Related Documents ENG_RELATIONSHIP_CHANGES
666 STRUCTURE_TYPE
667 ATTRIBUTE_GROUP id Attr Group Id
668 ATTACHMENT
669 */
670
671 -- First get the item information
672 SELECT revised_item_id, organization_id
673 INTO l_inventory_item_id, l_org_id
674 FROM eng_revised_items
675 WHERE revised_item_sequence_id = p_change_line_id;
676 -- Get the item details
677 SELECT item_catalog_group_id, lifecycle_id, current_phase_id , concatenated_segments
678 INTO l_item_catalog_cat_id, l_item_lifecycle_id, l_item_current_phase_id, l_concatenated_segments
679 FROM mtl_system_items_kfv
680 WHERE inventory_item_id = l_inventory_item_id
681 AND organization_id = l_org_id;
682
683 -- Check whether there are any change policies for the current phase of item at any level which are not allowed
684 FOR rev_items IN cur_item_change_not_allowed
685 LOOP
686
687 IF 'ATTRIBUTE_GROUP' = rev_items.attribute_code THEN -- Attribute Groups
688 -- Get the attribute group id
689 l_current_attr_group_id := rev_items.attribute_number_value;
690 SELECT attr_group_type INTO l_attribute_group_type FROM ego_attr_groups_v WHERE attr_group_id = l_current_attr_group_id;
691
692 IF l_attribute_group_type = 'EGO_ITEMMGMT_GROUP' THEN
693 -- Check if there are any UDA pending changes done through this Change Order for this attribute group
694 SELECT count(*) INTO l_pending_changes_count
695 FROM ego_items_attrs_changes_b
696 WHERE change_line_id = p_change_line_id
697 AND attr_group_id = l_current_attr_group_id
698 AND data_level_id not in (43103,43104,43105); -- Bug 6439100 Supplier datalevels change policy not supported
699
700 IF l_pending_changes_count > 0 THEN
701 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on User Defined Attribute Group with Id ' || l_current_attr_group_id);
702 l_can_implement_status := 'NO';
703 EXIT;
704 END IF;
705 END IF;
706 /*
707 -- Not required to check here. EGO_ITEM_PUB.process_item() API will do the change policy check
708 IF l_attribute_group_type = 'EGO_MASTER_ITEMS' THEN
709 END IF;
710 */
711 -- Check if there are item GDSN Singlerow attribute group changes
712 IF l_attribute_group_type = 'EGO_ITEM_GTIN_ATTRS' THEN
713 Chk_GDSN_SingleRow_Chgs_Exist(p_change_line_id => p_change_line_id,
714 p_attr_group_id => l_current_attr_group_id,
715 x_can_implement_status => l_can_implement_status);
716
717 IF l_can_implement_status = 'NO' THEN
718 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on GDSN Singlerow Attribute Group with Id ' || l_current_attr_group_id);
719 EXIT;
720 END IF;
721 END IF;
722
723 -- Check if there are item GDSN Multirow attribute group changes
724 IF l_attribute_group_type = 'EGO_ITEM_GTIN_MULTI_ATTRS' THEN
725 SELECT count(*) INTO l_pending_changes_count
726 FROM ego_gtn_mul_attr_chg_vl
727 WHERE change_line_id = p_change_line_id
728 AND attr_group_id = l_current_attr_group_id
729 AND implementation_date IS NULL;
730
731 IF l_pending_changes_count > 0 THEN
732 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on GDSN Multirow Attribute Group with Id ' || l_current_attr_group_id);
733 l_can_implement_status := 'NO';
734 EXIT;
735 END IF;
736 END IF;
737
738 END IF; -- All Attribute groups
739
740 -- Promote/Demote change policy check should be done for revision creation
741 IF 'PROMOTE_DEMOTE' = rev_items.attribute_code AND rev_items.attribute_number_value = 3 THEN -- New Revision for item
742 -- Check whether a new revision is created with this change order for the item
743 SELECT count(*) INTO l_pending_changes_count
744 FROM mtl_item_revisions
745 WHERE inventory_item_id = l_inventory_item_id
746 AND organization_id = l_org_id
747 AND revised_item_sequence_id = p_change_line_id
748 AND change_notice = ( SELECT change_notice FROM eng_engineering_changes
749 WHERE change_id in (SELECT change_id FROM eng_revised_items
750 WHERE revised_item_sequence_id = p_change_line_id))
751 AND implementation_date IS NULL;
752
753 IF l_pending_changes_count > 0 THEN
754 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on New Revision creation for the item.' );
755 l_can_implement_status := 'NO';
756 EXIT;
757 END IF;
758 END IF;
759
760 IF 'AML_RULE' = rev_items.attribute_code AND rev_items.attribute_number_value = 1 THEN -- AML Changes
761
762 SELECT count(*) INTO l_pending_changes_count
763 FROM ego_mfg_part_num_chgs
764 WHERE change_line_id = p_change_line_id
765 AND implmentation_date IS NULL;
766
767 IF l_pending_changes_count > 0 THEN
768 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on AML Associations.');
769 l_can_implement_status := 'NO';
770 EXIT;
771 END IF;
772 END IF;
773
774 IF 'AML_RULE' = rev_items.attribute_code AND rev_items.attribute_number_value = 2 THEN -- Related Documents Changes
775
776 SELECT count(*) INTO l_pending_changes_count
777 FROM eng_relationship_changes
778 WHERE entity_id = p_change_line_id;
779
780 IF l_pending_changes_count > 0 THEN
781 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on Related Document Changes.');
782 l_can_implement_status := 'NO';
783 EXIT;
784 END IF;
785 END IF;
786
787 IF 'STRUCTURE_TYPE' = rev_items.attribute_code THEN -- Structure Changes
788
789 l_current_attr_group_id := rev_items.attribute_number_value;
790
791 -- Check whether there are any structures created for the item with this change order ..
792 SELECT count(*) INTO l_pending_changes_count
793 FROM bom_bill_of_materials
794 WHERE assembly_item_id = l_inventory_item_id
795 AND organization_id = l_org_id
796 AND structure_type_id = l_current_attr_group_id
797 AND pending_from_ecn = ( SELECT change_notice FROM eng_engineering_changes
798 WHERE change_id in (SELECT change_id FROM eng_revised_items
799 WHERE revised_item_sequence_id = p_change_line_id));
800
801 IF l_pending_changes_count > 0 THEN
802 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on Structure Changes with structure type id ' || l_current_attr_group_id);
803 l_can_implement_status := 'NO';
804 EXIT;
805 END IF;
806
807 -- Check whether there are any component changes created for the item with this change order ..
808 SELECT count(*) INTO l_pending_changes_count
809 FROM bom_components_b comp, bom_bill_of_materials bom
810 WHERE revised_item_sequence_id = p_change_line_id
811 AND comp.implementation_date IS NULL
812 AND comp.bill_sequence_id = bom.bill_sequence_id
813 AND bom.structure_type_id = l_current_attr_group_id
814 AND comp.change_notice = ( SELECT change_notice FROM eng_engineering_changes
815 WHERE change_id in (SELECT change_id FROM eng_revised_items
816 WHERE revised_item_sequence_id = p_change_line_id));
817
818 IF l_pending_changes_count > 0 THEN
819 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on Component Changes with structure type id ' || l_current_attr_group_id);
820 l_can_implement_status := 'NO';
821 EXIT;
822 END IF;
823
824 -- Check whether there are any operations changes created for the item with this change order ..
825 SELECT count(st.structure_type_id) INTO l_pending_changes_count
826 FROM bom_operation_sequences op, eng_revised_items ri , bom_structure_types_vl st
827 WHERE op.revised_item_sequence_id = p_change_line_id
828 AND op.revised_item_sequence_id = ri.revised_item_sequence_id
829 AND op.implementation_date IS NULL
830 AND st.structure_type_id = ( SELECT bbom.structure_type_id
831 FROM bom_bill_of_materials bbom
832 WHERE bbom.bill_sequence_id = ri.bill_sequence_id )
833 AND st.structure_type_id = l_current_attr_group_id
834 AND op.change_notice = ( SELECT change_notice FROM eng_engineering_changes
835 WHERE change_id in (SELECT change_id FROM eng_revised_items
836 WHERE revised_item_sequence_id = p_change_line_id));
837
838 IF l_pending_changes_count > 0 THEN
839 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on Operations Changes with structure type id ' || l_current_attr_group_id);
840 l_can_implement_status := 'NO';
841 EXIT;
842 END IF;
843
844 END IF;
845
846 IF 'ATTACHMENT' = rev_items.attribute_code THEN -- Attachment Changes
847 l_current_attr_group_id := rev_items.attribute_number_value;
848
849 SELECT count(*) INTO l_pending_changes_count
850 FROM eng_attachment_changes
851 WHERE revised_item_sequence_id = p_change_line_id
852 AND category_id = l_current_attr_group_id; -- ?
853
854 IF l_pending_changes_count > 0 THEN
855 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Cannot Implement the Revised Item '|| l_concatenated_segments || ' because there is a change policy NOT_ALLOWED on Attachment Changes with Category type id ' || l_current_attr_group_id);
856 l_can_implement_status := 'NO';
857 EXIT;
858 END IF;
859 END IF;
860
861 END LOOP;
862
863 x_implementation_status := l_can_implement_status;
864 EXCEPTION
865 WHEN OTHERS THEN
866 x_implementation_status := 'NO';
867 RAISE abort_implementation;
868
869 END Can_Implement_Item;
870
871 -- Added procedure for bug 3402607
872 /********************************************************************
873 * API Name : LOG_IMPLEMENT_FAILURE
874 * Parameters IN : p_change_id, p_revised_item_seq_id
875 * Parameters OUT: None
876 * Purpose : Used to update the lifecycle states of the header
877 * and create a log in header Action Log if implementation fails.
878 * In case of revised item implementation failure, updates the revised
879 * item status_type
880 *********************************************************************/
881 PROCEDURE LOG_IMPLEMENT_FAILURE(p_change_id IN NUMBER
882 , p_revised_item_seq_id IN NUMBER) IS
883 l_plsql_block VARCHAR2(1000);
884 l_api_caller VARCHAR2(3) := 'CP';
885 l_msg_count NUMBER := 0;
886 l_return_status VARCHAR2(1);
887 l_msg_data VARCHAR2(2000);
888
889 -- Changes for bug 4642163
890 l_rev_item_sts_type eng_revised_items.status_type%TYPE;
891 l_plm_or_erp_change eng_engineering_changes.plm_or_erp_change%TYPE;
892
893 CURSOR c_get_rev_item_status_type
894 IS
895 SELECT ecs.status_type
896 FROM eng_change_statuses ecs, eng_revised_items eri
897 WHERE ecs.status_code = eri.status_code
898 AND eri.revised_item_sequence_id = p_revised_item_seq_id;
899
900 CURSOR c_plm_or_erp
901 IS
902 SELECT nvl(plm_or_erp_change, 'PLM') plm_or_erp
903 FROM eng_engineering_changes
904 WHERE change_id = p_change_id;
905 -- End changes for bug 4642163
906
907 BEGIN
908 -- Changes for bug 3720341
909 -- If p_revised_item_seq_id is null, then the implementation failure is
910 -- logged at the header level. Affects the status_type and change header lifecycle
911 IF (p_revised_item_seq_id IS NULL OR p_revised_item_seq_id = 0)
912 THEN
913 -- Using dynamic sql as the package has call to workflow apis which are not included in the
914 -- ENG patchset
915 l_plsql_block := 'begin ENG_CHANGE_LIFECYCLE_UTIL.Update_Lifecycle_States('
916 || 'p_api_version => 1.0 '
917 || ',p_change_id => :1 ' -- l_change_id
918 || ',p_status_code => 10 '
919 || ',p_api_caller => :2 ' -- 'CP'
920 || ',p_wf_route_id => NULL '
921 || ',p_route_status => NULL '
922 || ',x_return_status => :3 ' -- l_return_status
923 || ',x_msg_count => :4 ' -- l_msg_count
924 || ',x_msg_data => :5 );' -- l_msg_data
925 || 'end;';
926
927 EXECUTE IMMEDIATE l_plsql_block USING IN p_change_id, IN l_api_caller,
928 OUT l_return_status, OUT l_msg_count, OUT l_msg_data;
929 ELSE
930 /* IF p_revised_item_seq_id is not null, then the implementation failure is
931 logged at the revised item level. Affects the status_type (set to 10)
932 l_plsql_block := 'begin ENG_CHANGE_LIFECYCLE_UTIL.Update_RevItem_Lifecycle('
933 || 'p_api_version => 1.0 '
934 || ',p_rev_item_seq_id => :1 ' -- p_revised_item_seq_id
935 || ',p_status_type => 10 '
936 || ',p_api_caller => :2 ' -- 'CP'
937 || ',x_return_status => :3 ' -- l_return_status
938 || ',x_msg_count => :4 ' -- l_msg_count
939 || ',x_msg_data => :5 );' -- l_msg_data
940 || 'end;';
941
942 EXECUTE IMMEDIATE l_plsql_block USING IN p_revised_item_seq_id, IN l_api_caller,
943 OUT l_return_status, OUT l_msg_count, OUT l_msg_data;
944 END IF;*/
945 -- Changes for bug 4642163
946 OPEN c_plm_or_erp;
947 FETCH c_plm_or_erp INTO l_plm_or_erp_change;
948 CLOSE c_plm_or_erp;
949 -- Fetch the correct status type if it is ERP ECO else
950 -- set the status type as implementation failed
951 IF (l_plm_or_erp_change = 'PLM')
952 THEN
953 l_rev_item_sts_type := 10;
954 ELSE
955 OPEN c_get_rev_item_status_type;
956 FETCH c_get_rev_item_status_type INTO l_rev_item_sts_type;
957 CLOSE c_get_rev_item_status_type;
958 END IF;
959 -- IF p_revised_item_seq_id is not null, then the implementation failure is
960 -- logged at the revised item level. Affects the status_type (set to 10)
961 l_plsql_block := 'begin ENG_CHANGE_LIFECYCLE_UTIL.Update_RevItem_Lifecycle('
962 || 'p_api_version => 1.0 '
963 || ',p_rev_item_seq_id => :1 ' -- p_revised_item_seq_id
964 || ',p_status_type => :2 '
965 || ',p_api_caller => :3 ' -- 'CP'
966 || ',x_return_status => :4 ' -- l_return_status
967 || ',x_msg_count => :5 ' -- l_msg_count
968 || ',x_msg_data => :6 );' -- l_msg_data
969 || 'end;';
970
971 EXECUTE IMMEDIATE l_plsql_block
972 USING IN p_revised_item_seq_id
973 , IN l_rev_item_sts_type
974 , IN l_api_caller
975 , OUT l_return_status
976 , OUT l_msg_count
977 , OUT l_msg_data;
978 -- End changes for 4642163
979 END IF;
980 commit;
981 EXCEPTION
982 WHEN PLSQL_COMPILE_ERROR THEN
983 -- changes for 4642163
984 IF c_plm_or_erp%ISOPEN THEN
985 CLOSE c_plm_or_erp;
986 END IF;
987 IF c_get_rev_item_status_type%ISOPEN THEN
988 CLOSE c_get_rev_item_status_type;
989 END IF;
990 -- package is not found when called using dynamic sql
991 -- ok to proceed
992 -- null;
993 WHEN OTHERS THEN
994 -- changes for 4642163
995 IF c_plm_or_erp%ISOPEN THEN
996 CLOSE c_plm_or_erp;
997 END IF;
998 IF c_get_rev_item_status_type%ISOPEN THEN
999 CLOSE c_get_rev_item_status_type;
1000 END IF;
1001 -- Nothing is required to be done
1002 -- logging fails
1003 -- null;
1004 END LOG_IMPLEMENT_FAILURE;
1005
1006 -- ERES change begins
1007 PROCEDURE event_acknowledgement (p_event_status IN VARCHAR2) IS
1008
1009 CURSOR Get_Parent_Child_Events IS
1010 SELECT parent_event_name
1011 , parent_event_key
1012 , parent_erecord_id
1013 , event_name
1014 , event_key
1015 , erecord_id
1016 , event_status
1017 FROM eng_parent_child_events_temp;
1018
1019 l_erecord_id NUMBER;
1020 l_parent_child_count NUMBER;
1021 l_return_status VARCHAR2(2);
1022 l_msg_data VARCHAR2(240);
1023 l_msg_count NUMBER;
1024 l_dummy_cnt NUMBER;
1025 l_trans_status VARCHAR2(10);
1026 l_ackn_by VARCHAR2(200);
1027 SEND_ACKN_ERROR EXCEPTION;
1028
1029 BEGIN
1030 -- Acknowledgement part :
1031 -- for all the events raised in the process.
1032
1033 -- Get message that will be send to SEND_ACKN :
1034 FND_MESSAGE.SET_NAME('ENG', 'ENG_ERES_ACKN_ECO_IMPLEMENT');
1035 l_ackn_by := FND_MESSAGE.GET;
1036
1037 FOR my_events IN Get_Parent_Child_Events
1038 LOOP
1039
1040 IF (p_event_status = 'SUCCESS')
1041 THEN
1042 l_trans_status := 'SUCCESS';
1043 ELSE
1044 l_trans_status := 'ERROR';
1045 END IF;
1046 l_erecord_id := my_events.erecord_id;
1047 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Acknowledgement for ev_name='||my_events.event_name||', key='||my_events.event_key||', erec_id='||my_events.erecord_id||', stat='||l_trans_status);
1048
1049 IF l_erecord_id IS NOT NULL
1050 THEN
1051 -- In case of error, autonomousCommit = TRUE
1052 QA_EDR_STANDARD.SEND_ACKN
1053 ( p_api_version => 1.0
1054 , p_init_msg_list => FND_API.G_FALSE
1055 , x_return_status => l_return_status
1056 , x_msg_count => l_msg_count
1057 , x_msg_data => l_msg_data
1058 , p_event_name => my_events.event_name
1059 , p_event_key => my_events.event_key
1060 , p_erecord_id => my_events.erecord_id
1061 , p_trans_status => l_trans_status
1062 , p_ackn_by => l_ackn_by
1063 , p_ackn_note => my_events.event_name||', '||my_events.event_key
1064 , p_autonomous_commit => FND_API.G_TRUE);
1065
1066 FND_FILE.PUT_LINE(FND_FILE.LOG, 'After QA_EDR_STANDARD.SEND_ACKN msg='||l_msg_count);
1067 IF (NVL(l_return_status, FND_API.G_FALSE) <> FND_API.G_TRUE)
1068 AND (l_msg_count > 0)
1069 THEN
1070 RAISE SEND_ACKN_ERROR;
1071 END IF;
1072 END IF;
1073
1074 DELETE FROM eng_parent_child_events_temp
1075 WHERE erecord_id = my_events.erecord_id
1076 AND parent_erecord_id = my_events.parent_erecord_id;
1077
1078 -- select count(*) INTO l_parent_child_count from eng_parent_child_events_temp;
1079 -- FND_FILE.PUT_LINE(FND_FILE.LOG, 'eng_parent_child_events_temp count='||l_parent_child_count);
1080 END LOOP;
1081 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Normal end of acknowledgement part ');
1082
1083 EXCEPTION
1084 WHEN SEND_ACKN_ERROR THEN
1085 FND_MSG_PUB.Get(
1086 p_msg_index => 1,
1087 p_data => l_msg_data,
1088 p_encoded => FND_API.G_FALSE,
1089 p_msg_index_out => l_dummy_cnt);
1090 FND_FILE.PUT_LINE(FND_FILE.LOG, 'ACKN Error: '||l_msg_data);
1091
1092 WHEN OTHERS THEN
1093 l_msg_data := 'ACKN Others Error='||SQLERRM;
1094 FND_FILE.PUT_LINE(FND_FILE.LOG, l_msg_data);
1095
1096 END event_acknowledgement;
1097 -- ERES change ends
1098
1099
1100 /***********************************************************************************
1101
1102 procedure CHECK_ONHAND
1103 This procedure checks if there is any onhand qty available
1104 If onhand qty is found it returns FND_API.G_TRUE
1105
1106 arguments
1107 p_inventory_item_id :config item id
1108 p_org_id : given org id
1109 x_return_status : FND_API.G_TRUE
1110
1111 **********************************************************************************/
1112 PROCEDURE CHECK_ONHAND(
1113 p_inventory_item_id IN NUMBER,
1114 p_org_id IN NUMBER,
1115 x_return_status OUT NOCOPY VARCHAR2
1116 )
1117 IS
1118 xdummy number;
1119 BEGIN
1120 x_return_status := FND_API.G_FALSE;
1121
1122 select transaction_quantity into xdummy
1123 from mtl_onhand_quantities
1124 where inventory_item_id = p_inventory_item_id
1125 and organization_id = p_org_id
1126 and transaction_quantity > 0;
1127
1128 raise TOO_MANY_ROWS; -- single row treated as too many rows
1129
1130 EXCEPTION
1131 when no_data_found then
1132 null; -- no onhand. ok to proceed.
1133
1134 when too_many_rows then
1135 x_return_status := FND_API.G_TRUE;
1136
1137 when others then
1138 x_return_status := FND_API.G_TRUE;
1139
1140
1141 END;
1142
1143
1144
1145
1146 -- 11.5.10 changes This function checks if there is any onhand qty available
1147 --If onhand qty is found it returns 1 else 0
1148
1149 Function inv_onhand(p_item_id IN NUMBER,
1150 p_org_id IN NUMBER) RETURN NUMBER IS
1151 l_return_status VARCHAR2(1);
1152 BEGIN
1153
1154 CHECK_ONHAND(p_inventory_item_id =>p_item_id,
1155 p_org_id =>p_org_id,
1156 x_return_status =>l_return_status);
1157
1158 if (l_return_status = FND_API.G_TRUE )
1159 then
1160 return 1;
1161 else
1162 return 0;
1163 end if;
1164
1165 END;
1166
1167
1168 PROCEDURE CHANGE_ITEM_LIFECYCLE_PHASE (
1169 p_rev_item_seq_id IN NUMBER
1170 , p_organization_id IN NUMBER
1171 , p_inventory_item_id IN NUMBER
1172 , p_scheduled_date IN DATE
1173 , p_new_lifecycle_phase_id IN NUMBER
1174 , x_return_status OUT NOCOPY VARCHAR2)
1175 IS
1176
1177 l_project_id NUMBER;
1178 l_lifecycle_id NUMBER;
1179 l_lifecycle_project_id NUMBER;
1180 l_lifecycle_project_number VARCHAR2(30);
1181 l_return_status VARCHAR2(1);
1182 l_error_code NUMBER;
1183 l_msg_count NUMBER;
1184 l_msg_data VARCHAR2(4000);
1185 l_project_assoc_type VARCHAR2(24) := 'EGO_ITEM_PROJ_ASSOC_TYPE';
1186 l_lifecycle_tracking_code VARCHAR2(18) := 'LIFECYCLE_TRACKING';
1187 l_api_version VARCHAR2(3) := '1.0';
1188 l_sql_stmt VARCHAR2(1000);
1189 l_plsql_block VARCHAR2(1000);
1190 l_new_lifecycle_phase VARCHAR2(240);
1191 l_object_name VARCHAR2(30):= 'EGO_ITEM';
1192
1193 BEGIN
1194 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing lifecycle phase change .. ');
1195 l_sql_stmt := ' SELECT eip.project_id, ppa.name '
1196 || 'FROM EGO_ITEM_PROJECTS eip, PA_PROJECTS_ALL ppa '
1197 || 'WHERE eip.project_id = ppa.project_id '
1198 || 'AND eip.INVENTORY_ITEM_ID = :1 '
1199 || 'AND eip.ORGANIZATION_ID = :2 '
1200 || 'AND eip.REVISION IS NULL '
1201 || 'AND eip.ASSOCIATION_TYPE = :3 '
1202 || 'AND eip.ASSOCIATION_CODE = :4 '
1203 || 'AND ROWNUM = 1 ';
1204 BEGIN
1205 EXECUTE IMMEDIATE l_sql_stmt INTO l_lifecycle_project_id , l_lifecycle_project_number
1206 USING p_inventory_item_id, p_organization_id, l_project_assoc_type, l_lifecycle_tracking_code;
1207
1208 l_sql_stmt := ' SELECT name '
1209 || 'FROM PA_EGO_PHASES_V '
1210 || 'WHERE PROJ_ELEMENT_ID = :1; ';
1211 EXECUTE IMMEDIATE l_sql_stmt INTO l_new_lifecycle_phase
1212 USING p_new_lifecycle_phase_id;
1213
1214 /* call the Projects api */
1215 l_plsql_block := 'begin PA_PROJ_TASK_STRUC_PUB.Update_Current_Phase '
1216 || ' ( p_project_id => :1 '
1217 || ' , p_project_name => :2 '
1218 || ' , p_current_lifecycle_phase_id => :3 '
1219 || ' , p_current_lifecycle_phase => :4 '
1220 || ' , x_return_status => :5 '
1221 || ' , x_msg_count => :6 '
1222 || ' , x_msg_data => :7 '
1223 || ' ); '
1224 || 'end; ';
1225 EXECUTE IMMEDIATE l_plsql_block USING
1226 IN l_lifecycle_project_id, IN l_lifecycle_project_number, IN p_new_lifecycle_phase_id, IN l_new_lifecycle_phase,
1227 OUT l_return_status, OUT l_msg_count, OUT l_msg_data;
1228 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing lifecycle phase change for project '|| l_lifecycle_project_number || '.. ');
1229
1230 EXCEPTION
1231 WHEN NO_DATA_FOUND THEN
1232 l_sql_stmt := ' SELECT lifecycle_id '
1233 || ' FROM mtl_system_items_b '
1234 || ' WHERE inventory_item_id = :1 '
1235 || ' AND organization_id = :2 ' ;
1236
1237 BEGIN
1238 EXECUTE IMMEDIATE l_sql_stmt INTO l_lifecycle_id USING p_inventory_item_id, p_organization_id;
1239 EXCEPTION
1240 WHEN NO_DATA_FOUND THEN
1241 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Lifecycle phase change Error: No lifecycle associated to the item ');
1242 l_return_status := 'U';
1243 END;
1244 IF (l_lifecycle_id IS NOT NULL)
1245 THEN
1246 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing lifecycle phase change for item.. ');
1247
1248 /*l_plsql_block := 'begin '
1249 || 'ego_lifecycle_user_pub.Sync_Phase_Change '
1250 || '( p_api_version => :1 '
1251 || ', p_organization_id => :2 '
1252 || ', p_inventory_item_id => :3 '
1253 || ', p_revision => null '
1254 || ', p_lifecycle_id => :4 '
1255 || ', p_phase_id => :5 '
1256 || ', p_effective_date => :6 '
1257 || ', x_return_status => :7 '
1258 || ', x_errorcode => :8 '
1259 || ', x_msg_count => :9 '
1260 || ', x_msg_data => :10 '
1261 || '); '
1262 || 'end; ';
1263
1264 EXECUTE IMMEDIATE l_plsql_block USING
1265 IN l_api_version, IN p_organization_id, IN p_inventory_item_id, IN l_lifecycle_id, IN p_new_lifecycle_phase_id, IN p_scheduled_date,
1266 OUT l_return_status, OUT l_error_code,OUT l_msg_count, OUT l_msg_data;*/
1267 l_plsql_block := 'begin '
1268 || 'EGO_ITEM_LC_IMP_PC_PUB.Implement_Pending_Changes '
1269 || '( p_api_version => 1.0 '
1270 || ', p_commit => :1 '
1271 || ', p_change_id => null '
1272 || ', p_change_line_id => :2 '
1273 || ', x_return_status => :3 '
1274 || ', x_errorcode => :4 '
1275 || ', x_msg_count => :5 '
1276 || ', x_msg_data => :6 '
1277 || '); '
1278 || 'end; ';
1279
1280 EXECUTE IMMEDIATE l_plsql_block USING IN l_return_status, IN p_rev_item_seq_id,
1281 OUT l_return_status, OUT l_error_code,OUT l_msg_count, OUT l_msg_data;
1282
1283 FOR I IN 1..l_msg_count
1284 LOOP
1285 FND_FILE.PUT_LINE(FND_FILE.LOG, FND_MSG_PUB.get(I, 'F'));
1286 END LOOP;
1287
1288 END IF;
1289 END;
1290 x_return_status := l_return_status;
1291
1292 EXCEPTION
1293 WHEN OTHERS THEN
1294
1295 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Lifecycle phase change Error: ' ||SQLERRM);
1296 x_return_status := 'U';
1297
1298 END CHANGE_ITEM_LIFECYCLE_PHASE;
1299
1300 ------------------------------------------------------------------------
1301 -- R12: Changes for Common BOM Enhancement --
1302 -- Begin Private Procedures Definition --
1303 ------------------------------------------------------------------------
1304 ------------------------------------------------------------------------
1305 -- API name : Move_Pending_Dest_Components --
1306 -- Type : Private --
1307 -- Pre-reqs : None. --
1308 -- Procedure : Propagates the specified ECO --
1309 -- Parameters : --
1310 -- IN : p_src_old_comp_seq_id NUMBER Required --
1311 -- p_src_comp_seq_id NUMBER Required --
1312 -- p_change_notice vARCHAR2 Required --
1313 -- p_revised_item_sequence_id NUMBER Required --
1314 -- p_effectivity_date NUMBER Required --
1315 -- OUT : x_return_status VARCHAR2(1) --
1316 -- Version : Current version 1.0 --
1317 -- Initial version 1.0 --
1318 -- --
1319 -- Notes : This API is invoked only when a common bill has --
1320 -- pending changes associated for its WIP supply type --
1321 -- attributes and the common component in the source --
1322 -- bill is being implemented. --
1323 -- All the destination pending changes are then moved --
1324 -- to this new component with the effectivity range of --
1325 -- the component being implemented. --
1326 ------------------------------------------------------------------------
1327 PROCEDURE Move_Pending_Dest_Components (
1328 p_src_old_comp_seq_id IN NUMBER
1329 , p_src_comp_seq_id IN NUMBER
1330 , p_change_notice IN VARCHAR2
1331 , p_revised_item_sequence_id IN NUMBER
1332 , p_effectivity_date IN DATE
1333 , p_eco_for_production IN NUMBER
1334 , x_return_status OUT NOCOPY VARCHAR2
1335 ) IS
1336
1337 --
1338 -- Cursor to fetch the component being implemented wrt the detination bill
1339 -- for the change in the soruce bill
1340 --
1341 CURSOR c_related_components IS
1342 SELECT bcb.component_sequence_id, old_component_sequence_id, bill_sequence_id
1343 FROM bom_components_b bcb
1344 WHERE bcb.change_notice = p_change_notice
1345 AND bcb.revised_item_sequence_id = p_revised_item_sequence_id
1346 AND bcb.common_component_sequence_id = p_src_comp_seq_id
1347 AND bcb.common_component_sequence_id <> bcb.component_sequence_id
1348 AND bcb.implementation_date IS NULL;
1349
1350 BEGIN
1351 --
1352 -- Initialize
1353 --
1354 x_return_status := FND_API.G_RET_STS_SUCCESS;
1355 IF p_eco_for_production = 2
1356 -- Do not reset the value of old component sequence_id when only
1357 -- WIPs have to be updated and the BOM changes are to be reversed.
1358 -- This is actually done for normal bills post implemntation
1359 -- of the new component for update of the old_component_sequence_id
1360 -- Here, Doing it in one go for all the pending changes of the common
1361 -- referenced component being implemented.
1362 THEN
1363
1364 -- For each destination component record that will be implemented
1365 FOR c_dest_comp_rec IN c_related_components
1366 LOOP
1367 UPDATE bom_components_b bcb
1368 SET bcb.old_component_sequence_id = c_dest_comp_rec.component_sequence_id
1369 , bcb.common_component_sequence_id = p_src_comp_seq_id
1370 , bcb.last_update_date = sysdate
1371 , bcb.last_updated_by = FND_PROFILE.value('USER_ID')
1372 , bcb.last_update_login = FND_PROFILE.value('LOGIN_ID')
1373 , bcb.request_id = FND_PROFILE.value('REQUEST_ID')
1374 , bcb.program_application_id = FND_PROFILE.value('RESP_APPL_ID')
1375 , bcb.program_id = FND_PROFILE.value('PROGRAM_ID')
1376 , bcb.program_update_date = sysdate
1377 WHERE bcb.old_component_sequence_id = c_dest_comp_rec.old_component_sequence_id
1378 AND bcb.bill_sequence_id = c_dest_comp_rec.bill_sequence_id
1379 AND bcb.common_component_sequence_id = p_src_old_comp_seq_id
1380 AND bcb.implementation_date IS NULL
1381 -- The following exists clause is to ensure that the pending component is not a source
1382 -- referenced component but the one actually created for the destination bill itself
1383 AND EXISTS (SELECT 1 FROM eng_revised_items eri
1384 WHERE eri.revised_item_sequence_id = bcb.revised_item_sequence_id
1385 AND eri.change_notice= bcb.change_notice
1386 AND eri.bill_sequence_id = bcb.bill_sequence_id);
1387 END LOOP;
1388 ELSE
1389 -- For each destination component record that will be implemented
1390 FOR c_dest_comp_rec IN c_related_components
1391 LOOP
1392 -- set the values being updated into the global table to revert it
1393 -- when reverse standard bom is called .
1394 -- Here only common component sequence id is being updated to
1395 -- point to the new referenced component that is going to be implemented
1396 --
1397 g_common_rev_comps_cnt := g_common_rev_comps_cnt+1;
1398 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).revised_item_sequence_id := p_revised_item_sequence_id;
1399 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).dest_bill_sequence_id := c_dest_comp_rec.bill_sequence_id;
1400 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).dest_old_comp_sequence_id := c_dest_comp_rec.old_component_sequence_id;
1401 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).component_sequence_id := c_dest_comp_rec.component_sequence_id;
1402 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).common_component_sequence_id := p_src_comp_seq_id;
1403 g_Common_Rev_Comp_Tbl(g_common_rev_comps_cnt).prev_common_comp_sequence_id := p_src_old_comp_seq_id;
1404
1405 UPDATE bom_components_b bcb
1406 SET bcb.common_component_sequence_id = p_src_comp_seq_id
1407 , bcb.last_update_date = sysdate
1408 , bcb.last_updated_by = FND_PROFILE.value('USER_ID')
1409 , bcb.last_update_login = FND_PROFILE.value('LOGIN_ID')
1410 , bcb.request_id = FND_PROFILE.value('REQUEST_ID')
1411 , bcb.program_application_id = FND_PROFILE.value('RESP_APPL_ID')
1412 , bcb.program_id = FND_PROFILE.value('PROGRAM_ID')
1413 , bcb.program_update_date = sysdate
1414 WHERE bcb.old_component_sequence_id = c_dest_comp_rec.old_component_sequence_id
1415 AND bcb.bill_sequence_id = c_dest_comp_rec.bill_sequence_id
1416 AND bcb.common_component_sequence_id = p_src_old_comp_seq_id
1417 AND bcb.implementation_date IS NULL
1418 -- The following exists clause is to ensure that the pending component is not a source
1419 -- referenced component but the one actually created for the destination bill itself
1420 AND EXISTS (SELECT 1 FROM eng_revised_items eri
1421 WHERE eri.revised_item_sequence_id = bcb.revised_item_sequence_id
1422 AND eri.change_notice= bcb.change_notice
1423 AND eri.bill_sequence_id = bcb.bill_sequence_id);
1424 END LOOP;
1425 END IF;
1426 EXCEPTION
1427 WHEN OTHERS THEN
1428 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1429 END Move_Pending_Dest_Components;
1430
1431 PROCEDURE Reset_Common_Comp_Details (
1432 x_Mesg_Token_Tbl OUT NOCOPY Error_Handler.Mesg_Token_Tbl_Type
1433 , x_return_status OUT NOCOPY VARCHAR2
1434 ) IS
1435
1436 BEGIN
1437 --
1438 -- Initialize
1439 --
1440 x_return_status := FND_API.G_RET_STS_SUCCESS;
1441 -- For each component thats been
1442 FOR i IN 1..g_common_rev_comps_cnt
1443 LOOP
1444 UPDATE bom_components_b bcb
1445 SET bcb.common_component_sequence_id = g_Common_Rev_Comp_Tbl(i).prev_common_comp_sequence_id
1446 , bcb.last_update_date = sysdate
1447 , bcb.last_updated_by = FND_PROFILE.value('USER_ID')
1448 , bcb.last_update_login = FND_PROFILE.value('LOGIN_ID')
1449 , bcb.request_id = FND_PROFILE.value('REQUEST_ID')
1450 , bcb.program_application_id = FND_PROFILE.value('RESP_APPL_ID')
1451 , bcb.program_id = FND_PROFILE.value('PROGRAM_ID')
1452 , bcb.program_update_date = sysdate
1453 WHERE bcb.old_component_sequence_id = g_Common_Rev_Comp_Tbl(i).dest_old_comp_sequence_id
1454 AND bcb.bill_sequence_id = g_Common_Rev_Comp_Tbl(i).dest_bill_sequence_id
1455 AND bcb.common_component_sequence_id = g_Common_Rev_Comp_Tbl(i).common_component_sequence_id
1456 AND bcb.implementation_date IS NULL
1457 -- The following exists clause is to ensure that the pending component is not a source
1458 -- referenced component but the one actually created for the destination bill itself
1459 AND EXISTS (SELECT 1 FROM eng_revised_items eri
1460 WHERE eri.revised_item_sequence_id = bcb.revised_item_sequence_id
1461 AND eri.change_notice= bcb.change_notice
1462 AND eri.bill_sequence_id = bcb.bill_sequence_id);
1463
1464 BOMPCMBM.Update_Related_Components(
1465 p_src_comp_seq_id => g_Common_Rev_Comp_Tbl(i).prev_common_comp_sequence_id
1466 , x_Mesg_Token_Tbl => x_Mesg_Token_Tbl
1467 , x_Return_Status => x_return_status);
1468 END LOOP;
1469 EXCEPTION
1470 WHEN OTHERS THEN
1471 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1472
1473 END Reset_Common_Comp_Details;
1474
1475 --Reverting the changes introduced in bug 5285282 as part of bug 14039105
1476 -- PROCEDURE ENTER_WIP_DETAILS_FOR_COMPS
1477 -- Bug No: 5285282
1478 -- Procedure to populate the WIP_JOB_DETAILS_INTERFACE table.
1479 -- This procedure is called only if 'Update Job Only' is ticked for revised items.
1480 -- For 'Update Job Only' changes are not visible in the BOM explosion, hence to
1481 -- make these changes visible to the WIP jobs, we need to explicitly enter the
1482 -- data in the WIP interface table WIP_JOB_DETAILS_INTERFACE
1483 --
1484
1485 /*PROCEDURE ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id IN NUMBER,
1486 p_group_id IN NUMBER,
1487 p_parent_header_id IN NUMBER,
1488 p_mrp_active IN NUMBER,
1489 p_user_id IN NUMBER,
1490 p_login_id IN NUMBER,
1491 p_request_id IN NUMBER,
1492 p_program_id IN NUMBER,
1493 p_program_application_id IN NUMBER
1494 )
1495 IS
1496 CURSOR c_comps IS
1497 SELECT component_item_id,
1498 operation_seq_num,
1499 component_quantity,
1500 supply_locator_id,
1501 supply_subinventory,
1502 wip_supply_type,
1503 acd_type
1504 FROM bom_components_b
1505 WHERE revised_item_sequence_id = p_revised_item_sequence_id;
1506
1507 BEGIN
1508 FOR comp_details IN c_comps
1509 LOOP
1510 INSERT INTO WIP_JOB_DTLS_INTERFACE
1511 (created_by,
1512 creation_date,
1513 last_update_date,
1514 last_updated_by,
1515 last_update_login,
1516 request_id,
1517 program_id,
1518 program_application_id,
1519 program_update_date,
1520 group_id,
1521 load_type,
1522 parent_header_id,
1523 process_phase,
1524 process_status,
1525 substitution_type,
1526 inventory_item_id_new,
1527 inventory_item_id_old,
1528 operation_seq_num,
1529 quantity_per_assembly,
1530 supply_locator_id,
1531 supply_subinventory,
1532 wip_supply_type,
1533 mrp_net_flag)
1534 VALUES
1535 (p_user_id,
1536 sysdate,
1537 sysdate,
1538 p_user_id,
1539 p_login_id,
1540 p_request_id,
1541 p_program_id,
1542 p_program_application_id,
1543 sysdate,
1544 p_group_id,
1545 2, -- Load Type is 2 for components
1546 p_parent_header_id,
1547 2, -- process_phase 2 for validation
1548 1, -- process_status 1 for pending
1549 decode(comp_details.acd_type, 1, 2,
1550 2, 3,
1551 1), -- substitution_type 1->Delete, 2->Add, 3->Change
1552 decode(comp_details.acd_type, 1,
1553 comp_details.component_item_id, -- inventory_item_id_new populated only for component add
1554 null),
1555 decode(comp_details.acd_type, 1, -- inventory_item_id_old populated only for component change/delete
1556 null,
1557 comp_details.component_item_id),
1558 comp_details.operation_seq_num,
1559 comp_details.component_quantity,
1560 comp_details.supply_locator_id,
1561 comp_details.supply_subinventory,
1562 comp_details.wip_supply_type,
1563 p_mrp_active);
1564
1565 END LOOP;
1566 END ENTER_WIP_DETAILS_FOR_COMPS; */
1567
1568 ------------------------------------------------------------------------
1569 -- R12: Changes for Common BOM Enhancement --
1570 -- END Private Procedures Definition --
1571 ------------------------------------------------------------------------
1572
1573 Procedure implement_revised_item(
1574 revised_item in eng_revised_items.revised_item_sequence_id%type,
1575 trial_mode in number,
1576 max_messages in number, -- size of host arrays
1577 userid in number, -- user id
1578 reqstid in number, -- concurrent request id
1579 appid in number, -- application id
1580 progid in number, -- program id
1581 loginid in number, -- login id
1582 bill_sequence_id OUT NOCOPY eng_revised_items.bill_sequence_id%type ,
1583 routing_sequence_id OUT NOCOPY eng_revised_items.routing_sequence_id%type ,
1584 eco_for_production OUT NOCOPY eng_revised_items.eco_for_production%type ,
1585 revision_high_date OUT NOCOPY mtl_item_revisions.effectivity_date%type,
1586 rtg_revision_high_date OUT NOCOPY mtl_rtg_item_revisions.effectivity_date%type,
1587 update_wip OUT NOCOPY eng_revised_items.update_wip%type ,
1588 group_id1 OUT NOCOPY wip_job_schedule_interface.group_id%type,
1589 group_id2 OUT NOCOPY wip_job_schedule_interface.group_id%type,
1590 wip_job_name1 OUT NOCOPY wip_entities.wip_entity_name%type,
1591 wip_job_name2 OUT NOCOPY wip_entities.wip_entity_name%type,
1592 wip_job_name2_org_id OUT NOCOPY wip_entities.organization_id%type,
1593 message_names OUT NOCOPY NameArray,
1594 token1 OUT NOCOPY NameArray,
1595 value1 OUT NOCOPY StringArray,
1596 translate1 OUT NOCOPY BooleanArray,
1597 token2 OUT NOCOPY NameArray,
1598 value2 OUT NOCOPY StringArray,
1599 translate2 OUT NOCOPY BooleanArray,
1600 msg_qty in OUT NOCOPY binary_integer,
1601 warnings in OUT NOCOPY number,
1602 p_is_lifecycle_phase_change IN NUMBER,
1603 p_now IN DATE,
1604 p_status_code IN NUMBER)
1605 IS
1606
1607 -- ERES change begins
1608 bERES_Flag_for_BOM BOOLEAN := FALSE; -- bug 3741444.
1609 bERES_Flag_for_Routing BOOLEAN := FALSE; -- bug 3908563.
1610 l_eres_enabled VARCHAR2(10);
1611 l_child_record QA_EDR_STANDARD.ERECORD_ID_TBL_TYPE;
1612 l_event QA_EDR_STANDARD.ERES_EVENT_REC_TYPE;
1613 -- l_payload FND_WF_EVENT.PARAM_TABLE;
1614 -- ll_payload FND_WF_EVENT.PARAM_TABLE;
1615 l_msg_count NUMBER;
1616 l_msg_data VARCHAR2(2000);
1617 l_message VARCHAR2(2000);
1618 l_dummy_cnt NUMBER;
1619 l_erecord_id NUMBER;
1620 l_trans_status VARCHAR2(20);
1621 l_event_status VARCHAR2(20);
1622 i PLS_INTEGER;
1623 l_child_event_name VARCHAR2(200);
1624 l_temp_id VARCHAR2(200);
1625 l_parent_record_id NUMBER;
1626 l_pending_from_ecn VARCHAR2(10);
1627 l_alternate_designator VARCHAR2(10);
1628 l_send_ackn BOOLEAN;
1629 l_plsql_block VARCHAR2(1000);
1630 l_api_caller VARCHAR2(3) := 'CP';
1631
1632 -- Bug 6982970 vggarg declared this variable start
1633 l_base_cm_type_code eng_change_order_types.BASE_CHANGE_MGMT_TYPE_CODE%TYPE;
1634 -- Bug 6982970 vggarg end
1635
1636 l_err_tbl Error_Handler.Mesg_Token_Tbl_Type;
1637
1638
1639 -- Item Attribute and AML changes support
1640 plsql_block VARCHAR2(5000);
1641 -- Item Attribute and AML changes support
1642
1643 ERES_EVENT_ERROR EXCEPTION;
1644
1645 CURSOR Get_Bill_of_Materials_Info( bill_id IN NUMBER) IS
1646 SELECT pending_from_ecn
1647 , alternate_bom_designator
1648 FROM bom_bill_of_materials
1649 WHERE bill_sequence_id = bill_id;
1650
1651 CURSOR Get_Operational_Routing_Info( routing_id IN NUMBER) IS
1652 SELECT pending_from_ecn
1653 , alternate_routing_designator
1654 FROM bom_operational_routings
1655 WHERE routing_sequence_id = routing_id ;
1656 -- ERES change ends
1657
1658 abort_implementation exception;
1659 dummy varchar2(1);
1660 eco_rev_warning_flag varchar2(1);
1661 today date; -- implementation date
1662 now date; -- effectivity date and time
1663 eff_date date; -- effectivity date and time
1664 count_op_disable number:=0; -- count for table rev_op_disable_date_tbl
1665 count_comp_disable number:=0; -- count for table rev_comp_disable_date_tbl
1666 l_disable_date date; -- variable for disable date
1667 l_current_revision varchar2(3);
1668 l_current_rev_eff_date date;
1669 l_current_rtg_revision varchar2(3);
1670 l_current_rtg_rev_eff_date date;
1671
1672 -- Local variables for update routings
1673 l_routing_sequence_id NUMBER;
1674 l_cfm_routing_flag NUMBER;
1675 l_completion_subinventory VARCHAR2(10);
1676 l_completion_locator_id NUMBER;
1677 l_mixed_model_map_flag NUMBER;
1678 l_common_assembly_item_id NUMBER;
1679 l_common_routing_sequence_id NUMBER;
1680 l_ctp_flag NUMBER;
1681 l_priority NUMBER;
1682 l_routing_comment VARCHAR2(240);
1683 l_bom_assembly_type NUMBER;
1684
1685 l_old_disable_date date;
1686 -- Bug 5657390
1687 l_update_all_jobs NUMBER := nvl(fnd_profile.value('ENG:UPDATE_UNRELEASED_WIP_JOBS'),2);
1688
1689 -- ERES change
1690 -- odab added columns change_id, organization_code
1691 -- , organization_name, concatenated_segments, description
1692 -- last_update_date, last_updated_by, creation_date, created_by
1693 -- replaced mtl_system_items by mtl_system_items_vl
1694 -- added joint tables mtl_parameters, hr_all_organization_units_tl
1695 Cursor get_item_info is
1696 Select i.change_notice,
1697 i.change_id, -- ERES change
1698 i.organization_id,
1699 mp1.organization_code, -- ERES change
1700 hou.name organization_name, -- ERES change
1701 i.revised_item_id,
1702 si.concatenated_segments, -- ERES change
1703 si.description, -- ERES change
1704 si.bom_enabled_flag, -- Bug 5846248
1705 i.new_item_revision,
1706 i.bill_sequence_id,
1707 i.update_wip,
1708 si.pick_components_flag,
1709 si.bom_item_type, --BOM ER 9946990
1710 i.revised_item_sequence_id,
1711 i.scheduled_date,
1712 si.inventory_item_status_code,
1713 si.eng_item_flag,
1714 i.mrp_active,
1715 i.from_wip_entity_id,
1716 i.to_wip_entity_id,
1717 i.from_cum_qty,
1718 i.lot_number,
1719 i.new_routing_revision,
1720 i.routing_sequence_id,
1721 i.cfm_routing_flag,
1722 i.completion_locator_id ,
1723 i.completion_subinventory,
1724 i.mixed_model_map_flag,
1725 i.eco_for_production,
1726 i.ctp_flag,
1727 i.priority,
1728 i.routing_comment,
1729 i.designator_selection_type,
1730 i.alternate_bom_designator,
1731 i.transfer_or_copy,
1732 i.transfer_or_copy_item,
1733 i.transfer_or_copy_bill,
1734 i.transfer_or_copy_routing,
1735 i.copy_to_item,
1736 i.copy_to_item_desc,
1737 i.implemented_only,
1738 i.selection_option,
1739 i.selection_date,
1740 i.selection_unit_number, -- ERES change
1741 i.last_update_date, -- ERES change
1742 i.last_updated_by, -- ERES change
1743 i.creation_date, -- ERES change
1744 i.created_by , -- ERES change
1745 i.new_item_revision_id,
1746 i.current_item_revision_id ,
1747 i.new_lifecycle_state_id,
1748 i.use_up_item_id ,
1749 i.disposition_type,
1750 i.new_structure_revision,
1751 i.current_lifecycle_state_id,
1752 i.enable_item_in_local_org,
1753 i.from_end_item_id,
1754 i.from_end_item_rev_id
1755 from eng_revised_items i,
1756 mtl_system_items_vl si, -- ERES change
1757 mtl_parameters mp1, -- ERES change
1758 hr_all_organization_units_tl hou -- ERES change
1759 where i.revised_item_sequence_id = revised_item
1760 and si.inventory_item_id = i.revised_item_id
1761 and si.organization_id = i.organization_id
1762 AND hou.organization_id = i.organization_id
1763 AND hou.language(+) = USERENV('LANG')
1764 AND mp1.organization_id = i.organization_id
1765 for update of i.implementation_date,
1766 i.status_type,
1767 i.last_update_date,
1768 i.last_updated_by,
1769 i.last_update_login,
1770 i.request_id,
1771 i.program_application_id,
1772 i.program_id,
1773 i.program_update_date,
1774 i.status_code;
1775
1776 item get_item_info%rowtype;
1777 Cursor check_rev_item_inactive is
1778 Select 'x'
1779 from bom_parameters
1780 where organization_id = item.organization_id
1781 and bom_delete_status_code = item.inventory_item_status_code;
1782 Cursor check_for_unimp_items is
1783 Select 'x'
1784 from eng_revised_items
1785 where organization_id = item.organization_id
1786 and change_notice = item.change_notice
1787 and status_type not in
1788 (cancelled_status, implemented_status);
1789 Cursor unimplemented_rev is
1790 Select eri.new_item_revision
1791 from eng_engineering_changes eec,
1792 eng_revised_items eri
1793 where eec.change_notice = eri.change_notice
1794 and eec.organization_id = eri.organization_id
1795 and eri.organization_id = item.organization_id
1796 and eri.revised_item_id = item.revised_item_id
1797 and eec.status_type not in
1798 (cancelled_status, implemented_status)
1799 and eri.status_type not in
1800 (cancelled_status, implemented_status)
1801 and nlssort(eri.new_item_revision) <
1802 nlssort(item.new_item_revision);
1803
1804 unimp_rec unimplemented_rev%rowtype;
1805
1806 Cursor get_current_rev is
1807 Select r.revision, r.effectivity_date
1808 from mtl_item_revisions r
1809 where r.inventory_item_id = item.revised_item_id
1810 and r.organization_id = item.organization_id
1811 and r.effectivity_date = (
1812 select max(cr.effectivity_date)
1813 from mtl_item_revisions cr
1814 where cr.inventory_item_id = item.revised_item_id
1815 and cr.organization_id = item.organization_id
1816 and cr.implementation_date is not null
1817 and cr.effectivity_date <= eff_date
1818 );
1819 current_revision get_current_rev%rowtype;
1820 ----added r.effectivity_date >= eff_date for bug 5496417
1821 Cursor check_high_date_low_rev is
1822 Select 'x'
1823 from mtl_item_revisions r
1824 where r.inventory_item_id = item.revised_item_id
1825 and r.organization_id = item.organization_id
1826 and r.effectivity_date >= eff_date
1827 and r.revision < item.new_item_revision
1828 and r.implementation_date is not null;
1829
1830 -- added in 16344967, avoid invalid data are implemented by eff_date change
1831 Cursor check_same_scheduled_date is
1832 Select 'x'
1833 from eng_revised_items r1, eng_revised_items r2
1834 where r1.revised_item_id = r2.revised_item_id
1835 and r1.organization_id = r2.organization_id
1836 and r1.change_notice = r2.change_notice
1837 and r1.scheduled_date = r2.scheduled_date
1838 and r1.revised_item_sequence_id <> r2.revised_item_sequence_id
1839 and r1.new_item_revision = item.new_item_revision;
1840
1841 Cursor get_common_bills is
1842 Select b.organization_id, b.assembly_item_id,
1843 b.bill_sequence_id
1844 from bom_bill_of_materials b
1845 where b.common_assembly_item_id = item.revised_item_id
1846 and b.common_organization_id = item.organization_id
1847 AND b.source_bill_sequence_id = item.bill_sequence_id; -- R12: Common BOM changes
1848 --and b.common_bill_sequence_id = item.bill_sequence_id;
1849 common get_common_bills%rowtype;
1850 Cursor get_common_current_rev(common_assembly_item_id IN NUMBER,
1851 common_org_id IN NUMBER) is
1852 Select r.revision
1853 from mtl_item_revisions r
1854 where r.inventory_item_id = common_assembly_item_id
1855 and r.organization_id = common_org_id
1856 and r.effectivity_date = (
1857 select max(cr.effectivity_date)
1858 from mtl_item_revisions cr
1859 where cr.inventory_item_id = common_assembly_item_id
1860 and cr.organization_id = common_org_id
1861 and cr.implementation_date is not null
1862 and cr.effectivity_date <= eff_date);
1863 common_current_rev mtl_item_revisions.revision%type;
1864
1865 --* Added for Bug 4366583
1866 Cursor revision_exists(common_assembly_item_id IN NUMBER,
1867 common_org_id IN NUMBER,
1868 common_revision IN VARCHAR2) is
1869 select count(*)
1870 from mtl_item_revisions_b
1871 where inventory_item_id = common_assembly_item_id
1872 and organization_id = common_org_id
1873 and revision = common_revision;
1874 l_revision_exists NUMBER;
1875 --* End of Bug 4366583
1876
1877 Cursor chng_component_rows(cp_bill_sequence_id IN NUMBER) is
1878 Select c.component_sequence_id,
1879 f.concatenated_segments item_number,
1880 c.component_item_id,
1881 c.operation_seq_num,
1882 c.acd_type,
1883 c.quantity_related,
1884 c.component_quantity,
1885 c.old_component_sequence_id,
1886 c.disable_date,
1887 c.from_end_item_unit_number,
1888 c.to_end_item_unit_number,
1889 c.from_object_revision_id,
1890 c.to_object_revision_id,
1891 c.overlapping_changes,
1892 f.eng_item_flag,
1893 c.from_end_item_rev_id,
1894 c.to_end_item_rev_id,
1895 c.component_item_revision_id,
1896 c.obj_name,
1897 f.bom_item_type, --BOM ER 9946990
1898 f.replenish_to_order_flag, --BOM ER 9946990
1899 c.optional, --BOM ER 9946990
1900 c.component_remarks
1901 from bom_components_b c, --bom_inventory_components c,
1902 mtl_system_items_b_kfv f
1903 where c.revised_item_sequence_id = revised_item
1904 AND c.bill_sequence_id = cp_bill_sequence_id -- R12: Added for common bom changes
1905 and f.inventory_item_id = c.component_item_id
1906 and f.organization_id = item.organization_id
1907 AND c.obj_name IS NULL -- added for bom_components_b
1908 for update of c.implementation_date,
1909 c.change_notice,
1910 c.disable_date,
1911 c.from_end_item_unit_number,
1912 c.to_end_item_unit_number,
1913 c.from_object_revision_id,
1914 c.overlapping_changes,
1915 c.effectivity_date,
1916 c.last_update_date,
1917 c.last_updated_by,
1918 c.last_update_login,
1919 c.request_id,
1920 c.program_application_id,
1921 c.program_id,
1922 c.program_update_date;
1923 /*According to new where condition of this cursor union Query has commented out
1924 case 1: S1 => C1 (Q= 1 ,eff= D1) changed to S1 => C1 (Q= 10 ,eff= D1) [D1 = future date] is supported.
1925 initailly overlapping error used to come in both cases .
1926 case 2: S1 => C1(eff = D1 ,disb =D3) C1 (eff = D3 ) now make changes from C1(eff = D2 ,disb =D3) supported
1927 Initially disable adte 1 sec less than eff date was required now 1 sec gap won't be check.*/
1928
1929 Cursor check_existing_component(X_bill number, X_component number,
1930 X_operation number, X_comp_seq_id number, X_disable_date date,X_old_comp_seq_id number
1931 ,X_old_rec_disable_date date) is
1932 Select 'x' -- overlapping effectivity
1933 from bom_components_b c --bom_inventory_components c
1934 where c.bill_sequence_id = X_bill
1935 and c.component_item_id = X_component
1936 and c.operation_seq_num = X_operation
1937 and c.implementation_date is not null
1938 AND c.obj_name IS NULL -- added for bom_components_b
1939 /* Bug: 2307923 Date filter logic has been modified to prevent
1940 the duplicate creation of components through ECO */
1941 and ( (eff_date < c.effectivity_date
1942 and nvl(X_disable_date,c.effectivity_date + 1) > c.effectivity_date)
1943 or
1944 --Bug 12535300 if X_old_rec_disable_date is null and eff_date is earlier,
1945 --the following statement becomes true.
1946 --Replace c.effectivity_date in nvl(X_old_rec_disable_date...) with c.effectivity_date-1
1947 (eff_date < c.effectivity_date
1948 and nvl(X_disable_date,c.effectivity_date ) <> c.effectivity_date
1949 and nvl(X_old_rec_disable_date,c.effectivity_date-1) = c.effectivity_date ) -- Bug 12535300
1950 or
1951 /*Bug no:2867564 Eco is implementing and allowing duplicate item, and seqs. */
1952 /*and eff_date <= nvl(c.disable_date,eff_date-1)*/
1953 (eff_date > c.effectivity_date
1954 and eff_date < nvl(c.disable_date,eff_date+1) )
1955 or
1956 (eff_date = c.effectivity_date
1957 and c.component_sequence_id <> X_old_comp_seq_id
1958 and (c.disable_date <> c.effectivity_date or c.disable_date is null) ) ); --bug 12807712
1959 /*
1960 union
1961 select 'x' -- duplicate value on unique index
1962 from bom_components_b c --bom_inventory_components c
1963 where c.bill_sequence_id = X_bill
1964 and c.component_item_id = X_component
1965 and c.operation_seq_num = X_operation
1966 and c.effectivity_date = eff_date
1967 AND c.obj_name IS NULL -- added for bom_components_b
1968 and c.component_sequence_id <> X_comp_seq_id; */
1969
1970 Cursor check_existing_unit(X_bill number, X_component number,
1971 X_operation number, X_comp_seq_id number, X_from_unit_number varchar2,
1972 X_to_unit_number varchar2) is
1973 Select 'x' -- overlapping effectivity
1974 from bom_components_b c--bom_inventory_components c
1975 where c.bill_sequence_id = X_bill
1976 and c.component_item_id = X_component
1977 and c.operation_seq_num = X_operation
1978 and c.implementation_date is not null
1979 AND c.obj_name IS NULL -- added for bom_components_b
1980 and c.disable_date is NULL
1981 and (X_To_Unit_Number IS NULL
1982 or (X_To_Unit_Number >= c.from_end_item_unit_number))
1983 and ((X_From_Unit_Number <= c.to_end_item_unit_number)
1984 or c.to_end_item_unit_number IS NULL);
1985
1986 Cursor old_component(old_id number) is
1987 select o.change_notice,
1988 o.implementation_date,
1989 o.disable_date,
1990 o.effectivity_date,
1991 o.from_end_item_unit_number,
1992 o.to_end_item_unit_number,
1993 o.from_object_revision_id,
1994 o.to_object_revision_id,
1995 o.overlapping_changes,
1996 o.component_sequence_id,
1997 o.from_end_item_rev_id,
1998 o.to_end_item_rev_id
1999 FROM bom_components_b o -- bom_inventory_components o
2000 where o.component_sequence_id = old_id
2001 for update of o.change_notice,
2002 o.disable_date,
2003 o.to_object_revision_id,
2004 o.overlapping_changes,
2005 o.last_update_date,
2006 o.last_updated_by,
2007 o.last_update_login,
2008 o.request_id,
2009 o.program_application_id,
2010 o.program_id,
2011 o.program_update_date;
2012 old_comp_rec old_component%rowtype;
2013 Cursor count_ref_designators(comp_id number) is
2014 Select count(*)
2015 from bom_reference_designators r
2016 where r.component_sequence_id = comp_id
2017 and nvl(r.acd_type, acd_add) = acd_add;
2018 ref_designator_count number;
2019 X_GetInstallStatus boolean;
2020 X_InstallStatus varchar2(1) := 'N';
2021 X_Industry varchar2(1);
2022 X_prev_unit_number varchar2(30);
2023 X_UnitEff_RevItem varchar2(1) := 'N';
2024 X_new_structure_revision_id number := null;
2025 X_prev_structure_revision_id number := null;
2026
2027 -----------------------------------------------------------------
2028 -- For ECO cumulative/ECO wip job/ECO lot ---------8/2/2000----
2029 -----------------------------------------------------------------
2030 CURSOR check_job_valid_for_cum
2031 ( p_from_wip_entity_id NUMBER)
2032 IS
2033 SELECT wdj.scheduled_start_date,
2034 wdj.scheduled_completion_date,
2035 wdj.start_quantity,
2036 wdj.net_quantity,
2037 we.wip_entity_name,
2038 wdj.bom_revision,
2039 wdj.routing_revision,
2040 wdj.bom_revision_date,
2041 wdj.routing_revision_date
2042 FROM wip_discrete_jobs wdj, wip_entities we
2043 WHERE wdj.wip_entity_id = p_from_wip_entity_id
2044 AND we.wip_entity_id = wdj.wip_entity_id
2045 AND wdj.status_type = 1;
2046
2047 cum_job_rec check_job_valid_for_cum%rowtype;
2048
2049 CURSOR check_job_valid_for_job
2050 ( p_from_wip_entity_id NUMBER,
2051 p_to_wip_entity_id NUMBER,
2052 p_organization_id NUMBER,
2053 p_effective_date DATE )
2054 IS
2055 SELECT 'X'
2056 FROM DUAL
2057 WHERE EXISTS (
2058 SELECT 1
2059 FROM wip_discrete_jobs wdj,
2060 wip_entities we,
2061 wip_entities we1,
2062 wip_entities we2
2063 WHERE we1.wip_entity_id = p_from_wip_entity_id
2064 AND we2.wip_entity_id = p_to_wip_entity_id
2065 AND we.wip_entity_name >= we1.wip_entity_name
2066 AND we.wip_entity_name <= we2.wip_entity_name
2067 AND we.organization_id = p_organization_id
2068 AND wdj.wip_entity_id = we.wip_entity_id
2069 AND ( wdj.status_type <> 1
2070 OR
2071 (
2072 wdj.scheduled_start_date < p_effective_date
2073 and l_update_all_jobs = 2 -- Bug 5657390
2074 )
2075 )
2076 );
2077
2078 CURSOR check_job_valid_for_lot
2079 ( p_wip_lot_number VARCHAR2
2080 , p_effective_date DATE)
2081 IS
2082 SELECT 'X'
2083 FROM DUAL
2084 WHERE EXISTS (
2085 SELECT 1
2086 FROM wip_discrete_jobs wdj, wip_entities we
2087 WHERE wdj.lot_number = p_wip_lot_number
2088 AND wdj.wip_entity_id = we.wip_entity_id
2089 AND wdj.primary_item_id = item.revised_item_id
2090 AND wdj.organization_Id = item.organization_id
2091 AND ( status_type <> 1
2092 OR ( wdj.scheduled_start_date < p_effective_date
2093 and l_update_all_jobs = 2 ) -- Bug 5662105
2094 )
2095 );
2096
2097 CURSOR check_chng_rounting_existing( revised_item NUMBER) IS
2098 SELECT 'X'
2099 FROM bom_operation_sequences
2100 WHERE revised_item_sequence_id = revised_item;
2101
2102
2103 CURSOR chng_operation_rows IS
2104 SELECT change_notice
2105 , operation_seq_num
2106 , operation_sequence_id
2107 , old_operation_sequence_id
2108 , routing_sequence_id
2109 , acd_type
2110 , revised_item_sequence_id
2111 , disable_date
2112 , effectivity_date
2113 FROM bom_operation_sequences
2114 WHERE revised_item_sequence_id = revised_item
2115 AND change_notice = item.change_notice
2116 FOR UPDATE OF change_notice
2117 , implementation_date
2118 , old_operation_sequence_id
2119 , acd_type
2120 , revised_item_sequence_id
2121 , effectivity_date
2122 , disable_date
2123 , last_update_date
2124 , last_updated_by
2125 , last_update_login
2126 , request_id
2127 , program_application_id
2128 , program_id
2129 , program_update_date
2130 order by operation_sequence_id;
2131
2132 chng_operation_rec chng_operation_rows%rowtype;
2133
2134
2135 CURSOR check_op_seq_num_exists IS
2136 SELECT 'X'
2137 FROM bom_operation_sequences
2138 WHERE operation_sequence_id = chng_operation_rec.old_operation_sequence_id
2139 AND operation_seq_num = chng_operation_rec.operation_seq_num;
2140
2141 CURSOR unimplemented_rtg_rev
2142 IS
2143 SELECT eri.new_routing_revision
2144 FROM eng_engineering_changes eec,
2145 eng_revised_items eri
2146 WHERE eec.change_notice = eri.change_notice
2147 AND eec.organization_id = eri.organization_id
2148 AND eri.organization_id = item.organization_id
2149 AND eri.revised_item_id = item.revised_item_id
2150 AND eec.status_type NOT IN
2151 ( cancelled_status, implemented_status)
2152 AND eri.status_type NOT IN
2153 (cancelled_status, implemented_status)
2154 AND nlssort(eri.new_routing_revision) <
2155 nlssort(item.new_routing_revision);
2156
2157 unimp_ref_rec unimplemented_rtg_rev%ROWTYPE;
2158
2159 CURSOR check_highEffDate_lowRtgRev IS
2160 SELECT 'x'
2161 FROM mtl_rtg_item_revisions r
2162 WHERE r.inventory_item_id = item.revised_item_id
2163 AND r.organization_id = item.organization_id
2164 AND r.effectivity_date > eff_date
2165 AND r.process_revision < item.new_routing_revision --bug 3476154
2166 AND r.implementation_date IS NOT null;
2167
2168
2169 CURSOR get_common_routing IS
2170 SELECT r.organization_id,
2171 r.assembly_item_id,
2172 r.routing_sequence_id
2173 FROM bom_operational_routings r
2174 WHERE r.common_assembly_item_id = item.revised_item_id
2175 AND r.common_routing_sequence_id = item.routing_sequence_id;
2176
2177 common_routing get_common_routing%ROWTYPE;
2178
2179 CURSOR get_common_current_routing_rev(common_assembly_item_id IN NUMBER,
2180 common_org_id IN NUMBER) is
2181 Select r.process_revision
2182 from mtl_rtg_item_revisions r
2183 where r.inventory_item_id = common_assembly_item_id
2184 and r.organization_id = common_org_id
2185 and r.effectivity_date = (
2186 select max(cr.effectivity_date)
2187 from mtl_rtg_item_revisions cr
2188 where cr.inventory_item_id = common_assembly_item_id
2189 and cr.organization_id = common_org_id
2190 and cr.implementation_date is not null
2191 and cr.effectivity_date <= eff_date);
2192 common_current_rtg_rev mtl_rtg_item_revisions.process_revision%type;
2193
2194 --* Added for Bug 4366583
2195 Cursor routing_revision_exists(common_assembly_item_id IN NUMBER,
2196 common_org_id IN NUMBER,
2197 common_revision IN VARCHAR2) is
2198 select count(*)
2199 from mtl_rtg_item_revisions
2200 where inventory_item_id = common_assembly_item_id
2201 and organization_id = common_org_id
2202 and process_revision = common_revision;
2203 l_rtg_revision_exists NUMBER;
2204 --* End of Bug 4366583
2205
2206 CURSOR get_current_routing_rev IS
2207 SELECT r.process_revision,
2208 r.effectivity_date
2209 FROM mtl_rtg_item_revisions r
2210 WHERE r.inventory_item_id = item.revised_item_id
2211 AND r.organization_id = item.organization_id
2212 AND r.effectivity_date = (
2213 SELECT max(cr.effectivity_date)
2214 FROM mtl_rtg_item_revisions cr
2215 WHERE cr.inventory_item_id = item.revised_item_id
2216 AND cr.organization_id = item.organization_id
2217 AND cr.implementation_date is not null
2218 AND cr.effectivity_date <= eff_date);
2219
2220 current_routing_revision get_current_routing_rev%rowtype;
2221
2222 CURSOR check_not_existing_op_cum
2223 (p_from_wip_entity_id NUMBER,
2224 p_operation_seq_num NUMBER,
2225 p_organization_id NUMBER)
2226 IS
2227 SELECT 'X'
2228 FROM wip_operations o,
2229 wip_discrete_jobs w
2230 WHERE w.wip_entity_id = p_from_wip_entity_id
2231 AND w.status_type = 1
2232 AND o.wip_entity_id = w.wip_entity_id
2233 AND o.operation_seq_num = p_operation_seq_num
2234 AND o.organization_id = p_organization_id;
2235
2236 CURSOR check_not_existing_op_job
2237 ( p_from_wip_entity_id NUMBER,
2238 p_to_wip_entity_id NUMBER,
2239 p_operation_seq_num NUMBER,
2240 p_organization_id NUMBER )
2241 IS
2242 SELECT 'X'
2243 FROM DUAL
2244 WHERE EXISTS (
2245 SELECT 1
2246 FROM wip_discrete_jobs wdj,
2247 wip_entities we,
2248 wip_entities we1,
2249 wip_entities we2
2250 WHERE we1.wip_entity_id = p_from_wip_entity_id
2251 AND we2.wip_entity_id = p_to_wip_entity_id
2252 AND we.wip_entity_name >= we1.wip_entity_name
2253 AND we.wip_entity_name <= we2.wip_entity_name
2254 AND wdj.wip_entity_id = we.wip_entity_id
2255 AND we.organization_id = p_organization_id
2256 AND status_type = 1
2257 AND NOT EXISTS (
2258 SELECT 1
2259 FROM wip_operations wo
2260 WHERE wo.wip_entity_id = we.wip_entity_id
2261 AND operation_seq_num = p_operation_seq_num
2262 )
2263 );
2264
2265 CURSOR check_not_existing_op_lot
2266 ( p_wip_lot_number VARCHAR2,
2267 p_operation_seq_num NUMBER
2268 )
2269 IS
2270 SELECT 'X'
2271 FROM DUAL
2272 WHERE EXISTS (
2273 SELECT 1
2274 FROM wip_discrete_jobs wdj
2275 WHERE wdj.lot_number= p_wip_lot_number
2276 AND wdj.status_type = 1
2277 AND wdj.primary_item_id = item.revised_item_id
2278 AND wdj.organization_Id = item.organization_id
2279 AND NOT EXISTS (
2280 SELECT 1
2281 FROM wip_operations wo
2282 WHERE wo.wip_entity_id = wdj.wip_entity_id
2283 AND operation_seq_num = p_operation_seq_num
2284 )
2285 );
2286
2287 Cursor old_operation(old_id number) is
2288 select o.change_notice,
2289 o.implementation_date,
2290 o.disable_date,
2291 o.effectivity_date,
2292 o.operation_sequence_id
2293 from bom_operation_sequences o
2294 where o.operation_sequence_id = old_id
2295 for update of o.change_notice,
2296 o.disable_date,
2297 o.last_update_date,
2298 o.last_updated_by,
2299 o.last_update_login,
2300 o.request_id,
2301 o.program_application_id,
2302 o.program_id,
2303 o.program_update_date;
2304 old_op_rec old_operation%rowtype;
2305
2306 CURSOR chng_resource_rows is
2307 SELECT acd_type,
2308 operation_sequence_id,
2309 resource_seq_num,
2310 resource_id
2311 FROM bom_operation_resources
2312 WHERE operation_sequence_id= chng_operation_rec.operation_sequence_id;
2313
2314 chng_resource_rec chng_resource_rows%rowtype;
2315
2316 CURSOR check_overlapping_operation ( routing_seq_id NUMBER,
2317 operation_num NUMBER, operation_seq_id NUMBER, eff_date DATE) IS
2318 Select 'x' -- overlapping effectivity
2319 from bom_operation_sequences b
2320 where b.routing_sequence_id= routing_seq_id
2321 -- and b.operation_sequence_id = operation_seq_id
2322 and b.operation_seq_num = operation_num
2323 and b.implementation_date is not null
2324 and b.effectivity_date <= eff_date
2325 and nvl(b.disable_date, eff_date + 1) > eff_date
2326 union
2327 select 'x' -- duplicate value on unique index
2328 from bom_operation_sequences b
2329 where b.routing_sequence_id= routing_seq_id
2330 and b.operation_seq_num = operation_num
2331 and b.effectivity_date = eff_date
2332 and b.operation_sequence_id <> operation_seq_id;
2333
2334 --for resources conflict check
2335
2336 CURSOR check_not_existing_res_cum
2337 ( p_from_wip_entity_id NUMBER,
2338 p_operation_seq_num NUMBER,
2339 p_resource_seq_num NUMBER,
2340 p_organization_id NUMBER
2341 )
2342 IS
2343 SELECT 'X'
2344 FROM wip_operation_resources wor,
2345 wip_discrete_jobs w
2346 WHERE w.wip_entity_id = p_from_wip_entity_id
2347 AND w.status_type = 1
2348 AND wor.wip_entity_id = p_from_wip_entity_id
2349 AND wor.operation_seq_num = p_operation_seq_num
2350 AND wor.organization_id = p_organization_id
2351 AND wor.resource_seq_num = p_resource_seq_num;
2352
2353 CURSOR check_not_existing_res_job
2354 ( p_from_wip_entity_id NUMBER,
2355 p_to_wip_entity_id NUMBER,
2356 p_operation_seq_num NUMBER,
2357 p_resource_seq_num NUMBER,
2358 p_organization_id NUMBER
2359 )
2360 IS
2361 SELECT 'X'
2362 FROM DUAL
2363 WHERE EXISTS (
2364 SELECT 1
2365 FROM wip_discrete_jobs wdj,
2366 wip_entities we,
2367 wip_entities we1,
2368 wip_entities we2
2369 WHERE we1.wip_entity_id = p_from_wip_entity_id
2370 AND we2.wip_entity_id = p_to_wip_entity_id
2371 AND we.wip_entity_name >= we1.wip_entity_name
2372 AND we.wip_entity_name <= we2.wip_entity_name
2373 AND wdj.wip_entity_id = we.wip_entity_id
2374 AND we.organization_id = p_organization_id
2375 AND status_type = 1
2376 AND NOT EXISTS (
2377 SELECT 1
2378 FROM wip_operation_resources wor
2379 WHERE wor.wip_entity_id = we.wip_entity_id
2380 AND wor.operation_seq_num = p_operation_seq_num
2381 AND wor.resource_seq_num = p_resource_seq_num
2382 AND wor.organization_id = p_organization_id
2383 )
2384 );
2385
2386 CURSOR check_not_existing_res_lot
2387 ( p_wip_lot_number VARCHAR2,
2388 p_operation_seq_num NUMBER,
2389 p_resource_seq_num NUMBER,
2390 p_organization_id NUMBER
2391 )
2392 IS
2393 SELECT 'X'
2394 FROM DUAL
2395 WHERE EXISTS (
2396 SELECT 1
2397 FROM wip_discrete_jobs wdj
2398 WHERE wdj.lot_number= p_wip_lot_number
2399 AND wdj.primary_item_id = item.revised_item_id
2400 AND wdj.organization_Id = item.organization_id
2401 AND wdj.status_type = 1
2402 AND NOT EXISTS (
2403 SELECT 1
2404 FROM wip_operation_resources wor
2405 WHERE wor.wip_entity_id = wdj.wip_entity_id
2406 AND wor.operation_seq_num = p_operation_seq_num
2407 AND wor.resource_seq_num = p_resource_seq_num
2408 AND wor.organization_id = p_organization_id
2409 )
2410 );
2411
2412
2413 -- for components
2414 CURSOR check_not_existing_comp_cum
2415 (p_from_wip_entity_id NUMBER,
2416 p_operation_seq_num NUMBER,
2417 p_inventory_item_id NUMBER,
2418 p_organization_id NUMBER
2419 )
2420 IS
2421 SELECT 'X'
2422 FROM wip_requirement_operations ro,
2423 wip_discrete_jobs w
2424 WHERE w.wip_entity_id = p_from_wip_entity_id
2425 AND w.status_type = 1
2426 AND ro.wip_entity_id = p_from_wip_entity_id
2427 AND ro.operation_seq_num = p_operation_seq_num
2428 AND ro.organization_id = p_organization_id
2429 AND ro.inventory_item_id = p_inventory_item_id
2430 ;
2431
2432 CURSOR check_not_existing_comp_job
2433 ( p_from_wip_entity_id NUMBER,
2434 p_to_wip_entity_id NUMBER,
2435 p_operation_seq_num NUMBER,
2436 p_inventory_item_id NUMBER,
2437 p_organization_id NUMBER
2438 )
2439 IS
2440 SELECT 'X'
2441 FROM DUAL
2442 WHERE EXISTS (
2443 SELECT 1
2444 FROM wip_discrete_jobs wdj,
2445 wip_entities we,
2446 wip_entities we1,
2447 wip_entities we2
2448 WHERE we1.wip_entity_id = p_from_wip_entity_id
2449 AND we2.wip_entity_id = p_to_wip_entity_id
2450 AND we.wip_entity_name >= we1.wip_entity_name
2451 AND we.wip_entity_name <= we2.wip_entity_name
2452 AND wdj.wip_entity_id = we.wip_entity_id
2453 AND we.organization_id = p_organization_id
2454 AND status_type = 1
2455 AND NOT EXISTS (
2456 SELECT 1
2457 FROM wip_requirement_operations ro
2458 WHERE ro.wip_entity_id = we.wip_entity_id
2459 AND ro.operation_seq_num = p_operation_seq_num
2460 AND ro.inventory_item_id= p_inventory_item_id
2461 AND ro.organization_id = p_organization_id
2462 )
2463 );
2464
2465 CURSOR check_not_existing_comp_lot
2466 ( p_wip_lot_number VARCHAR2,
2467 p_operation_seq_num NUMBER,
2468 p_inventory_item_id NUMBER,
2469 p_organization_id NUMBER
2470 )
2471 IS
2472 SELECT 'X'
2473 FROM DUAL
2474 WHERE EXISTS (
2475 SELECT 1
2476 FROM wip_discrete_jobs wdj
2477 WHERE wdj.lot_number= p_wip_lot_number
2478 AND wdj.primary_item_id = item.revised_item_id
2479 AND wdj.organization_Id = item.organization_id
2480 AND wdj.status_type = 1
2481 AND NOT EXISTS (
2482 SELECT 1
2483 FROM wip_requirement_operations ro
2484 WHERE ro.wip_entity_id = wdj.wip_entity_id
2485 AND ro.operation_seq_num = p_operation_seq_num
2486 AND ro.inventory_item_id = p_inventory_item_id
2487 AND ro.organization_id = p_organization_id
2488 )
2489 );
2490
2491 -- Variables for ECO Enhancement
2492 -- l_rtg_header_rec BOM_Rtg_Pub.rtg_header_Rec_Type;
2493 -- l_rtg_header_unexp_rec BOM_Rtg_Pub.rtg_header_unexposed_Rec_Type;
2494 -- l_mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
2495 l_alternate_routing_designator VARCHAR2(10);
2496 l_return_status VARCHAR2(1);
2497
2498 -- Vairables for update wip
2499 l_wip_group_id1 NUMBER ;
2500 l_wip_group_id2 NUMBER ;
2501 l_wip_header_id NUMBER ;
2502 l_wip_organization_id NUMBER;
2503 l_wip_load_type NUMBER :=1;
2504 l_wip_status_type NUMBER :=1;
2505 l_wip_primary_item_id NUMBER;
2506 l_wip_bom_revision_date1 DATE;
2507 l_wip_routing_revision_date1 DATE;
2508 l_wip_bom_revision_date2 DATE;
2509 l_wip_routing_revision_date2 DATE;
2510 l_wip_job_name VARCHAR2(240):=NULL;
2511 l_wip_job_name1 VARCHAR2(240):=NULL;
2512 l_wip_job_name2 VARCHAR2(240):=NULL;
2513 l_wip_start_quantity1 NUMBER;
2514 l_wip_start_quantity2 NUMBER;
2515 l_wip_process_phase NUMBER :=2;
2516 l_wip_process_status NUMBER :=1;
2517 l_wip_last_u_compl_date1 DATE;
2518 l_wip_last_u_compl_date2 DATE;
2519 l_wip_completion_locator_id NUMBER;
2520 l_wip_routing_revision1 VARCHAR2(3):=NULL;
2521 l_wip_routing_revision2 VARCHAR2(3):=NULL;
2522 l_wip_bom_revision1 VARCHAR2(3):=NULL;
2523 l_wip_bom_revision2 VARCHAR2(3):=NULL;
2524 l_wip_completion_subinventory VARCHAR2(10):=NULL;
2525 l_wip_net_quantity1 NUMBER :=0;
2526 l_wip_net_quantity2 NUMBER :=0;
2527 l_wip_allow_explosion VARCHAR2(1) := 'Y';
2528 l_wip_jsi_insert_flag NUMBER :=0;
2529 l_old_op_seq_num NUMBER :=0; -- bug2722280
2530
2531 l_update_wip NUMBER;
2532 l_wip_from_cum_qty NUMBER;
2533 l_from_wip_entity_id NUMBER;
2534 l_to_wip_entity_id NUMBER;
2535 l_lot_number VARCHAR2(30):=NULL;
2536 --l_effective_date date;
2537 --l_update_all_jobs NUMBER := 2 ; Bug 5657390 declared in the beginning
2538 l_eco_for_production NUMBER := 2 ;
2539
2540 -- Bug 4455543
2541 -- Added the following flag to check if routing details have been updated
2542 -- for the revised item. Only then the routing details are set on the
2543 -- wip_job_schedules_interface. Otherwise they are not set.
2544 -- This is done so that WIP does not explode routings when there has been
2545 -- no changes for them as part of the revised item.
2546 l_WIP_Flag_for_Routing VARCHAR2(1);
2547
2548 -- for inserting rows to wip schedule interface
2549
2550 -- Cursor was added to resolve the bug 2722280
2551 CURSOR get_old_operation_seq_num
2552 ( p_old_component_sequence_id NUMBER
2553 )
2554 IS
2555
2556 SELECT operation_seq_num
2557 FROM bom_components_b --bom_inventory_components
2558 WHERE component_sequence_id = p_old_component_sequence_id ;
2559 -- Cursor completed Bug 2722280
2560
2561 CURSOR l_wip_name_for_job_cur
2562 IS
2563 SELECT we.wip_entity_name,
2564 we.organization_id,
2565 wdj.start_quantity,
2566 wdj.scheduled_start_date,
2567 wdj.scheduled_completion_date,
2568 wdj.primary_item_id,
2569 wdj.alternate_bom_designator, --2964588
2570 wdj.alternate_routing_designator, --2964588
2571 wdj.bom_revision_date,
2572 wdj.routing_revision_date,
2573 null bom_revision, -- Bug 3381547
2574 null routing_revision -- Bug 3381547
2575 FROM wip_discrete_jobs wdj,
2576 wip_entities we,
2577 wip_entities we1,
2578 wip_entities we2
2579 WHERE we1.wip_entity_id = l_from_wip_entity_id
2580 AND we2.wip_entity_id = l_to_wip_entity_id
2581 AND ( (we.wip_entity_name >= we1.wip_entity_name
2582 and we.wip_entity_name <= we2.wip_entity_name)
2583 )
2584 AND we.organization_id = l_wip_organization_id
2585 AND wdj.wip_entity_id = we.wip_entity_id
2586 AND wdj.status_type = 1
2587 AND wdj.job_type = 1 -- 2986915
2588 AND (( wdj.scheduled_start_date >= eff_date
2589 OR wdj.scheduled_completion_date >= eff_date) --1900068
2590 OR l_update_all_jobs =1) --bug 2327582.
2591 /* Modified for Bug 2883762 */
2592 UNION
2593 SELECT we.wip_entity_name,
2594 we.organization_id,
2595 wdj.start_quantity,
2596 wdj.scheduled_start_date,
2597 wdj.scheduled_completion_date,
2598 wdj.primary_item_id,
2599 wdj.alternate_bom_designator, --2964588
2600 wdj.alternate_routing_designator, --2964588
2601 wdj.bom_revision_date,
2602 wdj.routing_revision_date,
2603 wdj.bom_revision bom_revision, -- Bug 3381547
2604 wdj.routing_revision routing_revision -- Bug 3381547
2605 FROM wip_discrete_jobs wdj,
2606 wip_entities we,
2607 wip_requirement_operations o,
2608 wip_entities we1,
2609 wip_entities we2
2610 WHERE wdj.wip_entity_id = we.wip_entity_id
2611 AND we1.wip_entity_id = l_from_wip_entity_id
2612 AND we2.wip_entity_id = l_to_wip_entity_id
2613 AND ( (we.wip_entity_name >= we1.wip_entity_name
2614 and we.wip_entity_name <= we2.wip_entity_name)
2615 )
2616
2617 AND wdj.status_type = 1
2618 AND wdj.job_type = 1 -- 2986915
2619 AND (( wdj.scheduled_start_date >= eff_date
2620 or wdj.scheduled_completion_date >= eff_date ) --1900068
2621 OR l_update_all_jobs =1) --bug 2327582
2622 AND wdj.organization_id = we.organization_id
2623 AND we.organization_id = o.organization_id
2624 AND we.wip_entity_id = o.wip_entity_id
2625 AND o.inventory_item_id = l_wip_primary_item_id
2626 AND o.organization_id = l_wip_organization_id
2627 AND o.repetitive_schedule_id is NULL
2628 AND o.wip_supply_type = 6 ;
2629
2630 wip_name_for_job_rec l_wip_name_for_job_cur%ROWTYPE;
2631
2632 --commented out for bug 13059960
2633 /* CURSOR l_wip_name_for_lot_cur
2634 IS
2635 SELECT we.wip_entity_name,
2636 we.organization_id,
2637 wdj.start_quantity,
2638 wdj.scheduled_start_date,
2639 wdj.scheduled_completion_date,
2640 wdj.primary_item_id,
2641 wdj.alternate_bom_designator, --2964588
2642 wdj.alternate_routing_designator, --2964588
2643 wdj.bom_revision_date,
2644 wdj.routing_revision_date,
2645 null bom_revision, -- Bug 3381547
2646 null routing_revision -- Bug 3381547
2647 FROM wip_discrete_jobs wdj,
2648 wip_entities we,
2649 bom_bill_of_materials b --3412747
2650 WHERE we.organization_id = wdj.organization_id
2651 AND we.wip_entity_id = wdj.wip_entity_id
2652 AND wdj.status_type = 1
2653 AND wdj.job_type = 1 -- 2986915
2654 AND (( wdj.scheduled_start_date >= eff_date
2655 or wdj.scheduled_completion_date >= eff_date) --1900068
2656 OR l_update_all_jobs =1) --bug 2327582
2657 AND wdj.lot_number = l_lot_number
2658 --AND wdj.primary_item_id = item.revised_item_id --3412747
2659 AND wdj.primary_item_id = b.assembly_item_id
2660 AND wdj.organization_id = b.organization_id
2661 AND nvl(wdj.alternate_bom_designator,'NO ALTERNATE') =
2662 nvl(b.alternate_bom_designator,'NO ALTERNATE')
2663 --AND b.common_bill_sequence_id = item.bill_sequence_id
2664 AND b.source_bill_sequence_id = item.bill_sequence_id
2665 /* Modified for Bug 2883762 */
2666 /* UNION
2667 SELECT we.wip_entity_name,
2668 we.organization_id,
2669 wdj.start_quantity,
2670 wdj.scheduled_start_date,
2671 wdj.scheduled_completion_date,
2672 wdj.primary_item_id,
2673 wdj.alternate_bom_designator, --2964588
2674 wdj.alternate_routing_designator, --2964588
2675 wdj.bom_revision_date,
2676 wdj.routing_revision_date,
2677 wdj.bom_revision bom_revision, -- Bug 3381547
2678 wdj.routing_revision routing_revision -- Bug 3381547
2679 FROM wip_discrete_jobs wdj,
2680 wip_entities we,
2681 wip_requirement_operations o
2682 WHERE wdj.wip_entity_id = we.wip_entity_id
2683 AND wdj.status_type = 1
2684 AND wdj.job_type = 1 -- 2986915
2685 AND (( wdj.scheduled_start_date >= eff_date
2686 or wdj.scheduled_completion_date >= eff_date ) --1900068
2687 OR l_update_all_jobs =1) --bug 2327582
2688 AND wdj.organization_id = we.organization_id
2689 AND we.organization_id = o.organization_id
2690 AND we.wip_entity_id = o.wip_entity_id
2691 AND o.inventory_item_id = l_wip_primary_item_id
2692 AND o.organization_id = l_wip_organization_id
2693 AND o.repetitive_schedule_id is NULL
2694 AND o.wip_supply_type = 6
2695 AND wdj.lot_number = l_lot_number;
2696
2697
2698 wip_name_for_lot_rec l_wip_name_for_lot_cur%ROWTYPE; */
2699
2700 CURSOR l_wip_name_for_common_cur
2701 IS
2702 SELECT we.wip_entity_name,
2703 we.organization_id,
2704 wdj.start_quantity,
2705 wdj.scheduled_start_date,
2706 wdj.scheduled_completion_date,
2707 wdj.primary_item_id,
2708 wdj.alternate_bom_designator, --2964588
2709 wdj.alternate_routing_designator, --2964588
2710 wdj.bom_revision_date,
2711 wdj.routing_revision_date,
2712 null bom_revision, -- Bug 3381547
2713 null routing_revision -- Bug 3381547
2714 FROM wip_discrete_jobs wdj,
2715 wip_entities we,
2716 bom_bill_of_materials b --3412747
2717 WHERE we.organization_id = wdj.organization_id
2718 --WHERE we.organization_id = l_wip_organization_id
2719 AND wdj.wip_entity_id = we.wip_entity_id
2720 AND wdj.status_type = 1
2721 AND wdj.job_type = 1 -- 2986915
2722 AND (( wdj.scheduled_start_date >= eff_date
2723 or wdj.scheduled_completion_date >= eff_date ) --1900068
2724 OR l_update_all_jobs =1) --bug 2327582
2725 --AND wdj.primary_item_id = l_wip_primary_item_id --3412747
2726 AND wdj.primary_item_id = b.assembly_item_id
2727 AND wdj.organization_id = b.organization_id
2728 AND nvl(wdj.alternate_bom_designator,'NO ALTERNATE') =
2729 nvl(b.alternate_bom_designator,'NO ALTERNATE')
2730 --AND b.common_bill_sequence_id = item.bill_sequence_id
2731 AND b.source_bill_sequence_id = item.bill_sequence_id
2732 AND we.entity_type <> 5 --added for 13059960 to exlude lot based jobs
2733 AND l_lot_number IS NULL
2734 AND l_from_wip_entity_id IS NULL
2735 AND l_to_wip_entity_id IS NULL
2736 /* Modified for Bug 2883762 */
2737 UNION
2738 SELECT we.wip_entity_name,
2739 we.organization_id,
2740 wdj.start_quantity,
2741 wdj.scheduled_start_date,
2742 wdj.scheduled_completion_date,
2743 wdj.primary_item_id,
2744 wdj.alternate_bom_designator, --2964588
2745 wdj.alternate_routing_designator, --2964588
2746 wdj.bom_revision_date,
2747 wdj.routing_revision_date,
2748 wdj.bom_revision bom_revision, -- Bug 3381547
2749 wdj.routing_revision routing_revision -- Bug 3381547
2750 FROM wip_discrete_jobs wdj,
2751 wip_entities we,
2752 bom_bill_of_materials b, --3412747
2753 wip_requirement_operations o
2754 WHERE wdj.wip_entity_id = we.wip_entity_id
2755 AND wdj.status_type = 1
2756 AND wdj.job_type = 1 -- 2986915
2757 AND (( wdj.scheduled_start_date >= eff_date
2758 or wdj.scheduled_completion_date >= eff_date ) --1900068
2759 OR l_update_all_jobs =1) --bug 2327582
2760 AND wdj.organization_id = we.organization_id
2761 AND we.organization_id = o.organization_id
2762 AND we.wip_entity_id = o.wip_entity_id
2763 AND we.entity_type <> 5 --added for 13059960 to exlude lot based jobs
2764 --AND o.inventory_item_id = l_wip_primary_item_id --3412747
2765 --AND o.organization_id = l_wip_organization_id
2766 AND o.inventory_item_id = b.assembly_item_id
2767 AND o.organization_id = b.organization_id
2768 AND (nvl(wdj.alternate_bom_designator,'NO ALTERNATE') =
2769 nvl(b.alternate_bom_designator,'NO ALTERNATE')
2770 or
2771 (wdj.alternate_bom_designator is not null
2772 and
2773 b.alternate_bom_designator is null
2774 and not exists (select null
2775 from bom_bill_of_materials b2
2776 where b2.organization_id = b.organization_id
2777 and b2.assembly_item_id = b.assembly_item_id
2778 and b2.alternate_bom_designator =
2779 wdj.alternate_bom_designator)
2780 )
2781 )
2782 AND b.source_bill_sequence_id = item.bill_sequence_id -- r12 common bom changes
2783 --AND b.common_bill_sequence_id = item.bill_sequence_id
2784 AND o.repetitive_schedule_id is NULL
2785 AND o.wip_supply_type = 6
2786 /* Added for Bug 15894290 */
2787 UNION
2788 SELECT we.wip_entity_name,
2789 we.organization_id,
2790 wdj.start_quantity,
2791 wdj.scheduled_start_date,
2792 wdj.scheduled_completion_date,
2793 wdj.primary_item_id,
2794 wdj.alternate_bom_designator,
2795 wdj.alternate_routing_designator,
2796 wdj.bom_revision_date,
2797 wdj.routing_revision_date,
2798 null bom_revision,
2799 null routing_revision
2800 FROM wip_discrete_jobs wdj,
2801 wip_entities we,
2802 bom_operational_routings b
2803 WHERE we.organization_id = wdj.organization_id
2804 AND wdj.wip_entity_id = we.wip_entity_id
2805 AND wdj.status_type = 1
2806 AND wdj.job_type = 1
2807 AND (( wdj.scheduled_start_date >= eff_date
2808 or wdj.scheduled_completion_date >= eff_date )
2809 OR l_update_all_jobs =1)
2810 AND wdj.primary_item_id = b.assembly_item_id
2811 AND wdj.organization_id = b.organization_id
2812 AND nvl(wdj.alternate_routing_designator,'NO ALTERNATE') =
2813 nvl(b.alternate_routing_designator,'NO ALTERNATE')
2814 AND b.routing_sequence_id = item.routing_sequence_id
2815 AND we.entity_type <> 5
2816 AND l_lot_number IS NULL
2817 AND l_from_wip_entity_id IS NULL
2818 AND l_to_wip_entity_id IS NULL;
2819
2820 wip_name_for_common_rec l_wip_name_for_common_cur%ROWTYPE;
2821
2822 CURSOR mfgitem_already_exists(p_tomfg_item IN VARCHAR2)
2823 IS
2824 SELECT 1
2825 FROM mtl_system_items_kfv
2826 WHERE concatenated_segments = p_tomfg_item;
2827
2828 CURSOR Get_starting_revision (p_org_id IN NUMBER)
2829 IS
2830 select starting_revision
2831 from mtl_parameters where
2832 organization_id = p_org_id;
2833
2834 Cursor Check_Item(p_item_id IN NUMBER,
2835 p_org_id IN NUMBER) is
2836 Select 'x' dummy
2837 From mtl_system_items msi
2838 Where msi.inventory_item_id = p_item_id
2839 And msi.organization_id = p_org_id
2840 And msi.eng_item_flag = 'N';
2841
2842 Cursor Check_Bill(p_item_id IN NUMBER,
2843 p_org_id IN NUMBER,
2844 p_alternate IN VARCHAR2) is
2845 Select 'x' dummy
2846 From bom_bill_of_materials bbom
2847 Where bbom.assembly_item_id = p_item_id
2848 And bbom.organization_id = p_org_id
2849 And nvl(bbom.alternate_bom_designator, 'PRIMARY ALTERNATE') =
2850 nvl(p_alternate, 'PRIMARY ALTERNATE')
2851 And bbom.assembly_type = 1;
2852
2853 Cursor Check_Routing(p_item_id IN NUMBER,
2854 p_org_id IN NUMBER,
2855 p_alternate IN VARCHAR2) is
2856 Select 'x' dummy
2857 From bom_operational_routings bor
2858 Where bor.assembly_item_id = p_item_id
2859 And bor.organization_id = p_org_id
2860 And nvl(bor.alternate_routing_designator, 'PRIMARY ALTERNATE') =
2861 nvl(p_alternate, 'PRIMARY ALTERNATE')
2862 And bor.routing_type = 1;
2863
2864 l_item_revision VARCHAR2(3);
2865 l_routing_revision VARCHAR2(3);
2866 l_new_assembly_item_id NUMBER;
2867 l_concatenated_copy_segments VARCHAR2(2000);
2868
2869 TYPE SEGMENTARRAY IS table of VARCHAR2(150) index by BINARY_INTEGER;
2870
2871 copy_segments SEGMENTARRAY;
2872 l_language_code VARCHAR2(10); --Bug 2963301
2873
2874 l_impl_date DATE;
2875 l_max_scheduled_date DATE;
2876 l_implement_revised_item NUMBER := 1;
2877 l_Item_rec_in INV_ITEM_GRP.Item_Rec_Type;
2878 l_revision_rec INV_ITEM_GRP.Item_Revision_Rec_Type;
2879 l_Item_rec_out INV_ITEM_GRP.Item_Rec_Type;
2880 l_inv_return_status VARCHAR2(1);
2881 l_Error_tbl INV_ITEM_GRP.Error_Tbl_Type;
2882 l_item_lifecycle_changed NUMBER := 0;
2883 l_lc_return_status VARCHAR2(1);
2884
2885 CURSOR c_local_org_rev_items (p_change_id NUMBER,
2886 p_revised_item_sequence_id NUMBER
2887 ) IS
2888 SELECT scheduled_date, implementation_date
2889 FROM eng_revised_items
2890 WHERE revised_item_sequence_id IN
2891 (SELECT local_revised_item_sequence_id
2892 FROM eng_change_logs_vl
2893 WHERE (local_change_id, local_organization_id) IN
2894 (SELECT object_to_id1, object_to_id3 -- local_change_id, local_org_id
2895 From Eng_Change_Obj_Relationships
2896 Where object_to_name = 'ENG_CHANGE'
2897 and change_id = p_change_id
2898 And relationship_code = 'PROPAGATED_TO')
2899 AND local_change_id IS NOT NULL
2900 AND local_revised_item_sequence_id IS NOT NULL
2901 AND log_classification_code = 'PROPAGATN'
2902 AND change_id = p_change_id
2903 AND revised_item_sequence_id = p_revised_item_sequence_id
2904 AND log_type_code = 'INFO')
2905 AND status_type <> 5
2906 AND transfer_or_copy = 'O'
2907 AND parent_revised_item_seq_id IS NULL;
2908
2909 -- Fix for bug 3463308
2910 l_item_key VARCHAR2(240) := NULL;
2911 l_action_id NUMBER := NULL;
2912
2913 -- Added for bug 3482152
2914 l_curr_status_code NUMBER;
2915 l_implement_header VARCHAR2(1);
2916 l_plm_or_erp_change VARCHAR2(3);
2917 l_wf_route_id NUMBER; -- Bug 3479509
2918 l_overlap_found NUMBER;
2919
2920 -- Added For 11510+ Enhancement
2921
2922 l_effectivity_control NUMBER;
2923 l_revision_eff_bill VARCHAR2(1);
2924 l_from_rev_eff_date DATE;
2925 l_to_rev_eff_date DATE;
2926 l_old_from_rev_eff_date DATE;
2927 l_old_to_rev_eff_date DATE;
2928 l_from_revision VARCHAR2(3);
2929 l_current_end_item_revision VARCHAR2(3);
2930 l_to_revision VARCHAR2(3);
2931 l_from_end_item_id NUMBER;
2932 l_disabled_old_comp NUMBER;
2933 l_valid_from_to_revision NUMBER;
2934 l_prev_end_item_rev_id NUMBER;
2935 l_prev_end_item_eff DATE;
2936
2937 Cursor get_bill_effectivity_control (cp_bill_id NUMBER)
2938 Is
2939 SELECT effectivity_control
2940 FROM bom_structures_b
2941 WHERE bill_sequence_id = cp_bill_id;
2942
2943 Cursor check_impl_revision ( cp_revision_id NUMBER
2944 , cp_item_id NUMBER
2945 , cp_org_id NUMBER)
2946 Is
2947 select effectivity_date, revision
2948 from mtl_item_revisions_b
2949 where revision_id = cp_revision_id
2950 and inventory_item_id = cp_item_id
2951 and organization_id = cp_org_id
2952 and implementation_date is not null;
2953
2954 Cursor check_from_to_revision ( cp_from_rev_eff DATE
2955 , cp_comp_sequence_id NUMBER)
2956 Is
2957 SELECT -1
2958 FROM bom_components_b bcb
2959 where bcb.component_sequence_id = cp_comp_sequence_id
2960 AND cp_from_rev_eff >= (SELECT mirb1.effectivity_date FROM mtl_item_revisions_b mirb1
2961 WHERE mirb1.revision_id = bcb.from_end_item_rev_id)
2962 AND (bcb.to_end_item_rev_id is null
2963 OR cp_from_rev_eff <= (SELECT mirb2.effectivity_date FROM mtl_item_revisions_b mirb2
2964 WHERE mirb2.revision_id = bcb.to_end_item_rev_id)
2965 );
2966
2967 Cursor get_prev_impl_revision ( cp_item_id NUMBER
2968 , cp_org_id NUMBER
2969 , cp_effec_date DATE)
2970 Is
2971 Select mirb1.revision_id, mirb1.effectivity_date
2972 from mtl_item_revisions_b mirb1
2973 where mirb1.inventory_item_id = cp_item_id
2974 and mirb1.organization_id = cp_org_id
2975 and mirb1.effectivity_date < cp_effec_date
2976 and mirb1.implementation_date is not null
2977 and rownum < 2
2978 order by mirb1.revision desc;
2979
2980 Cursor check_existing_rev_eff_comp( cp_bill_id NUMBER
2981 , cp_component_item_id NUMBER
2982 , cp_operation_seq_num NUMBER
2983 , cp_end_item_id NUMBER
2984 , cp_org_id NUMBER
2985 , cp_from_rev_eff DATE
2986 , cp_to_rev_eff DATE)
2987 Is
2988 SELECT 1
2989 FROM bom_components_b bcb
2990 where bcb.bill_sequence_id = cp_bill_id
2991 and bcb.component_item_id = cp_component_item_id
2992 and bcb.operation_seq_num = cp_operation_seq_num
2993 and bcb.implementation_date is not null
2994 and bcb.disable_date is NULL
2995 AND EXISTS (SELECT null FROM mtl_item_revisions_b mirb1 WHERE
2996 mirb1.inventory_item_id = cp_end_item_id AND mirb1.organization_id = cp_org_id
2997 AND mirb1.revision_id = bcb.from_end_item_rev_id)
2998 AND ( cp_to_rev_eff IS NULL
2999 OR cp_to_rev_eff >= (SELECT mirb2.effectivity_date FROM mtl_item_revisions_b mirb2
3000 WHERE mirb2.revision_id = bcb.from_end_item_rev_id)
3001 )
3002 AND ( bcb.to_end_item_rev_id IS NULL
3003 OR cp_from_rev_eff <= (SELECT mirb3.effectivity_date FROM mtl_item_revisions_b mirb3
3004 WHERE mirb3.revision_id = bcb.to_end_item_rev_id)
3005 );
3006 -- End Changes: 11510+ Enhancement
3007
3008 -- Added for bug 4150069
3009 -- Cusrsor to fetch the revision given the revision id.
3010 Cursor c_get_revision (cp_revision_id NUMBER)
3011 Is
3012 select revision, implementation_date
3013 from mtl_item_revisions_b
3014 where revision_id = cp_revision_id;
3015
3016 l_revitem_from_rev mtl_item_revisions_b.revision%TYPE;
3017 l_rev_impl_date DATE;
3018 -- End Changes For bug 4150069
3019 -- Bug 4213886
3020 l_compitem_rev mtl_item_revisions_b.revision%TYPE;
3021 l_compitem_rev_impldate DATE;
3022
3023 -- R12 : Changes for common BOM
3024 CURSOR check_if_commoned_bom( cp_bill_id IN NUMBER) IS
3025 SELECT nvl(bsb.SOURCE_BILL_SEQUENCE_ID, bsb.BILL_SEQUENCE_ID) SOURCE_BILL_SEQUENCE_ID
3026 FROM bom_structures_b bsb
3027 WHERE bsb.source_bill_sequence_id = cp_bill_id
3028 AND bsb.bill_sequence_id <> bsb.source_bill_sequence_id;
3029 -- Cursor to fetch the valid value of effectivity date when the
3030 -- effectivity date is in the future.
3031 -- For common bom the component change made are to be immediately effective
3032 CURSOR get_common_bom_eff_date( cp_bill_id IN NUMBER, cp_rev_seq_id IN NUMBER ) IS
3033 SELECT bcb.effectivity_date
3034 FROM bom_components_b bcb
3035 WHERE bcb.revised_item_sequence_id = cp_rev_seq_id
3036 AND bcb.bill_sequence_id = cp_bill_id
3037 AND EXISTS
3038 (SELECT 1
3039 FROM bom_structures_b bsb
3040 WHERE bsb.bill_sequence_id = cp_bill_id
3041 AND bsb.bill_sequence_id <> bsb.source_bill_sequence_id)
3042 AND ROWNUM < 2;
3043
3044 commoned_bom check_if_commoned_bom%rowtype;
3045 l_common_bom_eff_date DATE;
3046 l_comn_return_status VARCHAR2(1);
3047 l_comn_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
3048 -- R12 : End Changes for common BOM
3049
3050 -- Bug 4584490 : Changes for BOM Business Events
3051 l_Comp_Child_Entity_Modified NUMBER;
3052 l_BOMEvents_Comps_ACD NUMBER;
3053 l_BOMEvents_Bill_Event_Name VARCHAR2(240);
3054 CURSOR c_Comp_Child_Entity_Modified(cp_component_sequence_id IN NUMBER)
3055 IS
3056 SELECT 1 FROM dual
3057 WHERE EXISTS (SELECT 1 FROM bom_substitute_components
3058 WHERE component_sequence_id = cp_component_sequence_id
3059 AND acd_type IS NOT NULL)
3060 OR EXISTS (SELECT 1 FROM bom_substitute_components
3061 WHERE component_sequence_id = cp_component_sequence_id
3062 AND acd_type IS NOT NULL);
3063 -- End Changes for bug 4584490
3064
3065 -- Bug 5854437 Start
3066 rec_exist NUMBER := 0;
3067 l_error_msg_count NUMBER := 0;
3068
3069 Cursor chng_sub_component_rows is
3070 SELECT a.component_sequence_id,
3071 b.old_component_sequence_id,
3072 a.acd_type,
3073 a.substitute_component_id,
3074 f.concatenated_segments item_number
3075 FROM bom_substitute_components a,
3076 bom_inventory_components b,
3077 mtl_system_items_b_kfv f
3078 WHERE a.component_sequence_id = b.component_sequence_id
3079 and b.revised_item_sequence_id = revised_item
3080 and f.inventory_item_id = a.substitute_component_id
3081 -- and f.organization_id = item.organization_id
3082 and f.organization_id = b.pk2_value
3083 and nvl(a.acd_type,acd_add) = acd_add;
3084
3085 Cursor check_existing_substitutes(X_old_comp_seq_id number,X_sub_comp_id number,X_change_notice varchar2) is
3086 select 'x'
3087 from bom_substitute_components a, bom_inventory_components b
3088 where a.component_sequence_id = b.component_sequence_id
3089 and b.component_sequence_id = X_old_comp_seq_id
3090 and nvl(a.acd_type, acd_add) = acd_add
3091 and b.change_notice = X_change_notice
3092 and a.substitute_component_id = X_sub_comp_id;
3093 -- Bug 5854437 End
3094
3095 Begin
3096
3097 msg_qty := 0;
3098 warnings := 0;
3099 rev_op_disable_date_tbl.delete;
3100 rev_comp_disable_date_tbl.delete;
3101
3102 -- Bug 4455543: Initialize l_WIP_Flag_for_Routing
3103 l_WIP_Flag_for_Routing := 'N';
3104 --
3105
3106 -- Get item information
3107 Open get_item_info;
3108 Fetch get_item_info into item;
3109
3110 /* -- changed for bug 2827313
3111 Select trunc(sysdate, 'MI')
3112 into now
3113 from dual;
3114 today := trunc(now, 'DD');
3115 */
3116 now := p_now;
3117 today := now;
3118
3119 --Code changes for bug 5846248 starts
3120 --If this is a transfer operation (or copy operation also--)
3121 IF (Nvl(item.transfer_or_copy,'N') = 'T' OR Nvl(item.transfer_or_copy,'N') = 'C') THEN
3122 BEGIN
3123 IF(item.bom_enabled_flag = 'N' ) THEN
3124 -- The user cannot try to transfer/copy a bill or routings when the bom_enabled flag of the item is false..
3125 IF( item.transfer_or_copy_bill = 1 OR item.transfer_or_copy_routing = 1) THEN
3126
3127 msg_qty := msg_qty + 1;
3128 message_names(msg_qty) :=
3129 'ENG_CANNOT_TRANSFER_OR_COPY';
3130 token1(msg_qty) := 'ITEM_NAME';
3131 value1(msg_qty) := item.concatenated_segments;
3132 translate1(msg_qty) := 0;
3133 IF trial_mode = no THEN
3134 Raise abort_implementation;
3135 END IF;
3136
3137 END IF;
3138 END IF;
3139 END;
3140 END IF;
3141
3142
3143 --bug 13418011 begin
3144 IF (Nvl(item.transfer_or_copy,'N') = 'T') THEN
3145 declare
3146 l_no_del_groups number;
3147 begin
3148 IF( item.transfer_or_copy_item =1 OR item.transfer_or_copy_bill = 1 OR item.transfer_or_copy_routing = 1) THEN
3149 select count(*) into l_no_del_groups from dual where exists
3150 (select 1 from bom_delete_entities where delete_status_type <> 4 and inventory_item_id = item.revised_item_id and organization_id = item.organization_id);
3151 if (l_no_del_groups > 0) then
3152 msg_qty := msg_qty + 1;
3153 message_names(msg_qty) := 'ENG_TRANSFER_PENDING_DG';
3154 token1(msg_qty) := 'ITEM_NAME';
3155 value1(msg_qty) := item.concatenated_segments;
3156 translate1(msg_qty) := 0;
3157 IF trial_mode = no THEN
3158 Raise abort_implementation;
3159 END IF;
3160 END IF;
3161 END IF;
3162 END;
3163 END IF;
3164 --bug 13418011
3165
3166 IF (Nvl(item.transfer_or_copy,'N') = 'T' OR Nvl(item.transfer_or_copy,'N') = 'C') THEN
3167 DECLARE
3168 l_no_bom_dis_comps NUMBER;
3169 l_no_bom_dis_sub_comps NUMBER;
3170 BEGIN
3171
3172 IF(item.transfer_or_copy_bill = 1 OR item.transfer_or_copy_routing = 1) then
3173 IF(item.implemented_only = 1) THEN
3174 --if it's implemented only then check if it's already implemented or going to be implemented as a part of this change...
3175 select count(*) into l_no_bom_dis_comps from dual where exists(
3176 select 1 from mtl_system_items_b where inventory_item_id in
3177 (
3178 select COMPONENT_ITEM_ID from bom_components_b WHERE bill_sequence_id IN
3179 (
3180 select bill_sequence_id from bom_bill_of_materials where
3181 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3182 ORGANIZATION_ID = item.organization_id AND
3183 (
3184 (item.designator_selection_type = 1) --select everything
3185 OR (item.designator_selection_type =2 AND ALTERNATE_BOM_DESIGNATOR IS NULL) --select only primary BOM
3186 OR (item.designator_selection_type = 3 AND ALTERNATE_BOM_DESIGNATOR = item.alternate_bom_designator) --select that particular BOM
3187 )
3188 )
3189 /*Bugfix 13964773: Checking for bom_enabled_flag depending on the value of field
3190 selection_option. Consider the following scenario:
3191 t-assy1
3192 .t-item1 disable_date: 19-APR-2012 23:00:00
3193 .t-item2 disable_date: null
3194
3195 Component t-item1 doesn't have the bom_enabled_flag set in Item Master.
3196
3197 While implementing an ECO for this assembly, the value of the field selection_option
3198 was not considered. This field has 3 values: 'All', 'Current' and 'Future and Current'.
3199 This sql picks up t-item1 without regard to the disable date value.
3200 */
3201 AND
3202 ( item.selection_option = 1
3203 OR (item.selection_option = 2 AND effectivity_date <= item.selection_date AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3204 OR (item.selection_option = 3 AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3205 )
3206 AND (CHANGE_NOTICE IS NULL OR IMPLEMENTATION_DATE IS NOT NULL OR revised_item_sequence_id = revised_item)
3207 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3208 );
3209 ELSE
3210 -- If implemented only is not set then check everything even other pending ECOS
3211 select count(*) into l_no_bom_dis_comps from dual where exists(
3212 select 1 from mtl_system_items_b where inventory_item_id in
3213 (
3214 select COMPONENT_ITEM_ID from bom_components_b WHERE bill_sequence_id IN
3215 (
3216 select bill_sequence_id from bom_bill_of_materials where
3217 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3218 ORGANIZATION_ID = item.organization_id AND
3219 (
3220 (item.designator_selection_type = 1) --select everything
3221 OR (item.designator_selection_type =2 AND ALTERNATE_BOM_DESIGNATOR IS NULL) --select only primary BOM
3222 OR (item.designator_selection_type = 3 AND ALTERNATE_BOM_DESIGNATOR = item.alternate_bom_designator) --select that particular BOM
3223 )
3224 )
3225 /*Bugfix 13964773: Checking for bom_enabled_flag depending on the value of field
3226 selection_option. Consider the following scenario:
3227 t-assy1
3228 .t-item1 disable_date: 19-APR-2012 23:00:00
3229 .t-item2 disable_date: null
3230
3231 Component t-item1 doesn't have the bom_enabled_flag set in Item Master.
3232
3233 While implementing an ECO for this assembly, the value of the field selection_option
3234 was not considered. This field has 3 values: 'All', 'Current' and 'Future and Current'.
3235 This sql picks up t-item1 without regard to the disable date value.
3236 */
3237 AND
3238 ( item.selection_option = 1
3239 OR (item.selection_option = 2 AND effectivity_date <= item.selection_date AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3240 OR (item.selection_option = 3 AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3241 )
3242 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3243 );
3244 END IF;
3245
3246 -- throw error if l_no_bom_dis_comps is greater than 0
3247 IF(l_no_bom_dis_comps >0) THEN
3248 msg_qty := msg_qty + 1;
3249 message_names(msg_qty) :=
3250 'ENG_COMP_NOT_BOM_ENABLED';
3251 token1(msg_qty) := 'OPERATION_NAME';
3252 value1(msg_qty) := 'Implement';
3253 translate1(msg_qty) := 0;
3254 token2(msg_qty) := 'RI_NAME';
3255 value2(msg_qty) := item.concatenated_segments;
3256 translate2(msg_qty) := 0;
3257 translate2(msg_qty) := 0;
3258 IF trial_mode = no THEN
3259 Raise abort_implementation;
3260 END IF;
3261 END IF;
3262
3263
3264 --Get all the sub components for which bom_enabled_flag is false...
3265 IF(item.implemented_only = 1) THEN
3266 select count(*) into l_no_bom_dis_sub_comps from dual where exists(
3267 select 1 from mtl_system_items_b WHERE inventory_item_id IN
3268 (
3269 --Get all the sub components for all the components for this item
3270 select SUBSTITUTE_COMPONENT_ID from bom_substitute_components where COMPONENT_SEQUENCE_ID in(
3271 -- Get all the components for this item
3272 select COMPONENT_SEQUENCE_ID from bom_components_b WHERE bill_sequence_id IN
3273 (
3274 select bill_sequence_id from bom_bill_of_materials where
3275 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3276 ORGANIZATION_ID = item.organization_id AND
3277 (
3278 (item.designator_selection_type = 1) --select everything
3279 OR (item.designator_selection_type =2 AND ALTERNATE_BOM_DESIGNATOR IS NULL) --select only primary BOM
3280 OR (item.designator_selection_type = 3 AND ALTERNATE_BOM_DESIGNATOR = item.alternate_bom_designator) --select that particular BOM
3281 )
3282
3283 ) AND (CHANGE_NOTICE IS NULL OR IMPLEMENTATION_DATE IS NOT NULL OR revised_item_sequence_id = revised_item)
3284 /*Bugfix 13964773: Checking for bom_enabled_flag depending on the value of field
3285 selection_option. Consider the following scenario:
3286 t-assy1
3287 .t-item1 disable_date: 19-APR-2012 23:00:00
3288 .t-item2 disable_date: null
3289
3290 Component t-item1 doesn't have the bom_enabled_flag set in Item Master.
3291
3292 While implementing an ECO for this assembly, the value of the field selection_option
3293 was not considered. This field has 3 values: 'All', 'Current' and 'Future and Current'.
3294 This sql picks up t-item1 without regard to the disable date value.
3295 */
3296 AND
3297 ( item.selection_option = 1
3298 OR (item.selection_option = 2 AND effectivity_date <= item.selection_date AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3299 OR (item.selection_option = 3 AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3300 )
3301 )
3302 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3303 );
3304 ELSE
3305 select count(*) into l_no_bom_dis_sub_comps from dual where exists(
3306 select 1 from mtl_system_items_b WHERE inventory_item_id IN
3307 (
3308 --Get all the sub components for all the components for this item
3309 select SUBSTITUTE_COMPONENT_ID from bom_substitute_components where COMPONENT_SEQUENCE_ID in(
3310 -- Get all the components for this item
3311 select COMPONENT_SEQUENCE_ID from bom_components_b WHERE bill_sequence_id IN
3312 (
3313 select bill_sequence_id from bom_bill_of_materials where
3314 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3315 ORGANIZATION_ID = item.organization_id AND
3316 (
3317 (item.designator_selection_type = 1) --select everything
3318 OR (item.designator_selection_type =2 AND ALTERNATE_BOM_DESIGNATOR IS NULL) --select only primary BOM
3319 OR (item.designator_selection_type = 3 AND ALTERNATE_BOM_DESIGNATOR = item.alternate_bom_designator) --select that particular BOM
3320 )
3321 )
3322 /*Bugfix 13964773: Checking for bom_enabled_flag depending on the value of field
3323 selection_option. Consider the following scenario:
3324 t-assy1
3325 .t-item1 disable_date: 19-APR-2012 23:00:00
3326 .t-item2 disable_date: null
3327
3328 Component t-item1 doesn't have the bom_enabled_flag set in Item Master.
3329
3330 While implementing an ECO for this assembly, the value of the field selection_option
3331 was not considered. This field has 3 values: 'All', 'Current' and 'Future and Current'.
3332 This sql picks up t-item1 without regard to the disable date value.
3333 */
3334 AND
3335 ( item.selection_option = 1
3336 OR (item.selection_option = 2 AND effectivity_date <= item.selection_date AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3337 OR (item.selection_option = 3 AND Nvl(disable_date, item.selection_date + 1) > item.selection_date)
3338 )
3339 )
3340 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3341 );
3342
3343 END IF;
3344
3345 -- throw error if l_no_bom_dis_sub_comps is greater than 0..
3346 IF(l_no_bom_dis_sub_comps > 0 ) THEN
3347 msg_qty := msg_qty + 1;
3348 message_names(msg_qty) :=
3349 'ENG_SUB_COMP_NOT_BOM_ENABLED';
3350 token1(msg_qty) := 'OPERATION_NAME';
3351 value1(msg_qty) := 'Implement';
3352 translate1(msg_qty) := 0;
3353 token2(msg_qty) := 'RI_NAME';
3354 value2(msg_qty) := item.concatenated_segments;
3355 translate2(msg_qty) := 0;
3356 translate2(msg_qty) := 0;
3357 IF trial_mode = no THEN
3358 Raise abort_implementation;
3359 END IF;
3360 END IF;
3361 END IF;
3362 END;
3363 END IF;
3364
3365
3366 IF (Nvl(item.transfer_or_copy,'N') <> 'T' AND Nvl(item.transfer_or_copy,'N') <> 'C') THEN
3367 -- This is not transfer or copy...
3368 IF(item.bom_enabled_flag = 'N') THEN
3369 --check if there are any components for this tiem
3370 -- bug 5846248
3371 --If bom_enabled_flag is false.. there should be no components or sub components for this revised item...
3372
3373 DECLARE
3374 l_no_components NUMBER;
3375 l_no_operations NUMBER;
3376 BEGIN
3377 --Note that in implementation we check only if there are any compoenents. Empty BOMs will be implemented
3378 --This is done because.. BOMs are created the first item we add a component in ECO.. but there is no way
3379 -- to delete that BOM, if the user wants to implement it by deleting the components and proceeding with other
3380 -- changes...
3381 SELECT Count(*) INTO l_no_components FROM dual WHERE EXISTS(
3382 select 1 from bom_components_b where bill_sequence_id in
3383 (
3384 select bill_sequence_id from bom_bill_of_materials where
3385 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3386 ORGANIZATION_ID = item.organization_id
3387 ) AND revised_item_sequence_id = revised_item AND acd_type <> acd_delete
3388 );
3389
3390 IF(l_no_components <> 0) THEN
3391 msg_qty := msg_qty + 1;
3392 message_names(msg_qty) :=
3393 'ENG_RI_NOT_BOM_ENABLED_COMP';
3394 token1(msg_qty) := 'OPERATION_NAME';
3395 value1(msg_qty) := 'Implement';
3396 translate1(msg_qty) := 0;
3397 token2(msg_qty) := 'RI_NAME';
3398 value2(msg_qty) := item.concatenated_segments;
3399 translate2(msg_qty) := 0;
3400 IF trial_mode = no THEN
3401 Raise abort_implementation;
3402 END IF;
3403 -- Need not code for substitute components in this flow because if there are components itself we are throwing an error
3404 -- so there is not way that there are substitute components, if we pass this condition
3405 END IF;
3406
3407 --Check if there are any operations for this item ..
3408 --Again, we allow empty routings to get implemented for the same reason for which we allowe empty BOMs
3409 SELECT Count(*) INTO l_no_operations FROM dual WHERE EXISTS(
3410 select 1 FROM bom_operation_sequences WHERE routing_sequence_id IN
3411 (
3412 SELECT routing_sequence_id FROM BOM_OPERATIONAL_ROUTINGS WHERE
3413 ASSEMBLY_ITEM_ID = item.revised_item_id and
3414 ORGANIZATION_ID = item.organization_id
3415 ) AND revised_item_sequence_id = item.revised_item_sequence_id AND acd_type <> acd_delete
3416 );
3417
3418 IF(l_no_operations <> 0) THEN
3419 msg_qty := msg_qty + 1;
3420 message_names(msg_qty) :=
3421 'ENG_RI_NOT_BOM_ENABLED_ROUT';
3422 token1(msg_qty) := 'OPERATION_NAME';
3423 value1(msg_qty) := 'Implement';
3424 translate1(msg_qty) := 0;
3425 token2(msg_qty) := 'RI_NAME';
3426 value2(msg_qty) := item.concatenated_segments;
3427 translate2(msg_qty) := 0;
3428 translate2(msg_qty) := 0;
3429 IF trial_mode = no THEN
3430 Raise abort_implementation;
3431 END IF;
3432 end if;
3433 END;
3434 END IF;
3435 -- bug 5846248
3436 -- for any one of the components or substitue components have bom_enabled_flag as 'N' then throw an error,
3437 -- even if the bom_enabled_flag of this revised item is 'Y'
3438
3439 DECLARE
3440
3441 no_bom_disabled_comps NUMBER;
3442 no_bom_disabled_sub_comps NUMBER;
3443 BEGIN
3444 --Check if there is atleast one component such that it's bom_enabled_flag is false for this Revised Item
3445 SELECT Count(*) INTO no_bom_disabled_comps FROM dual WHERE EXISTS(
3446 select 1 from mtl_system_items_b where inventory_item_id in
3447 (
3448 select COMPONENT_ITEM_ID from bom_components_b WHERE bill_sequence_id IN
3449 (
3450 select bill_sequence_id from bom_bill_of_materials where
3451 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3452 ORGANIZATION_ID = item.organization_id
3453 )
3454 AND revised_item_sequence_id = revised_item AND acd_type <> acd_delete
3455 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3456 );
3457
3458
3459 IF( no_bom_disabled_comps <> 0) THEN
3460 msg_qty := msg_qty + 1;
3461 message_names(msg_qty) :=
3462 'ENG_COMP_NOT_BOM_ENABLED';
3463 token1(msg_qty) := 'OPERATION_NAME';
3464 value1(msg_qty) := 'Implement';
3465 translate1(msg_qty) := 0;
3466 token2(msg_qty) := 'RI_NAME';
3467 value2(msg_qty) := item.concatenated_segments;
3468 translate2(msg_qty) := 0;
3469 translate2(msg_qty) := 0;
3470 IF trial_mode = no THEN
3471 Raise abort_implementation;
3472 END IF;
3473 END IF;
3474
3475 --Check if there is atleast one sub component such that it's bom_enabled_flag is false for this Revised Item
3476 SELECT Count(*) INTO no_bom_disabled_sub_comps FROM dual WHERE EXISTS(
3477 select 1 from mtl_system_items_b WHERE inventory_item_id IN
3478 (
3479 --Get all the sub components for all the components for this item
3480 select SUBSTITUTE_COMPONENT_ID from bom_substitute_components where COMPONENT_SEQUENCE_ID in(
3481 -- Get all the components for this item
3482 select COMPONENT_SEQUENCE_ID from bom_components_b WHERE bill_sequence_id IN
3483 (
3484 select bill_sequence_id from bom_bill_of_materials where
3485 ASSEMBLY_ITEM_ID = item.revised_item_id AND
3486 ORGANIZATION_ID = item.organization_id
3487 ) AND revised_item_sequence_id = revised_item AND acd_type <> acd_delete
3488 ) AND acd_type <> acd_delete
3489 ) and organization_id = item.organization_id and bom_enabled_flag = 'N'
3490 );
3491
3492 IF( no_bom_disabled_sub_comps <> 0) THEN
3493 msg_qty := msg_qty + 1;
3494 message_names(msg_qty) :=
3495 'ENG_SUB_COMP_NOT_BOM_ENABLED';
3496 token1(msg_qty) := 'OPERATION_NAME';
3497 value1(msg_qty) := 'Implement';
3498 translate1(msg_qty) := 0;
3499 token2(msg_qty) := 'RI_NAME';
3500 value2(msg_qty) := item.concatenated_segments;
3501 translate2(msg_qty) := 0;
3502 translate2(msg_qty) := 0;
3503 IF trial_mode = no then
3504 Raise abort_implementation;
3505 END IF;
3506 END IF;
3507 END;
3508 END IF;
3509
3510 --Code changes for bug 5846248 ends
3511
3512 --Code changes for Enhancement 6084027 start, update description while implementing the Co
3513 DECLARE
3514 l_new_description mtl_system_items_b.description%TYPE;
3515 BEGIN
3516 -- Get the new description from the eng_revised_items table
3517 -- check if the value is not null
3518 -- update the production if this value is not null
3519 -- Note: If the ECO fails these changes will be rollbacked automatically..
3520
3521 --commented out the below select statement for bug 9238945
3522 --SELECT new_item_description INTO l_new_description FROM eng_revised_items WHERE revised_item_sequence_id = item.revised_item_sequence_id;
3523
3524 IF (l_new_description IS NOT NULL) THEN
3525 UPDATE mtl_system_items_tl SET description = l_new_description WHERE inventory_item_id = item.revised_item_id AND
3526 organization_id = item.organization_id AND source_lang = UserEnv('LANG');
3527 END IF;
3528 END;
3529 --Code changes for Enhancement 6084027 ends
3530
3531
3532 -- ERES change begins
3533 -- First Get the parent event details (ECO Implementation)
3534 -- If the call fails or returns and error, the exception is not catched.
3535 l_eres_enabled := FND_PROFILE.VALUE('EDR_ERES_ENABLED');
3536 IF ( NVL( l_eres_enabled, 'N') = 'Y')
3537 THEN
3538 QA_EDR_STANDARD.GET_ERECORD_ID
3539 ( p_api_version => 1.0
3540 , p_init_msg_list => FND_API.G_TRUE
3541 , x_return_status => l_return_status
3542 , x_msg_count => l_msg_count
3543 , x_msg_data => l_msg_data
3544 , p_event_name => 'oracle.apps.eng.ecoImplement'
3545 , p_event_key => TO_CHAR(item.change_id)
3546 , x_erecord_id => l_parent_record_id);
3547
3548 -- When MassChangeBill, then an ECO Create is created.
3549 -- So, when procedure implement_revised_item is called,
3550 -- there is either an ECO implement event,
3551 -- or an ECO Create event created before.
3552 IF (l_parent_record_id IS NULL)
3553 THEN
3554 QA_EDR_STANDARD.GET_ERECORD_ID
3555 ( p_api_version => 1.0
3556 , p_init_msg_list => FND_API.G_TRUE
3557 , x_return_status => l_return_status
3558 , x_msg_count => l_msg_count
3559 , x_msg_data => l_msg_data
3560 , p_event_name => 'oracle.apps.eng.ecoCreate'
3561 , p_event_key => TO_CHAR(item.change_id)
3562 , x_erecord_id => l_parent_record_id);
3563 END IF;
3564
3565 FND_FILE.PUT_LINE(FND_FILE.LOG, 'in Implement Revised Item. After Getting Parent Id, parent_erecord_id='||l_parent_record_id||', msg_cnt='||l_msg_count);
3566 ELSE
3567 -- set the value to N in case it is NULL.
3568 l_eres_enabled := 'N';
3569 END IF;
3570 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Info: EDR_ERES_ENABLED='||l_eres_enabled);
3571
3572 -- ERES change ends
3573
3574 IF (Nvl(item.transfer_or_copy,'N') = 'T' OR Nvl(item.transfer_or_copy,'N') = 'C') -- Check for Transfer/Copy OR Revised Item Change
3575 THEN
3576
3577 l_item_revision := item.new_item_revision;
3578 l_routing_revision := item.new_routing_revision;
3579 l_new_assembly_item_id := item.revised_item_id;
3580
3581 FOR i IN 1..20
3582 LOOP
3583 copy_segments(i) := Null;
3584 END LOOP;
3585
3586 IF item.transfer_or_copy = 'C' THEN
3587 /* Check for the non existence of mfg item before copy */
3588 FOR r1 IN mfgitem_already_exists(item.copy_to_item)
3589 LOOP
3590 IF msg_qty < max_messages then
3591 msg_qty := msg_qty + 1;
3592 message_names(msg_qty) :=
3593 'ENG_COPYTO_MFGITEM_EXISTS';
3594 token1(msg_qty) := null;
3595 value1(msg_qty) := null;
3596 translate1(msg_qty) := 0;
3597 token2(msg_qty) := null;
3598 value2(msg_qty) := null;
3599 translate2(msg_qty) := 0;
3600 END IF;
3601 IF trial_mode = no then
3602 Raise abort_implementation;
3603 END IF;
3604 END LOOP;
3605
3606 IF l_item_revision IS NULL
3607 THEN
3608 FOR r1 IN get_starting_revision(item.organization_id)
3609 LOOP
3610 l_item_revision := r1.starting_revision;
3611 END LOOP;
3612 END IF;
3613
3614 IF l_routing_revision IS NULL
3615 THEN
3616 FOR r1 IN get_starting_revision(item.organization_id)
3617 LOOP
3618 l_routing_revision := r1.starting_revision;
3619 END LOOP;
3620 END IF;
3621
3622 SELECT mtl_system_items_s.NEXTVAL INTO l_new_assembly_item_id FROM dual;
3623
3624 SELECT concatenated_copy_segments INTO l_concatenated_copy_segments
3625 FROM eng_revised_items WHERE revised_item_sequence_id = item.revised_item_sequence_id;
3626
3627 FOR i IN 1..20
3628 LOOP
3629 copy_segments(i) := substr(l_concatenated_copy_segments,
3630 to_number(instr(l_concatenated_copy_segments,fnd_global.local_chr(1),1,i))+1,
3631 ( to_number( instr(l_concatenated_copy_segments,fnd_global.local_chr(1),1,i+1) ) -
3632 to_number(instr(l_concatenated_copy_segments,fnd_global.local_chr(1),1,i)+1)) );
3633 END LOOP;
3634
3635 END IF;
3636
3637 -- ERES change begins
3638 -- Create child event Transfer or Copy ToManufacturing:
3639 IF (l_eres_enabled = 'Y')
3640 THEN
3641 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Preparing ERES. parent_erecord_id='||l_parent_record_id);
3642
3643 l_event.param_name_1 := 'DEFERRED';
3644 l_event.param_value_1 := 'Y';
3645
3646 l_event.param_name_2 := 'POST_OPERATION_API';
3647 l_event.param_value_2 := 'NONE';
3648
3649 l_event.param_name_3 := 'PSIG_USER_KEY_LABEL';
3650 -- see later ... l_event.param_value_3 := '... ';
3651
3652 l_event.param_name_4 := 'PSIG_USER_KEY_VALUE';
3653 -- see later ... l_event.param_value_4 := '... ';
3654
3655 l_event.param_name_5 := 'PSIG_TRANSACTION_AUDIT_ID';
3656 l_event.param_value_5 := -1;
3657
3658 l_event.param_name_6 := '#WF_SOURCE_APPLICATION_TYPE';
3659 l_event.param_value_6 := 'DB';
3660
3661 l_event.param_name_7 := '#WF_SIGN_REQUESTER';
3662 l_event.param_value_7 := FND_GLOBAL.USER_NAME;
3663
3664 IF (item.transfer_or_copy = 'C')
3665 THEN
3666 l_child_event_name := 'oracle.apps.eng.copyToManufacturing';
3667 FND_MESSAGE.SET_NAME('ENG', 'ENG_ERES_CPY2MANUF_USER_KEY');
3668 l_event.param_value_3 := FND_MESSAGE.GET;
3669
3670 l_event.param_value_4 := item.concatenated_segments||'-'||item.organization_code||'-'||item.copy_to_item;
3671
3672 l_temp_id := TO_CHAR(item.revised_item_id)||'-'||TO_CHAR(item.organization_id)||'-'||TO_CHAR(l_new_assembly_item_id);
3673
3674 ELSIF (item.transfer_or_copy = 'T')
3675 THEN
3676 l_child_event_name := 'oracle.apps.eng.transferToManufacturing';
3677 FND_MESSAGE.SET_NAME('ENG', 'ENG_ERES_XFER2MANUF_USER_KEY');
3678 l_event.param_value_3 := FND_MESSAGE.GET;
3679
3680 -- bug 3741224 : odaboval changed the userkey order:
3681 -- l_event.param_value_4 := item.concatenated_segments||'-'||item.organization_code;
3682 l_event.param_value_4 := item.organization_code||'-'||item.concatenated_segments;
3683
3684 l_temp_id := TO_CHAR(item.revised_item_id)||'-'||TO_CHAR(item.organization_id);
3685 ELSE
3686 l_child_event_name := NULL;
3687 l_event.param_value_3 := 'NOT_FOUND';
3688 l_event.param_value_4 := 'NOT_FOUND';
3689 l_temp_id := '-1';
3690 END IF;
3691
3692 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Creating event='||l_child_event_name);
3693 FND_FILE.PUT_LINE(FND_FILE.LOG, 'for event_key='||l_temp_id);
3694 FND_FILE.PUT_LINE(FND_FILE.LOG, 'for user_event_key='||l_event.param_value_4);
3695
3696 IF (NVL(l_parent_record_id, -1) > 0)
3697 THEN
3698 --additional parameters for the child event
3699 l_event.param_name_8 := 'PARENT_EVENT_NAME';
3700 l_event.param_value_8 := 'oracle.apps.eng.ecoImplement';
3701 l_event.param_name_9 := 'PARENT_EVENT_KEY';
3702 l_event.param_value_9 := TO_CHAR(item.change_id);
3703 l_event.param_name_10 := 'PARENT_ERECORD_ID';
3704 l_event.param_value_10 := TO_CHAR(l_parent_record_id);
3705 END IF;
3706
3707 -- Part 2 of preparation of child event :
3708 l_event.event_name := l_child_event_name;
3709 l_event.event_key := l_temp_id;
3710 -- l_event.payload := l_payload;
3711 l_event.erecord_id := l_erecord_id;
3712 l_event.event_status := l_event_status;
3713
3714 -- populate the temporary table
3715 INSERT INTO eng_revised_items_temp
3716 ( temp_id
3717 , organization_id
3718 , organization_code
3719 , organization_name
3720 , inventory_item_id
3721 , item_number
3722 , item_description
3723 , transfer_or_copy_item
3724 , transfer_or_copy_bill
3725 , transfer_or_copy_routing
3726 , new_item_revision
3727 , new_routing_revision
3728 , designator_selection_type
3729 , alternate_bom_designator
3730 , change_notice
3731 , copy_to_item
3732 , copy_to_item_desc
3733 , transfer_or_copy
3734 , last_update_date
3735 , last_updated_by
3736 , creation_date
3737 , created_by)
3738 VALUES ( l_temp_id
3739 , item.organization_id
3740 , item.organization_code
3741 , item.organization_name
3742 , item.revised_item_id
3743 , item.concatenated_segments
3744 , item.description
3745 , item.transfer_or_copy_item
3746 , item.transfer_or_copy_bill
3747 , item.transfer_or_copy_routing
3748 , item.new_item_revision
3749 , item.new_routing_revision
3750 , item.designator_selection_type
3751 , item.alternate_bom_designator
3752 , item.change_notice
3753 , item.copy_to_item
3754 , item.copy_to_item_desc
3755 , item.transfer_or_copy
3756 , item.last_update_date
3757 , item.last_updated_by
3758 , item.creation_date
3759 , item.created_by);
3760
3761 QA_EDR_STANDARD.RAISE_ERES_EVENT
3762 ( p_api_version => 1.0
3763 , p_init_msg_list => FND_API.G_FALSE
3764 , p_validation_level => FND_API.G_VALID_LEVEL_FULL
3765 , x_return_status => l_return_status
3766 , x_msg_count => l_msg_count
3767 , x_msg_data => l_msg_data
3768 , p_child_erecords => l_child_record
3769 , x_event => l_event);
3770
3771 IF (NVL(l_return_status, FND_API.G_FALSE) <> FND_API.G_TRUE)
3772 AND (l_msg_count > 0)
3773 THEN
3774 RAISE ERES_EVENT_ERROR;
3775 END IF;
3776
3777 -- Keep the eRecord id :
3778 IF (NVL(l_event.erecord_id, -1) > 0)
3779 THEN
3780 INSERT INTO ENG_PARENT_CHILD_EVENTS_TEMP(parent_event_name
3781 , parent_event_key, parent_erecord_id
3782 , event_name, event_key, erecord_id
3783 , event_status)
3784 VALUES ( 'oracle.apps.eng.ecoImplement', TO_CHAR(item.change_id)
3785 , l_parent_record_id
3786 , l_event.event_name, l_event.event_key, l_event.erecord_id
3787 , l_event.event_status);
3788
3789 FND_FILE.PUT_LINE(FND_FILE.LOG, 'After event='||l_child_event_name||', eRecord_id='||l_event.erecord_id||', status='||l_event.event_status||', ev_key='||l_event.event_key);
3790 ELSE
3791 FND_FILE.PUT_LINE(FND_FILE.LOG, 'No eRecord generated for '||l_event.event_name||'. This is normal. Please check your rules or other setups');
3792 END IF;
3793 END IF; -- l_eres_enabled
3794 -- ERES change ends
3795
3796 -- Added procedure for bug 3584193
3797 -- Description: The bill with unapproved items should not be allowed to be transferred through ECO.
3798
3799 -- If the Transfer/Copy Bill option is selected, then check for the unapproved items. Log error message if unapproved items found.
3800 IF item.transfer_or_copy_bill = 1 AND UNAPPROVED_COMPONENTS_EXISTS (item.revised_item_id, item.organization_id, item.designator_selection_type, item.alternate_bom_designator) THEN
3801 IF msg_qty < max_messages THEN
3802 msg_qty := msg_qty + 1;
3803 token1(msg_qty) := null;
3804 value1(msg_qty) := null;
3805 translate1(msg_qty) := 0;
3806 token2(msg_qty) := null;
3807 value2(msg_qty) := null;
3808 translate2(msg_qty) := 0;
3809 message_names(msg_qty) := 'ENG_UNAPPROVED_COMP_IN_BILL';
3810 IF trial_mode = no THEN
3811 Raise abort_implementation;
3812 END IF;
3813 END IF;
3814 ELSE
3815 ENG_BOM_RTG_TRANSFER_PKG.ENG_BOM_RTG_TRANSFER(
3816 X_org_id => item.organization_id,
3817 X_eng_item_id => item.revised_item_id,
3818 X_mfg_item_id => l_new_assembly_item_id,
3819 X_transfer_option => item.selection_option,
3820 X_designator_option => item.designator_selection_type,
3821 X_alt_bom_designator => item.alternate_bom_designator,
3822 X_alt_rtg_designator => item.alternate_bom_designator,
3823 X_effectivity_date => item.selection_date,
3824 X_last_login_id => loginid,
3825 X_bom_rev_starting => l_item_revision,
3826 X_rtg_rev_starting => l_routing_revision,
3827 X_ecn_name => item.change_notice,
3828 X_item_code => item.transfer_or_copy_item,
3829 X_bom_code => item.transfer_or_copy_bill,
3830 X_rtg_code => item.transfer_or_copy_routing,
3831 X_mfg_description => item.copy_to_item_desc,
3832 X_segment1 => copy_segments(1),
3833 X_segment2 => copy_segments(2),
3834 X_segment3 => copy_segments(3),
3835 X_segment4 => copy_segments(4),
3836 X_segment5 => copy_segments(5),
3837 X_segment6 => copy_segments(6),
3838 X_segment7 => copy_segments(7),
3839 X_segment8 => copy_segments(8),
3840 X_segment9 => copy_segments(9),
3841 X_segment10 => copy_segments(10),
3842 X_segment11 => copy_segments(11),
3843 X_segment12 => copy_segments(12),
3844 X_segment13 => copy_segments(13),
3845 X_segment14 => copy_segments(14),
3846 X_segment15 => copy_segments(15),
3847 X_segment16 => copy_segments(16),
3848 X_segment17 => copy_segments(17),
3849 X_segment18 => copy_segments(18),
3850 X_segment19 => copy_segments(19),
3851 X_segment20 => copy_segments(20),
3852 X_implemented_only => item.implemented_only,
3853 X_unit_number => item.selection_unit_number);
3854 END IF;
3855
3856 IF (item.new_lifecycle_state_id IS NOT NULL AND item.new_lifecycle_state_id <> item.current_lifecycle_state_id )
3857 THEN
3858
3859 CHANGE_ITEM_LIFECYCLE_PHASE (
3860 p_rev_item_seq_id => revised_item
3861 , p_organization_id => item.organization_id
3862 , p_inventory_item_id => item.revised_item_id
3863 , p_scheduled_date => item.scheduled_date
3864 , p_new_lifecycle_phase_id => item.new_lifecycle_state_id
3865 , x_return_status => l_lc_return_status);
3866 IF (l_lc_return_status <> 'S')
3867 THEN
3868 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Change Item phase for transfer line Failed');
3869 RAISE abort_implementation;
3870 END IF;
3871 END IF;
3872
3873
3874 IF ( p_is_lifecycle_phase_change = 2)
3875 THEN
3876
3877 Update eng_revised_items
3878 set implementation_date = today,
3879 status_type = 6,
3880 last_update_date = sysdate,
3881 last_updated_by = userid,
3882 last_update_login = loginid,
3883 request_id = reqstid,
3884 program_application_id = appid,
3885 program_id = progid,
3886 program_update_date = sysdate,
3887 status_code = p_status_code
3888 where revised_item_sequence_id = item.revised_item_sequence_id;
3889
3890 END IF;
3891
3892
3893 END IF;
3894
3895 IF (item.transfer_or_copy = 'O') -- if the item is obsoleted
3896 THEN
3897 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing obsolete Item .. ');
3898
3899 l_max_scheduled_date := item.scheduled_date;
3900 l_implement_revised_item := 1;
3901 FOR li IN c_local_org_rev_items (item.change_id, item.revised_item_sequence_id)
3902 LOOP
3903 IF (li.implementation_date IS NULL )
3904 THEN
3905 FND_FILE.PUT_LINE(FND_FILE.LOG, 'This item cannot be obsoleted since revised items propagated to the local organizations have not been implemented');
3906 Raise abort_implementation;
3907 END IF;
3908 IF li.scheduled_date > l_max_scheduled_date THEN
3909 l_max_scheduled_date := li.scheduled_date;
3910 END IF;
3911
3912 END LOOP;
3913 /* reschedule the revised item if l_max_scheduled_date > item.scheduled_date*/
3914 IF ( l_max_scheduled_date > item.scheduled_date)
3915 THEN
3916 UPDATE eng_revised_items
3917 SET scheduled_date = l_max_scheduled_date
3918 WHERE revised_item_sequence_id = item.revised_item_sequence_id;
3919 END IF;
3920
3921 IF (item.new_lifecycle_state_id IS NOT NULL AND item.new_lifecycle_state_id <> item.current_lifecycle_state_id )
3922 THEN
3923 CHANGE_ITEM_LIFECYCLE_PHASE (
3924 p_rev_item_seq_id => revised_item
3925 , p_organization_id => item.organization_id
3926 , p_inventory_item_id => item.revised_item_id
3927 , p_scheduled_date => l_max_scheduled_date
3928 , p_new_lifecycle_phase_id => item.new_lifecycle_state_id
3929 , x_return_status => l_lc_return_status);
3930
3931 IF (l_lc_return_status <> 'S')
3932 THEN
3933 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Change Item phase for obsolete item line Failed');
3934 RAISE abort_implementation;
3935 END IF;
3936 END IF;
3937
3938 l_Item_rec_in.INVENTORY_ITEM_ID := item.revised_item_id;
3939 l_Item_rec_in.ORGANIZATION_ID := item.Organization_Id;
3940 l_Item_rec_in.INVENTORY_ITEM_STATUS_CODE := 'Inactive';
3941
3942 INV_Item_GRP.Update_Item (
3943 p_Item_rec => l_Item_rec_in
3944 , p_Revision_rec => l_revision_rec
3945 , p_Template_Id => NULL
3946 , p_Template_Name => NULL
3947 , x_Item_rec => l_Item_rec_out
3948 , x_return_status => l_inv_return_status
3949 , x_Error_tbl => l_Error_tbl );
3950
3951 IF (l_inv_return_status <> 'S' )
3952 THEN
3953 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Change Item status to inactive Failed');
3954 Raise abort_implementation;
3955 END IF;
3956
3957 IF (p_is_lifecycle_phase_change = 2 )
3958 THEN
3959 Update eng_revised_items
3960 set implementation_date = today,
3961 status_type = 6,
3962 last_update_date = sysdate,
3963 last_updated_by = userid,
3964 last_update_login = loginid,
3965 request_id = reqstid,
3966 program_application_id = appid,
3967 program_id = progid,
3968 program_update_date = sysdate,
3969 status_code = p_status_code
3970 where revised_item_sequence_id = item.revised_item_sequence_id;
3971 END IF;
3972
3973 ELSIF item.transfer_or_copy = 'L' THEN --life cycle phase chnage
3974
3975 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Processing phase change Item .. ');
3976 IF (item.new_lifecycle_state_id IS NOT NULL AND item.new_lifecycle_state_id <> item.current_lifecycle_state_id )
3977 THEN
3978 CHANGE_ITEM_LIFECYCLE_PHASE (
3979 p_rev_item_seq_id => revised_item
3980 , p_organization_id => item.organization_id
3981 , p_inventory_item_id => item.revised_item_id
3982 , p_scheduled_date => item.scheduled_date
3983 , p_new_lifecycle_phase_id => item.new_lifecycle_state_id
3984 , x_return_status => l_lc_return_status);
3985 IF (l_lc_return_status <> 'S')
3986 THEN
3987 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Change Item phase for phase change line Failed');
3988 RAISE abort_implementation;
3989 END IF;
3990 END IF;
3991
3992 IF (p_is_lifecycle_phase_change = 2)
3993 THEN
3994
3995 Update eng_revised_items
3996 set implementation_date = today,
3997 status_type = 6,
3998 last_update_date = sysdate,
3999 last_updated_by = userid,
4000 last_update_login = loginid,
4001 request_id = reqstid,
4002 program_application_id = appid,
4003 program_id = progid,
4004 program_update_date = sysdate,
4005 status_code = p_status_code
4006 where revised_item_sequence_id = item.revised_item_sequence_id;
4007
4008 END IF;
4009 END IF;
4010
4011 IF (p_is_lifecycle_phase_change = 1) THEN
4012
4013
4014 /* Implement Revised Item Change */
4015
4016
4017 -- Effectivity date should be sysdate, if scheduled_date < sysdate
4018 -- New eff_date included to fix bug #777353.
4019
4020 if (item.scheduled_date < now)
4021 then
4022 eff_date := now;
4023 revision_high_date := now;
4024 rtg_revision_high_date := now;
4025 else
4026 eff_date := item.scheduled_date;
4027 revision_high_date := item.scheduled_date;
4028 rtg_revision_high_date := item.scheduled_date;
4029 end if;
4030
4031
4032 /*** Added by 11.5.10 ***/
4033 if (item.use_up_item_id is not null and item.disposition_type = 8) then
4034 --- 8 use_up =Exhaust WIP and Inventory
4035 if (inv_onhand(item.use_up_item_id, item.organization_id) <> 0) then
4036 /* Fix for bug 5962435 - Added nvl around the profile,
4037 otherwise eff_date becomes null when that profile value is left blank.*/
4038 eff_date := eff_date + nvl(FND_PROFILE.VALUE('ENG:ENG_RESCHEDULE_DAYS_BY'),0);
4039 end if;
4040 end if;
4041 /*** ***/
4042
4043 Open get_current_rev;
4044 Fetch get_current_rev into current_revision;
4045 l_current_revision := current_revision.revision;
4046 l_current_rev_eff_date := current_revision.effectivity_date;
4047 Close get_current_rev;
4048
4049
4050 Open get_current_routing_rev;
4051 Fetch get_current_routing_rev into current_routing_revision;
4052 l_current_rtg_revision := current_routing_revision.process_revision;
4053 l_current_rtg_rev_eff_date := current_routing_revision.effectivity_date;
4054 Close get_current_routing_rev;
4055
4056
4057 bill_sequence_id := nvl(item.bill_sequence_id,-1) ;
4058 routing_sequence_id := nvl(item.routing_sequence_id,-1);
4059 update_wip := item.update_wip;
4060 eco_for_production := item.eco_for_production;
4061 l_wip_organization_id := item.organization_id;
4062 l_wip_completion_subinventory := item.completion_subinventory; -- Bug 5896479
4063 l_wip_completion_locator_id := item.completion_locator_id; -- Bug 5896479
4064
4065 -----------------------------------------------------------
4066 -- R12: Changes for Common BOM Enhancement
4067 -- Step 1: Initialization
4068 -----------------------------------------------------------
4069 g_Common_Rev_Comp_Tbl.delete;
4070 g_common_rev_comps_cnt := 0;
4071 isCommonedBOM := 'N';
4072 l_common_bom_eff_date := NULL;
4073 OPEN check_if_commoned_bom( item.bill_sequence_id);
4074 FETCH check_if_commoned_bom into commoned_bom;
4075 IF check_if_commoned_bom%FOUND
4076 THEN
4077 isCommonedBOM := 'Y';
4078 END IF;
4079 CLOSE check_if_commoned_bom;
4080 IF isCommonedBOM = 'N' AND eff_date > sysdate
4081 THEN
4082 -- check if it is a common bom and fetch its effectivity date
4083 -- from the components records if the effectivity date is not now
4084 OPEN get_common_bom_eff_date( item.bill_sequence_id, item.revised_item_sequence_id);
4085 FETCH get_common_bom_eff_date into l_common_bom_eff_date;
4086 CLOSE get_common_bom_eff_date;
4087 END IF;
4088 -----------------------------------------------------------
4089 -- R12: End Step 1: Changes for Common BOM Enhancement --
4090 -----------------------------------------------------------
4091 -- Initialize For Business events
4092 l_BOMEvents_Comps_ACD := NULL;
4093 l_BOMEvents_Bill_Event_Name := NULL;
4094 -- End Initialize For Bom Business Events
4095
4096 -- Is Unit Effective Revised Item?
4097
4098 If (PJM_UNIT_EFF.Enabled = 'Y' AND
4099 PJM_UNIT_EFF.Unit_Effective_Item(
4100 X_Item_ID => item.revised_item_id,
4101 X_Organization_ID => item.organization_id) = 'Y')
4102 then
4103 X_UnitEff_RevItem := 'Y';
4104 end if;
4105 -- Is Order Entry Installed?
4106
4107 X_GetInstallStatus := Fnd_Installation.get(
4108 appl_id => G_OrderEntry,
4109 dep_appl_id => G_OrderEntry,
4110 status => X_InstallStatus,
4111 industry => X_Industry);
4112
4113 If not X_GetInstallStatus then
4114 X_InstallStatus := 'N';
4115 End if;
4116
4117 -- Added validation for bug 4150069
4118 -- Check for revised items with unimplemented "From Revision".
4119 -- The value of "From revision" is saved in current_item_revision_id.
4120 -- In case of ECO Form the value of the current_item_revision_id will be:
4121 -- the current implemented revision of the item at the time of creation of the revised item.
4122 Open c_get_revision(item.current_item_revision_id);
4123 Fetch c_get_revision into l_revitem_from_rev, l_rev_impl_date;
4124 IF c_get_revision%FOUND AND l_rev_impl_date IS NULL
4125 THEN
4126 If msg_qty < max_messages
4127 Then
4128 msg_qty := msg_qty + 1;
4129 token1(msg_qty) := 'REVISION';
4130 value1(msg_qty) := l_revitem_from_rev;
4131 translate1(msg_qty) := 0;
4132 token2(msg_qty) := null;
4133 value2(msg_qty) := null;
4134 translate2(msg_qty) := 0;
4135 message_names(msg_qty) := 'ENG_REV_ITM_FROMREV_UNIMPL';
4136 IF trial_mode = no
4137 THEN
4138 Close c_get_revision;
4139 RAISE abort_implementation;
4140 END IF;
4141 End If;
4142 END IF;
4143 Close c_get_revision;
4144 -- End changes for bug 4150069
4145
4146 -- Check for rev items which are not active. Fix for bug 835813.
4147 Open check_rev_item_inactive;
4148 Fetch check_rev_item_inactive into dummy;
4149 If check_rev_item_inactive%found then
4150 If msg_qty < max_messages then
4151 msg_qty := msg_qty + 1;
4152 token1(msg_qty) := null;
4153 value1(msg_qty) := null;
4154 translate1(msg_qty) := 0;
4155 token2(msg_qty) := null;
4156 value2(msg_qty) := null;
4157 translate2(msg_qty) := 0;
4158 message_names(msg_qty) := 'ENG_REV_ITEM_INACTIVE';
4159 If trial_mode = no then
4160 Raise abort_implementation;
4161 end if;
4162 end if;
4163 end if;
4164 Close check_rev_item_inactive;
4165
4166 If item.new_item_revision is not null then
4167
4168 --
4169 -- Check if there exists an unimplemented ECO having the same
4170 -- item and a new revision less than the new revision of this ECO.
4171 -- if found, issue a warning only.
4172 --
4173
4174 Open unimplemented_rev;
4175 Fetch unimplemented_rev into unimp_rec;
4176 If unimplemented_rev%found then
4177 If msg_qty < max_messages then
4178
4179 begin
4180 SELECT substrb(profile_option_value,1,1)
4181 INTO eco_rev_warning_flag
4182 FROM fnd_profile_options opt,
4183 fnd_application appl,
4184 fnd_profile_option_values val
4185 WHERE opt.application_id = val.application_id
4186 AND opt.profile_option_id = val.profile_option_id
4187 AND opt.application_id = appl.application_id
4188 AND appl.application_short_name = 'ENG'
4189 AND opt.profile_option_name = 'ENG:ECO_REV_WARNING'
4190 AND val.level_id = 10001;
4191 exception
4192 when OTHERS then
4193 --eco_rev_warning_flag := 'Y';
4194 eco_rev_warning_flag := 'N'; -- Modified for bug 12826978
4195 end;
4196 msg_qty := msg_qty + 1;
4197 token1(msg_qty) := null;
4198 value1(msg_qty) := null;
4199 translate1(msg_qty) := 0;
4200 token2(msg_qty) := null;
4201 value2(msg_qty) := null;
4202 translate2(msg_qty) := 0;
4203
4204 if eco_rev_warning_flag = 'Y' then
4205
4206 warnings := warnings + 1;
4207 message_names(msg_qty) := 'ENG_REV_PENDING';
4208 -- Added for bug 12826978, to show the warning message in log
4209 FND_FILE.PUT_LINE(FND_FILE.LOG, 'WARNING: A lower revision for this revised item
4210 is pending on another ECO.');
4211 else
4212 message_names(msg_qty) := 'ENG_REV_IMPL_ORDER';
4213 If trial_mode = no then
4214 Raise abort_implementation;
4215 end if;
4216 end if;
4217
4218
4219 end if;
4220 end if;
4221 Close unimplemented_rev;
4222
4223 --
4224 -- Check if there is a revision lower than new revision with higher eff date.
4225 -- bug #737239.
4226
4227 -- added in 16344967, avoid invalid data are implemented by eff_date change
4228 Open check_same_scheduled_date;
4229 Fetch check_same_scheduled_date into dummy;
4230 if check_same_scheduled_date%notfound then
4231 -- 13978799, ensure effectivity_date value will not be same for revisions
4232 IF ( eff_date = l_current_rev_eff_date) THEN
4233 eff_date := l_current_rev_eff_date + 1/86400; -- add one second, 24*60*60
4234 end if;
4235 end if;
4236
4237 Open check_high_date_low_rev;
4238 Fetch check_high_date_low_rev into dummy;
4239 If check_high_date_low_rev%found then
4240 If msg_qty < max_messages then
4241 msg_qty := msg_qty + 1;
4242 token1(msg_qty) := null;
4243 value1(msg_qty) := null;
4244 translate1(msg_qty) := 0;
4245 token2(msg_qty) := null;
4246 value2(msg_qty) := null;
4247 translate2(msg_qty) := 0;
4248 message_names(msg_qty) := 'ENG_REVISION_ORDER';
4249 If trial_mode = no then
4250 Raise abort_implementation;
4251 end if;
4252 end if;
4253 end if;
4254 Close check_high_date_low_rev;
4255
4256 --
4257 -- Check if current revision is higher than new revision.
4258 --
4259
4260 If nlssort(l_current_revision) > nlssort(item.new_item_revision) then
4261 If msg_qty < max_messages then
4262 msg_qty := msg_qty + 1;
4263 message_names(msg_qty) := 'ENG_CUR_REV_HIGHER';
4264 token1(msg_qty) := 'ENTITY1';
4265 value1(msg_qty) := item.new_item_revision;
4266 translate1(msg_qty) := 0;
4267 token2(msg_qty) := 'ENTITY2';
4268 value2(msg_qty) := l_current_revision;
4269 translate2(msg_qty) := 0;
4270 end if;
4271 If trial_mode = no then
4272 Raise abort_implementation;
4273 end if;
4274 elsif nlssort(l_current_revision) < nlssort(item.new_item_revision) then
4275
4276 --
4277 -- Implement the new revision.
4278 --
4279 Update mtl_item_revisions_b --changed mtl_item_revisions to mtl_item_revisions_b
4280 set implementation_date = today,
4281 effectivity_date = eff_date,
4282 last_update_date = sysdate,
4283 last_updated_by = userid,
4284 last_update_login = loginid,
4285 request_id = reqstid,
4286 program_application_id = appid,
4287 program_id = progid,
4288 program_update_date = sysdate
4289 where inventory_item_id = item.revised_item_id
4290 and organization_id = item.organization_id
4291 and revision = item.new_item_revision;
4292
4293 -- R12: Business Event Enhancement:
4294 -- Raise Event if Revision got Updated successfully
4295 BEGIN
4296 INV_ITEM_EVENTS_PVT.Raise_Events(
4297 p_event_name => 'EGO_WF_WRAPPER_PVT.G_REV_CHANGE_EVENT'
4298 ,p_dml_type => 'UPDATE'
4299 ,p_inventory_item_id => item.revised_item_id
4300 ,p_organization_id => item.organization_id
4301 ,p_revision_id => item.new_item_revision_id );
4302 EXCEPTION
4303 WHEN OTHERS THEN
4304 NULL;
4305 END;
4306 -- R12: Business Event Enhancement:
4307 -- Raise Event if Revision got Updated successfully
4308
4309
4310 --
4311 -- Implement the new revision in common bills also.
4312 -- Fixed bug #747439.
4313 --
4314 OPEN get_common_bills;
4315 LOOP
4316 FETCH get_common_bills into common;
4317 EXIT WHEN get_common_bills%NOTFOUND;
4318
4319 OPEN get_common_current_rev(
4320 common_assembly_item_id=>common.assembly_item_id,
4321 common_org_id =>common.organization_id);
4322 FETCH get_common_current_rev into common_current_rev;
4323 CLOSE get_common_current_rev;
4324
4325 --* Added for Bug 4366583
4326 OPEN revision_exists(
4327 common_assembly_item_id=>common.assembly_item_id,
4328 common_org_id =>common.organization_id,
4329 common_revision =>item.new_item_revision);
4330 FETCH revision_exists into l_revision_exists;
4331 CLOSE revision_exists;
4332 --* End of Bug 4366583
4333
4334 if (( nlssort(common_current_rev) < nlssort(item.new_item_revision))
4335 and ( l_revision_exists = 0)) --* AND condition added for Bug 4366583
4336 then
4337 ENG_COPY_TABLE_ROWS_PKG.C_MTL_ITEM_REVISIONS(
4338 X_inventory_item_id => common.assembly_item_id,
4339 X_organization_id => common.organization_id,
4340 X_revision => item.new_item_revision,
4341 X_last_update_date => SYSDATE,
4342 X_last_updated_by => userid,
4343 X_creation_date => SYSDATE,
4344 X_created_by => userid,
4345 X_last_update_login => loginid,
4346 X_effectivity_date => eff_date,
4347 X_change_notice => item.change_notice,
4348 X_implementation_date => today);
4349 --Start of changes Bug 2963301
4350 Begin
4351 SELECT userenv('LANG') INTO l_language_code FROM dual;
4352 Update mtl_item_revisions_tl MIR
4353 set description =
4354 (select MIR1.description
4355 from mtl_item_revisions_tl MIR1
4356 where revision_id IN (SELECT revision_id
4357 FROM MTL_ITEM_REVISIONS_B
4358 WHERE
4359 inventory_item_id = item.revised_item_id
4360 and organization_id = item.organization_id
4361 and revision = item.new_item_revision)
4362 and language = l_language_code
4363 )
4364 where inventory_item_id = common.assembly_item_id
4365 and organization_id = common.organization_id
4366 and revision_id in (SELECT revision_id
4367 FROM MTL_ITEM_REVISIONS_B
4368 WHERE
4369 inventory_item_id = common.assembly_item_id
4370 and organization_id = common.organization_id
4371 and revision = item.new_item_revision);
4372
4373 Exception
4374 When Others then
4375 NULL;
4376 End;
4377 --End of changes Bug 2963301
4378 end if;
4379 END LOOP;
4380 CLOSE get_common_bills ; -- Closed this Cursor for Bug #3102887
4381 -- end fix #747439.
4382
4383 end if;
4384
4385 end if; -- end of "if new_item_revision is not null"
4386
4387 --- as there is no updation of description ,updation to mtl_item_revisions_tl is not required
4388 -- Moved this code here so that if new revision gets implemented rev effective structure will get implement successfully 5243333
4389 -- Added For 11510+ Enhancement
4390 -- Fetch the effectivity control of the bill
4391 Open get_bill_effectivity_control(bill_sequence_id);
4392 Fetch get_bill_effectivity_control into l_effectivity_control;
4393 Close get_bill_effectivity_control;
4394 -- Is the effectivity control End-item-revision Effectivity
4395 l_revision_eff_bill := 'N';
4396 If (l_effectivity_control = 4)
4397 Then
4398 l_revision_eff_bill := 'Y';
4399 Open check_impl_revision(item.from_end_item_rev_id, item.from_end_item_id, item.organization_id);
4400 Fetch check_impl_revision into l_from_rev_eff_date, l_from_revision;
4401 Close check_impl_revision;
4402 l_from_end_item_id := item.from_end_item_id;
4403 l_current_end_item_revision :=
4404 BOM_REVISIONS.GET_ITEM_REVISION_FN('ALL', 'IMPL_ONLY', item.organization_id, item.from_end_item_id, now);
4405 End If;
4406 -- End 11510+ Enhancement
4407
4408 -- Added to support structure revision
4409 If item.new_structure_revision is not null then
4410 -- Call BOM API to create new BOM revision
4411 X_new_structure_revision_id := null;
4412 X_prev_structure_revision_id := null;
4413 End if;
4414
4415
4416
4417 --
4418 -- Implement Item Pending Changes
4419 -- In R12
4420 -- ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes API
4421 -- implement all Item Pending Changes
4422 BEGIN
4423
4424 -- SAVEPOINT ITEM_CHG ;
4425
4426 FND_FILE.NEW_LINE(FND_FILE.LOG);
4427 FND_FILE.PUT_LINE(FND_FILE.LOG,'Implement Item Pending Changes ');
4428 FND_FILE.PUT_LINE(FND_FILE.LOG,'==================================================');
4429 FND_FILE.PUT_LINE(FND_FILE.LOG,'Before: ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes ');
4430
4431 l_return_status := FND_API.G_RET_STS_SUCCESS;
4432 plsql_block := 'BEGIN
4433 FND_MSG_PUB.initialize ;
4434 ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes
4435 ( p_api_version => 1.0
4436 , p_change_id => :a
4437 , p_change_line_id => :b
4438 , x_return_status => :c
4439 , x_msg_count => :d
4440 , x_msg_data => :e );
4441 END ; ' ;
4442
4443 EXECUTE IMMEDIATE plsql_block USING
4444 '', -- p_change_id
4445 revised_item, -- p_change_line_id
4446 OUT l_return_status, -- x_return_status
4447 OUT l_msg_count, -- x_msg_count
4448 OUT l_msg_data; -- x_msg_data
4449
4450 FND_FILE.PUT_LINE(FND_FILE.LOG,'After: ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes: Return Status=' || l_return_status);
4451
4452 IF l_return_status <> FND_API.G_RET_STS_SUCCESS
4453 THEN
4454 FND_MESSAGE.Set_Name('ENG','ENG_ERROR_CALLING_PS_API');
4455 FND_MESSAGE.Set_Token('OBJECT_NAME'
4456 ,'ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes') ;
4457 FND_MSG_PUB.Add;
4458
4459 RAISE FND_API.G_EXC_ERROR;
4460 END IF;
4461
4462 FND_FILE.PUT_LINE(FND_FILE.LOG,'==================================================');
4463
4464 EXCEPTION
4465 WHEN PLSQL_COMPILE_ERROR THEN
4466 null;
4467
4468 WHEN FND_API.G_EXC_ERROR THEN
4469
4470 FND_FILE.PUT_LINE(FND_FILE.LOG,'ENG_IMPL_ITEM_CHANGES_PKG.impl_item_changes failed ');
4471 FND_FILE.PUT_LINE(FND_FILE.LOG,'--------------------------------------------------');
4472 -- ROLLBACK TO SAVEPOINT ITEM_CHG ;
4473
4474 FOR I IN 1..FND_MSG_PUB.Count_Msg LOOP
4475
4476 FND_FILE.PUT_LINE(FND_FILE.LOG,'Message Number : '|| I );
4477 FND_FILE.PUT_LINE(FND_FILE.LOG,'DATA = '||replace(substr(FND_MSG_PUB.Get(I), 1, 200), chr(0), ' '));
4478
4479 IF msg_qty < max_messages
4480 then
4481 msg_qty := msg_qty + 1;
4482 message_names(msg_qty) := 'ENG_IMPL_ITEM_CHANGE_FAIL' ;
4483 token1(msg_qty) := 'MSG_TEXT';
4484 value1(msg_qty) := replace(substr(FND_MSG_PUB.Get(I), 1, 80), chr(0), ' ');
4485 translate1(msg_qty) := 0;
4486 token2(msg_qty) := null;
4487 value2(msg_qty) := null;
4488 translate2(msg_qty) := 0;
4489 END IF;
4490
4491
4492 END LOOP;
4493
4494
4495 FND_FILE.PUT_LINE(FND_FILE.LOG,'==================================================');
4496
4497 IF trial_mode = no then
4498 Raise abort_implementation;
4499 END IF;
4500
4501
4502
4503 WHEN OTHERS THEN
4504 FND_FILE.PUT_LINE(FND_FILE.LOG,'Other Unexpected Error: '|| substr(SQLERRM,1,200));
4505
4506 FND_FILE.PUT_LINE(FND_FILE.LOG,'--------------------------------------------------');
4507 FND_FILE.PUT_LINE(FND_FILE.LOG,'ROLL BACK TO ITEM_CHG');
4508 -- ROLLBACK TO SAVEPOINT ITEM_CHG ;
4509
4510
4511 IF msg_qty < max_messages
4512 then
4513 msg_qty := msg_qty + 1;
4514 message_names(msg_qty) := 'ENG_IMPL_ITEM_CHANGE_FAIL' ;
4515 token1(msg_qty) := 'MSG_TEXT';
4516 value1(msg_qty) := substr(SQLERRM, 1, 80);
4517 translate1(msg_qty) := 0;
4518 token2(msg_qty) := null;
4519 value2(msg_qty) := null;
4520 translate2(msg_qty) := 0;
4521 END IF;
4522
4523 FND_FILE.PUT_LINE(FND_FILE.LOG,'--------------------------------------------------');
4524
4525
4526 FND_FILE.PUT_LINE(FND_FILE.LOG,'==================================================');
4527
4528 IF trial_mode = no then
4529 Raise abort_implementation;
4530 END IF;
4531
4532 END;
4533
4534 -----------------------------------------------------------------
4535 -- For ECO cumulative/ECO wip job/ECO lot ---------8/2/2000----
4536 IF item.eco_for_production =1
4537 THEN
4538 IF item.from_wip_entity_id IS NULL
4539 AND item.to_wip_entity_id IS NULL
4540 AND item.from_cum_qty IS NULL
4541 AND item.lot_number IS NULL
4542 THEN
4543 IF msg_qty < max_messages then
4544 msg_qty := msg_qty + 1;
4545 message_names(msg_qty) :=
4546 'ENG_IMP_ECO_JOB_ONLY_CHECKED';
4547 token1(msg_qty) := null;
4548 value1(msg_qty) := null;
4549 translate1(msg_qty) := 0;
4550 token2(msg_qty) := null;
4551 value2(msg_qty) := null;
4552 translate2(msg_qty) := 0;
4553 END IF;
4554 IF trial_mode = no then
4555 Raise abort_implementation;
4556 END IF;
4557 END IF;
4558
4559 IF item.new_item_revision IS NOT NULL
4560 OR item.new_routing_revision IS NOT NULL
4561 THEN
4562 IF msg_qty < max_messages then
4563 msg_qty := msg_qty + 1;
4564 message_names(msg_qty) :=
4565 'ENG_IMP_INVALID_REVISION';
4566 token1(msg_qty) := null;
4567 value1(msg_qty) := null;
4568 translate1(msg_qty) := 0;
4569 token2(msg_qty) := null;
4570 value2(msg_qty) := null;
4571 translate2(msg_qty) := 0;
4572 END IF;
4573 IF trial_mode = no then
4574 Raise abort_implementation;
4575 END IF;
4576 END IF;
4577
4578 IF NOT ( item.from_wip_entity_id IS NOT NULL
4579 and item.to_wip_entity_id IS NOT NULL
4580 and item.from_cum_qty IS NULL
4581 and item.lot_number is NULL
4582 OR item.from_wip_entity_id IS NOT NULL
4583 and item.to_wip_entity_id IS NULL
4584 and item.from_cum_qty IS NOT NULL
4585 and item.lot_number is NULL
4586 OR item.from_wip_entity_id IS NULL
4587 and item.to_wip_entity_id IS NULL
4588 and item.from_cum_qty IS NULL
4589 and item.lot_number IS NOT NULL
4590 )
4591 THEN
4592 IF msg_qty < max_messages then
4593 msg_qty := msg_qty + 1;
4594 message_names(msg_qty) :=
4595 'ENG_IMP_INVALID_JOB_SPEC';
4596 token1(msg_qty) := null;
4597 value1(msg_qty) := null;
4598 translate1(msg_qty) := 0;
4599 token2(msg_qty) := null;
4600 value2(msg_qty) := null;
4601 translate2(msg_qty) := 0;
4602 END IF;
4603 IF trial_mode = no then
4604 Raise abort_implementation;
4605 END IF;
4606
4607 END IF;
4608 END IF;
4609
4610 IF item.eco_for_production =2
4611 AND ( item.from_wip_entity_id IS NOT NULL
4612 or item.to_wip_entity_id IS NOT NULL
4613 or item.from_cum_qty IS NOT NULL
4614 or item.lot_number is NOT NULL )
4615 THEN
4616 IF msg_qty < max_messages then
4617 msg_qty := msg_qty + 1;
4618 message_names(msg_qty) :=
4619 'ENG_IMP_ECO_JOB_ONLY_UNCHECKED';
4620 token1(msg_qty) := null;
4621 value1(msg_qty) := null;
4622 translate1(msg_qty) := 0;
4623 token2(msg_qty) := null;
4624 value2(msg_qty) := null;
4625 translate2(msg_qty) := 0;
4626 END IF;
4627 IF trial_mode = no then
4628 Raise abort_implementation;
4629 END IF;
4630
4631 END IF;
4632
4633
4634 IF item.update_wip = 1 and item.mrp_active = 2
4635 THEN
4636 -- For ECO cumulative type
4637 IF NVL(item.from_cum_qty, 0) > 0
4638 THEN
4639 OPEN check_job_valid_for_cum
4640 ( p_from_wip_entity_id => item.from_wip_entity_id);
4641 FETCH check_job_valid_for_cum INTO cum_job_rec;
4642 IF check_job_valid_for_cum %NOTFOUND
4643 THEN
4644 IF msg_qty < max_messages then
4645 msg_qty := msg_qty + 1;
4646 message_names(msg_qty) :=
4647 'ENG_NO_VALID_WO_FOR_ECO_CUM';
4648 token1(msg_qty) := null;
4649 value1(msg_qty) := null;
4650 translate1(msg_qty) := 0;
4651 token2(msg_qty) := null;
4652 value2(msg_qty) := null;
4653 translate2(msg_qty) := 0;
4654 END IF;
4655 IF trial_mode = no then
4656 Raise abort_implementation;
4657 END IF;
4658 ELSIF (item.from_cum_qty > cum_job_rec.start_quantity )
4659 THEN IF msg_qty < max_messages then
4660 msg_qty := msg_qty + 1;
4661 message_names(msg_qty) :=
4662 'ENG_INVALID_START_QTY_ECO_CUM';
4663 token1(msg_qty) := null;
4664 value1(msg_qty) := null;
4665 translate1(msg_qty) := 0;
4666 token2(msg_qty) := null;
4667 value2(msg_qty) := null;
4668 translate2(msg_qty) := 0;
4669 END IF;
4670 IF trial_mode = no then
4671 Raise abort_implementation;
4672 END IF;
4673 ELSIF eff_date > cum_job_rec.scheduled_start_date
4674 THEN IF msg_qty < max_messages then
4675 msg_qty := msg_qty + 1;
4676 message_names(msg_qty) :=
4677 'ENG_INVALID_EFF_DATE_ECO_CUM';
4678 token1(msg_qty) := null;
4679 value1(msg_qty) := null;
4680 translate1(msg_qty) := 0;
4681 token2(msg_qty) := null;
4682 value2(msg_qty) := null;
4683 translate2(msg_qty) := 0;
4684 END IF;
4685 IF trial_mode = no then
4686 Raise abort_implementation;
4687 END IF;
4688
4689 END IF; -- end of check_job_valid_for_cum %NOTFOUND
4690
4691
4692 -- set the following variables used in insert WIP schedule interface.
4693 l_wip_start_quantity1 := item.from_cum_qty - 1;
4694 l_wip_start_quantity2 := cum_job_rec.start_quantity-item.from_cum_qty + 1;
4695 IF cum_job_rec.start_quantity = cum_job_rec.net_quantity
4696 THEN
4697 l_wip_net_quantity1 := l_wip_start_quantity1;
4698 l_wip_net_quantity2 := l_wip_start_quantity2;
4699 ELSE
4700 l_wip_net_quantity1 :=
4701 round(cum_job_rec.net_quantity*l_wip_start_quantity1/cum_job_rec.start_quantity+0.5);
4702 l_wip_net_quantity2 :=
4703 round(cum_job_rec.net_quantity*l_wip_start_quantity2/cum_job_rec.start_quantity+0.5);
4704 END IF;
4705 l_wip_job_name := cum_job_rec.wip_entity_name;
4706 l_wip_bom_revision1 := cum_job_rec.bom_revision;
4707 l_wip_routing_revision1 := cum_job_rec.routing_revision;
4708
4709 /* select effectivity_date into l_wip_bom_revision_date1
4710 from mtl_item_revisions
4711 where inventory_item_id = item.revised_item_id
4712 and revision = l_wip_bom_revision1
4713 and organization_id = item.organization_id;
4714
4715 select effectivity_date into l_wip_routing_revision_date1
4716 from mtl_rtg_item_revisions
4717 where inventory_item_id = item.revised_item_id
4718 and process_revision = l_wip_routing_revision1
4719 and organization_id = item.organization_id;
4720 */
4721
4722
4723 -- l_wip_bom_revision_date1 := cum_job_rec.bom_revision_date;
4724 -- l_wip_routing_revision_date1:= cum_job_rec.routing_revision_date;
4725 l_wip_last_u_compl_date2 := cum_job_rec.scheduled_completion_date;
4726
4727 Generate_New_Wip_Name(
4728 p_wip_entity_name => l_wip_job_name
4729 ,p_organization_id => item.organization_id
4730 ,x_wip_entity_name1 => l_wip_job_name1
4731 ,x_wip_entity_name2 => l_wip_job_name2
4732 ,x_return_status => l_return_status
4733 );
4734
4735 -- set the values for out type parameters
4736 wip_job_name1 := l_wip_job_name1;
4737 wip_job_name2 := l_wip_job_name2;
4738 wip_job_name2_org_id := item.organization_id;
4739
4740
4741 IF l_return_status <>0
4742 THEN IF msg_qty < max_messages then
4743 msg_qty := msg_qty + 1;
4744 message_names(msg_qty) :=
4745 'ENG_NEW_WIP_JOB_NAMES_ERROR';
4746 token1(msg_qty) := 'WIP_JOB_NAME';
4747 value1(msg_qty) := l_wip_job_name;
4748 translate1(msg_qty) := 0;
4749 token2(msg_qty) := null;
4750 value2(msg_qty) := null;
4751 translate2(msg_qty) := 0;
4752 END IF;
4753 IF trial_mode = no then
4754 Raise abort_implementation;
4755 END IF;
4756 END IF; -- end of l_return_status <>0
4757
4758 CLOSE check_job_valid_for_cum;
4759 ELSIF NVL(item.from_cum_qty,0) < 0
4760 THEN
4761 IF msg_qty < max_messages then
4762 msg_qty := msg_qty + 1;
4763 message_names(msg_qty) :=
4764 'ENG_INVALID_START_QTY_ECO_CUM';
4765 token1(msg_qty) := null;
4766 value1(msg_qty) := null;
4767 translate1(msg_qty) := 0;
4768 token2(msg_qty) := null;
4769 value2(msg_qty) := null;
4770 translate2(msg_qty) := 0;
4771 END IF;
4772 IF trial_mode = no then
4773 Raise abort_implementation;
4774 END IF;
4775 END IF; -- end of NVL(item.start_quantity,0) > 0
4776
4777 -- For ECO job type
4778 IF nvl(item.to_wip_entity_id, 0) <> 0
4779 THEN
4780
4781 /* IF nvl(item.from_wip_entity_id, 0 ) > nvl(item.to_wip_entity_id, 0 )
4782 THEN
4783 IF msg_qty < max_messages then
4784 msg_qty := msg_qty + 1;
4785 message_names(msg_qty) :=
4786 'ENG_INVALID_EFF_WIP_JOB_IN_ECO_JOB';
4787 token1(msg_qty) := null;
4788 value1(msg_qty) := null;
4789 translate1(msg_qty) := 0;
4790 token2(msg_qty) := null;
4791 value2(msg_qty) := null;
4792 translate2(msg_qty) := 0;
4793 END IF;
4794 IF trial_mode = no then
4795 Raise abort_implementation;
4796 END IF;
4797 END IF; -- IF nvl(item.to_wip_entity_id, 0 )
4798 */
4799
4800
4801 OPEN check_job_valid_for_job
4802 ( p_from_wip_entity_id => item.from_wip_entity_id,
4803 p_to_wip_entity_id => item.to_wip_entity_id,
4804 p_effective_date => eff_date,
4805 p_organization_id => item.organization_id
4806 );
4807 FETCH check_job_valid_for_job INTO dummy;
4808 IF check_job_valid_for_job%FOUND
4809 THEN
4810
4811 IF msg_qty < max_messages then
4812 msg_qty := msg_qty + 1;
4813 message_names(msg_qty) :=
4814 'ENG_INVALID_WO_ECO_JOB';
4815 token1(msg_qty) := null;
4816 value1(msg_qty) := null;
4817 translate1(msg_qty) := 0;
4818 token2(msg_qty) := null;
4819 value2(msg_qty) := null;
4820 translate2(msg_qty) := 0;
4821 END IF;
4822 IF trial_mode = no then
4823 Raise abort_implementation;
4824 END IF;
4825 END IF; -- check_job_valid_for_job
4826
4827 l_from_wip_entity_id := item.from_wip_entity_id;
4828 l_to_wip_entity_id := item.to_wip_entity_id;
4829
4830 CLOSE check_job_valid_for_job;
4831
4832 END IF; -- IF nvl(item.to_wip_entity_id, 0) <> 0
4833
4834 -- For ECO lot type
4835 IF item.lot_number IS NOT NULL
4836 THEN
4837 OPEN check_job_valid_for_lot
4838 ( p_wip_lot_number => item.lot_number,
4839 p_effective_date => eff_date);
4840 FETCH check_job_valid_for_lot INTO dummy;
4841 IF check_job_valid_for_lot%FOUND
4842 THEN IF msg_qty < max_messages then
4843 msg_qty := msg_qty + 1;
4844 message_names(msg_qty) :=
4845 'ENG_INVALID_WO_EXITS_ECO_LOT';
4846 token1(msg_qty) := null;
4847 value1(msg_qty) := null;
4848 translate1(msg_qty) := 0;
4849 token2(msg_qty) := null;
4850 value2(msg_qty) := null;
4851 translate2(msg_qty) := 0;
4852 END IF;
4853 IF trial_mode = no then
4854 Raise abort_implementation;
4855 END IF;
4856 END IF; -- check_job_valid_for_lot
4857 l_lot_number := item.lot_number;
4858
4859 CLOSE check_job_valid_for_lot;
4860 END IF; -- IF item.lot_number IS NOT NULL
4861 END IF;
4862 -- update_wip = 1
4863
4864
4865
4866 -- Validate the new routing revision
4867 -- If new routing revision is not null, check the followings.
4868
4869 IF item.new_routing_revision IS NOT NULL
4870 THEN
4871 -- Check if there exists an unimplemented ECO having the same revised
4872 -- item and a routing revision less than the new revision of this
4873 -- routing. If found, issue a warning only
4874
4875 OPEN unimplemented_rtg_rev;
4876 FETCH unimplemented_rtg_rev INTO unimp_ref_rec;
4877 IF unimplemented_rtg_rev%FOUND
4878 THEN
4879 If msg_qty < max_messages then
4880
4881 begin
4882 SELECT substrb(profile_option_value,1,1)
4883 INTO eco_rev_warning_flag
4884 FROM fnd_profile_options opt,
4885 fnd_application appl,
4886 fnd_profile_option_values val
4887 WHERE opt.application_id = val.application_id
4888 AND opt.profile_option_id = val.profile_option_id
4889 AND opt.application_id = appl.application_id
4890 AND appl.application_short_name = 'ENG'
4891 AND opt.profile_option_name = 'ENG:ECO_REV_WARNING'
4892 AND val.level_id = 10001;
4893 exception
4894 when OTHERS then
4895 --eco_rev_warning_flag := 'Y';
4896 eco_rev_warning_flag := 'N'; -- Modified for bug 12826978
4897 end;
4898 msg_qty := msg_qty + 1;
4899 token1(msg_qty) := null;
4900 value1(msg_qty) := null;
4901 translate1(msg_qty) := 0;
4902 token2(msg_qty) := null;
4903 value2(msg_qty) := null;
4904 translate2(msg_qty) := 0;
4905
4906 if eco_rev_warning_flag = 'Y' then
4907
4908 warnings := warnings + 1;
4909 message_names(msg_qty) := 'ENG_RTG_REV_PENDING';
4910 -- Added for bug 12826978, to show the warning message in log
4911 FND_FILE.PUT_LINE(FND_FILE.LOG, 'WARNING: There exists a pending unimplemented
4912 ECO having the same revised item and its routing revision is less than the new
4913 revision.');
4914
4915 else
4916 message_names(msg_qty) := 'ENG_RTG_REV_IMPL_ORDER';
4917 If trial_mode = no then
4918 Raise abort_implementation;
4919 end if;
4920 end if;
4921 END IF; -- end of check_existing_diff_rev
4922 END IF; -- end of check_existing_diff_rev %FOUND
4923
4924 CLOSE unimplemented_rtg_rev;
4925
4926 -- Check if there is a routing revision lower than new routing revision
4927 -- with higher effective date.
4928 -- OPEN check_high_eff_date_low_rtg_rev;
4929 OPEN check_highEffDate_lowRtgRev;
4930 FETCH check_highEffDate_lowRtgRev INTO dummy;
4931 IF check_highEffDate_lowRtgRev%FOUND
4932 THEN
4933 If msg_qty < max_messages then
4934 msg_qty := msg_qty + 1;
4935 token1(msg_qty) := null;
4936 value1(msg_qty) := null;
4937 translate1(msg_qty) := 0;
4938 token2(msg_qty) := null;
4939 value2(msg_qty) := null;
4940 translate2(msg_qty) := 0;
4941 message_names(msg_qty) := 'ENG_RTG_REVISION_ORDER';
4942 If trial_mode = no then
4943 Raise abort_implementation;
4944 end if;
4945 end if;
4946
4947
4948 END IF;
4949 CLOSE check_highEffDate_lowRtgRev;
4950
4951
4952 -- Check if the current revision is higher than new revision
4953 /* OPEN get_current_routing_rev;
4954 FETCH get_current_routing_rev into current_routing_revision ;
4955 CLOSE get_current_routing_rev;
4956 */
4957 IF nlssort(l_current_rtg_revision) >
4958 nlssort(item.new_routing_revision)
4959 THEN
4960 If msg_qty < max_messages then
4961 msg_qty := msg_qty + 1;
4962 message_names(msg_qty) := 'ENG_CUR_RTG_REV_HIGHER';
4963 token1(msg_qty) := 'ENTITY1';
4964 value1(msg_qty) := item.new_item_revision;
4965 translate1(msg_qty) := 0;
4966 token2(msg_qty) := 'ENTITY2';
4967 value2(msg_qty) := l_current_revision;
4968 translate2(msg_qty) := 0;
4969 end if;
4970 If trial_mode = no then
4971 Raise abort_implementation;
4972 end if;
4973
4974 /*Bug 5256284 Added below IF condition to check whether the current rtg rev is less than new rtg rev.
4975 Implement the new rtg rev only if it is greater than (and not equal to) the current rtg rev.
4976 This is done to prevent the updation of the effectivity_date of the current rtg rev.*/
4977
4978 ELSIF nlssort(l_current_rtg_revision) < nlssort(item.new_routing_revision) THEN
4979 -- implement the new routing revision
4980 UPDATE mtl_rtg_item_revisions
4981 SET implementation_date = today,
4982 effectivity_date = eff_date,
4983 last_update_date = sysdate,
4984 last_updated_by = userid,
4985 last_update_login = loginid,
4986 request_id = reqstid,
4987 program_application_id = appid,
4988 program_id = progid,
4989 program_update_date = sysdate
4990 WHERE inventory_item_id = item.revised_item_id
4991 AND organization_id = item.organization_id
4992 AND process_revision = item.new_routing_revision;
4993
4994 -- ERES changes begin : bug 3908563
4995 IF SQL%ROWCOUNT > 0
4996 THEN
4997 -- ERES flag to be set for triggering Routing Event:
4998 bERES_Flag_for_Routing := TRUE;
4999 -- Bug 4455543: Set l_WIP_Flag_for_Routing when routing revision is being updated by revised item
5000 l_WIP_Flag_for_Routing := 'Y';
5001 FND_FILE.PUT_LINE(FND_FILE.LOG, 'in mtl_rtg_item_revisions... bERES_Flag_for_Routing=TRUE');
5002 END IF;
5003 -- ERES changes end.
5004
5005 END IF; -- end of nlssort(current_routing_revision)
5006
5007 -- implement the new revision in common routing too
5008
5009 OPEN get_common_routing;
5010 LOOP
5011 FETCH get_common_routing into common_routing;
5012 EXIT WHEN get_common_routing %NOTFOUND;
5013
5014 OPEN get_common_current_routing_rev
5015 (common_assembly_item_id => common_routing.assembly_item_id,
5016 --2809431 common_org_id => common.organization_id
5017 common_org_id => common_routing.organization_id
5018 ) ;
5019
5020
5021 FETCH get_common_current_routing_rev into
5022 common_current_rtg_rev;
5023 CLOSE get_common_current_routing_rev;
5024
5025 --* Added for Bug 4366583
5026 OPEN routing_revision_exists(
5027 common_assembly_item_id=>common_routing.assembly_item_id,
5028 common_org_id =>common_routing.organization_id,
5029 common_revision =>item.new_routing_revision);
5030 FETCH routing_revision_exists into l_rtg_revision_exists;
5031 CLOSE routing_revision_exists;
5032 --* End of Bug 4366583
5033
5034 -- 2809431 IF nlssort(common_current_rev)
5035 IF nlssort(common_current_rtg_rev) -- added for BUG 2809431
5036 < nlssort( item.new_routing_revision)
5037 AND l_rtg_revision_exists = 0 --* AND condition added for bug 4366583
5038 THEN
5039 --- Update the revision to new revision
5040 --- See if existing API can be used here
5041 --- 2809431 NULL;
5042 -- 2809431 ( added the below API to Populate common routing revision)
5043
5044
5045 ENG_COPY_TABLE_ROWS_PKG.C_MTL_RTG_ITEM_REVISIONS(
5046 X_inventory_item_id => common_routing.assembly_item_id,
5047 X_organization_id => common_routing.organization_id,
5048 X_process_revision => item.new_routing_revision,
5049 X_last_update_date => SYSDATE,
5050 X_last_updated_by => userid,
5051 X_creation_date => SYSDATE,
5052 X_created_by => userid,
5053 X_last_update_login => loginid,
5054 X_effectivity_date => eff_date,
5055 X_change_notice => item.change_notice,
5056 X_implementation_date => today);
5057
5058 -- 2809431 ( added the above API to Populate common routing revision)
5059 END IF;
5060 END LOOP;
5061 CLOSE get_common_routing;
5062
5063 END IF; -- IF item.new_routing_revision IS NOT NULL
5064
5065 --If routing change exists, Update routing header.
5066 --A new routing header should be generated from Form.
5067 -- Using RTG BO
5068 IF item.routing_sequence_id IS NOT NULL
5069 THEN
5070 SELECT alternate_routing_designator
5071 INTO l_alternate_routing_designator
5072 FROM bom_operational_routings
5073 WHERE routing_sequence_id = item.routing_sequence_id;
5074 /*
5075 BOM_Rtg_Header_Util.Query_Row
5076 ( p_assembly_item_id => item.revised_item_id
5077 , p_organization_id => item.organization_id
5078 , p_alternate_routing_code => l_alternate_routing_designator
5079 , x_rtg_header_rec => l_rtg_header_rec
5080 , x_rtg_header_unexp_rec => l_rtg_header_unexp_rec
5081 , x_Return_status => l_Return_status
5082 );
5083
5084 l_rtg_header_rec.cfm_routing_flag :=
5085 NVL(item.cfm_routing_flag, l_rtg_header_rec.cfm_routing_flag);
5086 l_rtg_header_rec.completion_subinventory :=
5087 NVL(item.completion_subinventory, l_rtg_header_rec.completion_subinventory);
5088 l_rtg_header_unexp_rec.completion_locator_id:=
5089 NVL(item.completion_locator_id, l_rtg_header_unexp_rec.completion_locator_id);
5090 l_rtg_header_rec.mixed_model_map_flag :=
5091 NVL(item.mixed_model_map_flag, l_rtg_header_rec.mixed_model_map_flag);
5092 */
5093
5094 SELECT
5095 routing_sequence_id
5096 ,cfm_routing_flag
5097 ,completion_subinventory
5098 ,completion_locator_id
5099 ,mixed_model_map_flag
5100 ,common_assembly_item_id
5101 ,common_routing_sequence_id
5102 ,ctp_flag
5103 ,priority
5104 ,routing_comment
5105 INTO
5106 l_routing_sequence_id
5107 ,l_cfm_routing_flag
5108 ,l_completion_subinventory
5109 ,l_completion_locator_id
5110 ,l_mixed_model_map_flag
5111 ,l_common_assembly_item_id
5112 ,l_common_routing_sequence_id
5113 ,l_ctp_flag
5114 ,l_priority
5115 ,l_routing_comment
5116 FROM bom_operational_routings
5117 WHERE assembly_item_id = item.revised_item_id
5118 AND organization_id = item.organization_id
5119 AND NVL(alternate_routing_designator, 'NULL_ALTERNATE_DESIGNATOR' )
5120 = NVL(l_alternate_routing_designator, 'NULL_ALTERNATE_DESIGNATOR')
5121 ;
5122
5123 --start of bugfix 3234628
5124 IF item.completion_subinventory IS NOT NULL OR
5125 item.completion_locator_id IS NOT NULL OR
5126 item.ctp_flag = 1 OR
5127 item.priority IS NOT NULL OR
5128 item.routing_comment IS NOT NULL
5129 THEN
5130
5131 UPDATE bom_operational_routings
5132 SET common_assembly_item_id =
5133 l_common_assembly_item_id
5134 , common_routing_sequence_id =
5135 l_common_routing_sequence_id
5136 , ctp_flag = NVL(item.ctp_flag,l_ctp_flag)
5137 , priority = NVL(item.priority,l_priority)
5138 , cfm_routing_flag =
5139 NVL(item.cfm_routing_flag, l_cfm_routing_flag)
5140 , routing_comment =
5141 NVL(item.routing_comment, l_routing_comment)
5142 , mixed_model_map_flag =
5143 NVL(item.mixed_model_map_flag, l_mixed_model_map_flag)
5144 , completion_subinventory =
5145 NVL(item.completion_subinventory, l_completion_subinventory)
5146 , completion_locator_id =
5147 NVL(item.completion_locator_id, l_completion_locator_id)
5148 , last_update_date = SYSDATE
5149 , last_updated_by = userid
5150 , last_update_login = loginid
5151 WHERE routing_sequence_id =
5152 l_routing_sequence_id;
5153
5154 -- ERES changes begin : bug 3908563
5155 IF SQL%ROWCOUNT > 0
5156 THEN
5157 -- ERES flag to be set for triggering Routing Event:
5158 bERES_Flag_for_Routing := TRUE;
5159 -- Bug 4455543: Set l_WIP_Flag_for_Routing when routing header is being updated by revised item
5160 l_WIP_Flag_for_Routing := 'Y';
5161 FND_FILE.PUT_LINE(FND_FILE.LOG, 'in bom_operational_routings ... bERES_Flag_for_Routing=TRUE');
5162 END IF;
5163 -- ERES changes end.
5164 END IF;
5165 --end of bugfix 3234628
5166 END IF; -- enf of IF item.routing_sequence_id IS NOT NULL
5167
5168
5169 --Check if there are revised operations or events for the routing.
5170
5171 OPEN chng_operation_rows;
5172 LOOP
5173 FETCH chng_operation_rows into chng_operation_rec;
5174 EXIT WHEN chng_operation_rows %NOTFOUND;
5175
5176
5177 --check the ECO operation conflict
5178 IF item.update_wip = 1
5179 AND chng_operation_rec.acd_type IN (acd_change, acd_delete)
5180 THEN
5181
5182 -- For ECO Cumulative type record
5183 -- Check if the current operation is not existing in
5184 -- the specified WIP discrete job.
5185 IF NVL(item.from_cum_qty, 0) > 0
5186 THEN
5187 OPEN check_not_existing_op_cum
5188 ( p_from_wip_entity_id => item.from_wip_entity_id,
5189 p_operation_seq_num => chng_operation_rec.operation_seq_num,
5190 p_organization_id => item.organization_id ) ;
5191 FETCH check_not_existing_op_cum INTO dummy;
5192 IF check_not_existing_op_cum%NOTFOUND
5193 THEN If msg_qty < max_messages then
5194 msg_qty := msg_qty + 1;
5195 message_names(msg_qty) := 'ENG_OP_ECO_CUM_CONFLICT';
5196 token1(msg_qty) := 'REVISED_ITEM';
5197 value1(msg_qty) := item.revised_item_id;
5198 translate1(msg_qty) := 0;
5199 token2(msg_qty) := 'OPERATION_SEQ_NUM';
5200 value2(msg_qty) :=
5201 chng_operation_rec.operation_seq_num;
5202 translate2(msg_qty) := 0;
5203 end if;
5204 If trial_mode = no then
5205 Raise abort_implementation;
5206 end if;
5207 END IF;
5208 CLOSE check_not_existing_op_cum;
5209 END IF; -- end of IF NVL(item.from_cum_qty, 0) > 0
5210
5211 -- For ECO Discrete Job type record
5212 -- At the WIP job range ( from_wip_job_name, to_wip_job_name),
5213 -- check if there is a WIP discrete job, in which the current
5214 -- operation has already disabled or changed.
5215 IF nvl(item.to_wip_entity_id, 0) <> 0
5216 THEN
5217 OPEN check_not_existing_op_job
5218 ( p_from_wip_entity_id => item.from_wip_entity_id,
5219 p_to_wip_entity_id => item.to_wip_entity_id,
5220 p_operation_seq_num => chng_operation_rec.operation_seq_num,
5221 p_organization_id => item.organization_id) ;
5222 FETCH check_not_existing_op_job INTO dummy;
5223 IF check_not_existing_op_job%FOUND
5224 THEN If msg_qty < max_messages then
5225 msg_qty := msg_qty + 1;
5226 message_names(msg_qty) := 'ENG_OP_ECO_JOB_CONFLICT';
5227 token1(msg_qty) := 'REVISED_ITEM';
5228 value1(msg_qty) := item.revised_item_id;
5229 translate1(msg_qty) := 0;
5230 token2(msg_qty) := 'OPERATION_SEQ_NUM';
5231 value2(msg_qty) :=
5232 chng_operation_rec.operation_seq_num;
5233 translate2(msg_qty) := 0;
5234 end if;
5235 If trial_mode = no then
5236 Raise abort_implementation;
5237 end if;
5238
5239 END IF;
5240 CLOSE check_not_existing_op_job ;
5241 END IF; -- nvl(item.to_wip_entity_id, 0) <> 0
5242
5243
5244 -- For ECO Lot type record
5245 -- Among WIP discrete jobs with same specified lot number, check
5246 -- if there is a WIP discrete job, in which the current opertion has
5247 -- already been disabled or changed.
5248 IF item.lot_number IS NOT NULL
5249 THEN
5250 OPEN check_not_existing_op_lot
5251 ( p_wip_lot_number => item.lot_number,
5252 p_operation_seq_num => chng_operation_rec.operation_seq_num);
5253 FETCH check_not_existing_op_lot INTO dummy;
5254 IF check_not_existing_op_lot%FOUND
5255 THEN If msg_qty < max_messages then
5256 msg_qty := msg_qty + 1;
5257 message_names(msg_qty) := 'ENG_OP_ECO_LOT_CONFLICT';
5258 token1(msg_qty) := 'REVISED_ITEM';
5259 value1(msg_qty) := item.revised_item_id;
5260 translate1(msg_qty) := 0;
5261 token2(msg_qty) := 'OPERATION_SEQ_NUM';
5262 value2(msg_qty) :=
5263 chng_operation_rec.operation_seq_num;
5264 translate2(msg_qty) := 0;
5265 end if;
5266 If trial_mode = no then
5267 Raise abort_implementation;
5268 end if;
5269 END IF;
5270 CLOSE check_not_existing_op_lot;
5271 END IF; -- item.lot_number IS NOT NULL
5272 END IF; -- end of IF item.update_wip = 1
5273
5274
5275 -- For operation ADD/Change type records, check the effectivity of
5276 -- operation
5277
5278 IF chng_operation_rec.acd_type IN (acd_change, acd_add)
5279 THEN
5280
5281 IF NVL(chng_operation_rec.disable_date, eff_date) < eff_date
5282 THEN If msg_qty < max_messages then
5283 msg_qty := msg_qty + 1;
5284 message_names(msg_qty) := 'ENG_OP_INVALID_DISABLE_DATE';
5285 token1(msg_qty) := 'OPERATION_SEQ_NUM';
5286 value1(msg_qty) := chng_operation_rec.operation_seq_num;
5287 translate1(msg_qty) := 0;
5288 token2(msg_qty) := 'DISABLE_DATE';
5289 value2(msg_qty) :=
5290 chng_operation_rec.disable_date;
5291 translate2(msg_qty) := 0;
5292 end if;
5293 If trial_mode = no then
5294 Raise abort_implementation;
5295 end if;
5296 END IF;
5297
5298
5299 END IF; -- end of IF chng_operation_rec.acd_type IN (acd_add, acd_change)
5300
5301
5302 IF chng_operation_rec.acd_type IN ( acd_change, acd_delete)
5303 THEN
5304
5305 Open old_operation(chng_operation_rec.old_operation_sequence_id);
5306 Fetch old_operation into old_op_rec;
5307
5308 If old_op_rec.implementation_date is null then
5309 If msg_qty < max_messages then
5310 msg_qty := msg_qty + 1;
5311 message_names(msg_qty) :=
5312 'ENG_OLD_OP_UNIMPLEMENTED';
5313 token1(msg_qty) := 'ITEM';
5314 value1(msg_qty) := item.revised_item_id;
5315 translate1(msg_qty) := 0;
5316 token2(msg_qty) := 'OPERATION';
5317 value2(msg_qty) := chng_operation_rec.operation_seq_num;
5318 translate2(msg_qty) := 0;
5319 end if;
5320 If trial_mode = no then
5321 Close old_operation;
5322 Raise abort_implementation;
5323 end if;
5324 elsif nvl(old_op_rec.disable_date,eff_date) < eff_date then
5325 If msg_qty < max_messages then
5326 msg_qty := msg_qty + 1;
5327 message_names(msg_qty) :=
5328 'ENG_OLD_OP_DISABLED';
5329 token1(msg_qty) := 'ITEM';
5330 value1(msg_qty) := item.revised_item_id;
5331 translate1(msg_qty) := 0;
5332 token2(msg_qty) := 'OPERATION';
5333 value2(msg_qty) := chng_operation_rec.operation_seq_num;
5334 translate2(msg_qty) := 0;
5335 end if;
5336 If trial_mode = no then
5337 Close old_operation;
5338 Raise abort_implementation;
5339 end if;
5340 elsif old_op_rec.effectivity_date > eff_date then
5341 If msg_qty < max_messages then
5342 msg_qty := msg_qty + 1;
5343 message_names(msg_qty) :=
5344 'ENG_OLD_OP_INEFFECTIVE';
5345 token1(msg_qty) := 'ITEM';
5346 value1(msg_qty) := item.revised_item_id;
5347 translate1(msg_qty) := 0;
5348 token2(msg_qty) := 'OPERATION';
5349 value2(msg_qty) := chng_operation_rec.operation_seq_num;
5350 translate2(msg_qty) := 0;
5351 end if;
5352 If trial_mode = no then
5353 Close old_operation;
5354 Raise abort_implementation;
5355 end if;
5356
5357 else
5358
5359 count_op_disable := count_op_disable + 1;
5360 rev_op_disable_date_tbl(count_op_disable).revised_item_id := item.revised_item_id;
5361 rev_op_disable_date_tbl(count_op_disable).operation_seq_id :=
5362 chng_operation_rec.old_operation_sequence_id;
5363 rev_op_disable_date_tbl(count_op_disable).disable_date := old_op_rec.disable_date;
5364
5365 old_op_rec.disable_date := eff_date;
5366 IF item.eco_for_production = 2
5367 THEN old_op_rec.change_notice := item.change_notice;
5368 END IF;
5369 end if;
5370
5371 If chng_operation_rec.acd_type = acd_delete then
5372 chng_operation_rec.disable_date := eff_date;
5373 end if;
5374
5375 -- Disalbe the old operation record
5376 UPDATE bom_operation_sequences
5377 SET
5378 change_notice = old_op_rec.change_notice,
5379 implementation_date = today,
5380 disable_date = old_op_rec.disable_date,
5381 --bug 5622459 disable_date = old_op_rec.disable_date - 1/(60*60*24),
5382 last_update_date = sysdate,
5383 last_updated_by = userid,
5384 last_update_login = loginid,
5385 request_id = reqstid,
5386 program_application_id = appid,
5387 program_id = progid,
5388 program_update_date = sysdate
5389 WHERE operation_sequence_id=
5390 old_op_rec.operation_sequence_id;
5391
5392 Close old_operation;
5393
5394 IF chng_operation_rec.acd_type IN (acd_change, acd_add)
5395 THEN
5396
5397 -- Check operation verlapping for date effective
5398 OPEN check_overlapping_operation
5399 ( chng_operation_rec.routing_sequence_id,
5400 chng_operation_rec.operation_seq_num,
5401 chng_operation_rec.operation_sequence_id,
5402 -- chng_operation_rec.effectivity_date -- changed for bug 2827313
5403 eff_date -- this is the date that will eventually be the effective date of the new operation
5404 );
5405 FETCH check_overlapping_operation INTO dummy;
5406 -- IF check_overlapping_operation%NOTFOUND
5407 IF check_overlapping_operation%FOUND
5408 THEN If msg_qty < max_messages then
5409 msg_qty := msg_qty + 1;
5410 message_names(msg_qty) := 'ENG_IMP_OP_INVALID_EFF_DATE';
5411 token1(msg_qty) := 'OPERATION_SEQ_NUM';
5412 value1(msg_qty) := chng_operation_rec.operation_seq_num;
5413 translate1(msg_qty) := 0;
5414 token2(msg_qty) := 'EFFECTIVE_DATE';
5415 value2(msg_qty) :=
5416 chng_operation_rec.effectivity_date;
5417 translate2(msg_qty) := 0;
5418 end if;
5419 If trial_mode = no then
5420 Raise abort_implementation;
5421 end if;
5422 END IF;
5423 CLOSE check_overlapping_operation;
5424 END IF;
5425
5426
5427 IF chng_operation_rec.acd_type = acd_change
5428 -- Copy attached resources in the old operation to the new operation,
5429 -- except the disabled resource.
5430 THEN
5431 INSERT INTO bom_operation_resources
5432 (
5433 operation_sequence_id
5434 , resource_seq_num
5435 , resource_id
5436 , activity_id
5437 , standard_rate_flag
5438 , assigned_units
5439 , usage_rate_or_amount
5440 , usage_rate_or_amount_inverse
5441 , basis_type
5442 , schedule_flag
5443 , last_update_date
5444 , last_updated_by
5445 , creation_date
5446 , created_by
5447 , last_update_login
5448 , resource_offset_percent
5449 , autocharge_type
5450 , attribute_category
5451 , attribute1
5452 , attribute2
5453 , attribute3
5454 , attribute4
5455 , attribute5
5456 , attribute6
5457 , attribute7
5458 , attribute8
5459 , attribute9
5460 , attribute10
5461 , attribute11
5462 , attribute12
5463 , attribute13
5464 , attribute14
5465 , attribute15
5466 , request_id
5467 , program_application_id
5468 , program_id
5469 , program_update_date
5470 , schedule_seq_num
5471 , substitute_group_num
5472 , principle_flag
5473 , change_notice
5474 , acd_type
5475 , original_system_reference
5476 )
5477 SELECT
5478 chng_operation_rec.operation_sequence_id
5479 , resource_seq_num
5480 , resource_id
5481 , activity_id
5482 , standard_rate_flag
5483 , assigned_units
5484 , usage_rate_or_amount
5485 , usage_rate_or_amount_inverse
5486 , basis_type
5487 , schedule_flag
5488 , sysdate
5489 , userid
5490 , sysdate
5491 , userid
5492 , loginid
5493 , resource_offset_percent
5494 , autocharge_type
5495 , attribute_category
5496 , attribute1
5497 , attribute2
5498 , attribute3
5499 , attribute4
5500 , attribute5
5501 , attribute6
5502 , attribute7
5503 , attribute8
5504 , attribute9
5505 , attribute10
5506 , attribute11
5507 , attribute12
5508 , attribute13
5509 , attribute14
5510 , attribute15
5511 , reqstid
5512 , appid
5513 , progid
5514 , sysdate
5515 , schedule_seq_num
5516 , substitute_group_num
5517 , principle_flag
5518 , change_notice
5519 , acd_type
5520 , original_system_reference
5521 FROM bom_operation_resources a
5522 WHERE operation_sequence_id =
5523 chng_operation_rec.old_operation_sequence_id
5524 --* Commented following line for Bug 3520302
5525 --* AND nvl(acd_type, acd_add) = acd_add
5526 --* Added for Bug 3520302
5527 AND nvl(acd_type, acd_add) in (acd_add,acd_change)
5528 AND resource_seq_num NOT IN (
5529 SELECT b.resource_seq_num
5530 FROM bom_operation_resources b
5531 WHERE b.operation_sequence_id =
5532 chng_operation_rec.operation_sequence_id);
5533
5534 /* Fix for bug 4606950 - In the above select query, modified the sub-query in the where clause.
5535 Replaced the resource_id with resource_seq_num. The old sub-query was commented as below*/
5536 /*
5537 AND resource_id NOT IN (
5538 SELECT b.resource_id
5539 FROM bom_operation_resources b
5540 WHERE b.operation_sequence_id =
5541 chng_operation_rec.operation_sequence_id
5542 and b.resource_seq_num = a.resource_seq_num);
5543 */
5544 -- Bug 2641382
5545 -- The above filter condition was modified to search the valid
5546 -- resources based on operation_sequence_id and resource_seq_num
5547
5548 -- Copy attached substitute resources in the old operation to the new operation,
5549 -- except the disabled substitute resource.
5550
5551 INSERT INTO bom_sub_operation_resources
5552 (
5553 operation_sequence_id
5554 , substitute_group_num
5555 , resource_id
5556 , replacement_group_num
5557 , activity_id
5558 , standard_rate_flag
5559 , assigned_units
5560 , usage_rate_or_amount
5561 , usage_rate_or_amount_inverse
5562 , basis_type
5563 , schedule_flag
5564 , last_update_date
5565 , last_updated_by
5566 , creation_date
5567 , created_by
5568 , last_update_login
5569 , resource_offset_percent
5570 , autocharge_type
5571 , principle_flag
5572 , attribute_category
5573 , attribute1
5574 , attribute2
5575 , attribute3
5576 , attribute4
5577 , attribute5
5578 , attribute6
5579 , attribute7
5580 , attribute8
5581 , attribute9
5582 , attribute10
5583 , attribute11
5584 , attribute12
5585 , attribute13
5586 , attribute14
5587 , attribute15
5588 , request_id
5589 , program_application_id
5590 , program_id
5591 , program_update_date
5592 , schedule_seq_num
5593 , change_notice
5594 , acd_type
5595 , original_system_reference
5596 )
5597 select
5598 chng_operation_rec.operation_sequence_id
5599 , substitute_group_num
5600 , resource_id
5601 , replacement_group_num
5602 , activity_id
5603 , standard_rate_flag
5604 , assigned_units
5605 , usage_rate_or_amount
5606 , usage_rate_or_amount_inverse
5607 , basis_type
5608 , schedule_flag
5609 , sysdate
5610 , userid
5611 , sysdate
5612 , userid
5613 , loginid
5614 , resource_offset_percent
5615 , autocharge_type
5616 , principle_flag
5617 , attribute_category
5618 , attribute1
5619 , attribute2
5620 , attribute3
5621 , attribute4
5622 , attribute5
5623 , attribute6
5624 , attribute7
5625 , attribute8
5626 , attribute9
5627 , attribute10
5628 , attribute11
5629 , attribute12
5630 , attribute13
5631 , attribute14
5632 , attribute15
5633 , reqstid
5634 , appid
5635 , progid
5636 , sysdate
5637 , schedule_seq_num
5638 , change_notice
5639 , acd_type
5640 , original_system_reference
5641 FROM bom_sub_operation_resources
5642 WHERE operation_sequence_id =
5643 chng_operation_rec.old_operation_sequence_id
5644 AND nvl(acd_type, acd_add) = acd_add
5645 AND resource_id NOT IN (
5646 SELECT resource_id
5647 FROM bom_sub_operation_resources
5648 WHERE operation_sequence_id =
5649 chng_operation_rec.operation_sequence_id );
5650
5651 -- Copy attachment of the Operation Sequences
5652 -- Added for Bug 3701023
5653 FND_ATTACHED_DOCUMENTS2_PKG.copy_attachments(
5654 X_from_entity_name => 'BOM_OPERATION_SEQUENCES'
5655 , X_from_pk1_value => to_char(chng_operation_rec.old_operation_sequence_id)
5656 , X_from_pk2_value => null
5657 , X_from_pk3_value => null
5658 , X_from_pk4_value => null
5659 , X_from_pk5_value => null
5660 , X_to_entity_name => 'BOM_OPERATION_SEQUENCES'
5661 , X_to_pk1_value => to_char(chng_operation_rec.operation_sequence_id)
5662 , X_to_pk2_value => null
5663 , X_to_pk3_value => null
5664 , X_to_pk4_value => null
5665 , X_to_pk5_value => null
5666 , X_created_by => userid
5667 , X_last_update_login => loginid
5668 , X_program_application_id => appid
5669 , X_program_id => progid
5670 , X_request_id => reqstid);
5671
5672 -- End Changes for Bug 3701023
5673
5674
5675 END IF; -- IF chng_operation_rec.acd_type = acd_change
5676
5677
5678
5679 END IF; -- end of IF chng_operation_rec.acd_type in ( acd_change, acd_delete )
5680
5681 IF chng_operation_rec.acd_type = acd_change
5682 THEN
5683
5684 -- The following is for resource process
5685 --Check resource Add/Disable record existing
5686 OPEN chng_resource_rows;
5687 LOOP
5688 FETCH chng_resource_rows into chng_resource_rec;
5689 EXIT WHEN chng_resource_rows%NOTFOUND;
5690
5691 -- Resource conflict check
5692 IF item.update_wip = 1
5693 AND chng_resource_rec.acd_type IN ( acd_change, acd_delete)
5694 THEN
5695
5696 --For ECO Cumulative type record
5697 --Check if the current resource is not existing in the
5698 --specified WIP discrete job'operation.
5699 IF NVL(item.from_cum_qty, 0) > 0
5700 THEN
5701
5702 OPEN check_not_existing_res_cum
5703 (p_from_wip_entity_id => item.from_wip_entity_id,
5704 p_operation_seq_num => chng_operation_rec.operation_seq_num,
5705 p_resource_seq_num => chng_resource_rec.resource_seq_num,
5706 p_organization_id => item.organization_id
5707 ) ;
5708 FETCH check_not_existing_res_cum INTO dummy;
5709 IF check_not_existing_res_cum%NOTFOUND
5710 THEN If msg_qty < max_messages then
5711 msg_qty := msg_qty + 1;
5712 message_names(msg_qty) := 'ENG_RES_ECO_CUM_CONFLICT';
5713 token1(msg_qty) := 'OPERATION_SEQ_NUM';
5714 value1(msg_qty) :=
5715 to_char(chng_operation_rec.operation_seq_num);
5716 translate1(msg_qty) := 0;
5717 token2(msg_qty) := 'RESOURCE_SEQ_NUM';
5718 value2(msg_qty) :=
5719 to_char(chng_resource_rec.resource_seq_num);
5720 translate2(msg_qty) := 0;
5721 end if;
5722 If trial_mode = no then
5723 Raise abort_implementation;
5724 end if;
5725
5726 END IF; -- end of check_not_existing_res_cum%NOTFOUND
5727 CLOSE check_not_existing_res_cum;
5728 END IF; -- end of NVL(item.from_cum_qty, 0) > 0
5729
5730
5731 --For ECO Discrete Job type record
5732 --At the WIP job range ( from_wip_job_name, to_wip_job_name),
5733 --check if there is a WIP discrete job, in which the current
5734 --resouce has already been disabled or changed.
5735 IF nvl(item.to_wip_entity_id, 0) <> 0
5736 THEN
5737 OPEN check_not_existing_res_job
5738 ( p_from_wip_entity_id=> item.from_wip_entity_id,
5739 p_to_wip_entity_id => item.to_wip_entity_id,
5740 p_operation_seq_num => chng_operation_rec.operation_seq_num,
5741 p_resource_seq_num => chng_resource_rec.resource_seq_num,
5742 p_organization_id => item.organization_id
5743 ) ;
5744 FETCH check_not_existing_res_job INTO dummy;
5745 IF check_not_existing_res_job%FOUND
5746 THEN If msg_qty < max_messages then
5747 msg_qty := msg_qty + 1;
5748 message_names(msg_qty) := 'ENG_RES_ECO_JOB_CONFLICT';
5749 token1(msg_qty) := 'OPERATION_SEQ_NUM';
5750 value1(msg_qty) :=
5751 to_char(chng_operation_rec.operation_seq_num);
5752 translate1(msg_qty) := 0;
5753 token2(msg_qty) := 'RESOURCE_SEQ_NUM';
5754 value2(msg_qty) :=
5755 to_char(chng_resource_rec.resource_seq_num);
5756 translate2(msg_qty) := 0;
5757
5758 end if;
5759 If trial_mode = no then
5760 Raise abort_implementation;
5761 end if;
5762
5763 END IF; -- end ofcheck_not_existing_res_job%FOUND
5764 CLOSE check_not_existing_res_job;
5765 END IF; -- envl(item.to_wip_entity_id, 0) <> 0
5766
5767 --For ECO Lot type record
5768 --Among WIP discrete jobs with same specified lot number,
5769 -- check if there is a WIP discrete job, in which the
5770 -- current component has already been disabled or changed.
5771 IF item.lot_number IS NOT NULL
5772 THEN
5773 OPEN check_not_existing_res_lot
5774 ( p_wip_lot_number => item.lot_number,
5775 p_operation_seq_num => chng_operation_rec.operation_seq_num,
5776 p_resource_seq_num => chng_resource_rec.resource_seq_num,
5777 p_organization_id => item.organization_id
5778 );
5779 FETCH check_not_existing_res_lot INTO dummy;
5780 IF check_not_existing_res_lot%FOUND
5781 THEN If msg_qty < max_messages then
5782 msg_qty := msg_qty + 1;
5783 message_names(msg_qty) := 'ENG_RES_ECO_LOT_CONFLICT';
5784 token1(msg_qty) := 'OPERATION_SEQ_NUM';
5785 value1(msg_qty) :=
5786 to_char(chng_operation_rec.operation_seq_num);
5787 translate1(msg_qty) := 0;
5788 token2(msg_qty) := 'RESOURCE_SEQ_NUM';
5789 value2(msg_qty) :=
5790 to_char(chng_resource_rec.resource_seq_num);
5791 translate2(msg_qty) := 0;
5792 end if;
5793 If trial_mode = no then
5794 Raise abort_implementation;
5795 end if;
5796 END IF; -- check_not_existing_res_lot%FOUND
5797 CLOSE check_not_existing_res_lot;
5798 END IF; -- end of IF item.lot_number IS NOT NULL
5799
5800 END IF; -- end of IF item.update_wip = 1 and chng_resource_rec
5801 --
5802 -- Check whether all resources in same resource group have been
5803 -- disabled, if so, delete the sub resources too.
5804 /* Commented the below delete st for bug 4577459 . This delete st deletes all rows from the table
5805 that have been created through the routing form irrespective of which routing they belong to.
5806 As while implementing the ECO we do not delete the bom_operation_resources data the sub resources
5807 associated need not be deleted */
5808 /* DELETE
5809 FROM bom_sub_operation_resources sr
5810 WHERE NOT EXISTS (
5811 SELECT 1
5812 FROM bom_operation_resources bor
5813 WHERE bor.operation_sequence_id = sr.operation_sequence_id
5814 AND bor.substitute_group_num = sr.substitute_group_num
5815 AND bor.acd_type <> 3
5816 );*/
5817
5818
5819 END LOOP; -- end of OPEN chng_resource_rows Loop
5820
5821 CLOSE chng_resource_rows;
5822
5823 END IF; -- end of IF chng_operation_rec.acd_type = acd_change
5824
5825 -- Implement the current operation row.
5826 UPDATE bom_operation_sequences
5827 SET
5828 change_notice = item.change_notice,
5829 implementation_date = today,
5830 disable_date = chng_operation_rec.disable_date,
5831 effectivity_date = eff_date,
5832 last_update_date = sysdate,
5833 last_updated_by = userid,
5834 last_update_login = loginid,
5835 request_id = reqstid,
5836 program_application_id = appid,
5837 program_id = progid,
5838 program_update_date = sysdate
5839 WHERE operation_sequence_id =
5840 chng_operation_rec.operation_sequence_id;
5841
5842
5843 --
5844 -- Update all unimplemented rows that point to the old row, so that they now
5845 -- point to the new operation row.
5846 --
5847
5848 If chng_operation_rec.acd_type = acd_change then
5849 --fix for bug 1607851
5850 IF item.eco_for_production = 2 THEN
5851 Update bom_operation_sequences
5852 set old_operation_sequence_id = chng_operation_rec.operation_sequence_id,
5853 last_update_date = sysdate,
5854 last_updated_by = userid,
5855 last_update_login = loginid,
5856 request_id = reqstid,
5857 program_application_id = appid,
5858 program_id = progid,
5859 program_update_date = sysdate
5860 where old_operation_sequence_id =
5861 chng_operation_rec.old_operation_sequence_id
5862 and implementation_date is null;
5863 END IF;
5864 end if; -- reset pointers
5865
5866 -- Copy all implemented operations to eng_revised_operations.
5867
5868 INSERT into eng_revised_operations(
5869 operation_sequence_id ,
5870 routing_sequence_id ,
5871 operation_seq_num ,
5872 last_update_date ,
5873 last_updated_by ,
5874 creation_date ,
5875 created_by ,
5876 last_update_login ,
5877 standard_operation_id ,
5878 department_id ,
5879 operation_lead_time_percent ,
5880 minimum_transfer_quantity ,
5881 count_point_type ,
5882 operation_description ,
5883 effectivity_date ,
5884 disable_date ,
5885 backflush_flag ,
5886 option_dependent_flag ,
5887 attribute_category ,
5888 attribute1 ,
5889 attribute2 ,
5890 attribute3 ,
5891 attribute4 ,
5892 attribute5 ,
5893 attribute6 ,
5894 attribute7 ,
5895 attribute8 ,
5896 attribute9 ,
5897 attribute10 ,
5898 attribute11 ,
5899 attribute12 ,
5900 attribute13 ,
5901 attribute14 ,
5902 attribute15 ,
5903 request_id ,
5904 program_application_id ,
5905 program_id ,
5906 program_update_date ,
5907 operation_type ,
5908 reference_flag ,
5909 process_op_seq_id ,
5910 line_op_seq_id ,
5911 yield ,
5912 cumulative_yield ,
5913 reverse_cumulative_yield ,
5914 labor_time_calc ,
5915 machine_time_calc ,
5916 total_time_calc ,
5917 labor_time_user ,
5918 machine_time_user ,
5919 total_time_user ,
5920 net_planning_percent ,
5921 --x_coodinate,
5922 --y_coordinate,
5923 include_in_rollup ,
5924 operation_yield_enabled ,
5925 change_notice ,
5926 implementation_date ,
5927 old_operation_sequence_id ,
5928 acd_type ,
5929 revised_item_sequence_id ,
5930 original_system_reference,
5931 eco_for_production
5932 )
5933 SELECT
5934 operation_sequence_id ,
5935 routing_sequence_id ,
5936 operation_seq_num ,
5937 last_update_date ,
5938 last_updated_by ,
5939 creation_date ,
5940 created_by ,
5941 last_update_login ,
5942 standard_operation_id ,
5943 department_id ,
5944 operation_lead_time_percent ,
5945 minimum_transfer_quantity ,
5946 count_point_type ,
5947 operation_description ,
5948 effectivity_date ,
5949 disable_date ,
5950 backflush_flag ,
5951 option_dependent_flag ,
5952 attribute_category ,
5953 attribute1 ,
5954 attribute2 ,
5955 attribute3 ,
5956 attribute4 ,
5957 attribute5 ,
5958 attribute6 ,
5959 attribute7 ,
5960 attribute8 ,
5961 attribute9 ,
5962 attribute10 ,
5963 attribute11 ,
5964 attribute12 ,
5965 attribute13 ,
5966 attribute14 ,
5967 attribute15 ,
5968 request_id ,
5969 program_application_id ,
5970 program_id ,
5971 program_update_date ,
5972 operation_type ,
5973 reference_flag ,
5974 process_op_seq_id ,
5975 line_op_seq_id ,
5976 yield ,
5977 cumulative_yield ,
5978 reverse_cumulative_yield ,
5979 labor_time_calc ,
5980 machine_time_calc ,
5981 total_time_calc ,
5982 labor_time_user ,
5983 machine_time_user ,
5984 total_time_user ,
5985 net_planning_percent ,
5986 --x_coodinate,
5987 --y_coordinate,
5988 include_in_rollup ,
5989 operation_yield_enabled ,
5990 change_notice ,
5991 implementation_date ,
5992 old_operation_sequence_id ,
5993 acd_type ,
5994 revised_item_sequence_id ,
5995 original_system_reference,
5996 eco_for_production
5997 FROM bom_operation_sequences b
5998 WHERE operation_sequence_id
5999 = chng_operation_rec.operation_sequence_id;
6000
6001 IF chng_operation_rec.acd_type = acd_delete then
6002 Delete from bom_operation_sequences
6003 where operation_sequence_id = chng_operation_rec.operation_sequence_id;
6004 END IF;
6005
6006 -- ERES changes begin : bug 3908563
6007 -- ERES flag to be set for triggering Routing Event:
6008 bERES_Flag_for_Routing := TRUE;
6009 -- Bug 4455543: Set l_WIP_Flag_for_Routing when routing details is being updated by revised item
6010 l_WIP_Flag_for_Routing := 'Y';
6011 FND_FILE.PUT_LINE(FND_FILE.LOG, 'in chng_operation_rows loop... bERES_Flag_for_Routing=TRUE');
6012 -- ERES changes end.
6013
6014 END LOOP;
6015
6016 CLOSE chng_operation_rows;
6017
6018 -- For ECO cumulative/ECO wip job/ECO lot ---------8/2/2000----
6019 -----------------------------------------------------------------
6020
6021 -- ECO for Bills implementation process
6022 --
6023 -- Select all component rows for the assembly and change notice in
6024 -- question from bom_inventory_components
6025 --
6026 -- if the common bom has a diiferent effectivity from the scheduled date then
6027 -- reset the eff_date value used for processing
6028 -- assuming that the components with the same effectivity are grouped together
6029 IF l_common_bom_eff_date IS NOT NULL
6030 THEN
6031 eff_date := l_common_bom_eff_date;
6032 END IF;
6033
6034 For component in chng_component_rows(item.bill_sequence_id) loop
6035
6036 -- Get pending from ecn to check if structure created through this revised item or not.
6037 -- Mark the BOM header as no longer pending from ECO
6038 --
6039 -- ERES Change begins
6040 -- Decision for BillCreate or Update depends on pending_from_ecn:
6041 OPEN Get_Bill_of_Materials_Info( item.bill_sequence_id);
6042 FETCH Get_Bill_of_Materials_Info
6043 INTO l_pending_from_ecn
6044 , l_alternate_designator;
6045 CLOSE Get_Bill_of_Materials_Info;
6046 -- ERES change ends
6047
6048 IF( l_pending_from_ecn IS NOT NULL AND l_pending_from_ecn <> item.change_notice ) then
6049 If msg_qty < max_messages then
6050 msg_qty := msg_qty + 1;
6051 message_names(msg_qty) := 'ENG_PENDING_BILL_EXIST';
6052 token1(msg_qty) := 'ECO_NAME';
6053 value1(msg_qty) := l_pending_from_ecn;
6054 translate1(msg_qty) := 0;
6055 end if;
6056 If trial_mode = no then
6057 Raise abort_implementation;
6058 end if;
6059 end if;
6060
6061 --BOM ER 9946990 begin
6062 if item.bom_item_type = 4 and item.pick_components_flag = 'Y'
6063 and component.bom_item_type = 4 and component.replenish_to_order_flag = 'Y'
6064 and nvl(FND_PROFILE.value('BOM:MANDATORY_ATO_IN_PTO'), 2) <> 1
6065 then
6066 If msg_qty < max_messages then
6067 msg_qty := msg_qty + 1;
6068 message_names(msg_qty) := 'BOM_KIT_COMP_PRF_NOT_SET';
6069 token1(msg_qty) := null;
6070 value1(msg_qty) := null;
6071 translate1(msg_qty) := 0;
6072 token2(msg_qty) := null;
6073 value2(msg_qty) := null;
6074 translate2(msg_qty) := 0;
6075 end if;
6076 If trial_mode = no then
6077 Raise abort_implementation;
6078 end if;
6079
6080 end if;
6081
6082 if item.bom_item_type = 1 and item.pick_components_flag = 'Y'
6083 and component.bom_item_type = 4 and component.replenish_to_order_flag = 'Y'
6084 and nvl(component.optional, 1) = 2
6085 and nvl(FND_PROFILE.value('BOM:MANDATORY_ATO_IN_PTO'), 2) <> 1
6086 then
6087 If msg_qty < max_messages then
6088 msg_qty := msg_qty + 1;
6089 message_names(msg_qty) := 'BOM_MODEL_COMP_PRF_NOT_SET';
6090 token1(msg_qty) := null;
6091 value1(msg_qty) := null;
6092 translate1(msg_qty) := 0;
6093 token2(msg_qty) := null;
6094 value2(msg_qty) := null;
6095 translate2(msg_qty) := 0;
6096 end if;
6097 If trial_mode = no then
6098 Raise abort_implementation;
6099 end if;
6100
6101 end if;
6102 --BOM ER 9946990 end
6103
6104 If component.acd_type in (acd_change, acd_add) and
6105 component.disable_date < eff_date then
6106 If msg_qty < max_messages then
6107 msg_qty := msg_qty + 1;
6108 message_names(msg_qty) := 'ENG_COMPONENT_ACD_DISABLED';
6109 token1(msg_qty) := 'ITEM';
6110 value1(msg_qty) := component.item_number;
6111 translate1(msg_qty) := 0;
6112 token2(msg_qty) := null;
6113 value2(msg_qty) := null;
6114 translate2(msg_qty) := 0;
6115 end if;
6116 If trial_mode = no then
6117 Raise abort_implementation;
6118 end if;
6119 end if;
6120
6121 -- Check for mfg assemblies with eng components.
6122
6123 /*bug 2264654
6124 Changed the condition to check for mfg assemblies instead of mfg items*/
6125
6126 begin
6127
6128 select assembly_type
6129 into l_bom_assembly_type
6130 from bom_bill_of_materials
6131 where bill_sequence_id = item.bill_sequence_id;
6132
6133 end;
6134
6135 -- If item.eng_item_flag = 'N' and
6136
6137 If l_bom_assembly_type = 1 and
6138 component.eng_item_flag = 'Y' then
6139 If msg_qty < max_messages then
6140 msg_qty := msg_qty + 1;
6141 token1(msg_qty) := null;
6142 value1(msg_qty) := null;
6143 translate1(msg_qty) := 0;
6144 token2(msg_qty) := null;
6145 value2(msg_qty) := null;
6146 translate2(msg_qty) := 0;
6147 message_names(msg_qty) := 'ENG_ENG_COMPONENTS';
6148 end if;
6149 If trial_mode = no then
6150 Raise abort_implementation;
6151 end if;
6152 end if;
6153
6154 -- Added validation for bug 4213886
6155 -- Check for component items with unimplemented component item revision.
6156 IF (component.component_item_revision_id IS NOT null)
6157 THEN
6158 l_compitem_rev_impldate := null;
6159 Open c_get_revision(component.component_item_revision_id);
6160 Fetch c_get_revision into l_compitem_rev, l_compitem_rev_impldate;
6161 IF c_get_revision%NOTFOUND
6162 THEN
6163 If msg_qty < max_messages
6164 Then
6165 msg_qty := msg_qty + 1;
6166 token1(msg_qty) := 'ITEM';
6167 value1(msg_qty) := component.item_number;
6168 translate1(msg_qty) := 0;
6169 token2(msg_qty) := 'OP_SEQ_NUM';
6170 value2(msg_qty) := to_char(component.operation_seq_num);
6171 translate2(msg_qty) := 0;
6172 message_names(msg_qty) := 'ENG_COMP_ITM_REV_INVALID';
6173 IF trial_mode = no
6174 THEN
6175 Close c_get_revision;
6176 RAISE abort_implementation;
6177 END IF;
6178 END IF;
6179 ELSIF c_get_revision%FOUND AND l_compitem_rev_impldate IS NULL
6180 THEN
6181 If msg_qty < max_messages
6182 Then
6183 msg_qty := msg_qty + 1;
6184 token1(msg_qty) := 'ITEM';
6185 value1(msg_qty) := component.item_number;
6186 translate1(msg_qty) := 0;
6187 token2(msg_qty) := 'OP_SEQ_NUM';
6188 value2(msg_qty) := to_char(component.operation_seq_num);
6189 translate2(msg_qty) := 0;
6190 message_names(msg_qty) := 'ENG_COMP_ITM_REV_UNIMPL';
6191 IF trial_mode = no
6192 THEN
6193 Close c_get_revision;
6194 RAISE abort_implementation;
6195 END IF;
6196 End If;
6197 END IF;
6198 Close c_get_revision;
6199 END IF;
6200 -- End changes for bug 4213886
6201
6202 -- check from and to unit numbers.
6203 -- Unit Effectivity implementation
6204 If (X_UnitEff_RevItem = 'Y')
6205 then
6206 if (component.from_end_item_unit_number is NULL)
6207 then
6208 If msg_qty < max_messages then
6209 msg_qty := msg_qty + 1;
6210 token1(msg_qty) := null;
6211 value1(msg_qty) := null;
6212 translate1(msg_qty) := 0;
6213 token2(msg_qty) := null;
6214 value2(msg_qty) := null;
6215 translate2(msg_qty) := 0;
6216 message_names(msg_qty) :=
6217 'ENG_RCOMP_UNIT_KEYCOL_NULL';
6218 end if;
6219 If trial_mode = no then
6220 Raise abort_implementation;
6221 end if;
6222 end if;
6223
6224 if (component.to_end_item_unit_number is not null AND
6225 component.to_end_item_unit_number < component.from_end_item_unit_number)
6226 then
6227 If msg_qty < max_messages then
6228 msg_qty := msg_qty + 1;
6229 message_names(msg_qty) :=
6230 'ENG_TOUNIT_LESSTHAN_FROMUNIT';
6231 token1(msg_qty) := 'ITEM';
6232 value1(msg_qty) := component.item_number;
6233 translate1(msg_qty) := 0;
6234 token2(msg_qty) := 'OP_SEQ_NUM';
6235 value2(msg_qty) :=
6236 to_char(component.operation_seq_num);
6237 translate2(msg_qty) := 0;
6238 end if;
6239 If trial_mode = no then
6240 Raise abort_implementation;
6241 end if;
6242 end if;
6243 end if;
6244
6245 --------------------------------------------------------------------------
6246 --For ECO cumulative/ECO WIP job/ECO lot 8/2/2000 ---------
6247 --IFACD type = CHANGE or DISABLE, check the followings.
6248
6249
6250 -- Component conflict check
6251 IF item.update_wip = 1
6252 AND component.acd_type IN (2, 3)
6253 THEN
6254 --For ECO Cumulative type record
6255 --Check if the current compoment is not existing in the
6256 --specified WIP discrete job'operation.
6257 IF NVL(item.from_cum_qty, 0) > 0
6258 THEN
6259 OPEN check_not_existing_comp_cum
6260 (p_from_wip_entity_id => item.from_wip_entity_id,
6261 p_operation_seq_num => component.operation_seq_num,
6262 p_inventory_item_id => component.component_item_id,
6263 p_organization_id => item.organization_id
6264 ) ;
6265 FETCH check_not_existing_comp_cum INTO dummy;
6266 IF check_not_existing_comp_cum%NOTFOUND
6267 THEN If msg_qty < max_messages then
6268 msg_qty := msg_qty + 1;
6269 message_names(msg_qty) := 'ENG_COMP_ECO_CUM_CONFLICT';
6270 token1(msg_qty) := 'COMPONENT';
6271 value1(msg_qty) :=component.component_item_id;
6272 translate1(msg_qty) := 0;
6273 token2(msg_qty) := 'OP_SEQ_NUM';
6274 value2(msg_qty) :=
6275 to_char(component.operation_seq_num);
6276 translate2(msg_qty) := 0;
6277 end if;
6278 If trial_mode = no then
6279 Raise abort_implementation;
6280 end if;
6281
6282 END IF; -- end of check_not_existing_res_cum%NOTFOUND
6283 CLOSE check_not_existing_comp_cum;
6284
6285 END IF; -- end of NVL(item.from_cum_qty, 0) > 0
6286
6287
6288 --For ECO Discrete Job type record
6289 --At the WIP job range ( from_wip_job_name, to_wip_job_name),
6290 --check if there is a WIP discrete job, in which the current
6291 --comp has already been disabled or changed.
6292 IF nvl(item.to_wip_entity_id, 0) <> 0
6293 THEN
6294
6295 -- code to resolve the bug 2722280 begin
6296 if (component.acd_type = 2) then
6297 OPEN get_old_operation_seq_num
6298 ( p_old_component_sequence_id => component.old_component_sequence_id );
6299
6300 FETCH get_old_operation_seq_num INTO l_old_op_seq_num;
6301 CLOSE get_old_operation_seq_num;
6302 else
6303 l_old_op_seq_num := component.operation_seq_num;
6304 end if;
6305 -- 2722280 completed
6306
6307 if (l_old_op_seq_num <> 1) then --2974766
6308
6309 OPEN check_not_existing_comp_job
6310 ( p_from_wip_entity_id => item.from_wip_entity_id,
6311 p_to_wip_entity_id => item.to_wip_entity_id,
6312 -- 2722280 p_operation_seq_num => component.operation_seq_num,
6313 p_operation_seq_num => l_old_op_seq_num,
6314 p_inventory_item_id => component.component_item_id,
6315 p_organization_id => item.organization_id
6316 );
6317
6318 FETCH check_not_existing_comp_job INTO dummy;
6319 IF check_not_existing_comp_job%FOUND
6320 THEN If msg_qty < max_messages then
6321 msg_qty := msg_qty + 1;
6322 message_names(msg_qty) := 'ENG_COMP_ECO_JOB_CONFLICT';
6323 token1(msg_qty) := 'COMPONENT';
6324 value1(msg_qty) :=component.component_item_id;
6325 translate1(msg_qty) := 0;
6326 token2(msg_qty) := 'OP_SEQ_NUM';
6327 value2(msg_qty) :=
6328 to_char(component.operation_seq_num);
6329 translate2(msg_qty) := 0;
6330 end if;
6331 If trial_mode = no then
6332 Raise abort_implementation;
6333 end if;
6334
6335 END IF; -- end of check_not_existing_comp_job%FOUND
6336 CLOSE check_not_existing_comp_job;
6337 End if; --2974766
6338 END IF;
6339
6340 -- For ECO Lot type record
6341 -- Among WIP discrete jobs with same specified lot number,
6342 -- check if there is a WIP discrete job, in which the
6343 -- current component has already been disabled or changed.
6344 IF item.lot_number IS NOT NULL
6345 THEN
6346 OPEN check_not_existing_comp_lot
6347 ( p_wip_lot_number => item.lot_number,
6348 p_operation_seq_num => component.operation_seq_num,
6349 p_inventory_item_id => component.component_item_id,
6350 p_organization_id => item.organization_id
6351 );
6352 FETCH check_not_existing_comp_lot INTO dummy;
6353 IF check_not_existing_comp_lot%FOUND
6354 THEN If msg_qty < max_messages then
6355 msg_qty := msg_qty + 1;
6356 message_names(msg_qty) := 'ENG_COMP_ECO_LOT_CONFLICT';
6357 token1(msg_qty) := 'COMPONENT';
6358 value1(msg_qty) :=component.component_item_id;
6359 translate1(msg_qty) := 0;
6360 token2(msg_qty) := 'OP_SEQ_NUM';
6361 value2(msg_qty) :=
6362 to_char(component.operation_seq_num);
6363 translate2(msg_qty) := 0;
6364 end if;
6365 If trial_mode = no then
6366 Raise abort_implementation;
6367 end if;
6368 END IF; -- check_not_existing_comp_lot%FOUND
6369 CLOSE check_not_existing_comp_lot;
6370 END IF; -- item.lot_number IS NOT NULL
6371 END IF; -- end of IF item.update_wip = 1
6372
6373 --For ECO cumulative/ECO WIP job/ECO lot 8/2/2000 ---------
6374 -------------------------------------------------------------------------
6375 --
6376 -- Added For 11510+ Enhancement
6377 -- Begin Validations For End-Item-Revision Effectivity
6378 --
6379 If (l_revision_eff_bill = 'Y')
6380 then
6381 -- Validate that from_end_item_revision_id is not null
6382 if (component.from_end_item_rev_id is NULL or component.from_end_item_rev_id <> item.from_end_item_rev_id)
6383 then
6384 If msg_qty < max_messages
6385 then
6386 msg_qty := msg_qty + 1;
6387 token1(msg_qty) := null;
6388 value1(msg_qty) := null;
6389 translate1(msg_qty) := 0;
6390 token2(msg_qty) := null;
6391 value2(msg_qty) := null;
6392 translate2(msg_qty) := 0;
6393 message_names(msg_qty) := 'ENG_RCOMP_REV_KEYCOL_INVALID';
6394 end if;
6395 If trial_mode = no
6396 then
6397 Raise abort_implementation;
6398 end if;
6399 end if;
6400
6401 -- Validate that from_end_item_revision_id is implemented
6402 if (l_from_revision is NULL)
6403 then
6404 If msg_qty < max_messages
6405 then
6406 msg_qty := msg_qty + 1;
6407 token1(msg_qty) := 'ITEM';
6408 value1(msg_qty) := component.item_number;
6409 translate1(msg_qty) := 0;
6410 token2(msg_qty) := 'OP_SEQ_NUM';
6411 value2(msg_qty) := to_char(component.operation_seq_num);
6412 translate2(msg_qty) := 0;
6413 message_names(msg_qty) := 'ENG_RCOMP_FROM_REV_UNIMPL';
6414 end if;
6415 If trial_mode = no
6416 then
6417 Raise abort_implementation;
6418 end if;
6419 end if;
6420 -- Validate that to_end_item_revision_id is implemented
6421 l_to_rev_eff_date := null;
6422 l_to_revision := null;
6423 If(component.to_end_item_rev_id is not null)
6424 Then
6425 Open check_impl_revision(component.to_end_item_rev_id, l_from_end_item_id, item.organization_id);
6426 Fetch check_impl_revision into l_to_rev_eff_date, l_to_revision;
6427 Close check_impl_revision;
6428 if (l_to_revision is NULL)
6429 then
6430 If msg_qty < max_messages then
6431 msg_qty := msg_qty + 1;
6432 token1(msg_qty) := 'ITEM';
6433 value1(msg_qty) := component.item_number;
6434 translate1(msg_qty) := 0;
6435 token2(msg_qty) := 'OP_SEQ_NUM';
6436 value2(msg_qty) := to_char(component.operation_seq_num);
6437 translate2(msg_qty) := 0;
6438 message_names(msg_qty) := 'ENG_RCOMP_TO_REV_UNIMPL';
6439 end if;
6440 If trial_mode = no
6441 then
6442 Raise abort_implementation;
6443 end if;
6444 end if;
6445 End If;
6446
6447 -- Validate that Effectivity_date of from_end_item_revision_id is less than the the
6448 -- Effectivity_date of to_end_item_revision_id of the component
6449 If(l_from_revision is not null and l_to_revision is not null
6450 and l_from_revision > l_to_revision)
6451 Then
6452 If msg_qty < max_messages
6453 then
6454 msg_qty := msg_qty + 1;
6455 token1(msg_qty) :='ITEM';
6456 value1(msg_qty) := component.item_number;
6457 translate1(msg_qty) := 0;
6458 token2(msg_qty) := 'OP_SEQ_NUM';
6459 value2(msg_qty) := to_char(component.operation_seq_num);
6460 translate2(msg_qty) := 0;
6461 message_names(msg_qty) := 'ENG_TOREV_LESSTHAN_FROMREV';
6462 end if;
6463 If trial_mode = no
6464 then
6465 Raise abort_implementation;
6466 end if;
6467 End If;
6468
6469 -- Validate that from_end_item_revision_id is effective i.e its effectivity_date
6470 -- is current or in future
6471
6472 If(l_current_end_item_revision > l_from_revision)
6473 Then
6474 If msg_qty < max_messages
6475 then
6476 msg_qty := msg_qty + 1;
6477 token1(msg_qty) := 'ITEM';
6478 value1(msg_qty) := component.item_number;
6479 translate1(msg_qty) := 0;
6480 token2(msg_qty) := 'OP_SEQ_NUM';
6481 value2(msg_qty) := to_char(component.operation_seq_num);
6482 translate2(msg_qty) := 0;
6483 message_names(msg_qty) := 'ENG_RCOMP_CURRREV_GREATER';
6484 end if;
6485 If trial_mode = no
6486 then
6487 Raise abort_implementation;
6488 end if;
6489 End If;
6490 End If;
6491 -- End Validations For End-Item-Revision Effectivity
6492 -- End Changes: 11510+ Enhancement
6493 --
6494
6495 If component.acd_type in (acd_change, acd_delete)
6496 then
6497 -- Fetch The Old component Details For Validations
6498 Open old_component(component.old_component_sequence_id);
6499 Fetch old_component into old_comp_rec;
6500
6501
6502 -- Case 1: Check if old component is implemented
6503 If old_comp_rec.implementation_date is null
6504 then
6505 If msg_qty < max_messages
6506 then
6507 msg_qty := msg_qty + 1;
6508 message_names(msg_qty) := 'ENG_OLD_COMP_UNIMPLEMENTED';
6509 token1(msg_qty) := 'ITEM';
6510 value1(msg_qty) := component.item_number;
6511 translate1(msg_qty) := 0;
6512 token2(msg_qty) := null;
6513 value2(msg_qty) := null;
6514 translate2(msg_qty) := 0;
6515 end if;
6516 If trial_mode = no
6517 then
6518 Close old_component;
6519 Raise abort_implementation;
6520 end if;
6521
6522 -- Case 2: Check that the old component is effective for CHANGE/DISABLE
6523 -- that is, the old component has not been disabled
6524 -- Changes Done For : 11510+ Enhancement
6525 elsif old_comp_rec.disable_date is not null
6526 then
6527 l_disabled_old_comp := 2;
6528 If (X_UnitEff_RevItem = 'Y' or l_revision_eff_bill = 'Y')
6529 Then
6530 l_disabled_old_comp := 1;
6531 Elsif (old_comp_rec.disable_date < eff_date)
6532 Then
6533 l_disabled_old_comp := 1;
6534 End If;
6535 If( l_disabled_old_comp = 1)
6536 Then
6537 If msg_qty < max_messages
6538 then
6539 msg_qty := msg_qty + 1;
6540 message_names(msg_qty) := 'ENG_OLD_COMP_DISABLED';
6541 token1(msg_qty) := 'ITEM';
6542 value1(msg_qty) := component.item_number;
6543 translate1(msg_qty) := 0;
6544 token2(msg_qty) := null;
6545 value2(msg_qty) := null;
6546 translate2(msg_qty) := 0;
6547 end if;
6548 If trial_mode = no
6549 then
6550 Close old_component;
6551 Raise abort_implementation;
6552 end if;
6553 End If;
6554 -- Case 3: Check the effectivity for date effective structures
6555 elsif (old_comp_rec.effectivity_date > eff_date and X_UnitEff_RevItem = 'N' AND l_revision_eff_bill = 'N')
6556 then
6557 If msg_qty < max_messages
6558 then
6559 msg_qty := msg_qty + 1;
6560 message_names(msg_qty) := 'ENG_OLD_COMP_INEFFECTIVE';
6561 token1(msg_qty) := 'ITEM';
6562 value1(msg_qty) := component.item_number;
6563 translate1(msg_qty) := 0;
6564 token2(msg_qty) := null;
6565 value2(msg_qty) := null;
6566 translate2(msg_qty) := 0;
6567 end if;
6568 If trial_mode = no
6569 then
6570 Close old_component;
6571 Raise abort_implementation;
6572 end if;
6573
6574 -- Changes Done For : 11510+ Enhancement
6575 -- Case 4: Validate that the from_end_item_revision of revised component
6576 -- > from_end_item_revision of the old component
6577 -- and < to_end_item_revision of the old component
6578 elsIf(l_revision_eff_bill = 'Y')
6579 Then
6580 l_valid_from_to_revision := 2;
6581 Open check_from_to_revision (l_from_rev_eff_date, old_comp_rec.component_sequence_id);
6582 Fetch check_from_to_revision into l_valid_from_to_revision;
6583 Close check_from_to_revision;
6584 If (l_valid_from_to_revision = 2)
6585 Then
6586 If msg_qty < max_messages
6587 then
6588 msg_qty := msg_qty + 1;
6589 message_names(msg_qty) := 'ENG_RCOMP_REV_NOTIN_OLDRANGE';
6590 token1(msg_qty) := 'ITEM';
6591 value1(msg_qty) := component.item_number;
6592 translate1(msg_qty) := 0;
6593 token2(msg_qty) := null;
6594 value2(msg_qty) := null;
6595 translate2(msg_qty) := 0;
6596 end if;
6597 If trial_mode = no
6598 then
6599 Close old_component;
6600 Raise abort_implementation;
6601 end if;
6602 End If;
6603
6604 -- If all validations passed, then set the old component record details
6605 ELSE
6606 -- added for eco enhancement
6607 count_comp_disable := count_comp_disable + 1;
6608 rev_comp_disable_date_tbl(count_comp_disable).revised_item_id := item.revised_item_id;
6609 rev_comp_disable_date_tbl(count_comp_disable).component_seq_id :=
6610 component.old_component_sequence_id;
6611 rev_comp_disable_date_tbl(count_comp_disable).disable_date := old_comp_rec.disable_date;
6612
6613
6614 old_comp_rec.disable_date := eff_date;
6615 /* Bug 2441062. disable_date should be a second lesser than eff_date
6616 to avoid overlapping effectivity within the same component
6617 The above change has been reverted for this bug 5622459
6618 */
6619 IF component.acd_type = acd_change
6620 THEN
6621 -- Set disable_date
6622 /*bug 5622459
6623 old_comp_rec.disable_date := eff_date-((1/1440)/60);
6624 */
6625 -- Set overlapping_changes
6626 IF component.overlapping_changes = 1
6627 THEN
6628 old_comp_rec.overlapping_changes := 1;
6629 END IF;
6630 ELSE
6631 old_comp_rec.disable_date := eff_date;
6632 END IF;
6633 -- Added for structure revision
6634 -- Set to_object_revision_id
6635 IF (old_comp_rec.from_object_revision_id is not null
6636 AND item.new_structure_revision is not null
6637 AND old_comp_rec.to_object_revision_id is NULL)
6638 THEN
6639 old_comp_rec.to_object_revision_id := X_prev_structure_revision_id;
6640 END IF;
6641 -- Set change_notice
6642 IF item.eco_for_production = 2
6643 THEN
6644 old_comp_rec.change_notice := item.change_notice;
6645 END IF;
6646 end if;
6647 -- End of Validations
6648
6649 If component.acd_type = acd_delete
6650 then
6651 component.disable_date := eff_date;
6652 end if;
6653 -- Unit Effectivity implementation
6654 If (X_UnitEff_RevItem = 'Y')
6655 then
6656 -- Disable the old component by populating disable_date, if
6657 -- the change/disable is for whole range starting from the
6658 -- from_unit_number of the old component.
6659 -- Else, update the to_unit_number of the old comp with the prev
6660 -- unit number of the new comp's from_unit_number.
6661 -- Need to be enhanced for spliting.
6662 if (component.from_end_item_unit_number = old_comp_rec.from_end_item_unit_number)
6663 then
6664 /*bug 5622459
6665 IF component.acd_type = acd_change
6666 THEN
6667 old_comp_rec.disable_date := eff_date-((1/1440)/60);
6668 ELSE*/
6669 old_comp_rec.disable_date := eff_date;
6670 --END IF;
6671
6672 Update bom_components_b --bom_inventory_components
6673 set disable_date = old_comp_rec.disable_date,
6674 to_object_revision_id = old_comp_rec.to_object_revision_id,
6675 overlapping_changes = old_comp_rec.overlapping_changes,
6676 change_notice = old_comp_rec.change_notice,
6677 implementation_date = today,
6678 last_update_date = sysdate,
6679 last_updated_by = userid,
6680 last_update_login = loginid,
6681 request_id = reqstid,
6682 program_application_id = appid,
6683 program_id = progid,
6684 program_update_date = sysdate
6685 where component_sequence_id = old_comp_rec.component_sequence_id;
6686 else
6687 X_prev_unit_number := PJM_UNIT_EFF.Prev_unit_number(X_unit_number => component.from_end_item_unit_number);
6688 if (X_prev_unit_number is NULL)
6689 then
6690 X_prev_unit_number := component.from_end_item_unit_number;
6691 end if;
6692 if (X_prev_unit_number < old_comp_rec.from_end_item_unit_number)
6693 then
6694 If msg_qty < max_messages
6695 then
6696 msg_qty := msg_qty + 1;
6697 message_names(msg_qty) := 'ENG_TOUNIT_LESSTHAN_FROMUNIT';
6698 token1(msg_qty) := 'ITEM';
6699 value1(msg_qty) := component.item_number;
6700 translate1(msg_qty) := 0;
6701 token2(msg_qty) := 'OP_SEQ_NUM';
6702 value2(msg_qty) := to_char(component.operation_seq_num);
6703 translate2(msg_qty) := 0;
6704 end if;
6705 If trial_mode = no
6706 then
6707 Raise abort_implementation;
6708 end if;
6709 end if;
6710
6711 Update bom_components_b --bom_inventory_components
6712 set to_end_item_unit_number = X_prev_unit_number,
6713 to_object_revision_id = old_comp_rec.to_object_revision_id,
6714 overlapping_changes = old_comp_rec.overlapping_changes,
6715 change_notice = old_comp_rec.change_notice,
6716 implementation_date = today,
6717 last_update_date = sysdate,
6718 last_updated_by = userid,
6719 last_update_login = loginid,
6720 request_id = reqstid,
6721 program_application_id = appid,
6722 program_id = progid,
6723 program_update_date = sysdate
6724 where component_sequence_id =
6725 old_comp_rec.component_sequence_id;
6726 end if;
6727 ELSIF (l_revision_eff_bill = 'Y')
6728 THEN
6729 -- Disable the old component by populating disable_date, if
6730 -- the change/disable is for whole range starting from the
6731 -- from_unit_number of the old component.
6732 -- Else, update the to_unit_number of the old comp with the prev
6733 -- unit number of the new comp's from_unit_number.
6734 -- Need to be enhanced for spliting.
6735 if (component.from_end_item_rev_id = old_comp_rec.from_end_item_rev_id)
6736 then
6737 /* bug 5622459. 1 sec difference is removed
6738 IF component.acd_type = acd_change
6739 THEN
6740 old_comp_rec.disable_date := eff_date-((1/1440)/60);
6741 ELSE*/
6742 old_comp_rec.disable_date := eff_date;
6743 --END IF;
6744
6745 Update bom_components_b --bom_inventory_components
6746 set disable_date = old_comp_rec.disable_date,
6747 to_object_revision_id = old_comp_rec.to_object_revision_id,
6748 overlapping_changes = old_comp_rec.overlapping_changes,
6749 change_notice = old_comp_rec.change_notice,
6750 implementation_date = today,
6751 last_update_date = sysdate,
6752 last_updated_by = userid,
6753 last_update_login = loginid,
6754 request_id = reqstid,
6755 program_application_id = appid,
6756 program_id = progid,
6757 program_update_date = sysdate
6758 where component_sequence_id = old_comp_rec.component_sequence_id;
6759 else
6760 l_prev_end_item_rev_id := NULL;
6761 OPEN get_prev_impl_revision(l_from_end_item_id,
6762 item.organization_id,
6763 l_from_rev_eff_date);
6764 FETCH get_prev_impl_revision INTO l_prev_end_item_rev_id, l_prev_end_item_eff;
6765 CLOSE get_prev_impl_revision;
6766 IF (l_prev_end_item_rev_id is NULL)
6767 THEN
6768 l_prev_end_item_rev_id := component.from_end_item_rev_id;
6769 l_prev_end_item_eff := l_from_rev_eff_date;
6770 END IF;
6771 l_valid_from_to_revision := 2;
6772 Open check_from_to_revision (l_prev_end_item_eff, old_comp_rec.component_sequence_id);
6773 Fetch check_from_to_revision into l_valid_from_to_revision;
6774 Close check_from_to_revision;
6775 IF (l_valid_from_to_revision = 2)
6776 Then
6777 If msg_qty < max_messages
6778 then
6779 msg_qty := msg_qty + 1;
6780 message_names(msg_qty) := 'ENG_TOREV_LESSTHAN_FROMREV';
6781 token1(msg_qty) := 'ITEM';
6782 value1(msg_qty) := component.item_number;
6783 translate1(msg_qty) := 0;
6784 token2(msg_qty) := 'OP_SEQ_NUM';
6785 value2(msg_qty) := to_char(component.operation_seq_num);
6786 translate2(msg_qty) := 0;
6787 end if;
6788 If trial_mode = no
6789 then
6790 Raise abort_implementation;
6791 end if;
6792 end if;
6793
6794 Update bom_components_b --bom_inventory_components
6795 set to_end_item_rev_id = l_prev_end_item_rev_id,
6796 to_object_revision_id = old_comp_rec.to_object_revision_id,
6797 overlapping_changes = old_comp_rec.overlapping_changes,
6798 change_notice = old_comp_rec.change_notice,
6799 implementation_date = today,
6800 last_update_date = sysdate,
6801 last_updated_by = userid,
6802 last_update_login = loginid,
6803 request_id = reqstid,
6804 program_application_id = appid,
6805 program_id = progid,
6806 program_update_date = sysdate
6807 where component_sequence_id = old_comp_rec.component_sequence_id;
6808 end if;
6809 else
6810 --Added to reflect correct disable date in old component.
6811 /*added case
6812 case 1: S1 => C1 (Q= 1 ,eff= D1) changed to S1 => C1 (Q= 10 ,eff= D1) [D1 = future date] is supported.
6813 in this case while implemention put disable date same as eff date in old comp.
6814 initailly overlapping error used to come*/
6815
6816 /* --bug 5622459 1 sec difference is removed
6817 IF component.acd_type = acd_change
6818 THEN
6819 IF old_comp_rec.effectivity_date = eff_date
6820 THEN
6821 old_comp_rec.disable_date := eff_date;
6822 ELSE
6823 old_comp_rec.disable_date := eff_date-((1/1440)/60);
6824 END IF;
6825 ELSE
6826 old_comp_rec.disable_date := eff_date;
6827 END IF;*/
6828 old_comp_rec.disable_date := eff_date; --bug 5622459
6829 l_old_disable_date := old_comp_rec.disable_date;
6830 -- Date effectivity implementation
6831 Update bom_components_b --bom_inventory_components
6832 set disable_date = old_comp_rec.disable_date,
6833 to_object_revision_id = old_comp_rec.to_object_revision_id,
6834 overlapping_changes = old_comp_rec.overlapping_changes,
6835 change_notice = old_comp_rec.change_notice,
6836 last_update_date = sysdate,
6837 last_updated_by = userid,
6838 last_update_login = loginid,
6839 request_id = reqstid,
6840 program_application_id = appid,
6841 program_id = progid,
6842 program_update_date = sysdate
6843 -- where current of old_component;
6844 where component_sequence_id = old_comp_rec.component_sequence_id;
6845 end if;
6846 -----------------------------------------------------------
6847 -- R12: Changes for Common BOM Enhancement
6848 -- Step 2: Update related old components
6849 -- Move/Copy pending changes on old component to new.
6850 -- Pending changes for WIP attributes could have been created
6851 -- on the implemented old component on the destination bill
6852 -- These need to be updated to reference the new component
6853 -- Since the effectivity date is not a modifiable attribute on
6854 -- the destination bill's component change records , the pending
6855 -- changes derive their old components effectivities only.
6856 -- So if the oldcomponent is disable date is future effective, then
6857 -- pending changes are copied from the old to the new refenced
6858 -- component in the destination bill
6859 -- They are copied otherwise.
6860 -----------------------------------------------------------
6861 IF isCommonedBOM = 'Y'
6862 THEN
6863 IF component.acd_type = acd_change
6864 THEN
6865 -- if the old component is being disabled as of not
6866 -- or the old component was future effective but is being disabled as of the
6867 -- same date then we move the pending changes to the new component.
6868 IF eff_date <= SYSDATE OR old_comp_rec.disable_date <= old_comp_rec.effectivity_date
6869 THEN
6870 Move_Pending_Dest_Components(
6871 p_src_old_comp_seq_id => old_comp_rec.component_sequence_id
6872 , p_src_comp_seq_id => component.component_sequence_id
6873 , p_change_notice => item.change_notice
6874 , p_revised_item_sequence_id => item.revised_item_sequence_id
6875 , p_effectivity_date => eff_date
6876 , p_eco_for_production => item.eco_for_production
6877 , x_return_status => l_comn_return_status);
6878 ELSE
6879 BOMPCMBM.Copy_Pending_Dest_Components(
6880 p_src_old_comp_seq_id => old_comp_rec.component_sequence_id
6881 , p_src_comp_seq_id => component.component_sequence_id
6882 , p_change_notice => item.change_notice
6883 , p_organization_id => item.organization_id
6884 , p_revised_item_sequence_id => item.revised_item_sequence_id
6885 , p_effectivity_date => eff_date
6886 , x_return_status => l_comn_return_status);
6887 END IF;
6888 If ( l_comn_return_status <> 'S')
6889 Then
6890 If msg_qty < max_messages
6891 then
6892 msg_qty := msg_qty + 1;
6893 message_names(msg_qty) := 'ENG_COM_COMP_UPDATE_FAILED';
6894 token1(msg_qty) := 'ITEM';
6895 value1(msg_qty) := component.item_number;
6896 translate1(msg_qty) := 0;
6897 token2(msg_qty) := null;
6898 value2(msg_qty) := null;
6899 translate2(msg_qty) := 0;
6900 end if;
6901 If trial_mode = no
6902 then
6903 Close old_component;
6904 Raise abort_implementation;
6905 end if;
6906 End If;
6907 --Bug 9238945 (changes in the corresponding destination bill
6908 --for acd_type =2
6909
6910 --bug 11731038
6911 --BOMPCMBM.Update_Impl_Rel_Comp(
6912 --p_src_comp_seq_id => old_comp_rec.component_sequence_id);
6913 END IF;
6914 --bug 11731038
6915 BOMPCMBM.Update_Impl_Rel_Comp(
6916 p_src_comp_seq_id => old_comp_rec.component_sequence_id);
6917 --commented out the following for bug 9238945
6918
6919 /*BOMPCMBM.Update_Related_Components(
6920 p_src_comp_seq_id => old_comp_rec.component_sequence_id
6921 , x_Mesg_Token_Tbl => l_comn_mesg_token_tbl
6922 , x_Return_Status => l_comn_return_status);
6923 If ( l_comn_return_status <> 'S')
6924 Then
6925 If msg_qty < max_messages
6926 then
6927 msg_qty := msg_qty + 1;
6928 message_names(msg_qty) := 'ENG_COM_COMP_UPDATE_FAILED';
6929 token1(msg_qty) := 'ITEM';
6930 value1(msg_qty) := component.item_number;
6931 translate1(msg_qty) := 0;
6932 token2(msg_qty) := null;
6933 value2(msg_qty) := null;
6934 translate2(msg_qty) := 0;
6935 end if;
6936 If trial_mode = no
6937 then
6938 Close old_component;
6939 Raise abort_implementation;
6940 end if;
6941 End If; */
6942 -- added here, for the R12 change management for common bom
6943 END IF;
6944 -----------------------------------------------------------
6945 -- R12: End Step 2: End Changes for Common BOM Enhancement --
6946 -----------------------------------------------------------
6947
6948 Close old_component;
6949 end if; -- old components
6950
6951 --
6952 -- Check for duplicate value on unique index (avoid overlapping effectivity)
6953 --
6954 /* No need to perform the overlap check for the component row which has acd_type as
6955 delete since this row will be deleted from the inventory_components table at the
6956 end if implementation */
6957 IF component.acd_type <> acd_delete
6958 THEN
6959 -- Initialize
6960 l_overlap_found := 2;
6961
6962 -- Check for Unit Effectivity implementation
6963 If (X_UnitEff_RevItem = 'Y')
6964 then
6965 Open check_existing_unit(
6966 X_bill => item.bill_sequence_id,
6967 X_component => component.component_item_id,
6968 X_operation => component.operation_seq_num,
6969 X_comp_seq_id => component.component_sequence_id,
6970 X_from_unit_number => component.from_end_item_unit_number,
6971 X_to_unit_number => component.to_end_item_unit_number);
6972 Fetch check_existing_unit into dummy;
6973 If check_existing_unit%found
6974 then
6975 l_overlap_found := 1;
6976 end if;
6977 Close check_existing_unit;
6978 -- Check For End-Item-Revision Effectivity
6979 -- 11510+ Enhancement
6980 elsIf(l_revision_eff_bill = 'Y')
6981 Then
6982 Open check_existing_rev_eff_comp
6983 ( cp_bill_id => item.bill_sequence_id
6984 , cp_component_item_id => component.component_item_id
6985 , cp_operation_seq_num => component.operation_seq_num
6986 , cp_end_item_id => l_from_end_item_id
6987 , cp_org_id => item.organization_id
6988 , cp_from_rev_eff => l_from_rev_eff_date
6989 , cp_to_rev_eff => l_to_rev_eff_date );
6990 Fetch check_existing_rev_eff_comp into l_overlap_found;
6991 Close check_existing_rev_eff_comp;
6992 else
6993 -- Check for Date effectivity implementation
6994 Open check_existing_component(
6995 X_bill => item.bill_sequence_id,
6996 X_component => component.component_item_id,
6997 X_operation => component.operation_seq_num,
6998 X_comp_seq_id => component.component_sequence_id,
6999 X_disable_date => component.disable_date,
7000 X_old_comp_seq_id => component.old_component_sequence_id,
7001 X_old_rec_disable_date => l_old_disable_date );
7002 Fetch check_existing_component into dummy;
7003 If check_existing_component%found
7004 then
7005 l_overlap_found := 1;
7006 end if;
7007 Close check_existing_component;
7008 end if;
7009 -- If overlapping Effectivity Found then Raise Error
7010 If l_overlap_found = 1
7011 Then
7012 If msg_qty < max_messages
7013 then
7014 msg_qty := msg_qty + 1;
7015 message_names(msg_qty) := 'ENG_COMPONENT_ALREADY_EXISTS';
7016 token1(msg_qty) := 'ITEM';
7017 value1(msg_qty) := component.item_number;
7018 translate1(msg_qty) := 0;
7019 token2(msg_qty) := 'OP';
7020 value2(msg_qty) := to_char(component.operation_seq_num);
7021 translate2(msg_qty) := 0;
7022 end if;
7023 If trial_mode = no then
7024 Raise abort_implementation;
7025 end if;
7026 End If;
7027 END IF;
7028 -- End of Check for duplicate values on unique Index (Overlapping Effectivities)
7029
7030 If component.acd_type = acd_change then
7031 -- Bug 4584490: Changes for Bom Business Events
7032 -- Check if there exists and substitue comps/ ref desigs
7033 -- on the component
7034 BEGIN
7035 IF item.eco_for_production = 2
7036 THEN
7037 l_Comp_Child_Entity_Modified := NULL;
7038 OPEN c_Comp_Child_Entity_Modified(component.component_sequence_id);
7039 FETCH c_Comp_Child_Entity_Modified INTO l_Comp_Child_Entity_Modified;
7040 CLOSE c_Comp_Child_Entity_Modified;
7041 IF l_Comp_Child_Entity_Modified IS NOT NULL
7042 THEN
7043 Bom_Business_Event_PKG.Raise_Component_Event(
7044 p_bill_sequence_Id => item.bill_sequence_id
7045 , p_pk1_value => component.component_item_id
7046 , p_pk2_value => item.organization_id
7047 , p_obj_name => component.obj_name
7048 , p_organization_id => item.organization_id
7049 , p_comp_item_name => component.item_number
7050 , p_comp_description => component.component_remarks
7051 , p_Event_Name => Bom_Business_Event_PKG.G_COMPONENT_MODIFIED_EVENT
7052 );
7053 END IF;
7054 END IF;
7055 EXCEPTION
7056 WHEN OTHERS THEN
7057 null;
7058 -- nothing is required to be done, process continues
7059 END;
7060 -- End changes for Bug 4584490
7061
7062 -- Bug 5854437 Start
7063 For sub_component in chng_sub_component_rows loop
7064 Open check_existing_substitutes(X_old_comp_seq_id => sub_component.old_component_sequence_id,
7065 X_sub_comp_id => sub_component.substitute_component_id,
7066 X_change_notice => item.change_notice);
7067 Fetch check_existing_substitutes into dummy;
7068
7069 If check_existing_substitutes%found then
7070 rec_exist:=0;
7071 BEGIN
7072 SELECT bsc.acd_type into rec_exist
7073 FROM Bom_Inventory_Components bic,
7074 BOM_SUBSTITUTE_COMPONENTS bsc
7075 WHERE bic.Old_Component_Sequence_Id = sub_component.old_component_sequence_id
7076 AND bic.Change_Notice = item.change_notice
7077 AND bic.Implementation_Date IS NULL
7078 AND bsc.component_sequence_id = bic.component_sequence_id
7079 AND bsc.substitute_component_id = sub_component.substitute_component_id
7080 ;-- AND bsc. ACD_TYPE = acd_delete; --removed for bug 8499831
7081 EXCEPTION
7082 WHEN NO_DATA_FOUND THEN
7083 -- NULL; --removed for bug 8499831
7084 rec_exist := sub_component.acd_type; --added for bug 8499831
7085 END;
7086 If (rec_exist <> acd_delete) and (rec_exist <> acd_add) then --changed for bug 8499831
7087 rec_exist := 0;
7088 If msg_qty < max_messages then
7089 msg_qty := msg_qty + 1;
7090 message_names(msg_qty) :=
7091 'ENG_SUB_COMP_ALREADY_EXISTS';
7092 token1(msg_qty) := 'SUBSTITUTE_ITEM_NAME';
7093 value1(msg_qty) := sub_component.item_number;
7094 translate1(msg_qty) := 0;
7095 token2(msg_qty) := 'REVISED_COMPONENT_NAME';
7096 value2(msg_qty) := component.item_number;
7097 translate2(msg_qty) := 0;
7098
7099 end if;
7100 FND_MESSAGE.Set_Name('ENG','ENG_SUB_COMP_ALREADY_EXISTS');
7101 FND_MESSAGE.Set_Token('SUBSTITUTE_ITEM_NAME',sub_component.item_number) ;
7102 FND_MESSAGE.Set_Token('REVISED_COMPONENT_NAME',component.item_number) ;
7103 FND_MSG_PUB.Add;
7104 FND_MSG_PUB.Count_And_Get(p_encoded => FND_API.G_FALSE, p_count => l_error_msg_count , p_data => l_message);
7105 FND_FILE.put_line(FND_FILE.LOG, l_message);
7106 If trial_mode = no then
7107 Close check_existing_substitutes;
7108 Raise abort_implementation;
7109 end if;
7110 end if;
7111 end if;
7112 Close check_existing_substitutes;
7113 end loop;
7114
7115 -- Bug 5854437 End
7116
7117
7118 -- Copy substitute components
7119 Insert into bom_substitute_components(
7120 substitute_component_id,
7121 last_update_date,
7122 last_updated_by,
7123 creation_date,
7124 created_by,
7125 last_update_login,
7126 substitute_item_quantity,
7127 component_sequence_id,
7128 acd_type,
7129 change_notice,
7130 request_id,
7131 program_application_id,
7132 program_id,
7133 program_update_date,
7134 attribute_category,
7135 attribute1,
7136 attribute2,
7137 attribute3,
7138 attribute4,
7139 attribute5,
7140 attribute6,
7141 attribute7,
7142 attribute8,
7143 attribute9,
7144 attribute10,
7145 attribute11,
7146 attribute12,
7147 attribute13,
7148 attribute14,
7149 attribute15)
7150 select
7151 substitute_component_id,
7152 last_update_date,
7153 last_updated_by,
7154 creation_date,
7155 created_by,
7156 last_update_login,
7157 substitute_item_quantity,
7158 component.component_sequence_id, -- new component
7159 acd_type,
7160 change_notice, --null, bug 5174519
7161 request_id,
7162 program_application_id,
7163 program_id,
7164 program_update_date,
7165 attribute_category,
7166 attribute1,
7167 attribute2,
7168 attribute3,
7169 attribute4,
7170 attribute5,
7171 attribute6,
7172 attribute7,
7173 attribute8,
7174 attribute9,
7175 attribute10,
7176 attribute11,
7177 attribute12,
7178 attribute13,
7179 attribute14,
7180 attribute15
7181 from bom_substitute_components
7182 where component_sequence_id =
7183 component.old_component_sequence_id
7184 and nvl(acd_type, acd_add) = acd_add
7185 and substitute_component_id not in (
7186 select substitute_component_id
7187 from bom_substitute_components
7188 where component_sequence_id =
7189 component.component_sequence_id);
7190 -- Copy reference designators
7191 Insert into bom_reference_designators (
7192 component_reference_designator,
7193 last_update_date,
7194 last_updated_by,
7195 creation_date,
7196 created_by,
7197 last_update_login,
7198 ref_designator_comment,
7199 change_notice,
7200 component_sequence_id,
7201 acd_type,
7202 request_id,
7203 program_application_id,
7204 program_id,
7205 program_update_date,
7206 attribute_category,
7207 attribute1,
7208 attribute2,
7209 attribute3,
7210 attribute4,
7211 attribute5,
7212 attribute6,
7213 attribute7,
7214 attribute8,
7215 attribute9,
7216 attribute10,
7217 attribute11,
7218 attribute12,
7219 attribute13,
7220 attribute14,
7221 attribute15)
7222 select
7223 component_reference_designator,
7224 last_update_date,
7225 last_updated_by,
7226 creation_date,
7227 created_by,
7228 last_update_login,
7229 ref_designator_comment,
7230 change_notice, --null, bug 5174519
7231 component.component_sequence_id, -- new component
7232 acd_type,
7233 request_id,
7234 program_application_id,
7235 program_id,
7236 program_update_date,
7237 attribute_category,
7238 attribute1,
7239 attribute2,
7240 attribute3,
7241 attribute4,
7242 attribute5,
7243 attribute6,
7244 attribute7,
7245 attribute8,
7246 attribute9,
7247 attribute10,
7248 attribute11,
7249 attribute12,
7250 attribute13,
7251 attribute14,
7252 attribute15
7253 from bom_reference_designators
7254 where component_sequence_id =
7255 component.old_component_sequence_id
7256 and nvl(acd_type, acd_add) = acd_add -- adds only
7257 and component_reference_designator not in (
7258 select component_reference_designator
7259 from bom_reference_designators
7260 where component_sequence_id =
7261 component.component_sequence_id);
7262 end if; -- Copy component's children
7263
7264 If component.acd_type in (acd_add, acd_change) and
7265 component.quantity_related = yes then
7266 Open count_ref_designators(component.component_sequence_id);
7267 Fetch count_ref_designators into ref_designator_count;
7268 Close count_ref_designators;
7269 If component.component_quantity <> ref_designator_count then
7270 If msg_qty < max_messages then
7271 msg_qty := msg_qty + 1;
7272 message_names(msg_qty) := 'ENG_QUANTITY_RELATED_2';
7273 token1(msg_qty) := 'ITEM';
7274 value1(msg_qty) := component.item_number;
7275 translate1(msg_qty) := 0;
7276 token2(msg_qty) := null;
7277 value2(msg_qty) := null;
7278 translate2(msg_qty) := 0;
7279 end if;
7280 If trial_mode = no then
7281 Raise abort_implementation;
7282 end if;
7283 end if;
7284 end if; -- reference designator count
7285
7286 -- Check fractional component quantities if OE is installed
7287 -- and the revised item is PTO
7288
7289 If component.acd_type in (acd_add, acd_change) and
7290 X_InstallStatus = 'I' and
7291 item.pick_components_flag = 'Y' and
7292 component.component_quantity <> trunc(component.component_quantity)
7293 then
7294 If msg_qty < max_messages then
7295 msg_qty := msg_qty + 1;
7296 message_names(msg_qty) := 'ENG_FRACTIONAL_QTY';
7297 token1(msg_qty) := 'ITEM';
7298 value1(msg_qty) := component.item_number;
7299 translate1(msg_qty) := 0;
7300 token2(msg_qty) := null;
7301 value2(msg_qty) := null;
7302 translate2(msg_qty) := 0;
7303 end if;
7304 If trial_mode = no then
7305 Raise abort_implementation;
7306 end if;
7307 end if;
7308
7309 -- added for structure revision
7310 If component.acd_type in (acd_add, acd_change) then
7311 IF item.new_structure_revision is not null THEN
7312 component.from_object_revision_id := X_new_structure_revision_id;
7313 END IF;
7314 IF component.overlapping_changes = 1 THEN
7315 component.overlapping_changes := null;
7316 END IF;
7317 end if;
7318
7319 Update bom_components_b--bom_inventory_components
7320 set implementation_date = today,
7321 change_notice = item.change_notice,
7322 disable_date = component.disable_date,
7323 effectivity_date = eff_date,
7324 from_object_revision_id = component.from_object_revision_id,
7325 overlapping_changes = component.overlapping_changes,
7326 last_update_date = sysdate,
7327 last_updated_by = userid,
7328 last_update_login = loginid,
7329 request_id = reqstid,
7330 program_application_id = appid,
7331 program_id = progid,
7332 program_update_date = sysdate
7333 -- where current of chng_component_rows;
7334 where component_sequence_id = component.component_sequence_id;
7335 -----------------------------------------------------------
7336 -- R12: Changes for Common BOM Enhancement
7337 -- Step 3: Implementing Referenced Pending Destination Components
7338 -- And Copy the Component's children to the Implemented Component
7339 -- Whether update attributes is requred from src to destination again ?
7340 -- Not done as any UI updates will maintain the attrs in sync
7341 -----------------------------------------------------------
7342 IF isCommonedBOM = 'Y'
7343 THEN
7344 UPDATE bom_components_b--bom_inventory_components
7345 SET implementation_date = today,
7346 change_notice = item.change_notice,
7347 disable_date = component.disable_date,
7348 effectivity_date = eff_date,
7349 overlapping_changes = component.overlapping_changes,
7350 last_update_date = sysdate,
7351 last_updated_by = userid,
7352 last_update_login = loginid,
7353 request_id = reqstid,
7354 program_application_id = appid,
7355 program_id = progid,
7356 program_update_date = sysdate
7357 WHERE common_component_sequence_id = component.component_sequence_id
7358 AND common_component_sequence_id <> component_sequence_id
7359 AND implementation_date IS NULL
7360 AND change_notice = item.change_notice
7361 AND revised_item_sequence_id = item.revised_item_sequence_id;
7362
7363 -- Update related components to set the effectivity and the disable date attributes
7364 -- as set above.
7365 -- This is a repitition of the move/copy related pending destination changes
7366 -- in the destination bill to the newly implemented component that is created
7367 -- as a reference in the destination bills.
7368
7369 --Bug 9238945
7370 --commenting out the following since not sure why is this required
7371
7372 /*BOMPCMBM.Update_Related_Components(
7373 p_src_comp_seq_id => component.component_sequence_id
7374 , x_Mesg_Token_Tbl => l_comn_mesg_token_tbl
7375 , x_Return_Status => l_comn_return_status);
7376 If ( l_comn_return_status <> 'S')
7377 Then
7378 If msg_qty < max_messages
7379 then
7380 msg_qty := msg_qty + 1;
7381 message_names(msg_qty) := 'ENG_COM_COMP_UPDATE_FAILED';
7382 token1(msg_qty) := 'ITEM';
7383 value1(msg_qty) := component.item_number;
7384 translate1(msg_qty) := 0;
7385 token2(msg_qty) := null;
7386 value2(msg_qty) := null;
7387 translate2(msg_qty) := 0;
7388 end if;
7389 If trial_mode = no
7390 then
7391 Close old_component;
7392 Raise abort_implementation;
7393 end if;
7394 End If; */
7395
7396 -- Copy the components children to the referneced components
7397 -- implemented just above statement
7398 BOMPCMBM.Replicate_Ref_Desg(
7399 p_component_sequence_id => component.component_sequence_id
7400 , x_Mesg_Token_Tbl => l_comn_mesg_token_tbl
7401 , x_Return_Status => l_comn_return_status);
7402 BOMPCMBM.Replicate_Sub_Comp(
7403 p_component_sequence_id => component.component_sequence_id
7404 , x_Mesg_Token_Tbl => l_comn_mesg_token_tbl
7405 , x_Return_Status => l_comn_return_status);
7406 END IF;
7407 -----------------------------------------------------------
7408 -- R12: End Step 3: Changes for Common BOM Enhancement --
7409 -----------------------------------------------------------
7410
7411 --
7412 -- Update all unimplemented rows that point to the old row, so that they now
7413 -- point to the new component row.
7414 --
7415
7416 If component.acd_type = acd_change then
7417 IF item.eco_for_production = 2 Then
7418 Update bom_components_b--bom_inventory_components
7419 set old_component_sequence_id = component.component_sequence_id,
7420 last_update_date = sysdate,
7421 last_updated_by = userid,
7422 last_update_login = loginid,
7423 request_id = reqstid,
7424 program_application_id = appid,
7425 program_id = progid,
7426 program_update_date = sysdate
7427 where old_component_sequence_id =
7428 component.old_component_sequence_id
7429 and implementation_date is null;
7430 --
7431 -- Here , the common Components are NOT being updated as they have been
7432 -- taken care of in the Step 1 of updation of pending desination changes.
7433 --
7434 END IF;
7435 end if; -- reset pointers
7436
7437 --
7438 -- Copy all implemented components to eng_revised_components.
7439 --
7440
7441 Insert into eng_revised_components(
7442 component_sequence_id,
7443 component_item_id,
7444 operation_sequence_num,
7445 bill_sequence_id,
7446 change_notice,
7447 effectivity_date,
7448 component_quantity,
7449 component_yield_factor,
7450 last_update_date,
7451 last_updated_by,
7452 creation_date,
7453 created_by,
7454 last_update_login,
7455 old_component_sequence_id,
7456 item_num,
7457 wip_supply_type,
7458 component_remarks,
7459 supply_subinventory,
7460 supply_locator_id,
7461 implementation_date,
7462 disable_date,
7463 acd_type,
7464 planning_factor,
7465 quantity_related,
7466 so_basis,
7467 optional,
7468 mutually_exclusive_options,
7469 include_in_cost_rollup,
7470 check_atp,
7471 shipping_allowed,
7472 required_to_ship,
7473 required_for_revenue,
7474 include_on_ship_docs,
7475 include_on_bill_docs,
7476 low_quantity,
7477 high_quantity,
7478 attribute_category,
7479 attribute1,
7480 attribute2,
7481 attribute3,
7482 attribute4,
7483 attribute5,
7484 attribute6,
7485 attribute7,
7486 attribute8,
7487 attribute9,
7488 attribute10,
7489 attribute11,
7490 attribute12,
7491 attribute13,
7492 attribute14,
7493 attribute15,
7494 request_id,
7495 program_application_id,
7496 program_id,
7497 program_update_date,
7498 revised_item_sequence_id,
7499 from_end_item_unit_number,
7500 to_end_item_unit_number,
7501 eco_for_production,
7502 FROM_END_ITEM_REV_ID,
7503 TO_END_ITEM_REV_ID,
7504 FROM_OBJECT_REVISION_ID,
7505 TO_OBJECT_REVISION_ID,
7506 FROM_END_ITEM_MINOR_REV_ID,
7507 TO_END_ITEM_MINOR_REV_ID,
7508 COMPONENT_ITEM_REVISION_ID,
7509 COMMON_COMPONENT_SEQUENCE_ID,
7510 BASIS_TYPE)
7511 select
7512 component_sequence_id,
7513 component_item_id,
7514 operation_seq_num,
7515 bill_sequence_id,
7516 change_notice,
7517 effectivity_date,
7518 component_quantity,
7519 component_yield_factor,
7520 last_update_date,
7521 last_updated_by,
7522 creation_date,
7523 created_by,
7524 last_update_login,
7525 old_component_sequence_id,
7526 item_num,
7527 wip_supply_type,
7528 component_remarks,
7529 supply_subinventory,
7530 supply_locator_id,
7531 implementation_date,
7532 disable_date,
7533 acd_type,
7534 planning_factor,
7535 quantity_related,
7536 so_basis,
7537 optional,
7538 mutually_exclusive_options,
7539 include_in_cost_rollup,
7540 check_atp,
7541 shipping_allowed,
7542 required_to_ship,
7543 required_for_revenue,
7544 include_on_ship_docs,
7545 include_on_bill_docs,
7546 low_quantity,
7547 high_quantity,
7548 attribute_category,
7549 attribute1,
7550 attribute2,
7551 attribute3,
7552 attribute4,
7553 attribute5,
7554 attribute6,
7555 attribute7,
7556 attribute8,
7557 attribute9,
7558 attribute10,
7559 attribute11,
7560 attribute12,
7561 attribute13,
7562 attribute14,
7563 attribute15,
7564 request_id,
7565 program_application_id,
7566 program_id,
7567 program_update_date,
7568 revised_item_sequence_id,
7569 from_end_item_unit_number,
7570 to_end_item_unit_number,
7571 eco_for_production,
7572 FROM_END_ITEM_REV_ID,
7573 TO_END_ITEM_REV_ID,
7574 FROM_OBJECT_REVISION_ID,
7575 TO_OBJECT_REVISION_ID,
7576 FROM_END_ITEM_MINOR_REV_ID,
7577 TO_END_ITEM_MINOR_REV_ID,
7578 COMPONENT_ITEM_REVISION_ID,
7579 COMMON_COMPONENT_SEQUENCE_ID,
7580 BASIS_TYPE
7581 from bom_components_b --bom_inventory_components
7582 where component_sequence_id = component.component_sequence_id;
7583 If component.acd_type = acd_delete then
7584 Delete from bom_components_b --bom_inventory_components
7585 -- where current of chng_component_rows;
7586 where component_sequence_id = component.component_sequence_id;
7587
7588 -----------------------------------------------------------
7589 -- R12: Changes for Common BOM Enhancement
7590 -- Step 4: Deleting Related Disabled Components
7591 -- When the disabled component is deleted from the bill,
7592 -- and it is a commoned bill, it will have referenced components
7593 -- in the common (destination) bills which also have to be deleted
7594 -- This record will have a reference to the change_notice and
7595 -- revised_item_sequence_id of the commoned component.
7596 -----------------------------------------------------------
7597 IF isCommonedBOM = 'Y'
7598 THEN
7599 DELETE FROM bom_components_b bcb
7600 WHERE bcb.common_component_sequence_id = component.component_sequence_id
7601 AND bcb.common_component_sequence_id <> bcb.component_sequence_id
7602 --AND bcb.implementation_date IS null --bug 11731038
7603 AND bcb.change_notice = item.change_notice
7604 AND bcb.revised_item_sequence_id = item.revised_item_sequence_id
7605 AND bcb.acd_type = acd_delete;
7606 END IF;
7607 -----------------------------------------------------------
7608 -- R12: End Step 4: Changes for Common BOM Enhancement --
7609 -----------------------------------------------------------
7610 end if;
7611
7612 -- ERES changes begin : bug 3741444
7613 bERES_Flag_for_BOM := TRUE;
7614 FND_FILE.PUT_LINE(FND_FILE.LOG, 'in component loop... bERES_Flag_for_BOM=TRUE');
7615 -- ERES changes end.
7616
7617 -- Bug 4584490: Changes for Bom Business Events
7618 -- l_BOMEvents_Comps_ACD:
7619 -- Setting as add when the components are only added to this bill
7620 -- Setting it as change if components are changed or disabled in this bill.
7621 -- Removed l_BOMEvents_Comps_ACD clause so that component quantity change will raise an event.
7622 IF (component.acd_type = acd_add AND l_BOMEvents_Comps_ACD IS NULL)
7623 THEN
7624 l_BOMEvents_Comps_ACD := acd_add;
7625 ELSIF (component.acd_type IN (acd_change, acd_delete) )
7626 THEN
7627 l_BOMEvents_Comps_ACD := acd_change;
7628 END IF;
7629 -- End changes for 4584490
7630 end loop; -- all components
7631
7632
7633
7634 Update bom_bill_of_materials
7635 set last_update_date = sysdate,
7636 last_updated_by = userid,
7637 last_update_login = loginid,
7638 request_id = reqstid,
7639 program_application_id = appid,
7640 program_id = progid,
7641 program_update_date = sysdate,
7642 pending_from_ecn = null
7643 where bill_sequence_id = item.bill_sequence_id
7644 AND pending_from_ecn = item.change_notice; -- Fixed for bug 3646438
7645
7646 -- Bug 4584490: Changes for Bom Business Events
7647 BEGIN
7648 IF item.eco_for_production = 2
7649 THEN
7650 IF (l_pending_from_ecn = item.change_notice AND l_BOMEvents_Comps_ACD = acd_add)
7651 THEN
7652 l_BOMEvents_Bill_Event_Name := Bom_Business_Event_PKG.G_STRUCTURE_CREATION_EVENT;
7653 ELSIF l_BOMEvents_Comps_ACD IS NOT NULL
7654 THEN
7655 l_BOMEvents_Bill_Event_Name := Bom_Business_Event_PKG.G_STRUCTURE_MODIFIED_EVENT;
7656 END IF;
7657 IF (l_BOMEvents_Bill_Event_Name IS NOT NULL)
7658 THEN
7659 Bom_Business_Event_PKG.Raise_Bill_Event(
7660 p_pk1_value => item.revised_item_id
7661 , p_pk2_value => item.organization_id
7662 , p_obj_name => null
7663 , p_structure_name => l_alternate_designator
7664 , p_organization_id => item.organization_id
7665 , p_structure_comment => NULL
7666 , p_Event_Name => l_BOMEvents_Bill_Event_Name
7667 , p_revised_item_sequence_id => item.revised_item_sequence_id -- Added for bug#8574333
7668 );
7669 END IF;
7670 END IF;
7671 EXCEPTION
7672 WHEN OTHERS THEN
7673 null;
7674 -- nothing is required to be done, process continues
7675 END;
7676 -- End changes for 4584490
7677
7678 -- ERES change begins
7679 --#######################################################
7680 -- Call the billCreate / billUpdate ERES event:
7681 -- BillCreate or billUpdate are children of event ecoImplementation
7682 -- Create or Update is decided on the value of
7683 -- column pending_from_ecn.
7684 --#######################################################
7685 IF (l_eres_enabled = 'Y')
7686 THEN
7687 -- bug 3234628, May-2004:
7688 -- odaboval added this test in order to only raise an ERES event
7689 -- when a row in bom_bill_of_materials has been updated:
7690 -- bug 3741444 : added bERES_Flag_for_BOM in the condition
7691 -- and removed ROWCOUNT>0 from the condition.
7692 IF (bERES_Flag_for_BOM)
7693 THEN
7694 -- First: Preparing child event BillCreate/Update
7695 IF (NVL(item.bill_sequence_id, -1) > 0)
7696 THEN
7697 l_event.param_name_1 := 'DEFERRED';
7698 l_event.param_value_1 := 'Y';
7699
7700 l_event.param_name_2 := 'POST_OPERATION_API';
7701 l_event.param_value_2 := 'NONE';
7702
7703 l_event.param_name_3 := 'PSIG_USER_KEY_LABEL';
7704 FND_MESSAGE.SET_NAME('BOM', 'BOM_ERES_BILL_USER_KEY');
7705 l_event.param_value_3 := FND_MESSAGE.GET;
7706
7707 l_event.param_name_4 := 'PSIG_USER_KEY_VALUE';
7708 IF (l_alternate_designator IS NOT NULL)
7709 THEN
7710 l_event.param_value_4 := item.concatenated_segments||' - '||item.organization_code||' - '||l_alternate_designator;
7711 ELSE
7712 l_event.param_value_4 := item.concatenated_segments||' - '||item.organization_code;
7713 END IF;
7714
7715 l_event.param_name_5 := 'PSIG_TRANSACTION_AUDIT_ID';
7716 l_event.param_value_5 := -1;
7717
7718 l_event.param_name_6 := '#WF_SOURCE_APPLICATION_TYPE';
7719 l_event.param_value_6 := 'DB';
7720
7721 l_event.param_name_7 := '#WF_SIGN_REQUESTER';
7722 l_event.param_value_7 := FND_GLOBAL.USER_NAME;
7723
7724 IF (l_pending_from_ecn IS NULL)
7725 THEN
7726 l_child_event_name := 'oracle.apps.bom.billUpdate';
7727 ELSE
7728 l_child_event_name := 'oracle.apps.bom.billCreate';
7729 END IF;
7730
7731 IF (NVL(l_parent_record_id, -1) > 0)
7732 THEN
7733 --additional parameters for the child event
7734 l_event.param_name_8 := 'PARENT_EVENT_NAME';
7735 l_event.param_value_8 := 'oracle.apps.eng.ecoImplement';
7736 l_event.param_name_9 := 'PARENT_EVENT_KEY';
7737 l_event.param_value_9 := TO_CHAR(item.change_id);
7738 l_event.param_name_10 := 'PARENT_ERECORD_ID';
7739 l_event.param_value_10 := TO_CHAR(l_parent_record_id);
7740 END IF;
7741
7742 -- Part 2 of preparation of child event :
7743 l_event.event_name := l_child_event_name;
7744 l_event.event_key := TO_CHAR(item.bill_sequence_id);
7745 -- l_event.payload := l_payload;
7746 l_event.erecord_id := l_erecord_id;
7747 l_event.event_status := l_event_status;
7748
7749 QA_EDR_STANDARD.RAISE_ERES_EVENT
7750 ( p_api_version => 1.0
7751 , p_init_msg_list => FND_API.G_FALSE
7752 , p_validation_level => FND_API.G_VALID_LEVEL_FULL
7753 , x_return_status => l_return_status
7754 , x_msg_count => l_msg_count
7755 , x_msg_data => l_msg_data
7756 , p_child_erecords => l_child_record
7757 , x_event => l_event);
7758
7759 IF (NVL(l_return_status, FND_API.G_FALSE) <> FND_API.G_TRUE)
7760 AND (l_msg_count > 0)
7761 THEN
7762 RAISE ERES_EVENT_ERROR;
7763 END IF;
7764
7765 -- Keep the eRecord id :
7766 IF (NVL(l_event.erecord_id, -1) > 0)
7767 THEN
7768 INSERT INTO ENG_PARENT_CHILD_EVENTS_TEMP(parent_event_name
7769 , parent_event_key, parent_erecord_id
7770 , event_name, event_key, erecord_id
7771 , event_status)
7772 VALUES ( 'oracle.apps.eng.ecoImplement', TO_CHAR(item.change_id)
7773 , l_parent_record_id
7774 , l_event.event_name, l_event.event_key, l_event.erecord_id
7775 , l_event.event_status);
7776
7777 FND_FILE.PUT_LINE(FND_FILE.LOG, 'After event='||l_child_event_name||', eRecord_id='||l_event.erecord_id||', status='||l_event.event_status||', bill='||item.bill_sequence_id);
7778 ELSE
7779 FND_FILE.PUT_LINE(FND_FILE.LOG, 'No eRecord generated for '||l_event.event_name||'. This is normal. Please check your rules or other setups');
7780 END IF;
7781 END IF; -- (NVL(item.bill_sequence_id, -1) > 0)
7782
7783 ELSE
7784 FND_FILE.PUT_LINE(FND_FILE.LOG, 'bERES_Flag_for_BOM=FALSE, then, NO ERES event for BOM .');
7785 END IF; -- SQL%ROWCOUNT > 0
7786 END IF; -- l_eres_enabled
7787 -- ERES change ends
7788
7789 --
7790 -- Mark the RTG header as no longer pending from ECO
7791 -- added for eco enhancement
7792 -- ERES Change begins
7793 -- Decision for RoutingCreate or Update depends on pending_from_ecn:
7794 OPEN Get_Operational_Routing_Info( item.routing_sequence_id);
7795 FETCH Get_Operational_Routing_Info
7796 INTO l_pending_from_ecn
7797 , l_alternate_designator;
7798 CLOSE Get_Operational_Routing_Info;
7799 -- ERES change ends
7800
7801 Update bom_operational_routings
7802 set last_update_date = sysdate,
7803 last_updated_by = userid,
7804 last_update_login = loginid,
7805 request_id = reqstid,
7806 program_application_id = appid,
7807 program_id = progid,
7808 program_update_date = sysdate,
7809 pending_from_ecn = null
7810 where routing_sequence_id = item.routing_sequence_id
7811 and pending_from_ecn is not null; --for bugfix 3234628
7812
7813 -- ERES change begins
7814 --#######################################################
7815 -- Call the routingUpdate ERES event:
7816 -- RoutingCreate or RoutingUpdate are children of event ecoImplementation
7817 -- Create or Update is decided on the value of
7818 -- column pending_from_ecn.
7819 --######################################################
7820 IF (l_eres_enabled = 'Y')
7821 THEN
7822 -- bug 3234628, May-2004:
7823 -- odaboval added this test in order to only raise an ERES event
7824 -- when a row in bom_operational_routings has been updated:
7825 -- bug 3908563 : added bERES_Flag_for_Routing in the condition
7826 -- and removed ROWCOUNT>0 from the condition.
7827 IF (bERES_Flag_for_Routing)
7828 THEN
7829 -- Preparing child event RoutingCreate/Update
7830 IF (NVL(item.routing_sequence_id, -1) > 0)
7831 THEN
7832 l_event.param_name_1 := 'DEFERRED';
7833 l_event.param_value_1 := 'Y';
7834
7835 l_event.param_name_2 := 'POST_OPERATION_API';
7836 l_event.param_value_2 := 'NONE';
7837
7838 l_event.param_name_3 := 'PSIG_USER_KEY_LABEL';
7839 FND_MESSAGE.SET_NAME('BOM', 'BOM_ERES_ROUTING_USER_KEY');
7840 l_event.param_value_3 := FND_MESSAGE.GET;
7841
7842 l_event.param_name_4 := 'PSIG_USER_KEY_VALUE';
7843 IF (l_alternate_designator IS NOT NULL)
7844 THEN
7845 l_event.param_value_4 := item.concatenated_segments||' - '||item.organization_code||' - '||l_alternate_designator;
7846 ELSE
7847 l_event.param_value_4 := item.concatenated_segments||' - '||item.organization_code;
7848 END IF;
7849
7850 l_event.param_name_5 := 'PSIG_TRANSACTION_AUDIT_ID';
7851 l_event.param_value_5 := -1;
7852
7853 l_event.param_name_6 := '#WF_SOURCE_APPLICATION_TYPE';
7854 l_event.param_value_6 := 'DB';
7855
7856 l_event.param_name_7 := '#WF_SIGN_REQUESTER';
7857 l_event.param_value_7 := FND_GLOBAL.USER_NAME;
7858
7859 IF (l_pending_from_ecn IS NULL)
7860 THEN
7861 l_child_event_name := 'oracle.apps.bom.routingUpdate';
7862 ELSE
7863 l_child_event_name := 'oracle.apps.bom.routingCreate';
7864 END IF;
7865
7866 IF (NVL(l_parent_record_id, -1) > 0)
7867 THEN
7868 --additional parameters for the child event
7869 l_event.param_name_8 := 'PARENT_EVENT_NAME';
7870 l_event.param_value_8 := 'oracle.apps.eng.ecoImplement';
7871 l_event.param_name_9 := 'PARENT_EVENT_KEY';
7872 l_event.param_value_9 := TO_CHAR(item.change_id);
7873 l_event.param_name_10 := 'PARENT_ERECORD_ID';
7874 l_event.param_value_10 := TO_CHAR(l_parent_record_id);
7875 END IF;
7876
7877 -- Part 2 of preparation of child event :
7878 l_event.event_name := l_child_event_name;
7879 l_event.event_key := TO_CHAR(item.routing_sequence_id);
7880 -- l_event.payload := l_payload;
7881 l_event.erecord_id := l_erecord_id;
7882 l_event.event_status := l_event_status;
7883
7884 QA_EDR_STANDARD.RAISE_ERES_EVENT
7885 ( p_api_version => 1.0
7886 , p_init_msg_list => FND_API.G_FALSE
7887 , p_validation_level => FND_API.G_VALID_LEVEL_FULL
7888 , x_return_status => l_return_status
7889 , x_msg_count => l_msg_count
7890 , x_msg_data => l_msg_data
7891 , p_child_erecords => l_child_record
7892 , x_event => l_event);
7893
7894 IF (NVL(l_return_status, FND_API.G_FALSE) <> FND_API.G_TRUE)
7895 AND (l_msg_count > 0)
7896 THEN
7897 RAISE ERES_EVENT_ERROR;
7898 END IF;
7899
7900 -- Keep the eRecord id :
7901 IF (NVL(l_event.erecord_id, -1) > 0)
7902 THEN
7903 INSERT INTO ENG_PARENT_CHILD_EVENTS_TEMP(parent_event_name
7904 , parent_event_key, parent_erecord_id
7905 , event_name, event_key, erecord_id
7906 , event_status)
7907 VALUES ( 'oracle.apps.eng.ecoImplement', TO_CHAR(item.change_id)
7908 , l_parent_record_id
7909 , l_event.event_name, l_event.event_key, l_event.erecord_id
7910 , l_event.event_status);
7911
7912 FND_FILE.PUT_LINE(FND_FILE.LOG, 'After event='||l_child_event_name||', eRecord_id='||l_event.erecord_id||', status='||l_event.event_status||', routing='||item.routing_sequence_id);
7913 ELSE
7914 FND_FILE.PUT_LINE(FND_FILE.LOG, 'No eRecord generated for '||l_event.event_name||'. This is normal. Please check your rules or other setups');
7915 END IF;
7916
7917 END IF; -- (NVL(item.routing_sequence_id, -1) > 0)
7918 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Normal end of ERES Calls for procedure implement_revised_item.');
7919
7920 ELSE
7921 FND_FILE.PUT_LINE(FND_FILE.LOG, 'bERES_Flag_for_Routing=FALSE, then, NO ERES event for Routing.');
7922 END IF; -- SQL%ROWCOUNT > 0
7923 END IF; -- l_eres_enabled
7924 -- ERES change ends
7925
7926 Update eng_revised_items
7927 set implementation_date = today,
7928 scheduled_date = eff_date,
7929 status_type = 6,
7930 last_update_date = sysdate,
7931 last_updated_by = userid,
7932 last_update_login = loginid,
7933 request_id = reqstid,
7934 program_application_id = appid,
7935 program_id = progid,
7936 program_update_date = sysdate,
7937 status_code = p_status_code
7938 -- where current of get_item_info;
7939 where revised_item_sequence_id = item.revised_item_sequence_id;
7940
7941
7942 -- set values for inserting rows into wip schedule interface
7943 l_wip_primary_item_id := item.revised_item_id;
7944 l_wip_from_cum_qty := item.from_cum_qty;
7945 l_from_wip_entity_id := item.from_wip_entity_id;
7946 l_to_wip_entity_id := item.to_wip_entity_id;
7947
7948 IF item.new_item_revision IS NOT NULL
7949 THEN
7950 l_wip_bom_revision2 := item.new_item_revision;
7951 l_wip_bom_revision_date2 := revision_high_date + 1/60/24;
7952 ELSE
7953 l_wip_bom_revision2 := l_current_revision;
7954 /* IF l_current_rev_eff_date <= now
7955 THEN
7956 l_wip_bom_revision_date2 := revision_high_date;
7957 ELSE
7958 IF l_current_rev_eff_date < revision_high_date
7959 THEN
7960 l_wip_bom_revision_date2 := revision_high_date;
7961 ELSE
7962 l_wip_bom_revision_date2 := l_current_rev_eff_date;
7963 END IF;
7964 END IF;
7965 */
7966 IF l_current_rev_eff_date <= revision_high_date
7967 THEN
7968 l_wip_bom_revision_date2 := revision_high_date + 1/60/24;
7969 ELSE
7970 l_wip_bom_revision_date2 := l_current_rev_eff_date;
7971 END IF;
7972
7973 END IF;
7974
7975 IF item.new_routing_revision IS NOT NULL
7976 THEN
7977 l_wip_routing_revision2 := item.new_routing_revision;
7978 l_wip_routing_revision_date2 := rtg_revision_high_date + 1/60/24;
7979 ELSE
7980 l_wip_routing_revision2 := l_current_rtg_revision;
7981 /* IF l_current_rtg_rev_eff_date <= now
7982 THEN
7983 l_wip_routing_revision_date2 := now;
7984 ELSE
7985 IF l_current_rtg_rev_eff_date < rtg_revision_high_date
7986 THEN
7987 l_wip_routing_revision_date2 := rtg_revision_high_date;
7988 ELSE
7989 l_wip_routing_revision_date2 := l_current_rtg_rev_eff_date;
7990 END IF;
7991 END IF;
7992 */
7993 IF l_current_rtg_rev_eff_date <= rtg_revision_high_date
7994 THEN
7995 l_wip_routing_revision_date2 := rtg_revision_high_date + 1/60/24;
7996 ELSE
7997 l_wip_routing_revision_date2 := l_current_rtg_rev_eff_date;
7998 END IF;
7999
8000 END IF;
8001
8002 l_wip_bom_revision_date1 := l_wip_bom_revision_date2- 1/3600/24; -- minus 1 second
8003 l_wip_routing_revision_date1 := l_wip_bom_revision_date2- 1; -- minus 1 day
8004
8005 l_update_wip := NVL(item.update_wip,2);
8006 l_eco_for_production := NVL(item.eco_for_production, 2);
8007
8008 END IF; -- Check for Transfer/Copy OR Revised Item Change
8009
8010 Close get_item_info;
8011
8012 Open check_for_unimp_items;
8013 Fetch check_for_unimp_items into dummy;
8014 If check_for_unimp_items%notfound then
8015 -- old code before 11.5.10 lifecycle enhancement
8016 /*
8017 Update eng_engineering_changes
8018 set implementation_date = today,
8019 status_type = 6,
8020 last_update_date = sysdate,
8021 last_updated_by = userid,
8022 last_update_login = loginid,
8023 request_id = reqstid,
8024 program_application_id = appid,
8025 program_id = progid,
8026 program_update_date = sysdate
8027 where organization_id = item.organization_id
8028 and change_notice = item.change_notice;
8029 */
8030
8031 -- New code: begin
8032 -- Check if implementation of header is allowed or not for the current phase
8033 -- added for bug 3482152
8034 select nvl(plm_or_erp_change, 'PLM') , status_code
8035 into l_plm_or_erp_change, l_curr_status_code
8036 from eng_engineering_changes where
8037 change_id = item.change_id;
8038
8039 l_implement_header := 'T';
8040 l_implement_header := check_header_impl_allowed(
8041 p_change_id => item.change_id
8042 , p_change_notice => item.change_notice
8043 , p_status_code => p_status_code
8044 , p_curr_status_code => l_curr_status_code
8045 , p_plm_or_erp_change => l_plm_or_erp_change
8046 , p_request_id => reqstid);
8047
8048 IF (l_implement_header = 'T')
8049 THEN
8050 -- setting the end-date to the current phase if null
8051 -- added for bug 3482152
8052 UPDATE eng_lifecycle_statuses
8053 SET completion_date = sysdate,
8054 last_update_date = sysdate,
8055 last_updated_by = userid,
8056 last_update_login = loginid
8057 WHERE entity_name = 'ENG_CHANGE'
8058 AND entity_id1 = item.change_id
8059 AND status_code = l_curr_status_code
8060 AND active_flag = 'Y'
8061 AND completion_date IS NULL;
8062
8063 -- First set header phase to implement
8064 Update eng_engineering_changes
8065 set implementation_date = today,
8066 status_type = 6,
8067 status_code = p_status_code,
8068 last_update_date = sysdate,
8069 last_updated_by = userid,
8070 last_update_login = loginid,
8071 request_id = reqstid,
8072 program_application_id = appid,
8073 program_id = progid,
8074 program_update_date = sysdate
8075 where organization_id = item.organization_id
8076 and change_notice = item.change_notice;
8077
8078 -- Reset promote_status_code
8079 Update eng_engineering_changes
8080 set promote_status_code = null
8081 where organization_id = item.organization_id
8082 and change_notice = item.change_notice;
8083
8084 -- Complete the last phase in the lifecycle
8085 UPDATE eng_lifecycle_statuses
8086 SET start_date = nvl(start_date,sysdate), -- set the start date on implemented phase after promoting the header to implemented phase
8087 -- added for bug 3482152
8088 completion_date = sysdate,
8089 last_update_date = sysdate,
8090 last_updated_by = userid,
8091 last_update_login = loginid
8092 WHERE entity_name = 'ENG_CHANGE'
8093 AND entity_id1 = (SELECT change_id
8094 FROM eng_engineering_changes
8095 WHERE organization_id = item.organization_id
8096 AND change_notice = item.change_notice
8097 )
8098 AND active_flag = 'Y'
8099 AND sequence_number = (SELECT max(sequence_number)
8100 FROM eng_lifecycle_statuses
8101 WHERE entity_name = 'ENG_CHANGE'
8102 AND entity_id1 = (SELECT change_id
8103 FROM eng_engineering_changes
8104 WHERE organization_id = item.organization_id
8105 AND change_notice = item.change_notice
8106 )
8107 );
8108 -- New code: end
8109
8110 -- Fix for bug: 3463308
8111 /* does not work for some reason, but do not delete
8112 FND_FILE.PUT_NAMES('CP.impECO.wf.log',
8113 'CP.impECO.wf.out',
8114 '/appslog/bis_top/utl/plm115dt/log'
8115 );
8116 FND_FILE.PUT_LINE(fnd_file.log, 'Before: calling startWorkflow');
8117 FND_FILE.PUT_LINE(fnd_file.log, ' item.change_id = ' || item.change_id);
8118 */
8119 -- using dynamic sql to launch status_change workflow API for implement phase
8120 BEGIN
8121 -- Log action for promotion to implement phase
8122 l_plsql_block :=
8123 'BEGIN '
8124 || ' ENG_CHANGE_ACTIONS_UTIL.Create_Change_Action('
8125 || ' p_api_version => 1.0 '
8126 || ',x_return_status => :1 '
8127 || ',x_msg_count => :2 '
8128 || ',x_msg_data => :3 '
8129 || ',p_action_type => ''PROMOTE'' '
8130 || ',p_object_name => ''ENG_CHANGE'' '
8131 || ',p_object_id1 => :4 '
8132 || ',p_parent_action_id => -1 '
8133 || ',p_status_code => :5 ' -- seeded value for implement phase
8134 || ',p_action_date => SYSDATE '
8135 || ',p_change_description => NULL '
8136 || ',p_user_id => -10000 '
8137 || ',p_api_caller => ''WF'' '
8138 || ',x_change_action_id => :6 '
8139 /*
8140 || ',p_init_msg_list => FND_API.G_TRUE '
8141 || ',p_validation_level => FND_API.G_VALID_LEVEL_FULL '
8142 || ',p_debug => FND_API.G_TRUE '
8143 || ',p_output_dir => ''/appslog/bis_top/utl/plm115dt/log'' '
8144 || ',p_debug_filename => ''engact.createAct4Imp.log'' '
8145 */
8146 || '); END;';
8147 EXECUTE IMMEDIATE l_plsql_block USING
8148 OUT l_return_status, -- :1
8149 OUT l_msg_count, -- :2
8150 OUT l_msg_data, -- :3
8151 IN item.change_id, -- :4
8152 IN p_status_code, -- :5
8153 OUT l_action_id; -- :6
8154
8155 -- Bug Fix: 5023201
8156 -- Should not start workflow if it's MFG Change Order
8157 IF ( l_plm_or_erp_change = 'PLM' )
8158 THEN
8159 --- Bug 6982970 vggarg code added for status change business event fire start
8160 SELECT cot.base_change_mgmt_type_code
8161 INTO l_base_cm_type_code
8162 FROM eng_engineering_changes ec,
8163 eng_change_order_types cot
8164 WHERE ec.change_id = item.change_id
8165 AND ec.change_mgmt_type_code = cot.change_mgmt_type_code
8166 AND cot.type_classification = 'CATEGORY';
8167
8168 Raise_Status_Change_Event
8169 ( p_change_id => item.change_id
8170 ,p_base_cm_type_code => l_base_cm_type_code
8171 ,p_status_code => p_status_code
8172 ,p_action_type => 'PROMOTE'
8173 ,p_action_id => l_action_id
8174 );
8175 --- Bug 6982970 vggarg code added for status change business event fire end
8176
8177 -- Start workflow for phase change
8178 l_plsql_block :=
8179 'BEGIN '
8180 || ' Eng_Workflow_Util.StartWorkflow('
8181 || ' p_api_version => 1.0 '
8182 || ',x_return_status => :1 '
8183 || ',x_msg_count => :2 '
8184 || ',x_msg_data => :3 '
8185 || ',p_item_type => Eng_Workflow_Util.G_CHANGE_ACTION_ITEM_TYPE '
8186 || ',x_item_key => :4 '
8187 || ',p_process_name => Eng_Workflow_Util.G_STATUS_CHANGE_PROC '
8188 || ',p_change_id => :5 '
8189 || ',p_action_id => :6 '
8190 || ',p_wf_user_id => -10000 '
8191 || ',p_route_id => 0 '
8192 /*
8193 || ',p_init_msg_list => FND_API.G_TRUE '
8194 || ',p_validation_level => FND_API.G_VALID_LEVEL_FULL '
8195 || ',p_debug => FND_API.G_TRUE '
8196 || ',p_output_dir => ''/appslog/bis_top/utl/plm115dt/log'' '
8197 || ',p_debug_filename => ''engact.startWF4Imp.log'' '
8198 */
8199 || '); END;';
8200 EXECUTE IMMEDIATE l_plsql_block USING
8201 OUT l_return_status, -- :1
8202 OUT l_msg_count, -- :2
8203 OUT l_msg_data, -- :3
8204 IN OUT l_item_key, -- :4
8205 IN item.change_id, -- :5
8206 IN l_action_id; -- :6
8207
8208 -- Bug: 3479509
8209 -- Starting the workflow associated to implemented status
8210 SELECT change_wf_route_id
8211 INTO l_wf_route_id
8212 FROM eng_lifecycle_statuses
8213 WHERE entity_name = 'ENG_CHANGE'
8214 AND entity_id1 = item.change_id
8215 AND status_code = p_status_code
8216 AND active_flag = 'Y'
8217 AND rownum = 1;
8218
8219 IF (l_wf_route_id IS NOT NULL) THEN
8220 l_plsql_block :=
8221 'BEGIN '
8222 || ' Eng_Workflow_Util.StartWorkflow('
8223 || ' p_api_version => 1.0 '
8224 || ',x_return_status => :1 '
8225 || ',x_msg_count => :2 '
8226 || ',x_msg_data => :3 '
8227 || ',p_item_type => Eng_Workflow_Util.G_CHANGE_ROUTE_ITEM_TYPE '
8228 || ',x_item_key => :4 '
8229 || ',p_process_name => Eng_Workflow_Util.G_ROUTE_AGENT_PROC '
8230 || ',p_change_id => :5 '
8231 || ',p_wf_user_id => -10000 '
8232 || ',p_route_id => :6 '
8233 || '); END;';
8234 EXECUTE IMMEDIATE l_plsql_block USING
8235 OUT l_return_status, -- :1
8236 OUT l_msg_count, -- :2
8237 OUT l_msg_data, -- :3
8238 IN OUT l_item_key, -- :4
8239 IN item.change_id, -- :5
8240 IN l_wf_route_id; -- :6
8241 END IF;
8242
8243 END IF ; -- ( l_plm_or_erp_change = 'PLM' )
8244
8245 EXCEPTION
8246 WHEN OTHERS THEN
8247 null;
8248 END;
8249 /* does not work for some reason, but do not delete
8250 FND_FILE.PUT_LINE(fnd_file.log, 'After: calling startWorkflow');
8251 FND_FILE.PUT_LINE(fnd_file.log, ' l_return_status = ' || l_return_status);
8252 FND_FILE.PUT_LINE(fnd_file.log, ' l_msg_count = ' || to_char( nvl(l_msg_count, 0) ) );
8253 FND_FILE.PUT_LINE(fnd_file.log, ' l_msg_data = ' || nvl(l_msg_data, 'no msg data') );
8254 FND_FILE.PUT_LINE(fnd_file.log, ' l_item_key = ' || nvl(l_item_key, 'no item key') );
8255 FND_FILE.CLOSE;
8256 */
8257 END IF;
8258 end if;
8259 Close check_for_unimp_items;
8260
8261 -----------------------------------------------------------------
8262 -- For ECO cumulative/ECO wip job/ECO lot ---------9/07/2000----
8263 -----------------------------------------------------------------
8264 -- IF item.update_wip = 1 and NVL(item.start_quantity,0) > 0
8265 IF l_update_wip = 1
8266 THEN
8267
8268 SELECT wip_job_schedule_interface_s.NEXTVAL INTO l_wip_group_id1
8269 FROM DUAL;
8270 group_id1 := l_wip_group_id1; --- set out type value
8271
8272 --bug 2327582
8273 l_update_all_jobs := fnd_profile.value('ENG:UPDATE_UNRELEASED_WIP_JOBS');
8274
8275 l_wip_jsi_insert_flag := 0;
8276 IF NVL(l_wip_from_cum_qty, 0) > 0
8277 THEN
8278 IF l_wip_start_quantity1 <> 0
8279 THEN
8280 SELECT wip_job_schedule_interface_s.NEXTVAL INTO l_wip_group_id2
8281 FROM DUAL;
8282 group_id2 := l_wip_group_id2; --- set out type value
8283 ELSE group_id2 := -1;
8284 END IF;
8285
8286 --WIP job gets split into 2 based on the CUM quantity
8287 -- delete the original wip job
8288 INSERT INTO wip_job_schedule_interface
8289 (
8290 last_update_date
8291 , last_updated_by
8292 , creation_date
8293 , created_by
8294 , request_id
8295 , program_application_id
8296 , program_id
8297 , program_update_date
8298 , group_id
8299 , process_phase
8300 , process_status
8301 , organization_id
8302 , load_type
8303 , status_type
8304 , wip_entity_id
8305 )
8306 VALUES
8307 (
8308 sysdate
8309 , userid
8310 , sysdate
8311 , userid
8312 , reqstid
8313 , appid
8314 , progid
8315 , sysdate
8316 , l_wip_group_id1
8317 , l_wip_process_phase
8318 , l_wip_process_status
8319 , item.organization_id
8320 , 3 -- update or delete wip
8321 , 7 -- cancel wip order
8322 , item.from_wip_entity_id
8323 );
8324
8325 -- Create first new order
8326 IF l_wip_start_quantity1 <> 0
8327 THEN
8328 INSERT INTO wip_job_schedule_interface
8329 (
8330 last_update_date
8331 , last_updated_by
8332 , creation_date
8333 , created_by
8334 , last_update_login
8335 , request_id
8336 , program_id
8337 , program_application_id
8338 , program_update_date
8339 , group_id
8340 , organization_id
8341 , load_type
8342 , status_type
8343 , primary_item_id
8344 , bom_revision_date
8345 , routing_revision_date
8346 , job_name
8347 , start_quantity
8348 , net_quantity
8349 , process_phase
8350 , process_status
8351 , last_unit_completion_date
8352 -- , routing_revision
8353 -- , bom_revision
8354 , completion_subinventory
8355 , completion_locator_id
8356 , allow_explosion
8357 , header_id
8358 )
8359 values
8360 ( sysdate
8361 , userid
8362 , sysdate
8363 , userid
8364 , loginid
8365 , reqstid
8366 , progid
8367 , appid
8368 , sysdate
8369 , l_wip_group_id2
8370 , l_wip_organization_id
8371 , l_wip_load_type
8372 , l_wip_status_type
8373 , l_wip_primary_item_id
8374 , l_wip_bom_revision_date1
8375 , decode(l_WIP_Flag_for_routing,'Y', l_wip_routing_revision_date1, NULL) -- Bug 4455543
8376 , l_wip_job_name1
8377 , l_wip_start_quantity1
8378 , l_wip_net_quantity1
8379 , l_wip_process_phase
8380 , l_wip_process_status
8381 , l_wip_last_u_compl_date1
8382 --, l_wip_routing_revision1
8383 --, l_wip_bom_revision1
8384 , l_wip_completion_subinventory
8385 , l_wip_completion_locator_id
8386 , l_wip_allow_explosion
8387 , l_wip_group_id2
8388 );
8389
8390 --Reverting the changes introduced in bug 5285282 as part of bug 14039105
8391 -- Add components for 'Update Job Only' case
8392 -- Bug No: 5285282
8393 /* IF l_eco_for_production = 1
8394 THEN
8395 ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id => item.revised_item_sequence_id,
8396 p_group_id => l_wip_group_id2,
8397 p_parent_header_id => l_wip_group_id2,
8398 p_mrp_active => item.mrp_active,
8399 p_user_id => userid,
8400 p_login_id => loginid,
8401 p_request_id => reqstid,
8402 p_program_id => progid,
8403 p_program_application_id => appid);
8404 END IF; */
8405 END IF; -- IF l_wip_start_quantity1 <> 0
8406
8407 -- Create second new records
8408 INSERT INTO wip_job_schedule_interface (
8409 last_update_date
8410 , last_updated_by
8411 , creation_date
8412 , created_by
8413 , last_update_login
8414 , request_id
8415 , program_id
8416 , program_application_id
8417 , program_update_date
8418 , group_id
8419 , organization_id
8420 , load_type
8421 , status_type
8422 , primary_item_id
8423 , bom_revision_date
8424 , routing_revision_date
8425 , job_name
8426 , start_quantity
8427 , net_quantity
8428 , process_phase
8429 , process_status
8430 , last_unit_completion_date
8431 -- , routing_revision
8432 -- , bom_revision
8433 , completion_subinventory
8434 , completion_locator_id
8435 , allow_explosion
8436 , header_id
8437 )
8438 values
8439 (
8440 sysdate
8441 , userid
8442 , sysdate
8443 , userid
8444 , loginid
8445 , reqstid
8446 , progid
8447 , appid
8448 , sysdate
8449 , l_wip_group_id1
8450 , l_wip_organization_id
8451 , l_wip_load_type
8452 , l_wip_status_type
8453 , l_wip_primary_item_id
8454 , l_wip_bom_revision_date2
8455 , decode(l_WIP_Flag_for_routing,'Y', l_wip_routing_revision_date2, NULL) -- Bug 4455543
8456 , l_wip_job_name2
8457 , l_wip_start_quantity2
8458 , l_wip_net_quantity2
8459 , l_wip_process_phase
8460 , l_wip_process_status
8461 , decode(l_WIP_Flag_for_routing,'Y',l_wip_last_u_compl_date2, NULL) -- Bug 4455543
8462 -- , l_wip_routing_revision2
8463 -- , l_wip_bom_revision2
8464 , l_wip_completion_subinventory
8465 , l_wip_completion_locator_id
8466 , l_wip_allow_explosion
8467 , l_wip_group_id1
8468 );
8469
8470 --Reverting the changes introduced in bug 5285282 as part of bug 14039105
8471 -- Add components for 'Update Job Only' case
8472 -- Bug No: 5285282
8473 /*IF l_eco_for_production = 1
8474 THEN
8475 ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id => item.revised_item_sequence_id,
8476 p_group_id => l_wip_group_id1,
8477 p_parent_header_id => l_wip_group_id1,
8478 p_mrp_active => item.mrp_active,
8479 p_user_id => userid,
8480 p_login_id => loginid,
8481 p_request_id => reqstid,
8482 p_program_id => progid,
8483 p_program_application_id => appid);
8484 END IF; */
8485
8486 l_wip_jsi_insert_flag := 1;
8487
8488 ELSIF NVL(l_to_wip_entity_id, 0) <> 0
8489 THEN
8490 FOR wip_name_for_job_rec in l_wip_name_for_job_cur
8491 LOOP
8492 l_wip_job_name2 := wip_name_for_job_rec.wip_entity_name;
8493 l_wip_last_u_compl_date2 := wip_name_for_job_rec.scheduled_completion_date;
8494
8495 SELECT wip_job_schedule_interface_s.NEXTVAL INTO l_wip_header_id
8496 FROM DUAL; --fix bug 5667398 cannot have duplicate header id from same group id
8497 /* Added for Bug2970539, Bug 3076067 */
8498
8499 --if (l_wip_bom_revision_date2 > today) then -- 3412747
8500 if (wip_name_for_job_rec.bom_revision_date > today)
8501 then
8502 l_wip_bom_revision_date2 := wip_name_for_job_rec.bom_revision_date;
8503 end if;
8504 --if (l_wip_routing_revision_date2 > today) then -- 3412747
8505 if (wip_name_for_job_rec.routing_revision_date > today)
8506 then
8507 l_wip_routing_revision_date2 := wip_name_for_job_rec.routing_revision_date;
8508 end if;
8509
8510 --Update existing WIP headers
8511 INSERT INTO wip_job_schedule_interface
8512 (
8513 last_update_date
8514 , last_updated_by
8515 , creation_date
8516 , created_by
8517 , last_update_login
8518 , request_id
8519 , program_id
8520 , program_application_id
8521 , program_update_date
8522 , group_id
8523 , organization_id
8524 , load_type
8525 , status_type
8526 , primary_item_id
8527 , bom_revision_date
8528 , routing_revision_date
8529 , job_name
8530 , process_phase
8531 , process_status
8532 , last_unit_completion_date
8533 , routing_revision
8534 , bom_revision
8535 , bom_reference_id
8536 , routing_reference_id
8537 , allow_explosion
8538 , alternate_bom_designator
8539 , alternate_routing_designator
8540 , completion_subinventory
8541 , completion_locator_id
8542 , header_id
8543 )
8544 values
8545 (
8546 sysdate
8547 , userid
8548 , sysdate
8549 , userid
8550 , loginid
8551 , reqstid
8552 , progid
8553 , appid
8554 , sysdate
8555 , l_wip_group_id1
8556 , l_wip_organization_id
8557 , 3 --l_wip_load_type
8558 , l_wip_status_type
8559 , wip_name_for_job_rec.primary_item_id
8560 --, l_wip_primary_item_id
8561 , l_wip_bom_revision_date2
8562 , decode(l_WIP_Flag_for_routing,'Y',l_wip_routing_revision_date2, NULL) -- Bug 4455543
8563 , l_wip_job_name2
8564 , l_wip_process_phase
8565 , l_wip_process_status
8566 , decode(l_WIP_Flag_for_routing,'Y', l_wip_last_u_compl_date2, NULL) -- Bug 4455543
8567 , decode(l_WIP_Flag_for_routing,'Y', nvl(wip_name_for_job_rec.routing_revision, l_wip_routing_revision2) -- Bug 3381547
8568 , NULL) -- Bug 4455543
8569 , nvl(wip_name_for_job_rec.bom_revision, l_wip_bom_revision2) -- Bug 3381547
8570 , wip_name_for_job_rec.primary_item_id
8571 , decode(l_WIP_Flag_for_routing,'Y',wip_name_for_job_rec.primary_item_id, NULL) -- Bug 4455543
8572 --, l_wip_primary_item_id
8573 --, l_wip_primary_item_id
8574 , l_wip_allow_explosion
8575 ,wip_name_for_job_rec.alternate_bom_designator --2964588
8576 ,decode(l_WIP_Flag_for_Routing,'Y',wip_name_for_job_rec.alternate_routing_designator,NULL) --2964588, modified for bug 8412836
8577 , l_wip_completion_subinventory -- Bug 5896479
8578 , l_wip_completion_locator_id -- Bug 5896479
8579 , l_wip_header_id
8580 );
8581
8582 --Reverting the changes introduced in bug 5285282 as part of bug 14039105
8583 -- Add components for 'Update Job Only' case
8584 -- Bug No: 5285282
8585 /*IF l_eco_for_production = 1
8586 THEN
8587 ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id => item.revised_item_sequence_id,
8588 p_group_id => l_wip_group_id1,
8589 p_parent_header_id => l_wip_header_id,
8590 p_mrp_active => item.mrp_active,
8591 p_user_id => userid,
8592 p_login_id => loginid,
8593 p_request_id => reqstid,
8594 p_program_id => progid,
8595 p_program_application_id => appid);
8596 END IF; */
8597
8598 IF l_wip_jsi_insert_flag = 0
8599 THEN
8600 l_wip_jsi_insert_flag := 1;
8601 END IF ;
8602 END LOOP;
8603 --commented out for bug 13059960
8604 /* ELSIF NVL(l_lot_number,'NULL') <> 'NULL'
8605 THEN
8606
8607 FOR wip_name_for_lot_rec in l_wip_name_for_lot_cur
8608 LOOP
8609 l_wip_job_name2 := wip_name_for_lot_rec.wip_entity_name;
8610 l_wip_last_u_compl_date2 := wip_name_for_lot_rec.scheduled_completion_date;
8611
8612 SELECT wip_job_schedule_interface_s.NEXTVAL INTO l_wip_header_id
8613 FROM DUAL; --fix bug 5667398 cannot have duplicate header id from same group id
8614
8615 /* Added for Bug2970539, Bug 3076067 */
8616
8617 --if (l_wip_bom_revision_date2 > today) then --3412747
8618 /* if (wip_name_for_lot_rec.bom_revision_date > today
8619 OR l_wip_bom_revision_date2 IS NULL -- Added 'OR' condition for Bug #3988681
8620 )
8621 then
8622 l_wip_bom_revision_date2 := wip_name_for_lot_rec.bom_revision_date;
8623 end if;
8624 --if (l_wip_routing_revision_date2 > today) then --3412747
8625 if (wip_name_for_lot_rec.routing_revision_date > today
8626 OR l_wip_routing_revision_date2 IS NULL -- Added 'OR' condition for Bug #3988681
8627 )
8628 then
8629 l_wip_routing_revision_date2 := wip_name_for_lot_rec.routing_revision_date;
8630 end if;
8631
8632 INSERT INTO wip_job_schedule_interface
8633 (
8634 last_update_date
8635 , last_updated_by
8636 , creation_date
8637 , created_by
8638 , last_update_login
8639 , request_id
8640 , program_id
8641 , program_application_id
8642 , program_update_date
8643 , group_id
8644 , organization_id
8645 , load_type
8646 , status_type
8647 , primary_item_id
8648 , bom_revision_date
8649 , routing_revision_date
8650 , job_name
8651 , process_phase
8652 , process_status
8653 , last_unit_completion_date
8654 , routing_revision
8655 , bom_revision
8656 , bom_reference_id
8657 , routing_reference_id
8658 , allow_explosion
8659 , alternate_bom_designator
8660 , alternate_routing_designator
8661 , completion_subinventory
8662 , completion_locator_id
8663 , header_id
8664 )
8665 values
8666 (
8667 sysdate
8668 , userid
8669 , sysdate
8670 , userid
8671 , loginid
8672 , reqstid
8673 , progid
8674 , appid
8675 , sysdate
8676 , l_wip_group_id1
8677 --, l_wip_organization_id --3412747
8678 , wip_name_for_lot_rec.organization_id
8679 , 3 --l_wip_load_type
8680 , l_wip_status_type
8681 , wip_name_for_lot_rec.primary_item_id
8682 -- , l_wip_primary_item_id
8683 , l_wip_bom_revision_date2
8684 , decode(l_WIP_Flag_for_routing,'Y',l_wip_routing_revision_date2, null) -- Bug 4455543
8685 , l_wip_job_name2
8686 , l_wip_process_phase
8687 , l_wip_process_status
8688 , decode(l_WIP_Flag_for_routing,'Y',l_wip_last_u_compl_date2, null) -- Bug 4455543
8689 , decode(l_WIP_Flag_for_routing,'Y',nvl(wip_name_for_lot_rec.routing_revision, l_wip_routing_revision2) -- Bug 3381547
8690 , null) -- Bug 4455543
8691 , nvl(wip_name_for_lot_rec.bom_revision, l_wip_bom_revision2) -- Bug 3381547
8692 , wip_name_for_lot_rec.primary_item_id
8693 , decode(l_WIP_Flag_for_routing,'Y',wip_name_for_lot_rec.primary_item_id, null) -- Bug 4455543
8694 -- , l_wip_primary_item_id
8695 -- , l_wip_primary_item_id
8696 , l_wip_allow_explosion
8697 ,wip_name_for_lot_rec.alternate_bom_designator --2964588
8698 ,decode(l_WIP_Flag_for_Routing,'Y',wip_name_for_lot_rec.alternate_routing_designator,NULL) --2964588, modified for bug 8412836
8699 , l_wip_completion_subinventory -- Bug 5896479
8700 , l_wip_completion_locator_id -- Bug 5896479
8701 , l_wip_header_id
8702 );
8703
8704 -- Add components for 'Update Job Only' case
8705 -- Bug No: 5285282
8706 IF l_eco_for_production = 1
8707 THEN
8708 ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id => item.revised_item_sequence_id,
8709 p_group_id => l_wip_group_id1,
8710 p_parent_header_id => l_wip_header_id,
8711 p_mrp_active => item.mrp_active,
8712 p_user_id => userid,
8713 p_login_id => loginid,
8714 p_request_id => reqstid,
8715 p_program_id => progid,
8716 p_program_application_id => appid);
8717 END IF;
8718
8719 IF l_wip_jsi_insert_flag = 0
8720 THEN
8721 l_wip_jsi_insert_flag := 1;
8722 END IF ;
8723 END LOOP; */
8724 ELSE
8725 -- for updating other common wip discrete jobs
8726
8727 FOR wip_name_for_common_rec in l_wip_name_for_common_cur
8728 LOOP
8729 l_wip_job_name2 := wip_name_for_common_rec.wip_entity_name;
8730 l_wip_last_u_compl_date2 := wip_name_for_common_rec.scheduled_completion_date;
8731
8732 SELECT wip_job_schedule_interface_s.NEXTVAL INTO l_wip_header_id
8733 FROM DUAL; --fix bug 5667398 cannot have duplicate header id from same group id
8734
8735 /* Added for Bug2970539, Bug 3076067 */
8736
8737 --if (l_wip_bom_revision_date2 > today) then --3412747
8738 if (wip_name_for_common_rec.bom_revision_date > today
8739 OR l_wip_bom_revision_date2 IS NULL -- Added 'OR' condition for Bug #3988681
8740 )
8741 then
8742 l_wip_bom_revision_date2 := wip_name_for_common_rec.bom_revision_date;
8743 end if;
8744 --if (l_wip_routing_revision_date2 > today) then --3412747
8745 if (wip_name_for_common_rec.routing_revision_date > today
8746 OR l_wip_routing_revision_date2 IS NULL -- Added 'OR' condition for Bug #3988681
8747 )
8748 then
8749 l_wip_routing_revision_date2 := wip_name_for_common_rec.routing_revision_date;
8750 end if;
8751
8752
8753 INSERT INTO wip_job_schedule_interface
8754 (
8755 last_update_date
8756 , last_updated_by
8757 , creation_date
8758 , created_by
8759 , last_update_login
8760 , request_id
8761 , program_id
8762 , program_application_id
8763 , program_update_date
8764 , group_id
8765 , organization_id
8766 , load_type
8767 , status_type
8768 , primary_item_id
8769 , bom_revision_date
8770 , routing_revision_date
8771 , job_name
8772 , process_phase
8773 , process_status
8774 , last_unit_completion_date
8775 , routing_revision
8776 , bom_revision
8777 , bom_reference_id
8778 , routing_reference_id
8779 , allow_explosion
8780 , alternate_bom_designator
8781 , alternate_routing_designator
8782 , completion_subinventory
8783 , completion_locator_id
8784 , header_id
8785 )
8786 values
8787 (
8788 sysdate
8789 , userid
8790 , sysdate
8791 , userid
8792 , loginid
8793 , reqstid
8794 , progid
8795 , appid
8796 , sysdate
8797 , l_wip_group_id1
8798 --, l_wip_organization_id --3412747
8799 , wip_name_for_common_rec.organization_id
8800 , 3 --l_wip_load_type
8801 , l_wip_status_type
8802 , wip_name_for_common_rec.primary_item_id
8803 --, l_wip_primary_item_id
8804 , l_wip_bom_revision_date2
8805 , decode(l_WIP_Flag_for_routing,'Y',l_wip_routing_revision_date2, null) -- Bug 4455543
8806 , l_wip_job_name2
8807 , l_wip_process_phase
8808 , l_wip_process_status
8809 , decode(l_WIP_Flag_for_routing,'Y',l_wip_last_u_compl_date2, null) -- Bug 4455543
8810 , decode(l_WIP_Flag_for_routing,'Y', nvl(wip_name_for_common_rec.routing_revision,l_wip_routing_revision2) -- Bug 3381547
8811 , null) -- Bug 4455543
8812 , nvl(wip_name_for_common_rec.bom_revision,l_wip_bom_revision2) -- Bug 3381547
8813 , wip_name_for_common_rec.primary_item_id
8814 , decode(l_WIP_Flag_for_routing,'Y',wip_name_for_common_rec.primary_item_id, null) -- Bug 4455543
8815 --, l_wip_primary_item_id
8816 --, l_wip_primary_item_id
8817 , l_wip_allow_explosion
8818 ,wip_name_for_common_rec.alternate_bom_designator --2964588
8819 ,decode(l_WIP_Flag_for_Routing,'Y',wip_name_for_common_rec.alternate_routing_designator,NULL) --2964588, modified for bug 8412836
8820 , l_wip_completion_subinventory -- Bug 5896479
8821 , l_wip_completion_locator_id -- Bug 5896479
8822 , l_wip_header_id
8823 );
8824
8825 --Reverting the changes introduced in bug 5285282 as part of bug 14039105
8826 -- Add components for 'Update Job Only' case
8827 -- Bug No: 5285282
8828 /*IF l_eco_for_production = 1
8829 THEN
8830 ENTER_WIP_DETAILS_FOR_COMPS ( p_revised_item_sequence_id => item.revised_item_sequence_id,
8831 p_group_id => l_wip_group_id1,
8832 p_parent_header_id => l_wip_header_id,
8833 p_mrp_active => item.mrp_active,
8834 p_user_id => userid,
8835 p_login_id => loginid,
8836 p_request_id => reqstid,
8837 p_program_id => progid,
8838 p_program_application_id => appid);
8839 END IF; */
8840
8841 IF l_wip_jsi_insert_flag = 0
8842 THEN
8843 l_wip_jsi_insert_flag := 1;
8844 END IF ;
8845 END LOOP;
8846 END IF; -- end of IF NVL(item.start_quantity,0)
8847
8848 END IF; -- end of item.update_wip = 1 and NVL...
8849 IF l_wip_jsi_insert_flag = 0
8850 THEN group_id1 := -1; --- reset out type value
8851 group_id2 := -1; --- reset out type value
8852 END IF;
8853
8854
8855 Exception
8856 When abort_implementation then
8857 Close get_item_info;
8858
8859 -- ERES change begins
8860 WHEN ERES_EVENT_ERROR THEN
8861
8862 FND_MSG_PUB.Get(
8863 p_msg_index => 1,
8864 p_data => l_message,
8865 p_encoded => FND_API.G_FALSE,
8866 p_msg_index_out => l_dummy_cnt);
8867
8868 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Error while creating event='||l_child_event_name||', key='||l_event.event_key);
8869 FND_FILE.PUT_LINE(FND_FILE.LOG, 'ERES_EVENT_ERROR: '||l_message);
8870 event_acknowledgement('FAILURE');
8871
8872 IF (msg_qty < max_messages)
8873 THEN
8874 msg_qty := msg_qty + 1;
8875 message_names(msg_qty) := 'ERES_EVENT_ERROR';
8876 token1(msg_qty) := 'CHANGE_ID';
8877 value1(msg_qty) := item.change_id;
8878 translate1(msg_qty) := 0;
8879 token2(msg_qty) := null;
8880 value2(msg_qty) := null;
8881 translate2(msg_qty) := 0;
8882
8883 msg_qty := msg_qty + 1;
8884 message_names(msg_qty) := l_message;
8885 token1(msg_qty) := 'CHANGE_ID';
8886 value1(msg_qty) := item.change_id;
8887 translate1(msg_qty) := 0;
8888 token2(msg_qty) := null;
8889 value2(msg_qty) := null;
8890 translate2(msg_qty) := 0;
8891 END IF;
8892 -- ERES change ends
8893
8894 When others then
8895 -- ERES change begins
8896 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Others Error: '||SQLERRM);
8897 event_acknowledgement('FAILURE');
8898 -- ERES change ends
8899
8900 -- Added for bug 4150069
8901 If c_get_revision%ISOPEN
8902 Then
8903 Close c_get_revision;
8904 End If;
8905 -- End changes for bug 4150069
8906
8907
8908 If msg_qty < max_messages then
8909 msg_qty := msg_qty + 1;
8910 message_names(msg_qty) := 'ENG_ORA_ERROR';
8911 token1(msg_qty) := 'ROUTINE';
8912 value1(msg_qty) := 'ENGPKLIMP';
8913 translate1(msg_qty) := 0;
8914 token2(msg_qty) := 'SQLERRM';
8915 value2(msg_qty) := substrb(sqlerrm, 1, 80);
8916 translate2(msg_qty) := 0;
8917 end if;
8918
8919 end;
8920
8921 Procedure reverse_standard_bom(
8922 revised_item in eng_revised_items.revised_item_sequence_id%type,
8923 userid in number, -- user id
8924 reqstid in number, -- concurrent request id
8925 appid in number, -- application id
8926 progid in number, -- program id
8927 loginid in number, -- login id
8928 bill_sequence_id in eng_revised_items.bill_sequence_id%type,
8929 routing_sequence_id in eng_revised_items.routing_sequence_id%type,
8930 return_message OUT NOCOPY VARCHAR2,
8931 return_status in OUT NOCOPY NUMBER
8932
8933 )
8934 IS
8935 i NUMBER := 0;
8936 p_bill_sequence_id number := bill_sequence_id;
8937 p_routing_sequence_id number := routing_sequence_id;
8938 p_revised_item_sequence_id number := revised_item;
8939 l_return_status VARCHAR2(1);
8940 -- l_mesg_token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
8941 l_comn_return_status VARCHAR2(1);
8942 l_comn_Mesg_Token_Tbl Error_Handler.Mesg_Token_Tbl_Type;
8943 begin
8944
8945
8946
8947 return_status := 0;
8948 return_message:= NULL;
8949
8950 -- Reverse standard bom is called from ENCACN.opp,
8951 -- If bill sequence id is null, p_bill_sequence_id = -1
8952 IF p_bill_sequence_id <> -1 THEN
8953 -- Delete the related bom_reference_designators records
8954 -- those records are still expected to show on the window after implementation
8955 --
8956 /* DELETE FROM bom_reference_designators
8957 WHERE component_sequence_id IN
8958 ( SELECT component_sequence_id
8959 FROM bom_inventory_components
8960 WHERE
8961 --fixed for bug 1870813
8962 revised_item_sequence_id = p_revised_item_sequence_id
8963 ) ;
8964 */
8965 -- Delete the related bom_substitute_components
8966 /* DELETE FROM bom_substitute_components
8967 WHERE component_sequence_id IN
8968 ( SELECT component_sequence_id
8969 FROM bom_inventory_components
8970 -- fixed for bug 1870813
8971 WHERE revised_item_sequence_id = p_revised_item_sequence_id
8972 ) ;
8973 */
8974 -- before delete the related bom_inventory_components records,
8975 -- make the old conponents active again.
8976 FOR i in 1..rev_comp_disable_date_tbl.count
8977 LOOP
8978
8979 UPDATE bom_components_b--bom_inventory_components
8980 SET
8981 disable_date = rev_comp_disable_date_tbl(i).disable_date,
8982 last_update_date = sysdate,
8983 last_updated_by = userid,
8984 last_update_login = loginid,
8985 request_id = reqstid,
8986 program_application_id = appid,
8987 program_id = progid,
8988 program_update_date = sysdate
8989 WHERE component_sequence_id = rev_comp_disable_date_tbl(i).component_seq_id;
8990 END LOOP;
8991 -----------------------------------------------------------
8992 -- R12: Changes for Common BOM Enhancement
8993 -- Step 2.1: Reset Common Component Details that had been updated
8994 -- when implementing the revised item
8995 -----------------------------------------------------------
8996 IF isCommonedBom = 'Y'
8997 THEN
8998 -- For moved pending destination components
8999 Reset_Common_Comp_Details(
9000 x_Mesg_Token_Tbl => l_comn_Mesg_Token_Tbl
9001 , x_return_status => l_comn_return_status);
9002 -- For copied pending destination components
9003 DELETE FROM bom_components_b
9004 WHERE implementation_date IS NULL -- as pending changes were copied to the new component
9005 AND (bill_sequence_id, old_component_sequence_id) IN
9006 (SELECT bsb.bill_sequence_id, rbcb.component_sequence_id
9007 FROM bom_components_b rbcb, bom_structures_b bsb
9008 WHERE bsb.bill_sequence_id <> p_bill_sequence_id
9009 AND bsb.source_bill_sequence_id = p_bill_sequence_id
9010 AND rbcb.bill_sequence_id = bsb.bill_sequence_id
9011 AND rbcb.revised_item_sequence_id = p_revised_item_sequence_id);
9012 END IF;
9013 -----------------------------------------------------------
9014 -- R12: End Step 2.1: Changes for Common BOM Enhancement --
9015 -----------------------------------------------------------
9016 -- Delete the related bom_inventory_components whose
9017 -- eco_for_production = 1.
9018 DELETE FROM bom_components_b--bom_inventory_components
9019 WHERE revised_item_sequence_id = p_revised_item_sequence_id ;
9020
9021 -- Delete the related eng revised _components whose
9022 -- eco_for_production = 1.
9023 /* DELETE FROM eng_revised_components
9024 WHERE bill_sequence_id = p_bill_sequence_id
9025 AND eco_for_production = 1;
9026 */
9027
9028 END IF;
9029
9030 IF p_bill_sequence_id <> -1 THEN
9031 -- Delete all the substitute resources assigned to the operations
9032 -- whose eco_for_production = 1.
9033 /* DELETE FROM bom_sub_operation_resources
9034 WHERE operation_sequence_id IN
9035 ( SELECT operation_sequence_id
9036 FROM bom_operation_sequences
9037 WHERE revised_item_sequence_id = p_revised_item_sequence_id
9038 );
9039 */
9040 -- Delete all the resources assigned to the operations whose
9041 -- eco_for_production = 1.
9042 /*
9043 DELETE FROM bom_operation_resources
9044 WHERE operation_sequence_id IN
9045 ( SELECT operation_sequence_id
9046 FROM bom_operation_sequences
9047 WHERE revised_item_sequence_id = p_revised_item_sequence_id
9048 );
9049 */
9050 -- before delete the related operation sequence records,
9051 -- make the old operation active again
9052
9053 FOR i in 1..rev_op_disable_date_tbl.count
9054 LOOP
9055 UPDATE bom_operation_sequences
9056 SET
9057 disable_date = rev_op_disable_date_tbl(i).disable_date,
9058 last_update_date = sysdate,
9059 last_updated_by = userid,
9060 last_update_login = loginid,
9061 request_id = reqstid,
9062 program_application_id = appid,
9063 program_id = progid,
9064 program_update_date = sysdate
9065 WHERE operation_sequence_id = rev_op_disable_date_tbl(i).operation_seq_id;
9066 END LOOP;
9067
9068 -- Delete the related operation sequence records
9069 DELETE FROM bom_operation_sequences
9070 WHERE revised_item_sequence_id = p_revised_item_sequence_id;
9071
9072 -- Delete the related revised operation sequence records
9073 /* DELETE FROM eng_revised_operations
9074 WHERE routing_sequence_id = p_routing_sequence_id
9075 AND eco_for_production = 1;
9076 */
9077 END IF;
9078
9079
9080 --Delete the related routing revision record
9081 -- DELETE FROM mtl_rtg_item_revisions
9082 -- WHERE inventory_item_id = p_revised_item
9083 -- AND organization_id = p_organization_id
9084 -- AND process_revision = p_new_routing_revision;
9085
9086
9087 Exception
9088 When others then
9089 return_status := 1;
9090 return_message := substrb(sqlerrm, 1, 80);
9091 end;
9092
9093 -- Generate new wip job names
9094 PROCEDURE Generate_New_Wip_Name
9095 (
9096 p_wip_entity_name IN VARCHAR2
9097 ,p_organization_id IN NUMBER
9098 ,x_wip_entity_name1 OUT NOCOPY VARCHAR2
9099 ,x_wip_entity_name2 OUT NOCOPY VARCHAR2
9100 ,x_return_status OUT NOCOPY NUMBER
9101 )
9102 IS
9103 l_wip_entity_name VARCHAR2(240);
9104 l_dummy VARCHAR2(1);
9105 i NUMBER :=0;
9106 l_count NUMBER := 0;
9107
9108 CURSOR wip_job_name_cur
9109 ( l_wip_entity_name IN VARCHAR2,
9110 l_organization_id IN NUMBER
9111 )
9112 IS
9113 SELECT '1'
9114 FROM DUAL
9115 WHERE NOT EXISTS
9116 (SELECT 1
9117 FROM WIP_ENTITIES
9118 WHERE organization_id = l_organization_id
9119 AND wip_entity_name = l_wip_entity_name)
9120 ;
9121
9122 wip_job_name_rec wip_job_name_cur%rowtype;
9123
9124 BEGIN
9125
9126 WHILE l_count <> 2
9127 LOOP
9128 i := i + 1;
9129 l_wip_entity_name := p_wip_entity_name ||'_' || to_char(i);
9130 l_dummy := 0;
9131 OPEN wip_job_name_cur
9132 ( l_wip_entity_name,
9133 p_organization_id
9134 );
9135
9136 FETCH wip_job_name_cur INTO l_dummy;
9137 IF wip_job_name_cur%FOUND
9138 THEN
9139 l_count := l_count + 1;
9140 IF l_count = 1
9141 THEN x_wip_entity_name1 := l_wip_entity_name ;
9142 ELSIF l_count = 2
9143 THEN x_wip_entity_name2 := l_wip_entity_name ;
9144 END IF;
9145 END IF;
9146
9147 CLOSE wip_job_name_cur;
9148 END LOOP;
9149
9150 x_return_status := 0;
9151
9152 END generate_new_wip_name;
9153
9154 Procedure implement_revised_item(
9155 revised_item in eng_revised_items.revised_item_sequence_id%type,
9156 trial_mode in number,
9157 max_messages in number, -- size of host arrays
9158 userid in number, -- user id
9159 reqstid in number, -- concurrent request id
9160 appid in number, -- application id
9161 progid in number, -- program id
9162 loginid in number, -- login id
9163 bill_sequence_id OUT NOCOPY eng_revised_items.bill_sequence_id%type ,
9164 routing_sequence_id OUT NOCOPY eng_revised_items.routing_sequence_id%type ,
9165 eco_for_production OUT NOCOPY eng_revised_items.eco_for_production%type ,
9166 revision_high_date OUT NOCOPY mtl_item_revisions.effectivity_date%type,
9167 rtg_revision_high_date OUT NOCOPY mtl_rtg_item_revisions.effectivity_date%type,
9168 update_wip OUT NOCOPY eng_revised_items.update_wip%type ,
9169 group_id1 OUT NOCOPY wip_job_schedule_interface.group_id%type,
9170 group_id2 OUT NOCOPY wip_job_schedule_interface.group_id%type,
9171 wip_job_name1 OUT NOCOPY wip_entities.wip_entity_name%type,
9172 wip_job_name2 OUT NOCOPY wip_entities.wip_entity_name%type,
9173 wip_job_name2_org_id OUT NOCOPY wip_entities.organization_id%type,
9174 message_names OUT NOCOPY NameArray,
9175 token1 OUT NOCOPY NameArray,
9176 value1 OUT NOCOPY StringArray,
9177 translate1 OUT NOCOPY BooleanArray,
9178 token2 OUT NOCOPY NameArray,
9179 value2 OUT NOCOPY StringArray,
9180 translate2 OUT NOCOPY BooleanArray,
9181 msg_qty in OUT NOCOPY binary_integer,
9182 warnings in OUT NOCOPY number) is
9183
9184 l_is_revised_item_change NUMBER;
9185 l_now DATE;
9186 l_status_code NUMBER := 6;
9187 l_plm_or_erp_change VARCHAR2(3);
9188 l_return_status VARCHAR2(2000);
9189 l_msg_data VARCHAR2(2000);
9190 l_change_type_id NUMBER;
9191 l_change_id NUMBER;
9192 l_approval_status NUMBER;
9193 l_msg_count NUMBER := 0;
9194 l_message_name VARCHAR2(50);
9195 l_message_desc VARCHAR2(100);
9196 /*
9197 Cursor to fetch all the sub revised items diven the revised item sequence id
9198 In ERP, only one revised item exists.
9199 In PLM, sub revised items may exist given a parent revised item sequence id
9200 */
9201
9202 CURSOR c_revised_items_all is
9203 SELECT *
9204 FROM eng_revised_items
9205 WHERE (revised_item_sequence_id = revised_item
9206 /*OR parent_revised_item_seq_id = revised_item*/)
9207 AND status_type <> 5; -- to remove cancelled revised items
9208
9209 l_plsql_block VARCHAR2(2000);
9210 l_implementation_status VARCHAR2(30);
9211
9212 abort_implementation exception;
9213
9214 BEGIN
9215 l_now := sysdate;
9216
9217 -- Get the change id
9218 SELECT change_id
9219 INTO l_change_id
9220 FROM eng_revised_items
9221 WHERE revised_item_sequence_id = revised_item;
9222
9223 -- Get whether it is a plm or erp change
9224 SELECT nvl(plm_or_erp_change, 'PLM')
9225 INTO l_plm_or_erp_change
9226 FROM eng_engineering_changes
9227 WHERE change_id = l_change_id;
9228
9229 -- Bug : 3446554 Determine the status code for PLM records
9230 IF(l_plm_or_erp_change = 'PLM')
9231 THEN
9232 -- In the PLM change lifecycle - 11.5.10 - the last phase will be implemented
9233 -- there will be only one implemented phase
9234 -- and scheduled phase is always followed by implemented
9235 -- All scheduled revised items will be picked for implementation on auto-implement
9236
9237 SELECT els1.status_code
9238 INTO l_status_code
9239 FROM eng_lifecycle_statuses els1
9240 WHERE els1.entity_id1 = l_change_id
9241 AND els1.entity_name = 'ENG_CHANGE'
9242 AND els1.active_flag = 'Y' -- added for bug 3553682
9243 AND els1.sequence_number = (SELECT max(els2.sequence_number)
9244 FROM eng_lifecycle_statuses els2
9245 WHERE els2.entity_id1 = l_change_id
9246 AND els2.entity_name = 'ENG_CHANGE'
9247 AND els2.active_flag = 'Y'); -- added for bug 3553682
9248
9249 END IF;
9250
9251 FOR ri IN c_revised_items_all
9252 LOOP
9253 -- Check if change policy allows change order / revised item to be implemented
9254 Can_Implement_Item( p_change_line_id => ri.revised_item_sequence_id,
9255 x_implementation_status => l_implementation_status);
9256
9257 IF l_implementation_status = 'NO' THEN
9258 Raise abort_implementation;
9259 END IF;
9260
9261
9262 IF (ri.transfer_or_copy IS NULL)
9263 THEN
9264 l_is_revised_item_change := 1;
9265 ELSE
9266 l_is_revised_item_change := 2;
9267 END IF;
9268
9269 --
9270 -- For PLM
9271 -- Check if the revised item is the parent
9272 -- then it has lifecycle phase change associalted with it
9273 --
9274 IF (ri.parent_revised_item_seq_id IS NULL
9275 AND ri.transfer_or_copy IS NOT NULL
9276 AND ri.enable_item_in_local_org IS NOT NULL)
9277 THEN
9278 l_is_revised_item_change := 1;
9279 END IF;
9280
9281 select approval_status_type into l_approval_status
9282 from eng_engineering_changes
9283 where change_id = l_change_id;
9284
9285 -- First trying to implement the revised item attachment changes
9286 -- Changes For bug 3402607
9287 BEGIN
9288 l_return_status := FND_API.G_RET_STS_SUCCESS;
9289 /*ENG_ATTACHMENT_IMPLEMENTATION.Implement_Attachment_Change(
9290 p_api_version => 1.0
9291 ,p_change_id => l_change_id
9292 ,p_rev_item_seq_id =>revised_item
9293 ,x_return_status => l_return_status
9294 ,x_msg_count => l_msg_count
9295 ,x_msg_data => l_msg_data
9296 ,P_APPROVAL_STATUS => l_approval_status);*/
9297 l_plsql_block := 'begin ENG_ATTACHMENT_IMPLEMENTATION.Implement_Attachment_Change('
9298 || ' p_api_version => 1.0 '
9299 || ' , p_change_id => :1 '
9300 || ' , p_rev_item_seq_id => :2 '
9301 || ' , x_return_status => :3 '
9302 || ' , x_msg_count => :4 '
9303 || ' , x_msg_data => :5 '
9304 || ' , p_approval_status => :6); '
9305 || ' end;';
9306 EXECUTE IMMEDIATE l_plsql_block USING IN l_change_id, IN revised_item, OUT l_return_status
9307 , OUT l_msg_count, OUT l_msg_data, IN l_approval_status;
9308
9309 IF l_return_status = 'E' THEN
9310 l_message_name := 'ENG_ATTACHMENT_IMP_ERROR';
9311 l_message_desc := 'Attachment Changes implementation failed';
9312 FND_FILE.PUT_LINE(FND_FILE.LOG, l_msg_data);
9313 END IF;
9314
9315 EXCEPTION
9316 WHEN OTHERS THEN
9317 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Attachment Changes Implementation Failed'||SQLERRM);
9318 l_message_name := 'ENG_ATTACHMENT_IMP_ERROR';
9319 l_message_desc := 'Attachment Changes implementation failed';
9320 goto error_block;
9321 END;
9322
9323 -- Also implement item related document here. Both attachment changes and item related document
9324 -- changes do not have any date effectivity, that is why it is added here..only when attachment impl is successfull
9325 BEGIN
9326 IF (NVL(l_return_status, FND_API.G_RET_STS_ERROR) = FND_API.G_RET_STS_SUCCESS)
9327 THEN
9328 l_return_status := FND_API.G_RET_STS_SUCCESS;
9329
9330 l_plsql_block := 'begin ENG_RELATED_ENTITY_PKG.Implement_Relationship_Changes('
9331 || ' p_api_version => 1.0 '
9332 || ' , p_change_id => :1 '
9333 || ' , p_entity_id => :2 '
9334 || ' , x_return_status => :3 '
9335 || ' , x_msg_count => :4 '
9336 || ' , x_msg_data => :5); '
9337 || ' end;';
9338 EXECUTE IMMEDIATE l_plsql_block
9339 USING IN l_change_id, IN revised_item,
9340 OUT l_return_status, OUT l_msg_count, OUT l_msg_data;
9341
9342 IF l_return_status = 'E' THEN
9343 l_message_name := 'ENG_RELATED_ENTITY_IMP_ERROR';
9344 l_message_desc := 'Related Entity Changes implementation failed';
9345 FND_FILE.PUT_LINE(FND_FILE.LOG, l_msg_data);
9346 END IF;
9347 END IF;
9348 EXCEPTION
9349 -- Don't throw an exception when package not found.
9350 WHEN PLSQL_COMPILE_ERROR THEN
9351 null;
9352 WHEN OTHERS THEN
9353 FND_FILE.PUT_LINE(FND_FILE.LOG, 'Related Entity Changes Implementation Failed'||SQLERRM);
9354 l_message_name := 'ENG_RELATED_ENTITY_IMP_ERROR';
9355 l_message_desc := 'Related Entity Changes implementation failed';
9356 goto error_block;
9357 END;
9358
9359 << error_block >>
9360 null;
9361
9362 BEGIN
9363 IF (NVL(l_return_status, FND_API.G_RET_STS_ERROR) <> FND_API.G_RET_STS_SUCCESS)
9364 THEN
9365 msg_qty := msg_qty + 1;
9366 token1(msg_qty) := null;
9367 value1(msg_qty) := null;
9368 translate1(msg_qty) := 0;
9369 token2(msg_qty) := null;
9370 value2(msg_qty) := null;
9371 translate2(msg_qty) := 0;
9372 message_names(msg_qty) := l_message_name;
9373 FOR I IN 1..l_msg_count
9374 LOOP
9375 FND_FILE.NEW_LINE(FND_FILE.LOG);
9376 FND_FILE.PUT_LINE(FND_FILE.LOG, l_message_desc);
9377 FND_FILE.PUT_LINE(FND_FILE.LOG, FND_MSG_PUB.get(I, 'F'));
9378
9379 END LOOP;
9380 ELSE
9381
9382 implement_revised_item(
9383 revised_item => ri.revised_item_sequence_id
9384 , trial_mode => trial_mode
9385 , max_messages => max_messages
9386 , userid => userid
9387 , reqstid => reqstid
9388 , appid => appid
9389 , progid => progid
9390 , loginid => loginid
9391 , bill_sequence_id => bill_sequence_id
9392 , routing_sequence_id => routing_sequence_id
9393 , eco_for_production => eco_for_production
9394 , revision_high_date => revision_high_date
9395 , rtg_revision_high_date => rtg_revision_high_date
9396 , update_wip => update_wip
9397 , group_id1 => group_id1
9398 , group_id2 => group_id2
9399 , wip_job_name1 => wip_job_name1
9400 , wip_job_name2 => wip_job_name2
9401 , wip_job_name2_org_id => wip_job_name2_org_id
9402 , message_names => message_names
9403 , token1 => token1
9404 , value1 => value1
9405 , translate1 => translate1
9406 , token2 => token2
9407 , value2 => value2
9408 , translate2 => translate2
9409 , msg_qty => msg_qty
9410 , warnings => warnings
9411 , p_is_lifecycle_phase_change => l_is_revised_item_change
9412 , p_now => l_now
9413 , p_status_code => l_status_code) ;
9414
9415 END IF;
9416 IF (msg_qty > warnings)
9417 THEN
9418 exit;
9419 END IF;
9420 END;
9421 END LOOP;
9422
9423 END implement_revised_item;
9424
9425 --Bug No: 4767315 starts procedure to implement ecos wo any unimplemented revised items
9426 --(deviating from basebug by putting procedure in pls file for easier maintenance. )
9427 Procedure implement_eco_wo_revised_item(
9428 p_change_notice in varchar2,
9429 temp_organization_id in varchar2)
9430 is
9431 l_implement_header varchar2(1);
9432
9433 -- cursor for finding the ecos which can be implemented as all revised items are implemented
9434 -- or to return values corresponding to the eco that is being manually implemented.
9435
9436 CURSOR C_IMPL_CUR IS
9437 select change_notice,change_id,organization_id,
9438 nvl(plm_or_erp_change, 'PLM') l_plm_or_erp_change,
9439 status_code curr_status_code
9440 from eng_engineering_changes e
9441 where to_char(e.organization_id) = temp_organization_id
9442 AND ((p_change_notice IS NULL and e.STATUS_TYPE = 4 ) -- scheduled
9443 OR (p_change_notice IS NOT NULL AND E.CHANGE_NOTICE = p_change_notice))
9444 AND e.APPROVAL_STATUS_TYPE <> 4 --eco rejected
9445 and e.status_type not in (5,6)
9446 and not exists (select 1 from eng_revised_items r
9447 where r.change_notice = e.change_notice
9448 and r.organization_id = e.organization_id
9449 and r.status_type not in (5,6))
9450 and exists (select 1 from eng_revised_items r1
9451 where r1.change_notice = e.change_notice
9452 and r1.organization_id = e.organization_id
9453 and r1.status_type = 6);
9454
9455 IMPL C_IMPL_CUR%rowtype;
9456
9457 BEGIN
9458 savepoint implement_eco_wo_revised_item;
9459 -- Check if implementation of header is allowed or not for the current phase
9460 OPEN C_IMPL_CUR;
9461 loop
9462 FETCH C_IMPL_CUR INTO IMPL;
9463 EXIT WHEN C_IMPL_CUR%NOTFOUND;
9464 l_implement_header:='T';
9465 l_implement_header := check_header_impl_allowed(
9466 p_change_id => IMPL.change_id,
9467 p_change_notice => IMPL.change_notice,
9468 p_status_code => 6,
9469 p_curr_status_code => IMPL.curr_status_code,
9470 p_plm_or_erp_change => IMPL.l_plm_or_erp_change,
9471 p_request_id => fnd_global.conc_request_id);
9472
9473 -- If Header can be implemented, then go ahead.
9474
9475 IF (l_implement_header = 'T')
9476 THEN
9477 -- update eco to status implemented
9478 UPDATE
9479 ENG_ENGINEERING_CHANGES
9480 SET STATUS_TYPE = 6,
9481 STATUS_CODE=6,
9482 IMPLEMENTATION_DATE = SYSDATE,
9483 LAST_UPDATE_DATE = SYSDATE,
9484 LAST_UPDATED_BY = fnd_global.user_id,
9485 LAST_UPDATE_LOGIN = fnd_global.login_id,
9486 REQUEST_ID = fnd_global.conc_request_id,
9487 PROGRAM_APPLICATION_ID = fnd_global.prog_appl_id,
9488 PROGRAM_ID = fnd_global.conc_program_id,
9489 PROGRAM_UPDATE_DATE = SYSDATE,
9490 promote_status_code = null
9491 WHERE CHANGE_NOTICE = IMPL.change_notice
9492 AND ORGANIZATION_ID = IMPL.organization_id;
9493
9494 -- Complete the last phase in the lifecycle
9495
9496 UPDATE
9497 eng_lifecycle_statuses
9498 SET start_date = nvl(start_date,sysdate), -- set the start date on implemented phase after promoting the header to implemented phase
9499 completion_date = sysdate,
9500 last_update_date = sysdate,
9501 last_updated_by = fnd_global.user_id,
9502 last_update_login = fnd_global.login_id
9503 WHERE entity_name = 'ENG_CHANGE'
9504 AND entity_id1 =
9505 (
9506 SELECT
9507 change_id
9508 FROM eng_engineering_changes
9509 WHERE organization_id = IMPL.organization_id
9510 AND change_notice = IMPL.change_notice
9511 )
9512 AND active_flag = 'Y'
9513 AND sequence_number =
9514 (
9515 SELECT
9516 max(sequence_number)
9517 FROM eng_lifecycle_statuses
9518 WHERE entity_name = 'ENG_CHANGE'
9519 AND entity_id1 =
9520 (
9521 SELECT
9522 change_id
9523 FROM eng_engineering_changes
9524 WHERE organization_id = IMPL.organization_id
9525 AND change_notice = IMPL.change_notice
9526 ) );
9527
9528 END IF;
9529 end loop;
9530 close C_IMPL_CUR;
9531 EXCEPTION
9532 WHEN OTHERS THEN
9533 IF C_IMPL_CUR%ISOPEN THEN
9534 CLOSE C_IMPL_CUR;
9535 END IF;
9536 rollback to savepoint implement_eco_wo_revised_item;
9537 END implement_eco_wo_revised_item;
9538
9539 --Bug No: 4767315 fix ends
9540
9541 /*
9542 * Added for bug 11895331. This Procedure updates request_id column, to avoid multiple concurrent
9543 * requests running on the same revised item, which causes the data corruption.
9544 * Autonomous Transaction is required to commit the changes only for this revised item.
9545 *
9546 * @param p_revised_item_sequence_id Revised Item Sequence ID.
9547 * @param x_return_status Return Status to check Success or Exception.
9548 * @param p_autonomous_commit Autonomous Commit flag
9549 */
9550 PROCEDURE Update_BSB_Request_Id_Column ( p_revised_item_sequence_id IN NUMBER,
9551 x_return_status OUT NOCOPY NUMBER,
9552 p_autonomous_commit IN VARCHAR2
9553 ) IS
9554 PRAGMA AUTONOMOUS_TRANSACTION;
9555 P_COMMONBOM_IS_RUNNING CONSTANT NUMBER := -666;
9556 P_ECOIMPL_IS_RUNNING CONSTANT NUMBER := -333;
9557 l_bill_sequence_id NUMBER := 0;
9558 common_bom_is_running EXCEPTION;
9559
9560 BEGIN
9561 FND_FILE.PUT_LINE( FND_FILE.LOG, '********* Update_BSB_Request_Id_Column procedure Start *********') ;
9562 IF FND_API.To_Boolean(p_autonomous_commit) THEN
9563 SELECT B.BILL_SEQUENCE_ID INTO l_bill_sequence_id
9564 FROM BOM_BILL_OF_MATERIALS B ,ENG_REVISED_ITEMS R
9565 WHERE R.REVISED_ITEM_SEQUENCE_ID = p_revised_item_sequence_id
9566 AND R.REVISED_ITEM_ID = B.ASSEMBLY_ITEM_ID
9567 AND R.ORGANIZATION_ID = B.ORGANIZATION_ID
9568 AND NVL(R.ALTERNATE_BOM_DESIGNATOR,' ') = NVL(B.ALTERNATE_BOM_DESIGNATOR,' ')
9569 AND B.BILL_SEQUENCE_ID (+) = R.BILL_SEQUENCE_ID;
9570
9571 FND_FILE.PUT_LINE( FND_FILE.LOG, 'Revised Item Sequence Id: ' || p_revised_item_sequence_id);
9572 FND_FILE.PUT_LINE( FND_FILE.LOG, 'Bill Sequence Id of the Revised Item: ' || l_bill_sequence_id);
9573 FND_FILE.PUT_LINE( FND_FILE.LOG, 'System Date: ' || sysdate);
9574
9575 update BOM_BILL_OF_MATERIALS bbm
9576 set bbm.REQUEST_ID = P_ECOIMPL_IS_RUNNING
9577 WHERE nvl(bbm.REQUEST_ID, 0) <> P_COMMONBOM_IS_RUNNING
9578 AND bbm.BILL_SEQUENCE_ID = l_bill_sequence_id;
9579 if(SQL%ROWCOUNT = 0 )
9580 then
9581 raise common_bom_is_running;
9582 else
9583 COMMIT; -- Commiting the autonomous transaction in case of successfull lock on the row.
9584 FND_FILE.PUT_LINE( FND_FILE.LOG, 'Successfully Stamped with '||P_ECOIMPL_IS_RUNNING||' on bom row');
9585 end if;
9586 END IF;
9587 x_return_status := 0; -- Success
9588 FND_FILE.PUT_LINE( FND_FILE.LOG, '********* Update_BSB_Request_Id_Column procedure End *********');
9589
9590 EXCEPTION
9591 WHEN common_bom_is_running THEN
9592 FND_FILE.PUT_LINE( FND_FILE.LOG, 'ERROR while Implementing Revised Item Sequence Id: ' || p_revised_item_sequence_id );
9593 FND_MESSAGE.SET_NAME('ENG','ENG_COMMONBOM_INPROGRESS');
9594 FND_FILE.PUT_LINE(FND_FILE.LOG, FND_MESSAGE.GET) ;
9595 x_return_status := 1; -- Error
9596 FND_FILE.PUT_LINE( FND_FILE.LOG, '********* Update_BSB_Request_Id_Column procedure End *********');
9597 ROLLBACK; -- Rolling back the autonomous transacation in case of exception.
9598 WHEN OTHERS THEN
9599 FND_FILE.PUT_LINE( FND_FILE.LOG, 'Not stamping with '||P_ECOIMPL_IS_RUNNING||' as Exception occurred in Update_BSB_Request_Id_Column procedure') ;
9600 FND_FILE.PUT_LINE( FND_FILE.LOG, 'Others '||SQLCODE || ':'||SQLERRM) ;
9601 x_return_status := 0;
9602 -- Deliberately setting it to success(0) in case of unknown exception because,when we cannot acquire a lock, we don't want the ECO process to end here itself,
9603 --and want it proceed and provide its own error logging
9604 FND_FILE.PUT_LINE( FND_FILE.LOG, '********* Update_BSB_Request_Id_Column procedure End *********');
9605 ROLLBACK; -- Rolling back the autonomous transaction in case of exception.
9606
9607 END Update_BSB_Request_Id_Column;
9608
9609 end ENGPKIMP;