[Home] [Help]
PACKAGE BODY: APPS.FUN_INITIATOR_WF_PKG
Source
1 PACKAGE BODY FUN_INITIATOR_WF_PKG AS
2 /* $Header: funwintb.pls 120.41 2011/05/16 20:16:38 jmary ship $ */
3
4
5 -- Set workflow item attributes for the process
6
7 /*-----------------------------------------------------|
8 | PROCEDURE SET_ATTRIBUTES |
9 |------------------------------------------------------|
10 | Parameters item_type IN Varchar2 |
11 | item_key IN Varchar2 |
12 | act_id IN NUMBER |
13 | funcmode IN Varchar2 |
14 | resultout IN Varchar2 |
15 | |
16 |------------------------------------------------------|
17 | Description |
18 | Set the attributes of the WF process |
19 | |
20 | |
21 | |
22 | |
23 | |
24 |-----------------------------------------------------*/
25
26
27 PROCEDURE SET_ATTRIBUTES (itemtype IN VARCHAR2,
28 itemkey IN VARCHAR2,
29 actid IN NUMBER,
30 funcmode IN VARCHAR2,
31 resultout OUT NOCOPY VARCHAR2)
32
33 IS
34
35 l_batch_id NUMBER;
36 l_trx_id NUMBER;
37 l_initiator_id NUMBER;
38 l_recipient_id NUMBER;
39 l_batch_number Varchar2(20);
40 l_gl_date DATE;
41 l_batch_date DATE;
42 l_recipient_name Varchar2(360);
43 l_invoice_flag Varchar2(1);
44 l_event_name Varchar2(240);
45 l_status_code Varchar2(15);
46 l_role_name Varchar2(30);
47 l_event_key Varchar2(64);
48 l_trx_amt NUMBER;
49 l_currency Varchar2(15);
50
51 l_initiator_name VARCHAR2(360);
52 l_initiator_person VARCHAR2(360);
53 l_trx_number fun_trx_headers.trx_number%TYPE;
54 l_user_env_lang varchar2(5);
55
56 BEGIN
57 l_status_code :='Test';
58 IF (funcmode = 'RUN') THEN
59
60 -- Obtain the batch_id and trx_id
61
62 -- Note the attributes BATCH_ID and TRX_ID are set
63 -- by the receiving event
64
65 l_batch_id := wf_engine.getitemattrnumber(itemtype,
66 itemkey,
67 'BATCH_ID');
68
69 l_trx_id := wf_engine.getitemattrnumber(itemtype,
70 itemkey,
71 'TRX_ID');
72 l_user_env_lang := wf_engine.GetItemAttrText
73 (itemtype => itemtype,
74 itemkey => itemkey,
75 aname => 'USER_LANG');
76
77
78
79 -- obtain the attrubutes value from the database
80 BEGIN
81
82 -- Changes for AME Uptake, 3671923. Bidisha S, 28 Jun 2004
83 -- Modified the query below to retrieve the recipient org name
84 -- and the transaction number
85 SELECT ftb.batch_number,
86 ftb.gl_date,
87 ftb.batch_date,
88 fth.initiator_id,
89 fth.recipient_id,
90 fth.invoice_flag,
91 -- decode(fth.init_amount_cr,0, fth.init_amount_dr, NULL, fth.init_amount_dr, fth.init_amount_cr),
92 -- Bug No. 6854675 Changed the select statement to fetch a numeric value
93 --ltrim(to_char(decode(nvl(ftb.running_total_cr,0),0,ftb.running_total_dr,ftb.running_total_cr),'999999999.99')),
94 decode(nvl(ftb.running_total_cr,0),0,ftb.running_total_dr,ftb.running_total_cr),
95 ftb.currency_code,
96 hzp.party_name ,
97 fth.trx_number,
98 ini.party_name
99 INTO l_batch_number,
100 l_gl_date,
101 l_batch_date,
102 l_initiator_id,
103 l_recipient_id,
104 l_invoice_flag,
105 l_trx_amt,
106 l_currency,
107 l_recipient_name,
108 l_trx_number,
109 l_initiator_name
110 FROM fun_trx_batches ftb,
111 fun_trx_headers fth,
112 hz_parties hzp,
113 hz_parties ini
114 WHERE ftb.batch_id = l_batch_id
115 AND ftb.batch_id=fth.batch_id
116 AND fth.recipient_id=hzp.party_id
117 AND fth.initiator_id=ini.party_id
118 AND fth.trx_id=l_trx_id;
119 EXCEPTION
120 WHEN NO_DATA_FOUND THEN
121 NULL;
122
123 END;
124
125
126 -- Added by JMARY for bug 11880642
127 BEGIN
128 SELECT p.PARTY_NAME PERSON_NAME
129 INTO l_initiator_person
130 FROM hz_parties p,
131 fnd_user fu,
132 fun_trx_batches b
133 WHERE fu.person_party_id = p.party_id
134 AND fu.user_id = b.created_by
135 AND b.batch_id = l_batch_id;
136 EXCEPTION
137 WHEN NO_DATA_FOUND THEN
138 NULL;
139 END;
140
141 -- set the attribute
142
143 -- batch number
144 wf_engine.setitemattrtext(itemtype,
145 itemkey,
146 'BATCH_NUMBER',
147 l_batch_number);
148
149 -- gl_date
150 wf_engine.setitemattrdate(itemtype,
151 itemkey,
152 'GL_DATE',
153 l_gl_date);
154
155 -- batch_date
156
157 wf_engine.setitemattrdate(itemtype,
158 itemkey,
159 'BATCH_DATE',
160 l_batch_date);
161
162 -- initiator_id
163
164 wf_engine.setitemattrnumber(itemtype,
165 itemkey,
166 'INITIATOR_ID',
167 l_initiator_id);
168 -- recipient_id
169
170 wf_engine.setitemattrnumber(itemtype,
171 itemkey,
172 'RECIPIENT_ID',
173 l_recipient_id);
174
175 -- invoice_flag
176
177 wf_engine.setitemattrtext(itemtype,
178 itemkey,
179 'INVOICE_FLAG',
180 l_invoice_flag);
181
182 -- transaction amount
183
184 wf_engine.setitemattrnumber(itemtype,
185 itemkey,
186 'TRX_AMT',
187 l_trx_amt);
188
189
190 -- Currency
191
192 wf_engine.setitemattrtext(itemtype,
193 itemkey,
194 'CURRENCY',
195 l_currency);
196
197 -- recipient name
198
199 wf_engine.setitemattrtext(itemtype,
203
200 itemkey,
201 'RECIPIENT_NAME',
202 l_recipient_name);
204 -- Added by JMARY for bug 11880642 (From Role)
205 wf_engine.SetItemAttrText(itemtype => itemtype,
206 itemkey => itemkey,
207 aname => '#FROM_ROLE',
208 avalue => l_initiator_person);
209
210
211
212 /* Start of changes for AME Uptake, 3671923. Bidisha S, 29 Jun 2004 */
213
214 wf_engine.setitemattrtext(itemtype,
215 itemkey,
216 'INITIATOR_NAME',
217 l_initiator_name);
218
219 wf_engine.setitemattrtext(itemtype,
220 itemkey,
221 'TRX_NUMBER',
222 l_trx_number);
223 -- Contact information
224 --l_role_name :=FUN_WF_COMMON.get_contact_role(l_initiator_id);
225
226 -- wf_engine.setitemattrtext(itemtype,
227 -- itemkey,
228 -- 'CONTACT',
229 -- l_role_name);
230
231 /* End of changes for AME Uptake, 3671923. Bidisha S, 29 Jun 2004 */
232
233
234 -- Get the status code from the event name
235
236 l_event_name := rtrim(ltrim(lower(wf_engine.getitemattrtext(itemtype,
237 itemkey,
238 'EVENT_NAME')), ' '), ' ');
239
240 -- Case check
241 if(INSTR(l_event_name, 'oracle.apps.fun.manualtrx.complete.receive')<>0) then
242 l_status_code:='COMPLETE';
243 elsif (INSTR(l_event_name, 'oracle.apps.fun.manualtrx.rejection.receive')<>0) then
244 l_status_code :='REJECTED';
245 elsif (INSTR(l_event_name, 'oracle.apps.fun.manualtrx.approval.receive')<>0) then
246 l_status_code :='APPROVED';
247
248 -- set the event key for the AR/GL transfer event
249 l_event_key :=FUN_INITIATOR_WF_PKG.generate_key(p_batch_id =>l_batch_id,
250 p_trx_id => l_trx_id);
251
252 wf_engine.setitemattrtext(itemtype,
253 itemkey,
254 'TRANSFER_KEY',
255 l_event_key);
256
257 elsif (INSTR(l_event_name,'oracle.apps.fun.manualtrx.reception.receive')<>0) then
258 l_status_code :='RECEIVED';
259 elsif (INSTR(l_event_name, 'oracle.apps.fun.manualtrx.error.receive')<>0) then
260 l_status_code :='ERROR';
261 else
262 l_status_code :='UNEXPECTED';
263 end if;
264
265 -- set the status code
266
267 wf_engine.setitemattrtext(itemtype,
268 itemkey,
269 'STATUS',
270 l_status_code);
271
272 wf_engine.setitemattrnumber(itemtype,
273 itemkey,
274 'BATCH_ID',
275 l_batch_id);
276
277 wf_engine.setitemattrnumber(itemtype,
278 itemkey,
279 'TRX_ID',
280 l_trx_id);
281
282 wf_engine.setitemattrnumber(itemtype,
283 itemkey,
284 'PARTY_ID',
285 l_initiator_id);
286 wf_engine.setitemattrtext(itemtype,
287 itemkey,
288 'USER_LANG',
289 l_user_env_lang);
290
291 -- no result needed
292 resultout := 'COMPLETE';
293 return;
294 END IF;
295
296 EXCEPTION
297
298 WHEN OTHERS THEN
299
300 -- Rcords this function call in the error system
301 -- in the case of an exception.
302
303 wf_core.context('FUN_INITIATOR_WF_PKG', 'SET_ATTRIBUTES',
304 itemtype, itemkey, to_char(actid), funcmode);
305
306 END SET_ATTRIBUTES;
307
308
309
310
311 -- Update Intercompany Transaction Status
312
313 /*-----------------------------------------------------|
314 | PROCEDURE UPDATE_STATUS |
315 |------------------------------------------------------|
316 | Parameters item_type IN Varchar2 |
317 | item_key IN Varchar2 |
318 | act_id IN NUMBER |
319 | funcmode IN Varchar2 |
320 | resultout IN Varchar2 |
321 | |
322 |------------------------------------------------------|
323 | Description |
324 | Update the intercompany transaction |
325 | status |
326 | |
327 | |
328 | |
329 | |
330 |-----------------------------------------------------*/
331
332
333 PROCEDURE UPDATE_STATUS ( itemtype in varchar2,
334 itemkey in varchar2,
335 actid in number,
336 funcmode in varchar2,
337 resultout out NOCOPY varchar2)
338
339 IS
340
341 -- Local variables
342
343 l_trx_id NUMBER;
344 l_batch_id NUMBER;
345 l_status VARCHAR2(15);
346 l_return_status Varchar2(1);
347 l_message_count NUMBER;
351
348 l_message_data Varchar2(1000);
349
350 BEGIN
352 -- get the attribute values
353
354 l_trx_id := wf_engine.GetItemAttrNumber( itemtype
355 , itemkey
356 , 'TRX_ID'
357 );
358
359 l_batch_id := wf_engine.GetItemAttrNumber( itemtype
360 , itemkey
361 , 'BATCH_ID'
362 );
363
364 l_status := wf_engine.GetItemAttrText( itemtype
365 ,itemkey
366 , 'STATUS'
367 );
368
369
370 -- Note: This function will call Transaction API
371 -- to update the status of a transaction
372 IF (funcmode = 'RUN') THEN
373
374 FUN_TRX_PVT.update_trx_status(p_api_version =>1.0,
375 x_return_status =>l_return_status,
376 x_msg_count => l_message_count,
377 x_msg_data => l_message_data,
378 p_trx_id => l_trx_id,
379 p_update_status_to => l_status);
380
381 -- Handle the API call return
382
383 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
384
385 raise FND_API.G_EXC_ERROR;
386 END IF;
387
388
389 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
390
391 raise FND_API.G_EXC_UNEXPECTED_ERROR;
392 END IF;
393
394 -- Assume the status update is successful
395
396
397 if( l_status='APPROVED') then
398 resultout := 'COMPLETE:APPROVED';
399 elsif (l_status ='REJECTED' ) then
400 resultout := 'COMPLETE:REJECTED';
401 elsif (l_status ='ERROR') then
402 resultout :='COMPLETE:ERROR';
403 else
404 resultout := 'COMPLETE:OTHERS';
405
406 END IF;
407
408 ELSE
409 resultout := 'COMPLETE';
410 END IF;
411
412 EXCEPTION
413 WHEN OTHERS THEN
414 WF_CORE.Context('FUN_INITIATOR_WF_PKG', 'UPDATE_STATUS',
415 itemtype, itemkey, actid, funcmode);
416 RAISE;
417
418
419 END UPDATE_STATUS;
420
421
422
423 -- Transfer the transaction to AR interface table
424 --
425
426 /*-----------------------------------------------------|
427 | PROCEDURE TRANSFER_AR |
428 |------------------------------------------------------|
429 | Parameters itemtype IN Varchar2 |
430 | itemkey IN Varchar2 |
431 | actid IN NUMBER |
432 | funcmode IN Varchar2 |
433 | resultout IN Varchar2 |
434 | |
435 |------------------------------------------------------|
436 | Description |
437 | Transfer the intercompany transaction to |
438 | AR interface table: AR_INTERFACE_LINES_ALL |
439 | |
440 | |
441 | |
442 | |
443 |-----------------------------------------------------*/
444
445
446
447 PROCEDURE TRANSFER_AR (itemtype IN VARCHAR2,
448 itemkey IN VARCHAR2,
449 actid IN NUMBER,
450 funcmode IN VARCHAR2,
451 resultout OUT NOCOPY VARCHAR2)
452
453 IS
454 l_batch_id NUMBER;
455 l_trx_id NUMBER;
456 l_recipient_id NUMBER;
457 l_trx_type_id Number;
458 l_line AR_Interface_line;
459 l_dist_line AR_Interface_Dist_line;
460 l_ou_id Number;
461 l_ledger_id Number;
462 l_le_id Number;
463 l_ap_ou_id Number;
464 l_ap_le_id Number;
465 l_initiator_id Number;
466 l_success boolean;
467 l_return_status Varchar2(1);
468 l_customer_id Number;
469 l_address_id Number;
470 l_site_use_id Number;
471 l_ar_trx_type_id Number;
472 l_ar_memo_line_id Number;
473 l_ar_trx_type_name RA_CUST_TRX_TYPES_ALL.name%TYPE; -- <bug 3450031>
474 l_ar_memo_line_name AR_MEMO_LINES_ALL_VL.name%TYPE; -- <bug 3450031>
475 l_default_term_id NUMBER;
476 l_term_id number;
477 l_message_count NUMBER;
478 l_message_data Varchar2(1000);
479 l_count Number:=0;
480 x_msg_data varchar2(1000);-- for the message returned form get_customer
481 l_parameter_list WF_PARAMETER_LIST_T :=wf_parameter_list_t();
482 l_event_key VARCHAR2(240);
483 -- added for bug: 7271703
484 l_batch_num varchar2(20);
485
486 -- Cursor to retrieve the line information
487 CURSOR c_line (p_batch_id IN Number,
488 p_trx_id IN Number) IS
489 SELECT decode(ftl.init_amount_cr,
490 0, ftl.init_amount_dr,
491 NULL, ftl.init_amount_dr,
492 ftl.init_amount_cr * (-1)),
493 ftl.line_id
494 FROM FUN_TRX_LINES ftl
495 WHERE p_trx_id = ftl.trx_id;
496
497 -- cursor to retrieve the initiator and recipient party / LE ID
498 -- Bug 7271703. also fetching batch number in cursor c_info
499
500 cursor c_info(p_trx_id IN Number) IS
501 SELECT ftb.batch_number,
502 ftb.initiator_id,
503 ftb.from_le_id,
504 ftb.from_ledger_id,
505 fth.recipient_id,
506 fth.to_le_id,
507 ftb.trx_type_id,
508 -- fth.ledger_id,
509 ftb.exchange_rate_type,
510 ftb.currency_code,
511 ftb.description,
512 ftb.gl_date,
513 ftb.batch_id,
514 fth.trx_id,
515 ftb.from_ledger_id,
516 ftb.batch_date
517 FROM FUN_TRX_BATCHES ftb,
518 FUN_TRX_HEADERS fth
519 WHERE fth.trx_id=p_trx_id
520 AND fth.batch_id=ftb.batch_id
521 AND fth.status='APPROVED';
522
523 -- cursor to retrieve the distribution information
524
525 CURSOR c_dist (p_trx_id IN Number) IS
526 SELECT
527 DECODE(FDL.dist_type_flag, 'L',
528 decode(fdl.amount_cr,
529 0, fdl.amount_dr * (-1),
530 NULL, fdl.amount_dr * (-1),
531 fdl.amount_cr),
532 'R', NULL,
533 NULL), -- <bug 3450031>
534 DECODE(FDL.dist_type_flag, 'L', NULL,
535 'R', 100,
536 NULL), -- <bug 3450031>
537 DECODE(FDL.dist_type_flag, 'R', 'REC',
538 'L', 'REV',
539 NULL), -- <bug 3450031>
540 fdl.ccid,
541 fth.batch_id,
542 fth.trx_id,
543 ftl.line_id
544 FROM FUN_TRX_HEADERS fth,
545 FUN_TRX_LINES ftl,
546 FUN_DIST_LINES fdl
547 WHERE fth.trx_id=p_trx_id
548 AND ftl.trx_id=fth.trx_id
549 AND ftl.line_id=fdl.line_id
550 AND fdl.party_type_flag='I';
551
555 select PAYMENT_TERM_ID
552 --Bug: 9052792. Cursor to get the term_id from site level.
553
554 CURSOR c_site_term(p_site_use_id NUMBER) IS
556 from HZ_CUST_SITE_USES_ALL
557 where site_use_code = 'BILL_TO'
558 and site_use_id = p_site_use_id;
559
560 --Bug: 9052792. Cursor to get the term_id from customer account level.
561
562 CURSOR c_account_term(p_cust_acct_id NUMBER) IS
563 select STANDARD_TERMS
564 from HZ_CUSTOMER_PROFILES
565 where cust_account_id = p_cust_acct_id;
566
567 BEGIN
568
569 if(funcmode='RUN') then
570
571 -- get the batch_id from the item attributes
572
573 l_batch_id := wf_engine.getitemattrnumber(itemtype,
574 itemkey,
575 'BATCH_ID');
576
577 l_trx_id := wf_engine.getitemattrnumber(itemtype,
578 itemkey,
579 'TRX_ID');
580 WF_EVENT.AddParameterToList(p_name=>'BATCH_ID',
581 p_value=>to_char(l_batch_id),
582 p_parameterlist =>l_parameter_list
583 );
584
585
586 WF_EVENT.AddParameterToList(p_name=>'TRX_ID',
587 p_value=>to_char(l_trx_id),
588 p_parameterlist =>l_parameter_list
589 );
590
591
592 wf_engine.setitemattrtext(itemtype,
593 itemkey,
594 'ERROR_MSG',
595 'Number of Lines' || l_count || 'Trx:' || l_trx_id || 'Test1');
596
597 -- set the generic variables
598
599 open c_info(l_trx_id);
600 LOOP
601 fetch c_info INTO
602 l_batch_num,
603 l_initiator_id,
604 l_le_id,
605 l_ledger_id,
606 l_recipient_id,
607 l_ap_le_id,
608 l_trx_type_id,
609 l_line.conversion_type,
610 l_line.currency_code,
611 l_line.description,
612 l_line.gl_date,
613 l_line.interface_line_attribute1,
614 l_line.interface_line_attribute2,
615 l_line.set_of_books_id,
616 l_line.trx_date;
617 exit when c_info%NOTFOUND;
618 END LOOP;
619 CLOSE c_info;
620
621 wf_engine.setitemattrtext(itemtype,
622 itemkey,
623 'ERROR_MSG',
624 'Number of Lines' || l_count || 'init:' || l_initiator_id || 'Test2');
625
626 -- Obtain the OU id
627
628 l_ou_id :=FUN_TCA_PKG.get_ou_id(l_initiator_id);
629 l_ap_ou_id :=FUN_TCA_PKG.get_ou_id(l_recipient_id);
630
631 if((l_ou_id is NULL) OR (l_ap_ou_id is NULL)) then
632 raise FND_API.G_EXC_UNEXPECTED_ERROR;
633 END IF;
634
635
636 -- Transfer to table RA_INTERFACE_LINES
637
638
639 open c_line(l_batch_id, l_trx_id);
640
641
642 LOOP
643
644 -- Amounts Transferred to AR should be
645 -- Init Trx Amount: 1000 Cr, AR Amount: -1000
646 -- Init Trx Amount: -1000 Cr, AR Amount: 1000
647 -- Init Trx Amount: 1000 Dr, AR Amount: 1000
648 -- Init Trx Amount: -1000 Dr, AR Amount: -1000
649
650 FETCH c_line INTO
651 l_line.amount,
652 l_line.interface_line_attribute3;
653
654 EXIT WHEN c_line%NOTFOUND;
655 l_line.org_id:=l_ou_id;
656 --added this for gscc warning
657 -- Bug 9634573 fetched src name from the table
658
659 SELECT name into l_line.BATCH_SOURCE_NAME FROM
660 RA_BATCH_SOURCES_ALL WHERE BATCH_SOURCE_ID = 22 AND org_id = l_ou_id;
661
662 -- l_line.BATCH_SOURCE_NAME:= 'Global Intercompany';
663 l_line.INTERFACE_LINE_CONTEXT:='INTERNAL_ALLOCATIONS';
664 l_line.LINE_TYPE:='LINE';
665 -- l_line.UOM_NAME :='Each'; bug 8675533
666 l_count:=l_count+1;
667 -- obtain the AR transaction type / memo_line
668
669 -- ER:8288979. Passing l_trx_id.
670 -- <bug 3450031>
671 FUN_TRX_TYPES_PUB.get_trx_type_map (
672 p_org_id => l_ou_id,
673 p_trx_type_id => l_trx_type_id,
674 p_trx_date => l_line.trx_date,
675 p_trx_id => l_trx_id,
676 x_memo_line_id => l_ar_memo_line_id,
677 x_memo_line_name => l_ar_memo_line_name,
678 x_ar_trx_type_id => l_ar_trx_type_id,
679 x_ar_trx_type_name => l_ar_trx_type_name,
680 x_default_term_id => l_default_term_id);
681
682
683 IF ((l_ar_memo_line_name IS NULL)
684 OR (l_ar_trx_type_name IS NULL)) THEN
685 RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
686 END IF;
687 -- <bug 3450031 end>
688
689 -- Obtain the customer_id and address_id
690
691 -- <bug 3450031>
692 -- Change the passin parameters
693 l_success :=
694 FUN_TRADING_RELATION.get_customer(
695 p_source => 'INTERCOMPANY',
696 p_trans_le_id => l_ap_le_id,
697 p_tp_le_id => l_le_id,
698 p_trans_org_id => l_ap_ou_id,
699 p_tp_org_id => l_ou_id,
700 p_trans_organization_id => l_recipient_id,
701 p_tp_organization_id => l_initiator_id,
702 x_msg_data => x_msg_data,
703 x_cust_acct_id => l_customer_id,
704 x_cust_acct_site_id => l_address_id,
705 x_site_use_id => l_site_use_id);
706
710 END IF;
707 if((l_success<>true) OR (l_customer_id is NULL)
708 OR (l_address_id is NULL)) then
709 raise FND_API.G_EXC_UNEXPECTED_ERROR;
711 --Bug: 9052792.
712 l_term_id := NULL;
713
714 OPEN c_site_term (l_site_use_id);
715 FETCH c_site_term INTO l_term_id;
716 IF c_site_term%NOTFOUND THEN
717 NULL;
718 END IF;
719 CLOSE c_site_term;
720
721 IF l_term_id IS NULL THEN
722 OPEN c_account_term (l_customer_id);
723 FETCH c_account_term INTO l_term_id;
724 IF c_account_term%NOTFOUND THEN
725 NULL;
726 END IF;
727 CLOSE c_account_term;
728 END IF;
729 --Bug: 9126518
730 IF (l_term_id IS NOT NULL AND l_default_term_id IS NOT NULL) THEN
731 l_default_term_id := l_term_id;
732 END IF;
733
734 l_line.orig_system_bill_customer_id:=l_customer_id;
735 l_line.orig_system_bill_address_id :=l_address_id;
736
737 -- insert the line into the AR interface table
738 wf_engine.setitemattrtext(itemtype,
739 itemkey,
740 'ERROR_MSG',
741 'SOURCE:' || l_line.batch_source_name
742 || 'LINE TYPE: ' || l_line.line_type
743 || 'DESCRIPTION:' || l_line.description
744 || 'CURRENCY_CODE:' || l_line.currency_code
745 || 'Set_of_Book:' || l_line.set_of_books_id
746 || 'Conversion Type:' || l_line.conversion_type
747 || 'Test2.5');
748
749
750 -- Bug: 6788142 Added PRIMARY_SALESREP_ID field in the insert query.
751 -- insert into AR Interface table
752 -- Bug: 7271703 populating the INTERFACE_LINE_ATTRIBUTE4 column
753 -- with the batch_number.
754 INSERT INTO RA_INTERFACE_LINES_ALL
755 (
756 AMOUNT,
757 BATCH_SOURCE_NAME,
758 CONVERSION_TYPE,
759 CURRENCY_CODE,
760 CUST_TRX_TYPE_ID, -- <bug 3450031>
761 CUST_TRX_TYPE_NAME, -- <bug 3450031>
762 DESCRIPTION,
763 GL_DATE,
764 INTERFACE_LINE_ATTRIBUTE1,
765 INTERFACE_LINE_ATTRIBUTE2,
766 INTERFACE_LINE_ATTRIBUTE3,
767 INTERFACE_LINE_ATTRIBUTE4,
768 INTERFACE_LINE_CONTEXT,
769 LINE_TYPE,
770 MEMO_LINE_ID, -- <bug 3450031>
771 MEMO_LINE_NAME, -- <bug 3450031>
772 ORG_ID,
773 ORIG_SYSTEM_BILL_ADDRESS_ID,
774 ORIG_SYSTEM_BILL_CUSTOMER_ID,
775 SET_OF_BOOKS_ID,
776 TRX_DATE,
777 TAXABLE_FLAG,
778 TERM_ID,
779 LEGAL_ENTITY_ID,
780 SOURCE_EVENT_CLASS_CODE,
781 PRIMARY_SALESREP_ID
782 )
783 VALUES
784 (
785 l_line.AMOUNT,
786 l_line.BATCH_SOURCE_NAME,
787 l_line.CONVERSION_TYPE,
788 l_line.CURRENCY_CODE,
789 l_ar_trx_type_id,
790 l_ar_trx_type_name, -- <bug 3450031>
791 NVL(l_line.DESCRIPTION,
792 'Transactions from Global Intercompany'), -- <bug 3450031>
793 l_line.GL_DATE,
794 l_line.INTERFACE_LINE_ATTRIBUTE1,
795 l_line.INTERFACE_LINE_ATTRIBUTE2,
796 l_line.INTERFACE_LINE_ATTRIBUTE3,
797 l_batch_num,
798 l_line.INTERFACE_LINE_CONTEXT,
799 l_line.LINE_TYPE,
800 l_ar_memo_line_id,
801 l_ar_memo_line_name, -- <bug 3450031>
802 l_line.ORG_ID,
803 l_line.ORIG_SYSTEM_BILL_ADDRESS_ID,
804 l_line.ORIG_SYSTEM_BILL_CUSTOMER_ID,
805 l_line.SET_OF_BOOKS_ID,
806 l_line.TRX_DATE,
807 -- Bug 9285035: Changed the value from 'S' to 'Y'
808 'Y',
809 --'S',
810 l_default_term_id,
811 l_le_id,
812 'INTERCOMPANY_TRX',
813 '-3'
814 );
815
816 -- Bug No. 6788142. Inserting into RA_INTERFACE_SALESCREDITS_ALL table
817
818 INSERT INTO RA_INTERFACE_SALESCREDITS_ALL
819 (
820 INTERFACE_LINE_CONTEXT ,
821 INTERFACE_LINE_ATTRIBUTE1 ,
822 INTERFACE_LINE_ATTRIBUTE2 ,
823 INTERFACE_LINE_ATTRIBUTE3 ,
824 INTERFACE_LINE_ATTRIBUTE4 ,
825 INTERFACE_LINE_ATTRIBUTE5 ,
826 INTERFACE_LINE_ATTRIBUTE6 ,
827 INTERFACE_LINE_ATTRIBUTE7 ,
828 INTERFACE_LINE_ATTRIBUTE8 ,
829 INTERFACE_LINE_ATTRIBUTE9 ,
830 INTERFACE_LINE_ATTRIBUTE10 ,
831 INTERFACE_LINE_ATTRIBUTE11 ,
832 INTERFACE_LINE_ATTRIBUTE12 ,
833 INTERFACE_LINE_ATTRIBUTE13 ,
834 INTERFACE_LINE_ATTRIBUTE14 ,
835 INTERFACE_LINE_ATTRIBUTE15,
836 SALES_CREDIT_PERCENT_SPLIT,
837 SALES_CREDIT_TYPE_ID,
838 SALESREP_ID,
839 ORG_ID
840 )
841 VALUES
842 (
843 l_line.INTERFACE_LINE_CONTEXT,
844 l_line.INTERFACE_LINE_ATTRIBUTE1,
845 l_line.INTERFACE_LINE_ATTRIBUTE2,
846 l_line.INTERFACE_LINE_ATTRIBUTE3,
847 NULL,
848 NULL,
849 NULL,
850 NULL,
851 NULL,
852 NULL,
853 NULL,
854 NULL,
855 NULL,
856 NULL,
857 NULL,
858 NULL,
859 '100',
860 '1',
861 '-3',
862 l_line.ORG_ID
863 );
864
865 wf_engine.setitemattrtext(itemtype,
866 itemkey,
867 'ERROR_MSG',
868 'Number of Lines: After Insert' || l_count || 'ORG:' || l_line.org_id || 'Test2.75');
869
870 END LOOP;
871
872 close c_line;
873
874 wf_engine.setitemattrtext(itemtype,
875 itemkey,
876 'ERROR_MSG',
877 'Number of Lines' || l_count || 'Test3');
878
879
880 -- Insert into the AR distrubution table
881 -- Amounts Transferred to AR should be
882 -- Ini Dst Amount: 1000 Dr, AR Amount: -1000
883 -- Ini Dst Amount: -1000 Dr, AR Amount: 1000
884 -- Ini Dst Amount: 1000 Cr, AR Amount: 1000
885 -- Ini Dst Amount: -1000 Cr, AR Amount: -1000
886
887 open c_dist(l_trx_id);
888 LOOP
889 FETCH c_dist INTO
890 l_dist_line.AMOUNT,
891 l_dist_line.percent, --<bug 3450031>
892 l_dist_line.account_class, -- <bug 3450031>
893 l_dist_line.CODE_COMBINATION_ID,
894 l_dist_line.INTERFACE_LINE_ATTRIBUTE1,
895 l_dist_line.INTERFACE_LINE_ATTRIBUTE2,
896 l_dist_line.INTERFACE_LINE_ATTRIBUTE3;
897
898 exit when c_dist%NOTFOUND;
899 l_dist_line.ORG_ID :=l_ou_id;
900 l_dist_line.INTERFACE_LINE_CONTEXT:='INTERNAL_ALLOCATIONS';
901 -- Insert the value into the distribution table
902
903
904 INSERT INTO RA_INTERFACE_DISTRIBUTIONS_ALL --<bug 3450031>
905 (
906 ACCOUNT_CLASS,
907 AMOUNT,
908 percent, --<bug 3450031>
909 CODE_COMBINATION_ID,
910 INTERFACE_LINE_ATTRIBUTE1,
911 INTERFACE_LINE_ATTRIBUTE2,
912 INTERFACE_LINE_ATTRIBUTE3,
913 INTERFACE_LINE_ATTRIBUTE4,
914 INTERFACE_LINE_CONTEXT,
915 ORG_ID
916 )
917 VALUES
918 (
919 l_dist_line.ACCOUNT_CLASS,
920 l_dist_line.AMOUNT,
921 l_dist_line.percent, --<bug 3450031>
922 l_dist_line.CODE_COMBINATION_ID,
923 l_dist_line.INTERFACE_LINE_ATTRIBUTE1,
924 l_dist_line.INTERFACE_LINE_ATTRIBUTE2,
925 l_dist_line.INTERFACE_LINE_ATTRIBUTE3,
926 l_batch_num,
927 l_dist_line.INTERFACE_LINE_CONTEXT,
928 l_dist_line.ORG_ID
929 );
930
931 END LOOP;
932 CLOSE c_dist;
933
934 -- <bug 3450031>
935 -- uncomment update status logic
936 -- Update the status
937
938 FUN_TRX_PVT.update_trx_status(p_api_version =>1.0,
939 x_return_status =>l_return_status,
940 x_msg_count => l_message_count,
941 x_msg_data => l_message_data,
942 p_trx_id => l_trx_id,
943 p_update_status_to => 'XFER_AR');
944
945 -- Handle the API call return
946
947 IF l_return_status = FND_API.G_RET_STS_ERROR THEN
948
949 raise FND_API.G_EXC_ERROR;
950 END IF;
951
952
953 IF l_return_status = FND_API.G_RET_STS_UNEXP_ERROR THEN
954
955 raise FND_API.G_EXC_UNEXPECTED_ERROR;
956 END IF;
957
958
959
960 -- Do we need commit? No
961 /*
962 wf_engine.setitemattrtext(itemtype,
963 itemkey,
964 'ERROR_MSG',
965 'Number of Lines' || l_count || 'Trx:' || l_trx_id || 'Test');
966 */
967
968
969 COMMIT;
970 resultout := 'COMPLETE';
971 return;
972
973
974 END IF; -- end of the run mode
975
976
977 -- Cancel mode
978
979 IF (funcmode = 'CANCEL') THEN
980
981 -- extra cancel code goes here
982
983 null;
984
985 -- no result needed
986 resultout := 'COMPLETE';
987 return;
988 END IF;
989
990
991 EXCEPTION
992
993
994
995 WHEN OTHERS THEN
996 -- Rcords this function call in the error system
997 -- in the case of an exception.
998 wf_core.context('FUN_INITIATOR_WF_PKG', 'TRANSFER_AR',
999 itemtype, itemkey, to_char(actid), funcmode);
1000
1001 END TRANSFER_AR;
1002
1003
1004
1005
1006 /*-----------------------------------------------------|
1007 | PROCEDURE CHECK_AR_SETUP |
1008 |------------------------------------------------------|
1009 | Parameters item_type IN Varchar2 |
1010 | item_key IN Varchar2 |
1011 | actid IN NUMBER |
1012 | funcmode IN Varchar2 |
1013 | resultout IN Varchar2 |
1014 | |
1015 |------------------------------------------------------|
1016 | Description |
1017 | Check the AR setup information |
1018 | |
1019 | Return true/false |
1020 | |
1021 | It will call intercompany transaction API |
1022 | to check AR related setup information |
1023 |-----------------------------------------------------*/
1024
1025
1026 PROCEDURE ChECK_AR_SETUP (itemtype IN VARCHAR2,
1027 itemkey IN VARCHAR2,
1028 actid IN NUMBER,
1029 funcmode IN VARCHAR2,
1030 resultout OUT NOCOPY VARCHAR2)
1031
1032 IS
1033
1034 l_message_count Number;
1035 l_status Varchar2(1);
1036 l_msg_data Varchar2(2000);
1037 l_message Varchar2(2000);
1038 l_trx_amt Number;
1039 l_trx_id Number;
1040 l_batch_id Number;
1041
1042 BEGIN
1043
1044 IF (funcmode = 'RUN') THEN
1045
1046
1047 l_status:=FND_API.G_RET_STS_SUCCESS;
1048
1049 l_trx_id := wf_engine.GetItemAttrNumber(itemtype => itemtype,
1050 itemkey => itemkey,
1051 aname => 'TRX_ID');
1052
1053 l_batch_id := wf_engine.GetItemAttrNumber(itemtype => itemtype,
1054 itemkey => itemkey,
1055 aname => 'BATCH_ID');
1056
1057 -- call transaction API to check the ar setup
1058 fun_trx_pvt.ar_transfer_validate (
1059 p_api_version => 1.0,
1060 p_init_msg_list => FND_API.G_TRUE,
1061 p_validation_level => FND_API.G_VALID_LEVEL_FULL,
1062 x_return_status => l_status,
1063 x_msg_count => l_message_count,
1064 x_msg_data => l_msg_data,
1065 p_batch_id => l_batch_id,
1066 p_trx_id => l_trx_id);
1067
1068 -- Bug: 7319371 Changing the query to make the l_trx_amt number reginal independent
1069 -- Also since the fun_trx_batches table is not used in the query removing a reference to the same
1070
1071 --select ltrim(to_char(decode(nvl(h.reci_amount_cr,0),0,h.reci_amount_dr,h.reci_amount_cr),'999999999.99'))
1072 --into l_trx_amt
1073 --from fun_trx_headers h, fun_trx_batches b
1074 --where h.trx_id = l_trx_id
1075 --and b.batch_id = l_batch_id;
1076
1077 SELECT LTRIM(TO_CHAR(DECODE(NVL(H.RECI_AMOUNT_CR,0),0,H.RECI_AMOUNT_DR,
1078 H.RECI_AMOUNT_CR),
1079 '999999999D99'))
1080 INTO l_trx_amt
1081 FROM FUN_TRX_HEADERS H
1082 WHERE H.TRX_ID = l_trx_id;
1083
1084 -- Bug: 7319371 END
1085
1086
1087 wf_engine.setitemattrnumber( itemtype => itemtype,
1088 itemkey => itemkey,
1089 aname => 'TRX_AMT',
1090 avalue => l_trx_amt);
1091
1092 -- Check the return status
1093 if(l_status <> FND_API.G_RET_STS_SUCCESS) THEN
1094
1095 -- assembling the error message
1096
1097 l_message :=FUN_WF_COMMON.concat_msg_stack(l_message_count);
1098
1099 -- set the item attribute ERROR_MSG
1100
1101 wf_engine.setitemattrtext(itemtype,
1102 itemkey,
1103 'ERROR_MSG',
1104 l_message);
1105 -- return false
1106 resultout:='COMPLETE:F';
1107 ELSE
1108 -- AR setup is vcalid
1109 resultout := 'COMPLETE:T';
1110 return;
1111 END IF;
1112 END IF;
1113
1114 EXCEPTION
1115
1116 WHEN OTHERS THEN
1117
1118 -- Rcords this function call in the error system
1119 -- in the case of an exception.
1120
1121 wf_core.context('FUN_INITIATOR_WF_PKG', 'CHECK_AR_SETUP',
1122 itemtype, itemkey, to_char(actid), funcmode);
1123
1124 RAISE;
1125
1126 END CHECK_AR_SETUP;
1127
1128
1129
1130
1131 /*-----------------------------------------------------|
1132 | PROCEDURE GET_INVOICE |
1133 |------------------------------------------------------|
1134 | Parameters p_subscription_guid IN RAW |
1135 | p_event IN OUT |
1136 | WF_EVENT_T |
1137 | |
1138 | Return Varchar2 |
1139 | |
1140 |------------------------------------------------------|
1141 | Description |
1142 | This is the event subscription function |
1143 | for AR Autoinvoice transfer event: |
1144 | oracle.apps.ar.batch.AutoInvoice.run |
1145 | to check AR related setup information |
1146 | |
1147 | It will retrieve AR invoice from AR table |
1148 | and then raise AR transfer complete event |
1149 |-----------------------------------------------------*/
1150
1151
1152 FUNCTION GET_INVOICE (p_subscription_guid IN RAW,
1153 p_event IN OUT NOCOPY WF_EVENT_T)
1154 return Varchar2 IS
1155
1156 l_parameter_list wf_parameter_list_t := wf_parameter_list_t();
1157 l_parameter_list_out wf_parameter_list_t := wf_parameter_list_t();
1158 l_parameter_t wf_parameter_t;
1159 l_parameter_name l_parameter_t.name%type;
1160 l_parameter_value l_parameter_t.value%type;
1161
1162 l_request_id Number;
1163 i PLS_Integer;
1164 l_batch_source_id Number;
1165 l_batch_id Number;
1166 l_trx_id Number;
1167 l_return_status Varchar2(1);
1168 l_message_count NUMBER;
1169 l_message_data Varchar2(1000);
1170 l_event_key Varchar2(240);
1171
1172 -- cursor to retrieve all imported transactions
1173 cursor c_trans(p_request_id IN NUMBER) IS
1174
1175 SELECT rct.trx_number invoice_number,
1176 rct.interface_header_attribute1 batch_id,
1177 rct.interface_header_attribute2 trx_id
1178 FROM ra_customer_trx_all rct,
1179 ra_batch_sources_all rbs
1180 WHERE rct.request_id=p_request_id
1181 AND rct.batch_source_id=rbs.batch_source_id
1182 AND NVL(rct.org_id, -99) =NVL(rbs.org_id, -99)
1183 AND rbs.name=(SELECT name FROM
1184 RA_BATCH_SOURCES_ALL WHERE BATCH_SOURCE_ID = 22 AND org_id = rct.org_id);
1185
1186
1187 BEGIN
1188 l_request_id := p_event.GetValueForParameter('REQUEST_ID');
1189
1190 -- Retieve the transaction number from AR table (note we are working with
1191 -- ALL table now)
1192
1193 -- We need raise individual event for each transaction
1194 -- (assume the import is successful)
1195
1196 FOR l_trans IN c_trans(l_request_id)
1197 LOOP
1198 -- Update the AR invoice number
1199
1200 UPDATE FUN_TRX_HEADERS
1201 SET ar_invoice_number = l_trans.invoice_number
1202 WHERE trx_id = l_trans.trx_id
1203 AND batch_id = l_trans.batch_id
1204 AND ar_invoice_number IS NULL;
1205
1206
1207 IF SQL%ROWCOUNT = 1
1208 THEN
1209 -- Raise the AR transfer complete event
1210
1211 -- Initiate the parameter list
1212 l_parameter_list_out :=wf_parameter_list_t();
1213
1214 WF_EVENT.AddParameterToList(p_name=>'BATCH_ID',
1215 p_value=>TO_CHAR(l_trans.batch_id),
1216 p_parameterlist=>l_parameter_list_out);
1217
1218 WF_EVENT.AddParameterToList(p_name=>'TRX_ID',
1219 p_value=>TO_CHAR(l_trans.trx_id),
1220 p_parameterlist=>l_parameter_list_out);
1221
1222 WF_EVENT.AddParameterToList(p_name=>'INVOICE_NUM',
1223 p_value=>TO_CHAR(l_trans.invoice_number),
1224 p_parameterlist=>l_parameter_list_out);
1225
1226 -- generate the event key
1227
1228 l_event_key := FUN_INITIATOR_WF_PKG.GENERATE_KEY
1229 (p_batch_id=>l_trans.batch_id,
1230 p_trx_id=>l_trans.trx_id);
1231
1232
1233 -- Raise the event
1234
1235 WF_EVENT.RAISE(p_event_name =>'oracle.apps.fun.manualtrx.arcomplete.send',
1236 p_event_key =>l_event_key,
1237 p_parameters =>l_parameter_list_out);
1238
1239 l_parameter_list_out.delete();
1240
1241
1242 END IF;
1243
1244 COMMIT;
1245
1246 END LOOP;
1247
1248 RETURN 'SUCCESS';
1249
1250 EXCEPTION
1251
1252 WHEN OTHERS THEN
1253
1254 -- Rcords this function call in the error system
1255 -- in the case of an exception.
1256
1257 wf_core.context('FUN_INITIATOR_WF_PKG', 'GET_INVOICE',
1258 p_event.getEventName(), p_subscription_guid);
1259 WF_EVENT.setErrorInfo(p_event, 'ERROR');
1260 return 'ERROR';
1261
1262
1263 END GET_INVOICE;
1264
1265
1266
1267
1268 /*-----------------------------------------------------|
1269 | PROCEDURE GENERATE_KEY |
1270 |------------------------------------------------------|
1271 | Parameters p_trx_id IN NUMBER |
1272 | |
1273 | Return Varchar2 |
1274 | |
1275 |------------------------------------------------------|
1276 | Description |
1277 | Generate the key for events |
1278 |-----------------------------------------------------*/
1279
1280
1281
1282
1283
1284 FUNCTION GENERATE_KEY( p_batch_id in NUMBER,
1285 p_trx_id in NUMBER) return Varchar2
1286 IS
1287
1288 BEGIN
1289 return to_char(p_batch_id) || '_' || to_char(p_trx_id) || '_' || SYS_GUID();
1290
1291 EXCEPTION
1292
1293 WHEN OTHERS THEN
1294 RAISE;
1295
1296
1297 END GENERATE_KEY;
1298
1299 -------------------------------------------------------------------------------
1300 --Start of Comments
1301 --Function:
1302 -- After transactions are interfaced to AR and invoices have been created,
1303 -- FUN_TRX_HEADERS.ar_invoice_number will be updated with the corresonding
1304 -- AR_CUSTOMER_TRX_ALL.trx_number
1305
1306 -- THIS PROCESS IS NOT USED ANYMORE
1307 -- INSTEAD GET_INVOICE IS USED
1308
1309 --End of Comments
1310 -------------------------------------------------------------------------------
1311
1312 PROCEDURE update_trx_headers(p_request_id IN NUMBER)
1313 IS
1314 l_trx_header_type fun_trx_header_type;
1315
1316 BEGIN
1317
1318
1319 NULL;
1320
1321 /* NOT USED ANYMORE
1322
1323 -- Get AR invoice number given autoinvoice conc. request id
1324 SELECT TO_NUMBER(RCT.interface_header_attribute1),
1325 TO_NUMBER(RCT.interface_header_attribute2),
1326 RCT.trx_number
1327 BULK COLLECT INTO
1328 l_trx_header_type.attribute1,
1329 l_trx_header_type.attribute2,
1330 l_trx_header_type.invoice_number
1331 FROM RA_CUSTOMER_TRX_ALL RCT,
1332 RA_BATCH_SOURCES_ALL RBS
1333 WHERE RBS.name = (SELECT name FROM
1334 RA_BATCH_SOURCES_ALL WHERE BATCH_SOURCE_ID = 22 AND org_id = rct.org_id)
1335 AND RBS.batch_source_id = RCT.batch_source_id
1336 AND RBS.org_id = RCT.org_id
1337 AND RCT.request_id = p_request_id;
1338
1339 IF SQL%NOTFOUND THEN
1340 RETURN;
1341 END IF;
1342
1343 -- update FUN_TRX_HEADERS with the corresponding invoice number
1344 FORALL i IN 1..l_trx_header_type.attribute1.COUNT
1345 UPDATE FUN_TRX_HEADERS
1346 SET ar_invoice_number = l_trx_header_type.invoice_number(i)
1347 WHERE batch_id = l_trx_header_type.attribute1(i)
1348 AND trx_id = l_trx_header_type.attribute2(i);
1349
1350 */
1351
1352
1353 EXCEPTION
1354 WHEN OTHERS THEN
1355 NULL;
1356 END update_trx_headers;
1357
1358
1359 ---------------------------------------------------------------------------
1360 --Start of Comments
1361 --Function:
1362 -- After transactions are interfaced to AR and invoices have been created,
1363 -- it will get AR invoice number based on autoinvice conc. program
1364 -- request_id, and then FUN_TRX_HEADERS.ar_invoice_number will be updated
1365 -- with the corresonding AR invoice number
1366
1367 -- THIS PROCESS IS NOT USED ANYMORE
1368 -- INSTEAD, GET_INVOICE IS CALLED FROM AR BUSINESS EVENT
1369
1370 --End of Comments
1371 ---------------------------------------------------------------------------
1372
1373
1374 PROCEDURE post_ar_invoice(
1375 itemtype IN varchar2,
1376 itemkey IN varchar2,
1377 actid IN number,
1378 funcmode IN varchar2,
1379 resultout IN OUT NOCOPY varchar2)
1380 IS
1381 l_request_id NUMBER;
1382
1383 BEGIN
1384
1385 /*
1386 IF (funcmode = 'RUN') THEN
1387 fnd_msg_pub.initialize;
1388
1389 l_request_id := wf_engine.GetItemAttrNumber(
1390 itemtype => itemtype,
1391 itemkey => itemkey,
1392 aname => 'REQUEST_ID');
1393
1394 update_trx_headers(l_request_id);
1395
1396 commit;
1397 resultout := wf_engine.eng_completed||':'||wf_engine.eng_null;
1398
1399 RETURN;
1400 END IF;
1401 */
1402
1403 resultout := wf_engine.eng_null;
1404 RETURN;
1405
1406 EXCEPTION
1407 WHEN OTHERS THEN
1408 wf_core.context('FUN_INITIATOR_WF_PKG', 'post_ar_invoice',
1409 itemtype, itemkey, TO_CHAR(actid), funcmode);
1410
1411 RAISE;
1412 END post_ar_invoice;
1413
1414
1415 END FUN_INITIATOR_WF_PKG;
1416