3: --
4: -- Package Variables
5: --
6: g_package varchar2(33) := ' PAY_ASSG_COST_WF.';
7: g_debug boolean := hr_utility.debug_enabled;
8: g_approver ame_util.approversTable2;
9: /*Used to get the transaction id pertaining to the specified
10: item type and item key. If the transaction id does not exists
11: then it will create starting a transaction.*/
31: --
32: l_dummy number(1);
33: c_proc constant varchar2(60) := 'create_item_attrib_if_notexist';
34: begin
35: g_debug := hr_utility.debug_enabled;
36: if g_debug then
37: hr_utility.set_location('Entering:'|| g_package||'.'||c_proc, 1);
38: end if;
39:
33: c_proc constant varchar2(60) := 'create_item_attrib_if_notexist';
34: begin
35: g_debug := hr_utility.debug_enabled;
36: if g_debug then
37: hr_utility.set_location('Entering:'|| g_package||'.'||c_proc, 1);
38: end if;
39:
40:
41: if g_debug then
38: end if;
39:
40:
41: if g_debug then
42: hr_utility.set_location('opening cursor csr_wiav with itemtype:'|| itemtype ||' , itemkey: '|| itemkey ||' , aname: '|| aname, 1);
43: end if;
44: -- open the cursor to determine if the attribute exists
45: open csr_wiav(itemtype,itemkey,aname);
46: fetch csr_wiav into l_dummy;
47: if csr_wiav%notfound then
48: --
49: -- item attribute does not exist so create it
50: if g_debug then
51: hr_utility.set_location('calling wf_engine.additemattr for aname:'||aname,2);
52: end if;
53: wf_engine.additemattr
54: (itemtype => itemtype
55: ,itemkey => itemkey
63: if csr_wiav%found then
64: -- set the values as per the type
65: if(text_value is not null) then
66: if g_debug then
67: hr_utility.set_location('calling wf_engine.setitemattrtext for text_value:'|| text_value,3);
68: end if;
69: wf_engine.setitemattrtext(itemtype,itemkey,aname,text_value);
70: end if;
71:
70: end if;
71:
72: if(number_value is not null) then
73: if g_debug then
74: hr_utility.set_location('calling wf_engine.setitemattrnumber for text_value:'|| number_value,4);
75: end if;
76: wf_engine.setitemattrnumber(itemtype,itemkey,aname,number_value);
77: end if;
78:
77: end if;
78:
79: if(date_value is not null) then
80: if g_debug then
81: hr_utility.set_location('calling wf_engine.setitemattrDate for text_value:'|| date_value,5);
82: end if;
83: wf_engine.setitemattrDate(itemtype,itemkey,aname,date_value);
84: end if;
85:
87:
88: close csr_wiav;
89:
90: if (g_debug ) then
91: hr_utility.set_location('Leaving:'|| g_package||'.'||c_proc, 10);
92: end if;
93:
94: exception
95: when others then
93:
94: exception
95: when others then
96: if g_debug then
97: hr_utility.set_location('Error in create_item_attrib_if_notexist SQLERRM' ||' '||to_char(SQLCODE),20);
98: end if;
99: raise;
100:
101: end create_item_attrib_if_notexist;
112: l_result varchar2(100);
113: l_performer_id number(10);
114: l_proc varchar2(100) := g_package||'GET_TRANSACTION_ID';
115: BEGIN
116: hr_utility.set_location('Entering ... '||l_proc,10);
117: l_transaction_id := wf_engine.GetItemAttrNumber(
118: itemtype => itemtype
119: ,itemkey => itemkey
120: ,aname => 'TRANSACTION_ID'
121: ,ignore_notfound => false
122: );
123: /*If no transaction exists, start a transaction.*/
124: IF L_TRANSACTION_ID IS NULL THEN
125: hr_utility.set_location(l_proc || '....Step1',20);
126: l_performer_id := wf_engine.GetItemAttrNumber(itemtype, itemkey, 'PERFORMER_PERSON_ID');
127:
128: hr_utility.set_location(l_proc , 30);
129:
124: IF L_TRANSACTION_ID IS NULL THEN
125: hr_utility.set_location(l_proc || '....Step1',20);
126: l_performer_id := wf_engine.GetItemAttrNumber(itemtype, itemkey, 'PERFORMER_PERSON_ID');
127:
128: hr_utility.set_location(l_proc , 30);
129:
130: hr_transaction_ss.start_transaction
131: (itemtype => itemtype
132: ,itemkey => itemkey
133: ,actid => actid
134: ,funmode => 'RUN'
135: ,p_login_person_id => l_performer_id
136: ,result => l_result);
137: hr_utility.set_location(l_proc, 40);
138:
139: /*Gett the newly created transaction and set as workflow attribute*/
140: l_transaction_id:= hr_transaction_ss.get_transaction_id
141: (p_item_type => itemtype
140: l_transaction_id:= hr_transaction_ss.get_transaction_id
141: (p_item_type => itemtype
142: ,p_item_key => itemkey);
143: wf_engine.SetItemAttrNumber(itemtype,itemkey,'TRANSACTION_ID',l_transaction_id);
144: hr_utility.set_location(l_proc ,50);
145:
146: END IF;
147: hr_utility.set_location('Leaving....'||l_proc ,60);
148: RETURN l_transaction_id;
143: wf_engine.SetItemAttrNumber(itemtype,itemkey,'TRANSACTION_ID',l_transaction_id);
144: hr_utility.set_location(l_proc ,50);
145:
146: END IF;
147: hr_utility.set_location('Leaving....'||l_proc ,60);
148: RETURN l_transaction_id;
149:
150: END GET_TRANSACTION_ID;
151: procedure check_approvers_exist
167: l_wf_admin ame_util.approverRecord2;
168: l_admin_name varchar2(240);
169: l_admin_display_name varchar2(240);
170: begin
171: hr_utility.set_location('Entering:'|| l_proc, 10);
172: --bug 16414912 transfer WAIT WF process to plsql sleep
173: dbms_lock.sleep(40);
174: --bug 16414912 transfer WAIT WF process to plsql sleep
175: /*Get the transaction id*/
185: Once he setup the approver then the notification would go to the approver
186: as expected. We are not supposed to reject any Workflow in the absense of
187: approver.*/
188:
189: hr_utility.set_location(l_proc, 20);
190: resultout := ame_util.booleanTrue;
191: begin
192: ame_api2.getNextApprovers4(
193: applicationIdIn => 801,
259: l_role_name varchar2(240);
260: l_role_display_name varchar2(240);
261:
262: begin
263: hr_utility.set_location('Entering ... '||l_proc, 10);
264: /*Get the transaction id*/
265: l_transaction_id := get_transaction_id(
266: itemtype => itemtype
267: ,itemkey => itemkey
271:
272: /*Update the status of the previous approver to true as the control
273: comes to this place once the approver approves it.*/
274:
275: hr_utility.set_location(l_proc,20);
276: ame_api2.updateApprovalStatus2(
277: applicationIdIn =>801,
278: transactionTypeIn =>'PAY_ASSIGNMENT_COSTING',
279: transactionIdIn =>l_transaction_id,
281: approverNameIn => wf_engine.getItemAttrText(itemtype, itemkey,'APPROVER_LOGIN_NAME'),
282: updateItemIn => true);
283:
284: /*Now get the next approver.*/
285: hr_utility.set_location(l_proc,30);
286: ame_api2.getNextApprovers4(
287: applicationIdIn => 801,
288: transactionTypeIn => 'PAY_ASSIGNMENT_COSTING',
289: transactionIdIn => l_transaction_id,
294: the attribute APPROVER_LOGIN_NAME. Workflow sends notifications to the approvers
295: If there are no approvers then we need to save the data. Once the resultout
296: is set to 'F' workflow take care of saving the data by calling underlaying
297: APIs*/
298: hr_utility.set_location(l_proc, 40);
299: if l_apprvl_process_complete = ame_util.booleanFalse then
300: /*Set the previous approver attributes.*/
301: wf_engine.setItemAttrText(itemtype, itemkey,'PREVIOUS_APPROVER_LOGIN_NAME',
302: wf_engine.getItemAttrText(itemtype, itemkey, 'APPROVER_LOGIN_NAME'));
315: resultout := 'T';
316: else
317: resultout := 'F';
318: end if;
319: hr_utility.set_location('Leaving.....'||l_proc,50);
320: EXCEPTION
321: WHEN OTHERS THEN
322: hr_utility.set_location('An EXCEPTION occured '||SQLERRM(SQLCODE),60);
323: hr_utility.set_location('Leaving ..'||l_proc,1000);
318: end if;
319: hr_utility.set_location('Leaving.....'||l_proc,50);
320: EXCEPTION
321: WHEN OTHERS THEN
322: hr_utility.set_location('An EXCEPTION occured '||SQLERRM(SQLCODE),60);
323: hr_utility.set_location('Leaving ..'||l_proc,1000);
324: RAISE;
325: end get_next_approver;
326: -- ------------------------------------------------------------------------
319: hr_utility.set_location('Leaving.....'||l_proc,50);
320: EXCEPTION
321: WHEN OTHERS THEN
322: hr_utility.set_location('An EXCEPTION occured '||SQLERRM(SQLCODE),60);
323: hr_utility.set_location('Leaving ..'||l_proc,1000);
324: RAISE;
325: end get_next_approver;
326: -- ------------------------------------------------------------------------
327: -- |--------------------------< START_WF_PROCESS>-------------------------|
354: where person_id = p_person_id
355: and trunc(sysdate) between effective_start_date and effective_end_date;
356:
357: BEGIN
358: hr_utility.set_location('Entering....'||l_proc,10);
359:
360: /*Create the workflow process.*/
361: wf_engine.CreateProcess (ItemType => l_Item_Type
362: ,ItemKey => p_Item_Key
411: ,itemkey => p_Item_Key
412: );
413: EXCEPTION
414: WHEN OTHERS THEN
415: hr_utility.set_location('An EXCEPTION occured',40);
416: hr_utility.set_location('Leaving ..'||l_proc,999);
417: RAISE;
418: END START_WF_PROCESS;
419: -- ------------------------------------------------------------------------
412: );
413: EXCEPTION
414: WHEN OTHERS THEN
415: hr_utility.set_location('An EXCEPTION occured',40);
416: hr_utility.set_location('Leaving ..'||l_proc,999);
417: RAISE;
418: END START_WF_PROCESS;
419: -- ------------------------------------------------------------------------
420: -- |--------------------------< APPROVE_PROCESS >-------------------------|
434: l_actid WF_ITEM_ACTIVITY_STATUSES.process_activity%TYPE;
435: l_effective_date DATE;
436: begin
437: if g_debug then
438: hr_utility.set_location('Entering ..'||l_proc,10);
439: end if;
440: /*Set the previous approver attributes.*/
441: wf_engine.setItemAttrText(itemtype, itemkey,'PREVIOUS_APPROVER_LOGIN_NAME',
442: wf_engine.getItemAttrText(itemtype, itemkey, 'APPROVER_LOGIN_NAME'));
473: ,actid => actid
474: ,funmode => funmode
475: ,result => result);
476: if (result = 'SUCCESS') then
477: hr_utility.set_location('Transaction deleted successfully ',20);
478: else
479: hr_utility.set_location('Error in deleting Transaction ',30);
480: end if;
481: if g_debug then
475: ,result => result);
476: if (result = 'SUCCESS') then
477: hr_utility.set_location('Transaction deleted successfully ',20);
478: else
479: hr_utility.set_location('Error in deleting Transaction ',30);
480: end if;
481: if g_debug then
482: hr_utility.set_location('Leaving ..'||l_proc,1000);
483: end if;
478: else
479: hr_utility.set_location('Error in deleting Transaction ',30);
480: end if;
481: if g_debug then
482: hr_utility.set_location('Leaving ..'||l_proc,1000);
483: end if;
484: -- commit;
485: EXCEPTION
486: WHEN OTHERS THEN
483: end if;
484: -- commit;
485: EXCEPTION
486: WHEN OTHERS THEN
487: hr_utility.set_location('An EXCEPTION occured',40);
488: hr_utility.set_location('Leaving ..'||l_proc,1000);
489: RAISE;
490: end APPROVE_PROCESS;
491: -- ------------------------------------------------------------------------
484: -- commit;
485: EXCEPTION
486: WHEN OTHERS THEN
487: hr_utility.set_location('An EXCEPTION occured',40);
488: hr_utility.set_location('Leaving ..'||l_proc,1000);
489: RAISE;
490: end APPROVE_PROCESS;
491: -- ------------------------------------------------------------------------
492: -- |--------------------------< REJECT_PROCESS >--------------------------|
500: l_proc varchar2(240) := g_package||'REJECT_PROCESS';
501: l_result varchar2(20);
502: BEGIN
503: if g_debug then
504: hr_utility.set_location('Entering ..'||l_proc,10);
505: end if;
506:
507: hr_transaction_ss.rollback_transaction(
508: itemtype => itemtype
510: ,actid => actid
511: ,funmode => funmode
512: ,result => l_result);
513: if (l_result = 'SUCCESS') then
514: hr_utility.set_location('Transaction deleted successfully ',20);
515: else
516: hr_utility.set_location('Error in deleting Transaction ',30);
517: end if;
518: if g_debug then
512: ,result => l_result);
513: if (l_result = 'SUCCESS') then
514: hr_utility.set_location('Transaction deleted successfully ',20);
515: else
516: hr_utility.set_location('Error in deleting Transaction ',30);
517: end if;
518: if g_debug then
519: hr_utility.set_location('Leaving ..'||l_proc,1000);
520: end if;
515: else
516: hr_utility.set_location('Error in deleting Transaction ',30);
517: end if;
518: if g_debug then
519: hr_utility.set_location('Leaving ..'||l_proc,1000);
520: end if;
521: EXCEPTION
522: WHEN OTHERS THEN
523: hr_utility.set_location('An EXCEPTION occured',40);
519: hr_utility.set_location('Leaving ..'||l_proc,1000);
520: end if;
521: EXCEPTION
522: WHEN OTHERS THEN
523: hr_utility.set_location('An EXCEPTION occured',40);
524: hr_utility.set_location('Leaving ..'||l_proc,1000);
525: RAISE;
526: END REJECT_PROCESS;
527:
520: end if;
521: EXCEPTION
522: WHEN OTHERS THEN
523: hr_utility.set_location('An EXCEPTION occured',40);
524: hr_utility.set_location('Leaving ..'||l_proc,1000);
525: RAISE;
526: END REJECT_PROCESS;
527:
528: end PAY_ASSG_COST_WF;