DBA Data[Home] [Help]

PACKAGE BODY: APPS.JA_CN_CUR_EXPORT_PKG

Source


1 PACKAGE BODY JA_CN_CUR_EXPORT_PKG AS
2   --$Header: JACNCURB.pls 120.3 2011/01/14 06:58:44 choli noship $
3   --+=======================================================================+
4   --|               Copyright (c) 1998 Oracle Corporation                   |
5   --|                       Redwood Shores, CA, USA                         |
6   --|                         All rights reserved.                          |
7   --+=======================================================================+
8   --| FILENAME                                                              |
9   --|     JACNCURB.pls                                                      |
10   --|                                                                       |
11   --| DESCRIPTION                                                           |
12   --|     Use this package to export Currencies                             |
13   --|                                                                       |
14   --| PROCEDURE LIST                                                        |
15   --|      PROCEDURE Add_Electronic_Accounting_Book                         |
16   --|                                                                       |
17   --|                                                                       |
18   --| HISTORY                                                               |
19   --|     01/20/2010    Chongwu Li  Created                                 |
20   --|     01/05/2011   Jianchao Chi Updated for the new solution to change  |
21   --|                               the logic of Voucher Number and Legal   |
22   --|                               Entity                                  |
23   --+======================================================================*/
24   GV_MODULE_PREFIX VARCHAR2(100) := 'JA_CN_CUR_EXPORT_PKG';
25 
26   --==========================================================================
27   --  PROCEDURE NAME:
28   --
29   --    Add_Currencies                        Public
30   --
31   --  DESCRIPTION:
32   --
33   --    This procedure is to export Currencies
34   --
35   --  PARAMETERS:
36   --      In:  pn_legal_entity_id     legal_entity ID
37   --           pn_ledger_id           ledger ID
38   --           pn_accounting_year     accounting year
39   --  DESIGN REFERENCES:
40   --    CNAO_V2_GL_TD.doc
41   --
42   --  CHANGE HISTORY:
43   --
44   --           20-JAN-2010   Chongwu Li   Created
45   --           05-JAN-2011   Jianchao Chi Updated for the new solution to change
46   --                                      the logic of Voucher Number and Legal Entity
47   --===========================================================================
48 
49   PROCEDURE Add_Currencies(pn_legal_entity_id NUMBER,
50                            pn_ledger_id       NUMBER,
51                            pn_accounting_year NUMBER) IS
52     lv_procedure_name VARCHAR2(40) := 'Add_Currencies';
53     ln_dbg_level      NUMBER := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
54     ln_proc_level     NUMBER := FND_LOG.LEVEL_PROCEDURE;
55     ln_row_count      NUMBER;
56     --NO_DATA EXCEPTION;
57 
58     -- to get Currencies
59     CURSOR Currencies_cur(ln_legal_entity_id NUMBER,
60                           ln_accounting_year NUMBER) IS
61       SELECT DISTINCT fcv.currency_code, fcv.name
62         FROM fnd_currencies_vl    fcv,
63              ja_cn_journal_lines  jcjl,
64              ja_cn_voucher_number jcvn
65              --Update by Jianchao Chi, for cnaov2 upgrade 05-JAN-2011
66               --Add ja_cn_voucher_number table, voucher number and legal entity
67               --are fetched from ja_cn_voucher_number
68               --The new one is
69               ----------------------------------------------------
70               --AND jcvn.je_header_id = jcjl.je_header_id
71               --AND jcvn.je_line_number = jcjl.je_line_num
72               --AND jcvn.legal_entity_id = ln_legal_entity_id;
73               ----------------------------------------------------
74        WHERE fcv.currency_code = jcjl.currency_code
75          --Add the follow two conditions by Jianchao Chi to change the logic of legal entity, 05-JAN-2011
76          AND jcvn.je_header_id = jcjl.je_header_id
77          AND jcvn.je_line_number = jcjl.je_line_num
78          AND jcjl.period_name IN
79              (SELECT gp.period_name
80                 FROM gl_periods gp, gl_ledgers gl
81                WHERE gp.period_year = ln_accounting_year
82                  AND gp.period_set_name = gl.period_set_name)
83          --Comment by Jianchao Chi to change the logic of legal entity, 05-JAN-2011
84          --AND jcjl.legal_entity_id = ln_legal_entity_id
85          AND jcvn.legal_entity_id = ln_legal_entity_id
86        ORDER BY fcv.currency_code;
87 
88   BEGIN
89     --logging for debug
90     IF (ln_proc_level >= ln_dbg_level) THEN
91       FND_LOG.STRING(ln_proc_level,
92                      GV_MODULE_PREFIX || '.' || lv_procedure_name ||
93                      '.begin',
94                      'Enter procedure');
95       FND_LOG.STRING(ln_proc_level,
96                      lv_procedure_name || '.parameters',
97                      'pn_legal_entity_id=' || pn_legal_entity_id || ',' ||
98                      'pn_ledger_id=' || pn_ledger_id || ',' ||
99                      'pn_accounting_year=' || pn_accounting_year);
100 
101     END IF; --ln_proc_level>=ln_dbg_level
102     FND_FILE.put_line(FND_FILE.log,
103                       lv_procedure_name || '.parameters:' ||
104                       'pn_legal_entity_id=' || pn_legal_entity_id || ',' ||
105                       'pn_ledger_id=' || pn_ledger_id || ',' ||
106                       'pn_accounting_year=' || pn_accounting_year);
107     ln_row_count := 0;
108     FOR v_row IN Currencies_cur(pn_legal_entity_id, pn_accounting_year) LOOP
109       ln_row_count := ln_row_count + 1;
110       Ja_Cn_Utility.Add_Sub_Root_Node('CURRENCY',
111                                       Ja_Cn_Utility.GV_TAG_TYPE_START);
112       Ja_Cn_Utility.Add_Child_Node('CURRENCY_CODE', v_row.currency_code);
113       Ja_Cn_Utility.Add_Child_Node('CURRENCY_NAME', v_row.name);
114       Ja_Cn_Utility.Add_Sub_Root_Node('CURRENCY',
115                                       Ja_Cn_Utility.GV_TAG_TYPE_END);
116 
117     END LOOP;
118 
119     IF (ln_row_count = 0) THEN
120       Ja_Cn_Utility.Print_No_Data_Found_For_Log('CURRENCY');
121       Ja_Cn_Utility.Add_Sub_Root_Node('CURRENCY',
122                                       Ja_Cn_Utility.GV_TAG_TYPE_START);
123       Ja_Cn_Utility.Add_Child_Node('CURRENCY_CODE', NULL);
124       Ja_Cn_Utility.Add_Child_Node('CURRENCY_NAME', NULL);
125       Ja_Cn_Utility.Add_Sub_Root_Node('CURRENCY',
126                                       Ja_Cn_Utility.GV_TAG_TYPE_END);
127     END IF; --ln_row_count = 0
128     --logging for debug
129     IF (ln_proc_level >= ln_dbg_level) THEN
130       FND_LOG.STRING(ln_proc_level,
131                      GV_MODULE_PREFIX || '.' || lv_procedure_name || '.end',
132                      'Exit procedure');
133     END IF; -- (ln_proc_level>=ln_dbg_level)
134   EXCEPTION
135     WHEN OTHERS THEN
136       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
137         FND_LOG.STRING(FND_LOG.LEVEL_UNEXPECTED,
138                        GV_MODULE_PREFIX || '.' || lv_procedure_name ||
139                        '.Other_Exception ',
140                        SQLCODE || SQLERRM);
141       END IF; -- (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
142       FND_FILE.put_line(FND_FILE.log,
143                         lv_procedure_name || SQLCODE || SQLERRM);
144       RAISE;
145   END Add_Currencies;
146 
147 END JA_CN_CUR_EXPORT_PKG;