[Home] [Help]
PACKAGE BODY: APPS.FAFLEX_PKG_WF
Source
1 PACKAGE BODY FAFLEX_PKG_WF as
2 /* $Header: faflxwfb.pls 120.6 2011/02/04 10:15:31 gigupta ship $*/
3 -------------------------------------------------------------------
4 -- This function replaces fafbgcc in FA_FLEX_PKG.fafb_call_flex
5
6 FUNCTION START_PROCESS
7 (X_flex_account_type in varchar2,
8 X_book_type_code in varchar2,
9 X_flex_num in number,
10 X_dist_ccid in number,
11 X_acct_segval in varchar2,
12 X_default_ccid in number,
13 X_account_ccid in number,
14 X_distribution_id in number default null,
15 X_Workflowprocess in varchar2 default null,
16 X_Validation_Date in date default sysdate,
17 X_return_ccid in out nocopy number
18 , p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) return boolean is
19
20 -- moved to package spec
21 -- ItemType varchar2(30) :='FAFLEXWF';
22 -- ItemKey varchar2(30);
23
24 h_concat_segs varchar2(2000);
25 h_concat_ids varchar2(2000);
26 h_concat_descrs varchar2(2000);
27 h_errmsg varchar2(2000);
28 h_encoded_msg varchar2(2000);
29 result boolean;
30 h_return_ccid number;
31 char_date varchar2(27);
32
33 h_appl_short_name varchar2(30);
34 h_message_name varchar2(30);
35 h_num number;
36 h_string varchar2(100);
37
38 h_new_ccid boolean;
39
40 l_nsegments NUMBER;
41 l_val_date DATE;
42
43 BEGIN <<GEN_CCID>>
44
45 itemkey := FND_FLEX_WORKFLOW.INITIALIZE
46 ('SQLGL',
47 'GL#',
48 X_flex_num,
49 'FAFLEXWF'
50 );
51
52 wf_engine.SetItemAttrNumber
53 (itemtype => itemtype,
54 itemkey => itemkey,
55 aname => 'CHART_OF_ACCOUNTS_ID',
56 avalue => X_flex_num);
57
58 wf_engine.SetItemAttrText
59 (itemtype => itemtype,
60 itemkey => itemkey,
61 aname => 'BOOK_TYPE_CODE',
62 avalue => X_book_type_code);
63
64 wf_engine.SetItemAttrNumber
65 (itemtype => itemtype,
66 itemkey => itemkey,
67 aname => 'DEFAULT_CCID',
68 avalue => X_default_ccid);
69
70 BEGIN
71
72 wf_engine.SetItemAttrDate
73 (itemtype => itemtype,
74 itemkey => itemkey,
75 aname => 'VALIDATION_DATE',
76 avalue => X_validation_date);
77
78 EXCEPTION
79 when others then
80 if (wf_core.error_name = 'WFENG_ITEM_ATTR') then
81 wf_engine.AddItemAttr(itemtype,itemkey,'VALIDATION_DATE');
82 wf_engine.SetItemAttrDate
83 (itemtype => itemtype,
84 itemkey => itemkey,
85 aname => 'VALIDATION_DATE',
86 avalue => X_validation_date);
87 else
88 raise;
89 end if;
90 END;
91
92
93
94 -- Initialize the workflow item attributes
95
96 wf_engine.SetItemAttrText
97 (itemtype => itemtype,
98 itemkey => itemkey,
99 aname => 'ACCOUNT_TYPE',
100 avalue => X_flex_account_type);
101
102 wf_engine.SetItemAttrNumber
103 (itemtype => itemtype,
104 itemkey => itemkey,
105 aname => 'DISTRIBUTION_CCID',
106 avalue => X_dist_ccid );
107
108 wf_engine.SetItemAttrText
109 (itemtype => itemtype,
110 itemkey => itemkey,
111 aname => 'ACCT_SEG_VAL',
112 avalue => X_acct_segval);
113
114 wf_engine.SetItemAttrNumber
115 (itemtype => itemtype,
116 itemkey => itemkey,
117 aname => 'ACCOUNT_CCID',
118 avalue => X_account_ccid);
119
120 wf_engine.SetItemAttrNumber
121 (itemtype => itemtype,
122 itemkey => itemkey,
123 aname => 'DISTRIBUTION_ID',
124 avalue => X_distribution_id);
125
126 -- BUG# 1833652
127 -- passing the insert_if_new and new_combination parameters
128 -- so that combinations will be dynamically inserted
129 -- bridgway 06/20/01
130
131 result := FND_FLEX_WORKFLOW.GENERATE
132 ('FAFLEXWF',
133 itemkey,
134 TRUE,
135 X_return_ccid,
136 h_concat_segs,
137 h_concat_ids,
138 h_concat_descrs,
139 h_errmsg,
140 h_new_ccid);
141
142 FA_GCCID_PKG.global_concat_segs := h_concat_segs;
143
144 if (not result) then
145
146 -- BUG# 1504839
147 -- enhancing the messaging here for fagda and for form level
148 -- transactions. Now dump the concatonated segs and the FND
149 -- error returned in encoded format from Workflow
150 -- bridgway 04/12/01
151
152 FA_SRVR_MSG.ADD_MESSAGE
153 (CALLING_FN => 'FAFLEX_PKG_WF.START_PROCESS',
154 NAME => 'FA_FLEXBUILDER_FAIL_CCID',
155 TOKEN1 => 'ACCOUNT_TYPE',
156 VALUE1 => X_flex_account_type,
157 TOKEN2 => 'BOOK_TYPE_CODE',
158 VALUE2 => X_book_type_code,
159 TOKEN3 => 'DIST_ID',
160 VALUE3 => X_distribution_id,
161 TOKEN4 => 'CONCAT_SEGS',
162 VALUE4 => h_concat_segs
163 , p_log_level_rec => p_log_level_rec);
164
165 fnd_message.set_encoded(h_errmsg);
166 fnd_msg_pub.add; -- end 1504839
167
168 return FALSE;
169 end if;
170
171 -- BUG# 1818599
172 -- changing date format as aol only accept the following
173 -- bridgway 06/07/01
174 -- BUG# 7529681
175 -- setting char_date to sysdate only if validation date is null
176
177 if (X_return_ccid = -1) then
178 select to_char(nvl(X_Validation_Date,sysdate),'YYYY/MM/DD HH24:MI:SS')
179 into char_date
180 from dual;
181
182 h_return_ccid := FND_FLEX_EXT.get_ccid
183 ('SQLGL',
184 'GL#',
185 X_flex_num,
186 char_date,
187 h_concat_segs);
188 if (h_return_ccid = 0 ) then
189
190 FA_SRVR_MSG.ADD_MESSAGE
191 (CALLING_FN =>'FAFLEX_PKG_WF.START_PROCESS',
192 NAME =>'FA_FLEXBUILDER_FAIL_CCID',
193 TOKEN1 => 'ACCOUNT_TYPE',
194 VALUE1 => X_flex_account_type,
195 TOKEN2 => 'BOOK_TYPE_CODE',
196 VALUE2 => X_book_type_code,
197 TOKEN3 => 'DIST_ID',
198 VALUE3 => X_distribution_id,
199 TOKEN4 => 'CONCAT_SEGS',
200 VALUE4 => h_concat_segs
201 , p_log_level_rec => p_log_level_rec);
202 fnd_message.set_encoded(h_errmsg);
203 fnd_msg_pub.add; -- end 1504839
204
205 return FALSE;
206 else
207
208 X_return_ccid := h_return_ccid;
209 end if;
210
211 end if;
212 RETURN result;
213
214 exception
215 when others then
216 wf_core.context('FA_FLEX_PKG','StartProcess',X_book_type_code,X_dist_ccid,
217 X_default_ccid,X_Workflowprocess);
218 raise;
219 end;
220
221
222 PROCEDURE CORP_OR_TAX(itemtype in varchar2,
223 itemkey in varchar2,
224 actid in number,
225 funcmode in varchar2,
226 result out nocopy varchar2, p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
227
228 h_book_type_code varchar2(30);
229 h_book_class varchar2(30);
230
231 BEGIN <<CORP_OR_TAX>>
232
233 IF (funcmode = 'RUN') THEN
234 h_book_type_code := wf_engine.GetItemAttrText(itemtype,itemkey,'BOOK_TYPE_CODE');
235 SELECT book_class
236 INTO h_book_class
237 FROM fa_book_controls
238 WHERE book_type_code = h_book_type_code;
239
240 result := 'COMPLETE:' || h_book_class ;
241 RETURN;
242 ELSIF (funcmode = 'CANCEL') THEN
243 result := 'COMPLETE:';
244 RETURN;
245 ELSE
246 result := '';
247 RETURN;
248 END IF;
249
250 EXCEPTION
251 WHEN OTHERS THEN
252 wf_core.context('FA_FLEX_PKG','CORP_OR_TAX',
253 itemtype,itemkey,TO_CHAR(actid),funcmode);
254 RAISE;
255 END;
256
257 PROCEDURE CHECK_ACCT(itemtype in varchar2,
258 itemkey in varchar2,
259 actid in number,
260 funcmode in varchar2,
261 result out nocopy varchar2, p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
262
263 h_account_type VARCHAR2(30);
264
265 BEGIN <<CHECK_ACCT>>
266 IF (funcmode = 'RUN') THEN
267 h_account_type := wf_engine.GetItemAttrText(itemtype,itemkey,'ACCOUNT_TYPE');
268 result := 'COMPLETE:' || h_account_type;
269 RETURN;
270 ELSIF (funcmode = 'CANCEL') THEN
271 result := 'COMPLETE:';
272 RETURN;
273 ELSE
274 result := '';
275 RETURN;
276 END IF;
277
278 EXCEPTION
279 WHEN OTHERS THEN
280 wf_core.context('FA_FLEX_PKG','CHECK_ACCT',
281 itemtype,itemkey,TO_CHAR(actid),funcmode);
282 RAISE;
283 END; /* CHECK_ACCT */
284
285 PROCEDURE CHECK_GROUP(itemtype in varchar2,
286 itemkey in varchar2,
287 actid in number,
288 funcmode in varchar2,
289 result out nocopy varchar2, p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
290
291 h_account_type VARCHAR2(30);
292
293 BEGIN <<CHECK_GROUP>>
294 IF (funcmode = 'RUN') THEN
295 h_account_type := wf_engine.GetItemAttrText(itemtype,itemkey,'ACCOUNT_TYPE');
296 IF (h_account_type in ('ASSET_COST','ASSET_CLEARING',
297 'CIP_CLEARING','CIP_COST',
298 'DEPRN_RSV','REV_AMORT','REV_RSV',
299 'BONUS_DEPRN_RSV','BONUS_DEPRN_EXP',
300 'IMPAIR_RSV', 'IMPAIR_EXP', -- Bug:6135190
301 'CAPITAL_ADJ','GENERAL_FUND', -- Bug 6666666
302 'REVAL_LOSS'
303 )) THEN
304 result := 'COMPLETE:' || 'CATE_LEVEL_ACCOUNT';
305 RETURN;
306 ELSIF (h_account_type in ('DEPRN_EXP')) THEN
307 result := 'COMPLETE:' || 'ASSET_LEVEL_ACCOUNT';
308 RETURN;
309 ELSE /* All Remaining accounts fall under book level */
310 result := 'COMPLETE:' || 'BOOK_LEVEL_ACCOUNT';
311 RETURN;
312 END IF;
313
314 ELSIF (funcmode = 'CANCEL') THEN
315 result := 'COMPLETE:';
316 RETURN;
317 ELSE
318 result := '';
319 RETURN;
320 END IF;
321
322 EXCEPTION
323 WHEN OTHERS THEN
324 wf_core.context('FA_FLEX_PKG','CHECK_GROUP',
325 itemtype,itemkey,TO_CHAR(actid),funcmode);
326 RAISE;
327 END;
328
329 PROCEDURE GET_BOOK_TYPE(itemtype in varchar2,
330 itemkey in varchar2,
331 actid in number,
332 funcmode in varchar2,
333 result out nocopy varchar2, p_log_level_rec IN FA_API_TYPES.log_level_rec_type default null) IS
334
335 h_book_type VARCHAR2(30);
336
337 BEGIN <<GET_BOOK_TYPE>>
338 IF (funcmode = 'RUN') THEN
339 h_book_type := wf_engine.GetItemAttrText(itemtype,itemkey,'BOOK_TYPE_CODE');
340 result := 'COMPLETE:' || h_book_type;
341 RETURN;
342 ELSIF (funcmode = 'CANCEL') THEN
343 result := 'COMPLETE:';
344 RETURN;
345 ELSE
346 result := '';
347 RETURN;
348 END IF;
349
350 EXCEPTION
351 WHEN OTHERS THEN
352 wf_core.context('FA_FLEX_PKG','GET_BOOK_TYPE', itemtype,itemkey,TO_CHAR(actid),funcmode);
353 RAISE;
354 END;
355
356 END FAFLEX_PKG_WF;