[Home] [Help]
PACKAGE BODY: APPS.WSH_CONTAINER_PUB
Source
1 PACKAGE BODY WSH_CONTAINER_PUB AS
2 /* $Header: WSHCOPBB.pls 120.0 2005/05/26 17:16:10 appldev noship $ */
3
4 -- standard global constants
5 G_PKG_NAME CONSTANT VARCHAR2(30) := 'WSH_CONTAINER_PUB';
6 p_message_type CONSTANT VARCHAR2(1) := 'E';
7
8
9 ------------------------------------------------------------------------------
10 -- Procedure: Create_Containers
11 --
12 -- Parameters: 1) container_item_id (key flex id)
13 -- 2) container_item_name (concatinated name for container item)
14 -- 3) container_item_seg (flex field seg array for item name)
15 -- 4) organization_id - organization id for container
16 -- 5) organization_code - organization code for container
17 -- 6) name_prefix - container name prefix
18 -- 7) name_suffix - container name suffix
19 -- 8) base_number - starting number for numeric portion of name
20 -- 9) num_digits - precision for number of digits
21 -- 10) quantity - number of containers
22 -- 11) container_name - container name if creating 1 container
23 -- 12) table of container ids - out table of ids
24 -- 13) other standard parameters
25 --
26 -- Description: This procedure takes in a container item id or container item
27 -- name and other necessary parameters to create one or more containers and
28 -- creates the required containers. It returns a table of container instance
29 -- ids (delivery detail ids) along with the standard out parameters.
30 ------------------------------------------------------------------------------
31
32 PROCEDURE Create_Containers (
33 -- Standard parameters
34 p_api_version IN NUMBER,
35 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
36 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
37 p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL,
38 x_return_status OUT NOCOPY VARCHAR2,
39 x_msg_count OUT NOCOPY NUMBER,
40 x_msg_data OUT NOCOPY VARCHAR2,
41
42 -- program specific parameters
43 p_container_item_id IN NUMBER,
44 p_container_item_name IN VARCHAR2,
45 p_container_item_seg IN FND_FLEX_EXT.SegmentArray,
46 p_organization_id IN NUMBER,
47 p_organization_code IN VARCHAR2,
48 p_name_prefix IN VARCHAR2,
49 p_name_suffix IN VARCHAR2,
50 p_base_number IN NUMBER,
51 p_num_digits IN NUMBER,
52 p_quantity IN NUMBER,
53 p_container_name IN VARCHAR2,
54
55 -- program specific out parameters
56 x_container_ids OUT NOCOPY WSH_UTIL_CORE.ID_TAB_TYPE,
57 p_ucc_128_suffix_flag IN NUMBER
58 ) IS
59
60
61 -- Standard call to check for call compatibility
62 l_api_version CONSTANT NUMBER := 1.0;
63 l_api_name CONSTANT VARCHAR2(30):= 'Create_Containers';
64
65
66 l_msg_summary VARCHAR2(32000) := NULL;
67 l_msg_details VARCHAR2(32000) := NULL;
68 l_detail_rec wsh_glbl_var_strct_grp.detailInRecType;
69 l_detail_tab wsh_glbl_var_strct_grp.delivery_details_attr_tbl_type;
70 l_out_rec wsh_glbl_var_strct_grp.detailOutRecType;
71 l_lpn_ids WSH_UTIL_CORE.Id_Tab_Type;
72
73 --
74 l_num_errors NUMBER := 0;
75 l_num_warning NUMBER := 0;
76 --
77 l_debug_on BOOLEAN;
78 --
79 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' ||
80 'Create_Containers';
81
82 WSH_INVALID_QTY EXCEPTION;
83 WSH_FAIL_CONT_CREATION EXCEPTION;
84
85
86 BEGIN
87
88 -- Standard begin of API savepoint
89 --
90 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
91 --
92 IF l_debug_on IS NULL
93 THEN
94 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
95 END IF;
96 --
97 SAVEPOINT Create_Containers_SP;
98
99 IF l_debug_on THEN
100 WSH_DEBUG_SV.push(l_module_name);
101 --
102 WSH_DEBUG_SV.log(l_module_name,'p_commit', p_commit);
103 WSH_DEBUG_SV.log(l_module_name,'p_container_name',p_container_name);
104 WSH_DEBUG_SV.log(l_module_name,'p_validation_level',
105 p_validation_level);
106 WSH_DEBUG_SV.log(l_module_name,'p_container_item_id',
107 p_container_item_id);
108 WSH_DEBUG_SV.log(l_module_name,'p_container_item_name',
112 WSH_DEBUG_SV.log(l_module_name,'p_organization_id',
109 p_container_item_name);
110 WSH_DEBUG_SV.log(l_module_name,'p_organization_code',
111 p_organization_code);
113 p_organization_id);
114 WSH_DEBUG_SV.log(l_module_name,'p_name_prefix',p_name_prefix);
115 WSH_DEBUG_SV.log(l_module_name,'p_name_suffix',p_name_suffix);
116 WSH_DEBUG_SV.log(l_module_name,'p_base_number',p_base_number);
117 WSH_DEBUG_SV.log(l_module_name,'p_num_digits',p_num_digits);
118 WSH_DEBUG_SV.log(l_module_name,'p_api_version',p_api_version);
119 WSH_DEBUG_SV.log(l_module_name,'p_init_msg_list',p_init_msg_list);
120 WSH_DEBUG_SV.log(l_module_name,'p_quantity',p_quantity);
121 WSH_DEBUG_SV.log(l_module_name,'ucc_128_suffix_flag',
122 p_ucc_128_suffix_flag);
123 END IF;
124
125
126 IF NOT FND_API.compatible_api_call (
127 l_api_version,
128 p_api_version,
129 l_api_name,
130 G_PKG_NAME) THEN
131 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
132 END IF;
133
134 -- Check p_init_msg_list
135 IF FND_API.to_boolean(p_init_msg_list) THEN
136 FND_MSG_PUB.initialize;
137 END IF;
138
139 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
140
141 -- validate quantity
142
143 IF p_quantity <= 0 THEN
144 RAISE WSH_INVALID_QTY;
145 END IF;
146
147
148
149 l_detail_rec.caller := 'WSH_PUB';
150 l_detail_rec.action_code := 'CREATE';
151 l_detail_rec.container_item_id := p_container_item_id;
152 l_detail_rec.container_item_name := p_container_item_name;
153 l_detail_rec.container_item_seg := p_container_item_seg;
154 l_detail_rec.organization_id := p_organization_id;
155 l_detail_rec.organization_code := p_organization_code;
156 l_detail_rec.name_prefix := p_name_prefix;
157 l_detail_rec.name_suffix := p_name_suffix;
158 l_detail_rec.base_number := p_base_number;
159 l_detail_rec.num_digits := p_num_digits;
160 l_detail_rec.quantity := p_quantity;
161 l_detail_rec.container_name := p_container_name;
162 l_detail_rec.ucc_128_suffix_flag := p_ucc_128_suffix_flag;
163 l_detail_rec.lpn_ids := l_lpn_ids;
164
165 wsh_interface_grp.Create_Update_Delivery_Detail(
166 p_api_version_number => 1.0,
167 p_init_msg_list => FND_API.G_FALSE,
168 p_commit => FND_API.G_FALSE,
169 x_return_status => x_return_status,
170 x_msg_count => x_msg_count,
171 x_msg_data => x_msg_data,
172 p_detail_info_tab => l_detail_tab,
173 p_IN_rec => l_detail_rec,
174 x_OUT_rec => l_out_rec);
175
176
177 wsh_util_core.api_post_call(
178 p_return_status =>x_return_status,
179 x_num_warnings =>l_num_warning,
180 x_num_errors =>l_num_errors,
181 p_msg_data =>x_msg_data,
182 p_raise_error_flag => FALSE);
183
184 IF x_return_status IN (wsh_util_core.g_ret_sts_error, wsh_util_core.G_RET_STS_UNEXP_ERROR ) THEN
185 raise WSH_FAIL_CONT_CREATION;
186 END IF;
187
188 IF l_out_rec.detail_ids.COUNT > 0 THEN
189 x_container_ids := l_out_rec.detail_ids;
190 END IF;
191
192 IF FND_API.TO_BOOLEAN(p_commit) THEN
193 -- dbms_output.put_line('commit');
194 COMMIT;
195 END IF;
196
197 --
198 FND_MSG_PUB.Count_And_Get
199 (
200 p_count => x_msg_count,
201 p_data => x_msg_data,
202 p_encoded => FND_API.G_FALSE
203 );
204 --
205
206 IF l_debug_on THEN
207 WSH_DEBUG_SV.pop(l_module_name);
208 END IF;
209
210 EXCEPTION
211
212 WHEN WSH_INVALID_QTY then
213 rollback to Create_Containers_SP;
214 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
215 fnd_message.set_name('WSH', 'WSH_CONT_INVALID_QTY');
216 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
217 --
218 FND_MSG_PUB.Count_And_Get
219 (
220 p_count => x_msg_count,
221 p_data => x_msg_data,
222 p_encoded => FND_API.G_FALSE
223 );
224 --
225 IF l_debug_on THEN
226 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INVALID_QTY');
227 END IF;
228
229 WHEN WSH_FAIL_CONT_CREATION then
230 rollback to Create_Containers_SP;
231 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
232 fnd_message.set_name('WSH', 'WSH_CONT_CREATE_ERROR');
233 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
234 --
235 FND_MSG_PUB.Count_And_Get
236 (
237 p_count => x_msg_count,
238 p_data => x_msg_data,
239 p_encoded => FND_API.G_FALSE
240 );
241 --
242 IF l_debug_on THEN
243 WSH_DEBUG_SV.pop(l_module_name,
247 WHEN OTHERS then
244 'EXCEPTION:WSH_FAIL_CONT_CREATION');
245 END IF;
246
248 rollback to Create_Containers_SP;
249 wsh_util_core.default_handler('WSH_CONTAINER_PUB.Create_Containers',l_module_name);
250 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
251
252 --
253 FND_MSG_PUB.Count_And_Get
254 (
255 p_count => x_msg_count,
256 p_data => x_msg_data,
257 p_encoded => FND_API.G_FALSE
258 );
259 --
260 IF l_debug_on THEN
261 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
262 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
263
264 END IF;
265
266
267 END Create_Containers;
268
269
270 PROCEDURE populate_record(
271 p_in_rec IN WSH_DELIVERY_DETAILS_PUB.CHANGEDATTRIBUTERECTYPE
272 , p_outrec OUT NOCOPY
273 wsh_glbl_var_strct_grp.Delivery_Details_Rec_Type)
274 IS
275 --
276 l_debug_on BOOLEAN;
277 --
278 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' ||
279 'populate_record';
280
281 BEGIN
282
283 --
284 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
285 --
286 IF l_debug_on IS NULL
287 THEN
288 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
289 END IF;
290 --
291 IF l_debug_on THEN
292 WSH_DEBUG_SV.push(l_module_name);
293 END IF;
294 p_outrec.delivery_detail_id := p_in_rec.delivery_detail_id;
295 p_outrec.source_code := FND_API.G_MISS_CHAR;
296 p_outrec.source_header_id := p_in_rec.source_header_id;
297 p_outrec.source_line_id := p_in_rec.source_line_id;
298 p_outrec.customer_id := FND_API.G_MISS_NUM;
299 p_outrec.sold_to_contact_id := p_in_rec.sold_to_contact_id;
300 p_outrec.inventory_item_id := FND_API.G_MISS_NUM;
301 p_outrec.item_description := FND_API.G_MISS_CHAR;
302 p_outrec.hazard_class_id := FND_API.G_MISS_NUM;
303 p_outrec.country_of_origin := FND_API.G_MISS_CHAR;
304 p_outrec.classification := FND_API.G_MISS_CHAR;
305 p_outrec.ship_from_location_id := FND_API.G_MISS_NUM;
306 p_outrec.ship_to_location_id := FND_API.G_MISS_NUM;
307 p_outrec.ship_to_contact_id := p_in_rec.ship_to_contact_id;
308 p_outrec.ship_to_site_use_id := FND_API.G_MISS_NUM;
309 p_outrec.deliver_to_location_id := FND_API.G_MISS_NUM;
310 p_outrec.deliver_to_contact_id := p_in_rec.deliver_to_contact_id;
311 p_outrec.deliver_to_site_use_id := FND_API.G_MISS_NUM;
312 p_outrec.intmed_ship_to_location_id := FND_API.G_MISS_NUM;
313 p_outrec.intmed_ship_to_contact_id := p_in_rec.intmed_ship_to_contact_id;
314 p_outrec.hold_code := FND_API.G_MISS_CHAR;
315 p_outrec.ship_tolerance_above := p_in_rec.ship_tolerance_above;
316 p_outrec.ship_tolerance_below := p_in_rec.ship_tolerance_below;
317 p_outrec.requested_quantity := FND_API.G_MISS_NUM;
318 p_outrec.shipped_quantity := p_in_rec.shipped_quantity;
319 p_outrec.delivered_quantity := FND_API.G_MISS_NUM;
320 p_outrec.requested_quantity_uom := FND_API.G_MISS_CHAR;
321 p_outrec.subinventory := p_in_rec.subinventory;
322 p_outrec.revision := p_in_rec.revision;
323 p_outrec.lot_number := p_in_rec.lot_number;
324 p_outrec.customer_requested_lot_flag := p_in_rec.customer_requested_lot_flag;
325 p_outrec.serial_number := p_in_rec.serial_number;
326 p_outrec.locator_id := p_in_rec.locator_id;
327 p_outrec.date_requested := p_in_rec.date_requested;
328 p_outrec.date_scheduled := p_in_rec.date_scheduled;
329 p_outrec.master_container_item_id := p_in_rec.master_container_item_id;
330 p_outrec.detail_container_item_id := p_in_rec.detail_container_item_id;
331 p_outrec.load_seq_number := FND_API.G_MISS_NUM;
332 p_outrec.ship_method_code := FND_API.G_MISS_CHAR;
333 p_outrec.carrier_id := p_in_rec.carrier_id;
334 p_outrec.freight_terms_code := p_in_rec.freight_terms_code;
335 p_outrec.shipment_priority_code := p_in_rec.shipment_priority_code;
336 p_outrec.fob_code := p_in_rec.fob_code;
337 p_outrec.customer_item_id := FND_API.G_MISS_NUM;
338 p_outrec.dep_plan_required_flag := p_in_rec.dep_plan_required_flag;
339 p_outrec.customer_prod_seq := p_in_rec.customer_prod_seq;
340 p_outrec.customer_dock_code := p_in_rec.customer_dock_code;
341 p_outrec.cust_model_serial_number := FND_API.G_MISS_CHAR;
342 p_outrec.customer_job := FND_API.G_MISS_CHAR;
343 p_outrec.customer_production_line := FND_API.G_MISS_CHAR;
344 p_outrec.net_weight := p_in_rec.net_weight;
345 p_outrec.weight_uom_code := p_in_rec.weight_uom_code;
346 p_outrec.volume := p_in_rec.volume;
347 -- J: W/V Changes
348 p_outrec.filled_volume := p_in_rec.filled_volume;
349 p_outrec.volume_uom_code := p_in_rec.volume_uom_code;
350 -- Bug 3723831 :tp attributes can be updated via public API. So assigning the values of p_in_rec to the same.
351 p_outrec.tp_attribute_category:= p_in_rec.tp_attribute_category;
352 p_outrec.tp_attribute1 := p_in_rec.tp_attribute1;
353 p_outrec.tp_attribute2 := p_in_rec.tp_attribute2;
354 p_outrec.tp_attribute3 := p_in_rec.tp_attribute3;
355 p_outrec.tp_attribute4 := p_in_rec.tp_attribute4;
356 p_outrec.tp_attribute5 := p_in_rec.tp_attribute5;
357 p_outrec.tp_attribute6 := p_in_rec.tp_attribute6;
361 p_outrec.tp_attribute10 := p_in_rec.tp_attribute10;
358 p_outrec.tp_attribute7 := p_in_rec.tp_attribute7;
359 p_outrec.tp_attribute8 := p_in_rec.tp_attribute8;
360 p_outrec.tp_attribute9 := p_in_rec.tp_attribute9;
362 p_outrec.tp_attribute11 := p_in_rec.tp_attribute11;
363 p_outrec.tp_attribute12 := p_in_rec.tp_attribute12;
364 p_outrec.tp_attribute13 := p_in_rec.tp_attribute13;
365 p_outrec.tp_attribute14 := p_in_rec.tp_attribute14;
366 p_outrec.tp_attribute15 := p_in_rec.tp_attribute15;
367 p_outrec.attribute_category := FND_API.G_MISS_CHAR;
368 p_outrec.attribute1 := p_in_rec.attribute1;
369 p_outrec.attribute2 := p_in_rec.attribute2;
370 p_outrec.attribute3 := p_in_rec.attribute3;
371 p_outrec.attribute4 := p_in_rec.attribute4;
372 p_outrec.attribute5 := p_in_rec.attribute5;
373 p_outrec.attribute6 := p_in_rec.attribute6;
374 p_outrec.attribute7 := p_in_rec.attribute7;
375 p_outrec.attribute8 := p_in_rec.attribute8;
376 p_outrec.attribute9 := p_in_rec.attribute9;
377 p_outrec.attribute10 := p_in_rec.attribute10;
378 p_outrec.attribute11 := p_in_rec.attribute11;
379 p_outrec.attribute12 := p_in_rec.attribute12;
380 p_outrec.attribute13 := p_in_rec.attribute13;
381 p_outrec.attribute14 := p_in_rec.attribute14;
382 p_outrec.attribute15 := p_in_rec.attribute15;
383 p_outrec.created_by := FND_API.G_MISS_NUM;
384 p_outrec.creation_date := FND_API.G_MISS_DATE;
385 p_outrec.last_update_date := FND_API.G_MISS_DATE;
386 p_outrec.last_update_login := FND_API.G_MISS_NUM;
387 p_outrec.last_updated_by := FND_API.G_MISS_NUM;
388 p_outrec.program_application_id := FND_API.G_MISS_NUM;
389 p_outrec.program_id := FND_API.G_MISS_NUM;
390 p_outrec.program_update_date := FND_API.G_MISS_DATE;
391 p_outrec.request_id := FND_API.G_MISS_NUM;
392 p_outrec.mvt_stat_status := FND_API.G_MISS_CHAR;
393 p_outrec.released_flag := FND_API.G_MISS_CHAR;
394 p_outrec.organization_id := FND_API.G_MISS_NUM;
395 p_outrec.transaction_temp_id := FND_API.G_MISS_NUM;
396 p_outrec.ship_set_id := p_in_rec.ship_set_id;
397 p_outrec.arrival_set_id := p_in_rec.arrival_set_id;
398 p_outrec.ship_model_complete_flag := p_in_rec.ship_model_complete_flag;
399 p_outrec.top_model_line_id := p_in_rec.top_model_line_id;
400 p_outrec.source_header_number := FND_API.G_MISS_CHAR;
401 p_outrec.source_header_type_id := FND_API.G_MISS_NUM;
402 p_outrec.source_header_type_name := FND_API.G_MISS_CHAR;
403 p_outrec.cust_po_number := p_in_rec.cust_po_number;
404 p_outrec.ato_line_id := p_in_rec.ato_line_id;
405 p_outrec.src_requested_quantity := FND_API.G_MISS_NUM;
406 p_outrec.src_requested_quantity_uom := FND_API.G_MISS_CHAR;
407 p_outrec.move_order_line_id := FND_API.G_MISS_NUM;
408 p_outrec.cancelled_quantity := FND_API.G_MISS_NUM;
409 p_outrec.quality_control_quantity := FND_API.G_MISS_NUM;
410 p_outrec.cycle_count_quantity := p_in_rec.cycle_count_quantity;
411 p_outrec.tracking_number := p_in_rec.tracking_number;
412 p_outrec.movement_id := FND_API.G_MISS_NUM;
413 p_outrec.shipping_instructions := p_in_rec.shipping_instructions;
414 p_outrec.packing_instructions := p_in_rec.packing_instructions;
415 p_outrec.project_id := FND_API.G_MISS_NUM;
416 p_outrec.task_id := FND_API.G_MISS_NUM;
417 p_outrec.org_id := FND_API.G_MISS_NUM;
418 p_outrec.oe_interfaced_flag := FND_API.G_MISS_CHAR;
419 p_outrec.split_from_detail_id := FND_API.G_MISS_NUM;
420 p_outrec.inv_interfaced_flag := FND_API.G_MISS_CHAR;
421 p_outrec.source_line_number := FND_API.G_MISS_CHAR;
422 p_outrec.inspection_flag := FND_API.G_MISS_CHAR;
423 p_outrec.released_status := p_in_rec.released_status;
424 p_outrec.container_flag := p_in_rec.container_flag;
425 p_outrec.container_type_code := FND_API.G_MISS_CHAR;
426 p_outrec.container_name := p_in_rec.container_name;
427 p_outrec.fill_percent := FND_API.G_MISS_NUM;
428 p_outrec.gross_weight := p_in_rec.gross_weight;
429 p_outrec.master_serial_number := FND_API.G_MISS_CHAR;
430 p_outrec.maximum_load_weight := FND_API.G_MISS_NUM;
431 p_outrec.maximum_volume := FND_API.G_MISS_NUM;
432 p_outrec.minimum_fill_percent := FND_API.G_MISS_NUM;
433 p_outrec.seal_code := FND_API.G_MISS_CHAR;
434 p_outrec.unit_number := FND_API.G_MISS_CHAR;
435 p_outrec.unit_price := FND_API.G_MISS_NUM;
436 p_outrec.currency_code := FND_API.G_MISS_CHAR;
437 p_outrec.freight_class_cat_id := FND_API.G_MISS_NUM;
438 p_outrec.commodity_code_cat_id := FND_API.G_MISS_NUM;
439 p_outrec.preferred_grade := p_in_rec.preferred_grade;
440 p_outrec.src_requested_quantity2 := FND_API.G_MISS_NUM;
441 p_outrec.src_requested_quantity_uom2 := FND_API.G_MISS_CHAR;
442 p_outrec.requested_quantity2 := FND_API.G_MISS_NUM;
443 p_outrec.shipped_quantity2 := FND_API.G_MISS_NUM;
444 p_outrec.delivered_quantity2 := FND_API.G_MISS_NUM;
445 p_outrec.cancelled_quantity2 := FND_API.G_MISS_NUM;
446 p_outrec.quality_control_quantity2 := FND_API.G_MISS_NUM;
447 p_outrec.cycle_count_quantity2 := FND_API.G_MISS_NUM;
448 p_outrec.requested_quantity_uom2 := FND_API.G_MISS_CHAR;
449 -- HW OPMCONV - No need for sublot_number
450 -- p_outrec.sublot_number := p_in_rec.sublot_number;
451 p_outrec.lpn_id := FND_API.G_MISS_NUM;
455 p_outrec.picked_quantity := FND_API.G_MISS_NUM;
452 p_outrec.pickable_flag := FND_API.G_MISS_CHAR;
453 p_outrec.original_subinventory := FND_API.G_MISS_CHAR;
454 p_outrec.to_serial_number := FND_API.G_MISS_CHAR;
456 p_outrec.picked_quantity2 := FND_API.G_MISS_NUM;
457 p_outrec.received_quantity := FND_API.G_MISS_NUM;
458 p_outrec.received_quantity2 := FND_API.G_MISS_NUM;
459 p_outrec.source_line_set_id := FND_API.G_MISS_NUM;
460
461
462 IF l_debug_on THEN
463 WSH_DEBUG_SV.pop(l_module_name);
464 END IF;
465
466 EXCEPTION
467
468 WHEN OTHERS THEN
469 wsh_util_core.default_handler('WSH_CONTAINER_PUB.populate_record',l_module_name) ;
470 IF l_debug_on THEN
471 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
472 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
473
474 END IF;
475
476 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
477
478 END populate_record;
479
480
481
482 ------------------------------------------------------------------------------
483 -- Procedure: Update_Container
484 --
485 -- Parameters: 1) container_rec - container record of type
486 -- wsh_delivery_details_pub.changedattributerectype
487 -- 2) other standard parameters
488 --
489 -- Description: This procedure takes in a record of container attributes that
490 -- contains the name and delivery detail id of container to update the
491 -- container record in WSH_DELIVERY_DETAILS with the attributes input in the
492 -- container rec type. The API validates the container name and detail id and
493 -- calls the wsh_delivery_details_pub.update_shipping_attributes public API.
494 ------------------------------------------------------------------------------
495
496 PROCEDURE Update_Container (
497 -- Standard parameters
498 p_api_version IN NUMBER,
499 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
500 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
501 p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL,
502 x_return_status OUT NOCOPY VARCHAR2,
503 x_msg_count OUT NOCOPY NUMBER,
504 x_msg_data OUT NOCOPY VARCHAR2,
505
506 -- program specific parameters
507 p_container_rec IN WSH_DELIVERY_DETAILS_PUB.CHANGEDATTRIBUTERECTYPE
508
509 ) IS
510
511 -- Standard call to check for call compatibility
512 l_api_version CONSTANT NUMBER := 1.0;
513 l_api_name CONSTANT VARCHAR2(30):= 'Update_Containers';
514
515
516 l_msg_summary VARCHAR2(32000) := NULL;
517 l_msg_details VARCHAR2(32000) := NULL;
518 l_detail_rec wsh_glbl_var_strct_grp.detailInRecType;
519 l_detail_info_tab wsh_glbl_var_strct_grp.delivery_details_attr_tbl_type;
520 l_detail_info_rec wsh_glbl_var_strct_grp.Delivery_Details_Rec_Type;
521 l_out_rec wsh_glbl_var_strct_grp.detailOutRecType;
522 l_lpn_ids WSH_UTIL_CORE.Id_Tab_Type;
523
524 --
525 l_num_errors NUMBER := 0;
526 l_num_warning NUMBER := 0;
527 --
528 l_debug_on BOOLEAN;
529 --
530 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' ||
531 'Update_Container';
532
533 WSH_INVALID_CONT_UPDATE EXCEPTION;
534 WSH_FAIL_CONT_UPDATE EXCEPTION;
535
536
537 BEGIN
538
539 -- Standard begin of API savepoint
540 --
541 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
542 --
543 IF l_debug_on IS NULL
544 THEN
545 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
546 END IF;
547 --
548 SAVEPOINT Update_Containers_SP;
549
550 IF l_debug_on THEN
551 WSH_DEBUG_SV.push(l_module_name);
552 WSH_DEBUG_SV.log(l_module_name,'p_commit', p_commit);
553 WSH_DEBUG_SV.log(l_module_name,'p_validation_level',
554 p_validation_level);
555 WSH_DEBUG_SV.log(l_module_name,'p_init_msg_list', p_init_msg_list);
556 WSH_DEBUG_SV.log(l_module_name,'p_api_version', p_api_version);
557 WSH_DEBUG_SV.log(l_module_name,'delivery_detail_id',
558 p_container_rec.delivery_detail_id);
559 END IF;
560
561 IF NOT FND_API.compatible_api_call (
562 l_api_version,
563 p_api_version,
564 l_api_name,
565 G_PKG_NAME) THEN
566 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
567 END IF;
568
569 -- Check p_init_msg_list
570 IF FND_API.to_boolean(p_init_msg_list) THEN
571 FND_MSG_PUB.initialize;
572 END IF;
573
574 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
575
576 -- check to make sure that the container record being input for update
577 -- does not have null delivery detail ids or container name or the
578 -- container flag is null or 'N'
579
580
581 -- Now check for valid container based on the information in the
582 -- container rec.
583
584
585 populate_record(p_container_rec,l_detail_info_rec);
586 l_detail_info_tab(1) := l_detail_info_rec;
587 l_detail_rec.caller := 'WSH_PUB';
588 l_detail_rec.action_code := 'UPDATE';
589 l_detail_rec.lpn_ids := l_lpn_ids;
590 --
591 wsh_interface_grp.Create_Update_Delivery_Detail(
595 x_return_status => x_return_status,
592 p_api_version_number => 1.0,
593 p_init_msg_list => FND_API.G_FALSE,
594 p_commit => FND_API.G_FALSE,
596 x_msg_count => x_msg_count,
597 x_msg_data => x_msg_data,
598 p_detail_info_tab => l_detail_info_tab,
599 p_IN_rec => l_detail_rec,
600 x_OUT_rec => l_out_rec);
601
602 wsh_util_core.api_post_call(
603 p_return_status =>x_return_status,
604 x_num_warnings =>l_num_warning,
605 x_num_errors =>l_num_errors,
606 p_msg_data =>x_msg_data,
607 p_raise_error_flag => FALSE);
608
609 IF x_return_status IN (wsh_util_core.g_ret_sts_error, wsh_util_core.G_RET_STS_UNEXP_ERROR ) THEN
610 raise WSH_FAIL_CONT_UPDATE;
611 END IF;
612
613 IF FND_API.TO_BOOLEAN(p_commit) THEN
614 -- dbms_output.put_line('commit');
615 COMMIT;
616 END IF;
617
618 --
619 FND_MSG_PUB.Count_And_Get
620 (
621 p_count => x_msg_count,
622 p_data => x_msg_data,
623 p_encoded => FND_API.G_FALSE
624 );
625 --
626
627
628 IF l_debug_on THEN
629 WSH_DEBUG_SV.pop(l_module_name);
630 END IF;
631
632
633 EXCEPTION
634
635 WHEN WSH_INVALID_CONT_UPDATE then
636 rollback to Update_Containers_SP;
637 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
638 fnd_message.set_name('WSH', 'WSH_CONT_INVALID_UPDATE');
639 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
640 --
641 FND_MSG_PUB.Count_And_Get
642 (
643 p_count => x_msg_count,
644 p_data => x_msg_data,
645 p_encoded => FND_API.G_FALSE
646 );
647 --
648
649 IF l_debug_on THEN
650 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INVALID_CONT_UPDATE');
651 END IF;
652
653 WHEN WSH_FAIL_CONT_UPDATE then
654 rollback to Update_Containers_SP;
655 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
656 fnd_message.set_name('WSH', 'WSH_CONT_UPDATE_ERROR');
657 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
658 --
659 FND_MSG_PUB.Count_And_Get
660 (
661 p_count => x_msg_count,
662 p_data => x_msg_data,
663 p_encoded => FND_API.G_FALSE
664 );
665 --
666 IF l_debug_on THEN
667 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_FAIL_CONT_UPDATE');
668 END IF;
669
670 WHEN OTHERS then
671 rollback to Update_Containers_SP;
672 wsh_util_core.default_handler('WSH_CONTAINER_PUB.Update_Container',l_module_name);
673 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
674 --
675 FND_MSG_PUB.Count_And_Get
676 (
677 p_count => x_msg_count,
678 p_data => x_msg_data,
679 p_encoded => FND_API.G_FALSE
680 );
681 --
682
683 IF l_debug_on THEN
684 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
685 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
686
687 END IF;
688 END Update_Container;
689
690
691 ------------------------------------------------------------------------------
692 -- Procedure: Auto_Pack
693 --
694 -- Parameters: 1) entity_tab - table of ids of either lines or containers or
695 -- deliveries that need to be autopacked
696 -- 2) entity_type - type of entity id contained in the entity_tab
697 -- that needs to be autopacked ('L' - lines,
698 -- 'C' - containers OR 'D' - deliveries)
699 -- 3) group_id_tab - table of ids (numbers that determine
700 -- the grouping of lines for packing into containers)
701 -- 4) container_instance_tab - table of delivery detail ids of
702 -- containers that are created during the autopacking
703 -- 5) pack cont flag - a 'Y' or 'N' value to determine whether to
704 -- to autopack the detail containers that are created into
705 -- parent containers.
706 -- 6) other standard parameters
707 --
708 -- Description: This procedure takes in a table of ids of either delivery lines
709 -- or container or deliveries and autopacks the lines/containers/deliveries
710 -- into detail containers. The grouping id table is used only if the input
711 -- table of entities are lines or containers only. The packing of lines and
712 -- containers into parent containers is determined by the grouping id for each
713 -- line/container. If the grouping id table is not input, the API determines
714 -- the grouping ids for the lines/containers based on the grouping attributes
715 -- of the lines/containers. The lines/containers are then autopacked into
716 -- detail containers and the detail containers are packed into parent/master
720 -- output table of ids will contain both the detail and parent containers'
717 -- containers based on whether the pack cont flag is set to 'Y' or 'N'. The
718 -- API returns a table of container instance ids created during the autopacking
719 -- operation. If the detail containers are packed into parent containers, the
721 -- delivery detail ids.
722 ------------------------------------------------------------------------------
723
724 PROCEDURE Auto_Pack (
725 -- Standard parameters
726 p_api_version IN NUMBER,
727 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
728 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
729 p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL,
730 x_return_status OUT NOCOPY VARCHAR2,
731 x_msg_count OUT NOCOPY NUMBER,
732 x_msg_data OUT NOCOPY VARCHAR2,
733
734 -- program specific parameters
735 p_entity_tab IN WSH_UTIL_CORE.ID_TAB_TYPE,
736 p_entity_type IN VARCHAR2,
737 p_group_id_tab IN WSH_UTIL_CORE.ID_TAB_TYPE,
738 p_pack_cont_flag IN VARCHAR2,
739
740 -- program specific out parameters
741 x_cont_inst_tab OUT NOCOPY WSH_UTIL_CORE.ID_TAB_TYPE
742
743 ) IS
744
745 -- Standard call to check for call compatibility
746 l_api_version CONSTANT NUMBER := 1.0;
747 l_api_name CONSTANT VARCHAR2(30):= 'Update_Containers';
748
749 l_return_status VARCHAR2(30) := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
750
751 l_entity_tab WSH_UTIL_CORE.ID_TAB_TYPE;
752
753 l_det_cnt NUMBER := 0;
754 l_count NUMBER;
755
756 l_msg_summary VARCHAR2(32000) := NULL;
757 l_msg_details VARCHAR2(32000) := NULL;
758
759 l_rec_att_tab wsh_glbl_var_strct_grp.delivery_details_attr_tbl_type;
760 l_action_prms wsh_glbl_var_strct_grp.dd_action_parameters_rec_type;
761 l_action_prms_dl WSH_DELIVERIES_GRP.action_parameters_rectype;
762 l_action_out_rec wsh_glbl_var_strct_grp.dd_action_out_rec_type;
763
764 l_delivery_out_rec WSH_DELIVERIES_GRP.Delivery_Action_Out_Rec_Type;
765 l_del_rec_attr wsh_new_deliveries_pvt.Delivery_Rec_type;
766 --
767 l_num_errors NUMBER := 0;
768 l_num_warning NUMBER := 0;
769 l_debug_on BOOLEAN;
770 --
771 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' ||
772 'AUTO_PACK';
773
774
775 WSH_INVALID_DETAIL EXCEPTION;
776 WSH_INVALID_DELIVERY EXCEPTION;
777 WSH_INVALID_ENTITY_TYPE EXCEPTION;
778 WSH_FAIL_AUTOPACK EXCEPTION;
779
780 BEGIN
781 -- Standard begin of API savepoint
782 --
783 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
784 --
785 IF l_debug_on IS NULL
786 THEN
787 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
788 END IF;
789 --
790 SAVEPOINT Autopack_SP;
791 IF l_debug_on THEN
792 WSH_DEBUG_SV.push(l_module_name);
793 WSH_DEBUG_SV.log(l_module_name,'p_commit', p_commit);
794 WSH_DEBUG_SV.log(l_module_name,'p_validation_level',
795 p_validation_level);
796 WSH_DEBUG_SV.log(l_module_name,'p_init_msg_list', p_init_msg_list);
797 WSH_DEBUG_SV.log(l_module_name,'p_api_version', p_api_version);
798 WSH_DEBUG_SV.log(l_module_name,'p_entity_type', p_entity_type);
799 WSH_DEBUG_SV.log(l_module_name,'p_pack_cont_flag',p_pack_cont_flag);
800 END IF;
801
802 IF NOT FND_API.compatible_api_call (
803 l_api_version,
804 p_api_version,
805 l_api_name,
806 G_PKG_NAME) THEN
807 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
808 END IF;
809
810 -- Check p_init_msg_list
811 IF FND_API.to_boolean(p_init_msg_list) THEN
812 FND_MSG_PUB.initialize;
813 END IF;
814
815 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
816
817 -- first decide which entity it is by checking entity type..
818 -- based on entity type validate all the entity ids..
819
820
821 l_count := p_entity_tab.count;
822 FOR i IN 1..l_count LOOP
823 IF p_entity_tab(i) IS NOT NULL THEN
824 l_det_cnt := l_det_cnt + 1;
825 l_entity_tab(l_det_cnt) := p_entity_tab(i);
826 ELSE
827 IF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
828 l_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
829 --bms what is the use of this l_return_status?
830 END IF;
831 END IF;
832
833 END LOOP;
834
835 IF p_entity_type = 'L' OR p_entity_type = 'C' THEN
836
837 IF l_entity_tab.count > 0 THEN
838
839 l_action_prms.caller := 'WSH_PUB';
840 IF p_pack_cont_flag = 'Y' THEN
841 l_action_prms.action_code := 'AUTO-PACK-MASTER';
842 ELSIF p_pack_cont_flag = 'N' THEN
843 l_action_prms.action_code := 'AUTO-PACK';
844 END IF;
845
846 wsh_interface_grp.Delivery_Detail_Action(
847 p_api_version_number => 1.0,
848 p_init_msg_list => FND_API.G_FALSE,
849 p_commit => FND_API.G_FALSE,
850 x_return_status =>x_return_status,
851 x_msg_count => x_msg_count,
852 x_msg_data => x_msg_data,
853 p_detail_id_tab =>l_entity_tab,
854 p_action_prms =>l_action_prms,
855 x_action_out_rec => l_action_out_rec);
856
857 wsh_util_core.api_post_call(
861 p_msg_data =>x_msg_data,
858 p_return_status =>x_return_status,
859 x_num_warnings =>l_num_warning,
860 x_num_errors =>l_num_errors,
862 p_raise_error_flag => FALSE);
863
864 IF x_return_status IN (wsh_util_core.g_ret_sts_error, wsh_util_core.G_RET_STS_UNEXP_ERROR ) THEN
865 raise WSH_FAIL_AUTOPACK;
866 END IF;
867
868 x_cont_inst_tab := l_action_out_rec.result_id_tab;
869 ELSE
870 RAISE WSH_INVALID_DETAIL;
871 END IF;
872
873 ELSIF p_entity_type = 'D' THEN
874 l_action_prms_dl.caller := 'WSH_PUB';
875 IF p_pack_cont_flag = 'Y' THEN
876 l_action_prms_dl.action_code := 'AUTO-PACK-MASTER';
877 ELSIF p_pack_cont_flag = 'N' THEN
878 l_action_prms_dl.action_code := 'AUTO-PACK';
879 END IF;
880
881 IF l_entity_tab.count = 0 THEN
882 RAISE WSH_INVALID_DELIVERY;
883 END IF;
884
885 wsh_interface_grp.Delivery_Action(
886 p_api_version_number => 1.0,
887 p_init_msg_list => FND_API.G_FALSE,
888 p_commit => FND_API.G_FALSE,
889 p_action_prms => l_action_prms_dl,
890 p_delivery_id_tab => l_entity_tab,
891 x_delivery_out_rec => l_delivery_out_rec,
892 x_return_status => x_return_status,
893 x_msg_count => x_msg_count,
894 x_msg_data => x_msg_data
895 );
896
897 wsh_util_core.api_post_call(
898 p_return_status =>x_return_status,
899 x_num_warnings =>l_num_warning,
900 x_num_errors =>l_num_errors,
901 p_msg_data =>x_msg_data,
902 p_raise_error_flag => FALSE);
903
904 IF x_return_status IN (wsh_util_core.g_ret_sts_error, wsh_util_core.G_RET_STS_UNEXP_ERROR ) THEN
905 raise WSH_FAIL_AUTOPACK;
906 END IF;
907
908 x_cont_inst_tab := l_delivery_out_rec.result_id_tab;
909
910
911 ELSE
912 RAISE WSH_INVALID_ENTITY_TYPE;
913 END IF;
914
915 IF FND_API.TO_BOOLEAN(p_commit) THEN
916 -- dbms_output.put_line('commit');
917 COMMIT;
918 END IF;
919
920 --
921 FND_MSG_PUB.Count_And_Get
922 (
923 p_count => x_msg_count,
924 p_data => x_msg_data,
925 p_encoded => FND_API.G_FALSE
926 );
927 --
928
929 IF l_debug_on THEN
930 WSH_DEBUG_SV.pop(l_module_name);
931 END IF;
932
933 EXCEPTION
934
935 WHEN WSH_INVALID_DETAIL then
936 rollback to Autopack_SP;
937 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
938 fnd_message.set_name('WSH', 'WSH_DET_INVALID_DETAIL');
939 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
940 --
941 FND_MSG_PUB.Count_And_Get
942 (
943 p_count => x_msg_count,
944 p_data => x_msg_data,
945 p_encoded => FND_API.G_FALSE
946 );
947 --
948 IF l_debug_on THEN
949 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INVALID_DETAIL');
950 END IF;
951
952 WHEN WSH_INVALID_DELIVERY then
953 rollback to Autopack_SP;
954 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
955 fnd_message.set_name('WSH', 'WSH_DET_INVALID_DEL');
956 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
957 --
958 FND_MSG_PUB.Count_And_Get
959 (
960 p_count => x_msg_count,
961 p_data => x_msg_data,
962 p_encoded => FND_API.G_FALSE
963 );
964 --
965
966 IF l_debug_on THEN
967 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INVALID_DELIVERY');
968 END IF;
969 WHEN WSH_FAIL_AUTOPACK then
970 rollback to Autopack_SP;
971 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
972 fnd_message.set_name('WSH', 'WSH_AUTOPACK_ERROR');
973 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
974 --
975 FND_MSG_PUB.Count_And_Get
976 (
977 p_count => x_msg_count,
978 p_data => x_msg_data,
979 p_encoded => FND_API.G_FALSE
980 );
981 --
982 IF l_debug_on THEN
983 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_FAIL_AUTOPACK');
984 END IF;
985
986 WHEN WSH_INVALID_ENTITY_TYPE then
987 rollback to Autopack_SP;
988 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
989 fnd_message.set_name('WSH', 'WSH_PUB_CONT_TYPE_ERR');
990 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
991 --
992 FND_MSG_PUB.Count_And_Get
993 (
994 p_count => x_msg_count,
995 p_data => x_msg_data,
996 p_encoded => FND_API.G_FALSE
997 );
998 --
999
1000 IF l_debug_on THEN
1004 rollback to Autopack_SP;
1001 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:WSH_INVALID_ENTITY_TYPE');
1002 END IF;
1003 WHEN OTHERS then
1005 wsh_util_core.default_handler('WSH_CONTAINER_PUB.Auto_Pack',l_module_name);
1006 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1007
1008 --
1009 FND_MSG_PUB.Count_And_Get
1010 (
1011 p_count => x_msg_count,
1012 p_data => x_msg_data,
1013 p_encoded => FND_API.G_FALSE
1014 );
1015 --
1016 IF l_debug_on THEN
1017 WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1018 WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1019
1020 END IF;
1021
1022 END Auto_Pack;
1023
1024
1025 ------------------------------------------------------------------------------
1026 -- Procedure: Container_Actions
1027 --
1028 -- Parameters: 1) detail_tab - input table of delivery detail ids
1029 -- 2) container_instance_id - delivery detail id of parent
1030 -- container that is being packed.
1031 -- 3) container_name - container name if id is not known
1032 -- 4) container_flag - 'Y' or 'N' depending on whether to unpack
1033 -- or not. ('Y' is unpack)
1034 -- 5) delivery_flag - 'Y' or 'N' if container needs to be
1035 -- unassigned from delivery. ('Y' if unassign from del)
1036 -- 6) delivery_id - delivery id to assign container to.
1037 -- 7) delivery_name - name of delivery that container is being
1038 -- assigned to.
1039 -- 8) action_code - action code 'Pack', 'Assign', 'Unpack' or
1040 -- 'Unassign' to specify what action to perform.
1041 -- 9) other standard parameters
1042 --
1043 -- Description: This procedure takes in a table of delivery detail ids and
1044 -- name and/or delivery detail id of container to pack. If the action code is
1045 -- is assign then delivery id and delivery name must be specified. The API
1046 -- determines what action to perform based on the action code and then calls
1047 -- appropriate private pack/assign/unpack/unassign API.
1048 -- The input table of ids could be lines or containers. The delivery lines and
1049 -- containers are separated from the input table and validated before the
1050 -- appropriate private APIs are called
1051 ------------------------------------------------------------------------------
1052
1053 PROCEDURE Container_Actions (
1054 -- Standard parameters
1055 p_api_version IN NUMBER,
1056 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
1057 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
1058 p_validation_level IN NUMBER DEFAULT FND_API.G_VALID_LEVEL_FULL,
1059 x_return_status OUT NOCOPY VARCHAR2,
1060 x_msg_count OUT NOCOPY NUMBER,
1061 x_msg_data OUT NOCOPY VARCHAR2,
1062
1063 -- program specific parameters
1064 p_detail_tab IN WSH_UTIL_CORE.ID_TAB_TYPE,
1065 p_container_name IN VARCHAR2 DEFAULT NULL,
1066 p_cont_instance_id IN NUMBER DEFAULT NULL,
1067 p_container_flag IN VARCHAR2 DEFAULT 'N',
1068 p_delivery_flag IN VARCHAR2 DEFAULT 'N',
1069 p_delivery_id IN NUMBER DEFAULT NULL,
1070 p_delivery_name IN VARCHAR2 DEFAULT NULL,
1071 p_action_code IN VARCHAR2
1072
1073 ) IS
1074
1075 -- Standard call to check for call compatibility
1076 l_api_version CONSTANT NUMBER := 1.0;
1077 l_api_name CONSTANT VARCHAR2(30):= 'Update_Containers';
1078
1079
1080 l_msg_summary VARCHAR2(32000) := NULL;
1081 l_msg_details VARCHAR2(32000) := NULL;
1082 l_action_prms wsh_glbl_var_strct_grp.dd_action_parameters_rec_type;
1083 l_num_errors NUMBER := 0;
1084 l_num_warning NUMBER := 0;
1085 l_action_out_rec wsh_glbl_var_strct_grp.dd_action_out_rec_type;
1086
1087 l_return_status VARCHAR2(1) := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1088 l_debug_on BOOLEAN;
1089 --
1090 l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' ||
1091 'Container_Actions';
1092
1093
1094 WSH_INVALID_DETAIL EXCEPTION;
1095
1096
1097 BEGIN
1098
1099 -- Standard begin of API savepoint
1100 --
1101 l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1102 --
1103 IF l_debug_on IS NULL
1104 THEN
1105 l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1106 END IF;
1107 --
1108 SAVEPOINT Container_Action_SP;
1109
1110 IF l_debug_on THEN
1111 wsh_debug_sv.push (l_module_name);
1112 wsh_debug_sv.log (l_module_name,'p_api_version', p_api_version);
1113 wsh_debug_sv.log (l_module_name,'p_init_msg_list', p_init_msg_list);
1114 wsh_debug_sv.log (l_module_name,'p_commit', p_commit);
1115 wsh_debug_sv.log (l_module_name,'p_validation_level', p_validation_level);
1116 wsh_debug_sv.log (l_module_name,'p_container_name', p_container_name);
1117 wsh_debug_sv.log (l_module_name,'p_cont_instance_id', p_cont_instance_id);
1118 wsh_debug_sv.log (l_module_name,'p_container_flag', p_container_flag);
1119 wsh_debug_sv.log (l_module_name,'p_delivery_flag', p_delivery_flag);
1120 wsh_debug_sv.log (l_module_name,'p_delivery_id', p_delivery_id);
1121 wsh_debug_sv.log (l_module_name,'p_delivery_name', p_delivery_name);
1122 wsh_debug_sv.log (l_module_name,'p_action_code', p_action_code);
1123 END IF;
1124
1125 IF NOT FND_API.compatible_api_call (
1126 l_api_version,
1127 p_api_version,
1128 l_api_name,
1129 G_PKG_NAME) THEN
1133 -- Check p_init_msg_list
1130 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1131 END IF;
1132
1134 IF FND_API.to_boolean(p_init_msg_list) THEN
1135 FND_MSG_PUB.initialize;
1136 END IF;
1137
1138 x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1139
1140 -- first decide which action to perform by checking action type..
1141 -- based on entity type validate all the entity ids..
1142
1143 IF p_detail_tab.COUNT = 0 THEN
1144 RAISE WSH_INVALID_DETAIL;
1145 END IF;
1146
1147 l_action_prms.caller := 'WSH_PUB';
1148 l_action_prms.Action_Code := UPPER(p_action_code);
1149 l_action_prms.container_name := p_container_name;
1150 l_action_prms.container_instance_id := p_cont_instance_id;
1151 l_action_prms.container_flag := p_container_flag;
1152 l_action_prms.delivery_flag := p_delivery_flag;
1153 l_action_prms.delivery_id := p_delivery_id;
1154 l_action_prms.delivery_name := p_delivery_name;
1155
1156
1157 wsh_interface_grp.Delivery_Detail_Action(
1158 p_api_version_number => 1.0,
1159 p_init_msg_list => FND_API.G_FALSE,
1160 p_commit => FND_API.G_FALSE,
1161 x_return_status =>l_return_status,
1162 x_msg_count => x_msg_count,
1163 x_msg_data => x_msg_data,
1164 p_detail_id_tab =>p_detail_tab,
1165 p_action_prms =>l_action_prms,
1166 x_action_out_rec => l_action_out_rec);
1167
1168
1169
1170 wsh_util_core.api_post_call(p_return_status =>l_return_status,
1171 x_num_warnings =>l_num_warning,
1172 x_num_errors =>l_num_errors);
1173
1174 x_return_status := l_return_status;
1175
1176 IF FND_API.TO_BOOLEAN(p_commit) THEN
1177 COMMIT;
1178 END IF;
1179
1180 --
1181 FND_MSG_PUB.Count_And_Get
1182 (
1183 p_count => x_msg_count,
1184 p_data => x_msg_data,
1185 p_encoded => FND_API.G_FALSE
1186 );
1187 --
1188
1189
1190 IF l_debug_on THEN
1191 WSH_DEBUG_SV.pop(l_module_name);
1192 END IF;
1193 EXCEPTION
1194
1195 WHEN WSH_INVALID_DETAIL then
1196 rollback to Container_Action_SP;
1197 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1198 fnd_message.set_name('WSH', 'WSH_DET_INVALID_DETAIL');
1199 WSH_UTIL_CORE.ADD_MESSAGE(x_return_status,l_module_name);
1200 --
1201 FND_MSG_PUB.Count_And_Get
1202 (
1203 p_count => x_msg_count,
1204 p_data => x_msg_data,
1205 p_encoded => FND_API.G_FALSE
1206 );
1207 --
1208
1209 IF l_debug_on THEN
1210 wsh_debug_sv.log (l_module_name,'EXCEPTION:WSH_INVALID_DETAIL');
1211 WSH_DEBUG_SV.pop(l_module_name);
1212 END IF;
1213
1214 WHEN FND_API.G_EXC_ERROR THEN
1215 rollback to Container_Action_SP;
1216 x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1217
1218 --
1219 FND_MSG_PUB.Count_And_Get
1220 (
1221 p_count => x_msg_count,
1222 p_data => x_msg_data,
1223 p_encoded => FND_API.G_FALSE
1224 );
1225 --
1226
1227 IF l_debug_on THEN
1228 wsh_debug_sv.log (l_module_name,'EXCEPTION:G_EXC_ERROR');
1229 WSH_DEBUG_SV.pop(l_module_name);
1230 END IF;
1231
1232
1233
1234 WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1235 rollback to Container_Action_SP;
1236 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1237 --
1238 FND_MSG_PUB.Count_And_Get
1239 (
1240 p_count => x_msg_count,
1241 p_data => x_msg_data,
1242 p_encoded => FND_API.G_FALSE
1243 );
1244 --
1245 IF l_debug_on THEN
1246 wsh_debug_sv.log (l_module_name,'EXCEPTION:G_RET_STS_UNEXP_ERROR');
1247 WSH_DEBUG_SV.pop(l_module_name);
1248 END IF;
1249
1250 WHEN WSH_UTIL_CORE.G_EXC_WARNING THEN
1251 x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1252 --
1253 FND_MSG_PUB.Count_And_Get
1254 (
1255 p_count => x_msg_count,
1256 p_data => x_msg_data,
1257 p_encoded => FND_API.G_FALSE
1258 );
1259 --
1260
1261 IF l_debug_on THEN
1262 wsh_debug_sv.log (l_module_name,'EXCEPTION:G_EXC_WARNING');
1263 WSH_DEBUG_SV.pop(l_module_name);
1264 END IF;
1265
1266 WHEN OTHERS then
1267 rollback to Container_Action_SP;
1268 wsh_util_core.default_handler('WSH_CONTAINER_PUB.Container_Actions');
1269 x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1270 --
1271 FND_MSG_PUB.Count_And_Get
1272 (
1273 p_count => x_msg_count,
1274 p_data => x_msg_data,
1275 p_encoded => FND_API.G_FALSE
1276 );
1277 --
1278 IF l_debug_on THEN
1279 wsh_debug_sv.log (l_module_name,'Others',substr(sqlerrm,1,200));
1280 WSH_DEBUG_SV.pop(l_module_name);
1281 END IF;
1282
1283
1284 END Container_Actions;
1285
1286
1287 END WSH_CONTAINER_PUB;