[Home] [Help]
PACKAGE BODY: APPS.PAY_US_WORKFLOW_API_PKG
Source
1 PACKAGE BODY PAY_US_WORKFLOW_API_PKG as
2 /* $Header: payuswfapipkg.pkb 115.4 2004/05/03 11:48:51 jgoswami noship $ */
3 /*
4 ******************************************************************
5 * *
6 * Copyright (C) 1993 Oracle Corporation. *
7 * All rights reserved. *
8 * *
9 * This material has been provided pursuant to an agreement *
10 * containing restrictions on its use. The material is also *
11 * protected by copyright law. No part of this material may *
12 * be copied or distributed, transmitted or transcribed, in *
13 * any form or by any means, electronic, mechanical, magnetic, *
14 * manual, or otherwise, or disclosed to third parties without *
15 * the express written permission of Oracle Corporation, *
16 * 500 Oracle Parkway, Redwood City, CA, 94065. *
17 * *
18 ******************************************************************
19
20 Name : pay_us_workflow_api_pkg
21
22 Description :
23
24 Change List
25 -----------
26 Date Name Vers Bug No Description
27 ----------- ---------- ------ ------- --------------------------
28 08-JUN-2003 jgoswami 115.0 Created
29 19-JUN-2003 jgoswami 115.1 3006871 Added procedure ExecuteConcProgram,
30 CheckProcessInputs
31
32 12-APR-2004 JGoswami 115.4 3316422 Added procedure IsResponseRequired
33 12-APR-2004 JGoswami 115.4 3316527 Modified get_assignment_info.
34 ******************************************************************************/
35
36 -- IN
37 -- itemtype - type of the current item
38 -- itemkey - key of the current item
39 -- actid - process activity instance id
40 -- funcmode - function execution mode ('RUN', 'CANCEL', 'TIMEOUT', ...)
41 -- OUT
42 -- result
43 -- - COMPLETE[:<result ]
44 -- activity has completed with the indicated result
45 -- - WAITING
46 -- activity is waiting for additional transitions
47 -- - DEFERED
48 -- execution should be defered to background
49 -- - NOTIFIED[:<notification_id :<assigned_user ]
50 -- activity has notified an external entity that this
51 -- step must be performed. A call to wf_engine.CompleteActivty
52 -- will signal when this step is complete. Optional
53 -- return of notification ID and assigned user.
54 -- - ERROR[:<error_code ]
55 -- function encountered an error.
56
57 X_bg_id NUMBER;
58 X_org_id NUMBER;
59 X_req_id VARCHAR2(50);
60
61
62 /* ************************************************************************
63
64 This procedure gets the Assignment Info and create the Document.
65 ************************************************************************ */
66
67 PROCEDURE get_assignment_info (document_id IN VARCHAR2,
68 display_type IN VARCHAR2,
69 document IN OUT nocopy VARCHAR2,
70 document_type IN OUT nocopy VARCHAR2)
71
72 IS
73
74 ln_request_id number(15);
75 ln_business_group_id number(15);
76 ln_payroll_id number(15);
77 ld_payroll_date_paid varchar2(20);
78 ln_total number(9);
79 ln_complete number(9);
80 ln_error number(9);
81 ln_unprocessed number(9);
82 lv_business_group_name varchar2(240);
83 X_Segment1 VARCHAR2(240);
84 X_Segment2 VARCHAR2(240);
85 X_Segment3 VARCHAR2(240);
86 X_Segment4 VARCHAR2(240);
87 X_Segment5 VARCHAR2(240);
88 X_result VARCHAR2(2000);
89 l_cur_req_id Varchar2(240);
90 l_payroll_flag varchar2(1);
91 l_bg_flag varchar2(1);
92 l_space varchar2(25);
93
94
95 CURSOR asg_info_cur(p_req_id Number)
96 IS
97 select ppf.payroll_name PAYROLL_NAME,
98 to_char(count(paa.assignment_action_id)) ASG_COUNT,
99 paa.action_status ASG_STATUS
100 from pay_assignment_actions paa,
101 pay_payroll_actions ppa,
102 pay_all_payrolls_f ppf
103 where paa.payroll_action_id = ppa.payroll_action_id
104 and ppa.request_id = to_number(p_req_id)
105 and ppa.business_group_id = ln_business_group_id
106 and ppa.payroll_id = ppf.payroll_id
107 and ppf.payroll_id = ln_payroll_id
108 and ppa.effective_date between
109 ppf.effective_start_date and
110 ppf.effective_end_date
111 and ppa.effective_date = trunc(to_date(ld_payroll_date_paid,'YYYY/MM/DD HH24:MI:SS'))
112 and ppa.action_type = 'R'
113 and paa.source_action_id is null
114 and paa.run_type_id is null
115 group by ppf.payroll_name,paa.action_status;
116
117
118 BEGIN
119 l_payroll_flag := 'N';
120 l_bg_flag := 'N';
121 l_space := ' ';
122 ln_total := 0;
123 ln_complete := 0;
124 ln_error := 0;
125 ln_unprocessed := 0;
126
127 hr_utility.trace('B4 ASG Info');
128 hr_utility.trace('Document Id '||document_id);
129
130 ln_request_id := substr(document_id,1,instr(document_id,':') -1 );
131 ln_business_group_id := substr(document_id,instr(document_id,':',1,1)+1 ,
132 instr(document_id,':',1,2) -instr(document_id,':',1,1)-1 );
133 ln_payroll_id := substr(document_id,instr(document_id,':',1,2)+1 ,
134 instr(document_id,':',1,3) -instr(document_id,':',1,2)-1 );
135 ld_payroll_date_paid := substr(document_id,instr(document_id,':',1,3)+1 );
136
137 hr_utility.trace('ln_request_id = '||ln_request_id);
138 hr_utility.trace('ln_business_group_id = '||ln_business_group_id);
139 hr_utility.trace('ln_payroll_id = '||ln_payroll_id);
140 hr_utility.trace('ld_payroll_date_paid = '||ld_payroll_date_paid);
141
142 begin
143 select pbg.name into lv_business_group_name
144 from per_business_groups pbg
145 where pbg.business_group_id = ln_business_group_id;
146
147 hr_utility.trace('ln_business_group_id = '||ln_business_group_id);
148 exception when others then
149 null;
150 end;
151
152 FOR asg_info_rec in asg_info_cur(ln_request_id) LOOP
153
154
155 if lv_business_group_name is not null
156 and l_bg_flag <> 'Y'then
157 X_segment1 := 'Business Group :'||lv_business_group_name||l_space||wf_core.newline;
158 l_bg_flag := 'Y';
159 end if;
160
161 if asg_info_rec.PAYROLL_NAME is not null
162 and l_payroll_flag <> 'Y'then
163 X_segment2 := 'Payroll :'||asg_info_rec.PAYROLL_NAME||l_space||wf_core.newline;
164 l_payroll_flag := 'Y';
165 end if;
166
167 if asg_info_rec.ASG_STATUS = 'C' then
168 ln_complete := asg_info_rec.ASG_COUNT;
169 elsif asg_info_rec.ASG_STATUS = 'E' then
170 ln_error := asg_info_rec.ASG_COUNT;
171 elsif asg_info_rec.ASG_STATUS = 'U' then
172 ln_unprocessed := asg_info_rec.ASG_COUNT;
173 end if;
174
175 END LOOP ;
176
177 X_segment3 := 'Total Assignment Successfully Processed :'||to_char(ln_complete)||l_space||wf_core.newline;
178 X_segment4 := 'Total Assignment Errored :'||to_char(ln_error)||l_space||wf_core.newline;
179 X_segment5 := 'Total Assignment Un-Processed :'||to_char(ln_unprocessed)||l_space||wf_core.newline;
180
181 document := '<p>'||X_segment3||'<br>'||X_segment4||'<br>'||X_segment5||'<br></p>';
182
183 document := document || l_space||wf_core.newline;
184
185 hr_utility.trace('Document '||document);
186
187
188 document_type := 'text/html';
189 Exception When others then
190 hr_utility.trace('In Exception ');
191
192 End Get_Assignment_Info;
193
194 --
195
196 /*
197 procedure set_attr_value(itemtype in varchar2,
198 itemkey in varchar2,
199 actid in number,
200 funcmode in varchar2,
201 resultout out nocopy varchar2) is
202 ---> <local declarations>
203 lv_aname varchar2(30);
204
205 begin
206 -- Do nothing in cancel or timeout mode
207 if (funcmode <> wf_engine.eng_run) then
208 resultout := wf_engine.eng_null;
209 else
210
211 lv_aname := PAY_WORKFLOW_API_PKG.set_value(itemtype,itemkey,actid);
212 hr_utility.trace('lv_aname = '|| lv_aname);
213 -- put this activity in wait/notified state
214 if lv_aname is not null then
215 resultout := 'COMPLETE'||':'||wf_engine.eng_null;
216 else
217 resultout := wf_engine.eng_null;
218 end if;
219
220 end if;
221 return;
222 exception
223 when others then
224 WF_CORE.CONTEXT ('PAY_WORKFLOW_API_PKG', 'set_attr_value', itemtype,
225 itemkey, to_char(actid), funcmode);
226 raise;
227 end set_attr_value;
228
229 procedure get_attr_value(itemtype in varchar2,
230 itemkey in varchar2,
231 actid in number,
232 funcmode in varchar2,
233 resultout out nocopy varchar2) is
234 ---> <local declarations>
235 lv_aname varchar2(30);
236
237 begin
238 -- Do nothing in cancel or timeout mode
239 if (funcmode <> wf_engine.eng_run) then
240 resultout := wf_engine.eng_null;
241 else
242
243 lv_aname := PAY_WORKFLOW_API_PKG.get_value(itemtype,itemkey,actid)
244 -- put this activity in wait/notified state
245 if lv_aname is not null then
246 resultout := 'COMPLETE'||':'||wf_engine.eng_null;
247 else
248 resultout := wf_engine.eng_null;
249 end if;
250
251 end if;
252 return;
253 exception
254 when others then
255 WF_CORE.CONTEXT ('PAY_WORKFLOW_API_PKG', 'get_attr_value', itemtype,
256 itemkey, to_char(actid), funcmode);
257 raise;
258 end get_attr_value;
259 */
260
261 PROCEDURE get_message_details (document_id IN VARCHAR2,
262 display_type IN VARCHAR2,
263 document IN OUT nocopy VARCHAR2,
264 document_type IN OUT nocopy VARCHAR2)
265
266 IS
267
268 X_Segment1 VARCHAR2(240);
269 X_Segment2 VARCHAR2(240);
270 X_Segment3 VARCHAR2(240);
271 X_Segment4 VARCHAR2(240);
272 X_Segment5 VARCHAR2(240);
273 X_result VARCHAR2(2000);
274 l_cur_req_id Varchar2(240);
275 l_payroll_flag varchar2(1);
276 l_bg_flag varchar2(1);
277 l_space varchar2(25);
278
279
280 args Varchar2(240);
281 firstcolon number;
282 nextcolon number;
283 lv_itemtype Varchar2(240);
284 lv_itemkey Varchar2(240);
285 lv_attr_name Varchar2(30);
286
287 BEGIN
288 l_payroll_flag := 'N';
289 l_bg_flag := 'N';
290 l_space := ' ';
291 hr_utility.trace('B4 MSG Details ');
292 hr_utility.trace('Document Id '||document_id);
293
294 args := document_id;
295 -- args has format itemtype:itemkey:attr_name
296 firstcolon := instr(args,':');
297 nextcolon := instr(args,':',firstcolon+1);
298 lv_itemtype := substr(args,1, firstcolon-1);
299 hr_utility.trace('Item Type '||lv_itemtype);
300 lv_itemkey := substr(args,firstcolon+1,nextcolon -(firstcolon-1));
301 hr_utility.trace('Item Key '||lv_itemkey);
302 lv_attr_name := substr(args,nextcolon+1);
303 hr_utility.trace('Attr Name '||lv_attr_name);
304
305 -- l_cur_req_id := get_value(lv_itemtype,lv_itemkey,lv_attr_name);
306
307 X_segment1 := '<p> The Function GET_VALUE retrives the value of the request id for the given attribute name Request Id :'||l_cur_req_id||wf_core.newline ||'<br> </p>';
308 document := document || X_segment1||wf_core.newline;
309 document_type := 'text/html';
310 hr_utility.trace('Document '||document);
311 Exception When others then
312 hr_utility.trace('In Exception of Get message_details');
313
314 End get_message_details;
315
316 /*
317 -- Get Value
318 FUNCTION get_value(
319 wf_item_type in varchar2,
320 wf_item_key in varchar2,
321 attr_name in varchar2
322 ) RETURN VARCHAR2 IS
323 ignore_notfound boolean := FALSE;
324 attr_value varchar2(80);
325 Begin
326
327 -- From the Runtime Attributes Get the Value of the Attribute for the Workflow
328 -- Item Type, Item Key,Attribute Name.
329
330 attr_value := WF_Engine.GetItemAttrText(wf_item_type , wf_item_key , attr_name , ignore_notfound);
331
332 return attr_value;
333
334 Exception When others then
335 hr_utility.trace('In Exception of get_value');
336
337 End get_value;
338 */
339
340 /*
341 -- Set Value
342 FUNCTION set_value(
343 wf_item_type in varchar2 default 'NO_WF_ITEM',
344 wf_item_key in varchar2,
345 wf_actid in number
346 ) RETURN VARCHAR2 IS
347 aname Wf_Engine.NameTabTyp;
348 avalue Wf_Engine.TextTabTyp;
349
350 lv_attr_name varchar2(30);
351 lv_attr_value varchar2(30);
352 Begin
353
354 -- Add an Item Attribute at Runtime and Set the Value of the Attribute
355 -- for the Workflow Item Type, Item Key,Attribute Name.
356
357 lv_attr_name := wf_engine.GetActivityAttrText(wf_item_type,wf_item_key,wf_actid, 'ATTR_NAME');
358 lv_attr_value := wf_engine.GetActivityAttrText(wf_item_type,wf_item_key,wf_actid, 'ATTR_VALUE');
359 -- aname(1) := lv_attr_name;
360 -- avalue(1) := lv_attr_value;
361
362 hr_utility.trace('aname = '|| lv_attr_name);
363 hr_utility.trace('avalue = '|| lv_attr_value);
364 if aname is not null then
365 --WF_Engine.AddItemAttr(wf_item_type, wf_item_key, aname, avalue);
366 WF_Engine.AddItemAttr(wf_item_type, wf_item_key, lv_attr_name, lv_attr_value);
367 --return aname;
368 return lv_attr_name;
369 else
370 return null;
371 end if;
372 Exception When others then
373 hr_utility.trace('In Exception of set_value');
374
375 End set_value;
379 itemkey in varchar2,
376 */
377
378 procedure GetRetroInformation(itemtype in varchar2,
380 actid in number,
381 funcmode in varchar2,
382 resultout out nocopy varchar2) is
383 aname varchar2(80);
384 avalue number(30);
385 result varchar2(30);
386 lv_result varchar2(30);
387 lv_retro_asg_set varchar2(30);
388 ln_retro_asg_set_id number(30);
389 ln_get_retro_asgset_id number(30);
390 ignore_notfound boolean;
391 l_notification_id NUMBER;
392 l_notification_id2 NUMBER;
393 nid NUMBER;
394
395
396 begin
397
398 lv_result := 'SKIP';
399 ignore_notfound := FALSE;
400
401 hr_utility.trace(' In GetRetroInformation ');
402 if ( funcmode = 'RUN' ) then
403 hr_utility.trace('Function Mode = '||funcmode);
404 -- get attr value
405 --<your RUN executable statements>
406 hr_utility.trace('itemtype = '||itemtype);
407 hr_utility.trace('itemkey = '||itemkey);
408 hr_utility.trace('actid = '||to_char(actid));
409
410 aname := 'RETRO_ASSIGNMENT_SET_NAME';
411 lv_retro_asg_set := Wf_Engine.GetItemAttrText(
412 itemtype ,
413 itemkey ,
414 aname,
415 ignore_notfound);
416
417 aname := 'P_BUSINESS_GROUP_ID';
418
419 X_bg_id := Wf_Engine.GetItemAttrNumber(
420 itemtype,
421 itemkey,
422 aname,
423 ignore_notfound);
424
425
426 hr_utility.trace(' BG Id = '|| to_char(X_bg_id));
427 hr_utility.trace(' Retro Asg Set = '|| lv_retro_asg_set);
428
429 begin
430 select assignment_set_id
431 into ln_retro_asg_set_id
432 from hr_assignment_sets
433 where business_group_id = X_bg_id
434 and assignment_set_name like lv_retro_asg_set||'%';
435
436 hr_utility.trace(' Retro Asg Set ID = '|| to_char(ln_retro_asg_set_id));
437 exception when others then
438 result := 'SKIP';
439 hr_utility.trace('Skiping Retro Pay By Element as Assignment Set Not Found');
440 end;
441
442 if ln_retro_asg_set_id is not null then
443
444 Wf_Engine.SetItemAttrNumber
445 (itemtype,
446 itemkey,
447 'RETRO_ASSIGNMENT_SET_ID',
448 ln_retro_asg_set_id);
449 result := 'RUN';
450 hr_utility.trace('result = '||result);
451 else
452 result := 'SKIP';
453
454 hr_utility.trace('result = '||result);
455 end if;
456
457 resultout := 'COMPLETE:'||result;
458 hr_utility.trace(' Resultout = '|| resultout);
459 return;
460 elsif ( funcmode = 'CANCEL' ) then
461 -- <your CANCEL executable statements>
462 null;
463 result := 'SKIP';
464 resultout := 'COMPLETE:'||result;
465 hr_utility.trace('In Skip Resultout = '|| resultout);
466 return;
467
468 end if;
469
470 exception
471 when others then
472 WF_CORE.CONTEXT ('PAY_US_WORKFLOW_API_PKG', 'GetRetroInformation', itemtype, itemkey, to_char(actid), funcmode);
473 raise;
474 end GetRetroInformation;
475
476
477 procedure post_notification_set_attr(itemtype in varchar2,
478 itemkey in varchar2,
479 actid in number,
480 funcmode in varchar2,
481 resultout out nocopy varchar2) is
482 aname varchar2(80);
483 avalue number(30);
484 result varchar2(30);
485 lv_result varchar2(30);
486 lv_retro_asg_set varchar2(30);
487 ln_retro_asg_set_id number(30);
488 ln_get_retro_asgset_id number(30);
489 ignore_notfound boolean;
490 l_notification_id NUMBER;
491 l_notification_id2 NUMBER;
492 nid NUMBER;
493
494 begin
495
496 lv_result := 'SKIP';
497 ignore_notfound := FALSE;
498
499 hr_utility.trace('1. Function Mode = '||funcmode);
500 if ( funcmode = 'RUN' ) then
501 ln_get_retro_asgset_id := Wf_Engine.GetItemAttrNumber(
502 itemtype,
503 itemkey,
504 'RETRO_ASSIGNMENT_SET_ID');
505
506 hr_utility.trace('Function Mode = '||funcmode);
507 hr_utility.trace('1. ln_get_retro_asgset_id = '||to_char(ln_get_retro_asgset_id));
508
509 if ln_get_retro_asgset_id is not null then
510 resultout := 'COMPLETE:RUN';
511 hr_utility.trace(' Resultout = '|| resultout);
512 else
513 resultout := 'COMPLETE:SKIP';
514 hr_utility.trace(' Resultout = '|| resultout);
515 end if;
516
517 return;
518 end if;
519
520
521 if ( funcmode = 'RESPOND' ) then
522 hr_utility.trace('Function Mode = '||funcmode);
523 -- get attr value
524 --<your RUN executable statements>
525 hr_utility.trace('itemtype = '||itemtype);
526 hr_utility.trace('itemkey = '||itemkey);
527 hr_utility.trace('actid = '||to_char(actid));
528 l_notification_id2:= wf_engine.context_nid;
529 hr_utility.trace('2. l_notification_id = '||to_char(l_notification_id2));
530
531 if (l_notification_id is not null ) then
535 lv_result := WF_NOTIFICATION.GetAttrText( l_notification_id2, 'RESULT');
532 lv_result := WF_NOTIFICATION.GetAttrText( l_notification_id, 'RESULT');
533 hr_utility.trace('1. lv_result = '||lv_result);
534 elsif ( l_notification_id2 is not null) then
536 hr_utility.trace('2.lv_result = '||lv_result);
537 end if;
538
539 if (lv_result <> 'SKIP') then
540 aname := 'RETRO_ASSIGNMENT_SET_NAME';
541 lv_retro_asg_set := Wf_Engine.GetItemAttrText(
542 itemtype ,
543 itemkey ,
544 aname,
545 ignore_notfound);
546
547 aname := 'P_BUSINESS_GROUP_ID';
548
549 X_bg_id := Wf_Engine.GetItemAttrNumber(
550 itemtype,
551 itemkey,
552 aname,
553 ignore_notfound);
554
555
556 hr_utility.trace(' BG Id = '|| to_char(X_bg_id));
557 hr_utility.trace(' Retro Asg Set = '|| lv_retro_asg_set);
558
559 begin
560 select assignment_set_id
561 into ln_retro_asg_set_id
562 from hr_assignment_sets
563 where business_group_id = X_bg_id
564 and assignment_set_name like lv_retro_asg_set||'%';
565
566 hr_utility.trace(' Retro Asg Set ID = '|| to_char(ln_retro_asg_set_id));
567 exception when others then
568 result := 'SKIP';
569 hr_utility.trace('Skiping Retro Pay By Element as Assignment Set Not Found');
570 end;
571
572 if ln_retro_asg_set_id is not null then
573
574 Wf_Engine.SetItemAttrNumber
575 (itemtype,
576 itemkey,
577 'RETRO_ASSIGNMENT_SET_ID',
578 ln_retro_asg_set_id);
579 result := 'RUN';
580 hr_utility.trace('result = '||result);
581 else
582 result := 'SKIP';
583
584 hr_utility.trace('result = '||result);
585 end if;
586
587 resultout := 'COMPLETE:'||result;
588 hr_utility.trace(' Resultout = '|| resultout);
589 return;
590 else
591 result := 'SKIP';
592 resultout := 'COMPLETE:'||result;
593 hr_utility.trace('In Skip Resultout = '|| resultout);
594 return;
595
596 end if;
597 -- result := 'SKIP';
598 -- resultout := 'COMPLETE:'||result;
599 -- hr_utility.trace('In Skip Resultout = '|| resultout);
600 -- return;
601
602 end if;
603
604 if ( funcmode = 'CANCEL' ) then
605 -- <your CANCEL executable statements>
606 null;
607 result := 'SKIP';
608 resultout := 'COMPLETE:'||result;
609 return;
610 end if;
611
612
613 exception
614 when others then
615 WF_CORE.CONTEXT ('PAY_US_WORKFLOW_API_PKG', 'post_notification_set_attr', itemtype, itemkey, to_char(actid), funcmode);
616 raise;
617 end post_notification_set_attr;
618
619 PROCEDURE ExecuteConcProgram
620 ( p_itemtype in varchar2
621 , p_itemkey in varchar2
622 , p_actid in number
623 , p_funcmode in varchar2
624 , p_result in out nocopy varchar2
625 )
626 IS
627 l_user_id NUMBER;
628 l_resp_id NUMBER;
629 l_resp_appl_id NUMBER;
630 l_org_id NUMBER;
631 l_resultout varchar2(80);
632 l_security_group_id NUMBER;
633 l_per_security_id NUMBER;
634
635 work_item_org_id NUMBER;
636 session_org_id varchar2(100);
637 BEGIN
638
639 /*
640 cursor c1 is select
641 furg.user_id,
642 furg.responsibility_id,
643 furg.responsibility_application_id
644 from fnd_user_resp_groups furg,
645 fnd_user fu,
646 fnd_responsibility fr
647 where fu.user_id = furg.user_id
648 and furg.responsibility_id = fr.responsibility_id
649 and fu.user_name = 'JATIN'
650 and responsibility_key like 'JJ CA HRMS MANAGER';
651 */
652
653
654
655 --FOR crec in c1 loop
656
657 IF (p_funcmode = 'RUN') THEN
658
659 -- Code that determines Start Process
660 -- p_result := 'COMPLETE';
661 -- get Item Attributes for user_id, responsibility_id and application_id
662 -- this assumes that they were set as item attribute, probably through
663 -- definition.
664
665 hr_utility.trace('In set context of ExecuteConcProgram');
666 l_user_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'USER_ID');
667 l_resp_appl_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'APPLICATION_ID');
668 l_resp_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'RESPONSIBILITY_ID');
669 l_org_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'ORG_ID');
670
671 l_security_group_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'SECURITY_GROUP_ID');
672 l_per_security_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'PER_SECURITY_PROFILE_ID');
673 /*
674 l_user_id:= crec.user_id;
675 l_resp_appl_id:= crec.responsibility_application_id;
676 l_resp_id:= crec.responsibility_id;
677
678 */
679 hr_utility.trace('l_user_id = '|| l_user_id);
683 hr_utility.trace('l_security_group_id = '|| l_security_group_id);
680 hr_utility.trace('l_resp_appl_id: = '|| l_resp_appl_id);
681 hr_utility.trace('l_resp_id = '|| l_resp_id);
682 hr_utility.trace('l_org_id = '|| l_org_id);
684 hr_utility.trace('l_per_security_id = '|| l_per_security_id);
685
686 -- Set the database session context which also sets the org
687 --FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_security_group_id);
688 FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_per_security_id);
689
690 hr_utility.trace('In funcmode RUN of ExecuteConcProgram');
691 -- HR_SIGNON.Initialize_HR_Security;
692 hr_utility.trace('A4 HR_SIGNON.Initialize_HR_Security of ExecuteConcProgram');
693 fnd_wf_standard.ExecuteConcProgram(p_itemtype ,
694 p_itemkey ,
695 p_actid ,
696 p_funcmode ,
697 l_resultout );
698
699 p_result := l_resultout;
700 return;
701
702 ELSIF (p_funcmode = 'TEST_CTX') THEN
703 hr_utility.trace('In Test context of ExecuteConcProgram');
704 -- Code that compares current session context
705 -- with the work item context required to execute
706 -- the workflow safely
707
708 fnd_profile.get(name=>'ORG_ID',val=>session_org_id);
709
710 work_item_org_id := wf_engine.GetItemAttrNumber(p_itemtype, p_itemkey, 'ORG_ID');
711
712 if session_org_id = work_item_org_id then
713
714 p_result := 'COMPLETE:TRUE';
715
716 else
717 -- If the background engine is executing the
718 -- Selector/Callback function, the workflow engine
719 -- Will immediately run the Selector/Callback
720 -- Function in SET_CTX mode
721
722 p_result := 'COMPLETE:FALSE';
723
724 end if;
725
726 return;
727
728 ELSIF(p_funcmode = 'SET_CTX') THEN
729
730 -- Code that sets the current session context
731 -- based on the work item context stored in item attributes
732
733 -- get Item Attributes for user_id, responsibility_id and application_id
734 -- this assumes that they were set as item attribute, probably through
735 -- definition.
736
737 hr_utility.trace('In set context of ExecuteConcProgram');
738 l_user_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'USER_ID');
739 l_resp_appl_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'APPLICATION_ID');
740 l_resp_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'RESPONSIBILITY_ID');
741 l_org_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'ORG_ID');
742
743 /*
744 l_user_id:= crec.user_id;
745 l_resp_appl_id:= crec.responsibility_application_id;
746 l_resp_id:= crec.responsibility_id;
747
748 */
749 -- Set the database session context which also sets the org
750 FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id);
751
752
753 p_result := 'COMPLETE';
754
755 return;
756
757 ELSE
758 p_result := 'COMPLETE';
759 return;
760
761
762 END IF;
763 --end loop;
764
765
766 EXCEPTION
767 WHEN OTHERS THEN NULL;
768 WF_CORE.Context('PAY_US_WORKFLOW_API_PKG', 'ExecuteConcProgram',
769 p_itemtype, p_itemkey, p_actid, p_funcmode);
770 RAISE;
771
772
773 END ExecuteConcProgram;
774
775 PROCEDURE CheckProcessInputs
776 ( p_itemtype in varchar2
777 , p_itemkey in varchar2
778 , p_actid in number
779 , p_funcmode in varchar2
780 , p_result in out nocopy varchar2
781 )
782 IS
783 l_user_id NUMBER;
784 l_resp_id NUMBER;
785 l_resp_appl_id NUMBER;
786 l_org_id NUMBER;
787 l_resultout varchar2(80);
788 l_security_group_id NUMBER;
789 l_per_security_id NUMBER;
790
791 BEGIN
792
793 hr_utility.trace('In CheckProcessInputs');
794
795 IF (p_funcmode = 'RUN') THEN
796
797 -- Code that determines Start Process
798 -- p_result := 'COMPLETE:RUN';
799 -- get Item Attributes for user_id, responsibility_id and application_id
800 -- this assumes that they were set as item attribute, probably through
801 -- definition.
802 hr_utility.trace('In set context of ExecuteConcProgram');
803 l_user_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'USER_ID');
804 l_resp_appl_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'APPLICATION_ID');
805 l_resp_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'RESPONSIBILITY_ID');
806 l_org_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'ORG_ID');
807
808 l_security_group_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'SECURITY_GROUP_ID');
809 l_per_security_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'PER_SECURITY_PROFILE_ID');
810
811 hr_utility.trace('l_user_id = '|| l_user_id);
812 hr_utility.trace('l_resp_appl_id: = '|| l_resp_appl_id);
813 hr_utility.trace('l_resp_id = '|| l_resp_id);
814 hr_utility.trace('l_org_id = '|| l_org_id);
815 hr_utility.trace('l_security_group_id = '|| l_security_group_id);
816 hr_utility.trace('l_per_security_id = '|| l_per_security_id);
817
818 -- Set the database session context which also sets the org
819 --FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_security_group_id);
820 FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_per_security_id);
821
822 WF_STANDARD.COMPARE(p_itemtype ,
826 l_resultout );
823 p_itemkey ,
824 p_actid ,
825 p_funcmode ,
827
828 if (l_resultout = 'COMPLETE:EQ') then
829 p_result := 'COMPLETE:RUN';
830 elsif ((l_resultout = 'COMPLETE:LT') or
831 (l_resultout = 'COMPLETE:GT') or
832 (l_resultout = 'COMPLETE:NULL')) then
833 p_result := 'COMPLETE:SKIP';
834 end if;
835
836 return;
837
838 ELSE
839 p_result := 'COMPLETE:SKIP';
840 return;
841
842 END IF;
843
844
845 EXCEPTION
846 WHEN OTHERS THEN NULL;
847 WF_CORE.Context('PAY_US_WORKFLOW_API_PKG', 'CheckProcessInputs',
848 p_itemtype, p_itemkey, p_actid, p_funcmode);
849 RAISE;
850
851
852 END CheckProcessInputs;
853
854
855 PROCEDURE IsResponseRequired
856 ( p_itemtype in varchar2
857 , p_itemkey in varchar2
858 , p_actid in number
859 , p_funcmode in varchar2
860 , p_result in out nocopy varchar2
861 )
862 IS
863 l_user_id NUMBER;
864 l_resp_id NUMBER;
865 l_resp_appl_id NUMBER;
866 l_org_id NUMBER;
867 l_resultout varchar2(80);
868 l_security_group_id NUMBER;
869 l_per_security_id NUMBER;
870
871 BEGIN
872
873 hr_utility.trace('In IsResponseRequired');
874
875 IF (p_funcmode = 'RUN') THEN
876
877 -- Code that determines Start Process
878 -- p_result := 'COMPLETE:RUN';
879 -- get Item Attributes for user_id, responsibility_id and application_id
880 -- this assumes that they were set as item attribute, probably through
881 -- definition.
882 hr_utility.trace('In set context of ExecuteConcProgram');
883 l_user_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'USER_ID');
884 l_resp_appl_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'APPLICATION_ID');
885 l_resp_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'RESPONSIBILITY_ID');
886 l_org_id:= wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'ORG_ID');
887
888 l_security_group_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'SECURITY_GROUP_ID');
889 l_per_security_id := wf_engine.GetItemAttrNumber(p_itemtype,p_itemkey,'PER_SECURITY_PROFILE_ID');
890
891 hr_utility.trace('l_user_id = '|| l_user_id);
892 hr_utility.trace('l_resp_appl_id: = '|| l_resp_appl_id);
893 hr_utility.trace('l_resp_id = '|| l_resp_id);
894 hr_utility.trace('l_org_id = '|| l_org_id);
895 hr_utility.trace('l_security_group_id = '|| l_security_group_id);
896 hr_utility.trace('l_per_security_id = '|| l_per_security_id);
897
898 -- Set the database session context which also sets the org
899 --FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_security_group_id);
900 FND_GLOBAL.Apps_Initialize(l_user_id, l_resp_id, l_resp_appl_id,l_per_security_id);
901
902 WF_STANDARD.COMPARE(p_itemtype ,
903 p_itemkey ,
904 p_actid ,
905 p_funcmode ,
906 l_resultout );
907
908 if (l_resultout = 'COMPLETE:EQ') then
909 p_result := 'COMPLETE:Y';
910 elsif ((l_resultout = 'COMPLETE:LT') or
911 (l_resultout = 'COMPLETE:GT') or
912 (l_resultout = 'COMPLETE:NULL')) then
913 p_result := 'COMPLETE:N';
914 end if;
915
916 return;
917
918 ELSE
919 p_result := 'COMPLETE:Y';
920 return;
921
922 END IF;
923
924
925 EXCEPTION
926 WHEN OTHERS THEN NULL;
927 WF_CORE.Context('PAY_US_WORKFLOW_API_PKG', 'IsResponseRequired',
928 p_itemtype, p_itemkey, p_actid, p_funcmode);
929 RAISE;
930
931
932 END IsResponseRequired;
933
934 --begin
935 -- hr_utility.trace_on(null,'PYWF');
936
937 END PAY_US_WORKFLOW_API_PKG;