DBA Data[Home] [Help]

PACKAGE BODY: APPS.WSH_DELIVERY_DETAILS_UTILITIES

Source


1 PACKAGE BODY WSH_DELIVERY_DETAILS_UTILITIES as
2 /* $Header: WSHDDUTB.pls 120.9.12020000.2 2012/07/04 10:28:39 suppal ship $ */
3 
4 
5 G_PKG_NAME CONSTANT VARCHAR2(50) := 'WSH_DELIVERY_DETAILS_UTILITIES';
6 
7 --Forward Declaration
8 -- TPW - Distributed Organization Changes
9 PROCEDURE Validate_Delivery_Line (
10                    p_changed_attributes IN  WSH_INTERFACE.ChangedAttributeTabType,
11                    x_return_status      OUT NOCOPY VARCHAR2 );
12 
13 
14 -- ------------------------------------------------------------------------------------
15 -- Start of comments
16 -- API name : Auto_Assign_Deliveries
17 -- Type: private, called by group API
18 -- Prereqs : None
19 -- Preconditions: Given a list of delivery details with same grouping
20 --                attributes.
21 --
22 -- Function: This procedure groups the delivery details respecting FTE
23 --   compibility constraints then assign them to deliveries with matching
24 --   grouping attributes
25 --
26 -- Input Parameters :
27 --   p_line_rows           : table of delivery details
28 --   p_group_by_header      :'Y': within an order, 'N': across orders
29 --   p_check_fte_compatibility : 'Y'- check fte compatibility (called from Process Deliveries)
30 --                             : 'N'- skip fte compatibility (called from Pick Release since the
31 --                                    compatibility has been checked already)
32 -- Output Parameters:
33 --
34 --   x_assigned_rows       : table of delivery details and delivery id it assigned to
35 --   x_unassigned_rows     : table of delivery detail IDs that are not appended
36 --   x_return_status       : return status
37 -- ------------------------------------------------------------------------------------
38 PROCEDURE Auto_Assign_Deliveries(
39     p_line_rows               IN OUT NOCOPY wsh_delivery_autocreate.grp_attr_tab_type,
40     p_group_by_header         IN  VARCHAR2,
41     p_check_fte_compatibility IN  VARCHAR2,
42     x_assigned_rows           OUT NOCOPY WSH_DELIVERY_DETAILS_UTILITIES.delivery_assignment_rec_tbl,
43     x_unassigned_rows         OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
44     x_appended_del_tbl        OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
45     x_return_status           OUT NOCOPY VARCHAR2) IS
46 
47 
48 
49   --dummy tables for calling validate_constraint_main
50   l_cc_del_attr_tab      WSH_NEW_DELIVERIES_PVT.Delivery_Attr_Tbl_Type;
51   l_cc_det_attr_tab      WSH_GLBL_VAR_STRCT_GRP.Delivery_Details_Attr_Tbl_Type;
52   l_cc_trip_attr_tab     WSH_TRIPS_PVT.Trip_Attr_Tbl_Type;
53   l_cc_stop_attr_tab     WSH_TRIP_STOPS_PVT.Stop_Attr_Tbl_Type;
54   l_cc_in_ids            WSH_UTIL_CORE.id_tab_type;
55   l_cc_fail_ids          WSH_UTIL_CORE.id_tab_type;
56   l_cc_validate_result   VARCHAR2(1);
57   l_cc_failed_records    WSH_FTE_COMP_CONSTRAINT_PKG.failed_line_tab_type;
58   l_cc_line_groups       WSH_FTE_COMP_CONSTRAINT_PKG.line_group_tab_type;
59   l_cc_group_info        WSH_FTE_COMP_CONSTRAINT_PKG.cc_group_tab_type;
60 
61   l_msg_count            NUMBER := 0;
62   l_msg_data             VARCHAR2(2000);
63   l_return_status        VARCHAR2(1);
64 
65   l_debug_on             BOOLEAN;
66   l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'AUTO_ASSIGN_DELIVERIES';
67 
68   l_exception_message    VARCHAR2(2000);
69 
70   l_action_prms          WSH_GLBL_VAR_STRCT_GRP.dd_action_parameters_rec_type;
71   l_defaults             WSH_GLBL_VAR_STRCT_GRP.dd_default_parameters_rec_type;
72   l_action_out_rec       WSH_GLBL_VAR_STRCT_GRP.dd_action_out_rec_type;
73   l_details_in_cc_group  WSH_GLBL_VAR_STRCT_GRP.delivery_details_Attr_tbl_Type;
74 
75 
76   l_attr_tab             WSH_DELIVERY_AUTOCREATE.grp_attr_tab_type;
77   l_group_info           WSH_DELIVERY_AUTOCREATE.grp_attr_tab_type;
78   l_action_rec           WSH_DELIVERY_AUTOCREATE.action_rec_type;
79   l_target_rec           WSH_DELIVERY_AUTOCREATE.grp_attr_rec_type;
80   l_matched_entities     WSH_UTIL_CORE.id_tab_type;
81   l_out_rec              WSH_DELIVERY_AUTOCREATE.out_rec_type;
82 
83 
84   l_index                NUMBER;
85   l_current_line         NUMBER;
86 
87   l_cc_groupExists       BOOLEAN;
88   l_delivery_done        BOOLEAN;
89   l_multiple_sub_groups  BOOLEAN;
90   l_cc_group_ids         WSH_UTIL_CORE.id_tab_type;
91 
92   l_get_autocreate_del_criteria VARCHAR2(1);
93   l_warning_num          NUMBER := 0;
94   i                      NUMBER;
95   j                      NUMBER;
96   k                      NUMBER;
97   log_exception_err      EXCEPTION;
98 
99   l_sc_FINAL             VARCHAR2(6000);
100   l_sc_SELECT            VARCHAR2(2000);
101   l_sc_FROM              VARCHAR2(2000);
102   l_sc_WHERE             VARCHAR2(2000);
103   v_CursorID             NUMBER := 0;
104   l_sub_str              VARCHAR2(2000);
105   l_str_length           NUMBER := 0;
106   l_delivery_id          NUMBER := 0;
107   l_exception_id         NUMBER := NULL;
108   v_ignore               INTEGER;
109   l_group_id             NUMBER := 0;
110   l_date_scheduled       DATE := NULL;
111   l_date_requested       DATE := NULL;
112 
113   -- OTM R12 : update delivery
114   -- select d.ignore_for_planning is added
115  --bugfix 13998576 added hint in subquery
116   CURSOR c_get_deliveries IS
117   SELECT t.id, d.ignore_for_planning
118   FROM wsh_tmp            t,
119        wsh_new_deliveries d
120   WHERE d.delivery_id = t.id
121   AND NOT EXISTS (
122       SELECT /*+ no_unnest */ WDA.delivery_detail_id
123       FROM wsh_delivery_assignments_v WDA,
124            wsh_delivery_details       WDD
125       WHERE WDA.delivery_detail_id = WDD.delivery_detail_id
126       AND WDA.delivery_id = t.id
127       AND WDA.delivery_id is not NULL
128       AND WDD.source_code <> 'OE'
129       AND wdd.container_flag = 'N')
130   AND NOT EXISTS (
131       -- deliveries in consolidations are ineligible
132       SELECT 1
133       FROM WSH_DELIVERY_LEGS WDL
134       WHERE WDL.delivery_id = t.id
135       AND   WDL.parent_delivery_leg_id IS NOT NULL
136   )
137   ORDER BY d.creation_date;
138 
139 
140   -- OTM R12 : update delivery
141   l_delivery_info_tab       WSH_NEW_DELIVERIES_PVT.Delivery_Attr_Tbl_Type;
142   l_delivery_info           WSH_NEW_DELIVERIES_PVT.Delivery_Rec_Type;
143   l_new_interface_flag_tab  WSH_UTIL_CORE.COLUMN_TAB_TYPE;
144   l_tms_update              VARCHAR2(1);
145   l_trip_not_found          VARCHAR2(1);
146   l_trip_info_rec           WSH_DELIVERY_VALIDATIONS.trip_info_rec_type;
147   l_tms_version_number      WSH_NEW_DELIVERIES.TMS_VERSION_NUMBER%TYPE;
148   l_ignore_for_planning     WSH_NEW_DELIVERIES.IGNORE_FOR_PLANNING%TYPE;
149   l_otm_return_status       VARCHAR2(1); -- not to overwrite l_return_status
150   l_gc3_is_installed        VARCHAR2(1);
151   -- End of OTM R12 : update delivery
152 
153 BEGIN
154 
155    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
156    --
157    IF l_debug_on IS NULL THEN
158       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
159    END IF;
160    --
161    IF l_debug_on THEN
162       WSH_DEBUG_SV.push(l_module_name);
163       WSH_DEBUG_SV.log(l_module_name,'p_group_by_header', p_group_by_header);
164       WSH_DEBUG_SV.log(l_module_name,'p_check_fte_compatibility', p_check_fte_compatibility);
165    END IF;
166 
167 
168 
169    x_return_status  :=  WSH_UTIL_CORE.G_RET_STS_SUCCESS;
170    -- OTM R12
171    l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
172 
173    IF (l_gc3_is_installed IS NULL) THEN
174      l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
175    END IF;
176    -- End of OTM R12
177 
178 
179    l_cc_in_ids.delete;
180 
181 
182    IF l_debug_on THEN
183       i := p_line_rows.FIRST;
184       WHILE i is not NULL LOOP
185          WSH_DEBUG_SV.log(l_module_name,' p_line_rows('||i||').entity_id', p_line_rows(i).entity_id);
186       i := p_line_rows.next(i);
187       END LOOP;
188    END IF;
189 
190 
191 
192    WHILE p_line_rows.count > 0  LOOP
193 
194       l_current_line := p_line_rows.FIRST;
195 
196       l_sc_FINAL                                  := NULL;
197       l_sc_SELECT                                 := NULL;
198       l_sc_FROM                                   := NULL;
199       l_sc_WHERE                                  := NULL;
200       v_CursorID                                  := 0;
201 
202 
203       -- put the rows with same group_id in l_cc_in_ids
204       i := p_line_rows.FIRST;
205       WHILE i is not NULL LOOP
206 
207          IF p_line_rows(l_current_line).group_id = p_line_rows(i).group_id THEN
208             l_cc_in_ids(l_cc_in_ids.count+1) := p_line_rows(i).entity_id;
209 
210             IF l_debug_on THEN
211                WSH_DEBUG_SV.logmsg(l_module_name,'   Get delivery detail: '||p_line_rows(i).entity_id );
212             END IF;
213 
214          END IF;
215          i := p_line_rows.next(i);
216       END LOOP;
217 
218       l_multiple_sub_groups := FALSE;
219       l_cc_line_groups.delete;
220 
221 
222       -- construct
223       IF wsh_util_core.fte_is_installed = 'Y'
224          AND p_check_fte_compatibility = FND_API.G_TRUE
225          AND l_cc_in_ids.count > 1 THEN
226          IF l_debug_on THEN
227             WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_FTE_COMP_CONSTRAINT_PKG.validate_constraint_main');
228          END IF;
229          WSH_FTE_COMP_CONSTRAINT_PKG.validate_constraint_main(
230              p_api_version_number   =>  1.0,
231              p_init_msg_list        =>  FND_API.G_FALSE,
232              p_entity_type          =>  'L',
233              p_target_id            =>  null,
234              p_action_code          =>  'AUTOCREATE-DEL',
235              p_del_attr_tab         =>  l_cc_del_attr_tab,
236              p_det_attr_tab         =>  l_cc_det_attr_tab,
237              p_trip_attr_tab        =>  l_cc_trip_attr_tab,
238              p_stop_attr_tab        =>  l_cc_stop_attr_tab,
239              p_in_ids               =>  l_cc_in_ids,
240              x_fail_ids             =>  l_cc_fail_ids,
241              x_validate_result      =>  l_cc_validate_result,
242              x_failed_lines         =>  l_cc_failed_records,
243              -- passed out delivery detail id and the group id
244              x_line_groups          =>  l_cc_line_groups,
245              -- passed out group information
246              x_group_info           =>  l_cc_group_info,
247              x_msg_count            =>  l_msg_count,
248              x_msg_data             =>  l_msg_data,
249              x_return_status        =>  l_return_status);
250 
251          -- handle return status
252 
253          -- x_fail_ids and x_failed_lines are not populated for AUTOCREATE-DEL
254          l_cc_group_ids.delete;
255 
256          IF l_cc_line_groups.COUNT > 0 AND l_return_status = wsh_util_core.g_ret_sts_error THEN
257 
258             i := l_cc_line_groups.FIRST;
259             WHILE i is NOT NULL LOOP
260 
261                -- build l_cc_group_ids to hold the sub-group IDs
262                l_cc_groupExists := FALSE ;
263 
264                IF l_debug_on THEN
265                   WSH_DEBUG_SV.logmsg(l_module_name,'l_cc_line_groups('|| i ||').entity_line_id: '||l_cc_line_groups(i).entity_line_id);
266                   WSH_DEBUG_SV.logmsg(l_module_name,'l_cc_line_groups('|| i ||').line_group_id:  '||l_cc_line_groups(i).line_group_id);
267                END IF;
268 
269                IF l_cc_group_ids.COUNT > 0 THEN
270                   j := l_cc_group_ids.FIRST;
271                   WHILE j is not NULL LOOP
272                      IF l_cc_group_ids(j) = l_cc_line_groups(i).line_group_id THEN
273                         l_cc_groupExists := TRUE;
274                         exit;
275                      END IF;
276                   j := l_cc_group_ids.next(j);
277                   END LOOP;
278                END IF;
279                IF (NOT(l_cc_groupExists)) THEN
280                   l_cc_group_ids(l_cc_group_ids.count+1) := l_cc_line_groups(i).line_group_id;
281                   IF l_debug_on THEN
282                      WSH_DEBUG_SV.logmsg(l_module_name,'Add Sub-group '||l_cc_line_groups(i).line_group_id||' to table l_cc_group_ids' );
283                   END IF;
284                END IF;
285 
286                -- update p_line_rows with new sub_group ids
287                k := p_line_rows.FIRST;
288                WHILE k is not NULL LOOP
289                   IF p_line_rows(k).entity_id = l_cc_line_groups(i).entity_line_id  THEN
290                       -- correct the group_id with constraint group_id
291                       p_line_rows(k).group_id := l_cc_line_groups(i).line_group_id;
292 
293                       IF l_debug_on THEN
294                          WSH_DEBUG_SV.logmsg(l_module_name,'change group id of p_line_rows('||k||').entity_id '|| p_line_rows(k).entity_id||' to ' ||l_cc_line_groups(i).line_group_id);
295                       END IF;
296 
297                       exit;
298                   END IF;
299                   k := p_line_rows.next(k);
300                END LOOP;
301 
302             i := l_cc_line_groups.next(i);
303             END LOOP;
304 
305             l_multiple_sub_groups := TRUE;
306 
307          END IF;
308 
309        END IF;  /* FTE is installed */
310 
311        -- No sub-group, l_cc_group_ids has only one record
312        IF NOT l_multiple_sub_groups  THEN
313             l_cc_group_ids(l_cc_group_ids.count+1) := p_line_rows(l_current_line).group_id;
314        END IF;
315 
316        l_group_id := p_line_rows(l_current_line).group_id;
317 
318        l_action_rec.action := 'MATCH_GROUPS';
319        l_action_rec.group_by_header_flag := p_group_by_header;
320        l_action_rec.output_format_type := 'TEMP_TAB';
321        l_target_rec.entity_type := 'DELIVERY';
322 
323        l_group_info.delete;
324        l_attr_tab.delete;
325        l_attr_tab(1) := p_line_rows(l_current_line);
326        l_attr_tab(1).entity_type := 'DELIVERY_DETAIL';
327 
328        WSH_Delivery_Autocreate.Reset_WSH_TMP;
329 
330        wsh_delivery_autocreate.Find_Matching_Groups(
331           p_attr_tab => l_attr_tab,
332           p_action_rec => l_action_rec,
333           p_target_rec => l_target_rec,
334           p_group_tab  => l_group_info,
335           x_matched_entities => l_matched_entities,
336           x_out_rec => l_out_rec,
337           x_return_status => x_return_status);
338 
339       -- execute the cursor
340       OPEN c_get_deliveries;
341       -- fetching the rows
342       LOOP
343          -- OTM R12 : update delivery, l_ignore_for_planning is added to cursor
344          FETCH c_get_deliveries INTO l_delivery_id, l_ignore_for_planning;
345          IF c_get_deliveries%NOTFOUND THEN
346             CLOSE c_get_deliveries;
347             EXIT;
348          END IF;
349             -- store column value in local variables
350 
351             IF l_debug_on THEN
352                WSH_DEBUG_SV.log(l_module_name,'   Fetched candidate delivery '|| to_char(l_delivery_id));
353                WSH_DEBUG_SV.log(l_module_name,'   l_ignore_for_planning'||l_ignore_for_planning); -- OTM R12
354             END IF;
355 
356 
357          -- l_delivery_done indicastes if it needs to exit out of the sub-group loop
358          -- If the assignment happens for the delivery, it needs to exist in order
359          -- to advance to next delivery
360 
361          l_delivery_done := FALSE;
362 
363          -- loop through each sub group and try to assign the delivery details in the
364          -- sub-group to the delivery
365 
366          l_index := l_cc_group_ids.FIRST;
367          WHILE l_index is not null AND not l_delivery_done LOOP
368 
369             -- loop through each sub-group
370             l_details_in_cc_group.delete;
371 
372             IF l_debug_on THEN
373                i := l_cc_group_ids.FIRST;
374                WHILE i is not NULL LOOP
375                   WSH_DEBUG_SV.log(l_module_name,'   l_cc_group_ids('||i||') ', l_cc_group_ids(i));
376                i := l_cc_group_ids.next(i);
377                END LOOP;
378             END IF;
379 
380 
381             i := p_line_rows.FIRST;
382             WHILE i is not NULL LOOP
383                IF p_line_rows(i).group_id = l_cc_group_ids(l_index)  THEN
384                   l_details_in_cc_group(l_details_in_cc_group.count+1).delivery_detail_id := p_line_rows(i).entity_id;
385                   --
386                   l_details_in_cc_group(l_details_in_cc_group.count).released_status       := p_line_rows(i).status_code;
387                   l_details_in_cc_group(l_details_in_cc_group.count).organization_id       := p_line_rows(i).organization_id;
388                   l_details_in_cc_group(l_details_in_cc_group.count).container_flag        := p_line_rows(i).container_flag;
389                   l_details_in_cc_group(l_details_in_cc_group.count).source_code           := p_line_rows(i).source_code;
390                   l_details_in_cc_group(l_details_in_cc_group.count).lpn_id                := p_line_rows(i).lpn_id;
391                   l_details_in_cc_group(l_details_in_cc_group.count).customer_id           := p_line_rows(i).customer_id;
392                   l_details_in_cc_group(l_details_in_cc_group.count).inventory_item_id     := p_line_rows(i).inventory_item_id;
393                   l_details_in_cc_group(l_details_in_cc_group.count).ship_from_location_id := p_line_rows(i).ship_from_location_id;
394                   l_details_in_cc_group(l_details_in_cc_group.count).ship_to_location_id   := p_line_rows(i).ship_to_location_id;
395                   l_details_in_cc_group(l_details_in_cc_group.count).intmed_ship_to_location_id := p_line_rows(i).intmed_ship_to_location_id;
396                   l_details_in_cc_group(l_details_in_cc_group.count).date_requested        := p_line_rows(i).date_requested;
397                   l_details_in_cc_group(l_details_in_cc_group.count).date_scheduled        := p_line_rows(i).date_scheduled;
398                   l_details_in_cc_group(l_details_in_cc_group.count).ship_method_code      := p_line_rows(i).ship_method_code;
399                   l_details_in_cc_group(l_details_in_cc_group.count).carrier_id            := p_line_rows(i).carrier_id;
400                   l_details_in_cc_group(l_details_in_cc_group.count).shipping_control      := p_line_rows(i).shipping_control;
401                   l_details_in_cc_group(l_details_in_cc_group.count).party_id              := p_line_rows(i).party_id;
402                   l_details_in_cc_group(l_details_in_cc_group.count).line_direction        := p_line_rows(i).line_direction;
403 
404                   --
405                END IF;
406                i := p_line_rows.next(i);
407             END LOOP;
408 
409             -- reset date_scheduled and date_requested
410             l_date_scheduled := NULL;
411             l_date_requested := NULL;
412 
413             l_action_prms.action_code := 'ASSIGN';
414             l_action_prms.delivery_id := l_delivery_id;
415             l_action_prms.caller      := 'WSH_DLMG';
416 
417 
418             -- assign delivery details of this sub-group to the delivery
419             WSH_DELIVERY_DETAILS_GRP.Delivery_Detail_Action(
420                p_api_version_number  => 1.0,
421                p_init_msg_list       => FND_API.G_FALSE,
422                p_commit              => FND_API.G_FALSE,
423                x_return_status       => l_return_status,
424                x_msg_count           => l_msg_count,
425                x_msg_data            => l_msg_data,
426                -- Procedure specific Parameters
427                p_rec_attr_tab        => l_details_in_cc_group,
428                p_action_prms         => l_action_prms,
429                x_defaults            => l_defaults,
430                x_action_out_rec      => l_action_out_rec);
431 
432             IF l_debug_on THEN
433                WSH_DEBUG_SV.log(l_module_name,'Return status from WSH_DELIVERY_DETAILS_GRP.Delivery_Detail_Action '|| l_return_status);
434             END IF;
435 
436             -- OTM R12 : update delivery
437             l_tms_update := 'N';
438             l_new_interface_flag_tab(1) := NULL;
439 
440             -- delivery update will be done only for SUCCESS, WARNING case
441             IF (l_return_status in (WSH_UTIL_CORE.G_RET_STS_SUCCESS,
442                                     WSH_UTIL_CORE.G_RET_STS_WARNING) AND
443                 l_gc3_is_installed = 'Y' AND
444                 nvl(l_ignore_for_planning, 'N') = 'N') THEN
445               -- l_otm_return_status is used here not to change l_return_status
446               -- from the above API call
447               l_otm_return_status := NULL;
448               l_trip_not_found := 'N';
449 
450               --get trip information for delivery, no update when trip not OPEN
451               WSH_DELIVERY_VALIDATIONS.get_trip_information
452                            (p_delivery_id     => l_delivery_id,
453                             x_trip_info_rec   => l_trip_info_rec,
454                             x_return_status   => l_otm_return_status);
455 
456               IF (l_otm_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR)) THEN
457                 x_return_status := l_otm_return_status;
458                 IF l_debug_on THEN
459                   WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_DELIVERY_VALIDATIONS.get_trip_information');
460                   WSH_DEBUG_SV.pop(l_module_name);
461                 END IF;
462                 RETURN;
463               END IF;
464 
465               IF (l_trip_info_rec.trip_id IS NULL) THEN
466                 l_trip_not_found := 'Y';
467               END IF;
468 
469               -- only do changes when there's no trip or trip status is OPEN
470               IF (l_trip_info_rec.status_code = 'OP' OR
471                   l_trip_not_found = 'Y') THEN
472 
473                 WSH_DELIVERY_VALIDATIONS.get_delivery_information(
474                                       p_delivery_id   => l_delivery_id,
475                                       x_delivery_rec  => l_delivery_info,
476                                       x_return_status => l_otm_return_status);
477 
478                 IF (l_otm_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR)) THEN
479                   x_return_status := l_otm_return_status;
480                   IF l_debug_on THEN
481                     WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_DELIVERY_VALIDATIONS.get_delivery_information');
482                     WSH_DEBUG_SV.pop(l_module_name);
483                   END IF;
484                   RETURN;
485                 END IF;
486 
487 
488                 -- checking that fob code, freight terms code, ship method code,
489                 -- carrier id, service level,or mode of transport is changed
490                 -- and delivery is include for planning, then update is required
491                 IF (nvl(l_delivery_info.fob_code, '@@') <>
492                     NVL(l_delivery_info.fob_code,
493                         nvl(l_attr_tab(1).fob_code, '@@')) OR
494                     nvl(l_delivery_info.freight_terms_code, '@@') <>
495                     NVL(l_delivery_info.freight_terms_code,
496                         nvl(l_attr_tab(1).freight_terms_code, '@@')) OR
497                     nvl(l_delivery_info.ship_method_code, '@@') <>
498                     NVL(l_delivery_info.ship_method_code,
499                         nvl(l_attr_tab(1).ship_method_code, '@@')) OR
500                     nvl(l_delivery_info.carrier_id, -1) <>
501                     NVL(l_delivery_info.carrier_id,
502                         nvl(l_attr_tab(1).carrier_id, -1)) OR
503                     nvl(l_delivery_info.service_level, '@@') <>
504                     NVL(l_delivery_info.service_level,
505                         nvl(l_attr_tab(1).service_level, '@@')) OR
506                     nvl(l_delivery_info.mode_of_transport, '@@') <>
507                     NVL(l_delivery_info.mode_of_transport,
508                         nvl(l_attr_tab(1).mode_of_transport, '@@'))) THEN
509                   IF (l_delivery_info.tms_interface_flag NOT IN
510                       (WSH_NEW_DELIVERIES_PVT.C_TMS_NOT_TO_BE_SENT,
511                        WSH_NEW_DELIVERIES_PVT.C_TMS_CREATE_REQUIRED,
512                        WSH_NEW_DELIVERIES_PVT.C_TMS_DELETE_REQUIRED,
513                        WSH_NEW_DELIVERIES_PVT.C_TMS_DELETE_IN_PROCESS,
514                        WSH_NEW_DELIVERIES_PVT.C_TMS_UPDATE_REQUIRED)) THEN
515                     l_tms_update := 'Y';
516                     l_delivery_info_tab(1) := l_delivery_info;
517                     l_new_interface_flag_tab(1) := WSH_NEW_DELIVERIES_PVT.C_TMS_UPDATE_REQUIRED;
518                     l_tms_version_number := nvl(l_delivery_info.tms_version_number, 1) + 1;
519                   END IF;
520                 END IF; -- checking the value differences
521               END IF; -- IF ((l_trip_not_found = 'N' AND
522             END IF; -- IF (l_gc3_is_installed = 'Y'
523 
524             -- End of OTM R12 : update delivery
525 
526             -- If there are some delivery details assigned to the delivery,
527             -- we populate the assigned table and delete it from the main table
528 
529             IF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS  THEN
530 
531                   IF l_debug_on THEN
532                     i := l_action_out_rec.result_id_tab.FIRST;
533                     WHILE i is not NULL LOOP
534                       WSH_DEBUG_SV.log(l_module_name, 'l_action_out_rec.result_id_tab('||i||')', l_action_out_rec.result_id_tab(i));
535                     i :=  l_action_out_rec.result_id_tab.next(i);
536                     END LOOP;
537                   END IF;
538 
539 
540                   -- this delivery is used, go to next delivery
541                   l_delivery_done := TRUE;
542 
543                   i := l_details_in_cc_group.FIRST;
544                   WHILE i is not NULL  LOOP
545 
546                      -- log_exception if Append Deliveries is turned on
547                      IF l_attr_tab(1).batch_id is NULL THEN
548 
549                         FND_MESSAGE.SET_NAME('WSH', 'WSH_DEL_APPENDED');
550                         FND_MESSAGE.SET_TOKEN('DELIVERY_DETAIL_ID' , to_char(l_details_in_cc_group(i).delivery_detail_id));
551                         FND_MESSAGE.SET_TOKEN('DELIVERY_ID' , to_char(l_delivery_id));
552                         l_exception_message := FND_MESSAGE.Get;
553 
554                         l_exception_id := NULL;
555 
556                         wsh_xc_util.log_exception(
557                            p_api_version           => 1.0,
558                            x_return_status         => l_return_status,
559                            x_msg_count             => l_msg_count,
560                            x_msg_data              => l_msg_data,
561                            x_exception_id          => l_exception_id,
562                            p_exception_location_id => l_details_in_cc_group(i).ship_from_location_id,
563                            p_logged_at_location_id => l_details_in_cc_group(i).ship_from_location_id,
564                            p_logging_entity        => 'SHIPPER',
565                            p_logging_entity_id     => FND_GLOBAL.USER_ID,
566                            p_exception_name        => 'WSH_DELIVERY_APPENDED',
567                            p_message               => substrb(l_exception_message,1,2000),
568                            p_delivery_id           => l_delivery_id,
569                            p_delivery_detail_id    => l_details_in_cc_group(i).delivery_detail_id);
570 
571 
572                         IF l_return_status in ( WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR , WSH_UTIL_CORE.G_RET_STS_ERROR  ) THEN
573                            IF l_debug_on THEN
574                               WSH_DEBUG_SV.log(l_module_name,' log_exception failed ');
575                            END IF;
576                            raise log_exception_err;
577                         END IF;
578 
579                      END IF;
580 
581                      -- delete the processed record in p_line_rows
582                      j := p_line_rows.FIRST;
583                      WHILE j is not NULL LOOP
584                         IF p_line_rows(j).entity_id  = l_details_in_cc_group(i).delivery_detail_id THEN
585                            x_assigned_rows(x_assigned_rows.count+1).delivery_detail_id := p_line_rows(j).entity_id;
586                            x_assigned_rows(x_assigned_rows.count).delivery_id := l_delivery_id;
587 
588                            IF l_debug_on THEN
589                               WSH_DEBUG_SV.logmsg(l_module_name,'Added delivery_detail_id '||p_line_rows(j).entity_id||' to x_assigned_rows' );
590                            END IF;
591                            l_date_scheduled := least(NVL(l_date_scheduled,p_line_rows(j).date_scheduled), p_line_rows(j).date_scheduled);
592                            l_date_requested := least(NVL(l_date_requested,p_line_rows(j).date_requested), p_line_rows(j).date_requested);
593                            p_line_rows.delete(j);
594                            exit;
595                         END IF;
596                         j := p_line_rows.next(j);
597                      END LOOP;
598 
599                      i := l_details_in_cc_group.next(i);
600                   END LOOP;
601 
602                   -- update  appended delivery
603                   IF l_debug_on THEN
604                       WSH_DEBUG_SV.logmsg(l_module_name,  'UPDATING WSH_NEW_DELIVERIES ATTRIBUTES'  );
605                       WSH_DEBUG_SV.log(l_module_name,  'intmed_ship_to_location_id', l_attr_tab(1).intmed_ship_to_location_id );
606                       WSH_DEBUG_SV.log(l_module_name,  'fob_code', l_attr_tab(1).fob_code );
607                       WSH_DEBUG_SV.log(l_module_name,  'freight_terms_code', l_attr_tab(1).freight_terms_code );
608                       WSH_DEBUG_SV.log(l_module_name,  'carrier_id', l_attr_tab(1).carrier_id );
609                       WSH_DEBUG_SV.log(l_module_name,  'date_scheduled', l_date_scheduled);
610                       WSH_DEBUG_SV.log(l_module_name,  'date_requested', l_date_requested);
611                       WSH_DEBUG_SV.log(l_module_name,  'service_level', l_attr_tab(1).service_level );
612                       WSH_DEBUG_SV.log(l_module_name,  'mode_of_transport', l_attr_tab(1).mode_of_transport);
613                       WSH_DEBUG_SV.log(l_module_name,  'source_header_id', l_attr_tab(1).source_header_id);
614 
615                       -- OTM R12 : update delivery
616                       WSH_DEBUG_SV.log(l_module_name, 'l_gc3_is_installed', l_gc3_is_installed);
617                       WSH_DEBUG_SV.log(l_module_name, 'l_tms_update', l_tms_update);
618                       IF (l_tms_update = 'Y') THEN
619                         WSH_DEBUG_SV.log(l_module_name, 'l_new_interface_flag_tab', l_new_interface_flag_tab(1));
620                         WSH_DEBUG_SV.log(l_module_name, 'l_tms_version_number', l_tms_version_number);
621                       END IF;
622                       -- End of OTM R12 : update delivery
623                   END IF;
624 
625                   UPDATE wsh_new_deliveries
626                   SET    intmed_ship_to_location_id = NVL(intmed_ship_to_location_id,l_attr_tab(1).intmed_ship_to_location_id),
627                          fob_code                   = NVL(fob_code,l_attr_tab(1).fob_code),
628                          freight_terms_code         = NVL(freight_terms_code,l_attr_tab(1).freight_terms_code),
629                          ship_method_code           = NVL(ship_method_code,l_attr_tab(1).ship_method_code),
630                          carrier_id                 = NVL(carrier_id,l_attr_tab(1).carrier_id),
631                          initial_pickup_date        = least(initial_pickup_date, l_date_scheduled),
632                          -- bug 2466054 - switch between date_scheduled and date_requested
633                          ultimate_dropoff_date      = greatest(least(initial_pickup_date, l_date_scheduled),
634                                                                least(ultimate_dropoff_date,l_date_requested)),
635                          service_level              = NVL(service_level,l_attr_tab(1).service_level),
636                          mode_of_transport          = NVL(mode_of_transport,l_attr_tab(1).mode_of_transport),
637                          source_header_id           = NVL(source_header_id, l_attr_tab(1).source_header_id),
638                          last_update_date           = SYSDATE,
639                          last_updated_by            = FND_GLOBAL.user_id,
640                          last_update_login          = FND_GLOBAL.login_id,
641                          -- OTM R12
642                          TMS_INTERFACE_FLAG = decode(l_tms_update, 'Y', l_new_interface_flag_tab(1), nvl(TMS_INTERFACE_FLAG, WSH_NEW_DELIVERIES_PVT.C_TMS_NOT_TO_BE_SENT)),
643                          TMS_VERSION_NUMBER = decode(l_tms_update, 'Y', l_tms_version_number, nvl(tms_version_number, 1))
644                          -- End of OTM R12
645                   WHERE  delivery_id = l_delivery_id;
646 
647                   -- OTM R12 : update delivery
648                   IF (l_gc3_is_installed = 'Y' AND l_tms_update = 'Y') THEN
649                     WSH_XC_UTIL.LOG_OTM_EXCEPTION(
650                                 p_delivery_info_tab      => l_delivery_info_tab,
651                                 p_new_interface_flag_tab => l_new_interface_flag_tab,
652                                 x_return_status          => l_otm_return_status);
653                     IF (l_otm_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR)) THEN
654                       x_return_status := l_otm_return_status;
655                       IF l_debug_on THEN
656                         WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_XC_UTIL.log_otm_exception');
657                         WSH_DEBUG_SV.pop(l_module_name);
658                       END IF;
659                       RETURN;
660                     END IF;
661                   END IF;
662                   -- End of OTM R12 : update delivery
663 
664                   x_appended_del_tbl(x_appended_del_tbl.count+1) := l_delivery_id;
665                   -- delete the processed record in l_cc_group_ids
666                   i := l_cc_group_ids.FIRST;
667                   WHILE i is not NULL LOOP
668                      IF l_cc_group_ids(i) = l_group_id THEN
669                         l_cc_group_ids.delete(i);
670                      END IF;
671                      i := l_cc_group_ids.next(i);
672                   END LOOP;
673 
674             ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING /* some of them are successfully
675                   assigned */ THEN
676 
677                l_delivery_done := TRUE;
678                IF l_action_out_rec.result_id_tab.count > 0 THEN
679                   i := l_action_out_rec.result_id_tab.FIRST;
680                   WHILE i is not NULL LOOP
681 
682                      IF l_debug_on THEN
683                         WSH_DEBUG_SV.log(l_module_name, 'l_action_out_rec.result_id_tab('||i||')', l_action_out_rec.result_id_tab(i));
684                      END IF;
685 
686                      IF l_attr_tab(1).batch_id is NULL THEN
687 
688                       -- do not log exception when appending within a PR release
689                         FND_MESSAGE.SET_NAME('WSH', 'WSH_DEL_APPENDED');
690                         FND_MESSAGE.SET_TOKEN('DELIVERY_DETAIL_ID' , to_char(l_action_out_rec.result_id_tab(i)));
691                         FND_MESSAGE.SET_TOKEN('DELIVERY_ID' , to_char(l_delivery_id));
692                         l_exception_message := FND_MESSAGE.Get;
693 
694                         l_exception_id := NULL;
695 
696                         wsh_xc_util.log_exception(
697                            p_api_version           => 1.0,
698                            x_return_status         => l_return_status,
699                            x_msg_count             => l_msg_count,
700                            x_msg_data              => l_msg_data,
701                            x_exception_id          => l_exception_id,
702                            p_exception_handling    => 'NO_ACTION_REQUIRED',
703                            p_exception_location_id => l_details_in_cc_group(l_details_in_cc_group.FIRST).ship_from_location_id,
704                            p_logged_at_location_id => l_details_in_cc_group(l_details_in_cc_group.FIRST).ship_from_location_id,
705                            p_logging_entity        => 'SHIPPER',
706                            p_logging_entity_id     => FND_GLOBAL.USER_ID,
707                            p_exception_name        => 'WSH_DELIVERY_APPENDED',
708                            p_message               => substrb(l_exception_message,1,2000),
709                            p_delivery_id           => l_delivery_id,
710                            p_delivery_detail_id    => l_action_out_rec.result_id_tab(i));
711 
712                         IF l_return_status in ( WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR , WSH_UTIL_CORE.G_RET_STS_ERROR  ) THEN
713                            IF l_debug_on THEN
714                               WSH_DEBUG_SV.log(l_module_name,' log_exception failed ');
715                            END IF;
716                            raise log_exception_err;
717                         END IF;
718 
719                      END IF;
720 
721                      -- delete the processed record in p_line_rows
722                      j := p_line_rows.FIRST;
723                      WHILE j is not NULL LOOP
724                         IF p_line_rows(j).entity_id  = l_action_out_rec.result_id_tab(i) THEN
725                            x_assigned_rows(x_assigned_rows.count+1).delivery_detail_id := p_line_rows(j).entity_id;
726                            x_assigned_rows(x_assigned_rows.count).delivery_id := l_delivery_id;
727 
728                            IF l_debug_on THEN
729                               WSH_DEBUG_SV.logmsg(l_module_name,'Added delivery_detail_id '||p_line_rows(j).entity_id||' to x_assigned_rows' );
730                            END IF;
731                            -- get the date_scheduled and date_requrested
732                            l_date_scheduled := least(NVL(l_date_scheduled,p_line_rows(j).date_scheduled), p_line_rows(j).date_scheduled);
733                            l_date_requested := least(NVL(l_date_requested,p_line_rows(j).date_requested), p_line_rows(j).date_requested);
734                            p_line_rows.delete(j);
735                            exit;
736                         END IF;
737                         j := p_line_rows.next(j);
738                      END LOOP;
739 
740                      -- delete the assigned delivery details in l_details_in_cc_group
741                      -- Has gap, need to modify later
742                      k := l_details_in_cc_group.FIRST;
743                      WHILE k is not null LOOP
744                         IF l_details_in_cc_group(k).delivery_detail_id = l_action_out_rec.result_id_tab(i) THEN
745                            l_details_in_cc_group.delete(k);
746                            exit;
747                         END IF;
748                         k := l_details_in_cc_group.next(k);
749                      END LOOP;
750 
751                   i := l_action_out_rec.result_id_tab.next(i);
752                   END LOOP;
753 
754                   IF l_debug_on THEN
755                       WSH_DEBUG_SV.logmsg(l_module_name,  'UPDATING WSH_NEW_DELIVERIES ATTRIBUTES'  );
756                       WSH_DEBUG_SV.log(l_module_name,  'intmed_ship_to_location_id', l_attr_tab(1).intmed_ship_to_location_id );
757                       WSH_DEBUG_SV.log(l_module_name,  'fob_code', l_attr_tab(1).fob_code );
758                       WSH_DEBUG_SV.log(l_module_name,  'freight_terms_code', l_attr_tab(1).freight_terms_code );
759                       WSH_DEBUG_SV.log(l_module_name,  'carrier_id', l_attr_tab(1).carrier_id );
760                       WSH_DEBUG_SV.log(l_module_name,  'date_scheduled', l_date_scheduled);
761                       WSH_DEBUG_SV.log(l_module_name,  'date_requested', l_date_requested);
762                       WSH_DEBUG_SV.log(l_module_name,  'service_level', l_attr_tab(1).service_level );
763                       WSH_DEBUG_SV.log(l_module_name,  'mode_of_transport', l_attr_tab(1).mode_of_transport);
764                       WSH_DEBUG_SV.log(l_module_name,  'source_header_id', l_attr_tab(1).source_header_id);
765                       -- OTM R12 : update delivery
766                       WSH_DEBUG_SV.log(l_module_name, 'l_gc3_is_installed', l_gc3_is_installed);
767                       WSH_DEBUG_SV.log(l_module_name, 'l_tms_update', l_tms_update);
768                       IF (l_tms_update = 'Y') THEN
769                         WSH_DEBUG_SV.log(l_module_name, 'l_new_interface_flag_tab', l_new_interface_flag_tab(1));
770                         WSH_DEBUG_SV.log(l_module_name, 'l_tms_version_number', l_tms_version_number);
771                       END IF;
772                       -- End of OTM R12 : update delivery
773                   END IF;
774 
775                   UPDATE wsh_new_deliveries
776                   SET    intmed_ship_to_location_id = NVL(intmed_ship_to_location_id,l_attr_tab(1).intmed_ship_to_location_id),
777                          fob_code                   = NVL(fob_code,l_attr_tab(1).fob_code),
778                          freight_terms_code         = NVL(freight_terms_code,l_attr_tab(1).freight_terms_code),
779                          ship_method_code           = NVL(ship_method_code,l_attr_tab(1).ship_method_code),
780                          carrier_id                 = NVL(carrier_id,l_attr_tab(1).carrier_id),
781                          initial_pickup_date        = least(initial_pickup_date,l_date_scheduled),
782                          -- bug 2466054 - switch between date_scheduled and date_requested
783                          ultimate_dropoff_date      = greatest(least(initial_pickup_date,l_date_scheduled),
784                                                                least(ultimate_dropoff_date,l_date_requested)),
785                          service_level              = NVL(service_level,l_attr_tab(1).service_level),
786                          mode_of_transport          = NVL(mode_of_transport,l_attr_tab(1).mode_of_transport),
787                          source_header_id           = NVL(source_header_id, l_attr_tab(1).source_header_id),
788                          last_update_date           = SYSDATE,
789                          last_updated_by            = FND_GLOBAL.user_id,
790                          last_update_login          = FND_GLOBAL.login_id,
791                          -- OTM R12
792                          TMS_INTERFACE_FLAG = decode(l_tms_update, 'Y', l_new_interface_flag_tab(1), nvl(TMS_INTERFACE_FLAG, WSH_NEW_DELIVERIES_PVT.C_TMS_NOT_TO_BE_SENT)),
793                          TMS_VERSION_NUMBER = decode(l_tms_update, 'Y', l_tms_version_number, nvl(tms_version_number, 1))
794                          -- End of OTM R12
795                   WHERE  delivery_id = l_delivery_id;
796 
797                   -- OTM R12 : update delivery
798                   IF (l_gc3_is_installed = 'Y' AND l_tms_update = 'Y') THEN
799                     WSH_XC_UTIL.LOG_OTM_EXCEPTION(
800                                 p_delivery_info_tab      => l_delivery_info_tab,
801                                 p_new_interface_flag_tab => l_new_interface_flag_tab,
802                                 x_return_status          => l_otm_return_status);
803                     IF (l_otm_return_status IN (WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR, WSH_UTIL_CORE.G_RET_STS_ERROR)) THEN
804                       x_return_status := l_otm_return_status;
805                       IF l_debug_on THEN
806                         WSH_DEBUG_SV.logmsg(l_module_name,'Error in WSH_XC_UTIL.log_otm_exception');
807                         WSH_DEBUG_SV.pop(l_module_name);
808                       END IF;
809                       RETURN;
810                     END IF;
811                   END IF;
812                   -- End of OTM R12 : update delivery
813 
814                   x_appended_del_tbl(x_appended_del_tbl.count+1) := l_delivery_id;
815 
816                END IF;
817 
818                -- all of the delivery lines get assigned, but rate delivery or carrier selection
819                -- are not successful
820 
821                IF l_action_out_rec.result_id_tab.count >= l_details_in_cc_group.count THEN
822                   -- delete the processed record in l_cc_group_ids
823                   i := l_cc_group_ids.FIRST;
824                   WHILE i is not NULL LOOP
825                      IF l_cc_group_ids(i) = l_group_id THEN
826                         l_cc_group_ids.delete(i);
827                      END IF;
828                      i := l_cc_group_ids.next(i);
829                   END LOOP;
830                END IF;
831             ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
832             -- none of the delivery detail are assigned, it means that the delivery
833             -- do not match the constraint requirement, we have to try another delivery
834 
835                NULL;
836 
837             ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
838             -- searous error happens, skip to next sub-group
839 
840                i := p_line_rows.FIRST;
841                WHILE i is not NULL LOOP
842                   IF p_line_rows(i).group_id = l_group_id THEN
843                      x_unassigned_rows(x_unassigned_rows.count+1):= p_line_rows(i).entity_id;
844                      IF l_debug_on THEN
845                         WSH_DEBUG_SV.logmsg(l_module_name,'Added delivery_detail_id '||p_line_rows(i).entity_id||' to x_unassigned_rows' );
846                      END IF;
847                      p_line_rows.delete(i);
848                   END IF;
849                   i := p_line_rows.next(i);
850                END LOOP;
851 
852                -- delete the processed record in l_cc_group_ids
853                i := l_cc_group_ids.FIRST;
854 
855                WHILE i is not NULL LOOP
856                   IF l_cc_group_ids(i) = l_group_id THEN
857                      l_cc_group_ids.delete(i);
858                      exit;
859                   END IF;
860                   i := l_cc_group_ids.next(i);
861                END LOOP;
862 
863             END IF;   -- check the result of assignment
864 
865 
866             l_index := l_cc_group_ids.next(l_index) ;
867          END LOOP;  -- loop through each sub-group
868 
869          -- exit delivery loop
870          IF l_cc_group_ids.count = 0  THEN
871            CLOSE c_get_deliveries;
872            EXIT;
873          END IF;
874 
875       END LOOP; -- fetch delivery loop
876 
877       -- OTM R12, if the cursor is still open then close the cursor
878       IF c_get_deliveries%ISOPEN THEN
879          CLOSE c_get_deliveries;
880       END IF;
881 
882 
883       IF l_cc_group_ids.count > 0 THEN
884          -- have exhausted all the candidate deliveies, move the delivery lines to
885          -- unassigned table
886          i := l_cc_group_ids.FIRST;
887          WHILE i is not NULL LOOP
888 
889             -- this table has gaps
890             IF l_debug_on THEN
891                      WSH_DEBUG_SV.log(l_module_name,'p_line_rows count', p_line_rows.count);
892             END IF;
893             j := p_line_rows.FIRST;
894             WHILE j is not null LOOP
895 
896                IF p_line_rows(j).group_id = l_cc_group_ids(i) THEN
897                   x_unassigned_rows(x_unassigned_rows.count+1):= p_line_rows(j).entity_id;
898                   IF l_debug_on THEN
899                      WSH_DEBUG_SV.logmsg(l_module_name,'Added delivery_detail_id '||p_line_rows(j).entity_id||' to x_unassigned_rows' );
900                   END IF;
901                   p_line_rows.delete(j);
902                END IF;
903 
904                j := p_line_rows.NEXT(j);
905             END LOOP;
906             l_cc_group_ids.delete(i);
907             i := l_cc_group_ids.NEXT(i);
908          END LOOP;
909 
910       END IF ;
911 
912    END LOOP; -- p_line_rows loop
913 
914 
915    IF l_debug_on THEN
916       i := x_unassigned_rows.FIRST;
917       WHILE i is not NULL LOOP
918         WSH_DEBUG_SV.log(l_module_name,'x_unassigned_rows('||i||')' , x_unassigned_rows(i));
919       i := x_unassigned_rows.next(i);
920       END LOOP;
921    END IF;
922 
923 
924    IF x_unassigned_rows.count > 0 OR l_warning_num > 0 THEN
925       x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
926    END IF;
927 
928    IF l_debug_on THEN
929       WSH_DEBUG_SV.pop(l_module_name, 'Return Status: '||x_return_status);
930    END IF;
931 
932 
933 
934 EXCEPTION
935 
936    WHEN log_exception_err THEN
937 
938       -- OTM R12 : if the cursor is still open then close the cursor
939       IF c_get_deliveries%ISOPEN THEN
940          CLOSE c_get_deliveries;
941       END IF;
942 
943       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
944       WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
945       IF l_debug_on THEN
946          WSH_DEBUG_SV.pop(l_module_name, 'Log_exception returns error ');
947       END IF;
948 
949 
950    WHEN others THEN
951 
952       -- if the cursor is still open then close the cursor
953       IF c_get_deliveries%ISOPEN THEN
954          CLOSE c_get_deliveries;
955       END IF;
956       wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_UTILITIES.Auto_Assign_Deliveries');
957       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
958       IF l_debug_on THEN
959          WSH_DEBUG_SV.pop(l_module_name);
960       END IF;
961 
962 
963 END Auto_Assign_Deliveries;
964 
965 
966   -- ----------------------------------------------------------------------------------
967   -- Start of comments
968   -- API name : Append_to_Deliveries
969   -- Type: private, called by group API
970   -- Prereqs : None
971   -- Function: Assign delivery lines to existing deliveries respecting
972   --           grouping rules , across order options and FTE compatibility constraints.
973   --           This procedure only append OE lines per design
974   --           This procedure is called from Pick Release process or Process Deliveries SRS
975   -- Input Parameters :
976   --   p_delivery_detail_tbl : table of delivery details
977   --   p_append_flag         : NULL  or 'Y' - check the appending_limit in shipping parameters for
978   --                                  the organization, append delivery details only if
979   --                                  appending_limit is not 'No'
980   --
981   --                           'N' -  do not append delivery details, in this case
982   --                                  x_unappended_det_tbl is the same as p_delivery_detail_tbl
983   --   p_group_by_header     : 'Y' - use source_header_id in grouping delivery details
984   --                           'N' - do not use source_header_id in grouping delivery details
985   --                           NULL - get the value from shipping_parameters to decide if
986   --                           source_header_id should be used in grouping delivery details
987   --
988   --   p_commit                FND_API.G_TRUE  - commit
989   --                           FND_API.G_FALSE - do not commit
990   --
991   --   p_lock_rows             FND_API.G_TRUE  - lock rows before append
992   --                           FND_API.G_FALSE - do not lock rows befor append, usually the
993   --                                             caller procedure already locks the rows
994   --
995   --   p_check_fte_compatibility FND_API.G_TRUE - needs to check compatibility when grouping
996   --                                              the delivery lines
997   --                             FND_API.G_FALSE - do not needs to check compatibility when
998   --                                              the delivery lines, usually it has been
999   --                                              checked by the caller procedure
1000   --
1001   --   x_appended_det_tbl    : table of delivery details and delivery id it successfully appended
1002   --
1003   --   x_unappended_det_tbl  : table of delivery detail IDs that are not appended
1004   --
1005   --   x_appended_del_tbl    : table of deliveries that got appended
1006   --
1007   --   x_return_status       : Success: mean calling problem can continue with next step
1008   --                         : Error or Unexpected Error: the autocreate delivery
1009   --                           process should not continue
1010   --
1011   -- ----------------------------------------------------------------------------------
1012 
1013 PROCEDURE Append_to_Deliveries(
1014           p_delivery_detail_tbl     IN  WSH_UTIL_CORE.Id_Tab_Type,
1015           p_append_flag             IN  VARCHAR2,
1016           p_group_by_header         IN  VARCHAR2,
1017           p_commit                  IN  VARCHAR2,
1018           p_lock_rows               IN  VARCHAR2,
1019           p_check_fte_compatibility IN  VARCHAR2,
1020           x_appended_det_tbl        OUT NOCOPY WSH_DELIVERY_DETAILS_UTILITIES.delivery_assignment_rec_tbl,
1021           x_unappended_det_tbl      OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
1022           x_appended_del_tbl        OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
1023           x_return_status           OUT NOCOPY VARCHAR2) IS
1024 
1025   CURSOR get_line_details_check(c_detail_id NUMBER) IS
1026   SELECT   wdd.delivery_detail_id,
1027            wdd.ship_to_location_id,
1028            wdd.ship_from_location_id,
1029            wdd.customer_id,
1030            wdd.intmed_ship_to_location_id,
1031            wdd.fob_code,
1032            wdd.freight_terms_code,
1033            wdd.ship_method_code,
1034            wdd.carrier_id,
1035            wdd.source_header_id,
1036            wdd.deliver_to_location_id,
1037            wdd.organization_id,
1038            wdd.date_scheduled,
1039            wdd.date_requested,
1040            wdd.released_status,
1041            wdd.container_flag,
1042            wdd.shipping_control,
1043            wdd.party_id,
1044            wdd.line_direction,
1045            wdd.inventory_item_id,
1046            wdd.source_code,
1047            wdd.lpn_id,
1048            wsp.appending_limit,
1049 	   wdd.ignore_for_planning --bugfix 7164767
1050   FROM     wsh_delivery_details wdd,
1051            wsh_delivery_assignments_v wda,
1052            wsh_shipping_parameters  wsp
1053   WHERE    wdd.delivery_detail_id = c_detail_id
1054            AND wda.delivery_detail_id = wdd.delivery_detail_id
1055            AND wda.delivery_id is NULL
1056            AND NVL(wdd.line_direction, 'O') in ('O', 'IO')
1057            AND wdd.source_code = 'OE'
1058            AND wdd.container_flag = 'N'
1059            AND wsp.organization_id   = wdd.organization_id;
1060            -- AND wsp.appending_limit <> 'N' ;
1061 
1062   l_warning_num               NUMBER := 0;
1063   l_return_status             VARCHAR2(1) ;
1064 
1065   l_detail_info               WSH_DELIVERY_AUTOCREATE.grp_attr_tab_type;
1066 
1067   l_unassigned_rows           WSH_UTIL_CORE.Id_Tab_Type;
1068   l_assgined_rows             WSH_DELIVERY_DETAILS_UTILITIES.delivery_assignment_rec_tbl;
1069   l_index                     NUMBER;
1070   l_delivery_detail_id        NUMBER;
1071 
1072   l_group_info                WSH_DELIVERY_AUTOCREATE.grp_attr_tab_type;
1073   l_action_rec                WSH_DELIVERY_AUTOCREATE.action_rec_type;
1074   l_target_rec                WSH_DELIVERY_AUTOCREATE.grp_attr_rec_type;
1075   l_matched_entities          WSH_UTIL_CORE.id_tab_type;
1076   l_out_rec                   WSH_DELIVERY_AUTOCREATE.out_rec_type;
1077 
1078   l_debug_on                  BOOLEAN;
1079   l_module_name               CONSTANT VARCHAR2(100) := 'wsh.plsql.' || g_pkg_name || '.' || 'Append_to_Deliveries';
1080   Auto_Assign_Deliveries_ERR  EXCEPTION;
1081   Group_Delivery_Details_ERR  EXCEPTION;
1082   l_appending_limit           VARCHAR2(1);
1083   i                           NUMBER;
1084 
1085   BEGIN
1086 
1087     SAVEPOINT START_OF_APPEND_DELIVERIES;
1088     l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1089     --
1090     IF l_debug_on IS NULL THEN
1091        l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1092     END IF;
1093     IF l_debug_on THEN
1094        WSH_DEBUG_SV.push(l_module_name);
1095        WSH_DEBUG_SV.log(l_module_name, 'p_append_flag', p_append_flag);
1096        WSH_DEBUG_SV.log(l_module_name, 'p_group_by_header', p_group_by_header);
1097        WSH_DEBUG_SV.log(l_module_name, 'p_commit', p_commit);
1098        WSH_DEBUG_SV.log(l_module_name, 'p_lock_rows', p_lock_rows);
1099        WSH_DEBUG_SV.log(l_module_name, 'p_check_fte_compatibility', p_check_fte_compatibility);
1100        WSH_DEBUG_SV.log(l_module_name, 'WSH_PICK_LIST.G_BATCH_ID', WSH_PICK_LIST.G_BATCH_ID);
1101 
1102     END IF;
1103 
1104     x_return_status  :=  WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1105     x_unappended_det_tbl.delete;  -- unappended list
1106     x_appended_det_tbl.delete;    -- successfully appended list
1107     x_appended_del_tbl.delete;    -- appended deliveries
1108 
1109 
1110     -- need to check append_limit in shipping parameters
1111     l_index := p_delivery_detail_tbl.FIRST;
1112     WHILE l_index is NOT NULL LOOP
1113        IF l_debug_on THEN
1114          WSH_DEBUG_SV.log(l_module_name,'p_delivery_detail_tbl('||l_index||'): ',p_delivery_detail_tbl(l_index));
1115        END IF;
1116 
1117 
1118        OPEN get_line_details_check(p_delivery_detail_tbl(l_index));
1119        FETCH get_line_details_check INTO  l_detail_info(l_index).entity_id,
1120                                           l_detail_info(l_index).ship_to_location_id,
1121                                           l_detail_info(l_index).ship_from_location_id,
1122                                           l_detail_info(l_index).customer_id,
1123                                           l_detail_info(l_index).intmed_ship_to_location_id,
1124                                           l_detail_info(l_index).fob_code,
1125                                           l_detail_info(l_index).freight_terms_code,
1126                                           l_detail_info(l_index).ship_method_code,
1127                                           l_detail_info(l_index).carrier_id,
1128                                           l_detail_info(l_index).source_header_id,
1129                                           l_detail_info(l_index).deliver_to_location_id,
1130                                           l_detail_info(l_index).organization_id,
1131                                           l_detail_info(l_index).date_scheduled,
1132                                           l_detail_info(l_index).date_requested,
1133                                           l_detail_info(l_index).status_code,
1134                                           l_detail_info(l_index).container_flag,
1135                                           l_detail_info(l_index).shipping_control,
1136                                           l_detail_info(l_index).party_id,
1137                                           l_detail_info(l_index).line_direction,
1138                                           l_detail_info(l_index).inventory_item_id,
1139                                           l_detail_info(l_index).source_code,
1140                                           l_detail_info(l_index).lpn_id,
1141                                           l_appending_limit,
1142 					  l_detail_info(l_index).ignore_for_planning; --bugfix 7164767
1143 
1144 
1145        IF get_line_details_check%NOTFOUND THEN
1146           x_unappended_det_tbl(x_unappended_det_tbl.count+1) := p_delivery_detail_tbl(l_index);
1147           l_detail_info.delete(l_index);
1148           CLOSE get_line_details_check;
1149           goto loop_end;
1150        ELSE
1151           CLOSE get_line_details_check;
1152           -- these are the lines that will be grouped
1153           IF p_lock_rows = FND_API.G_TRUE THEN
1154              -- lock the delivery detail record
1155              select delivery_detail_id into l_delivery_detail_id from wsh_delivery_details where
1156              delivery_detail_id = p_delivery_detail_tbl(l_index) for update nowait;
1157           END IF;
1158           IF NVL(p_append_flag, l_appending_limit) = 'N' and WSH_PICK_LIST.G_BATCH_ID is NULL THEN
1159              x_unappended_det_tbl(x_unappended_det_tbl.count+1) := l_detail_info(l_index).entity_id;
1160              l_detail_info.delete(l_index);
1161           ELSIF NVL(p_append_flag, l_appending_limit) = 'N' and WSH_PICK_LIST.G_BATCH_ID is NOT NULL THEN
1162              l_detail_info(l_index).batch_id := WSH_PICK_LIST.G_BATCH_ID;
1163 
1164           END IF;
1165        END IF;
1166        <<loop_end>>
1167        l_index := p_delivery_detail_tbl.next(l_index);
1168     END LOOP;
1169 
1170 
1171 
1172        IF l_debug_on THEN
1173           i := l_detail_info.FIRST;
1174           WHILE i is not NULL LOOP
1175                WSH_DEBUG_SV.log(l_module_name,' l_detail_info('||i||').entity_id', l_detail_info(i).entity_id);
1176           i := l_detail_info.next(i);
1177           END LOOP;
1178        END IF;
1179 
1180 
1181 
1182       IF l_detail_info.count > 0 THEN
1183          l_unassigned_rows.delete;
1184 
1185          IF l_debug_on THEN
1186             WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit Group_Delivery_Details');
1187          END IF;
1188 
1189          l_action_rec.action := 'CREATE_GROUPS';
1190          l_action_rec.group_by_header_flag := p_group_by_header;
1191 
1192          WSH_DELIVERY_AUTOCREATE.Find_Matching_Groups(
1193             p_attr_tab => l_detail_info,
1194             p_action_rec => l_action_rec,
1195             p_target_rec => l_target_rec,
1196             p_group_tab  => l_group_info,
1197             x_matched_entities => l_matched_entities,
1198             x_out_rec => l_out_rec,
1199             x_return_status => l_return_status);
1200 
1201          IF l_debug_on THEN
1202             WSH_DEBUG_SV.logmsg(l_module_name,' after calling Find_Matching_Groups');
1203                i := l_detail_info.FIRST;
1204                WHILE i is not NULL LOOP
1205                   WSH_DEBUG_SV.log(l_module_name,' l_detail_info('||i||').entity_id', l_detail_info(i).entity_id);
1206                i := l_detail_info.next(i);
1207                END LOOP;
1208 
1209          END IF;
1210 
1211          IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
1212                l_warning_num := l_warning_num + 1;
1213          ELSIF (l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR OR
1214                l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR) THEN
1215                raise Group_Delivery_Details_ERR;
1216          END IF;
1217 
1218          IF l_debug_on THEN
1219             WSH_DEBUG_SV.logmsg(l_module_name,'Return status from wsh_delivery_autocreate.Find_Matching_Groups: '|| l_return_status );
1220             WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit Auto_Assign_Deliveries');
1221          END IF;
1222 
1223          Auto_Assign_Deliveries(
1224             p_line_rows               => l_detail_info,
1225             p_group_by_header         => p_group_by_header,
1226             p_check_fte_compatibility => p_check_fte_compatibility,
1227             x_assigned_rows           => x_appended_det_tbl,
1228             x_unassigned_rows         => l_unassigned_rows,
1229             x_appended_del_tbl        => x_appended_del_tbl,
1230             x_return_status           => l_return_status);
1231 
1232          IF l_debug_on THEN
1233             WSH_DEBUG_SV.logmsg(l_module_name,'Return status from Auto_Assign_Deliveries: '|| l_return_status );
1234          END IF;
1235 
1236          IF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
1237             l_warning_num := l_warning_num + 1;
1238             IF l_unassigned_rows.count > 0 THEN
1239                l_index := l_unassigned_rows.FIRST;
1240                WHILE l_index IS NOT NULL LOOP
1241                   x_unappended_det_tbl(x_unappended_det_tbl.count+1) := l_unassigned_rows(l_index);
1242                   l_index := l_unassigned_rows.next(l_index);
1243                END LOOP;
1244             END IF;
1245             IF l_debug_on THEN
1246 	       WSH_DEBUG_SV.log(l_module_name,'x_unappended_det_tbl.count', x_unappended_det_tbl.count);
1247             END IF;
1248          ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR OR
1249                l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
1250             raise Auto_Assign_Deliveries_ERR;
1251          END IF;
1252 
1253 
1254       IF p_commit = FND_API.G_TRUE THEN
1255          commit;
1256       END IF;
1257 
1258     END IF;
1259 
1260     IF x_unappended_det_tbl.count > 0 OR l_warning_num > 0 THEN
1261          x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
1262     END IF;
1263 
1264     IF l_debug_on THEN
1265        wsh_debug_sv.pop(l_module_name);
1266     END IF;
1267 
1268   EXCEPTION
1269 
1270     WHEN Group_Delivery_Details_ERR THEN
1271        ROLLBACK TO START_OF_APPEND_DELIVERIES;
1272        x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1273        FND_MESSAGE.SET_NAME('WSH', 'WSH_GRP_DETAILS_ERR');
1274        wsh_util_core.add_message(x_return_status, l_module_name);
1275 
1276        IF l_debug_on THEN
1277           wsh_debug_sv.logmsg(l_module_name, 'Group_Delivery_Details failed');
1278           wsh_debug_sv.pop(l_module_name, 'EXCEPTION:Group_Delivery_Details_ERR');
1279        END IF;
1280 
1281     WHEN Auto_Assign_Deliveries_ERR THEN
1282        ROLLBACK TO START_OF_APPEND_DELIVERIES;
1283        x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1284        FND_MESSAGE.SET_NAME('WSH', 'WSH_AUTO_ASSIGN_ERR');
1285        wsh_util_core.add_message(x_return_status, l_module_name);
1286 
1287        IF l_debug_on THEN
1288           wsh_debug_sv.logmsg(l_module_name, 'Auto_Assign_Deliveries failed');
1289           wsh_debug_sv.pop(l_module_name, 'EXCEPTION:Auto_Assign_Deliveries_ERR');
1290        END IF;
1291 
1292     WHEN Others THEN
1293        ROLLBACK TO START_OF_APPEND_DELIVERIES;
1294        -- release all the locks
1295        IF get_line_details_check%ISOPEN  THEN
1296           CLOSE get_line_details_check;
1297        END IF;
1298 
1299        x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1300        wsh_util_core.default_handler('WSH_DELIVERY_DETAILS_UTILITIES.Append_to_Deliveries');
1301        IF l_debug_on THEN
1302           wsh_debug_sv.log(l_module_name, 'Unexpected error has occured. Oracle error message is ' || SQLERRM);
1303           wsh_debug_sv.pop(l_module_name, 'EXCEPTION:OTHERS');
1304        END IF;
1305 
1306  END Append_to_Deliveries;
1307 
1308 -- TPW - Distributed Organization Changes - Start
1309 --
1310 --=============================================================================
1311 -- PUBLIC PROCEDURE :
1312 --       Check_Updates_Allowed
1313 --
1314 -- PARAMETERS:
1315 --       p_changed_attributes   => Delivery Details changed attributes
1316 --       p_source_code          => Source Code
1317 --       x_update_allowed       => Update Allowed Flag
1318 --       x_return_status        => Return Status of API (S,E,U)
1319 --
1320 -- COMMENT:
1321 --       API will not allow updates other than Ordered Quantity and Order
1322 --       Quantity UOM, if
1323 --       1) Organization is Distributed Enabled Org (TW2)
1324 --       2) Delivery line corresponding to order line is associated with
1325 --          Shipment batch.
1326 --       Increase in quantity is always allowed
1327 --       For decrease in quantity, there should be delivery line(s) which are
1328 --       not yet assigned to Shipment Batch atleast for quantity being cancelled.
1329 --=============================================================================
1330 --
1331 PROCEDURE Check_Updates_Allowed(
1332           p_changed_attributes IN  WSH_INTERFACE.ChangedAttributeTabType,
1333           p_source_code        IN  VARCHAR2,
1334           x_update_allowed     OUT NOCOPY  VARCHAR2,
1335           x_return_status      OUT NOCOPY  VARCHAR2)
1336 IS
1337    CURSOR c_del_details ( c_source_line_id IN NUMBER )
1338    IS
1339    select organization_id,
1340           src_requested_quantity,
1341           src_requested_quantity_uom,
1342           requested_quantity,
1343           requested_quantity_uom,
1344           inventory_item_id
1345    from   wsh_delivery_details
1346    where  source_code= p_source_code
1347    and    released_status not in ( 'D', 'C' )
1348    and    shipment_batch_id is not null
1349    and    source_line_id = c_source_line_id
1350    and    rownum = 1;
1351 
1352    CURSOR c_open_detail_qty (c_source_line_id IN NUMBER)
1353    IS
1354    select nvl(sum(requested_quantity), 0)
1355    from   wsh_delivery_details
1356    where  source_code = p_source_code
1357    and    released_status in ( 'R', 'X', 'B' ) -- Check with klr
1358    and    source_line_id = c_source_line_id
1359    and    shipment_batch_id is null
1360    and    shipment_line_number is null;
1361 
1362    l_return_status          VARCHAR2(1);
1363    l_wh_type                VARCHAR2(30);
1364 
1365    l_source_line_id         NUMBER;
1366    l_open_qty               NUMBER;
1367    l_change_quantity        NUMBER;
1368    l_converted_open_qty     NUMBER;
1369    l_converted_ordered_qty  NUMBER;
1370    l_new_src_requested_quantity   NUMBER;
1371 
1372    wsh_update_not_allowed   EXCEPTION;
1373    wsh_invalid_org          EXCEPTION;
1374 
1375    l_detail_rec             c_del_details%ROWTYPE;
1376    --
1377    l_debug_on               BOOLEAN;
1378    l_module_name CONSTANT   VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Check_Updates_Allowed';
1379    --
1380 BEGIN
1381    --
1382    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1383    --
1384    IF l_debug_on IS NULL
1385    THEN
1386        l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1387    END IF;
1388    --
1389    IF l_debug_on THEN
1390       WSH_DEBUG_SV.push(l_module_name);
1391       --
1392       WSH_DEBUG_SV.log(l_module_name, 'p_changed_attributes.count',p_changed_attributes.count);
1393       WSH_DEBUG_SV.log(l_module_name, 'p_source_code', p_source_code);
1394    END IF;
1395    --
1396    x_return_status     := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
1397 
1398    IF not WSH_DELIVERY_UTIL.G_INBOUND_FLAG and
1399       p_source_code = 'OE' -- check with klr
1400    THEN
1401    --{ Inbound Flag If - Starts
1402       FOR l_counter IN p_changed_attributes.FIRST ..p_changed_attributes.LAST
1403       LOOP
1404       --{ Loop Starts
1405          --
1406          IF l_debug_on THEN
1407             wsh_debug_sv.log(l_module_name,'original_source_line_id:',p_changed_attributes(l_counter).original_source_line_id);
1408             wsh_debug_sv.log (l_module_name, 'source_line_id: ',p_changed_attributes(l_counter).source_line_id);
1409             wsh_debug_sv.log (l_module_name, 'action_flag',p_changed_attributes(l_counter).action_flag);
1410          END IF;
1411          --
1412 
1413          IF (p_changed_attributes(l_counter).action_flag <> 'I' ) THEN
1414          --{ Action Flag If - Starts
1415             IF (p_changed_attributes(l_counter).action_flag = 'S' ) THEN
1416                l_source_line_id := nvl(p_changed_attributes(l_counter).original_source_line_id, p_changed_attributes(l_counter).source_line_id);
1417             ELSE
1418                l_source_line_id := p_changed_attributes(l_counter).source_line_id;
1419             END IF;
1420 
1421             open  c_del_details(l_source_line_id);
1422             Fetch c_del_details into l_detail_rec;
1423 
1424             IF ( c_del_details%FOUND ) THEN
1425                close c_del_details;
1426                l_wh_type := WSH_EXTERNAL_INTERFACE_SV.Get_Warehouse_Type(
1427                                        p_organization_id    => l_detail_rec.organization_id,
1428                                        x_return_status      => l_return_status );
1429 
1430                IF l_debug_on THEN
1431                   wsh_debug_sv.log(l_module_name,'l_wh_type,l_return_status',l_wh_type||','||l_return_status);
1432                END IF;
1433 
1434                IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
1435                   raise wsh_invalid_org;
1436                END IF;
1437 
1438                IF ( nvl(l_wh_type, FND_API.G_MISS_CHAR) = 'TW2' ) THEN
1439                   --
1440                   IF l_debug_on THEN
1441                      WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Validate_Delivery_Line', WSH_DEBUG_SV.C_PROC_LEVEL);
1442                   END IF;
1443                   --
1444                   Validate_Delivery_Line (
1445                            p_changed_attributes => p_changed_attributes,
1446                            x_return_status      => l_return_status );
1447 
1448                   --
1449                   IF l_debug_on THEN
1450                      WSH_DEBUG_SV.log(l_module_name, 'Return Status of WSH_DELIVERY_DETAILS_PUB.Split_Line', l_return_status);
1451                   END IF;
1452                   --
1453 
1454                   IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1455                      --
1456                      IF l_debug_on THEN
1457                         WSH_DEBUG_SV.logmsg(l_module_name, 'Error: CMS changes other than Quantity and Quantity UOM');
1458                      END IF;
1459                      --
1460                      raise wsh_update_not_allowed;
1461                   END IF;
1462 
1463                   OPEN  c_open_detail_qty(l_source_line_id);
1464                   FETCH c_open_detail_qty into l_open_qty;
1465                   CLOSE c_open_detail_qty;
1466 
1467                   l_converted_open_qty := l_open_qty;
1468 
1469                   --Convert Open quantity to Src Requested Quantity UOM(if UOM does not match)
1470                   IF l_detail_rec.requested_quantity_uom <> l_detail_rec.src_requested_quantity_uom THEN
1471                      --
1472                      IF l_debug_on THEN
1473                          WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.CONVERT_UOM',WSH_DEBUG_SV.C_PROC_LEVEL);
1474                      END IF;
1475                      --
1476                      l_converted_open_qty := WSH_WV_UTILS.Convert_Uom(
1477                             l_detail_rec.requested_quantity_uom,
1478                             l_detail_rec.src_requested_quantity_uom, -- Converting UOM using any detail
1479                             l_open_qty,
1480                             l_detail_rec.inventory_item_id);
1481                   END IF;
1482 
1483                   l_converted_ordered_qty := p_changed_attributes(l_counter).ordered_quantity;
1484 
1485                   --Convert OM Ordered Quantity to Src Requested Quantity UOM(if UOM does not match)
1486                   IF l_detail_rec.src_requested_quantity_uom <> p_changed_attributes(l_counter).order_quantity_uom THEN
1487                      --
1488                      IF l_debug_on THEN
1489                          WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WSH_WV_UTILS.CONVERT_UOM',WSH_DEBUG_SV.C_PROC_LEVEL);
1490                      END IF;
1491                      --
1492                      l_converted_ordered_qty := WSH_WV_UTILS.Convert_Uom(
1493                             p_changed_attributes(l_counter).order_quantity_uom,
1494                             l_detail_rec.src_requested_quantity_uom, -- Converting UOM using any detail
1495                             p_changed_attributes(l_counter).ordered_quantity,
1496                             l_detail_rec.inventory_item_id);
1497                   END IF;
1498 
1499                   l_change_quantity := l_detail_rec.src_requested_quantity - l_converted_ordered_qty;
1500 
1501                   --
1502                   IF l_debug_on THEN
1503                      WSH_DEBUG_SV.log(l_module_name, 'Open Quantity', l_open_qty);
1504                      WSH_DEBUG_SV.log(l_module_name, 'Converted Open Quantity', l_converted_open_qty);
1505                      WSH_DEBUG_SV.log(l_module_name, 'Ordered Quantity', p_changed_attributes(l_counter).ordered_quantity);
1506                      WSH_DEBUG_SV.log(l_module_name, 'Converted Ordered Quantity', l_converted_ordered_qty);
1507                      WSH_DEBUG_SV.log(l_module_name, 'Source Requested Quantity', l_detail_rec.src_requested_quantity);
1508                      WSH_DEBUG_SV.log(l_module_name, 'Change in quantity', l_change_quantity );
1509                   END IF;
1510                   --
1511 
1512                   --During CMS, Raise error if open quantity available for cancelleation is less than quantity cancelled from OM
1513                   IF l_converted_open_qty < l_change_quantity AND
1514                      l_detail_rec.src_requested_quantity > l_converted_ordered_qty
1515                   THEN
1516                      --
1517                      IF l_debug_on THEN
1518                         WSH_DEBUG_SV.logmsg(l_module_name, 'During CMS Actual Cancel Quantity available ' || l_converted_open_qty ||
1519                                               ' is less than cancel quantity requested ' || l_change_quantity ||
1520                                               '(UOM => ' || l_detail_rec.src_requested_quantity_uom || ')');
1521                      END IF;
1522                      --
1523                      raise wsh_update_not_allowed;
1524                   END IF;
1525                END IF;
1526             END IF;
1527 
1528             IF c_del_details%ISOPEN THEN
1529                close c_del_details;
1530             END IF;
1531          --} Action Flag If - Ends
1532          END IF;
1533       --} Loop Ends
1534       END LOOP;
1535    --} Inbound Flag If - Ends
1536    END IF;
1537 
1538    x_update_allowed := 'Y';
1539 
1540    --
1541    IF l_debug_on THEN
1542       WSH_DEBUG_SV.log(l_module_name, 'x_update_allowed', x_update_allowed);
1543       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
1544       WSH_DEBUG_SV.pop(l_module_name);
1545    END IF;
1546    --
1547 EXCEPTION
1548    WHEN wsh_update_not_allowed THEN
1549       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1550       FND_MESSAGE.SET_NAME('WSH', 'WSH_UPDATE_NOT_ALLOWED');
1551       WSH_UTIL_CORE.Add_Message(x_return_status,l_module_name);
1552       x_update_allowed := 'N';
1553       IF c_del_details%ISOPEN THEN
1554          close c_del_details;
1555       END IF;
1556       --
1557       IF l_debug_on THEN
1558           WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured while spliting line');
1559           WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:wsh_update_not_allowed');
1560       END IF;
1561       --
1562    WHEN wsh_invalid_org THEN
1563       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
1564       x_update_allowed := 'N';
1565       IF c_del_details%ISOPEN THEN
1566          close c_del_details;
1567       END IF;
1568       --
1569       IF l_debug_on THEN
1570           WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured while spliting line');
1571           WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:wsh_invalid_org');
1572       END IF;
1573       --
1574    WHEN others THEN
1575       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
1576       --
1577       IF l_debug_on THEN
1578           WSH_DEBUG_SV.logmsg(l_module_name,'Rolling back the transactions');
1579       END IF;
1580       --
1581       IF c_del_details%ISOPEN THEN
1582          close c_del_details;
1583       END IF;
1584       IF l_debug_on THEN
1585          WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
1586          WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
1587       END IF;
1588 END Check_Updates_Allowed;
1589 --
1590 --=============================================================================
1591 -- PRIVATE PROCEDURE :
1592 --       Validate_Delivery_Line
1593 --
1594 -- PARAMETERS:
1595 --       p_changed_attributes   => Delivery Details changed attributes
1596 --       x_return_status        => Return Status of API (S,E,U)
1597 --
1598 -- COMMENT:
1599 --       API to check if any attributes other than Ordered Quantity and Order
1600 --       Quantity UOM is updated during CMS(Change Management System) from OM.
1601 --
1602 --=============================================================================
1603 --
1604 PROCEDURE Validate_Delivery_Line (
1605                    p_changed_attributes IN  WSH_INTERFACE.ChangedAttributeTabType,
1606                    x_return_status      OUT NOCOPY VARCHAR2 )
1607 IS
1608    CURSOR c_delivery_line_info(c_line_id NUMBER)
1609    IS
1610    select wdd.*
1611    from   wsh_delivery_details     wdd
1612    where  wdd.source_line_id = c_line_id
1613    and    wdd.source_code = 'OE'
1614    and    wdd.released_status not in ( 'D', 'C' )
1615    and    wdd.shipment_batch_id is not null
1616    and    wdd.shipment_line_number is not null
1617    and    rownum = 1;
1618 
1619    l_delivery_line_info  c_delivery_line_info%ROWTYPE;
1620 
1621    --
1622    l_debug_on BOOLEAN;
1623    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Validate_Delivery_Line';
1624    --
1625 BEGIN
1626    --
1627    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
1628    --
1629    IF l_debug_on IS NULL THEN
1630       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
1631    END IF;
1632    --
1633    IF l_debug_on THEN
1634       WSH_DEBUG_SV.push(l_module_name);
1635    END IF;
1636    --
1637 
1638    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
1639 
1640    FOR i in p_changed_attributes.FIRST .. p_changed_attributes.LAST
1641    LOOP
1642       --
1643       IF l_debug_on THEN
1644          WSH_DEBUG_SV.log(l_module_name, 'source_line_id', p_changed_attributes(i).source_line_id );
1645       END IF;
1646       --
1647 
1648       IF p_changed_attributes(i).ordered_quantity = 0 THEN
1649          --
1650          IF l_debug_on THEN
1651             WSH_DEBUG_SV.logmsg(l_module_name, 'Ordered Quantity for line is zero, so do not validate');
1652          END IF;
1653          --
1654          EXIT;
1655       END IF;
1656 
1657       OPEN  c_delivery_line_info(p_changed_attributes(i).source_line_id);
1658       FETCH c_delivery_line_info INTO l_delivery_line_info;
1659       IF c_delivery_line_info%NOTFOUND THEN
1660          EXIT;
1661       END IF;
1662       CLOSE c_delivery_line_info;
1663 
1664       /*
1665       -- Just for debugging
1666       --
1667       IF l_debug_on THEN
1668          WSH_DEBUG_SV.log(l_module_name, 'p_changed_attributes(i).shipping_instructions', p_changed_attributes(i).shipping_instructions );
1669          WSH_DEBUG_SV.log(l_module_name, 'l_delivery_line_info.shipping_instructions', l_delivery_line_info.shipping_instructions );
1670          WSH_DEBUG_SV.logmsg(l_module_name, 'arrival_set_id                 => ' || p_changed_attributes(i).arrival_set_id                || ' , => ' || l_delivery_line_info.arrival_set_id );
1671          WSH_DEBUG_SV.logmsg(l_module_name, 'ato_line_id                    => ' || p_changed_attributes(i).ato_line_id                   || ' , => ' || l_delivery_line_info.ato_line_id );
1672          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute1                     => ' || p_changed_attributes(i).attribute1                    || ' , => ' || l_delivery_line_info.attribute1 );
1673          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute10                    => ' || p_changed_attributes(i).attribute10                   || ' , => ' || l_delivery_line_info.attribute10 );
1674          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute11                    => ' || p_changed_attributes(i).attribute11                   || ' , => ' || l_delivery_line_info.attribute11 );
1675          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute12                    => ' || p_changed_attributes(i).attribute12                   || ' , => ' || l_delivery_line_info.attribute12 );
1676          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute13                    => ' || p_changed_attributes(i).attribute13                   || ' , => ' || l_delivery_line_info.attribute13 );
1677          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute14                    => ' || p_changed_attributes(i).attribute14                   || ' , => ' || l_delivery_line_info.attribute14 );
1678          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute15                    => ' || p_changed_attributes(i).attribute15                   || ' , => ' || l_delivery_line_info.attribute15 );
1679          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute2                     => ' || p_changed_attributes(i).attribute2                    || ' , => ' || l_delivery_line_info.attribute2 );
1680          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute3                     => ' || p_changed_attributes(i).attribute3                    || ' , => ' || l_delivery_line_info.attribute3 );
1681          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute4                     => ' || p_changed_attributes(i).attribute4                    || ' , => ' || l_delivery_line_info.attribute4 );
1682          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute5                     => ' || p_changed_attributes(i).attribute5                    || ' , => ' || l_delivery_line_info.attribute5 );
1683          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute6                     => ' || p_changed_attributes(i).attribute6                    || ' , => ' || l_delivery_line_info.attribute6 );
1684          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute7                     => ' || p_changed_attributes(i).attribute7                    || ' , => ' || l_delivery_line_info.attribute7 );
1685          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute8                     => ' || p_changed_attributes(i).attribute8                    || ' , => ' || l_delivery_line_info.attribute8 );
1686          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute9                     => ' || p_changed_attributes(i).attribute9                    || ' , => ' || l_delivery_line_info.attribute9 );
1687          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute_category             => ' || p_changed_attributes(i).attribute_category            || ' , => ' || l_delivery_line_info.attribute_category );
1688          WSH_DEBUG_SV.logmsg(l_module_name, 'cancelled_quantity             => ' || p_changed_attributes(i).cancelled_quantity            || ' , => ' || l_delivery_line_info.cancelled_quantity );
1689          WSH_DEBUG_SV.logmsg(l_module_name, 'cancelled_quantity2            => ' || p_changed_attributes(i).cancelled_quantity2           || ' , => ' || l_delivery_line_info.cancelled_quantity2 );
1690          WSH_DEBUG_SV.logmsg(l_module_name, 'carrier_id                     => ' || p_changed_attributes(i).carrier_id                    || ' , => ' || l_delivery_line_info.carrier_id );
1691          WSH_DEBUG_SV.logmsg(l_module_name, 'classification                 => ' || p_changed_attributes(i).classification                || ' , => ' || l_delivery_line_info.classification );
1692          WSH_DEBUG_SV.logmsg(l_module_name, 'commodity_code_cat_id          => ' || p_changed_attributes(i).commodity_code_cat_id         || ' , => ' || l_delivery_line_info.commodity_code_cat_id );
1693          WSH_DEBUG_SV.logmsg(l_module_name, 'container_flag                 => ' || p_changed_attributes(i).container_flag                || ' , => ' || l_delivery_line_info.container_flag );
1694          WSH_DEBUG_SV.logmsg(l_module_name, 'container_name                 => ' || p_changed_attributes(i).container_name                || ' , => ' || l_delivery_line_info.container_name );
1695          WSH_DEBUG_SV.logmsg(l_module_name, 'container_type_code            => ' || p_changed_attributes(i).container_type_code           || ' , => ' || l_delivery_line_info.container_type_code );
1696          WSH_DEBUG_SV.logmsg(l_module_name, 'country_of_origin              => ' || p_changed_attributes(i).country_of_origin             || ' , => ' || l_delivery_line_info.country_of_origin );
1697          WSH_DEBUG_SV.logmsg(l_module_name, 'currency_code                  => ' || p_changed_attributes(i).currency_code                 || ' , => ' || l_delivery_line_info.currency_code );
1698          WSH_DEBUG_SV.logmsg(l_module_name, 'cust_model_serial_number       => ' || p_changed_attributes(i).cust_model_serial_number      || ' , => ' || l_delivery_line_info.cust_model_serial_number );
1699          WSH_DEBUG_SV.logmsg(l_module_name, 'cust_po_number                 => ' || p_changed_attributes(i).cust_po_number                || ' , => ' || l_delivery_line_info.cust_po_number );
1700          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_dock_code             => ' || p_changed_attributes(i).customer_dock_code            || ' , => ' || l_delivery_line_info.customer_dock_code );
1701          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_id                    => ' || p_changed_attributes(i).customer_id                   || ' , => ' || l_delivery_line_info.customer_id );
1702          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_item_id               => ' || p_changed_attributes(i).customer_item_id              || ' , => ' || l_delivery_line_info.customer_item_id );
1703          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_job                   => ' || p_changed_attributes(i).customer_job                  || ' , => ' || l_delivery_line_info.customer_job );
1704          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_prod_seq              => ' || p_changed_attributes(i).customer_prod_seq             || ' , => ' || l_delivery_line_info.customer_prod_seq );
1705          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_production_line       => ' || p_changed_attributes(i).customer_production_line      || ' , => ' || l_delivery_line_info.customer_production_line );
1706          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_requested_lot_flag    => ' || p_changed_attributes(i).customer_requested_lot_flag   || ' , => ' || l_delivery_line_info.customer_requested_lot_flag );
1707          WSH_DEBUG_SV.logmsg(l_module_name, 'cycle_count_quantity           => ' || p_changed_attributes(i).cycle_count_quantity          || ' , => ' || l_delivery_line_info.cycle_count_quantity );
1708          WSH_DEBUG_SV.logmsg(l_module_name, 'cycle_count_quantity2          => ' || p_changed_attributes(i).cycle_count_quantity2         || ' , => ' || l_delivery_line_info.cycle_count_quantity2 );
1709          WSH_DEBUG_SV.logmsg(l_module_name, 'date_requested                 => ' || p_changed_attributes(i).date_requested                || ' , => ' || l_delivery_line_info.date_requested );
1710          WSH_DEBUG_SV.logmsg(l_module_name, 'date_scheduled                 => ' || p_changed_attributes(i).date_scheduled                || ' , => ' || l_delivery_line_info.date_scheduled );
1711          WSH_DEBUG_SV.logmsg(l_module_name, 'deliver_to_contact_id          => ' || p_changed_attributes(i).deliver_to_contact_id         || ' , => ' || l_delivery_line_info.deliver_to_contact_id );
1712          WSH_DEBUG_SV.logmsg(l_module_name, 'deliver_to_org_id              => ' || p_changed_attributes(i).deliver_to_org_id             || ' , => ' || l_delivery_line_info.deliver_to_site_use_id );
1713          WSH_DEBUG_SV.logmsg(l_module_name, 'delivered_quantity             => ' || p_changed_attributes(i).delivered_quantity            || ' , => ' || l_delivery_line_info.delivered_quantity );
1714          WSH_DEBUG_SV.logmsg(l_module_name, 'delivered_quantity2            => ' || p_changed_attributes(i).delivered_quantity2           || ' , => ' || l_delivery_line_info.delivered_quantity2 );
1715          WSH_DEBUG_SV.logmsg(l_module_name, 'delivery_detail_id             => ' || p_changed_attributes(i).delivery_detail_id            || ' , => ' || l_delivery_line_info.delivery_detail_id );
1716          WSH_DEBUG_SV.logmsg(l_module_name, 'dep_plan_required_flag         => ' || p_changed_attributes(i).dep_plan_required_flag        || ' , => ' || l_delivery_line_info.dep_plan_required_flag );
1717          WSH_DEBUG_SV.logmsg(l_module_name, 'detail_container_item_id       => ' || p_changed_attributes(i).detail_container_item_id      || ' , => ' || l_delivery_line_info.detail_container_item_id );
1718          WSH_DEBUG_SV.logmsg(l_module_name, 'fill_percent                   => ' || p_changed_attributes(i).fill_percent                  || ' , => ' || l_delivery_line_info.fill_percent );
1719          WSH_DEBUG_SV.logmsg(l_module_name, 'fob_code                       => ' || p_changed_attributes(i).fob_code                      || ' , => ' || l_delivery_line_info.fob_code );
1720          WSH_DEBUG_SV.logmsg(l_module_name, 'freight_class_cat_id           => ' || p_changed_attributes(i).freight_class_cat_id          || ' , => ' || l_delivery_line_info.freight_class_cat_id );
1721          WSH_DEBUG_SV.logmsg(l_module_name, 'freight_terms_code             => ' || p_changed_attributes(i).freight_terms_code            || ' , => ' || l_delivery_line_info.freight_terms_code );
1722          WSH_DEBUG_SV.logmsg(l_module_name, 'gross_weight                   => ' || p_changed_attributes(i).gross_weight                  || ' , => ' || l_delivery_line_info.gross_weight );
1723          WSH_DEBUG_SV.logmsg(l_module_name, 'hazard_class_id                => ' || p_changed_attributes(i).hazard_class_id               || ' , => ' || l_delivery_line_info.hazard_class_id );
1724          WSH_DEBUG_SV.logmsg(l_module_name, 'hold_code                      => ' || p_changed_attributes(i).hold_code                     || ' , => ' || l_delivery_line_info.hold_code );
1725          WSH_DEBUG_SV.logmsg(l_module_name, 'inspection_flag                => ' || p_changed_attributes(i).inspection_flag               || ' , => ' || l_delivery_line_info.inspection_flag );
1726          WSH_DEBUG_SV.logmsg(l_module_name, 'intmed_ship_to_contact_id      => ' || p_changed_attributes(i).intmed_ship_to_contact_id     || ' , => ' || l_delivery_line_info.intmed_ship_to_contact_id );
1727          WSH_DEBUG_SV.logmsg(l_module_name, 'inv_interfaced_flag            => ' || p_changed_attributes(i).inv_interfaced_flag           || ' , => ' || l_delivery_line_info.inv_interfaced_flag );
1728          WSH_DEBUG_SV.logmsg(l_module_name, 'inventory_item_id              => ' || p_changed_attributes(i).inventory_item_id             || ' , => ' || l_delivery_line_info.inventory_item_id );
1729          WSH_DEBUG_SV.logmsg(l_module_name, 'item_description               => ' || p_changed_attributes(i).item_description              || ' , => ' || l_delivery_line_info.item_description );
1730          WSH_DEBUG_SV.logmsg(l_module_name, 'load_seq_number                => ' || p_changed_attributes(i).load_seq_number               || ' , => ' || l_delivery_line_info.load_seq_number );
1731          WSH_DEBUG_SV.logmsg(l_module_name, 'locator_id                     => ' || p_changed_attributes(i).locator_id                    || ' , => ' || l_delivery_line_info.locator_id );
1732          WSH_DEBUG_SV.logmsg(l_module_name, 'lot_number                     => ' || p_changed_attributes(i).lot_number                    || ' , => ' || l_delivery_line_info.lot_number );
1733          WSH_DEBUG_SV.logmsg(l_module_name, 'lpn_id                         => ' || p_changed_attributes(i).lpn_id                        || ' , => ' || l_delivery_line_info.lpn_id );
1734          WSH_DEBUG_SV.logmsg(l_module_name, 'master_container_item_id       => ' || p_changed_attributes(i).master_container_item_id      || ' , => ' || l_delivery_line_info.master_container_item_id );
1735          WSH_DEBUG_SV.logmsg(l_module_name, 'master_serial_number           => ' || p_changed_attributes(i).master_serial_number          || ' , => ' || l_delivery_line_info.master_serial_number );
1736          WSH_DEBUG_SV.logmsg(l_module_name, 'maximum_load_weight            => ' || p_changed_attributes(i).maximum_load_weight           || ' , => ' || l_delivery_line_info.maximum_load_weight );
1737          WSH_DEBUG_SV.logmsg(l_module_name, 'maximum_volume                 => ' || p_changed_attributes(i).maximum_volume                || ' , => ' || l_delivery_line_info.maximum_volume );
1738          WSH_DEBUG_SV.logmsg(l_module_name, 'minimum_fill_percent           => ' || p_changed_attributes(i).minimum_fill_percent          || ' , => ' || l_delivery_line_info.minimum_fill_percent );
1739          WSH_DEBUG_SV.logmsg(l_module_name, 'move_order_line_id             => ' || p_changed_attributes(i).move_order_line_id            || ' , => ' || l_delivery_line_info.move_order_line_id );
1740          WSH_DEBUG_SV.logmsg(l_module_name, 'movement_id                    => ' || p_changed_attributes(i).movement_id                   || ' , => ' || l_delivery_line_info.movement_id );
1741          WSH_DEBUG_SV.logmsg(l_module_name, 'mvt_stat_status                => ' || p_changed_attributes(i).mvt_stat_status               || ' , => ' || l_delivery_line_info.mvt_stat_status );
1742          WSH_DEBUG_SV.logmsg(l_module_name, 'net_weight                     => ' || p_changed_attributes(i).net_weight                    || ' , => ' || l_delivery_line_info.net_weight );
1743          WSH_DEBUG_SV.logmsg(l_module_name, 'oe_interfaced_flag             => ' || p_changed_attributes(i).oe_interfaced_flag            || ' , => ' || l_delivery_line_info.oe_interfaced_flag );
1744          WSH_DEBUG_SV.logmsg(l_module_name, 'order_quantity_uom             => ' || p_changed_attributes(i).order_quantity_uom            || ' , => ' || l_delivery_line_info.src_requested_quantity_uom );
1745          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity               => ' || p_changed_attributes(i).ordered_quantity              || ' , => ' || l_delivery_line_info.src_requested_quantity );
1746          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity2              => ' || p_changed_attributes(i).ordered_quantity2             || ' , => ' || l_delivery_line_info.src_requested_quantity2 );
1747          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity_uom2          => ' || p_changed_attributes(i).ordered_quantity_uom2         || ' , => ' || l_delivery_line_info.src_requested_quantity_uom2 );
1748          WSH_DEBUG_SV.logmsg(l_module_name, 'org_id                         => ' || p_changed_attributes(i).org_id                        || ' , => ' || l_delivery_line_info.org_id );
1749          WSH_DEBUG_SV.logmsg(l_module_name, 'organization_id                => ' || p_changed_attributes(i).organization_id               || ' , => ' || l_delivery_line_info.organization_id );
1750          WSH_DEBUG_SV.logmsg(l_module_name, 'original_subinventory          => ' || p_changed_attributes(i).original_subinventory         || ' , => ' || l_delivery_line_info.original_subinventory );
1751          WSH_DEBUG_SV.logmsg(l_module_name, 'packing_instructions           => ' || p_changed_attributes(i).packing_instructions          || ' , => ' || l_delivery_line_info.packing_instructions );
1752          WSH_DEBUG_SV.logmsg(l_module_name, 'pickable_flag                  => ' || p_changed_attributes(i).pickable_flag                 || ' , => ' || l_delivery_line_info.pickable_flag );
1753          WSH_DEBUG_SV.logmsg(l_module_name, 'picked_quantity                => ' || p_changed_attributes(i).picked_quantity               || ' , => ' || l_delivery_line_info.picked_quantity );
1754          WSH_DEBUG_SV.logmsg(l_module_name, 'picked_quantity2               => ' || p_changed_attributes(i).picked_quantity2              || ' , => ' || l_delivery_line_info.picked_quantity2 );
1755          WSH_DEBUG_SV.logmsg(l_module_name, 'preferred_grade                => ' || p_changed_attributes(i).preferred_grade               || ' , => ' || l_delivery_line_info.preferred_grade );
1756          WSH_DEBUG_SV.logmsg(l_module_name, 'project_id                     => ' || p_changed_attributes(i).project_id                    || ' , => ' || l_delivery_line_info.project_id );
1757          WSH_DEBUG_SV.logmsg(l_module_name, 'quality_control_quantity       => ' || p_changed_attributes(i).quality_control_quantity      || ' , => ' || l_delivery_line_info.quality_control_quantity );
1758          WSH_DEBUG_SV.logmsg(l_module_name, 'quality_control_quantity2      => ' || p_changed_attributes(i).quality_control_quantity2     || ' , => ' || l_delivery_line_info.quality_control_quantity2 );
1759          WSH_DEBUG_SV.logmsg(l_module_name, 'received_quantity              => ' || p_changed_attributes(i).received_quantity             || ' , => ' || l_delivery_line_info.received_quantity );
1760          WSH_DEBUG_SV.logmsg(l_module_name, 'received_quantity2             => ' || p_changed_attributes(i).received_quantity2            || ' , => ' || l_delivery_line_info.received_quantity2 );
1761          WSH_DEBUG_SV.logmsg(l_module_name, 'released_status                => ' || p_changed_attributes(i).released_status               || ' , => ' || l_delivery_line_info.released_status );
1762          WSH_DEBUG_SV.logmsg(l_module_name, 'request_id                     => ' || p_changed_attributes(i).request_id                    || ' , => ' || l_delivery_line_info.request_id );
1763          WSH_DEBUG_SV.logmsg(l_module_name, 'revision                       => ' || p_changed_attributes(i).revision                      || ' , => ' || l_delivery_line_info.revision );
1764          WSH_DEBUG_SV.logmsg(l_module_name, 'seal_code                      => ' || p_changed_attributes(i).seal_code                     || ' , => ' || l_delivery_line_info.seal_code );
1765          WSH_DEBUG_SV.logmsg(l_module_name, 'serial_number                  => ' || p_changed_attributes(i).serial_number                 || ' , => ' || l_delivery_line_info.serial_number );
1766          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_from_org_id               => ' || p_changed_attributes(i).ship_from_org_id              || ' , => ' || l_delivery_line_info.organization_id );
1767          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_model_complete_flag       => ' || p_changed_attributes(i).ship_model_complete_flag      || ' , => ' || l_delivery_line_info.ship_model_complete_flag );
1768          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_set_id                    => ' || p_changed_attributes(i).ship_set_id                   || ' , => ' || l_delivery_line_info.ship_set_id );
1769          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_contact_id             => ' || p_changed_attributes(i).ship_to_contact_id            || ' , => ' || l_delivery_line_info.ship_to_contact_id );
1770          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_org_id                 => ' || p_changed_attributes(i).ship_to_org_id                || ' , => ' || l_delivery_line_info.ship_to_site_use_id );
1771          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_site_use_id            => ' || p_changed_attributes(i).ship_to_site_use_id           || ' , => ' || l_delivery_line_info.ship_to_site_use_id );
1772          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_tolerance_above           => ' || p_changed_attributes(i).ship_tolerance_above          || ' , => ' || l_delivery_line_info.ship_tolerance_above );
1773          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_tolerance_below           => ' || p_changed_attributes(i).ship_tolerance_below          || ' , => ' || l_delivery_line_info.ship_tolerance_below );
1774          WSH_DEBUG_SV.logmsg(l_module_name, 'shipment_priority_code         => ' || p_changed_attributes(i).shipment_priority_code        || ' , => ' || l_delivery_line_info.shipment_priority_code );
1775          WSH_DEBUG_SV.logmsg(l_module_name, 'shipped_quantity               => ' || p_changed_attributes(i).shipped_quantity              || ' , => ' || l_delivery_line_info.shipped_quantity );
1776          WSH_DEBUG_SV.logmsg(l_module_name, 'shipped_quantity2              => ' || p_changed_attributes(i).shipped_quantity2             || ' , => ' || l_delivery_line_info.shipped_quantity2 );
1777          WSH_DEBUG_SV.logmsg(l_module_name, 'shipping_instructions          => ' || p_changed_attributes(i).shipping_instructions         || ' , => ' || l_delivery_line_info.shipping_instructions );
1778          WSH_DEBUG_SV.logmsg(l_module_name, 'shipping_method_code           => ' || p_changed_attributes(i).shipping_method_code          || ' , => ' || l_delivery_line_info.ship_method_code );
1779          WSH_DEBUG_SV.logmsg(l_module_name, 'sold_to_contact_id             => ' || p_changed_attributes(i).sold_to_contact_id            || ' , => ' || l_delivery_line_info.sold_to_contact_id );
1780          WSH_DEBUG_SV.logmsg(l_module_name, 'sold_to_org_id                 => ' || p_changed_attributes(i).sold_to_org_id                || ' , => ' || l_delivery_line_info.customer_id);
1781          WSH_DEBUG_SV.logmsg(l_module_name, 'source_code                    => ' || p_changed_attributes(i).source_code                   || ' , => ' || l_delivery_line_info.source_code );
1782          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_id               => ' || p_changed_attributes(i).source_header_id              || ' , => ' || l_delivery_line_info.source_header_id );
1783          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_number           => ' || p_changed_attributes(i).source_header_number          || ' , => ' || l_delivery_line_info.source_header_number );
1784          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_type_id          => ' || p_changed_attributes(i).source_header_type_id         || ' , => ' || l_delivery_line_info.source_header_type_id );
1785          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_type_name        => ' || p_changed_attributes(i).source_header_type_name       || ' , => ' || l_delivery_line_info.source_header_type_name );
1786          WSH_DEBUG_SV.logmsg(l_module_name, 'source_line_id                 => ' || p_changed_attributes(i).source_line_id                || ' , => ' || l_delivery_line_info.source_line_id );
1787          WSH_DEBUG_SV.logmsg(l_module_name, 'source_line_set_id             => ' || p_changed_attributes(i).source_line_set_id            || ' , => ' || l_delivery_line_info.source_line_set_id );
1788          WSH_DEBUG_SV.logmsg(l_module_name, 'split_from_delivery_detail_id  => ' || p_changed_attributes(i).split_from_delivery_detail_id || ' , => ' || l_delivery_line_info.split_from_delivery_detail_id );
1789          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity         => ' || p_changed_attributes(i).src_requested_quantity        || ' , => ' || l_delivery_line_info.src_requested_quantity );
1790          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity2        => ' || p_changed_attributes(i).src_requested_quantity2       || ' , => ' || l_delivery_line_info.src_requested_quantity2 );
1791          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity_uom     => ' || p_changed_attributes(i).src_requested_quantity_uom    || ' , => ' || l_delivery_line_info.src_requested_quantity_uom );
1792          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity_uom2    => ' || p_changed_attributes(i).src_requested_quantity_uom2   || ' , => ' || l_delivery_line_info.src_requested_quantity_uom2 );
1793          WSH_DEBUG_SV.logmsg(l_module_name, 'subinventory                   => ' || p_changed_attributes(i).subinventory                  || ' , => ' || l_delivery_line_info.subinventory );
1794          WSH_DEBUG_SV.logmsg(l_module_name, 'task_id                        => ' || p_changed_attributes(i).task_id                       || ' , => ' || l_delivery_line_info.task_id );
1795          WSH_DEBUG_SV.logmsg(l_module_name, 'to_serial_number               => ' || p_changed_attributes(i).to_serial_number              || ' , => ' || l_delivery_line_info.to_serial_number );
1796          WSH_DEBUG_SV.logmsg(l_module_name, 'top_model_line_id              => ' || p_changed_attributes(i).top_model_line_id             || ' , => ' || l_delivery_line_info.top_model_line_id );
1797          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute1                  => ' || p_changed_attributes(i).tp_attribute1                 || ' , => ' || l_delivery_line_info.tp_attribute1 );
1798          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute10                 => ' || p_changed_attributes(i).tp_attribute10                || ' , => ' || l_delivery_line_info.tp_attribute10 );
1799          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute11                 => ' || p_changed_attributes(i).tp_attribute11                || ' , => ' || l_delivery_line_info.tp_attribute11 );
1800          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute12                 => ' || p_changed_attributes(i).tp_attribute12                || ' , => ' || l_delivery_line_info.tp_attribute12 );
1801          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute13                 => ' || p_changed_attributes(i).tp_attribute13                || ' , => ' || l_delivery_line_info.tp_attribute13 );
1802          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute14                 => ' || p_changed_attributes(i).tp_attribute14                || ' , => ' || l_delivery_line_info.tp_attribute14 );
1803          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute15                 => ' || p_changed_attributes(i).tp_attribute15                || ' , => ' || l_delivery_line_info.tp_attribute15 );
1804          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute2                  => ' || p_changed_attributes(i).tp_attribute2                 || ' , => ' || l_delivery_line_info.tp_attribute2 );
1805          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute3                  => ' || p_changed_attributes(i).tp_attribute3                 || ' , => ' || l_delivery_line_info.tp_attribute3 );
1806          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute4                  => ' || p_changed_attributes(i).tp_attribute4                 || ' , => ' || l_delivery_line_info.tp_attribute4 );
1807          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute5                  => ' || p_changed_attributes(i).tp_attribute5                 || ' , => ' || l_delivery_line_info.tp_attribute5 );
1808          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute6                  => ' || p_changed_attributes(i).tp_attribute6                 || ' , => ' || l_delivery_line_info.tp_attribute6 );
1809          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute7                  => ' || p_changed_attributes(i).tp_attribute7                 || ' , => ' || l_delivery_line_info.tp_attribute7 );
1810          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute8                  => ' || p_changed_attributes(i).tp_attribute8                 || ' , => ' || l_delivery_line_info.tp_attribute8 );
1811          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute9                  => ' || p_changed_attributes(i).tp_attribute9                 || ' , => ' || l_delivery_line_info.tp_attribute9 );
1812          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute_category          => ' || p_changed_attributes(i).tp_attribute_category         || ' , => ' || l_delivery_line_info.tp_attribute_category );
1813          WSH_DEBUG_SV.logmsg(l_module_name, 'tracking_number                => ' || p_changed_attributes(i).tracking_number               || ' , => ' || l_delivery_line_info.tracking_number );
1814          WSH_DEBUG_SV.logmsg(l_module_name, 'transaction_temp_id            => ' || p_changed_attributes(i).transaction_temp_id           || ' , => ' || l_delivery_line_info.transaction_temp_id );
1815          WSH_DEBUG_SV.logmsg(l_module_name, 'unit_number                    => ' || p_changed_attributes(i).unit_number                   || ' , => ' || l_delivery_line_info.unit_number );
1816          WSH_DEBUG_SV.logmsg(l_module_name, 'unit_price                     => ' || p_changed_attributes(i).unit_price                    || ' , => ' || l_delivery_line_info.unit_price );
1817          WSH_DEBUG_SV.logmsg(l_module_name, 'volume                         => ' || p_changed_attributes(i).volume                        || ' , => ' || l_delivery_line_info.volume );
1818          WSH_DEBUG_SV.logmsg(l_module_name, 'volume_uom_code                => ' || p_changed_attributes(i).volume_uom_code               || ' , => ' || l_delivery_line_info.volume_uom_code );
1819          WSH_DEBUG_SV.logmsg(l_module_name, 'weight_uom_code                => ' || p_changed_attributes(i).weight_uom_code               || ' , => ' || l_delivery_line_info.weight_uom_code );
1820          WSH_DEBUG_SV.logmsg(l_module_name, 'filled_volume                  => ' || p_changed_attributes(i).filled_volume                 || ' , => ' || l_delivery_line_info.filled_volume );
1821          WSH_DEBUG_SV.logmsg(l_module_name, 'Changed Subinventory           => ' || p_changed_attributes(i).subinventory                  || ' , => ' || l_delivery_line_info.original_subinventory );
1822       END IF;
1823       --
1824       */
1825 
1826       IF (
1827              ( ( nvl(p_changed_attributes(i).arrival_set_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.arrival_set_id, FND_API.G_MISS_NUM ) )
1828               or ( p_changed_attributes(i).arrival_set_id = FND_API.G_MISS_NUM ) )
1829          and ( (  nvl(p_changed_attributes(i).ato_line_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ato_line_id, FND_API.G_MISS_NUM ) )
1830               or ( p_changed_attributes(i).ato_line_id = FND_API.G_MISS_NUM ) )
1831          and ( (  nvl(p_changed_attributes(i).attribute1, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute1, FND_API.G_MISS_CHAR ) )
1832               or ( p_changed_attributes(i).attribute1 = FND_API.G_MISS_CHAR ) )
1833          and ( (  nvl(p_changed_attributes(i).attribute10, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute10, FND_API.G_MISS_CHAR ) )
1834               or ( p_changed_attributes(i).attribute10 = FND_API.G_MISS_CHAR ) )
1835          and ( (  nvl(p_changed_attributes(i).attribute11, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute11, FND_API.G_MISS_CHAR ) )
1836               or ( p_changed_attributes(i).attribute11 = FND_API.G_MISS_CHAR ) )
1837          and ( (  nvl(p_changed_attributes(i).attribute12, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute12, FND_API.G_MISS_CHAR ) )
1838               or ( p_changed_attributes(i).attribute12 = FND_API.G_MISS_CHAR ) )
1839          and ( (  nvl(p_changed_attributes(i).attribute13, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute13, FND_API.G_MISS_CHAR ) )
1840               or ( p_changed_attributes(i).attribute13 = FND_API.G_MISS_CHAR ) )
1841          and ( (  nvl(p_changed_attributes(i).attribute14, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute14, FND_API.G_MISS_CHAR ) )
1842               or ( p_changed_attributes(i).attribute14 = FND_API.G_MISS_CHAR ) )
1843          and ( (  nvl(p_changed_attributes(i).attribute15, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute15, FND_API.G_MISS_CHAR ) )
1844               or ( p_changed_attributes(i).attribute15 = FND_API.G_MISS_CHAR ) )
1845          and ( (  nvl(p_changed_attributes(i).attribute2, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute2, FND_API.G_MISS_CHAR ) )
1846               or ( p_changed_attributes(i).attribute2 = FND_API.G_MISS_CHAR ) )
1847          and ( (  nvl(p_changed_attributes(i).attribute3, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute3, FND_API.G_MISS_CHAR ) )
1848               or ( p_changed_attributes(i).attribute3 = FND_API.G_MISS_CHAR ) )
1849          and ( (  nvl(p_changed_attributes(i).attribute4, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute4, FND_API.G_MISS_CHAR ) )
1850               or ( p_changed_attributes(i).attribute4 = FND_API.G_MISS_CHAR ) )
1851          and ( (  nvl(p_changed_attributes(i).attribute5, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute5, FND_API.G_MISS_CHAR ) )
1852               or ( p_changed_attributes(i).attribute5 = FND_API.G_MISS_CHAR ) )
1853          and ( (  nvl(p_changed_attributes(i).attribute6, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute6, FND_API.G_MISS_CHAR ) )
1854               or ( p_changed_attributes(i).attribute6 = FND_API.G_MISS_CHAR ) )
1855          and ( (  nvl(p_changed_attributes(i).attribute7, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute7, FND_API.G_MISS_CHAR ) )
1856               or ( p_changed_attributes(i).attribute7 = FND_API.G_MISS_CHAR ) )
1857          and ( (  nvl(p_changed_attributes(i).attribute8, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute8, FND_API.G_MISS_CHAR ) )
1858               or ( p_changed_attributes(i).attribute8 = FND_API.G_MISS_CHAR ) )
1859          and ( (  nvl(p_changed_attributes(i).attribute9, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute9, FND_API.G_MISS_CHAR ) )
1860               or ( p_changed_attributes(i).attribute9 = FND_API.G_MISS_CHAR ) )
1861          and ( (  nvl(p_changed_attributes(i).attribute_category, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.attribute_category, FND_API.G_MISS_CHAR ) )
1862               or ( p_changed_attributes(i).attribute_category = FND_API.G_MISS_CHAR ) )
1863          and ( (  nvl(p_changed_attributes(i).cancelled_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.cancelled_quantity, FND_API.G_MISS_NUM ) )
1864               or ( p_changed_attributes(i).cancelled_quantity = FND_API.G_MISS_NUM ) )
1865          and ( (  nvl(p_changed_attributes(i).cancelled_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.cancelled_quantity2, FND_API.G_MISS_NUM ) )
1866               or ( p_changed_attributes(i).cancelled_quantity2 = FND_API.G_MISS_NUM ) )
1867          and ( (  nvl(p_changed_attributes(i).carrier_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.carrier_id, FND_API.G_MISS_NUM ) )
1868               or ( p_changed_attributes(i).carrier_id = FND_API.G_MISS_NUM ) )
1869          and ( (  nvl(p_changed_attributes(i).classification, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.classification, FND_API.G_MISS_CHAR ) )
1870               or ( p_changed_attributes(i).classification = FND_API.G_MISS_CHAR ) )
1871          and ( (  nvl(p_changed_attributes(i).commodity_code_cat_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.commodity_code_cat_id, FND_API.G_MISS_NUM ) )
1872               or ( p_changed_attributes(i).commodity_code_cat_id = FND_API.G_MISS_NUM ) )
1873          and ( (  nvl(p_changed_attributes(i).container_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.container_flag, FND_API.G_MISS_CHAR ) )
1874               or ( p_changed_attributes(i).container_flag = FND_API.G_MISS_CHAR ) )
1875          and ( (  nvl(p_changed_attributes(i).container_name, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.container_name, FND_API.G_MISS_CHAR ) )
1876               or ( p_changed_attributes(i).container_name = FND_API.G_MISS_CHAR ) )
1877          and ( (  nvl(p_changed_attributes(i).container_type_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.container_type_code, FND_API.G_MISS_CHAR ) )
1878               or ( p_changed_attributes(i).container_type_code = FND_API.G_MISS_CHAR ) )
1879          and ( (  nvl(p_changed_attributes(i).country_of_origin, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.country_of_origin, FND_API.G_MISS_CHAR ) )
1880               or ( p_changed_attributes(i).country_of_origin = FND_API.G_MISS_CHAR ) )
1881          and ( (  nvl(p_changed_attributes(i).currency_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.currency_code, FND_API.G_MISS_CHAR ) )
1882               or ( p_changed_attributes(i).currency_code = FND_API.G_MISS_CHAR ) )
1883          and ( (  nvl(p_changed_attributes(i).cust_model_serial_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.cust_model_serial_number, FND_API.G_MISS_CHAR ) )
1884               or ( p_changed_attributes(i).cust_model_serial_number = FND_API.G_MISS_CHAR ) )
1885          and ( (  nvl(p_changed_attributes(i).cust_po_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.cust_po_number, FND_API.G_MISS_CHAR ) )
1886               or ( p_changed_attributes(i).cust_po_number = FND_API.G_MISS_CHAR ) )
1887          and ( (  nvl(p_changed_attributes(i).customer_dock_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.customer_dock_code, FND_API.G_MISS_CHAR ) )
1888               or ( p_changed_attributes(i).customer_dock_code = FND_API.G_MISS_CHAR ) )
1889          and ( (  nvl(p_changed_attributes(i).customer_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.customer_id, FND_API.G_MISS_NUM ) )
1890               or ( p_changed_attributes(i).customer_id = FND_API.G_MISS_NUM ) )
1891          and ( (  nvl(p_changed_attributes(i).customer_job, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.customer_job, FND_API.G_MISS_CHAR ) )
1892               or ( p_changed_attributes(i).customer_job = FND_API.G_MISS_CHAR ) )
1893          and ( (  nvl(p_changed_attributes(i).customer_prod_seq, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.customer_prod_seq, FND_API.G_MISS_CHAR ) )
1894               or ( p_changed_attributes(i).customer_prod_seq = FND_API.G_MISS_CHAR ) )
1895          and ( (  nvl(p_changed_attributes(i).customer_production_line, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.customer_production_line, FND_API.G_MISS_CHAR ) )
1896               or ( p_changed_attributes(i).customer_production_line = FND_API.G_MISS_CHAR ) )
1897          and ( (  nvl(p_changed_attributes(i).customer_requested_lot_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.customer_requested_lot_flag, FND_API.G_MISS_CHAR ) )
1898               or ( p_changed_attributes(i).customer_requested_lot_flag = FND_API.G_MISS_CHAR ) )
1899          and ( (  nvl(p_changed_attributes(i).cycle_count_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.cycle_count_quantity, FND_API.G_MISS_NUM ) )
1900               or ( p_changed_attributes(i).cycle_count_quantity = FND_API.G_MISS_NUM ) )
1901          and ( (  nvl(p_changed_attributes(i).cycle_count_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.cycle_count_quantity2, FND_API.G_MISS_NUM ) )
1902               or ( p_changed_attributes(i).cycle_count_quantity2 = FND_API.G_MISS_NUM ) )
1903          and ( (  nvl(p_changed_attributes(i).date_requested, FND_API.G_MISS_DATE) = nvl(l_delivery_line_info.date_requested, FND_API.G_MISS_DATE ) )
1904               or ( p_changed_attributes(i).date_requested = FND_API.G_MISS_DATE ) )
1905          and ( (  nvl(p_changed_attributes(i).date_scheduled, FND_API.G_MISS_DATE) = nvl(l_delivery_line_info.date_scheduled, FND_API.G_MISS_DATE ) )
1906               or ( p_changed_attributes(i).date_scheduled = FND_API.G_MISS_DATE ) )
1907          and ( (  nvl(p_changed_attributes(i).deliver_to_contact_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.deliver_to_contact_id, FND_API.G_MISS_NUM ) )
1908               or ( p_changed_attributes(i).deliver_to_contact_id = FND_API.G_MISS_NUM ) )
1909          and ( (  nvl(p_changed_attributes(i).deliver_to_org_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.deliver_to_site_use_id, FND_API.G_MISS_NUM ) )
1910               or ( p_changed_attributes(i).deliver_to_org_id = FND_API.G_MISS_NUM ) )
1911          and ( (  nvl(p_changed_attributes(i).delivered_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.delivered_quantity, FND_API.G_MISS_NUM ) )
1912               or ( p_changed_attributes(i).delivered_quantity = FND_API.G_MISS_NUM ) )
1913          and ( (  nvl(p_changed_attributes(i).delivered_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.delivered_quantity2, FND_API.G_MISS_NUM ) )
1914               or ( p_changed_attributes(i).delivered_quantity2 = FND_API.G_MISS_NUM ) )
1915          and ( (  nvl(p_changed_attributes(i).delivery_detail_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.delivery_detail_id, FND_API.G_MISS_NUM ) )
1916               or ( p_changed_attributes(i).delivery_detail_id = FND_API.G_MISS_NUM ) )
1917          and ( (  nvl(p_changed_attributes(i).dep_plan_required_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.dep_plan_required_flag, FND_API.G_MISS_CHAR ) )
1918               or ( p_changed_attributes(i).dep_plan_required_flag = FND_API.G_MISS_CHAR ) )
1919          and ( (  nvl(p_changed_attributes(i).detail_container_item_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.detail_container_item_id, FND_API.G_MISS_NUM ) )
1920               or ( p_changed_attributes(i).detail_container_item_id = FND_API.G_MISS_NUM ) )
1921          and ( (  nvl(p_changed_attributes(i).fill_percent, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.fill_percent, FND_API.G_MISS_NUM ) )
1922               or ( p_changed_attributes(i).fill_percent = FND_API.G_MISS_NUM ) )
1923          and ( (  nvl(p_changed_attributes(i).fob_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.fob_code, FND_API.G_MISS_CHAR ) )
1924               or ( p_changed_attributes(i).fob_code = FND_API.G_MISS_CHAR ) )
1925          and ( (  nvl(p_changed_attributes(i).freight_class_cat_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.freight_class_cat_id, FND_API.G_MISS_NUM ) )
1926               or ( p_changed_attributes(i).freight_class_cat_id = FND_API.G_MISS_NUM ) )
1927          and ( (  nvl(p_changed_attributes(i).freight_terms_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.freight_terms_code, FND_API.G_MISS_CHAR ) )
1928               or ( p_changed_attributes(i).freight_terms_code = FND_API.G_MISS_CHAR ) )
1929          and ( (  nvl(p_changed_attributes(i).gross_weight, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.gross_weight, FND_API.G_MISS_NUM ) )
1930               or ( p_changed_attributes(i).gross_weight = FND_API.G_MISS_NUM ) )
1931          and ( (  nvl(p_changed_attributes(i).hazard_class_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.hazard_class_id, FND_API.G_MISS_NUM ) )
1932               or ( p_changed_attributes(i).hazard_class_id = FND_API.G_MISS_NUM ) )
1933          and ( (  nvl(p_changed_attributes(i).hold_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.hold_code, FND_API.G_MISS_CHAR ) )
1934               or ( p_changed_attributes(i).hold_code = FND_API.G_MISS_CHAR ) )
1935          and ( (  nvl(p_changed_attributes(i).inspection_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.inspection_flag, FND_API.G_MISS_CHAR ) )
1936               or ( p_changed_attributes(i).inspection_flag = FND_API.G_MISS_CHAR ) )
1937          and ( (  nvl(p_changed_attributes(i).intmed_ship_to_contact_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.intmed_ship_to_contact_id, FND_API.G_MISS_NUM ) )
1938               or ( p_changed_attributes(i).intmed_ship_to_contact_id = FND_API.G_MISS_NUM ) )
1939          and ( (  nvl(p_changed_attributes(i).inv_interfaced_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.inv_interfaced_flag, FND_API.G_MISS_CHAR ) )
1940               or ( p_changed_attributes(i).inv_interfaced_flag = FND_API.G_MISS_CHAR ) )
1941          and ( (  nvl(p_changed_attributes(i).inventory_item_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.inventory_item_id, FND_API.G_MISS_NUM ) )
1942               or ( p_changed_attributes(i).inventory_item_id = FND_API.G_MISS_NUM ) )
1943          and ( (  nvl(p_changed_attributes(i).item_description, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.item_description, FND_API.G_MISS_CHAR ) )
1944               or ( p_changed_attributes(i).item_description = FND_API.G_MISS_CHAR ) )
1945          and ( (  nvl(p_changed_attributes(i).load_seq_number, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.load_seq_number, FND_API.G_MISS_NUM ) )
1946               or ( p_changed_attributes(i).load_seq_number = FND_API.G_MISS_NUM ) )
1947          and ( (  nvl(p_changed_attributes(i).locator_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.locator_id, FND_API.G_MISS_NUM ) )
1948               or ( p_changed_attributes(i).locator_id = FND_API.G_MISS_NUM ) )
1949          and ( (  nvl(p_changed_attributes(i).lot_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.lot_number, FND_API.G_MISS_CHAR ) )
1950               or ( p_changed_attributes(i).lot_number = FND_API.G_MISS_CHAR ) )
1951          and ( (  nvl(p_changed_attributes(i).lpn_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.lpn_id, FND_API.G_MISS_NUM ) )
1952               or ( p_changed_attributes(i).lpn_id = FND_API.G_MISS_NUM ) )
1953          and ( (  nvl(p_changed_attributes(i).master_container_item_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.master_container_item_id, FND_API.G_MISS_NUM ) )
1954               or ( p_changed_attributes(i).master_container_item_id = FND_API.G_MISS_NUM ) )
1955          and ( (  nvl(p_changed_attributes(i).master_serial_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.master_serial_number, FND_API.G_MISS_CHAR ) )
1956               or ( p_changed_attributes(i).master_serial_number = FND_API.G_MISS_CHAR ) )
1957          and ( (  nvl(p_changed_attributes(i).maximum_load_weight, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.maximum_load_weight, FND_API.G_MISS_NUM ) )
1958               or ( p_changed_attributes(i).maximum_load_weight = FND_API.G_MISS_NUM ) )
1959          and ( (  nvl(p_changed_attributes(i).maximum_volume, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.maximum_volume, FND_API.G_MISS_NUM ) )
1960               or ( p_changed_attributes(i).maximum_volume = FND_API.G_MISS_NUM ) )
1961          and ( (  nvl(p_changed_attributes(i).minimum_fill_percent, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.minimum_fill_percent, FND_API.G_MISS_NUM ) )
1962               or ( p_changed_attributes(i).minimum_fill_percent = FND_API.G_MISS_NUM ) )
1963          and ( (  nvl(p_changed_attributes(i).move_order_line_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.move_order_line_id, FND_API.G_MISS_NUM ) )
1964               or ( p_changed_attributes(i).move_order_line_id = FND_API.G_MISS_NUM ) )
1965          and ( (  nvl(p_changed_attributes(i).movement_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.movement_id, FND_API.G_MISS_NUM ) )
1966               or ( p_changed_attributes(i).movement_id = FND_API.G_MISS_NUM ) )
1967          and ( (  nvl(p_changed_attributes(i).mvt_stat_status, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.mvt_stat_status, FND_API.G_MISS_CHAR ) )
1968               or ( p_changed_attributes(i).mvt_stat_status = FND_API.G_MISS_CHAR ) )
1969          and ( (  nvl(p_changed_attributes(i).net_weight, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.net_weight, FND_API.G_MISS_NUM ) )
1970               or ( p_changed_attributes(i).net_weight = FND_API.G_MISS_NUM ) )
1971          and ( (  nvl(p_changed_attributes(i).oe_interfaced_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.oe_interfaced_flag, FND_API.G_MISS_CHAR ) )
1972               or ( p_changed_attributes(i).oe_interfaced_flag = FND_API.G_MISS_CHAR ) )
1973       -- Only ordered quantity and uom is allowed to update as part of CMS.
1974       /*
1975          and ( (  nvl(p_changed_attributes(i).order_quantity_uom, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.src_requested_quantity_uom, FND_API.G_MISS_CHAR ) )
1976               or ( p_changed_attributes(i).order_quantity_uom = FND_API.G_MISS_CHAR ) )
1977          and ( (  nvl(p_changed_attributes(i).ordered_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.src_requested_quantity, FND_API.G_MISS_NUM ) )
1978               or ( p_changed_attributes(i).ordered_quantity = FND_API.G_MISS_NUM ) )
1979       */
1980          and ( (  nvl(p_changed_attributes(i).ordered_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.src_requested_quantity2, FND_API.G_MISS_NUM ) )
1981               or ( p_changed_attributes(i).ordered_quantity2 = FND_API.G_MISS_NUM ) )
1982          and ( (  nvl(p_changed_attributes(i).ordered_quantity_uom2, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.src_requested_quantity_uom2, FND_API.G_MISS_CHAR ) )
1983               or ( p_changed_attributes(i).ordered_quantity_uom2 = FND_API.G_MISS_CHAR ) )
1984          and ( (  nvl(p_changed_attributes(i).org_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.org_id, FND_API.G_MISS_NUM ) )
1985               or ( p_changed_attributes(i).org_id = FND_API.G_MISS_NUM ) )
1986          and ( (  nvl(p_changed_attributes(i).organization_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.organization_id, FND_API.G_MISS_NUM ) )
1987               or ( p_changed_attributes(i).organization_id = FND_API.G_MISS_NUM ) )
1988          and ( (  nvl(p_changed_attributes(i).subinventory, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.original_subinventory, FND_API.G_MISS_CHAR ) )
1989               or ( p_changed_attributes(i).subinventory = FND_API.G_MISS_CHAR ) )
1990          and ( (  nvl(p_changed_attributes(i).packing_instructions, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.packing_instructions, FND_API.G_MISS_CHAR ) )
1991               or ( p_changed_attributes(i).packing_instructions = FND_API.G_MISS_CHAR ) )
1992          and ( (  nvl(p_changed_attributes(i).pickable_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.pickable_flag, FND_API.G_MISS_CHAR ) )
1993               or ( p_changed_attributes(i).pickable_flag = FND_API.G_MISS_CHAR ) )
1994          and ( (  nvl(p_changed_attributes(i).picked_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.picked_quantity, FND_API.G_MISS_NUM ) )
1995               or ( p_changed_attributes(i).picked_quantity = FND_API.G_MISS_NUM ) )
1996          and ( (  nvl(p_changed_attributes(i).picked_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.picked_quantity2, FND_API.G_MISS_NUM ) )
1997               or ( p_changed_attributes(i).picked_quantity2 = FND_API.G_MISS_NUM ) )
1998          and ( (  nvl(p_changed_attributes(i).preferred_grade, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.preferred_grade, FND_API.G_MISS_CHAR ) )
1999               or ( p_changed_attributes(i).preferred_grade = FND_API.G_MISS_CHAR ) )
2000          and ( (  nvl(p_changed_attributes(i).project_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.project_id, FND_API.G_MISS_NUM ) )
2001               or ( p_changed_attributes(i).project_id = FND_API.G_MISS_NUM ) )
2002          and ( (  nvl(p_changed_attributes(i).quality_control_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.quality_control_quantity, FND_API.G_MISS_NUM ) )
2003               or ( p_changed_attributes(i).quality_control_quantity = FND_API.G_MISS_NUM ) )
2004          and ( (  nvl(p_changed_attributes(i).quality_control_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.quality_control_quantity2, FND_API.G_MISS_NUM ) )
2005               or ( p_changed_attributes(i).quality_control_quantity2 = FND_API.G_MISS_NUM ) )
2006          and ( (  nvl(p_changed_attributes(i).received_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.received_quantity, FND_API.G_MISS_NUM ) )
2007               or ( p_changed_attributes(i).received_quantity = FND_API.G_MISS_NUM ) )
2008          and ( (  nvl(p_changed_attributes(i).received_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.received_quantity2, FND_API.G_MISS_NUM ) )
2009               or ( p_changed_attributes(i).received_quantity2 = FND_API.G_MISS_NUM ) )
2010          and ( (  nvl(p_changed_attributes(i).released_status, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.released_status, FND_API.G_MISS_CHAR ) )
2011               or ( p_changed_attributes(i).released_status = FND_API.G_MISS_CHAR ) )
2012          and ( (  nvl(p_changed_attributes(i).request_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.request_id, FND_API.G_MISS_NUM ) )
2013               or ( p_changed_attributes(i).request_id = FND_API.G_MISS_NUM ) )
2014          and ( (  nvl(p_changed_attributes(i).revision, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.revision, FND_API.G_MISS_CHAR ) )
2015               or ( p_changed_attributes(i).revision = FND_API.G_MISS_CHAR ) )
2016          and ( (  nvl(p_changed_attributes(i).seal_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.seal_code, FND_API.G_MISS_CHAR ) )
2017               or ( p_changed_attributes(i).seal_code = FND_API.G_MISS_CHAR ) )
2018          and ( (  nvl(p_changed_attributes(i).serial_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.serial_number, FND_API.G_MISS_CHAR ) )
2019               or ( p_changed_attributes(i).serial_number = FND_API.G_MISS_CHAR ) )
2020          and ( (  nvl(p_changed_attributes(i).ship_from_org_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.organization_id, FND_API.G_MISS_NUM ) )
2021               or ( p_changed_attributes(i).ship_from_org_id = FND_API.G_MISS_NUM ) )
2022          and ( (  nvl(p_changed_attributes(i).ship_model_complete_flag, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.ship_model_complete_flag, FND_API.G_MISS_CHAR ) )
2023               or ( p_changed_attributes(i).ship_model_complete_flag = FND_API.G_MISS_CHAR ) )
2024          and ( (  nvl(p_changed_attributes(i).ship_set_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_set_id, FND_API.G_MISS_NUM ) )
2025               or ( p_changed_attributes(i).ship_set_id = FND_API.G_MISS_NUM ) )
2026          and ( (  nvl(p_changed_attributes(i).ship_to_contact_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_to_contact_id, FND_API.G_MISS_NUM ) )
2027               or ( p_changed_attributes(i).ship_to_contact_id = FND_API.G_MISS_NUM ) )
2028          and ( (  nvl(p_changed_attributes(i).ship_to_org_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_to_site_use_id, FND_API.G_MISS_NUM ) )
2029               or ( p_changed_attributes(i).ship_to_org_id = FND_API.G_MISS_NUM ) )
2030          and ( (  nvl(p_changed_attributes(i).ship_to_site_use_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_to_site_use_id, FND_API.G_MISS_NUM ) )
2031               or ( p_changed_attributes(i).ship_to_site_use_id = FND_API.G_MISS_NUM ) )
2032          and ( (  nvl(p_changed_attributes(i).ship_tolerance_above, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_tolerance_above, FND_API.G_MISS_NUM ) )
2033               or ( p_changed_attributes(i).ship_tolerance_above = FND_API.G_MISS_NUM ) )
2034          and ( (  nvl(p_changed_attributes(i).ship_tolerance_below, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.ship_tolerance_below, FND_API.G_MISS_NUM ) )
2035               or ( p_changed_attributes(i).ship_tolerance_below = FND_API.G_MISS_NUM ) )
2036          and ( (  nvl(p_changed_attributes(i).shipment_priority_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.shipment_priority_code, FND_API.G_MISS_CHAR ) )
2037               or ( p_changed_attributes(i).shipment_priority_code = FND_API.G_MISS_CHAR ) )
2038          and ( (  nvl(p_changed_attributes(i).shipped_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.shipped_quantity, FND_API.G_MISS_NUM ) )
2039               or ( p_changed_attributes(i).shipped_quantity = FND_API.G_MISS_NUM ) )
2040          and ( (  nvl(p_changed_attributes(i).shipped_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.shipped_quantity2, FND_API.G_MISS_NUM ) )
2041               or ( p_changed_attributes(i).shipped_quantity2 = FND_API.G_MISS_NUM ) )
2042          and ( (  nvl(p_changed_attributes(i).shipping_instructions, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.shipping_instructions, FND_API.G_MISS_CHAR ) )
2043               or ( p_changed_attributes(i).shipping_instructions = FND_API.G_MISS_CHAR ) )
2044          and ( (  nvl(p_changed_attributes(i).shipping_method_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.ship_method_code, FND_API.G_MISS_CHAR ) )
2045               or ( p_changed_attributes(i).shipping_method_code = FND_API.G_MISS_CHAR ) )
2046          and ( (  nvl(p_changed_attributes(i).sold_to_contact_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.sold_to_contact_id, FND_API.G_MISS_NUM ) )
2047               or ( p_changed_attributes(i).sold_to_contact_id = FND_API.G_MISS_NUM ) )
2048          and ( (  nvl(p_changed_attributes(i).sold_to_org_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.customer_id, FND_API.G_MISS_NUM ) )
2049               or ( p_changed_attributes(i).sold_to_org_id = FND_API.G_MISS_NUM ) )
2050          and ( (  nvl(p_changed_attributes(i).source_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.source_code, FND_API.G_MISS_CHAR ) )
2051               or ( p_changed_attributes(i).source_code = FND_API.G_MISS_CHAR ) )
2052          and ( (  nvl(p_changed_attributes(i).source_header_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.source_header_id, FND_API.G_MISS_NUM ) )
2053               or ( p_changed_attributes(i).source_header_id = FND_API.G_MISS_NUM ) )
2054          and ( (  nvl(p_changed_attributes(i).source_header_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.source_header_number, FND_API.G_MISS_CHAR ) )
2055               or ( p_changed_attributes(i).source_header_number = FND_API.G_MISS_CHAR ) )
2056          and ( (  nvl(p_changed_attributes(i).source_header_type_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.source_header_type_id, FND_API.G_MISS_NUM ) )
2057               or ( p_changed_attributes(i).source_header_type_id = FND_API.G_MISS_NUM ) )
2058          and ( (  nvl(p_changed_attributes(i).source_header_type_name, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.source_header_type_name, FND_API.G_MISS_CHAR ) )
2059               or ( p_changed_attributes(i).source_header_type_name = FND_API.G_MISS_CHAR ) )
2060          and ( (  nvl(p_changed_attributes(i).source_line_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.source_line_id, FND_API.G_MISS_NUM ) )
2061               or ( p_changed_attributes(i).source_line_id = FND_API.G_MISS_NUM ) )
2062          and ( (  nvl(p_changed_attributes(i).source_line_set_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.source_line_set_id, FND_API.G_MISS_NUM ) )
2063               or ( p_changed_attributes(i).source_line_set_id = FND_API.G_MISS_NUM ) )
2064          and ( (  nvl(p_changed_attributes(i).split_from_delivery_detail_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.split_from_delivery_detail_id, FND_API.G_MISS_NUM ) )
2065               or ( p_changed_attributes(i).split_from_delivery_detail_id = FND_API.G_MISS_NUM ) )
2066          and ( (  nvl(p_changed_attributes(i).src_requested_quantity, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.src_requested_quantity, FND_API.G_MISS_NUM ) )
2067               or ( p_changed_attributes(i).src_requested_quantity = FND_API.G_MISS_NUM ) )
2068          and ( (  nvl(p_changed_attributes(i).src_requested_quantity2, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.src_requested_quantity2, FND_API.G_MISS_NUM ) )
2069               or ( p_changed_attributes(i).src_requested_quantity2 = FND_API.G_MISS_NUM ) )
2070          and ( (  nvl(p_changed_attributes(i).src_requested_quantity_uom, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.src_requested_quantity_uom, FND_API.G_MISS_CHAR ) )
2071               or ( p_changed_attributes(i).src_requested_quantity_uom = FND_API.G_MISS_CHAR ) )
2072          and ( (  nvl(p_changed_attributes(i).src_requested_quantity_uom2, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.src_requested_quantity_uom2, FND_API.G_MISS_CHAR ) )
2073               or ( p_changed_attributes(i).src_requested_quantity_uom2 = FND_API.G_MISS_CHAR ) )
2074          and ( (  nvl(p_changed_attributes(i).task_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.task_id, FND_API.G_MISS_NUM ) )
2075               or ( p_changed_attributes(i).task_id = FND_API.G_MISS_NUM ) )
2076          and ( (  nvl(p_changed_attributes(i).to_serial_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.to_serial_number, FND_API.G_MISS_CHAR ) )
2077               or ( p_changed_attributes(i).to_serial_number = FND_API.G_MISS_CHAR ) )
2078          and ( (  nvl(p_changed_attributes(i).top_model_line_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.top_model_line_id, FND_API.G_MISS_NUM ) )
2079               or ( p_changed_attributes(i).top_model_line_id = FND_API.G_MISS_NUM ) )
2080          and ( (  nvl(p_changed_attributes(i).tp_attribute1, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute1, FND_API.G_MISS_CHAR ) )
2081               or ( p_changed_attributes(i).tp_attribute1 = FND_API.G_MISS_CHAR ) )
2082          and ( (  nvl(p_changed_attributes(i).tp_attribute10, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute10, FND_API.G_MISS_CHAR ) )
2083               or ( p_changed_attributes(i).tp_attribute10 = FND_API.G_MISS_CHAR ) )
2084          and ( (  nvl(p_changed_attributes(i).tp_attribute11, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute11, FND_API.G_MISS_CHAR ) )
2085               or ( p_changed_attributes(i).tp_attribute11 = FND_API.G_MISS_CHAR ) )
2086          and ( (  nvl(p_changed_attributes(i).tp_attribute12, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute12, FND_API.G_MISS_CHAR ) )
2087               or ( p_changed_attributes(i).tp_attribute12 = FND_API.G_MISS_CHAR ) )
2088          and ( (  nvl(p_changed_attributes(i).tp_attribute13, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute13, FND_API.G_MISS_CHAR ) )
2089               or ( p_changed_attributes(i).tp_attribute13 = FND_API.G_MISS_CHAR ) )
2090          and ( (  nvl(p_changed_attributes(i).tp_attribute14, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute14, FND_API.G_MISS_CHAR ) )
2091               or ( p_changed_attributes(i).tp_attribute14 = FND_API.G_MISS_CHAR ) )
2092          and ( (  nvl(p_changed_attributes(i).tp_attribute15, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute15, FND_API.G_MISS_CHAR ) )
2093               or ( p_changed_attributes(i).tp_attribute15 = FND_API.G_MISS_CHAR ) )
2094          and ( (  nvl(p_changed_attributes(i).tp_attribute2, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute2, FND_API.G_MISS_CHAR ) )
2095               or ( p_changed_attributes(i).tp_attribute2 = FND_API.G_MISS_CHAR ) )
2096          and ( (  nvl(p_changed_attributes(i).tp_attribute3, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute3, FND_API.G_MISS_CHAR ) )
2097               or ( p_changed_attributes(i).tp_attribute3 = FND_API.G_MISS_CHAR ) )
2098          and ( (  nvl(p_changed_attributes(i).tp_attribute4, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute4, FND_API.G_MISS_CHAR ) )
2099               or ( p_changed_attributes(i).tp_attribute4 = FND_API.G_MISS_CHAR ) )
2100          and ( (  nvl(p_changed_attributes(i).tp_attribute5, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute5, FND_API.G_MISS_CHAR ) )
2101               or ( p_changed_attributes(i).tp_attribute5 = FND_API.G_MISS_CHAR ) )
2102          and ( (  nvl(p_changed_attributes(i).tp_attribute6, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute6, FND_API.G_MISS_CHAR ) )
2103               or ( p_changed_attributes(i).tp_attribute6 = FND_API.G_MISS_CHAR ) )
2104          and ( (  nvl(p_changed_attributes(i).tp_attribute7, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute7, FND_API.G_MISS_CHAR ) )
2105               or ( p_changed_attributes(i).tp_attribute7 = FND_API.G_MISS_CHAR ) )
2106          and ( (  nvl(p_changed_attributes(i).tp_attribute8, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute8, FND_API.G_MISS_CHAR ) )
2107               or ( p_changed_attributes(i).tp_attribute8 = FND_API.G_MISS_CHAR ) )
2108          and ( (  nvl(p_changed_attributes(i).tp_attribute9, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute9, FND_API.G_MISS_CHAR ) )
2109               or ( p_changed_attributes(i).tp_attribute9 = FND_API.G_MISS_CHAR ) )
2110          and ( (  nvl(p_changed_attributes(i).tp_attribute_category, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tp_attribute_category, FND_API.G_MISS_CHAR ) )
2111               or ( p_changed_attributes(i).tp_attribute_category = FND_API.G_MISS_CHAR ) )
2112          and ( (  nvl(p_changed_attributes(i).tracking_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.tracking_number, FND_API.G_MISS_CHAR ) )
2113               or ( p_changed_attributes(i).tracking_number = FND_API.G_MISS_CHAR ) )
2114          and ( (  nvl(p_changed_attributes(i).transaction_temp_id, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.transaction_temp_id, FND_API.G_MISS_NUM ) )
2115               or ( p_changed_attributes(i).transaction_temp_id = FND_API.G_MISS_NUM ) )
2116          and ( (  nvl(p_changed_attributes(i).unit_number, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.unit_number, FND_API.G_MISS_CHAR ) )
2117               or ( p_changed_attributes(i).unit_number = FND_API.G_MISS_CHAR ) )
2118          and ( (  nvl(p_changed_attributes(i).unit_price, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.unit_price, FND_API.G_MISS_NUM ) )
2119               or ( p_changed_attributes(i).unit_price = FND_API.G_MISS_NUM ) )
2120          and ( (  nvl(p_changed_attributes(i).volume, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.volume, FND_API.G_MISS_NUM ) )
2121               or ( p_changed_attributes(i).volume = FND_API.G_MISS_NUM ) )
2122          and ( (  nvl(p_changed_attributes(i).volume_uom_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.volume_uom_code, FND_API.G_MISS_CHAR ) )
2123               or ( p_changed_attributes(i).volume_uom_code = FND_API.G_MISS_CHAR ) )
2124          and ( (  nvl(p_changed_attributes(i).weight_uom_code, FND_API.G_MISS_CHAR) = nvl(l_delivery_line_info.weight_uom_code, FND_API.G_MISS_CHAR ) )
2125               or ( p_changed_attributes(i).weight_uom_code = FND_API.G_MISS_CHAR ) )
2126          and ( (  nvl(p_changed_attributes(i).filled_volume, FND_API.G_MISS_NUM) = nvl(l_delivery_line_info.filled_volume, FND_API.G_MISS_NUM ) )
2127               or ( p_changed_attributes(i).filled_volume = FND_API.G_MISS_NUM ) )
2128           )
2129       THEN
2130          --Nothing has been changed
2131          --
2132          IF l_debug_on THEN
2133             WSH_DEBUG_SV.logmsg(l_module_name, 'INSIDE VALIDATION SUCCESS' );
2134          END IF;
2135          --
2136          x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
2137       ELSE
2138          --Raise Error
2139          --
2140          IF l_debug_on THEN
2141             WSH_DEBUG_SV.logmsg(l_module_name, 'Attributes does not match so returning error' );
2142          END IF;
2143          --
2144          x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2145       END IF;
2146    END LOOP;
2147 
2148    --
2149    IF l_debug_on THEN
2150       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
2151       WSH_DEBUG_SV.pop(l_module_name);
2152    END IF;
2153    --
2154 EXCEPTION
2155    WHEN OTHERS THEN
2156       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2157       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Validate_Delivery_Line');
2158       --
2159       IF l_debug_on THEN
2160         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2161         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2162       END IF;
2163       --
2164 END Validate_Delivery_Line;
2165 
2166 -- TPW - Distributed Organization Changes - End
2167 
2168 
2169 
2170 END WSH_DELIVERY_DETAILS_UTILITIES;
2171 
2172