DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGC_CC_ACCGNWF_PKG

Source


1 PACKAGE BODY IGC_CC_ACCGNWF_PKG AS
2 /* $Header: IGCCAGNB.pls 120.11 2011/07/13 14:33:09 aarsridh ship $ */
3 
4 
5   G_PKG_NAME 	CONSTANT VARCHAR2(30) := 'IGC_CC_ACCGNWF_PKG';
6   g_profile_name  VARCHAR2(255);
7 
8 
9 --g_debug_mode VARCHAR2(1) := NVL(FND_PROFILE.VALUE('IGC_DEBUG_ENABLED'),'N');
10   g_debug_mode        VARCHAR2(1);
11 
12 --Variables for ATG Central logging
13   g_debug_level       NUMBER;
14   g_state_level       NUMBER;
15   g_proc_level        NUMBER;
16   g_event_level       NUMBER;
17   g_excep_level       NUMBER;
18   g_error_level       NUMBER;
19   g_unexp_level       NUMBER;
20   g_path              VARCHAR2(255);
21 
22 
23 
24 PROCEDURE Put_Debug_Msg (
25    p_path      IN VARCHAR2,
26    p_debug_msg IN VARCHAR2
27 );
28 
29 
30 ---------------------------------------------
31 -- These are private procedures that support workflow API's
32 --------------------------------------------
33 
34 PROCEDURE Call_WF_API_to_set_Att (l_itemtype varchar2, l_itemkey varchar2,
35                                   aname varchar2, avalue varchar2);
36 PROCEDURE Call_WF_API_to_set_no_Att (l_itemtype varchar2, l_itemkey varchar2,
37                                   aname varchar2, avalue number);
38 PROCEDURE Call_WF_API_to_set_date_Att (l_itemtype varchar2, l_itemkey varchar2,
39                                   aname varchar2, avalue date);
40 --------------------------------------------
41 
42 PROCEDURE message_token(
43    tokname IN VARCHAR2,
44    tokval  IN VARCHAR2
45 ) ;
46 
47 /****************************************************************************/
48 
49 -- Sets the Message Stack
50 
51 PROCEDURE add_message(
52    appname IN VARCHAR2,
53    msgname IN VARCHAR2
54 ) ;
55 
56 PROCEDURE Generate_Message;
57 
58 --------------------------------------------
59 -- The followings are global API's
60 --------------------------------------------
61 
62 
63 -- Generate Accounts
64 
65 /*===========================================================================+
66  |                      PROCEDURE Generate_Account                           |
67  +===========================================================================*/
68 PROCEDURE Generate_Account
69 (
70   p_project_id                     IN  igc_cc_acct_lines.project_id%TYPE       ,
71   p_task_id                        IN  igc_cc_acct_lines.task_id%TYPE          ,
72   p_expenditure_type               IN  igc_cc_acct_lines.expenditure_type%TYPE ,
73   p_expenditure_organization_id    IN  igc_cc_acct_lines.expenditure_org_id%TYPE ,
74   p_expenditure_item_date          IN  igc_cc_acct_lines.expenditure_item_date%TYPE,
75   p_vendor_id                      IN  NUMBER,
76   p_chart_of_accounts_id           IN  NUMBER,
77   p_gen_budget_account             IN  VARCHAR2,  /* 'Y' or 'N' */
78   p_cc_acct_line_id                IN  igc_cc_acct_lines.cc_acct_line_id%TYPE ,
79   p_cc_header_id                   IN  igc_cc_acct_lines.cc_header_id%TYPE ,
80   p_cc_charge_ccid                 IN  igc_cc_acct_lines.cc_charge_code_combination_id%TYPE ,
81   p_cc_budget_ccid                 IN  igc_cc_acct_lines.cc_budget_code_combination_id%TYPE ,
82   p_cc_acct_desc                   IN  igc_cc_acct_lines.cc_acct_desc%TYPE ,
83   p_cc_acct_taxable_flag           IN  igc_cc_acct_lines.cc_acct_taxable_flag%TYPE ,
84   p_tax_name                       IN  igc_cc_acct_lines.tax_classif_code%TYPE , /* bug -6472296 Modified tax_id to tax_name for Ebtax uptake*/
85   p_context                        IN  igc_cc_acct_lines.context%TYPE ,
86   p_attribute1                     IN  igc_cc_acct_lines.attribute1%TYPE ,
87   p_attribute2                     IN  igc_cc_acct_lines.attribute2%TYPE ,
88   p_attribute3                     IN  igc_cc_acct_lines.attribute3%TYPE ,
89   p_attribute4                     IN  igc_cc_acct_lines.attribute4%TYPE ,
90   p_attribute5                     IN  igc_cc_acct_lines.attribute5%TYPE ,
91   p_attribute6                     IN  igc_cc_acct_lines.attribute6%TYPE ,
92   p_attribute7                     IN  igc_cc_acct_lines.attribute7%TYPE ,
93   p_attribute8                     IN  igc_cc_acct_lines.attribute8%TYPE ,
94   p_attribute9                     IN  igc_cc_acct_lines.attribute9%TYPE ,
95   p_attribute10                    IN  igc_cc_acct_lines.attribute10%TYPE ,
96   p_attribute11                    IN  igc_cc_acct_lines.attribute11%TYPE ,
97   p_attribute12                    IN  igc_cc_acct_lines.attribute12%TYPE ,
98   p_attribute13                    IN  igc_cc_acct_lines.attribute13%TYPE ,
99   p_attribute14                    IN  igc_cc_acct_lines.attribute14%TYPE ,
100   p_attribute15                    IN  igc_cc_acct_lines.attribute15%TYPE ,
101 
102   x_out_charge_ccid                OUT NOCOPY igc_cc_acct_lines.cc_charge_code_combination_id%TYPE ,
103   x_out_budget_ccid                OUT NOCOPY igc_cc_acct_lines.cc_budget_code_combination_id%TYPE ,
104   x_out_charge_account_flex        OUT NOCOPY VARCHAR2,
105   x_out_budget_account_flex        OUT NOCOPY VARCHAR2,
106   x_out_charge_account_desc        OUT NOCOPY VARCHAR2,
107   x_out_budget_account_desc        OUT NOCOPY VARCHAR2,
108 
109   x_return_status                  OUT NOCOPY     VARCHAR2,
110   x_msg_count                      OUT NOCOPY     NUMBER  ,
111   x_msg_data                       OUT NOCOPY     VARCHAR2
112 )
113 IS
114 
115   l_itemtype                    VARCHAR2(30);
116   l_itemkey                     VARCHAR2(30);
117   l_api_name                    VARCHAR2(20);
118 
119   l_new_ccid_generated	        BOOLEAN := FALSE;
120   l_result                      BOOLEAN := FALSE;
121   l_insert_if_new	            BOOLEAN := TRUE; --If the dynamic insert in ON
122 
123   l_concat_segs                 VARCHAR2(200);
124   l_concat_ids                  VARCHAR2(200);
125   l_concat_descrs               VARCHAR2(500);
126   l_char_date 			varchar2(27);
127 
128   l_error_msg                   VARCHAR2(200); --modified to fix bug3793841
129   l_return_ccid                 gl_code_combinations.code_combination_id%TYPE;
130 
131   l_new_combination             BOOLEAN := FALSE; -- To verify if this is a new ccid
132 
133 
134   l_class_code                  pa_class_codes.class_code%TYPE;
135   l_direct_flag                 pa_project_types_all.direct_flag%TYPE;
136   l_expenditure_category        pa_expenditure_categories.expenditure_category%TYPE;
137   l_expenditure_org_name        hr_organization_units.name%TYPE;
138   l_project_number              pa_projects_all.segment1%TYPE;
139   l_project_organization_name   hr_organization_units.name%TYPE;
140   l_project_organization_id     hr_organization_units.organization_id %TYPE;
141   l_project_type                pa_project_types_all.project_type%TYPE;
142 
143   l_public_sector_flag          pa_projects_all.public_sector_flag%TYPE;
144   l_revenue_category            pa_expenditure_types.revenue_category_code%TYPE;
145   l_task_number                 pa_tasks.task_number%TYPE;
146   l_task_organization_name      hr_organization_units.name%TYPE;
147   l_task_organization_id        hr_organization_units.organization_id %TYPE;
148   l_task_service_type           pa_tasks.service_type_code%TYPE;
149   l_top_task_id                 pa_tasks.task_id%TYPE;
150   l_top_task_number             pa_tasks.task_number%TYPE;
151   l_vendor_employee_id          per_people_f.person_id%TYPE;
152   l_vendor_employee_number      per_people_f.employee_number%TYPE;
153   l_vendor_type                 po_vendors.vendor_type_lookup_code%TYPE;
154 
155   l_full_path         VARCHAR2(255);
156 
157 BEGIN
158 
159 
160   l_itemtype  := 'CCACCGEN';
161   l_api_name  :='Generate_Account';
162   l_full_path := g_path || 'Generate_Account';
163 
164   x_return_status := FND_API.G_RET_STS_SUCCESS;
165 
166 --  IF (upper(fnd_profile.value('IGC_DEBUG_ENABLED')) ='Y') THEN
167 --     IGC_MSGS_PKG.g_debug_mode := TRUE;
168 --  ELSE
169 --     IGC_MSGS_PKG.g_debug_mode := FALSE;
170 --  END IF;
171 
172   IF (g_debug_mode = 'Y') THEN
173     Put_Debug_Msg(l_full_path, '**************************************************************************');
174     Put_Debug_Msg(l_full_path, 'CC Account generator is being called , Date '||to_char(sysdate,'DD-MON-YY MI:SS'));
175     Put_Debug_Msg(l_full_path, '**************************************************************************');
176   END IF;
177 
178   fnd_profile.put('ACCOUNT_GENERATOR:DEBUG_MODE','Y');
179 
180   IF ( p_project_id IS NOT NULL ) Then
181 
182     IF (g_debug_mode = 'Y') THEN
183        Put_Debug_Msg(l_full_path, 'Obtaining project info');
184     END IF;
185 
186     pa_acc_gen_wf_pkg.wf_acc_derive_params ( p_project_id => p_project_id,
187 					    p_task_id    => p_task_id,
188 					    p_expenditure_type => p_expenditure_type,
189 					    p_vendor_id  => p_vendor_id,
190 				 	    p_expenditure_organization_id => p_expenditure_organization_id,
191 					    p_expenditure_item_date => p_expenditure_item_date,
192 					    x_class_code  => l_class_code,
193 					    x_direct_flag => l_direct_flag,
194 					    x_expenditure_category  => l_expenditure_category,
195 					    x_expenditure_org_name  => l_expenditure_org_name,
196 					    x_project_number  => l_project_number,
197 					    x_project_organization_name => l_project_organization_name,
198 					    x_project_organization_id => l_project_organization_id,
199 					    x_project_type => l_project_type,
200 					    x_public_sector_flag => l_public_sector_flag,
201 					    x_revenue_category => l_revenue_category,
202 					    x_task_number => l_task_number,
203 					    x_task_organization_name => l_task_organization_name,
204 					    x_task_organization_id => l_task_organization_id,
205 					    x_task_service_type => l_task_service_type,
206 					    x_top_task_id => l_top_task_id,
207 					    x_top_task_number => l_top_task_number,
208 					    x_vendor_employee_id => l_vendor_employee_id,
209 					    x_vendor_employee_number => l_vendor_employee_number,
210 					    x_vendor_type => l_vendor_type);
211 
212 
213 
214      IF (g_debug_mode = 'Y') THEN
215         Put_Debug_Msg(l_full_path, 'Done');
216      END IF;
217 
218   END IF;
219 
220 
221   l_itemtype:= '';
222 
223   LOOP
224 
225      --This loop is executed once or twice, depending on if we need to generate budget acct or not.
226 
227      IF l_itemtype IS NULL THEN
228 
229         l_itemtype:= 'IGCACGNC';  -- Name of charge acc gen
230 
231      ELSIF  l_itemtype= 'IGCACGNC'  AND p_gen_budget_account = 'Y' THEN
232 
233         l_itemtype:= 'IGCACGNB'; -- Name of budget acc gen
234 
235      ELSE
236 
237         EXIT;  -- Exiting loop;
238 
239      END IF;
240 
241      IF (g_debug_mode = 'Y') THEN
242         Put_Debug_Msg(l_full_path, 'Initalizing WF for '||l_itemtype);
243      END IF;
244 
245      l_itemkey := fnd_flex_workflow.initialize
246                (
247                  appl_short_name => 'SQLGL',
248                  code            => 'GL#',
249                  num             => p_chart_of_accounts_id,
250                  itemtype        => l_itemtype
251                );
252 
253 
254      IF (g_debug_mode = 'Y') THEN
255         Put_Debug_Msg(l_full_path, 'Itemkey received:  '||l_itemkey);
256      END IF;
257 
258      IF l_Itemkey IS NULL THEN
259         --Erroring out.
260         IF (g_debug_mode = 'Y') THEN
261            Put_Debug_Msg(l_full_path, 'Itemkey is invalid, raising an exception');
262         END IF;
263 
264         RAISE FND_API.G_EXC_ERROR;
265 
266      END IF;
267 
268      IF (g_debug_mode = 'Y') THEN
269         Put_Debug_Msg(l_full_path, 'Initialize the workflow item attributes');
270      END IF;
271 
272      -----------------------------------------------------------
273      -- Initialize the workflow item attributes
274      ----------------------------------------------------------
275 
276 
277      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'CLASS_CODE', l_class_code);
278      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'DIRECT_FLAG', l_direct_flag);
279      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'EXPENDITURE_CATEGORY', l_expenditure_category);
280      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'EXPENDITURE_ORG_NAME', l_expenditure_org_name);
281      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'PROJECT_NUMBER', l_project_number);
282      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'PROJECT_ORGANIZATION_NAME', l_project_organization_name);
283      Call_WF_API_to_set_no_Att (l_itemtype, l_itemkey, 'PROJECT_ORGANIZATION_ID', l_project_organization_id);
284      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'PROJECT_TYPE', l_project_type);
285      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'PUBLIC_SECTOR_FLAG', l_public_sector_flag);
286      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'REVENUE_CATEGORY', l_revenue_category);
287      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'TASK_NUMBER', l_task_number);
288      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'TASK_ORGANIZATION_NAME', l_task_organization_name);
289      Call_WF_API_to_set_no_Att (l_itemtype, l_itemkey, 'TASK_ORGANIZATION_ID', l_task_organization_id);
290      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'TASK_SERVICE_TYPE', l_task_service_type);
291      Call_WF_API_to_set_no_Att (l_itemtype, l_itemkey, 'TOP_TASK_ID', l_top_task_id);
292      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'TOP_TASK_NUMBER', l_top_task_number);
293      Call_WF_API_to_set_no_Att (l_itemtype, l_itemkey, 'VENDOR_EMPLOYEE_ID', l_vendor_employee_id);
294      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'VENDOR_EMPLOYEE_NUMBER', l_vendor_employee_number);
295      Call_WF_API_to_set_Att (l_itemtype, l_itemkey, 'VENDOR_TYPE', l_vendor_type);
296 
297      wf_engine.SetItemAttrNumber ( itemtype   => l_itemtype,
298                                 itemkey    => l_itemkey,
299                                 aname      => 'PROJECT_ID',
300                                 avalue     => p_project_id);
301 
302      wf_engine.SetItemAttrNumber ( itemtype   => l_itemtype,
303                                 itemkey    => l_itemkey,
304                                 aname      => 'TASK_ID',
305                                 avalue     => p_task_id);
306 
307      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
308                                 itemkey    => l_itemkey,
309                                 aname      => 'EXPENDITURE_TYPE',
310                                 avalue     => p_expenditure_type);
311 
312      wf_engine.SetItemAttrNumber ( itemtype   => l_itemtype,
313                                 itemkey    => l_itemkey,
314                                 aname      => 'EXPENDITURE_ORG_ID',
315                                 avalue     => p_expenditure_organization_id);
316 
317      wf_engine.SetItemAttrDate   (  itemtype   =>  l_itemtype,
318                                  itemkey    =>  l_itemkey,
319                                  aname      =>  'EXPENDITURE_ITEM_DATE',
320                                  avalue     =>  p_expenditure_item_date );
321 
322      wf_engine.SetItemAttrNumber( itemtype   => l_itemtype,
323                                itemkey    => l_itemkey,
324                                aname      => 'CHART_OF_ACCOUNTS_ID',
325                                avalue     => p_chart_of_accounts_id);
326 
327      wf_engine.SetItemAttrNumber( itemtype   => l_itemtype,
328                                itemkey    => l_itemkey,
329                                aname      => 'CC_ACCT_LINE_ID',
330                                avalue     => p_cc_acct_line_id);
331 
332      wf_engine.SetItemAttrNumber( itemtype   => l_itemtype,
333                                itemkey    => l_itemkey,
334                                aname      => 'CC_HEADER_ID',
335                                avalue     => p_cc_header_id);
336 
337      wf_engine.SetItemAttrNumber( itemtype   => l_itemtype,
338                                itemkey    => l_itemkey,
339                                aname      => 'CC_BUDGET_CCID',
340                                avalue     => p_cc_budget_ccid);
341 
342      wf_engine.SetItemAttrNumber( itemtype   => l_itemtype,
343                                itemkey    => l_itemkey,
344                                aname      => 'CC_CHARGE_CCID',
345                                avalue     => NVL(l_return_ccid,p_cc_charge_ccid));
346 
347      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
348                                 itemkey    => l_itemkey,
349                                 aname      => 'CC_ACCT_DESC',
350                                 avalue     => p_cc_acct_desc);
351 
352      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
353                                 itemkey    => l_itemkey,
354                                 aname      => 'CC_ACCT_TAXABLE_FLAG',
355                                 avalue     => p_cc_acct_taxable_flag);
356 
357      wf_engine.SetItemAttrText( itemtype   => l_itemtype,
358                                itemkey    => l_itemkey,
359                                aname      => 'TAX_NAME',
360                                avalue     => p_tax_name);
361 			       /* bug -6472296 Modified tax_id to tax_name for Ebtax uptake*/
362 
363      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
364                                 itemkey    => l_itemkey,
365                                 aname      => 'CONTEXT',
366                                 avalue     => p_context);
367 
368      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
369                                 itemkey    => l_itemkey,
370                                 aname      => 'ATTRIBUTE1',
371                                 avalue     => p_attribute1);
372 
373      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
374                                 itemkey    => l_itemkey,
375                                 aname      => 'ATTRIBUTE2',
376                                 avalue     => p_attribute2);
377 
378      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
379                                 itemkey    => l_itemkey,
380                                 aname      => 'ATTRIBUTE3',
381                                 avalue     => p_attribute3);
382 
383      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
384                                 itemkey    => l_itemkey,
385                                 aname      => 'ATTRIBUTE4',
386                                 avalue     => p_attribute4);
387 
388      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
389                                 itemkey    => l_itemkey,
390                                 aname      => 'ATTRIBUTE5',
391                                 avalue     => p_attribute5);
392 
393      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
394                                 itemkey    => l_itemkey,
395                                 aname      => 'ATTRIBUTE6',
396                                 avalue     => p_attribute6);
397 
398      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
399                                 itemkey    => l_itemkey,
400                                 aname      => 'ATTRIBUTE7',
401                                 avalue     => p_attribute7);
402 
403      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
404                                 itemkey    => l_itemkey,
405                                 aname      => 'ATTRIBUTE8',
406                                 avalue     => p_attribute8);
407 
408      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
409                                 itemkey    => l_itemkey,
410                                 aname      => 'ATTRIBUTE9',
411                                 avalue     => p_attribute9);
412 
413      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
414                                 itemkey    => l_itemkey,
415                                 aname      => 'ATTRIBUTE10',
416                                 avalue     => p_attribute10);
417 
418      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
419                                 itemkey    => l_itemkey,
420                                 aname      => 'ATTRIBUTE11',
421                                 avalue     => p_attribute11);
422 
423      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
424                                 itemkey    => l_itemkey,
425                                 aname      => 'ATTRIBUTE12',
426                                 avalue     => p_attribute12);
427 
428      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
429                                 itemkey    => l_itemkey,
430                                 aname      => 'ATTRIBUTE13',
431                                 avalue     => p_attribute13);
432 
433      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
434                                 itemkey    => l_itemkey,
435                                 aname      => 'ATTRIBUTE14',
436                                 avalue     => p_attribute14);
437 
438      wf_engine.SetItemAttrText   ( itemtype   => l_itemtype,
439                                 itemkey    => l_itemkey,
440                                 aname      => 'ATTRIBUTE15',
441                                 avalue     => p_attribute15);
442 
443      -----------------------------------------------------------
444      -- Call the workflow Generate function to trigger off the
445      -- workflow account generation
446      -----------------------------------------------------------
447 
448      l_error_msg       := NULL;
449      l_concat_segs     := NULL;
450      l_concat_ids      := NULL;
451      l_concat_descrs   := NULL;
452      l_return_ccid     := NULL;
453 
454      IF (g_debug_mode = 'Y') THEN
455         Put_Debug_Msg(l_full_path, 'Submiting the AccGen WF ');
456      END IF;
457 
458      l_result := fnd_flex_workflow.generate
459               (
460                 itemtype        => l_itemtype        ,
461                 itemkey         => l_itemkey         ,
462                 insert_if_new   => l_insert_if_new   ,
463                 ccid            => l_return_ccid     ,
464                 concat_segs     => l_concat_segs     ,
465                 concat_ids      => l_concat_ids      ,
466                 concat_descrs   => l_concat_descrs   ,
467                 error_message   => l_error_msg       ,
468                 new_combination => l_new_combination
469               );
470 
471      	if l_return_ccid > 1 then
472 		null;
473 	elsif l_return_ccid = -1 then
474 		l_return_ccid := fnd_flex_ext.get_ccid(
475 			'SQLGL',
476 			'GL#',
477 			p_chart_of_accounts_id,
478 			l_char_date,
479 			l_concat_segs);
480 
481      else
482          --Errorout error.
483 
484         IF (g_debug_mode = 'Y') THEN
485            Put_Debug_Msg(l_full_path, 'Result is invalid, error text: '||l_error_msg);
486         END IF;
487 
488         message_token ('ITEM_KEY', l_itemkey);
489         message_token ('ERR_TEXT', l_error_msg);
490 
491         IF l_itemtype = 'IGCACGNC' THEN
492            add_message ('IGC', 'IGC_CC_CGEN_WF_ERR');
493         ELSE
494            add_message ('IGC', 'IGC_CC_BGEN_WF_ERR');
495         END IF;
496 
497 
498         RAISE FND_API.G_EXC_ERROR;
499 
500      END IF;
501 
502      IF (g_debug_mode = 'Y') THEN
503         Put_Debug_Msg(l_full_path, 'Result is ccid: '||l_return_ccid);
504      END IF;
505 
506      IF l_itemtype = 'IGCACGNC' THEN
507         x_out_charge_ccid         := l_return_ccid ;
508         x_out_charge_account_flex := l_concat_segs ;
509         x_out_charge_account_desc := l_concat_descrs ;
510      ELSE
511         x_out_budget_ccid         := l_return_ccid ;
512         x_out_budget_account_flex := l_concat_segs ;
513         x_out_budget_account_desc := l_concat_descrs ;
514      END IF;
515 
516   END LOOP;
517 
518 
519   FND_MSG_PUB.Count_And_Get
520   (       p_count  => x_msg_count ,
521           p_data   => x_msg_data
522   );
523 
524 EXCEPTION
525    WHEN FND_API.G_EXC_ERROR THEN
526 
527      x_return_status := FND_API.G_RET_STS_ERROR;
528 
529      FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
530                                 p_data  => x_msg_data);
531     IF (g_excep_level >=  g_debug_level ) THEN
532        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_ERROR Exception Raised');
533     END IF;
534    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
535 
536      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
537 
538      FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
539                                 p_data  => x_msg_data);
540     IF (g_excep_level >=  g_debug_level ) THEN
541        FND_LOG.STRING (g_excep_level,l_full_path,'FND_API.G_EXC_UNEXPECTED_ERROR Exception Raised');
542     END IF;
543    WHEN OTHERS THEN
544 
545      x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
546 
547      IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
548        FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME,
549                                 l_api_name);
550      END IF;
551      FND_MSG_PUB.Count_And_Get (p_count => x_msg_count,
552                                 p_data  => x_msg_data);
553      IF ( g_unexp_level >= g_debug_level ) THEN
554        FND_MESSAGE.SET_NAME('IGC','IGC_LOGGING_UNEXP_ERROR');
555        FND_MESSAGE.SET_TOKEN('CODE',SQLCODE);
556        FND_MESSAGE.SET_TOKEN('MSG',  SQLERRM);
557        FND_LOG.MESSAGE ( g_unexp_level,l_full_path, TRUE);
558      END IF;
559 
560 
561 END Generate_Account ;
562 
563 
564 --
565 -- Private Procedures
566 --
567 PROCEDURE Call_WF_API_to_set_Att (l_itemtype varchar2, l_itemkey varchar2, aname varchar2,
568                                   avalue varchar2)
569 IS
570 BEGIN
571 
572         If avalue IS NOT NULL then
573           wf_engine.SetItemAttrText (  itemtype   =>  l_itemtype,
574                                        itemkey    =>  l_itemkey,
575                                        aname      =>  aname,
576                                        avalue     =>  avalue );
577         end if;
578 END Call_WF_API_to_set_Att;
579 --
580 --
581 PROCEDURE Call_WF_API_to_set_no_Att (l_itemtype varchar2, l_itemkey varchar2, aname varchar2,
582                                   avalue number)
583 IS
584 BEGIN
585 
586         If avalue IS NOT NULL then
587           wf_engine.SetItemAttrNumber (  itemtype   =>  l_itemtype,
588                                          itemkey    =>  l_itemkey,
589                                          aname      =>  aname,
590                                          avalue     =>  avalue );
591         end if;
592 END Call_WF_API_to_set_no_Att;
593 --
594 --
595 PROCEDURE Call_WF_API_to_set_date_Att (l_itemtype varchar2, l_itemkey varchar2, aname varchar2,
596                                   avalue date)
597 IS
598 BEGIN
599         If avalue IS NOT NULL then
600           wf_engine.SetItemAttrDate (  itemtype   =>  l_itemtype,
601                                        itemkey    =>  l_itemkey,
602                                        aname      =>  aname,
603                                        avalue     =>  avalue );
604         end if;
605 END Call_WF_API_to_set_date_Att;
606 --
607 
608 PROCEDURE message_token(
609    tokname IN VARCHAR2,
610    tokval  IN VARCHAR2
611 ) IS
612 
613 BEGIN
614 
615   IGC_MSGS_PKG.message_token (p_tokname => tokname,
616                               p_tokval  => tokval);
617 
618 END message_token;
619 
620 
621 /****************************************************************************/
622 
623 -- Sets the Message Stack
624 PROCEDURE Put_Debug_Msg (
625    p_path      IN VARCHAR2,
626    p_debug_msg IN VARCHAR2
627 ) IS
628 
629 -- Constants :
630 
631    /*l_return_status    VARCHAR2(1);*/
632    l_api_name         CONSTANT VARCHAR2(30) := 'Put_Debug_Msg';
633 
634 BEGIN
635 
636 
637 --   IF (IGC_MSGS_PKG.g_debug_mode) THEN
638       /*IGC_MSGS_PKG.Put_Debug_Msg (l_full_path, p_debug_message    => p_debug_msg,
639                                   p_profile_log_name => g_profile_name,
640                                   p_prod             => 'IGC',
641                                   p_sub_comp         => 'CC_ACCGEN',
642                                   p_filename_val     => NULL,
643                                   x_Return_Status    => l_return_status
644                                  );
645       IF (l_Return_Status <> FND_API.G_RET_STS_SUCCESS) THEN
646          raise FND_API.G_EXC_ERROR;
647       END IF;*/
648    IF(g_state_level >= g_debug_level) THEN
649         FND_LOG.STRING(g_state_level, p_path, p_debug_msg);
650    END IF;
651 --   END IF;
652 
653 -- --------------------------------------------------------------------
654 -- Exception handler section for the Put_Debug_Msg procedure.
655 -- --------------------------------------------------------------------
656 EXCEPTION
657 
658    /*WHEN FND_API.G_EXC_ERROR THEN
659        RETURN;*/
660 
661    WHEN OTHERS THEN
662        IF (FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)) THEN
663           FND_MSG_PUB.Add_Exc_Msg (G_PKG_NAME, l_api_name);
664        END IF;
665 	   NULL;
666        RETURN;
667 
668 END Put_Debug_Msg;
669 
670 
671 PROCEDURE add_message(
672    appname IN VARCHAR2,
673    msgname IN VARCHAR2
674 ) IS
675 
676 i  BINARY_INTEGER;
677 l_full_path         VARCHAR2(255);
678 
679 BEGIN
680 
681    l_full_path := g_path || 'add_message';
682 
683    IGC_MSGS_PKG.add_message (p_appname => appname,
684                              p_msgname => msgname);
685 
686    IF (g_debug_mode = 'Y') THEN
687       Put_Debug_Msg(l_full_path, 'Raising an execution exception: '||fnd_msg_pub.get(1,FND_API.G_FALSE));
688    END IF;
689 
690 END add_message;
691 
692 PROCEDURE Generate_Message
693 IS
694 l_cur                     NUMBER;
695 l_msg_count               NUMBER ;
696 l_msg_data                VARCHAR2(32000) ;
697 l_full_path               VARCHAR2(255);
698 
699 BEGIN
700 
701   l_full_path := g_path || 'Generate_Message';
702 
703   IF (g_debug_mode = 'Y') THEN
704      Put_Debug_Msg(l_full_path, 'Error during the execution ');
705   END IF;
706 
707   FND_MSG_PUB.Count_And_Get ( p_count => l_msg_count,
708                               p_data  => l_msg_data );
709 
710   IF l_msg_count >0 THEN
711      l_msg_data :='';
712 
713      FOR l_cur IN 1..l_msg_count LOOP
714         --l_msg_data :=l_msg_data||' Mes No'||l_cur||' '||FND_MSG_PUB.GET(l_cur,FND_API.G_FALSE);
715 	l_msg_data :=l_msg_data||' '||l_cur||' '||FND_MSG_PUB.GET(l_cur,FND_API.G_FALSE);
716 	IF(g_error_level >= g_debug_level) THEN
717            FND_LOG.STRING(g_error_level, l_full_path, l_msg_data);
718 	END IF;
719      END LOOP;
720   ELSE
721      l_msg_data :='Error stack has no data';
722        IF(g_error_level >= g_debug_level) THEN
723            FND_LOG.STRING(g_error_level, l_full_path, l_msg_data);
724        END IF;
725   END IF;
726 
727   IF (g_debug_mode = 'Y') THEN
728      Put_Debug_Msg(l_full_path, 'Error text is '||l_msg_data);
729   END IF;
730 
731 END Generate_Message;
732 
733 BEGIN
734 
735   g_profile_name    := 'IGC_DEBUG_LOG_DIRECTORY';
736   g_debug_mode    := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
737 
738 --Variables for ATG Central logging
739   g_debug_level  :=	FND_LOG.G_CURRENT_RUNTIME_LEVEL;
740   g_state_level  :=	FND_LOG.LEVEL_STATEMENT;
741   g_proc_level   :=	FND_LOG.LEVEL_PROCEDURE;
742   g_event_level  :=	FND_LOG.LEVEL_EVENT;
743   g_excep_level  :=	FND_LOG.LEVEL_EXCEPTION;
744   g_error_level  :=	FND_LOG.LEVEL_ERROR;
745   g_unexp_level  :=	FND_LOG.LEVEL_UNEXPECTED;
746   g_path         := 'IGC.PLSQL.IGCCAGNB.IGC_CC_ACCGNWF_PKG.';
747 
748 END IGC_CC_ACCGNWF_PKG;