1 PACKAGE BODY fnd_cp_opp_cmd AS
2 /* $Header: AFCPOPCB.pls 120.2 2005/08/11 16:13:32 pferguso noship $ */
3
4
5 ICM_ID constant varchar2(8) := 'FNDICM';
6 OPP_ID constant varchar2(8) := 'FNDOPP';
7 OPP_PACKAGE constant varchar2(30) := 'oracle.apps.fnd.cp.opp';
8
9 -- Commands
10 OPP_SHUTDOWN_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPImmediateShutdownCommand';
11 OPP_TERMINATE_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPTerminateCommand';
12 OPP_PING_CMD constant varchar2(64) := OPP_PACKAGE || '.' || 'OPPPingCommand';
13
14
15 --------------------------------------------------------------------------------
16
17
18 --
19 -- Send an immediate shutdown request to a specific OPP process
20 --
21 procedure send_opp_shutdown_request(cpid in number) is
22
23 begin
24
25 fnd_cp_opp_ipc.send_command(cpid, ICM_ID, OPP_SHUTDOWN_CMD, '');
26
27
28 end;
29
30
31 --
32 -- Requests termination of postprocessing for a specific request
33 --
34 procedure terminate_opp_request(reqid in number, senderid in number) is
35
36 pragma autonomous_transaction;
37
38 cpid number;
39 complete varchar2(1);
40 deadlock_detected exception;
41
42 pragma exception_init(deadlock_detected , -60);
43
44 begin
45
46 select processor_id, completed
47 into cpid, complete
48 from fnd_conc_pp_actions
49 where concurrent_request_id = reqid
50 and action_type = 6
51 and sequence = 1;
52
53 if cpid is null then
54
55 -- post-processor has not started yet, update the table with our id
56 -- so the post-processor will not pick it up.
57
58 update fnd_conc_pp_actions
59 set processor_id = senderid
60 where concurrent_request_id = reqid;
61
62 commit;
63
64 -- also update the post-processing status of the request
65 -- this could possibly cause a deadlock if the manager running the request still has the lock
66 begin
67 update fnd_concurrent_requests
68 set pp_end_date = sysdate,
69 post_request_status = 'E'
70 where request_id = reqid;
71 exception
72 when deadlock_detected then
73 null;
74 end;
75
76 else
77 if complete <> 'Y' then
78
79 -- post-processor is actively running it, send a terminate command
80
81 fnd_cp_opp_ipc.send_command(cpid, senderid, OPP_TERMINATE_CMD, reqid);
82
83 end if;
84
85 end if;
86
87 commit;
88
89 exception
90 when no_data_found then
91 rollback;
92
93
94 end;
95
96
97 --
98 -- Ping a specific OPP service process
99 -- Returns TRUE if process replies.
100 --
101 function ping_opp_service(cpid in number, senderid in number, timeout in number) return boolean is
102
103 flag varchar2(1);
104 msgtype number;
105 message varchar2(240);
106 params varchar2(2000);
107 sender varchar2(30);
108 msggroup varchar2(30);
109
110 begin
111
112 fnd_cp_opp_ipc.send_command(cpid, senderid, OPP_PING_CMD, '');
113
114 -- should not have to wait long for the reply
115 fnd_cp_opp_ipc.get_message(senderid, flag, msgtype, msggroup, message, params, sender, timeout);
116
117 if flag = 'Y' and message = 'PING' then
118 return true;
119 end if;
120
121 return false;
122
123 end;
124
125
126 END fnd_cp_opp_cmd;