DBA Data[Home] [Help]

PACKAGE BODY: APPS.OE_EXPORT_COMPLIANCE_WF

Source


1 PACKAGE BODY OE_EXPORT_COMPLIANCE_WF as
2 /* $Header: OEXWECSB.pls 120.3.12010000.4 2010/06/25 23:01:03 shrgupta ship $ */
3 
4 PROCEDURE ECS_Request(
5     itemtype  in varchar2,
6     itemkey   in varchar2,
7     actid     in number,
8     funcmode  in varchar2,
9     resultout in out NOCOPY /* file.sql.39 change */ varchar2)
10 IS
11 l_header_id		NUMBER;
12 l_return_status		VARCHAR2(30);
13 l_msg_count		NUMBER;
14 l_msg_data		VARCHAR2(2000);
15 l_line_rec              OE_Order_PUB.Line_Rec_Type;
16 l_old_line_rec          OE_Order_PUB.Line_Rec_Type;
17 p_line_rec		OE_Order_PUB.Line_Rec_Type;
18 l_call_appl_id		NUMBER;
19 l_org_id		NUMBER;
20 l_organization_id	NUMBER;
21 l_result_out		VARCHAR2(100);
22 l_top_model_line_id	NUMBER;
23 l_dummy			VARCHAR2(2);
24 
25 --
26 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
27 --
28 BEGIN
29 
30   --
31   -- RUN mode - normal process execution
32   --
33   if (funcmode = 'RUN') then
34 
35         OE_MSG_PUB.set_msg_context(
36            p_entity_code           => 'LINE'
37           ,p_entity_id                  => to_number(itemkey)
38           ,p_line_id                    => to_number(itemkey));
39 
40 	IF l_debug_level  > 0 THEN
41 	    oe_debug_pub.add(  'WITHIN DENIED PARTY WORKFLOW COVER ' ) ;
42 	END IF;
43         IF l_debug_level  > 0 THEN
44             oe_debug_pub.add(  'ITEM KEY IS ' || ITEMKEY ) ;
45         END IF;
46 	OE_STANDARD_WF.Set_Msg_Context(actid);
47 
48 	SAVEPOINT Before_Lock;
49 
50 	select top_model_line_id into l_top_model_line_id
51 	from oe_order_lines_all where
52 	line_id = to_number(itemkey);
53 
54         -- bug 4503620
55         BEGIN
56           IF l_top_model_line_id is not null then
57 	    select '1' into l_dummy
58 	    from  oe_order_lines_all
59 	    where line_id = l_top_model_line_id
60 	    for update; --commented for bug 6415831 -- nowait;
61 	  END IF;
62         EXCEPTION
63           WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
64              IF l_debug_level  > 0 THEN
65                oe_debug_pub.add('OEXWECSB.pls: unable to lock the line:'||l_top_model_line_id,1);
66              END IF;
67            resultout := 'COMPLETE:INCOMPLETE';
68            IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR) THEN
69               fnd_message.set_name('ONT', 'OE_LINE_LOCKED');
70               OE_MSG_PUB.Add;
71            END IF;
72            OE_STANDARD_WF.Save_Messages;
73            OE_STANDARD_WF.Clear_Msg_Context;
74            return;
75         END; -- bug 4503620 ends
76 
77         OE_Line_Util.Lock_Row
78             (p_line_id	        => to_number(itemkey),
79              p_x_line_rec	=> l_line_rec,
80 	     x_return_status    => l_return_status);
81 
82     	IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
83           IF l_debug_level  > 0 THEN
84               oe_debug_pub.add(  'LOCK ROW RETURNED WITH ERROR' , 1 ) ;
85           END IF;
86           resultout := 'COMPLETE:INCOMPLETE';
87           OE_STANDARD_WF.Save_Messages;
88           OE_STANDARD_WF.Clear_Msg_Context;
89           return;
90     	END IF;
91 
92         OE_MSG_PUB.set_msg_context(
93            p_entity_code           => 'LINE'
94           ,p_entity_id                  => l_line_rec.line_id
95           ,p_header_id                  => l_line_rec.header_id
96           ,p_line_id                    => l_line_rec.line_id
97           ,p_order_source_id            => l_line_rec.order_source_id
98           ,p_orig_sys_document_ref      => l_line_rec.orig_sys_document_ref
99           ,p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
100           ,p_orig_sys_shipment_ref      => l_line_rec.orig_sys_shipment_ref
101           ,p_change_sequence            => l_line_rec.change_sequence
102           ,p_source_document_type_id    => l_line_rec.source_document_type_id
103           ,p_source_document_id         => l_line_rec.source_document_id
104           ,p_source_document_line_id    => l_line_rec.source_document_line_id );
105 
106 /*	Here we call the procedure to populate the data into the interface  tables.
107 	After populating the interface tables we need to check invoke the Clearcross
108 	Adapter which processes the data in the interface table.
109 	If there is no data in the Response table then it means that the
110 	Clearcross Adapter has not got the result.
111 	This may be due to any reason like:
112 	(a) Technicall Error:
113 	This may be due to any technical error which has come up and this may include
114 	problems like Network Error,Server not responding and so on.
115 	(b) Functional Error:
116 		This may be due to error in the Clearcross adapter.
117 
118 */
119 
120 -- 	This is the procedure which calls the Procedure for populating
121 --	the data into the Transaction tables.
122 
123 --      This is the procedure which calls the Procedure for populating the data
124 --	into the Transaction tables.
125 
126         ONT_ITM_PKG.Process_ITM_REQUEST(
127 		p_line_rec 	  => l_line_rec
128 		,x_return_status  => l_return_status
129 		,x_result_out     => l_result_out);
130 
131 
132 	IF l_debug_level  > 0 THEN
133 	    oe_debug_pub.add(  'AFTER PROCESSING THE REQUEST :'||L_RETURN_STATUS ) ;
134 	END IF;
135 
136 
137 -- 	If error is generated by the Insert Procedure then we need to
138 --	capture the that error and do not allow the Workflow to process
139 --	further.
140 --
141 	 IF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
142             IF l_result_out = OE_GLOBALS.G_WFR_COMPLETE THEN
143                 resultout := 'NOTIFIED';
144 		OE_STANDARD_WF.Save_Messages;
145 		OE_STANDARD_WF.Clear_Msg_Context;
146 		RETURN;
147 	    END IF;
148 	ELSIF l_return_status = FND_API.G_RET_STS_ERROR THEN
149 		resultout := 'COMPLETE:INCOMPLETE';
150 		OE_STANDARD_WF.Save_Messages;
151 		OE_STANDARD_WF.Clear_Msg_Context;
152 		RETURN;
153         ELSE
154 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
155         END IF;
156 
157         RETURN;
158 
159   END IF; -- End for 'RUN' mode
160 
161   --
162   -- CANCEL mode - activity 'compensation'
163   --
164 
165   --  This is an event point called with the effect of the activity
166 --  be undone, for example when a process is reset to an earlier point
167   --  due to a loop back.
168   --
169 
170   if (funcmode = 'CANCEL') then
171 
172     -- your cancel code goes here
173     null;
174 
175     -- no result needed
176     resultout := 'COMPLETE';
177     return;
178   end if;
179 
180 
181   --
182   -- Other execution modes may be created in the future.  Your
183   -- activity will indicate that it does not implement a mode
184   -- by returning null
185   --
186 --  resultout := '';
187 --  return;
188 
189 exception
190   when others then
191     -- The line below records this function call in the error system
192     -- in the case of an exception.
193     wf_core.context('OE_EXPORT_COMPLIANCE_WF', 'ECS_Request',
194                     itemtype, itemkey, to_char(actid), funcmode);
195     -- start data fix project
196     OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
197                                           p_itemtype => itemtype,
198                                           p_itemkey => itemkey);
199     OE_STANDARD_WF.Save_Messages;
200     OE_STANDARD_WF.Clear_Msg_Context;
201     -- end data fix project
202     raise;
203 END ECS_Request;
204 
205 /*
206 NAME :
207        update_screening_results
208 BRIEF DESCRIPTION  :
209        This API is called when OM receives a response from ITM for the
210        export compliance screening results. It is responsible for updating
211        the order line with the screening response. Introduced as a part of
212        bug fix 8762350.
213 CALLER :
214        1. Called from the workflow activity UPDATE_SCREENING_RESULTS.
215 RELEASE LEVEL :
216        12.1.2 and higher.
217 PARAMETERS :
218        standard WF activity parameters
219 */
220 
221 PROCEDURE Update_Screening_Results (
222 			       itemtype IN VARCHAR2,
223 			       itemkey IN VARCHAR2,
224 			       actid IN NUMBER,
225 			       funcmode IN VARCHAR2,
226 			       resultout IN OUT NOCOPY /* file.sql.39 change */ VARCHAR2)
227 IS
228 CURSOR C_Resp_Lines(cp_response_header_id NUMBER) IS
229     SELECT wl.Error_Text, wl.denied_party_flag, wp.Party_name
230     FROM wsh_itm_response_lines wl,
231     wsh_itm_parties wp
232     WHERE wl.Response_header_id = cp_response_header_id
233     AND wp.party_id = wl.party_id;
234 
235 CURSOR C_Get_Responses(cp_request_control_id NUMBER,
236 		       cp_request_set_id NUMBER)
237     IS
238     SELECT request_control_id, response_header_id, organization_id,
239     nvl(original_system_line_reference, 0) line_id,
240     nvl(original_system_reference, 0) header_id --bug 4503620
241     FROM wsh_itm_request_control wrc
242     WHERE request_control_id = nvl(cp_request_control_id, 0)
243     AND wrc.application_id = 660
244     UNION
245     SELECT request_control_id, response_header_id, organization_id,
246     nvl(original_system_line_reference, 0) line_id,
247     nvl(original_system_reference, 0) header_id --bug 4503620
248     FROM wsh_itm_request_control wrc
249     WHERE request_set_id = nvl(cp_request_set_id, 0)
250     AND wrc.application_id = 660;
251 
252 l_api_name CONSTANT VARCHAR2(30) := 'Update_Screening_Results';
253 l_request_control_id NUMBER;
254 l_request_set_id NUMBER;
255 l_process_flag NUMBER;
256 l_response_header_id NUMBER;
257 l_denied_party_flag VARCHAR2(1);
258 l_line_id NUMBER;
259 l_header_id NUMBER; -- bug 4503620
260 l_top_model_line_id NUMBER;
261 l_activity_id NUMBER; -- 8762350
262 l_line_rec OE_ORDER_PUB.line_rec_type;
263 l_services WSH_ITM_RESPONSE_PKG.SrvTabTyp;
264 l_hold_source_rec OE_Holds_PVT.Hold_Source_REC_type;
265 l_return_status VARCHAR2(35);
266 l_data_error VARCHAR2(1);
267 l_system_error VARCHAR2(1);
268 l_activity_complete VARCHAR2(1);
269 l_hold_applied VARCHAR2(1);
270 l_dp_hold_flag VARCHAR2(1);
271 l_gen_hold_flag VARCHAR2(1);
272 l_interpreted_value VARCHAR2(30);
273 p_return_status VARCHAR2(30);
274 l_result_out VARCHAR2(30);
275 l_msg_count NUMBER := 0;
276 l_msg_data VARCHAR2(2000);
277 l_error_text VARCHAR2(2000);
278 l_dummy VARCHAR2(10);
279 l_org_id NUMBER;
280 l_serv INTEGER;
281 --
282 l_debug_level CONSTANT NUMBER := oe_debug_pub.g_debug_level;
283 --
284 BEGIN
285 
286   --
287   -- RUN mode - normal process execution
288   --
289   IF (funcmode = 'RUN') THEN
290 
291             OE_MSG_PUB.set_msg_context(
292              p_entity_code           => 'LINE'
293             ,p_entity_id             => to_number(itemkey)
294             ,p_line_id               => to_number(itemkey));
295 
296 	    OE_DEBUG_PUB.Add('Entering Update_screening_results...');
297 
298 	    SAVEPOINT UPDATE_API;
299 
300 	    -- MOAC change DBMS_APPLICATION_INFO.Set_Client_Info(l_org_id);
301 
302 	    SELECT org_id
303 	    INTO   l_org_id
304 	    FROM   oe_order_lines_all
305 	    WHERE  line_id = to_number(itemkey);
306 
307 	    mo_global.set_policy_context('S', l_org_id);
308 
309 	    OE_LINE_UTIL.Query_Row ( p_line_id  => to_number(itemkey),
310 				     x_line_rec => l_line_rec);
311 
312 	    l_line_id := l_line_rec.line_id;
313             l_header_id := l_line_rec.header_id;
314 
315 	    Oe_debug_pub.add('Calling shipping API to get request status...');
316 
317 	    wsh_itm_util.get_compliance_status (
318 				    p_appliciation_id => 660,
319 				    p_original_sys_reference => l_line_rec.header_id,
320 				    p_original_sys_line_reference => l_line_rec.line_id,
321 				    x_process_flag => l_process_flag,
322 				    x_request_control_id => l_request_control_id,
323 				    x_request_set_id => l_request_set_id,
324 				    x_return_status => l_return_status
325 	                                        );
326 
327 	    Oe_debug_pub.add('request_control_id : ' || l_request_control_id);
328 	    Oe_debug_pub.add('request_set_id : ' || l_request_set_id);
329 	    Oe_debug_pub.add('process_flag : ' || l_process_flag);
330 	    Oe_debug_pub.add('return status : ' || l_return_status);
331 
332 	    IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
333 		Oe_debug_pub.add('get_compliance_status API returned error.!');
334 		RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
335 	    END IF;
336 
337             -- This select statement is used to lock the Top Model Line.
338 	    -- After the Top Model Line is Locked we go ahead the Lock the
339 	    -- individual Line.
340 
341 	    SELECT top_model_line_id
342 	    INTO l_top_model_line_id
343 	    FROM oe_order_lines
344 	    WHERE line_id = l_line_id;
345 
346             BEGIN --bug 4503620
347 	     /*
348 		 Commenting the following block for 9273310
349                  Locking the top model is not needed as no processing is done
350                  on it, and it can potentially cause a locking issue.
351 
352 		 IF l_top_model_line_id IS NOT NULL THEN
353 		    SELECT '1'
354 		    INTO l_dummy
355 		    FROM oe_order_lines_all
356 		    WHERE line_id = l_top_model_line_id
357 		    FOR UPDATE
358 		    --Commented for bug 6415831
359 		    NOWAIT; -- Uncommented for 8762350
360 		END IF;
361 
362                 End of 9273310
363 	    */
364 
365 		-- Wait until the lock on the row is released and then
366 		-- lock the row
367 
368 		SELECT '1'
369 		INTO l_dummy
370 		FROM oe_order_lines_all
371 		WHERE line_id = l_line_id
372 		FOR UPDATE
373 		--Commented for bug 6415831
374 		NOWAIT; -- Uncommented for 8762350
375 
376 		Oe_debug_pub.ADD('Lock on lines taken.');
377 
378                 BEGIN  --9853045
379 
380   		   SELECT 'Y'
381 		   INTO l_dummy
382 		   FROM ONT_DBI_CHANGE_LOG
383 		   WHERE line_id = l_line_id
384 		   FOR UPDATE NOWAIT;
385 
386                 EXCEPTION  -- Exception added as part of 9853045
387 	           WHEN NO_DATA_FOUND THEN
388 	            Oe_debug_pub.ADD('SKIPPING NO DATA FOUND from DBI Table Query');
389                     NULL;
390                    WHEN TOO_MANY_ROWS THEN
391 	            Oe_debug_pub.ADD('SKIPPING TOO MANY ROWS  from DBI Table Query');
392                     NULL;
393                 END;  --9853045
394 
395 
396 
397 		Oe_debug_pub.ADD('Lock on dbi taken.');
398 
399 	    EXCEPTION
400 		WHEN APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION THEN
401 		    IF l_debug_level > 0 THEN
402 			oe_debug_pub.add('OEXWECSB.pls: unable to lock the line', 1);
403 		    END IF;
404 		    IF OE_MSG_PUB.Check_Msg_Level(OE_MSG_PUB.G_MSG_LVL_ERROR) THEN
405 			OE_MSG_PUB.set_msg_context(
406 						   p_entity_code => 'LINE'
407 						   , p_entity_id => l_line_id
408 						   , p_header_id => l_header_id
409 						   , p_line_id => l_line_id);
410 
411 			fnd_message.set_name('ONT', 'OE_LINE_LOCKED');
412 			OE_MSG_PUB.Add;
413 			OE_MSG_PUB.Save_API_Messages;
414 		    END IF;
415 
416 		    ROLLBACK TO UPDATE_API;
417 
418 		    resultout := 'COMPLETE:INCOMPLETE';
419 
420 		    -- RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
421 		    RETURN;
422 	    END; --bug 4503620 ends
423 
424 	    -- Check whether the Line is cancelled
425 
426 	    IF l_line_rec.cancelled_flag = 'Y' THEN
427 		IF l_debug_level > 0 THEN
428 		    oe_debug_pub.add('The line ' || to_char(l_line_id) || 'is already cancelled.', 1);
429 		END IF;
430 		RETURN;
431 	    END IF;
432 
433 	    OE_MSG_PUB.set_msg_context(
434 				       p_entity_code => 'LINE'
435 				       , p_entity_id => l_line_rec.line_id
436 				       , p_header_id => l_line_rec.header_id
437 				       , p_line_id => l_line_rec.line_id
438 				       , p_order_source_id => l_line_rec.order_source_id
439 				       , p_orig_sys_document_ref => l_line_rec.orig_sys_document_ref
440 				       , p_orig_sys_document_line_ref => l_line_rec.orig_sys_line_ref
441 				       , p_orig_sys_shipment_ref => l_line_rec.orig_sys_shipment_ref
442 				       , p_change_sequence => l_line_rec.change_sequence
443 				       , p_source_document_type_id => l_line_rec.source_document_type_id
444 				       , p_source_document_id => l_line_rec.source_document_id
445 				       , p_source_document_line_id => l_line_rec.source_document_line_id
446 				       );
447 
448 
449 	    -- If the user has choosen to override Screening
450 
451 	    IF l_process_flag = 3 THEN
452 
453 		IF l_debug_level > 0 THEN
454 		    oe_debug_pub.add('Override screening for line id:' || l_line_id, 3);
455 		END IF;
456 
457 		-- Update Work flow Status Code
458 
459 		OE_ORDER_WF_UTIL.Update_Flow_Status_Code (
460 							  p_line_id => l_line_id,
461 							  p_flow_status_code => 'EXPORT_SCREENING_COMPLETED',
462 							  x_return_status => l_return_status
463 							  );
464 
465 
466 		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
467 		    OE_STANDARD_WF.Save_Messages;
468 		    OE_STANDARD_WF.Clear_Msg_Context;
469 		    APP_EXCEPTION.Raise_Exception;
470 		END IF;
471 
472 		resultout := 'COMPLETE:OVERRIDE';
473 		OE_STANDARD_WF.Save_Messages;
474 		OE_STANDARD_WF.Clear_Msg_Context;
475 
476 		RETURN;
477 	    END IF;
478 
479 	    -- Calling Response Analyser
480 
481 	    FOR c_responses IN C_Get_Responses(l_request_control_id, l_request_set_id)
482 		LOOP
483 		BEGIN
484 
485 		    l_request_control_id := c_responses.request_control_id;
486 		    l_response_header_id := c_responses.response_header_id;
487 
488 		    WSH_ITM_RESPONSE_PKG.ONT_RESPONSE_ANALYSER (
489 								p_request_control_id => l_request_control_id,
490 								x_interpreted_value => l_interpreted_value,
491 								x_SrvTab => l_services,
492 								x_return_status => l_return_status
493 								);
494 
495 
496 
497 		    IF l_debug_level > 0 THEN
498 			OE_DEBUG_PUB.Add('Response analyser return status :' || l_return_status, 1);
499 		    END IF;
500 
501 		    -- Check for System or Data errors.
502 
503 		    IF l_interpreted_value = 'SYSTEM' OR l_interpreted_value = 'DATA' THEN
504 
505 			--  Check for errors in Response Headers.
506 
507 			SELECT error_text
508 			INTO l_error_text
509 			FROM wsh_itm_response_headers
510 			WHERE response_header_id = l_response_header_id;
511 
512 			IF l_interpreted_value = 'DATA' THEN
513 			    l_data_error := 'Y';
514 			    FND_MESSAGE.SET_NAME('ONT', 'OE_ECS_DATA_ERROR');
515 			ELSE
516 			    l_system_error := 'Y';
517 			    FND_MESSAGE.SET_NAME('ONT', 'OE_ECS_SYSTEM_ERROR');
518 			END IF;
519 
520 			FND_MESSAGE.SET_TOKEN('ERRORTEXT', l_error_text);
521 			OE_MSG_PUB.Add;
522 
523 
524 			-- Check for errors in Response lines
525 
526 			FOR c_error IN c_resp_lines(l_response_header_id)
527 			    LOOP
528 			    BEGIN
529 				l_error_text := c_error.error_text;
530 
531 				IF l_interpreted_value = 'DATA' THEN
532 				    FND_MESSAGE.SET_NAME('ONT', 'OE_ECS_DATA_ERROR');
533 				ELSE
534 				    FND_MESSAGE.SET_NAME('ONT', 'OE_ECS_SYSTEM_ERROR');
535 				END IF;
536 
537 				FND_MESSAGE.SET_TOKEN('ERRORTEXT', l_error_text);
538 				OE_MSG_PUB.Add;
539 			    END;
540 			END LOOP;
541 		    END IF; --Check for System or Data Errors
542 
543 		    -- Get the Parties Denied.
544 
545 		    FOR c_resplines IN c_resp_lines(l_response_header_id)
546 			LOOP
547 			BEGIN
548 			    IF c_resplines.denied_party_flag = 'Y' THEN
549 				FND_MESSAGE.SET_NAME('ONT', 'OE_ECS_DENIED_PARTY');
550 				FND_MESSAGE.SET_TOKEN('DENIEDPARTY',
551 						      c_resplines.party_name);
552 				OE_MSG_PUB.Add;
553 				IF l_debug_level > 0 THEN
554 				    OE_DEBUG_PUB.Add('Party Name:' || c_resplines.party_name || ',denied');
555 				END IF;
556 			    END IF;
557 			END;
558 		    END LOOP;
559 
560 		    -- Check for Denied Party Service
561 
562 
563 		    FOR l_serv IN 1..l_services.COUNT
564 			LOOP
565 			IF l_debug_level > 0 THEN
566 			    OE_DEBUG_PUB.Add('Service Result' || l_services(l_serv).Service_Result, 1);
567 			END IF;
568 
569 			IF l_services(l_serv).Service_Type = 'DP' THEN
570 			    l_dp_hold_flag := l_services(l_serv).Service_Result;
571 			END IF;
572 			IF l_services(l_serv).Service_Type = 'OM_EXPORT_COMPLIANCE' AND
573 			    OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
574 			    l_gen_hold_flag := l_services(l_serv).Service_Result;
575 			END IF;
576 		    END LOOP;
577 
578 		    l_hold_applied := l_dp_hold_flag;
579 
580 		    IF l_interpreted_value = 'SUCCESS' THEN
581 			l_activity_complete := 'Y';
582 		    END IF;
583 		END;
584 	    END LOOP;
585 
586 	    -- Progress Work Flow to Next Stage
587 
588 	    IF l_debug_level > 0 THEN
589 		oe_debug_pub.add('Progress Work Flow to Next Stage...', 1);
590 	    END IF;
591 
592 
593 	    -- If one response has system error and other has data error we
594 	    -- consider that line has system error. If both the responses has
595 	    -- data error we consider thata line has data error.
596 
597 	    IF l_system_error = 'Y' THEN
598 		-- we will never come here.
599 		NULL;
600 
601 	    ELSIF l_data_error = 'Y' THEN
602 
603 		OE_ORDER_WF_UTIL.Update_Flow_Status_Code
604 		(p_line_id => l_line_id,
605 		 p_flow_status_code => 'EXPORT_SCREENING_DATA_ERROR',
606 		 x_return_status => l_return_status
607 		 );
608 
609 		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
610 		    resultout := 'COMPLETE:INCOMPLETE';
611 		    OE_STANDARD_WF.Save_Messages;
612 		    OE_STANDARD_WF.Clear_Msg_Context;
613 		    APP_EXCEPTION.Raise_Exception;
614 		END IF;
615 
616 		resultout := 'COMPLETE:SCREENING_ERROR';
617 		OE_STANDARD_WF.Save_Messages;
618 		OE_STANDARD_WF.Clear_Msg_Context;
619 
620 	    ELSIF l_gen_hold_flag = 'Y' AND
621 		OE_CODE_CONTROL.CODE_RELEASE_LEVEL >= '110510' THEN
622 
623 		OE_DEBUG_PUB.Add('Generic Hold!!!');
624 
625 		-- The Hold_Id of the Generic Hold has been
626 		-- seeded as 23.
627 
628 
629 		l_hold_source_rec.hold_entity_code := 'O';
630 		l_hold_source_rec.hold_id          := 23;
631 		l_hold_source_rec.hold_entity_id   := l_line_rec.header_id;
632 		l_hold_source_rec.line_id          := l_line_rec.line_id;
633 
634 		OE_HOLDS_PUB.Apply_Holds
635 		( p_api_version => 1.0
636 		  , p_validation_level => FND_API.G_VALID_LEVEL_NONE
637 		  , p_hold_source_rec => l_hold_source_rec
638 		  , x_return_status => l_return_status
639 		  , x_msg_count => l_msg_count
640 		  , x_msg_data => l_msg_data
641 		  );
642 
643 		IF l_return_status = FND_API.G_RET_STS_ERROR THEN
644 		    RAISE FND_API.G_EXC_ERROR;
645 		ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
646 		    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
647 		ELSIF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
648 		    IF l_debug_level > 0 THEN
649 			oe_debug_pub.add('Applied Generic hold on line:' || l_line_rec.line_id, 1);
650 		    END IF;
651 		END IF;
652 
653 		OE_Order_WF_Util.Update_Flow_Status_Code
654 		(p_line_id => l_line_id,
655 		 p_flow_status_code => 'EXPORT_SCREENING_COMPLETED',
656 		 x_return_status => l_return_status
657 		 );
658 
659 		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
660 		    resultout := 'COMPLETE:INCOMPLETE';
661 		    OE_STANDARD_WF.Save_Messages;
662 		    OE_STANDARD_WF.Clear_Msg_Context;
663 		    APP_EXCEPTION.Raise_Exception;
664 		END IF;
665 
666 		resultout := 'COMPLETE:HOLD_APPLIED';
667 		OE_STANDARD_WF.Save_Messages;
668 		OE_STANDARD_WF.Clear_Msg_Context;
669 
670 	    ELSIF l_hold_applied = 'Y' THEN
671 
672 		-- Check whether Denied party hold needs to be applied
673 
674 		-- The Hold_Id of the Denied Party Hold has been
675 		-- seeded as 21.
676 
677 
678 		l_hold_source_rec.hold_entity_code := 'O';
679 		l_hold_source_rec.hold_id          := 21;
680 		l_hold_source_rec.hold_entity_id   := l_line_rec.header_id;
681 		l_hold_source_rec.line_id          := l_line_rec.line_id;
682 
683 		OE_HOLDS_PUB.Apply_Holds
684 		( p_api_version => 1.0
685 		  , p_validation_level => FND_API.G_VALID_LEVEL_NONE
686 		  , p_hold_source_rec => l_hold_source_rec
687 		  , x_return_status => l_return_status
688 		  , x_msg_count => l_msg_count
689 		  , x_msg_data => l_msg_data
690 		  );
691 
692 		IF l_return_status = FND_API.G_RET_STS_ERROR THEN
693 		    RAISE FND_API.G_EXC_ERROR;
694 		ELSIF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
695 		    RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
696 		ELSIF l_return_status = FND_API.G_RET_STS_SUCCESS THEN
697 		    IF l_debug_level > 0 THEN
698 			oe_debug_pub.add('Applied denied party hold on line:' || l_line_rec.line_id, 1);
699 		    END IF;
700 		END IF;
701 
702 		OE_Order_WF_Util.Update_Flow_Status_Code
703 		(p_line_id => l_line_id,
704 		 p_flow_status_code => 'EXPORT_SCREENING_COMPLETED',
705 		 x_return_status => l_return_status
706 		 );
707 
708 		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
709 		    resultout := 'COMPLETE:INCOMPLETE';
710 		    OE_STANDARD_WF.Save_Messages;
711 		    OE_STANDARD_WF.Clear_Msg_Context;
712 		    APP_EXCEPTION.Raise_Exception;
713 		END IF;
714 
715 		resultout := 'COMPLETE:HOLD_APPLIED';
716 		OE_STANDARD_WF.Save_Messages;
717 		OE_STANDARD_WF.Clear_Msg_Context;
718 
719 	    ELSIF l_activity_complete = 'Y' THEN
720 
721 		OE_ORDER_WF_UTIL.Update_Flow_Status_Code
722 		(p_line_id => l_line_id,
723 		 p_flow_status_code => 'EXPORT_SCREENING_COMPLETED',
724 		 x_return_status => l_return_status
725 		 );
726 
727 		IF l_return_status <> FND_API.G_RET_STS_SUCCESS THEN
728 		    resultout := 'COMPLETE:INCOMPLETE';
729 		    OE_STANDARD_WF.Save_Messages;
730 		    OE_STANDARD_WF.Clear_Msg_Context;
731 		    APP_EXCEPTION.Raise_Exception;
732 		END IF;
733 
734 		resultout := 'COMPLETE:COMPLETE';
735 		OE_STANDARD_WF.Save_Messages;
736 		OE_STANDARD_WF.Clear_Msg_Context;
737 
738 	    END IF;
739 
740 
741 	    OE_MSG_PUB.SAVE_MESSAGES(l_line_rec.line_id);
742 
743 	    IF l_debug_level > 0 THEN
744 		oe_debug_pub.add('Exiting response api', 1);
745 	    END IF;
746   END IF;
747 
748   -- End for 'RUN' mode
749 
750   --
751   -- CANCEL mode - activity 'compensation'
752   --
753 
754   --  This is an event point called with the effect of the activity
755   --  be undone, for example when a process is reset to an earlier point
756   --  due to a loop back.
757   --
758 
759   if (funcmode = 'CANCEL') then
760 
761     -- your cancel code goes here
762     null;
763 
764     -- no result needed
765     resultout := 'COMPLETE';
766     return;
767   end if;
768 
769   --
770   -- Other execution modes may be created in the future.  Your
771   -- activity will indicate that it does not implement a mode
772   -- by returning null
773   --
774   --  resultout := '';
775   --  return;
776 
777 EXCEPTION
778     WHEN OTHERS THEN
779 	-- The line below records this function call in the error system
780 	-- in the case of an exception.
781 	wf_core.context('OE_EXPORT_COMPLIANCE_WF', 'Update_Screening_Results',
782 			itemtype, itemkey, to_char(actid), funcmode);
783 	-- start data fix project
784 	OE_STANDARD_WF.Add_Error_Activity_Msg(p_actid => actid,
785 					      p_itemtype => itemtype,
786 					      p_itemkey => itemkey);
787         OE_STANDARD_WF.Save_Messages;
788 	OE_STANDARD_WF.Clear_Msg_Context;
789 	-- end data fix project
790 
791 	ROLLBACK TO UPDATE_API;
792 
793 	IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
794 	    FND_MSG_PUB.Add_Exc_Msg
795 	    ('OE_EXPORT_COMPLIANCE_WF',
796 	     'Update_Screening_Results'
797 	     );
798 	END IF;
799 
800 	RAISE;
801 
802 END Update_screening_results;
803 
804 END OE_EXPORT_COMPLIANCE_WF;