[Home] [Help]
PACKAGE BODY: APPS.EAM_ACTIVITY_PUB
Source
1 PACKAGE BODY EAM_Activity_PUB AS
2 /* $Header: EAMPACTB.pls 120.2 2006/09/12 14:12:28 amourya noship $ */
3
4 G_PKG_NAME CONSTANT VARCHAR2(30):='EAM_AssetActivity_PUB';
5
6
7 -- ======================================================================
8 -- Private Helper Functions
9
10 PROCEDURE Validate_Copy_Activity_Options(
11 p_bom_copy_option IN NUMBER,
12 p_routing_copy_option IN NUMBER,
13 p_association_copy_option IN NUMBER
14 )
15 IS
16 BEGIN
17
18 IF p_bom_copy_option NOT IN (1, 2) THEN
19 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACTCOPY_BOM_COPY_OPT');
20 -- FND_MESSAGE.SET_ENCODED('BOM Copy Option should be 1 (NONE) or 2 (ALL).');
21 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
22 RAISE FND_API.G_EXC_ERROR;
23 END IF;
24
25 IF p_routing_copy_option NOT IN (1, 2) THEN
26 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACTCOPY_RTG_COPY_OPT');
27 -- FND_MESSAGE.SET_ENCODED('Routing Copy Option should be 1 (NONE) or 2 (ALL).');
28 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
29 RAISE FND_API.G_EXC_ERROR;
30 END IF;
31
32 IF p_bom_copy_option NOT IN (1, 2) THEN
33 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACTCOPY_ASC_COPY_OPT');
34 -- FND_MESSAGE.SET_ENCODED('Association Copy Option should be 1 (NONE) or 2 (ALL).');
35 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
36 RAISE FND_API.G_EXC_ERROR;
37 END IF;
38
39 END;
40
41 PROCEDURE Validate_Copy_Options(
42 p_work_order_rec IN EAM_Activity_PUB.Work_Order_Rec_Type,
43 p_operation_copy_option IN NUMBER,
44 p_material_copy_option IN NUMBER,
45 p_resource_copy_option IN NUMBER,
46 p_association_copy_option IN NUMBER
47 )
48 IS
49 l_activity_id_from_wo NUMBER;
50 BEGIN
51 -- Validate p_operation_copy_option, p_material_copy_option, and p_resource_copy_option
52 IF p_operation_copy_option = 1 THEN
53 -- p_operation_copy_option = 1 (NONE)
54 -- p_material_copy_option and p_resource_copy_option both as to be 1 (NONE)
55 IF p_material_copy_option <> 1 THEN
56 -- Error: Material Copy Option has to be 1 (NONE) when Operation Copy Option is 1 (NONE).
57 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_MAT_COPY_OPT_NOT_NONE');
58 -- FND_MESSAGE.SET_ENCODED('Material Copy Option has to be 1 (NONE) when Operation Copy Option is 1 (NONE).');
59 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
60 RAISE FND_API.G_EXC_ERROR;
61 END IF;
62 IF p_resource_copy_option <> 1 THEN
63 -- Error: Resource Copy Option has to be 1 (NONE) when Operation Copy Option is 1 (NONE).
64 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_RES_COPY_OPT_NOT_NONE');
65 -- FND_MESSAGE.SET_ENCODED('Resource Copy Option has to be 1 (NONE) when Operation Copy Option is 1 (NONE).');
66 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
67 RAISE FND_API.G_EXC_ERROR;
68 END IF;
69 ELSIF p_operation_copy_option = 2 THEN
70 -- p_operation_copy_option = 2 (ALL)
71 -- p_material_copy_option and p_resource_copy_option can be 1 (NONE), 2 (ISSUED), or 3 (ALL)
72
73 IF p_material_copy_option NOT IN (1, 2, 3) THEN
74 -- Error: Material Copy Option should be either 1 (NONE), 2 (ISSUED), or 3 (ALL).
75 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_MAT_COPY_OPT_INVALID');
76 -- FND_MESSAGE.SET_ENCODED('Material Copy Option should be either 1 (NONE), 2 (ISSUED), or 3 (ALL).');
77 RAISE FND_API.G_EXC_ERROR;
78 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
79 END IF;
80 IF p_resource_copy_option NOT IN (1, 2, 3) THEN
81 -- Error: Resource Copy Option should be either 1 (NONE), 2 (ISSUED), or 3 (ALL).
82 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_RES_COPY_OPT_INVALID');
83 -- FND_MESSAGE.SET_ENCODED('Resource Copy Option should be either 1 (NONE), 2 (ISSUED), or 3 (ALL).');
84 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
85 RAISE FND_API.G_EXC_ERROR;
86 END IF;
87 ELSE
88 -- Error: Operation Copy Option should be either 1 (NONE), or 2 (ALL).
89 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_OP_COPY_OPT_INVALID');
90 -- FND_MESSAGE.SET_ENCODED('Operation Copy Option should be either 1 (NONE), or 2 (ALL).');
91 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
92 RAISE FND_API.G_EXC_ERROR;
93 END IF;
94
95 -- Validation of p_association_copy_option is independent of the others.
96
97 -- First need to find out if source Work Order as an Activity linked to it.
98
99
100 -- 2003-01-10: Enchancement: if source Work Order has no Activity, treat Copy Option All as Current
101 -- So don't have to check for source Work Order Activity any more.
102
103 /*
104 l_activity_id_from_wo := EAM_ActivityUtilities_PVT.Get_Act_Id_From_Work_Order(p_work_order_rec.wip_entity_id);
105 IF l_activity_id_from_wo IS NULL THEN
106 -- No Activity linked to source Work Order
107 IF p_association_copy_option NOT IN (1, 2) THEN
108 -- Error: When Source Work Order is not linked to an Activity, Association Copy Option should be either 1 (NONE), or 2 (CURRENT).
109 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ASSO_COPY_OPT_NO_ACT');
110 -- FND_MESSAGE.SET_ENCODED('When Source Work Order is not linked to an Activity, Association Copy Option should be either 1 (NONE), or 2 (CURRENT).');
111 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
112 RAISE FND_API.G_EXC_ERROR;
113 END IF;
114 ELSE
115 -- l_activity_id_from_wo IS NOT NULL
116 */
117 IF p_association_copy_option NOT IN (1, 2, 3) THEN
118 -- Error: Association Copy Option should be either 1 (NONE), 2 (CURRENT), or 3 (ALL).
119 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ASSO_COPY_OPT_INVALID');
120 -- FND_MESSAGE.SET_ENCODED('Association Copy Option should be either 1 (NONE), 2 (CURRENT), or 3 (ALL).');
121 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
122 RAISE FND_API.G_EXC_ERROR;
123 END IF;
124 /*
125 END IF;
126 */
127 END;
128
129 -- ----------------------------------------------------------------------
130 PROCEDURE Create_Activity_Routing(
131 p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
132 p_work_order_rec IN EAM_Activity_PUB.Work_Order_Rec_Type,
133 p_operation_copy_option IN NUMBER,
134 p_resource_copy_option IN NUMBER,
135
136 x_rtg_header_rec OUT NOCOPY BOM_Rtg_Pub.Rtg_Header_Rec_Type,
137 x_rtg_revision_tbl OUT NOCOPY BOM_Rtg_Pub.Rtg_Revision_Tbl_Type,
138 x_operation_tbl OUT NOCOPY BOM_Rtg_Pub.Operation_Tbl_Type,
139 x_op_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Resource_Tbl_Type,
140 x_sub_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Sub_Resource_Tbl_Type,
141 x_op_network_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Network_Tbl_Type,
142 x_rtg_return_status OUT NOCOPY VARCHAR2,
143 x_rtg_msg_count OUT NOCOPY NUMBER,
144 x_rtg_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type
145 )
146
147 IS
148 l_current_date CONSTANT DATE := sysdate;
149 l_effectivity_date CONSTANT DATE := l_current_date;
150 l_create_txn_type CONSTANT VARCHAR(10) := 'CREATE';
151
152 -- misc local var
153 l_x_pos NUMBER;
154 l_y_pos NUMBER;
155
156 -- local variables for call the Routing Business Object API
157 l_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
158 l_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
159 l_operation_tbl_index BINARY_INTEGER;
160 l_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
161 l_op_resource_tbl_index BINARY_INTEGER;
162 l_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
163 l_op_network_tbl_index BINARY_INTEGER;
164
165 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
166 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
167 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
168 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
169 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
170 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
171 l_x_rtg_return_status VARCHAR2(1);
172 l_x_rtg_msg_count NUMBER;
173 l_x_rtg_msg_list Error_Handler.Error_Tbl_Type;
174
175 CURSOR wip_operation_cur (
176 p_organization_id IN NUMBER
177 , p_wip_entity_id IN NUMBER
178 )
179 IS
180 SELECT *
181 FROM wip_operations
182 WHERE wip_entity_id = p_wip_entity_id
183 AND organization_id = p_organization_id;
184
185 CURSOR wip_op_network_cur (
186 p_organization_id IN NUMBER
187 , p_wip_entity_id IN NUMBER
188 )
189 IS
190 SELECT *
191 FROM wip_operation_networks
192 WHERE organization_id = p_organization_id
193 AND wip_entity_id = p_wip_entity_id;
194
195 CURSOR wip_resource_cur (
196 p_organization_id IN NUMBER
197 , p_wip_entity_id IN NUMBER
198 )
199 IS
200 SELECT *
201 FROM wip_operation_resources
202 WHERE organization_id = p_organization_id
203 AND wip_entity_id = p_wip_entity_id;
204
205 BEGIN
206 EAM_ActivityUtilities_PVT.Write_Debug('---------- Entering EAM_Activity_PUB.Create_Activity_Routing ----------');
207 EAM_ActivityUtilities_PVT.Write_Debug('p_operation_copy_option=' || p_operation_copy_option);
208 EAM_ActivityUtilities_PVT.Write_Debug('p_resource_copy_option=' || p_resource_copy_option);
209 EAM_ActivityUtilities_PVT.Write_Debug('p_target_item_rec.organization_id=' || p_target_item_rec.organization_id);
210 EAM_ActivityUtilities_PVT.Write_Debug('p_target_item_rec.organization_code=' || p_target_item_rec.organization_code);
211 EAM_ActivityUtilities_PVT.Write_Debug('p_target_item_rec.inventory_item_id=' || p_target_item_rec.inventory_item_id);
212 EAM_ActivityUtilities_PVT.Write_Debug('p_target_item_rec.item_number=' || p_target_item_rec.item_number);
213 EAM_ActivityUtilities_PVT.Write_Debug('p_work_order_rec.organization_id=' || p_work_order_rec.organization_id);
214 EAM_ActivityUtilities_PVT.Write_Debug('p_work_order_rec.organization_code=' || p_work_order_rec.organization_code);
215 EAM_ActivityUtilities_PVT.Write_Debug('p_work_order_rec.wip_entity_id=' || p_work_order_rec.wip_entity_id);
216 EAM_ActivityUtilities_PVT.Write_Debug('p_work_order_rec.wip_entity_name=' || p_work_order_rec.wip_entity_name);
217
218
219 -- Create Operations
220 -- We need 1 Routing Header, table of Operations and Operation Networks, and table of Resources
221 IF p_operation_copy_option = 2 THEN
222 -- p_operation_copy_option = 2 (ALL)
223
224 -- 2 a) Set up rtg_header_rec
225 -- First initialize record fields to NULL
226 -- l_rtg_header_rec := NULL;
227 -- populate fields
228 l_rtg_header_rec.Assembly_Item_Name := p_target_item_rec.Item_Number;
229 l_rtg_header_rec.Organization_Code := p_target_item_rec.Organization_Code;
230 l_rtg_header_rec.Transaction_Type := l_create_txn_type;
231
232 -- 2 b) Create operations
233 l_operation_tbl_index := 1;
234 FOR l_wip_operation_row IN wip_operation_cur(p_work_order_rec.organization_id,
235 p_work_order_rec.wip_entity_id)
236 LOOP
237 -- First initialize the fields of the record to NULL
238 -- l_operation_tbl(l_operation_tbl_index) := NULL;
239 -- Then populate fields from cursor.
240 l_operation_tbl(l_operation_tbl_index).Transaction_Type := l_create_txn_type;
241 l_operation_tbl(l_operation_tbl_index).Organization_Code := l_rtg_header_rec.Organization_Code;
242 l_operation_tbl(l_operation_tbl_index).Assembly_Item_Name := l_rtg_header_rec.Assembly_Item_Name;
243 l_operation_tbl(l_operation_tbl_index).Operation_Sequence_Number := l_wip_operation_row.Operation_Seq_Num;
244 l_operation_tbl(l_operation_tbl_index).Start_Effective_Date := l_effectivity_date;
245 l_operation_tbl(l_operation_tbl_index).Department_Code :=
246 EAM_ActivityUtilities_PVT.Get_Department_Code(l_wip_operation_row.Organization_Id,
247 l_wip_operation_row.department_id);
248 l_operation_tbl(l_operation_tbl_index).Operation_Description := l_wip_operation_row.Description;
249 l_operation_tbl(l_operation_tbl_index).Count_Point_Type := l_wip_operation_row.count_point_type;
250 l_operation_tbl(l_operation_tbl_index).Backflush_Flag := l_wip_operation_row.Backflush_Flag;
251 l_operation_tbl(l_operation_tbl_index).Minimum_Transfer_Quantity := l_wip_operation_row.Minimum_Transfer_Quantity;
252 l_operation_tbl(l_operation_tbl_index).Shutdown_Type := l_wip_operation_row.Shutdown_Type;
253 l_operation_tbl(l_operation_tbl_index).Yield := l_wip_operation_row.Operation_Yield;
254 l_operation_tbl(l_operation_tbl_index).Op_Yield_Enabled_Flag := l_wip_operation_row.Operation_Yield_Enabled;
255
256 l_operation_tbl(l_operation_tbl_index).Attribute_Category := l_wip_operation_row.Attribute_Category;
257 l_operation_tbl(l_operation_tbl_index).Attribute1 := l_wip_operation_row.Attribute1;
258 l_operation_tbl(l_operation_tbl_index).Attribute2 := l_wip_operation_row.Attribute2;
259 l_operation_tbl(l_operation_tbl_index).Attribute3 := l_wip_operation_row.Attribute3;
260 l_operation_tbl(l_operation_tbl_index).Attribute4 := l_wip_operation_row.Attribute4;
261 l_operation_tbl(l_operation_tbl_index).Attribute5 := l_wip_operation_row.Attribute5;
262 l_operation_tbl(l_operation_tbl_index).Attribute6 := l_wip_operation_row.Attribute6;
263 l_operation_tbl(l_operation_tbl_index).Attribute7 := l_wip_operation_row.Attribute7;
264 l_operation_tbl(l_operation_tbl_index).Attribute8 := l_wip_operation_row.Attribute8;
265 l_operation_tbl(l_operation_tbl_index).Attribute9 := l_wip_operation_row.Attribute9;
266 l_operation_tbl(l_operation_tbl_index).Attribute10 := l_wip_operation_row.Attribute10;
267 l_operation_tbl(l_operation_tbl_index).Attribute11 := l_wip_operation_row.Attribute11;
268 l_operation_tbl(l_operation_tbl_index).Attribute12 := l_wip_operation_row.Attribute12;
269 l_operation_tbl(l_operation_tbl_index).Attribute13 := l_wip_operation_row.Attribute13;
270 l_operation_tbl(l_operation_tbl_index).Attribute14 := l_wip_operation_row.Attribute14;
271 l_operation_tbl(l_operation_tbl_index).Attribute15 := l_wip_operation_row.Attribute15;
272
273 l_operation_tbl_index := l_operation_tbl_index + 1;
274 END LOOP;
275
276 -- 2 c) Create Operation Networks
277 l_op_network_tbl_index := 1;
278 FOR l_wip_op_network_row IN wip_op_network_cur(p_work_order_rec.organization_id,
279 p_work_order_rec.wip_entity_id)
280 LOOP
281 -- l_op_network_tbl(l_op_network_tbl_index) := NULL;
282 l_op_network_tbl(l_op_network_tbl_index).Transaction_Type := l_create_txn_type;
283 l_op_network_tbl(l_op_network_tbl_index).Organization_Code := l_rtg_header_rec.Organization_Code;
284 l_op_network_tbl(l_op_network_tbl_index).Assembly_Item_Name := l_rtg_header_rec.Assembly_Item_Name;
285 l_op_network_tbl(l_op_network_tbl_index).From_Op_Seq_Number := l_wip_op_network_row.Prior_Operation;
286 l_op_network_tbl(l_op_network_tbl_index).From_Start_Effective_Date := l_effectivity_date;
287 l_op_network_tbl(l_op_network_tbl_index).To_Op_Seq_Number := l_wip_op_network_row.Next_Operation;
288 l_op_network_tbl(l_op_network_tbl_index).To_Start_Effective_Date := l_effectivity_date;
289
290 EAM_ActivityUtilities_PVT.Get_Op_Coordinates(
291 p_organization_id => p_work_order_rec.organization_id,
292 p_wip_entity_id => p_work_order_rec.wip_entity_id,
293 p_operation_seq_num => l_wip_op_network_row.Prior_Operation,
294 x_x_pos => l_x_pos,
295 x_y_pos => l_y_pos
296 );
297 l_op_network_tbl(l_op_network_tbl_index).From_X_Coordinate := l_x_pos;
298 l_op_network_tbl(l_op_network_tbl_index).From_Y_Coordinate := l_y_pos;
299
300 EAM_ActivityUtilities_PVT.Get_Op_Coordinates(
301 p_organization_id => p_work_order_rec.organization_id,
302 p_wip_entity_id => p_work_order_rec.wip_entity_id,
303 p_operation_seq_num => l_wip_op_network_row.Next_Operation,
304 x_x_pos => l_x_pos,
305 x_y_pos => l_y_pos
306 );
307 l_op_network_tbl(l_op_network_tbl_index).To_X_Coordinate := l_x_pos;
308 l_op_network_tbl(l_op_network_tbl_index).To_Y_Coordinate := l_y_pos;
309
310 l_op_network_tbl(l_op_network_tbl_index).Attribute_Category := l_wip_op_network_row.Attribute_Category;
311 l_op_network_tbl(l_op_network_tbl_index).Attribute1 := l_wip_op_network_row.Attribute1;
312 l_op_network_tbl(l_op_network_tbl_index).Attribute2 := l_wip_op_network_row.Attribute2;
313 l_op_network_tbl(l_op_network_tbl_index).Attribute3 := l_wip_op_network_row.Attribute3;
314 l_op_network_tbl(l_op_network_tbl_index).Attribute4 := l_wip_op_network_row.Attribute4;
315 l_op_network_tbl(l_op_network_tbl_index).Attribute5 := l_wip_op_network_row.Attribute5;
316 l_op_network_tbl(l_op_network_tbl_index).Attribute6 := l_wip_op_network_row.Attribute6;
317 l_op_network_tbl(l_op_network_tbl_index).Attribute7 := l_wip_op_network_row.Attribute7;
318 l_op_network_tbl(l_op_network_tbl_index).Attribute8 := l_wip_op_network_row.Attribute8;
319 l_op_network_tbl(l_op_network_tbl_index).Attribute9 := l_wip_op_network_row.Attribute9;
320 l_op_network_tbl(l_op_network_tbl_index).Attribute10 := l_wip_op_network_row.Attribute10;
321 l_op_network_tbl(l_op_network_tbl_index).Attribute11 := l_wip_op_network_row.Attribute11;
322 l_op_network_tbl(l_op_network_tbl_index).Attribute12 := l_wip_op_network_row.Attribute12;
323 l_op_network_tbl(l_op_network_tbl_index).Attribute13 := l_wip_op_network_row.Attribute13;
324 l_op_network_tbl(l_op_network_tbl_index).Attribute14 := l_wip_op_network_row.Attribute14;
325 l_op_network_tbl(l_op_network_tbl_index).Attribute15 := l_wip_op_network_row.Attribute15;
326
327 l_op_network_tbl_index := l_op_network_tbl_index + 1;
328 END LOOP;
329
330
331 END IF; -- p_operation_option = 2
332
333 -- 2 d) Create Resources
334 IF p_resource_copy_option = 1 THEN
335 -- p_resource_copy_option = 1 (NONE), do nothing
336 NULL;
337 ELSIF p_resource_copy_option in (2, 3) THEN
338 -- p_resource_copy_option = 2 (ISSUED), or 3 (ALL)
339 l_op_resource_tbl_index := 1;
340 FOR l_wip_resource_row IN wip_resource_cur(p_work_order_rec.organization_id,
341 p_work_order_rec.wip_entity_id)
342 LOOP
343 -- First initialize the fields of the record to be NULL
344 -- l_op_resource_tbl(l_op_resource_tbl_index) := NULL;
345 -- Then populate fields from cursor.
346 l_op_resource_tbl(l_op_resource_tbl_index).Transaction_Type := l_create_txn_type;
347 l_op_resource_tbl(l_op_resource_tbl_index).Organization_Code := l_rtg_header_rec.Organization_Code;
348 l_op_resource_tbl(l_op_resource_tbl_index).Assembly_Item_Name := l_rtg_header_rec.Assembly_Item_Name;
349 l_op_resource_tbl(l_op_resource_tbl_index).Operation_Sequence_Number := l_wip_resource_row.Operation_Seq_Num;
350 l_op_resource_tbl(l_op_resource_tbl_index).Resource_Code :=
351 EAM_ActivityUtilities_PVT.Get_Resource_Code(l_wip_resource_row.Organization_Id,
352 l_wip_resource_row.Resource_Id);
353 l_op_resource_tbl(l_op_resource_tbl_index).Op_Start_Effective_Date := l_effectivity_date;
354 l_op_resource_tbl(l_op_resource_tbl_index).Resource_Sequence_Number := l_wip_resource_row.Resource_Seq_Num;
355
356 IF p_resource_copy_option = 2 THEN
357 -- p_resource_copy_option = 2 (ISSUED)
358 l_op_resource_tbl(l_op_resource_tbl_index).Usage_Rate_Or_Amount :=
359 l_wip_resource_row.Applied_Resource_Units;
360 ELSE
361 -- p_resource_copy_option = 3 (ALL)
362 l_op_resource_tbl(l_op_resource_tbl_index).Usage_Rate_Or_Amount :=
363 EAM_ActivityUtilities_PVT.Get_WO_Res_Scheduled_Units(
364 l_wip_resource_row.Organization_Id,
365 l_wip_resource_row.Wip_Entity_Id,
366 l_wip_resource_row.Operation_Seq_Num,
367 l_wip_resource_row.Resource_Seq_Num);
368 END IF;
369
370 l_op_resource_tbl(l_op_resource_tbl_index).Activity :=
371 EAM_ActivityUtilities_PVT.Get_Cost_Activity(l_wip_resource_row.Activity_Id);
372 l_op_resource_tbl(l_op_resource_tbl_index).Schedule_Flag := l_wip_resource_row.Scheduled_Flag;
373 l_op_resource_tbl(l_op_resource_tbl_index).Assigned_Units := l_wip_resource_row.Assigned_Units;
374 l_op_resource_tbl(l_op_resource_tbl_index).Autocharge_Type := l_wip_resource_row.Autocharge_Type;
375 l_op_resource_tbl(l_op_resource_tbl_index).Standard_Rate_Flag := l_wip_resource_row.Standard_Rate_Flag;
376 l_op_resource_tbl(l_op_resource_tbl_index).Principle_Flag := l_wip_resource_row.Principle_Flag;
377
378 l_op_resource_tbl(l_op_resource_tbl_index).Attribute_Category := l_wip_resource_row.Attribute_Category;
379 l_op_resource_tbl(l_op_resource_tbl_index).Attribute1 := l_wip_resource_row.Attribute1;
380 l_op_resource_tbl(l_op_resource_tbl_index).Attribute2 := l_wip_resource_row.Attribute2;
381 l_op_resource_tbl(l_op_resource_tbl_index).Attribute3 := l_wip_resource_row.Attribute3;
382 l_op_resource_tbl(l_op_resource_tbl_index).Attribute4 := l_wip_resource_row.Attribute4;
383 l_op_resource_tbl(l_op_resource_tbl_index).Attribute5 := l_wip_resource_row.Attribute5;
384 l_op_resource_tbl(l_op_resource_tbl_index).Attribute6 := l_wip_resource_row.Attribute6;
385 l_op_resource_tbl(l_op_resource_tbl_index).Attribute7 := l_wip_resource_row.Attribute7;
386 l_op_resource_tbl(l_op_resource_tbl_index).Attribute8 := l_wip_resource_row.Attribute8;
387 l_op_resource_tbl(l_op_resource_tbl_index).Attribute9 := l_wip_resource_row.Attribute9;
388 l_op_resource_tbl(l_op_resource_tbl_index).Attribute10 := l_wip_resource_row.Attribute10;
389 l_op_resource_tbl(l_op_resource_tbl_index).Attribute11 := l_wip_resource_row.Attribute11;
390 l_op_resource_tbl(l_op_resource_tbl_index).Attribute12 := l_wip_resource_row.Attribute12;
391 l_op_resource_tbl(l_op_resource_tbl_index).Attribute13 := l_wip_resource_row.Attribute13;
392 l_op_resource_tbl(l_op_resource_tbl_index).Attribute14 := l_wip_resource_row.Attribute14;
393 l_op_resource_tbl(l_op_resource_tbl_index).Attribute15 := l_wip_resource_row.Attribute15;
394
395 l_op_resource_tbl_index := l_op_resource_tbl_index + 1;
396 END LOOP;
397
398 ELSE
399 -- since we performed validation on p_resource_copy_option already, shouldn't reach here.
400 NULL;
401 END IF;
402
403 -- 2 e) Call the Routing Business Object API
404 -- Only Call Routing Business Object API if operation tabel is not empty
405 IF l_operation_tbl.FIRST IS NOT NULL THEN
406 Error_Handler.initialize;
407 -- log call to Process_Rtg API
408 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> BOM_RTG_PUB.Process_Rtg INPUT Parameters >>>>>>>>>>>>>>>');
409 EAM_ActivityUtilities_PVT.Log_Process_Rtg_Parameters(l_rtg_header_rec,
410 l_operation_tbl,
411 l_op_resource_tbl,
412 l_op_network_tbl);
413
414 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_RTG_PUB.Process_Rtg **********');
415 BOM_RTG_PUB.Process_Rtg(
416 p_rtg_header_rec => l_rtg_header_rec
417 , p_operation_tbl => l_operation_tbl
418 , p_op_resource_tbl => l_op_resource_tbl
419 , p_op_network_tbl => l_op_network_tbl
420 , x_rtg_header_rec => l_x_rtg_header_rec
421 , x_rtg_revision_tbl => l_x_rtg_revision_tbl
422 , x_operation_tbl => l_x_operation_tbl
423 , x_op_resource_tbl => l_x_op_resource_tbl
424 , x_sub_resource_tbl => l_x_sub_resource_tbl
425 , x_op_network_tbl => l_x_op_network_tbl
426 , x_return_status => l_x_rtg_return_status
427 , x_msg_count => l_x_rtg_msg_count
428 );
429 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_RTG_PUB.Process_Rtg **********');
430
431 Error_Handler.Get_Message_List(l_x_rtg_msg_list);
432
433 -- log errors
434 EAM_ActivityUtilities_PVT.Write_Debug('l_x_rtg_return_status=' || l_x_rtg_return_status);
435 EAM_ActivityUtilities_PVT.Write_Debug('l_x_rtg_msg_count=' || l_x_rtg_msg_count);
436 Error_Handler.Get_Message_List(l_x_rtg_msg_list);
437 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_RTG_PUB.Process_Rtg >>>>>');
438 EAM_ActivityUtilities_PVT.Log_Bom_Error_Tbl(l_x_rtg_msg_list);
439 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_RTG_PUB.Process_Rtg <<<<<');
440 EAM_ActivityUtilities_PVT.Write_Debug('<<<<<<<<<<<<<<< BOM_RTG_PUB.Process_Rtg OUTPUT Parameters <<<<<<<<<<<<<<<');
441 EAM_ActivityUtilities_PVT.Log_Process_Rtg_Parameters(l_x_rtg_header_rec,
442 l_x_operation_tbl,
443 l_x_op_resource_tbl,
444 l_x_op_network_tbl);
445
446 -- Assign outputs.
447 x_rtg_header_rec := l_x_rtg_header_rec;
448 x_rtg_revision_tbl := l_x_rtg_revision_tbl;
449 x_operation_tbl := l_x_operation_tbl;
450 x_op_resource_tbl := l_x_op_resource_tbl;
451 x_sub_resource_tbl := l_x_sub_resource_tbl;
452 x_op_network_tbl := l_x_op_network_tbl;
453 x_rtg_return_status := l_x_rtg_return_status;
454 x_rtg_msg_count := l_x_rtg_msg_count;
455 x_rtg_msg_list := l_x_rtg_msg_list;
456
457 END IF;
458
459 EAM_ActivityUtilities_PVT.Write_Debug('---------- Exiting EAM_Activity_PUB.Create_Activity_Routing ----------');
460 END;
461
462 -- ----------------------------------------------------------------------
463 PROCEDURE Create_Activity_BOM(
464 p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
465 p_work_order_rec IN EAM_Activity_PUB.Work_Order_Rec_Type,
466 p_material_copy_option IN NUMBER,
467
468 x_bom_header_rec OUT NOCOPY BOM_BO_PUB.BOM_Head_Rec_Type,
469 x_bom_revision_tbl OUT NOCOPY BOM_BO_PUB.BOM_Revision_Tbl_Type,
470 x_bom_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Comps_Tbl_Type,
471 x_bom_ref_designator_tbl OUT NOCOPY BOM_BO_PUB.BOM_Ref_Designator_Tbl_Type,
472 x_bom_sub_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Sub_Component_Tbl_Type,
473 x_bom_return_status OUT NOCOPY VARCHAR2,
474 x_bom_msg_count OUT NOCOPY NUMBER,
475 x_bom_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type
476 )
477 IS
478 l_current_date CONSTANT DATE := sysdate;
479 l_effectivity_date CONSTANT DATE := l_current_date;
480 l_create_txn_type CONSTANT VARCHAR(10) := 'CREATE';
481 -- local variabels for calling BOM Business Object API
482 l_bom_head_rec BOM_BO_PUB.Bom_Head_Rec_Type;
483 l_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
484 l_bom_comp_tbl_index BINARY_INTEGER;
485
486 l_x_bom_header_rec BOM_BO_PUB.Bom_Head_Rec_Type;
487 l_x_bom_revision_tbl BOM_BO_PUB.Bom_Revision_Tbl_Type;
488 l_x_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
489 l_x_bom_ref_designator_tbl BOM_BO_PUB.Bom_Ref_Designator_Tbl_Type;
490 l_x_bom_sub_component_tbl BOM_BO_PUB.Bom_Sub_Component_Tbl_Type;
491 l_x_bom_return_status VARCHAR2(1);
492 l_x_bom_msg_count NUMBER;
493 l_x_bom_msg_list Error_Handler.Error_Tbl_Type;
494 l_stock_enabled_flag varchar2(1);
495 l_list_price_per_unit number;
496 CURSOR wip_requirement_cur (
497 p_organization_id IN NUMBER,
498 p_wip_entity_id IN NUMBER
499 )
500 IS
501 SELECT *
502 FROM wip_requirement_operations
503 WHERE wip_entity_id = p_wip_entity_id
504 AND organization_id = p_organization_id;
505
506 BEGIN
507 IF p_material_copy_option = 1 THEN
508 -- p_material_copy_option = 1 (NONE), do nothing
509 NULL;
510 ELSIF p_material_copy_option IN (2, 3) THEN
511 -- We need 1 BOM Header (Assembly_Item_Rec_Type) and a table of Components ( Rev_Component_Rec_Type)
512 -- 2 a) Create BOM Header
513 -- l_bom_head_rec := NULL;
514 l_bom_head_rec.Assembly_Item_Name := p_target_item_rec.Item_Number;
515 l_bom_head_rec.Transaction_Type := l_create_txn_type;
516 l_bom_head_rec.Organization_Code := p_target_item_rec.Organization_Code;
517 l_bom_head_rec.Assembly_Type := 1;
518
519 -- 2 b) Create table of Components
520 l_bom_comp_tbl_index := 1;
521 FOR l_wip_requirement_row IN wip_requirement_cur(p_work_order_rec.organization_id,
522 p_work_order_rec.wip_entity_id)
523 LOOP
524 -- l_bom_component_tbl(l_bom_comp_tbl_index) := NULL;
525 l_bom_component_tbl(l_bom_comp_tbl_index).Transaction_Type := l_create_txn_type;
526 l_bom_component_tbl(l_bom_comp_tbl_index).Organization_Code := l_bom_head_rec.Organization_Code;
527 l_bom_component_tbl(l_bom_comp_tbl_index).Assembly_Item_Name := l_bom_head_rec.Assembly_Item_Name;
528 l_bom_component_tbl(l_bom_comp_tbl_index).Start_Effective_Date := l_effectivity_date;
529 l_bom_component_tbl(l_bom_comp_tbl_index).Operation_Sequence_Number :=
530 l_wip_requirement_row.Operation_Seq_Num;
531 l_bom_component_tbl(l_bom_comp_tbl_index).Component_Item_Name :=
532 EAM_ActivityUtilities_PVT.Get_Item_Concatenated_Segments(l_wip_requirement_row.organization_id,
533 l_wip_requirement_row.inventory_item_id);
534 -- l_bom_component_tbl(l_bom_comp_tbl_index).Item_Sequence_Number :=
535 -- l_wip_requirement_row.Component_Sequence_Id;
536 -- l_bom_component_tbl(l_bom_comp_tbl_index).Item_Sequence_Number := l_bom_comp_tbl_index;
537
538 IF p_material_copy_option = 2 THEN
539 -- p_material_copy_option = 2 (ISSUED)
540 l_bom_component_tbl(l_bom_comp_tbl_index).Quantity_Per_Assembly :=
541 l_wip_requirement_row.Quantity_Issued;
542 ELSE
543 -- p_material_copy_option = 3 (ALL)
544 l_bom_component_tbl(l_bom_comp_tbl_index).Quantity_Per_Assembly :=
545 l_wip_requirement_row.Required_Quantity;
546 END IF;
547
548 l_bom_component_tbl(l_bom_comp_tbl_index).Wip_Supply_Type := l_wip_requirement_row.Wip_Supply_Type;
549 l_bom_component_tbl(l_bom_comp_tbl_index).Supply_Subinventory := l_wip_requirement_row.Supply_Subinventory;
550 l_bom_component_tbl(l_bom_comp_tbl_index).Location_Name :=
551 EAM_ActivityUtilities_PVT.Get_Locator(l_wip_requirement_row.organization_id,
552 l_wip_requirement_row.Supply_Subinventory,
553 l_wip_requirement_row.Supply_Locator_Id);
554 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute_Category := l_wip_requirement_row.Attribute_Category;
555 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute1 := l_wip_requirement_row.Attribute1;
556 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute2 := l_wip_requirement_row.Attribute2;
557 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute3 := l_wip_requirement_row.Attribute3;
558 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute4 := l_wip_requirement_row.Attribute4;
559 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute5 := l_wip_requirement_row.Attribute5;
560 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute6 := l_wip_requirement_row.Attribute6;
561 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute7 := l_wip_requirement_row.Attribute7;
562 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute8 := l_wip_requirement_row.Attribute8;
563 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute9 := l_wip_requirement_row.Attribute9;
564 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute10 := l_wip_requirement_row.Attribute10;
565 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute11 := l_wip_requirement_row.Attribute11;
566 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute12 := l_wip_requirement_row.Attribute12;
567 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute13 := l_wip_requirement_row.Attribute13;
568 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute14 := l_wip_requirement_row.Attribute14;
569 l_bom_component_tbl(l_bom_comp_tbl_index).Attribute15 := l_wip_requirement_row.Attribute15;
570
571 l_bom_component_tbl(l_bom_comp_tbl_index).Comments := l_wip_requirement_row.Comments;
572
573 -- sraval: added for Direct Items 11.5.10
574 select stock_enabled_flag,list_price_per_unit
575 into l_stock_enabled_flag,l_list_price_per_unit
576 from mtl_system_items
577 where inventory_item_id = l_wip_requirement_row.inventory_item_id
578 and organization_id = l_wip_requirement_row.organization_id;
579
580 if l_stock_enabled_flag = 'N' then
581 l_bom_component_tbl(l_bom_comp_tbl_index).suggested_vendor_name := l_wip_requirement_row.suggested_vendor_name;
582 l_bom_component_tbl(l_bom_comp_tbl_index).unit_price := l_wip_requirement_row.unit_price;
583 end if;
584
585 l_bom_comp_tbl_index := l_bom_comp_tbl_index + 1;
586 END LOOP;
587 ELSE
588 -- p_material_copy_option NOT IN (1, 2, 3)
589 -- Since we performed validation on p_material_copy_option in the beginning already, should not happen.
590 NULL;
591 END IF; -- p_material_copy_option
592
593 -- 2 c) Call the BOM Business Object API
594
595 -- Only call BOM Business Object API if Component Table is not empty
596 IF l_bom_component_tbl.FIRST IS NOT NULL THEN
597
598 Error_Handler.initialize;
599 -- log call to Process_BOM API
600 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> BOM_BO_PUB.Process_BOM INPUT Parameters >>>>>>>>>>>>>>>');
601 EAM_ActivityUtilities_PVT.Log_Process_BOM_Parameters(l_bom_head_rec,
602 l_bom_component_tbl);
603
604 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_BO_PUB.Process_BOM **********');
605 BOM_BO_PUB.Process_BOM(
606 p_bom_header_rec => l_bom_head_rec,
607 p_bom_component_tbl => l_bom_component_tbl,
608 x_bom_header_rec => l_x_bom_header_rec,
609 x_bom_revision_tbl => l_x_bom_revision_tbl,
610 x_bom_component_tbl => l_x_bom_component_tbl,
611 x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
612 x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
613 x_return_status => l_x_bom_return_status,
614 x_msg_count => l_x_bom_msg_count
615 );
616 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_BO_PUB.Process_BOM **********');
617
618 Error_Handler.Get_Message_List(l_x_bom_msg_list);
619
620 -- log errors
621 EAM_ActivityUtilities_PVT.Write_Debug('l_x_bom_return_status=' || l_x_bom_return_status);
622 EAM_ActivityUtilities_PVT.Write_Debug('l_x_bom_msg_count=' || l_x_bom_msg_count);
623 Error_Handler.Get_Message_List(l_x_bom_msg_list);
624 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_BO_PUB.Process_BOM >>>>>');
625 EAM_ActivityUtilities_PVT.Log_Bom_Error_Tbl(l_x_bom_msg_list);
626 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_BO_PUB.Process_BOM <<<<<');
627 EAM_ActivityUtilities_PVT.Write_Debug('<<<<<<<<<<<<<<< BOM_BO_PUB.Process_BOM OUTPUT Parameters <<<<<<<<<<<<<<<');
628 EAM_ActivityUtilities_PVT.Log_Process_BOM_Parameters(l_x_bom_header_rec,
629 l_x_bom_component_tbl);
630
631
632 -- Assign outputs.
633 x_bom_header_rec := l_x_bom_header_rec;
634 x_bom_revision_tbl := l_x_bom_revision_tbl;
635 x_bom_component_tbl := l_x_bom_component_tbl;
636 x_bom_ref_designator_tbl := l_x_bom_ref_designator_tbl;
637 x_bom_sub_component_tbl := l_x_bom_sub_component_tbl;
638 x_bom_return_status := l_x_bom_return_status;
639 x_bom_msg_count := l_x_bom_msg_count;
640 x_bom_msg_list := l_x_bom_msg_list;
641
642 END IF;
643
644 END;
645 -- ================================================================================
646 PROCEDURE Get_Errors
647 ( p_item_error_tbl IN INV_Item_GRP.Error_Tbl_Type ,
648 x_error_msg_old IN VARCHAR2,
649 x_error_msg_new OUT NOCOPY VARCHAR2
650 )
651 IS
652 l_index BINARY_INTEGER;
653 l_error_msg VARCHAR2(3000);
654 BEGIN
655 l_error_msg:=x_error_msg_old;
656 l_index:=p_item_error_tbl.FIRST;
657 WHILE l_index IS NOT NULL
658 LOOP
659 l_error_msg:=l_error_msg||p_item_error_tbl(l_index).message_text;
660 l_index:=p_item_error_tbl.NEXT(l_index);
661 END LOOP;
662 x_error_msg_new:=l_error_msg;
663 END;
664 -- ================================================================================
665
666 -- ----------------------------------------------------------------------
667 PROCEDURE Create_Item(
668 p_asset_activity IN INV_Item_GRP.Item_Rec_Type,
669 p_template_id IN NUMBER := NULL,
670 p_template_name IN VARCHAR2 := NULL,
671
672 x_curr_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
673 x_curr_item_return_status OUT NOCOPY VARCHAR2,
674 x_curr_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
675
676 x_master_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
677 x_master_item_return_status OUT NOCOPY VARCHAR2,
678 x_master_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type
679 )
680 IS
681 l_master_organization_id NUMBER;
682 l_curr_organization_id NUMBER;
683 l_item_rec INV_Item_GRP.Item_rec_type;
684 l_validate_org_ret_sts VARCHAR2(1);
685
686 l_temp_org_id NUMBER;
687 l_temp_org_code VARCHAR2(3);
688
689 -- local variables for calling INV_Item_GRP package
690
691 l_x_curr_item_rec INV_Item_GRP.Item_rec_type;
692 l_x_curr_item_return_status VARCHAR2(1);
693 l_x_curr_item_error_tbl INV_Item_GRP.Error_tbl_type;
694
695 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
696 l_x_master_item_return_status VARCHAR2(1);
697 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
698 l_error_string VARCHAR(2000);
699
700 BEGIN
701 -- Step 2: Create Asset Activity. Call INV_Item_GRP package.
702
703 -- Copy input activity record to a working record
704 l_item_rec := p_asset_activity;
705
706 -- Validate org id and org code
707 EAM_ActivityUtilities_PVT.Validate_Organization(
708 p_organization_id => l_item_rec.organization_id,
709 p_organization_code => l_item_rec.organization_code,
710 x_return_status => l_validate_org_ret_sts,
711 x_organization_id => l_temp_org_id,
712 x_organization_code => l_temp_org_code
713 );
714 l_item_rec.organization_id := l_temp_org_id;
715 l_item_rec.organization_code := l_temp_org_code;
716
717 IF l_validate_org_ret_sts <> FND_API.G_RET_STS_SUCCESS THEN
718 RAISE FND_API.G_EXC_ERROR;
719 END IF;
720
721 -- ============================================================
722 EAM_ActivityUtilities_PVT.Write_Debug('-------- Beginning EAM_Activity_PUB.Create_Item --------');
723
724 -- Save current org id
725 l_curr_organization_id := l_item_rec.organization_id;
726 EAM_ActivityUtilities_PVT.Write_Debug('l_curr_organization_id=' || l_curr_organization_id);
727
728 -- 2 a) Get master org id
729 l_master_organization_id := EAM_ActivityUtilities_PVT.Get_Master_Org_Id(l_curr_organization_id);
730 EAM_ActivityUtilities_PVT.Write_Debug('l_master_organization_id=' || l_master_organization_id);
731
732 -- Set attributes of l_item_rec
733 l_item_rec.eam_item_type := 2; -- EAM Asset Activity
734
735 IF l_item_rec.inventory_item_flag IS NULL OR l_item_rec.inventory_item_flag = fnd_api.g_MISS_CHAR
736 THEN
737 l_item_rec.inventory_item_flag := 'Y';
738 END IF;
739
740 IF l_item_rec.expense_account IS NULL OR l_item_rec.expense_account = fnd_api.g_MISS_NUM
741 THEN
742 -- In the Master Item form, Expense Account defaulted from Master Org. So should use Master Org.
743 l_item_rec.expense_account := EAM_ActivityUtilities_PVT.Get_Expense_Account_Id(l_master_organization_id);
744 END IF;
745 -- Check that expense_account is not null
746 IF l_item_rec.expense_account IS NULL OR l_item_rec.expense_account = fnd_api.g_MISS_NUM
747 THEN
748 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_EXPENSE_ACCOUNT_NULL');
749 -- FND_MESSAGE.SET_ENCODED('Please define the Expense Account for the Organization.');
750 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
751 RAISE FND_API.G_EXC_ERROR;
752 END IF;
753
754 IF l_item_rec.bom_enabled_flag IS NULL OR
755 l_item_rec.bom_enabled_flag = fnd_api.g_MISS_CHAR
756 THEN
757 l_item_rec.bom_enabled_flag := 'Y';
758 END IF;
759
760 -- 2 c) If current org is not master org, creat Activity in master org first
761 IF l_curr_organization_id <> l_master_organization_id THEN
762 -- set org to master org
763 l_item_rec.organization_id := l_master_organization_id;
764 l_item_rec.organization_code := NULL;
765
766 EAM_ActivityUtilities_PVT.Write_Debug('Creating MASTER Item...');
767 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> INV_Item_GRP.Create_Item INPUT Parameters >>>>>>>>>>>>>>>');
768 EAM_ActivityUtilities_PVT.Write_Debug('p_template_id=' || p_template_id);
769 EAM_ActivityUtilities_PVT.Write_Debug('p_template_name=' || p_template_name);
770 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_item_rec);
771 INV_Item_GRP.Create_Item(
772 p_Item_rec => l_item_rec,
773 p_Template_Id => p_template_id,
774 p_Template_Name => p_template_name,
775 x_Item_rec => l_x_master_item_rec,
776 x_return_status => l_x_master_item_return_status,
777 x_Error_tbl => l_x_master_item_error_tbl
778 );
779 -- Assign outputs
780 x_master_item_rec := l_x_master_item_rec;
781 x_master_item_return_status := l_x_master_item_return_status;
782 x_master_item_error_tbl := l_x_master_item_error_tbl;
783
784 -- log outputs
785 EAM_ActivityUtilities_PVT.Write_Debug('l_x_master_item_return_status=' || l_x_master_item_return_status);
786 EAM_ActivityUtilities_PVT.Write_Debug('Results of INV_Item_GRP.Create_Item (master item) >>>>>');
787 EAM_ActivityUtilities_PVT.Log_Item_Error_Tbl(l_x_master_item_error_tbl);
788 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of INV_Item_GRP.Create_Item (master item) <<<<<');
789 EAM_ActivityUtilities_PVT.Write_Debug('<<<<<<<<<<<<<<< INV_Item_GRP.Create_Item OUTPUT Parameters <<<<<<<<<<<<<<<');
790 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_x_master_item_rec);
791
792 IF l_x_master_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
793 -- Create Item under master org fail, no use tyring to create it under child org.
794 RETURN;
795 END IF;
796 ELSE
797 -- Current Org is Master Org, no additional Item needs to be created.
798 EAM_ActivityUtilities_PVT.Write_Debug('Current Org is Master Org, no additional Item needs to be created.');
799 x_master_item_rec := l_x_master_item_rec; -- should be NULL
800 x_master_item_return_status := FND_API.G_RET_STS_SUCCESS;
801 x_master_item_error_tbl := l_x_master_item_error_tbl; -- should be NULL
802 END IF;
803
804 -- 2 d) Create Activity in current org
805 -- set org to current org
806 l_item_rec.organization_id := l_curr_organization_id;
807 l_item_rec.organization_code := NULL;
808 /*Bug3269789 - Added below code since master items form uses exp acct of child org
809 when assigning to child org*/
810 /*Bug#3269789 - start*/
811 l_item_rec.expense_account := EAM_ActivityUtilities_PVT.Get_Expense_Account_Id(l_curr_organization_id);
812
813 -- Check that expense_account is not null
814 IF l_item_rec.expense_account IS NULL OR l_item_rec.expense_account = fnd_api.g_MISS_NUM
815 THEN
816 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_EXPENSE_ACCOUNT_NULL');
817 -- FND_MESSAGE.SET_ENCODED('Please define the Expense Account for the Organization.');
818 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
819 RAISE FND_API.G_EXC_ERROR;
820 END IF;
821 /*Bug#3269789 - end*/
822
823 EAM_ActivityUtilities_PVT.Write_Debug('Creating CURRENT Item...');
824 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> INV_Item_GRP.Create_Item INPUT Parameters >>>>>>>>>>>>>>>');
825 EAM_ActivityUtilities_PVT.Write_Debug('p_template_id=' || p_template_id);
826 EAM_ActivityUtilities_PVT.Write_Debug('p_template_name=' || p_template_name);
827 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_item_rec);
828 INV_Item_GRP.Create_Item(
829 p_Item_rec => l_item_rec,
830 p_Template_Id => p_template_id,
831 p_Template_Name => p_template_name,
832 x_Item_rec => l_x_curr_item_rec,
833 x_return_status => l_x_curr_item_return_status,
834 x_Error_tbl => l_x_curr_item_error_tbl
835 );
836 -- Assign outputs
837 x_curr_item_rec := l_x_curr_item_rec;
838 x_curr_item_return_status := l_x_curr_item_return_status;
839 x_curr_item_error_tbl := l_x_curr_item_error_tbl;
840
841 -- log outputs
842 EAM_ActivityUtilities_PVT.Write_Debug('l_x_curr_item_return_status=' || l_x_curr_item_return_status);
843 EAM_ActivityUtilities_PVT.Write_Debug('Results of INV_Item_GRP.Create_Item (current item) >>>>>');
844 EAM_ActivityUtilities_PVT.Log_Item_Error_Tbl(l_x_curr_item_error_tbl);
845 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of INV_Item_GRP.Create_Item (current item) <<<<<');
846 EAM_ActivityUtilities_PVT.Write_Debug('<<<<<<<<<<<<<<< INV_Item_GRP.Create_Item OUTPUT Parameters <<<<<<<<<<<<<<<');
847 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_x_curr_item_rec);
848
849 -- ============================================================
850 EAM_ActivityUtilities_PVT.Write_Debug('-------- Finished EAM_Activity_PUB.Create_Item --------');
851 END;
852
853 -- ======================================================================
854 PROCEDURE Create_Activity
855 ( p_api_version IN NUMBER ,
856 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE ,
857 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
858 p_validation_level IN NUMBER :=
859 FND_API.G_VALID_LEVEL_FULL ,
860 x_return_status OUT NOCOPY VARCHAR2 ,
861 x_msg_count OUT NOCOPY NUMBER ,
862 x_msg_data OUT NOCOPY VARCHAR2 ,
863
864 p_asset_activity IN INV_Item_GRP.Item_Rec_Type,
865 p_template_id IN NUMBER := NULL,
866 p_template_name IN VARCHAR2 := NULL,
867 p_activity_type_code IN VARCHAR2 := NULL,
868 p_activity_cause_code IN VARCHAR2 := NULL,
869 p_shutdown_type_code IN VARCHAR2 := NULL,
870 p_notification_req_flag IN VARCHAR2 := NULL,
871 p_activity_source_code IN VARCHAR2 := NULL,
872 p_work_order_rec IN EAM_Activity_PUB.Work_Order_Rec_Type,
873 p_operation_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
874 p_material_copy_option IN NUMBER := 2, -- 1 (NONE), 2 (ISSUED), OR 3 (ALL)
875 p_resource_copy_option IN NUMBER := 2, -- 1 (NONE), 2 (ISSUED), OR 3 (ALL)
876 p_association_copy_option IN NUMBER := 2, -- 1 (NONE), 2 (CURRENT), OR 3 (ALL)
877
878 -- x_inventory_item_id OUT NUMBER, -- the inventory_item_it the system has created
879 x_work_order_rec OUT NOCOPY EAM_Activity_PUB.Work_Order_Rec_Type,
880
881 x_curr_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
882 x_curr_item_return_status OUT NOCOPY VARCHAR2,
883 x_curr_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
884 x_master_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
885 x_master_item_return_status OUT NOCOPY VARCHAR2,
886 x_master_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
887
888 x_rtg_header_rec OUT NOCOPY BOM_Rtg_Pub.Rtg_Header_Rec_Type,
889 x_rtg_revision_tbl OUT NOCOPY BOM_Rtg_Pub.Rtg_Revision_Tbl_Type,
890 x_operation_tbl OUT NOCOPY BOM_Rtg_Pub.Operation_Tbl_Type,
891 x_op_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Resource_Tbl_Type,
892 x_sub_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Sub_Resource_Tbl_Type,
893 x_op_network_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Network_Tbl_Type,
894 x_rtg_return_status OUT NOCOPY VARCHAR2,
895 x_rtg_msg_count OUT NOCOPY NUMBER,
896 x_rtg_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type,
897
898 x_bom_header_rec OUT NOCOPY BOM_BO_PUB.BOM_Head_Rec_Type,
899 x_bom_revision_tbl OUT NOCOPY BOM_BO_PUB.BOM_Revision_Tbl_Type,
900 x_bom_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Comps_Tbl_Type,
901 x_bom_ref_designator_tbl OUT NOCOPY BOM_BO_PUB.BOM_Ref_Designator_Tbl_Type,
902 x_bom_sub_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Sub_Component_Tbl_Type,
903 x_bom_return_status OUT NOCOPY VARCHAR2,
904 x_bom_msg_count OUT NOCOPY NUMBER,
905 x_bom_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type,
906
907 x_assoc_return_status OUT NOCOPY VARCHAR2,
908 x_assoc_msg_count OUT NOCOPY NUMBER,
909 x_assoc_msg_data OUT NOCOPY VARCHAR2,
910 x_act_num_association_tbl OUT NOCOPY EAM_Activity_PUB.Activity_Association_Tbl_Type,
911 x_activity_association_tbl OUT NOCOPY EAM_Activity_PUB.Activity_Association_Tbl_Type
912 )
913
914 IS
915 l_api_name CONSTANT VARCHAR2(30) := 'Create_Activity';
916 l_api_version CONSTANT NUMBER := 1.0;
917
918 -- local variables for validating source Work Order
919 l_x_work_order_rec EAM_Activity_PUB.Work_Order_Rec_Type;
920 l_x_work_order_ret_sts VARCHAR2(1);
921
922 -- local variables for calling INV_Item_GRP package
923 l_asset_activity INV_Item_GRP.Item_rec_type;
924 l_x_curr_item_rec INV_Item_GRP.Item_rec_type;
925 l_x_curr_item_return_status VARCHAR2(1);
926 l_x_curr_item_error_tbl INV_Item_GRP.Error_tbl_type;
927 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
928 l_x_master_item_return_status VARCHAR2(1);
929 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
930
931 -- local variabels for calling BOM Business Object API
932 l_x_bom_header_rec BOM_BO_PUB.Bom_Head_Rec_Type;
933 l_x_bom_revision_tbl BOM_BO_PUB.Bom_Revision_Tbl_Type;
934 l_x_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
935 l_x_bom_ref_designator_tbl BOM_BO_PUB.Bom_Ref_Designator_Tbl_Type;
936 l_x_bom_sub_component_tbl BOM_BO_PUB.Bom_Sub_Component_Tbl_Type;
937 l_x_bom_return_status VARCHAR2(1);
938 l_x_bom_msg_count NUMBER;
939 l_x_bom_msg_list Error_Handler.Error_Tbl_Type;
940
941 -- local variables for call the Routing Business Object API
942 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
943 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
944 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
945 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
946 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
947 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
948 l_x_rtg_return_status VARCHAR2(1);
949 l_x_rtg_msg_count NUMBER;
950 l_x_rtg_msg_list Error_Handler.Error_Tbl_Type;
951
952 -- local variables for call Association Creation package
953 l_x_assoc_return_status VARCHAR2(1);
954 l_x_assoc_msg_count NUMBER;
955 l_x_assoc_msg_data VARCHAR2(20000);
956 l_x_act_num_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
957 l_x_activity_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
958
959
960 -- ======================================================================
961 BEGIN
962 -- Standard Start of API savepoint
963 SAVEPOINT Create_Activity_PUB;
964 -- Standard call to check for call compatibility.
965 IF NOT FND_API.Compatible_API_Call ( l_api_version ,
966 p_api_version ,
967 l_api_name ,
968 G_PKG_NAME )
969 THEN
970 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
971 END IF;
972 -- Initialize message list if p_init_msg_list is set to TRUE.
973 IF FND_API.to_Boolean( p_init_msg_list ) THEN
974 FND_MSG_PUB.initialize;
975 END IF;
976 -- Initialize API return status to success
977 x_return_status := FND_API.G_RET_STS_SUCCESS;
978 -- API body
979
980 -- ============================================================
981 EAM_ActivityUtilities_PVT.Write_Debug('========== Entering EAM_Activity_PUB.Create_Activity ==========');
982 EAM_ActivityUtilities_PVT.Write_Debug('Organization_Id=' || p_asset_activity.Organization_Id);
983 EAM_ActivityUtilities_PVT.Write_Debug('Organization_Code=' || p_asset_activity.Organization_Code);
984 EAM_ActivityUtilities_PVT.Write_Debug('Inventory_Item_Id=' || p_asset_activity.Inventory_Item_Id);
985 EAM_ActivityUtilities_PVT.Write_Debug('Item Number=' || p_asset_activity.Item_Number);
986 EAM_ActivityUtilities_PVT.Write_Debug('Segment1=' || p_asset_activity.Segment1);
987 EAM_ActivityUtilities_PVT.Write_Debug('Segment2=' || p_asset_activity.Segment2);
988 EAM_ActivityUtilities_PVT.Write_Debug('Segment3=' || p_asset_activity.Segment3);
989 EAM_ActivityUtilities_PVT.Write_Debug('Segment4=' || p_asset_activity.Segment4);
990 EAM_ActivityUtilities_PVT.Write_Debug('Segment5=' || p_asset_activity.Segment5);
991 EAM_ActivityUtilities_PVT.Write_Debug('Segment6=' || p_asset_activity.Segment6);
992 EAM_ActivityUtilities_PVT.Write_Debug('Segment7=' || p_asset_activity.Segment7);
993 EAM_ActivityUtilities_PVT.Write_Debug('Segment8=' || p_asset_activity.Segment8);
994 EAM_ActivityUtilities_PVT.Write_Debug('Segment9=' || p_asset_activity.Segment9);
995 EAM_ActivityUtilities_PVT.Write_Debug('Segment10=' || p_asset_activity.Segment10);
996 EAM_ActivityUtilities_PVT.Write_Debug('Segment11=' || p_asset_activity.Segment11);
997 EAM_ActivityUtilities_PVT.Write_Debug('Segment12=' || p_asset_activity.Segment12);
998 EAM_ActivityUtilities_PVT.Write_Debug('Segment13=' || p_asset_activity.Segment13);
999 EAM_ActivityUtilities_PVT.Write_Debug('Segment14=' || p_asset_activity.Segment14);
1000 EAM_ActivityUtilities_PVT.Write_Debug('Segment15=' || p_asset_activity.Segment15);
1001 EAM_ActivityUtilities_PVT.Write_Debug('Segment16=' || p_asset_activity.Segment16);
1002 EAM_ActivityUtilities_PVT.Write_Debug('Segment17=' || p_asset_activity.Segment17);
1003 EAM_ActivityUtilities_PVT.Write_Debug('Segment18=' || p_asset_activity.Segment18);
1004 EAM_ActivityUtilities_PVT.Write_Debug('Segment19=' || p_asset_activity.Segment19);
1005 EAM_ActivityUtilities_PVT.Write_Debug('Segment20=' || p_asset_activity.Segment20);
1006 EAM_ActivityUtilities_PVT.Write_Debug('Description=' || p_asset_activity.Description);
1007
1008 -- ============================================================
1009 -- Step 1: Validate inputs
1010 -- 1 a) Validate source Work Order
1011 EAM_ActivityUtilities_PVT.Validate_Work_Order(
1012 p_work_order_rec => p_work_order_rec,
1013 x_return_status => l_x_work_order_ret_sts,
1014 x_work_order_rec => l_x_work_order_rec
1015 );
1016 IF l_x_work_order_ret_sts <> FND_API.G_RET_STS_SUCCESS THEN
1017 RAISE FND_API.G_EXC_ERROR;
1018 END IF;
1019 -- Set return parameter
1020 x_work_order_rec := l_x_work_order_rec;
1021
1022 -- 1 b) Validate copy options
1023 Validate_Copy_Options(
1024 l_x_work_order_rec,
1025 p_operation_copy_option,
1026 p_material_copy_option,
1027 p_resource_copy_option,
1028 p_association_copy_option
1029 );
1030
1031 -- ============================================================
1032 -- Step 2: Create Asset Activity. Call INV_Item_GRP package.
1033
1034 l_asset_activity := p_asset_activity;
1035
1036 -- Get org id from work order
1037 l_asset_activity.organization_id := l_x_work_order_rec.organization_id;
1038
1039 l_asset_activity.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1040 l_asset_activity.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1041 l_asset_activity.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1042 l_asset_activity.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1043 l_asset_activity.EAM_ACTIVITY_SOURCE_CODE := p_activity_source_code;
1044
1045 Create_Item(
1046 p_asset_activity => l_asset_activity,
1047 p_template_id => p_template_id,
1048 p_template_name => p_template_name,
1049
1050 x_curr_item_rec => l_x_curr_item_rec,
1051 x_curr_item_return_status => l_x_curr_item_return_status,
1052 x_curr_item_error_tbl => l_x_curr_item_error_tbl,
1053 x_master_item_rec => l_x_master_item_rec,
1054 x_master_item_return_status => l_x_master_item_return_status,
1055 x_master_item_error_tbl => l_x_master_item_error_tbl
1056 );
1057
1058 IF l_x_master_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1059 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_MASTER_FAILED');
1060 -- FND_MESSAGE.SET_ENCODED('Create Activity under Master Organization failed.');
1061 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1062 RAISE FND_API.G_EXC_ERROR;
1063 END IF;
1064
1065 IF l_x_curr_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1066 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_CURRENT_FAILED');
1067 -- FND_MESSAGE.SET_ENCODED('Create Activity under Current Organization failed.');
1068 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1069 RAISE FND_API.G_EXC_ERROR;
1070 END IF;
1071
1072 -- Set the Activity Attributes in the Item Record, don't have to do it manually
1073 /*
1074 -- Overwrite Activity Properties with user-supplied values
1075 l_x_master_item_rec.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1076 l_x_master_item_rec.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1077 l_x_master_item_rec.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1078 l_x_master_item_rec.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1079
1080 BEGIN
1081 UPDATE mtl_system_items
1082 SET EAM_ACTIVITY_TYPE_CODE = p_activity_type_code,
1083 EAM_ACTIVITY_CAUSE_CODE = p_activity_cause_code,
1084 EAM_ACT_SHUTDOWN_STATUS = p_shutdown_type_code,
1085 EAM_ACT_NOTIFICATION_FLAG = p_notification_req_flag,
1086 EAM_ACTIVITY_SOURCE_CODE = p_activity_source_code
1087 WHERE inventory_item_id = l_x_master_item_rec.inventory_item_id
1088 AND organization_id = l_x_master_item_rec.organization_id;
1089 EXCEPTION
1090 WHEN OTHERS THEN
1091 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1092 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACT_PROPERTIES');
1093 FND_MSG_PUB.ADD;
1094 END IF;
1095 RAISE FND_API.G_EXC_ERROR;
1096 END;
1097
1098 l_x_curr_item_rec.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1099 l_x_curr_item_rec.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1100 l_x_curr_item_rec.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1101 l_x_curr_item_rec.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1102
1103 BEGIN
1104 UPDATE mtl_system_items
1105 SET EAM_ACTIVITY_TYPE_CODE = p_activity_type_code,
1106 EAM_ACTIVITY_CAUSE_CODE = p_activity_cause_code,
1107 EAM_ACT_SHUTDOWN_STATUS = p_shutdown_type_code,
1108 EAM_ACT_NOTIFICATION_FLAG = p_notification_req_flag,
1109 EAM_ACTIVITY_SOURCE_CODE = p_activity_source_code
1110 WHERE inventory_item_id = l_x_curr_item_rec.inventory_item_id
1111 AND organization_id = l_x_curr_item_rec.organization_id;
1112 EXCEPTION
1113 WHEN OTHERS THEN
1114 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1115 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACT_PROPERTIES');
1116 FND_MSG_PUB.ADD;
1117 END IF;
1118 RAISE FND_API.G_EXC_ERROR;
1119 END;
1120 */
1121
1122 -- Assign outputs
1123 x_curr_item_rec := l_x_curr_item_rec;
1124 x_curr_item_return_status := l_x_curr_item_return_status;
1125 x_curr_item_error_tbl := l_x_curr_item_error_tbl;
1126 x_master_item_rec := l_x_master_item_rec;
1127 x_master_item_return_status := l_x_master_item_return_status;
1128 x_master_item_error_tbl := l_x_master_item_error_tbl;
1129
1130 -- ============================================================
1131 -- Step 3: Create Operations and Resources
1132 Create_Activity_Routing(
1133 p_target_item_rec => l_x_curr_item_rec
1134 , p_work_order_rec => l_x_work_order_rec
1135 , p_operation_copy_option => p_operation_copy_option
1136 , p_resource_copy_option => p_resource_copy_option
1137
1138 , x_rtg_header_rec => l_x_rtg_header_rec
1139 , x_rtg_revision_tbl => l_x_rtg_revision_tbl
1140 , x_operation_tbl => l_x_operation_tbl
1141 , x_op_resource_tbl => l_x_op_resource_tbl
1142 , x_sub_resource_tbl => l_x_sub_resource_tbl
1143 , x_op_network_tbl => l_x_op_network_tbl
1144 , x_rtg_return_status => l_x_rtg_return_status
1145 , x_rtg_msg_count => l_x_rtg_msg_count
1146 , x_rtg_msg_list => l_x_rtg_msg_list
1147 );
1148 -- Assign outputs.
1149 x_rtg_header_rec := l_x_rtg_header_rec;
1150 x_rtg_revision_tbl := l_x_rtg_revision_tbl;
1151 x_operation_tbl := l_x_operation_tbl;
1152 x_op_resource_tbl := l_x_op_resource_tbl;
1153 x_sub_resource_tbl := l_x_sub_resource_tbl;
1154 x_op_network_tbl := l_x_op_network_tbl;
1155 x_rtg_return_status := l_x_rtg_return_status;
1156 x_rtg_msg_count := l_x_rtg_msg_count;
1157 x_rtg_msg_list := l_x_rtg_msg_list;
1158
1159 -- Handle errors
1160 IF l_x_rtg_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1161 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_RTG_BO_FAILED');
1162 -- FND_MESSAGE.SET_ENCODED('Call to Routing Business Object API Failed.');
1163 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1164 RAISE FND_API.G_EXC_ERROR;
1165 END IF;
1166
1167
1168 -- ============================================================
1169 -- Step 4: Create BOM and attach it to the newly created Activity
1170 Create_Activity_BOM(
1171 p_target_item_rec => l_x_curr_item_rec
1172 , p_work_order_rec => l_x_work_order_rec
1173 , p_material_copy_option => p_material_copy_option,
1174 x_bom_header_rec => l_x_bom_header_rec,
1175 x_bom_revision_tbl => l_x_bom_revision_tbl,
1176 x_bom_component_tbl => l_x_bom_component_tbl,
1177 x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
1178 x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
1179 x_bom_return_status => l_x_bom_return_status,
1180 x_bom_msg_count => l_x_bom_msg_count,
1181 x_bom_msg_list => l_x_bom_msg_list
1182 );
1183 -- Assign outputs.
1184 x_bom_header_rec := l_x_bom_header_rec;
1185 x_bom_revision_tbl := l_x_bom_revision_tbl;
1186 x_bom_component_tbl := l_x_bom_component_tbl;
1187 x_bom_ref_designator_tbl := l_x_bom_ref_designator_tbl;
1188 x_bom_sub_component_tbl := l_x_bom_sub_component_tbl;
1189 x_bom_return_status := l_x_bom_return_status;
1190 x_bom_msg_count := l_x_bom_msg_count;
1191 x_bom_msg_list := l_x_bom_msg_list;
1192
1193 -- Handle errors
1194 IF l_x_bom_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1195 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_BOM_BO_FAILED');
1196 -- FND_MESSAGE.SET_ENCODED('Call to Routing Business Object API Failed.');
1197 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1198 RAISE FND_API.G_EXC_ERROR;
1199 END IF;
1200
1201
1202 -- ============================================================
1203 -- Step 5: Update Association to Asset Numbers for the newly created activity
1204 IF p_association_copy_option <> 1 THEN
1205 -- p_association_copy_option <> 1 (NONE), call private package to create association
1206 EAM_ActivityAssociation_PVT.Create_Association(
1207 p_api_version => 1.0,
1208 x_return_status => l_x_assoc_return_status,
1209 x_msg_count => l_x_assoc_msg_count,
1210 x_msg_data => l_x_assoc_msg_data,
1211
1212 p_target_org_id => l_x_curr_item_rec.organization_id,
1213 p_target_activity_id => l_x_curr_item_rec.inventory_item_id,
1214
1215 p_wip_entity_id => l_x_work_order_rec.wip_entity_id,
1216 p_association_copy_option => p_association_copy_option,
1217
1218 x_act_num_association_tbl => l_x_act_num_association_tbl,
1219 x_activity_association_tbl => l_x_activity_association_tbl
1220 );
1221 -- Assing outputs
1222 x_assoc_return_status := l_x_assoc_return_status;
1223 x_assoc_msg_count := l_x_assoc_msg_count;
1224 x_assoc_msg_data := l_x_assoc_msg_data;
1225 x_act_num_association_tbl := l_x_act_num_association_tbl;
1226 x_activity_association_tbl := l_x_activity_association_tbl;
1227
1228 -- Handle error
1229 IF l_x_assoc_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1230 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ASSOC_FAILED');
1231 -- FND_MESSAGE.SET_ENCODED('Create Activity Associations failed.');
1232 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1233 RAISE FND_API.G_EXC_ERROR;
1234 END IF;
1235
1236 END IF;
1237
1238 -- ======================================================================
1239
1240 -- End of API body.
1241 -- Standard check of p_commit.
1242 IF FND_API.To_Boolean( p_commit ) THEN
1243 COMMIT WORK;
1244 END IF;
1245 -- Standard call to get message count and if count is 1, get message info.
1246 FND_MSG_PUB.Count_And_Get
1247 ( p_count => x_msg_count ,
1248 p_data => x_msg_data
1249 );
1250
1251
1252 EAM_ActivityUtilities_PVT.Write_Debug('========== Exiting EAM_Activity_PUB.Create_Activity ==========');
1253
1254 -- ======================================================================
1255
1256 EXCEPTION
1257 WHEN FND_API.G_EXC_ERROR THEN
1258 ROLLBACK TO Create_Activity_PUB;
1259 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Create_Activity: EXPECTED_ERROR ==========');
1260 x_return_status := FND_API.G_RET_STS_ERROR ;
1261 FND_MSG_PUB.Count_And_Get
1262 ( p_count => x_msg_count ,
1263 p_data => x_msg_data
1264 );
1265 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1266 ROLLBACK TO Create_Activity_PUB;
1267 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Create_Activity: UNEXPECTED_ERROR ==========');
1268 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1269 FND_MSG_PUB.Count_And_Get
1270 ( p_count => x_msg_count ,
1271 p_data => x_msg_data
1272 );
1273 WHEN OTHERS THEN
1274 ROLLBACK TO Create_Activity_PUB;
1275 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1276 IF FND_MSG_PUB.Check_Msg_Level
1277 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1278 THEN
1279 FND_MSG_PUB.Add_Exc_Msg
1280 ( G_PKG_NAME ,
1281 l_api_name
1282 );
1283 -- log error message also
1284 EAM_ActivityUtilities_PVT.Write_Debug(FND_MSG_PUB.Get(FND_MSG_PUB.G_LAST, FND_API.G_FALSE));
1285 END IF;
1286 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Create_Activity: OTHER ERROR ==========');
1287 FND_MSG_PUB.Count_And_Get
1288 ( p_count => x_msg_count ,
1289 p_data => x_msg_data
1290 );
1291 END Create_Activity;
1292
1293 -- ================================================================================
1294
1295 PROCEDURE Copy_Activity
1296 ( p_api_version IN NUMBER ,
1297 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE ,
1298 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
1299 p_validation_level IN NUMBER :=
1300 FND_API.G_VALID_LEVEL_FULL ,
1301 x_return_status OUT NOCOPY VARCHAR2 ,
1302 x_msg_count OUT NOCOPY NUMBER ,
1303 x_msg_data OUT NOCOPY VARCHAR2 ,
1304
1305 -- target activity, need to set org, item name, description
1306 p_asset_activity IN INV_Item_GRP.Item_Rec_Type,
1307
1308
1309 p_template_id IN NUMBER := NULL,
1310 p_template_name IN VARCHAR2 := NULL,
1311 p_activity_type_code IN VARCHAR2 := NULL,
1312 p_activity_cause_code IN VARCHAR2 := NULL,
1313 p_shutdown_type_code IN VARCHAR2 := NULL,
1314 p_notification_req_flag IN VARCHAR2 := NULL,
1315 p_activity_source_code IN VARCHAR2 := NULL,
1316
1317 -- source Activity
1318 p_source_org_id IN NUMBER,
1319 p_source_activity_id IN NUMBER, -- inventory_item_id
1320 -- source BOM
1321 p_source_alt_bom_designator IN VARCHAR2 := NULL,
1322 p_source_bom_rev_date IN DATE := sysdate,
1323 -- source Routing
1324 p_source_alt_rtg_designator IN VARCHAR2 := NULL,
1325 p_source_rtg_rev_date IN DATE := sysdate,
1326
1327 p_bom_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
1328 p_routing_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
1329 p_association_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
1330
1331 x_curr_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
1332 x_curr_item_return_status OUT NOCOPY VARCHAR2,
1333 x_curr_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
1334 x_master_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
1335 x_master_item_return_status OUT NOCOPY VARCHAR2,
1336 x_master_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
1337
1338 x_assoc_return_status OUT NOCOPY VARCHAR2,
1339 x_assoc_msg_count OUT NOCOPY NUMBER,
1340 x_assoc_msg_data OUT NOCOPY VARCHAR2,
1341 x_act_num_association_tbl OUT NOCOPY EAM_Activity_PUB.Activity_Association_Tbl_Type,
1342 x_activity_association_tbl OUT NOCOPY EAM_Activity_PUB.Activity_Association_Tbl_Type
1343 )
1344 IS
1345 l_api_name CONSTANT VARCHAR2(30) := 'Copy_Activity';
1346 l_api_version CONSTANT NUMBER := 1.0;
1347
1348 -- local variables
1349 l_create_txn_type CONSTANT VARCHAR(10) := 'CREATE';
1350
1351 -- local variables for validating source Work Order
1352 l_x_work_order_rec EAM_Activity_PUB.Work_Order_Rec_Type;
1353 l_x_work_order_ret_sts VARCHAR2(1);
1354
1355 -- local variables for calling INV_Item_GRP package
1356 l_asset_activity INV_Item_GRP.Item_rec_type;
1357 l_x_curr_item_rec INV_Item_GRP.Item_rec_type;
1358 l_x_curr_item_return_status VARCHAR2(1);
1359 l_x_curr_item_error_tbl INV_Item_GRP.Error_tbl_type;
1360 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
1361 l_x_master_item_return_status VARCHAR2(1);
1362 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
1363
1364 -- local variables for calling copy_bill API
1365 l_source_bom_sequence_id NUMBER;
1366 l_target_bom_sequence_id NUMBER;
1367 l_copy_bill_error_msg VARCHAR2(20000);
1368
1369 l_bom_head_rec BOM_BO_PUB.Bom_Head_Rec_Type;
1370
1371 l_x_bom_header_rec BOM_BO_PUB.Bom_Head_Rec_Type;
1372 l_x_bom_revision_tbl BOM_BO_PUB.Bom_Revision_Tbl_Type;
1373 l_x_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
1374 l_x_bom_ref_designator_tbl BOM_BO_PUB.Bom_Ref_Designator_Tbl_Type;
1375 l_x_bom_sub_component_tbl BOM_BO_PUB.Bom_Sub_Component_Tbl_Type;
1376 l_x_bom_return_status VARCHAR2(1);
1377 l_x_bom_msg_count NUMBER;
1378 l_x_bom_msg_list Error_Handler.Error_Tbl_Type;
1379
1380 -- local variables for call the Routing Business Object API
1381 l_source_rtg_sequence_id NUMBER;
1382 l_target_rtg_sequence_id NUMBER;
1383
1384 l_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
1385
1386 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
1387 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
1388 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
1389 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
1390 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
1391 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
1392 l_x_rtg_return_status VARCHAR2(1);
1393 l_x_rtg_msg_count NUMBER;
1394 l_x_rtg_msg_list Error_Handler.Error_Tbl_Type;
1395
1396 -- local variables for call Association Creation package
1397 l_x_assoc_return_status VARCHAR2(1);
1398 l_x_assoc_msg_count NUMBER;
1399 l_x_assoc_msg_data VARCHAR2(20000);
1400 l_x_act_num_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
1401 l_x_activity_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
1402
1403 BEGIN
1404 -- Standard Start of API savepoint
1405 SAVEPOINT Copy_Activity_PUB;
1406 -- Standard call to check for call compatibility.
1407 IF NOT FND_API.Compatible_API_Call ( l_api_version ,
1408 p_api_version ,
1409 l_api_name ,
1410 G_PKG_NAME )
1411 THEN
1412 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1413 END IF;
1414 -- Initialize message list if p_init_msg_list is set to TRUE.
1415 IF FND_API.to_Boolean( p_init_msg_list ) THEN
1416 FND_MSG_PUB.initialize;
1417 END IF;
1418 -- Initialize API return status to success
1419 x_return_status := FND_API.G_RET_STS_SUCCESS;
1420 -- API body
1421
1422 -- ============================================================
1423 EAM_ActivityUtilities_PVT.Write_Debug('========== Entering EAM_Activity_PUB.Copy_Activity ==========');
1424 EAM_ActivityUtilities_PVT.Write_Debug('Organization_Id=' || p_asset_activity.Organization_Id);
1425 EAM_ActivityUtilities_PVT.Write_Debug('Organization_Code=' || p_asset_activity.Organization_Code);
1426 EAM_ActivityUtilities_PVT.Write_Debug('Inventory_Item_Id=' || p_asset_activity.Inventory_Item_Id);
1427 EAM_ActivityUtilities_PVT.Write_Debug('Item Number=' || p_asset_activity.Item_Number);
1428 EAM_ActivityUtilities_PVT.Write_Debug('Segment1=' || p_asset_activity.Segment1);
1429 EAM_ActivityUtilities_PVT.Write_Debug('Segment2=' || p_asset_activity.Segment2);
1430 EAM_ActivityUtilities_PVT.Write_Debug('Segment3=' || p_asset_activity.Segment3);
1431 EAM_ActivityUtilities_PVT.Write_Debug('Segment4=' || p_asset_activity.Segment4);
1432 EAM_ActivityUtilities_PVT.Write_Debug('Segment5=' || p_asset_activity.Segment5);
1433 EAM_ActivityUtilities_PVT.Write_Debug('Segment6=' || p_asset_activity.Segment6);
1434 EAM_ActivityUtilities_PVT.Write_Debug('Segment7=' || p_asset_activity.Segment7);
1435 EAM_ActivityUtilities_PVT.Write_Debug('Segment8=' || p_asset_activity.Segment8);
1436 EAM_ActivityUtilities_PVT.Write_Debug('Segment9=' || p_asset_activity.Segment9);
1437 EAM_ActivityUtilities_PVT.Write_Debug('Segment10=' || p_asset_activity.Segment10);
1438 EAM_ActivityUtilities_PVT.Write_Debug('Segment11=' || p_asset_activity.Segment11);
1439 EAM_ActivityUtilities_PVT.Write_Debug('Segment12=' || p_asset_activity.Segment12);
1440 EAM_ActivityUtilities_PVT.Write_Debug('Segment13=' || p_asset_activity.Segment13);
1441 EAM_ActivityUtilities_PVT.Write_Debug('Segment14=' || p_asset_activity.Segment14);
1442 EAM_ActivityUtilities_PVT.Write_Debug('Segment15=' || p_asset_activity.Segment15);
1443 EAM_ActivityUtilities_PVT.Write_Debug('Segment16=' || p_asset_activity.Segment16);
1444 EAM_ActivityUtilities_PVT.Write_Debug('Segment17=' || p_asset_activity.Segment17);
1445 EAM_ActivityUtilities_PVT.Write_Debug('Segment18=' || p_asset_activity.Segment18);
1446 EAM_ActivityUtilities_PVT.Write_Debug('Segment19=' || p_asset_activity.Segment19);
1447 EAM_ActivityUtilities_PVT.Write_Debug('Segment20=' || p_asset_activity.Segment20);
1448 EAM_ActivityUtilities_PVT.Write_Debug('Description=' || p_asset_activity.Description);
1449
1450 -- ============================================================
1451 -- Step 1: Validate inputs
1452 -- 1 a) Validate ???
1453
1454 -- fixthis: any other inputs needed to be validated?
1455
1456 -- 1 b) Validate copy options
1457 Validate_Copy_Activity_Options(
1458 p_bom_copy_option,
1459 p_routing_copy_option,
1460 p_association_copy_option
1461 );
1462
1463 -- ============================================================
1464 -- Step 2: Create Asset Activity. Call INV_Item_GRP package.
1465
1466 l_asset_activity := p_asset_activity;
1467
1468 l_asset_activity.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1469 l_asset_activity.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1470 l_asset_activity.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1471 l_asset_activity.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1472 l_asset_activity.EAM_ACTIVITY_SOURCE_CODE := p_activity_source_code;
1473
1474 Create_Item(
1475 p_asset_activity => l_asset_activity,
1476 p_template_id => p_template_id,
1477 p_template_name => p_template_name,
1478
1479 x_curr_item_rec => l_x_curr_item_rec,
1480 x_curr_item_return_status => l_x_curr_item_return_status,
1481 x_curr_item_error_tbl => l_x_curr_item_error_tbl,
1482 x_master_item_rec => l_x_master_item_rec,
1483 x_master_item_return_status => l_x_master_item_return_status,
1484 x_master_item_error_tbl => l_x_master_item_error_tbl
1485 );
1486
1487 IF l_x_master_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1488 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_MASTER_FAILED');
1489 -- FND_MESSAGE.SET_ENCODED('Create Activity under Master Organization failed.');
1490 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1491 RAISE FND_API.G_EXC_ERROR;
1492 END IF;
1493
1494 IF l_x_curr_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1495 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_CURRENT_FAILED');
1496 -- FND_MESSAGE.SET_ENCODED('Create Activity under Current Organization failed.');
1497 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1498 RAISE FND_API.G_EXC_ERROR;
1499 END IF;
1500
1501 -- Set the Activity Attributes in the Item Record, don't have to do it manually
1502 /*
1503 -- Overwrite Activity Properties with user-supplied values
1504 l_x_master_item_rec.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1505 l_x_master_item_rec.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1506 l_x_master_item_rec.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1507 l_x_master_item_rec.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1508
1509 BEGIN
1510 UPDATE mtl_system_items
1511 SET EAM_ACTIVITY_TYPE_CODE = p_activity_type_code,
1512 EAM_ACTIVITY_CAUSE_CODE = p_activity_cause_code,
1513 EAM_ACT_SHUTDOWN_STATUS = p_shutdown_type_code,
1514 EAM_ACT_NOTIFICATION_FLAG = p_notification_req_flag,
1515 EAM_ACTIVITY_SOURCE_CODE = p_activity_source_code
1516 WHERE inventory_item_id = l_x_master_item_rec.inventory_item_id
1517 AND organization_id = l_x_master_item_rec.organization_id;
1518 EXCEPTION
1519 WHEN OTHERS THEN
1520 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1521 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACT_PROPERTIES');
1522 FND_MSG_PUB.ADD;
1523 END IF;
1524 RAISE FND_API.G_EXC_ERROR;
1525 END;
1526
1527 l_x_curr_item_rec.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
1528 l_x_curr_item_rec.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
1529 l_x_curr_item_rec.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
1530 l_x_curr_item_rec.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
1531
1532 BEGIN
1533 UPDATE mtl_system_items
1534 SET EAM_ACTIVITY_TYPE_CODE = p_activity_type_code,
1535 EAM_ACTIVITY_CAUSE_CODE = p_activity_cause_code,
1536 EAM_ACT_SHUTDOWN_STATUS = p_shutdown_type_code,
1537 EAM_ACT_NOTIFICATION_FLAG = p_notification_req_flag,
1538 EAM_ACTIVITY_SOURCE_CODE = p_activity_source_code
1539 WHERE inventory_item_id = l_x_curr_item_rec.inventory_item_id
1540 AND organization_id = l_x_curr_item_rec.organization_id;
1541 EXCEPTION
1542 WHEN OTHERS THEN
1543 IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
1544 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_ACT_PROPERTIES');
1545 FND_MSG_PUB.ADD;
1546 END IF;
1547 RAISE FND_API.G_EXC_ERROR;
1548 END;
1549 */
1550
1551 -- Assign outputs
1552 x_curr_item_rec := l_x_curr_item_rec;
1553 x_curr_item_return_status := l_x_curr_item_return_status;
1554 x_curr_item_error_tbl := l_x_curr_item_error_tbl;
1555 x_master_item_rec := l_x_master_item_rec;
1556 x_master_item_return_status := l_x_master_item_return_status;
1557 x_master_item_error_tbl := l_x_master_item_error_tbl;
1558
1559 -- ============================================================
1560 -- Bug # 3662214 : Need to create Routing first and then BOM so
1561 -- that operation sequence number in BOM is retained.
1562
1563 -- Step 3: Copy Routing
1564 EAM_ActivityUtilities_PVT.Write_Debug('-------- Beginning Copy Routing --------');
1565
1566 -- 3 a) Check Routing Copy Option
1567 EAM_ActivityUtilities_PVT.Write_Debug('p_routing_copy_option=' || p_routing_copy_option);
1568 IF p_routing_copy_option = 2 THEN
1569
1570 -- 3 b) Check if Source has Routing (sequence id)
1571 l_source_rtg_sequence_id := EAM_ActivityUtilities_PVT.Get_Rtg_Sequence_id(
1572 p_organization_id => p_source_org_id,
1573 p_assembly_item_id => p_source_activity_id,
1574 p_alternate_rtg_designator => p_source_alt_rtg_designator);
1575 EAM_ActivityUtilities_PVT.Write_Debug('l_source_rtg_sequence_id=' || l_source_rtg_sequence_id);
1576
1577 IF l_source_rtg_sequence_id IS NULL THEN
1578 -- Source Activity does not have Routing, nothing to copy
1579 NULL;
1580 ELSE
1581
1582 -- 4 c) Create target Routing header
1583
1584 -- l_rtg_header_rec := NULL;
1585 -- populate fields
1586 l_rtg_header_rec.Transaction_Type := l_create_txn_type;
1587 l_rtg_header_rec.Assembly_Item_Name := l_x_curr_item_rec.Item_Number;
1588 l_rtg_header_rec.Organization_Code := l_x_curr_item_rec.Organization_Code;
1589
1590 Error_Handler.initialize;
1591 -- log call to Process_Rtg API
1592 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_RTG_PUB.Process_Rtg **********');
1593 BOM_RTG_PUB.Process_Rtg(
1594 p_rtg_header_rec => l_rtg_header_rec
1595 , x_rtg_header_rec => l_x_rtg_header_rec
1596 , x_rtg_revision_tbl => l_x_rtg_revision_tbl
1597 , x_operation_tbl => l_x_operation_tbl
1598 , x_op_resource_tbl => l_x_op_resource_tbl
1599 , x_sub_resource_tbl => l_x_sub_resource_tbl
1600 , x_op_network_tbl => l_x_op_network_tbl
1601 , x_return_status => l_x_rtg_return_status
1602 , x_msg_count => l_x_rtg_msg_count
1603 );
1604 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_RTG_PUB.Process_Rtg **********');
1605
1606 -- log errors
1607 EAM_ActivityUtilities_PVT.Write_Debug('l_x_rtg_return_status=' || l_x_rtg_return_status);
1608 EAM_ActivityUtilities_PVT.Write_Debug('l_x_rtg_msg_count=' || l_x_rtg_msg_count);
1609 Error_Handler.Get_Message_List(l_x_rtg_msg_list);
1610 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_RTG_PUB.Process_Rtg >>>>>');
1611 EAM_ActivityUtilities_PVT.Log_Bom_Error_Tbl(l_x_rtg_msg_list);
1612 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_RTG_PUB.Process_Rtg <<<<<');
1613
1614 -- Handle errors
1615 IF l_x_bom_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1616 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_BOM_BO_FAILED');
1617 -- FND_MESSAGE.SET_ENCODED('Call to Routing Business Object API Failed.');
1618 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1619 RAISE FND_API.G_EXC_ERROR;
1620 END IF;
1621
1622 l_target_rtg_sequence_id := EAM_ActivityUtilities_PVT.Get_Rtg_Sequence_id(
1623 p_organization_id => l_x_curr_item_rec.organization_id,
1624 p_assembly_item_id => l_x_curr_item_rec.inventory_item_id,
1625 p_alternate_rtg_designator => NULL);
1626 EAM_ActivityUtilities_PVT.Write_Debug('l_target_rtg_sequence_id=' || l_target_rtg_sequence_id);
1627
1628 -- 4 d) Call copy_routing API
1629 -- log call to copy_routing API
1630 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_COPY_ROUTING.copy_routing **********');
1631 BOM_COPY_ROUTING.copy_routing(
1632 to_sequence_id => l_target_rtg_sequence_id,
1633 from_sequence_id => l_source_rtg_sequence_id,
1634 from_org_id => p_source_org_id,
1635 to_org_id => l_x_curr_item_rec.organization_id,
1636 user_id => FND_GLOBAL.USER_ID,
1637 to_item_id => l_x_curr_item_rec.inventory_item_id,
1638 direction => 1,
1639 to_alternate => NULL,
1640 rev_date => p_source_rtg_rev_date
1641 );
1642 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_COPY_ROUTING.copy_routing **********');
1643
1644 -- write copy_routing error message to fnd message stack and log file
1645 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_COPY_ROUTING.copy_routing >>>>>');
1646 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1647 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_COPY_ROUTING.copy_routing <<<<<');
1648
1649 END IF; -- l_source_rtg_sequence_id IS NULL
1650
1651 END IF; -- p_routing_copy_option
1652
1653 EAM_ActivityUtilities_PVT.Write_Debug('-------- Finished Copy Routing --------');
1654
1655 -- ============================================================
1656 -- Step 4: Copy BOM
1657 EAM_ActivityUtilities_PVT.Write_Debug('-------- Beginning Copy BOM --------');
1658
1659 -- 4 a) Check BOM Copy Option
1660 EAM_ActivityUtilities_PVT.Write_Debug('p_bom_copy_option=' || p_bom_copy_option);
1661 IF p_bom_copy_option = 2 THEN
1662
1663 -- 4 b) Check if Source has BOM (sequence_id)
1664 l_source_bom_sequence_id := EAM_ActivityUtilities_PVT.Get_Bom_Sequence_id(
1665 p_organization_id => p_source_org_id,
1666 p_assembly_item_id => p_source_activity_id,
1667 p_alternate_bom_designator => p_source_alt_bom_designator);
1668 EAM_ActivityUtilities_PVT.Write_Debug('l_source_bom_sequence_id=' || l_source_bom_sequence_id);
1669
1670 IF l_source_bom_sequence_id IS NULL THEN
1671 -- Source Activity does not have BOM, nothing to copy
1672 NULL;
1673 ELSE
1674
1675 -- 3 c) Create target BOM header (and get bom sequence_id)
1676 -- l_bom_head_rec := NULL;
1677 l_bom_head_rec.Transaction_Type := l_create_txn_type;
1678 l_bom_head_rec.Assembly_Item_Name := l_x_curr_item_rec.Item_Number;
1679 l_bom_head_rec.Organization_Code := l_x_curr_item_rec.Organization_Code;
1680 l_bom_head_rec.Assembly_Type := 1;
1681
1682 -- Create empty BOM header through BOM Business Object API
1683 Error_Handler.initialize;
1684 -- log call to Process_BOM API
1685 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_BO_PUB.Process_BOM **********');
1686 BOM_BO_PUB.Process_BOM(
1687 p_bom_header_rec => l_bom_head_rec,
1688 x_bom_header_rec => l_x_bom_header_rec,
1689 x_bom_revision_tbl => l_x_bom_revision_tbl,
1690 x_bom_component_tbl => l_x_bom_component_tbl,
1691 x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
1692 x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
1693 x_return_status => l_x_bom_return_status,
1694 x_msg_count => l_x_bom_msg_count
1695 );
1696 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_BO_PUB.Process_BOM **********');
1697
1698 -- log errors
1699 EAM_ActivityUtilities_PVT.Write_Debug('l_x_bom_return_status=' || l_x_bom_return_status);
1700 EAM_ActivityUtilities_PVT.Write_Debug('l_x_bom_msg_count=' || l_x_bom_msg_count);
1701 Error_Handler.Get_Message_List(l_x_bom_msg_list);
1702 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_BO_PUB.Process_BOM >>>>>');
1703 EAM_ActivityUtilities_PVT.Log_Bom_Error_Tbl(l_x_bom_msg_list);
1704 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_BO_PUB.Process_BOM <<<<<');
1705
1706 -- Handle errors
1707 IF l_x_rtg_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1708 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_RTG_BO_FAILED');
1709 -- FND_MESSAGE.SET_ENCODED('Call to Routing Business Object API Failed.');
1710 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1711 RAISE FND_API.G_EXC_ERROR;
1712 END IF;
1713
1714 l_target_bom_sequence_id := EAM_ActivityUtilities_PVT.Get_Bom_Sequence_id(
1715 p_organization_id => l_x_curr_item_rec.organization_id,
1716 p_assembly_item_id => l_x_curr_item_rec.inventory_item_id,
1717 p_alternate_bom_designator => NULL);
1718 EAM_ActivityUtilities_PVT.Write_Debug('l_target_bom_sequence_id=' || l_target_bom_sequence_id);
1719
1720 -- 3 d) Call copy_bill API
1721 -- log call to copy_bill API
1722 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_COPY_BILL.copy_bill **********');
1723 BOM_COPY_BILL.copy_bill(
1724 to_sequence_id => l_target_bom_sequence_id,
1725 from_sequence_id => l_source_bom_sequence_id,
1726 from_org_id => p_source_org_id,
1727 to_org_id => l_x_curr_item_rec.organization_id,
1728 user_id => FND_GLOBAL.USER_ID,
1729 to_item_id => l_x_curr_item_rec.inventory_item_id,
1730 direction => 1,
1731 to_alternate => NULL,
1732 rev_date => p_source_bom_rev_date,
1733 e_change_notice => NULL,
1734 rev_item_seq_id => NULL,
1735 bill_or_eco => 1,
1736 eco_eff_date => NULL,
1737 from_item_id => p_source_activity_id
1738 );
1739 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_COPY_BILL.copy_bill **********');
1740
1741 -- write copy_bill error message to fnd message stack and log file
1742 EAM_ActivityUtilities_PVT.Write_Debug('Results of BOM_COPY_BILL.copy_bill >>>>>');
1743 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1744 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of BOM_COPY_BILL.copy_bill <<<<<');
1745
1746
1747 END IF; -- l_source_bom_sequence_id IS NULL
1748
1749 END IF; -- p_bom_copy_option = 2
1750
1751 EAM_ActivityUtilities_PVT.Write_Debug('-------- Finished Copy BOM --------');
1752
1753 -- ============================================================
1754 -- Step 5: Update Association to Asset Numbers for the newly created activity
1755 EAM_ActivityUtilities_PVT.Write_Debug('-------- Beginning Copy Association --------');
1756
1757 EAM_ActivityUtilities_PVT.Write_Debug('p_association_copy_option=' || p_association_copy_option);
1758 IF p_association_copy_option <> 1 THEN
1759 -- p_association_copy_option <> 1 (NONE), call private package to create association
1760 EAM_ActivityUtilities_PVT.Write_Debug(
1761 '********** Calling EAM_ActivityAssociation_PVT.Create_Association **********');
1762 EAM_ActivityAssociation_PVT.Create_Association(
1763 p_api_version => 1.0,
1764 x_return_status => l_x_assoc_return_status,
1765 x_msg_count => l_x_assoc_msg_count,
1766 x_msg_data => l_x_assoc_msg_data,
1767
1768 p_target_org_id => l_x_curr_item_rec.organization_id,
1769 p_target_activity_id => l_x_curr_item_rec.inventory_item_id,
1770 p_wip_entity_id => NULL,
1771 p_source_org_id => p_source_org_id,
1772 p_source_activity_id => p_source_activity_id,
1773 p_association_copy_option => p_association_copy_option,
1774
1775 x_act_num_association_tbl => l_x_act_num_association_tbl,
1776 x_activity_association_tbl => l_x_activity_association_tbl
1777 );
1778 EAM_ActivityUtilities_PVT.Write_Debug(
1779 '********** Returned from EAM_ActivityAssociation_PVT.Create_Association **********');
1780 EAM_ActivityUtilities_PVT.Write_Debug('l_x_assoc_return_status=' || l_x_assoc_return_status);
1781 EAM_ActivityUtilities_PVT.Write_Debug('l_x_assoc_msg_count=' || l_x_assoc_msg_count);
1782 EAM_ActivityUtilities_PVT.Write_Debug('l_x_assoc_msg_data=' || l_x_assoc_msg_data);
1783
1784 -- Assing outputs
1785 x_assoc_return_status := l_x_assoc_return_status;
1786 x_assoc_msg_count := l_x_assoc_msg_count;
1787 x_assoc_msg_data := l_x_assoc_msg_data;
1788 x_act_num_association_tbl := l_x_act_num_association_tbl;
1789 x_activity_association_tbl := l_x_activity_association_tbl;
1790
1791 -- Handle error
1792 IF l_x_assoc_return_status <> FND_API.G_RET_STS_SUCCESS THEN
1793 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ASSOC_FAILED');
1794 -- FND_MESSAGE.SET_ENCODED('Create Activity Associations failed.');
1795 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
1796 RAISE FND_API.G_EXC_ERROR;
1797 END IF;
1798
1799 END IF;
1800
1801 EAM_ActivityUtilities_PVT.Write_Debug('-------- Finished Copy Association --------');
1802
1803 -- ======================================================================
1804
1805
1806 -- End of API body.
1807 -- Standard check of p_commit.
1808 IF FND_API.To_Boolean( p_commit ) THEN
1809 COMMIT WORK;
1810 END IF;
1811 -- Standard call to get message count and if count is 1, get message info.
1812 FND_MSG_PUB.Count_And_Get
1813 ( p_count => x_msg_count ,
1814 p_data => x_msg_data
1815 );
1816
1817 EAM_ActivityUtilities_PVT.Write_Debug('========== Exiting EAM_Activity_PUB.Copy_Activity ==========');
1818
1819
1820 -- ======================================================================
1821 EXCEPTION
1822 WHEN FND_API.G_EXC_ERROR THEN
1823 ROLLBACK TO Copy_Activity_PUB;
1824 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Copy_Activity: EXPECTED_ERROR ==========');
1825 x_return_status := FND_API.G_RET_STS_ERROR ;
1826 FND_MSG_PUB.Count_And_Get
1827 ( p_count => x_msg_count ,
1828 p_data => x_msg_data
1829 );
1830 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1831 ROLLBACK TO Copy_Activity_PUB;
1832 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Copy_Activity: UNEXPECTED_ERROR ==========');
1833 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1834 FND_MSG_PUB.Count_And_Get
1835 ( p_count => x_msg_count ,
1836 p_data => x_msg_data
1837 );
1838
1839 WHEN OTHERS THEN
1840 ROLLBACK TO Copy_Activity_PUB;
1841 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
1842 IF FND_MSG_PUB.Check_Msg_Level
1843 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1844 THEN
1845 FND_MSG_PUB.Add_Exc_Msg
1846 ( G_PKG_NAME ,
1847 l_api_name
1848 );
1849 -- log error message also
1850 EAM_ActivityUtilities_PVT.Write_Debug(FND_MSG_PUB.Get(FND_MSG_PUB.G_LAST, FND_API.G_FALSE));
1851 END IF;
1852 EAM_ActivityUtilities_PVT.Write_Debug('========== EAM_Activity_PUB.Copy_Activity: OTHER ERROR ==========');
1853 FND_MSG_PUB.Count_And_Get
1854 ( p_count => x_msg_count ,
1855 p_data => x_msg_data
1856 );
1857 END Copy_Activity;
1858
1859
1860 -- ================================================================================
1861
1862 PROCEDURE Create_Activity_From_Form (
1863 p_wip_entity_id IN NUMBER
1864 , p_asset_activity IN VARCHAR2
1865 , p_segment1 IN VARCHAR2
1866 , p_segment2 IN VARCHAR2
1867 , p_segment3 IN VARCHAR2
1868 , p_segment4 IN VARCHAR2
1869 , p_segment5 IN VARCHAR2
1870 , p_segment6 IN VARCHAR2
1871 , p_segment7 IN VARCHAR2
1872 , p_segment8 IN VARCHAR2
1873 , p_segment9 IN VARCHAR2
1874 , p_segment10 IN VARCHAR2
1875 , p_segment11 IN VARCHAR2
1876 , p_segment12 IN VARCHAR2
1877 , p_segment13 IN VARCHAR2
1878 , p_segment14 IN VARCHAR2
1879 , p_segment15 IN VARCHAR2
1880 , p_segment16 IN VARCHAR2
1881 , p_segment17 IN VARCHAR2
1882 , p_segment18 IN VARCHAR2
1883 , p_segment19 IN VARCHAR2
1884 , p_segment20 IN VARCHAR2
1885 , p_description IN VARCHAR2
1886 , p_template_id IN NUMBER
1887 , p_activity_type_code IN VARCHAR2
1888 , p_activity_cause_code IN VARCHAR2
1889 , p_shutdown_type_code IN VARCHAR2
1890 , p_notification_req_flag IN VARCHAR2
1891 , p_activity_source_code IN VARCHAR2
1892
1893 , p_operation_copy_option IN NUMBER
1894 , p_material_copy_option IN NUMBER
1895 , p_resource_copy_option IN NUMBER
1896 , p_association_copy_option IN NUMBER
1897 , x_successful OUT NOCOPY BOOLEAN
1898 )
1899 IS
1900
1901 l_create_activity_ver NUMBER := 1.0;
1902 l_x_return_status VARCHAR2(1);
1903 l_x_msg_count NUMBER;
1904 l_x_msg_data VARCHAR2(20000);
1905
1906 l_asset_activity INV_Item_GRP.Item_Rec_Type;
1907 l_work_order_rec EAM_Activity_PUB.Work_Order_Rec_Type;
1908 l_x_inventory_item_id NUMBER;
1909 l_x_work_order_rec EAM_Activity_PUB.Work_Order_Rec_Type;
1910
1911 -- output variables of inv package
1912 l_x_curr_item_rec INV_Item_GRP.Item_Rec_Type;
1913 l_x_curr_item_return_status VARCHAR2(1);
1914 l_x_curr_item_error_tbl INV_Item_GRP.Error_Tbl_Type;
1915 l_x_master_item_rec INV_Item_GRP.Item_Rec_Type;
1916 l_x_master_item_return_status VARCHAR2(1);
1917 l_x_master_item_error_tbl INV_Item_GRP.Error_Tbl_Type;
1918 -- output variables of Routing Business Object API
1919 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
1920 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
1921 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
1922 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
1923 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
1924 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
1925 l_x_rtg_return_status VARCHAR2(1);
1926 l_x_rtg_msg_count NUMBER;
1927 -- output variables of BOM Business Object API
1928 l_x_bom_header_rec BOM_BO_PUB.Bom_Head_Rec_Type;
1929 l_x_bom_revision_tbl BOM_BO_PUB.Bom_Revision_Tbl_Type;
1930 l_x_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
1931 l_x_bom_ref_designator_tbl BOM_BO_PUB.Bom_Ref_Designator_Tbl_Type;
1932 l_x_bom_sub_component_tbl BOM_BO_PUB.Bom_Sub_Component_Tbl_Type;
1933 l_x_bom_return_status VARCHAR2(1);
1934 l_x_bom_msg_count NUMBER;
1935 -- Routing and BOM common Error Handler
1936 l_x_bom_error_list Error_Handler.Error_Tbl_Type;
1937 l_x_bom_error_count INTEGER;
1938 l_bom_error_count INTEGER;
1939 l_index BINARY_INTEGER;
1940 l_x_rtg_error_list Error_Handler.Error_Tbl_Type;
1941 l_x_rtg_error_count INTEGER;
1942 -- Activity Association
1943 l_x_assoc_return_status VARCHAR2(1);
1944 l_x_assoc_msg_count NUMBER;
1945 l_x_assoc_msg_data VARCHAR2(20000);
1946 l_x_act_num_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
1947 l_x_activity_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
1948
1949 BEGIN
1950
1951 EAM_ActivityUtilities_PVT.Open_Debug_Session;
1952
1953 -- 1: Step up activity parameters
1954 l_work_order_rec.wip_entity_id := p_wip_entity_id;
1955 l_asset_activity.Description := p_description;
1956
1957 -- 1.1: Set up Item Number. Use segments if specified.
1958 IF p_segment1 IS NOT NULL OR
1959 p_segment2 IS NOT NULL OR
1960 p_segment3 IS NOT NULL OR
1961 p_segment4 IS NOT NULL OR
1962 p_segment5 IS NOT NULL OR
1963 p_segment6 IS NOT NULL OR
1964 p_segment7 IS NOT NULL OR
1965 p_segment8 IS NOT NULL OR
1966 p_segment9 IS NOT NULL OR
1967 p_segment10 IS NOT NULL OR
1968 p_segment11 IS NOT NULL OR
1969 p_segment12 IS NOT NULL OR
1970 p_segment13 IS NOT NULL OR
1971 p_segment14 IS NOT NULL OR
1972 p_segment15 IS NOT NULL OR
1973 p_segment16 IS NOT NULL OR
1974 p_segment17 IS NOT NULL OR
1975 p_segment18 IS NOT NULL OR
1976 p_segment19 IS NOT NULL OR
1977 p_segment20 IS NOT NULL
1978 THEN
1979 l_asset_activity.Segment1 := p_segment1;
1980 l_asset_activity.Segment2 := p_segment2;
1981 l_asset_activity.Segment3 := p_segment3;
1982 l_asset_activity.Segment4 := p_segment4;
1983 l_asset_activity.Segment5 := p_segment5;
1984 l_asset_activity.Segment6 := p_segment6;
1985 l_asset_activity.Segment7 := p_segment7;
1986 l_asset_activity.Segment8 := p_segment8;
1987 l_asset_activity.Segment9 := p_segment9;
1988 l_asset_activity.Segment10 := p_segment10;
1989 l_asset_activity.Segment11 := p_segment11;
1990 l_asset_activity.Segment12 := p_segment12;
1991 l_asset_activity.Segment13 := p_segment13;
1992 l_asset_activity.Segment14 := p_segment14;
1993 l_asset_activity.Segment15 := p_segment15;
1994 l_asset_activity.Segment16 := p_segment16;
1995 l_asset_activity.Segment17 := p_segment17;
1996 l_asset_activity.Segment18 := p_segment18;
1997 l_asset_activity.Segment19 := p_segment19;
1998 l_asset_activity.Segment20 := p_segment20;
1999 ELSE
2000 l_asset_activity.Item_Number := p_asset_activity;
2001 END IF;
2002
2003 -- Set EAM attributes
2004 l_asset_activity.EAM_ITEM_TYPE := 2; -- EAM Asset Activity
2005
2006 EAM_Activity_PUB.Create_Activity(
2007 p_api_version => l_create_activity_ver,
2008
2009 x_return_status => l_x_return_status,
2010 x_msg_count => l_x_msg_count,
2011 x_msg_data => l_x_msg_data,
2012
2013 p_asset_activity => l_asset_activity,
2014 p_template_id => p_template_id,
2015
2016 p_activity_type_code => p_activity_type_code,
2017 p_activity_cause_code => p_activity_cause_code,
2018 p_shutdown_type_code => p_shutdown_type_code,
2019 p_notification_req_flag => p_notification_req_flag,
2020 p_activity_source_code => p_activity_source_code,
2021
2022 p_work_order_rec => l_work_order_rec,
2023 p_operation_copy_option => p_operation_copy_option,
2024 p_material_copy_option => p_material_copy_option,
2025 p_resource_copy_option => p_resource_copy_option,
2026 p_association_copy_option => p_association_copy_option,
2027
2028 -- x_inventory_item_id => l_x_inventory_item_id,
2029 x_work_order_rec => l_x_work_order_rec
2030
2031 -- inv variables
2032 , x_curr_item_rec => l_x_curr_item_rec
2033 , x_curr_item_return_status => l_x_curr_item_return_status
2034 , x_curr_item_error_tbl => l_x_curr_item_error_tbl
2035 , x_master_item_rec => l_x_master_item_rec
2036 , x_master_item_return_status => l_x_master_item_return_status
2037 , x_master_item_error_tbl => l_x_master_item_error_tbl
2038
2039 -- Routing outputs
2040 , x_rtg_header_rec => l_x_rtg_header_rec
2041 , x_rtg_revision_tbl => l_x_rtg_revision_tbl
2042 , x_operation_tbl => l_x_operation_tbl
2043 , x_op_resource_tbl => l_x_op_resource_tbl
2044 , x_sub_resource_tbl => l_x_sub_resource_tbl
2045 , x_op_network_tbl => l_x_op_network_tbl
2046 , x_rtg_return_status => l_x_rtg_return_status
2047 , x_rtg_msg_count => l_x_rtg_msg_count
2048 , x_rtg_msg_list => l_x_rtg_error_list
2049 -- BOM outputs
2050 , x_bom_header_rec => l_x_bom_header_rec
2051 , x_bom_revision_tbl => l_x_bom_revision_tbl
2052 , x_bom_component_tbl => l_x_bom_component_tbl
2053 , x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl
2054 , x_bom_sub_component_tbl => l_x_bom_sub_component_tbl
2055 , x_bom_return_status => l_x_bom_return_status
2056 , x_bom_msg_count => l_x_bom_msg_count
2057 , x_bom_msg_list => l_x_bom_error_list
2058
2059 , x_assoc_return_status => l_x_assoc_return_status
2060 , x_assoc_msg_count => l_x_assoc_msg_count
2061 , x_assoc_msg_data => l_x_assoc_msg_data
2062 , x_act_num_association_tbl => l_x_act_num_association_tbl
2063 , x_activity_association_tbl => l_x_activity_association_tbl
2064
2065 );
2066
2067 -- Assign outputs
2068
2069 IF l_x_return_status = FND_API.G_RET_STS_SUCCESS THEN
2070 commit;
2071 x_successful := TRUE;
2072 ELSE
2073 x_successful := FALSE;
2074 END IF;
2075
2076 EAM_ActivityUtilities_PVT.Close_Debug_Session;
2077
2078 END Create_Activity_From_Form;
2079
2080
2081 -- ================================================================================
2082
2083 PROCEDURE Create_Activity_With_Template(
2084 p_api_version IN NUMBER ,
2085 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE ,
2086 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
2087 p_validation_level IN NUMBER :=
2088 FND_API.G_VALID_LEVEL_FULL ,
2089 x_return_status OUT NOCOPY VARCHAR2 ,
2090 x_msg_count OUT NOCOPY NUMBER ,
2091 x_msg_data OUT NOCOPY VARCHAR2 ,
2092
2093 p_organization_id IN NUMBER := NULL,
2094 p_organization_code IN NUMBER := NULL,
2095 p_asset_activity IN VARCHAR2,
2096 p_segment1 IN VARCHAR2,
2097 p_segment2 IN VARCHAR2,
2098 p_segment3 IN VARCHAR2,
2099 p_segment4 IN VARCHAR2,
2100 p_segment5 IN VARCHAR2,
2101 p_segment6 IN VARCHAR2,
2102 p_segment7 IN VARCHAR2,
2103 p_segment8 IN VARCHAR2,
2104 p_segment9 IN VARCHAR2,
2105 p_segment10 IN VARCHAR2,
2106 p_segment11 IN VARCHAR2,
2107 p_segment12 IN VARCHAR2,
2108 p_segment13 IN VARCHAR2,
2109 p_segment14 IN VARCHAR2,
2110 p_segment15 IN VARCHAR2,
2111 p_segment16 IN VARCHAR2,
2112 p_segment17 IN VARCHAR2,
2113 p_segment18 IN VARCHAR2,
2114 p_segment19 IN VARCHAR2,
2115 p_segment20 IN VARCHAR2,
2116 p_description IN VARCHAR2,
2117 p_template_id IN NUMBER := NULL,
2118 p_template_name IN VARCHAR2 := NULL,
2119 p_activity_type_code IN VARCHAR2 := NULL,
2120 p_activity_cause_code IN VARCHAR2 := NULL,
2121 p_shutdown_type_code IN VARCHAR2 := NULL,
2122 p_notification_req_flag IN VARCHAR2 := NULL,
2123 p_activity_source_code IN VARCHAR2 := NULL,
2124
2125 x_curr_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
2126 x_curr_item_return_status OUT NOCOPY VARCHAR2,
2127 x_curr_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type,
2128 x_master_item_rec OUT NOCOPY INV_Item_GRP.Item_Rec_Type,
2129 x_master_item_return_status OUT NOCOPY VARCHAR2,
2130 x_master_item_error_tbl OUT NOCOPY INV_Item_GRP.Error_Tbl_Type
2131
2132 )
2133 IS
2134
2135 l_asset_activity INV_Item_GRP.Item_rec_type;
2136
2137 l_api_name CONSTANT VARCHAR2(30) := 'Create_Activity_With_Template';
2138 l_api_version CONSTANT NUMBER := 1.0;
2139
2140 l_x_curr_item_rec INV_Item_GRP.Item_rec_type;
2141 l_x_curr_item_return_status VARCHAR2(1);
2142 l_x_curr_item_error_tbl INV_Item_GRP.Error_tbl_type;
2143
2144 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
2145 l_x_master_item_return_status VARCHAR2(1);
2146 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
2147
2148 BEGIN
2149 -- Standard Start of API savepoint
2150 SAVEPOINT Create_Act_With_Templ_PUB;
2151 -- Standard call to check for call compatibility.
2152 IF NOT FND_API.Compatible_API_Call ( l_api_version ,
2153 p_api_version ,
2154 l_api_name ,
2155 G_PKG_NAME )
2156 THEN
2157 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
2158 END IF;
2159 -- Initialize message list if p_init_msg_list is set to TRUE.
2160 IF FND_API.to_Boolean( p_init_msg_list ) THEN
2161 FND_MSG_PUB.initialize;
2162 END IF;
2163 -- Initialize API return status to success
2164 x_return_status := FND_API.G_RET_STS_SUCCESS;
2165 -- API body
2166
2167 -- ============================================================
2168 EAM_ActivityUtilities_PVT.Write_Debug('========== Entering EAM_Activity_PUB.Create_Activity_With_Template ==========');
2169 EAM_ActivityUtilities_PVT.Write_Debug('p_organization_id=' || p_organization_id);
2170 EAM_ActivityUtilities_PVT.Write_Debug('p_organization_code=' || p_organization_code);
2171 EAM_ActivityUtilities_PVT.Write_Debug('p_asset_activity=' || p_asset_activity);
2172 EAM_ActivityUtilities_PVT.Write_Debug('p_segment1=' || p_segment1);
2173 EAM_ActivityUtilities_PVT.Write_Debug('p_segment2=' || p_segment2);
2174 EAM_ActivityUtilities_PVT.Write_Debug('p_segment3=' || p_segment3);
2175 EAM_ActivityUtilities_PVT.Write_Debug('p_segment4=' || p_segment4);
2176 EAM_ActivityUtilities_PVT.Write_Debug('p_segment5=' || p_segment5);
2177 EAM_ActivityUtilities_PVT.Write_Debug('p_segment6=' || p_segment6);
2178 EAM_ActivityUtilities_PVT.Write_Debug('p_segment7=' || p_segment7);
2179 EAM_ActivityUtilities_PVT.Write_Debug('p_segment8=' || p_segment8);
2180 EAM_ActivityUtilities_PVT.Write_Debug('p_segment9=' || p_segment9);
2181 EAM_ActivityUtilities_PVT.Write_Debug('p_segment10=' || p_segment10);
2182 EAM_ActivityUtilities_PVT.Write_Debug('p_segment11=' || p_segment11);
2183 EAM_ActivityUtilities_PVT.Write_Debug('p_segment12=' || p_segment12);
2184 EAM_ActivityUtilities_PVT.Write_Debug('p_segment13=' || p_segment13);
2185 EAM_ActivityUtilities_PVT.Write_Debug('p_segment14=' || p_segment14);
2186 EAM_ActivityUtilities_PVT.Write_Debug('p_segment15=' || p_segment15);
2187 EAM_ActivityUtilities_PVT.Write_Debug('p_segment16=' || p_segment16);
2188 EAM_ActivityUtilities_PVT.Write_Debug('p_segment17=' || p_segment17);
2189 EAM_ActivityUtilities_PVT.Write_Debug('p_segment18=' || p_segment18);
2190 EAM_ActivityUtilities_PVT.Write_Debug('p_segment19=' || p_segment19);
2191 EAM_ActivityUtilities_PVT.Write_Debug('p_segment20=' || p_segment20);
2192 EAM_ActivityUtilities_PVT.Write_Debug('p_description=' || p_description);
2193
2194 -- ============================================================
2195 -- Create Asset Activity. Call INV_Item_GRP package.
2196
2197 l_asset_activity.organization_id := p_organization_id;
2198 l_asset_activity.organization_code := p_organization_code;
2199
2200 -- Set up Item Number. Use segments if specified.
2201 IF p_segment1 IS NOT NULL OR
2202 p_segment2 IS NOT NULL OR
2203 p_segment3 IS NOT NULL OR
2204 p_segment4 IS NOT NULL OR
2205 p_segment5 IS NOT NULL OR
2206 p_segment6 IS NOT NULL OR
2207 p_segment7 IS NOT NULL OR
2208 p_segment8 IS NOT NULL OR
2209 p_segment9 IS NOT NULL OR
2210 p_segment10 IS NOT NULL OR
2211 p_segment11 IS NOT NULL OR
2212 p_segment12 IS NOT NULL OR
2213 p_segment13 IS NOT NULL OR
2214 p_segment14 IS NOT NULL OR
2215 p_segment15 IS NOT NULL OR
2216 p_segment16 IS NOT NULL OR
2217 p_segment17 IS NOT NULL OR
2218 p_segment18 IS NOT NULL OR
2219 p_segment19 IS NOT NULL OR
2220 p_segment20 IS NOT NULL
2221 THEN
2222 l_asset_activity.Segment1 := p_segment1;
2223 l_asset_activity.Segment2 := p_segment2;
2224 l_asset_activity.Segment3 := p_segment3;
2225 l_asset_activity.Segment4 := p_segment4;
2226 l_asset_activity.Segment5 := p_segment5;
2227 l_asset_activity.Segment6 := p_segment6;
2228 l_asset_activity.Segment7 := p_segment7;
2229 l_asset_activity.Segment8 := p_segment8;
2230 l_asset_activity.Segment9 := p_segment9;
2231 l_asset_activity.Segment10 := p_segment10;
2232 l_asset_activity.Segment11 := p_segment11;
2233 l_asset_activity.Segment12 := p_segment12;
2234 l_asset_activity.Segment13 := p_segment13;
2235 l_asset_activity.Segment14 := p_segment14;
2236 l_asset_activity.Segment15 := p_segment15;
2237 l_asset_activity.Segment16 := p_segment16;
2238 l_asset_activity.Segment17 := p_segment17;
2239 l_asset_activity.Segment18 := p_segment18;
2240 l_asset_activity.Segment19 := p_segment19;
2241 l_asset_activity.Segment20 := p_segment20;
2242 ELSE
2243 l_asset_activity.Item_Number := p_asset_activity;
2244 END IF;
2245
2246
2247
2248
2249 l_asset_activity.description := p_description;
2250
2251 l_asset_activity.EAM_ACTIVITY_TYPE_CODE := p_activity_type_code;
2252 l_asset_activity.EAM_ACTIVITY_CAUSE_CODE := p_activity_cause_code;
2253 l_asset_activity.EAM_ACT_NOTIFICATION_FLAG := p_notification_req_flag;
2254 l_asset_activity.EAM_ACT_SHUTDOWN_STATUS := p_shutdown_type_code;
2255 l_asset_activity.EAM_ACTIVITY_SOURCE_CODE := p_activity_source_code;
2256
2257 Create_Item(
2258 p_asset_activity => l_asset_activity,
2259 p_template_id => p_template_id,
2260 p_template_name => p_template_name,
2261
2262 x_curr_item_rec => l_x_curr_item_rec,
2263 x_curr_item_return_status => l_x_curr_item_return_status,
2264 x_curr_item_error_tbl => l_x_curr_item_error_tbl,
2265 x_master_item_rec => l_x_master_item_rec,
2266 x_master_item_return_status => l_x_master_item_return_status,
2267 x_master_item_error_tbl => l_x_master_item_error_tbl
2268 );
2269 -- Assign outputs
2270 x_curr_item_rec := l_x_curr_item_rec;
2271 x_curr_item_return_status := l_x_curr_item_return_status;
2272 x_curr_item_error_tbl := l_x_curr_item_error_tbl;
2273 x_master_item_rec := l_x_master_item_rec;
2274 x_master_item_return_status := l_x_master_item_return_status;
2275 x_master_item_error_tbl := l_x_master_item_error_tbl;
2276
2277 IF l_x_master_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2278 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_MASTER_FAILED');
2279 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
2280 RAISE FND_API.G_EXC_ERROR;
2281 END IF;
2282
2283 IF l_x_curr_item_return_status <> FND_API.G_RET_STS_SUCCESS THEN
2284 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_CURRENT_FAILED');
2285 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
2286 RAISE FND_API.G_EXC_ERROR;
2287 END IF;
2288
2289 -- =============================================================
2290
2291 -- End of API body.
2292 -- Standard check of p_commit.
2293 IF FND_API.To_Boolean( p_commit ) THEN
2294 COMMIT WORK;
2295 END IF;
2296 -- Standard call to get message count and if count is 1, get message info.
2297 FND_MSG_PUB.Count_And_Get
2298 ( p_count => x_msg_count ,
2299 p_data => x_msg_data
2300 );
2301
2302
2303 EAM_ActivityUtilities_PVT.Write_Debug('========== Exiting EAM_Activity_PUB.Create_Activity_With_Template ==========');
2304
2305 -- ======================================================================
2306
2307 EXCEPTION
2308 WHEN FND_API.G_EXC_ERROR THEN
2309 ROLLBACK TO Create_Act_With_Templ_PUB;
2310 EAM_ActivityUtilities_PVT.Write_Debug(
2311 '========== EAM_Activity_PUB.Create_Activity_With_Template: EXPECTED ERROR ==========');
2312 x_return_status := FND_API.G_RET_STS_ERROR ;
2313 FND_MSG_PUB.Count_And_Get
2314 ( p_count => x_msg_count ,
2315 p_data => x_msg_data
2316 );
2317 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
2318 ROLLBACK TO Create_Act_With_Templ_PUB;
2319 EAM_ActivityUtilities_PVT.Write_Debug(
2320 '========== EAM_Activity_PUB.Create_Activity_With_Template: UNEXPECTED ERROR ==========');
2321 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2322 FND_MSG_PUB.Count_And_Get
2323 ( p_count => x_msg_count ,
2324 p_data => x_msg_data
2325 );
2326 WHEN OTHERS THEN
2327 ROLLBACK TO Create_Act_With_Templ_PUB;
2328 EAM_ActivityUtilities_PVT.Write_Debug(
2329 '========== EAM_Activity_PUB.Create_Activity_With_Template: OTHER ERROR ==========');
2330 x_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
2331 IF FND_MSG_PUB.Check_Msg_Level
2332 (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
2333 THEN
2334 FND_MSG_PUB.Add_Exc_Msg
2335 ( G_PKG_NAME ,
2336 l_api_name
2337 );
2338 END IF;
2339 FND_MSG_PUB.Count_And_Get
2340 ( p_count => x_msg_count ,
2341 p_data => x_msg_data
2342 );
2343 END Create_Activity_With_Template;
2344
2345
2346 -- From Saurabh
2347 procedure create_bom_header(
2348 p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
2349 --p_source_org_id IN NUMBER,
2350 --p_source_activity_id IN NUMBER, -- inventory_item_id
2351
2352 --p_material_copy_option IN NUMBER,
2353
2354 x_bom_header_rec OUT NOCOPY BOM_BO_PUB.BOM_Head_Rec_Type,
2355 x_bom_revision_tbl OUT NOCOPY BOM_BO_PUB.BOM_Revision_Tbl_Type,
2356 x_bom_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Comps_Tbl_Type,
2357 x_bom_ref_designator_tbl OUT NOCOPY BOM_BO_PUB.BOM_Ref_Designator_Tbl_Type,
2358 x_bom_sub_component_tbl OUT NOCOPY BOM_BO_PUB.BOM_Sub_Component_Tbl_Type,
2359 x_bom_return_status OUT NOCOPY VARCHAR2,
2360 x_bom_msg_count OUT NOCOPY NUMBER,
2361 x_bom_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type
2362
2363 )
2364 IS
2365 --l_current_date CONSTANT DATE := sysdate;
2366 l_create_txn_type CONSTANT VARCHAR(10) := 'CREATE';
2367 -- local variabels for calling BOM Business Object API
2368 l_bom_head_rec BOM_BO_PUB.Bom_Head_Rec_Type;
2369 l_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
2370 l_bom_comp_tbl_index BINARY_INTEGER;
2371
2372 l_x_bom_header_rec BOM_BO_PUB.Bom_Head_Rec_Type;
2373 l_x_bom_revision_tbl BOM_BO_PUB.Bom_Revision_Tbl_Type;
2374 l_x_bom_component_tbl BOM_BO_PUB.Bom_Comps_Tbl_Type;
2375 l_x_bom_ref_designator_tbl BOM_BO_PUB.Bom_Ref_Designator_Tbl_Type;
2376 l_x_bom_sub_component_tbl BOM_BO_PUB.Bom_Sub_Component_Tbl_Type;
2377 l_x_bom_return_status VARCHAR2(1);
2378 l_x_bom_msg_count NUMBER;
2379 l_x_bom_msg_list Error_Handler.Error_Tbl_Type;
2380
2381 begin
2382 -- l_bom_head_rec := NULL;
2383 l_bom_head_rec.Assembly_Item_Name := p_target_item_rec.Item_Number;
2384 l_bom_head_rec.Transaction_Type := l_create_txn_type;
2385 l_bom_head_rec.Organization_Code := p_target_item_rec.Organization_Code;
2386 --l_bom_head_rec.Alternate_Bom_Code := l_bom_bom_row.alternate_bom_designator;
2387 --l_bom_head_rec.Assembly_Type := l_bom_bom_row.assembly_type;
2388
2389 -- fixthis??
2390 -- Common_Assembly_Name
2391 -- Common_Organization_Code
2392
2393 /*l_bom_head_rec.Attribute_Category := l_bom_bom_row.attribute_category;
2394 l_bom_head_rec.Attribute1 := l_bom_bom_row.attribute1;
2395 l_bom_head_rec.Attribute2 := l_bom_bom_row.attribute2;
2396 l_bom_head_rec.Attribute3 := l_bom_bom_row.attribute3;
2397 l_bom_head_rec.Attribute4 := l_bom_bom_row.attribute4;
2398 l_bom_head_rec.Attribute5 := l_bom_bom_row.attribute5;
2399 l_bom_head_rec.Attribute6 := l_bom_bom_row.attribute6;
2400 l_bom_head_rec.Attribute7 := l_bom_bom_row.attribute7;
2401 l_bom_head_rec.Attribute8 := l_bom_bom_row.attribute8;
2402 l_bom_head_rec.Attribute9 := l_bom_bom_row.attribute9;
2403 l_bom_head_rec.Attribute10 := l_bom_bom_row.attribute10;
2404 l_bom_head_rec.Attribute11 := l_bom_bom_row.attribute11;
2405 l_bom_head_rec.Attribute12 := l_bom_bom_row.attribute12;
2406 l_bom_head_rec.Attribute13 := l_bom_bom_row.attribute13;
2407 l_bom_head_rec.Attribute14 := l_bom_bom_row.attribute14;
2408 l_bom_head_rec.Attribute15 := l_bom_bom_row.attribute15;
2409 */
2410 --l_bom_head_rec.Alternate_Bom_Code := l_bom_bom_row.alternate_bom_designator;
2411 --l_bom_head_rec.Assembly_Type := l_bom_bom_row.assembly_type;
2412 -- log call to Process_BOM API
2413 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_BO_PUB.Process_BOM **********');
2414 BOM_BO_PUB.Process_BOM(
2415 p_bom_header_rec => l_bom_head_rec,
2416 p_bom_component_tbl => l_bom_component_tbl,
2417 x_bom_header_rec => l_x_bom_header_rec,
2418 x_bom_revision_tbl => l_x_bom_revision_tbl,
2419 x_bom_component_tbl => l_x_bom_component_tbl,
2420 x_bom_ref_designator_tbl => l_x_bom_ref_designator_tbl,
2421 x_bom_sub_component_tbl => l_x_bom_sub_component_tbl,
2422 x_return_status => l_x_bom_return_status,
2423 x_msg_count => l_x_bom_msg_count
2424 );
2425 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_BO_PUB.Process_BOM **********');
2426
2427 x_bom_header_rec := l_x_bom_header_rec;
2428 x_bom_revision_tbl := l_x_bom_revision_tbl;
2429 x_bom_component_tbl := l_x_bom_component_tbl;
2430 x_bom_ref_designator_tbl := l_x_bom_ref_designator_tbl;
2431 x_bom_sub_component_tbl := l_x_bom_sub_component_tbl;
2432 x_bom_return_status := l_x_bom_return_status;
2433 x_bom_msg_count := l_x_bom_msg_count;
2434 Error_Handler.Get_Message_List(l_x_bom_msg_list);
2435 x_bom_msg_list := l_x_bom_msg_list;
2436 end create_bom_header;
2437
2438 procedure create_bom_header_form(
2439 --p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
2440 p_inventory_item_name varchar2,
2441 p_organization_code varchar2,
2442 x_return_status OUT NOCOPY VARCHAR2
2443 )is
2444 l_target_item_rec INV_Item_GRP.Item_Rec_Type;
2445 x_bom_header_rec BOM_BO_PUB.BOM_Head_Rec_Type;
2446 x_bom_revision_tbl BOM_BO_PUB.BOM_Revision_Tbl_Type;
2447 x_bom_component_tbl BOM_BO_PUB.BOM_Comps_Tbl_Type;
2448 x_bom_ref_designator_tbl BOM_BO_PUB.BOM_Ref_Designator_Tbl_Type;
2449 x_bom_sub_component_tbl BOM_BO_PUB.BOM_Sub_Component_Tbl_Type;
2450 x_bom_return_status VARCHAR2(1);
2451 x_bom_msg_count NUMBER;
2452 x_bom_msg_list Error_Handler.Error_Tbl_Type;
2453
2454 begin
2455 l_target_item_rec.item_number := p_inventory_item_name;
2456 l_target_item_rec.organization_code := p_organization_code;
2457
2458 EAM_ACTIVITY_PUB.create_bom_header(
2459 p_target_item_rec => l_target_item_rec,
2460 --p_source_org_id IN NUMBER,
2461 --p_source_activity_id IN NUMBER, -- inventory_item_id
2462
2463 --p_material_copy_option IN NUMBER,
2464
2465 x_bom_header_rec => x_bom_header_rec,
2466 x_bom_revision_tbl => x_bom_revision_tbl,
2467 x_bom_component_tbl => x_bom_component_tbl,
2468 x_bom_ref_designator_tbl => x_bom_ref_designator_tbl,
2469 x_bom_sub_component_tbl => x_bom_sub_component_tbl ,
2470 x_bom_return_status => x_bom_return_status ,
2471 x_bom_msg_count => x_bom_msg_count ,
2472 x_bom_msg_list => x_bom_msg_list
2473 );
2474
2475 x_return_status := x_bom_return_status;
2476 end create_bom_header_form;
2477
2478
2479 PROCEDURE Create_Activity_With_Template(
2480 --p_api_version IN NUMBER ,
2481 --p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE ,
2482 --p_commit IN VARCHAR2 := FND_API.G_FALSE ,
2483 --p_validation_level IN NUMBER :=
2484 -- FND_API.G_VALID_LEVEL_FULL ,
2485 x_return_status OUT NOCOPY VARCHAR2 ,
2486 --x_msg_count OUT NUMBER ,
2487 --x_msg_data OUT VARCHAR2 ,
2488
2489 p_organization_id IN NUMBER := NULL,
2490 p_organization_code IN NUMBER := NULL,
2491 p_asset_activity IN VARCHAR2,
2492 p_segment1 IN VARCHAR2,
2493 p_segment2 IN VARCHAR2,
2494 p_segment3 IN VARCHAR2,
2495 p_segment4 IN VARCHAR2,
2496 p_segment5 IN VARCHAR2,
2497 p_segment6 IN VARCHAR2,
2498 p_segment7 IN VARCHAR2,
2499 p_segment8 IN VARCHAR2,
2500 p_segment9 IN VARCHAR2,
2501 p_segment10 IN VARCHAR2,
2502 p_segment11 IN VARCHAR2,
2503 p_segment12 IN VARCHAR2,
2504 p_segment13 IN VARCHAR2,
2505 p_segment14 IN VARCHAR2,
2506 p_segment15 IN VARCHAR2,
2507 p_segment16 IN VARCHAR2,
2508 p_segment17 IN VARCHAR2,
2509 p_segment18 IN VARCHAR2,
2510 p_segment19 IN VARCHAR2,
2511 p_segment20 IN VARCHAR2,
2512 p_description IN VARCHAR2,
2513 p_template_id IN NUMBER := NULL,
2514 p_template_name IN VARCHAR2 := NULL,
2515 p_activity_type_code IN VARCHAR2 := NULL,
2516 p_activity_cause_code IN VARCHAR2 := NULL,
2517 p_shutdown_type_code IN VARCHAR2 := NULL,
2518 p_notification_req_flag IN VARCHAR2 := NULL,
2519 p_activity_source_code IN VARCHAR2 := NULL
2520
2521 --x_curr_item_rec OUT INV_Item_GRP.Item_Rec_Type,
2522 --x_curr_item_return_status OUT VARCHAR2,
2523 --x_curr_item_error_tbl OUT INV_Item_GRP.Error_Tbl_Type,
2524 --x_master_item_rec OUT INV_Item_GRP.Item_Rec_Type,
2525 --x_master_item_return_status OUT VARCHAR2,
2526 --x_master_item_error_tbl OUT INV_Item_GRP.Error_Tbl_Type
2527 )is
2528 l_asset_activity INV_Item_GRP.Item_rec_type;
2529
2530 l_api_name CONSTANT VARCHAR2(30) := 'Create_Activity_With_Template';
2531 l_api_version CONSTANT NUMBER := 1.0;
2532 l_init_msg_list CONSTANT VARCHAR2(1) := FND_API.G_FALSE ;
2533 l_commit CONSTANT VARCHAR2(1) := FND_API.G_TRUE ;
2534 l_validation_level NUMBER := FND_API.G_VALID_LEVEL_FULL;
2535
2536 l_x_curr_item_rec INV_Item_GRP.Item_rec_type;
2537 l_x_curr_item_return_status VARCHAR2(1);
2538 l_x_curr_item_error_tbl INV_Item_GRP.Error_tbl_type;
2539
2540 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
2541 l_x_master_item_return_status VARCHAR2(1);
2542 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
2543 l_msg_count number;
2544 l_msg_data varchar2(20000);
2545 begin
2546
2547
2548 -- ============================================================
2549 EAM_ActivityUtilities_PVT.Open_Debug_Session;
2550
2551 create_activity_with_template(
2552 p_api_version => l_api_version,
2553 p_init_msg_list => l_init_msg_list,
2554 p_commit => l_commit,
2555 p_validation_level => l_validation_level,
2556 x_return_status => x_return_status,
2557 x_msg_count => l_msg_count,
2558 x_msg_data => l_msg_data,
2559 p_organization_id => p_organization_id,
2560 p_organization_code => p_organization_code,
2561 p_asset_activity => p_asset_activity,
2562 p_segment1 => p_segment1,
2563 p_segment2 => p_segment2,
2564 p_segment3 => p_segment3,
2565 p_segment4 => p_segment4,
2566 p_segment5 => p_segment5,
2567 p_segment6 => p_segment6,
2568 p_segment7 => p_segment7,
2569 p_segment8 => p_segment8,
2570 p_segment9 => p_segment9,
2571 p_segment10 => p_segment10,
2572 p_segment11 => p_segment11,
2573 p_segment12 => p_segment12,
2574 p_segment13 => p_segment13,
2575 p_segment14 => p_segment14,
2576 p_segment15 => p_segment15,
2577 p_segment16 => p_segment16,
2578 p_segment17 => p_segment17,
2579 p_segment18 => p_segment18,
2580 p_segment19 => p_segment19,
2581 p_segment20 => p_segment20,
2582 p_description => p_description,
2583 p_template_id => p_template_id,
2584 p_template_name => p_template_name,
2585 p_activity_type_code => p_activity_type_code,
2586 p_activity_cause_code => p_activity_cause_code,
2587 p_shutdown_type_code => p_shutdown_type_code,
2588 p_notification_req_flag => p_notification_req_flag,
2589 p_activity_source_code => p_activity_source_code,
2590 x_curr_item_rec => l_x_curr_item_rec,
2591 x_curr_item_return_status => l_x_curr_item_return_status,
2592 x_curr_item_error_tbl => l_x_curr_item_error_tbl,
2593 x_master_item_rec => l_x_master_item_rec,
2594 x_master_item_return_status => l_x_master_item_return_status,
2595 x_master_item_error_tbl => l_x_master_item_error_tbl
2596 );
2597
2598 if (l_x_master_item_return_status = fnd_api.g_ret_sts_success AND l_x_curr_item_return_status = fnd_api.g_ret_sts_success) then
2599 commit;
2600 end if;
2601
2602 /*if x_curr_item_return_status = FND_API.G_RET_STS_SUCCESS AND x_master_item_return_status = FND_API.G_RET_STS_SUCCESS then
2603 commit;
2604 x_success := TRUE;
2605 else
2606 x_success := FALSE;
2607 end if;*/
2608
2609 -- ============================================================
2610 EAM_ActivityUtilities_PVT.Close_Debug_Session;
2611
2612 end create_activity_with_template;
2613
2614 PROCEDURE Create_Routing_Header(
2615 p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
2616
2617 x_rtg_header_rec OUT NOCOPY BOM_Rtg_Pub.Rtg_Header_Rec_Type,
2618 x_rtg_revision_tbl OUT NOCOPY BOM_Rtg_Pub.Rtg_Revision_Tbl_Type,
2619 x_operation_tbl OUT NOCOPY BOM_Rtg_Pub.Operation_Tbl_Type,
2620 x_op_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Resource_Tbl_Type,
2621 x_sub_resource_tbl OUT NOCOPY BOM_Rtg_Pub.Sub_Resource_Tbl_Type,
2622 x_op_network_tbl OUT NOCOPY BOM_Rtg_Pub.Op_Network_Tbl_Type,
2623 x_rtg_return_status OUT NOCOPY VARCHAR2,
2624 x_rtg_msg_count OUT NOCOPY NUMBER,
2625 x_rtg_msg_list OUT NOCOPY Error_Handler.Error_Tbl_Type
2626 )
2627
2628 IS
2629 --l_current_date CONSTANT DATE := sysdate;
2630 l_create_txn_type CONSTANT VARCHAR(10) := 'CREATE';
2631
2632 -- local variables for call the Routing Business Object API
2633 l_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
2634 l_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
2635 l_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
2636 l_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
2637
2638
2639 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
2640 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
2641 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
2642 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
2643 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
2644 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
2645 l_x_rtg_return_status VARCHAR2(1);
2646 l_x_rtg_msg_count NUMBER;
2647 l_x_rtg_msg_list Error_Handler.Error_Tbl_Type;
2648
2649
2650
2651 BEGIN
2652
2653 -- First initialize record fields to NULL
2654 -- l_rtg_header_rec := NULL;
2655 -- populate fields
2656 l_rtg_header_rec.Assembly_Item_Name := p_target_item_rec.Item_Number;
2657 l_rtg_header_rec.Organization_Code := p_target_item_rec.Organization_Code;
2658 l_rtg_header_rec.Transaction_Type := l_create_txn_type;
2659
2660 Error_Handler.initialize;
2661 -- log call to Process_Rtg API
2662 EAM_ActivityUtilities_PVT.Write_Debug('********** Calling BOM_RTG_PUB.Process_Rtg **********');
2663 BOM_RTG_PUB.Process_Rtg(
2664 p_rtg_header_rec => l_rtg_header_rec
2665 , p_operation_tbl => l_operation_tbl
2666 , p_op_resource_tbl => l_op_resource_tbl
2667 , p_op_network_tbl => l_op_network_tbl
2668 , x_rtg_header_rec => l_x_rtg_header_rec
2669 , x_rtg_revision_tbl => l_x_rtg_revision_tbl
2670 , x_operation_tbl => l_x_operation_tbl
2671 , x_op_resource_tbl => l_x_op_resource_tbl
2672 , x_sub_resource_tbl => l_x_sub_resource_tbl
2673 , x_op_network_tbl => l_x_op_network_tbl
2674 , x_return_status => l_x_rtg_return_status
2675 , x_msg_count => l_x_rtg_msg_count
2676 );
2677 EAM_ActivityUtilities_PVT.Write_Debug('********** Returned from BOM_RTG_PUB.Process_Rtg **********');
2678
2679 -- Assign outputs.
2680 x_rtg_header_rec := l_x_rtg_header_rec;
2681 x_rtg_revision_tbl := l_x_rtg_revision_tbl;
2682 x_operation_tbl := l_x_operation_tbl;
2683 x_op_resource_tbl := l_x_op_resource_tbl;
2684 x_sub_resource_tbl := l_x_sub_resource_tbl;
2685 x_op_network_tbl := l_x_op_network_tbl;
2686 x_rtg_return_status := l_x_rtg_return_status;
2687 x_rtg_msg_count := l_x_rtg_msg_count;
2688 Error_Handler.Get_Message_List(l_x_rtg_msg_list);
2689 x_rtg_msg_list := l_x_rtg_msg_list;
2690
2691
2692 END Create_Routing_Header;
2693
2694 procedure create_routing_header_form(
2695 --p_target_item_rec IN INV_Item_GRP.Item_Rec_Type,
2696 p_inventory_item_name varchar2,
2697 p_organization_code varchar2,
2698 x_return_status OUT NOCOPY VARCHAR2
2699 )is
2700 l_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
2701 l_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
2702 l_operation_tbl_index BINARY_INTEGER;
2703 l_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
2704 l_op_resource_tbl_index BINARY_INTEGER;
2705 l_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
2706 l_op_network_tbl_index BINARY_INTEGER;
2707
2708 l_x_rtg_header_rec BOM_RTG_PUB.Rtg_Header_Rec_Type;
2709 l_x_rtg_revision_tbl BOM_RTG_PUB.Rtg_Revision_Tbl_Type;
2710 l_x_operation_tbl BOM_RTG_PUB.Operation_Tbl_Type;
2711 l_x_op_resource_tbl BOM_RTG_PUB.Op_Resource_Tbl_Type;
2712 l_x_sub_resource_tbl BOM_RTG_PUB.Sub_Resource_Tbl_Type;
2713 l_x_op_network_tbl BOM_RTG_PUB.Op_Network_Tbl_Type;
2714 l_x_rtg_return_status VARCHAR2(1);
2715 l_x_rtg_msg_count NUMBER;
2716 l_x_rtg_msg_list Error_Handler.Error_Tbl_Type;
2717
2718 l_target_item_rec INV_Item_GRP.Item_Rec_Type;
2719
2720 begin
2721 l_target_item_rec.item_number := p_inventory_item_name;
2722 l_target_item_rec.organization_code := p_organization_code;
2723
2724 EAM_ACTIVITY_PUB.create_routing_header(
2725 p_target_item_rec => l_target_item_rec,
2726
2727
2728 x_rtg_header_rec => l_x_rtg_header_rec,
2729 x_rtg_revision_tbl => l_x_rtg_revision_tbl,
2730 x_operation_tbl => l_x_operation_tbl,
2731 x_op_resource_tbl => l_x_op_resource_tbl,
2732 x_sub_resource_tbl => l_x_sub_resource_tbl,
2733 x_op_network_tbl => l_x_op_network_tbl,
2734 x_rtg_return_status => l_x_rtg_return_status,
2735 x_rtg_msg_count => l_x_rtg_msg_count,
2736 x_rtg_msg_list => l_x_rtg_msg_list
2737 );
2738
2739 x_return_status := l_x_rtg_return_status;
2740
2741 --commit;
2742 end create_routing_header_form;
2743
2744
2745 -- From Saurabh
2746 -- package body
2747 -- wrapper API used to call Copy_Activity procedure from form
2748 procedure Copy_Activity(
2749 p_api_version IN NUMBER ,
2750 p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE ,
2751 p_commit IN VARCHAR2 := FND_API.G_FALSE ,
2752 p_validation_level IN NUMBER :=
2753 FND_API.G_VALID_LEVEL_FULL ,
2754 x_return_status OUT NOCOPY VARCHAR2 ,
2755 x_msg_count OUT NOCOPY NUMBER ,
2756 x_msg_data OUT NOCOPY VARCHAR2 ,
2757
2758 p_activity_item_name in varchar2,
2759 p_segment1 IN VARCHAR2,
2760 p_segment2 IN VARCHAR2,
2761 p_segment3 IN VARCHAR2,
2762 p_segment4 IN VARCHAR2,
2763 p_segment5 IN VARCHAR2,
2764 p_segment6 IN VARCHAR2,
2765 p_segment7 IN VARCHAR2,
2766 p_segment8 IN VARCHAR2,
2767 p_segment9 IN VARCHAR2,
2768 p_segment10 IN VARCHAR2,
2769 p_segment11 IN VARCHAR2,
2770 p_segment12 IN VARCHAR2,
2771 p_segment13 IN VARCHAR2,
2772 p_segment14 IN VARCHAR2,
2773 p_segment15 IN VARCHAR2,
2774 p_segment16 IN VARCHAR2,
2775 p_segment17 IN VARCHAR2,
2776 p_segment18 IN VARCHAR2,
2777 p_segment19 IN VARCHAR2,
2778 p_segment20 IN VARCHAR2,
2779 p_activity_org_id in number,
2780 p_activity_description in varchar2,
2781
2782 p_template_id IN NUMBER := NULL,
2783 p_template_name IN VARCHAR2 := NULL,
2784 p_activity_type_code IN VARCHAR2 := NULL,
2785 p_activity_cause_code IN VARCHAR2 := NULL,
2786 p_shutdown_type_code IN VARCHAR2 := NULL,
2787 p_notification_req_flag IN VARCHAR2 := NULL,
2788 p_activity_source_code IN VARCHAR2 := NULL,
2789
2790 -- source Activity
2791 p_source_org_id IN NUMBER,
2792 p_source_activity_id IN NUMBER, -- inventory_item_id
2793 p_bom_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
2794 p_routing_copy_option IN NUMBER := 2, -- 1 (NONE) or 2 (ALL)
2795 p_association_copy_option IN NUMBER := 2 -- 1 (NONE) or 2 (ALL)
2796
2797 )
2798 is
2799 l_asset_activity INV_Item_GRP.Item_Rec_Type;
2800 l_x_curr_item_rec INV_Item_GRP.Item_Rec_Type;
2801 l_x_curr_item_return_status VARCHAR2(1);
2802 l_x_curr_item_error_tbl INV_Item_GRP.Error_Tbl_Type;
2803 l_x_master_item_rec INV_Item_GRP.Item_Rec_Type;
2804 l_x_master_item_return_status VARCHAR2(1);
2805 l_x_master_item_error_tbl INV_Item_GRP.Error_Tbl_Type;
2806
2807 l_x_assoc_return_status VARCHAR2(1);
2808 l_x_assoc_msg_count NUMBER;
2809 l_x_assoc_msg_data VARCHAR2(20000);
2810 l_x_act_num_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
2811 l_x_activity_association_tbl EAM_Activity_PUB.Activity_Association_Tbl_Type;
2812 begin
2813
2814 EAM_ActivityUtilities_PVT.Open_Debug_Session;
2815
2816 -- Set up Item Number. Use segments if specified.
2817 IF p_segment1 IS NOT NULL OR
2818 p_segment2 IS NOT NULL OR
2819 p_segment3 IS NOT NULL OR
2820 p_segment4 IS NOT NULL OR
2821 p_segment5 IS NOT NULL OR
2822 p_segment6 IS NOT NULL OR
2823 p_segment7 IS NOT NULL OR
2824 p_segment8 IS NOT NULL OR
2825 p_segment9 IS NOT NULL OR
2826 p_segment10 IS NOT NULL OR
2827 p_segment11 IS NOT NULL OR
2828 p_segment12 IS NOT NULL OR
2829 p_segment13 IS NOT NULL OR
2830 p_segment14 IS NOT NULL OR
2831 p_segment15 IS NOT NULL OR
2832 p_segment16 IS NOT NULL OR
2833 p_segment17 IS NOT NULL OR
2834 p_segment18 IS NOT NULL OR
2835 p_segment19 IS NOT NULL OR
2836 p_segment20 IS NOT NULL
2837 THEN
2838 l_asset_activity.Segment1 := p_segment1;
2839 l_asset_activity.Segment2 := p_segment2;
2840 l_asset_activity.Segment3 := p_segment3;
2841 l_asset_activity.Segment4 := p_segment4;
2842 l_asset_activity.Segment5 := p_segment5;
2843 l_asset_activity.Segment6 := p_segment6;
2844 l_asset_activity.Segment7 := p_segment7;
2845 l_asset_activity.Segment8 := p_segment8;
2846 l_asset_activity.Segment9 := p_segment9;
2847 l_asset_activity.Segment10 := p_segment10;
2848 l_asset_activity.Segment11 := p_segment11;
2849 l_asset_activity.Segment12 := p_segment12;
2850 l_asset_activity.Segment13 := p_segment13;
2851 l_asset_activity.Segment14 := p_segment14;
2852 l_asset_activity.Segment15 := p_segment15;
2853 l_asset_activity.Segment16 := p_segment16;
2854 l_asset_activity.Segment17 := p_segment17;
2855 l_asset_activity.Segment18 := p_segment18;
2856 l_asset_activity.Segment19 := p_segment19;
2857 l_asset_activity.Segment20 := p_segment20;
2858 ELSE
2859 l_asset_activity.item_number := p_activity_item_name;
2860 END IF;
2861
2862 l_asset_activity.organization_id := p_activity_org_id;
2863 l_asset_activity.description := p_activity_description;
2864
2865 EAM_ACTIVITY_PUB.Copy_Activity(
2866 p_api_version => p_api_version,
2867 p_init_msg_list => p_init_msg_list,
2868 p_commit => p_commit,
2869 p_validation_level => p_validation_level,
2870 x_return_status => x_return_status,
2871 x_msg_count => x_msg_count,
2872 x_msg_data => x_msg_data,
2873
2874 -- target activity, need to set org, item name, description
2875 p_asset_activity => l_asset_activity,
2876
2877
2878 p_template_id => p_template_id,
2879 p_template_name => p_template_name,
2880 p_activity_type_code => p_activity_type_code,
2881 p_activity_cause_code => p_activity_cause_code,
2882 p_shutdown_type_code => p_shutdown_type_code,
2883 p_notification_req_flag => p_notification_req_flag,
2884 p_activity_source_code => p_activity_source_code,
2885
2886 -- source Activity
2887 p_source_org_id => p_source_org_id ,
2888 p_source_activity_id => p_source_activity_id , -- inventory_item_id
2889 -- source BOM
2890 p_source_alt_bom_designator => NULL,
2891 p_source_bom_rev_date => sysdate,
2892 -- source Routing
2893 p_source_alt_rtg_designator => NULL,
2894 p_source_rtg_rev_date => sysdate,
2895
2896 p_bom_copy_option => p_bom_copy_option , -- 1 (NONE) or 2 (ALL)
2897 p_routing_copy_option => p_routing_copy_option , -- 1 (NONE) or 2 (ALL)
2898 p_association_copy_option => p_association_copy_option , -- 1 (NONE) or 2 (ALL)
2899
2900 x_curr_item_rec =>l_x_curr_item_rec ,
2901 x_curr_item_return_status => l_x_curr_item_return_status ,
2902 x_curr_item_error_tbl => l_x_curr_item_error_tbl,
2903 x_master_item_rec => l_x_master_item_rec ,
2904 x_master_item_return_status => l_x_master_item_return_status ,
2905 x_master_item_error_tbl => l_x_master_item_error_tbl ,
2906
2907 x_assoc_return_status => l_x_assoc_return_status ,
2908 x_assoc_msg_count => l_x_assoc_msg_count ,
2909 x_assoc_msg_data => l_x_assoc_msg_data ,
2910 x_act_num_association_tbl => l_x_act_num_association_tbl ,
2911 x_activity_association_tbl => l_x_activity_association_tbl
2912 );
2913
2914 EAM_ActivityUtilities_PVT.Close_Debug_Session;
2915
2916 end Copy_Activity;
2917
2918
2919 /* Procedure to assign the activity to the current maintenance organization */
2920
2921 PROCEDURE Activity_org_assign
2922 ( p_api_version IN NUMBER ,
2923 x_return_status OUT NOCOPY VARCHAR2 ,
2924 x_msg_count OUT NOCOPY NUMBER ,
2925 x_msg_data OUT NOCOPY VARCHAR2 ,
2926 p_org_id IN NUMBER,
2927 p_activity_id IN NUMBER -- inventory_item_id
2928 )IS
2929
2930 l_api_name CONSTANT VARCHAR2(30) := 'Activity_org_assign';
2931 l_api_version CONSTANT NUMBER := 1.0;
2932 l_full_name CONSTANT VARCHAR2(60) := g_pkg_name || '.' || l_api_name;
2933
2934
2935 l_master_organization_id NUMBER;
2936 l_item_rec INV_Item_GRP.Item_rec_type;
2937
2938 -- local variables for calling INV_Item_GRP package
2939
2940 l_x_item_rec INV_Item_GRP.Item_rec_type;
2941 l_x_return_status VARCHAR2(1);
2942 l_x_error_tbl INV_Item_GRP.Error_tbl_type;
2943 l_x_master_item_rec INV_Item_GRP.Item_rec_type;
2944 l_x_master_item_return_status VARCHAR2(1);
2945 l_x_master_item_error_tbl INV_Item_GRP.Error_tbl_type;
2946 l_error_string VARCHAR2(2000);
2947 l_msg_string VARCHAR2(200);
2948
2949
2950 BEGIN
2951 SAVEPOINT EAM_Activity_PUB;
2952 -- Standard call to check for call compatibility.
2953 --EAM_ActivityUtilities_PVT.Open_Debug_Session;
2954 IF NOT fnd_api.compatible_api_call(
2955 l_api_version
2956 ,p_api_version
2957 ,l_api_name
2958 ,g_pkg_name) THEN
2959 RAISE fnd_api.g_exc_unexpected_error;
2960 END IF;
2961 /*
2962 -- Initialize message list if p_init_msg_list is set to TRUE.
2963 IF fnd_api.to_boolean(p_init_msg_list) THEN
2964 fnd_msg_pub.initialize;
2965 END IF;
2966 */
2967 -- Get master org id
2968 l_master_organization_id := EAM_ActivityUtilities_PVT.Get_Master_Org_Id(p_org_id);
2969 EAM_ActivityUtilities_PVT.Write_Debug('l_master_organization_id=' || l_master_organization_id);
2970
2971 BEGIN
2972 -- check if the activity exists in Master organization
2973 SELECT segment1, segment2, segment3, segment4, segment5, segment6, segment7,
2974 segment8, segment9, segment10, segment11, segment12, segment13, segment14,
2975 segment15, segment16, segment17, segment18, segment19, segment20, description,
2976 eam_activity_type_code, eam_activity_cause_code, eam_activity_source_code,
2977 eam_act_notification_flag, eam_act_shutdown_status, eam_item_type
2978 INTO l_item_rec.segment1, l_item_rec.segment2, l_item_rec.segment3, l_item_rec.segment4,
2979 l_item_rec.segment5, l_item_rec.segment6, l_item_rec.segment7, l_item_rec.segment8,
2980 l_item_rec.segment9, l_item_rec.segment10, l_item_rec.segment11, l_item_rec.segment12,
2981 l_item_rec.segment13, l_item_rec.segment14, l_item_rec.segment15, l_item_rec.segment16,
2982 l_item_rec.segment17, l_item_rec.segment18, l_item_rec.segment19, l_item_rec.segment20,
2983 l_item_rec.description, l_item_rec.eam_activity_type_code,
2984 l_item_rec.eam_activity_cause_code, l_item_rec.eam_activity_source_code,
2985 l_item_rec.eam_act_notification_flag, l_item_rec.eam_act_shutdown_status,
2986 l_item_rec.eam_item_type
2987 FROM mtl_system_items_b
2988 WHERE organization_id = l_master_organization_id
2989 AND inventory_item_id = p_activity_id;
2990
2991 -- Validate org id and org code
2992 EAM_ActivityUtilities_PVT.Validate_Organization(
2993 p_organization_id => p_org_id,
2994 p_organization_code => l_item_rec.organization_code,
2995 x_return_status => l_x_return_status,
2996 x_organization_id => l_item_rec.organization_id,
2997 x_organization_code => l_item_rec.organization_code
2998 );
2999
3000 IF l_x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3001
3002 RAISE FND_API.G_EXC_ERROR;
3003 END IF;
3004
3005 -- ============================================================
3006 EAM_ActivityUtilities_PVT.Write_Debug('-------- Beginning EAM_Activity_PUB.Activity_org_assign --------');
3007
3008
3009 IF l_item_rec.inventory_item_flag IS NULL OR
3010 l_item_rec.inventory_item_flag = fnd_api.g_MISS_CHAR THEN
3011 l_item_rec.inventory_item_flag := 'Y';
3012 END IF;
3013 /*
3014 IF l_item_rec.expense_account IS NULL OR l_item_rec.expense_account = fnd_api.g_MISS_NUM THEN
3015 -- In the Master Item form, Expense Account defaulted from Master Org. So should use Master Org.
3016 l_item_rec.expense_account := EAM_ActivityUtilities_PVT.Get_Expense_Account_Id(l_master_organization_id);
3017 END IF;
3018 -- Check that expense_account is not null
3019 IF l_item_rec.expense_account IS NULL OR l_item_rec.expense_account = fnd_api.g_MISS_NUM THEN
3020 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_EXPENSE_ACCOUNT_NULL');
3021 --FND_MESSAGE.SET_ENCODED('Please define the Expense Account for the Organization.');
3022 EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
3023
3024 RAISE FND_API.G_EXC_ERROR;
3025
3026 END IF;
3027
3028 */ -- commented for BUG# 5484686
3029 IF l_item_rec.bom_enabled_flag IS NULL OR
3030 l_item_rec.bom_enabled_flag = fnd_api.g_MISS_CHAR THEN
3031 l_item_rec.bom_enabled_flag := 'Y';
3032 END IF;
3033
3034 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> INV_Item_GRP.Create_Item INPUT Parameters >>>>>>>>>>>>>>>');
3035 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_item_rec);
3036
3037
3038 INV_Item_GRP.Create_Item
3039 (
3040 p_Item_rec => l_item_rec,
3041 p_Template_Id => 19,
3042 p_Template_Name => null,
3043 x_Item_rec => l_x_item_rec,
3044 x_return_status => l_x_return_status,
3045 x_Error_tbl => l_x_error_tbl
3046 );
3047 Get_Errors
3048 (
3049 p_item_error_tbl=>l_x_error_tbl,
3050 x_error_msg_old=>l_error_string,
3051 x_error_msg_new=>l_error_string
3052 );
3053
3054 -- log outputs
3055 EAM_ActivityUtilities_PVT.Write_Debug('l_x_return_status=' || l_x_return_status);
3056 EAM_ActivityUtilities_PVT.Write_Debug('Results of INV_Item_GRP.Create_Item >>>>>');
3057 EAM_ActivityUtilities_PVT.Log_Item_Error_Tbl(l_x_error_tbl);
3058 EAM_ActivityUtilities_PVT.Write_Debug('End of Results of INV_Item_GRP.Create_Item <<<<<');
3059 EAM_ActivityUtilities_PVT.Write_Debug('<<<<<<<<<<<<<<< INV_Item_GRP.Create_Item OUTPUT Parameters <<<<<<<<<<<<<<<');
3060 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_x_item_rec);
3061
3062 EXCEPTION
3063 WHEN NO_DATA_FOUND THEN
3064 -- There is no record in master org... so create in both ...
3065 SELECT segment1, segment2, segment3, segment4, segment5, segment6, segment7,
3066 segment8, segment9, segment10, segment11, segment12, segment13, segment14,
3067 segment15, segment16, segment17, segment18, segment19, segment20, description,
3068 eam_activity_type_code, eam_activity_cause_code, eam_activity_source_code,
3069 eam_act_notification_flag, eam_act_shutdown_status, eam_item_type
3070 INTO l_item_rec.segment1, l_item_rec.segment2, l_item_rec.segment3, l_item_rec.segment4,
3071 l_item_rec.segment5, l_item_rec.segment6, l_item_rec.segment7, l_item_rec.segment8,
3072 l_item_rec.segment9, l_item_rec.segment10, l_item_rec.segment11, l_item_rec.segment12,
3073 l_item_rec.segment13, l_item_rec.segment14, l_item_rec.segment15, l_item_rec.segment16,
3074 l_item_rec.segment17, l_item_rec.segment18, l_item_rec.segment19, l_item_rec.segment20,
3075 l_item_rec.description, l_item_rec.eam_activity_type_code,
3076 l_item_rec.eam_activity_cause_code, l_item_rec.eam_activity_source_code,
3077 l_item_rec.eam_act_notification_flag, l_item_rec.eam_act_shutdown_status,
3078 l_item_rec.eam_item_type
3079 FROM mtl_system_items_b
3080 WHERE inventory_item_id = p_activity_id
3081 AND ROWNUM = 1;
3082
3083 l_item_rec.organization_id := p_org_id;
3084 EAM_ActivityUtilities_PVT.Write_Debug('Creating CURRENT Item...');
3085 EAM_ActivityUtilities_PVT.Write_Debug('>>>>>>>>>>>>>>> INV_Item_GRP.Create_Item INPUT Parameters >>>>>>>>>>>>>>>');
3086 EAM_ActivityUtilities_PVT.Log_Inv_Item_Rec(l_item_rec);
3087
3088 Create_Item(
3089 p_asset_activity => l_item_rec,
3090 p_template_id => 19,
3091 p_template_name => null,
3092 x_curr_item_rec => l_x_item_rec,
3093 x_curr_item_return_status => l_x_return_status,
3094 x_curr_item_error_tbl => l_x_error_tbl,
3095 x_master_item_rec => l_x_master_item_rec,
3096 x_master_item_return_status => l_x_master_item_return_status,
3097 x_master_item_error_tbl => l_x_master_item_error_tbl
3098 );
3099 Get_Errors
3100 (
3101 p_item_error_tbl=>l_x_master_item_error_tbl,
3102 x_error_msg_old=>l_error_string,
3103 x_error_msg_new=>l_error_string
3104 );
3105
3106 END;
3107
3108 -- Assign outputs
3109 x_return_status := l_x_return_status;
3110
3111 IF nvl(l_x_master_item_return_status, FND_API.G_RET_STS_SUCCESS) <> FND_API.G_RET_STS_SUCCESS THEN
3112 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_MASTER_FAILED');
3113 l_msg_string:=FND_MESSAGE.GET;
3114 --EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
3115 RAISE FND_API.G_EXC_ERROR;
3116
3117 END IF;
3118
3119
3120 IF l_x_return_status <> FND_API.G_RET_STS_SUCCESS THEN
3121 FND_MESSAGE.SET_NAME('EAM', 'EAM_ABO_CR_ACT_CURRENT_FAILED');
3122 l_msg_string:=FND_MESSAGE.GET;
3123 --EAM_ActivityUtilities_PVT.Add_Message(FND_MSG_PUB.G_MSG_LVL_ERROR);
3124 -- commented for BUG# 5484686
3125 RAISE FND_API.G_EXC_ERROR;
3126 END IF;
3127
3128
3129 -- Standard call to get message count and if count is 1, get message info.
3130 --fnd_msg_pub.count_and_get(p_count => x_msg_count
3131 -- ,p_data => x_msg_data);
3132 -- commented for BUG# 5484686
3133
3134 EAM_ActivityUtilities_PVT.Write_Debug('-------- Finished EAM_Activity_PUB.Activity_org_assign --------');
3135
3136 EXCEPTION
3137 WHEN fnd_api.g_exc_error THEN
3138 ROLLBACK TO EAM_Activity_PUB;
3139 x_return_status := fnd_api.g_ret_sts_error;
3140
3141 -- fnd_msg_pub.count_and_get(p_count => x_msg_count
3142 -- ,p_data => x_msg_data);
3143 -- commented for BUG# 5484686
3144 WHEN fnd_api.g_exc_unexpected_error THEN
3145 ROLLBACK TO EAM_Activity_PUB;
3146 x_return_status := fnd_api.g_ret_sts_unexp_error;
3147
3148 --fnd_msg_pub.count_and_get(p_count => x_msg_count
3149 -- ,p_data => x_msg_data);
3150 -- commented for BUG# 5484686
3151 WHEN OTHERS THEN
3152 ROLLBACK TO EAM_Activity_PUB;
3153 x_return_status := fnd_api.g_ret_sts_unexp_error;
3154 /* IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error) THEN
3155 fnd_msg_pub.add_exc_msg(g_pkg_name, l_api_name);
3156 END IF;*/
3157 -- fnd_msg_pub.count_and_get(p_count => x_msg_count
3158 -- ,p_data => x_msg_data);
3159 -- commented for BUG# 5484686
3160
3161 x_msg_data:=l_msg_string||l_error_string;
3162
3163 END Activity_org_assign;
3164
3165 END EAM_Activity_PUB;