[Home] [Help]
PACKAGE BODY: APPS.FND_CP_TMSRV_PIPE
Source
1 package body FND_CP_TMSRV_PIPE as
2 /* $Header: AFCPTMPB.pls 120.1 2005/09/17 01:59:53 pferguso noship $ */
3
4
5 --
6 -- Constants
7 --
8 FNDCPRP constant varchar2(10) := 'FNDCPTM:R:'; -- R pipe prefix
9 FNDCPTP constant varchar2(10) := 'FNDCPTM:T:'; -- T pipe prefix
10
11
12 --
13 -- Private variables
14 --
15 P_DEBUG varchar2(1) := FNDCP_TMSRV.DBG_OFF;
16 P_R_PIPE varchar2(30) := null;
17 P_T_PIPE varchar2(30) := null;
18
19
20
21
22
23 procedure initialize (e_code in out nocopy number,
24 qid in number,
25 pid in number) is
26 begin
27
28 P_T_PIPE := FNDCPTP || qid;
29 P_R_PIPE := FNDCPRP || qid;
30
31 e_code := FNDCP_TMSRV.E_SUCCESS;
32
33 end initialize;
34
35
36
37 procedure set_debug(dbgtype in varchar2) is
38 begin
39 P_DEBUG := dbgtype;
40 FNDCP_TMSRV.P_DEBUG := dbgtype;
41 end set_debug;
42
43
44 --
45 -- Put the transaction token to indicate that the TM is ready to process
46 -- the next TP.
47 --
48
49 procedure put_token is
50
51 e_code number;
52
53 begin
54 dbms_pipe.pack_message ( FNDCP_TMSRV.PK_TKN);
55 e_code := dbms_pipe.send_message (P_T_PIPE);
56 end put_token;
57
58
59 --
60 -- Take the transaction token.
61 --
62
63 procedure take_token is
64
65 e_code number;
66
67 begin
68 e_code := dbms_pipe.receive_message (P_T_PIPE, 0);
69 if (e_code = FNDCP_TMSRV.E_SUCCESS) then
70 dbms_pipe.reset_buffer;
71 end if;
72 end take_token;
73
74
75 procedure read_message (e_code in out nocopy number,
76 timeout in number,
77 pktyp in out nocopy varchar2,
78 enddate in out nocopy varchar2,
79 reqid in out nocopy number,
80 return_id in out nocopy varchar2,
81 nlslang in out nocopy varchar2,
82 nls_num_chars in out nocopy varchar2,
83 nls_date_lang in out nocopy varchar2,
84 secgrpid in out nocopy number,
85 usrid in out nocopy number,
86 rspapid in out nocopy number,
87 rspid in out nocopy number,
88 logid in out nocopy number,
89 apsname in out nocopy varchar2,
90 program in out nocopy varchar2,
91 numargs in out nocopy number,
92 org_type in out nocopy varchar2,
93 org_id in out nocopy number,
94 arg_1 in out nocopy varchar2,
95 arg_2 in out nocopy varchar2,
96 arg_3 in out nocopy varchar2,
97 arg_4 in out nocopy varchar2,
98 arg_5 in out nocopy varchar2,
99 arg_6 in out nocopy varchar2,
100 arg_7 in out nocopy varchar2,
101 arg_8 in out nocopy varchar2,
102 arg_9 in out nocopy varchar2,
103 arg_10 in out nocopy varchar2,
104 arg_11 in out nocopy varchar2,
105 arg_12 in out nocopy varchar2,
106 arg_13 in out nocopy varchar2,
107 arg_14 in out nocopy varchar2,
108 arg_15 in out nocopy varchar2,
109 arg_16 in out nocopy varchar2,
110 arg_17 in out nocopy varchar2,
111 arg_18 in out nocopy varchar2,
112 arg_19 in out nocopy varchar2,
113 arg_20 in out nocopy varchar2) is
114 end_date date;
115 enable_trace varchar2(255);
116 sql_stmt varchar2(255);
117 ops_inst number;
118
119 begin
120
121 -- Indicate that the TM is ready to process a TP.
122 put_token;
123
124 -- Read wait R_pipe.
125 e_code := dbms_pipe.receive_message (P_R_PIPE, timeout);
126
127 -- If timed out or other error, return
128 if (e_code > FNDCP_TMSRV.E_SUCCESS) then
129 take_token;
130 return;
131 end if;
132
133 -- If packet type is not a Transaction request, return.
134 dbms_pipe.unpack_message (pktyp);
135 if (pktyp not in (FNDCP_TMSRV.PK_TRN, FNDCP_TMSRV.PK_TRN_D1, FNDCP_TMSRV.PK_TRN_D2)) then
136 take_token;
137 return;
138 end if;
139
140 -- Set debug level
141 set_debug(pktyp);
142
143 dbms_pipe.unpack_message (end_date);
144 enddate := to_char (end_date, 'DD-MON-RR HH24:MI:SS');
145
146
147 dbms_pipe.unpack_message (reqid);
148 dbms_pipe.unpack_message (return_id);
149 dbms_pipe.unpack_message (nlslang);
150 dbms_pipe.unpack_message (nls_num_chars);
151 dbms_pipe.unpack_message (nls_date_lang);
152 dbms_pipe.unpack_message (secgrpid);
153 dbms_pipe.unpack_message (ops_inst);
154 dbms_pipe.unpack_message (enable_trace);
155 dbms_pipe.unpack_message (usrid);
156 dbms_pipe.unpack_message (rspapid);
157 dbms_pipe.unpack_message (rspid);
158 dbms_pipe.unpack_message (logid);
159 dbms_pipe.unpack_message (apsname);
160 dbms_pipe.unpack_message (program);
161 dbms_pipe.unpack_message (org_type);
162 dbms_pipe.unpack_message (org_id);
163
164 numargs := 0;
165 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
166 dbms_pipe.unpack_message (arg_1);
167 numargs := numargs + 1;
168 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
169 dbms_pipe.unpack_message (arg_2);
170 numargs := numargs + 1;
171 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
172 dbms_pipe.unpack_message (arg_3);
173 numargs := numargs + 1;
174 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
175 dbms_pipe.unpack_message (arg_4);
176 numargs := numargs + 1;
177 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
178 dbms_pipe.unpack_message (arg_5);
179 numargs := numargs + 1;
180 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
181 dbms_pipe.unpack_message (arg_6);
182 numargs := numargs + 1;
183 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
184 dbms_pipe.unpack_message (arg_7);
185 numargs := numargs + 1;
186 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
187 dbms_pipe.unpack_message (arg_8);
188 numargs := numargs + 1;
189 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
190 dbms_pipe.unpack_message (arg_9);
191 numargs := numargs + 1;
192 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
193 dbms_pipe.unpack_message (arg_10);
194 numargs := numargs + 1;
195 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
196 dbms_pipe.unpack_message (arg_11);
197 numargs := numargs + 1;
198 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
199 dbms_pipe.unpack_message (arg_12);
200 numargs := numargs + 1;
201 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
202 dbms_pipe.unpack_message (arg_13);
203 numargs := numargs + 1;
204 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
205 dbms_pipe.unpack_message (arg_14);
206 numargs := numargs + 1;
207 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
208 dbms_pipe.unpack_message (arg_15);
209 numargs := numargs + 1;
210 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
211 dbms_pipe.unpack_message (arg_16);
212 numargs := numargs + 1;
213 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
214 dbms_pipe.unpack_message (arg_17);
215 numargs := numargs + 1;
216 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
217 dbms_pipe.unpack_message (arg_18);
218 numargs := numargs + 1;
219 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
220 dbms_pipe.unpack_message (arg_19);
221 numargs := numargs + 1;
222 if (dbms_pipe.next_item_type = 0) then goto end_args; end if;
223 dbms_pipe.unpack_message (arg_20);
224 numargs := numargs + 1;
225
226 <<end_args>>
227
228
229 if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
230 fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
231 'Unpacked request details', NULL, 'M');
232
233 end if;
234
235 FND_CONC_GLOBAL.Override_OPS_INST_NUM(ops_inst);
236
237 sql_stmt := 'ALTER SESSION SET SQL_TRACE = '|| enable_trace;
238 EXECUTE IMMEDIATE sql_stmt ;
239
240 if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
241 fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
242 'SQL_TRACE:', enable_trace, 'M');
243
244 end if;
245 return;
246
247 exception
248 when others then
249 fndcp_tmsrv.debug_info('TMSRV_PIPE.read_message',
250 'EXCEPTION', sqlerrm, 'M');
251 end read_message;
252
253
254
255 procedure write_message (e_code in out nocopy number,
256 return_id in varchar2,
257 pktyp in varchar2,
258 reqid in number,
259 outcome in varchar2,
260 message in varchar2) is
261
262 begin
263 e_code := FNDCP_TMSRV.E_SUCCESS;
264
265 dbms_pipe.reset_buffer;
266
267 dbms_pipe.pack_message (pktyp);
268
269 -- Pack reply only if it's a valid reply
270 if (pktyp = FNDCP_TMSRV.PK_REP) then
271 dbms_pipe.pack_message (reqid);
272 dbms_pipe.pack_message (outcome);
273 dbms_pipe.pack_message (message);
274 for i in 1..FNDCP_TMSRV.P_RETVALCOUNT loop
275 dbms_pipe.pack_message (FNDCP_TMSRV.P_RETURN_VALS (i));
276 end loop;
277 end if;
278
279 FNDCP_TMSRV.P_RETVALCOUNT := 0; -- Reset the return values table.
280
281 if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
282 fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
283 'Packing return message' ,
284 NULL, 'S');
285
286 end if;
287
288 e_code := dbms_pipe.send_message (return_id);
289
290 if ( P_DEBUG <> FNDCP_TMSRV.DBG_OFF ) then
291 fndcp_tmsrv.debug_info('TMSRV_PIPE.write_message',
292 'Sent Message' ,
293 NULL, 'S');
294
295 end if;
296
297 -- Turn off debug.
298 set_debug(FNDCP_TMSRV.DBG_OFF);
299
300 end write_message;
301
302
303 end fnd_cp_tmsrv_pipe;