DBA Data[Home] [Help]

PACKAGE BODY: APPS.WSH_SHIPMENT_REQUEST_PKG

Source


1 PACKAGE BODY WSH_SHIPMENT_REQUEST_PKG AS
2 /* $Header: WSHSRPKB.pls 120.7 2010/09/06 09:58:45 selsubra noship $ */
3 
4    G_PKG_NAME      CONSTANT VARCHAR2(30) := 'WSH_SHIPMENT_REQUEST_PKG';
5    g_interface_action_code  WSH_NEW_DEL_INTERFACE.INTERFACE_ACTION_CODE%TYPE;
6    g_po_total_time          NUMBER := 0;
7    g_sold_to_ref            VARCHAR2(50) := 'CUST-SOLD-TO-REF';
8    g_ship_to_ref            VARCHAR2(50) := 'CUST-SHIP-TO-REF';
9    g_invoice_to_ref         VARCHAR2(50) := 'CUST-INVOICE-TO-REF';
10    g_deliver_to_ref         VARCHAR2(50) := 'CUST-DELIVER-TO-REF';
11    g_ship_to_address_ref    VARCHAR2(50) := 'CUST-SHIP-TO-ADDRESS-REF';
12    g_invoice_to_address_ref VARCHAR2(50) := 'CUST-INVOICE-ADDRESS-TO-REF';
13    g_deliver_to_address_ref VARCHAR2(50) := 'CUST-DELIVER-TO-ADDRESS-REF';
14    g_sold_to_contact_ref    VARCHAR2(50) := 'CUST-SOLD-TO-CONTACT-REF';
15    g_ship_to_contact_ref    VARCHAR2(50) := 'CUST-SHIP-TO-CONTACT-REF';
16    g_invoice_to_contact_ref VARCHAR2(50) := 'CUST-INVOICE-TO-CONTACT-REF';
17    g_deliver_to_contact_ref VARCHAR2(50) := 'CUST-DELIVER-TO-CONTACT-REF';
18    G_BINARY_LIMIT           NUMBER       := 2147483647; --LSP Project
19 
20 --FORWARD Declaration
21 PROCEDURE Populate_OM_Common_Attr(
22           p_om_header_rec     IN OM_Header_Rec_Type,
23           p_del_interface_rec IN Del_Interface_Rec_Type,
24           x_header_rec        IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type,
25           x_line_tbl          IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type,
26           x_customer_info     OUT NOCOPY OE_ORDER_PUB.Customer_Info_Table_Type,
27           x_return_status     OUT NOCOPY VARCHAR2 );
28 
29 PROCEDURE Print_OE_Header_Record(
30           p_header_rec         IN OE_ORDER_PUB.Header_Rec_Type,
31           p_header_val_rec     IN OE_ORDER_PUB.Header_Val_Rec_Type,
32           p_customer_info      IN OE_ORDER_PUB.Customer_Info_Table_Type,
33           p_action_request_tbl IN OE_ORDER_PUB.Request_Tbl_Type );
34 
35 PROCEDURE Print_OE_Line_Record(
36           p_line_tbl       IN OE_ORDER_PUB.Line_Tbl_Type,
37           p_line_val_tbl   IN OE_ORDER_PUB.Line_Val_Tbl_Type );
38 
39 PROCEDURE Populate_Error_Records(
40           p_interface_id             IN  NUMBER,
41           p_interface_table_name     IN  VARCHAR2,
42           x_interface_errors_rec_tab IN OUT NOCOPY WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_tab,
43           x_return_status            OUT NOCOPY VARCHAR2 );
44 --
45 --=============================================================================
46 -- PUBLIC PROCEDURE :
47 --       Shipment_Request_Inbound
48 --
49 -- PARAMETERS:
50 --       errbuf                 => Message returned to Concurrent Manager
51 --       retcode                => Code (0, 1, 2) returned to Concurrent Manager
52 --       p_transaction_status   => Either AP, ER, NULL
53 --       p_deploy_mode          => Dummy for LSP(Enable or Disable Client)
54 --       p_client_code          => Client Code  -- Modified R12.1.1 LSP PROJECT
55 --       p_from_document_number => From Document Number
56 --       p_to_document_number   => To Document Number
57 --       p_from_creation_date   => From Creation Date
58 --       p_to_creation_date     => To Creation Date
59 --       p_transaction_id       => Transacation id to be processed
60 --       p_log_level            => Either 1(Debug), 0(No Debug)
61 -- COMMENT:
62 --       API will be invoked from Concurrent Manager whenever concurrent program
63 --       'Process Shipment Requests' is triggered.
64 --=============================================================================
65 --
66 PROCEDURE Shipment_Request_Inbound (
67           errbuf                 OUT NOCOPY   VARCHAR2,
68           retcode                OUT NOCOPY   NUMBER,
69           p_transaction_status   IN  VARCHAR2,
70           p_deploy_mode          IN  VARCHAR2,  -- Modified R12.1.1 LSP PROJECT
71           p_client_code          IN  VARCHAR2,  -- Modified R12.1.1 LSP PROJECT
72           p_from_document_number IN  NUMBER,
73           p_to_document_number   IN  NUMBER,
74           p_from_creation_date   IN  VARCHAR2,
75           p_to_creation_date     IN  VARCHAR2,
76           p_transaction_id       IN  NUMBER,
77           p_log_level            IN  NUMBER )
78 IS
79    l_completion_status          VARCHAR2(30);
80    l_return_status              VARCHAR2(1);
81 
82    l_debug_on                 BOOLEAN;
83    l_module_name CONSTANT     VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Shipment_Request_Inbound';
84 BEGIN
85    --
86    WSH_UTIL_CORE.Enable_Concurrent_Log_Print;
87    WSH_UTIL_CORE.Set_Log_Level(p_log_level);
88    --
89    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
90    --
91    IF l_debug_on IS NULL
92    THEN
93        l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
94    END IF;
95    --
96    IF l_debug_on THEN
97       wsh_debug_sv.push(l_module_name);
98       wsh_debug_sv.log(l_module_name, 'p_transaction_status', p_transaction_status);
99       wsh_debug_sv.log(l_module_name, 'p_client_code', p_client_code);  -- Modified R12.1.1 LSP PROJECT
100       wsh_debug_sv.log(l_module_name, 'p_from_document_number', p_from_document_number);
101       wsh_debug_sv.log(l_module_name, 'p_to_document_number', p_to_document_number);
102       wsh_debug_sv.log(l_module_name, 'p_from_creation_date', p_from_creation_date);
103       wsh_debug_sv.log(l_module_name, 'p_to_creation_date', p_to_creation_date);
104       wsh_debug_sv.log(l_module_name, 'p_transaction_id', p_transaction_id);
105       wsh_debug_sv.log(l_module_name, 'p_log_level', p_log_level);
106    END IF;
107    --
108 
109    --
110    IF l_debug_on THEN
111       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Process_Shipment_Request', WSH_DEBUG_SV.C_PROC_LEVEL);
112    END IF;
113    --
114 
115    Process_Shipment_Request(
116             p_commit_flag          => FND_API.G_TRUE,
117             p_transaction_status   => p_transaction_status,
118             p_client_code            => p_client_code,  -- Modified R12.1.1 LSP PROJECT
119             p_from_document_number => p_from_document_number,
120             p_to_document_number   => p_to_document_number,
121             p_from_creation_date   => p_from_creation_date,
122             p_to_creation_date     => p_to_creation_date,
123             p_transaction_id       => p_transaction_id,
124             x_return_status        => l_return_status );
125 
126    --
127    IF l_debug_on THEN
128       WSH_DEBUG_SV.log(l_module_name, 'Return Status of Process_Shipment_Request', l_return_status);
129    END IF;
130    --
131 
132 
133    IF l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
134       l_completion_status := 'SUCCESS';
135       errbuf := 'Process Shipment Requests Program has completed successfully';
136       retcode := '0';
137    ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_WARNING THEN
138       l_completion_status := 'WARNING';
139       errbuf := 'Process Shipment Requests Program has completed with warning';
140       retcode := '1';
141    ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
142       l_completion_status := 'ERROR';
143       errbuf := 'Process Shipment Requests Program has completed with error';
144       retcode := '2';
145    ELSIF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
146       l_completion_status := 'UNEXPECTED ERROR';
147       errbuf := 'Process Shipment Requests Program has completed with unexpected error';
148       retcode := '2';
149    END IF;
150 
151    --
152    IF l_debug_on THEN
153       WSH_DEBUG_SV.log(l_module_name,'l_completion_status', l_completion_status);
154       WSH_DEBUG_SV.log(l_module_name,'errbuf', errbuf);
155       WSH_DEBUG_SV.log(l_module_name,'retcode', retcode);
156       WSH_DEBUG_SV.pop(l_module_name);
157    END IF;
158    --
159 EXCEPTION
160    WHEN OTHERS THEN
161       l_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
162       errbuf := 'Process Shipment Requests Program is completed with unexpected error - ' || SQLCODE;
163       retcode := '2';
164       --
165       IF l_debug_on THEN
166         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
167         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
168       END IF;
169       --
170 END Shipment_Request_Inbound;
171 
172 --
173 --=============================================================================
174 -- PUBLIC PROCEDURE :
175 --       Process_Shipment_Request
176 --
177 -- PARAMETERS:
178 --       p_commit_flag          => Either FND_API.G_TRUE, FND_API.G_FALSE
179 --       p_transaction_status   => Either AP, ER, NULL
180 --       p_client_code          => Client Code   -- Modified R12.1.1 LSP PROJECT
181 --       p_from_document_number => From Document Number
182 --       p_to_document_number   => To Document Number
183 --       p_from_creation_date   => From Creation Date
184 --       p_to_creation_date     => To Creation Date
185 --       p_transaction_id       => Transacation id to be processed
186 --       x_return_status        => Return Status of API (S,W,E,U)
187 -- COMMENT:
188 --       Based on input parameter values, eligble records for processing are
189 --       queried from WTH table. Calling Workflow API WF_ENGINE.handleError to
190 --       process further, if WTH row queried is triggered from Workflow.
191 --       Calling Overloaded API Process_Shipment_Request, if WTH row queried is
192 --       NOT triggered from Workflow.
193 --=============================================================================
194 --
195 PROCEDURE Process_Shipment_Request (
196           p_commit_flag          IN  VARCHAR2,
197           p_transaction_status   IN  VARCHAR2,
198           p_client_code          IN  VARCHAR2,  -- Modified R12.1.1 LSP PROJECT
199           p_from_document_number IN  NUMBER,
200           p_to_document_number   IN  NUMBER,
201           p_from_creation_date   IN  VARCHAR2,
202           p_to_creation_date     IN  VARCHAR2,
203           p_transaction_id       IN  NUMBER,
204           x_return_status        OUT NOCOPY VARCHAR2 )
205 IS
206 
207    CURSOR C_Get_One_Transactions
208    IS
209       SELECT wth.Transaction_ID,
210              wth.Document_Type,
211              wth.Document_Direction,
212              wth.Document_Number,
213              wth.Orig_Document_Number,
214              wth.Entity_Number,
215              wth.Entity_Type,
216              wth.Trading_Partner_ID,
217              wth.Action_Type,
218              wth.Transaction_Status,
219              wth.ECX_Message_ID,
220              wth.Event_Name,
221              wth.Event_Key,
222              wth.Item_Type,
223              wth.Internal_Control_Number,
224              wth.document_revision,
225              wth.Attribute_Category,
226              wth.Attribute1,
227              wth.Attribute2,
228              wth.Attribute3,
229              wth.Attribute4,
230              wth.Attribute5,
231              wth.Attribute6,
232              wth.Attribute7,
233              wth.Attribute8,
234              wth.Attribute9,
235              wth.Attribute10,
236              wth.Attribute11,
237              wth.Attribute12,
238              wth.Attribute13,
239              wth.Attribute14,
240              wth.Attribute15,
241              NULL  -- LSP PROJECT : just added for dependency for client_id
242    FROM   Wsh_Transactions_History wth,
243           Wsh_New_Del_Interface wndi
244    WHERE  wndi.interface_action_code = g_interface_action_code
245    AND    wndi.delivery_interface_id = to_number(wth.entity_number)
246    AND    wth.transaction_id = p_transaction_id
247    AND    wth.transaction_status = nvl(p_transaction_status, wth.transaction_status);
248 
249    l_from_document_number       VARCHAR2(30);
250    l_to_document_number         VARCHAR2(30);
251 
252    cursor c_get_status (v_trx_id NUMBER)
253    is
254       select transaction_status
255       from   wsh_transactions_history
256       where  transaction_id = v_trx_id;
257 
258 
259    l_transaction_rec            WSH_TRANSACTIONS_HISTORY_PKG.Txns_History_Record_Type;
260    l_trx_status                 wsh_transactions_history.transaction_status%TYPE;
261 
262    l_from_creation_date         DATE;
263    l_to_creation_date           DATE;
264 
265    l_total                      NUMBER := 0;
266    l_success                    NUMBER := 0;
267    l_errors                     NUMBER := 0;
268    v_cursorid                   INTEGER;
269    v_ignore                     INTEGER;
270    l_tmp_status                 VARCHAR2(1);
271    l_standalone_mode            VARCHAR2(1);
272    l_document_where             VARCHAR2(200);
273    l_transaction_query          VARCHAR2(15000);
274    l_client_code                VARCHAR2(10); -- Modified R12.1.1 LSP PROJECT
275    --
276    others                       EXCEPTION;
277 
278    l_debug_on                 BOOLEAN;
279    l_module_name CONSTANT     VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Process_Shipment_Request1';
280 BEGIN
281    --
282    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
283    --
284    IF l_debug_on IS NULL
285    THEN
286        l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
287    END IF;
288    --
289    IF l_debug_on THEN
290       wsh_debug_sv.push(l_module_name);
291       wsh_debug_sv.log(l_module_name, 'p_commit_flag', p_commit_flag);
292       wsh_debug_sv.log(l_module_name, 'p_transaction_status', p_transaction_status);
293       wsh_debug_sv.log(l_module_name, 'p_client_code', p_client_code);  -- Modified R12.1.1 LSP PROJECT
294       wsh_debug_sv.log(l_module_name, 'p_from_document_number', p_from_document_number);
295       wsh_debug_sv.log(l_module_name, 'p_to_document_number', p_to_document_number);
296       wsh_debug_sv.log(l_module_name, 'p_from_creation_date', p_from_creation_date);
297       wsh_debug_sv.log(l_module_name, 'p_to_creation_date', p_to_creation_date);
298       wsh_debug_sv.log(l_module_name, 'p_transaction_id', p_transaction_id);
299    END IF;
300    --
301 
302    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
303 
304    --Check if instance is running in Standalone, if not exit out of the program
305    --
306    IF l_debug_on THEN
307       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WMS_DEPLOY.Wms_Deployment_Mode', WSH_DEBUG_SV.C_PROC_LEVEL);
308    END IF;
309    --
310    l_standalone_mode := WMS_DEPLOY.Wms_Deployment_Mode;
311 
312    IF l_standalone_mode = 'D' THEN
313       g_interface_action_code := '94X_STANDALONE';
314       IF l_debug_on THEN
315          WSH_DEBUG_SV.logmsg(l_module_name, 'Deployment Mode is : Distributed');
316       END IF;
317    ELSIF l_standalone_mode = 'L' THEN --  LSP PROJECT : Consider LSP mode also
318       g_interface_action_code := '94X_STANDALONE';
319       IF l_debug_on THEN
320          WSH_DEBUG_SV.logmsg(l_module_name, 'Deployment Mode is : LSP ');
321       END IF;
322    ELSE
323       --
324       IF l_debug_on THEN
325          WSH_DEBUG_SV.logmsg(l_module_name, 'Deployment Mode is not LSP/Distributed');
326       END IF;
327       --
328       RAISE FND_API.G_EXC_ERROR;
329    END IF;
330 
331    l_from_creation_date   := to_date(p_from_creation_date,'YYYY/MM/DD HH24:MI:SS');
332    l_to_creation_date     := to_date(p_to_creation_date,'YYYY/MM/DD HH24:MI:SS');
333    l_from_document_number := to_char(p_from_document_number);
334    l_to_document_number   := to_char(p_to_document_number);
335 
336    --
337    IF l_debug_on THEN
338       WSH_DEBUG_SV.log(l_module_name,'l_from_creation_date',l_from_creation_date);
339       WSH_DEBUG_SV.log(l_module_name,'l_to_creation_date',l_to_creation_date);
340       WSH_DEBUG_SV.log(l_module_name,'l_from_document_number',l_from_document_number);
341       WSH_DEBUG_SV.log(l_module_name,'l_to_document_number',l_to_document_number);
342    END IF;
343    --
344 
345    IF p_transaction_id is not null THEN
346       OPEN C_Get_One_Transactions;
347    ELSE
348       IF p_from_document_number is not null OR p_to_document_number is not null
349       THEN
350          l_document_where := 'TO_NUMBER(DECODE(RTRIM(TRANSLATE(wth1.document_number,''0123456789'', '' '')), NULL, wth1.document_number,-99999)) ';
351       END IF;
352 
353       --SELECT Clause
354       l_transaction_query := 'SELECT wth.Transaction_ID, ';
355       l_transaction_query := l_transaction_query || 'wth.Document_Type, ';
356       l_transaction_query := l_transaction_query || 'wth.Document_Direction, ';
357       l_transaction_query := l_transaction_query || 'wth.Document_Number, ';
358       l_transaction_query := l_transaction_query || 'wth.Orig_Document_Number, ';
359       l_transaction_query := l_transaction_query || 'wth.Entity_Number, ';
360       l_transaction_query := l_transaction_query || 'wth.Entity_Type, ';
361       l_transaction_query := l_transaction_query || 'wth.Trading_Partner_ID, ';
362       l_transaction_query := l_transaction_query || 'wth.Action_Type, ';
363       l_transaction_query := l_transaction_query || 'wth.Transaction_Status, ';
364       l_transaction_query := l_transaction_query || 'wth.ECX_Message_ID, ';
365       l_transaction_query := l_transaction_query || 'wth.Event_Name, ';
366       l_transaction_query := l_transaction_query || 'wth.Event_Key, ';
367       l_transaction_query := l_transaction_query || 'wth.Item_Type, ';
368       l_transaction_query := l_transaction_query || 'wth.Internal_Control_Number, ';
369       l_transaction_query := l_transaction_query || 'wth.document_revision, ';
370       l_transaction_query := l_transaction_query || 'wth.Attribute_Category, ';
371       l_transaction_query := l_transaction_query || 'wth.Attribute1, ';
372       l_transaction_query := l_transaction_query || 'wth.Attribute2, ';
373       l_transaction_query := l_transaction_query || 'wth.Attribute3, ';
374       l_transaction_query := l_transaction_query || 'wth.Attribute4, ';
375       l_transaction_query := l_transaction_query || 'wth.Attribute5, ';
376       l_transaction_query := l_transaction_query || 'wth.Attribute6, ';
377       l_transaction_query := l_transaction_query || 'wth.Attribute7, ';
378       l_transaction_query := l_transaction_query || 'wth.Attribute8, ';
379       l_transaction_query := l_transaction_query || 'wth.Attribute9, ';
380       l_transaction_query := l_transaction_query || 'wth.Attribute10, ';
381       l_transaction_query := l_transaction_query || 'wth.Attribute11, ';
382       l_transaction_query := l_transaction_query || 'wth.Attribute12, ';
383       l_transaction_query := l_transaction_query || 'wth.Attribute13, ';
384       l_transaction_query := l_transaction_query || 'wth.Attribute14, ';
385       l_transaction_query := l_transaction_query || 'wth.Attribute15 ';
386 
387       --FROM Clause
388       l_transaction_query := l_transaction_query || '   FROM   Wsh_Transactions_History wth, ';
389       --l_transaction_query := l_transaction_query || '   FROM   Wsh_New_Del_Interface    wndi, ';
390       l_transaction_query := l_transaction_query || '( SELECT max(wth1.document_revision) document_revision, ';
391       l_transaction_query := l_transaction_query || '         to_char(max(to_number(entity_number))) entity_number, ';
392       l_transaction_query := l_transaction_query || '         document_number, document_type, document_direction ';
393       l_transaction_query := l_transaction_query || '  FROM   Wsh_Transactions_History wth1 ';
394 
395       l_transaction_query := l_transaction_query || '  WHERE  wth1.document_type = ''SR'' ';
396       l_transaction_query := l_transaction_query || '  AND    wth1.document_direction = ''I'' ';
397 
398       IF p_from_document_number is not null and p_to_document_number is not null
399       THEN
400          l_transaction_query := l_transaction_query || '  AND    ' || l_document_where || ' between :x_from_document_number ';
401          l_transaction_query := l_transaction_query || '  and :x_to_document_number ';
402       ELSIF p_from_document_number is not null and p_to_document_number is null
403       THEN
404          l_transaction_query := l_transaction_query || '  AND    ' || l_document_where || ' >= :x_from_document_number ';
405       ELSIF p_from_document_number is null and p_to_document_number is not null
406       THEN
407          -- Querying documents with greater than Zero since if document number contains characters it will be translated to -99999
408          l_transaction_query := l_transaction_query || '  AND    ' || l_document_where || ' between 0 and :x_to_document_number ';
409       END IF;
410 
411       IF p_transaction_status is not null
412       THEN
413          l_transaction_query := l_transaction_query || '  AND    wth1.transaction_status = :x_transaction_status ';
414       ELSE
415          l_transaction_query := l_transaction_query || '  AND    wth1.transaction_status in (''AP'', ''ER'') ';
416       END IF;
417 
418       IF l_from_creation_date is not null and l_to_creation_date is not null
419       THEN
420          l_transaction_query := l_transaction_query || '  AND    wth1.creation_date between :x_from_creation_date ';
421          l_transaction_query := l_transaction_query || '  and :x_to_creation_date ';
422       ELSIF l_from_creation_date is not null and l_to_creation_date is null
423       THEN
424          l_transaction_query := l_transaction_query || '  AND    wth1.creation_date >= :x_from_creation_date ';
425       ELSIF l_from_creation_date is null and l_to_creation_date is not null
426       THEN
427          l_transaction_query := l_transaction_query || '  AND    wth1.creation_date <= :x_to_creation_date ';
428       END IF;
429 
430       l_transaction_query := l_transaction_query || '  group by document_number, document_type, document_direction ) MDR ';
431       l_transaction_query := l_transaction_query || 'WHERE  wth.document_number = MDR.document_number ';
432       l_transaction_query := l_transaction_query || 'AND    wth.entity_number = MDR.entity_number ';
433       l_transaction_query := l_transaction_query || 'AND    wth.document_revision = MDR.document_revision ';
434       l_transaction_query := l_transaction_query || 'AND    wth.document_type = ''SR'' ';
435       l_transaction_query := l_transaction_query || 'AND    wth.document_direction = ''I'' ';
436       l_transaction_query := l_transaction_query || 'AND    exists ';
437       l_transaction_query := l_transaction_query || '     ( SELECT 1 from wsh_new_del_interface wndi ';
438       l_transaction_query := l_transaction_query || 'WHERE  interface_action_code = ''' || g_interface_action_code || '''';
439       -- Modified R12.1.1 LSP PROJECT* :Begin
440       IF p_client_code is not null THEN
441         l_transaction_query := l_transaction_query || '  AND wndi.client_code=:x_client_code  ';
442       END IF;
443       -- Modified R12.1.1 LSP PROJECT* : end
444       l_transaction_query := l_transaction_query || 'AND    wndi.delivery_interface_id = wth.entity_number ) ';
445 
446       l_transaction_query := l_transaction_query || 'ORDER BY decode(wth.action_type, ''D'', 1, ''C'', 2, ''A'', 3, 4 ) ';
447 
448 
449       --
450       IF l_debug_on THEN
451          WSH_DEBUG_SV.log(l_module_name, 'Transaction Query', l_transaction_query);
452       END IF;
453       --
454 
455       v_cursorid := DBMS_SQL.Open_Cursor;
456       --
457       IF l_debug_on THEN
458          WSH_DEBUG_SV.log(l_module_name, 'Opended cursor successfully', v_cursorid);
459       END IF;
460       --
461       DBMS_SQL.Parse(v_cursorid, l_transaction_query, DBMS_SQL.v7 );
462 
463       --
464       IF l_debug_on THEN
465          WSH_DEBUG_SV.logmsg(l_module_name, 'Parsed cursor successfully');
466       END IF;
467       --
468       DBMS_SQL.Define_Column(v_cursorid, 1,  l_transaction_rec.Transaction_ID);
469       DBMS_SQL.Define_Column(v_cursorid, 2,  l_transaction_rec.Document_Type, 30);
470       DBMS_SQL.Define_Column(v_cursorid, 3,  l_transaction_rec.Document_Direction, 1);
471       DBMS_SQL.Define_Column(v_cursorid, 4,  l_transaction_rec.Document_Number, 120);
472       DBMS_SQL.Define_Column(v_cursorid, 5,  l_transaction_rec.Orig_Document_Number, 120);
473       DBMS_SQL.Define_Column(v_cursorid, 6,  l_transaction_rec.Entity_Number, 30);
474       DBMS_SQL.Define_Column(v_cursorid, 7,  l_transaction_rec.Entity_Type, 30);
475       DBMS_SQL.Define_Column(v_cursorid, 8,  l_transaction_rec.Trading_Partner_ID);
476       DBMS_SQL.Define_Column(v_cursorid, 9,  l_transaction_rec.Action_Type, 30);
477       DBMS_SQL.Define_Column(v_cursorid, 10, l_transaction_rec.Transaction_Status, 2);
478       DBMS_SQL.Define_Column_Raw(v_cursorid, 11, l_transaction_rec.ecx_message_id, 16);
479       DBMS_SQL.Define_Column(v_cursorid, 12, l_transaction_rec.Event_Name, 240);
480       DBMS_SQL.Define_Column(v_cursorid, 13, l_transaction_rec.Event_Key, 240);
481       DBMS_SQL.Define_Column(v_cursorid, 14, l_transaction_rec.Item_Type, 8);
482       DBMS_SQL.Define_Column(v_cursorid, 15, l_transaction_rec.Internal_Control_Number);
483       DBMS_SQL.Define_Column(v_cursorid, 16, l_transaction_rec.document_revision);
484       DBMS_SQL.Define_Column(v_cursorid, 17, l_transaction_rec.Attribute_Category, 150);
485       DBMS_SQL.Define_Column(v_cursorid, 18, l_transaction_rec.Attribute1, 150);
486       DBMS_SQL.Define_Column(v_cursorid, 19, l_transaction_rec.Attribute2, 150);
487       DBMS_SQL.Define_Column(v_cursorid, 20, l_transaction_rec.Attribute3, 150);
488       DBMS_SQL.Define_Column(v_cursorid, 21, l_transaction_rec.Attribute4, 150);
489       DBMS_SQL.Define_Column(v_cursorid, 22, l_transaction_rec.Attribute5, 150);
490       DBMS_SQL.Define_Column(v_cursorid, 23, l_transaction_rec.Attribute6, 150);
491       DBMS_SQL.Define_Column(v_cursorid, 24, l_transaction_rec.Attribute7, 150);
492       DBMS_SQL.Define_Column(v_cursorid, 25, l_transaction_rec.Attribute8, 150);
493       DBMS_SQL.Define_Column(v_cursorid, 26, l_transaction_rec.Attribute9, 150);
494       DBMS_SQL.Define_Column(v_cursorid, 27, l_transaction_rec.Attribute10, 150);
495       DBMS_SQL.Define_Column(v_cursorid, 28, l_transaction_rec.Attribute11, 150);
496       DBMS_SQL.Define_Column(v_cursorid, 29, l_transaction_rec.Attribute12, 150);
497       DBMS_SQL.Define_Column(v_cursorid, 30, l_transaction_rec.Attribute13, 150);
498       DBMS_SQL.Define_Column(v_cursorid, 31, l_transaction_rec.Attribute14, 150);
499       DBMS_SQL.Define_Column(v_cursorid, 32, l_transaction_rec.Attribute15, 150);
500       --
501       IF l_debug_on THEN
502          WSH_DEBUG_SV.logmsg(l_module_name, 'Defined Columns successfully');
503       END IF;
504       --
505 
506       --Start assigning BIND values
507       IF p_from_document_number is not null and p_to_document_number is not null
508       THEN
509          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_from_document_number', p_from_document_number);
510          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_to_document_number', p_to_document_number);
511       ELSIF p_from_document_number is not null and p_to_document_number is null
512       THEN
513          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_from_document_number', p_from_document_number);
514       ELSIF p_from_document_number is null and p_to_document_number is not null
515       THEN
516          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_to_document_number', p_to_document_number);
517       END IF;
518 
519       IF p_transaction_status is not null
520       THEN
521          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_transaction_status', p_transaction_status);
522       END IF;
523 
524       IF l_from_creation_date is not null and l_to_creation_date is not null
525       THEN
526          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_from_creation_date', l_from_creation_date);
527          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_to_creation_date', l_to_creation_date);
528       ELSIF l_from_creation_date is not null and l_to_creation_date is null
529       THEN
530          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_from_creation_date', l_from_creation_date);
531       ELSIF l_from_creation_date is null and l_to_creation_date is not null
532       THEN
533          DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_to_creation_date', l_to_creation_date);
534       END IF;
535       /*Modified R12.1.1 LSP PROJECT */
536       IF p_client_code is not null
537       THEN
538         DBMS_SQL.BIND_VARIABLE(v_cursorid,':x_client_code', p_client_code); --Modified R12.1.1 LSP PROJECT
539       END IF;
540       /*Modified R12.1.1 LSP PROJECT */
541       --End assigning BIND values
542       --
543       IF l_debug_on THEN
544          WSH_DEBUG_SV.logmsg(l_module_name, 'Bind values successfully');
545       END IF;
546       --
547 
548       v_ignore := DBMS_SQL.Execute(v_cursorid);
549       --
550       IF l_debug_on THEN
551          WSH_DEBUG_SV.log(l_module_name, 'Cursor executed successfully', v_ignore);
552       END IF;
553       --
554    END IF;
555 
556    LOOP --{
557       IF p_transaction_id is not null THEN
558          FETCH C_Get_One_Transactions INTO l_transaction_rec;
559          EXIT WHEN C_Get_One_Transactions%NOTFOUND;
560       ELSE
561          v_ignore := DBMS_SQL.Fetch_Rows(v_cursorid);
562          --
563          IF l_debug_on THEN
564             WSH_DEBUG_SV.log(l_module_name, 'Fetched successfully', v_ignore);
565          END IF;
566          --
567          IF v_ignore = 0 THEN
568             EXIT;
569          END IF;
570 
571          DBMS_SQL.Column_Value(v_cursorid, 1, l_transaction_rec.Transaction_ID);
572          DBMS_SQL.Column_Value(v_cursorid, 2, l_transaction_rec.Document_Type);
573          DBMS_SQL.Column_Value(v_cursorid, 3, l_transaction_rec.Document_Direction);
574          DBMS_SQL.Column_Value(v_cursorid, 4, l_transaction_rec.Document_Number);
575          DBMS_SQL.Column_Value(v_cursorid, 5, l_transaction_rec.Orig_Document_Number);
576          DBMS_SQL.Column_Value(v_cursorid, 6, l_transaction_rec.Entity_Number);
577          DBMS_SQL.Column_Value(v_cursorid, 7, l_transaction_rec.Entity_Type);
578          DBMS_SQL.Column_Value(v_cursorid, 8, l_transaction_rec.Trading_Partner_ID);
579          DBMS_SQL.Column_Value(v_cursorid, 9, l_transaction_rec.Action_Type);
580          DBMS_SQL.Column_Value(v_cursorid, 10, l_transaction_rec.Transaction_Status);
581          DBMS_SQL.Column_Value_Raw(v_cursorid, 11, l_transaction_rec.ecx_message_id);
582          DBMS_SQL.Column_Value(v_cursorid, 12, l_transaction_rec.Event_Name);
583          DBMS_SQL.Column_Value(v_cursorid, 13, l_transaction_rec.Event_Key);
584          DBMS_SQL.Column_Value(v_cursorid, 14, l_transaction_rec.Item_Type);
585          DBMS_SQL.Column_Value(v_cursorid, 15, l_transaction_rec.Internal_Control_Number);
586          DBMS_SQL.Column_Value(v_cursorid, 16, l_transaction_rec.document_revision);
587          DBMS_SQL.Column_Value(v_cursorid, 17, l_transaction_rec.Attribute_Category);
588          DBMS_SQL.Column_Value(v_cursorid, 18, l_transaction_rec.Attribute1);
589          DBMS_SQL.Column_Value(v_cursorid, 19, l_transaction_rec.Attribute2);
590          DBMS_SQL.Column_Value(v_cursorid, 20, l_transaction_rec.Attribute3);
591          DBMS_SQL.Column_Value(v_cursorid, 21, l_transaction_rec.Attribute4);
592          DBMS_SQL.Column_Value(v_cursorid, 22, l_transaction_rec.Attribute5);
593          DBMS_SQL.Column_Value(v_cursorid, 23, l_transaction_rec.Attribute6);
594          DBMS_SQL.Column_Value(v_cursorid, 24, l_transaction_rec.Attribute7);
595          DBMS_SQL.Column_Value(v_cursorid, 25, l_transaction_rec.Attribute8);
596          DBMS_SQL.Column_Value(v_cursorid, 26, l_transaction_rec.Attribute9);
597          DBMS_SQL.Column_Value(v_cursorid, 27, l_transaction_rec.Attribute10);
598          DBMS_SQL.Column_Value(v_cursorid, 28, l_transaction_rec.Attribute11);
599          DBMS_SQL.Column_Value(v_cursorid, 29, l_transaction_rec.Attribute12);
600          DBMS_SQL.Column_Value(v_cursorid, 30, l_transaction_rec.Attribute13);
601          DBMS_SQL.Column_Value(v_cursorid, 31, l_transaction_rec.Attribute14);
602          DBMS_SQL.Column_Value(v_cursorid, 32, l_transaction_rec.Attribute15);
603          --
604          IF l_debug_on THEN
605             WSH_DEBUG_SV.logmsg(l_module_name, 'Fetched from cursor successfully');
606          END IF;
607          --
608       END IF;
609 
610       l_tmp_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
611       l_total := l_total + 1;
612 
613       IF l_transaction_rec.item_type is not null and
614          l_transaction_rec.event_key is not null   --{
615       THEN
616          --
617          IF l_debug_on THEN
618             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling wf_engine.handleError', WSH_DEBUG_SV.C_PROC_LEVEL);
619          END IF;
620          --
621          WF_ENGINE.handleError(
622                   itemType => l_transaction_rec.item_type,
623                   itemKey  => l_transaction_rec.event_key,
624                   activity => 'WSH_STAND_PROCESS_WF:POPULATE_BASE_TABLES',
625                   command  => 'RETRY',
626                   result   => NULL );
627 
628          OPEN  c_get_status(l_transaction_rec.transaction_id);
629          FETCH c_get_status INTO l_trx_status;
630          CLOSE c_get_status;
631 
632          IF l_debug_on THEN
633             wsh_debug_sv.log(l_module_name,'l_trx_status', l_trx_status);
634          END IF;
635 
636          IF l_trx_status <> 'SC' THEN
637             l_tmp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
638          END IF;
639       ELSE
640          --
641          IF l_debug_on THEN
642             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Process_Shipment_Request', WSH_DEBUG_SV.C_PROC_LEVEL);
643          END IF;
644          --
645          Process_Shipment_Request(
646                   p_transaction_rec => l_transaction_rec,
647                   p_commit_flag     => p_commit_flag,
648                   x_return_status   => l_tmp_status );
649 
650          --
651          IF l_debug_on THEN
652             wsh_debug_sv.log(l_module_name,'l_tmp_status', l_tmp_status);
653          END IF;
654          --
655       END IF; --}
656 
657       -- API Process_Shipment_Request will return WARNING if its not able to lock tables.
658       IF l_tmp_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
659          l_success := l_success + 1;
660       ELSIF l_tmp_status = WSH_UTIL_CORE.G_RET_STS_ERROR
661       THEN
662          l_errors := l_errors + 1;
663       ELSIF l_tmp_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR
664       THEN
665          --
666          IF l_debug_on THEN
667             wsh_debug_sv.log(l_module_name,'Unexpected error occurred in Process_Shipment_Request', l_tmp_status);
668          END IF;
669          --
670          raise others;
671       END IF;
672    END LOOP; --}
673 
674    IF p_transaction_id is not null THEN
675       IF C_Get_One_Transactions%ISOPEN THEN
676          CLOSE C_Get_One_Transactions;
677       END IF;
678    ELSE
679       IF DBMS_SQL.Is_Open(v_cursorid) THEN
680          --
681          IF l_debug_on THEN
682             WSH_DEBUG_SV.logmsg(l_module_name, 'Closing cursor');
683          END IF;
684          --
685          DBMS_SQL.Close_Cursor(v_cursorid);
686          v_cursorid := null;
687       END IF;
688    END IF;
689 
690    IF (l_total = l_success) THEN
691       x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
692    ELSIF (l_total = l_errors) THEN
693       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
694    ELSE
695       x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
696    END IF;
697 
698    -- To Print in Concurrent Request Output File
699    IF FND_GLOBAL.Conc_Request_Id > 0 THEN
700       FND_FILE.put_line(FND_FILE.output, 'Time taken by OE_ORDER_GRP.Process_Order API alone in secs => ' || g_po_total_time);
701       FND_FILE.put_line(FND_FILE.output, '');
702       FND_FILE.put_line(FND_FILE.output, 'Summary:-');
703       FND_FILE.put_line(FND_FILE.output,'===================================');
704       FND_FILE.put_line(FND_FILE.output, 'No. of Shipment Requests selected for processing   => ' || l_total);
705       FND_FILE.put_line(FND_FILE.output, 'No. of Shipment Requests processed successfully    => ' || l_success);
706       FND_FILE.put_line(FND_FILE.output, 'No. of Shipment Requests errored during processing => ' || l_errors);
707    END IF;
708    --
709 
710    --
711    IF l_debug_on THEN
712       WSH_DEBUG_SV.log(l_module_name, 'Return Status from Process_Shipment_Request1', x_return_status);
713       WSH_DEBUG_SV.log(l_module_name, 'Time taken by OE_ORDER_GRP.Process_Order API alone', g_po_total_time);
714       WSH_DEBUG_SV.logmsg(l_module_name,'');
715       WSH_DEBUG_SV.logmsg(l_module_name,'Summary:-');
716       WSH_DEBUG_SV.logmsg(l_module_name,'===================================');
717       WSH_DEBUG_SV.log(l_module_name,'No. of Shipment Requests selected for processing  ', l_total);
718       WSH_DEBUG_SV.log(l_module_name,'No. of Shipment Requests processed successfully   ', l_success);
719       WSH_DEBUG_SV.log(l_module_name,'No. of Shipment Requests errored during processing', l_errors);
720       WSH_DEBUG_SV.pop(l_module_name);
721    END IF;
722    --
723 EXCEPTION
724    when FND_API.G_EXC_ERROR then
725       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
726       IF p_transaction_id is not null THEN
727          IF C_Get_One_Transactions%ISOPEN THEN
728             CLOSE C_Get_One_Transactions;
729          END IF;
730       ELSE
731          IF DBMS_SQL.Is_Open(v_cursorid) THEN
732             DBMS_SQL.Close_Cursor(v_cursorid);
733             v_cursorid := null;
734          END IF;
735       END IF;
736       --
737       IF l_debug_on THEN
738          wsh_debug_sv.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
739          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
740       END IF;
741       --
742 
743    WHEN OTHERS THEN
744       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
745       IF p_transaction_id is not null THEN
746          IF C_Get_One_Transactions%ISOPEN THEN
747             CLOSE C_Get_One_Transactions;
748          END IF;
749       ELSE
750          IF DBMS_SQL.Is_Open(v_cursorid) THEN
751             DBMS_SQL.Close_Cursor(v_cursorid);
752             v_cursorid := null;
753          END IF;
754       END IF;
755       --
756       IF l_debug_on THEN
757         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
758         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
759       END IF;
760       --
761 END Process_Shipment_Request;
762 --
763 --=============================================================================
764 -- PUBLIC PROCEDURE :
765 --       Overloaded Process_Shipment_Request
766 --
767 -- PARAMETERS:
768 --       p_transaction_rec => Transaction History Record
769 --       p_commit_flag     => Either FND_API.G_TRUE, FND_API.G_FALSE
770 --       x_return_status   => Return Status of API (Either S,E,U)
771 -- COMMENT:
772 --       Calls APIs to validate data from Interface tables WNDI(Order Header)
773 --       and WDDI(Order Lines). Calls OM Process Order Group API
774 --       OE_ORDER_GRP.Process_Order to Create/Update/Cancel Sales Order.
775 --       Attributes related to shipping are validated, If PO group api returns
776 --       success.
777 --       If PO group api returns error then corresponding error messages are
778 --       logged in Wsh_Interface_Errors table.
779 --=============================================================================
780 --
781 PROCEDURE Process_Shipment_Request (
782           p_transaction_rec      IN  WSH_TRANSACTIONS_HISTORY_PKG.Txns_History_Record_Type,
783           p_commit_flag          IN  VARCHAR2,
784           x_return_status        OUT NOCOPY VARCHAR2 )
785 IS
786 
787    CURSOR c_open_del_lines(c_line_id NUMBER)
788    IS
789    select 'x'
790    from   oe_order_lines_all oel,
791           wsh_delivery_details wdd
792    where  oel.open_flag = 'Y'
793    and    oel.shipped_quantity is null
794    and    oel.line_id = c_line_id
795    and    wdd.source_code = 'OE'
796    and    wdd.source_line_id = oel.line_id
797    and    wdd.released_status in ( 'N','R','S','Y','B','X' );
798    --
799    -- LSP PROJECT :
800    CURSOR c_get_ordertype_org (c_cust_acct_id NUMBER, c_party_site_id NUMBER) IS
801      SELECT  su.org_id,su.order_type_id
802      FROM
803        hz_party_sites ps,
804        hz_cust_acct_sites_all ca,
805 	   hz_cust_site_uses_all su
806      WHERE  ps.party_site_id = c_party_site_id
807        AND  su.cust_acct_site_id = ca.cust_acct_site_id
808        AND  ca.party_site_id = ps.party_site_id
809        AND  ca.cust_account_id = c_cust_acct_id;
810 
811    l_order_type_id              NUMBER;
812    l_payment_term_id            NUMBER;
813    l_price_list_id              NUMBER;
814    l_header_id                  NUMBER;
815    l_line_id                    NUMBER;
816    l_org_id                     NUMBER;
817    l_msg_count                  NUMBER;
818    l_entity_id                  NUMBER;
819    l_order_source_id            NUMBER;
820    l_source_document_type_id    NUMBER;
821    l_source_document_id         NUMBER;
822    l_source_document_line_id    NUMBER;
823    l_constraint_id              NUMBER;
824    l_process_activity           NUMBER;
825    l_document_revision          NUMBER;
826    l_document_number            NUMBER;
827    l_entity_number              NUMBER;
828    l_line_number                NUMBER;
829    l_po_tot_time                NUMBER;
830 
831    l_return_status              VARCHAR2(1);
832    l_tmp                        VARCHAR2(10);
833    l_standalone_mode            VARCHAR2(1);
834    l_currency_code              VARCHAR2(15); -- as per transactional_curr_code in OE_Order_PUB.Header_Rec_Type
835    l_temp_currency_code         VARCHAR2(15);
836    l_temp_status                VARCHAR2(15);
837    l_error_msg                  VARCHAR2(4000);
838    l_msg_data                   VARCHAR2(4000);
839    l_header_doc_ref             VARCHAR2(50);
840    l_line_doc_ref               VARCHAR2(50);
841    l_entity_code                VARCHAR2(30);
842    l_entity_ref                 VARCHAR2(50);
843    l_orig_sys_document_ref      VARCHAR2(50);
844    l_orig_sys_document_line_ref VARCHAR2(50);
845    l_orig_sys_shipment_ref      VARCHAR2(50);
846    l_change_sequence            VARCHAR2(50);
847    l_attribute_code             VARCHAR2(30);
848    l_notification_flag          VARCHAR2(1);
849    l_type                       VARCHAR2(30);
850 
851    l_po_start_time              DATE;
852    l_po_end_time                DATE;
853 
854    l_line_details_tbl           WSH_UTIl_CORE.Id_Tab_Type;
855    l_details_marked             WSH_UTIL_CORE.Id_Tab_Type;
856    l_txn_history_tbl            WSH_UTIL_CORE.Id_Tab_Type;
857    l_upd_txn_history_tbl        WSH_UTIL_CORE.Id_Tab_Type;
858    l_entity_number_tbl          WSH_UTIL_CORE.Id_Tab_Type;
859    l_del_interface_error_tbl    WSH_UTIL_CORE.Id_Tab_Type;
860    l_det_interface_error_tbl    WSH_UTIL_CORE.Id_Tab_Type;
861    l_close_line_tbl             WSH_UTIL_CORE.Id_Tab_Type;
862    l_delivery_interface_tbl     WSH_UTIL_CORE.Id_Tab_Type;
863    l_detail_interface_tbl       WSH_UTIL_CORE.Id_Tab_Type;
864    l_del_assgn_interface_tbl    WSH_UTIL_CORE.Id_Tab_Type;
865    l_delivery_detail_tab        WSH_UTIL_CORE.Id_Tab_Type;
866    l_transaction_rec            WSH_TRANSACTIONS_HISTORY_PKG.Txns_History_Record_Type;
867 
868    l_init_om_header_rec         OM_Header_Rec_Type;
869    l_om_header_rec              OM_Header_Rec_Type;
870    l_om_line_tbl_type           OM_Line_Tbl_Type;
871    l_new_del_rec                Del_Interface_Rec_Type;
872    l_details_interface_tab      Del_Details_Interface_Rec_Tab;
873 
874    l_action_request_tbl         OE_ORDER_PUB.Request_Tbl_Type;
875    l_header_rec                 OE_ORDER_PUB.Header_Rec_Type;
876    l_header_val_rec             OE_Order_PUB.Header_Val_Rec_Type;
877    l_old_header_rec             OE_ORDER_PUB.Header_Rec_Type;
878    l_Header_Payment_tbl         OE_ORDER_PUB.Header_Payment_Tbl_Type;
879    l_line_tbl                   OE_ORDER_PUB.Line_Tbl_Type;
880    l_line_val_tbl               OE_Order_PUB.Line_Val_Tbl_Type;
881    l_old_line_tbl               OE_ORDER_PUB.Line_Tbl_Type;
882    l_header_customer_info_tbl   OE_ORDER_PUB.Customer_Info_Table_Type;
883    l_line_customer_info_tbl     OE_ORDER_PUB.Customer_Info_Table_Type;
884 
885    x_header_rec                 OE_ORDER_PUB.Header_Rec_Type;
886    x_header_val_rec             OE_ORDER_PUB.Header_Val_Rec_Type;
887    x_Header_Adj_tbl             OE_ORDER_PUB.Header_Adj_Tbl_Type;
888    x_Header_Adj_val_tbl         OE_ORDER_PUB.Header_Adj_Val_Tbl_Type;
889    x_Header_price_Att_tbl       OE_ORDER_PUB.Header_Price_Att_Tbl_Type;
890    x_Header_Adj_Att_tbl         OE_ORDER_PUB.Header_Adj_Att_Tbl_Type;
891    x_Header_Adj_Assoc_tbl       OE_ORDER_PUB.Header_Adj_Assoc_Tbl_Type;
892    x_Header_Scredit_tbl         OE_ORDER_PUB.Header_Scredit_Tbl_Type;
893    x_Header_Scredit_val_tbl     OE_ORDER_PUB.Header_Scredit_Val_Tbl_Type;
894    x_Header_Payment_tbl         OE_ORDER_PUB.Header_Payment_Tbl_Type;
895    x_Header_Payment_val_tbl     OE_ORDER_PUB.Header_Payment_Val_Tbl_Type;
896    x_line_tbl                   OE_ORDER_PUB.Line_Tbl_Type;
897    x_line_val_tbl               OE_ORDER_PUB.Line_Val_Tbl_Type;
898    x_Line_Adj_tbl               OE_ORDER_PUB.Line_Adj_Tbl_Type;
899    x_Line_Adj_val_tbl           OE_ORDER_PUB.Line_Adj_Val_Tbl_Type;
900    x_Line_price_Att_tbl         OE_ORDER_PUB.Line_Price_Att_Tbl_Type;
901    x_Line_Adj_Att_tbl           OE_ORDER_PUB.Line_Adj_Att_Tbl_Type;
902    x_Line_Adj_Assoc_tbl         OE_ORDER_PUB.Line_Adj_Assoc_Tbl_Type;
903    x_Line_Scredit_tbl           OE_ORDER_PUB.Line_Scredit_Tbl_Type;
904    x_Line_Scredit_val_tbl       OE_ORDER_PUB.Line_Scredit_Val_Tbl_Type;
905    x_Line_Payment_tbl           OE_ORDER_PUB.Line_Payment_Tbl_Type;
906    x_Line_Payment_val_tbl       OE_ORDER_PUB.Line_Payment_Val_Tbl_Type;
907    x_Lot_Serial_tbl             OE_ORDER_PUB.Lot_Serial_Tbl_Type;
908    x_Lot_Serial_val_tbl         OE_ORDER_PUB.Lot_Serial_Val_Tbl_Type;
909    x_action_request_tbl         OE_ORDER_PUB.Request_Tbl_Type;
910    l_control_rec                OE_GLOBALS.Control_Rec_Type;
911 
912    l_lpn_in_sync_comm_rec       WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_in_rec_type;
913    l_lpn_out_sync_comm_rec      WSH_GLBL_VAR_STRCT_GRP.lpn_sync_comm_out_rec_type;
914 
915    interface_error_rec          WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_type;
916    interface_error_tab          WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_tab;
917    l_dummy                      WSH_UTIL_CORE.Id_Tab_Type;
918    -- LSP PROJECT : begin
919    l_modify_otm_flag            VARCHAR2(1);
920    l_modify_oe_iface_flag       VARCHAR2(1);
921    l_client_id                  NUMBER;
922    l_client_name                VARCHAR2(200);
923    l_client_params              inv_cache.ct_rec_type;
924    l_gnore_for_planning         VARCHAR2(1);
925    l_gc3_is_installed           VARCHAR2(1);
926 
927    -- LSP PROJECT : end
928    i                             NUMBER;
929    j                             NUMBER;
930 
931 
932    RECORD_LOCKED                EXCEPTION;
933    PRAGMA EXCEPTION_INIT(RECORD_LOCKED, -54);
934 
935    l_debug_on                 BOOLEAN;
936    l_module_name CONSTANT     VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Process_Shipment_Request2';
937 BEGIN
938    --
939    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
940    --
941    IF l_debug_on IS NULL
942    THEN
943        l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
944    END IF;
945    --
946    IF l_debug_on THEN
947       wsh_debug_sv.push(l_module_name);
948       wsh_debug_sv.log(l_module_name, 'p_commit_flag', p_commit_flag);
949       wsh_debug_sv.log(l_module_name, 'transaction_id', p_transaction_rec.transaction_id);
950       wsh_debug_sv.log(l_module_name, 'transaction_status', p_transaction_rec.transaction_status);
951    END IF;
952    --
953 
954    l_tmp := null;
955 
956    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
957 
958    --
959    IF l_debug_on THEN
960      WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WMS_DEPLOY.Wms_Deployment_Mode', WSH_DEBUG_SV.C_PROC_LEVEL);
961    END IF;
962    --
963    l_standalone_mode := WMS_DEPLOY.Wms_Deployment_Mode;
964    IF g_interface_action_code is null THEN
965       IF l_standalone_mode = 'D' THEN
966          g_interface_action_code := '94X_STANDALONE';
967          IF l_debug_on THEN
968             WSH_DEBUG_SV.logmsg(l_module_name, 'Standalone WMS is installed');
969          END IF;
970       ELSIF l_standalone_mode = 'L' THEN --  LSP PROJECT : Consider LSP mode also
971          g_interface_action_code := '94X_STANDALONE';
972          IF l_debug_on THEN
973             WSH_DEBUG_SV.logmsg(l_module_name, 'Deployment Mode is : LSP ');
974          END IF;
975       ELSE
976          --
977          IF l_debug_on THEN
978             WSH_DEBUG_SV.logmsg(l_module_name, 'Standalone WMS is not installed');
979          END IF;
980          --
981          RAISE FND_API.G_EXC_ERROR;
982       END IF;
983    END IF;
984 
985    l_transaction_rec := p_transaction_rec;
986    l_temp_status    := 'VALID';
987 
988    --Initialize OM Header Record with default values
989    l_om_header_rec := l_init_om_header_rec;
990 
991    --
992    IF l_debug_on THEN
993       WSH_DEBUG_SV.logmsg(l_module_name, '**** Processing document ' || l_transaction_rec.document_number
994                                       || ' with revision ' || l_transaction_rec.document_revision
995                                       || ', action type ' || l_transaction_rec.action_type || ' ****' );
996    END IF;
997    --
998 
999    -- To Print in Concurrent Request Output File
1000    IF FND_GLOBAL.Conc_Request_Id > 0 THEN
1001       FND_FILE.put_line(FND_FILE.output, '**** Processing document ' || l_transaction_rec.document_number
1002                                       || ' with revision ' || l_transaction_rec.document_revision
1003                                       || ', action type ' || l_transaction_rec.action_type || ' ****' );
1004    END IF;
1005    --
1006 
1007    --Validating Document Number
1008    BEGIN
1009       l_document_number := to_number(l_transaction_rec.document_number);
1010       IF trunc(l_document_number) <> l_document_number THEN
1011          RAISE VALUE_ERROR;
1012       END IF;
1013    EXCEPTION
1014       WHEN VALUE_ERROR THEN
1015          l_temp_status := 'INVALID_HEADER';
1016          --
1017          IF l_debug_on THEN
1018             WSH_DEBUG_SV.logmsg(l_module_name, 'VALUE_ERROR exception has occured for Document Number', WSH_DEBUG_SV.C_EXCEP_LEVEL);
1019          END IF;
1020          --
1021          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_POSITIVE_INTEGER');
1022          FND_MESSAGE.Set_Token('ATTRIBUTE', 'DOCUMENT_NUMBER');
1023          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1024    END;
1025 
1026    --Validating Document Revision
1027    BEGIN
1028       l_document_revision := to_number(l_transaction_rec.document_revision);
1029       IF trunc(l_document_revision) <> l_document_revision THEN
1030          RAISE VALUE_ERROR;
1031       END IF;
1032    EXCEPTION
1033       WHEN VALUE_ERROR THEN
1034          l_temp_status := 'INVALID_HEADER';
1035          --
1036          IF l_debug_on THEN
1037             WSH_DEBUG_SV.logmsg(l_module_name, 'VALUE_ERROR exception has occured for Document Revision', WSH_DEBUG_SV.C_EXCEP_LEVEL);
1038          END IF;
1039          --
1040          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_POSITIVE_INTEGER');
1041          FND_MESSAGE.Set_Token('ATTRIBUTE', 'DOCUMENT_REVISION');
1042          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1043    END;
1044 
1045    BEGIN
1046       l_entity_number := to_number(l_transaction_rec.entity_number);
1047    EXCEPTION
1048       WHEN VALUE_ERROR THEN
1049          l_temp_status := 'INVALID_HEADER';
1050          --
1051          IF l_debug_on THEN
1052             WSH_DEBUG_SV.logmsg(l_module_name, 'VALUE_ERROR exception has occured for Entity Number => '
1053                                           || l_transaction_rec.entity_number, WSH_DEBUG_SV.C_EXCEP_LEVEL);
1054          END IF;
1055    END;
1056 
1057    --Log error, if validation fails for Document Number/Document Revision/Entity Number
1058    IF l_temp_status = 'INVALID_HEADER' THEN
1059       goto loop_end;
1060    END IF;
1061 
1062    --Lock all transaction history before processing
1063    BEGIN
1064       --Lock all transaction history records
1065       IF l_debug_on THEN
1066          WSH_DEBUG_SV.logmsg(l_module_name, 'Locking wsh_transactions_history Records');
1067       END IF;
1068       --
1069 
1070       SELECT transaction_id, entity_number
1071       BULK COLLECT INTO l_txn_history_tbl, l_entity_number_tbl
1072       FROM   wsh_transactions_history
1073       WHERE  transaction_status in ( 'IP', 'AP', 'ER' )
1074       AND    document_type = 'SR'
1075       AND    document_direction = 'I'
1076       AND    document_revision <= l_transaction_rec.document_revision
1077       AND    document_number = l_transaction_rec.document_number
1078       order by document_revision
1079       for update nowait;
1080 
1081       --Lock all delivery interface records
1082       IF l_debug_on THEN
1083          WSH_DEBUG_SV.logmsg(l_module_name, 'Locked '||SQL%ROWCOUNT||' wsh_transactions_history Records');
1084          WSH_DEBUG_SV.logmsg(l_module_name, 'Locking wsh_new_del_interface Records');
1085       END IF;
1086       --
1087 
1088       SELECT wndi.delivery_interface_id
1089       BULK COLLECT INTO l_delivery_interface_tbl
1090       FROM   Wsh_New_Del_Interface wndi,
1091              Wsh_Transactions_History wth
1092       WHERE  wndi.interface_action_code = g_interface_action_code
1093       AND    wndi.delivery_interface_id = to_number(wth.entity_number)
1094       AND    wth.transaction_status in ( 'IP', 'AP', 'ER' )
1095       AND    wth.document_type = 'SR'
1096       AND    wth.document_direction = 'I'
1097       AND    wth.document_revision <= l_transaction_rec.document_revision
1098       AND    wth.document_number = l_transaction_rec.document_number
1099       for update of wndi.delivery_interface_id nowait;
1100 
1101       --Lock all delivery detail interface records
1102       IF l_debug_on THEN
1103          WSH_DEBUG_SV.logmsg(l_module_name, 'Locked '||SQL%ROWCOUNT||' wsh_new_del_interface Records');
1104          WSH_DEBUG_SV.logmsg(l_module_name, 'Locking wsh_del_details_interface, wsh_del_assgn_interface Records');
1105       END IF;
1106       --
1107 
1108       SELECT wddi.delivery_detail_interface_id, wdai.del_assgn_interface_id
1109       BULK COLLECT INTO l_detail_interface_tbl, l_del_assgn_interface_tbl
1110       FROM   Wsh_Del_Details_Interface wddi,
1111              Wsh_Del_Assgn_Interface   wdai,
1112              Wsh_Transactions_History wth
1113       WHERE  wddi.interface_action_code = g_interface_action_code
1114       AND    wdai.interface_action_code = g_interface_action_code
1115       AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
1116       AND    wdai.delivery_interface_id = wth.entity_number
1117       AND    wth.transaction_status in ( 'IP', 'AP', 'ER' )
1118       AND    wth.document_type = 'SR'
1119       AND    wth.document_direction = 'I'
1120       AND    wth.document_revision <= l_transaction_rec.document_revision
1121       AND    wth.document_number = l_transaction_rec.document_number
1122       for update of wddi.delivery_detail_interface_id, wdai.del_assgn_interface_id nowait;
1123 
1124       --
1125       IF l_debug_on THEN
1126          WSH_DEBUG_SV.logmsg(l_module_name, 'Locked '||SQL%ROWCOUNT||' wsh_del_details_interface, wsh_del_assgn_interface Records');
1127          WSH_DEBUG_SV.logmsg(l_module_name, 'Locking wsh_interface_errors Records (For Delivery Interface)');
1128       END IF;
1129       --
1130 
1131       SELECT wie.interface_error_id
1132       BULK COLLECT INTO l_del_interface_error_tbl
1133       FROM   wsh_interface_errors wie,
1134              wsh_transactions_history wth
1135       WHERE  wie.interface_table_name = 'WSH_NEW_DEL_INTERFACE'
1136       AND    wie.interface_action_code = g_interface_action_code
1137       AND    wth.transaction_status in ( 'IP', 'AP', 'ER' )
1138       AND    wth.document_type = 'SR'
1139       AND    wth.document_direction = 'I'
1140       AND    wth.document_revision <= l_transaction_rec.document_revision
1141       AND    wth.document_number = l_transaction_rec.document_number
1142       AND    wie.interface_id = to_number(wth.entity_number)
1143       FOR UPDATE NOWAIT;
1144 
1145       --
1146       IF l_debug_on THEN
1147          WSH_DEBUG_SV.logmsg(l_module_name, 'Locked '||SQL%ROWCOUNT||' wsh_interface_errors Records (For Delivery Interface)');
1148          WSH_DEBUG_SV.logmsg(l_module_name, 'Locking wsh_interface_errors Records (For Detail Interface)');
1149       END IF;
1150       --
1151 
1152       SELECT wie.interface_error_id
1153       BULK COLLECT INTO l_det_interface_error_tbl
1154       FROM   wsh_interface_errors wie
1155       WHERE  interface_table_name = 'WSH_DEL_DETAILS_INTERFACE'
1156       AND    interface_action_code = g_interface_action_code
1157       AND    interface_id in
1158            ( select wddi.delivery_detail_interface_id
1159              FROM   Wsh_Del_Details_Interface wddi,
1160                     Wsh_Del_Assgn_Interface wdai,
1161                     wsh_transactions_history wth
1162              WHERE  wddi.interface_action_code = g_interface_action_code
1163              AND    wdai.interface_action_code = g_interface_action_code
1164              AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
1165              AND    wth.transaction_status in ( 'IP', 'AP', 'ER' )
1166              AND    wth.document_type = 'SR'
1167              AND    wth.document_direction = 'I'
1168              AND    wth.document_revision <= l_transaction_rec.document_revision
1169              AND    wth.document_number = l_transaction_rec.document_number
1170              AND    wdai.delivery_interface_id = to_number(wth.entity_number) )
1171       FOR UPDATE NOWAIT;
1172 
1173       IF l_debug_on THEN
1174          WSH_DEBUG_SV.logmsg(l_module_name, 'Locked '||SQL%ROWCOUNT||' wsh_interface_errors Records (For Detail Interface)');
1175       END IF;
1176 
1177    EXCEPTION
1178      WHEN RECORD_LOCKED THEN
1179        l_temp_status := 'NO_LOCK';
1180        --
1181        IF l_debug_on THEN
1182           WSH_DEBUG_SV.logmsg(l_module_name,'RECORD_LOCKED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
1183        END IF;
1184        --
1185        goto loop_end;
1186    END;
1187 
1188    --
1189    IF l_debug_on THEN
1190       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Get_Standalone_Defaults', WSH_DEBUG_SV.C_PROC_LEVEL);
1191    END IF;
1192    --
1193    Get_Standalone_Defaults (
1194                   p_delivery_interface_id  => l_entity_number,
1195                   x_delivery_interface_rec => l_new_del_rec,
1196                   x_return_status          => l_return_status );
1197 
1198    IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1199       --
1200       IF l_debug_on THEN
1201          WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Get_Standalone_Defaults => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1202       END IF;
1203       --
1204       l_temp_status := 'INVALID_HEADER';
1205       goto loop_end;
1206    END IF;
1207 
1208    --
1209    -- LSP PROJECT : validate client code and get default parameter values for the client.
1210    IF l_debug_on THEN
1211        wsh_debug_sv.log(l_module_name, 'client_code', l_new_del_rec.client_code);
1212        wsh_debug_sv.log(l_module_name, 'l_standalone_mode', l_standalone_mode);
1213    END IF;
1214    l_client_id := NULL;
1215    IF l_standalone_mode = 'L' THEN
1216    --{ LSP check
1217      IF ( l_new_del_rec.client_code IS NOT NULL ) THEN
1218      --{ client validation
1219        IF l_debug_on THEN
1220            WSH_DEBUG_SV.logmsg(l_module_name,'Calling program unit WMS_DEPLOY.GET_CLIENT_DETAILS',WSH_DEBUG_SV.C_PROC_LEVEL);
1221        END IF;
1222        wms_deploy.get_client_details(
1223            x_client_id     => l_client_id,
1224            x_client_name   => l_client_name,
1225            x_client_code   => l_new_del_rec.client_code,
1226            x_return_status => l_return_status);
1227        IF l_debug_on THEN
1228            WSH_DEBUG_SV.logmsg(l_module_name, 'ClientId:'||l_client_id||','||'ClientName:'||l_client_name||','||'Return status:'||l_return_status);
1229        END IF;
1230        IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1231        --{
1232            IF l_debug_on THEN
1233                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in WMS_DEPLOY.GET_CLIENT_DETAILS');
1234            END IF;
1235            l_temp_status := 'INVALID_HEADER';
1236            FND_MESSAGE.Set_Name('WSH', 'WSH_OI_INVALID_ATTRIBUTE');
1237            FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CLIENT_CODE');
1238            WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1239            GOTO loop_end;
1240        --}
1241        END IF;
1242        -- Call client setup API to return all client default parameter values.
1243        IF l_debug_on THEN
1244            WSH_DEBUG_SV.logmsg(l_module_name, 'Calling INV_CACHE.GET_CLIENT_DEFAULT_PARAMETERS', WSH_DEBUG_SV.C_PROC_LEVEL);
1245        END IF;
1246        inv_cache.get_client_default_parameters (
1247            p_client_id             => l_client_id,
1248            x_client_parameters_rec => l_client_params,
1249            x_return_status         => l_return_status);
1250        IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1251            IF l_debug_on THEN
1252                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in get_client_default_parameters => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1253            END IF;
1254            l_temp_status := 'INVALID_HEADER';
1255            FND_MESSAGE.Set_Name('WSH', 'WSH_OI_INVALID_ATTRIBUTE');
1256            FND_MESSAGE.SET_TOKEN('ATTRIBUTE','CLIENT_DEFAULTS');
1257            WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1258            GOTO loop_end;
1259        END IF;
1260        l_org_id        := NULL;
1261        l_order_type_id := NULL;
1262        -- get the order type id for the given OU Id.
1263        OPEN c_get_ordertype_org(l_client_id,l_client_params.client_rec.trading_partner_site_id);
1264        FETCH c_get_ordertype_org INTO l_org_id,l_order_type_id;
1265        CLOSE c_get_ordertype_org;
1266        IF l_debug_on THEN
1267            WSH_DEBUG_SV.logmsg(l_module_name,'Client order type => ' || l_order_type_id
1268                                      || ', Operating Unit => ' || l_org_id);
1269        END IF;
1270        --
1271        -- Populate Operating Unit ID value.
1272        l_new_del_rec.org_id := l_org_id;
1273        -- Get Order Type info from client parameters.
1274        IF ( l_new_del_rec.transaction_type_id IS NULL ) THEN
1275            l_new_del_rec.transaction_type_id := l_order_type_id;
1276        END IF;
1277      ELSE
1278        IF l_debug_on THEN
1279                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in get_client_default_parameters => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1280        END IF;
1281        l_temp_status := 'INVALID_HEADER';
1282        FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ATTR_MANDATORY');
1283        FND_MESSAGE.Set_Token('ATTRIBUTE', 'CLIENT_CODE');
1284        WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1285        GOTO loop_end;
1286      --} client validation.
1287      END IF;
1288    --} LSP check
1289    END IF;
1290    -- LSP PROJECT : End.
1291    --
1292    --
1293    IF l_debug_on THEN
1294       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_CUSTOM_PUB.Get_Standalone_WMS_Defaults', WSH_DEBUG_SV.C_PROC_LEVEL);
1295    END IF;
1296    --
1297    WSH_CUSTOM_PUB.Get_Standalone_WMS_Defaults (
1298                   p_transaction_id   => l_transaction_rec.transaction_id,
1299                   x_order_type_id    => l_order_type_id,
1300                   x_price_list_id    => l_price_list_id,
1301                   x_payment_term_id  => l_payment_term_id,
1302                   x_currency_code    => l_currency_code );
1303    --
1304    IF l_debug_on THEN
1305       WSH_DEBUG_SV.logmsg(l_module_name,'Custom: Order Type Id => ' || l_order_type_id
1306                                 || ', Price List Id => ' || l_price_list_id
1307                                 || ', Payment Term Id => ' || l_payment_term_id
1308                                 || ', Operating Unit => ' || l_new_del_rec.org_id
1309                                 || ', Currency Code => ' || l_currency_code );
1310    END IF;
1311    --
1312 
1313    l_order_type_id   := nvl(l_new_del_rec.transaction_type_id, l_order_type_id);
1314    l_price_list_id   := nvl(l_new_del_rec.price_list_id, l_price_list_id);
1315    l_currency_code   := nvl(l_new_del_rec.currency_code, l_currency_code);
1316    l_org_id          := l_new_del_rec.org_id;
1317 
1318 
1319    IF l_payment_term_id is null THEN
1320       --
1321       IF l_debug_on THEN
1322          WSH_DEBUG_SV.logmsg(l_module_name, 'Setting seeded value for payment term');
1323       END IF;
1324       --
1325       l_payment_term_id := 4; --Seeded value '30 NET'
1326    END IF;
1327 
1328    -- LSP PROJECT : price list name currency code can be NULL in case of LSP mode.
1329    --
1330    IF l_debug_on THEN
1331       WSH_DEBUG_SV.logmsg(l_module_name,'Final Values for: Order Type Id => ' || l_order_type_id
1332                                 || ', Price List Id => ' || l_price_list_id
1333                                 || ', Payment Term Id => ' || l_payment_term_id
1334                                 || ', Operating Unit => ' || l_org_id
1335                                 || ', Currency Code => ' || l_currency_code );
1336    END IF;
1337    --
1338 
1339    IF ( l_order_type_id is null OR
1340         (l_price_list_id is null AND l_new_del_rec.client_code IS NULL) OR
1341          l_currency_code is null OR
1342          l_org_id is null )
1343    THEN
1344       --
1345       IF l_debug_on THEN
1346          WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Some or all of Order Type/Price List/Org Id are not set');
1347       END IF;
1348       --
1349       l_temp_status := 'INVALID_HEADER';
1350       FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ERROR');
1351       WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1352       goto loop_end;
1353    END IF;
1354 
1355    --Validate Currency Code
1356    BEGIN
1357       SELECT distinct currency_code
1358       INTO   l_temp_currency_code
1359       FROM   Wsh_Del_Details_Interface wddi,
1360              Wsh_Del_Assgn_Interface wdai
1361       WHERE  wddi.interface_action_code = g_interface_action_code
1362       AND    wdai.interface_action_code = g_interface_action_code
1363       AND    wddi.currency_code is not null
1364       AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
1365       AND    wdai.delivery_interface_id = l_entity_number;
1366 
1367    EXCEPTION
1368       WHEN NO_DATA_FOUND THEN
1369          l_temp_currency_code := l_currency_code;
1370 
1371       WHEN TOO_MANY_ROWS THEN
1372          l_temp_status := 'INVALID_HEADER';
1373          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_CURRENCY_CODE');
1374          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1375          IF l_debug_on THEN
1376            WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Shipment Request has lines with more than 1 Currency Code');
1377          END IF;
1378          --
1379          goto loop_end;
1380    END;
1381 
1382    IF l_currency_code <> l_temp_currency_code THEN
1383       l_temp_status := 'INVALID_HEADER';
1384       FND_MESSAGE.Set_Name('WSH', 'WSH_STND_CURRENCY_MISMATCH');
1385       FND_MESSAGE.Set_Token('CUR_CODE_HDR', l_currency_code);
1386       FND_MESSAGE.Set_Token('CUR_CODE_LINES', l_temp_currency_code);
1387       WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1388       --
1389       IF l_debug_on THEN
1390         WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Shipment Request has lines with more than 1 Currency Code');
1391       END IF;
1392       --
1393       goto loop_end;
1394    END IF;
1395 
1396    --
1397    IF l_debug_on THEN
1398       WSH_DEBUG_SV.log(l_module_name, 'Currency Code', l_currency_code);
1399    END IF;
1400    --
1401 
1402    --
1403    IF l_debug_on THEN
1404       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Check_Header_Exists', WSH_DEBUG_SV.C_PROC_LEVEL);
1405    END IF;
1406    --
1407 
1408    Check_Header_Exists (
1409          p_order_number       => l_document_number,
1410          p_order_type_id      => l_order_type_id,
1411          x_om_header_rec_type => l_om_header_rec,
1412          x_return_status      => l_return_status);
1413 
1414    IF l_debug_on THEN
1415       WSH_DEBUG_SV.logmsg(l_module_name,'Header Id=> ' || l_om_header_rec.header_id
1416                                || ', Header Version No=> ' || l_om_header_rec.version_number
1417                                || ', Transaction Version No=> '|| l_document_revision);
1418    END IF;
1419    --
1420    l_header_id := l_om_header_rec.header_id;
1421 
1422    IF l_header_id is not null THEN -- {
1423 
1424       IF l_transaction_rec.action_type = 'A' THEN
1425          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_HEADER_EXISTS');
1426          FND_MESSAGE.Set_Token('DOCUMENT_NUMBER', l_document_number);
1427          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1428          l_temp_status := 'INVALID_HEADER';
1429          --
1430          IF l_debug_on THEN
1431            WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Shipment Request already exist for same document number and revision');
1432          END IF;
1433          --
1434          goto loop_end;
1435       ELSIF  l_om_header_rec.open_flag = 'N' THEN
1436          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_HEADER_CLOSED');
1437          FND_MESSAGE.Set_Token('DOCUMENT_NUMBER', l_document_number);
1438          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1439          l_temp_status := 'INVALID_HEADER';
1440          --
1441          IF l_debug_on THEN
1442            WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Shipment Request is already closed');
1443          END IF;
1444          --
1445          goto loop_end;
1446       ELSIF  l_om_header_rec.version_number >= l_document_revision
1447       THEN
1448          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_INVALID_REVISION');
1449          FND_MESSAGE.Set_Token('DOCUMENT_REVISION', l_document_revision);
1450          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1451          l_temp_status := 'INVALID_HEADER';
1452          --
1453          IF l_debug_on THEN
1454            WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Shipment Request with higher revision is already processed');
1455          END IF;
1456          --
1457          goto loop_end;
1458       ELSE
1459          --
1460          IF l_debug_on THEN
1461             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Lock_SR_Lines to lock interface records', WSH_DEBUG_SV.C_PROC_LEVEL);
1462          END IF;
1463          --
1464          Lock_SR_Lines(
1465               p_header_id             => l_header_id,
1466               p_delivery_interface_id => l_entity_number,
1467               p_interface_records     => 'Y',
1468               x_return_status         => l_return_status );
1469 
1470          IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS )
1471          THEN
1472             l_temp_status := 'NO_LOCK';
1473             goto loop_end;
1474          END IF;
1475       END IF;
1476 
1477    ELSIF l_header_id is null and l_transaction_rec.action_type = 'D'
1478    THEN
1479       --dont error out, update the transaction history to SC
1480       --
1481       IF l_debug_on THEN
1482          WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header does not exists for this Shipment Request,'
1483                                        || ' so updating the Transaction history status to SC');
1484       END IF;
1485       --
1486       IF l_txn_history_tbl.count > 0 THEN
1487          FORALL i in l_txn_history_tbl.FIRST..l_txn_history_tbl.LAST
1488             UPDATE wsh_transactions_history
1489             SET    transaction_status     = 'SC',
1490                    program_application_id = FND_GLOBAL.Prog_Appl_Id,
1491                    program_id             = FND_GLOBAL.Conc_Program_Id,
1492                    request_id             = FND_GLOBAL.Conc_Request_Id,
1493                    program_update_date    = sysdate,
1494                    last_updated_by        = FND_GLOBAL.User_Id,
1495                    last_update_date       = sysdate,
1496                    last_update_login      = FND_GLOBAL.Login_Id
1497             WHERE  transaction_id = l_txn_history_tbl(i);
1498 
1499             --
1500             IF l_debug_on THEN
1501                WSH_DEBUG_SV.logmsg(l_module_name, sql%rowcount || ' row(s) updated in wsh_transactions_history');
1502             END IF;
1503             --
1504       END IF;
1505 
1506       --
1507       IF l_debug_on THEN
1508         WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_PROC_LEVEL);
1509       END IF;
1510       --
1511       --Call Custom API
1512       WSH_CUSTOM_PUB.Post_Process_Shipment_Request(
1513                      p_transaction_id => l_transaction_rec.transaction_id,
1514                      x_return_status  => l_return_status );
1515 
1516       IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
1517          --
1518          IF l_debug_on THEN
1519             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_ERR_LEVEL);
1520          END IF;
1521          --
1522          RAISE FND_API.G_EXC_ERROR;
1523       END IF;
1524 
1525       IF l_debug_on THEN
1526         WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records', WSH_DEBUG_SV.C_PROC_LEVEL);
1527       END IF;
1528 
1529       WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records (
1530          p_del_interface_id_tbl       => l_delivery_interface_tbl,
1531          p_del_det_interface_id_tbl   => l_detail_interface_tbl,
1532          p_del_assgn_interface_id_tbl => l_del_assgn_interface_tbl,
1533          p_del_error_interface_id_tbl => l_del_interface_error_tbl,
1534          p_det_error_interface_id_tbl => l_det_interface_error_tbl,
1535          x_return_status              => l_return_status);
1536 
1537       IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
1538          --
1539          IF l_debug_on THEN
1540             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Delete_Interface_Records => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1541          END IF;
1542          --
1543          RAISE FND_API.G_EXC_ERROR;
1544       END IF;
1545       goto loop_end;
1546    END IF; --}
1547 
1548    IF l_transaction_rec.action_type in ( 'A', 'C' ) THEN
1549       -- Setting Org Id before calling Derive_Header_Rec so that APIs in OM
1550       -- Package OE_Value_To_Id does not fail.
1551       MO_GLOBAL.Set_Policy_Context('S', l_org_id);
1552       --
1553       IF l_debug_on THEN
1554          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Derive_Header_Rec', WSH_DEBUG_SV.C_PROC_LEVEL);
1555       END IF;
1556       --
1557       Derive_Header_Rec(
1558              p_om_header_rec         => l_om_header_rec,
1559              x_del_interface_rec     => l_new_del_rec,
1560              x_return_status         => l_return_status );
1561 
1562       IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1563          --
1564          IF l_debug_on THEN
1565             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Derive_Header_Rec => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1566          END IF;
1567          --
1568          l_temp_status := 'INVALID_HEADER';
1569          goto loop_end;
1570       END IF;
1571    END IF;
1572 
1573    l_new_del_rec.document_revision := l_document_revision;
1574    l_new_del_rec.order_number      := l_document_number;
1575    l_new_del_rec.org_id            := l_org_id;
1576    l_om_header_rec.order_type_id   := l_order_type_id;
1577    l_om_header_rec.price_list_id   := l_price_list_id;
1578    l_om_header_rec.payment_term_id := l_payment_term_id;
1579    l_om_header_rec.org_id          := l_org_id;
1580    l_om_header_rec.currency_code   := l_currency_code;
1581 
1582    --
1583    IF l_debug_on THEN
1584       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Populate_Header_Rec', WSH_DEBUG_SV.C_PROC_LEVEL);
1585    END IF;
1586    --
1587    Populate_Header_Rec(
1588           p_action_type           => l_transaction_rec.action_type,
1589           p_om_header_rec         => l_om_header_rec,
1590           p_del_interface_rec     => l_new_del_rec,
1591           x_header_rec            => l_header_rec,
1592           x_return_status         => l_return_status );
1593 
1594    IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1595       --
1596       IF l_debug_on THEN
1597          WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Populate_Header_Rec => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1598       END IF;
1599       --
1600       l_temp_status := 'INVALID_HEADER';
1601       goto loop_end;
1602    END IF;
1603 
1604    --If its new Shipment Request setting action_request_table to book sales order.
1605    IF nvl(l_header_rec.header_id, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
1606       l_action_request_tbl(1).request_type    := OE_GLOBALS.G_BOOK_ORDER;
1607       l_action_request_tbl(1).entity_code     := OE_GLOBALS.G_ENTITY_HEADER;
1608    END IF;
1609 
1610    l_header_doc_ref := l_header_rec.orig_sys_document_ref;
1611 
1612    --
1613    IF l_debug_on THEN
1614       WSH_DEBUG_SV.logmsg(l_module_name, 'Populated header record');
1615    END IF;
1616    --
1617 
1618    IF l_transaction_rec.action_type in ( 'A', 'C' )
1619    THEN -- { Action Add/Change
1620       --
1621       IF l_debug_on THEN
1622          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Derive_Line_Rec', WSH_DEBUG_SV.C_PROC_LEVEL);
1623       END IF;
1624       --
1625       Derive_Line_Rec(
1626              p_header_id                 => l_header_id,
1627              p_del_interface_rec         => l_new_del_rec,
1628              x_om_line_tbl_type          => l_om_line_tbl_type,
1629              x_details_interface_rec_tab => l_details_interface_tab,
1630              x_interface_error_tab       => interface_error_tab,
1631              x_return_status             => l_return_status );
1632 
1633       IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1634          --
1635          IF l_debug_on THEN
1636             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Derive_Line_Rec => ' || l_return_status, WSH_DEBUG_SV.C_ERR_LEVEL);
1637          END IF;
1638          --
1639          l_temp_status := 'INVALID';
1640          goto loop_end;
1641       END IF;
1642 
1643       IF l_om_header_rec.header_attributes_changed THEN
1644          --
1645          IF l_debug_on THEN
1646             WSH_DEBUG_SV.logmsg(l_module_name, 'Header Attributes has changed');
1647             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Lock_SR_Lines to lock non-interface records', WSH_DEBUG_SV.C_PROC_LEVEL);
1648          END IF;
1649          --
1650          Lock_SR_Lines(
1651             p_header_id             => l_header_id,
1652             p_delivery_interface_id => l_entity_number,
1653             p_interface_records     => 'N',
1654             x_return_status         => l_return_status );
1655 
1656          IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS )
1657          THEN
1658             l_temp_status := 'NO_LOCK';
1659             goto loop_end;
1660          END IF;
1661       END IF;
1662 
1663       --
1664       IF l_debug_on THEN
1665          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Populate_Line_Records', WSH_DEBUG_SV.C_PROC_LEVEL);
1666       END IF;
1667       --
1668       Populate_Line_Records(
1669              p_om_line_tbl_type          => l_om_line_tbl_type,
1670              p_details_interface_rec_tab => l_details_interface_tab,
1671              p_om_header_rec_type        => l_om_header_rec,
1672              p_delivery_interface_rec    => l_new_del_rec,
1673              x_line_tbl                  => l_line_tbl,
1674              x_line_details_tbl          => l_line_details_tbl,
1675              x_return_status             => l_return_status );
1676 
1677       IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1678          --
1679          IF l_debug_on THEN
1680             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Populate_Line_Records', WSH_DEBUG_SV.C_ERR_LEVEL);
1681          END IF;
1682          --
1683          l_temp_status := 'INVALID';
1684          goto loop_end;
1685       END IF;
1686 
1687       --
1688       IF l_debug_on THEN
1689          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Populate_OM_Common_Attr', WSH_DEBUG_SV.C_PROC_LEVEL);
1690       END IF;
1691       --
1692 
1693       Populate_OM_Common_Attr(
1694           p_om_header_rec     => l_om_header_rec,
1695           p_del_interface_rec => l_new_del_rec,
1696           x_header_rec        => l_header_rec,
1697           x_line_tbl          => l_line_tbl,
1698           x_customer_info     => l_header_customer_info_tbl,
1699           x_return_status     => l_return_status );
1700 
1701       IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1702          --
1703          IF l_debug_on THEN
1704             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occurred in Populate_OM_Common_Attr', WSH_DEBUG_SV.C_ERR_LEVEL);
1705          END IF;
1706          --
1707          l_temp_status := 'INVALID';
1708          goto loop_end;
1709       END IF;
1710 
1711       IF l_om_header_rec.ship_to_changed or
1712          l_om_header_rec.invoice_to_changed or
1713          l_om_header_rec.deliver_to_changed or
1714          l_om_header_rec.ship_to_contact_changed or
1715          l_om_header_rec.invoice_to_contact_changed or
1716          l_om_header_rec.deliver_to_contact_changed
1717       THEN
1718          l_line_customer_info_tbl := l_header_customer_info_tbl;
1719       END IF;
1720 
1721       --Check if atleast one order line exists before calling Process Order API
1722       IF l_line_tbl.count = 0 THEN
1723          --
1724          IF l_debug_on THEN
1725             WSH_DEBUG_SV.logmsg(l_module_name, 'Error: No order lines to process for action Add/Change');
1726          END IF;
1727          --
1728          l_temp_status := 'INVALID_HEADER';
1729          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_LINE_MISSING');
1730          WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
1731          goto loop_end;
1732       ELSE
1733          FOR i in l_line_tbl.first..l_line_tbl.last
1734          LOOP
1735             l_line_val_tbl(i) := OE_ORDER_PUB.G_MISS_LINE_VAL_REC;
1736          END LOOP;
1737       END IF;
1738    END IF; -- } Action Add/Change
1739 
1740    -- Setting controlled_operation and process_partial to TRUE, so that
1741    -- process order api can validate all the lines, even if validation
1742    -- fails for any one line.
1743    -- Process Order Public API does not accecpt l_control_rec parameter,
1744    -- so Shipping has to call Process Order Group API(which acceps p_control_rec parameter)
1745    l_control_rec.controlled_operation := TRUE;
1746    l_control_rec.process_partial      := TRUE;
1747    l_header_val_rec                   := OE_ORDER_PUB.G_MISS_HEADER_VAL_REC;
1748 
1749    l_line_doc_ref := 'SHIPMENT_REQUEST_LINE';
1750 
1751    --
1752    IF l_debug_on THEN
1753       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling MO_GLOBAL.Set_Policy_Context with org_id '||l_org_id);
1754    END IF;
1755    --
1756    MO_GLOBAL.init('ONT'); -- 1/2/2009 => Added this for integration testing after discussing with Srihari Mani
1757    MO_GLOBAL.Set_Policy_Context('S', l_org_id);
1758 
1759    --Setting value for G_MODE to 'STANDALONE', so that intermediate COMMIT does
1760    --not happen in WSH_MAP_LOCATION_REGION_PKG.Rule_Location
1761    WSH_MAP_LOCATION_REGION_PKG.G_MODE := 'STANDALONE';
1762 
1763    --
1764    IF l_debug_on THEN
1765       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Print_OE_Header_Record', WSH_DEBUG_SV.C_PROC_LEVEL);
1766       Print_OE_Header_Record(
1767                p_header_rec         => l_header_rec,
1768                p_header_val_rec     => l_header_val_rec,
1769                p_customer_info      => l_header_customer_info_tbl,
1770                p_action_request_tbl => l_action_request_tbl);
1771 
1772 
1773       IF l_transaction_rec.action_type in ('A','C') THEN
1774          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Print_OE_Line_Record', WSH_DEBUG_SV.C_PROC_LEVEL);
1775          Print_OE_Line_Record(
1776                   p_line_tbl     => l_line_tbl,
1777                   p_line_val_tbl => l_line_val_tbl );
1778       END IF;
1779    END IF;
1780    --
1781 
1782    --
1783    IF l_debug_on THEN
1784       WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_ORDER_GRP.Process_Order '||to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
1785    END IF;
1786    --
1787 
1788    l_po_start_time := sysdate;
1789 
1790    -- Calling Group API instead of Public API after discussing with OM team
1791    OE_ORDER_GRP.Process_Order (
1792                 p_api_version_number       => 1,
1793                 p_init_msg_list            => FND_API.G_TRUE,
1794                 p_return_values            => FND_API.G_TRUE,
1795                 p_commit                   => FND_API.G_FALSE,
1796                 x_return_status            => l_return_status,
1797                 x_msg_count                => l_msg_count,
1798                 x_msg_data                 => l_msg_data,
1799                 p_action_request_tbl       => l_action_request_tbl,
1800                 p_header_rec               => l_header_rec,
1801                 p_header_val_rec           => l_header_val_rec,
1802                 p_old_header_rec           => l_old_header_rec,
1803                 p_Header_Payment_tbl       => l_Header_Payment_tbl,
1804                 p_line_tbl                 => l_line_tbl,
1805                 p_line_val_tbl             => l_line_val_tbl,
1806                 p_old_line_tbl             => l_old_line_tbl,
1807                 x_header_rec               => x_header_rec,
1808                 x_header_val_rec           => x_header_val_rec,
1809                 x_Header_Adj_tbl           => x_Header_Adj_tbl,
1810                 x_Header_Adj_val_tbl       => x_Header_Adj_val_tbl,
1811                 x_Header_price_Att_tbl     => x_Header_Price_Att_Tbl,
1812                 x_Header_Adj_Att_tbl       => x_Header_Adj_Att_Tbl,
1813                 x_Header_Adj_Assoc_tbl     => x_Header_Adj_Assoc_Tbl,
1814                 x_Header_Scredit_tbl       => x_Header_Scredit_Tbl,
1815                 x_Header_Scredit_val_tbl   => x_Header_Scredit_Val_Tbl,
1816                 x_Header_Payment_tbl       => x_Header_Payment_tbl,
1817                 x_Header_Payment_val_tbl   => x_Header_Payment_val_tbl,
1818                 x_line_tbl                 => x_Line_Tbl,
1819                 x_line_val_tbl             => x_Line_Val_Tbl,
1820                 x_Line_Adj_tbl             => x_Line_Adj_Tbl,
1821                 x_Line_Adj_val_tbl         => x_Line_Adj_Val_Tbl,
1822                 x_Line_price_Att_tbl       => x_Line_Price_Att_Tbl,
1823                 x_Line_Adj_Att_tbl         => x_Line_Adj_Att_Tbl,
1824                 x_Line_Adj_Assoc_tbl       => x_Line_Adj_Assoc_Tbl,
1825                 x_Line_Scredit_tbl         => x_Line_Scredit_Tbl,
1826                 x_Line_Scredit_val_tbl     => x_Line_Scredit_Val_Tbl,
1827                 x_Line_Payment_tbl         => x_Line_Payment_tbl,
1828                 x_Line_Payment_val_tbl     => x_Line_Payment_val_tbl,
1829                 x_Lot_Serial_tbl           => x_Lot_Serial_Tbl,
1830                 x_Lot_Serial_val_tbl       => x_Lot_Serial_Val_Tbl,
1831                 x_action_request_tbl       => x_action_request_tbl,
1832                 p_header_customer_info_tbl => l_header_customer_info_tbl,
1833                 p_line_customer_info_tbl   => l_line_customer_info_tbl,
1834                 p_control_rec              => l_control_rec );
1835 
1836    --Setting value for G_MODE back to 'NORMAL'
1837    WSH_MAP_LOCATION_REGION_PKG.G_MODE := 'NORMAL';
1838    l_po_end_time := SYSDATE;
1839    l_po_tot_time := ( l_po_end_time - l_po_start_time ) * 24 * 60 * 60;
1840    g_po_total_time := g_po_total_time + l_po_tot_time;
1841 
1842    --
1843    IF l_debug_on THEN
1844       WSH_DEBUG_SV.logmsg(l_module_name, 'Return Status after OE_ORDER_GRP.Process_Order => '
1845                            || l_return_status || ' : ' || to_char(sysdate,'MM/DD/YYYY HH24:MI:SS'));
1846       WSH_DEBUG_SV.log(l_module_name, 'Time taken by OE_ORDER_GRP.Process_Order in secs', l_po_tot_time);
1847    END IF;
1848    --
1849 
1850    IF x_action_request_tbl.count > 0 THEN
1851       FOR i in x_action_request_tbl.first..x_action_request_tbl.last
1852       LOOP
1853          --
1854          IF l_debug_on THEN
1855             WSH_DEBUG_SV.logmsg(l_module_name, 'Request Type: ' || x_action_request_tbl(i).request_type ||
1856                                ', Entity_code: ' || x_action_request_tbl(i).entity_code ||
1857                                ', Return_status: ' || x_action_request_tbl(i).return_status);
1858          END IF;
1859          --
1860 
1861          IF x_action_request_tbl(1).request_type = OE_GLOBALS.G_BOOK_ORDER and
1862             x_action_request_tbl(1).entity_code  = OE_GLOBALS.G_ENTITY_HEADER and
1863             x_action_request_tbl(i).return_status <> 'S'
1864          THEN
1865             --
1866             IF l_debug_on THEN
1867                WSH_DEBUG_SV.logmsg(l_module_name, 'ACTION REQUEST "' || x_action_request_tbl(1).request_type
1868                           || '" HAS ERRORED IN PO API, SO SET THE OVERALL RETURN STATUS AS ERROR');
1869             END IF;
1870             --
1871             l_return_status := 'E';
1872          END IF;
1873       END LOOP;
1874    END IF;
1875 
1876    IF l_return_status = 'S' --{
1877    THEN
1878       --
1879       IF l_debug_on THEN
1880          WSH_DEBUG_SV.log(l_module_name, 'Sales order created/updated/cancelled ', x_header_rec.order_number );
1881          WSH_DEBUG_SV.log(l_module_name, 'Header Id', x_header_rec.header_id);
1882          WSH_DEBUG_SV.log(l_module_name, 'Line Table count', x_line_tbl.count);
1883 
1884          IF x_line_tbl.count > 0 THEN
1885             FOR i in x_line_tbl.first..x_line_tbl.last
1886             LOOP
1887                WSH_DEBUG_SV.logmsg(l_module_name, 'Line Id => ' || x_line_tbl(i).line_id ||
1888                                         ', Line Number =>  ' || x_line_tbl(i).line_number ||
1889                                         ', Flow Status Code => ' || x_line_tbl(i).flow_status_code);
1890             END LOOP;
1891          END IF;
1892          WSH_DEBUG_SV.log(l_module_name, 'l_details_interface_tab.count', l_details_interface_tab.count );
1893       END IF;
1894       --
1895 
1896       IF l_details_interface_tab.count > 0 THEN -- {
1897          --
1898          IF l_debug_on THEN
1899             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Validate_Interface_Details', WSH_DEBUG_SV.C_PROC_LEVEL);
1900          END IF;
1901          --
1902          Validate_Interface_Details(
1903                p_details_interface_tab => l_details_interface_tab,
1904                x_interface_error_tab   => interface_error_tab,
1905                x_return_status         => l_return_status );
1906 
1907          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
1908             --
1909             IF l_debug_on THEN
1910                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Validate_Interface_Details', WSH_DEBUG_SV.C_ERR_LEVEL);
1911             END IF;
1912             --
1913             l_temp_status := 'INVALID';
1914             goto loop_end;
1915          END IF;
1916          --
1917          -- LSP PROJECT : Needs to populate include for planning value for new shipment request and
1918          --          if the request is having client information.
1919          l_modify_otm_flag      := 'N';
1920          l_modify_oe_iface_flag := 'N';
1921          IF (l_transaction_rec.action_type = 'A' AND l_client_id IS NOT NULL ) THEN
1922          --{
1923              l_modify_oe_iface_flag := 'Y'; --Need to update oe_interfaced_flag value to 'X' (om interface is not required).
1924              --
1925              l_modify_otm_flag      := 'Y'; --Need to update ignore for planning value.
1926              l_gc3_is_installed := WSH_UTIL_CORE.G_GC3_IS_INSTALLED;
1927              IF l_gc3_is_installed IS NULL THEN
1928                  l_gc3_is_installed := WSH_UTIL_CORE.GC3_IS_INSTALLED;
1929              END IF;
1930 	         IF l_debug_on THEN
1931 	             wsh_debug_sv.log(l_module_name,'l_gc3_is_installed ',l_gc3_is_installed);
1932                  wsh_debug_sv.log(l_module_name,'otm_enabled ',l_client_params.client_rec.otm_enabled);
1933              END IF;
1934              -- needs to populate include for planning when Client is OTM enabled.
1935              IF l_client_params.client_rec.otm_enabled = 'Y' AND l_gc3_is_installed = 'Y' THEN
1936                  l_gnore_for_planning := 'N';
1937              ELSE
1938                  l_gnore_for_planning := 'Y';
1939              END IF;
1940          ELSE
1941              l_modify_otm_flag := 'N'; --Should not update ignore for planning value.
1942          --}
1943          END IF;
1944          IF l_debug_on THEN
1945              WSH_DEBUG_SV.log(l_module_name,'l_modify_otm_flag:'||l_modify_otm_flag||','||'l_gnore_for_planning:'||l_gnore_for_planning);
1946              WSH_DEBUG_SV.log(l_module_name,'l_modify_oe_iface_flag:'||l_modify_oe_iface_flag);
1947          END IF;
1948          -- LSP PROJECT end.
1949          --
1950          FOR i IN l_details_interface_tab.first..l_details_interface_tab.last
1951          LOOP
1952             --
1953             IF l_debug_on THEN
1954                WSH_DEBUG_SV.logmsg(l_module_name, 'Delivery_Detail_Interface_Id => ' || l_details_interface_tab(i).delivery_detail_interface_id
1955                                     || ', Line Id => ' || l_details_interface_tab(i).line_id );
1956             END IF;
1957             --
1958 
1959             -- Do not proceed further, if line is getting cancelled completely
1960             IF l_details_interface_tab(i).requested_quantity = 0 THEN
1961                --
1962                IF l_debug_on THEN
1963                   WSH_DEBUG_SV.logmsg(l_module_name, 'Line Number ' || l_details_interface_tab(i).line_number
1964                                || ' is cancelled, so not proceeding further......' );
1965                END IF;
1966                --
1967                goto end_loop;
1968             END IF;
1969 
1970             IF nvl(l_details_interface_tab(i).line_id, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM and
1971                x_line_tbl.count > 0
1972             THEN
1973                FOR j in x_line_tbl.first..x_line_tbl.last
1974                LOOP
1975                   IF x_line_tbl(j).line_number = l_details_interface_tab(i).line_number THEN
1976                      l_details_interface_tab(i).line_id := x_line_tbl(j).line_id;
1977                      EXIT;
1978                   END IF;
1979                END LOOP;
1980 
1981                --
1982                IF l_debug_on THEN
1983                   WSH_DEBUG_SV.log(l_module_name, 'After loop, Details Interface Line Id', l_details_interface_tab(i).line_id );
1984                END IF;
1985                --
1986             END IF;
1987             --
1988             --
1989             IF l_debug_on THEN
1990                WSH_DEBUG_SV.log(l_module_name, 'changed_flag', l_details_interface_tab(i).changed_flag );
1991                WSH_DEBUG_SV.log(l_module_name, 'schedule_date_changed', l_details_interface_tab(i).schedule_date_changed );
1992             END IF;
1993             --
1994 
1995             IF l_details_interface_tab(i).changed_flag = 'Y' THEN
1996                --Call WSH_DELIVERY_DETAILS_PKG.Update_Delivery_Details api instead of updating WDD directly.
1997                UPDATE wsh_delivery_details
1998                SET    reference_number            = l_details_interface_tab(i).source_header_number,
1999                       reference_line_number       = l_details_interface_tab(i).source_line_number,
2000                       reference_line_quantity     = l_details_interface_tab(i).src_requested_quantity,
2001                       reference_line_quantity_uom = l_details_interface_tab(i).src_requested_quantity_uom,
2002                       original_lot_number         = l_details_interface_tab(i).lot_number,
2003                       original_revision           = l_details_interface_tab(i).revision,
2004                       original_locator_id         = l_details_interface_tab(i).locator_id,
2005                       lot_number                  = l_details_interface_tab(i).lot_number,
2006                       revision                    = l_details_interface_tab(i).revision,
2007                       locator_id                  = l_details_interface_tab(i).locator_id,
2008                       earliest_pickup_date        = l_details_interface_tab(i).earliest_pickup_date,
2009                       latest_pickup_date          = l_details_interface_tab(i).latest_pickup_date,
2010                       earliest_dropoff_date       = l_details_interface_tab(i).earliest_dropoff_date,
2011                       latest_dropoff_date         = l_details_interface_tab(i).latest_dropoff_date,
2012                       -- LSP PROJECT
2013                       client_id                   = DECODE(l_transaction_rec.action_type,'A',l_client_id,client_id),
2014                       ignore_for_planning         = DECODE(l_modify_otm_flag,'Y',l_gnore_for_planning,ignore_for_planning),
2015                       oe_interfaced_flag          = DECODE(l_modify_oe_iface_flag,'Y','X',oe_interfaced_flag),
2016                       -- LSP PROJECT
2017                       last_update_date            = sysdate,
2018                       last_updated_by             = FND_GLOBAL.User_Id,
2019                       program_application_id      = FND_GLOBAL.Prog_Appl_Id,
2020                       program_id                  = FND_GLOBAL.Conc_Program_Id,
2021                       request_id                  = FND_GLOBAL.Conc_Request_Id,
2022                       program_update_date         = sysdate
2023                WHERE  source_code = 'OE'
2024                AND    source_line_id = l_details_interface_tab(i).line_id
2025                RETURNING delivery_detail_id BULK COLLECT INTO l_delivery_detail_tab;
2026 
2027                --
2028                IF l_debug_on THEN
2029                   WSH_DEBUG_SV.logmsg(l_module_name, sql%rowcount || ' row(s) updated for Line Id =>' || l_details_interface_tab(i).line_id);
2030                END IF;
2031                --
2032                -- Modified code while fixing bug 8452056.
2033                -- OM Process Order API will return Success even if shipping fails to
2034                -- create delivery details while Order Booking (or) Adding order line
2035                -- to existing booked order.
2036                -- So handling no-data-found after updating WDD table.
2037                -- For new order lines created, always WDD table will be updated.
2038                IF sql%rowcount = 0 THEN
2039                   --
2040                   IF l_debug_on THEN
2041                      WSH_DEBUG_SV.log(l_module_name, 'Error: Delivery details not created for Line Id', l_details_interface_tab(i).line_id);
2042                   END IF;
2043                   --
2044                   l_temp_status := 'INVALID_HEADER';
2045                   FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ERROR');
2046                   WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
2047                   goto loop_end;
2048                END IF;
2049             END IF;
2050 
2051             -- Schedule date change check
2052             IF l_details_interface_tab(i).schedule_date_changed = 'Y' THEN -- {
2053                IF l_delivery_detail_tab.count > 0
2054                THEN
2055                   FOR j in l_delivery_detail_tab.first..l_delivery_detail_tab.last
2056                   LOOP
2057                      l_details_marked(l_details_marked.count+1) := l_delivery_detail_tab(j);
2058                   END LOOP;
2059                END IF;
2060             END IF; -- }
2061 
2062             l_tmp := null;
2063             -- Check if no open delivery lines exists for open order line
2064             -- If yes then call API WSH_SHIP_CONFIRM_ACTIONS.Process_Lines_To_OM
2065             -- so that OM can progress the line further.
2066             OPEN  c_open_del_lines(l_details_interface_tab(i).line_id);
2067             FETCH c_open_del_lines into l_tmp;
2068             IF c_open_del_lines%NOTFOUND THEN
2069                l_close_line_tbl(l_close_line_tbl.count+1) := l_details_interface_tab(i).line_id;
2070             END IF;
2071             CLOSE c_open_del_lines;
2072 
2073             <<end_loop>>
2074                null;
2075          END LOOP;
2076       END IF; -- } Details Count > 0
2077 
2078       IF l_details_marked.count > 0 THEN -- {
2079          --
2080          IF l_debug_on THEN
2081             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_TP_RELEASE.Calculate_cont_del_tpdates', WSH_DEBUG_SV.C_PROC_LEVEL);
2082          END IF;
2083          --
2084          WSH_TP_RELEASE.Calculate_cont_del_tpdates(
2085                         p_entity        => 'DLVB',
2086                         p_entity_ids    => l_details_marked,
2087                         x_return_status => l_return_status);
2088 
2089 
2090          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
2091             --
2092             IF l_debug_on THEN
2093                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Calculate_cont_del_tpdates', WSH_DEBUG_SV.C_ERR_LEVEL);
2094             END IF;
2095             --
2096             l_temp_status := 'INVALID';
2097             goto loop_end;
2098          END IF;
2099       END IF; -- }
2100 
2101       IF l_close_line_tbl.count > 0 THEN -- {
2102          --
2103          IF l_debug_on THEN
2104             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_SHIP_CONFIRM_ACTIONS.Process_Lines_To_OM', WSH_DEBUG_SV.C_PROC_LEVEL);
2105          END IF;
2106          --
2107 
2108          WSH_SHIP_CONFIRM_ACTIONS.Process_Lines_To_OM(
2109              p_line_id_tab   => l_close_line_tbl,
2110              x_return_status => l_return_status );
2111 
2112          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
2113             --
2114             IF l_debug_on THEN
2115                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in WSH_Process_line_To_OM', WSH_DEBUG_SV.C_ERR_LEVEL);
2116             END IF;
2117             --
2118             l_temp_status := 'INVALID';
2119             goto loop_end;
2120          END IF;
2121       END IF; -- }
2122 
2123       -- Update only processing transaction history record, if its triggered through Workflow
2124       IF l_transaction_rec.item_type is not null and
2125          l_transaction_rec.event_key is not null
2126       THEN
2127          l_upd_txn_history_tbl(1) := l_transaction_rec.transaction_id;
2128       ELSE
2129          -- Update processing/existing transaction history record, if its not triggered through Workflow
2130          l_upd_txn_history_tbl := l_txn_history_tbl;
2131       END IF;
2132 
2133       --
2134       IF l_debug_on THEN
2135          WSH_DEBUG_SV.log(l_module_name, 'Update transaction history table count', l_upd_txn_history_tbl.count);
2136       END IF;
2137       --
2138 
2139       IF l_upd_txn_history_tbl.count > 0 THEN
2140          -- Entity Type and Entity Number should be updated only for current
2141          -- processing transaction history record
2142          FORALL i in l_upd_txn_history_tbl.FIRST..l_upd_txn_history_tbl.LAST
2143             UPDATE wsh_transactions_history
2144             SET    transaction_status     = 'SC',
2145                    entity_type            = decode(transaction_id, l_transaction_rec.transaction_id, 'ORDER', entity_type),
2146                    entity_number          = decode(transaction_id, l_transaction_rec.transaction_id, x_header_rec.header_id, entity_number),
2147                    program_application_id = FND_GLOBAL.Prog_Appl_Id,
2148                    program_id             = FND_GLOBAL.Conc_Program_Id,
2149                    request_id             = FND_GLOBAL.Conc_Request_Id,
2150                    program_update_date    = sysdate,
2151                    last_updated_by        = FND_GLOBAL.User_Id,
2152                    last_update_date       = sysdate,
2153                    last_update_login      = FND_GLOBAL.Login_Id
2154             WHERE  transaction_id = l_upd_txn_history_tbl(i);
2155 
2156             --
2157             IF l_debug_on THEN
2158                WSH_DEBUG_SV.logmsg(l_module_name, sql%rowcount || ' row(s) updated in wsh_transactions_history');
2159             END IF;
2160             --
2161       END IF;
2162 
2163       IF l_debug_on THEN
2164         WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records', WSH_DEBUG_SV.C_PROC_LEVEL);
2165       END IF;
2166 
2167       --
2168       IF l_debug_on THEN
2169         WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_PROC_LEVEL);
2170       END IF;
2171       --
2172       --Call Custom API
2173       WSH_CUSTOM_PUB.Post_Process_Shipment_Request(
2174                      p_transaction_id => l_transaction_rec.transaction_id,
2175                      x_return_status  => l_return_status );
2176 
2177       IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
2178          --
2179          IF l_debug_on THEN
2180             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_ERR_LEVEL);
2181          END IF;
2182          --
2183          RAISE FND_API.G_EXC_ERROR;
2184       END IF;
2185 
2186       WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records (
2187          p_del_interface_id_tbl       => l_delivery_interface_tbl,
2188          p_del_det_interface_id_tbl   => l_detail_interface_tbl,
2189          p_del_assgn_interface_id_tbl => l_del_assgn_interface_tbl,
2190          p_del_error_interface_id_tbl => l_del_interface_error_tbl,
2191          p_det_error_interface_id_tbl => l_det_interface_error_tbl,
2192          x_return_status              => l_return_status);
2193 
2194      IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
2195         --
2196         IF l_debug_on THEN
2197            WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Delete_Interface_Records', WSH_DEBUG_SV.C_ERR_LEVEL);
2198         END IF;
2199         --
2200         RAISE FND_API.G_EXC_ERROR;
2201      END IF;
2202    -- }
2203    ELSE --Error/Unexpected Error returned from Process Order api  {
2204       l_temp_status := 'INVALID';
2205       FOR i IN 1 .. oe_msg_pub.g_msg_tbl.COUNT LOOP
2206          l_error_msg := SUBSTRB( OE_MSG_PUB.Get (i, 'F'), 1, 4000 );
2207 
2208          OE_MSG_PUB.Get_Msg_Context(
2209                     p_msg_index                  => i,
2210                     x_entity_code                => l_entity_code,
2211                     x_entity_ref                 => l_entity_ref,
2212                     x_entity_id                  => l_entity_id,
2213                     x_header_id                  => l_header_id,
2214                     x_line_id                    => l_line_id,
2215                     x_order_source_id            => l_order_source_id,
2216                     x_orig_sys_document_ref      => l_orig_sys_document_ref,
2217                     x_orig_sys_line_ref          => l_orig_sys_document_line_ref,
2218                     x_orig_sys_shipment_ref      => l_orig_sys_shipment_ref,
2219                     x_change_sequence            => l_change_sequence,
2220                     x_source_document_type_id    => l_source_document_type_id,
2221                     x_source_document_id         => l_source_document_id,
2222                     x_source_document_line_id    => l_source_document_line_id,
2223                     x_constraint_id              => l_constraint_id,
2224                     x_attribute_code             => l_attribute_code,
2225                     x_process_activity           => l_process_activity,
2226                     x_notification_flag          => l_notification_flag,
2227                     x_type                       => l_type );
2228 
2229 
2230 
2231          IF ( l_orig_sys_document_ref is not null or l_orig_sys_document_line_ref is not null or l_orig_sys_shipment_ref is not null) then
2232          --
2233             IF l_debug_on THEN
2234                WSH_DEBUG_SV.logmsg(l_module_name, 'x_entity_code    : ' ||  l_entity_code);
2235                WSH_DEBUG_SV.logmsg(l_module_name, 'x_entity_ref     : ' ||  l_entity_ref);
2236                WSH_DEBUG_SV.logmsg(l_module_name, 'x_entity_id      : ' ||  l_entity_id);
2237                WSH_DEBUG_SV.logmsg(l_module_name, 'x_header_id      : ' ||  l_header_id);
2238                WSH_DEBUG_SV.logmsg(l_module_name, 'x_line_id        : ' ||  l_line_id);
2239                WSH_DEBUG_SV.logmsg(l_module_name, 'x_orig_sys_document_ref : ' ||  l_orig_sys_document_ref);
2240                WSH_DEBUG_SV.logmsg(l_module_name, 'x_orig_sys_document_line_ref : ' ||  l_orig_sys_document_line_ref);
2241                WSH_DEBUG_SV.logmsg(l_module_name, 'x_orig_sys_shipment_ref : ' ||  l_orig_sys_shipment_ref);
2242                WSH_DEBUG_SV.logmsg(l_module_name, 'Error Message : ' ||  OE_MSG_PUB.Get (i, 'F') );
2243             END IF;
2244             --
2245 
2246             -- OM API returns 'Order has been booked.' even if validation fails.
2247             -- This is the expected behaviour as per doc bug 3725134
2248             IF ( l_orig_sys_document_ref = l_header_doc_ref and
2249                  l_entity_code = 'HEADER' )
2250             THEN
2251                --
2252                IF l_debug_on THEN
2253                   WSH_DEBUG_SV.logmsg(l_module_name, 'Populating error for delivery interface');
2254                END IF;
2255                --
2256                interface_error_rec.p_interface_table_name := 'WSH_NEW_DEL_INTERFACE';
2257                interface_error_rec.p_interface_id :=  l_entity_number;
2258             -- LSP PROJECT : For line level errors, l_line_details_tbl stores all dd iface ids.
2259             ELSIF (l_entity_code = 'LINE' AND l_line_details_tbl.exists(MOD(l_entity_id,G_BINARY_LIMIT)))
2260             THEN
2261                --
2262                IF l_debug_on THEN
2263                   WSH_DEBUG_SV.logmsg(l_module_name, 'Populating error for delivery detail interface');
2264                END IF;
2265                --
2266                interface_error_rec.p_interface_table_name := 'WSH_DEL_DETAILS_INTERFACE';
2267                interface_error_rec.p_interface_id   :=  l_line_details_tbl(MOD(l_entity_id,G_BINARY_LIMIT));
2268             ELSE
2269                interface_error_rec.p_interface_table_name := NULL;
2270             END IF;
2271 
2272             IF interface_error_rec.p_interface_table_name is not null THEN
2273                interface_error_rec.p_message_name   := 'WSH_UTIL_MESSAGE_E';
2274                interface_error_rec.p_token1         := 'MSG_TEXT';
2275                interface_error_rec.p_value1         := substr(l_error_msg,1,250);
2276                interface_error_tab(interface_error_tab.count+1) := interface_error_rec;
2277             END IF;
2278          END IF;
2279       END LOOP;
2280    END IF; --}
2281 
2282    <<loop_end>>
2283       IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
2284       THEN
2285       --{
2286          --
2287          IF l_debug_on THEN
2288             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS', WSH_DEBUG_SV.C_PROC_LEVEL);
2289          END IF;
2290          --
2291          WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
2292            (
2293              p_in_rec             => l_lpn_in_sync_comm_rec,
2294              x_return_status      => l_return_status,
2295              x_out_rec            => l_lpn_out_sync_comm_rec
2296            );
2297          --
2298          IF l_debug_on THEN
2299            WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
2300          END IF;
2301          --
2302          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
2303             --
2304             IF l_debug_on THEN
2305                WSH_DEBUG_SV.logmsg(l_module_name, 'LPN Sync API WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS failed');
2306             END IF;
2307             --
2308             l_temp_status := 'INVALID';
2309          END IF;
2310       --}
2311       END IF;
2312 
2313       IF l_temp_status in ( 'INVALID', 'INVALID_HEADER' ) THEN --{
2314          x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2315          -- To Print in Concurrent Request Output File
2316          IF FND_GLOBAL.Conc_Request_Id > 0 THEN
2317             FND_FILE.put_line(FND_FILE.output, '  Process Shipment Request failed to process document number: ' || l_transaction_rec.document_number);
2318          END IF;
2319          --
2320          --Rollback the transaction
2321          IF l_debug_on THEN
2322             WSH_DEBUG_SV.logmsg(l_module_name, 'Rolling Back the changes done for this transaction');
2323          END IF;
2324          ROLLBACK;
2325 
2326          -- If header level validation fails then retrive the error messages from Stack.
2327          IF l_temp_status = 'INVALID_HEADER' THEN
2328             --
2329             IF l_debug_on THEN
2330                WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Populate_Error_Records', WSH_DEBUG_SV.C_PROC_LEVEL);
2331             END IF;
2332             --
2333             Populate_Error_Records(
2334                  p_interface_id             => l_entity_number,
2335                  p_interface_table_name     => 'WSH_NEW_DEL_INTERFACE',
2336                  x_interface_errors_rec_tab => interface_error_tab,
2337                  x_return_status            => l_return_status );
2338 
2339             IF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
2340                --
2341                IF l_debug_on THEN
2342                   WSH_DEBUG_SV.logmsg(l_module_name, 'Populate_Error_Records returned unexpected error', WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2343                END IF;
2344                --
2345             END IF;
2346          END IF;
2347 
2348          --
2349          IF l_debug_on THEN
2350             WSH_DEBUG_SV.log(l_module_name, 'Querying wsh_interface_errors Records (For Delivery Interface)', l_entity_number);
2351          END IF;
2352          --
2353 
2354          --Flushing following arrays since it contains interface errors of Current/Existing document revisions
2355          l_del_interface_error_tbl.delete;
2356          l_det_interface_error_tbl.delete;
2357 
2358          --Querying interface errors of Current processing document revision - Start
2359          SELECT wie.interface_error_id
2360          BULK COLLECT INTO l_del_interface_error_tbl
2361          FROM   wsh_interface_errors wie
2362          WHERE  wie.interface_table_name = 'WSH_NEW_DEL_INTERFACE'
2363          AND    wie.interface_action_code = g_interface_action_code
2364          AND    wie.interface_id = l_entity_number;
2365 
2366          --
2367          IF l_debug_on THEN
2368             WSH_DEBUG_SV.logmsg(l_module_name, 'Queried '||SQL%ROWCOUNT||' wsh_interface_errors Records (For Delivery Interface)');
2369             WSH_DEBUG_SV.log(l_module_name, 'Querying wsh_interface_errors Records (For Detail Interface)', l_entity_number);
2370          END IF;
2371          --
2372 
2373          SELECT wie.interface_error_id
2374          BULK COLLECT INTO l_det_interface_error_tbl
2375          FROM   wsh_interface_errors wie
2376          WHERE  interface_table_name = 'WSH_DEL_DETAILS_INTERFACE'
2377          AND    interface_action_code = g_interface_action_code
2378          AND    interface_id in
2379               ( select wddi.delivery_detail_interface_id
2380                 FROM   Wsh_Del_Details_Interface wddi,
2381                        Wsh_Del_Assgn_Interface wdai
2382                 WHERE  wddi.interface_action_code = g_interface_action_code
2383                 AND    wdai.interface_action_code = g_interface_action_code
2384                 AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
2385                 AND    wdai.delivery_interface_id = l_entity_number );
2386 
2387          IF l_debug_on THEN
2388             WSH_DEBUG_SV.logmsg(l_module_name, 'Queried '||SQL%ROWCOUNT||' wsh_interface_errors Records (For Detail Interface)');
2389          END IF;
2390          --Querying interface errors of Current processing document revision - End
2391 
2392          --
2393          IF l_debug_on THEN
2394            WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_PROC_LEVEL);
2395          END IF;
2396          --
2397          --Call Custom API
2398          WSH_CUSTOM_PUB.Post_Process_Shipment_Request(
2399                         p_transaction_id => l_transaction_rec.transaction_id,
2400                         x_return_status  => l_return_status );
2401 
2402          IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
2403             --
2404             IF l_debug_on THEN
2405                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in WSH_CUSTOM_PUB.Post_Process_Shipment_Request', WSH_DEBUG_SV.C_ERR_LEVEL);
2406             END IF;
2407             --
2408             RAISE FND_API.G_EXC_ERROR;
2409          END IF;
2410 
2411          IF (l_del_interface_error_tbl.COUNT > 0) OR (l_det_interface_error_tbl.COUNT > 0) THEN --{
2412             IF l_debug_on THEN
2413               WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records', WSH_DEBUG_SV.C_PROC_LEVEL);
2414             END IF;
2415 
2416             WSH_PROCESS_INTERFACED_PKG.Delete_Interface_Records (
2417               p_del_interface_id_tbl       => l_dummy,
2418               p_del_det_interface_id_tbl   => l_dummy,
2419               p_del_assgn_interface_id_tbl => l_dummy,
2420               p_del_error_interface_id_tbl => l_del_interface_error_tbl,
2421               p_det_error_interface_id_tbl => l_det_interface_error_tbl,
2422               x_return_status              => l_return_status);
2423 
2424             IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
2425                --
2426                IF l_debug_on THEN
2427                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Delete_Interface_Records', WSH_DEBUG_SV.C_ERR_LEVEL);
2428                END IF;
2429                --
2430                RAISE FND_API.G_EXC_ERROR;
2431             END IF;
2432          END IF; --}
2433 
2434          --
2435          IF l_debug_on THEN
2436             WSH_DEBUG_SV.log(l_module_name, 'interface_error_tab.count', interface_error_tab.count);
2437          END IF;
2438          --
2439          IF interface_error_tab.count > 0 THEN
2440             --
2441             IF l_debug_on THEN
2442                WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_INTERFACE_VALIDATIONS_PKG.Log_Interface_Errors', WSH_DEBUG_SV.C_PROC_LEVEL);
2443             END IF;
2444             --
2445             WSH_INTERFACE_VALIDATIONS_PKG.Log_Interface_Errors (
2446                 p_interface_errors_rec_tab => interface_error_tab,
2447                 p_interface_action_code    => g_interface_action_code,
2448                 x_return_status            => l_return_status);
2449 
2450             IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
2451                --
2452                IF l_debug_on THEN
2453                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Log_Interface_Errors', WSH_DEBUG_SV.C_ERR_LEVEL);
2454                END IF;
2455                --
2456                RAISE FND_API.G_EXC_ERROR;
2457             END IF;
2458          END IF;
2459 
2460          l_transaction_rec.transaction_status := 'ER';
2461 
2462          --
2463          IF l_debug_on THEN
2464             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_TRANSACTIONS_HISTORY_PKG.Create_Update_Txns_History', WSH_DEBUG_SV.C_PROC_LEVEL);
2465          END IF;
2466          --
2467          WSH_TRANSACTIONS_HISTORY_PKG.Create_Update_Txns_History (
2468                   p_txns_history_rec => l_transaction_rec,
2469                   x_txns_id          => l_transaction_rec.transaction_id,
2470                   x_return_status    => l_return_status );
2471 
2472          --
2473          IF l_debug_on THEN
2474             wsh_debug_sv.log (l_module_name, 'Return status after Create_Update_Txns_History ', l_return_status);
2475          END IF;
2476          --
2477          IF ( l_return_status <> WSH_UTIL_CORE.g_ret_sts_success ) THEN
2478             --
2479             IF l_debug_on THEN
2480                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Create_Update_Txns_History', WSH_DEBUG_SV.C_ERR_LEVEL);
2481             END IF;
2482             --
2483             RAISE FND_API.G_EXC_ERROR;
2484          END IF;
2485 
2486       ELSIF (l_temp_status = 'NO_LOCK') THEN
2487          x_return_status := WSH_UTIL_CORE.G_RET_STS_WARNING;
2488          --
2489          IF l_debug_on THEN
2490             wsh_debug_sv.logmsg(l_module_name, 'Unable to lock the records for Transaction '||l_transaction_rec.transaction_id||'. Skipping the Record');
2491          END IF;
2492          --
2493          ROLLBACK;
2494       END IF; --}
2495    -- End of <<loop_end>>
2496 
2497    -- COMMIT THE TRANSACTION
2498    IF p_commit_flag = FND_API.G_TRUE THEN
2499       --
2500       IF l_debug_on THEN
2501          wsh_debug_sv.logmsg(l_module_name, 'Commiting the changes done for this transaction');
2502       END IF;
2503       --
2504       COMMIT;
2505    END IF;
2506 
2507    --
2508    IF l_debug_on THEN
2509       wsh_debug_sv.log(l_module_name, 'Return Status from Process_Shipment_Request2', x_return_status);
2510       WSH_DEBUG_SV.pop(l_module_name);
2511    END IF;
2512    --
2513 EXCEPTION
2514    when FND_API.G_EXC_ERROR then
2515       --Rollback the transaction
2516       IF l_debug_on THEN
2517          WSH_DEBUG_SV.logmsg(l_module_name, 'Inside exception FND_API.G_EXC_ERROR, Rolling Back the changes done for this transaction');
2518       END IF;
2519       --
2520       ROLLBACK;
2521       --Setting value for G_MODE back to 'NORMAL'
2522       IF WSH_MAP_LOCATION_REGION_PKG.G_MODE <> 'NORMAL' THEN
2523          WSH_MAP_LOCATION_REGION_PKG.G_MODE := 'NORMAL';
2524       END IF;
2525       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2526 
2527       IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
2528       THEN
2529       --{
2530          --
2531          IF l_debug_on THEN
2532             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS', WSH_DEBUG_SV.C_PROC_LEVEL);
2533          END IF;
2534          --
2535          WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
2536            (
2537              p_in_rec             => l_lpn_in_sync_comm_rec,
2538              x_return_status      => l_return_status,
2539              x_out_rec            => l_lpn_out_sync_comm_rec
2540            );
2541          --
2542          IF l_debug_on THEN
2543            WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
2544          END IF;
2545          --
2546          IF l_return_status = WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR THEN
2547             x_return_status := l_return_status;
2548          END IF;
2549       --}
2550       END IF;
2551       --
2552       IF l_debug_on THEN
2553          wsh_debug_sv.logmsg(l_module_name,'FND_API.G_EXC_ERROR exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
2554          wsh_debug_sv.pop(l_module_name, 'EXCEPTION:FND_API.G_EXC_ERROR');
2555       END IF;
2556       --
2557 
2558    WHEN OTHERS THEN
2559       --Rollback the transaction
2560       IF l_debug_on THEN
2561          WSH_DEBUG_SV.logmsg(l_module_name, 'Inside exception OTHERS, Rolling Back the changes done for this transaction');
2562       END IF;
2563       --
2564       ROLLBACK;
2565       --Setting value for G_MODE back to 'NORMAL'
2566       IF WSH_MAP_LOCATION_REGION_PKG.G_MODE <> 'NORMAL' THEN
2567          WSH_MAP_LOCATION_REGION_PKG.G_MODE := 'NORMAL';
2568       END IF;
2569       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2570 
2571       IF WSH_WMS_LPN_GRP.G_CALLBACK_REQUIRED = 'Y'
2572       THEN
2573       --{
2574          --
2575          IF l_debug_on THEN
2576             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS', WSH_DEBUG_SV.C_PROC_LEVEL);
2577          END IF;
2578          --
2579          WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS
2580            (
2581              p_in_rec             => l_lpn_in_sync_comm_rec,
2582              x_return_status      => l_return_status,
2583              x_out_rec            => l_lpn_out_sync_comm_rec
2584            );
2585          --
2586          IF l_debug_on THEN
2587            WSH_DEBUG_SV.log(l_module_name,'Return status after calling WSH_LPN_SYNC_COMM_PKG.SYNC_LPNS_TO_WMS',l_return_status);
2588          END IF;
2589          --
2590       --}
2591       END IF;
2592       --
2593       IF l_debug_on THEN
2594         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2595         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2596       END IF;
2597       --
2598 END Process_Shipment_Request;
2599 --
2600 --=============================================================================
2601 -- PUBLIC PROCEDURE :
2602 --       Get_Standalone_Defaults
2603 --
2604 -- PARAMETERS:
2605 --       p_delivery_interface_id  => Delivery Interface Id
2606 --       x_delivery_interface_rec => Delivery Interface Record
2607 --       x_return_status          => Return Status of API (S,E,U)
2608 -- COMMENT:
2609 --       Queries WNDI details, validates organization and derives
2610 --       operating unit for organization.
2611 --=============================================================================
2612 --
2613 PROCEDURE Get_Standalone_Defaults (
2614           p_delivery_interface_id  IN         NUMBER,
2615           x_delivery_interface_rec OUT NOCOPY Del_Interface_Rec_Type,
2616           x_return_status          OUT NOCOPY VARCHAR2 )
2617 IS
2618    CURSOR c_delivery_interface_rec
2619    IS
2620    SELECT delivery_interface_id,
2621           organization_code,
2622           organization_id,
2623           customer_id,
2624           customer_name,
2625           ship_to_customer_id,
2626           ship_to_customer_name,
2627           ship_to_address_id,
2628           ship_to_address1,
2629           ship_to_address2,
2630           ship_to_address3,
2631           ship_to_address4,
2632           ship_to_city,
2633           ship_to_state,
2634           ship_to_country,
2635           ship_to_postal_code,
2636           ship_to_contact_id,
2637           ship_to_contact_name,
2638           ship_to_contact_phone,
2639           invoice_to_customer_id,
2640           invoice_to_customer_name,
2641           invoice_to_address_id,
2642           invoice_to_address1,
2643           invoice_to_address2,
2644           invoice_to_address3,
2645           invoice_to_address4,
2646           invoice_to_city,
2647           invoice_to_state,
2648           invoice_to_country,
2649           invoice_to_postal_code,
2650           invoice_to_contact_id,
2651           invoice_to_contact_name,
2652           invoice_to_contact_phone,
2653           deliver_to_customer_id,
2654           deliver_to_customer_name,
2655           deliver_to_address_id,
2656           deliver_to_address1,
2657           deliver_to_address2,
2658           deliver_to_address3,
2659           deliver_to_address4,
2660           deliver_to_city,
2661           deliver_to_state,
2662           deliver_to_country,
2663           deliver_to_postal_code,
2664           deliver_to_contact_id,
2665           deliver_to_contact_name,
2666           deliver_to_contact_phone,
2667           transaction_type_id,
2668           price_list_id,
2669           null,
2670           currency_code,
2671           carrier_code,
2672           carrier_id,
2673           service_level,
2674           mode_of_transport,
2675           freight_terms_code,
2676           fob_code,
2677           null, -- Shipping Method Code
2678           null, -- Org Id
2679           null, -- Document Revision
2680           null,  -- Order Number
2681           client_code  -- LSP PROJECT : client_code
2682    FROM   Wsh_New_Del_Interface wndi
2683    WHERE  wndi.delivery_interface_id = p_delivery_interface_id;
2684 
2685    l_return_status      VARCHAR2(1);
2686 
2687    --
2688    l_debug_on BOOLEAN;
2689    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Get_Standalone_Defaults';
2690    --
2691 BEGIN
2692    --Debug Push
2693    --
2694    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2695    --
2696    IF l_debug_on IS NULL THEN
2697       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2698    END IF;
2699    --
2700    IF l_debug_on THEN
2701       WSH_DEBUG_SV.push(l_module_name);
2702       WSH_DEBUG_SV.log(l_module_name, 'p_delivery_interface_id', p_delivery_interface_id );
2703    END IF;
2704    --
2705    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
2706 
2707    open  c_delivery_interface_rec;
2708    fetch c_delivery_interface_rec into x_delivery_interface_rec;
2709    IF c_delivery_interface_rec%NOTFOUND THEN
2710       --
2711       IF l_debug_on THEN
2712          wsh_debug_sv.logmsg(l_module_name, 'Delivery Interface Record Missing');
2713       END IF;
2714       --
2715       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2716       WSH_DEBUG_SV.pop(l_module_name);
2717       RETURN;
2718    END IF;
2719    close c_delivery_interface_rec;
2720 
2721    --
2722    IF l_debug_on THEN
2723       wsh_debug_sv.logmsg(l_module_name, 'Calling api Validate_Organization', WSH_DEBUG_SV.C_PROC_LEVEL);
2724    END IF;
2725    --
2726 
2727    Validate_Organization(
2728             p_org_code        => x_delivery_interface_rec.organization_code,
2729             p_organization_id => x_delivery_interface_rec.organization_id,
2730             x_return_status   => l_return_status );
2731 
2732    IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
2733       --
2734       IF l_debug_on THEN
2735          WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Validate_Organization', WSH_DEBUG_SV.C_ERR_LEVEL);
2736       END IF;
2737       --
2738       x_return_status := l_return_status;
2739    ELSE
2740       --
2741       IF l_debug_on THEN
2742          wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_CORE.Get_Operating_Unit', WSH_DEBUG_SV.C_PROC_LEVEL);
2743       END IF;
2744       --
2745       x_delivery_interface_rec.org_id := WSH_UTIL_CORE.Get_Operating_Unit(x_delivery_interface_rec.organization_id);
2746 
2747       IF nvl(x_delivery_interface_rec.org_id, -1) = -1 THEN
2748          --
2749          IF l_debug_on THEN
2750             wsh_debug_sv.logmsg(l_module_name, 'Error: Invalid Operating Unit returned');
2751          END IF;
2752          --
2753          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_OU_NOT_ASSIGNED');
2754          FND_MESSAGE.Set_Token('ORG_NAME', WSH_UTIL_CORE.Get_Org_Name(x_delivery_interface_rec.organization_id));
2755          x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
2756          WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name );
2757       END IF;
2758    END IF;
2759 
2760    --
2761    IF l_debug_on THEN
2762       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
2763       WSH_DEBUG_SV.logmsg(l_module_name, 'order_type_id => ' || x_delivery_interface_rec.transaction_type_id ||
2764                                        ', price_list_id => ' || x_delivery_interface_rec.price_list_id ||
2765                                        ', organization_id => ' || x_delivery_interface_rec.organization_id ||
2766                                        ', org_id => ' || x_delivery_interface_rec.org_id ||
2767                                        ', currency_code => ' || x_delivery_interface_rec.currency_code );
2768       WSH_DEBUG_SV.pop(l_module_name);
2769    END IF;
2770    --
2771 EXCEPTION
2772 WHEN OTHERS THEN
2773       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2774       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Get_Standalone_Defaults');
2775       IF c_delivery_interface_rec%ISOPEN THEN
2776          close c_delivery_interface_rec;
2777       END IF;
2778       --
2779       IF l_debug_on THEN
2780         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2781         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2782       END IF;
2783       --
2784 END Get_Standalone_Defaults;
2785 --
2786 --=============================================================================
2787 -- PUBLIC PROCEDURE :
2788 --       Check_Header_Exists
2789 --
2790 -- PARAMETERS:
2791 --       p_order_number       => Order Number
2792 --       p_order_type_id      => Order Type
2793 --       x_om_header_rec_type => Standalone related order header attributes record
2794 --       x_return_status      => Return Status of API (Either S,U)
2795 -- COMMENT:
2796 --       Queries standalone related order header attributes from table
2797 --       Oe_Order_Headers_All based on Order Number and Order Type passed.
2798 --=============================================================================
2799 --
2800 PROCEDURE Check_Header_Exists (
2801           p_order_number       IN         NUMBER,
2802           p_order_type_id      IN         NUMBER,
2803           x_om_header_rec_type OUT NOCOPY OM_Header_Rec_Type,
2804           x_return_status      OUT NOCOPY VARCHAR2 )
2805 IS
2806    cursor c_order_info is
2807    select header_id,
2808           open_flag,
2809           order_type_id,
2810           version_number,
2811           sold_to_org_id,
2812           ship_to_org_id,
2813           invoice_to_org_id,
2814           deliver_to_org_id,
2815           sold_to_contact_id,
2816           ship_to_contact_id,
2817           invoice_to_contact_id,
2818           deliver_to_contact_id,
2819           ship_from_org_id,
2820           price_list_id,
2821           payment_term_id,
2822           shipping_method_code,
2823           freight_terms_code,
2824           fob_point_code
2825    from   oe_order_headers_all
2826    where  order_number = p_order_number
2827    and    order_type_id = p_order_type_id;
2828 
2829    --
2830    l_debug_on BOOLEAN;
2831    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Check_Header_Exists';
2832    --
2833 BEGIN
2834    --Debug Push
2835    --
2836    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2837    --
2838    IF l_debug_on IS NULL THEN
2839       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2840    END IF;
2841    --
2842    IF l_debug_on THEN
2843       WSH_DEBUG_SV.push(l_module_name);
2844       WSH_DEBUG_SV.log(l_module_name, 'p_order_number', p_order_number );
2845       WSH_DEBUG_SV.log(l_module_name, 'p_order_type_id', p_order_type_id );
2846    END IF;
2847    --
2848 
2849    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
2850 
2851    open  c_order_info;
2852    fetch c_order_info into
2853             x_om_header_rec_type.header_id,
2854             x_om_header_rec_type.open_flag,
2855             x_om_header_rec_type.order_type_id,
2856             x_om_header_rec_type.version_number,
2857             x_om_header_rec_type.sold_to_org_id,
2858             x_om_header_rec_type.ship_to_org_id,
2859             x_om_header_rec_type.invoice_to_org_id,
2860             x_om_header_rec_type.deliver_to_org_id,
2861             x_om_header_rec_type.sold_to_contact_id,
2862             x_om_header_rec_type.ship_to_contact_id,
2863             x_om_header_rec_type.invoice_to_contact_id,
2864             x_om_header_rec_type.deliver_to_contact_id,
2865             x_om_header_rec_type.ship_from_org_id,
2866             x_om_header_rec_type.price_list_id,
2867             x_om_header_rec_type.payment_term_id,
2868             x_om_header_rec_type.shipping_method_code,
2869             x_om_header_rec_type.freight_terms_code,
2870             x_om_header_rec_type.fob_point_code;
2871    close c_order_info;
2872 
2873    --
2874    IF l_debug_on THEN
2875       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
2876       WSH_DEBUG_SV.log(l_module_name, 'Header id', x_om_header_rec_type.header_id);
2877       WSH_DEBUG_SV.pop(l_module_name);
2878    END IF;
2879    --
2880 EXCEPTION
2881 WHEN OTHERS THEN
2882       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
2883       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Check_Header_Exists');
2884       IF c_order_info%ISOPEN THEN
2885          close c_order_info;
2886       END IF;
2887       --
2888       IF l_debug_on THEN
2889         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
2890         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
2891       END IF;
2892       --
2893 END Check_Header_Exists;
2894 --
2895 --=============================================================================
2896 -- PUBLIC PROCEDURE :
2897 --       Check_Line_Exists
2898 --
2899 -- PARAMETERS:
2900 --       p_header_id        => Order Header Id
2901 --       p_line_number      => Order Line Number
2902 --       x_om_line_rec_type => Standalone related order line attributes record
2903 --       x_return_status    => Return Status of API (Either S,U)
2904 -- COMMENT:
2905 --       Queries standalone related order lines attributes from table
2906 --       Oe_Order_Lines_All based on Header Id and Line Number passed.
2907 --=============================================================================
2908 --
2909 PROCEDURE Check_Line_Exists (
2910           p_header_id        IN         NUMBER,
2911           p_line_number      IN         NUMBER,
2912           x_om_line_rec_type OUT NOCOPY OM_Line_Rec_Type,
2913           x_return_status    OUT NOCOPY VARCHAR2 )
2914 IS
2915    cursor c_line_info is
2916    select line_id,
2917           decode(open_flag,'N','N',decode(shipped_quantity,null,'Y','N')) open_flag,
2918           ordered_quantity,
2919           inventory_item_id,
2920           ordered_item_id,
2921           order_quantity_uom,
2922           ship_tolerance_above,
2923           ship_tolerance_below,
2924           request_date,
2925           schedule_ship_date,
2926           ship_set_id,
2927           shipping_instructions,
2928           packing_instructions,
2929           shipment_priority_code,
2930           cust_po_number,
2931           subinventory,
2932           unit_selling_price,
2933           rownum
2934    from   oe_order_lines_all
2935    where  line_number = p_line_number
2936    and    header_id = p_header_id;
2937 
2938    l_ship_set_id   NUMBER;
2939 
2940    --
2941    l_debug_on BOOLEAN;
2942    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Check_Line_Exists';
2943    --
2944 BEGIN
2945    --Debug Push
2946    --
2947    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
2948    --
2949    IF l_debug_on IS NULL THEN
2950       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
2951    END IF;
2952    --
2953    IF l_debug_on THEN
2954       WSH_DEBUG_SV.push(l_module_name);
2955       WSH_DEBUG_SV.log(l_module_name, 'p_header_id', p_header_id );
2956       WSH_DEBUG_SV.log(l_module_name, 'p_line_number', p_line_number );
2957    END IF;
2958    --
2959 
2960    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
2961 
2962    FOR i in c_line_info
2963    LOOP
2964       IF i.rownum > 1 THEN
2965          --
2966          IF l_debug_on THEN
2967             WSH_DEBUG_SV.log(l_module_name, 'Error: More than one order line exists for same line number', p_line_number);
2968          END IF;
2969          --
2970          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ERROR');
2971          x_return_status := WSH_UTIl_CORE.G_RET_STS_ERROR;
2972          WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name);
2973       END IF;
2974 
2975       -- Error out while entering into the loop second time.
2976       x_om_line_rec_type.line_id                := i.line_id;
2977       x_om_line_rec_type.open_flag              := i.open_flag;
2978       x_om_line_rec_type.ordered_quantity       := i.ordered_quantity;
2979       x_om_line_rec_type.inventory_item_id      := i.inventory_item_id;
2980       x_om_line_rec_type.ordered_item_id        := i.ordered_item_id;
2981       x_om_line_rec_type.order_quantity_uom     := i.order_quantity_uom;
2982       x_om_line_rec_type.ship_tolerance_above   := i.ship_tolerance_above;
2983       x_om_line_rec_type.ship_tolerance_below   := i.ship_tolerance_below;
2984       x_om_line_rec_type.request_date           := i.request_date;
2985       x_om_line_rec_type.schedule_ship_date     := i.schedule_ship_date;
2986       x_om_line_rec_type.shipping_instructions  := i.shipping_instructions;
2987       x_om_line_rec_type.packing_instructions   := i.packing_instructions;
2988       x_om_line_rec_type.shipment_priority_code := i.shipment_priority_code;
2989       x_om_line_rec_type.cust_po_number         := i.cust_po_number;
2990       x_om_line_rec_type.subinventory           := i.subinventory;
2991       x_om_line_rec_type.unit_selling_price     := i.unit_selling_price;
2992       l_ship_set_id                             := i.ship_set_id;
2993 
2994       IF l_ship_set_id is null THEN
2995          x_om_line_rec_type.ship_set_name          := null;
2996       ELSE
2997          BEGIN
2998             select set_name
2999             into   x_om_line_rec_type.ship_set_name
3000             from   oe_sets
3001             where  set_id = l_ship_set_id;
3002          EXCEPTION
3003          WHEN NO_DATA_FOUND THEN
3004             x_om_line_rec_type.ship_set_name := null;
3005          END;
3006       END IF;
3007    END LOOP;
3008 
3009    --
3010    IF l_debug_on THEN
3011       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
3012       WSH_DEBUG_SV.log(l_module_name, 'Line id', x_om_line_rec_type.line_id);
3013       WSH_DEBUG_SV.pop(l_module_name);
3014    END IF;
3015    --
3016 EXCEPTION
3017 WHEN OTHERS THEN
3018       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3019       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Check_Line_Exists');
3020       --
3021       IF l_debug_on THEN
3022         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3023         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3024       END IF;
3025       --
3026 END Check_Line_Exists;
3027 --
3028 --=============================================================================
3029 -- PUBLIC PROCEDURE :
3030 --       Lock_SR_Lines
3031 --
3032 -- PARAMETERS:
3033 --       p_header_id             => Order Header Id
3034 --       p_delivery_interface_id => Delivery Interface Id
3035 --       p_interface_records     => Either Y or N
3036 --       x_return_status         => Return Status of API (Either S,E,U)
3037 -- COMMENT:
3038 --       API to Lock records from OEH, OEL and WDD table.
3039 --       Based on p_interface_records value,
3040 --       Y : Lock records from OEL, WDD corresponding to records from WDDI
3041 --           Interface Table
3042 --       N : Lock records from OEL, WDD for lines which are not populated in
3043 --           WDDI Interface Table
3044 --=============================================================================
3045 --
3046 PROCEDURE Lock_SR_Lines (
3047           p_header_id             IN NUMBER,
3048           p_delivery_interface_id IN NUMBER,
3049           p_interface_records     IN VARCHAR2,
3050           x_return_status         OUT NOCOPY VARCHAR2 )
3051 IS
3052 
3053    cursor c_lock_interface_lines
3054    is
3055       select oel.line_id
3056       from   oe_order_lines_all oel,
3057              wsh_del_details_interface wddi,
3058              wsh_del_assgn_interface   wdai
3059       where  oel.header_id   = p_header_id
3060       and    oel.line_number = wddi.line_number
3061       and    wddi.interface_action_code = g_interface_action_code
3062       and    wdai.interface_action_code = g_interface_action_code
3063       and    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
3064       and    wdai.delivery_interface_id = p_delivery_interface_id
3065       for update of oel.line_id nowait;
3066 
3067    cursor c_lock_non_interface_lines
3068    is
3069       select oel.line_id
3070       from   oe_order_lines_all oel
3071       where  oel.header_id   = p_header_id
3072       and    not exists
3073            ( select '1'
3074              from   wsh_del_details_interface wddi,
3075                     wsh_del_assgn_interface   wdai
3076              where  oel.line_number = wddi.line_number
3077              and    wddi.interface_action_code = g_interface_action_code
3078              and    wdai.interface_action_code = g_interface_action_code
3079              and    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
3080              and    wdai.delivery_interface_id = p_delivery_interface_id )
3081    for update of oel.line_id nowait;
3082 
3083    cursor c_lock_delivery_details( c_line_id NUMBER )
3084    is
3085       select delivery_detail_id
3086       from   wsh_delivery_details
3087       where  source_code = 'OE'
3088       and    source_line_id = c_line_id
3089       for update nowait;
3090 
3091    l_header_id          NUMBER;
3092    l_details_tab        WSH_UTIL_CORE.Id_Tab_Type;
3093 
3094    RECORD_LOCKED         EXCEPTION;
3095    PRAGMA EXCEPTION_INIT(RECORD_LOCKED, -54);
3096 
3097    --
3098    l_debug_on BOOLEAN;
3099    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Lock_SR_Lines';
3100    --
3101 BEGIN
3102    --
3103    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3104    --
3105    IF l_debug_on IS NULL THEN
3106       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3107    END IF;
3108    --
3109    IF l_debug_on THEN
3110       WSH_DEBUG_SV.push(l_module_name);
3111       WSH_DEBUG_SV.log(l_module_name, 'p_header_id', p_header_id );
3112       WSH_DEBUG_SV.log(l_module_name, 'p_delivery_interface_id', p_delivery_interface_id );
3113       WSH_DEBUG_SV.log(l_module_name, 'p_interface_records', p_interface_records );
3114    END IF;
3115    --
3116 
3117    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
3118 
3119    IF p_interface_records = 'Y' THEN
3120       --
3121       IF l_debug_on THEN
3122          WSH_DEBUG_SV.logmsg(l_module_name, 'Obtaining lock on order headers');
3123       END IF;
3124       --
3125       select header_id
3126       into   l_header_id
3127       from   oe_order_headers_all
3128       where  header_id = p_header_id
3129       for update nowait;
3130 
3131       --
3132       IF l_debug_on THEN
3133          WSH_DEBUG_SV.logmsg(l_module_name, 'Obtaining lock on order lines');
3134       END IF;
3135       --
3136       FOR l_line_rec in c_lock_interface_lines
3137       LOOP
3138          --
3139          IF l_debug_on THEN
3140             WSH_DEBUG_SV.logmsg(l_module_name, 'Obtaining lock on delivery details');
3141          END IF;
3142          --
3143          select delivery_detail_id
3144          bulk collect into l_details_tab
3145          from   wsh_delivery_details
3146          where  source_code = 'OE'
3147          and    source_line_id = l_line_rec.line_id
3148          for update nowait;
3149       END LOOP;
3150    ELSE
3151       --
3152       IF l_debug_on THEN
3153          WSH_DEBUG_SV.logmsg(l_module_name, 'Obtaining lock on non-interface order lines');
3154       END IF;
3155       --
3156       FOR l_line_rec in c_lock_non_interface_lines
3157       LOOP
3158          --
3159          IF l_debug_on THEN
3160             WSH_DEBUG_SV.logmsg(l_module_name, 'Obtaining lock on non-interface delivery details');
3161          END IF;
3162          --
3163          select delivery_detail_id
3164          bulk collect into l_details_tab
3165          from   wsh_delivery_details
3166          where  source_code = 'OE'
3167          and    source_line_id = l_line_rec.line_id
3168          for update nowait;
3169       END LOOP;
3170    END IF;
3171 
3172    --
3173    IF l_debug_on THEN
3174       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
3175       WSH_DEBUG_SV.pop(l_module_name);
3176    END IF;
3177    --
3178 EXCEPTION
3179    WHEN RECORD_LOCKED THEN
3180         x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3181         FND_MESSAGE.SET_NAME('WSH','WSH_NO_LOCK');
3182         WSH_UTIL_CORE.add_message (x_return_status);
3183         --
3184         IF l_debug_on THEN
3185            WSH_DEBUG_SV.logmsg(l_module_name,'RECORD_LOCKED exception has occured.',WSH_DEBUG_SV.C_EXCEP_LEVEL);
3186            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:RECORD_LOCKED');
3187         END IF;
3188         --
3189    WHEN OTHERS THEN
3190         x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3191         WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Lock_SR_Lines');
3192         WSH_UTIL_CORE.add_message (x_return_status);
3193         --
3194         IF l_debug_on THEN
3195           WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3196           WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3197         END IF;
3198         --
3199 END Lock_SR_Lines;
3200 --
3201 --=============================================================================
3202 -- PUBLIC PROCEDURE :
3203 --       Validate_Delivery_Line
3204 --
3205 -- PARAMETERS:
3206 --       p_changed_attributes => Changed Attributes passed from OM
3207 --       x_return_status      => Return Status of API (Either S,E,U)
3208 -- COMMENT:
3209 --       Only Requested Quantity can be updated during Shipment Request process
3210 --       for Shipment lines if any delivery line is in a confirmed delivery or
3211 --       has been shipped.
3212 --=============================================================================
3213 --
3214 PROCEDURE Validate_Delivery_Line (
3215                    p_changed_attributes IN  WSH_INTERFACE.ChangedAttributeTabType,
3216                    x_return_status      OUT NOCOPY VARCHAR2 )
3217 IS
3218    CURSOR c_delivery_line_info(c_line_id NUMBER)
3219    IS
3220    select wdd.*
3221    from   wsh_delivery_details     wdd,
3222           wsh_delivery_assignments wda,
3223           wsh_new_deliveries       wnd
3224    where  wnd.status_code in ( 'CL', 'IT', 'CO' )
3225    and    wnd.delivery_id = wda.delivery_id
3226    and    wda.delivery_detail_id = wdd.delivery_detail_id
3227    and    source_code = 'OE'
3228    and    released_status in ( 'C', 'Y' )
3229    and    wdd.source_line_id = c_line_id
3230    and    rownum = 1;
3231 
3232    --
3233    l_debug_on BOOLEAN;
3234    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Validate_Delivery_Line';
3235    --
3236 BEGIN
3237    --
3238    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3239    --
3240    IF l_debug_on IS NULL THEN
3241       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3242    END IF;
3243    --
3244    IF l_debug_on THEN
3245       WSH_DEBUG_SV.push(l_module_name);
3246    END IF;
3247    --
3248 
3249    x_return_status := WSH_UTIl_CORE.G_RET_STS_SUCCESS;
3250 
3251    FOR i in p_changed_attributes.FIRST .. p_changed_attributes.LAST
3252    LOOP
3253       --
3254       IF l_debug_on THEN
3255          WSH_DEBUG_SV.log(l_module_name, 'source_line_id', p_changed_attributes(i).source_line_id );
3256       END IF;
3257       --
3258    FOR delivery_line_info in c_delivery_line_info(p_changed_attributes(i).source_line_id )
3259    LOOP
3260    /*
3261       -- Just for debugging
3262       --
3263       IF l_debug_on THEN
3264          WSH_DEBUG_SV.log(l_module_name, 'p_changed_attributes(i).shipping_instructions', p_changed_attributes(i).shipping_instructions );
3265          WSH_DEBUG_SV.log(l_module_name, 'delivery_line_info.shipping_instructions', delivery_line_info.shipping_instructions );
3266          WSH_DEBUG_SV.logmsg(l_module_name, 'arrival_set_id                 => ' || p_changed_attributes(i).arrival_set_id                || ' , => ' || delivery_line_info.arrival_set_id );
3267          WSH_DEBUG_SV.logmsg(l_module_name, 'ato_line_id                    => ' || p_changed_attributes(i).ato_line_id                   || ' , => ' || delivery_line_info.ato_line_id );
3268          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute1                     => ' || p_changed_attributes(i).attribute1                    || ' , => ' || delivery_line_info.attribute1 );
3269          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute10                    => ' || p_changed_attributes(i).attribute10                   || ' , => ' || delivery_line_info.attribute10 );
3270          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute11                    => ' || p_changed_attributes(i).attribute11                   || ' , => ' || delivery_line_info.attribute11 );
3271          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute12                    => ' || p_changed_attributes(i).attribute12                   || ' , => ' || delivery_line_info.attribute12 );
3272          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute13                    => ' || p_changed_attributes(i).attribute13                   || ' , => ' || delivery_line_info.attribute13 );
3273          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute14                    => ' || p_changed_attributes(i).attribute14                   || ' , => ' || delivery_line_info.attribute14 );
3274          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute15                    => ' || p_changed_attributes(i).attribute15                   || ' , => ' || delivery_line_info.attribute15 );
3275          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute2                     => ' || p_changed_attributes(i).attribute2                    || ' , => ' || delivery_line_info.attribute2 );
3276          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute3                     => ' || p_changed_attributes(i).attribute3                    || ' , => ' || delivery_line_info.attribute3 );
3277          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute4                     => ' || p_changed_attributes(i).attribute4                    || ' , => ' || delivery_line_info.attribute4 );
3278          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute5                     => ' || p_changed_attributes(i).attribute5                    || ' , => ' || delivery_line_info.attribute5 );
3279          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute6                     => ' || p_changed_attributes(i).attribute6                    || ' , => ' || delivery_line_info.attribute6 );
3280          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute7                     => ' || p_changed_attributes(i).attribute7                    || ' , => ' || delivery_line_info.attribute7 );
3281          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute8                     => ' || p_changed_attributes(i).attribute8                    || ' , => ' || delivery_line_info.attribute8 );
3282          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute9                     => ' || p_changed_attributes(i).attribute9                    || ' , => ' || delivery_line_info.attribute9 );
3283          WSH_DEBUG_SV.logmsg(l_module_name, 'attribute_category             => ' || p_changed_attributes(i).attribute_category            || ' , => ' || delivery_line_info.attribute_category );
3284          WSH_DEBUG_SV.logmsg(l_module_name, 'cancelled_quantity             => ' || p_changed_attributes(i).cancelled_quantity            || ' , => ' || delivery_line_info.cancelled_quantity );
3285          WSH_DEBUG_SV.logmsg(l_module_name, 'cancelled_quantity2            => ' || p_changed_attributes(i).cancelled_quantity2           || ' , => ' || delivery_line_info.cancelled_quantity2 );
3286          WSH_DEBUG_SV.logmsg(l_module_name, 'carrier_id                     => ' || p_changed_attributes(i).carrier_id                    || ' , => ' || delivery_line_info.carrier_id );
3287          WSH_DEBUG_SV.logmsg(l_module_name, 'classification                 => ' || p_changed_attributes(i).classification                || ' , => ' || delivery_line_info.classification );
3288          WSH_DEBUG_SV.logmsg(l_module_name, 'commodity_code_cat_id          => ' || p_changed_attributes(i).commodity_code_cat_id         || ' , => ' || delivery_line_info.commodity_code_cat_id );
3289          WSH_DEBUG_SV.logmsg(l_module_name, 'container_flag                 => ' || p_changed_attributes(i).container_flag                || ' , => ' || delivery_line_info.container_flag );
3290          WSH_DEBUG_SV.logmsg(l_module_name, 'container_name                 => ' || p_changed_attributes(i).container_name                || ' , => ' || delivery_line_info.container_name );
3291          WSH_DEBUG_SV.logmsg(l_module_name, 'container_type_code            => ' || p_changed_attributes(i).container_type_code           || ' , => ' || delivery_line_info.container_type_code );
3292          WSH_DEBUG_SV.logmsg(l_module_name, 'country_of_origin              => ' || p_changed_attributes(i).country_of_origin             || ' , => ' || delivery_line_info.country_of_origin );
3293          WSH_DEBUG_SV.logmsg(l_module_name, 'currency_code                  => ' || p_changed_attributes(i).currency_code                 || ' , => ' || delivery_line_info.currency_code );
3294          WSH_DEBUG_SV.logmsg(l_module_name, 'cust_model_serial_number       => ' || p_changed_attributes(i).cust_model_serial_number      || ' , => ' || delivery_line_info.cust_model_serial_number );
3295          WSH_DEBUG_SV.logmsg(l_module_name, 'cust_po_number                 => ' || p_changed_attributes(i).cust_po_number                || ' , => ' || delivery_line_info.cust_po_number );
3296          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_dock_code             => ' || p_changed_attributes(i).customer_dock_code            || ' , => ' || delivery_line_info.customer_dock_code );
3297          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_id                    => ' || p_changed_attributes(i).customer_id                   || ' , => ' || delivery_line_info.customer_id );
3298          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_item_id               => ' || p_changed_attributes(i).customer_item_id              || ' , => ' || delivery_line_info.customer_item_id );
3299          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_job                   => ' || p_changed_attributes(i).customer_job                  || ' , => ' || delivery_line_info.customer_job );
3300          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_prod_seq              => ' || p_changed_attributes(i).customer_prod_seq             || ' , => ' || delivery_line_info.customer_prod_seq );
3301          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_production_line       => ' || p_changed_attributes(i).customer_production_line      || ' , => ' || delivery_line_info.customer_production_line );
3302          WSH_DEBUG_SV.logmsg(l_module_name, 'customer_requested_lot_flag    => ' || p_changed_attributes(i).customer_requested_lot_flag   || ' , => ' || delivery_line_info.customer_requested_lot_flag );
3303          WSH_DEBUG_SV.logmsg(l_module_name, 'cycle_count_quantity           => ' || p_changed_attributes(i).cycle_count_quantity          || ' , => ' || delivery_line_info.cycle_count_quantity );
3304          WSH_DEBUG_SV.logmsg(l_module_name, 'cycle_count_quantity2          => ' || p_changed_attributes(i).cycle_count_quantity2         || ' , => ' || delivery_line_info.cycle_count_quantity2 );
3305          WSH_DEBUG_SV.logmsg(l_module_name, 'date_requested                 => ' || p_changed_attributes(i).date_requested                || ' , => ' || delivery_line_info.date_requested );
3306          WSH_DEBUG_SV.logmsg(l_module_name, 'date_scheduled                 => ' || p_changed_attributes(i).date_scheduled                || ' , => ' || delivery_line_info.date_scheduled );
3307          WSH_DEBUG_SV.logmsg(l_module_name, 'deliver_to_contact_id          => ' || p_changed_attributes(i).deliver_to_contact_id         || ' , => ' || delivery_line_info.deliver_to_contact_id );
3308          WSH_DEBUG_SV.logmsg(l_module_name, 'deliver_to_org_id              => ' || p_changed_attributes(i).deliver_to_org_id             || ' , => ' || delivery_line_info.deliver_to_site_use_id );
3309          WSH_DEBUG_SV.logmsg(l_module_name, 'delivered_quantity             => ' || p_changed_attributes(i).delivered_quantity            || ' , => ' || delivery_line_info.delivered_quantity );
3310          WSH_DEBUG_SV.logmsg(l_module_name, 'delivered_quantity2            => ' || p_changed_attributes(i).delivered_quantity2           || ' , => ' || delivery_line_info.delivered_quantity2 );
3311          WSH_DEBUG_SV.logmsg(l_module_name, 'delivery_detail_id             => ' || p_changed_attributes(i).delivery_detail_id            || ' , => ' || delivery_line_info.delivery_detail_id );
3312          WSH_DEBUG_SV.logmsg(l_module_name, 'dep_plan_required_flag         => ' || p_changed_attributes(i).dep_plan_required_flag        || ' , => ' || delivery_line_info.dep_plan_required_flag );
3313          WSH_DEBUG_SV.logmsg(l_module_name, 'detail_container_item_id       => ' || p_changed_attributes(i).detail_container_item_id      || ' , => ' || delivery_line_info.detail_container_item_id );
3314          WSH_DEBUG_SV.logmsg(l_module_name, 'fill_percent                   => ' || p_changed_attributes(i).fill_percent                  || ' , => ' || delivery_line_info.fill_percent );
3315          WSH_DEBUG_SV.logmsg(l_module_name, 'fob_code                       => ' || p_changed_attributes(i).fob_code                      || ' , => ' || delivery_line_info.fob_code );
3316 --         WSH_DEBUG_SV.logmsg(l_module_name, 'freight_carrier_code           => ' || p_changed_attributes(i).freight_carrier_code          || ' , => ' || delivery_line_info.freight_carrier_code );
3317          WSH_DEBUG_SV.logmsg(l_module_name, 'freight_class_cat_id           => ' || p_changed_attributes(i).freight_class_cat_id          || ' , => ' || delivery_line_info.freight_class_cat_id );
3318          WSH_DEBUG_SV.logmsg(l_module_name, 'freight_terms_code             => ' || p_changed_attributes(i).freight_terms_code            || ' , => ' || delivery_line_info.freight_terms_code );
3319          WSH_DEBUG_SV.logmsg(l_module_name, 'gross_weight                   => ' || p_changed_attributes(i).gross_weight                  || ' , => ' || delivery_line_info.gross_weight );
3320          WSH_DEBUG_SV.logmsg(l_module_name, 'hazard_class_id                => ' || p_changed_attributes(i).hazard_class_id               || ' , => ' || delivery_line_info.hazard_class_id );
3321          WSH_DEBUG_SV.logmsg(l_module_name, 'hold_code                      => ' || p_changed_attributes(i).hold_code                     || ' , => ' || delivery_line_info.hold_code );
3322          WSH_DEBUG_SV.logmsg(l_module_name, 'inspection_flag                => ' || p_changed_attributes(i).inspection_flag               || ' , => ' || delivery_line_info.inspection_flag );
3323          WSH_DEBUG_SV.logmsg(l_module_name, 'intmed_ship_to_contact_id      => ' || p_changed_attributes(i).intmed_ship_to_contact_id     || ' , => ' || delivery_line_info.intmed_ship_to_contact_id );
3324 --         WSH_DEBUG_SV.logmsg(l_module_name, 'intmed_ship_to_org_id          => ' || p_changed_attributes(i).intmed_ship_to_org_id         || ' , => ' || delivery_line_info.intmed_ship_to_org_id );
3325          WSH_DEBUG_SV.logmsg(l_module_name, 'inv_interfaced_flag            => ' || p_changed_attributes(i).inv_interfaced_flag           || ' , => ' || delivery_line_info.inv_interfaced_flag );
3326          WSH_DEBUG_SV.logmsg(l_module_name, 'inventory_item_id              => ' || p_changed_attributes(i).inventory_item_id             || ' , => ' || delivery_line_info.inventory_item_id );
3327          WSH_DEBUG_SV.logmsg(l_module_name, 'item_description               => ' || p_changed_attributes(i).item_description              || ' , => ' || delivery_line_info.item_description );
3328 --         WSH_DEBUG_SV.logmsg(l_module_name, 'item_type_code                 => ' || p_changed_attributes(i).item_type_code                || ' , => ' || delivery_line_info.item_type_code );
3329 --         WSH_DEBUG_SV.logmsg(l_module_name, 'line_number                    => ' || p_changed_attributes(i).line_number                   || ' , => ' || delivery_line_info.line_number );
3330          WSH_DEBUG_SV.logmsg(l_module_name, 'load_seq_number                => ' || p_changed_attributes(i).load_seq_number               || ' , => ' || delivery_line_info.load_seq_number );
3331          WSH_DEBUG_SV.logmsg(l_module_name, 'locator_id                     => ' || p_changed_attributes(i).locator_id                    || ' , => ' || delivery_line_info.locator_id );
3332 --         WSH_DEBUG_SV.logmsg(l_module_name, 'lot_id                         => ' || p_changed_attributes(i).lot_id                        || ' , => ' || delivery_line_info.lot_id );
3333          WSH_DEBUG_SV.logmsg(l_module_name, 'lot_number                     => ' || p_changed_attributes(i).lot_number                    || ' , => ' || delivery_line_info.lot_number );
3334          WSH_DEBUG_SV.logmsg(l_module_name, 'lpn_id                         => ' || p_changed_attributes(i).lpn_id                        || ' , => ' || delivery_line_info.lpn_id );
3335          WSH_DEBUG_SV.logmsg(l_module_name, 'master_container_item_id       => ' || p_changed_attributes(i).master_container_item_id      || ' , => ' || delivery_line_info.master_container_item_id );
3336          WSH_DEBUG_SV.logmsg(l_module_name, 'master_serial_number           => ' || p_changed_attributes(i).master_serial_number          || ' , => ' || delivery_line_info.master_serial_number );
3337          WSH_DEBUG_SV.logmsg(l_module_name, 'maximum_load_weight            => ' || p_changed_attributes(i).maximum_load_weight           || ' , => ' || delivery_line_info.maximum_load_weight );
3338          WSH_DEBUG_SV.logmsg(l_module_name, 'maximum_volume                 => ' || p_changed_attributes(i).maximum_volume                || ' , => ' || delivery_line_info.maximum_volume );
3339          WSH_DEBUG_SV.logmsg(l_module_name, 'minimum_fill_percent           => ' || p_changed_attributes(i).minimum_fill_percent          || ' , => ' || delivery_line_info.minimum_fill_percent );
3340          WSH_DEBUG_SV.logmsg(l_module_name, 'move_order_line_id             => ' || p_changed_attributes(i).move_order_line_id            || ' , => ' || delivery_line_info.move_order_line_id );
3341          WSH_DEBUG_SV.logmsg(l_module_name, 'movement_id                    => ' || p_changed_attributes(i).movement_id                   || ' , => ' || delivery_line_info.movement_id );
3342          WSH_DEBUG_SV.logmsg(l_module_name, 'mvt_stat_status                => ' || p_changed_attributes(i).mvt_stat_status               || ' , => ' || delivery_line_info.mvt_stat_status );
3343          WSH_DEBUG_SV.logmsg(l_module_name, 'net_weight                     => ' || p_changed_attributes(i).net_weight                    || ' , => ' || delivery_line_info.net_weight );
3344          WSH_DEBUG_SV.logmsg(l_module_name, 'oe_interfaced_flag             => ' || p_changed_attributes(i).oe_interfaced_flag            || ' , => ' || delivery_line_info.oe_interfaced_flag );
3345          WSH_DEBUG_SV.logmsg(l_module_name, 'order_quantity_uom             => ' || p_changed_attributes(i).order_quantity_uom            || ' , => ' || delivery_line_info.src_requested_quantity_uom );
3346          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity               => ' || p_changed_attributes(i).ordered_quantity              || ' , => ' || delivery_line_info.src_requested_quantity );
3347          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity2              => ' || p_changed_attributes(i).ordered_quantity2             || ' , => ' || delivery_line_info.src_requested_quantity2 );
3348          WSH_DEBUG_SV.logmsg(l_module_name, 'ordered_quantity_uom2          => ' || p_changed_attributes(i).ordered_quantity_uom2         || ' , => ' || delivery_line_info.src_requested_quantity_uom2 );
3349          WSH_DEBUG_SV.logmsg(l_module_name, 'org_id                         => ' || p_changed_attributes(i).org_id                        || ' , => ' || delivery_line_info.org_id );
3350          WSH_DEBUG_SV.logmsg(l_module_name, 'organization_id                => ' || p_changed_attributes(i).organization_id               || ' , => ' || delivery_line_info.organization_id );
3351 --         WSH_DEBUG_SV.logmsg(l_module_name, 'original_source_line_id        => ' || p_changed_attributes(i).original_source_line_id       || ' , => ' || delivery_line_info.original_source_line_id );
3352          WSH_DEBUG_SV.logmsg(l_module_name, 'original_subinventory          => ' || p_changed_attributes(i).original_subinventory         || ' , => ' || delivery_line_info.original_subinventory );
3353          WSH_DEBUG_SV.logmsg(l_module_name, 'packing_instructions           => ' || p_changed_attributes(i).packing_instructions          || ' , => ' || delivery_line_info.packing_instructions );
3354 --         WSH_DEBUG_SV.logmsg(l_module_name, 'pending_quantity               => ' || p_changed_attributes(i).pending_quantity              || ' , => ' || delivery_line_info.pending_quantity );
3355 --         WSH_DEBUG_SV.logmsg(l_module_name, 'pending_quantity2              => ' || p_changed_attributes(i).pending_quantity2             || ' , => ' || delivery_line_info.pending_quantity2 );
3356          WSH_DEBUG_SV.logmsg(l_module_name, 'pickable_flag                  => ' || p_changed_attributes(i).pickable_flag                 || ' , => ' || delivery_line_info.pickable_flag );
3357          WSH_DEBUG_SV.logmsg(l_module_name, 'picked_quantity                => ' || p_changed_attributes(i).picked_quantity               || ' , => ' || delivery_line_info.picked_quantity );
3358          WSH_DEBUG_SV.logmsg(l_module_name, 'picked_quantity2               => ' || p_changed_attributes(i).picked_quantity2              || ' , => ' || delivery_line_info.picked_quantity2 );
3359          WSH_DEBUG_SV.logmsg(l_module_name, 'preferred_grade                => ' || p_changed_attributes(i).preferred_grade               || ' , => ' || delivery_line_info.preferred_grade );
3360          WSH_DEBUG_SV.logmsg(l_module_name, 'project_id                     => ' || p_changed_attributes(i).project_id                    || ' , => ' || delivery_line_info.project_id );
3361          WSH_DEBUG_SV.logmsg(l_module_name, 'quality_control_quantity       => ' || p_changed_attributes(i).quality_control_quantity      || ' , => ' || delivery_line_info.quality_control_quantity );
3362          WSH_DEBUG_SV.logmsg(l_module_name, 'quality_control_quantity2      => ' || p_changed_attributes(i).quality_control_quantity2     || ' , => ' || delivery_line_info.quality_control_quantity2 );
3363          WSH_DEBUG_SV.logmsg(l_module_name, 'received_quantity              => ' || p_changed_attributes(i).received_quantity             || ' , => ' || delivery_line_info.received_quantity );
3364          WSH_DEBUG_SV.logmsg(l_module_name, 'received_quantity2             => ' || p_changed_attributes(i).received_quantity2            || ' , => ' || delivery_line_info.received_quantity2 );
3365          WSH_DEBUG_SV.logmsg(l_module_name, 'released_status                => ' || p_changed_attributes(i).released_status               || ' , => ' || delivery_line_info.released_status );
3366          WSH_DEBUG_SV.logmsg(l_module_name, 'request_id                     => ' || p_changed_attributes(i).request_id                    || ' , => ' || delivery_line_info.request_id );
3367          WSH_DEBUG_SV.logmsg(l_module_name, 'revision                       => ' || p_changed_attributes(i).revision                      || ' , => ' || delivery_line_info.revision );
3368          WSH_DEBUG_SV.logmsg(l_module_name, 'seal_code                      => ' || p_changed_attributes(i).seal_code                     || ' , => ' || delivery_line_info.seal_code );
3369          WSH_DEBUG_SV.logmsg(l_module_name, 'serial_number                  => ' || p_changed_attributes(i).serial_number                 || ' , => ' || delivery_line_info.serial_number );
3370          --WSH_DEBUG_SV.logmsg(l_module_name, 'ship_from_org_id               => ' || p_changed_attributes(i).ship_from_org_id              || ' , => ' || delivery_line_info.ship_from_org_id );
3371          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_model_complete_flag       => ' || p_changed_attributes(i).ship_model_complete_flag      || ' , => ' || delivery_line_info.ship_model_complete_flag );
3372          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_set_id                    => ' || p_changed_attributes(i).ship_set_id                   || ' , => ' || delivery_line_info.ship_set_id );
3373          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_contact_id             => ' || p_changed_attributes(i).ship_to_contact_id            || ' , => ' || delivery_line_info.ship_to_contact_id );
3374          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_org_id                 => ' || p_changed_attributes(i).ship_to_org_id                || ' , => ' || delivery_line_info.ship_to_site_use_id );
3375          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_to_site_use_id            => ' || p_changed_attributes(i).ship_to_site_use_id           || ' , => ' || delivery_line_info.ship_to_site_use_id );
3376          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_tolerance_above           => ' || p_changed_attributes(i).ship_tolerance_above          || ' , => ' || delivery_line_info.ship_tolerance_above );
3377          WSH_DEBUG_SV.logmsg(l_module_name, 'ship_tolerance_below           => ' || p_changed_attributes(i).ship_tolerance_below          || ' , => ' || delivery_line_info.ship_tolerance_below );
3378          WSH_DEBUG_SV.logmsg(l_module_name, 'shipment_priority_code         => ' || p_changed_attributes(i).shipment_priority_code        || ' , => ' || delivery_line_info.shipment_priority_code );
3379          --WSH_DEBUG_SV.logmsg(l_module_name, 'shipped_flag                   => ' || p_changed_attributes(i).shipped_flag                  || ' , => ' || delivery_line_info.shipped_flag );
3380          WSH_DEBUG_SV.logmsg(l_module_name, 'shipped_quantity               => ' || p_changed_attributes(i).shipped_quantity              || ' , => ' || delivery_line_info.shipped_quantity );
3381          WSH_DEBUG_SV.logmsg(l_module_name, 'shipped_quantity2              => ' || p_changed_attributes(i).shipped_quantity2             || ' , => ' || delivery_line_info.shipped_quantity2 );
3382          WSH_DEBUG_SV.logmsg(l_module_name, 'shipping_instructions          => ' || p_changed_attributes(i).shipping_instructions         || ' , => ' || delivery_line_info.shipping_instructions );
3383          --WSH_DEBUG_SV.logmsg(l_module_name, 'shipping_method_code           => ' || p_changed_attributes(i).shipping_method_code          || ' , => ' || delivery_line_info.shipping_method_code );
3384          WSH_DEBUG_SV.logmsg(l_module_name, 'sold_to_contact_id             => ' || p_changed_attributes(i).sold_to_contact_id            || ' , => ' || delivery_line_info.sold_to_contact_id );
3385          WSH_DEBUG_SV.logmsg(l_module_name, 'sold_to_org_id                 => ' || p_changed_attributes(i).sold_to_org_id                || ' , => ' || delivery_line_info.customer_id);
3386          WSH_DEBUG_SV.logmsg(l_module_name, 'source_code                    => ' || p_changed_attributes(i).source_code                   || ' , => ' || delivery_line_info.source_code );
3387          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_id               => ' || p_changed_attributes(i).source_header_id              || ' , => ' || delivery_line_info.source_header_id );
3388          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_number           => ' || p_changed_attributes(i).source_header_number          || ' , => ' || delivery_line_info.source_header_number );
3389          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_type_id          => ' || p_changed_attributes(i).source_header_type_id         || ' , => ' || delivery_line_info.source_header_type_id );
3390          WSH_DEBUG_SV.logmsg(l_module_name, 'source_header_type_name        => ' || p_changed_attributes(i).source_header_type_name       || ' , => ' || delivery_line_info.source_header_type_name );
3391          WSH_DEBUG_SV.logmsg(l_module_name, 'source_line_id                 => ' || p_changed_attributes(i).source_line_id                || ' , => ' || delivery_line_info.source_line_id );
3392          WSH_DEBUG_SV.logmsg(l_module_name, 'source_line_set_id             => ' || p_changed_attributes(i).source_line_set_id            || ' , => ' || delivery_line_info.source_line_set_id );
3393          WSH_DEBUG_SV.logmsg(l_module_name, 'split_from_delivery_detail_id  => ' || p_changed_attributes(i).split_from_delivery_detail_id || ' , => ' || delivery_line_info.split_from_delivery_detail_id );
3394          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity         => ' || p_changed_attributes(i).src_requested_quantity        || ' , => ' || delivery_line_info.src_requested_quantity );
3395          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity2        => ' || p_changed_attributes(i).src_requested_quantity2       || ' , => ' || delivery_line_info.src_requested_quantity2 );
3396          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity_uom     => ' || p_changed_attributes(i).src_requested_quantity_uom    || ' , => ' || delivery_line_info.src_requested_quantity_uom );
3397          WSH_DEBUG_SV.logmsg(l_module_name, 'src_requested_quantity_uom2    => ' || p_changed_attributes(i).src_requested_quantity_uom2   || ' , => ' || delivery_line_info.src_requested_quantity_uom2 );
3398          WSH_DEBUG_SV.logmsg(l_module_name, 'subinventory                   => ' || p_changed_attributes(i).subinventory                  || ' , => ' || delivery_line_info.subinventory );
3399          --WSH_DEBUG_SV.logmsg(l_module_name, 'sublot_number                  => ' || p_changed_attributes(i).sublot_number                 || ' , => ' || delivery_line_info.sublot_number );
3400          WSH_DEBUG_SV.logmsg(l_module_name, 'task_id                        => ' || p_changed_attributes(i).task_id                       || ' , => ' || delivery_line_info.task_id );
3401          WSH_DEBUG_SV.logmsg(l_module_name, 'to_serial_number               => ' || p_changed_attributes(i).to_serial_number              || ' , => ' || delivery_line_info.to_serial_number );
3402          WSH_DEBUG_SV.logmsg(l_module_name, 'top_model_line_id              => ' || p_changed_attributes(i).top_model_line_id             || ' , => ' || delivery_line_info.top_model_line_id );
3403          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute1                  => ' || p_changed_attributes(i).tp_attribute1                 || ' , => ' || delivery_line_info.tp_attribute1 );
3404          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute10                 => ' || p_changed_attributes(i).tp_attribute10                || ' , => ' || delivery_line_info.tp_attribute10 );
3405          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute11                 => ' || p_changed_attributes(i).tp_attribute11                || ' , => ' || delivery_line_info.tp_attribute11 );
3406          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute12                 => ' || p_changed_attributes(i).tp_attribute12                || ' , => ' || delivery_line_info.tp_attribute12 );
3407          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute13                 => ' || p_changed_attributes(i).tp_attribute13                || ' , => ' || delivery_line_info.tp_attribute13 );
3408          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute14                 => ' || p_changed_attributes(i).tp_attribute14                || ' , => ' || delivery_line_info.tp_attribute14 );
3409          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute15                 => ' || p_changed_attributes(i).tp_attribute15                || ' , => ' || delivery_line_info.tp_attribute15 );
3410          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute2                  => ' || p_changed_attributes(i).tp_attribute2                 || ' , => ' || delivery_line_info.tp_attribute2 );
3411          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute3                  => ' || p_changed_attributes(i).tp_attribute3                 || ' , => ' || delivery_line_info.tp_attribute3 );
3412          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute4                  => ' || p_changed_attributes(i).tp_attribute4                 || ' , => ' || delivery_line_info.tp_attribute4 );
3413          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute5                  => ' || p_changed_attributes(i).tp_attribute5                 || ' , => ' || delivery_line_info.tp_attribute5 );
3414          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute6                  => ' || p_changed_attributes(i).tp_attribute6                 || ' , => ' || delivery_line_info.tp_attribute6 );
3415          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute7                  => ' || p_changed_attributes(i).tp_attribute7                 || ' , => ' || delivery_line_info.tp_attribute7 );
3416          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute8                  => ' || p_changed_attributes(i).tp_attribute8                 || ' , => ' || delivery_line_info.tp_attribute8 );
3417          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute9                  => ' || p_changed_attributes(i).tp_attribute9                 || ' , => ' || delivery_line_info.tp_attribute9 );
3418          WSH_DEBUG_SV.logmsg(l_module_name, 'tp_attribute_category          => ' || p_changed_attributes(i).tp_attribute_category         || ' , => ' || delivery_line_info.tp_attribute_category );
3419          WSH_DEBUG_SV.logmsg(l_module_name, 'tracking_number                => ' || p_changed_attributes(i).tracking_number               || ' , => ' || delivery_line_info.tracking_number );
3420          --WSH_DEBUG_SV.logmsg(l_module_name, 'trans_id                       => ' || p_changed_attributes(i).trans_id                      || ' , => ' || delivery_line_info.trans_id );
3421          WSH_DEBUG_SV.logmsg(l_module_name, 'transaction_temp_id            => ' || p_changed_attributes(i).transaction_temp_id           || ' , => ' || delivery_line_info.transaction_temp_id );
3422          --WSH_DEBUG_SV.logmsg(l_module_name, 'transfer_lpn_id                => ' || p_changed_attributes(i).transfer_lpn_id               || ' , => ' || delivery_line_info.transfer_lpn_id );
3423          WSH_DEBUG_SV.logmsg(l_module_name, 'unit_number                    => ' || p_changed_attributes(i).unit_number                   || ' , => ' || delivery_line_info.unit_number );
3424          WSH_DEBUG_SV.logmsg(l_module_name, 'unit_price                     => ' || p_changed_attributes(i).unit_price                    || ' , => ' || delivery_line_info.unit_price );
3425          WSH_DEBUG_SV.logmsg(l_module_name, 'volume                         => ' || p_changed_attributes(i).volume                        || ' , => ' || delivery_line_info.volume );
3426          WSH_DEBUG_SV.logmsg(l_module_name, 'volume_uom_code                => ' || p_changed_attributes(i).volume_uom_code               || ' , => ' || delivery_line_info.volume_uom_code );
3427          WSH_DEBUG_SV.logmsg(l_module_name, 'weight_uom_code                => ' || p_changed_attributes(i).weight_uom_code               || ' , => ' || delivery_line_info.weight_uom_code );
3428          --WSH_DEBUG_SV.logmsg(l_module_name, 'latest_acceptable_date         => ' || p_changed_attributes(i).latest_acceptable_date        || ' , => ' || delivery_line_info.latest_acceptable_date );
3429          --WSH_DEBUG_SV.logmsg(l_module_name, 'promise_date                   => ' || p_changed_attributes(i).promise_date                  || ' , => ' || delivery_line_info.promise_date );
3430          --WSH_DEBUG_SV.logmsg(l_module_name, 'schedule_arrival_date          => ' || p_changed_attributes(i).schedule_arrival_date         || ' , => ' || delivery_line_info.schedule_arrival_date );
3431          --WSH_DEBUG_SV.logmsg(l_module_name, 'earliest_acceptable_date       => ' || p_changed_attributes(i).earliest_acceptable_date      || ' , => ' || delivery_line_info.earliest_acceptable_date );
3432          --WSH_DEBUG_SV.logmsg(l_module_name, 'earliest_ship_date             => ' || p_changed_attributes(i).earliest_ship_date            || ' , => ' || delivery_line_info.earliest_ship_date );
3433          WSH_DEBUG_SV.logmsg(l_module_name, 'filled_volume                  => ' || p_changed_attributes(i).filled_volume                 || ' , => ' || delivery_line_info.filled_volume );
3434          WSH_DEBUG_SV.logmsg(l_module_name, 'Changed Subinventory           => ' || p_changed_attributes(i).subinventory                  || ' , => ' || delivery_line_info.original_subinventory );
3435       END IF;
3436       --
3437       */
3438       IF (
3439              ( ( nvl(p_changed_attributes(i).arrival_set_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.arrival_set_id, FND_API.G_MISS_NUM ) )
3440               or ( p_changed_attributes(i).arrival_set_id = FND_API.G_MISS_NUM ) )
3441          and ( (  nvl(p_changed_attributes(i).ato_line_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ato_line_id, FND_API.G_MISS_NUM ) )
3442               or ( p_changed_attributes(i).ato_line_id = FND_API.G_MISS_NUM ) )
3443          and ( (  nvl(p_changed_attributes(i).attribute1, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute1, FND_API.G_MISS_CHAR ) )
3444               or ( p_changed_attributes(i).attribute1 = FND_API.G_MISS_CHAR ) )
3445          and ( (  nvl(p_changed_attributes(i).attribute10, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute10, FND_API.G_MISS_CHAR ) )
3446               or ( p_changed_attributes(i).attribute10 = FND_API.G_MISS_CHAR ) )
3447          and ( (  nvl(p_changed_attributes(i).attribute11, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute11, FND_API.G_MISS_CHAR ) )
3448               or ( p_changed_attributes(i).attribute11 = FND_API.G_MISS_CHAR ) )
3449          and ( (  nvl(p_changed_attributes(i).attribute12, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute12, FND_API.G_MISS_CHAR ) )
3450               or ( p_changed_attributes(i).attribute12 = FND_API.G_MISS_CHAR ) )
3451          and ( (  nvl(p_changed_attributes(i).attribute13, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute13, FND_API.G_MISS_CHAR ) )
3452               or ( p_changed_attributes(i).attribute13 = FND_API.G_MISS_CHAR ) )
3453          and ( (  nvl(p_changed_attributes(i).attribute14, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute14, FND_API.G_MISS_CHAR ) )
3454               or ( p_changed_attributes(i).attribute14 = FND_API.G_MISS_CHAR ) )
3455          and ( (  nvl(p_changed_attributes(i).attribute15, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute15, FND_API.G_MISS_CHAR ) )
3456               or ( p_changed_attributes(i).attribute15 = FND_API.G_MISS_CHAR ) )
3457          and ( (  nvl(p_changed_attributes(i).attribute2, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute2, FND_API.G_MISS_CHAR ) )
3458               or ( p_changed_attributes(i).attribute2 = FND_API.G_MISS_CHAR ) )
3459          and ( (  nvl(p_changed_attributes(i).attribute3, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute3, FND_API.G_MISS_CHAR ) )
3460               or ( p_changed_attributes(i).attribute3 = FND_API.G_MISS_CHAR ) )
3461          and ( (  nvl(p_changed_attributes(i).attribute4, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute4, FND_API.G_MISS_CHAR ) )
3462               or ( p_changed_attributes(i).attribute4 = FND_API.G_MISS_CHAR ) )
3463          and ( (  nvl(p_changed_attributes(i).attribute5, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute5, FND_API.G_MISS_CHAR ) )
3464               or ( p_changed_attributes(i).attribute5 = FND_API.G_MISS_CHAR ) )
3465          and ( (  nvl(p_changed_attributes(i).attribute6, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute6, FND_API.G_MISS_CHAR ) )
3466               or ( p_changed_attributes(i).attribute6 = FND_API.G_MISS_CHAR ) )
3467          and ( (  nvl(p_changed_attributes(i).attribute7, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute7, FND_API.G_MISS_CHAR ) )
3468               or ( p_changed_attributes(i).attribute7 = FND_API.G_MISS_CHAR ) )
3469          and ( (  nvl(p_changed_attributes(i).attribute8, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute8, FND_API.G_MISS_CHAR ) )
3470               or ( p_changed_attributes(i).attribute8 = FND_API.G_MISS_CHAR ) )
3471          and ( (  nvl(p_changed_attributes(i).attribute9, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute9, FND_API.G_MISS_CHAR ) )
3472               or ( p_changed_attributes(i).attribute9 = FND_API.G_MISS_CHAR ) )
3473          and ( (  nvl(p_changed_attributes(i).attribute_category, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.attribute_category, FND_API.G_MISS_CHAR ) )
3474               or ( p_changed_attributes(i).attribute_category = FND_API.G_MISS_CHAR ) )
3475          and ( (  nvl(p_changed_attributes(i).cancelled_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.cancelled_quantity, FND_API.G_MISS_NUM ) )
3476               or ( p_changed_attributes(i).cancelled_quantity = FND_API.G_MISS_NUM ) )
3477          and ( (  nvl(p_changed_attributes(i).cancelled_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.cancelled_quantity2, FND_API.G_MISS_NUM ) )
3478               or ( p_changed_attributes(i).cancelled_quantity2 = FND_API.G_MISS_NUM ) )
3479          and ( (  nvl(p_changed_attributes(i).carrier_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.carrier_id, FND_API.G_MISS_NUM ) )
3480               or ( p_changed_attributes(i).carrier_id = FND_API.G_MISS_NUM ) )
3481          and ( (  nvl(p_changed_attributes(i).classification, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.classification, FND_API.G_MISS_CHAR ) )
3482               or ( p_changed_attributes(i).classification = FND_API.G_MISS_CHAR ) )
3483          and ( (  nvl(p_changed_attributes(i).commodity_code_cat_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.commodity_code_cat_id, FND_API.G_MISS_NUM ) )
3484               or ( p_changed_attributes(i).commodity_code_cat_id = FND_API.G_MISS_NUM ) )
3485          and ( (  nvl(p_changed_attributes(i).container_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.container_flag, FND_API.G_MISS_CHAR ) )
3486               or ( p_changed_attributes(i).container_flag = FND_API.G_MISS_CHAR ) )
3487          and ( (  nvl(p_changed_attributes(i).container_name, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.container_name, FND_API.G_MISS_CHAR ) )
3488               or ( p_changed_attributes(i).container_name = FND_API.G_MISS_CHAR ) )
3489          and ( (  nvl(p_changed_attributes(i).container_type_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.container_type_code, FND_API.G_MISS_CHAR ) )
3490               or ( p_changed_attributes(i).container_type_code = FND_API.G_MISS_CHAR ) )
3491          and ( (  nvl(p_changed_attributes(i).country_of_origin, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.country_of_origin, FND_API.G_MISS_CHAR ) )
3492               or ( p_changed_attributes(i).country_of_origin = FND_API.G_MISS_CHAR ) )
3493          and ( (  nvl(p_changed_attributes(i).currency_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.currency_code, FND_API.G_MISS_CHAR ) )
3494               or ( p_changed_attributes(i).currency_code = FND_API.G_MISS_CHAR ) )
3495          and ( (  nvl(p_changed_attributes(i).cust_model_serial_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.cust_model_serial_number, FND_API.G_MISS_CHAR ) )
3496               or ( p_changed_attributes(i).cust_model_serial_number = FND_API.G_MISS_CHAR ) )
3497          and ( (  nvl(p_changed_attributes(i).cust_po_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.cust_po_number, FND_API.G_MISS_CHAR ) )
3498               or ( p_changed_attributes(i).cust_po_number = FND_API.G_MISS_CHAR ) )
3499          and ( (  nvl(p_changed_attributes(i).customer_dock_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.customer_dock_code, FND_API.G_MISS_CHAR ) )
3500               or ( p_changed_attributes(i).customer_dock_code = FND_API.G_MISS_CHAR ) )
3501          and ( (  nvl(p_changed_attributes(i).customer_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.customer_id, FND_API.G_MISS_NUM ) )
3502               or ( p_changed_attributes(i).customer_id = FND_API.G_MISS_NUM ) )
3503          and ( (  nvl(p_changed_attributes(i).customer_job, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.customer_job, FND_API.G_MISS_CHAR ) )
3504               or ( p_changed_attributes(i).customer_job = FND_API.G_MISS_CHAR ) )
3505          and ( (  nvl(p_changed_attributes(i).customer_prod_seq, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.customer_prod_seq, FND_API.G_MISS_CHAR ) )
3506               or ( p_changed_attributes(i).customer_prod_seq = FND_API.G_MISS_CHAR ) )
3507          and ( (  nvl(p_changed_attributes(i).customer_production_line, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.customer_production_line, FND_API.G_MISS_CHAR ) )
3508               or ( p_changed_attributes(i).customer_production_line = FND_API.G_MISS_CHAR ) )
3509          and ( (  nvl(p_changed_attributes(i).customer_requested_lot_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.customer_requested_lot_flag, FND_API.G_MISS_CHAR ) )
3510               or ( p_changed_attributes(i).customer_requested_lot_flag = FND_API.G_MISS_CHAR ) )
3511          and ( (  nvl(p_changed_attributes(i).cycle_count_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.cycle_count_quantity, FND_API.G_MISS_NUM ) )
3512               or ( p_changed_attributes(i).cycle_count_quantity = FND_API.G_MISS_NUM ) )
3513          and ( (  nvl(p_changed_attributes(i).cycle_count_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.cycle_count_quantity2, FND_API.G_MISS_NUM ) )
3514               or ( p_changed_attributes(i).cycle_count_quantity2 = FND_API.G_MISS_NUM ) )
3515          and ( (  nvl(p_changed_attributes(i).date_requested, FND_API.G_MISS_DATE) = nvl(delivery_line_info.date_requested, FND_API.G_MISS_DATE ) )
3516               or ( p_changed_attributes(i).date_requested = FND_API.G_MISS_DATE ) )
3517          and ( (  nvl(p_changed_attributes(i).date_scheduled, FND_API.G_MISS_DATE) = nvl(delivery_line_info.date_scheduled, FND_API.G_MISS_DATE ) )
3518               or ( p_changed_attributes(i).date_scheduled = FND_API.G_MISS_DATE ) )
3519          and ( (  nvl(p_changed_attributes(i).deliver_to_contact_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.deliver_to_contact_id, FND_API.G_MISS_NUM ) )
3520               or ( p_changed_attributes(i).deliver_to_contact_id = FND_API.G_MISS_NUM ) )
3521          and ( (  nvl(p_changed_attributes(i).deliver_to_org_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.deliver_to_site_use_id, FND_API.G_MISS_NUM ) )
3522               or ( p_changed_attributes(i).deliver_to_org_id = FND_API.G_MISS_NUM ) )
3523          and ( (  nvl(p_changed_attributes(i).delivered_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.delivered_quantity, FND_API.G_MISS_NUM ) )
3524               or ( p_changed_attributes(i).delivered_quantity = FND_API.G_MISS_NUM ) )
3525          and ( (  nvl(p_changed_attributes(i).delivered_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.delivered_quantity2, FND_API.G_MISS_NUM ) )
3526               or ( p_changed_attributes(i).delivered_quantity2 = FND_API.G_MISS_NUM ) )
3527          and ( (  nvl(p_changed_attributes(i).delivery_detail_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.delivery_detail_id, FND_API.G_MISS_NUM ) )
3528               or ( p_changed_attributes(i).delivery_detail_id = FND_API.G_MISS_NUM ) )
3529          and ( (  nvl(p_changed_attributes(i).dep_plan_required_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.dep_plan_required_flag, FND_API.G_MISS_CHAR ) )
3530               or ( p_changed_attributes(i).dep_plan_required_flag = FND_API.G_MISS_CHAR ) )
3531          and ( (  nvl(p_changed_attributes(i).detail_container_item_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.detail_container_item_id, FND_API.G_MISS_NUM ) )
3532               or ( p_changed_attributes(i).detail_container_item_id = FND_API.G_MISS_NUM ) )
3533          and ( (  nvl(p_changed_attributes(i).fill_percent, FND_API.G_MISS_NUM) = nvl(delivery_line_info.fill_percent, FND_API.G_MISS_NUM ) )
3534               or ( p_changed_attributes(i).fill_percent = FND_API.G_MISS_NUM ) )
3535          and ( (  nvl(p_changed_attributes(i).fob_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.fob_code, FND_API.G_MISS_CHAR ) )
3536               or ( p_changed_attributes(i).fob_code = FND_API.G_MISS_CHAR ) )
3537          and ( (  nvl(p_changed_attributes(i).freight_class_cat_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.freight_class_cat_id, FND_API.G_MISS_NUM ) )
3538               or ( p_changed_attributes(i).freight_class_cat_id = FND_API.G_MISS_NUM ) )
3539          and ( (  nvl(p_changed_attributes(i).freight_terms_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.freight_terms_code, FND_API.G_MISS_CHAR ) )
3540               or ( p_changed_attributes(i).freight_terms_code = FND_API.G_MISS_CHAR ) )
3541          and ( (  nvl(p_changed_attributes(i).gross_weight, FND_API.G_MISS_NUM) = nvl(delivery_line_info.gross_weight, FND_API.G_MISS_NUM ) )
3542               or ( p_changed_attributes(i).gross_weight = FND_API.G_MISS_NUM ) )
3543          and ( (  nvl(p_changed_attributes(i).hazard_class_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.hazard_class_id, FND_API.G_MISS_NUM ) )
3544               or ( p_changed_attributes(i).hazard_class_id = FND_API.G_MISS_NUM ) )
3545          and ( (  nvl(p_changed_attributes(i).hold_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.hold_code, FND_API.G_MISS_CHAR ) )
3546               or ( p_changed_attributes(i).hold_code = FND_API.G_MISS_CHAR ) )
3547          and ( (  nvl(p_changed_attributes(i).inspection_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.inspection_flag, FND_API.G_MISS_CHAR ) )
3548               or ( p_changed_attributes(i).inspection_flag = FND_API.G_MISS_CHAR ) )
3549          and ( (  nvl(p_changed_attributes(i).intmed_ship_to_contact_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.intmed_ship_to_contact_id, FND_API.G_MISS_NUM ) )
3550               or ( p_changed_attributes(i).intmed_ship_to_contact_id = FND_API.G_MISS_NUM ) )
3551          and ( (  nvl(p_changed_attributes(i).inv_interfaced_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.inv_interfaced_flag, FND_API.G_MISS_CHAR ) )
3552               or ( p_changed_attributes(i).inv_interfaced_flag = FND_API.G_MISS_CHAR ) )
3553          and ( (  nvl(p_changed_attributes(i).inventory_item_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.inventory_item_id, FND_API.G_MISS_NUM ) )
3554               or ( p_changed_attributes(i).inventory_item_id = FND_API.G_MISS_NUM ) )
3555          and ( (  nvl(p_changed_attributes(i).item_description, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.item_description, FND_API.G_MISS_CHAR ) )
3556               or ( p_changed_attributes(i).item_description = FND_API.G_MISS_CHAR ) )
3557          and ( (  nvl(p_changed_attributes(i).load_seq_number, FND_API.G_MISS_NUM) = nvl(delivery_line_info.load_seq_number, FND_API.G_MISS_NUM ) )
3558               or ( p_changed_attributes(i).load_seq_number = FND_API.G_MISS_NUM ) )
3559          and ( (  nvl(p_changed_attributes(i).locator_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.locator_id, FND_API.G_MISS_NUM ) )
3560               or ( p_changed_attributes(i).locator_id = FND_API.G_MISS_NUM ) )
3561          and ( (  nvl(p_changed_attributes(i).lot_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.lot_number, FND_API.G_MISS_CHAR ) )
3562               or ( p_changed_attributes(i).lot_number = FND_API.G_MISS_CHAR ) )
3563          and ( (  nvl(p_changed_attributes(i).lpn_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.lpn_id, FND_API.G_MISS_NUM ) )
3564               or ( p_changed_attributes(i).lpn_id = FND_API.G_MISS_NUM ) )
3565          and ( (  nvl(p_changed_attributes(i).master_container_item_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.master_container_item_id, FND_API.G_MISS_NUM ) )
3566               or ( p_changed_attributes(i).master_container_item_id = FND_API.G_MISS_NUM ) )
3567          and ( (  nvl(p_changed_attributes(i).master_serial_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.master_serial_number, FND_API.G_MISS_CHAR ) )
3568               or ( p_changed_attributes(i).master_serial_number = FND_API.G_MISS_CHAR ) )
3569          and ( (  nvl(p_changed_attributes(i).maximum_load_weight, FND_API.G_MISS_NUM) = nvl(delivery_line_info.maximum_load_weight, FND_API.G_MISS_NUM ) )
3570               or ( p_changed_attributes(i).maximum_load_weight = FND_API.G_MISS_NUM ) )
3571          and ( (  nvl(p_changed_attributes(i).maximum_volume, FND_API.G_MISS_NUM) = nvl(delivery_line_info.maximum_volume, FND_API.G_MISS_NUM ) )
3572               or ( p_changed_attributes(i).maximum_volume = FND_API.G_MISS_NUM ) )
3573          and ( (  nvl(p_changed_attributes(i).minimum_fill_percent, FND_API.G_MISS_NUM) = nvl(delivery_line_info.minimum_fill_percent, FND_API.G_MISS_NUM ) )
3574               or ( p_changed_attributes(i).minimum_fill_percent = FND_API.G_MISS_NUM ) )
3575          and ( (  nvl(p_changed_attributes(i).move_order_line_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.move_order_line_id, FND_API.G_MISS_NUM ) )
3576               or ( p_changed_attributes(i).move_order_line_id = FND_API.G_MISS_NUM ) )
3577          and ( (  nvl(p_changed_attributes(i).movement_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.movement_id, FND_API.G_MISS_NUM ) )
3578               or ( p_changed_attributes(i).movement_id = FND_API.G_MISS_NUM ) )
3579          and ( (  nvl(p_changed_attributes(i).mvt_stat_status, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.mvt_stat_status, FND_API.G_MISS_CHAR ) )
3580               or ( p_changed_attributes(i).mvt_stat_status = FND_API.G_MISS_CHAR ) )
3581          and ( (  nvl(p_changed_attributes(i).net_weight, FND_API.G_MISS_NUM) = nvl(delivery_line_info.net_weight, FND_API.G_MISS_NUM ) )
3582               or ( p_changed_attributes(i).net_weight = FND_API.G_MISS_NUM ) )
3583          and ( (  nvl(p_changed_attributes(i).oe_interfaced_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.oe_interfaced_flag, FND_API.G_MISS_CHAR ) )
3584               or ( p_changed_attributes(i).oe_interfaced_flag = FND_API.G_MISS_CHAR ) )
3585       -- Only ordered quantity and uom is allowed to update even if line is partially shipped.
3586       /*
3587          and ( (  nvl(p_changed_attributes(i).order_quantity_uom, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.src_requested_quantity_uom, FND_API.G_MISS_CHAR ) )
3588               or ( p_changed_attributes(i).order_quantity_uom = FND_API.G_MISS_CHAR ) )
3589          and ( (  nvl(p_changed_attributes(i).ordered_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.src_requested_quantity, FND_API.G_MISS_NUM ) )
3590               or ( p_changed_attributes(i).ordered_quantity = FND_API.G_MISS_NUM ) )
3591       */
3592          and ( (  nvl(p_changed_attributes(i).ordered_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.src_requested_quantity2, FND_API.G_MISS_NUM ) )
3593               or ( p_changed_attributes(i).ordered_quantity2 = FND_API.G_MISS_NUM ) )
3594          and ( (  nvl(p_changed_attributes(i).ordered_quantity_uom2, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.src_requested_quantity_uom2, FND_API.G_MISS_CHAR ) )
3595               or ( p_changed_attributes(i).ordered_quantity_uom2 = FND_API.G_MISS_CHAR ) )
3596          and ( (  nvl(p_changed_attributes(i).org_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.org_id, FND_API.G_MISS_NUM ) )
3597               or ( p_changed_attributes(i).org_id = FND_API.G_MISS_NUM ) )
3598          and ( (  nvl(p_changed_attributes(i).organization_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.organization_id, FND_API.G_MISS_NUM ) )
3599               or ( p_changed_attributes(i).organization_id = FND_API.G_MISS_NUM ) )
3600          and ( (  nvl(p_changed_attributes(i).subinventory, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.original_subinventory, FND_API.G_MISS_CHAR ) )
3601               or ( p_changed_attributes(i).subinventory = FND_API.G_MISS_CHAR ) )
3602          and ( (  nvl(p_changed_attributes(i).packing_instructions, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.packing_instructions, FND_API.G_MISS_CHAR ) )
3603               or ( p_changed_attributes(i).packing_instructions = FND_API.G_MISS_CHAR ) )
3604          and ( (  nvl(p_changed_attributes(i).pickable_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.pickable_flag, FND_API.G_MISS_CHAR ) )
3605               or ( p_changed_attributes(i).pickable_flag = FND_API.G_MISS_CHAR ) )
3606          and ( (  nvl(p_changed_attributes(i).picked_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.picked_quantity, FND_API.G_MISS_NUM ) )
3607               or ( p_changed_attributes(i).picked_quantity = FND_API.G_MISS_NUM ) )
3608          and ( (  nvl(p_changed_attributes(i).picked_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.picked_quantity2, FND_API.G_MISS_NUM ) )
3609               or ( p_changed_attributes(i).picked_quantity2 = FND_API.G_MISS_NUM ) )
3610          and ( (  nvl(p_changed_attributes(i).preferred_grade, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.preferred_grade, FND_API.G_MISS_CHAR ) )
3611               or ( p_changed_attributes(i).preferred_grade = FND_API.G_MISS_CHAR ) )
3612          and ( (  nvl(p_changed_attributes(i).project_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.project_id, FND_API.G_MISS_NUM ) )
3613               or ( p_changed_attributes(i).project_id = FND_API.G_MISS_NUM ) )
3614          and ( (  nvl(p_changed_attributes(i).quality_control_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.quality_control_quantity, FND_API.G_MISS_NUM ) )
3615               or ( p_changed_attributes(i).quality_control_quantity = FND_API.G_MISS_NUM ) )
3616          and ( (  nvl(p_changed_attributes(i).quality_control_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.quality_control_quantity2, FND_API.G_MISS_NUM ) )
3617               or ( p_changed_attributes(i).quality_control_quantity2 = FND_API.G_MISS_NUM ) )
3618          and ( (  nvl(p_changed_attributes(i).received_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.received_quantity, FND_API.G_MISS_NUM ) )
3619               or ( p_changed_attributes(i).received_quantity = FND_API.G_MISS_NUM ) )
3620          and ( (  nvl(p_changed_attributes(i).received_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.received_quantity2, FND_API.G_MISS_NUM ) )
3621               or ( p_changed_attributes(i).received_quantity2 = FND_API.G_MISS_NUM ) )
3622          and ( (  nvl(p_changed_attributes(i).released_status, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.released_status, FND_API.G_MISS_CHAR ) )
3623               or ( p_changed_attributes(i).released_status = FND_API.G_MISS_CHAR ) )
3624          and ( (  nvl(p_changed_attributes(i).request_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.request_id, FND_API.G_MISS_NUM ) )
3625               or ( p_changed_attributes(i).request_id = FND_API.G_MISS_NUM ) )
3626          and ( (  nvl(p_changed_attributes(i).revision, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.revision, FND_API.G_MISS_CHAR ) )
3627               or ( p_changed_attributes(i).revision = FND_API.G_MISS_CHAR ) )
3628          and ( (  nvl(p_changed_attributes(i).seal_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.seal_code, FND_API.G_MISS_CHAR ) )
3629               or ( p_changed_attributes(i).seal_code = FND_API.G_MISS_CHAR ) )
3630          and ( (  nvl(p_changed_attributes(i).serial_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.serial_number, FND_API.G_MISS_CHAR ) )
3631               or ( p_changed_attributes(i).serial_number = FND_API.G_MISS_CHAR ) )
3632          and ( (  nvl(p_changed_attributes(i).ship_model_complete_flag, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.ship_model_complete_flag, FND_API.G_MISS_CHAR ) )
3633               or ( p_changed_attributes(i).ship_model_complete_flag = FND_API.G_MISS_CHAR ) )
3634          and ( (  nvl(p_changed_attributes(i).ship_set_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_set_id, FND_API.G_MISS_NUM ) )
3635               or ( p_changed_attributes(i).ship_set_id = FND_API.G_MISS_NUM ) )
3636          and ( (  nvl(p_changed_attributes(i).ship_to_contact_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_to_contact_id, FND_API.G_MISS_NUM ) )
3637               or ( p_changed_attributes(i).ship_to_contact_id = FND_API.G_MISS_NUM ) )
3638          and ( (  nvl(p_changed_attributes(i).ship_to_org_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_to_site_use_id, FND_API.G_MISS_NUM ) )
3639               or ( p_changed_attributes(i).ship_to_org_id = FND_API.G_MISS_NUM ) )
3640          and ( (  nvl(p_changed_attributes(i).ship_to_site_use_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_to_site_use_id, FND_API.G_MISS_NUM ) )
3641               or ( p_changed_attributes(i).ship_to_site_use_id = FND_API.G_MISS_NUM ) )
3642          and ( (  nvl(p_changed_attributes(i).ship_tolerance_above, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_tolerance_above, FND_API.G_MISS_NUM ) )
3643               or ( p_changed_attributes(i).ship_tolerance_above = FND_API.G_MISS_NUM ) )
3644          and ( (  nvl(p_changed_attributes(i).ship_tolerance_below, FND_API.G_MISS_NUM) = nvl(delivery_line_info.ship_tolerance_below, FND_API.G_MISS_NUM ) )
3645               or ( p_changed_attributes(i).ship_tolerance_below = FND_API.G_MISS_NUM ) )
3646          and ( (  nvl(p_changed_attributes(i).shipment_priority_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.shipment_priority_code, FND_API.G_MISS_CHAR ) )
3647               or ( p_changed_attributes(i).shipment_priority_code = FND_API.G_MISS_CHAR ) )
3648          and ( (  nvl(p_changed_attributes(i).shipped_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.shipped_quantity, FND_API.G_MISS_NUM ) )
3649               or ( p_changed_attributes(i).shipped_quantity = FND_API.G_MISS_NUM ) )
3650          and ( (  nvl(p_changed_attributes(i).shipped_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.shipped_quantity2, FND_API.G_MISS_NUM ) )
3651               or ( p_changed_attributes(i).shipped_quantity2 = FND_API.G_MISS_NUM ) )
3652          and ( (  nvl(p_changed_attributes(i).shipping_instructions, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.shipping_instructions, FND_API.G_MISS_CHAR ) )
3653               or ( p_changed_attributes(i).shipping_instructions = FND_API.G_MISS_CHAR ) )
3654          and ( (  nvl(p_changed_attributes(i).sold_to_contact_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.sold_to_contact_id, FND_API.G_MISS_NUM ) )
3655               or ( p_changed_attributes(i).sold_to_contact_id = FND_API.G_MISS_NUM ) )
3656          and ( (  nvl(p_changed_attributes(i).sold_to_org_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.customer_id, FND_API.G_MISS_NUM ) )
3657               or ( p_changed_attributes(i).sold_to_org_id = FND_API.G_MISS_NUM ) )
3658          and ( (  nvl(p_changed_attributes(i).source_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.source_code, FND_API.G_MISS_CHAR ) )
3659               or ( p_changed_attributes(i).source_code = FND_API.G_MISS_CHAR ) )
3660          and ( (  nvl(p_changed_attributes(i).source_header_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.source_header_id, FND_API.G_MISS_NUM ) )
3661               or ( p_changed_attributes(i).source_header_id = FND_API.G_MISS_NUM ) )
3662          and ( (  nvl(p_changed_attributes(i).source_header_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.source_header_number, FND_API.G_MISS_CHAR ) )
3663               or ( p_changed_attributes(i).source_header_number = FND_API.G_MISS_CHAR ) )
3664          and ( (  nvl(p_changed_attributes(i).source_header_type_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.source_header_type_id, FND_API.G_MISS_NUM ) )
3665               or ( p_changed_attributes(i).source_header_type_id = FND_API.G_MISS_NUM ) )
3666          and ( (  nvl(p_changed_attributes(i).source_header_type_name, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.source_header_type_name, FND_API.G_MISS_CHAR ) )
3667               or ( p_changed_attributes(i).source_header_type_name = FND_API.G_MISS_CHAR ) )
3668          and ( (  nvl(p_changed_attributes(i).source_line_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.source_line_id, FND_API.G_MISS_NUM ) )
3669               or ( p_changed_attributes(i).source_line_id = FND_API.G_MISS_NUM ) )
3670          and ( (  nvl(p_changed_attributes(i).source_line_set_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.source_line_set_id, FND_API.G_MISS_NUM ) )
3671               or ( p_changed_attributes(i).source_line_set_id = FND_API.G_MISS_NUM ) )
3672          and ( (  nvl(p_changed_attributes(i).split_from_delivery_detail_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.split_from_delivery_detail_id, FND_API.G_MISS_NUM ) )
3673               or ( p_changed_attributes(i).split_from_delivery_detail_id = FND_API.G_MISS_NUM ) )
3674          and ( (  nvl(p_changed_attributes(i).src_requested_quantity, FND_API.G_MISS_NUM) = nvl(delivery_line_info.src_requested_quantity, FND_API.G_MISS_NUM ) )
3675               or ( p_changed_attributes(i).src_requested_quantity = FND_API.G_MISS_NUM ) )
3676          and ( (  nvl(p_changed_attributes(i).src_requested_quantity2, FND_API.G_MISS_NUM) = nvl(delivery_line_info.src_requested_quantity2, FND_API.G_MISS_NUM ) )
3677               or ( p_changed_attributes(i).src_requested_quantity2 = FND_API.G_MISS_NUM ) )
3678          and ( (  nvl(p_changed_attributes(i).src_requested_quantity_uom, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.src_requested_quantity_uom, FND_API.G_MISS_CHAR ) )
3679               or ( p_changed_attributes(i).src_requested_quantity_uom = FND_API.G_MISS_CHAR ) )
3680          and ( (  nvl(p_changed_attributes(i).src_requested_quantity_uom2, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.src_requested_quantity_uom2, FND_API.G_MISS_CHAR ) )
3681               or ( p_changed_attributes(i).src_requested_quantity_uom2 = FND_API.G_MISS_CHAR ) )
3682          and ( (  nvl(p_changed_attributes(i).task_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.task_id, FND_API.G_MISS_NUM ) )
3683               or ( p_changed_attributes(i).task_id = FND_API.G_MISS_NUM ) )
3684          and ( (  nvl(p_changed_attributes(i).to_serial_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.to_serial_number, FND_API.G_MISS_CHAR ) )
3685               or ( p_changed_attributes(i).to_serial_number = FND_API.G_MISS_CHAR ) )
3686          and ( (  nvl(p_changed_attributes(i).top_model_line_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.top_model_line_id, FND_API.G_MISS_NUM ) )
3687               or ( p_changed_attributes(i).top_model_line_id = FND_API.G_MISS_NUM ) )
3688          and ( (  nvl(p_changed_attributes(i).tp_attribute1, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute1, FND_API.G_MISS_CHAR ) )
3689               or ( p_changed_attributes(i).tp_attribute1 = FND_API.G_MISS_CHAR ) )
3690          and ( (  nvl(p_changed_attributes(i).tp_attribute10, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute10, FND_API.G_MISS_CHAR ) )
3691               or ( p_changed_attributes(i).tp_attribute10 = FND_API.G_MISS_CHAR ) )
3692          and ( (  nvl(p_changed_attributes(i).tp_attribute11, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute11, FND_API.G_MISS_CHAR ) )
3693               or ( p_changed_attributes(i).tp_attribute11 = FND_API.G_MISS_CHAR ) )
3694          and ( (  nvl(p_changed_attributes(i).tp_attribute12, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute12, FND_API.G_MISS_CHAR ) )
3695               or ( p_changed_attributes(i).tp_attribute12 = FND_API.G_MISS_CHAR ) )
3696          and ( (  nvl(p_changed_attributes(i).tp_attribute13, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute13, FND_API.G_MISS_CHAR ) )
3697               or ( p_changed_attributes(i).tp_attribute13 = FND_API.G_MISS_CHAR ) )
3698          and ( (  nvl(p_changed_attributes(i).tp_attribute14, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute14, FND_API.G_MISS_CHAR ) )
3699               or ( p_changed_attributes(i).tp_attribute14 = FND_API.G_MISS_CHAR ) )
3700          and ( (  nvl(p_changed_attributes(i).tp_attribute15, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute15, FND_API.G_MISS_CHAR ) )
3701               or ( p_changed_attributes(i).tp_attribute15 = FND_API.G_MISS_CHAR ) )
3702          and ( (  nvl(p_changed_attributes(i).tp_attribute2, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute2, FND_API.G_MISS_CHAR ) )
3703               or ( p_changed_attributes(i).tp_attribute2 = FND_API.G_MISS_CHAR ) )
3704          and ( (  nvl(p_changed_attributes(i).tp_attribute3, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute3, FND_API.G_MISS_CHAR ) )
3705               or ( p_changed_attributes(i).tp_attribute3 = FND_API.G_MISS_CHAR ) )
3706          and ( (  nvl(p_changed_attributes(i).tp_attribute4, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute4, FND_API.G_MISS_CHAR ) )
3707               or ( p_changed_attributes(i).tp_attribute4 = FND_API.G_MISS_CHAR ) )
3708          and ( (  nvl(p_changed_attributes(i).tp_attribute5, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute5, FND_API.G_MISS_CHAR ) )
3709               or ( p_changed_attributes(i).tp_attribute5 = FND_API.G_MISS_CHAR ) )
3710          and ( (  nvl(p_changed_attributes(i).tp_attribute6, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute6, FND_API.G_MISS_CHAR ) )
3711               or ( p_changed_attributes(i).tp_attribute6 = FND_API.G_MISS_CHAR ) )
3712          and ( (  nvl(p_changed_attributes(i).tp_attribute7, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute7, FND_API.G_MISS_CHAR ) )
3713               or ( p_changed_attributes(i).tp_attribute7 = FND_API.G_MISS_CHAR ) )
3714          and ( (  nvl(p_changed_attributes(i).tp_attribute8, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute8, FND_API.G_MISS_CHAR ) )
3715               or ( p_changed_attributes(i).tp_attribute8 = FND_API.G_MISS_CHAR ) )
3716          and ( (  nvl(p_changed_attributes(i).tp_attribute9, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute9, FND_API.G_MISS_CHAR ) )
3717               or ( p_changed_attributes(i).tp_attribute9 = FND_API.G_MISS_CHAR ) )
3718          and ( (  nvl(p_changed_attributes(i).tp_attribute_category, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tp_attribute_category, FND_API.G_MISS_CHAR ) )
3719               or ( p_changed_attributes(i).tp_attribute_category = FND_API.G_MISS_CHAR ) )
3720          and ( (  nvl(p_changed_attributes(i).tracking_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.tracking_number, FND_API.G_MISS_CHAR ) )
3721               or ( p_changed_attributes(i).tracking_number = FND_API.G_MISS_CHAR ) )
3722          and ( (  nvl(p_changed_attributes(i).transaction_temp_id, FND_API.G_MISS_NUM) = nvl(delivery_line_info.transaction_temp_id, FND_API.G_MISS_NUM ) )
3723               or ( p_changed_attributes(i).transaction_temp_id = FND_API.G_MISS_NUM ) )
3724          and ( (  nvl(p_changed_attributes(i).unit_number, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.unit_number, FND_API.G_MISS_CHAR ) )
3725               or ( p_changed_attributes(i).unit_number = FND_API.G_MISS_CHAR ) )
3726          and ( (  nvl(p_changed_attributes(i).unit_price, FND_API.G_MISS_NUM) = nvl(delivery_line_info.unit_price, FND_API.G_MISS_NUM ) )
3727               or ( p_changed_attributes(i).unit_price = FND_API.G_MISS_NUM ) )
3728          and ( (  nvl(p_changed_attributes(i).volume, FND_API.G_MISS_NUM) = nvl(delivery_line_info.volume, FND_API.G_MISS_NUM ) )
3729               or ( p_changed_attributes(i).volume = FND_API.G_MISS_NUM ) )
3730          and ( (  nvl(p_changed_attributes(i).volume_uom_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.volume_uom_code, FND_API.G_MISS_CHAR ) )
3731               or ( p_changed_attributes(i).volume_uom_code = FND_API.G_MISS_CHAR ) )
3732          and ( (  nvl(p_changed_attributes(i).weight_uom_code, FND_API.G_MISS_CHAR) = nvl(delivery_line_info.weight_uom_code, FND_API.G_MISS_CHAR ) )
3733               or ( p_changed_attributes(i).weight_uom_code = FND_API.G_MISS_CHAR ) )
3734          and ( (  nvl(p_changed_attributes(i).filled_volume, FND_API.G_MISS_NUM) = nvl(delivery_line_info.filled_volume, FND_API.G_MISS_NUM ) )
3735               or ( p_changed_attributes(i).filled_volume = FND_API.G_MISS_NUM ) )
3736           )
3737       THEN
3738          --Nothing has been changed
3739          --
3740          IF l_debug_on THEN
3741             WSH_DEBUG_SV.logmsg(l_module_name, 'INSIDE VALIDATION SUCCESS' );
3742          END IF;
3743          --
3744          x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
3745       ELSE
3746          --Raise Error
3747          --
3748          IF l_debug_on THEN
3749             WSH_DEBUG_SV.logmsg(l_module_name, 'Attributes does not match so returning error' );
3750          END IF;
3751          --
3752          x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
3753       END IF;
3754    END LOOP;
3755    END LOOP;
3756 
3757    --
3758    IF l_debug_on THEN
3759       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
3760       WSH_DEBUG_SV.pop(l_module_name);
3761    END IF;
3762    --
3763 EXCEPTION
3764    WHEN OTHERS THEN
3765       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
3766       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Validate_Delivery_Line');
3767       --
3768       IF l_debug_on THEN
3769         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3770         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3771       END IF;
3772       --
3773 END Validate_Delivery_Line;
3774 --
3775 --=============================================================================
3776 -- PRIVATE PROCEDURE :
3777 --       Print_OE_Header_Record
3778 --
3779 -- PARAMETERS:
3780 --       p_header_rec         => Order Header record
3781 --       p_header_val_rec     => Order Header value record
3782 --       p_customer_info      => Customer Information
3783 --       p_action_request_tbl => Action Type collection type
3784 -- COMMENT:
3785 --       API to print order header, customer, action request attributes, If
3786 --       Shipping debug is enabled.
3787 --=============================================================================
3788 --
3789 PROCEDURE Print_OE_Header_Record(
3790           p_header_rec         IN OE_ORDER_PUB.Header_Rec_Type,
3791           p_header_val_rec     IN OE_ORDER_PUB.Header_Val_Rec_Type,
3792           p_customer_info      IN OE_ORDER_PUB.Customer_Info_Table_Type,
3793           p_action_request_tbl IN OE_ORDER_PUB.Request_Tbl_Type )
3794 IS
3795    --
3796    l_debug_on BOOLEAN;
3797    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Print_OE_Header_Record';
3798    --
3799 BEGIN
3800    --
3801    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
3802    --
3803    IF l_debug_on IS NULL THEN
3804       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
3805    END IF;
3806    --
3807    IF l_debug_on THEN
3808       WSH_DEBUG_SV.push(l_module_name);
3809       WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3810       WSH_DEBUG_SV.logmsg(l_module_name, '|          HEADER RECORD DETAILS              |');
3811       WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3812       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.order_number',            p_header_rec.order_number            );
3813       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.header_id',               p_header_rec.header_id               );
3814       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.operation',               p_header_rec.operation               );
3815       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.cancelled_flag',          p_header_rec.cancelled_flag          );
3816       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.change_reason',           p_header_rec.change_reason           );
3817       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_from_org_id',        p_header_rec.ship_from_org_id        );
3818       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.sold_to_org_id',          p_header_rec.sold_to_org_id          );
3819       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.sold_to_contact_id',      p_header_rec.sold_to_contact_id      );
3820       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_to_org_id',          p_header_rec.ship_to_org_id          );
3821       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_to_contact_id',      p_header_rec.ship_to_contact_id      );
3822       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.invoice_to_org_id',       p_header_rec.invoice_to_org_id       );
3823       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.invoice_to_contact_id',   p_header_rec.invoice_to_contact_id   );
3824       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.deliver_to_org_id',       p_header_rec.deliver_to_org_id       );
3825       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.deliver_to_contact_id',   p_header_rec.deliver_to_contact_id   );
3826       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.shipping_method_code',    p_header_rec.shipping_method_code    );
3827       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.freight_terms_code',      p_header_rec.freight_terms_code      );
3828       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.fob_point_code',          p_header_rec.fob_point_code          );
3829       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.order_type_id',           p_header_rec.order_type_id           );
3830       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.price_list_id',           p_header_rec.price_list_id           );
3831       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.payment_term_id',         p_header_rec.payment_term_id         );
3832       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.org_id',                  p_header_rec.org_id                  );
3833       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.sold_from_org_id',        p_header_rec.sold_from_org_id        );
3834       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.order_source_id',         p_header_rec.order_source_id         );
3835       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.transactional_curr_code', p_header_rec.transactional_curr_code );
3836       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.salesrep_id',             p_header_rec.salesrep_id             );
3837       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.tax_exempt_flag',         p_header_rec.tax_exempt_flag         );
3838       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.open_flag',               p_header_rec.open_flag               );
3839       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.booked_flag',             p_header_rec.booked_flag             );
3840       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ordered_date',            p_header_rec.ordered_date            );
3841       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.order_category_code',     p_header_rec.order_category_code     );
3842       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.sold_to_customer_ref',    p_header_rec.sold_to_customer_ref    );
3843       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_to_customer_ref',    p_header_rec.ship_to_customer_ref    );
3844       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.invoice_to_customer_ref', p_header_rec.invoice_to_customer_ref );
3845       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.deliver_to_customer_ref', p_header_rec.deliver_to_customer_ref );
3846       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_to_address_ref',     p_header_rec.ship_to_address_ref     );
3847       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.invoice_to_address_ref',  p_header_rec.invoice_to_address_ref  );
3848       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.deliver_to_address_ref',  p_header_rec.deliver_to_address_ref  );
3849       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.ship_to_contact_ref',     p_header_rec.ship_to_contact_ref     );
3850       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.invoice_to_contact_ref',  p_header_rec.invoice_to_contact_ref  );
3851       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.deliver_to_contact_ref',  p_header_rec.deliver_to_contact_ref  );
3852       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.version_number',          p_header_rec.version_number          );
3853       WSH_DEBUG_SV.log(l_module_name, 'p_header_rec.orig_sys_document_ref',   p_header_rec.orig_sys_document_ref   );
3854 
3855    /* Printing Val Record is Commented since values are not populated during Shipment Request Processing
3856       WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3857       WSH_DEBUG_SV.logmsg(l_module_name, '|        HEADER VAL RECORD DETAILS             |');
3858       WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3859       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_org',         p_header_val_rec.sold_to_org         );
3860       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_address1',    p_header_val_rec.sold_to_address1    );
3861       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_address2',    p_header_val_rec.sold_to_address2    );
3862       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_address3',    p_header_val_rec.sold_to_address3    );
3863       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_address4',    p_header_val_rec.sold_to_address4    );
3864       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_city',        p_header_val_rec.sold_to_city        );
3865       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_state',       p_header_val_rec.sold_to_state       );
3866       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_country',     p_header_val_rec.sold_to_country     );
3867       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_zip',         p_header_val_rec.sold_to_zip         );
3868       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.sold_to_contact',     p_header_val_rec.sold_to_contact     );
3869       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_org',         p_header_val_rec.ship_to_org         );
3870       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_address1',    p_header_val_rec.ship_to_address1    );
3871       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_address2',    p_header_val_rec.ship_to_address2    );
3872       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_address3',    p_header_val_rec.ship_to_address3    );
3873       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_address4',    p_header_val_rec.ship_to_address4    );
3874       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_city',        p_header_val_rec.ship_to_city        );
3875       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_state',       p_header_val_rec.ship_to_state       );
3876       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_country',     p_header_val_rec.ship_to_country     );
3877       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_zip',         p_header_val_rec.ship_to_zip         );
3878       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.ship_to_contact',     p_header_val_rec.ship_to_contact     );
3879       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_org',      p_header_val_rec.invoice_to_org      );
3880       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_address1', p_header_val_rec.invoice_to_address1 );
3881       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_address2', p_header_val_rec.invoice_to_address2 );
3882       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_address3', p_header_val_rec.invoice_to_address3 );
3883       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_address4', p_header_val_rec.invoice_to_address4 );
3884       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_city',     p_header_val_rec.invoice_to_city     );
3885       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_state',    p_header_val_rec.invoice_to_state    );
3886       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_country',  p_header_val_rec.invoice_to_country  );
3887       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_zip',      p_header_val_rec.invoice_to_zip      );
3888       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.invoice_to_contact',  p_header_val_rec.invoice_to_contact  );
3889       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_org',      p_header_val_rec.deliver_to_org      );
3890       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_address1', p_header_val_rec.deliver_to_address1 );
3891       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_address2', p_header_val_rec.deliver_to_address2 );
3892       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_address3', p_header_val_rec.deliver_to_address3 );
3893       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_address4', p_header_val_rec.deliver_to_address4 );
3894       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_city',     p_header_val_rec.deliver_to_city     );
3895       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_state',    p_header_val_rec.deliver_to_state    );
3896       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_country',  p_header_val_rec.deliver_to_country  );
3897       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_zip',      p_header_val_rec.deliver_to_zip      );
3898       WSH_DEBUG_SV.log(l_module_name, 'p_header_val_rec.deliver_to_contact',  p_header_val_rec.deliver_to_contact  );
3899    */
3900 
3901       IF p_customer_info.count > 0 THEN
3902          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3903          WSH_DEBUG_SV.logmsg(l_module_name, '|               ADDRESS DETAILS                |');
3904          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3905          FOR i in p_customer_info.first..p_customer_info.last
3906          LOOP
3907             WSH_DEBUG_SV.log(l_module_name, 'INDEX', i );
3908             WSH_DEBUG_SV.log(l_module_name, 'customer_info_ref',        p_customer_info(i).customer_info_ref        );
3909             WSH_DEBUG_SV.log(l_module_name, 'parent_customer_info_ref', p_customer_info(i).parent_customer_info_ref );
3910             WSH_DEBUG_SV.log(l_module_name, 'customer_type',            p_customer_info(i).customer_type            );
3911             WSH_DEBUG_SV.log(l_module_name, 'customer_info_type_code',  p_customer_info(i).customer_info_type_code  );
3912 
3913             IF p_customer_info(i).customer_info_ref = g_sold_to_ref or
3914                p_customer_info(i).customer_info_ref = g_ship_to_ref or
3915                p_customer_info(i).customer_info_ref = g_invoice_to_ref or
3916                p_customer_info(i).customer_info_ref = g_deliver_to_ref
3917             THEN
3918                WSH_DEBUG_SV.log(l_module_name, 'customer_id',           p_customer_info(i).customer_id        );
3919                WSH_DEBUG_SV.log(l_module_name, 'organization_name',     p_customer_info(i).organization_name  );
3920             END IF;
3921 
3922             IF p_customer_info(i).customer_info_ref = g_ship_to_address_ref or
3923                p_customer_info(i).customer_info_ref = g_invoice_to_address_ref or
3924                p_customer_info(i).customer_info_ref = g_deliver_to_address_ref
3925             THEN
3926                WSH_DEBUG_SV.log(l_module_name, 'site_use_id', p_customer_info(i).site_use_id );
3927                WSH_DEBUG_SV.log(l_module_name, 'site_number', p_customer_info(i).site_number );
3928                WSH_DEBUG_SV.log(l_module_name, 'address1',    p_customer_info(i).address1    );
3929                WSH_DEBUG_SV.log(l_module_name, 'address2',    p_customer_info(i).address2    );
3930                WSH_DEBUG_SV.log(l_module_name, 'address3',    p_customer_info(i).address3    );
3931                WSH_DEBUG_SV.log(l_module_name, 'address4',    p_customer_info(i).address4    );
3932                WSH_DEBUG_SV.log(l_module_name, 'city',        p_customer_info(i).city        );
3933                WSH_DEBUG_SV.log(l_module_name, 'state',       p_customer_info(i).state       );
3934                WSH_DEBUG_SV.log(l_module_name, 'postal_code', p_customer_info(i).postal_code );
3935                WSH_DEBUG_SV.log(l_module_name, 'country',     p_customer_info(i).country     );
3936                WSH_DEBUG_SV.log(l_module_name, 'location_number', p_customer_info(i).location_number );
3937             END IF;
3938 
3939             IF p_customer_info(i).customer_info_ref = g_sold_to_contact_ref or
3940                p_customer_info(i).customer_info_ref = g_ship_to_contact_ref or
3941                p_customer_info(i).customer_info_ref = g_invoice_to_contact_ref or
3942                p_customer_info(i).customer_info_ref = g_deliver_to_contact_ref
3943             THEN
3944                WSH_DEBUG_SV.log(l_module_name, 'contact_id',         p_customer_info(i).contact_id         );
3945                WSH_DEBUG_SV.log(l_module_name, 'contact_number',     p_customer_info(i).contact_number     );
3946                WSH_DEBUG_SV.log(l_module_name, 'person_first_name',  p_customer_info(i).person_first_name  );
3947                WSH_DEBUG_SV.log(l_module_name, 'person_middle_name', p_customer_info(i).person_middle_name );
3948                WSH_DEBUG_SV.log(l_module_name, 'person_last_name',   p_customer_info(i).person_last_name   );
3949                WSH_DEBUG_SV.log(l_module_name, 'person_name_suffix', p_customer_info(i).person_name_suffix );
3950                WSH_DEBUG_SV.log(l_module_name, 'person_title',       p_customer_info(i).person_title       );
3951                WSH_DEBUG_SV.log(l_module_name, 'email_address',      p_customer_info(i).email_address      );
3952                WSH_DEBUG_SV.log(l_module_name, 'phone_country_code', p_customer_info(i).phone_country_code );
3953                WSH_DEBUG_SV.log(l_module_name, 'phone_area_code',    p_customer_info(i).phone_area_code    );
3954                WSH_DEBUG_SV.log(l_module_name, 'phone_number',       p_customer_info(i).phone_number       );
3955                WSH_DEBUG_SV.log(l_module_name, 'phone_extension',    p_customer_info(i).phone_extension    );
3956             END IF;
3957          END LOOP;
3958       END IF;
3959 
3960       IF p_action_request_tbl.count > 0 THEN
3961          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3962          WSH_DEBUG_SV.logmsg(l_module_name, '|           ACTION REQUEST DETAILS             |');
3963          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
3964 
3965          FOR i in p_action_request_tbl.first..p_action_request_tbl.last
3966          LOOP
3967             WSH_DEBUG_SV.log(l_module_name, 'p_action_request_tbl.request_type',  p_action_request_tbl(i).request_type  );
3968             WSH_DEBUG_SV.log(l_module_name, 'p_action_request_tbl.request_type',  p_action_request_tbl(i).entity_code  );
3969          END LOOP;
3970       END IF;
3971    END IF;
3972    --
3973 
3974    --
3975    IF l_debug_on THEN
3976       WSH_DEBUG_SV.pop(l_module_name);
3977    END IF;
3978    --
3979 EXCEPTION
3980    WHEN OTHERS THEN
3981          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Print_OE_Header_Record');
3982          --
3983          IF l_debug_on THEN
3984            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
3985            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
3986          END IF;
3987          --
3988 END Print_OE_Header_Record;
3989 --
3990 --=============================================================================
3991 -- PRIVATE PROCEDURE :
3992 --       Print_OE_Line_Record
3993 --
3994 -- PARAMETERS:
3995 --       p_line_tbl     => Order Line record
3996 --       p_line_val_tbl => Order Line value record
3997 -- COMMENT:
3998 --       API to print order line attributes, If Shipping debug is enabled.
3999 --=============================================================================
4000 --
4001 PROCEDURE Print_OE_Line_Record(
4002           p_line_tbl     IN OE_ORDER_PUB.Line_Tbl_Type,
4003           p_line_val_tbl IN OE_ORDER_PUB.Line_Val_Tbl_Type )
4004 IS
4005    --
4006    l_debug_on BOOLEAN;
4007    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Print_OE_Line_Record';
4008    --
4009 BEGIN
4010    --
4011    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4012    --
4013    IF l_debug_on IS NULL THEN
4014       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4015    END IF;
4016    --
4017    IF l_debug_on THEN
4018       WSH_DEBUG_SV.push(l_module_name);
4019    END IF;
4020    --
4021 
4022    IF ( p_line_tbl.count > 0 ) THEN
4023       FOR i in p_line_tbl.first..p_line_tbl.last
4024       LOOP
4025          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
4026          WSH_DEBUG_SV.logmsg(l_module_name, '|          LINE RECORD DETAILS - ' || i || '           |');
4027          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
4028          WSH_DEBUG_SV.log(l_module_name, 'line_id',                p_line_tbl(i).line_id                 );
4029          WSH_DEBUG_SV.log(l_module_name, 'operation',              p_line_tbl(i).operation               );
4030          WSH_DEBUG_SV.log(l_module_name, 'change_reason',          p_line_tbl(i).change_reason           );
4031          WSH_DEBUG_SV.log(l_module_name, 'line_number',            p_line_tbl(i).line_number             );
4032          WSH_DEBUG_SV.log(l_module_name, 'shipment_number',        p_line_tbl(i).shipment_number         );
4033          WSH_DEBUG_SV.log(l_module_name, 'ordered_quantity',       p_line_tbl(i).ordered_quantity        );
4034          WSH_DEBUG_SV.log(l_module_name, 'order_quantity_uom',     p_line_tbl(i).order_quantity_uom      );
4035          WSH_DEBUG_SV.log(l_module_name, 'ship_from_org_id',       p_line_tbl(i).ship_from_org_id        );
4036          WSH_DEBUG_SV.log(l_module_name, 'ordered_item',           p_line_tbl(i).ordered_item            );
4037          WSH_DEBUG_SV.log(l_module_name, 'inventory_item_id',      p_line_tbl(i).inventory_item_id       );
4038          WSH_DEBUG_SV.log(l_module_name, 'ordered_item_id',        p_line_tbl(i).ordered_item_id         );
4039          WSH_DEBUG_SV.log(l_module_name, 'ship_to_org_id',         p_line_tbl(i).ship_to_org_id          );
4040          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_org_id',      p_line_tbl(i).invoice_to_org_id       );
4041          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_org_id',      p_line_tbl(i).deliver_to_org_id       );
4042          WSH_DEBUG_SV.log(l_module_name, 'ship_to_contact_id',     p_line_tbl(i).ship_to_contact_id      );
4043          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_contact_id',  p_line_tbl(i).invoice_to_contact_id   );
4044          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_contact_id',  p_line_tbl(i).deliver_to_contact_id   );
4045          WSH_DEBUG_SV.log(l_module_name, 'shipping_method_code',   p_line_tbl(i).shipping_method_code    );
4046          WSH_DEBUG_SV.log(l_module_name, 'freight_terms_code',     p_line_tbl(i).freight_terms_code      );
4047          WSH_DEBUG_SV.log(l_module_name, 'fob_point_code',         p_line_tbl(i).fob_point_code          );
4048          WSH_DEBUG_SV.log(l_module_name, 'item_identifier_type',   p_line_tbl(i).item_identifier_type    );
4049          WSH_DEBUG_SV.log(l_module_name, 'ship_tolerance_above',   p_line_tbl(i).ship_tolerance_above    );
4050          WSH_DEBUG_SV.log(l_module_name, 'ship_tolerance_below',   p_line_tbl(i).ship_tolerance_below    );
4051          WSH_DEBUG_SV.log(l_module_name, 'request_date',           p_line_tbl(i).request_date            );
4052          WSH_DEBUG_SV.log(l_module_name, 'schedule_ship_date',     p_line_tbl(i).schedule_ship_date      );
4053          WSH_DEBUG_SV.log(l_module_name, 'ship_set',               p_line_tbl(i).ship_set                );
4054          WSH_DEBUG_SV.log(l_module_name, 'shipping_instructions',  p_line_tbl(i).shipping_instructions   );
4055          WSH_DEBUG_SV.log(l_module_name, 'packing_instructions',   p_line_tbl(i).packing_instructions    );
4056          WSH_DEBUG_SV.log(l_module_name, 'shipment_priority_code', p_line_tbl(i).shipment_priority_code  );
4057          WSH_DEBUG_SV.log(l_module_name, 'calculate_price_flag',   p_line_tbl(i).calculate_price_flag    );
4058          WSH_DEBUG_SV.log(l_module_name, 'cust_po_number',         p_line_tbl(i).cust_po_number          );
4059          WSH_DEBUG_SV.log(l_module_name, 'subinventory',           p_line_tbl(i).subinventory            );
4060          WSH_DEBUG_SV.log(l_module_name, 'unit_list_price',        p_line_tbl(i).unit_list_price         );
4061          WSH_DEBUG_SV.log(l_module_name, 'unit_selling_price',     p_line_tbl(i).unit_selling_price      );
4062          WSH_DEBUG_SV.log(l_module_name, 'sold_to_customer_ref',   p_line_tbl(i).sold_to_customer_ref    );
4063          WSH_DEBUG_SV.log(l_module_name, 'ship_to_customer_ref',   p_line_tbl(i).ship_to_customer_ref    );
4064          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_customer_ref',p_line_tbl(i).invoice_to_customer_ref );
4065          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_customer_ref',p_line_tbl(i).deliver_to_customer_ref );
4066          WSH_DEBUG_SV.log(l_module_name, 'ship_to_address_ref',    p_line_tbl(i).ship_to_address_ref     );
4067          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_address_ref', p_line_tbl(i).invoice_to_address_ref  );
4068          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_address_ref', p_line_tbl(i).deliver_to_address_ref  );
4069          WSH_DEBUG_SV.log(l_module_name, 'ship_to_contact_ref',    p_line_tbl(i).ship_to_contact_ref     );
4070          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_contact_ref', p_line_tbl(i).invoice_to_contact_ref  );
4071          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_contact_ref', p_line_tbl(i).deliver_to_contact_ref  );
4072          WSH_DEBUG_SV.log(l_module_name, 'orig_sys_document_ref',  p_line_tbl(i).orig_sys_document_ref   );
4073          WSH_DEBUG_SV.log(l_module_name, 'orig_sys_line_ref',      p_line_tbl(i).orig_sys_line_ref       );
4074 
4075       END LOOP;
4076    END IF;
4077 
4078    /* Printing Val Record is Commented since values are not populated during Shipment Request Processing
4079    IF ( p_line_val_tbl.count > 0 ) THEN
4080       FOR i in p_line_val_tbl.first..p_line_val_tbl.last
4081       LOOP
4082          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
4083          WSH_DEBUG_SV.logmsg(l_module_name, '|          LINE VAL RECORD DETAILS - ' || i || '        |');
4084          WSH_DEBUG_SV.logmsg(l_module_name, '===============================================');
4085          WSH_DEBUG_SV.log(l_module_name, 'ship_to_org',         p_line_val_tbl(i).ship_to_org         );
4086          WSH_DEBUG_SV.log(l_module_name, 'ship_to_address1',    p_line_val_tbl(i).ship_to_address1    );
4087          WSH_DEBUG_SV.log(l_module_name, 'ship_to_address2',    p_line_val_tbl(i).ship_to_address2    );
4088          WSH_DEBUG_SV.log(l_module_name, 'ship_to_address3',    p_line_val_tbl(i).ship_to_address3    );
4089          WSH_DEBUG_SV.log(l_module_name, 'ship_to_address4',    p_line_val_tbl(i).ship_to_address4    );
4090          WSH_DEBUG_SV.log(l_module_name, 'ship_to_city',        p_line_val_tbl(i).ship_to_city        );
4091          WSH_DEBUG_SV.log(l_module_name, 'ship_to_state',       p_line_val_tbl(i).ship_to_state       );
4092          WSH_DEBUG_SV.log(l_module_name, 'ship_to_country',     p_line_val_tbl(i).ship_to_country     );
4093          WSH_DEBUG_SV.log(l_module_name, 'ship_to_zip',         p_line_val_tbl(i).ship_to_zip         );
4094          WSH_DEBUG_SV.log(l_module_name, 'ship_to_contact',     p_line_val_tbl(i).ship_to_contact     );
4095          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_org',      p_line_val_tbl(i).invoice_to_org      );
4096          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_address1', p_line_val_tbl(i).invoice_to_address1 );
4097          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_address2', p_line_val_tbl(i).invoice_to_address2 );
4098          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_address3', p_line_val_tbl(i).invoice_to_address3 );
4099          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_address4', p_line_val_tbl(i).invoice_to_address4 );
4100          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_city',     p_line_val_tbl(i).invoice_to_city     );
4101          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_state',    p_line_val_tbl(i).invoice_to_state    );
4102          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_country',  p_line_val_tbl(i).invoice_to_country  );
4103          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_zip',      p_line_val_tbl(i).invoice_to_zip      );
4104          WSH_DEBUG_SV.log(l_module_name, 'invoice_to_contact',  p_line_val_tbl(i).invoice_to_contact  );
4105          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_org',      p_line_val_tbl(i).deliver_to_org      );
4106          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_address1', p_line_val_tbl(i).deliver_to_address1 );
4107          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_address2', p_line_val_tbl(i).deliver_to_address2 );
4108          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_address3', p_line_val_tbl(i).deliver_to_address3 );
4109          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_address4', p_line_val_tbl(i).deliver_to_address4 );
4110          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_city',     p_line_val_tbl(i).deliver_to_city     );
4111          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_state',    p_line_val_tbl(i).deliver_to_state    );
4112          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_country',  p_line_val_tbl(i).deliver_to_country  );
4113          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_zip',      p_line_val_tbl(i).deliver_to_zip      );
4114          WSH_DEBUG_SV.log(l_module_name, 'deliver_to_contact',  p_line_val_tbl(i).deliver_to_contact  );
4115       END LOOP;
4116    END IF;
4117    */
4118 
4119    --
4120    IF l_debug_on THEN
4121       WSH_DEBUG_SV.pop(l_module_name);
4122    END IF;
4123    --
4124 EXCEPTION
4125    WHEN OTHERS THEN
4126          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Print_OE_Line_Record');
4127          --
4128          IF l_debug_on THEN
4129            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4130            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4131          END IF;
4132          --
4133 END Print_OE_Line_Record;
4134 --
4135 --=============================================================================
4136 -- PUBLIC PROCEDURE :
4137 --       Check_Header_Attr_Changed
4138 --
4139 -- PARAMETERS:
4140 --       p_del_interface_rec => Delivery Interface Record
4141 --       p_om_header_rec     => Standalone related order header attributes record
4142 --       x_return_status     => Return Status of API (Either S,E,U)
4143 --
4144 -- COMMENT:
4145 --       API to check if following order header attributes are being changed
4146 --       1) ShipTo Customer, Address, Contact
4147 --       2) InvoiceTo Customer, Address, Contact
4148 --       3) DeliverTo Customer, Address, Contact
4149 --       4) Ship Method Code
4150 --       5) Freight Terms
4151 --       6) FOB Code
4152 --=============================================================================
4153 --
4154 PROCEDURE Check_Header_Attr_Changed(
4155           p_del_interface_rec IN OUT NOCOPY Del_Interface_Rec_Type,
4156           p_om_header_rec     IN OUT NOCOPY OM_Header_Rec_Type,
4157           x_return_status     OUT NOCOPY VARCHAR2 )
4158 IS
4159    l_sold_to                    NUMBER;
4160    l_ship_to                    NUMBER;
4161    l_invoice_to                 NUMBER;
4162    l_deliver_to                 NUMBER;
4163    l_ship_to_site               NUMBER;
4164    l_invoice_to_site            NUMBER;
4165    l_deliver_to_site            NUMBER;
4166    l_ship_to_contact            NUMBER;
4167    l_invoice_to_contact         NUMBER;
4168    l_deliver_to_contact         NUMBER;
4169 
4170    --
4171    l_debug_on BOOLEAN;
4172    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Check_Header_Attr_Changed';
4173    --
4174 BEGIN
4175    --
4176    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4177    --
4178    IF l_debug_on IS NULL THEN
4179       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4180    END IF;
4181    --
4182    IF l_debug_on THEN
4183       WSH_DEBUG_SV.push(l_module_name);
4184    END IF;
4185    --
4186 
4187    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4188    p_om_header_rec.header_attributes_changed := FALSE;
4189 
4190    IF p_del_interface_rec.organization_id <> p_om_header_rec.ship_from_org_id THEN
4191       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4192       FND_MESSAGE.Set_Name('WSH', 'WSH_STND_REJECT_ORG_CHANGE');
4193       WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name );
4194       --
4195       IF l_debug_on THEN
4196          WSH_DEBUG_SV.logmsg(l_module_name, 'Error => Ship From Changed');
4197          WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header Ship_From => ' || p_om_header_rec.ship_from_org_id
4198                                     || ', New Ship_From => ' || p_del_interface_rec.organization_id);
4199       END IF;
4200       --
4201    END IF;
4202 
4203    --
4204    IF l_debug_on THEN
4205       WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header Sold-To => ' || p_om_header_rec.sold_to_org_id
4206                                     || ', New Sold-To => ' || p_del_interface_rec.customer_id);
4207    END IF;
4208    --
4209 
4210    l_sold_to := p_del_interface_rec.customer_id;
4211 
4212    --Sold-To Cannot be changed, once order is booked
4213    IF ( p_del_interface_rec.customer_id is null and
4214         p_del_interface_rec.customer_name is not null )
4215    THEN
4216       --
4217       IF l_debug_on THEN
4218          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
4219       END IF;
4220       --
4221       l_sold_to := OE_Value_To_Id.Sold_To_Org(
4222                             p_sold_to_org     => p_del_interface_rec.customer_name,
4223                             p_customer_number => NULL );
4224 
4225       --
4226       IF l_debug_on THEN
4227          WSH_DEBUG_SV.log(l_module_name, 'SoldTo Customer derived from Customer Name', l_sold_to );
4228       END IF;
4229       --
4230 
4231       IF nvl(l_sold_to, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
4232          l_sold_to := null;
4233       ELSE
4234          p_del_interface_rec.customer_id := l_sold_to;
4235       END IF;
4236    END IF;
4237 
4238    IF ( nvl(l_sold_to, FND_API.G_MISS_NUM) <> p_om_header_rec.sold_to_org_id ) THEN
4239       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
4240       FND_MESSAGE.Set_Name('WSH', 'WSH_STND_REJECT_SOLDTO_CHANGE');
4241       WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name );
4242       --
4243       IF l_debug_on THEN
4244          WSH_DEBUG_SV.logmsg(l_module_name, 'Error => SoldTo customer changed');
4245       END IF;
4246       --
4247    END IF;
4248 
4249    IF x_return_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
4250       --
4251       IF l_debug_on THEN
4252          WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
4253          WSH_DEBUG_SV.pop(l_module_name);
4254       END IF;
4255       --
4256       RETURN;
4257    END IF;
4258 
4259    -- Ship-To Customer
4260    IF ( p_del_interface_rec.ship_to_customer_id is null and
4261         p_del_interface_rec.ship_to_customer_name is not null )
4262    THEN
4263       --Check if ShipTo Customer is same as SoldTo
4264       IF ( p_del_interface_rec.ship_to_customer_name = p_del_interface_rec.customer_name )
4265       THEN
4266          p_del_interface_rec.ship_to_customer_id := p_del_interface_rec.customer_id;
4267       ELSE
4268          --
4269          IF l_debug_on THEN
4270             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Org to derive Ship-To customer', WSH_DEBUG_SV.C_PROC_LEVEL);
4271          END IF;
4272          --
4273          l_ship_to := OE_Value_To_Id.Sold_To_Org(
4274                                p_sold_to_org     => p_del_interface_rec.ship_to_customer_name,
4275                                p_customer_number => NULL );
4276 
4277          IF nvl(l_ship_to, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
4278             p_om_header_rec.ship_to_changed := TRUE;
4279          ELSE
4280             p_del_interface_rec.ship_to_customer_id := l_ship_to;
4281          END IF;
4282       END IF;
4283    END IF;
4284 
4285    --Check if InvoiceTo Customer is same as SoldTo/ShipTo
4286    IF ( p_del_interface_rec.invoice_to_customer_id is null and
4287         p_del_interface_rec.invoice_to_customer_name = p_del_interface_rec.customer_name )
4288    THEN
4289       p_del_interface_rec.invoice_to_customer_id := p_del_interface_rec.customer_id;
4290    ELSIF ( p_del_interface_rec.invoice_to_customer_id is null and
4291            p_del_interface_rec.invoice_to_customer_name = p_del_interface_rec.ship_to_customer_name )
4292    THEN
4293       IF p_om_header_rec.ship_to_changed THEN
4294          p_om_header_rec.invoice_to_changed := TRUE;
4295       ELSE
4296          p_del_interface_rec.invoice_to_customer_id := p_del_interface_rec.ship_to_customer_id;
4297       END IF;
4298    END IF;
4299 
4300    -- Derive Invoice-To Customer
4301    IF ( p_del_interface_rec.invoice_to_customer_id is null and
4302         p_del_interface_rec.invoice_to_customer_name is not null and
4303         p_om_header_rec.invoice_to_changed = FALSE )
4304    THEN
4305       --
4306       IF l_debug_on THEN
4307          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Org to derive Invoice-To customer', WSH_DEBUG_SV.C_PROC_LEVEL);
4308       END IF;
4309       --
4310       l_invoice_to := OE_Value_To_Id.Sold_To_Org(
4311                             p_sold_to_org     => p_del_interface_rec.invoice_to_customer_name,
4312                             p_customer_number => NULL );
4313 
4314       IF nvl(l_invoice_to, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
4315          p_om_header_rec.invoice_to_changed := TRUE;
4316       ELSE
4317          p_del_interface_rec.invoice_to_customer_id := l_invoice_to;
4318       END IF;
4319    END IF;
4320 
4321    --Check if DeliverTo Customer is same as SoldTo/ShipTo/InvoiceTo
4322    IF ( p_del_interface_rec.deliver_to_customer_id is null and
4323         p_del_interface_rec.deliver_to_customer_name is not null and
4324         p_del_interface_rec.deliver_to_customer_name = p_del_interface_rec.customer_name )
4325    THEN
4326       p_del_interface_rec.deliver_to_customer_id := p_del_interface_rec.customer_id;
4327    ELSIF ( p_del_interface_rec.deliver_to_customer_id is null and
4328            p_del_interface_rec.deliver_to_customer_name is not null and
4329            p_del_interface_rec.deliver_to_customer_name = p_del_interface_rec.ship_to_customer_name )
4330    THEN
4331       IF p_om_header_rec.ship_to_changed THEN
4332          p_om_header_rec.deliver_to_changed := TRUE;
4333       ELSE
4334          p_del_interface_rec.deliver_to_customer_id := p_del_interface_rec.ship_to_customer_id;
4335       END IF;
4336    ELSIF ( p_del_interface_rec.deliver_to_customer_id is null and
4337            p_del_interface_rec.deliver_to_customer_name is not null and
4338            p_del_interface_rec.deliver_to_customer_name = p_del_interface_rec.invoice_to_customer_name )
4339    THEN
4340       IF p_om_header_rec.invoice_to_changed THEN
4341          p_om_header_rec.deliver_to_changed := TRUE;
4342       ELSE
4343          p_del_interface_rec.deliver_to_customer_id := p_del_interface_rec.invoice_to_customer_id;
4344       END IF;
4345    END IF;
4346 
4347    -- Derive Deliver-To Customer
4348    IF ( p_del_interface_rec.deliver_to_customer_id is null and
4349         p_del_interface_rec.deliver_to_customer_name is not null and
4350         p_om_header_rec.deliver_to_changed = FALSE )
4351    THEN
4352       --
4353       IF l_debug_on THEN
4354          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Org to derive Deliver-To customer', WSH_DEBUG_SV.C_PROC_LEVEL);
4355       END IF;
4356       --
4357       l_deliver_to := OE_Value_To_Id.Sold_To_Org(
4358                             p_sold_to_org     => p_del_interface_rec.deliver_to_customer_name,
4359                             p_customer_number => NULL );
4360 
4361       IF nvl(l_deliver_to, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
4362          p_om_header_rec.deliver_to_changed := TRUE;
4363       ELSE
4364          p_del_interface_rec.deliver_to_customer_id := l_deliver_to;
4365       END IF;
4366    END IF;
4367 
4368    --
4369    IF l_debug_on THEN
4370       WSH_DEBUG_SV.logmsg(l_module_name, 'Customer Ids' );
4371       WSH_DEBUG_SV.logmsg(l_module_name, '==============');
4372       WSH_DEBUG_SV.log(l_module_name, 'Sold-To Customer Id', p_del_interface_rec.customer_id);
4373       WSH_DEBUG_SV.log(l_module_name, 'Ship-To Customer Id', p_del_interface_rec.ship_to_customer_id);
4374       WSH_DEBUG_SV.log(l_module_name, 'Invoice-To Customer Id', p_del_interface_rec.invoice_to_customer_id);
4375       WSH_DEBUG_SV.log(l_module_name, 'Deliver-To Customer Id', p_del_interface_rec.deliver_to_customer_id);
4376    END IF;
4377    --
4378 
4379    --
4380    IF l_debug_on THEN
4381       WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header ShipTo Site => ' || p_om_header_rec.ship_to_org_id
4382                                     || ', New ShipTo Site => ' || p_del_interface_rec.ship_to_address_id);
4383    END IF;
4384    --
4385 
4386    IF ( p_del_interface_rec.ship_to_address_id is null and
4387         p_del_interface_rec.ship_to_address1 is not null and
4388         p_om_header_rec.ship_to_changed = FALSE )
4389    THEN -- { Ship-To
4390       --
4391       IF l_debug_on THEN
4392          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Ship_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
4393       END IF;
4394       --
4395       l_ship_to_site :=
4396             OE_Value_To_Id.Ship_To_Org(
4397                      p_ship_to_address1    => p_del_interface_rec.ship_to_address1,
4398                      p_ship_to_address2    => p_del_interface_rec.ship_to_address2,
4399                      p_ship_to_address3    => p_del_interface_rec.ship_to_address3,
4400                      p_ship_to_address4    => p_del_interface_rec.ship_to_address4,
4401                      p_ship_to_location    => NULL,
4402                      p_ship_to_org         => NULL,
4403                      p_sold_to_org_id      => p_del_interface_rec.ship_to_customer_id,
4404                      p_ship_to_city        => p_del_interface_rec.ship_to_city,
4405                      p_ship_to_state       => p_del_interface_rec.ship_to_state,
4406                      p_ship_to_postal_code => p_del_interface_rec.ship_to_postal_code,
4407                      p_ship_to_country     => p_del_interface_rec.ship_to_country,
4408                      p_ship_to_customer_id => p_del_interface_rec.ship_to_customer_id );
4409 
4410       --
4411       IF l_debug_on THEN
4412          WSH_DEBUG_SV.log(l_module_name, 'ShipTo Site Use Id', l_ship_to_site);
4413       END IF;
4414       --
4415       IF ( nvl(l_ship_to_site, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4416       THEN
4417          p_om_header_rec.ship_to_changed := TRUE;
4418       ELSIF ( l_ship_to_site <> nvl(p_om_header_rec.ship_to_org_id, FND_API.G_MISS_NUM) ) THEN
4419          p_del_interface_rec.ship_to_address_id := l_ship_to_site;
4420          p_om_header_rec.ship_to_changed := TRUE;
4421       ELSE
4422          p_del_interface_rec.ship_to_address_id := l_ship_to_site;
4423       END IF;
4424    ELSIF ( p_del_interface_rec.ship_to_customer_id is not null and
4425            p_del_interface_rec.ship_to_address_id is not null and
4426            p_del_interface_rec.ship_to_address_id <> nvl(p_om_header_rec.ship_to_org_id, FND_API.G_MISS_NUM) )
4427    THEN
4428       p_om_header_rec.ship_to_changed := TRUE;
4429    END IF; -- } Ship-To
4430 
4431    --
4432    IF l_debug_on THEN
4433       WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header InvoiceTo Site => ' || p_om_header_rec.Invoice_to_org_id
4434                                     || ', New InvoiceTo Site => ' || p_del_interface_rec.Invoice_to_address_id);
4435    END IF;
4436    --
4437 
4438    -- Derive InvoiceTo Address
4439    IF ( p_del_interface_rec.invoice_to_address_id is null and
4440         p_del_interface_rec.invoice_to_address1 is not null and
4441         p_om_header_rec.invoice_to_changed = FALSE )
4442    THEN -- { Invoice-To
4443       --
4444       IF l_debug_on THEN
4445          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Invoice_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
4446       END IF;
4447       --
4448       l_invoice_to_site :=
4449             OE_Value_To_Id.Invoice_To_Org(
4450                      p_invoice_to_address1    => p_del_interface_rec.invoice_to_address1,
4451                      p_invoice_to_address2    => p_del_interface_rec.invoice_to_address2,
4452                      p_invoice_to_address3    => p_del_interface_rec.invoice_to_address3,
4453                      p_invoice_to_address4    => p_del_interface_rec.invoice_to_address4,
4454                      p_invoice_to_location    => NULL,
4455                      p_invoice_to_org         => NULL,
4456                      p_sold_to_org_id         => p_del_interface_rec.invoice_to_customer_id,
4457                      p_invoice_to_city        => p_del_interface_rec.invoice_to_city,
4458                      p_invoice_to_state       => p_del_interface_rec.invoice_to_state,
4459                      p_invoice_to_postal_code => p_del_interface_rec.invoice_to_postal_code,
4460                      p_invoice_to_country     => p_del_interface_rec.invoice_to_country,
4461                      p_invoice_to_customer_id => p_del_interface_rec.invoice_to_customer_id );
4462 
4463       --
4464       IF l_debug_on THEN
4465          WSH_DEBUG_SV.log(l_module_name, 'InvoiceTo Site l_invoice_to_site', l_invoice_to_site);
4466       END IF;
4467       --
4468 
4469       IF ( nvl(l_invoice_to_site, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4470       THEN
4471          p_om_header_rec.invoice_to_changed := TRUE;
4472       ELSIF ( l_invoice_to_site <> nvl(p_om_header_rec.invoice_to_org_id, FND_API.G_MISS_NUM) ) THEN
4473          p_del_interface_rec.invoice_to_address_id := l_invoice_to_site;
4474          p_om_header_rec.invoice_to_changed := TRUE;
4475       ELSE
4476          p_del_interface_rec.invoice_to_address_id := l_invoice_to_site;
4477       END IF;
4478    ELSIF ( p_del_interface_rec.invoice_to_customer_id is not null and
4479            p_del_interface_rec.invoice_to_address_id is not null and
4480            p_del_interface_rec.invoice_to_address_id <> nvl(p_om_header_rec.invoice_to_org_id, FND_API.G_MISS_NUM) )
4481    THEN
4482       p_om_header_rec.invoice_to_changed := TRUE;
4483    END IF; -- } Invoice-To
4484 
4485    --
4486    IF l_debug_on THEN
4487       WSH_DEBUG_SV.logmsg(l_module_name, 'Order Header DeliverTo Site => ' || p_om_header_rec.Deliver_to_org_id
4488                                     || ', New DeliverTo Site => ' || p_del_interface_rec.Deliver_to_address_id);
4489    END IF;
4490    --
4491 
4492    -- Derive DeliverTo Address
4493    IF ( p_del_interface_rec.deliver_to_address_id is null and
4494         p_del_interface_rec.deliver_to_address1 is not null and
4495         p_om_header_rec.deliver_to_changed = FALSE )
4496    THEN -- { Deliver-To
4497       --
4498       IF l_debug_on THEN
4499          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Deliver_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
4500       END IF;
4501       --
4502       l_deliver_to_site :=
4503             OE_Value_To_Id.Deliver_To_Org(
4504                      p_deliver_to_address1    => p_del_interface_rec.deliver_to_address1,
4505                      p_deliver_to_address2    => p_del_interface_rec.deliver_to_address2,
4506                      p_deliver_to_address3    => p_del_interface_rec.deliver_to_address3,
4507                      p_deliver_to_address4    => p_del_interface_rec.deliver_to_address4,
4508                      p_deliver_to_location    => NULL,
4509                      p_deliver_to_org         => NULL,
4510                      p_sold_to_org_id         => p_del_interface_rec.deliver_to_customer_id,
4511                      p_deliver_to_city        => p_del_interface_rec.deliver_to_city,
4512                      p_deliver_to_state       => p_del_interface_rec.deliver_to_state,
4513                      p_deliver_to_postal_code => p_del_interface_rec.deliver_to_postal_code,
4514                      p_deliver_to_country     => p_del_interface_rec.deliver_to_country,
4515                      p_deliver_to_customer_id => p_del_interface_rec.deliver_to_customer_id );
4516 
4517       --
4518       IF l_debug_on THEN
4519          WSH_DEBUG_SV.log(l_module_name, 'DeliverTo Site l_deliver_to_site', l_deliver_to_site);
4520       END IF;
4521       --
4522 
4523       IF ( nvl(l_deliver_to_site, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4524       THEN
4525          p_om_header_rec.deliver_to_changed := TRUE;
4526       ELSIF ( l_deliver_to_site <> nvl(p_om_header_rec.deliver_to_org_id, FND_API.G_MISS_NUM) ) THEN
4527          p_del_interface_rec.deliver_to_address_id := l_deliver_to_site;
4528          p_om_header_rec.deliver_to_changed := TRUE;
4529       ELSE
4530          p_del_interface_rec.deliver_to_address_id := l_deliver_to_site;
4531       END IF;
4532    ELSIF ( ( p_del_interface_rec.deliver_to_customer_id is not null and
4533              p_del_interface_rec.deliver_to_address_id is not null and
4534              p_del_interface_rec.deliver_to_address_id <> nvl(p_om_header_rec.deliver_to_org_id, FND_API.G_MISS_NUM) ) OR
4535            ( p_del_interface_rec.deliver_to_address_id is null and
4536              p_del_interface_rec.deliver_to_address1 is null and
4537              p_om_header_rec.deliver_to_org_id is not null ) )
4538    THEN
4539       p_om_header_rec.deliver_to_changed := TRUE;
4540    END IF; -- } Deliver-To
4541 
4542    --
4543    IF l_debug_on THEN
4544       WSH_DEBUG_SV.logmsg(l_module_name, 'Site Use Ids' );
4545       WSH_DEBUG_SV.logmsg(l_module_name, '==============');
4546       WSH_DEBUG_SV.log(l_module_name, 'ShipTo Site Id', p_del_interface_rec.ship_to_address_id);
4547       WSH_DEBUG_SV.log(l_module_name, 'InvoiceTo Site Id', p_del_interface_rec.invoice_to_address_id);
4548       WSH_DEBUG_SV.log(l_module_name, 'DeliverTo Site Id', p_del_interface_rec.deliver_to_address_id);
4549    END IF;
4550    --
4551 
4552    -- Ship-To-Contact
4553    IF ( p_del_interface_rec.ship_to_contact_id is not null and
4554         p_del_interface_rec.ship_to_contact_id <> nvl(p_om_header_rec.ship_to_contact_id, FND_API.G_MISS_NUM) )
4555    THEN
4556       p_om_header_rec.ship_to_contact_changed := TRUE;
4557    ELSIF ( p_del_interface_rec.ship_to_contact_id is null and
4558            p_del_interface_rec.ship_to_contact_name is not null and
4559            p_del_interface_rec.ship_to_customer_id is null )
4560    THEN -- {
4561       p_om_header_rec.ship_to_contact_changed := TRUE;
4562    ELSIF ( p_del_interface_rec.ship_to_contact_id is null and
4563            p_del_interface_rec.ship_to_contact_name is not null )
4564    THEN -- {
4565       --
4566       IF l_debug_on THEN
4567          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Contact Ship-To-Contact', WSH_DEBUG_SV.C_PROC_LEVEL);
4568       END IF;
4569       --
4570       l_ship_to_contact :=
4571             OE_Value_To_Id.Sold_To_Contact (
4572                      p_sold_to_contact => p_del_interface_rec.ship_to_contact_name,
4573                      p_sold_to_org_id  => p_del_interface_rec.ship_to_customer_id );
4574 
4575       --
4576       IF l_debug_on THEN
4577          WSH_DEBUG_SV.logmsg(l_module_name, 'ShipTo Contact => ' || l_ship_to_contact ||
4578                               ', Order Header ShipTo Contact => ' || p_om_header_rec.ship_to_contact_id);
4579       END IF;
4580       --
4581 
4582       IF ( nvl(l_ship_to_contact, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4583       THEN
4584          p_om_header_rec.ship_to_contact_changed := TRUE;
4585       ELSIF ( l_ship_to_contact <>
4586               nvl(p_om_header_rec.ship_to_contact_id, FND_API.G_MISS_NUM) )
4587       THEN
4588          p_del_interface_rec.ship_to_contact_id := l_ship_to_contact;
4589          p_om_header_rec.ship_to_contact_changed := TRUE;
4590       END IF;
4591    ELSIF ( p_del_interface_rec.ship_to_contact_id is null and
4592            p_del_interface_rec.ship_to_contact_name is null and
4593            p_om_header_rec.ship_to_contact_id is not null )
4594    THEN
4595       p_om_header_rec.ship_to_contact_changed := TRUE;
4596    END IF; -- } Ship-To-Contact
4597 
4598    --Check if InvoiceTo Contact is same as ShipTo's
4599    IF ( p_del_interface_rec.invoice_to_customer_id  = p_del_interface_rec.ship_to_customer_id and
4600         p_del_interface_rec.invoice_to_contact_name = p_del_interface_rec.ship_to_contact_name )
4601    THEN
4602       IF p_om_header_rec.ship_to_contact_changed THEN
4603          p_om_header_rec.invoice_to_contact_changed := TRUE;
4604       ELSE
4605          p_del_interface_rec.invoice_to_contact_id := p_del_interface_rec.ship_to_contact_id;
4606       END IF;
4607    END IF;
4608 
4609    -- Derive Invoice-To-Contact
4610    IF ( p_del_interface_rec.invoice_to_contact_id is not null and
4611         p_del_interface_rec.invoice_to_contact_id <> nvl(p_om_header_rec.invoice_to_contact_id, FND_API.G_MISS_NUM) )
4612    THEN
4613       p_om_header_rec.invoice_to_contact_changed := TRUE;
4614    ELSIF ( p_del_interface_rec.invoice_to_contact_id is null and
4615            p_del_interface_rec.invoice_to_contact_name is not null and
4616            p_del_interface_rec.invoice_to_customer_id is null )
4617    THEN
4618       p_om_header_rec.invoice_to_contact_changed := TRUE;
4619    ELSIF ( p_del_interface_rec.invoice_to_contact_id is null and
4620            p_del_interface_rec.invoice_to_contact_name is not null and
4621            p_om_header_rec.invoice_to_contact_changed = FALSE )
4622    THEN -- {
4623       --
4624       IF l_debug_on THEN
4625          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Contact Invoice-To-Contact', WSH_DEBUG_SV.C_PROC_LEVEL);
4626       END IF;
4627       --
4628       l_invoice_to_contact :=
4629             OE_Value_To_Id.Sold_To_Contact (
4630                      p_sold_to_contact => p_del_interface_rec.invoice_to_contact_name,
4631                      p_sold_to_org_id  => p_del_interface_rec.invoice_to_customer_id );
4632 
4633       --
4634       IF l_debug_on THEN
4635          WSH_DEBUG_SV.logmsg(l_module_name, 'InvoiceTo Contact => ' || l_invoice_to_contact ||
4636                               ', Order Header InvoiceTo Contact => ' || p_om_header_rec.invoice_to_contact_id);
4637       END IF;
4638       --
4639 
4640       IF ( nvl(l_invoice_to_contact, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4641       THEN
4642          p_om_header_rec.invoice_to_contact_changed := TRUE;
4643       ELSIF ( l_invoice_to_contact <>
4644               nvl(p_om_header_rec.invoice_to_contact_id, FND_API.G_MISS_NUM) )
4645       THEN
4646          p_del_interface_rec.invoice_to_contact_id := l_invoice_to_contact;
4647          p_om_header_rec.invoice_to_contact_changed := TRUE;
4648       END IF;
4649    ELSIF ( p_del_interface_rec.invoice_to_contact_id is null and
4650            p_del_interface_rec.invoice_to_contact_name is null and
4651            p_om_header_rec.invoice_to_contact_id is not null )
4652    THEN
4653       p_om_header_rec.invoice_to_contact_changed := TRUE;
4654    END IF; -- } Invoice-To-Contact
4655 
4656    --Check if DeliverTo Contact is same as ShipTo's/InvoiceTo's
4657    IF ( p_del_interface_rec.deliver_to_customer_id  = p_del_interface_rec.ship_to_customer_id and
4658         p_del_interface_rec.deliver_to_contact_name = p_del_interface_rec.ship_to_contact_name )
4659    THEN
4660       IF p_om_header_rec.ship_to_contact_changed THEN
4661          p_om_header_rec.deliver_to_contact_changed := TRUE;
4662       ELSE
4663          p_del_interface_rec.deliver_to_contact_id := p_del_interface_rec.ship_to_contact_id;
4664       END IF;
4665    ELSIF ( p_del_interface_rec.deliver_to_customer_id  = p_del_interface_rec.invoice_to_customer_id and
4666            p_del_interface_rec.deliver_to_contact_name = p_del_interface_rec.invoice_to_contact_name )
4667    THEN
4668       IF p_om_header_rec.invoice_to_contact_changed THEN
4669          p_om_header_rec.deliver_to_contact_changed := TRUE;
4670       ELSE
4671          p_del_interface_rec.deliver_to_contact_id := p_del_interface_rec.invoice_to_contact_id;
4672       END IF;
4673    END IF;
4674 
4675    -- Deliver-To-Contact
4676    IF ( p_del_interface_rec.deliver_to_contact_id is not null and
4677         p_del_interface_rec.deliver_to_contact_id <> nvl(p_om_header_rec.deliver_to_contact_id, FND_API.G_MISS_NUM) )
4678    THEN
4679       p_om_header_rec.deliver_to_contact_changed := TRUE;
4680    ELSIF ( p_del_interface_rec.deliver_to_contact_id is null and
4681            p_del_interface_rec.deliver_to_contact_name is not null and
4682            p_del_interface_rec.deliver_to_customer_id is null )
4683    THEN
4684       p_om_header_rec.deliver_to_contact_changed := TRUE;
4685    ELSIF ( p_del_interface_rec.deliver_to_contact_id is null and
4686            p_del_interface_rec.deliver_to_contact_name is not null and
4687            p_om_header_rec.deliver_to_contact_changed = FALSE )
4688    THEN -- {
4689       --
4690       IF l_debug_on THEN
4691          WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Contact for Deliver-To-Contact', WSH_DEBUG_SV.C_PROC_LEVEL);
4692       END IF;
4693       --
4694       l_deliver_to_contact :=
4695             OE_Value_To_Id.Sold_To_Contact (
4696                      p_sold_to_contact => p_del_interface_rec.deliver_to_contact_name,
4697                      p_sold_to_org_id  => p_del_interface_rec.deliver_to_customer_id );
4698 
4699       --
4700       IF l_debug_on THEN
4701          WSH_DEBUG_SV.logmsg(l_module_name, 'DeliverTo Contact => ' || l_deliver_to_contact ||
4702                               ', Order Header DeliverTo Contact => ' || p_om_header_rec.deliver_to_contact_id);
4703       END IF;
4704       --
4705 
4706       IF ( nvl(l_deliver_to_contact, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM )
4707       THEN
4708          p_om_header_rec.deliver_to_contact_changed := TRUE;
4709       ELSIF ( l_deliver_to_contact <>
4710               nvl(p_om_header_rec.deliver_to_contact_id, FND_API.G_MISS_NUM) )
4711       THEN
4712          p_del_interface_rec.deliver_to_contact_id := l_deliver_to_contact;
4713          p_om_header_rec.deliver_to_contact_changed := TRUE;
4714       END IF;
4715    ELSIF ( p_del_interface_rec.deliver_to_contact_id is null and
4716            p_del_interface_rec.deliver_to_contact_name is null and
4717            p_om_header_rec.deliver_to_contact_id is not null )
4718    THEN
4719       p_om_header_rec.deliver_to_contact_changed := TRUE;
4720    END IF; -- } Deliver-To-Contact
4721 
4722    --
4723    IF l_debug_on THEN
4724       WSH_DEBUG_SV.logmsg(l_module_name, 'Contact Ids' );
4725       WSH_DEBUG_SV.logmsg(l_module_name, '============');
4726       WSH_DEBUG_SV.log(l_module_name, 'ShipTo Contact', p_del_interface_rec.ship_to_contact_id);
4727       WSH_DEBUG_SV.log(l_module_name, 'InvoiceTo Contact', p_del_interface_rec.invoice_to_contact_id);
4728       WSH_DEBUG_SV.log(l_module_name, 'DeliverTo Contact', p_del_interface_rec.deliver_to_contact_id);
4729    END IF;
4730    --
4731 
4732    IF ( nvl(p_om_header_rec.shipping_method_code, FND_API.G_MISS_CHAR ) <>
4733                 nvl(p_del_interface_rec.ship_method_code, FND_API.G_MISS_CHAR) )
4734    THEN
4735       p_om_header_rec.shipping_method_changed := TRUE;
4736    END IF;
4737 
4738    IF ( nvl(p_del_interface_rec.freight_terms_code, FND_API.G_MISS_CHAR) <>
4739             nvl(p_om_header_rec.freight_terms_code, FND_API.G_MISS_CHAR) )
4740    THEN
4741       p_om_header_rec.freight_terms_changed := TRUE;
4742    END IF;
4743 
4744    IF ( nvl(p_del_interface_rec.fob_code, FND_API.G_MISS_CHAR) <>
4745             nvl(p_om_header_rec.fob_point_code, FND_API.G_MISS_CHAR) )
4746    THEN
4747       p_om_header_rec.fob_point_changed := TRUE;
4748    END IF;
4749 
4750    --
4751    IF l_debug_on THEN
4752       WSH_DEBUG_SV.logmsg(l_module_name, 'Header Attributes Changed:');
4753       WSH_DEBUG_SV.logmsg(l_module_name, '===========================');
4754       IF p_om_header_rec.ship_to_changed THEN
4755          WSH_DEBUG_SV.logmsg(l_module_name, 'CHANGED: Order Header ShipTo Site => ' || p_om_header_rec.ship_to_org_id
4756                                     || ', New ShipTo Site => ' || p_del_interface_rec.ship_to_address_id
4757                                     || ', New ShipTo Address1 => ' || p_del_interface_rec.ship_to_address1 );
4758       END IF;
4759 
4760       IF p_om_header_rec.invoice_to_changed THEN
4761          WSH_DEBUG_SV.logmsg(l_module_name, 'CHANGED: Order Header InvoiceTo Site => ' || p_om_header_rec.invoice_to_org_id
4762                                        || ', New InvoiceTo Site => ' || p_del_interface_rec.invoice_to_address_id
4763                                        || ', New InvoiceTo Address1 => ' || p_del_interface_rec.invoice_to_address1 );
4764       END IF;
4765 
4766       IF p_om_header_rec.deliver_to_changed THEN
4767          WSH_DEBUG_SV.logmsg(l_module_name, 'CHANGED: Order Header DeliverTo Site => ' || p_om_header_rec.deliver_to_org_id
4768                                        || ', New DeliverTo Site => ' || p_del_interface_rec.deliver_to_address_id
4769                                        || ', New DeliverTo Address1 => ' || p_del_interface_rec.deliver_to_address1 );
4770       END IF;
4771 
4772       IF p_om_header_rec.ship_to_contact_changed THEN
4773          WSH_DEBUG_SV.logmsg(l_module_name,
4774                       'Changed: New ShipTo Contact => ' || p_del_interface_rec.ship_to_contact_id ||
4775                       ', New ShipTo Contact Name => ' || p_del_interface_rec.ship_to_contact_name ||
4776                       ', Order Header ShipTo Contact => ' || p_om_header_rec.ship_to_contact_id );
4777       END IF;
4778 
4779       IF p_om_header_rec.invoice_to_contact_changed THEN
4780          WSH_DEBUG_SV.logmsg(l_module_name,
4781                       'Changed: New InvoiceTo Contact => ' || p_del_interface_rec.invoice_to_contact_id ||
4782                       ', New InvoiceTo Contact Name => ' || p_del_interface_rec.invoice_to_contact_name ||
4783                       ', Order Header InvoiceTo Contact => ' || p_om_header_rec.invoice_to_contact_id );
4784       END IF;
4785 
4786       IF p_om_header_rec.deliver_to_contact_changed THEN
4787          WSH_DEBUG_SV.logmsg(l_module_name,
4788                       'Changed: DeliverTo Contact => ' || p_del_interface_rec.deliver_to_contact_id ||
4789                          ', New DeliverTo Contact Name => ' || p_del_interface_rec.deliver_to_contact_name ||
4790                       ', Order Header DeliverTo Contact => ' || p_om_header_rec.deliver_to_contact_id );
4791       END IF;
4792 
4793       IF p_om_header_rec.shipping_method_changed THEN
4794          WSH_DEBUG_SV.logmsg(l_module_name, 'Changed: Order Header Ship_Method_Code => ' || p_om_header_rec.shipping_method_code
4795                                        || ', New Ship_Method_Code => ' || p_del_interface_rec.ship_method_code);
4796       END IF;
4797 
4798       IF p_om_header_rec.freight_terms_changed THEN
4799          WSH_DEBUG_SV.logmsg(l_module_name, 'Changed: Order Header Freight_Terms => ' || p_om_header_rec.freight_terms_code
4800                                        || ', New Freight_Terms => ' || p_del_interface_rec.freight_terms_code);
4801       END IF;
4802 
4803       IF p_om_header_rec.fob_point_changed THEN
4804          WSH_DEBUG_SV.logmsg(l_module_name, 'Changed: Order Header FOB_Code => ' || p_om_header_rec.fob_point_code
4805                                        || ', New FOB_Code => ' || p_del_interface_rec.fob_code);
4806       END IF;
4807       WSH_DEBUG_SV.logmsg(l_module_name, '===========================');
4808    END IF;
4809    --
4810 
4811    IF ( p_om_header_rec.ship_to_changed or
4812         p_om_header_rec.invoice_to_changed or
4813         p_om_header_rec.deliver_to_changed or
4814         p_om_header_rec.invoice_to_contact_changed or
4815         p_om_header_rec.deliver_to_contact_changed or
4816         p_om_header_rec.ship_to_contact_changed or
4817         p_om_header_rec.shipping_method_changed or
4818         p_om_header_rec.freight_terms_changed or
4819         p_om_header_rec.fob_point_changed )
4820    THEN
4821       p_om_header_rec.header_attributes_changed := TRUE;
4822    END IF;
4823    --
4824 
4825    IF l_debug_on THEN
4826       IF p_om_header_rec.header_attributes_changed THEN
4827          WSH_DEBUG_SV.logmsg(l_module_name, 'p_om_header_rec.header_attributes_changed is TRUE');
4828       ELSE
4829          WSH_DEBUG_SV.logmsg(l_module_name, 'p_om_header_rec.header_attributes_changed is FALSE');
4830       END IF;
4831       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
4832       WSH_DEBUG_SV.pop(l_module_name);
4833    END IF;
4834    --
4835 EXCEPTION
4836    WHEN OTHERS THEN
4837          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
4838          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Check_Header_Attr_Changed');
4839          --
4840          IF l_debug_on THEN
4841            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
4842            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
4843          END IF;
4844          --
4845 END Check_Header_Attr_Changed;
4846 --
4847 --=============================================================================
4848 -- PRIVATE PROCEDURE :
4849 --       Populate_OM_Common_Attr
4850 --
4851 -- PARAMETERS:
4852 --       p_om_header_rec     => Standalone related order header attributes record
4853 --       p_del_interface_rec => Delivery Interface Record
4854 --       x_header_rec        => Order Header Record
4855 --       x_line_tbl          => Collection of Order Lines record
4856 --       x_customer_info     => Customer Related information
4857 --       x_return_status     => Return Status of API (Either S,E,U)
4858 --
4859 -- COMMENT:
4860 --       API to populate attributes common to Order Headers and lines
4861 --=============================================================================
4862 --
4863 PROCEDURE Populate_OM_Common_Attr(
4864           p_om_header_rec     IN OM_Header_Rec_Type,
4865           p_del_interface_rec IN Del_Interface_Rec_Type,
4866           x_header_rec        IN OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type,
4867           x_line_tbl          IN OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type,
4868           x_customer_info     OUT NOCOPY OE_ORDER_PUB.Customer_Info_Table_Type,
4869           x_return_status     OUT NOCOPY VARCHAR2 )
4870 IS
4871 
4872    l_index                      NUMBER;
4873    --
4874    l_debug_on BOOLEAN;
4875    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Populate_OM_Common_Attr';
4876    --
4877 BEGIN
4878    --
4879    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
4880    --
4881    IF l_debug_on IS NULL THEN
4882       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
4883    END IF;
4884    --
4885    IF l_debug_on THEN
4886       WSH_DEBUG_SV.push(l_module_name);
4887       WSH_DEBUG_SV.log(l_module_name, 'p_om_header_rec.header_id', p_om_header_rec.header_id);
4888       WSH_DEBUG_SV.log(l_module_name, 'x_line_tbl.count', x_line_tbl.count);
4889    END IF;
4890    --
4891    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
4892 
4893    -- Always pass  SOLD-TO CUSTOMER DETAILS
4894    --
4895    IF l_debug_on THEN
4896       WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Sold-To-Customer Information');
4897    END IF;
4898    --
4899    l_index := x_customer_info.count + 1;
4900    x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
4901    x_header_rec.sold_to_customer_ref := g_sold_to_ref;
4902 
4903    x_customer_info(l_index).customer_info_ref := g_sold_to_ref;
4904    x_customer_info(l_index).customer_info_type_code := 'CUSTOMER';
4905    x_customer_info(l_index).customer_type := 'ORGANIZATION';
4906 
4907    IF p_del_interface_rec.customer_id is not null THEN
4908       x_customer_info(l_index).customer_id := p_del_interface_rec.customer_id;
4909    ELSE
4910       x_customer_info(l_index).organization_name := p_del_interface_rec.customer_name;
4911    END IF;
4912 
4913    --SHIP-TO CUSTOMER DETAILS
4914    IF ( p_om_header_rec.header_id is null or
4915           ( p_om_header_rec.header_id is not null and
4916             ( p_om_header_rec.ship_to_changed or
4917               ( p_om_header_rec.ship_to_contact_changed and
4918                 ( p_del_interface_rec.ship_to_contact_id is not null or
4919                   p_del_interface_rec.ship_to_contact_name is not null ) ) ) )
4920         )
4921    THEN -- {
4922       --
4923       IF l_debug_on THEN
4924          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Ship-To-Customer Information');
4925       END IF;
4926       --
4927       l_index := x_customer_info.count + 1;
4928       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
4929       x_header_rec.ship_to_customer_ref := g_ship_to_ref;
4930 
4931       x_customer_info(l_index).customer_info_ref := g_ship_to_ref;
4932       x_customer_info(l_index).customer_info_type_code := 'CUSTOMER';
4933       x_customer_info(l_index).customer_type := 'ORGANIZATION';
4934 
4935       IF p_del_interface_rec.ship_to_customer_id is not null THEN
4936          x_customer_info(l_index).customer_id := p_del_interface_rec.ship_to_customer_id;
4937       ELSE
4938          x_customer_info(l_index).organization_name := p_del_interface_rec.ship_to_customer_name;
4939       END IF;
4940    END IF; -- }
4941 
4942    --INVOICE-TO CUSTOMER DETAILS
4943    IF ( p_om_header_rec.header_id is null or
4944           ( p_om_header_rec.header_id is not null and
4945             ( p_om_header_rec.invoice_to_changed or
4946               ( p_om_header_rec.invoice_to_contact_changed and
4947                 ( p_del_interface_rec.invoice_to_contact_id is not null or
4948                   p_del_interface_rec.invoice_to_contact_name is not null ) ) ) )
4949         )
4950    THEN -- {
4951       --
4952       IF l_debug_on THEN
4953          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Invoice-To-Customer Information');
4954       END IF;
4955       --
4956       l_index := x_customer_info.count + 1;
4957       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
4958       x_header_rec.invoice_to_customer_ref := g_invoice_to_ref;
4959 
4960       x_customer_info(l_index).customer_info_ref := g_invoice_to_ref;
4961       x_customer_info(l_index).customer_info_type_code := 'CUSTOMER';
4962       x_customer_info(l_index).customer_type := 'ORGANIZATION';
4963 
4964       IF p_del_interface_rec.invoice_to_customer_id is not null THEN
4965          x_customer_info(l_index).customer_id := p_del_interface_rec.invoice_to_customer_id;
4966       ELSE
4967          x_customer_info(l_index).organization_name := p_del_interface_rec.invoice_to_customer_name;
4968       END IF;
4969    END IF; -- }
4970 
4971    --DELIVER-TO CUSTOMER DETAILS
4972    IF ( ( p_del_interface_rec.deliver_to_customer_id is not null or
4973           p_del_interface_rec.deliver_to_customer_name is not null ) and
4974         ( p_om_header_rec.header_id is null or
4975           ( p_om_header_rec.header_id is not null and
4976             ( p_om_header_rec.deliver_to_changed or
4977               ( p_om_header_rec.deliver_to_contact_changed and
4978                 ( p_del_interface_rec.deliver_to_contact_id is not null or
4979                   p_del_interface_rec.deliver_to_contact_name is not null ) ) ) )
4980         ) )
4981    THEN -- {
4982       --
4983       IF l_debug_on THEN
4984          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Deliver-To-Customer Information');
4985       END IF;
4986       --
4987       l_index := x_customer_info.count + 1;
4988       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
4989       x_header_rec.deliver_to_customer_ref := g_deliver_to_ref;
4990 
4991       x_customer_info(l_index).customer_info_ref := g_deliver_to_ref;
4992       x_customer_info(l_index).customer_info_type_code := 'CUSTOMER';
4993       x_customer_info(l_index).customer_type := 'ORGANIZATION';
4994 
4995       IF p_del_interface_rec.deliver_to_customer_id is not null THEN
4996          x_customer_info(l_index).customer_id := p_del_interface_rec.deliver_to_customer_id;
4997       ELSE
4998          x_customer_info(l_index).organization_name := p_del_interface_rec.deliver_to_customer_name;
4999       END IF;
5000    END IF; -- }
5001 
5002    -- SHIP-TO ADDRESS DETAILS
5003    IF ( ( p_om_header_rec.header_id is null ) or
5004         ( p_om_header_rec.header_id is not null and
5005           p_om_header_rec.ship_to_changed ) )
5006    THEN -- {
5007       --
5008       IF l_debug_on THEN
5009          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Ship-To-Address Information');
5010       END IF;
5011       --
5012       l_index := x_customer_info.count + 1;
5013       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5014       x_header_rec.ship_to_address_ref := g_ship_to_address_ref;
5015 
5016       x_customer_info(l_index).customer_info_type_code  := 'ADDRESS';
5017       x_customer_info(l_index).customer_info_ref        := g_ship_to_address_ref;
5018       x_customer_info(l_index).parent_customer_info_ref := g_ship_to_ref;
5019 
5020       IF p_del_interface_rec.ship_to_address_id is not null THEN
5021          x_customer_info(l_index).site_use_id := p_del_interface_rec.ship_to_address_id;
5022       ELSE
5023          x_customer_info(l_index).address1    := p_del_interface_rec.ship_to_address1;
5024          x_customer_info(l_index).address2    := p_del_interface_rec.ship_to_address2;
5025          x_customer_info(l_index).address3    := p_del_interface_rec.ship_to_address3;
5026          x_customer_info(l_index).address4    := p_del_interface_rec.ship_to_address4;
5027          x_customer_info(l_index).city        := p_del_interface_rec.ship_to_city;
5028          x_customer_info(l_index).state       := p_del_interface_rec.ship_to_state;
5029          x_customer_info(l_index).postal_code := p_del_interface_rec.ship_to_postal_code;
5030          x_customer_info(l_index).country     := p_del_interface_rec.ship_to_country;
5031       END IF;
5032    END IF; -- }
5033 
5034    -- INVOICE-TO ADDRESS DETAILS
5035    IF ( ( p_om_header_rec.header_id is null ) or
5036         ( p_om_header_rec.header_id is not null and
5037           p_om_header_rec.invoice_to_changed ) )
5038    THEN -- {
5039       --
5040       IF l_debug_on THEN
5041          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Invoice-To-Address Information');
5042       END IF;
5043       --
5044       l_index := x_customer_info.count + 1;
5045       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5046       x_header_rec.invoice_to_address_ref := g_invoice_to_address_ref;
5047 
5048       x_customer_info(l_index).customer_info_type_code  := 'ADDRESS';
5049       x_customer_info(l_index).customer_info_ref        := g_invoice_to_address_ref;
5050       x_customer_info(l_index).parent_customer_info_ref := g_invoice_to_ref;
5051 
5052       IF p_del_interface_rec.invoice_to_address_id is not null THEN
5053          x_customer_info(l_index).site_use_id := p_del_interface_rec.invoice_to_address_id;
5054       ELSE
5055          x_customer_info(l_index).address1    := p_del_interface_rec.invoice_to_address1;
5056          x_customer_info(l_index).address2    := p_del_interface_rec.invoice_to_address2;
5057          x_customer_info(l_index).address3    := p_del_interface_rec.invoice_to_address3;
5058          x_customer_info(l_index).address4    := p_del_interface_rec.invoice_to_address4;
5059          x_customer_info(l_index).city        := p_del_interface_rec.invoice_to_city;
5060          x_customer_info(l_index).state       := p_del_interface_rec.invoice_to_state;
5061          x_customer_info(l_index).postal_code := p_del_interface_rec.invoice_to_postal_code;
5062          x_customer_info(l_index).country     := p_del_interface_rec.invoice_to_country;
5063       END IF;
5064    END IF; -- }
5065 
5066    -- DELIVER-TO ADDRESS DETAILS
5067    IF ( ( ( p_om_header_rec.header_id is null ) OR
5068           ( p_om_header_rec.header_id is not null and
5069             p_om_header_rec.deliver_to_changed )
5070         ) AND
5071         ( p_del_interface_rec.deliver_to_address_id is not null or
5072           p_del_interface_rec.deliver_to_address1 is not null ) )
5073    THEN -- {
5074       --
5075       IF l_debug_on THEN
5076          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Deliver-To-Address Information');
5077       END IF;
5078       --
5079       l_index := x_customer_info.count + 1;
5080       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5081       x_header_rec.deliver_to_address_ref := g_deliver_to_address_ref;
5082 
5083       x_customer_info(l_index).customer_info_type_code  := 'ADDRESS';
5084       x_customer_info(l_index).customer_info_ref        := g_deliver_to_address_ref;
5085       x_customer_info(l_index).parent_customer_info_ref := g_deliver_to_ref;
5086 
5087       IF p_del_interface_rec.deliver_to_address_id is not null THEN
5088          x_customer_info(l_index).site_use_id := p_del_interface_rec.deliver_to_address_id;
5089       ELSE
5090          x_customer_info(l_index).address1    := p_del_interface_rec.deliver_to_address1;
5091          x_customer_info(l_index).address2    := p_del_interface_rec.deliver_to_address2;
5092          x_customer_info(l_index).address3    := p_del_interface_rec.deliver_to_address3;
5093          x_customer_info(l_index).address4    := p_del_interface_rec.deliver_to_address4;
5094          x_customer_info(l_index).city        := p_del_interface_rec.deliver_to_city;
5095          x_customer_info(l_index).state       := p_del_interface_rec.deliver_to_state;
5096          x_customer_info(l_index).postal_code := p_del_interface_rec.deliver_to_postal_code;
5097          x_customer_info(l_index).country     := p_del_interface_rec.deliver_to_country;
5098       END IF;
5099    ELSIF ( p_om_header_rec.deliver_to_changed and
5100            p_del_interface_rec.deliver_to_address_id is null and
5101            p_del_interface_rec.deliver_to_address1 is null )
5102    THEN
5103       x_header_rec.deliver_to_org_id := null;
5104    END IF; -- }
5105 
5106    -- SHIP-TO CONTACT DETAILS
5107    IF ( ( p_om_header_rec.header_id is null or
5108           ( p_om_header_rec.header_id is not null and
5109             p_om_header_rec.ship_to_contact_changed )
5110         ) and
5111         ( p_del_interface_rec.ship_to_contact_id is not null or
5112           p_del_interface_rec.ship_to_contact_name is not null )
5113       )
5114    THEN -- {
5115       --
5116       IF l_debug_on THEN
5117          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Ship-To Contact Information');
5118       END IF;
5119       --
5120       l_index := x_customer_info.count + 1;
5121       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5122       x_header_rec.ship_to_contact_ref := g_ship_to_contact_ref;
5123 
5124       x_customer_info(l_index).customer_info_type_code  := 'CONTACT';
5125       x_customer_info(l_index).customer_info_ref        := g_ship_to_contact_ref;
5126       x_customer_info(l_index).parent_customer_info_ref := g_ship_to_ref;
5127 
5128       IF p_del_interface_rec.ship_to_contact_id is not null THEN
5129          x_customer_info(l_index).contact_id := p_del_interface_rec.ship_to_contact_id;
5130       ELSE
5131          x_customer_info(l_index).person_last_name := p_del_interface_rec.ship_to_contact_name;
5132       END IF;
5133 
5134       IF p_del_interface_rec.ship_to_contact_phone is not null THEN
5135          x_customer_info(l_index).phone_number := p_del_interface_rec.ship_to_contact_phone;
5136       END IF;
5137    ELSIF ( p_om_header_rec.ship_to_contact_changed and
5138            p_del_interface_rec.ship_to_contact_id is null and
5139            p_del_interface_rec.ship_to_contact_name is null )
5140    THEN
5141       x_header_rec.ship_to_contact_id := null;
5142    END IF; -- }
5143 
5144    -- INVOICE-TO CONTACT DETAILS
5145    IF ( ( p_om_header_rec.header_id is null or
5146           ( p_om_header_rec.header_id is not null and
5147             p_om_header_rec.invoice_to_contact_changed )
5148         ) and
5149         ( p_del_interface_rec.invoice_to_contact_id is not null or
5150           p_del_interface_rec.invoice_to_contact_name is not null )
5151       )
5152    THEN -- {
5153       --
5154       IF l_debug_on THEN
5155          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Invoice-To Contact Information');
5156       END IF;
5157       --
5158       l_index := x_customer_info.count + 1;
5159       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5160       x_header_rec.invoice_to_contact_ref := g_invoice_to_contact_ref;
5161 
5162       x_customer_info(l_index).customer_info_type_code  := 'CONTACT';
5163       x_customer_info(l_index).customer_info_ref        := g_invoice_to_contact_ref;
5164       x_customer_info(l_index).parent_customer_info_ref := g_invoice_to_ref;
5165 
5166       IF p_del_interface_rec.invoice_to_contact_id is not null THEN
5167          x_customer_info(l_index).contact_id := p_del_interface_rec.invoice_to_contact_id;
5168       ELSE
5169          x_customer_info(l_index).person_last_name := p_del_interface_rec.invoice_to_contact_name;
5170       END IF;
5171 
5172       IF p_del_interface_rec.invoice_to_contact_phone is not null THEN
5173          x_customer_info(l_index).phone_number := p_del_interface_rec.invoice_to_contact_phone;
5174       END IF;
5175    ELSIF ( p_om_header_rec.invoice_to_contact_changed and
5176            p_del_interface_rec.invoice_to_contact_id is null and
5177            p_del_interface_rec.invoice_to_contact_name is null )
5178    THEN
5179       x_header_rec.invoice_to_contact_id := null;
5180    END IF; -- }
5181 
5182    -- DELIVER-TO CONTACT DETAILS
5183    IF ( ( p_om_header_rec.header_id is null or
5184           ( p_om_header_rec.header_id is not null and
5185             p_om_header_rec.deliver_to_contact_changed )
5186         ) and
5187         ( p_del_interface_rec.deliver_to_contact_id is not null or
5188           p_del_interface_rec.deliver_to_contact_name is not null )
5189       )
5190    THEN -- {
5191       --
5192       IF l_debug_on THEN
5193          WSH_DEBUG_SV.logmsg(l_module_name, 'Adding Deliver-To Contact Information');
5194       END IF;
5195       --
5196       l_index := x_customer_info.count + 1;
5197       x_customer_info(l_index) := OE_ORDER_PUB.G_MISS_CUSTOMER_INFO_REC;
5198       x_header_rec.deliver_to_contact_ref := g_deliver_to_contact_ref;
5199 
5200       x_customer_info(l_index).customer_info_type_code  := 'CONTACT';
5201       x_customer_info(l_index).customer_info_ref        := g_deliver_to_contact_ref;
5202       x_customer_info(l_index).parent_customer_info_ref := g_deliver_to_ref;
5203 
5204       IF p_del_interface_rec.deliver_to_contact_id is not null THEN
5205          x_customer_info(l_index).contact_id := p_del_interface_rec.deliver_to_contact_id;
5206       ELSE
5207          x_customer_info(l_index).person_last_name := p_del_interface_rec.deliver_to_contact_name;
5208       END IF;
5209 
5210       IF p_del_interface_rec.deliver_to_contact_phone is not null THEN
5211          x_customer_info(l_index).phone_number := p_del_interface_rec.deliver_to_contact_phone;
5212       END IF;
5213    ELSIF ( p_om_header_rec.deliver_to_contact_changed and
5214            p_del_interface_rec.deliver_to_contact_id is null and
5215            p_del_interface_rec.deliver_to_contact_name is null )
5216    THEN
5217       x_header_rec.deliver_to_contact_id := null;
5218    END IF; -- }
5219 
5220    x_header_rec.ship_from_org_id     := p_del_interface_rec.organization_id;
5221 
5222    IF p_om_header_rec.header_id is null or
5223       p_om_header_rec.shipping_method_changed
5224    THEN
5225       x_header_rec.shipping_method_code := p_del_interface_rec.ship_method_code;
5226    END IF;
5227 
5228    IF p_om_header_rec.header_id is null or
5229       p_om_header_rec.freight_terms_changed
5230    THEN
5231       x_header_rec.freight_terms_code     := p_del_interface_rec.freight_terms_code;
5232    END IF;
5233 
5234    IF p_om_header_rec.header_id is null or
5235       p_om_header_rec.fob_point_changed
5236    THEN
5237       x_header_rec.fob_point_code     := p_del_interface_rec.fob_code;
5238    END IF;
5239 
5240    IF p_om_header_rec.header_attributes_changed and
5241       x_line_tbl.count > 0
5242    THEN -- {
5243       FOR i in x_line_tbl.first..x_line_tbl.last
5244       LOOP
5245          IF x_line_tbl(i).operation = OE_GLOBALS.G_OPR_UPDATE THEN
5246             IF nvl(x_header_rec.sold_to_customer_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5247                x_line_tbl(i).sold_to_customer_ref := x_header_rec.sold_to_customer_ref;
5248             END IF;
5249 
5250             IF nvl(x_header_rec.ship_to_customer_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5251                x_line_tbl(i).ship_to_customer_ref := x_header_rec.ship_to_customer_ref;
5252             END IF;
5253 
5254             IF nvl(x_header_rec.invoice_to_customer_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5255                x_line_tbl(i).invoice_to_customer_ref := x_header_rec.invoice_to_customer_ref;
5256             END IF;
5257 
5258             IF nvl(x_header_rec.deliver_to_customer_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5259                x_line_tbl(i).deliver_to_customer_ref := x_header_rec.deliver_to_customer_ref;
5260             END IF;
5261 
5262             IF nvl(x_header_rec.ship_to_address_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5263                x_line_tbl(i).ship_to_address_ref := x_header_rec.ship_to_address_ref;
5264             END IF;
5265 
5266             IF nvl(x_header_rec.invoice_to_address_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5267                x_line_tbl(i).invoice_to_address_ref := x_header_rec.invoice_to_address_ref;
5268             END IF;
5269 
5270             IF nvl(x_header_rec.deliver_to_address_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5271                x_line_tbl(i).deliver_to_address_ref := x_header_rec.deliver_to_address_ref;
5272             END IF;
5273 
5274             IF nvl(x_header_rec.ship_to_contact_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5275                x_line_tbl(i).ship_to_contact_ref := x_header_rec.ship_to_contact_ref;
5276             END IF;
5277 
5278             IF nvl(x_header_rec.invoice_to_contact_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5279                x_line_tbl(i).invoice_to_contact_ref := x_header_rec.invoice_to_contact_ref;
5280             END IF;
5281 
5282             IF nvl(x_header_rec.deliver_to_contact_ref, FND_API.G_MISS_CHAR) <> FND_API.G_MISS_CHAR THEN
5283                x_line_tbl(i).deliver_to_contact_ref := x_header_rec.deliver_to_contact_ref;
5284             END IF;
5285 
5286             IF p_om_header_rec.deliver_to_changed and
5287                x_header_rec.deliver_to_org_id is null
5288             THEN
5289                x_line_tbl(i).deliver_to_org_id := null;
5290             END IF;
5291 
5292             IF p_om_header_rec.ship_to_contact_changed and
5293                x_header_rec.ship_to_contact_id is null
5294             THEN
5295                x_line_tbl(i).ship_to_contact_id := null;
5296             END IF;
5297 
5298             IF p_om_header_rec.invoice_to_contact_changed and
5299                x_header_rec.invoice_to_contact_id is null
5300             THEN
5301                x_line_tbl(i).invoice_to_contact_id := null;
5302             END IF;
5303 
5304             IF p_om_header_rec.deliver_to_contact_changed and
5305                x_header_rec.deliver_to_contact_id is null
5306             THEN
5307                x_line_tbl(i).deliver_to_contact_id := null;
5308             END IF;
5309 
5310             IF p_om_header_rec.shipping_method_changed THEN
5311                x_line_tbl(i).shipping_method_code := x_header_rec.shipping_method_code;
5312             END IF;
5313 
5314             IF p_om_header_rec.freight_terms_changed THEN
5315                x_line_tbl(i).freight_terms_code := x_header_rec.freight_terms_code;
5316             END IF;
5317 
5318             IF p_om_header_rec.fob_point_changed THEN
5319                x_line_tbl(i).fob_point_code := x_header_rec.fob_point_code;
5320             END IF;
5321          END IF;
5322       END LOOP;
5323    END IF; -- }
5324 
5325    --
5326    IF l_debug_on THEN
5327       WSH_DEBUG_SV.log(l_module_name, 'x_customer_info count', x_customer_info.count);
5328       WSH_DEBUG_SV.log(l_module_name, 'Return Status', x_return_status);
5329       WSH_DEBUG_SV.pop(l_module_name);
5330    END IF;
5331    --
5332 EXCEPTION
5333    WHEN OTHERS THEN
5334          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
5335          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Populate_OM_Common_Attr');
5336          --
5337          IF l_debug_on THEN
5338            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5339            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5340          END IF;
5341          --
5342 END Populate_OM_Common_Attr;
5343 --
5344 --=============================================================================
5345 -- PUBLIC PROCEDURE :
5346 --       Populate_Header_Rec
5347 --
5348 -- PARAMETERS:
5349 --       p_action_type       => Either D(Cancel),A(Add),C(Change or Update)
5350 --       p_om_header_rec     => Standalone related order header attributes record
5351 --       p_del_interface_rec => Delivery Interface Record
5352 --       x_header_rec        => Order Header Record
5353 --       x_return_status     => Return Status of API (Either S,E,U)
5354 --
5355 -- COMMENT:
5356 --       API to populate Order Header attributes.
5357 --       If order header already exists only the operation related attributes
5358 --       are populated.
5359 --=============================================================================
5360 --
5361 PROCEDURE Populate_Header_Rec(
5362           p_action_type           IN VARCHAR2,
5363           p_om_header_rec         IN OM_Header_Rec_Type,
5364           p_del_interface_rec     IN Del_Interface_Rec_Type,
5365           x_header_rec            OUT NOCOPY OE_ORDER_PUB.Header_Rec_Type,
5366           x_return_status         OUT NOCOPY VARCHAR2 )  IS
5367 
5368 
5369    CURSOR c_get_source_id( p_client_code IN VARCHAR2) IS
5370    SELECT order_source_id
5371    FROM   OE_ORDER_SOURCES
5372    WHERE  name = p_client_code;
5373    --
5374    l_header_id                  NUMBER;
5375    l_debug_on BOOLEAN;
5376    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Populate_Header_Rec';
5377    --
5378 BEGIN
5379    --
5380    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5381    --
5382    IF l_debug_on IS NULL THEN
5383       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5384    END IF;
5385    --
5386    IF l_debug_on THEN
5387       WSH_DEBUG_SV.push(l_module_name);
5388       WSH_DEBUG_SV.log(l_module_name, 'p_action_type', p_action_type);
5389       WSH_DEBUG_SV.log(l_module_name, 'p_om_header_rec.header_id', p_om_header_rec.header_id);
5390    END IF;
5391    --
5392    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5393 
5394    l_header_id := p_om_header_rec.header_id;
5395 
5396    x_header_rec                        := OE_ORDER_PUB.G_MISS_HEADER_REC;
5397    x_header_rec.version_number         := p_del_interface_rec.document_revision;
5398    -- LSP PROJECT : Populate orig sys document ref as 'SHIPMENT_REQUEST:CLIENT CODE:ORDER NUMBER
5399    IF p_del_interface_rec.client_code IS NOT NULL THEN
5400        x_header_rec.orig_sys_document_ref  := 'SHIPMENT_REQUEST:'||p_del_interface_rec.client_code||':'||p_del_interface_rec.order_number;
5401    ELSE
5402        x_header_rec.orig_sys_document_ref  := 'SHIPMENT_REQUEST:' || p_del_interface_rec.order_number;
5403    END IF;
5404 
5405    IF p_action_type = 'D' -- { Action Type 'CANCEL'
5406    THEN
5407       x_header_rec.operation              := OE_GLOBALS.G_OPR_UPDATE;
5408       x_header_rec.header_id              := l_header_id;
5409       x_header_rec.change_reason          := 'Not provided';
5410       x_header_rec.cancelled_flag         := 'Y';
5411    ELSE
5412       --Populating header record
5413 
5414       IF l_header_id is NOT NULL THEN -- { Header Id not null
5415          x_header_rec.operation               := OE_GLOBALS.G_OPR_UPDATE;
5416          x_header_rec.header_id               := l_header_id;
5417          x_header_rec.order_type_id           := p_om_header_rec.order_type_id;
5418       ELSE -- Going to create new Sales Order
5419          x_header_rec.operation                  := OE_GLOBALS.G_OPR_CREATE;
5420          x_header_rec.order_number               := p_del_interface_rec.order_number;
5421 
5422          x_header_rec.order_type_id              := p_om_header_rec.order_type_id;
5423          x_header_rec.price_list_id              := p_om_header_rec.price_list_id;
5424          x_header_rec.payment_term_id            := p_om_header_rec.payment_term_id;
5425          x_header_rec.org_id                     := p_om_header_rec.org_id;
5426          x_header_rec.transactional_curr_code    := p_om_header_rec.currency_code;
5427 
5428          x_header_rec.sold_from_org_id           := p_om_header_rec.org_id;
5429          --
5430          -- LSP PROJECT: Populate order_source_id from oe_order_sources
5431          IF ( p_del_interface_rec.client_code IS NOT NULL ) THEN
5432          --{
5433              OPEN c_get_source_id(p_del_interface_rec.client_code);
5434              FETCH c_get_source_id INTO x_header_rec.order_source_id;
5435              CLOSE c_get_source_id;
5436              IF l_debug_on THEN
5437                 WSH_DEBUG_SV.log(l_module_name, 'x_header_rec.order_source_id', x_header_rec.order_source_id);
5438              END IF;
5439              IF (x_header_rec.order_source_id IS NULL OR x_header_rec.order_source_id = FND_API.G_MISS_NUM ) THEN
5440              --{
5441                  FND_MESSAGE.Set_Name('WSH', 'WSH_OI_INVALID_ATTRIBUTE');
5442                  FND_MESSAGE.SET_TOKEN('ATTRIBUTE','ORDER_SOURCE');
5443                  x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5444                  WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name );
5445                  IF l_debug_on THEN
5446                      WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
5447                      WSH_DEBUG_SV.pop(l_module_name);
5448                  END IF;
5449              --}
5450              END IF;
5451          --}
5452          ELSE
5453          --{
5454              x_header_rec.order_source_id            := 0; /* Online */
5455          --}
5456          END IF;
5457          -- LSP PROJECT: end
5458          --
5459          x_header_rec.salesrep_id                := -3; -- Salesrep => No Sales Credit
5460 
5461          --Common parameters for Process Order API Header record
5462          x_header_rec.open_flag                  := 'Y';
5463          -- 2/16/2009 Check with klr commented after discussing with OM for bug 8253903 logged
5464          --x_header_rec.booked_flag                := 'Y';
5465          x_header_rec.ordered_date               := sysdate;
5466          x_header_rec.order_category_code        := 'ORDER';
5467 
5468       END IF; -- } Header Id not null
5469    END IF; -- }
5470 
5471    --
5472    IF l_debug_on THEN
5473       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
5474       WSH_DEBUG_SV.pop(l_module_name);
5475    END IF;
5476    --
5477 EXCEPTION
5478    WHEN OTHERS THEN
5479          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
5480          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Populate_Header_Rec');
5481          --
5482          IF l_debug_on THEN
5483            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5484            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5485          END IF;
5486          --
5487 END Populate_Header_Rec;
5488 --
5489 --=============================================================================
5490 -- PUBLIC PROCEDURE :
5491 --       Derive_Header_Rec
5492 --
5493 -- PARAMETERS:
5494 --       p_om_header_rec     => Standalone related order header attributes record
5495 --       x_del_interface_rec => Delivery Interface Record
5496 --       x_return_status     => Return Status of API (Either S,E,U)
5497 --
5498 -- COMMENT:
5499 --       API to derive/validate standalone related order header attributes
5500 --       populated in Wsh_New_Del_Interface table.
5501 --=============================================================================
5502 --
5503 PROCEDURE Derive_Header_Rec(
5504           p_om_header_rec         IN OUT NOCOPY OM_Header_Rec_Type,
5505           x_del_interface_rec     IN OUT NOCOPY Del_Interface_Rec_Type,
5506           x_return_status         OUT NOCOPY VARCHAR2 )
5507 IS
5508 
5509    l_return_status              VARCHAR2(1);
5510    l_temp_status                VARCHAR2(1);
5511    l_tmp                        VARCHAR2(1);
5512    l_carrier_code               WSH_CARRIERS.Freight_Code%TYPE;
5513    l_missing_attr               VARCHAR2(1000);
5514    l_carrier_id                 NUMBER;
5515    l_header_id                  NUMBER;
5516    l_call_attr_changed          BOOLEAN;
5517 
5518    --
5519    l_debug_on BOOLEAN;
5520    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Derive_Header_Rec';
5521    --
5522 BEGIN
5523    --
5524    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5525    --
5526    IF l_debug_on IS NULL THEN
5527       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5528    END IF;
5529    --
5530    IF l_debug_on THEN
5531       WSH_DEBUG_SV.push(l_module_name);
5532       WSH_DEBUG_SV.logmsg(l_module_name, 'SoldTo Partner Name => ' || x_del_interface_rec.customer_name
5533                               || ', ' || 'ShipTo Partner Name => ' || x_del_interface_rec.ship_to_customer_name
5534                               || ', ' || 'InvoiceTo Partner Name => ' || x_del_interface_rec.ship_to_customer_name
5535                               || ', ' || 'ShipTo Partner Address1 => ' || x_del_interface_rec.ship_to_address1
5536                               || ', ' || 'InvoiceTo Partner Address1 => ' || x_del_interface_rec.invoice_to_address1 );
5537       WSH_DEBUG_SV.logmsg(l_module_name, 'Ids: SoldTo Partner => ' || x_del_interface_rec.customer_id
5538                               || ', ' || 'ShipTo Partner => ' || x_del_interface_rec.ship_to_customer_id
5539                               || ', ' || 'InvoiceTo Partner => ' || x_del_interface_rec.ship_to_customer_id
5540                               || ', ' || 'ShipTo Partner Address => ' || x_del_interface_rec.ship_to_address_id
5541                               || ', ' || 'InvoiceTo Partner Address => ' || x_del_interface_rec.invoice_to_address_id );
5542    END IF;
5543    --
5544 
5545    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5546    l_temp_status   := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5547 
5548    l_missing_attr  := null;
5549    l_header_id     := p_om_header_rec.header_id;
5550    l_call_attr_changed := TRUE;
5551 
5552    IF x_del_interface_rec.ship_to_customer_id is null and
5553       x_del_interface_rec.ship_to_customer_name is null
5554    THEN
5555       IF l_missing_attr is null THEN
5556          l_missing_attr := 'SHIPTO_PARTNER';
5557       ELSE
5558          l_missing_attr := l_missing_attr || ', ' || 'SHIPTO_PARTNER';
5559       END IF;
5560       l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5561    END IF;
5562 
5563    IF x_del_interface_rec.ship_to_address_id is null and
5564       x_del_interface_rec.ship_to_address1 is null
5565    THEN
5566       IF l_missing_attr is null THEN
5567          l_missing_attr := 'SHIPTO_PARTNER_ADDRESS';
5568       ELSE
5569          l_missing_attr := l_missing_attr || ', ' || 'SHIPTO_PARTNER_ADDRESS';
5570       END IF;
5571       l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5572    END IF;
5573 
5574    IF x_del_interface_rec.customer_id is null and
5575       x_del_interface_rec.customer_name is null
5576    THEN
5577       x_del_interface_rec.customer_id   := x_del_interface_rec.ship_to_customer_id;
5578       x_del_interface_rec.customer_name := x_del_interface_rec.ship_to_customer_name;
5579    END IF;
5580 
5581    IF x_del_interface_rec.invoice_to_customer_id is null and
5582       x_del_interface_rec.invoice_to_customer_name is null
5583    THEN
5584       x_del_interface_rec.invoice_to_customer_id   := x_del_interface_rec.ship_to_customer_id;
5585       x_del_interface_rec.invoice_to_customer_name := x_del_interface_rec.ship_to_customer_name;
5586    END IF;
5587 
5588    IF x_del_interface_rec.invoice_to_address_id is null and
5589       x_del_interface_rec.invoice_to_address1 is null
5590    THEN
5591       x_del_interface_rec.invoice_to_address_id  := x_del_interface_rec.ship_to_address_id;
5592       x_del_interface_rec.invoice_to_address1    := x_del_interface_rec.ship_to_address1;
5593       x_del_interface_rec.invoice_to_address2    := x_del_interface_rec.ship_to_address2;
5594       x_del_interface_rec.invoice_to_address3    := x_del_interface_rec.ship_to_address3;
5595       x_del_interface_rec.invoice_to_address4    := x_del_interface_rec.ship_to_address4;
5596       x_del_interface_rec.invoice_to_city        := x_del_interface_rec.ship_to_city;
5597       x_del_interface_rec.invoice_to_state       := x_del_interface_rec.ship_to_state;
5598       x_del_interface_rec.invoice_to_country     := x_del_interface_rec.ship_to_country;
5599       x_del_interface_rec.invoice_to_postal_code := x_del_interface_rec.ship_to_postal_code;
5600    END IF;
5601 
5602    IF l_temp_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
5603       --
5604       IF l_debug_on THEN
5605          WSH_DEBUG_SV.log(l_module_name, 'Error: Missing Attributes', l_missing_attr);
5606       END IF;
5607       --
5608       FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ATTR_MANDATORY');
5609       FND_MESSAGE.Set_Token('ATTRIBUTE', l_missing_attr);
5610       WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5611       l_call_attr_changed := FALSE;
5612    END IF;
5613 
5614    -- DeliverTo Address cannot be populated if DeliverTo Partner is NULL
5615    IF x_del_interface_rec.deliver_to_customer_id is null and
5616       x_del_interface_rec.deliver_to_customer_name is null
5617    THEN
5618       IF x_del_interface_rec.deliver_to_address_id is not null or
5619          x_del_interface_rec.deliver_to_address1 is not null
5620       THEN
5621          --
5622          IF l_debug_on THEN
5623             WSH_DEBUG_SV.logmsg(l_module_name, 'Error: DeliverTo Partner Address is populated without DeliverTo Partner detail');
5624          END IF;
5625          --
5626          l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5627          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_INVALID_DELIVER_INFO');
5628          FND_MESSAGE.Set_Token('ATTRIBUTE', 'DELIVERTO_PARTNER_ADDRESS');
5629          WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5630          l_call_attr_changed := FALSE;
5631       END IF;
5632    END IF;
5633 
5634    -- DeliverTo Contact cannot be populated if DeliverTo Partner or Address is NULL
5635    IF ( x_del_interface_rec.deliver_to_customer_id is null and
5636         x_del_interface_rec.deliver_to_customer_name is null ) OR
5637       ( x_del_interface_rec.deliver_to_address_id is null and
5638         x_del_interface_rec.deliver_to_address1 is null )
5639    THEN
5640       IF x_del_interface_rec.deliver_to_contact_id is not null or
5641          x_del_interface_rec.deliver_to_contact_name is not null
5642       THEN
5643          --
5644          IF l_debug_on THEN
5645             WSH_DEBUG_SV.logmsg(l_module_name, 'Error: DeliverTo Partner Contact is populated without DeliverTo Partner detail');
5646          END IF;
5647          --
5648          l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5649          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_INVALID_DELIVER_INFO');
5650          FND_MESSAGE.Set_Token('ATTRIBUTE', 'DELIVERTO_PARTNER_CONTACT');
5651          WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5652          l_call_attr_changed := FALSE;
5653       END IF;
5654    END IF;
5655 
5656    -- Validate Carrier Id or Carrier Code
5657    IF l_debug_on THEN
5658       wsh_debug_sv.logmsg(l_module_name, 'Carrier Id: '||x_del_interface_rec.carrier_id||' Carrier Code: '||x_del_interface_rec.carrier_code);
5659    END IF;
5660 
5661    BEGIN
5662       IF x_del_interface_rec.carrier_id is not null
5663       THEN
5664          select freight_code
5665          into   l_carrier_code
5666          from   wsh_carriers
5667          where  carrier_id = x_del_interface_rec.carrier_id;
5668       ELSIF x_del_interface_rec.carrier_code is not null THEN
5669          select carrier_id
5670          into   x_del_interface_rec.carrier_id
5671          from   wsh_carriers
5672          where  freight_code = x_del_interface_rec.carrier_code;
5673 
5674          l_carrier_id   := x_del_interface_rec.carrier_id;
5675          l_carrier_code := x_del_interface_rec.carrier_code;
5676       END IF;
5677 
5678       IF ( x_del_interface_rec.carrier_id is not null and
5679            x_del_interface_rec.service_level is not null and
5680            x_del_interface_rec.mode_of_transport is not null )
5681       THEN
5682          --
5683          IF l_debug_on THEN
5684             wsh_debug_sv.logmsg(l_module_name, 'Calling api Validate_Ship_Method', WSH_DEBUG_SV.C_PROC_LEVEL);
5685          END IF;
5686          --
5687          Validate_Ship_Method(
5688                   p_carrier_code      => l_carrier_code,
5689                   p_organization_id   => x_del_interface_rec.organization_id,
5690                   p_service_level     => x_del_interface_rec.service_level,
5691                   p_mode_of_transport => x_del_interface_rec.mode_of_transport,
5692                   x_ship_method_code  => x_del_interface_rec.ship_method_code,
5693                   x_return_status     => l_return_status );
5694 
5695          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
5696             --
5697             IF l_debug_on THEN
5698                WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Validate_Ship_Method', WSH_DEBUG_SV.C_ERR_LEVEL);
5699             END IF;
5700             --
5701             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5702          END IF;
5703       ELSIF ( ( x_del_interface_rec.carrier_id is not null or
5704                 x_del_interface_rec.service_level is not null or
5705                 x_del_interface_rec.mode_of_transport is not null ) and
5706               ( x_del_interface_rec.carrier_id is null or
5707                 x_del_interface_rec.service_level is null or
5708                 x_del_interface_rec.mode_of_transport is null ) )
5709       THEN
5710          --
5711          IF l_debug_on THEN
5712             wsh_debug_sv.logmsg(l_module_name, 'Error: Ship Method information is incomplete');
5713          END IF;
5714          --
5715          l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5716          FND_MESSAGE.Set_Name('WSH', 'WSH_STND_INCOMPLETE_SM');
5717          WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5718       END IF;
5719 
5720    EXCEPTION
5721       WHEN NO_DATA_FOUND THEN
5722          FND_MESSAGE.Set_Name('WSH', 'WSH_CARRIER_NOT_FOUND');
5723          l_temp_status   := WSH_UTIL_CORE.G_RET_STS_ERROR;
5724          WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5725          --
5726          IF l_debug_on THEN
5727             wsh_debug_sv.logmsg(l_module_name, 'Error: Carrier not found');
5728          END IF;
5729          --
5730    END;
5731 
5732    -- If Order Header already exists, then validate if Ship-From, Sold-To,
5733    -- Ship-To, Invoice-To, Deliver-To and Ship-Method remains the same,
5734    -- if not then validate it.
5735    IF l_header_id is not null and l_call_attr_changed THEN
5736       --
5737       IF l_debug_on THEN
5738          wsh_debug_sv.logmsg(l_module_name, 'Calling api Check_Header_Attr_Changed', WSH_DEBUG_SV.C_PROC_LEVEL);
5739       END IF;
5740       --
5741       Check_Header_Attr_Changed(
5742             p_del_interface_rec => x_del_interface_rec,
5743             p_om_header_rec     => p_om_header_rec,
5744             x_return_status     => l_return_status );
5745 
5746       IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
5747          --
5748          IF l_debug_on THEN
5749             WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Check_Header_Attr_Changed', WSH_DEBUG_SV.C_ERR_LEVEL);
5750          END IF;
5751          --
5752          l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5753       ELSIF ( p_om_header_rec.header_attributes_changed )
5754       THEN
5755          --
5756          IF l_debug_on THEN
5757             WSH_DEBUG_SV.logmsg(l_module_name, 'Header Attributes Changed, Check if there exists any Shipped delivery lines');
5758          END IF;
5759          --
5760 
5761          BEGIN
5762             select 'x'
5763             into   l_tmp
5764             from   wsh_delivery_details     wdd,
5765                    wsh_delivery_assignments wda,
5766                    wsh_new_deliveries       wnd
5767             where  wnd.status_code in ( 'CO', 'IT', 'CL' )
5768             and    wnd.delivery_id = wda.delivery_id
5769             and    wda.delivery_detail_id = wdd.delivery_detail_id
5770             and    wdd.source_code = 'OE'
5771             and    released_status in ( 'Y', 'C' )
5772             and    wdd.source_header_id = l_header_id;
5773 
5774          EXCEPTION
5775             WHEN NO_DATA_FOUND THEN
5776                l_tmp := null;
5777          END;
5778 
5779          IF l_tmp is not null THEN
5780             l_missing_attr := null;
5781             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5782 
5783             IF p_om_header_rec.ship_to_changed THEN
5784                l_missing_attr := 'SHIPTO_PARTNER';
5785             END IF;
5786 
5787             IF p_om_header_rec.ship_to_contact_changed THEN
5788                IF l_missing_attr is null THEN
5789                   l_missing_attr := 'SHIPTO_PARTNER_CONTACT';
5790                ELSE
5791                   l_missing_attr := l_missing_attr || ', ' || 'SHIPTO_PARTNER_CONTACT';
5792                END IF;
5793             END IF;
5794 
5795             IF p_om_header_rec.invoice_to_changed THEN
5796                IF l_missing_attr is null THEN
5797                   l_missing_attr := 'INVOICETO_PARTNER';
5798                ELSE
5799                   l_missing_attr := l_missing_attr || ', ' || 'INVOICETO_PARTNER';
5800                END IF;
5801             END IF;
5802 
5803             IF p_om_header_rec.invoice_to_contact_changed THEN
5804                IF l_missing_attr is null THEN
5805                   l_missing_attr := 'INVOICETO_PARTNER_CONTACT';
5806                ELSE
5807                   l_missing_attr := l_missing_attr || ', ' || 'INVOICETO_PARTNER_CONTACT';
5808                END IF;
5809             END IF;
5810 
5811             IF p_om_header_rec.deliver_to_changed THEN
5812                IF l_missing_attr is null THEN
5813                   l_missing_attr := 'DELIVERTO_PARTNER';
5814                ELSE
5815                   l_missing_attr := l_missing_attr || ', ' || 'DELIVERTO_PARTNER';
5816                END IF;
5817             END IF;
5818 
5819             IF p_om_header_rec.deliver_to_contact_changed THEN
5820                IF l_missing_attr is null THEN
5821                   l_missing_attr := 'DELIVERTO_PARTNER_CONTACT';
5822                ELSE
5823                   l_missing_attr := l_missing_attr || ', ' || 'DELIVERTO_PARTNER_CONTACT';
5824                END IF;
5825             END IF;
5826 
5827             IF p_om_header_rec.freight_terms_changed THEN
5828                IF l_missing_attr is null THEN
5829                   l_missing_attr := 'FREIGHT_TERMS';
5830                ELSE
5831                   l_missing_attr := l_missing_attr || ', ' || 'FREIGHT_TERMS';
5832                END IF;
5833             END IF;
5834 
5835             IF p_om_header_rec.fob_point_changed THEN
5836                IF l_missing_attr is null THEN
5837                   l_missing_attr := 'FOB_CODE';
5838                ELSE
5839                   l_missing_attr := l_missing_attr || ', ' || 'FOB_CODE';
5840                END IF;
5841             END IF;
5842 
5843             IF p_om_header_rec.shipping_method_changed THEN
5844                IF l_missing_attr is null THEN
5845                   l_missing_attr := 'SHIP_METHOD';
5846                ELSE
5847                   l_missing_attr := l_missing_attr || ', ' || 'SHIP_METHOD';
5848                END IF;
5849             END IF;
5850 
5851             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_REJECT_HEADER_CHANGE');
5852             FND_MESSAGE.Set_Token('HEADER_ATTR', l_missing_attr);
5853             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name);
5854             --
5855             IF l_debug_on THEN
5856                wsh_debug_sv.logmsg(l_module_name, 'Error: Header attributes cannot be changed');
5857             END IF;
5858             --
5859          END IF;
5860       END IF;
5861    END IF;
5862 
5863    IF l_temp_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
5864       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
5865    END IF;
5866 
5867    --
5868    IF l_debug_on THEN
5869       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
5870       WSH_DEBUG_SV.pop(l_module_name);
5871    END IF;
5872    --
5873 EXCEPTION
5874    WHEN OTHERS THEN
5875          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
5876          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Derive_Header_Rec');
5877          --
5878          IF l_debug_on THEN
5879            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
5880            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
5881          END IF;
5882          --
5883 END Derive_Header_Rec;
5884 --
5885 --=============================================================================
5886 -- PUBLIC PROCEDURE :
5887 --       Derive_Line_Rec
5888 --
5889 -- PARAMETERS:
5890 --       p_header_id                 => Header Id
5891 --       p_del_interface_rec         => Delivery Interface Record
5892 --       x_om_line_tbl_type          => Table of standalone related order line attributes
5893 --       x_details_interface_rec_tab => Table of Delivery Detail Interface Record
5894 --       x_interface_error_tab       => Table of Interface error records
5895 --       x_return_status             => Return Status of API (Either S,E,U)
5896 --
5897 -- COMMENT:
5898 --       API to derive/validate standalone related order line attributes
5899 --       populated in Wsh_Del_Details_Interface table.
5900 --=============================================================================
5901 --
5902 PROCEDURE Derive_Line_Rec(
5903           p_header_id                 IN NUMBER,
5904           p_del_interface_rec         IN OUT NOCOPY Del_Interface_Rec_Type,
5905           x_om_line_tbl_type          OUT NOCOPY OM_Line_Tbl_Type,
5906           x_details_interface_rec_tab OUT NOCOPY Del_Details_Interface_Rec_Tab,
5907           x_interface_error_tab       OUT NOCOPY WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_tab,
5908           x_return_status             OUT NOCOPY VARCHAR2 )
5909 IS
5910    CURSOR c_del_details_interface_rec
5911    IS
5912    SELECT wddi.delivery_detail_interface_id,
5913           wddi.lot_number,
5914           wddi.subinventory,
5915           wddi.revision,
5916           wddi.locator_id,
5917           wddi.locator_code,
5918           wddi.line_number,
5919           wddi.customer_item_number,
5920           wddi.customer_item_id,
5921           wddi.item_number,
5922           wddi.inventory_item_id,
5923           p_del_interface_rec.organization_id,
5924           wddi.item_description,
5925           wddi.requested_quantity,
5926           wddi.requested_quantity_uom,
5927           wddi.src_requested_quantity,
5928           wddi.src_requested_quantity_uom,
5929           wddi.currency_code,
5930           nvl(wddi.unit_selling_price, 0),
5931           wddi.ship_tolerance_above,
5932           wddi.ship_tolerance_below,
5933           wddi.date_requested,
5934           wddi.date_scheduled,
5935           wddi.earliest_pickup_date,
5936           wddi.latest_pickup_date,
5937           wddi.earliest_dropoff_date,
5938           wddi.latest_dropoff_date,
5939           wddi.ship_set_name,
5940           wddi.packing_instructions,
5941           wddi.shipping_instructions,
5942           wddi.shipment_priority_code,
5943           wddi.source_header_number,
5944           wddi.source_line_number,
5945           wddi.cust_po_number,
5946           null, -- Line Id
5947           'N',  -- Schedule Date Changed
5948           'N'   -- Changed Flag
5949    FROM   Wsh_Del_Details_Interface wddi,
5950           Wsh_Del_Assgn_Interface wdai,
5951           Wsh_New_Del_Interface wndi
5952    WHERE  wddi.interface_action_code = g_interface_action_code
5953    AND    wdai.interface_action_code = g_interface_action_code
5954    AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
5955    AND    wdai.delivery_interface_id = wndi.delivery_interface_id
5956    AND    wndi.delivery_interface_id = p_del_interface_rec.delivery_interface_id
5957    ORDER  BY wddi.line_number;
5958 
5959    l_temp_status                VARCHAR2(1);
5960    l_return_status              VARCHAR2(1);
5961 
5962    l_item_number                WSH_DEL_DETAILS_INTERFACE.Item_Number%TYPE;
5963 
5964    l_line_cnt                   NUMBER;
5965    l_customer_id                NUMBER;
5966    l_ship_to_org_id             NUMBER;
5967    l_address_id                 NUMBER;
5968    l_inventory_item_id          NUMBER;
5969    l_customer_item_id           NUMBER;
5970 
5971    --
5972    l_debug_on BOOLEAN;
5973    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Derive_Line_Rec';
5974    --
5975 BEGIN
5976    --
5977    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
5978    --
5979    IF l_debug_on IS NULL THEN
5980       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
5981    END IF;
5982    --
5983    IF l_debug_on THEN
5984       WSH_DEBUG_SV.push(l_module_name);
5985       WSH_DEBUG_SV.log(l_module_name, 'p_del_interface_rec.delivery_interface_id', p_del_interface_rec.delivery_interface_id);
5986       WSH_DEBUG_SV.log(l_module_name, 'p_header_id', p_header_id);
5987    END IF;
5988    --
5989 
5990    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
5991 
5992    open  c_del_details_interface_rec;
5993    fetch c_del_details_interface_rec BULK COLLECT INTO x_details_interface_rec_tab;
5994    close c_del_details_interface_rec;
5995 
5996    --
5997    IF l_debug_on THEN
5998       WSH_DEBUG_SV.log(l_module_name, 'x_details_interface_rec_tab.count', x_details_interface_rec_tab.count);
5999    END IF;
6000    --
6001 
6002    IF x_details_interface_rec_tab.count > 0 THEN
6003       l_line_cnt := 0;
6004       FOR i in x_details_interface_rec_tab.first..x_details_interface_rec_tab.last
6005       LOOP
6006          l_line_cnt := l_line_cnt + 1;
6007          l_temp_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6008          --
6009          IF l_debug_on THEN
6010             WSH_DEBUG_SV.logmsg(l_module_name, 'Processing Line Number', x_details_interface_rec_tab(i).line_number);
6011          END IF;
6012          --
6013 
6014          IF (x_details_interface_rec_tab(i).line_number <= 0) OR
6015               (trunc(x_details_interface_rec_tab(i).line_number) <> x_details_interface_rec_tab(i).line_number) THEN
6016             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_POSITIVE_INTEGER');
6017             FND_MESSAGE.Set_Token('ATTRIBUTE', 'LINE_NUMBER');
6018             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6019             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6020             --
6021             IF l_debug_on THEN
6022                wsh_debug_sv.logmsg(l_module_name, 'Error: Line number should be positive integer');
6023             END IF;
6024             --
6025             goto loop_end;
6026          END IF;
6027 
6028          IF p_header_id is not null -- {
6029          THEN
6030             --
6031             IF l_debug_on THEN
6032                WSH_DEBUG_SV.logmsg(l_module_name, 'Calling Check_Line_Exists', WSH_DEBUG_SV.C_PROC_LEVEL);
6033             END IF;
6034             --
6035             Check_Line_Exists (
6036                   p_header_id        => p_header_id,
6037                   p_line_number      => x_details_interface_rec_tab(i).line_number,
6038                   x_om_line_rec_type => x_om_line_tbl_type(i),
6039                   x_return_status    => l_return_status );
6040 
6041             --
6042             IF l_debug_on THEN
6043                WSH_DEBUG_SV.log(l_module_name, 'Return Status from Check_Line_Exists', l_return_status);
6044             END IF;
6045             --
6046 
6047             IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN
6048                --
6049                IF l_debug_on THEN
6050                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Check_Line_Exists', WSH_DEBUG_SV.C_ERR_LEVEL);
6051                END IF;
6052                --
6053                l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6054                goto loop_end;
6055             END IF;
6056 
6057             --
6058             IF l_debug_on THEN
6059                WSH_DEBUG_SV.logmsg(l_module_name, 'Line Id => ' || x_om_line_tbl_type(i).line_id);
6060             END IF;
6061             --
6062             x_details_interface_rec_tab(i).line_id := x_om_line_tbl_type(i).line_id;
6063 
6064             IF (x_om_line_tbl_type(i).open_flag = 'N') THEN
6065                --
6066                IF l_debug_on THEN
6067                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Line is already Closed');
6068                END IF;
6069                --
6070                FND_MESSAGE.Set_Name('WSH', 'WSH_STND_LINE_CLOSED');
6071                FND_MESSAGE.Set_Token('LINE_NUMBER', x_details_interface_rec_tab(i).line_number);
6072                l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6073                WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6074                goto loop_end;
6075             END IF;
6076          END IF; --}
6077 
6078          IF  ( x_details_interface_rec_tab(i).requested_quantity IS NULL )
6079          THEN
6080             --
6081             IF l_debug_on THEN
6082                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Requested Quantity is NULL');
6083             END IF;
6084             --
6085             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ATTR_MANDATORY');
6086             FND_MESSAGE.Set_Token('ATTRIBUTE', 'ORDERED_QUANTITY');
6087             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6088             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6089          -- Bug 8452056: Check only if ordered quantity is negative.
6090          ELSIF ( x_details_interface_rec_tab(i).requested_quantity < 0 )
6091          THEN
6092             --
6093             IF l_debug_on THEN
6094                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Requested Quantity cannot be Negative');
6095             END IF;
6096             --
6097             FND_MESSAGE.Set_Name('WSH', 'WSH_UI_NEGATIVE_QTY');
6098             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6099             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6100          END IF;
6101 
6102          IF  ( x_details_interface_rec_tab(i).requested_quantity_uom IS NULL )
6103          THEN
6104             --
6105             IF l_debug_on THEN
6106                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Requested Quantity UOM is NULL');
6107             END IF;
6108             --
6109             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_ATTR_MANDATORY');
6110             FND_MESSAGE.Set_Token('ATTRIBUTE', 'ORDERED_QUANTITY_UOM');
6111             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6112             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6113          END IF;
6114 
6115          IF  (x_details_interface_rec_tab(i).ship_tolerance_above IS NOT NULL) AND
6116                ((x_details_interface_rec_tab(i).ship_tolerance_above < 0) OR
6117                 (trunc(x_details_interface_rec_tab(i).ship_tolerance_above) <> x_details_interface_rec_tab(i).ship_tolerance_above))
6118          THEN
6119             --
6120             IF l_debug_on THEN
6121                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Ship Tolerance Above('||x_details_interface_rec_tab(i).ship_tolerance_above||') Validation Failed');
6122             END IF;
6123             --
6124             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_POSITIVE_INTEGER');
6125             FND_MESSAGE.Set_Token('ATTRIBUTE', 'SHIP_TOLERANCE_ABOVE');
6126             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6127             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6128          END IF;
6129 
6130          IF  (x_details_interface_rec_tab(i).ship_tolerance_below IS NOT NULL) AND
6131                ((x_details_interface_rec_tab(i).ship_tolerance_below < 0) OR
6132                 (trunc(x_details_interface_rec_tab(i).ship_tolerance_below) <> x_details_interface_rec_tab(i).ship_tolerance_below))
6133          THEN
6134             --
6135             IF l_debug_on THEN
6136                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Ship Tolerance Below('||x_details_interface_rec_tab(i).ship_tolerance_below||') Validation Failed');
6137             END IF;
6138             --
6139             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_POSITIVE_INTEGER');
6140             FND_MESSAGE.Set_Token('ATTRIBUTE', 'SHIP_TOLERANCE_BELOW');
6141             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6142             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6143          END IF;
6144 
6145          --Derive Inventory Item Id
6146          IF ( x_details_interface_rec_tab(i).inventory_item_id is null and -- {
6147               x_details_interface_rec_tab(i).item_number is null )
6148          THEN
6149             --
6150             IF l_debug_on THEN
6151                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Inventory Item information is missing');
6152             END IF;
6153             --
6154             FND_MESSAGE.Set_Name('WSH', 'WSH_REQUIRED_FIELD_NULL');
6155             FND_MESSAGE.Set_Token('FIELD_NAME', 'ITEM_NUMBER OR ITEM_ID');
6156             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6157             WSH_UTIL_CORE.Add_Message(l_temp_status, l_module_name );
6158          ELSIF x_details_interface_rec_tab(i).inventory_item_id is null
6159          THEN
6160             l_item_number    := x_details_interface_rec_tab(i).item_number;
6161             --
6162             IF l_debug_on THEN
6163                WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_UTIL_VALIDATE.Validate_Item', WSH_DEBUG_SV.C_PROC_LEVEL);
6164             END IF;
6165             --
6166             WSH_UTIL_VALIDATE.Validate_Item(
6167                      p_item_number       => l_item_number,
6168                      p_organization_id   => x_details_interface_rec_tab(i).organization_id,
6169                      x_inventory_item_id => l_inventory_item_id,
6170                      x_return_status     => l_return_status );
6171 
6172             x_details_interface_rec_tab(i).inventory_item_id := l_inventory_item_id;
6173 
6174             IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN -- {
6175                --
6176                IF l_debug_on THEN
6177                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Validate_Item', WSH_DEBUG_SV.C_ERR_LEVEL);
6178                END IF;
6179                --
6180                l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6181             END IF; --}
6182          END IF; -- } Inventory Item Validation
6183 
6184          -- Customer Item Id validation
6185          IF ( x_details_interface_rec_tab(i).inventory_item_id is not null and
6186               x_details_interface_rec_tab(i).customer_item_id is null and
6187               x_details_interface_rec_tab(i).customer_item_number is not null )
6188          THEN -- {
6189             l_ship_to_org_id := null;
6190             l_customer_id    := null;
6191             l_address_id     := null;
6192 
6193             l_customer_id := p_del_interface_rec.customer_id;
6194             -- Derive Customer Id, if its null
6195             IF l_customer_id is null THEN -- {
6196                --
6197                IF l_debug_on THEN
6198                   WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Sold_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
6199                END IF;
6200                --
6201                l_customer_id := OE_Value_To_Id.Sold_To_Org(
6202                                      p_sold_to_org     => p_del_interface_rec.customer_name,
6203                                      p_customer_number => NULL );
6204 
6205                IF nvl(l_customer_id, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM THEN
6206                   l_customer_id := null;
6207                   --Check with klr for Error Message
6208                   --
6209                   IF l_debug_on THEN
6210                      WSH_DEBUG_SV.logmsg(l_module_name, 'Customer does not exist. So, Customer item is invalid');
6211                   END IF;
6212                   --
6213                   l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6214                END IF;
6215             END IF; -- }
6216 
6217             --Derive Ship-To-Org, if its null
6218             l_ship_to_org_id := p_del_interface_rec.ship_to_address_id;
6219             IF ( l_customer_id is not null and
6220                  l_ship_to_org_id is null and
6221                  p_del_interface_rec.ship_to_address1 is not null )
6222             THEN -- {
6223                --
6224                IF l_debug_on THEN
6225                   WSH_DEBUG_SV.logmsg(l_module_name, 'Calling OE_Value_To_Id.Ship_To_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
6226                END IF;
6227                --
6228                l_ship_to_org_id :=
6229                      OE_Value_To_Id.Ship_To_Org(
6230                               p_ship_to_address1    => p_del_interface_rec.ship_to_address1,
6231                               p_ship_to_address2    => p_del_interface_rec.ship_to_address2,
6232                               p_ship_to_address3    => p_del_interface_rec.ship_to_address3,
6233                               p_ship_to_address4    => p_del_interface_rec.ship_to_address4,
6234                               p_ship_to_location    => NULL,
6235                               p_ship_to_org         => NULL,
6236                               p_sold_to_org_id      => l_customer_id, --p_del_interface_rec.customer_id,
6237                               p_ship_to_city        => p_del_interface_rec.ship_to_city,
6238                               p_ship_to_state       => p_del_interface_rec.ship_to_state,
6239                               p_ship_to_postal_code => p_del_interface_rec.ship_to_postal_code,
6240                               p_ship_to_country     => p_del_interface_rec.ship_to_country,
6241                               p_ship_to_customer_id => NULL );
6242 
6243                IF nvl(l_ship_to_org_id, FND_API.G_MISS_NUM) = FND_API.G_MISS_NUM
6244                THEN -- {
6245                   l_ship_to_org_id := null;
6246                   --
6247                   IF l_debug_on THEN
6248                      WSH_DEBUG_SV.logmsg(l_module_name, 'Invalid Ship-To Information');
6249                   END IF;
6250                   --
6251                   l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6252                END IF; -- }
6253             END IF; -- }
6254 
6255             --Derive Ship-To-Cust Site Use
6256             IF l_ship_to_org_id is not null THEN -- {
6257                BEGIN
6258                   SELECT cust_acct_site_id
6259                   INTO   l_address_id
6260                   FROM   hz_cust_site_uses_all
6261                   WHERE  org_id = p_del_interface_rec.org_id
6262                   AND    site_use_id = l_ship_to_org_id;
6263 
6264                   p_del_interface_rec.ship_to_address_id := l_ship_to_org_id;
6265                EXCEPTION
6266                WHEN NO_DATA_FOUND THEN
6267                   --
6268                   IF l_debug_on THEN
6269                      WSH_DEBUG_SV.logmsg(l_module_name, 'No-Data-Found Exception for Customer Account Site');
6270                   END IF;
6271                   --
6272                END;
6273             END IF; -- }
6274 
6275             IF l_customer_id is not null or
6276                l_address_id is not null
6277             THEN -- {
6278                --
6279                IF l_debug_on THEN
6280                   WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_UTIL_VALIDATE.Validate_Customer_Item', WSH_DEBUG_SV.C_PROC_LEVEL);
6281                END IF;
6282                --
6283                WSH_UTIL_VALIDATE.Validate_Customer_Item(
6284                       p_item_number      => x_details_interface_rec_tab(i).customer_item_number,
6285                       p_customer_id      => l_customer_id,
6286                       p_address_id       => l_address_id,
6287                       x_customer_item_id => l_customer_item_id,
6288                       x_return_status    => l_return_status );
6289 
6290 
6291                IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS THEN -- {
6292                   --
6293                   IF l_debug_on THEN
6294                      WSH_DEBUG_SV.logmsg(l_module_name, 'Error occured in Validate_Customer_Item', WSH_DEBUG_SV.C_ERR_LEVEL);
6295                   END IF;
6296                   --
6297                   l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6298                ELSE
6299                   x_details_interface_rec_tab(i).customer_item_id := l_customer_item_id;
6300                END IF; --}
6301 
6302             END IF; --}
6303          END IF; -- }
6304 
6305          <<loop_end>>
6306          IF l_temp_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
6307             x_return_status := l_temp_status;
6308             Populate_Error_Records(
6309                  p_interface_id             => x_details_interface_rec_tab(i).delivery_detail_interface_id,
6310                  p_interface_table_name     => 'WSH_DEL_DETAILS_INTERFACE',
6311                  x_interface_errors_rec_tab => x_interface_error_tab,
6312                  x_return_status            => l_return_status );
6313          END IF;
6314       END LOOP;
6315    END IF;
6316 
6317    --
6318    IF l_debug_on THEN
6319       WSH_DEBUG_SV.log(l_module_name, 'x_om_line_tbl_type.count', x_om_line_tbl_type.count);
6320       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
6321       WSH_DEBUG_SV.pop(l_module_name);
6322    END IF;
6323    --
6324 
6325 EXCEPTION
6326    WHEN OTHERS THEN
6327          IF c_del_details_interface_rec%ISOPEN THEN
6328             close c_del_details_interface_rec;
6329          END IF;
6330          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6331          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Derive_Line_Rec');
6332          --
6333          IF l_debug_on THEN
6334            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6335            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6336          END IF;
6337          --
6338 END Derive_Line_Rec;
6339 --
6340 --=============================================================================
6341 -- PUBLIC PROCEDURE :
6342 --       Populate_Line_Records
6343 --
6344 -- PARAMETERS:
6345 --       p_om_line_tbl_type          => Table of standalone related order line attributes
6346 --       p_details_interface_rec_tab => Table of Delivery Detail Interface Record
6347 --       p_om_header_rec_type        => Standalone Order Header attributes
6348 --       p_delivery_interface_rec    => Delivery Interface Record
6349 --       x_line_tbl                  => Table of Order Line attributes
6350 --       x_line_details_tbl          => Table of Delivery Detail Interface Id
6351 --       x_return_status             => Return Status of API (Either S,E,U)
6352 --
6353 -- COMMENT:
6354 --       API to populate Order Line attributes.
6355 --       If order line already exists only the changed attributes are populated.
6356 --=============================================================================
6357 --
6358 PROCEDURE Populate_Line_Records(
6359           p_om_line_tbl_type          IN OM_Line_Tbl_Type,
6360           p_details_interface_rec_tab IN Del_Details_Interface_Rec_Tab,
6361           p_om_header_rec_type        IN OM_Header_Rec_Type,
6362           p_delivery_interface_rec    IN Del_Interface_Rec_Type,
6363           x_line_tbl                  OUT NOCOPY OE_ORDER_PUB.Line_Tbl_Type,
6364           x_line_details_tbl          OUT NOCOPY WSH_UTIL_CORE.Id_Tab_Type,
6365           x_return_status             OUT NOCOPY VARCHAR2 )
6366 IS
6367    CURSOR c_non_interface_order_lines
6368    IS
6369    SELECT oel.line_id,
6370           oel.line_number
6371    FROM   oe_order_lines_all oel
6372    WHERE  header_id = p_om_header_rec_type.header_id
6373    AND    NOT EXISTS
6374         ( SELECT 'X'
6375           FROM   Wsh_Del_Details_Interface wddi,
6376                  Wsh_Del_Assgn_Interface wdai,
6377                  Wsh_New_Del_Interface wndi
6378           WHERE  wddi.line_number = oel.line_number
6379           AND    wddi.interface_action_code = g_interface_action_code
6380           AND    wdai.interface_action_code = g_interface_action_code
6381           AND    wddi.delivery_detail_interface_id = wdai.delivery_detail_interface_id
6382           AND    wdai.delivery_interface_id = wndi.delivery_interface_id
6383           AND    wndi.delivery_interface_id = p_delivery_interface_rec.delivery_interface_id );
6384 
6385    l_line_cnt                   NUMBER;
6386    l_line_id                    NUMBER;
6387 
6388    --
6389    l_debug_on BOOLEAN;
6390    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Populate_Line_Records';
6391    --
6392 BEGIN
6393    --
6394    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6395    --
6396    IF l_debug_on IS NULL THEN
6397       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6398    END IF;
6399    --
6400    IF l_debug_on THEN
6401       WSH_DEBUG_SV.push(l_module_name);
6402       WSH_DEBUG_SV.log(l_module_name, 'x_line_tbl.count', x_line_tbl.count);
6403       WSH_DEBUG_SV.log(l_module_name, 'p_om_header_rec_type.header_id', p_om_header_rec_type.header_id);
6404       WSH_DEBUG_SV.log(l_module_name, 'p_om_line_tbl_type.count', p_om_line_tbl_type.count);
6405       WSH_DEBUG_SV.log(l_module_name, 'p_details_interface_rec_tab.count', p_details_interface_rec_tab.count);
6406    END IF;
6407    --
6408 
6409    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6410 
6411    l_line_cnt := x_line_tbl.count;
6412 
6413    IF p_details_interface_rec_tab.count > 0 THEN -- { Interface records
6414       FOR i in p_details_interface_rec_tab.first..p_details_interface_rec_tab.last
6415       LOOP
6416          -- Bug 8452056: Skip processing interface records with Zero requested quantity
6417          IF ( p_details_interface_rec_tab(i).line_id is null and
6418               p_details_interface_rec_tab(i).requested_quantity = 0 )
6419          THEN
6420             --
6421             IF l_debug_on THEN
6422                WSH_DEBUG_SV.logmsg(l_module_name, 'Warning: Ordered Quantity is Zero and order line does not exist, so skipping interface record with line number '
6423                                          || p_details_interface_rec_tab(i).line_number );
6424             END IF;
6425             --
6426             goto zero_req_quantity;
6427          END IF;
6428 
6429          l_line_cnt := l_line_cnt + 1;
6430          x_line_tbl(l_line_cnt)     := OE_ORDER_PUB.G_MISS_LINE_REC;
6431 
6432          l_line_id  := p_details_interface_rec_tab(i).line_id;
6433 
6434          -- LSP PROJECT commented out the following code.
6435          /*-- Used for Error logging when PO api errors out
6436          x_line_details_tbl(p_details_interface_rec_tab(i).line_number) := p_details_interface_rec_tab(i).delivery_detail_interface_id; */
6437 
6438          IF (l_line_id is not null) THEN  /* Line Update Mode */
6439             x_line_tbl(l_line_cnt).line_id    := l_line_id;
6440             x_line_tbl(l_line_cnt).operation  := OE_GLOBALS.G_OPR_UPDATE;
6441             x_line_tbl(l_line_cnt).calculate_price_flag := 'N';
6442 
6443             IF nvl(p_details_interface_rec_tab(i).requested_quantity, FND_API.G_MISS_NUM) <>
6444                nvl(p_om_line_tbl_type(i).ordered_quantity, FND_API.G_MISS_NUM)
6445             THEN
6446                x_line_tbl(l_line_cnt).ordered_quantity   := p_details_interface_rec_tab(i).requested_quantity;
6447 
6448                --If new ordered quantity is less then order lines ordered quantity then pass change reason code
6449                IF p_om_line_tbl_type(i).ordered_quantity > p_details_interface_rec_tab(i).requested_quantity THEN
6450                   x_line_tbl(l_line_cnt).change_reason := 'Not provided';
6451                END IF;
6452             END IF;
6453 
6454             IF nvl(p_details_interface_rec_tab(i).requested_quantity_uom, FND_API.G_MISS_CHAR) <>
6455                nvl(p_om_line_tbl_type(i).order_quantity_uom, FND_API.G_MISS_CHAR)
6456             THEN
6457                x_line_tbl(l_line_cnt).order_quantity_uom := p_details_interface_rec_tab(i).requested_quantity_uom;
6458             END IF;
6459 
6460             IF nvl(p_details_interface_rec_tab(i).ship_tolerance_above, FND_API.G_MISS_NUM) <>
6461                nvl(p_om_line_tbl_type(i).ship_tolerance_above, FND_API.G_MISS_NUM)
6462             THEN
6463                x_line_tbl(l_line_cnt).ship_tolerance_above := p_details_interface_rec_tab(i).ship_tolerance_above;
6464             END IF;
6465 
6466             IF nvl(p_details_interface_rec_tab(i).ship_tolerance_below, FND_API.G_MISS_NUM) <>
6467                nvl(p_om_line_tbl_type(i).ship_tolerance_below, FND_API.G_MISS_NUM)
6468             THEN
6469                x_line_tbl(l_line_cnt).ship_tolerance_below := p_details_interface_rec_tab(i).ship_tolerance_below;
6470             END IF;
6471 
6472             IF nvl(p_details_interface_rec_tab(i).shipping_instructions, FND_API.G_MISS_CHAR) <>
6473                nvl(p_om_line_tbl_type(i).shipping_instructions, FND_API.G_MISS_CHAR)
6474             THEN
6475                x_line_tbl(l_line_cnt).shipping_instructions := p_details_interface_rec_tab(i).shipping_instructions;
6476             END IF;
6477 
6478             IF nvl(p_details_interface_rec_tab(i).packing_instructions, FND_API.G_MISS_CHAR) <>
6479                nvl(p_om_line_tbl_type(i).packing_instructions, FND_API.G_MISS_CHAR)
6480             THEN
6481                x_line_tbl(l_line_cnt).packing_instructions := p_details_interface_rec_tab(i).packing_instructions;
6482             END IF;
6483 
6484             IF nvl(p_details_interface_rec_tab(i).ship_set_name, FND_API.G_MISS_CHAR) <>
6485                nvl(p_om_line_tbl_type(i).ship_set_name, FND_API.G_MISS_CHAR)
6486             THEN
6487                x_line_tbl(l_line_cnt).ship_set := p_details_interface_rec_tab(i).ship_set_name;
6488             END IF;
6489 
6490             --Leelaraj, If request date is not passed during updting then following error is thrown from PO API
6491             --A request date is required on the line to perform scheduling.
6492             IF p_details_interface_rec_tab(i).date_requested IS NULL
6493             THEN
6494                x_line_tbl(l_line_cnt).request_date := p_om_line_tbl_type(i).request_date;
6495             ELSIF p_details_interface_rec_tab(i).date_requested <>
6496                       nvl(p_om_line_tbl_type(i).request_date, FND_API.G_MISS_DATE)
6497             THEN
6498                x_line_tbl(l_line_cnt).request_date := p_details_interface_rec_tab(i).date_requested;
6499             END IF;
6500 
6501             IF p_details_interface_rec_tab(i).date_scheduled is null
6502             THEN
6503                x_line_tbl(l_line_cnt).schedule_ship_date := p_om_line_tbl_type(i).schedule_ship_date;
6504             ELSIF p_details_interface_rec_tab(i).date_scheduled <>
6505                          nvl(p_om_line_tbl_type(i).schedule_ship_date, FND_API.G_MISS_DATE)
6506             THEN
6507                x_line_tbl(l_line_cnt).schedule_ship_date := p_details_interface_rec_tab(i).date_scheduled;
6508             END IF;
6509 
6510             IF nvl(p_details_interface_rec_tab(i).shipment_priority_code, FND_API.G_MISS_CHAR) <>
6511                nvl(p_om_line_tbl_type(i).shipment_priority_code, FND_API.G_MISS_CHAR)
6512             THEN
6513                x_line_tbl(l_line_cnt).shipment_priority_code   := p_details_interface_rec_tab(i).shipment_priority_code;
6514             END IF;
6515 
6516             IF nvl(p_details_interface_rec_tab(i).cust_po_number, FND_API.G_MISS_CHAR) <>
6517                nvl(p_om_line_tbl_type(i).cust_po_number, FND_API.G_MISS_CHAR)
6518             THEN
6519                x_line_tbl(l_line_cnt).cust_po_number   := p_details_interface_rec_tab(i).cust_po_number;
6520             END IF;
6521 
6522             IF nvl(p_details_interface_rec_tab(i).subinventory, FND_API.G_MISS_CHAR) <>
6523                nvl(p_om_line_tbl_type(i).subinventory, FND_API.G_MISS_CHAR)
6524             THEN
6525                x_line_tbl(l_line_cnt).subinventory   := p_details_interface_rec_tab(i).subinventory;
6526             END IF;
6527 
6528             IF nvl(p_details_interface_rec_tab(i).unit_selling_price, FND_API.G_MISS_NUM) <>
6529                nvl(p_om_line_tbl_type(i).unit_selling_price, FND_API.G_MISS_NUM)
6530             THEN
6531                x_line_tbl(l_line_cnt).unit_selling_price   := p_details_interface_rec_tab(i).unit_selling_price;
6532             END IF;
6533 
6534             -- Inventory item cannot be changed on booked order line. OM PO api will error out
6535             -- if Item is being changed for booked order line.
6536             -- While fixing any bugs in future, shipping should error out wihtout calling OM api
6537             -- if Item is being changed on booked sales order line.
6538             IF nvl(p_details_interface_rec_tab(i).inventory_item_id, FND_API.G_MISS_NUM) <>
6539                nvl(p_om_line_tbl_type(i).inventory_item_id, FND_API.G_MISS_NUM)
6540             THEN
6541                x_line_tbl(l_line_cnt).inventory_item_id := p_details_interface_rec_tab(i).inventory_item_id;
6542             END IF;
6543 
6544             -- Do not pass NULL value to ordered_item_id, if customer_item_id derived from
6545             -- Interface table is NULL. If NULL value is passed then OM triggers re-pricing.
6546             -- Refer bug 7648864 for more details.
6547             IF p_details_interface_rec_tab(i).customer_item_id is not null and
6548                ( p_details_interface_rec_tab(i).customer_item_id <>
6549                  nvl(p_om_line_tbl_type(i).ordered_item_id, FND_API.G_MISS_NUM) )
6550             THEN
6551                x_line_tbl(l_line_cnt).ordered_item_id := p_details_interface_rec_tab(i).customer_item_id;
6552             END IF;
6553 
6554          ELSIF ( l_line_id is null ) THEN /* Line Create Mode */
6555             -- LSP PROJECT.
6556             SELECT oe_order_lines_S.NEXTVAL into l_line_id from dual;
6557             x_line_tbl(l_line_cnt).line_id    := l_line_id;
6558             -- LSP PROJECT : end
6559             x_line_tbl(l_line_cnt).operation              := OE_GLOBALS.G_OPR_CREATE;
6560             x_line_tbl(l_line_cnt).calculate_price_flag   := 'N';
6561             x_line_tbl(l_line_cnt).line_number            := p_details_interface_rec_tab(i).line_number;
6562             x_line_tbl(l_line_cnt).shipment_number        := 1;
6563             x_line_tbl(l_line_cnt).inventory_item_id      := p_details_interface_rec_tab(i).inventory_item_id;
6564             x_line_tbl(l_line_cnt).ordered_quantity       := p_details_interface_rec_tab(i).requested_quantity;
6565             x_line_tbl(l_line_cnt).order_quantity_uom     := p_details_interface_rec_tab(i).requested_quantity_uom;
6566 
6567             IF p_details_interface_rec_tab(i).customer_item_id is not null THEN
6568                x_line_tbl(l_line_cnt).ordered_item_id      := p_details_interface_rec_tab(i).customer_item_id;
6569                x_line_tbl(l_line_cnt).item_identifier_type := 'CUST';
6570             END IF;
6571             --USP and ULP is mandatory for booking sales order
6572             x_line_tbl(l_line_cnt).unit_selling_price     := nvl(p_details_interface_rec_tab(i).unit_selling_price, 0);
6573             x_line_tbl(l_line_cnt).unit_list_price        := x_line_tbl(l_line_cnt).unit_selling_price;
6574             x_line_tbl(l_line_cnt).ship_tolerance_above   := p_details_interface_rec_tab(i).ship_tolerance_above;
6575             x_line_tbl(l_line_cnt).ship_tolerance_below   := p_details_interface_rec_tab(i).ship_tolerance_below;
6576             x_line_tbl(l_line_cnt).request_date           := nvl(p_details_interface_rec_tab(i).date_requested, SYSDATE);
6577             x_line_tbl(l_line_cnt).schedule_ship_date     := p_details_interface_rec_tab(i).date_scheduled;
6578             x_line_tbl(l_line_cnt).packing_instructions   := p_details_interface_rec_tab(i).packing_instructions;
6579             x_line_tbl(l_line_cnt).shipping_instructions  := p_details_interface_rec_tab(i).shipping_instructions;
6580             x_line_tbl(l_line_cnt).shipment_priority_code := p_details_interface_rec_tab(i).shipment_priority_code;
6581             x_line_tbl(l_line_cnt).ship_set               := p_details_interface_rec_tab(i).ship_set_name;
6582             x_line_tbl(l_line_cnt).cust_po_number         := p_details_interface_rec_tab(i).cust_po_number;
6583             x_line_tbl(l_line_cnt).subinventory           := p_details_interface_rec_tab(i).subinventory;
6584             x_line_tbl(l_line_cnt).ship_from_org_id       := p_delivery_interface_rec.organization_id;
6585          END IF;
6586          -- LSP PROJECT: Begin
6587          x_line_tbl(l_line_cnt).orig_sys_document_ref   := p_details_interface_rec_tab(i).source_header_number;
6588          x_line_tbl(l_line_cnt).orig_sys_line_ref       := p_details_interface_rec_tab(i).source_line_number;
6589          --
6590          /* Used for Error logging when PO api errors out */
6591          x_line_details_tbl(MOD(l_line_id,G_BINARY_LIMIT)) := p_details_interface_rec_tab(i).delivery_detail_interface_id;
6592          -- LSP PROJECT: end
6593 
6594          <<zero_req_quantity>>
6595             null;
6596       END LOOP;
6597    END IF; -- } Interface records
6598 
6599    l_line_cnt := x_line_tbl.count;
6600 
6601    IF p_om_header_rec_type.header_attributes_changed
6602    THEN -- { Non-Interface Order Lines
6603       FOR l_non_interface_rec in c_non_interface_order_lines
6604       LOOP
6605          IF l_debug_on THEN
6606             WSH_DEBUG_SV.logmsg(l_module_name, 'Non-Interface details, Line Id => ' || l_non_interface_rec.line_id
6607                                    || ', Line Number => ' || l_non_interface_rec.line_number );
6608          END IF;
6609          l_line_cnt := l_line_cnt + 1;
6610          x_line_tbl(l_line_cnt)                 := OE_ORDER_PUB.G_MISS_LINE_REC;
6611          x_line_tbl(l_line_cnt).operation       := OE_GLOBALS.G_OPR_UPDATE;
6612          x_line_tbl(l_line_cnt).line_id         := l_non_interface_rec.line_id;
6613          x_line_tbl(l_line_cnt).calculate_price_flag    := 'N';
6614          -- LSP PROJECT: commented the following after discussion with UMA.
6615          -- No need to change these values on the existing lines.
6616          /*x_line_tbl(l_line_cnt).orig_sys_document_ref   := 'SHIPMENT_REQUEST' || p_delivery_interface_rec.order_number;
6617          x_line_tbl(l_line_cnt).orig_sys_line_ref       := 'SHIPMENT_REQUEST_LINE' || l_non_interface_rec.line_number;*/
6618          -- LSP PROJECT: end
6619       END LOOP;
6620    END IF; -- } Non-Interface Order Lines
6621 
6622    --
6623    IF l_debug_on THEN
6624       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
6625       WSH_DEBUG_SV.pop(l_module_name);
6626    END IF;
6627    --
6628 EXCEPTION
6629    WHEN OTHERS THEN
6630          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6631          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Populate_Line_Records');
6632          --
6633          IF l_debug_on THEN
6634            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6635            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6636          END IF;
6637          --
6638 END Populate_Line_Records;
6639 --
6640 --=============================================================================
6641 -- PUBLIC PROCEDURE :
6642 --       Validate_Organization
6643 --
6644 -- PARAMETERS:
6645 --       p_org_code        => Organization Code
6646 --       p_organization_id => Organization Id
6647 --       x_return_status   => Return Status of API (Either S,E,U)
6648 --
6649 -- COMMENT:
6650 --       API to validate organization id/code passed. Organization should
6651 --       be WMS enabled and NOT Process manufacturing enabled.
6652 --=============================================================================
6653 --
6654 PROCEDURE Validate_Organization(
6655           p_org_code         IN VARCHAR2,
6656           p_organization_id  IN OUT NOCOPY NUMBER,
6657           x_return_status    OUT NOCOPY VARCHAR2 )
6658 IS
6659 
6660    l_organization_code          VARCHAR2(3);
6661    l_return_status              VARCHAR2(1);
6662    --
6663    l_debug_on BOOLEAN;
6664    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Validate_Organization';
6665    --
6666 BEGIN
6667    --Debug Push
6668    --
6669    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6670    --
6671    IF l_debug_on IS NULL THEN
6672       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6673    END IF;
6674    --
6675    IF l_debug_on THEN
6676       WSH_DEBUG_SV.push(l_module_name);
6677       WSH_DEBUG_SV.log(l_module_name, 'p_organization_id', p_organization_id);
6678       WSH_DEBUG_SV.log(l_module_name, 'p_org_code', p_org_code);
6679    END IF;
6680    --
6681 
6682    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6683 
6684    IF ( p_org_code is not null or p_organization_id is not null )
6685    THEN
6686       --Validate Organization Code from Interface table
6687       IF p_organization_id is not null THEN
6688          l_organization_code := null;
6689       ELSE
6690          l_organization_code := p_org_code;
6691       END IF;
6692 
6693       --
6694       IF l_debug_on THEN
6695          wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_VALIDATE.Validate_Org', WSH_DEBUG_SV.C_PROC_LEVEL);
6696       END IF;
6697       --
6698       WSH_UTIL_VALIDATE.Validate_Org (
6699                         p_org_id        => p_organization_id,
6700                         p_org_code      => l_organization_code,
6701                         x_return_status => l_return_status );
6702 
6703       --
6704       IF l_debug_on THEN
6705          wsh_debug_sv.log(l_module_name, 'Return Status', l_return_status);
6706          wsh_debug_sv.logmsg(l_module_name, 'Organization Id => ' || p_organization_id
6707                                      || ', Organization Code => ' || l_organization_code );
6708       END IF;
6709       --
6710 
6711       IF ( l_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS )
6712       THEN
6713          --
6714          IF l_debug_on THEN
6715             wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_VALIDATE.Validate_SR_Organization', WSH_DEBUG_SV.C_PROC_LEVEL);
6716          END IF;
6717          --
6718          WSH_UTIL_VALIDATE.Validate_SR_Organization(
6719                            p_organization_id => p_organization_id,
6720                            x_return_status   => l_return_status );
6721 
6722          --
6723          IF l_debug_on THEN
6724             wsh_debug_sv.log(l_module_name, 'Validate_SR_Organization Return Status', l_return_status);
6725          END IF;
6726          --
6727 
6728       END IF;
6729 
6730       IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
6731          x_return_status := l_return_status;
6732       END IF;
6733    ELSE
6734       --
6735       IF l_debug_on THEN
6736          wsh_debug_sv.logmsg(l_module_name, 'Error: Organization information is missing.');
6737       END IF;
6738       --
6739       x_return_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
6740       FND_MESSAGE.Set_Name('WSH', 'WSH_REQUIRED_FIELD_NULL');
6741       FND_MESSAGE.Set_Token('FIELD_NAME', 'ORGANIZATION');
6742       WSH_UTIL_CORE.Add_Message(x_return_status, l_module_name );
6743    END IF;
6744 
6745    --
6746    IF l_debug_on THEN
6747       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
6748       WSH_DEBUG_SV.pop(l_module_name);
6749    END IF;
6750    --
6751 EXCEPTION
6752 WHEN OTHERS THEN
6753       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6754       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Validate_Organization');
6755       --
6756       IF l_debug_on THEN
6757         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6758         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6759       END IF;
6760       --
6761 END Validate_Organization;
6762 --
6763 --=============================================================================
6764 -- PUBLIC PROCEDURE :
6765 --       Validate_Ship_Method
6766 --
6767 -- PARAMETERS:
6768 --       p_carrier_code      => Freight Code
6769 --       p_organization_id   => Organization id
6770 --       p_service_level     => Service Level
6771 --       p_mode_of_transport => Mode of Transport
6772 --       x_ship_method_code  => Ship Method Code derived
6773 --       x_return_status     => Return Status of API (Either S,E,U)
6774 --
6775 -- COMMENT:
6776 --       API to validate lookups Service Level and Mode of Transaport. Derives
6777 --       Ship Method code based on Carrier Id, Service Level, Mode of transport
6778 --       and Organization passed.
6779 --=============================================================================
6780 --
6781 PROCEDURE Validate_Ship_Method(
6782           p_carrier_code      IN  VARCHAR2,
6783           p_organization_id   IN  NUMBER,
6784           p_service_level     IN  VARCHAR2,
6785           p_mode_of_transport IN  VARCHAR2,
6786           x_ship_method_code  OUT NOCOPY VARCHAR2,
6787           x_return_status     OUT NOCOPY VARCHAR2 )
6788 IS
6789    l_return_status              VARCHAR2(1);
6790    l_service_level              VARCHAR2(30);
6791    l_mode_of_transport          VARCHAR2(30);
6792 
6793    --
6794    l_debug_on BOOLEAN;
6795    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Validate_Ship_Method';
6796    --
6797 BEGIN
6798    --Debug Push
6799    --
6800    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6801    --
6802    IF l_debug_on IS NULL THEN
6803       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6804    END IF;
6805    --
6806    IF l_debug_on THEN
6807       WSH_DEBUG_SV.push(l_module_name);
6808       WSH_DEBUG_SV.log(l_module_name, 'p_carrier_code', p_carrier_code);
6809       WSH_DEBUG_SV.log(l_module_name, 'p_service_level', p_service_level);
6810       WSH_DEBUG_SV.log(l_module_name, 'p_mode_of_transport', p_mode_of_transport);
6811       WSH_DEBUG_SV.log(l_module_name, 'p_organization_id', p_organization_id);
6812    END IF;
6813    --
6814 
6815    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6816 
6817    --
6818    IF l_debug_on THEN
6819       wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_VALIDATE.Validate_Lookup', WSH_DEBUG_SV.C_PROC_LEVEL);
6820    END IF;
6821    --
6822    l_service_level := p_service_level;
6823 
6824    WSH_UTIL_VALIDATE.Validate_Lookup(
6825             p_lookup_type   => 'WSH_SERVICE_LEVELS',
6826             p_lookup_code   => l_service_level,
6827             p_meaning       => null,
6828             x_return_status => l_return_status );
6829 
6830    IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
6831       --
6832       IF l_debug_on THEN
6833          wsh_debug_sv.logmsg(l_module_name, 'Error occured in Validate_Lookup(SL)', WSH_DEBUG_SV.C_ERR_LEVEL);
6834       END IF;
6835       --
6836       x_return_status := l_return_status;
6837    END IF;
6838 
6839    --
6840    IF l_debug_on THEN
6841       wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_VALIDATE.Validate_Lookup', WSH_DEBUG_SV.C_PROC_LEVEL);
6842    END IF;
6843    --
6844 
6845    l_mode_of_transport := p_mode_of_transport;
6846 
6847    WSH_UTIL_VALIDATE.Validate_Lookup(
6848             p_lookup_type   => 'WSH_MODE_OF_TRANSPORT',
6849             p_lookup_code   => l_mode_of_transport,
6850             p_meaning       => null,
6851             x_return_status => l_return_status );
6852 
6853    IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
6854       --
6855       IF l_debug_on THEN
6856          wsh_debug_sv.logmsg(l_module_name, 'Error occured in Validate_Lookup(MOT)', WSH_DEBUG_SV.C_ERR_LEVEL);
6857       END IF;
6858       --
6859       x_return_status := l_return_status;
6860    END IF;
6861 
6862    IF x_return_status = WSH_UTIL_CORE.G_RET_STS_SUCCESS and
6863       p_organization_id is not null
6864    THEN
6865       --
6866       IF l_debug_on THEN
6867          wsh_debug_sv.logmsg(l_module_name, 'Calling api WSH_UTIL_VALIDATE.Validate_Ship_Method', WSH_DEBUG_SV.C_PROC_LEVEL);
6868       END IF;
6869       --
6870       WSH_UTIL_VALIDATE.Validate_Ship_Method(
6871                p_organization_id   => p_organization_id,
6872                p_carrier_code      => p_carrier_code,
6873                p_service_level     => p_service_level,
6874                p_mode_of_transport => p_mode_of_transport,
6875                x_ship_method_code  => x_ship_method_code,
6876                x_return_status     => l_return_status );
6877 
6878       IF ( l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS ) THEN
6879          --
6880          IF l_debug_on THEN
6881             wsh_debug_sv.logmsg(l_module_name, 'Error occured in Validate_Ship_Method', WSH_DEBUG_SV.C_ERR_LEVEL);
6882          END IF;
6883          --
6884          x_return_status := l_return_status;
6885       END IF;
6886    END IF;
6887 
6888    --
6889    IF l_debug_on THEN
6890       WSH_DEBUG_SV.logmsg(l_module_name, 'Ship Method is '||x_ship_method_code);
6891       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
6892       WSH_DEBUG_SV.pop(l_module_name);
6893    END IF;
6894    --
6895 EXCEPTION
6896 WHEN OTHERS THEN
6897       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6898       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Validate_Ship_Method');
6899       --
6900       IF l_debug_on THEN
6901         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6902         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6903       END IF;
6904       --
6905 END Validate_Ship_Method;
6906 --
6907 --=============================================================================
6908 -- PRIVATE PROCEDURE :
6909 --       Populate_Error_Records
6910 --
6911 -- PARAMETERS:
6912 --       p_interface_id             => Interface Id (Delivery_Interface_Id or Delivery_Detail_Interface_Id)
6913 --       p_interface_table_name     => Interface Table Name( WNDI or WDDI)
6914 --       x_interface_errors_rec_tab => Table of Interface Error records
6915 --       x_return_status            => Return Status of API (Either S,U)
6916 --
6917 -- COMMENT:
6918 --       Populates error messages set in stack to x_interface_errors_rec_tab
6919 --=============================================================================
6920 --
6921 PROCEDURE Populate_Error_Records(
6922           p_interface_id             IN  NUMBER,
6923           p_interface_table_name     IN  VARCHAR2,
6924           x_interface_errors_rec_tab IN OUT NOCOPY WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_tab,
6925           x_return_status            OUT NOCOPY VARCHAR2 )
6926 IS
6927    l_error_count                NUMBER;
6928    l_msg_count                  NUMBER;
6929 
6930    --
6931    l_debug_on BOOLEAN;
6932    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Populate_Error_Records';
6933    --
6934 BEGIN
6935    --Debug Push
6936    --
6937    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
6938    --
6939    IF l_debug_on IS NULL THEN
6940       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
6941    END IF;
6942    --
6943    IF l_debug_on THEN
6944       WSH_DEBUG_SV.push(l_module_name);
6945       WSH_DEBUG_SV.log(l_module_name, 'p_interface_id', p_interface_id);
6946       WSH_DEBUG_SV.log(l_module_name, 'p_interface_table_name', p_interface_table_name);
6947       WSH_DEBUG_SV.log(l_module_name, 'x_interface_errors_rec_tab.count', x_interface_errors_rec_tab.count);
6948    END IF;
6949    --
6950 
6951    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
6952    l_error_count := x_interface_errors_rec_tab.count;
6953    l_msg_count   := FND_MSG_PUB.count_msg;
6954    --
6955    IF l_debug_on THEN
6956       WSH_DEBUG_SV.log(l_module_name, 'FND_MSG_PUB.count_msg', l_msg_count);
6957    END IF;
6958    --
6959 
6960    IF l_msg_count > 0 THEN
6961       FOR i in 1..l_msg_count
6962       LOOP
6963          l_error_count := l_error_count + 1;
6964          x_interface_errors_rec_tab(l_error_count).p_interface_table_name := p_interface_table_name;
6965          x_interface_errors_rec_tab(l_error_count).p_interface_id := p_interface_id;
6966          x_interface_errors_rec_tab(l_error_count).p_text := FND_MSG_PUB.Get(i, FND_API.G_FALSE);
6967       END LOOP;
6968    END IF;
6969 
6970    FND_MSG_PUB.initialize;
6971 
6972    --
6973    IF l_debug_on THEN
6974       WSH_DEBUG_SV.log(l_module_name, 'x_interface_errors_rec_tab.count', x_interface_errors_rec_tab.count);
6975       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
6976       WSH_DEBUG_SV.pop(l_module_name);
6977    END IF;
6978    --
6979 EXCEPTION
6980 WHEN OTHERS THEN
6981       x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
6982       WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Populate_Error_Records');
6983       --
6984       IF l_debug_on THEN
6985         WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
6986         WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
6987       END IF;
6988       --
6989 END Populate_Error_Records;
6990 --
6991 --=============================================================================
6992 -- PUBLIC PROCEDURE :
6993 --       Validate_Interface_Details
6994 --
6995 -- PARAMETERS:
6996 --       p_details_interface_tab    => Table of Delivery Detail Interface record
6997 --       x_interface_errors_rec_tab => Table of Interface Error records
6998 --       x_return_status            => Return Status of API (Either S,E,U)
6999 --
7000 -- COMMENT:
7001 --       API to validate Inventory attributes like revision, locator.
7002 --       Inventory attributes cannot be changed if delivery line corresponding
7003 --       to shipment line is picked or in a confirmed delivery or has been shipped.
7004 --       Schedule dates cannot be changed if delivery line corresponding to
7005 --       shipment line is in a confirmed delivery or has been shipped.
7006 --=============================================================================
7007 --
7008 PROCEDURE Validate_Interface_Details(
7009           p_details_interface_tab IN OUT NOCOPY Del_Details_Interface_Rec_Tab,
7010           x_interface_error_tab   OUT NOCOPY WSH_INTERFACE_VALIDATIONS_PKG.interface_errors_rec_tab,
7011           x_return_status         OUT NOCOPY VARCHAR2 )
7012 IS
7013 
7014    CURSOR c_delivery_details_info(c_line_id NUMBER)
7015    IS
7016    SELECT wdd.delivery_detail_id,
7017           wdd.original_subinventory,
7018           wdd.original_lot_number,
7019           wdd.original_revision,
7020           wdd.original_locator_id,
7021           wdd.organization_id,
7022           wdd.inventory_item_id,
7023           wdd.earliest_pickup_date,
7024           wdd.latest_pickup_date,
7025           wdd.earliest_dropoff_date,
7026           wdd.latest_dropoff_date,
7027           wdd.source_line_id,
7028           wdd.reference_number,
7029           wdd.reference_line_number,
7030           wdd.reference_line_quantity,
7031           wdd.reference_line_quantity_uom,
7032           wdd.rowid
7033    FROM   Wsh_Delivery_Details wdd
7034    WHERE  wdd.source_code = 'OE'
7035    AND    wdd.source_line_id = c_line_id
7036    AND    ROWNUM = 1;
7037 
7038    l_delivery_details_rec       c_delivery_details_info%rowtype;
7039    l_return_status              VARCHAR2(1);
7040    l_changed_flag               VARCHAR2(1);
7041    l_tmp                        VARCHAR2(1);
7042    l_temp_status                VARCHAR2(1);
7043    l_line_id                    NUMBER;
7044    l_inv_control_changed        BOOLEAN;
7045    l_inv_result                 BOOLEAN;
7046 
7047    --
7048    l_debug_on BOOLEAN;
7049    l_module_name CONSTANT VARCHAR2(100) := 'wsh.plsql.' || G_PKG_NAME || '.' || 'Validate_Interface_Details';
7050    --
7051 BEGIN
7052    --
7053    l_debug_on := WSH_DEBUG_INTERFACE.g_debug;
7054    --
7055    IF l_debug_on IS NULL THEN
7056       l_debug_on := WSH_DEBUG_SV.is_debug_enabled;
7057    END IF;
7058    --
7059    IF l_debug_on THEN
7060       WSH_DEBUG_SV.push(l_module_name);
7061       WSH_DEBUG_SV.log(l_module_name, 'p_details_interface_tab.count', p_details_interface_tab.count);
7062    END IF;
7063    --
7064 
7065    x_return_status := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7066 
7067    FOR i in p_details_interface_tab.first..p_details_interface_tab.last
7068    LOOP --{
7069       l_temp_status  := WSH_UTIL_CORE.G_RET_STS_SUCCESS;
7070       l_changed_flag := 'N';
7071       l_inv_control_changed := FALSE;
7072       l_line_id := p_details_interface_tab(i).line_id;
7073       p_details_interface_tab(i).schedule_date_changed := 'N';
7074 
7075       --
7076       IF l_debug_on THEN
7077          WSH_DEBUG_SV.logmsg(l_module_name, 'delivery_interface_id => ' || p_details_interface_tab(i).delivery_detail_interface_id
7078                                      || ', Line Id => ' || l_line_id );
7079       END IF;
7080       --
7081 
7082       -- No validation to be performed if line is cancelled
7083       IF p_details_interface_tab(i).requested_quantity = 0 THEN
7084          --
7085          IF l_debug_on THEN
7086             WSH_DEBUG_SV.logmsg(l_module_name, 'Line Number ' || p_details_interface_tab(i).line_number
7087                          || ' is cancelled, so skipping complete interface detail validation......' );
7088          END IF;
7089          --
7090          goto end_loop;
7091       END IF;
7092 
7093       IF l_line_id is null THEN --{
7094          l_changed_flag := 'Y';
7095          p_details_interface_tab(i).changed_flag := l_changed_flag;
7096          p_details_interface_tab(i).schedule_date_changed := 'Y';
7097       ELSE
7098          OPEN  c_delivery_details_info(l_line_id);
7099          FETCH c_delivery_details_info into l_delivery_details_rec;
7100          IF c_delivery_details_info%NOTFOUND THEN
7101             --
7102             IF l_debug_on THEN
7103                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: For order line ' || l_line_id
7104                             || ', delivery detail does not exist in WDD table' );
7105             END IF;
7106             --
7107             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7108             -- Modified Message Name while fixing bug 8452056.
7109             WSH_UTIL_CORE.Add_Message(l_temp_status, 'NO_DATA_FOUND');
7110             goto end_loop;
7111          END IF;
7112          CLOSE c_delivery_details_info;
7113 
7114          -- Schedule Date Changes
7115          IF (    ( nvl(p_details_interface_tab(i).earliest_pickup_date, FND_API.G_MISS_DATE ) <>
7116                    nvl(l_delivery_details_rec.earliest_pickup_date, FND_API.G_MISS_DATE ) )
7117               OR ( nvl(p_details_interface_tab(i).earliest_dropoff_date, FND_API.G_MISS_DATE ) <>
7118                    nvl(l_delivery_details_rec.earliest_dropoff_date, FND_API.G_MISS_DATE ) )
7119               OR ( nvl(p_details_interface_tab(i).latest_pickup_date, FND_API.G_MISS_DATE ) <>
7120                    nvl(l_delivery_details_rec.latest_pickup_date, FND_API.G_MISS_DATE ) )
7121               OR ( nvl(p_details_interface_tab(i).latest_dropoff_date, FND_API.G_MISS_DATE ) <>
7122                    nvl(l_delivery_details_rec.latest_dropoff_date, FND_API.G_MISS_DATE ) )
7123             )
7124          THEN
7125             l_changed_flag := 'Y';
7126             p_details_interface_tab(i).schedule_date_changed := 'Y';
7127 
7128             BEGIN
7129                select 'x'
7130                into   l_tmp
7131                from   wsh_delivery_details wdd
7132                where  source_code = 'OE'
7133                and    source_line_id = l_line_id
7134                and    released_status in ( 'Y', 'C' )
7135                and    exists
7136                     ( select 'y'
7137                       from   wsh_delivery_assignments wda,
7138                              wsh_new_deliveries       wnd
7139                       where  wnd.status_code in ( 'CO', 'IT', 'CL' )
7140                       and    wnd.delivery_id = wda.delivery_id
7141                       and    wda.delivery_detail_id = wdd.delivery_detail_id )
7142                and    rownum = 1;
7143             EXCEPTION
7144             WHEN NO_DATA_FOUND THEN
7145                l_tmp := null;
7146             END;
7147 
7148             IF l_tmp is not null THEN
7149                --
7150                IF l_debug_on THEN
7151                   WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Schedule dates cannot be changed.');
7152                END IF;
7153                --
7154                l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7155                FND_MESSAGE.Set_Name('WSH', 'WSH_STND_REJ_SCH_DATE_CHANGE');
7156                WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
7157                goto end_loop;
7158             END IF;
7159          END IF;
7160 
7161          -- Reference Information Changes.
7162          IF (
7163               (  nvl(p_details_interface_tab(i).source_line_number, FND_API.G_MISS_CHAR) <>
7164                  nvl(l_delivery_details_rec.reference_line_number, FND_API.G_MISS_CHAR) ) OR
7165               (  nvl(p_details_interface_tab(i).source_header_number, FND_API.G_MISS_CHAR) <>
7166                  nvl(l_delivery_details_rec.reference_number, FND_API.G_MISS_CHAR) ) OR
7167               (  nvl(p_details_interface_tab(i).src_requested_quantity, FND_API.G_MISS_NUM) <>
7168                  nvl(l_delivery_details_rec.reference_line_quantity, FND_API.G_MISS_NUM) ) OR
7169               (  nvl(p_details_interface_tab(i).src_requested_quantity_uom, FND_API.G_MISS_CHAR) <>
7170                  nvl(l_delivery_details_rec.reference_line_quantity_uom, FND_API.G_MISS_CHAR) )
7171             )
7172          THEN
7173             l_changed_flag := 'Y';
7174          END IF;
7175       END IF; --}
7176 
7177       -- Inventory Control Validation Starts
7178       IF p_details_interface_tab(i).locator_id is null and
7179          p_details_interface_tab(i).locator_code is not null
7180       THEN
7181          --
7182          IF l_debug_on THEN
7183             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_UTIL_VALIDATE.Validate_Locator_Code', WSH_DEBUG_SV.C_PROC_LEVEL);
7184          END IF;
7185          --
7186          WSH_UTIL_VALIDATE.Validate_Locator_Code(
7187                 p_locator_code    => p_details_interface_tab(i).locator_code,
7188                 p_organization_id => p_details_interface_tab(i).organization_id,
7189                 x_locator_id      => p_details_interface_tab(i).locator_id,
7190                 x_return_status   => l_return_status );
7191 
7192          IF l_return_status <> WSH_UTIL_CORE.G_RET_STS_SUCCESS or
7193             p_details_interface_tab(i).locator_id is null
7194          THEN
7195             --
7196             IF l_debug_on THEN
7197                wsh_debug_sv.logmsg(l_module_name, 'Error occured in Validate_Locator_Code', WSH_DEBUG_SV.C_ERR_LEVEL);
7198             END IF;
7199             --
7200             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7201             goto end_loop;
7202          END IF;
7203       END IF;
7204 
7205       IF ( (  l_line_id is not null ) AND
7206            (  nvl(p_details_interface_tab(i).revision, FND_API.G_MISS_CHAR) <>
7207               nvl(l_delivery_details_rec.original_revision, FND_API.G_MISS_CHAR) ) OR
7208            (  nvl(p_details_interface_tab(i).locator_id, FND_API.G_MISS_NUM) <>
7209               nvl(l_delivery_details_rec.original_locator_id, FND_API.G_MISS_NUM) ) OR
7210            (  nvl(p_details_interface_tab(i).lot_number, FND_API.G_MISS_CHAR) <>
7211               nvl(l_delivery_details_rec.original_lot_number, FND_API.G_MISS_CHAR) )
7212          )
7213       THEN
7214          l_changed_flag := 'Y';
7215          l_inv_control_changed := TRUE;
7216 
7217          BEGIN
7218             select 'x'
7219             into   l_tmp
7220             from   wsh_delivery_details
7221             where  source_code = 'OE'
7222             and    source_line_id = l_line_id
7223             and    released_status in ( 'S', 'Y', 'C' )
7224             and    rownum = 1;
7225          EXCEPTION
7226          WHEN NO_DATA_FOUND THEN
7227             l_tmp := null;
7228          END;
7229 
7230          IF l_tmp is not null THEN
7231             --
7232             IF l_debug_on THEN
7233                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Inventory attributes cannot be changed.');
7234             END IF;
7235             --
7236             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7237             FND_MESSAGE.Set_Name('WSH', 'WSH_STND_REJ_INV_CTRL_CHANGE');
7238             WSH_UTIL_CORE.Add_Message(WSH_UTIL_CORE.G_RET_STS_ERROR, l_module_name );
7239             goto end_loop;
7240          END IF;
7241       END IF;
7242 
7243       --Revision validation begins
7244       IF ( ( l_inv_control_changed and
7245              p_details_interface_tab(i).revision is not null ) OR
7246            ( l_line_id is null AND
7247              p_details_interface_tab(i).revision is not null ) )
7248       THEN
7249          --
7250          IF l_debug_on THEN
7251             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_DELIVERY_DETAILS_INV.Validate_Revision', WSH_DEBUG_SV.C_PROC_LEVEL);
7252          END IF;
7253          --
7254 
7255          WSH_DELIVERY_DETAILS_INV.Validate_Revision(
7256              p_revision          => p_details_interface_tab(i).revision,
7257              p_organization_id   => p_details_interface_tab(i).organization_id,
7258              p_inventory_item_id => p_details_interface_tab(i).inventory_item_id,
7259              x_return_status     => l_return_status,
7260              x_result            => l_inv_result );
7261 
7262          --
7263          IF l_debug_on THEN
7264              WSH_DEBUG_SV.log(l_module_name, 'Result after validate revision', l_inv_result);
7265              WSH_DEBUG_SV.log(l_module_name, 'Return status after validate revision', l_return_status);
7266          END IF;
7267          --
7268 
7269          IF NOT l_inv_result THEN
7270             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7271             WSH_UTIL_CORE.Add_Message(l_temp_status, 'WSH_INVALID_REVISION');
7272             --
7273             IF l_debug_on THEN
7274                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Invalid Revision');
7275             END IF;
7276             --
7277          END IF;
7278       END IF;
7279 
7280       IF ( ( l_inv_control_changed and
7281              p_details_interface_tab(i).locator_id is not null ) OR
7282            ( l_line_id is null AND
7283              p_details_interface_tab(i).locator_id is not null ) )
7284       THEN
7285          --
7286          IF l_debug_on THEN
7287             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_DELIVERY_DETAILS_INV.Validate_Locator', WSH_DEBUG_SV.C_PROC_LEVEL);
7288          END IF;
7289          --
7290 
7291          WSH_DELIVERY_DETAILS_INV.Validate_Locator(
7292              p_locator_id        => p_details_interface_tab(i).locator_id,
7293              p_inventory_item_id => p_details_interface_tab(i).inventory_item_id,
7294              p_organization_id   => p_details_interface_tab(i).organization_id,
7295              p_subinventory      => p_details_interface_tab(i).subinventory,
7296              x_return_status     => l_return_status,
7297              x_result            => l_inv_result );
7298 
7299          --
7300          IF l_debug_on THEN
7301              WSH_DEBUG_SV.log(l_module_name, 'Result after validate locator', l_inv_result);
7302              WSH_DEBUG_SV.log(l_module_name, 'Return status after validate locator', l_return_status);
7303          END IF;
7304          --
7305 
7306          IF NOT l_inv_result THEN
7307             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7308             WSH_UTIL_CORE.Add_Message(l_temp_status, 'WSH_INVALID_LOCATOR');
7309             --
7310             IF l_debug_on THEN
7311                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Invalid Locator');
7312             END IF;
7313             --
7314          END IF;
7315       END IF;
7316 
7317       /* 1/21/2009 : Validation for lot number removed as the material could
7318          be received in the lot before Pick Release
7319 
7320       IF ( ( l_inv_control_changed and
7321              p_details_interface_tab(i).lot_number is not null ) OR
7322            ( l_line_id is null AND
7323              p_details_interface_tab(i).lot_number is not null ) )
7324       THEN
7325          --
7326          IF l_debug_on THEN
7327             WSH_DEBUG_SV.logmsg(l_module_name, 'Calling WSH_DELIVERY_DETAILS_INV.Validate_Lot_Number', WSH_DEBUG_SV.C_PROC_LEVEL);
7328          END IF;
7329          --
7330 
7331          WSH_DELIVERY_DETAILS_INV.Validate_Lot_Number(
7332              p_lot_number        => p_details_interface_tab(i).lot_number,
7333              p_organization_id   => p_details_interface_tab(i).organization_id,
7334              p_inventory_item_id => p_details_interface_tab(i).inventory_item_id,
7335              p_subinventory      => p_details_interface_tab(i).subinventory,
7336              p_revision          => p_details_interface_tab(i).revision,
7337              p_locator_id        => p_details_interface_tab(i).locator_id,
7338              x_return_status     => l_return_status,
7339              x_result            => l_inv_result );
7340 
7341          --
7342          IF l_debug_on THEN
7343              WSH_DEBUG_SV.log(l_module_name, 'Result after validate lot', l_inv_result);
7344              WSH_DEBUG_SV.log(l_module_name, 'Return status after validate lot', l_return_status);
7345          END IF;
7346          --
7347 
7348          IF NOT l_inv_result THEN
7349             l_temp_status := WSH_UTIL_CORE.G_RET_STS_ERROR;
7350             WSH_UTIL_CORE.Add_Message(l_temp_status, 'WSH_INVALID_LOT');
7351             --
7352             IF l_debug_on THEN
7353                WSH_DEBUG_SV.logmsg(l_module_name, 'Error: Invalid Lot Number');
7354             END IF;
7355             --
7356          END IF;
7357       END IF;
7358       */
7359       --Inventory Control validation ends
7360 
7361       p_details_interface_tab(i).changed_flag := l_changed_flag;
7362 
7363       --
7364       IF l_debug_on THEN
7365          WSH_DEBUG_SV.logmsg(l_module_name, 'changed_flag => ' || p_details_interface_tab(i).changed_flag ||
7366                           ', schedule_date_changed => ' || p_details_interface_tab(i).schedule_date_changed );
7367       END IF;
7368       --
7369 
7370       <<end_loop>>
7371          IF l_temp_status = WSH_UTIL_CORE.G_RET_STS_ERROR THEN
7372             x_return_status := l_temp_status;
7373 
7374             Populate_Error_Records(
7375                  p_interface_id             => p_details_interface_tab(i).delivery_detail_interface_id,
7376                  p_interface_table_name     => 'WSH_DEL_DETAILS_INTERFACE',
7377                  x_interface_errors_rec_tab => x_interface_error_tab,
7378                  x_return_status            => l_return_status );
7379          END IF;
7380    END LOOP; --}
7381 
7382    --
7383    IF l_debug_on THEN
7384       WSH_DEBUG_SV.log(l_module_name, 'x_interface_error_tab.COUNT', x_interface_error_tab.COUNT);
7385       WSH_DEBUG_SV.log(l_module_name, 'Return Status',x_return_status);
7386       WSH_DEBUG_SV.pop(l_module_name);
7387    END IF;
7388    --
7389 EXCEPTION
7390    WHEN OTHERS THEN
7391          IF c_delivery_details_info%ISOPEN THEN
7392             CLOSE c_delivery_details_info;
7393          END IF;
7394 
7395          x_return_status := WSH_UTIL_CORE.G_RET_STS_UNEXP_ERROR;
7396          WSH_UTIL_CORE.Default_Handler('WSH_SHIPMENT_REQUEST_PKG.Validate_Interface_Details');
7397          --
7398          IF l_debug_on THEN
7399            WSH_DEBUG_SV.logmsg(l_module_name,'Unexpected error has occured. Oracle error message is '|| SQLERRM,WSH_DEBUG_SV.C_UNEXPEC_ERR_LEVEL);
7400            WSH_DEBUG_SV.pop(l_module_name,'EXCEPTION:OTHERS');
7401          END IF;
7402          --
7403 END Validate_Interface_Details;
7404 
7405 END WSH_SHIPMENT_REQUEST_PKG;