[Home] [Help]
PACKAGE BODY: APPS.IGI_IAC_WF_PKG
Source
1 PACKAGE BODY IGI_IAC_WF_PKG AS
2 /* $Header: igiiawfb.pls 120.5.12000000.1 2007/08/01 16:19:43 npandya ship $ */
3
4 --===========================FND_LOG.START=====================================
5
6 g_state_level NUMBER := FND_LOG.LEVEL_STATEMENT;
7 g_proc_level NUMBER := FND_LOG.LEVEL_PROCEDURE;
8 g_event_level NUMBER := FND_LOG.LEVEL_EVENT;
9 g_excep_level NUMBER := FND_LOG.LEVEL_EXCEPTION;
10 g_error_level NUMBER := FND_LOG.LEVEL_ERROR;
11 g_unexp_level NUMBER := FND_LOG.LEVEL_UNEXPECTED;
12 g_path VARCHAR2(100):= 'IGI.PLSQL.igiiawfb.igi_iac_wf_pkg.';
13
14 --===========================FND_LOG.END=====================================
15
16 FUNCTION START_PROCESS (X_flex_account_type in varchar2,
17 X_book_type_code in varchar2,
18 X_chart_of_accounts_id in number,
19 X_dist_ccid in number,
20 X_acct_segval in varchar2,
21 X_default_ccid in number,
22 X_account_ccid in number,
23 X_distribution_id in number,
24 X_Workflowprocess in varchar2,
25 X_return_ccid in out NOCOPY number)
26 return boolean is
27 ItemType varchar2(30) :='IGIIACWF';
28 ItemKey varchar2(50);
29 l_concat_segs varchar2(2000);
30 l_concat_ids varchar2(2000);
31 l_concat_descrs varchar2(2000);
32 l_errmsg varchar2(2000);
33 l_encoded_msg varchar2(2000);
34 result boolean;
35 l_result boolean;
36 l_return_ccid number;
37 l_char_date varchar2(27);
38 l_account_type varchar2(2000);
39
40 l_appl_short_name varchar2(30);
41 l_message_name varchar2(30);
42 l_num number;
43 l_string varchar2(100);
44 l_path_name VARCHAR2(150) := g_path||'start_process';
45
46 l_new_acc boolean;
47 -- Default the item key to "IGIIACWF"
48 BEGIN -- <<GEN_CCID>>
49 --Initialize the fnd flex workflow
50 -- fnd_flex_workflow.debug_on;
51 itemkey := FND_FLEX_WORKFLOW.INITIALIZE
52 ('SQLGL',
53 'GL#',
54 X_chart_of_accounts_id,
55 'IGIIACWF'
56 );
57
58 /* Initialize the workflow item attributes */
59 wf_engine.SetItemAttrText(itemtype => itemtype,
60 Itemkey => itemkey,
61 aname =>'IAC_BOOK_TYPE_CODE',
62 avalue =>X_book_type_code);
63 wf_engine.SetItemAttrText(itemtype => itemtype,
64 itemkey => itemkey,
65 aname =>'IAC_ACCOUNT_TYPE',
66 avalue =>X_flex_account_type);
67 wf_engine.SetItemAttrNumber(itemtype => itemtype,
68 itemkey => itemkey,
69 aname =>'IAC_CHART_OF_ACCOUNTS_ID',
70 avalue =>X_chart_of_accounts_id);
71
72 wf_engine.SetItemAttrNumber(itemtype => itemtype,
73 itemkey => itemkey,
74 aname => 'IAC_DISTRIBUTION_CCID',
75 avalue => X_dist_ccid );
76
77 wf_engine.SetItemAttrText(itemtype => itemtype,
78 itemkey => itemkey,
79 aname => 'IAC_ACCT_SEG_VAL',
80 avalue => X_acct_segval);
81
82 wf_engine.SetItemAttrNumber(itemtype => itemtype,
83 itemkey => itemkey,
84 aname => 'IAC_DEFAULT_CCID',
85 avalue => X_default_ccid);
86
87
88 wf_engine.SetItemAttrNumber(itemtype => itemtype,
89 itemkey => itemkey,
90 aname => 'IAC_ACCOUNT_CCID',
91 avalue => X_account_ccid);
92
93 wf_engine.SetItemAttrNumber(itemtype => itemtype,
94 itemkey => itemkey,
95 aname => 'IAC_DISTRIBUTION_ID',
96 avalue => X_distribution_id);
97 l_result := FND_FLEX_WORKFLOW.GENERATE(
98 'IGIIACWF',
99 itemkey,
100 TRUE,
101 l_return_ccid,
102 l_concat_segs,
103 l_concat_ids,
104 l_concat_descrs,
105 l_errmsg,
106 l_new_acc);
107
108 IF NOT l_result THEN
109 -- ADD message IGI_IAC_WF_FAILED_CCID to stack
110 -- With Tokens ACCOUNT_TYPE,DISTRIBUTION_ID,BOOK_TYPE_CODE.
111 FND_MESSAGE.SET_NAME ('IGI', 'IGI_IAC_WF_FAILED_CCID');
112 FND_MESSAGE.SET_TOKEN('ACCOUNT_TYPE',X_flex_Account_type, TRUE);
113 --FND_MESSAGE.SET_TOKEN('BOOK_TYPE_CODE',X_book_type_code, TRUE);
114 FND_MESSAGE.SET_TOKEN('DIST_ID',TO_CHAR(X_distribution_id), TRUE);
115 FND_MESSAGE.SET_TOKEN('CONCAT_SEGS',l_concat_segs , TRUE);
116 igi_iac_debug_pkg.debug_other_msg(p_level => g_error_level,
117 p_full_path => l_path_name,
118 p_remove_from_stack => FALSE);
119 FND_MESSAGE.RAISE_ERROR;
120 RETURN FALSE;
121
122 END IF;
123
124 IF l_return_ccid > 1 Then
125 X_return_ccid := l_return_ccid;
126 return true;
127 elsif
128 l_return_ccid = -1 then --use the function to get the value
129 l_return_ccid := FND_FLEX_EXT.get_ccid(
130 'SQLGL',
131 'GL#',
132 X_chart_of_accounts_id,
133 l_char_date,
134 l_concat_segs);
135 X_return_ccid := l_return_ccid;
136 return true;
137
138
139
140 Else
141 --ADD message IGI_IAC_WF_FAILED_CCID to stack
142 --With Tokens ACCOUNT_TYPE,DISTRIBUTION_ID,BOOK_TYPE_CODE.
143 FND_MESSAGE.SET_NAME ('IGI', 'IGI_IAC_WF_FAILED_CCID');
144 FND_MESSAGE.SET_TOKEN('ACCOUNT_TYPE',X_flex_Account_type , TRUE);
145 -- FND_MESSAGE.SET_TOKEN('BOOK_TYPE_CODE',X_book_type_code, TRUE);
146 FND_MESSAGE.SET_TOKEN('DIST_ID',TO_CHAR(X_distribution_id), TRUE);
147 FND_MESSAGE.SET_TOKEN('CONCAT_SEGS',l_concat_segs , TRUE);
148 igi_iac_debug_pkg.debug_other_msg(p_level => g_error_level,
149 p_full_path => l_path_name,
150 p_remove_from_stack => FALSE);
151 FND_MESSAGE.RAISE_ERROR;
152 RETURN FALSE;
153 END IF ;
154
155 X_return_ccid := l_return_ccid;
156 Return TRUE;
157 EXCEPTION
158 WHEN OTHERS THEN
159 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
160 wf_core.context('IGI_IAC_WF_PKG',
161 'Start_Process',
162 X_book_type_code,
163 X_dist_ccid,
164 X_default_ccid,
165 'IGIIACWF');
166 RAISE;
167 END start_process;
168
169 /* The check_account function should return the group of the account based on the account type */
170
171 PROCEDURE CHECK_ACCT(itemtype in varchar2,
172 itemkey in varchar2,
173 actid in number,
174 funcmode in varchar2,
175 result out NOCOPY varchar2)
176 IS
177 l_account_type varchar2(250);
178 l_path_name VARCHAR2(150) := g_path||'check_acct';
179
180 BEGIN << CHECK_ACCT>>
181
182 --Based on the run mode return the values.
183 IF (funcmode = 'RUN') THEN
184 l_account_type := wf_engine.GetItemAttrText(itemtype,itemkey,'IAC_ACCOUNT_TYPE');
185 result := 'COMPLETE:' || l_account_type;
186 RETURN;
187 ELSIF (funcmode = 'CANCEL') THEN
188 result := 'COMPLETE:';
189 RETURN;
190 ELSE
191 result := '';
192 RETURN;
193 END IF;
194 EXCEPTION
195 WHEN OTHERS THEN
196 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
197 wf_core.context('IGI_IAC_WF_PKG',
198 'Check_Acct',
199 itemkey,
200 itemtype,
201 funcmode);
202 RAISE;
203
204 END; /* CHECK_ACCT */
205
206
207 /* The check_group function should return the group of the account based on the account type */
208
209 PROCEDURE CHECK_GROUP(itemtype in varchar2,
210 itemkey in varchar2,
211 actid in number,
212 funcmode in varchar2,
213 result out NOCOPY varchar2)
214 IS
215 l_account_type varchar2(250);
216 l_path_name VARCHAR2(150) := g_path||'check_group';
217 BEGIN <<CHECK_GROUP>>
218
219
220 IF (funcmode = 'RUN') THEN
221 /* determine the account group based on the account type passed */
222 /* All accounts expect the DEPRN_EXP falls to category levelaccount*/
223 /* Need to know which account falls into which account type */
224
225 l_account_type := wf_engine.GetItemAttrText(itemtype,itemkey,'IAC_ACCOUNT_TYPE');
226 IF (l_account_type in ( 'BACKLOG_DEPRN_RSV_ACCT',
227 'OPERATING_EXPENSE_ACCT',
228 'GENERAL_FUND_ACCT',
229 'REVAL_RESERVE_ACCT',
230 'REVAL_RESERVE_RETIRED_ACCT'))
231 THEN
232 result:= 'COMPLETE:' || 'CATE_LEVEL_ACCOUNT';
233 ELSE
234 result := 'COMPLETE:';
235 END IF;
236 ELSIF (funcmode = 'CANCEL') THEN
237 result := 'COMPLETE:';
238 RETURN;
239 ELSE
240 result := '';
241 RETURN;
242 END IF;
243 EXCEPTION
244 WHEN OTHERS THEN
245 igi_iac_debug_pkg.debug_unexpected_msg(p_full_path => l_path_name);
246 wf_core.context('IGI_IAC_WF_PKG',
247 'Check_Group',
248 itemkey,
249 itemtype,
250 funcmode);
251 RAISE;
252 END; /* CHECK_GROUP */
253 END; --end of package igi_iac_wf_pkg
254