[Home] [Help]
PACKAGE BODY: APPS.XNP_ADAPTER
Source
1 PACKAGE BODY xnp_adapter AS
2 /* $Header: XNPADAPB.pls 120.1 2005/06/18 00:40:45 appldev $ */
3
4 PROCEDURE talk_to_adapter(p_channel_name in VARCHAR2,
5 p_msg_text in VARCHAR2,
6 x_error_code OUT NOCOPY NUMBER,
7 x_error_message OUT NOCOPY VARCHAR2);
8
9 PROCEDURE open( p_fe_name in VARCHAR2
10 ,p_channel_name in VARCHAR2
11 ,x_error_code OUT NOCOPY NUMBER
12 ,x_error_message OUT NOCOPY VARCHAR2 )
13 IS
14
15 l_msg_header xnp_message.msg_header_rec_type;
16 l_msg_text VARCHAR2(32767) ;
17 l_op_data VARCHAR2(32767) ;
18 l_channel VARCHAR2(1024) ;
19 l_sp_name VARCHAR2(1024) ;
20
21 l_fe_attr_list xdp_types.order_parameter_list ;
22
23 BEGIN
24
25 null;
26
27
28 /* This procedure needs to be deleted once the SEED data is fixed
29 -- x_error_code := 0 ;
30 -- x_error_message := NULL ;
31 --
32 -- xnp_xml_utils.initialize_doc ;
33 -- xnp_xml_utils.write_element('FE_NAME', p_fe_name) ;
34 --
35 -- FND_PROFILE.GET( NAME => 'SP_NAME',
36 -- VAL => l_sp_name ) ;
37 --
38 -- xnp_xml_utils.write_element('SP_NAME', l_sp_name) ;
39 --
40 --
41 -- --Get all FE attributes for the given FE
42 --
43 -- l_fe_attr_list := xdp_engine.get_fe_attributeval_list(p_fe_name) ;
44 --
45 --
46 -- FOR i IN 1..l_fe_attr_list.COUNT LOOP
47 --
48 -- xnp_xml_utils.write_element(
49 -- l_fe_attr_list(i).parameter_name,
50 -- l_fe_attr_list(i).parameter_value ) ;
51 --
52 -- END LOOP ;
53 --
54 -- xnp_xml_utils.get_document(l_op_data) ;
55 --
56 -- xnp_control_u.create_msg(xnp$operation=>'OPEN',
57 -- xnp$op_data=>l_op_data,
58 -- x_msg_header=>l_msg_header,
59 -- x_msg_text=>l_msg_text,
60 -- x_error_code=>x_error_code,
61 -- x_error_message=>x_error_message
62 -- ) ;
63 --
64 -- IF (x_error_code = 0) THEN
65 --
66 -- talk_to_adapter(p_channel_name,
67 -- l_msg_text,
68 -- x_error_code,
69 -- x_error_message ) ;
70 --
71 -- END IF ;
72 */
73
74 EXCEPTION
75 WHEN NO_DATA_FOUND THEN
76 fnd_message.set_name('XNP','INVALID_FE_CONFIGURATION');
77 fnd_message.set_token('FE_NAME',p_fe_name) ;
78 x_error_message := fnd_message.get ;
79 x_error_code := xnp_errors.G_INVALID_FE_CONFIGURATION;
80
81 WHEN OTHERS THEN
82 x_error_code := SQLCODE ;
83 x_error_message := SQLERRM ;
84
85 END open;
86
87 /**********************************************************************************
88 ***** PROCEDURE: CLOSE()
89 *******************************************************************************/
90
91 PROCEDURE close( p_fe_name in VARCHAR2
92 ,p_channel_name in VARCHAR2
93 ,x_error_code OUT NOCOPY NUMBER
94 ,x_error_message OUT NOCOPY VARCHAR2 )
95 IS
96
97 l_fe_attributes fe_data ;
98
99 BEGIN
100
101
102 null;
103
104
105 /* This procedure needs to be deleted once the SEED data is fixed
106 -- user_control( p_fe_name => p_fe_name
107 -- ,p_channel_name => p_channel_name
108 -- ,p_operation => 'CLOSE'
109 -- ,p_operation_data => l_fe_attributes
110 -- ,x_error_code => x_error_code
111 -- ,x_error_message => x_error_message) ;
112 */
113
114 EXCEPTION
115 WHEN OTHERS THEN
116 x_error_code := SQLCODE ;
117 x_error_message := SQLERRM ;
118 END close;
119
120 /**********************************************************************************
121 ***** PROCEDURE: SUSPEND()
122 *******************************************************************************/
123
124 PROCEDURE suspend( p_fe_name in VARCHAR2
125 ,p_channel_name in VARCHAR2
126 ,x_error_code OUT NOCOPY NUMBER
127 ,x_error_message OUT NOCOPY VARCHAR2 )
128 IS
129
130 l_fe_attributes fe_data ;
131
132 BEGIN
133
134
135 user_control( p_fe_name => p_fe_name
136 ,p_channel_name => p_channel_name
137 ,p_operation => 'SUSPEND'
138 ,p_operation_data => l_fe_attributes
139 ,x_error_code => x_error_code
140 ,x_error_message => x_error_message) ;
141
142 EXCEPTION
143 WHEN OTHERS THEN
144 x_error_code := SQLCODE ;
145 x_error_message := SQLERRM ;
146 END suspend;
147
148 /**********************************************************************************
149 ***** PROCEDURE: RESUME()
150 *******************************************************************************/
151
152 PROCEDURE resume( p_fe_name in VARCHAR2
153 ,p_channel_name in VARCHAR2
154 ,x_error_code OUT NOCOPY NUMBER
155 ,x_error_message OUT NOCOPY VARCHAR2 )
156
157 IS
158
159 l_fe_attributes fe_data ;
160
161 BEGIN
162
163
164 user_control( p_fe_name => p_fe_name
165 ,p_channel_name => p_channel_name
166 ,p_operation => 'RESUME'
167 ,p_operation_data => l_fe_attributes
168 ,x_error_code => x_error_code
169 ,x_error_message => x_error_message) ;
170
171 EXCEPTION
172 WHEN OTHERS THEN
173 x_error_code := SQLCODE ;
174 x_error_message := SQLERRM ;
175 END resume ;
176
177 /**********************************************************************************
178 ***** PROCEDURE: SHUTDOWN()
179 *******************************************************************************/
180
181 PROCEDURE shutdown( p_fe_name in VARCHAR2
182 ,p_channel_name in VARCHAR2
183 ,x_error_code OUT NOCOPY NUMBER
184 ,x_error_message OUT NOCOPY VARCHAR2 )
185
186
187 IS
188
189 l_fe_attributes fe_data ;
190
191 BEGIN
192
193
194 user_control( p_fe_name => p_fe_name
195 ,p_channel_name => p_channel_name
196 ,p_operation => 'SHUTDOWN_NORMAL'
197 ,p_operation_data => l_fe_attributes
198 ,x_error_code => x_error_code
199 ,x_error_message => x_error_message) ;
200
201 EXCEPTION
202 WHEN OTHERS THEN
203 x_error_code := SQLCODE ;
204 x_error_message := SQLERRM ;
205 END shutdown ;
206
207 /****************************************************************************
208 *** PROCEDURE: user_control()
209 ****************************************************************************/
210
211 PROCEDURE user_control( p_fe_name IN VARCHAR2
212 ,p_channel_name IN VARCHAR2
213 ,p_operation IN VARCHAR2
214 ,p_operation_data IN fe_data
215 ,x_error_code OUT NOCOPY NUMBER
216 ,x_error_message OUT NOCOPY VARCHAR2 )
217 IS
218
219 l_msg_header xnp_message.msg_header_rec_type;
220 l_msg_text VARCHAR2(32767) ;
221 l_op_data VARCHAR2(32767) ;
222 l_count NUMBER ;
223
224 BEGIN
225
226 xnp_xml_utils.initialize_doc ;
227 xnp_xml_utils.write_element('FE_NAME', p_fe_name) ;
228
229 /* generate XML for the rest of the attributes */
230
231 l_count := p_operation_data.COUNT ;
232
233 FOR i IN 1..l_count LOOP
234
235 xnp_xml_utils.write_element (
236 p_operation_data(i).attribute_name,
237 p_operation_data(i).attribute_value
238 );
239
240 END LOOP;
241
242 xnp_xml_utils.get_document(l_op_data) ;
243
244 xnp_control_u.create_msg(xnp$operation=>p_operation,
245 xnp$op_data=>l_op_data,
246 x_msg_header=>l_msg_header,
247 x_msg_text=>l_msg_text,
248 x_error_code=>x_error_code,
249 x_error_message=>x_error_message
250 ) ;
251
252 IF (x_error_code = 0) THEN
253 talk_to_adapter(p_channel_name,
254 l_msg_text,
255 x_error_code,
256 x_error_message ) ;
257 END IF ;
258 EXCEPTION
259 WHEN OTHERS THEN
260 x_error_code := SQLCODE ;
261 x_error_message := SQLERRM ;
262
263 END user_control ;
264
265
266 /****************************************************************************
267 *** PROCEDURE: close_file()
268 ****************************************************************************/
269 PROCEDURE CLOSE_FILE( p_fe_name IN VARCHAR2
270 ,p_channel_name IN VARCHAR2
271 ,p_file_name IN VARCHAR2 DEFAULT NULL
272 ,x_error_code OUT NOCOPY NUMBER
273 ,x_error_message OUT NOCOPY VARCHAR2 )
274 IS
275
276 l_file_attr fe_data ;
277
278 BEGIN
279
280 xnp_xml_utils.initialize_doc ;
281 xnp_xml_utils.write_element('FE_NAME', p_fe_name) ;
282
283 /* generate XML for the rest of the attributes */
284
285 l_file_attr(1).attribute_name := 'FILE_NAME' ;
286 l_file_attr(1).attribute_value := p_file_name ;
287
288 user_control( p_fe_name => p_fe_name
289 ,p_channel_name => p_channel_name
290 ,p_operation => 'CLOSEFILE'
291 ,p_operation_data => l_file_attr
292 ,x_error_code => x_error_code
293 ,x_error_message => x_error_message) ;
294
295 EXCEPTION
296 WHEN OTHERS THEN
297 x_error_code := SQLCODE ;
298 x_error_message := SQLERRM ;
299
300 END close_file ;
301
302 /****************************************************************************
303 *** PROCEDURE: new ftp() API
304 *** 11.5.6: Now this API uses new Adapter Business Object
305 ****************************************************************************/
306
307 PROCEDURE FTP( p_channel_name IN VARCHAR2
308 ,p_file_name IN VARCHAR2 DEFAULT NULL
309 ,x_error_code OUT NOCOPY NUMBER
310 ,x_error_message OUT NOCOPY VARCHAR2 )
311
312 IS
313 l_file_name VARCHAR2(1024);
314
315 BEGIN
316
317 IF p_file_name IS NOT NULL THEN
318 l_file_name := '<FILE_NAME>'||p_file_name||'</FILE_NAME>';
319 ELSE
320 l_file_name := NULL;
321 END IF;
322
323 xdp_adapter.GENERIC_OPERATION(p_Channel_Name,
324 'FTP_FILE',
325 l_file_name,
326 x_error_code,
327 x_error_message);
328 EXCEPTION
329 WHEN OTHERS THEN
330 x_error_code := SQLCODE ;
331 x_error_message := SQLERRM ;
332 END ftp;
333
334 /****************************************************************************
335 *** PROCEDURE: ftp()
336 *** maintained for backward compatibility
337 ****************************************************************************/
338 PROCEDURE FTP( p_fe_name IN VARCHAR2
339 ,p_channel_name IN VARCHAR2
340 ,p_file_name IN VARCHAR2 DEFAULT NULL
341 ,x_error_code OUT NOCOPY NUMBER
342 ,x_error_message OUT NOCOPY VARCHAR2 )
343
344 IS
345 -- l_file_attr fe_data ;
346
347 BEGIN
348
349 -- xnp_xml_utils.initialize_doc ;
350 -- xnp_xml_utils.write_element('FE_NAME', p_fe_name) ;
351 --
352 -- /* generate XML for the rest of the attributes */
353 --
354 -- l_file_attr(1).attribute_name := 'FILE_NAME' ;
355 -- l_file_attr(1).attribute_value := p_file_name ;
356 --
357 -- user_control( p_fe_name => p_fe_name
358 -- ,p_channel_name => p_channel_name
359 -- ,p_operation => 'FTP_FILE'
360 -- ,p_operation_data => l_file_attr
361 -- ,x_error_code => x_error_code
362 -- ,x_error_message => x_error_message) ;
363
364 FTP(p_Channel_Name,
365 p_file_name,
366 x_error_code,
367 x_error_message);
368
369 EXCEPTION
370 WHEN OTHERS THEN
371 x_error_code := SQLCODE ;
372 x_error_message := SQLERRM ;
373 END ftp;
374
375 /****************************************************************************
376 *** PROCEDURE: talk_to_adapter()
377 ****************************************************************************/
378
379 PROCEDURE talk_to_adapter(p_channel_name in VARCHAR2,
380 p_msg_text in VARCHAR2,
381 x_error_code OUT NOCOPY NUMBER,
382 x_error_message OUT NOCOPY VARCHAR2)
383 IS
384 l_msg_text VARCHAR2(32767) ;
385 l_channel_name VARCHAR2(1024) ;
386 BEGIN
387 x_error_code := 0;
388 x_error_message := null;
389
390 xnp_pipe.write(p_channel_name,
391 p_msg_text,
392 x_error_code,
393 x_error_message ) ;
394
395 IF (x_error_code = 0) THEN
396
397 l_channel_name := p_channel_name || '_REPLY' ;
398
399 xnp_pipe.read(l_channel_name,
400 l_msg_text,
401 x_error_code,
402 x_error_message,
403 45) ;
404
405 /* get adapter status on successful Pipe Reads */
406
407 IF (x_error_code = 0) THEN
408 xnp_xml_utils.decode(l_msg_text,'STATUS_CODE',
409 x_error_code) ;
410 xnp_xml_utils.decode(l_msg_text,'DESCRIPTION',
411 x_error_message) ;
412 END IF ;
413 END IF;
414
415 END talk_to_adapter ;
416
417
418 /***************************************************************************
419 ***** Procedure: NOTIFY_FMC()
420 ***** Purpose: Notifies the FMC of Adapter Erors.
421 ***** Description: Starts a Workflow to notify the FMC. The FMC waits
422 ***** for a response from an FMC user.
423 ****************************************************************************/
424
425 PROCEDURE notify_fmc
426 (p_msg_header IN xnp_message.msg_header_rec_type
427 ,p_msg_text IN VARCHAR2
428 ,x_error_code OUT NOCOPY NUMBER
429 ,x_error_message OUT NOCOPY VARCHAR2
430 )
431 IS
432
433 l_item_type VARCHAR2(1024) ;
434 l_item_key VARCHAR2(4000) ;
435 l_performer VARCHAR2(1024) ;
436 l_fe_name VARCHAR2(1024) ;
437 l_channel_name VARCHAR2(1024) ;
438 l_description VARCHAR2(1024) ;
439
440 l_NameArray Wf_Engine.NameTabTyp;
441 l_ValArray Wf_Engine.TextTabTyp;
442
443 CURSOR get_performer_name IS
444 SELECT xms.role_name
445 FROM xnp_msg_types_b xms,
446 xnp_msgs xmg
447 WHERE xmg.msg_id = p_msg_header.message_id
448 AND xms.msg_code = xmg.msg_code;
449
450 BEGIN
451
452 /* Create a Workflow Context */
453
454 OPEN get_performer_name ;
455 FETCH get_performer_name INTO l_performer ;
456 CLOSE get_performer_name ;
457
458 -- Notification performer is defaulted to 'NP_SYSADMIN'
459 -- Bug 1658346
460 -- Notification performer defaulted to 'OP_SYSADMIN' rnyberg March 08, 2002
461 IF l_performer IS NULL THEN
462 l_performer := 'FND_RESP535:21704';
463 END IF;
464 -- l_performer := xdp_utilities.get_wf_notifrecipient(l_performer) ;
465
466
467 l_item_type := 'XDPWFSTD' ;
468 l_item_key := 'MESSAGE_' || TO_CHAR(p_msg_header.message_id) ;
469
470 xnp_xml_utils.decode(p_msg_text,'FE_NAME',l_fe_name) ;
471 xnp_xml_utils.decode(p_msg_text,'CHANNEL_NAME',l_channel_name) ;
472 xnp_xml_utils.decode(p_msg_text,'DESCRIPTION',l_description) ;
473
474 wf_core.context('XDP_WF_STANDARD',
475 'ADAPTER_ERROR',
476 l_item_type,
477 l_item_key) ;
478
479 wf_engine.createprocess(l_item_type,
480 l_item_key,
481 'ADAPTER_ERROR_NOTIFICATION') ;
482
483 -- modified the code to replace the multiple calls to set the
484 -- item attribute with Wf_Engine.SetItemAttrTextArray
485 -- skilaru 03/23/2001
486
487 /****
488 wf_engine.SetItemAttrText(
489 ItemType=>l_item_type,
490 ItemKey=>l_item_key,
491 aname=>'FE_NAME',
492 avalue=>l_fe_name);
493
494 wf_engine.SetItemAttrText(
495 ItemType=>l_item_type,
496 ItemKey=>l_item_key,
497 aname=>'CHANNEL_NAME',
498 avalue=>l_channel_name);
499
500 wf_engine.SetItemAttrText(
501 ItemType=>l_item_type,
502 ItemKey=>l_item_key,
503 aname=>'DESCRIPTION',
504 avalue=>l_description);
505
506 wf_engine.SetItemAttrText(
507 ItemType=>l_item_type,
508 ItemKey=>l_item_key,
509 aname=>'MSG_HANDLING_ROLE',
510 avalue=>l_performer);
511 ****/
512 --
513 -- Initialize workflow item attributes
514 --
515 l_NameArray(1) := 'FE_NAME';
516 l_ValArray(1) := l_fe_name;
517 l_NameArray(2) := 'CHANNEL_NAME';
518 l_ValArray(2) := l_channel_name;
519 l_NameArray(3) := 'DESCRIPTION';
520 l_ValArray(3) := l_description;
521 l_NameArray(4) := 'MSG_HANDLING_ROLE';
522 l_ValArray(4) := l_performer;
523
524 Wf_Engine.SetItemAttrTextArray (l_item_type, l_item_key, l_NameArray, l_ValArray);
525
526 wf_engine.startprocess(l_item_type,
527 l_item_key ) ;
528
529 EXCEPTION
530 WHEN OTHERS THEN
531 x_error_code := SQLCODE;
532 x_error_message := SQLERRM;
533
534 END notify_fmc ;
535
536 END xnp_adapter ;