DBA Data[Home] [Help]

PACKAGE BODY: APPS.XLA_AE_JOURNAL_ENTRY_PKG

Source


1 PACKAGE BODY xla_ae_journal_entry_pkg AS
2 /* $Header: xlajejex.pkb 120.137.12020000.11 2013/03/21 11:09:50 sgullape ship $   */
3 /*===========================================================================+
4 |             Copyright (c) 2001-2002 Oracle Corporation                     |
5 |                       Redwood Shores, CA, USA                              |
6 |                         All rights reserved.                               |
7 +============================================================================+
8 | PACKAGE NAME                                                               |
9 |     XLA_AE_JOURNAL_ENTRY_PKG                                               |
10 |                                                                            |
11 | DESCRIPTION                                                                |
12 |                                                                            |
13 |                                                                            |
14 | HISTORY                                                                    |
15 |     10-NOV-2002 K.Boussema  Created                                        |
16 |     12-DEC-2002 K.Boussema  Added Calls to Validation APIs                 |
17 |     16-DEC-2002 K.Boussema  Reverse creation of lines before headers       |
18 |     08-JAN-2003 K.Boussema  Changed xla_temp_journal_entries by            |
19 |                             xla_journal_entries_temp                       |
20 |     10-JAN-2003 K.Boussema  Removed gl_sl_link_id column from temp table   |
21 |                             Added 'dbdrv' command                          |
22 |     20-FEB-2003 K.Boussema    Made changes for the new bulk approach of the|
23 |                               accounting engine                            |
24 |     09-APR-2003 K.Boussema    Renamed temporary tables :                   |
25 |                                       xla_je_headers_temp,xla_je_lines_temp|
26 |     19-APR-2003 K.Boussema    Included Error messages                      |
27 |     22-APR-2003 K.Boussema    Added DOC_CATEGORY_NAME source               |
28 |     05-MAI-2003 K.Boussema    Modified to fix bug 2926949                  |
29 |                               Added sla_ledger_id in ledger cache          |
30 |     07-MAI-2003 K.Boussema    Changed the call to cache API, bug 2945359   |
31 |     13-MAI-2003 K.Boussema    Renamed temporary tables xla_je_lines_gt by  |
32 |                               xla_ae_lines_gt, xla_je_headers_gt by        |
33 |                               xla_ae_headers_gt                            |
34 |                               Renamed in xla_distribution_links the column |
35 |                               base_amount by ledger_amount                 |
36 |     14-MAI-2003 K.Boussema    Removed the SELECT of application_name       |
37 |     20-MAI-2003 K.Boussema    Added a Token to XLA_AP_CANNOT_INSERT_JE     |
38 |                               message                                      |
39 |     27-MAI-2003 K.Boussema    Renamed code_combination_status by           |
40 |                                  code_combination_status_flag              |
41 |                               Renamed base_amount by ledger_amount         |
42 |     02-JUN-2003 K.Boussema    Changed the insert of headers to fix         |
43 |                                  bugs 2981358 and 2981862                  |
44 |     11-JUN-2003 K.Boussema    Renamed Sequence columns, bug 3000007        |
45 |     17-JUL-2003 K.Boussema    Updated the call to accounting cache, 3055039|
46 |     18-JUL-2003 K.Boussema    Reviewed the call to GetSessionValueChar API |
47 |     21-JUL-2003 K.Boussema   Changed the source name from                  |
48 |                              GL_COA_MAPPINGS_NAME to GL_COA_MAPPING_NAME   |
49 |                              Reviewed GetAlternateCurrencyLedger           |
50 |     24-JUL-2003 K.Boussema    Updated the error messages                   |
51 |     28-JUL-2003 K.Boussema   Reviewed GetAlternateCurrencyLedger Procedure |
52 |     29-JUL-2003 K.Boussema    Reviewed the code to solve bug 3072881       |
53 |     31-JUL-2003 K.Boussema   Added in XLA_AE_LINES the two columns:        |
54 |                               DISPLAYED_LINE_NUMBER and GL_SL_LINK_TABLE   |
55 |     05-Aug-2003 Shishir J    Removed currency_code column from the         |
56 |                              xla_distribution_links table                  |
57 |     13-Aug-2003 Shishir J    Includes Neil's performance changes.          |
58 |     19-SEP-2003 K.Boussema    Code changed to include reversed_ae_header_id|
59 |                               and reversed_line_num, see bug 3143095       |
60 |     16-Oct-2003 Shishir J    Added accounting class code in the call to the|
61 |                              GET_HASH_VALUE function.                      |
62 |     22-OCT-2003 K.Boussema    Changed to capture the Merge Matching Lines  |
63 |                               preference for Accounting Reversal from JLT  |
64 |     14-NOV-2003 K.Boussema   Reviewed the cache of the primary ledger coa  |
65 |     26-NOV-2003 K.Boussema   Called the accounting cache to get the coa    |
66 |                              DYNAMIC_INSERTS_ALLOWED_FLAG, bug3256226      |
67 |     02-DEC-2003 K.Boussema   Populated xla_ae_lines.gl_sl_link_table column|
68 |                              with 'XLAJEL'                                 |
69 |     05-DEC-2003 K.Boussema   Changed the cache of coa to fix  bug3289875   |
70 |     12-DEC-2003 K.Boussema   Added the validation of event accounting mode |
71 |     18-DEC-2003 K.Boussema    Changed to fix bug 3042840,3307761,3268940   |
72 |                               3310291 and 3320689                          |
73 |     07-JAN-2003 K.Boussema   Changed to take in account switch_side in the |
74 |                              merge, bug 3272564                            |
75 |     20-JAN-2004 K.Boussema   Reverted the change made in bug 3139470       |
76 |                              and renamed the how columns by who columns    |
77 |     05-FEB-2004 S.Singhania   Changes based on bug 3419803.                |
78 |                                 - correct column names are used            |
79 |                                   TAX_LINE_REF_ID, TAX_SUMMARY_LINE_REF_ID,|
80 |                                   TAX_REC_NREC_DIST_REF_ID                 |
81 |                                 - reference to the column is removed.      |
82 |                                   TAX_REC_NREC_SUMMARY_DIST_REF            |
83 |     16-FEB-2004 K.Boussema   Made changes for the FND_LOG.                 |
84 |     04-MAR-2004 K.Boussema   Revised summarization of entered amounts      |
85 |     22-MAR-2004 K.Boussema    Added a parameter p_module to the TRACE calls|
86 |                               and the procedure.                           |
87 |     25-MAR-2004 K.Boussema   Added the accounting cache call to retrieve   |
88 |                              the SL_COA_MAPPING_ID value                   |
89 |     05-MAY-04 K.Boussema  Bug 3502295: Changed the sum of entered and      |
90 |                           accounted amounts, reviewed InsertLines function |
91 |     11-MAY-2004 K.Boussema  Removed the call to XLA trace routine from     |
92 |                             trace() procedure                              |
93 |     17-MAY-2004 W.Shen      Change for Attribute enhancement project       |
94 |                             InsertHeader and InsertLinks procedure are     |
95 |                             affected                                       |
96 |     14-JUN-2004 K.Boussema  Changed to improve performance, bug 3673478    |
97 |                             Change affects InsertAnalyticalCriteria proc.  |
98 |                             Removed the call to xla_utility_pkg.trace()    |
99 |     22-Sep-2004 S.Singhania Made changes for the bulk peroformance. It has |
100 |                               changed the code at number of places.        |
101 |     05-Oct-2004 S.Singhania Bug 3931752: Removed the not required where    |
102 |                               condition from the sqls that inserts into    |
103 |                               XLA_AE_LINES and XLA_DISTRIBUTION_LINKS.     |
104 |     05-OCT-2004 K.Boussema  Changed for Extract Source Values Dump feature |
105 |                             added procedures :                             |
106 |                                  - insert_extract_event()                  |
107 |                                  - insert_extract_ledger()                 |
108 |                             changed functions                              |
109 |                                   - set_event_info()                       |
110 |                                   - GetLedgersInfo()                       |
111 |     08-Dec-2004 K.Boussema  Reviewed and Renamed :                         |
112 |                             - insert_extract_ledger by insert_diag_ledger  |
113 |                             - insert_extract_event by insert_diag_event    |
114 |     09-Mar-2005 W. Shen       Ledger Currency Project                      |
115 |                               Multiple changes. For details please see DLD |
116 |     14-Mar-2005 K.Boussema Changed for ADR-enhancements.                   |
117 |     20-Apr-2005 W. Shen     replace column document_rounding_amount by     |
118 |                               doc_rounding_acctd_amt                       |
119 |     27-Apr-2005 W. Shen     Performance change. Insert into xla_ae_headers |
120 |                               with zero_amount_flag always = 'N'. will     |
121 |                               update it to 'Y' later in validation package |
122 |     26-May-2005 W. Shen     change for Unrounded_entered_amount            |
123 |     26-May-2005 A. Wan      4262811 MPA project                            |
124 |     1- Jul-2005 W. Shen     fix bug 4243728, calculate amount for 2nd      |
125 |                               ledger. Add 2 cache to ledger                |
126 |                                 calculate_amts_flag to ledger cache        |
127 |                               add ledger_category_code to ledger_cache     |
128 |                             Also set the entered amount side based on the  |
129 |                             side of unrounded accounted amount if the      |
130 |                              entered amount is 0. This is for bug 4444730  |
131 |     01-Aug-2005 W. Chan     4458381 - Public Sector Enhancement            |
132 |     01-Sep-2005 K.Boussema  reviewed insert_diag_event() for bug 4577709   |
133 |     02-Sep-2005 W. Chan     4577174 - Add call to GetTranslatedEventInfo   |
134 |                             in set_event_info                              |
135 |     09-Sep-2005 W. Shen     3720250 - new msg when gl date is null         |
136 |     18-Oct-2005 V. Kumar    Removed code for Analytical Criteria           |
137 |     04-Nov-2005 S. Singhania  Bug 4719297: Modified update statement in    |
138 |                                 GetLineNumber to add NVL in the where      |
139 |                                 condition related to header_num            |
140 |     20-Dec-2005 W. Chan     4872235 - Fixed the side for the 0 amounts     |
141 |     27-Dec-2005 A. Wan      4669308 - modify NVL(header_num,-1) to NVL(0)  |
142 |     02-Jan-2006 V. Kumar    4918497 - Added hint for performance           |
143 |                             4752807 - Conditional check to execute UPDATE  |
144 |    1/5/06    W. Shen  bug 4690710, set the amount to null in summerization |
145 |                         when the amounts are all null in temporary lines   |
146 |     09-Jan-2006 A. Wan      4669308 - AdjustMpaRevLine                     |
147 |     11-Jan-2006 W. Shen     4943507 - modify GetLineNum to add more merge  |
148 |                                       columns when get linehashnum         |
149 |     13-Feb-2006 V. Kumar    4955764 - Populating Ledger_id,Accounting_date |
150 |                                       in xla_ae_lines table                |
151 |     03-Mar-2006 V. Kumar   5041325 Populating GL_SL_LINK_ID in xla_ae_lines|
152 |     21-Jun-2006 A. Wan     5100860 Performance fix, see bug for detail     |
153 |     23-Sep-2008 Vijaya.G   7377888 Changes in AdjustMPALine procedure for  |
154 |                            MPA Accounting                                  |
155 |     03-Oct-2008 KARAMAKR   7382288 insert analytical criteria for          |
156 |                             invoice cancellation event in                  |
157 |                            xla_ae_line_acs, if analytical criteria         |
158 |			     for invoice validation event exists.            |
159 |     31-Oct-2008 VGOPISET   7230462 Changes in GetLineNumber and AdjustMPALine|
160 |                            to stamp the correct Parent_AE_Line_Num for     |
161 |                            complete MPA Accounting                         |
162 |     26-Feb-2009 VGOPISET   7560587 changes in GetLineNumber for create     |
163 |                                    accounting performance issues.          |
164 |     26-Feb-2009 VGOPISET   8277823 changes in GetLineNumber to populate    |
165 |                                    correct REF_AE_HEADER_ID for reversal   |
166 |                                    links created by AccountingReversal     |
167 |     03-Jun-2009 VGOPISET   8505463 changed the logic to derive accounting  |
168 |                                    ENTRY STATUS CODE for MPA entries when  |
169 |                                    MPA Accounting Date > P_END_DATE        |
170 |     11-Jun-2009 VGOPISET   8619700 Perf issues with REF_AE_HEADER_ID update|
171 |                                    for changes via bug8277823              |
172 |     13-MAY-2010 VGOPISET   9630931 Perf Change for REF_AE_HEADER_ID update |
173 |                            introduced via bug 8619700                      |
174 |     29-OCT-2010 VGOPISET   10247334 Perf Change of GetLineNumber SQL update|
175 |                            of AE_HEADER_ID in XLA_AE_LINES_GT              |
176 |     11-Nov-2010 VGOPISET   10242870 Changes in AdjustMPALine to adjust the |
177 |                            difference in Last Period header with MAX Amount|
178 |                            to avoid sum getting added to ERV MPA Lines.    |
179 |     26-NOV-2010 Narayanan M.S. Bug#10124492 Group_id will not be stamped   |
180 |                                             for headers with               |
181 |                                             gl_transfer_status_code as NT  |
182 |    24-Jan-2011 karamakr        Bug:11680489- Made code changes for VM based|
183 |                                secondary ledger                            |
184 |     07-Feb-2011 VGOPISET   10394715 Changes in AdjustMPALine to adjust the |
185 |                            amounts based on the side of parent entry rather|
186 |                            than looking at the CR/DR amounts.              |
187 |     27-Oct-2011 VGOPISET   13250448 and 13061446, Unrounded Amounts with   |
188 |                            no of digits >40 are truncated while inserting  |
189 |                            data into XAL from Lines_Gt. InsertLines proc.  |
190 |    20-Feb-2012  NMIKKILI  Added a Case for STAT TO ROUND OFF TO the        |
191 |                           PRECISION OF STAT irrespective OF ledger currency|
192 |                           For a STAT Currency Journal both Entered and     |
193 |			    Accounted are Same and Rounding should be of MAU |
194 |			    of STAT and NOT of Ledger Currency               |
195 |    30-Apr-2012  NMIKKILI  Added else block to mark CalculateAmts as N for  |
196 |                           ALC with same currency of Primary at ledger level|
197 |    16-Aug-2012  pshukla   Removing above changes as they causing regression|
198 |                           for Payroll create accounting.Changes are done in|
199 |			    xlajelns.pkb which would fix payroll create      |
200 |			    accouting error issue.                           |
201 |    20-Sep-2012  PDAMARAC  14603435-Code changes related to inclusion of    |
202 |			    Balancing Segment Value in the Grouping for      |
203 |			    calculation of rounded amounts.                  |
204 +===========================================================================*/
205 --
206 -- legal_entity_name value is missing
207 --
208 --
209 TYPE t_rec_who_columns IS RECORD
210 (
211   creation_date                  DATE
212 , created_by                     INTEGER
213 , last_update_date               DATE
214 , last_updated_by                INTEGER
215 , last_update_login              INTEGER
216 , program_update_date            DATE
217 , program_application_id         INTEGER
218 , program_id                     INTEGER
219 , request_id                     NUMBER
220 )
221 ;
222 --
223 TYPE t_array_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
224 --+==========================================================================+
225 --|                                                                          |
226 --|                                                                          |
227 --| Global variables                                                         |
228 --|                                                                          |
229 --|                                                                          |
230 --+==========================================================================+
231 --
232 g_who_columns                         t_rec_who_columns;
233 
234 --+==========================================================================+
235 --|                                                                          |
236 --|                                                                          |
237 --| Global constant                                                          |
238 --|                                                                          |
239 --|                                                                          |
240 --+==========================================================================+
241 --
242 C_CCID_CREATED                            CONSTANT VARCHAR2(30)  := 'CREATED';
243 C_CCID_INVALID                            CONSTANT VARCHAR2(30)  := 'INVALID';
244 --
245 C_DRAFT_STATUS                            CONSTANT VARCHAR2(1)   := 'D';
246 C_FINAL_STATUS                            CONSTANT VARCHAR2(1)   := 'F';
247 
248 C_BULK_LIMIT                              CONSTANT NUMBER        :=2000;
249 C_OVN                                     CONSTANT NUMBER        :=1;
250 
251 --+==========================================================================+
252 --|                                                                          |
253 --|                                                                          |
254 --| Local Trace Routine                                                      |
255 --|                                                                          |
256 --|                                                                          |
257 --+==========================================================================+
258 --=============================================================================
259 --               *********** Local Trace Routine **********
260 --=============================================================================
261 
262 C_LEVEL_STATEMENT     CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
263 C_LEVEL_PROCEDURE     CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
264 C_LEVEL_EVENT         CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
265 C_LEVEL_EXCEPTION     CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
266 C_LEVEL_ERROR         CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
267 C_LEVEL_UNEXPECTED    CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
268 
269 C_LEVEL_LOG_DISABLED  CONSTANT NUMBER := 99;
270 C_DEFAULT_MODULE      CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_AE_JOURNAL_ENTRY_PKG';
271 
272 g_line_ac_count       PLS_INTEGER;
273 g_hdr_ac_count        PLS_INTEGER;
274 
275 g_log_level           NUMBER;
276 g_log_enabled         BOOLEAN;
277 
278 PROCEDURE trace
279            (p_msg                        IN VARCHAR2
280            ,p_level                      IN NUMBER
281            ,p_module                     IN VARCHAR2) IS
282 BEGIN
283        ----------------------------------------------------------------------------
284        -- Following is for FND log.
285        ----------------------------------------------------------------------------
286        IF (p_msg IS NULL AND p_level >= g_log_level) THEN
287           fnd_log.message(p_level, p_module);
288        ELSIF p_level >= g_log_level THEN
289           fnd_log.string(p_level, p_module, p_msg);
290        END IF;
291 
292 EXCEPTION
293        WHEN xla_exceptions_pkg.application_exception THEN
294           RAISE;
295        WHEN OTHERS THEN
296           xla_exceptions_pkg.raise_message
297              (p_location   => 'XLA_AE_JOURNAL_ENTRY_PKG.trace');
298 END trace;
299 
300 --
301 --====================================================================
302 --
303 --
304 --
305 --
306 -- Forward declaration of local routines
307 --
308 --
309 --
310 --
311 --======================================================================
312 --
313 PROCEDURE  SetStandardWhoColumn
314 ;
315 --
316 PROCEDURE GetLineNumber
317 ;
318 --
319 PROCEDURE UpdateLineNumber
320 ;
321 --
322 PROCEDURE UpdateLineNumber0
323 ;
324 --
325 PROCEDURE UpdateLineNumber10
326 ;
327 --
328 PROCEDURE UpdateLineNumber50
329 ;
330 --
331 PROCEDURE UpdateLineNumber100
332 ;
333 --
334 
335 FUNCTION InsertLines(p_application_id         IN INTEGER
336                     ,p_budgetary_control_mode IN VARCHAR2)
337 RETURN NUMBER
338 ;
339 PROCEDURE AdjustMpaLine(p_application_id  IN INTEGER)     -- 4262811b
340 ;
341 -- PROCEDURE AdjustMpaRevLine(p_application_id  IN INTEGER);  -- 4669308
342 
343 PROCEDURE InsertAnalyticalCriteria
344 ;
345 PROCEDURE InsertAnalyticalCriteria10
346 ;
347 PROCEDURE InsertAnalyticalCriteria50
348 ;
349 PROCEDURE InsertAnalyticalCriteria100
350 ;
351 --
352 PROCEDURE InsertLinks(p_application_id    IN INTEGER)
353 ;
354 --
355 FUNCTION InsertHeaders(p_application_id                 IN INTEGER
356                       ,p_accounting_batch_id            IN NUMBER
357                       ,p_end_date                       IN DATE        -- 4262811
358                       -- bulk perfromance
359                       ,p_accounting_mode                in varchar)
360 RETURN NUMBER
361 ;
362 PROCEDURE InsertHdrAnalyticalCriteria
363 ;
364 PROCEDURE InsertHdrAnalyticalCriteria10
365 ;
366 PROCEDURE InsertHdrAnalyticalCriteria50
367 ;
368 PROCEDURE InsertHdrAnalyticalCriteria100
369 ;
370 --
371 --
372 PROCEDURE insert_diag_event(
373                                p_event_id                       IN NUMBER
374                               ,p_application_id                 IN NUMBER
375                               ,p_ledger_id                      IN NUMBER
376                               ,p_transaction_num                IN VARCHAR2
377                               ,p_entity_code                    IN VARCHAR2
378                               ,p_event_class_code               IN VARCHAR2
379                               ,p_event_type_code                IN VARCHAR2
380                               ,p_event_number                   IN NUMBER
381                               ,p_event_date                     IN DATE
382 )
383 ;
384 --
385 PROCEDURE insert_diag_ledger (  p_application_id    IN NUMBER
386                               , p_ledger_id         IN NUMBER
387                               , p_primary_ledger_id IN NUMBER
388                               , p_pad_start_date    IN DATE
389                               , p_pad_end_date      IN DATE
390 )
391 ;
392 --
393 PROCEDURE Insert_ANC_Inv_Canc;
394 /*======================================================================+
395 |                                                                       |
396 | PRIVATE Procedure                                                     |
397 |                                                                       |
398 |                                                                       |
399 +======================================================================*/
400 PROCEDURE  SetStandardWhoColumn
401 IS
402 l_log_module         VARCHAR2(240);
403 BEGIN
404 IF g_log_enabled THEN
405       l_log_module := C_DEFAULT_MODULE||'.SetStandardWhoColumn';
406 END IF;
407 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
408       trace
409          (p_msg      => 'BEGIN of SetStandardWhoColumn'
410          ,p_level    => C_LEVEL_PROCEDURE
411          ,p_module   => l_log_module);
412 
413 END IF;
414 
415 g_who_columns.creation_date                   := SYSDATE; --Removed TRUNC, bug 12655233
416 g_who_columns.created_by                      := xla_environment_pkg.g_Usr_Id ;
417 g_who_columns.last_update_date                := SYSDATE; --Removed TRUNC, bug 12655233
418 g_who_columns.last_updated_by                 := xla_environment_pkg.g_Usr_Id ;
419 g_who_columns.last_update_login               := xla_environment_pkg.g_Login_Id  ;
420 g_who_columns.program_update_date             := SYSDATE; --Removed TRUNC, bug 12655233
421 g_who_columns.program_application_id          := xla_environment_pkg.g_Prog_Appl_Id ;
422 g_who_columns.program_id                      := xla_environment_pkg.g_Prog_Id ;
423 g_who_columns.request_id                      := xla_environment_pkg.g_Req_Id ;
424 
425 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
426       trace
427          (p_msg      => 'END of SetStandardWhoColumn'
428          ,p_level    => C_LEVEL_PROCEDURE
429          ,p_module   => l_log_module);
430 
431 END IF;
432 EXCEPTION
433 WHEN xla_exceptions_pkg.application_exception THEN
434   RAISE;
435 WHEN OTHERS  THEN
436        xla_exceptions_pkg.raise_message
437                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.SetStandardWhoColumn');
438 END SetStandardWhoColumn;
439 --
440 /*======================================================================+
441 |                                                                       |
442 | Public Function                                                       |
443 |                                                                       |
444 |                                                                       |
445 +======================================================================*/
446 --
447 FUNCTION GetAlternateCurrencyLedger(p_base_ledger_id           IN NUMBER )
448 RETURN xla_accounting_cache_pkg.t_array_ledger_id
449 IS
450 l_array_alc_ledgers       xla_accounting_cache_pkg.t_array_ledger_id ;
451 l_array_ledgers           xla_accounting_cache_pkg.t_array_ledger_id ;
452 l_log_module              VARCHAR2(240);
453 BEGIN
454 --
455 IF g_log_enabled THEN
456       l_log_module := C_DEFAULT_MODULE||'.GetAlternateCurrencyLedger';
457 END IF;
458 --
459 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
460       trace
461          (p_msg      => 'BEGIN of GetAlternateCurrencyLedger'
462          ,p_level    => C_LEVEL_PROCEDURE
463          ,p_module   => l_log_module);
464 
465       trace
466           (p_msg      =>'p_base_ledger_id = '||TO_CHAR( p_base_ledger_id)
467          ,p_level    => C_LEVEL_PROCEDURE
468          ,p_module   => l_log_module);
469 
470       trace
471           (p_msg      =>'-> CALL xla_accounting_cache_pkg.GetAlcLedgers API'
472          ,p_level    => C_LEVEL_PROCEDURE
473          ,p_module   => l_log_module);
474 
475 END IF;
476 --
477 l_array_ledgers(1)   := p_base_ledger_id;
478 --
479 l_array_alc_ledgers  := xla_accounting_cache_pkg.GetAlcLedgers(
480                                           p_primary_ledger_id => p_base_ledger_id
481                                         );
482 
483 IF (C_LEVEL_EVENT >= g_log_level) THEN
484           trace
485              (p_msg      => '# of alternate ledgers = '||TO_CHAR(l_array_alc_ledgers.COUNT)
486              ,p_level    => C_LEVEL_EVENT
487              ,p_module   => l_log_module);
488 END IF;
489 
490 IF  l_array_alc_ledgers.COUNT > 0 THEN
491 
492 FOR Idx IN l_array_alc_ledgers.FIRST .. l_array_alc_ledgers.LAST LOOP
493 
494   l_array_ledgers(l_array_ledgers.LAST + 1) := l_array_alc_ledgers(Idx);
495 
496 END LOOP;
497 
498 END IF;
499 --
500 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
501       trace
502          (p_msg      => 'END of GetAlternateCurrencyLedger'
503          ,p_level    => C_LEVEL_PROCEDURE
504          ,p_module   => l_log_module);
505 END IF;
506 
507 RETURN l_array_ledgers ;
508 EXCEPTION
509 WHEN xla_exceptions_pkg.application_exception THEN
510    xla_accounting_err_pkg.build_message
511                                        (p_appli_s_name            => 'XLA'
512                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
513                                        ,p_token_1                 => 'PROCEDURE'
514                                        ,p_value_1                 => 'xla_accounting_cache_pkg.GetAlcLedgers'
515                                        ,p_entity_id               => g_cache_event.entity_id
516                                        ,p_event_id                => g_cache_event.event_id
517                                        ,p_ledger_id               => g_cache_event.target_ledger_id
518                               );
519 
520   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
521                            trace
522                               (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
523                               ,p_level    => C_LEVEL_EXCEPTION
524                               ,p_module   => l_log_module);
525   END IF;
526 
527   RAISE;
528 WHEN OTHERS  THEN
529      xla_exceptions_pkg.raise_message
530              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetAlternateCurrencyLedger');
531        --
532 END GetAlternateCurrencyLedger;
533 
534 /*======================================================================+
535 |                                                                       |
536 | Public Procedure                                                      |
537 |                                                                       |
538 |                                                                       |
539 +======================================================================*/
540 --
541 PROCEDURE cache_event_ledgers(
542     p_base_ledger_id                 IN NUMBER
543    ,p_target_ledger_id               IN NUMBER
544  )
545 IS
546 l_log_module         VARCHAR2(240);
547 BEGIN
548 --
549 IF g_log_enabled THEN
550       l_log_module := C_DEFAULT_MODULE||'.cache_event_ledgers';
551 END IF;
552 --
553 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
554       trace
555          (p_msg      => 'BEGIN of cache_event_ledgers'
556          ,p_level    => C_LEVEL_PROCEDURE
557          ,p_module   => l_log_module);
558       trace
559           (p_msg      =>'p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)||
560                         ' - p_target_ledger_id = '||TO_CHAR(p_target_ledger_id)
561          ,p_level    => C_LEVEL_PROCEDURE
562          ,p_module   => l_log_module);
563 
564 END IF;
565 
566    g_cache_event.base_ledger_id                 := p_base_ledger_id;
567    g_cache_event.target_ledger_id               := p_target_ledger_id;
568 --
569 --
570 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
571       trace
572          (p_msg      => 'END of cache_event_ledgers'
573          ,p_level    => C_LEVEL_PROCEDURE
574          ,p_module   => l_log_module);
575 
576 END IF;
577 
578 EXCEPTION
579 WHEN xla_exceptions_pkg.application_exception THEN
580   RAISE;
581 WHEN OTHERS  THEN
582        xla_exceptions_pkg.raise_message
583                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.cache_event_ledgers');
584 END cache_event_ledgers;
585 
586 /*======================================================================+
587 |                                                                       |
588 | Public PROCEDURE                                                      |
589 |                                                                       |
590 |  Update the stats of the journal entries creation (0,1,2)             |
591 +======================================================================*/
592 --
593 PROCEDURE UpdateResult(  p_old_status           IN OUT NOCOPY NUMBER
594                        , p_new_status           IN NUMBER
595 )
596 IS
597 l_old_status         NUMBER;
598 l_log_module         VARCHAR2(240);
599 BEGIN
600 --
601 IF g_log_enabled THEN
602       l_log_module := C_DEFAULT_MODULE||'.UpdateResult';
603 END IF;
604 --
605 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
606 
607       trace
608          (p_msg      => 'BEGIN of UpdateResult'
609          ,p_level    => C_LEVEL_PROCEDURE
610          ,p_module   => l_log_module);
611 
612       trace
613           (p_msg      => 'p_old_status = '||p_old_status
614          ,p_level    => C_LEVEL_PROCEDURE
615          ,p_module   => l_log_module);
616 
617      trace
618          (p_msg      => 'p_new_status = '||p_new_status
619          ,p_level    => C_LEVEL_PROCEDURE
620          ,p_module   => l_log_module);
621 
622 END IF;
623 
624 l_old_status   := p_old_status;
625 IF l_old_status = -1 OR
626    (p_new_status = 2 AND l_old_status = 2 ) OR
627    (p_new_status = 0 AND l_old_status = 0 ) OR
628    (p_new_status = 0 AND l_old_status = 2 )
629 THEN
630   p_old_status := p_new_status;
631 ELSE
632   p_old_status := 1;
633 END IF;
634 
635 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
636 
637       trace
638          (p_msg      => 'return value. = '||p_old_status
639          ,p_level    => C_LEVEL_PROCEDURE
640          ,p_module   => l_log_module);
641 
642       trace
643          (p_msg      => 'END of UpdateResult'
644          ,p_level    => C_LEVEL_PROCEDURE
645          ,p_module   => l_log_module);
646 
647 END IF;
648 
649 EXCEPTION
650 WHEN xla_exceptions_pkg.application_exception THEN
651   RAISE;
652 WHEN OTHERS  THEN
653    xla_exceptions_pkg.raise_message
654            (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateResult');
655        --
656 END UpdateResult;
657 --
658 --
659 /*======================================================================+
660 |                                                                       |
661 | Public Procedure                                                      |
662 |                                                                       |
663 |                                                                       |
664 +======================================================================*/
665 PROCEDURE  SetProductAcctDefinition(
666   p_product_rule_code      IN VARCHAR2
667 , p_product_rule_type_code IN VARCHAR2
668 , p_product_rule_version   IN VARCHAR2
669 , p_product_rule_name      IN VARCHAR2
670 , p_amb_context_code       IN VARCHAR2
671 )
672 IS
673 l_log_module         VARCHAR2(240);
674 BEGIN
675 --
676 IF g_log_enabled THEN
677       l_log_module := C_DEFAULT_MODULE||'.SetProductAcctDefinition';
678 END IF;
679 --
680 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
681 
682       trace
683          (p_msg      => 'BEGIN of SetProductAcctDefinition'
684          ,p_level    => C_LEVEL_PROCEDURE
685          ,p_module   => l_log_module);
686 
687 END IF;
688 
689   g_cache_pad.product_rule_code        := p_product_rule_code      ;
690   g_cache_pad.product_rule_type_code   := p_product_rule_type_code ;
691   g_cache_pad.product_rule_name        := p_product_rule_name      ;
692   g_cache_pad.product_rule_version     := p_product_rule_version   ;
693   g_cache_pad.amb_context_code         := p_amb_context_code       ;
694 
695 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
696 
697       trace
698          (p_msg      => 'p_product_rule_code = '||p_product_rule_code||
699                         ' - p_product_rule_type_code = '||p_product_rule_type_code||
700                         ' - p_product_rule_version = '||p_product_rule_version||
701                         ' - p_product_rule_name = '||p_product_rule_name||
702                         ' -p_amb_context_code = '||p_amb_context_code
703          ,p_level    => C_LEVEL_STATEMENT
704          ,p_module   => l_log_module);
705 END IF;
706 
707 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
708       trace
709          (p_msg      => 'END of SetProductAcctDefinition'
710          ,p_level    => C_LEVEL_PROCEDURE
711          ,p_module   => l_log_module);
712 END IF;
713 EXCEPTION
714 WHEN xla_exceptions_pkg.application_exception THEN
715   RAISE;
716 WHEN OTHERS  THEN
717    xla_exceptions_pkg.raise_message
718            (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.SetProductAcctDefinition');
719 END SetProductAcctDefinition;
720 
721 /*======================================================================+
722 |                                                                       |
723 | PRIVATE Procedure                                                     |
724 |                                                                       |
725 |    Called by Diagnostic Framework to store event info.                |
726 +======================================================================*/
727 --
728 PROCEDURE insert_diag_ledger (
729   p_application_id    IN NUMBER
730 , p_ledger_id         IN NUMBER
731 , p_primary_ledger_id IN NUMBER
732 , p_pad_start_date    IN DATE
733 , p_pad_end_date      IN DATE
734 )
735 IS
736 l_log_module         VARCHAR2(240);
737 l_request_id         NUMBER;
738 BEGIN
739 IF g_log_enabled THEN
740       l_log_module := C_DEFAULT_MODULE||'.insert_diag_ledger';
741 END IF;
742 --
743 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
744     trace
745      (p_msg      => 'BEGIN of insert_diag_ledger'
746      ,p_level    => C_LEVEL_PROCEDURE
747      ,p_module   => l_log_module);
748 END IF;
749 
750 l_request_id := xla_environment_pkg.g_Req_Id ;
751 
752    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
753      trace
754          (p_msg      => 'SQL- Insert xla_diag_ledgers  the ledger_id ='||p_ledger_id
755          ,p_level    => C_LEVEL_STATEMENT
756          ,p_module   => l_log_module);
757    END IF;
758 
759    INSERT INTO xla_diag_ledgers
760    (
761         application_id
762       , ledger_id
763       , primary_ledger_id
764       , sla_ledger_id
765       , description_language
766       , nls_desc_language
767       , currency_code
768       , product_rule_code
769       , product_rule_type_code
770       , amb_context_code
771       , start_date_active
772       , end_date_active
773       , accounting_request_id
774       , created_by
775       , creation_date
776       , last_update_date
777       , last_updated_by
778       , last_update_login
779       , program_update_date
780       , program_application_id
781       , program_id
782       , request_id
783    )
784    SELECT
785        p_application_id
786      , p_ledger_id
787      , p_primary_ledger_id
788      , g_cache_ledgers_info.sla_ledger_id
789      , g_cache_ledgers_info.description_language
790      , g_cache_ledgers_info.nls_desc_language
791      , g_cache_ledgers_info.currency_code
792      , g_cache_pad.product_rule_code
793      , g_cache_pad.product_rule_type_code
794      , g_cache_pad.amb_context_code
795      , p_pad_start_date
796      , p_pad_end_date
797      , l_request_id
798      , xla_environment_pkg.g_Usr_Id
799      , TRUNC(SYSDATE)
800      , TRUNC(SYSDATE)
801      , xla_environment_pkg.g_Usr_Id
802      , xla_environment_pkg.g_Login_Id
803      , TRUNC(SYSDATE)
804      , xla_environment_pkg.g_Prog_Appl_Id
805      , xla_environment_pkg.g_Prog_Id
806      , xla_environment_pkg.g_Req_Id
807     FROM xla_subledger_options_v
808    WHERE application_id         = p_application_id
809      AND ledger_id              = p_ledger_id
810      AND primary_ledger_id      = p_primary_ledger_id
811      AND not exists (SELECT 'x'
812                        FROM xla_diag_ledgers
813                       WHERE application_id         = p_application_id
814                         AND ledger_id              = p_ledger_id
815                         AND primary_ledger_id      = p_primary_ledger_id
816                         AND accounting_request_id  = l_request_id
817                     )
818     ;
819 
820 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
821     trace
822          (p_msg      => 'Number of Extract ledgers Inserted = '||SQL%ROWCOUNT
823          ,p_level    => C_LEVEL_STATEMENT
824          ,p_module   => l_log_module);
825 END IF;
826 
827 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
828 trace
829      (p_msg      => 'END of insert_diag_ledger'
830      ,p_level    => C_LEVEL_PROCEDURE
831      ,p_module   => l_log_module);
832 END IF;
833 EXCEPTION
834 WHEN xla_exceptions_pkg.application_exception THEN
835   RAISE;
836 WHEN OTHERS  THEN
837        xla_exceptions_pkg.raise_message
838                (p_location => 'xla_ae_journal_entry_pkg.insert_diag_ledger');
839   --
840 END insert_diag_ledger;
841 --
842 /*======================================================================+
843 |                                                                       |
844 | Public Procedure                                                      |
845 |                                                                       |
846 |                                                                       |
847 +======================================================================*/
848 --
849 FUNCTION  GetLedgersInfo(
850  p_application_id           IN NUMBER
851 ,p_base_ledger_id           IN NUMBER
852 ,p_target_ledger_id         IN NUMBER
853 -- bulk performance
854 ,p_primary_ledger_id        in number
855 ,p_pad_start_date           IN DATE
856 ,p_pad_end_date             IN DATE
857 --
858 )
859 RETURN BOOLEAN
860 IS
861 l_result               BOOLEAN:=TRUE;
862 l_api_name             VARCHAR2(30);
863 l_log_module           VARCHAR2(240);
864 l_sl_coa_mapping_id    NUMBER:=NULL;
865 l_category_code        VARCHAR2(30);
866 l_primary_currency     VARCHAR2(30);
867 l_currency             VARCHAR2(30);
868 l_alc_enabled_flag   VARCHAR2(1);
869 l_primary_ledger_id   NUMBER := NULL; --Bug :11680489
870 
871 --Bug :11680489- Code change for VM based secondary ledger having different CoA than primary
872 CURSOR csr IS
873 SELECT xso.primary_ledger_id
874  FROM  xla_subledger_options_v xso
875  WHERE xso.ledger_id = p_target_ledger_id
876    AND xso.application_id =p_application_id
877    AND ledger_category_code = 'SECONDARY'
878    AND valuation_method_flag = 'Y';
879 
880 BEGIN
881 --
882 IF g_log_enabled THEN
883       l_log_module := C_DEFAULT_MODULE||'.GetLedgersInfo';
884 END IF;
885 --
886 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
887 
888       trace
889          (p_msg      => 'BEGIN of GetLedgersInfo'
890          ,p_level    => C_LEVEL_PROCEDURE
891          ,p_module   => l_log_module);
892 
893       trace
894          (p_msg      => '-> CALL xla_accounting_cache_pkg.GetValueChar/Num/Date APIs'
895          ,p_level    => C_LEVEL_PROCEDURE
896          ,p_module   => l_log_module);
897 
898 END IF;
899 --Bug :11680489- Code change for VM based secondary ledger having different CoA than primary
900 OPEN csr;
901 FETCH csr INTO l_primary_ledger_id;
902 IF csr%NOTFOUND THEN
903     IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
904 
905       trace
906          (p_msg      => p_target_ledger_id||' is not a VM based secondary ledger'
907          ,p_level    => C_LEVEL_PROCEDURE
908          ,p_module   => l_log_module);
909     END IF;
910 END IF;
911 CLOSE csr;
912 
913 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
914 
915   trace
916 	 (p_msg      => 'l_primary_ledger_id in GetLedgersInfo : '||l_primary_ledger_id
917 	 ,p_level    => C_LEVEL_PROCEDURE
918 	 ,p_module   => l_log_module);
919 END IF;
920 
921 ---Code change for VM based secondary ledger having different CoA than primary--------
922    g_cache_event.base_ledger_id                 := p_base_ledger_id;
923    g_cache_event.target_ledger_id               := p_target_ledger_id;
924 
925   --
926   -- target ledger language
927   --
928   l_api_name:= 'GetValueChar';
929   g_cache_ledgers_info.description_language := xla_accounting_cache_pkg.GetValueChar(
930                                   p_source_code        => 'XLA_DESCRIPTION_LANGUAGE'
931                                 , p_target_ledger_id   => p_target_ledger_id
932                                 );
933 
934   IF g_cache_ledgers_info.description_language IS NULL THEN
935 
936   l_result := FALSE;
937 
938           xla_accounting_err_pkg.build_message
939                    (p_appli_s_name            => 'XLA'
940                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
941                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
942                    ,p_value_1                 => 'Description Language'
943                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
944                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
945                    ,p_ledger_id               => p_target_ledger_id
946          );
947 
948          IF (C_LEVEL_ERROR >= g_log_level) THEN
949              trace
950                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
951                   ,p_level    => C_LEVEL_ERROR
952                   ,p_module   => l_log_module);
953          END IF;
954   END IF;
955 
956 
957   --
958   -- target minimum accountable unit
959   --
960   l_api_name:= 'GetValueNum';
961   g_cache_ledgers_info.minimum_accountable_unit:= xla_accounting_cache_pkg.GetValueNum(
962                                   p_source_code        => 'XLA_CURRENCY_MAU'
963                                 , p_target_ledger_id   => p_target_ledger_id
964                                 );
965 
966   IF g_cache_ledgers_info.minimum_accountable_unit IS NULL THEN
967 
968   l_result := FALSE;
969 
970           xla_accounting_err_pkg.build_message
971                    (p_appli_s_name            => 'XLA'
972                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
973                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
974                    ,p_value_1                 => 'Minimum Accountable Unit'
975                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
976                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
977                    ,p_ledger_id               => p_target_ledger_id
978          );
979 
980          IF (C_LEVEL_ERROR >= g_log_level) THEN
981              trace
982                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
983                   ,p_level    => C_LEVEL_ERROR
984                   ,p_module   => l_log_module);
985          END IF;
986   END IF;
987 
988   --
989   -- Rounding rule code
990   --
991   l_api_name:= 'GetValueChar';
992   g_cache_ledgers_info.rounding_rule_code:= xla_accounting_cache_pkg.GetValueChar(
993                                   p_source_code        => 'XLA_ROUNDING_RULE_CODE'
994                                 , p_target_ledger_id   => p_target_ledger_id
995                                 );
996 
997   IF g_cache_ledgers_info.rounding_rule_code IS NULL THEN
998 
999   l_result := FALSE;
1000 
1001           xla_accounting_err_pkg.build_message
1002                    (p_appli_s_name            => 'XLA'
1003                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1004                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1005                    ,p_value_1                 => 'Rounding Rule Code'
1006                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1007                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1008                    ,p_ledger_id               => p_target_ledger_id
1009          );
1010 
1011          IF (C_LEVEL_ERROR >= g_log_level) THEN
1012              trace
1013                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1014                   ,p_level    => C_LEVEL_ERROR
1015                   ,p_module   => l_log_module);
1016          END IF;
1017   END IF;
1018   --
1019   -- SLA ledger id
1020   --
1021   l_api_name:= 'GetValueNum';
1022   g_cache_ledgers_info.sla_ledger_id      := xla_accounting_cache_pkg.GetValueNum(
1023                                     p_source_code        => 'SLA_LEDGER_ID'
1024                                   , p_target_ledger_id   => p_target_ledger_id
1025                                   );
1026 
1027   IF g_cache_ledgers_info.sla_ledger_id IS NULL THEN
1028 
1029       l_result := FALSE;
1030 
1031       xla_accounting_err_pkg.build_message
1032                          (p_appli_s_name            => 'XLA'
1033                          ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1034                          ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1035                          ,p_value_1                 => 'Sla ledger id'
1036                          ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1037                          ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1038                          ,p_ledger_id               => p_target_ledger_id
1039            );
1040 
1041        IF (C_LEVEL_ERROR >= g_log_level) THEN
1042              trace
1043                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1044                   ,p_level    => C_LEVEL_ERROR
1045                   ,p_module   => l_log_module);
1046        END IF;
1047   END IF;
1048   --
1049   -- target currency code
1050   --
1051   l_api_name:= 'GetValueChar';
1052   l_currency := xla_accounting_cache_pkg.GetValueChar(
1053                                   p_source_code        => 'XLA_CURRENCY_CODE'
1054                                 , p_target_ledger_id   => p_target_ledger_id
1055                                 );
1056   g_cache_ledgers_info.currency_code      := l_currency;
1057 
1058   IF g_cache_ledgers_info.currency_code IS NULL THEN
1059 
1060     xla_accounting_err_pkg.build_message
1061                        (p_appli_s_name            => 'XLA'
1062                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1063                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1064                        ,p_value_1                 => 'Ledger Currency Code'
1065                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1066                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1067                        ,p_ledger_id               => p_target_ledger_id
1068          );
1069 
1070     IF (C_LEVEL_ERROR >= g_log_level) THEN
1071              trace
1072                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1073                   ,p_level    => C_LEVEL_ERROR
1074                   ,p_module   => l_log_module);
1075     END IF;
1076 
1077   END IF;
1078 
1079   --
1080   -- get primary coa id
1081   --
1082   l_api_name:= 'GetValueNum';
1083   g_cache_ledgers_info.source_coa_id  := xla_accounting_cache_pkg.GetValueNum(
1084                                   p_source_code       => 'XLA_COA_ID'
1085                                 , p_target_ledger_id  => nvl(l_primary_ledger_id,p_primary_ledger_id) --Bug :11680489
1086                                  );
1087 
1088   IF g_cache_ledgers_info.source_coa_id IS NULL THEN
1089 
1090     l_result := FALSE;
1091 
1092      xla_accounting_err_pkg.build_message
1093                        (p_appli_s_name            => 'XLA'
1094                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1095                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1096                        ,p_value_1                 => 'Chart of accounts'
1097                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1098                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1099                        ,p_ledger_id               => p_base_ledger_id
1100          );
1101 
1102     IF (C_LEVEL_ERROR >= g_log_level) THEN
1103              trace
1104                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1105                   ,p_level    => C_LEVEL_ERROR
1106                   ,p_module   => l_log_module);
1107     END IF;
1108   ELSE
1109   --
1110   -- cache source coa info
1111   --
1112     XLA_AE_CODE_COMBINATION_PKG.cache_coa(p_coa_id => g_cache_ledgers_info.source_coa_id);
1113   --
1114   END IF;
1115   --
1116   -- target coa id, used to build the target code combination
1117   --
1118   l_api_name:= 'GetValueNum';
1119   g_cache_ledgers_info.target_coa_id  := xla_accounting_cache_pkg.GetValueNum(
1120                                   p_source_code       => 'XLA_COA_ID'
1121                                 , p_target_ledger_id  => p_target_ledger_id
1122                                  );
1123 
1124   IF g_cache_ledgers_info.target_coa_id IS NULL THEN
1125 
1126     l_result := FALSE;
1127 
1128     xla_accounting_err_pkg.build_message
1129                            (p_appli_s_name            => 'XLA'
1130                            ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1131                            ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1132                            ,p_value_1                 => 'Chart of accounts'
1133                            ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1134                            ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1135                            ,p_ledger_id               => p_target_ledger_id
1136          );
1137 
1138     IF (C_LEVEL_ERROR >= g_log_level) THEN
1139              trace
1140                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1141                   ,p_level    => C_LEVEL_ERROR
1142                   ,p_module   => l_log_module);
1143     END IF;
1144 
1145   ELSE
1146   --
1147   -- cache target coa info
1148   --
1149     XLA_AE_CODE_COMBINATION_PKG.cache_coa( p_coa_id => g_cache_ledgers_info.target_coa_id);
1150   --
1151   END IF;
1152   --
1153   -- Get multiple posting information
1154   --
1155   l_api_name:= 'GetValueChar';
1156   g_cache_ledgers_info.sl_coa_mapping_name  :=  xla_accounting_cache_pkg.GetValueChar(
1157                                       p_source_code       => 'GL_COA_MAPPING_NAME'
1158                                     , p_target_ledger_id  => p_base_ledger_id
1159                                      );
1160 
1161  --
1162  -- get SL coa mapping id
1163  --
1164     l_api_name:= 'GetValueNum';
1165 
1166     l_sl_coa_mapping_id   :=  xla_accounting_cache_pkg.GetValueNum(
1167                                           p_source_code       => 'SL_COA_MAPPING_ID'
1168                                         , p_target_ledger_id  => p_base_ledger_id
1169                                      );
1170 
1171      g_cache_ledgers_info.sl_coa_mapping_id:= l_sl_coa_mapping_id;
1172 
1173  IF g_cache_ledgers_info.sl_coa_mapping_name IS NOT NULL  AND
1174     l_sl_coa_mapping_id IS NOT NULL
1175  THEN
1176        --
1177        -- get coa dynamic insert flag
1178        --
1179        l_api_name:= 'GetValueChar';
1180 
1181        g_cache_ledgers_info.dynamic_insert_flag  :=  xla_accounting_cache_pkg.GetValueChar(
1182                                           p_source_code       => 'DYNAMIC_INSERTS_ALLOWED_FLAG'
1183                                         , p_target_ledger_id  => p_base_ledger_id
1184                                      );
1185 
1186       --
1187         XLA_AE_CODE_COMBINATION_PKG.cacheGLMapping(
1188                          p_sla_coa_mapping_name => g_cache_ledgers_info.sl_coa_mapping_name
1189                        , p_sla_coa_mapping_id   => g_cache_ledgers_info.sl_coa_mapping_id
1190                        , p_dynamic_inserts_flag => g_cache_ledgers_info.dynamic_insert_flag
1191                         );
1192 
1193  END IF;
1194   --
1195   -- nls descriptions  of target ledger
1196   --
1197   l_api_name:= 'GetValueChar';
1198   g_cache_ledgers_info.nls_desc_language := xla_accounting_cache_pkg.GetValueChar(
1199                                   p_source_code        => 'XLA_NLS_DESC_LANGUAGE'
1200                                 , p_target_ledger_id   =>  p_target_ledger_id
1201                                  );
1202 
1203   IF g_cache_ledgers_info.nls_desc_language IS NULL THEN
1204 
1205     l_result := FALSE;
1206 
1207         xla_accounting_err_pkg.build_message
1208                                (p_appli_s_name            => 'XLA'
1209                                ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1210                                ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1211                                ,p_value_1                 => 'NLS description language'
1212                                ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1213                                ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1214                                ,p_ledger_id               => p_target_ledger_id
1215          );
1216 
1217     IF (C_LEVEL_ERROR >= g_log_level) THEN
1218              trace
1219                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1220                   ,p_level    => C_LEVEL_ERROR
1221                   ,p_module   => l_log_module);
1222     END IF;
1223 
1224   END IF;
1225   --
1226   -- target reversal option
1227   --
1228   l_api_name:= 'GetValueChar';
1229   g_cache_ledgers_info.ledger_reversal_option  :=  xla_accounting_cache_pkg.GetValueChar(
1230                                   p_source_code       => 'XLA_ACCT_REVERSAL_OPTION'
1231                                 , p_target_ledger_id  => p_target_ledger_id
1232                                 );
1233 
1234 
1235 
1236   --
1237   IF g_cache_ledgers_info.ledger_reversal_option IS NOT NULL AND
1238      g_cache_ledgers_info.ledger_reversal_option NOT IN ('SIDE','SIGN') THEN
1239 
1240     l_result := FALSE;
1241 
1242     xla_accounting_err_pkg.build_message
1243                            (p_appli_s_name            => 'XLA'
1244                            ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1245                            ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1246                            ,p_value_1                 => 'Accounting Reversal Option'
1247                            ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1248                            ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1249                            ,p_ledger_id               => p_target_ledger_id
1250          );
1251 
1252     IF (C_LEVEL_ERROR >= g_log_level) THEN
1253               trace
1254                    (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1255                    ,p_level    => C_LEVEL_ERROR
1256                    ,p_module   => l_log_module);
1257     END IF;
1258 
1259   END IF;
1260   --
1261   --
1262 
1263   -- ledger category code
1264   --
1265   l_api_name:= 'GetValueChar';
1266   l_category_code:= xla_accounting_cache_pkg.GetValueChar(
1267                                   p_source_code        => 'LEDGER_CATEGORY_CODE'
1268                                 , p_target_ledger_id   => p_target_ledger_id
1269                                 );
1270 
1271   g_cache_ledgers_info.ledger_category_code :=l_category_code;
1272 
1273   IF l_category_code IS NULL THEN
1274 
1275     xla_accounting_err_pkg.build_message
1276                        (p_appli_s_name            => 'XLA'
1277                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1278                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1279                        ,p_value_1                 => 'Ledger Category Code'
1280                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1281                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1282                        ,p_ledger_id               => p_target_ledger_id
1283          );
1284 
1285     IF (C_LEVEL_ERROR >= g_log_level) THEN
1286              trace
1287                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1288                   ,p_level    => C_LEVEL_ERROR
1289                   ,p_module   => l_log_module);
1290     END IF;
1291 
1292   END IF;
1293 
1294   g_cache_ledgers_info.calculate_amts_flag:='Y';
1295 
1296 
1297   IF(l_category_code= 'SECONDARY') THEN
1298 
1299     -- primary currency code
1300     --
1301     l_api_name:= 'GetValueChar';
1302     l_primary_currency:= xla_accounting_cache_pkg.GetValueChar(
1303                                   p_source_code        => 'XLA_CURRENCY_CODE'
1304                                 , p_target_ledger_id   => nvl(l_primary_ledger_id,p_primary_ledger_id)--Bug :11680489
1305                                 );
1306 
1307     IF l_primary_currency IS NULL THEN
1308 
1309       xla_accounting_err_pkg.build_message
1310                        (p_appli_s_name            => 'XLA'
1311                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1312                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1313                        ,p_value_1                 => 'Ledger Currency Code'
1314                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1315                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1316                        ,p_ledger_id               => nvl(l_primary_ledger_id,p_primary_ledger_id)--Bug :11680489
1317          );
1318 
1319       IF (C_LEVEL_ERROR >= g_log_level) THEN
1320              trace
1321                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1322                   ,p_level    => C_LEVEL_ERROR
1323                   ,p_module   => l_log_module);
1324       END IF;
1325 
1326     END IF;
1327     IF l_primary_currency = l_currency THEN
1328       g_cache_ledgers_info.calculate_amts_flag:='N';
1329     END IF;
1330   ELSIF l_category_code= 'ALC' THEN
1331     l_alc_enabled_flag :=xla_accounting_cache_pkg.GetValueChar('XLA_ALC_ENABLED_FLAG');
1332    IF(l_alc_enabled_flag = 'N') THEN
1333       g_cache_ledgers_info.calculate_amts_flag:='N';
1334 
1335       /* -- else block to mark CalculateAmts as N for ALC with same currency of Primary bug 13636827
1336        ELSE
1337       l_api_name:= 'GetValueChar';
1338       l_primary_currency:= xla_accounting_cache_pkg.GetValueChar(
1339                                   p_source_code        => 'XLA_CURRENCY_CODE'
1340                                 , p_target_ledger_id   => p_primary_ledger_id
1341                                 );
1342       IF l_primary_currency = l_currency THEN
1343          g_cache_ledgers_info.calculate_amts_flag:='N';
1344       END IF; */ -- commenting bug 14505020
1345 
1346     END IF;
1347   END IF;
1348 
1349 
1350 -----------------------------------------------------------------------
1351 --
1352 -- Call insert_diag_ledger to store event information
1353 --
1354 -----------------------------------------------------------------------
1355 IF ( xla_accounting_engine_pkg.g_diagnostics_mode = 'Y') THEN
1356 
1357    trace
1358          (p_msg      => '-> Call Extract Source Values Diagnostics routine'
1359          ,p_level    => C_LEVEL_STATEMENT
1360          ,p_module   => l_log_module);
1361 
1362    insert_diag_ledger(
1363                         p_application_id      => p_application_id
1364                        ,p_ledger_id           => p_target_ledger_id
1365                        ,p_primary_ledger_id   => p_primary_ledger_id
1366                        ,p_pad_start_date      => p_pad_start_date
1367                        ,p_pad_end_date        => p_pad_end_date
1368                        );
1369 END IF;
1370 
1371 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1372       trace
1373          (p_msg      => 'description_language = '||g_cache_ledgers_info.description_language||
1374                          ' - sla_ledger_id = '||g_cache_ledgers_info.sla_ledger_id||
1375                          ' - currency_code = '||g_cache_ledgers_info.currency_code||
1376                          ' - source_coa_id = '||g_cache_ledgers_info.source_coa_id||
1377                          ' - target_coa_id = '||g_cache_ledgers_info.target_coa_id||
1378                          ' - sl_coa_mapping_name = '||g_cache_ledgers_info.sl_coa_mapping_name||
1379                          ' - dynamic_insert_flag = '||g_cache_ledgers_info.dynamic_insert_flag||
1380                          ' - nls_desc_language = '||g_cache_ledgers_info.nls_desc_language||
1381                          ' - calculate_amts_flag= '||g_cache_ledgers_info.calculate_amts_flag||
1382                          ' - ledger_category_code= '||g_cache_ledgers_info.ledger_category_code||
1383                          ' - ledger_reversal_option = '||g_cache_ledgers_info.ledger_reversal_option
1384 
1385          ,p_level    => C_LEVEL_STATEMENT
1386          ,p_module   => l_log_module);
1387 END IF;
1388 --
1389 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1390       trace
1391          (p_msg      => 'END of GetLedgersInfo'
1392          ,p_level    => C_LEVEL_PROCEDURE
1393          ,p_module   => l_log_module);
1394 END IF;
1395 --
1396 RETURN l_result;
1397 --
1398 EXCEPTION
1399   --
1400 WHEN xla_exceptions_pkg.application_exception THEN
1401    xla_accounting_err_pkg.build_message
1402                                        (p_appli_s_name            => 'XLA'
1403                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
1404                                        ,p_token_1                 => 'PROCEDURE'
1405                                        ,p_value_1                 => 'xla_accounting_cache_pkg.'||l_api_name
1406                                        ,p_entity_id               => g_cache_event.entity_id
1407                                        ,p_event_id                => g_cache_event.event_id
1408                                        ,p_ledger_id               => g_cache_event.target_ledger_id
1409                               );
1410 
1411   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1412      trace
1413          (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
1414          ,p_level    => C_LEVEL_EXCEPTION
1415          ,p_module   => l_log_module);
1416 
1417   END IF;
1418   RAISE;
1419 WHEN OTHERS  THEN
1420      xla_exceptions_pkg.raise_message
1421              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo');
1422        --
1423 END GetLedgersInfo;
1424 --
1425 --
1426 /*======================================================================+
1427 |                                                                       |
1428 | Public Procedure                                                      |
1429 |                                                                       |
1430 |                                                                       |
1431 +======================================================================*/
1432 --
1433 FUNCTION  GetTranslatedEventInfo
1434 RETURN BOOLEAN
1435 IS
1436 l_log_module         VARCHAR2(240);
1437 BEGIN
1438 --
1439 IF g_log_enabled THEN
1440       l_log_module := C_DEFAULT_MODULE||'.GetTranslatedEventInfo';
1441 END IF;
1442 --
1443 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1444 
1445       trace
1446          (p_msg      => 'BEGIN of  GetTranslatedEventInfo'
1447          ,p_level    => C_LEVEL_PROCEDURE
1448          ,p_module   => l_log_module);
1449 
1450        trace
1451          (p_msg      => '-> CALL xla_accounting_cache_pkg.get_event_info API'
1452          ,p_level    => C_LEVEL_PROCEDURE
1453          ,p_module   => l_log_module);
1454 END IF;
1455 
1456  xla_accounting_cache_pkg.get_event_info
1457         (p_ledger_id                  => g_cache_event.target_ledger_id
1458         ,p_event_class_code           => g_cache_event.event_class
1459         ,p_event_type_code            => g_cache_event.event_type
1460         ,p_ledger_event_class_name    => g_cache_event_tl.event_class_name
1461         ,p_session_event_class_name   => g_cache_event_tl.session_event_class
1462         ,p_ledger_event_type_name     => g_cache_event_tl.event_type_name
1463         ,p_session_event_type_name    => g_cache_event_tl.session_event_type
1464        );
1465 
1466 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1467 
1468       trace
1469          (p_msg      => 'END of  GetTranslatedEventInfo'
1470          ,p_level    => C_LEVEL_PROCEDURE
1471          ,p_module   => l_log_module);
1472 
1473 END IF;
1474 RETURN TRUE;
1475 EXCEPTION
1476 WHEN xla_exceptions_pkg.application_exception THEN
1477    xla_accounting_err_pkg.build_message
1478                                        (p_appli_s_name            => 'XLA'
1479                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
1480                                        ,p_token_1                 => 'PROCEDURE'
1481                                        ,p_value_1                 => 'xla_accounting_cache_pkg.get_event_info'
1482                                        ,p_entity_id               => g_cache_event.entity_id
1483                                        ,p_event_id                => g_cache_event.event_id
1484                                        ,p_ledger_id               => g_cache_event.target_ledger_id
1485                               );
1486 
1487 
1488   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1489 
1490          trace
1491              (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
1492              ,p_level    => C_LEVEL_EXCEPTION
1493              ,p_module   => l_log_module);
1494 
1495   END IF;
1496   RAISE;
1497 WHEN OTHERS  THEN
1498      xla_exceptions_pkg.raise_message
1499              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetTranslatedEventInfo');
1500 END GetTranslatedEventInfo;
1501 --
1502 --
1503 /*======================================================================+
1504 |                                                                       |
1505 | Public Procedure                                                      |
1506 |                                                                       |
1507 |                                                                       |
1508 +======================================================================*/
1509 --
1510 PROCEDURE free_ae_cache
1511 IS
1512 l_null_event             t_rec_event;
1513 l_null_pad               t_rec_product_rule;
1514 l_null_ledgers_info      t_rec_ledgers_info;
1515 l_null_event_tl          t_rec_event_tl;
1516 l_null_sc_value_set      XLA_AE_SOURCES_PKG.t_array_meaning;
1517 --
1518 l_log_module         VARCHAR2(240);
1519 --
1520 BEGIN
1521 --
1522 IF g_log_enabled THEN
1523       l_log_module := C_DEFAULT_MODULE||'.free_ae_cache';
1524 END IF;
1525 --
1526 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1527 
1528       trace
1529          (p_msg      => 'BEGIN of free_ae_cache'
1530          ,p_level    => C_LEVEL_PROCEDURE
1531          ,p_module   => l_log_module);
1532 
1533 END IF;
1534 
1535    g_global_status             := 2;
1536    g_cache_event               := l_null_event;
1537    g_cache_pad                 := l_null_pad;
1538    g_cache_ledgers_info        := l_null_ledgers_info;
1539    g_cache_event_tl            := l_null_event_tl;
1540    --
1541    XLA_AE_HEADER_PKG.RefreshHeader;
1542    XLA_AE_LINES_PKG.RefreshLines;
1543    --
1544    -- free source value set cache
1545    --
1546    XLA_AE_SOURCES_PKG.g_array_meaning:= l_null_sc_value_set;
1547    --
1548 --
1549 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1550 
1551       trace
1552          (p_msg      => 'END of free_ae_cache'
1553          ,p_level    => C_LEVEL_PROCEDURE
1554          ,p_module   => l_log_module);
1555 
1556 END IF;
1557 --
1558 EXCEPTION
1559 WHEN xla_exceptions_pkg.application_exception THEN
1560   RAISE;
1561 WHEN OTHERS  THEN
1562        xla_exceptions_pkg.raise_message
1563                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.free_ae_cache');
1564 --
1565 END free_ae_cache;
1566 --
1567 --
1568 /*======================================================================+
1569 |                                                                       |
1570 | GetLineNumber                                                         |
1571 |                                                                       |
1572 |                                                                       |
1573 +======================================================================*/
1574 --
1575 PROCEDURE GetLineNumber
1576 IS
1577 --
1578 l_ae_line_num   NUMBER;
1579 l_ae_header_id  NUMBER;
1580 l_log_module         VARCHAR2(240);
1581 --
1582 type t_array_rowid is table of rowid index by binary_integer;
1583 
1584 
1585 l_array_rowid        t_array_rowid;
1586 l_array_rowid1       t_array_rowid;
1587 l_array_ae_line_num  t_array_Num;
1588 l_array_doc_rounding_amt1   t_array_Num;
1589 l_array_rounding_entd_amt1   t_array_Num;
1590 l_array_ledger_id    t_array_ledger_id;
1591 l_array_header_id    t_array_Num;
1592 /*
1593 l_array_base_ledgers      xla_accounting_cache_pkg.t_array_ledger_id;
1594 l_array_alc_ledgers       xla_accounting_cache_pkg.t_array_ledger_id ;
1595 l_array_ledgers           xla_accounting_cache_pkg.t_array_ledger_id ;
1596 */
1597 l_rounding_rule_code VARCHAR2(30);
1598 l_array_rounding_offset  t_array_Num;
1599 l_array_mau              t_array_Num;
1600 l_array_rounding_class_code  t_array_V30L;
1601 l_array_doc_rounding_level   t_array_V30L;
1602 l_array_unrounded_amount     t_array_Num;
1603 l_array_unrounded_entd_amount     t_array_Num;
1604 l_array_entd_mau              t_array_Num;
1605 
1606 l_curr_rounding_class_code VARCHAR2(30);
1607 l_curr_doc_rounding_level  VARCHAR2(30);
1608 l_curr_doc_rounding_amount NUMBER;
1609 l_curr_entd_rounding_amount NUMBER;
1610 l_curr_total_unrounded     NUMBER;
1611 l_curr_total_rounded       NUMBER;
1612 l_curr_entd_total_unrounded     NUMBER;
1613 l_curr_entd_total_rounded       NUMBER;
1614 l_curr_max_rowid           ROWID;
1615 l_curr_max_amount          NUMBER;
1616 l_curr_ledger_id           NUMBER;
1617 l_curr_header_id           NUMBER;
1618 l_curr_mau                 NUMBER;
1619 l_curr_entd_mau            NUMBER;
1620 l_curr_offset              NUMBER;
1621 j                          NUMBER;
1622 -- start changes for bug 14603435
1623 l_case_sql VARCHAR2(1000);
1624 l_sql      VARCHAR2(2000);
1625 bsv_segment_name VARCHAR2(30);
1626 l_curr_bsv_value VARCHAR2(60);
1627 l_array_bsv_value             t_array_V30L;
1628 type r_cursor is REF CURSOR;
1629 c_rounding r_cursor;
1630 -- end changes for bug 14603435
1631 
1632 
1633 l_count             NUMBER :=1;
1634 
1635 l_ledger_attrs       xla_accounting_cache_pkg.t_array_ledger_attrs;
1636 
1637 --CURSOR csr_rounding_lines is
1638 --SELECT max(xalg.rowid)
1639 --       ,rounding_class_code
1640 --       ,document_rounding_level
1641  --      ,NVL(SUM(unrounded_accounted_cr), 0)
1642 --                - NVL(SUM(unrounded_accounted_dr), 0) unrounded_amount
1643 --       ,ledger_id
1644 --       ,ae_header_id
1645 --       ,NVL(SUM(unrounded_entered_cr), 0)
1646 --                - NVL(SUM(unrounded_entered_dr), 0) unrounded_entered_amount
1647 --       ,entered_currency_mau
1648 --FROM   xla_ae_lines_gt xalg
1649 --WHERE temp_line_num <> 0
1650 --GROUP BY ledger_id, event_id, ae_header_id,
1651 --         rounding_class_code, document_rounding_level, ae_line_num
1652 --         ,entered_currency_mau
1653 --HAVING document_rounding_level is not null
1654 --   AND rounding_class_code is not null
1655 --ORDER BY document_rounding_level, rounding_class_code;
1656 
1657 
1658 BEGIN
1659 IF g_log_enabled THEN
1660       l_log_module := C_DEFAULT_MODULE||'.GetLineNumber';
1661 END IF;
1662 --
1663 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1664 
1665       trace
1666          (p_msg      => 'BEGIN of GetLineNumber'
1667          ,p_level    => C_LEVEL_PROCEDURE
1668          ,p_module   => l_log_module);
1669 END IF;
1670 
1671 xla_accounting_cache_pkg.GetLedgerArray(l_ledger_attrs);
1672 
1673 For i in 1..l_ledger_attrs.array_ledger_id.COUNT LOOP
1674   l_array_mau(l_ledger_attrs.array_ledger_id(i)) := l_ledger_attrs.array_mau(i);
1675   l_array_rounding_offset(l_ledger_attrs.array_ledger_id(i)) :=
1676                                         l_ledger_attrs.array_rounding_offset(i);
1677 END LOOP;
1678 
1679 BEGIN
1680 
1681    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1682 
1683       trace
1684          (p_msg      => 'SQL - Update xla_ae_lines_gt'
1685          ,p_level    => C_LEVEL_STATEMENT
1686          ,p_module   => l_log_module);
1687 
1688    END IF;
1689 
1690 IF g_array_event_id.count > 0 then
1691 -- Commented FORALL Update for perf bug#10247334
1692 /* forall i in 1..g_array_event_id.count
1693  -- added the hint for bug:7560587
1694  */
1695 --update /*+ index(ael,XLA_AE_LINES_GT_N4) */ xla_ae_lines_gt  ael
1696 /*set ae_header_id = g_array_ae_header_id(i)
1697    ,ref_ae_header_id = DECODE(ref_event_id,NULL,g_array_ae_header_id(i),ref_ae_header_id)
1698 */
1699 /* Calling get_hash_value for each row is expensive.
1700    Moved the columns to the select statement to retrieve ae_line_num.
1701 
1702    ,line_hash_num =
1703 DBMS_UTILITY.GET_HASH_VALUE
1704         (ae_header_id
1705         ||gl_transfer_mode_code
1706         ||accounting_class_code
1707         ||rounding_class_code
1708         ||document_rounding_level
1709         ||currency_code
1710         ||currency_conversion_type
1711         ||currency_conversion_date
1712         ||currency_conversion_rate
1713         ||party_id
1714         ||party_site_id
1715         ||party_type_code
1716         ||code_combination_id
1717         ||code_combination_status_code
1718         ||segment1
1719         ||segment2
1720         ||segment3
1721         ||segment4
1722         ||segment5
1723         ||segment6
1724         ||segment7
1725         ||segment8
1726         ||segment9
1727         ||segment10
1728         ||segment11
1729         ||segment12
1730         ||segment13
1731         ||segment14
1732         ||segment15
1733         ||segment16
1734         ||segment17
1735         ||segment18
1736         ||segment19
1737         ||segment20
1738         ||segment21
1739         ||segment22
1740         ||segment23
1741         ||segment24
1742         ||segment25
1743         ||segment26
1744         ||segment27
1745         ||segment28
1746         ||segment29
1747         ||segment30
1748         ||alt_code_combination_id
1749         ||alt_ccid_status_code
1750         ||alt_segment1
1751         ||alt_segment2
1752         ||alt_segment3
1753         ||alt_segment4
1754         ||alt_segment5
1755         ||alt_segment6
1756         ||alt_segment7
1757         ||alt_segment8
1758         ||alt_segment9
1759         ||alt_segment10
1760         ||alt_segment11
1761         ||alt_segment12
1762         ||alt_segment13
1763         ||alt_segment14
1764         ||alt_segment15
1765         ||alt_segment16
1766         ||alt_segment17
1767         ||alt_segment18
1768         ||alt_segment19
1769         ||alt_segment20
1770         ||alt_segment21
1771         ||alt_segment22
1772         ||alt_segment23
1773         ||alt_segment24
1774         ||alt_segment25
1775         ||alt_segment26
1776         ||alt_segment27
1777         ||alt_segment28
1778         ||alt_segment29
1779         ||alt_segment30
1780         ||description
1781         ||jgzz_recon_ref
1782         ||ussgl_transaction_code
1783         ||merge_duplicate_code
1784         ||line_definition_owner_code
1785         ||line_definition_code
1786         ||business_class_code
1787         ||mpa_accrual_entry_flag
1788         ||encumbrance_type_id,
1789        1,
1790        1073741824)
1791 */
1792 /*   , merge_index = CASE accounting_class_code
1793                    WHEN 'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY' THEN -1
1794                    ELSE
1795                      CASE nvl(code_combination_id,0)
1796                      WHEN -1 THEN temp_line_num
1797                      ELSE CASE nvl(alt_code_combination_id,0)
1798                          WHEN -1 THEN temp_line_num
1799                          ELSE
1800                           CASE merge_duplicate_code
1801                             WHEN 'A' THEN
1802                               CASE switch_side_flag
1803                               WHEN 'Y' THEN -1
1804                               ELSE
1805                                 CASE
1806                                   WHEN unrounded_accounted_cr is null THEN -2
1807                                   ELSE -3
1808                                 END
1809                               END
1810                             WHEN 'W' THEN
1811                                CASE
1812                                  WHEN unrounded_accounted_cr is null THEN -2
1813                                  ELSE -3
1814                                END
1815                             WHEN 'N' THEN temp_line_num
1816                            END
1817                          END
1818                       END
1819                     END
1820   */  /* CASE merge_duplicate_code
1821                     WHEN 'A' THEN
1822                       CASE switch_side_flag
1823                        WHEN 'Y' THEN -1
1824                        ELSE
1825                          CASE
1826                           WHEN accounted_cr is null THEN -2
1827                           ELSE -3
1828                          END
1829                        END
1830                     WHEN 'W' THEN
1831                       CASE
1832                        WHEN accounted_cr is null THEN -2
1833                        ELSE -3
1834                       END
1835                     WHEN 'N' THEN temp_line_num
1836                    END*/
1837 /*where ae_header_id = g_array_event_id(i)
1838   and event_id = g_array_event_id(i)
1839   and ledger_id = g_array_ledger_id(i)
1840   and balance_type_code = g_array_balance_type(i)
1841 */--
1842   -- Bug 4719297 added NVL to the following.
1843   --
1844 -- 4669308 NVL(-1) creates a separate header for MPA reversal. NVL(0) combines original reversal and MPA reversal into 1 header
1845 --         Also, this was causing XLA_AE_LINES_U1 error
1846 --and nvl(header_num,-1) = nvl(g_array_header_num(i),-1)
1847 /*  and     header_num     = nvl(g_array_header_num(i), 0);  -- 5100860 instead of nvl(header_num, 0) */
1848 --and temp_line_num <> 0;                                  -- 5100860 should never be zero
1849 
1850 --added the below MERGE Update for bug#10247334
1851  merge /*+ use_hash(xal) */ into xla_ae_lines_gt XAL
1852  using xla_ae_headers_gt xah
1853  on (
1854       xal.event_id = xah.event_id
1855  and  xal.ledger_id = xah.ledger_id
1856  and  xal.balance_type_code = xah.balance_type_code
1857  and  xal.header_num = NVL(xah.header_num,0)
1858  )
1859  when matched then
1860  update set XAL.ae_header_id = XAH.ae_header_id
1861         ,   XAL.ref_ae_header_id  = DECODE( XAL.ref_event_id,NULL,XAH.ae_header_id,XAL.ref_ae_header_id )
1862         ,   XAL.merge_index = CASE xal.accounting_class_code
1863                               WHEN 'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY' THEN -1
1864                               ELSE
1865                      		CASE nvl(xal.code_combination_id,0)
1866                      		WHEN -1 THEN xal.temp_line_num
1867                      		ELSE CASE nvl( xal.alt_code_combination_id,0 )
1868                          	     WHEN -1 THEN xal.temp_line_num
1869                          	     ELSE
1870                           		CASE xal.merge_duplicate_code
1871                             		WHEN 'A' THEN
1872                               		   CASE xal.switch_side_flag
1873                               		   WHEN 'Y' THEN -1
1874                               		   ELSE
1875                                 	      CASE
1876                                  	 	WHEN xal.unrounded_accounted_cr is null THEN -2
1877                                                 ELSE -3
1878                                               END
1879                                            END
1880                                         WHEN 'W' THEN
1881                                            CASE
1882                                            WHEN xal.unrounded_accounted_cr is null THEN -2
1883                                            ELSE -3
1884                                            END
1885                                         WHEN 'N' THEN xal.temp_line_num
1886                                         END
1887                                      END
1888                                 END
1889                               END ;
1890 
1891 end if;
1892 
1893    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1894 
1895       trace
1896          (p_msg      => 'SQL - Update xla_ae_lines_gt 2: '||SQL%ROWCOUNT
1897          ,p_level    => C_LEVEL_STATEMENT
1898          ,p_module   => l_log_module);
1899 
1900    END IF;
1901 
1902    UpdateLineNumber;
1903 
1904 -- 4262811 ------------------------------------------------------------------
1905    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1906 
1907       trace
1908          (p_msg      => 'SQL - Update xla_ae_lines_gt 3.5'
1909          ,p_level    => C_LEVEL_STATEMENT
1910          ,p_module   => l_log_module);
1911 
1912    END IF;
1913 
1914 ----------------------------------------------------------
1915 -- Populate the parent_ae_line_num by the real ae_line_num
1916 ----------------------------------------------------------
1917 /* PROBLEM: incorrectly sets parent_ae_line_num to NULL
1918 forall i in 1..l_array_rowid.count
1919 update xla_ae_headers_gt h
1920    set parent_ae_line_num =
1921        (select l_array_ae_line_num(i)
1922           from xla_ae_lines_gt l
1923          where h.parent_header_id    = l.event_id   -- awan l.ae_header_id no rows
1924            and h.ledger_id           = l.ledger_id
1925            and h.balance_type_code   = l.balance_type_code
1926            and h.event_id            = l.event_id
1927            and l.header_num          = 0
1928            and l.rowid               = l_array_rowid(i))
1929  where parent_ae_line_num IS NOT NULL;
1930 */
1931   -- IF l_array_rowid.count > 0 THEN      commented IF for 7230462
1932       UPDATE xla_ae_headers_gt h
1933       SET    parent_ae_line_num =
1934           (SELECT /*+ index(L XLA_AE_LINES_GT_U1)  */ ae_line_num --Index added for bug 14246749
1935              FROM xla_ae_lines_gt l
1936             WHERE h.parent_header_id    = l.event_id   -- awan l.ae_header_id no rows
1937               AND h.ledger_id           = l.ledger_id
1938               AND h.balance_type_code   = l.balance_type_code
1939               AND h.event_id            = l.event_id
1940               AND h.event_id            = l.event_id
1941               AND h.parent_ae_line_num  = l.temp_line_num
1942               AND l.header_num          = 0)
1943       WHERE parent_ae_line_num IS NOT NULL;
1944   -- END IF;
1945 
1946 -----------------------------------------------------------------------------
1947 
1948    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1949 
1950       trace
1951          (p_msg      => 'SQL - Update xla_ae_lines_gt 4'
1952          ,p_level    => C_LEVEL_STATEMENT
1953          ,p_module   => l_log_module);
1954 
1955    END IF;
1956 
1957 UPDATE xla_ae_lines_gt  ael
1958    SET (ref_ae_header_id, ref_temp_line_num) =
1959           (SELECT ae_header_id, temp_line_num
1960              FROM xla_ae_lines_gt
1961             WHERE event_id = ael.ref_event_id
1962               AND ledger_id = ael.ledger_id
1963               AND balance_type_code = ael.balance_type_code
1964               AND temp_line_num = ael.temp_line_num * -1)
1965  WHERE ref_event_id IS NOT NULL
1966    AND ref_temp_line_num IS NULL;
1967 
1968    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1969       trace
1970          (p_msg      => 'SQL - Update xla_ae_lines_gt 5'
1971          ,p_level    => C_LEVEL_STATEMENT
1972          ,p_module   => l_log_module);
1973    END IF;
1974 
1975 -- added the follwing update to correct REF_AE_HEADER_ID when ORIGINAL AND REVERSAL EVENTS
1976 -- are accounted in the same batch for bug:8277823
1977 -- commented the following code for performance issues faced in bug: 8619700
1978 /*
1979 UPDATE xla_ae_lines_gt  ael
1980    SET ael.ref_event_id     = -1 * ael.ref_event_id
1981      , ael.ref_ae_header_id =
1982                              ( SELECT lgt.ae_header_id
1983                                FROM  xla_ae_lines_gt lgt
1984                                WHERE lgt.event_id = -1 * ael.ref_event_id
1985                                AND   lgt.ledger_id = ael.ledger_id
1986                                AND   lgt.balance_type_code = ael.balance_type_code
1987                                AND   lgt.temp_line_num = ael.temp_line_num * -1
1988 			    )
1989  WHERE ael.ref_event_id < 0
1990    AND ael.temp_line_num < 0
1991    AND ael.reversal_code = 'REVERSAL' ;
1992 */
1993 -- added the following code for performance issues faced in bug:8619700
1994 -- added hint for perf bug9630931
1995    forall i in 1..g_array_event_id.count
1996    UPDATE /*+ INDEX(ael XLA_AE_LINES_GT_U1) */  XLA_AE_LINES_GT AEL
1997        SET AEL.REF_EVENT_ID = -1 * AEL.REF_EVENT_ID ,
1998            AEL.REF_AE_HEADER_ID =  g_array_ae_header_id(i)
1999    WHERE AEL.REF_AE_HEADER_ID = g_array_event_id(i)
2000    AND   AEL.REF_EVENT_ID = -1 * g_array_event_id(i)
2001    AND   AEL.TEMP_LINE_NUM < 0
2002    AND   AEL.LEDGER_ID = g_array_ledger_id(i)
2003    AND   AEL.BALANCE_TYPE_CODE = g_array_balance_type(i)
2004    AND   AEL.REVERSAL_CODE = 'REVERSAL'
2005    AND   AEL.HEADER_NUM = NVL( g_array_header_num(i) , 0) ;
2006 
2007    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2008       trace
2009          (p_msg      => 'SQL - Update xla_ae_lines_gt 5_1 for ReversalEvents '|| SQL%ROWCOUNT
2010          ,p_level    => C_LEVEL_STATEMENT
2011          ,p_module   => l_log_module);
2012    END IF;
2013 
2014    -- end of changes for bug: 8277823
2015 
2016 -- start changes for bug 14603435
2017 
2018  For i in 1..l_ledger_attrs.array_ledger_id.COUNT LOOP
2019     bsv_segment_name := xla_accounting_cache_pkg.GetValueChar('BAL_SEG_COLUMN_NAME',l_ledger_attrs.array_ledger_id(i));
2020     l_case_sql := l_case_sql || ' WHEN ledger_id = ' || l_ledger_attrs.array_ledger_id(i) ||'  THEN gcc.' ||  bsv_segment_name ;
2021   END LOOP    ;
2022      l_case_sql := ' , CASE ' || l_case_sql || ' END ' ;
2023 
2024   l_sql :=    ' SELECT max(xalg.rowid) '||
2025     '   ,rounding_class_code '||
2026     '   ,document_rounding_level '||
2027     '   ,NVL(SUM(unrounded_accounted_cr), 0) '||
2028     '            - NVL(SUM(unrounded_accounted_dr), 0) unrounded_amount '||
2029     '   ,ledger_id '||
2030     '   ,ae_header_id '||
2031 	    l_case_sql || ' bsv_value   '||
2032     '   ,NVL(SUM(unrounded_entered_cr), 0) '||
2033     '            - NVL(SUM(unrounded_entered_dr), 0) unrounded_entered_amount '||
2034     '   ,entered_currency_mau '||
2035     ' FROM   xla_ae_lines_gt xalg '||
2036     '        , gl_code_combinations gcc '||
2037     ' WHERE temp_line_num <> 0 '||
2038     ' and gcc.code_combination_id = xalg.code_combination_id '||
2039     ' GROUP BY ledger_id, event_id, ae_header_id, '||
2040     '     rounding_class_code, document_rounding_level ' || l_case_sql ||' , ae_line_num '||
2041     '     ,entered_currency_mau '||
2042     ' HAVING     document_rounding_level is not null '||
2043     '       AND rounding_class_code is not null '||
2044     ' ORDER BY 5 , 6 , 7 , 3, 2 ' ;
2045 
2046 
2047    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2048          trace
2049             (p_msg      => 'l_case_sql: '|| l_case_sql
2050             ,p_level    => C_LEVEL_STATEMENT
2051             ,p_module   => l_log_module);
2052 
2053 		 trace
2054             (p_msg      => 'l_sql: '|| l_sql
2055             ,p_level    => C_LEVEL_STATEMENT
2056             ,p_module   => l_log_module);
2057     END IF;
2058 
2059   -- open csr_rounding_lines;
2060   open c_rounding  for l_sql;
2061 
2062 -- end changes for bug 14603435
2063   j:=1;
2064 /*
2065   l_curr_rounding_class_code := l_array_rounding_class_code(1);
2066   l_curr_doc_rounding_level := l_array_doc_rounding_level(1);
2067   l_curr_total_unrounded :=0;
2068   l_curr_total_rounded :=0;
2069   l_curr_max_rowid := l_array_rowid(1);
2070   l_curr_max_amount := ABS(l_array_unrounded_amount(1));
2071   l_curr_ledger_id :=l_array_ledger_id(1);
2072   l_curr_header_id :=l_array_header_id(1);
2073   l_curr_mau := l_array_mau(l_curr_ledger_id);
2074   l_curr_offset := l_array_rounding_offset(l_curr_ledger_id);
2075 */
2076   l_curr_rounding_class_code := null;
2077   l_curr_doc_rounding_level := null;
2078   l_curr_total_unrounded :=null;
2079   l_curr_total_rounded :=null;
2080   l_curr_max_rowid :=null;
2081   l_curr_max_amount := null;
2082   l_curr_ledger_id :=null;
2083   l_curr_header_id :=null;
2084   l_curr_mau := null;
2085   l_curr_entd_mau := null;
2086   l_curr_offset := null;
2087   l_curr_entd_rounding_amount := null;
2088   l_curr_entd_total_unrounded :=null;
2089   l_curr_entd_total_rounded :=null;
2090    l_curr_bsv_value := null ;  -- change for bug 14603435
2091 
2092 LOOP
2093   FETCH c_rounding  -- change for bug 14603435
2094   BULK COLLECT INTO l_array_rowid
2095                  ,l_array_rounding_class_code
2096                  ,l_array_doc_rounding_level
2097                  ,l_array_unrounded_amount
2098                  ,l_array_ledger_id
2099                  ,l_array_header_id
2100 		  ,l_array_bsv_value  -- change for bug 14603435
2101                  ,l_array_unrounded_entd_amount
2102                  ,l_array_entd_mau
2103   LIMIT C_BULK_LIMIT;
2104 
2105   IF(l_array_rounding_class_code.COUNT=0) THEN
2106     EXIT;
2107   END IF;
2108   IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2109       trace
2110          (p_msg      => 'SQL - Update xla_ae_lines_gt 6'
2111          ,p_level    => C_LEVEL_STATEMENT
2112          ,p_module   => l_log_module);
2113       trace
2114          (p_msg      => 'count:'||to_char(l_array_rounding_class_code.count)
2115          ,p_level    => C_LEVEL_STATEMENT
2116          ,p_module   => l_log_module);
2117   END IF;
2118 
2119   FOR Idx IN l_array_rounding_class_code.FIRST .. l_array_rounding_class_code.LAST LOOP
2120     IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2121       trace
2122          (p_msg      => 'Ixd:'||to_char(Idx) ||' rounding class code:'||l_array_rounding_class_code(Idx) || ' rounding level:'||l_array_doc_rounding_level(Idx)
2123                            || ' ledgerid:'||to_char(l_array_ledger_id(Idx))||' unrounded:'|| to_char(l_curr_total_unrounded)
2124                            ||' rounded:'|| to_char(l_curr_total_rounded)
2125          ,p_level    => C_LEVEL_STATEMENT
2126          ,p_module   => l_log_module);
2127       trace
2128          (p_msg      => 'amount:'||to_char(l_array_unrounded_amount(Idx))||'curr mau:'||to_char(l_curr_mau)||' curr offset:'||to_char(l_curr_offset)
2129          ,p_level    => C_LEVEL_STATEMENT
2130          ,p_module   => l_log_module);
2131 	 -- start changes for bug 14603435
2132 		  trace(p_msg      => 'bsv_value:'||l_array_bsv_value(Idx)
2133          ,p_level    => C_LEVEL_STATEMENT
2134          ,p_module   => l_log_module);
2135 	 -- end changes for bug 14603435
2136       trace
2137          (p_msg      => 'cur rounding class code:'||l_curr_rounding_class_code || ' rounding level:'||l_curr_doc_rounding_level || ' ledgerid:'||to_char(l_curr_ledger_id)
2138          ,p_level    => C_LEVEL_STATEMENT
2139          ,p_module   => l_log_module);
2140       trace
2141          (p_msg      => ' unrounded entered:'|| to_char(l_curr_entd_total_unrounded)
2142                            ||' rounded entered:'|| to_char(l_curr_entd_total_rounded)
2143                            ||' amount:'|| to_char(l_array_unrounded_entd_amount(Idx))
2144                            ||' mau:'|| to_char(l_array_entd_mau(Idx))
2145          ,p_level    => C_LEVEL_STATEMENT
2146          ,p_module   => l_log_module);
2147     END IF;
2148 
2149     IF(l_array_rounding_class_code(Idx) = l_curr_rounding_class_code
2150          AND l_array_doc_rounding_level(Idx) = l_curr_doc_rounding_level
2151          AND  l_array_header_id(Idx) = l_curr_header_id
2152          AND  l_array_ledger_id(Idx) = l_curr_ledger_id
2153 	  AND  l_array_bsv_value(Idx) = l_curr_bsv_value ) THEN -- change for bug 14603435
2154       l_curr_total_unrounded:= l_curr_total_unrounded + l_array_unrounded_amount(Idx);
2155       l_curr_total_rounded:= l_curr_total_rounded
2156              + ROUND( l_array_unrounded_amount(Idx)/l_curr_mau + l_curr_offset)
2157              *l_curr_mau;
2158       l_curr_entd_total_unrounded:= l_curr_entd_total_unrounded + l_array_unrounded_entd_amount(Idx);
2159       l_curr_entd_total_rounded:= l_curr_entd_total_rounded
2160              + ROUND( l_array_unrounded_entd_amount(Idx)/l_array_entd_mau(Idx)+ l_curr_offset)
2161              *l_array_entd_mau(Idx);
2162       IF(l_curr_max_amount < ABS(l_array_unrounded_amount(Idx))) THEN
2163         l_curr_max_amount := ABS(l_array_unrounded_amount(Idx));
2164         l_curr_max_rowid := l_array_rowid(Idx);
2165       END IF;
2166     ELSE
2167       IF(l_curr_total_unrounded is not null) THEN
2168         l_curr_doc_rounding_amount :=
2169              ROUND(l_curr_total_unrounded/l_curr_mau + l_curr_offset)
2170              *l_curr_mau -l_curr_total_rounded;
2171         l_curr_entd_rounding_amount :=
2172              ROUND(l_curr_entd_total_unrounded/l_curr_entd_mau + l_curr_offset)
2173              *l_curr_entd_mau -l_curr_entd_total_rounded;
2174         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2175            trace
2176             (p_msg      => 'doc rounding is:'||to_char(l_curr_doc_rounding_amount)
2177                            ||' unrounded:'|| to_char(l_curr_total_unrounded)
2178                            ||' rounded:'|| to_char(l_curr_total_rounded)
2179             ,p_level    => C_LEVEL_STATEMENT
2180             ,p_module   => l_log_module);
2181            trace
2182             (p_msg      => 'entd rounding is:'||to_char(l_curr_entd_rounding_amount)
2183                            ||' unrounded:'|| to_char(l_curr_entd_total_unrounded)
2184                            ||' rounded:'|| to_char(l_curr_entd_total_rounded)
2185             ,p_level    => C_LEVEL_STATEMENT
2186             ,p_module   => l_log_module);
2187         END IF;
2188         IF(l_curr_doc_rounding_amount <>0 or l_curr_entd_rounding_amount <> 0) THEN
2189           l_array_rowid1(j):= l_curr_max_rowid;
2190           l_array_doc_rounding_amt1(j) := l_curr_doc_rounding_amount;
2191           l_array_rounding_entd_amt1(j) := l_curr_entd_rounding_amount;
2192           j:= j+1;
2193           IF (j> C_BULK_LIMIT) THEN
2194             FORALL i in 1..j-1
2195               update xla_ae_lines_gt
2196               set doc_rounding_acctd_amt = l_array_doc_rounding_amt1(i)
2197                  ,doc_rounding_entered_amt = l_array_rounding_entd_amt1(i)
2198               where rowid = l_array_rowid1(i);
2199             j:=1;
2200           END IF;
2201         END IF;
2202       END IF;
2203       IF(l_curr_ledger_id is null or
2204              l_curr_ledger_id <> l_array_ledger_id(Idx)) THEN
2205         l_curr_ledger_id :=l_array_ledger_id(Idx);
2206         l_curr_mau := l_array_mau(l_curr_ledger_id);
2207         l_curr_offset := l_array_rounding_offset(l_curr_ledger_id);
2208       END IF;
2209        l_curr_bsv_value := l_array_bsv_value(Idx); -- change for bug 14603435
2210       l_curr_entd_mau:=l_array_entd_mau(Idx);
2211       l_curr_header_id :=l_array_header_id(Idx);
2212       l_curr_rounding_class_code := l_array_rounding_class_code(Idx);
2213       l_curr_doc_rounding_level := l_array_doc_rounding_level(Idx);
2214       l_curr_total_unrounded:= l_array_unrounded_amount(Idx);
2215       l_curr_total_rounded:=
2216              ROUND( l_array_unrounded_amount(Idx)/l_curr_mau + l_curr_offset)
2217              *l_curr_mau;
2218       l_curr_entd_total_unrounded:= l_array_unrounded_entd_amount(Idx);
2219         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2220            trace
2221             (p_msg      => '----l_curr_entd_total_rounded:'||to_char(l_curr_entd_total_rounded)
2222                            ||' l_array_unrounded_entd_amount(Idx):'|| to_char(l_array_unrounded_entd_amount(Idx))
2223                            ||' l_curr_entd_mau:'|| to_char(l_curr_entd_mau)
2224                            ||'l_curr_offset :'|| to_char(l_curr_offset)
2225             ,p_level    => C_LEVEL_STATEMENT
2226             ,p_module   => l_log_module);
2227         END IF;
2228       l_curr_entd_total_rounded:=
2229              ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)
2230              *l_curr_entd_mau;
2231         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2232            trace
2233             (p_msg      => '----l_curr_entd_total_rounded:'||to_char(l_curr_entd_total_rounded)
2234                            ||' l_array_unrounded_entd_amount(Idx):'|| to_char(l_array_unrounded_entd_amount(Idx))
2235                            ||' l_curr_entd_mau:'|| to_char(l_curr_entd_mau)
2236                            ||'l_curr_offset :'|| to_char(l_curr_offset)
2237             ,p_level    => C_LEVEL_STATEMENT
2238             ,p_module   => l_log_module);
2239            trace
2240             (p_msg      => '----test:'||to_char(l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau)
2241                            ||' :'|| to_char(l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)
2242                            ||' :'|| to_char(ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset))
2243                            ||':'|| to_char(ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)*l_curr_entd_mau)
2244             ,p_level    => C_LEVEL_STATEMENT
2245             ,p_module   => l_log_module);
2246         END IF;
2247       l_curr_max_rowid := l_array_rowid(Idx);
2248       l_curr_max_amount := ABS(l_array_unrounded_amount(Idx));
2249     END IF;
2250   END LOOP;
2251 END LOOP;
2252 -- process the last one
2253 IF(l_curr_total_unrounded is not null) THEN
2254   l_curr_doc_rounding_amount :=
2255              ROUND(l_curr_total_unrounded/l_curr_mau + l_curr_offset)
2256              *l_curr_mau -l_curr_total_rounded;
2257   l_curr_entd_rounding_amount :=
2258              ROUND(l_curr_entd_total_unrounded/l_curr_entd_mau + l_curr_offset)
2259              *l_curr_entd_mau -l_curr_entd_total_rounded;
2260   IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2261          trace
2262             (p_msg      => 'doc rounding is:'||to_char(l_curr_doc_rounding_amount)
2263                            ||' unrounded:'|| to_char(l_curr_total_unrounded)
2264                            ||' rounded:'|| to_char(l_curr_total_rounded)
2265             ,p_level    => C_LEVEL_STATEMENT
2266             ,p_module   => l_log_module);
2267   END IF;
2268 END IF;
2269 IF(l_curr_doc_rounding_amount <>0  or l_curr_entd_rounding_amount <> 0) THEN
2270   l_array_rowid1(j):= l_curr_max_rowid;
2271   l_array_doc_rounding_amt1(j) := l_curr_doc_rounding_amount;
2272   l_array_rounding_entd_amt1(j) := l_curr_entd_rounding_amount;
2273   j:= j+1;
2274 END IF;
2275 
2276 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2277     trace
2278          (p_msg      => 'SQL - Update xla_ae_lines_gt 7, j='||to_char(j)
2279          ,p_level    => C_LEVEL_STATEMENT
2280          ,p_module   => l_log_module);
2281 END IF;
2282 
2283 IF j>1 THEN
2284   FORALL i in 1..j-1
2285     update xla_ae_lines_gt
2286     set doc_rounding_acctd_amt = l_array_doc_rounding_amt1(i)
2287        ,doc_rounding_entered_amt = l_array_rounding_entd_amt1(i)
2288     where rowid = l_array_rowid1(i);
2289 END IF;
2290 
2291 EXCEPTION
2292 WHEN OTHERS  THEN
2293 
2294   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
2295          trace
2296             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
2297             ,p_level    => C_LEVEL_EXCEPTION
2298             ,p_module   => l_log_module);
2299   END IF;
2300 
2301   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
2302                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
2303                                     ,p_token_1      => 'ERROR'
2304                                     ,p_value_1      => sqlerrm
2305                                     );
2306 END;
2307 
2308 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2309 
2310       trace
2311          (p_msg      => 'END of GetLineNumber'
2312          ,p_level    => C_LEVEL_PROCEDURE
2313          ,p_module   => l_log_module);
2314 END IF;
2315 
2316 EXCEPTION
2317 WHEN xla_exceptions_pkg.application_exception THEN
2318   RAISE;
2319 WHEN OTHERS  THEN
2320   xla_exceptions_pkg.raise_message
2321                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetLineNumber');
2322 END GetLineNumber;
2323 
2324 PROCEDURE UpdateLineNumber IS
2325 
2326    l_line_ac_count      PLS_INTEGER;
2327    l_log_module         VARCHAR2(240);
2328 
2329 BEGIN
2330 
2331    IF g_log_enabled THEN
2332       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber0';
2333    END IF;
2334    --
2335    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2336 
2337       trace
2338          (p_msg      => 'BEGIN of UpdateLineNumber0'
2339          ,p_level    => C_LEVEL_PROCEDURE
2340          ,p_module   => l_log_module);
2341 
2342    END IF;
2343 
2344    l_line_ac_count := xla_analytical_criteria_pkg.get_line_ac_count;
2345 
2346    IF l_line_ac_count = 0 THEN
2347 
2348       UpdateLineNumber0;
2349 
2350    ELSIF l_line_ac_count <= 10 THEN
2351 
2352       UpdateLineNumber10;
2353 
2354    ELSIF l_line_ac_count <= 50 THEN
2355 
2356       UpdateLineNumber50;
2357 
2358    ELSIF l_line_ac_count <= 100 THEN
2359 
2360       UpdateLineNumber100;
2361 
2362    END IF;
2363 
2364    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2365 
2366       trace
2367          (p_msg      => 'END of UpdateLineNumber'
2368          ,p_level    => C_LEVEL_PROCEDURE
2369          ,p_module   => l_log_module);
2370    END IF;
2371 
2372 EXCEPTION
2373 WHEN xla_exceptions_pkg.application_exception THEN
2374   RAISE;
2375 WHEN OTHERS  THEN
2376   xla_exceptions_pkg.raise_message
2377                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber');
2378 END UpdateLineNumber;
2379 
2380 
2381 PROCEDURE UpdateLineNumber0 IS
2382 
2383    l_array_rowid        t_array_rowid;
2384    l_array_ae_line_num  t_array_Num;
2385 
2386    l_log_module         VARCHAR2(240);
2387 
2388 BEGIN
2389 
2390    IF g_log_enabled THEN
2391       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber0';
2392    END IF;
2393    --
2394    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2395 
2396       trace
2397          (p_msg      => 'BEGIN of UpdateLineNumber0'
2398          ,p_level    => C_LEVEL_PROCEDURE
2399          ,p_module   => l_log_module);
2400 
2401    END IF;
2402 
2403    SELECT ROWID
2404          ,DENSE_RANK() OVER
2405           (PARTITION BY ae_header_id
2406                ORDER BY ae_header_id
2407                        ,gl_transfer_mode_code
2408                        ,accounting_class_code
2409 		       ,event_type_code
2410                        ,rounding_class_code
2411                        ,document_rounding_level
2412                        ,currency_code
2413                        ,currency_conversion_type
2414                        ,currency_conversion_date
2415                        ,currency_conversion_rate
2416                        ,party_id
2417                        ,party_site_id
2418                        ,party_type_code
2419                        ,code_combination_id
2420                        ,code_combination_status_code
2421                        ,segment1
2422                        ,segment2
2423                        ,segment3
2424                        ,segment4
2425                        ,segment5
2426                        ,segment6
2427                        ,segment7
2428                        ,segment8
2429                        ,segment9
2430                        ,segment10
2431                        ,segment11
2432                        ,segment12
2433                        ,segment13
2434                        ,segment14
2435                        ,segment15
2436                        ,segment16
2437                        ,segment17
2438                        ,segment18
2439                        ,segment19
2440                        ,segment20
2441                        ,segment21
2442                        ,segment22
2443                        ,segment23
2444                        ,segment24
2445                        ,segment25
2446                        ,segment26
2447                        ,segment27
2448                        ,segment28
2449                        ,segment29
2450                        ,segment30
2451                        ,alt_code_combination_id
2452                        ,alt_ccid_status_code
2453                        ,alt_segment1
2454                        ,alt_segment2
2455                        ,alt_segment3
2456                        ,alt_segment4
2457                        ,alt_segment5
2458                        ,alt_segment6
2459                        ,alt_segment7
2460                        ,alt_segment8
2461                        ,alt_segment9
2462                        ,alt_segment10
2463                        ,alt_segment11
2464                        ,alt_segment12
2465                        ,alt_segment13
2466                        ,alt_segment14
2467                        ,alt_segment15
2468                        ,alt_segment16
2469                        ,alt_segment17
2470                        ,alt_segment18
2471                        ,alt_segment19
2472                        ,alt_segment20
2473                        ,alt_segment21
2474                        ,alt_segment22
2475                        ,alt_segment23
2476                        ,alt_segment24
2477                        ,alt_segment25
2478                        ,alt_segment26
2479                        ,alt_segment27
2480                        ,alt_segment28
2481                        ,alt_segment29
2482                        ,alt_segment30
2483                        ,description
2484                        ,jgzz_recon_ref
2485                        ,ussgl_transaction_code
2486                        ,merge_duplicate_code
2487                        ,line_definition_owner_code
2488                        ,line_definition_code
2489                        ,business_class_code
2490                        ,mpa_accrual_entry_flag
2491                        ,encumbrance_type_id
2492                        ,merge_index
2493 		       ,calculate_g_l_amts_flag
2494 		       ,entered_currency_mau)
2495 
2496                         ae_line_num
2497     BULK COLLECT
2498     INTO l_array_rowid
2499         ,l_array_ae_line_num
2500     FROM xla_ae_lines_gt
2501    WHERE temp_line_num <> 0;
2502 
2503    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2504 
2505       trace
2506          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
2507          ,p_level    => C_LEVEL_STATEMENT
2508          ,p_module   => l_log_module);
2509 
2510    END IF;
2511 
2512    FORALL i IN 1..l_array_rowid.COUNT
2513      UPDATE xla_ae_lines_gt
2514         SET ae_line_num = l_array_ae_line_num(i)
2515       WHERE rowid = l_array_rowid(i);
2516 
2517    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2518 
2519       trace
2520          (p_msg      => 'END of UpdateLineNumber0'
2521          ,p_level    => C_LEVEL_PROCEDURE
2522          ,p_module   => l_log_module);
2523    END IF;
2524 
2525 EXCEPTION
2526 WHEN xla_exceptions_pkg.application_exception THEN
2527   RAISE;
2528 WHEN OTHERS  THEN
2529   xla_exceptions_pkg.raise_message
2530                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber0');
2531 END UpdateLineNumber0;
2532 
2533 
2534 PROCEDURE UpdateLineNumber10 IS
2535 
2536    l_array_rowid        t_array_rowid;
2537    l_array_ae_line_num  t_array_Num;
2538 
2539    l_log_module         VARCHAR2(240);
2540 
2541 BEGIN
2542 
2543    IF g_log_enabled THEN
2544       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber10';
2545    END IF;
2546    --
2547    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2548 
2549       trace
2550          (p_msg      => 'BEGIN of UpdateLineNumber10'
2551          ,p_level    => C_LEVEL_PROCEDURE
2552          ,p_module   => l_log_module);
2553 
2554    END IF;
2555 
2556 SELECT ROWID
2557       ,DENSE_RANK() OVER
2558           (PARTITION BY ae_header_id
2559                ORDER BY ae_header_id
2560                        ,gl_transfer_mode_code
2561                        ,accounting_class_code
2562                        ,event_type_code
2563                        ,rounding_class_code
2564                        ,document_rounding_level
2565                        ,currency_code
2566                        ,currency_conversion_type
2567                        ,currency_conversion_date
2568                        ,currency_conversion_rate
2569                        ,party_id
2570                        ,party_site_id
2571                        ,party_type_code
2572                        ,code_combination_id
2573                        ,code_combination_status_code
2574                        ,segment1
2575                        ,segment2
2576                        ,segment3
2577                        ,segment4
2578                        ,segment5
2579                        ,segment6
2580                        ,segment7
2581                        ,segment8
2582                        ,segment9
2583                        ,segment10
2584                        ,segment11
2585                        ,segment12
2586                        ,segment13
2587                        ,segment14
2588                        ,segment15
2589                        ,segment16
2590                        ,segment17
2591                        ,segment18
2592                        ,segment19
2593                        ,segment20
2594                        ,segment21
2595                        ,segment22
2596                        ,segment23
2597                        ,segment24
2598                        ,segment25
2599                        ,segment26
2600                        ,segment27
2601                        ,segment28
2602                        ,segment29
2603                        ,segment30
2604                        ,alt_code_combination_id
2605                        ,alt_ccid_status_code
2606                        ,alt_segment1
2607                        ,alt_segment2
2608                        ,alt_segment3
2609                        ,alt_segment4
2610                        ,alt_segment5
2611                        ,alt_segment6
2612                        ,alt_segment7
2613                        ,alt_segment8
2614                        ,alt_segment9
2615                        ,alt_segment10
2616                        ,alt_segment11
2617                        ,alt_segment12
2618                        ,alt_segment13
2619                        ,alt_segment14
2620                        ,alt_segment15
2621                        ,alt_segment16
2622                        ,alt_segment17
2623                        ,alt_segment18
2624                        ,alt_segment19
2625                        ,alt_segment20
2626                        ,alt_segment21
2627                        ,alt_segment22
2628                        ,alt_segment23
2629                        ,alt_segment24
2630                        ,alt_segment25
2631                        ,alt_segment26
2632                        ,alt_segment27
2633                        ,alt_segment28
2634                        ,alt_segment29
2635                        ,alt_segment30
2636                        ,description
2637                        ,jgzz_recon_ref
2638                        ,ussgl_transaction_code
2639                        ,merge_duplicate_code
2640                        ,analytical_balance_flag
2641                        ,anc_id_1
2642                        ,anc_id_2
2643                        ,anc_id_3
2644                        ,anc_id_4
2645                        ,anc_id_5
2646                        ,anc_id_6
2647                        ,anc_id_7
2648                        ,anc_id_8
2649                        ,anc_id_9
2650                        ,anc_id_10
2651                        ,anc_id_11
2652                        ,anc_id_12
2653                        ,anc_id_13
2654                        ,anc_id_14
2655                        ,anc_id_15
2656                        ,anc_id_16
2657                        ,anc_id_17
2658                        ,anc_id_18
2659                        ,anc_id_19
2660                        ,anc_id_20
2661                        ,anc_id_21
2662                        ,anc_id_22
2663                        ,anc_id_23
2664                        ,anc_id_24
2665                        ,anc_id_25
2666                        ,anc_id_26
2667                        ,anc_id_27
2668                        ,anc_id_28
2669                        ,anc_id_29
2670                        ,anc_id_30
2671                        ,anc_id_31
2672                        ,anc_id_32
2673                        ,anc_id_33
2674                        ,anc_id_34
2675                        ,anc_id_35
2676                        ,anc_id_36
2677                        ,anc_id_37
2678                        ,anc_id_38
2679                        ,anc_id_39
2680                        ,anc_id_40
2681                        ,anc_id_41
2682                        ,anc_id_42
2683                        ,anc_id_43
2684                        ,anc_id_44
2685                        ,anc_id_45
2686                        ,anc_id_46
2687                        ,anc_id_47
2688                        ,anc_id_48
2689                        ,anc_id_49
2690                        ,anc_id_50
2691                        ,anc_id_51
2692                        ,anc_id_52
2693                        ,anc_id_53
2694                        ,anc_id_54
2695                        ,anc_id_55
2696                        ,anc_id_56
2697                        ,anc_id_57
2698                        ,anc_id_58
2699                        ,anc_id_59
2700                        ,anc_id_60
2701                        ,anc_id_61
2702                        ,anc_id_62
2703                        ,anc_id_63
2704                        ,anc_id_64
2705                        ,anc_id_65
2706                        ,anc_id_66
2707                        ,anc_id_67
2708                        ,anc_id_68
2709                        ,anc_id_69
2710                        ,anc_id_70
2711                        ,anc_id_71
2712                        ,anc_id_72
2713                        ,anc_id_73
2714                        ,anc_id_74
2715                        ,anc_id_75
2716                        ,anc_id_76
2717                        ,anc_id_77
2718                        ,anc_id_78
2719                        ,anc_id_79
2720                        ,anc_id_80
2721                        ,anc_id_81
2722                        ,anc_id_82
2723                        ,anc_id_83
2724                        ,anc_id_84
2725                        ,anc_id_85
2726                        ,anc_id_86
2727                        ,anc_id_87
2728                        ,anc_id_88
2729                        ,anc_id_89
2730                        ,anc_id_90
2731                        ,anc_id_91
2732                        ,anc_id_92
2733                        ,anc_id_93
2734                        ,anc_id_94
2735                        ,anc_id_95
2736                        ,anc_id_96
2737                        ,anc_id_97
2738                        ,anc_id_98
2739                        ,anc_id_99
2740                        ,anc_id_100
2741                        ,line_definition_owner_code
2742                        ,line_definition_code
2743                        ,business_class_code
2744                        ,mpa_accrual_entry_flag
2745                        ,encumbrance_type_id
2746                        ,merge_index
2747 		       ,calculate_g_l_amts_flag
2748 		       ,entered_currency_mau)
2749 
2750                         ae_line_num
2751 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
2752 FROM xla_ae_lines_gt
2753 WHERE temp_line_num <> 0;
2754 
2755    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2756 
2757       trace
2758          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
2759          ,p_level    => C_LEVEL_STATEMENT
2760          ,p_module   => l_log_module);
2761 
2762    END IF;
2763 
2764 forall i in 1..l_array_rowid.count
2765 update xla_ae_lines_gt
2766 set ae_line_num = l_array_ae_line_num(i)
2767 where rowid = l_array_rowid(i);
2768 
2769 
2770 
2771    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2772 
2773       trace
2774          (p_msg      => 'END of UpdateLineNumber10'
2775          ,p_level    => C_LEVEL_PROCEDURE
2776          ,p_module   => l_log_module);
2777    END IF;
2778 
2779 EXCEPTION
2780 WHEN xla_exceptions_pkg.application_exception THEN
2781   RAISE;
2782 WHEN OTHERS  THEN
2783   xla_exceptions_pkg.raise_message
2784                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber10');
2785 END UpdateLineNumber10;
2786 
2787 
2788 PROCEDURE UpdateLineNumber50 IS
2789 
2790    l_array_rowid        t_array_rowid;
2791    l_array_ae_line_num  t_array_Num;
2792 
2793    l_log_module         VARCHAR2(240);
2794 
2795 BEGIN
2796 
2797    IF g_log_enabled THEN
2798       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber50';
2799    END IF;
2800    --
2801    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2802 
2803       trace
2804          (p_msg      => 'BEGIN of UpdateLineNumber50'
2805          ,p_level    => C_LEVEL_PROCEDURE
2806          ,p_module   => l_log_module);
2807 
2808    END IF;
2809 
2810 SELECT ROWID
2811       ,DENSE_RANK() OVER
2812           (PARTITION BY ae_header_id
2813                ORDER BY ae_header_id
2814                        ,gl_transfer_mode_code
2815                        ,accounting_class_code
2816                        ,event_type_code
2817                        ,rounding_class_code
2818                        ,document_rounding_level
2819                        ,currency_code
2820                        ,currency_conversion_type
2821                        ,currency_conversion_date
2822                        ,currency_conversion_rate
2823                        ,party_id
2824                        ,party_site_id
2825                        ,party_type_code
2826                        ,code_combination_id
2827                        ,code_combination_status_code
2828                        ,segment1
2829                        ,segment2
2830                        ,segment3
2831                        ,segment4
2832                        ,segment5
2833                        ,segment6
2834                        ,segment7
2835                        ,segment8
2836                        ,segment9
2837                        ,segment10
2838                        ,segment11
2839                        ,segment12
2840                        ,segment13
2841                        ,segment14
2842                        ,segment15
2843                        ,segment16
2844                        ,segment17
2845                        ,segment18
2846                        ,segment19
2847                        ,segment20
2848                        ,segment21
2849                        ,segment22
2850                        ,segment23
2851                        ,segment24
2852                        ,segment25
2853                        ,segment26
2854                        ,segment27
2855                        ,segment28
2856                        ,segment29
2857                        ,segment30
2858                        ,alt_code_combination_id
2859                        ,alt_ccid_status_code
2860                        ,alt_segment1
2861                        ,alt_segment2
2862                        ,alt_segment3
2863                        ,alt_segment4
2864                        ,alt_segment5
2865                        ,alt_segment6
2866                        ,alt_segment7
2867                        ,alt_segment8
2868                        ,alt_segment9
2869                        ,alt_segment10
2870                        ,alt_segment11
2871                        ,alt_segment12
2872                        ,alt_segment13
2873                        ,alt_segment14
2874                        ,alt_segment15
2875                        ,alt_segment16
2876                        ,alt_segment17
2877                        ,alt_segment18
2878                        ,alt_segment19
2879                        ,alt_segment20
2880                        ,alt_segment21
2881                        ,alt_segment22
2882                        ,alt_segment23
2883                        ,alt_segment24
2884                        ,alt_segment25
2885                        ,alt_segment26
2886                        ,alt_segment27
2887                        ,alt_segment28
2888                        ,alt_segment29
2889                        ,alt_segment30
2890                        ,description
2891                        ,jgzz_recon_ref
2892                        ,ussgl_transaction_code
2893                        ,merge_duplicate_code
2894                        ,analytical_balance_flag
2895                        ,anc_id_1
2896                        ,anc_id_2
2897                        ,anc_id_3
2898                        ,anc_id_4
2899                        ,anc_id_5
2900                        ,anc_id_6
2901                        ,anc_id_7
2902                        ,anc_id_8
2903                        ,anc_id_9
2904                        ,anc_id_10
2905                        ,anc_id_11
2906                        ,anc_id_12
2907                        ,anc_id_13
2908                        ,anc_id_14
2909                        ,anc_id_15
2910                        ,anc_id_16
2911                        ,anc_id_17
2912                        ,anc_id_18
2913                        ,anc_id_19
2914                        ,anc_id_20
2915                        ,anc_id_21
2916                        ,anc_id_22
2917                        ,anc_id_23
2918                        ,anc_id_24
2919                        ,anc_id_25
2920                        ,anc_id_26
2921                        ,anc_id_27
2922                        ,anc_id_28
2923                        ,anc_id_29
2924                        ,anc_id_30
2925                        ,anc_id_31
2926                        ,anc_id_32
2927                        ,anc_id_33
2928                        ,anc_id_34
2929                        ,anc_id_35
2930                        ,anc_id_36
2931                        ,anc_id_37
2932                        ,anc_id_38
2933                        ,anc_id_39
2934                        ,anc_id_40
2935                        ,anc_id_41
2936                        ,anc_id_42
2937                        ,anc_id_43
2938                        ,anc_id_44
2939                        ,anc_id_45
2940                        ,anc_id_46
2941                        ,anc_id_47
2942                        ,anc_id_48
2943                        ,anc_id_49
2944                        ,anc_id_50
2945                        ,anc_id_51
2946                        ,anc_id_52
2947                        ,anc_id_53
2948                        ,anc_id_54
2949                        ,anc_id_55
2950                        ,anc_id_56
2951                        ,anc_id_57
2952                        ,anc_id_58
2953                        ,anc_id_59
2954                        ,anc_id_60
2955                        ,anc_id_61
2956                        ,anc_id_62
2957                        ,anc_id_63
2958                        ,anc_id_64
2959                        ,anc_id_65
2960                        ,anc_id_66
2961                        ,anc_id_67
2962                        ,anc_id_68
2963                        ,anc_id_69
2964                        ,anc_id_70
2965                        ,anc_id_71
2966                        ,anc_id_72
2967                        ,anc_id_73
2968                        ,anc_id_74
2969                        ,anc_id_75
2970                        ,anc_id_76
2971                        ,anc_id_77
2972                        ,anc_id_78
2973                        ,anc_id_79
2974                        ,anc_id_80
2975                        ,anc_id_81
2976                        ,anc_id_82
2977                        ,anc_id_83
2978                        ,anc_id_84
2979                        ,anc_id_85
2980                        ,anc_id_86
2981                        ,anc_id_87
2982                        ,anc_id_88
2983                        ,anc_id_89
2984                        ,anc_id_90
2985                        ,anc_id_91
2986                        ,anc_id_92
2987                        ,anc_id_93
2988                        ,anc_id_94
2989                        ,anc_id_95
2990                        ,anc_id_96
2991                        ,anc_id_97
2992                        ,anc_id_98
2993                        ,anc_id_99
2994                        ,anc_id_100
2995                        ,line_definition_owner_code
2996                        ,line_definition_code
2997                        ,business_class_code
2998                        ,mpa_accrual_entry_flag
2999                        ,encumbrance_type_id
3000                        ,merge_index
3001 		       ,calculate_g_l_amts_flag
3002 		       ,entered_currency_mau)
3003 
3004                         ae_line_num
3005 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
3006 FROM xla_ae_lines_gt
3007 WHERE temp_line_num <> 0;
3008 
3009    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3010 
3011       trace
3012          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
3013          ,p_level    => C_LEVEL_STATEMENT
3014          ,p_module   => l_log_module);
3015 
3016    END IF;
3017 
3018 forall i in 1..l_array_rowid.count
3019 update xla_ae_lines_gt
3020 set ae_line_num = l_array_ae_line_num(i)
3021 where rowid = l_array_rowid(i);
3022 
3023 
3024    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3025 
3026       trace
3027          (p_msg      => 'END of UpdateLineNumber50'
3028          ,p_level    => C_LEVEL_PROCEDURE
3029          ,p_module   => l_log_module);
3030 
3031    END IF;
3032 
3033 EXCEPTION
3034 WHEN xla_exceptions_pkg.application_exception THEN
3035   RAISE;
3036 WHEN OTHERS  THEN
3037   xla_exceptions_pkg.raise_message
3038                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber50');
3039 END UpdateLineNumber50;
3040 
3041 PROCEDURE UpdateLineNumber100 IS
3042 
3043    l_array_rowid        t_array_rowid;
3044    l_array_ae_line_num  t_array_Num;
3045 
3046    l_log_module         VARCHAR2(240);
3047 
3048 BEGIN
3049 
3050    IF g_log_enabled THEN
3051       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber100';
3052    END IF;
3053    --
3054    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3055 
3056       trace
3057          (p_msg      => 'BEGIN of UpdateLineNumber100'
3058          ,p_level    => C_LEVEL_PROCEDURE
3059          ,p_module   => l_log_module);
3060 
3061    END IF;
3062 
3063 SELECT ROWID
3064       ,DENSE_RANK() OVER
3065           (PARTITION BY ae_header_id
3066                ORDER BY ae_header_id
3067                        ,gl_transfer_mode_code
3068                        ,accounting_class_code
3069                        ,event_type_code
3070                        ,rounding_class_code
3071                        ,document_rounding_level
3072                        ,currency_code
3073                        ,currency_conversion_type
3074                        ,currency_conversion_date
3075                        ,currency_conversion_rate
3076                        ,party_id
3077                        ,party_site_id
3078                        ,party_type_code
3079                        ,code_combination_id
3080                        ,code_combination_status_code
3081                        ,segment1
3082                        ,segment2
3083                        ,segment3
3084                        ,segment4
3085                        ,segment5
3086                        ,segment6
3087                        ,segment7
3088                        ,segment8
3089                        ,segment9
3090                        ,segment10
3091                        ,segment11
3092                        ,segment12
3093                        ,segment13
3094                        ,segment14
3095                        ,segment15
3096                        ,segment16
3097                        ,segment17
3098                        ,segment18
3099                        ,segment19
3100                        ,segment20
3101                        ,segment21
3102                        ,segment22
3103                        ,segment23
3104                        ,segment24
3105                        ,segment25
3106                        ,segment26
3107                        ,segment27
3108                        ,segment28
3109                        ,segment29
3110                        ,segment30
3111                        ,alt_code_combination_id
3112                        ,alt_ccid_status_code
3113                        ,alt_segment1
3114                        ,alt_segment2
3115                        ,alt_segment3
3116                        ,alt_segment4
3117                        ,alt_segment5
3118                        ,alt_segment6
3119                        ,alt_segment7
3120                        ,alt_segment8
3121                        ,alt_segment9
3122                        ,alt_segment10
3123                        ,alt_segment11
3124                        ,alt_segment12
3125                        ,alt_segment13
3126                        ,alt_segment14
3127                        ,alt_segment15
3128                        ,alt_segment16
3129                        ,alt_segment17
3130                        ,alt_segment18
3131                        ,alt_segment19
3132                        ,alt_segment20
3133                        ,alt_segment21
3134                        ,alt_segment22
3135                        ,alt_segment23
3136                        ,alt_segment24
3137                        ,alt_segment25
3138                        ,alt_segment26
3139                        ,alt_segment27
3140                        ,alt_segment28
3141                        ,alt_segment29
3142                        ,alt_segment30
3143                        ,description
3144                        ,jgzz_recon_ref
3145                        ,ussgl_transaction_code
3146                        ,merge_duplicate_code
3147                        ,analytical_balance_flag
3148                        ,anc_id_1
3149                        ,anc_id_2
3150                        ,anc_id_3
3151                        ,anc_id_4
3152                        ,anc_id_5
3153                        ,anc_id_6
3154                        ,anc_id_7
3155                        ,anc_id_8
3156                        ,anc_id_9
3157                        ,anc_id_10
3158                        ,anc_id_11
3159                        ,anc_id_12
3160                        ,anc_id_13
3161                        ,anc_id_14
3162                        ,anc_id_15
3163                        ,anc_id_16
3164                        ,anc_id_17
3165                        ,anc_id_18
3166                        ,anc_id_19
3167                        ,anc_id_20
3168                        ,anc_id_21
3169                        ,anc_id_22
3170                        ,anc_id_23
3171                        ,anc_id_24
3172                        ,anc_id_25
3173                        ,anc_id_26
3174                        ,anc_id_27
3175                        ,anc_id_28
3176                        ,anc_id_29
3177                        ,anc_id_30
3178                        ,anc_id_31
3179                        ,anc_id_32
3180                        ,anc_id_33
3181                        ,anc_id_34
3182                        ,anc_id_35
3183                        ,anc_id_36
3184                        ,anc_id_37
3185                        ,anc_id_38
3186                        ,anc_id_39
3187                        ,anc_id_40
3188                        ,anc_id_41
3189                        ,anc_id_42
3190                        ,anc_id_43
3191                        ,anc_id_44
3192                        ,anc_id_45
3193                        ,anc_id_46
3194                        ,anc_id_47
3195                        ,anc_id_48
3196                        ,anc_id_49
3197                        ,anc_id_50
3198                        ,anc_id_51
3199                        ,anc_id_52
3200                        ,anc_id_53
3201                        ,anc_id_54
3202                        ,anc_id_55
3203                        ,anc_id_56
3204                        ,anc_id_57
3205                        ,anc_id_58
3206                        ,anc_id_59
3207                        ,anc_id_60
3208                        ,anc_id_61
3209                        ,anc_id_62
3210                        ,anc_id_63
3211                        ,anc_id_64
3212                        ,anc_id_65
3213                        ,anc_id_66
3214                        ,anc_id_67
3215                        ,anc_id_68
3216                        ,anc_id_69
3217                        ,anc_id_70
3218                        ,anc_id_71
3219                        ,anc_id_72
3220                        ,anc_id_73
3221                        ,anc_id_74
3222                        ,anc_id_75
3223                        ,anc_id_76
3224                        ,anc_id_77
3225                        ,anc_id_78
3226                        ,anc_id_79
3227                        ,anc_id_80
3228                        ,anc_id_81
3229                        ,anc_id_82
3230                        ,anc_id_83
3231                        ,anc_id_84
3232                        ,anc_id_85
3233                        ,anc_id_86
3234                        ,anc_id_87
3235                        ,anc_id_88
3236                        ,anc_id_89
3237                        ,anc_id_90
3238                        ,anc_id_91
3239                        ,anc_id_92
3240                        ,anc_id_93
3241                        ,anc_id_94
3242                        ,anc_id_95
3243                        ,anc_id_96
3244                        ,anc_id_97
3245                        ,anc_id_98
3246                        ,anc_id_99
3247                        ,anc_id_100
3248                        ,line_definition_owner_code
3249                        ,line_definition_code
3250                        ,business_class_code
3251                        ,mpa_accrual_entry_flag
3252                        ,encumbrance_type_id
3253                        ,merge_index
3254 		       ,calculate_g_l_amts_flag
3255 		       ,entered_currency_mau)
3256 
3257                         ae_line_num
3258 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
3259 FROM xla_ae_lines_gt
3260 WHERE temp_line_num <> 0;
3261 
3262    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3263 
3264       trace
3265          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
3266          ,p_level    => C_LEVEL_STATEMENT
3267          ,p_module   => l_log_module);
3268 
3269    END IF;
3270 
3271 forall i in 1..l_array_rowid.count
3272 update xla_ae_lines_gt
3273 set ae_line_num = l_array_ae_line_num(i)
3274 where rowid = l_array_rowid(i);
3275 
3276 
3277    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3278 
3279       trace
3280          (p_msg      => 'END of UpdateLineNumber100'
3281          ,p_level    => C_LEVEL_PROCEDURE
3282          ,p_module   => l_log_module);
3283 
3284    END IF;
3285 
3286 EXCEPTION
3287 WHEN xla_exceptions_pkg.application_exception THEN
3288   RAISE;
3289 WHEN OTHERS  THEN
3290   xla_exceptions_pkg.raise_message
3291                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber100');
3292 END UpdateLineNumber100;
3293 --
3294 --
3295 /*======================================================================+
3296 |                                                                       |
3297 | Insert final Lines                                                    |
3298 |                                                                       |
3299 |                                                                       |
3300 +======================================================================*/
3301 --
3302 
3303 FUNCTION InsertLines(p_application_id         IN INTEGER
3304                     ,p_budgetary_control_mode IN VARCHAR2)
3305 RETURN NUMBER
3306 IS
3307 l_log_module         VARCHAR2(240);
3308 l_count number;
3309 l_ledger_attrs       xla_accounting_cache_pkg.t_array_ledger_attrs;
3310 l_accounting_mode    VARCHAR2(1);
3311 
3312 BEGIN
3313 --
3314 IF g_log_enabled THEN
3315       l_log_module := C_DEFAULT_MODULE||'.InsertLines';
3316 END IF;
3317 --
3318 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3319 
3320       trace
3321          (p_msg      => 'BEGIN of InsertLines'
3322          ,p_level    => C_LEVEL_PROCEDURE
3323          ,p_module   => l_log_module);
3324 
3325 END IF;
3326 l_accounting_mode := xla_accounting_pkg.g_accounting_mode;
3327 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3328       trace
3329          (p_msg      => 'Accounting_mode = '||l_accounting_mode
3330          ,p_level    => C_LEVEL_STATEMENT
3331          ,p_module   => l_log_module);
3332 END IF;
3333 
3334 --
3335 BEGIN
3336 
3337    IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3338       trace
3339          (p_msg      => 'SQL - Insert into xla_ae_lines'
3340          ,p_level    => C_LEVEL_STATEMENT
3341          ,p_module   => l_log_module);
3342    END IF;
3343 --
3344 xla_accounting_cache_pkg.GetLedgerArray(l_ledger_attrs);
3345 
3346 
3347    IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3348       trace
3349          (p_msg      => 'Before insert...'
3350          ,p_level    => C_LEVEL_STATEMENT
3351          ,p_module   => l_log_module);
3352    END IF;
3353 
3354 
3355 FORALL i in 1..l_ledger_attrs.array_ledger_id.count
3356   INSERT INTO xla_ae_lines
3357   (
3358      ae_header_id
3359    , ae_line_num
3360    , displayed_line_number
3361    , code_combination_id
3362    , gl_transfer_mode_code
3363    , creation_date
3364    , accounted_cr
3365    , accounted_dr
3366    , unrounded_accounted_cr
3367    , unrounded_accounted_dr
3368    , gain_or_loss_flag
3369    , accounting_class_code
3370    , currency_code
3371    , currency_conversion_date
3372    , currency_conversion_rate
3373    , currency_conversion_type
3374    , description
3375    , entered_cr
3376    , entered_dr
3377    , unrounded_entered_cr
3378    , unrounded_entered_dr
3379    , last_update_date
3380    , last_update_login
3381    , party_id
3382    , party_site_id
3383    , party_type_code
3384    , statistical_amount
3385    , ussgl_transaction_code
3386    , created_by
3387    , last_updated_by
3388    , jgzz_recon_ref
3389    , program_update_date
3390    , program_application_id
3391    , program_id
3392    , analytical_balance_flag
3393    , application_id
3394    , request_id
3395    , gl_sl_link_table
3396    , business_class_code    -- 4336173
3397    , mpa_accrual_entry_flag -- 4262811
3398    , encumbrance_type_id    -- 4458381 Public Sector Enh
3399    , ledger_id              --4955764
3400    , accounting_date        --4955764
3401    , gl_sl_link_id          --5041325
3402    , control_balance_flag   --4930177
3403   )
3404   (SELECT
3405       ae_header_id
3406      ,ae_line_num
3407      ,decode(nvl(accounted_cr, 0) + nvl(accounted_dr, 0), 0, -1, 1) *
3408          (ROW_NUMBER() over (PARTITION BY ae_header_id order by
3409                       DECODE(SIGN(abs(nvl(accounted_dr, 0)) - abs(nvl(accounted_cr, 0))), 1, 3, -1, 2, 0) desc,
3410                       abs(nvl(accounted_dr, 0) + nvl(accounted_cr, 0)) desc,
3411                       SIGN(nvl(accounted_dr, 0) + nvl(accounted_cr, 0)) desc))
3412      ,code_combination_id
3413      ,gl_transfer_mode_code
3414      ,creation_date
3415      ,accounted_cr
3416      ,accounted_dr
3417      ,unrounded_accounted_cr
3418      ,unrounded_accounted_dr
3419      ,gain_or_loss_flag
3420      ,decode(accounting_class_code, 'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY', 'EXCHANGE_GAIN_LOSS', accounting_class_code)
3421      ,currency_code
3422      ,currency_conversion_date
3423      ,currency_conversion_rate
3424      ,currency_conversion_type
3425      ,description
3426      ,entered_cr
3427      ,entered_dr
3428      ,unrounded_entered_cr
3429      ,unrounded_entered_dr
3430      ,last_update_date
3431      ,last_update_login
3432      ,party_id
3433      ,party_site_id
3434      ,party_type_code
3435      ,statistical_amount
3436      ,ussgl_transaction_code
3437      ,created_by
3438      ,last_updated_by
3439      ,jgzz_recon_ref
3440      ,program_update_date
3441      ,program_application_id
3442      ,program_id
3443      ,analytical_balance_flag
3444      ,application_id
3445      ,request_id
3446      ,gl_sl_link_table
3447      ,business_class_code
3448      ,mpa_accrual_entry_flag
3449      ,encumbrance_type_id
3450      ,ledger_id
3451      ,accounting_date
3452      ,Decode(l_accounting_mode,'F',xla_gl_sl_link_id_s.nextval,NULL)
3453      ,Decode(control_balance_flag,'Y','P'
3454 	                         ,'CUSTOMER','P'
3455 			         ,'SUPPLIER','P'
3456                                  ,NULL)
3457    FROM
3458   (SELECT /*+ Leading (LIN) Cardinality(LIN 1) use_nl(GCC) */
3459      lin.ae_header_id  ae_header_id
3460    , ae_line_num
3461    , CASE gain_or_loss_flag
3462      WHEN 'Y' THEN
3463        CASE calculate_g_l_amts_flag
3464        WHEN 'Y' THEN
3465            decode(SIGN(SUM(nvl(unrounded_accounted_cr, 0)-
3466              nvl(unrounded_accounted_dr, 0))),
3467              1,
3468                decode(code_combination_status_code
3469                   ,C_CCID_CREATED,lin.code_combination_id
3470                   , -1 ),
3471                decode(alt_ccid_status_code
3472                   ,C_CCID_CREATED,alt_code_combination_id
3473                   , -1 ))
3474        ELSE
3475            DECODE(code_combination_status_code
3476                 ,C_CCID_CREATED,lin.code_combination_id
3477                 , -1 )
3478        END
3479      ELSE
3480        DECODE(code_combination_status_code
3481             ,C_CCID_CREATED,lin.code_combination_id
3482             , -1 )
3483      END       code_combination_id
3484    , gl_transfer_mode_code
3485    , g_who_columns.creation_date  creation_date
3486 --accounted_cr
3487             ,DECODE(NVL(SUM(unrounded_accounted_cr), SUM(unrounded_accounted_dr)), NULL, to_number(NULL), -- to_number() for bug13061446
3488             CASE switch_side_flag
3489               WHEN 'Y'
3490               THEN
3491                 CASE SIGN( NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)+ NVL(SUM(doc_rounding_acctd_amt), 0) )
3492                   WHEN                                        -1
3493                   THEN NULL
3494                   WHEN 1
3495                   THEN
3496                     CASE
3497                       WHEN currency_code = 'STAT'
3498                       THEN --Bug13685918 Adding the case for STAT
3499                         --TO ROUND OFF TO the PRECISION OF STAT irrespective OF ledger currency.
3500                         -- For a STAT Currency Journal both Entered and Accounted are Same
3501                         -- and Rounding should be of MAU of STAT and NOT of Ledger Currency
3502                         ROUND( (NVL(SUM(unrounded_accounted_cr),0)    - NVL(SUM(unrounded_accounted_dr),0)+ NVL(SUM(doc_rounding_acctd_amt), 0))
3503 			/entered_currency_mau +l_ledger_attrs.array_rounding_offset(i)) *entered_currency_mau
3504                       ELSE ROUND( (NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)+ NVL(SUM(doc_rounding_acctd_amt), 0))
3505 		      /l_ledger_attrs.array_mau(i) +l_ledger_attrs.array_rounding_offset(i)) *l_ledger_attrs.array_mau(i)
3506                     END
3507                   ELSE
3508                     CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0) + NVL(SUM(doc_rounding_entered_amt), 0))
3509                       WHEN                                     -1
3510                       THEN NULL
3511                       WHEN 1
3512                       THEN 0
3513                       ELSE DECODE(SUM(unrounded_accounted_cr), 0, 0, NULL)
3514                     END
3515                 END
3516               ELSE DECODE(SUM(unrounded_accounted_cr), NULL, to_number(NULL) ,
3517                 CASE
3518                   WHEN currency_code = 'STAT'
3519                   THEN --Bug13685918 Adding the case for STAT
3520                     --TO ROUND OFF TO the PRECISION OF STAT irrespective OF ledger currency
3521                     -- For a STAT Currency Journal both Entered and Accounted are Same
3522                     -- and Rounding should be of MAU of STAT and NOT of Ledger Currency
3523                     ROUND( (SUM(unrounded_accounted_cr)    + NVL(SUM(doc_rounding_acctd_amt), 0))
3524 		    /entered_currency_mau +l_ledger_attrs.array_rounding_offset(i)) *entered_currency_mau
3525                   ELSE ROUND( (SUM(unrounded_accounted_cr) + NVL(SUM(doc_rounding_acctd_amt), 0))
3526 		  /l_ledger_attrs.array_mau(i) +l_ledger_attrs.array_rounding_offset(i)) *l_ledger_attrs.array_mau(i)
3527                 END)
3528             END) accounted_cr
3529             -- accounted_dr
3530             ,
3531             DECODE(NVL(SUM(unrounded_accounted_cr), SUM(unrounded_accounted_dr)), NULL, to_number(NULL), -- to_number() for bug13061446
3532             CASE switch_side_flag
3533               WHEN 'Y'
3534               THEN
3535                 CASE SIGN( NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)- NVL(SUM(doc_rounding_acctd_amt), 0) )
3536                   WHEN                                        -1
3537                   THEN NULL
3538                   WHEN 1
3539                   THEN
3540                     CASE
3541                       WHEN currency_code = 'STAT'
3542                       THEN --Bug13685918 Adding the case for STAT
3543                         --TO ROUND OFF TO the PRECISION OF STAT irrespective OF ledger currency
3544                         -- For a STAT Currency Journal both Entered and Accounted are Same
3545                         -- and Rounding should be of MAU of STAT and NOT of Ledger Currency
3546                         ROUND( (NVL(SUM(unrounded_accounted_dr),0)    - NVL(SUM(unrounded_accounted_cr),0)- NVL(SUM(doc_rounding_acctd_amt), 0))
3547 			/entered_currency_mau +l_ledger_attrs.array_rounding_offset(i)) *entered_currency_mau
3548                       ELSE ROUND( (NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)- NVL(SUM(doc_rounding_acctd_amt), 0))
3549 		      /l_ledger_attrs.array_mau(i) +l_ledger_attrs.array_rounding_offset(i)) *l_ledger_attrs.array_mau(i)
3550                     END
3551                   ELSE
3552                     CASE SIGN(NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(doc_rounding_entered_amt), 0))
3553                       WHEN                                     -1
3554                       THEN NULL
3555                       WHEN 1
3556                       THEN 0
3557                       ELSE DECODE(SUM(unrounded_accounted_cr), 0, to_number(NULL), 0)
3558                     END
3559                 END
3560               ELSE DECODE(SUM(unrounded_accounted_cr), NULL,
3561                 CASE
3562                   WHEN currency_code = 'STAT'
3563                   THEN --Bug13685918 Adding the case for STAT
3564                     --TO ROUND OFF TO the PRECISION OF STAT irrespective OF ledger currency
3565                     -- For a STAT Currency Journal both Entered and Accounted are Same
3566                     -- and Rounding should be of MAU of STAT and NOT of Ledger Currency
3567                     ROUND( (SUM(unrounded_accounted_dr)   -NVL(SUM(doc_rounding_acctd_amt), 0))
3568 		    /entered_currency_mau +l_ledger_attrs.array_rounding_offset(i)) *entered_currency_mau
3569                   ELSE ROUND( (SUM(unrounded_accounted_dr)-NVL(SUM(doc_rounding_acctd_amt), 0))
3570 		  /l_ledger_attrs.array_mau(i) +l_ledger_attrs.array_rounding_offset(i)) *l_ledger_attrs.array_mau(i)
3571                 END ,
3572                 CASE
3573                   WHEN currency_code = 'STAT'
3574                   THEN --Bug13685918 Adding the case for STAT
3575                     --TO ROUND OFF TO the PRECISION OF STAT irrespective OF ledger currency
3576                     -- For a STAT Currency Journal both Entered and Accounted are Same
3577                     -- and Rounding should be of MAU of STAT and NOT of Ledger Currency
3578                     ROUND( SUM(unrounded_accounted_dr)
3579 		    /entered_currency_mau +l_ledger_attrs.array_rounding_offset(i)) *entered_currency_mau
3580                   ELSE ROUND( SUM(unrounded_accounted_dr)
3581 		  /l_ledger_attrs.array_mau(i) +l_ledger_attrs.array_rounding_offset(i)) *l_ledger_attrs.array_mau(i)
3582                 END )
3583             END) accounted_dr
3584 
3585    -- unrounded_accounted_cr
3586    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, to_number(null), -- to_number() for bug13061446
3587        CASE switch_side_flag
3588        WHEN 'Y' THEN
3589          CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3590          WHEN -1 THEN null
3591          WHEN 1 THEN
3592            NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)
3593          ELSE
3594            CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3595            WHEN -1 THEN null
3596            WHEN 1 THEN 0
3597            ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3598            END
3599          END
3600        ELSE SUM(unrounded_accounted_cr)
3601        END) unrounded_accounted_cr
3602    -- unrounded_accounted_dr
3603    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, to_number(null), -- to_number() for bug13061446
3604        CASE switch_side_flag
3605        WHEN 'Y' THEN
3606          CASE SIGN(NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0))
3607          WHEN 1 THEN
3608            NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)
3609          WHEN -1 THEN null
3610          ELSE
3611            CASE SIGN(NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0))
3612            WHEN -1 THEN null
3613            WHEN 1 THEN 0
3614            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3615            END
3616          END
3617        ELSE SUM(unrounded_accounted_dr)
3618        END) unrounded_accounted_dr
3619    , gain_or_loss_flag
3620    , accounting_class_code
3621    , currency_code
3622    --, currency_conversion_date   new condition added below for bug7253542
3623    , DECODE(l_ledger_attrs.array_ledger_type(i),
3624             'PRIMARY',
3625             (DECODE(currency_code,
3626 		    l_ledger_attrs.array_ledger_currency_code(i),
3627                     NULL,
3628 		    currency_conversion_date)),
3629              currency_conversion_date) currency_conversion_date
3630    , currency_conversion_rate
3631    , currency_conversion_type
3632    , lin.description   description
3633    -- entered_cr
3634    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, to_number(null), -- to_number() for bug13061446
3635        CASE switch_side_flag
3636        WHEN 'Y' THEN
3637          CASE SIGN(
3638                   NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)+
3639                   NVL(SUM(doc_rounding_entered_amt), 0)
3640                 )
3641          WHEN -1 THEN null
3642          WHEN 1 THEN
3643               ROUND(
3644                 (NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)+
3645                 NVL(SUM(doc_rounding_entered_amt), 0))
3646                 /entered_currency_mau
3647                 +l_ledger_attrs.array_rounding_offset(i))
3648               *entered_currency_mau
3649          ELSE
3650                CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)
3651                          +NVL(SUM(doc_rounding_acctd_amt), 0))
3652                WHEN -1 THEN null
3653                WHEN 1 THEN 0
3654                ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3655                END
3656          END
3657        ELSE DECODE(SUM(unrounded_entered_cr), null, to_number(null) ,
3658               ROUND(
3659                 (SUM(unrounded_entered_cr) +
3660                 NVL(SUM(doc_rounding_entered_amt), 0))
3661                 /entered_currency_mau
3662                 +l_ledger_attrs.array_rounding_offset(i))
3663               *entered_currency_mau)
3664        END) entered_cr
3665    -- entered_dr
3666    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, to_number(null), -- to_number() for bug13061446
3667        CASE switch_side_flag
3668        WHEN 'Y' THEN
3669          CASE SIGN(
3670                   NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)-
3671                   NVL(SUM(doc_rounding_entered_amt), 0)
3672                 )
3673          WHEN -1 THEN null
3674          WHEN 1 THEN
3675             ROUND(
3676                 (NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)-
3677                 NVL(SUM(doc_rounding_entered_amt), 0))
3678                 /entered_currency_mau
3679                 +l_ledger_attrs.array_rounding_offset(i))
3680               *entered_currency_mau
3681          ELSE
3682            CASE SIGN(NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)
3683                      -NVL(SUM(doc_rounding_acctd_amt), 0))
3684            WHEN -1 THEN null
3685            WHEN 1 THEN 0
3686            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3687            END
3688          END
3689        ELSE
3690            decode(SUM(unrounded_entered_cr), null,
3691             ROUND(
3692               (SUM(unrounded_entered_dr)-NVL(SUM(doc_rounding_entered_amt), 0))
3693               /entered_currency_mau
3694               +l_ledger_attrs.array_rounding_offset(i))
3695               *entered_currency_mau
3696            ,ROUND(
3697               SUM(unrounded_entered_dr) /entered_currency_mau
3698               +l_ledger_attrs.array_rounding_offset(i))
3699               *entered_currency_mau
3700            )
3701        END) entered_dr
3702    -- unrounded_entered_cr
3703    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, to_number(null), -- to_number() for bug13061446
3704        CASE switch_side_flag
3705        WHEN 'Y' THEN
3706          CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3707          WHEN -1 THEN null
3708          WHEN 1 THEN NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)
3709          ELSE
3710            CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3711            WHEN -1 THEN null
3712            WHEN 1 THEN 0
3713            ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3714            END
3715          END
3716        ELSE SUM(unrounded_entered_cr)
3717        END) unrounded_entered_cr
3718    -- unrounded_entered_dr
3719    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, to_number(null), -- to_number() for bug13061446
3720        CASE switch_side_flag
3721        WHEN 'Y' THEN
3722          CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3723          WHEN 1 THEN null
3724          WHEN -1 THEN NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)
3725          ELSE
3726            CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3727            WHEN 1 THEN null
3728            WHEN -1 THEN 0
3729            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3730            END
3731          END
3732        ELSE SUM(unrounded_entered_dr)
3733        END) unrounded_entered_dr
3734    , g_who_columns.last_update_date      last_update_date
3735    , g_who_columns.last_update_login     last_update_login
3736    , party_id
3737    , party_site_id
3738    , party_type_code
3739    , sum(statistical_amount)            statistical_amount
3740    , ussgl_transaction_code
3741    , g_who_columns.created_by           created_by
3742    , g_who_columns.last_updated_by      last_updated_by
3743    , jgzz_recon_ref
3744    , g_who_columns.program_update_date  program_update_date
3745    , g_who_columns.program_application_id  program_application_id
3746    , g_who_columns.program_id           program_id
3747    , analytical_balance_flag            analytical_balance_flag
3748    , p_application_id                   application_id
3749    , g_who_columns.request_id           request_id
3750    , 'XLAJEL'                           gl_sl_link_table
3751    , business_class_code    -- 4336173
3752    , mpa_accrual_entry_flag -- 4262811
3753    , encumbrance_type_id    -- 4458381 Public Sector Enh
3754    , ledger_id              -- 4955764
3755    , accounting_date        -- 4955764
3756    , gcc.reference3                     control_balance_flag   --4930177
3757   FROM xla_ae_lines_gt     lin
3758       ,gl_code_combinations gcc
3759   WHERE ledger_id = l_ledger_attrs.array_ledger_id(i)
3760     AND ae_line_num is not NULL
3761     AND lin.code_combination_id = gcc.code_combination_id(+)     --5261785
3762  GROUP BY lin.ae_header_id
3763         , ae_line_num
3764         , header_num                    -- 4262811c  MPA reversal lines
3765         , gl_transfer_mode_code
3766         , g_who_columns.creation_date
3767         , g_who_columns.last_update_date
3768         , g_who_columns.last_update_login
3769         , g_who_columns.created_by
3770         , g_who_columns.last_updated_by
3771         , g_who_columns.program_update_date
3772         , g_who_columns.program_application_id
3773         , g_who_columns.program_id
3774         , g_who_columns.request_id
3775         , 'XLAJEL'
3776         , p_application_id
3777         , accounting_class_code
3778         , event_class_code
3779         , event_type_code
3780         , line_definition_owner_code
3781         , line_definition_code
3782         , entered_currency_mau
3783         , currency_code
3784         , currency_conversion_type
3785         , currency_conversion_date
3786         , currency_conversion_rate
3787         , party_id
3788         , party_site_id
3789         , party_type_code
3790         , lin.code_combination_id
3791         , C_CCID_CREATED
3792         , code_combination_status_code
3793         , lin.description
3794         , jgzz_recon_ref
3795         , ussgl_transaction_code
3796         , merge_duplicate_code
3797         , analytical_balance_flag
3798         , switch_side_flag
3799         , gain_or_loss_flag
3800         , calculate_g_l_amts_flag
3801         , alt_ccid_status_code
3802         , alt_code_combination_id
3803         , lin.business_class_code    -- 4336173
3804         , lin.mpa_accrual_entry_flag -- 4262811
3805         , encumbrance_type_id -- 4458381 Public Sector Enh
3806         , merge_index
3807         , ledger_id
3808         , accounting_date
3809         , gcc.reference3
3810         )
3811   WHERE accounting_class_code <>'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY' or nvl(accounted_cr, 0) <> nvl(accounted_dr, 0)
3812 );
3813 --
3814 
3815 EXCEPTION
3816 WHEN OTHERS  THEN
3817 
3818   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3819          trace
3820             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
3821             ,p_level    => C_LEVEL_EXCEPTION
3822             ,p_module   => l_log_module);
3823   END IF;
3824 
3825   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
3826                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
3827                                     ,p_token_1      => 'ERROR'
3828                                     ,p_value_1      => sqlerrm
3829                                     );
3830 END;
3831 
3832 --
3833 l_count := SQL%ROWCOUNT;
3834 IF (C_LEVEL_EVENT >= g_log_level) THEN
3835       trace
3836          (p_msg      => '# journal entry lines inserted into xla_ae_lines = '||to_char(l_count)
3837          ,p_level    => C_LEVEL_EVENT
3838          ,p_module   => l_log_module);
3839 END IF;
3840 
3841 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3842 
3843       trace
3844          (p_msg      => 'return value. = '||TO_CHAR(l_count)
3845          ,p_level    => C_LEVEL_PROCEDURE
3846          ,p_module   => l_log_module);
3847 
3848 
3849       trace
3850          (p_msg      => 'END of InsertLines'
3851          ,p_level    => C_LEVEL_PROCEDURE
3852          ,p_module   => l_log_module);
3853 END IF;
3854 
3855 RETURN l_count;
3856 
3857 EXCEPTION
3858 WHEN xla_exceptions_pkg.application_exception THEN
3859   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3860        trace
3861            (p_msg      => 'Error. = '||sqlerrm
3862            ,p_level    => C_LEVEL_PROCEDURE
3863            ,p_module   => l_log_module);
3864   END IF;
3865   RAISE;
3866 WHEN OTHERS  THEN
3867   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3868        trace
3869            (p_msg      => 'Error. = '||sqlerrm
3870            ,p_level    => C_LEVEL_PROCEDURE
3871            ,p_module   => l_log_module);
3872   END IF;
3873   xla_exceptions_pkg.raise_message
3874                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertLines');
3875 END InsertLines;
3876 --
3877 --
3878 /*======================================================================+
3879 | PRIVATE Procedure                                                     |
3880 |                                                                       |
3881 | InsertAnalyticalCriteria                                              |
3882 |                                                                       |
3883 |                                                                       |
3884 +======================================================================*/
3885 --
3886 PROCEDURE InsertAnalyticalCriteria
3887 IS
3888 l_rowcount           NUMBER;
3889 l_log_module         VARCHAR2(240);
3890 l_reversal_flag      VARCHAR2(1);
3891 BEGIN
3892 --
3893 IF g_log_enabled THEN
3894       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria';
3895 END IF;
3896 --
3897 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3898 
3899       trace
3900          (p_msg      => 'BEGIN of InsertAnalyticalCriteria'
3901          ,p_level    => C_LEVEL_PROCEDURE
3902          ,p_module   => l_log_module);
3903 END IF;
3904 
3905 l_rowcount  := 0;
3906 
3907 BEGIN
3908 
3909    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3910 
3911       trace
3912          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
3913          ,p_level    => C_LEVEL_STATEMENT
3914          ,p_module   => l_log_module);
3915 
3916       trace
3917          (p_msg      => '# of line ACs: ' || g_line_ac_count
3918          ,p_level    => C_LEVEL_STATEMENT
3919          ,p_module   => l_log_module);
3920 
3921    END IF;
3922    BEGIN
3923 	SELECT 'Y' into l_reversal_flag
3924 	FROM dual
3925 	WHERE exists
3926 	(SELECT 1 FROM xla_ae_lines_gt WHERE reversal_code='REVERSAL');
3927 
3928 	IF l_reversal_flag='Y' THEN
3929 	    Insert_ANC_Inv_Canc;
3930 	END IF;
3931 
3932         EXCEPTION
3933 	WHEN NO_DATA_FOUND THEN
3934 	null;
3935    END;
3936 
3937 
3938    IF g_line_ac_count <= 10 THEN
3939 
3940       InsertAnalyticalCriteria10;
3941 
3942    ELSIF g_line_ac_count <= 50 THEN
3943 
3944       InsertAnalyticalCriteria50;
3945 
3946    ELSIF g_line_ac_count <= 100 THEN
3947 
3948       InsertAnalyticalCriteria100;
3949 
3950    END IF;
3951 
3952    --
3953    l_rowcount := SQL%ROWCOUNT;
3954 
3955    IF (C_LEVEL_EVENT >= g_log_level) THEN
3956       trace
3957          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
3958          ,p_level    => C_LEVEL_EVENT
3959          ,p_module   => l_log_module);
3960    END IF;
3961 
3962    EXCEPTION
3963    WHEN OTHERS  THEN
3964 
3965      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3966           trace
3967               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
3968               ,p_level    => C_LEVEL_EXCEPTION
3969               ,p_module   => l_log_module);
3970      END IF;
3971 
3972      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
3973                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
3974                                       ,p_token_1      => 'ERROR'
3975                                       ,p_value_1      => sqlerrm
3976                                       );
3977 
3978 
3979    END;
3980 
3981 EXCEPTION
3982 WHEN xla_exceptions_pkg.application_exception THEN
3983   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3984        trace
3985            (p_msg      => 'Error. = '||sqlerrm
3986            ,p_level    => C_LEVEL_PROCEDURE
3987            ,p_module   => l_log_module);
3988   END IF;
3989   RAISE;
3990 WHEN OTHERS  THEN
3991   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3992        trace
3993            (p_msg      => 'Error. = '||sqlerrm
3994            ,p_level    => C_LEVEL_PROCEDURE
3995            ,p_module   => l_log_module);
3996   END IF;
3997   xla_exceptions_pkg.raise_message
3998                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria');
3999 END InsertAnalyticalCriteria;
4000 
4001 --
4002 --
4003 /*======================================================================+
4004 | PRIVATE Procedure                                                     |
4005 |                                                                       |
4006 | InsertAnalyticalCriteria10                                            |
4007 |                                                                       |
4008 |                                                                       |
4009 +======================================================================*/
4010 --
4011 PROCEDURE InsertAnalyticalCriteria10
4012 IS
4013 l_rowcount           NUMBER;
4014 l_log_module         VARCHAR2(240);
4015 BEGIN
4016 --
4017 IF g_log_enabled THEN
4018       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria10';
4019 END IF;
4020 --
4021 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4022 
4023       trace
4024          (p_msg      => 'BEGIN of InsertAnalyticalCriteria10'
4025          ,p_level    => C_LEVEL_PROCEDURE
4026          ,p_module   => l_log_module);
4027 END IF;
4028 
4029 l_rowcount  := 0;
4030 
4031 BEGIN
4032 
4033    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4034 
4035       trace
4036          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
4037          ,p_level    => C_LEVEL_STATEMENT
4038          ,p_module   => l_log_module);
4039 
4040    END IF;
4041 
4042 INSERT ALL
4043 WHEN anc_id_1 IS NOT NULL and anc_id_1 not like 'DUMMY_ANC_%' THEN    -- Bug 8691573
4044   INTO xla_ae_line_acs (
4045         ae_header_id , ae_line_num , object_version_number
4046       , analytical_criterion_code
4047       , analytical_criterion_type_code
4048       , amb_context_code
4049       , ac1,ac2,ac3,ac4,ac5)
4050 VALUES (ae_header_id, ae_line_num, C_OVN
4051 ,SUBSTRB(anc_id_1
4052        ,1
4053        ,INSTRB(anc_id_1,'(]',1,1) -1)
4054 ,SUBSTRB(anc_id_1
4055        ,INSTRB(anc_id_1,'(]',1,1) + 2
4056        ,INSTRB(anc_id_1,'(]',1,2) -
4057         INSTRB(anc_id_1,'(]',1,1) - 2)
4058 ,SUBSTRB(anc_id_1
4059        ,INSTRB(anc_id_1,'(]',1,2) + 2
4060        ,INSTRB(anc_id_1,'(]',1,3) -
4061         INSTRB(anc_id_1,'(]',1,2) - 2)
4062 ,SUBSTRB(anc_id_1
4063        ,INSTRB(anc_id_1,'(]',1,3) + 2
4064        ,INSTRB(anc_id_1,'(]',1,4) -
4065         INSTRB(anc_id_1,'(]',1,3) - 2)
4066 ,SUBSTRB(anc_id_1
4067        ,INSTRB(anc_id_1,'(]',1,4) + 2
4068        ,INSTRB(anc_id_1,'(]',1,5) -
4069         INSTRB(anc_id_1,'(]',1,4) - 2)
4070 ,SUBSTRB(anc_id_1
4071        ,INSTRB(anc_id_1,'(]',1,5) + 2
4072        ,INSTRB(anc_id_1,'(]',1,6) -
4073         INSTRB(anc_id_1,'(]',1,5) - 2)
4074 ,SUBSTRB(anc_id_1
4075        ,INSTRB(anc_id_1,'(]',1,6) + 2
4076        ,INSTRB(anc_id_1,'(]',1,7) -
4077         INSTRB(anc_id_1,'(]',1,6) - 2)
4078 ,SUBSTRB(anc_id_1
4079        ,INSTRB(anc_id_1,'(]',1,7) + 2
4080        ,LENGTHB(anc_id_1))
4081 )
4082 
4083 WHEN anc_id_2 IS NOT NULL THEN
4084   INTO xla_ae_line_acs (
4085         ae_header_id , ae_line_num , object_version_number
4086       , analytical_criterion_code
4087       , analytical_criterion_type_code
4088       , amb_context_code
4089       , ac1,ac2,ac3,ac4,ac5)
4090 VALUES (ae_header_id, ae_line_num, C_OVN
4091 ,SUBSTRB(anc_id_2
4092        ,1
4093        ,INSTRB(anc_id_2,'(]',1,1) -1)
4094 ,SUBSTRB(anc_id_2
4095        ,INSTRB(anc_id_2,'(]',1,1) + 2
4096        ,INSTRB(anc_id_2,'(]',1,2) -
4097         INSTRB(anc_id_2,'(]',1,1) - 2)
4098 ,SUBSTRB(anc_id_2
4099        ,INSTRB(anc_id_2,'(]',1,2) + 2
4100        ,INSTRB(anc_id_2,'(]',1,3) -
4101         INSTRB(anc_id_2,'(]',1,2) - 2)
4102 ,SUBSTRB(anc_id_2
4103        ,INSTRB(anc_id_2,'(]',1,3) + 2
4104        ,INSTRB(anc_id_2,'(]',1,4) -
4105         INSTRB(anc_id_2,'(]',1,3) - 2)
4106 ,SUBSTRB(anc_id_2
4107        ,INSTRB(anc_id_2,'(]',1,4) + 2
4108        ,INSTRB(anc_id_2,'(]',1,5) -
4109         INSTRB(anc_id_2,'(]',1,4) - 2)
4110 ,SUBSTRB(anc_id_2
4111        ,INSTRB(anc_id_2,'(]',1,5) + 2
4112        ,INSTRB(anc_id_2,'(]',1,6) -
4113         INSTRB(anc_id_2,'(]',1,5) - 2)
4114 ,SUBSTRB(anc_id_2
4115        ,INSTRB(anc_id_2,'(]',1,6) + 2
4116        ,INSTRB(anc_id_2,'(]',1,7) -
4117         INSTRB(anc_id_2,'(]',1,6) - 2)
4118 ,SUBSTRB(anc_id_2
4119        ,INSTRB(anc_id_2,'(]',1,7) + 2
4120        ,LENGTHB(anc_id_2))
4121 )
4122 
4123 WHEN anc_id_3 IS NOT NULL THEN
4124   INTO xla_ae_line_acs (
4125         ae_header_id , ae_line_num , object_version_number
4126       , analytical_criterion_code
4127       , analytical_criterion_type_code
4128       , amb_context_code
4129       , ac1,ac2,ac3,ac4,ac5)
4130 VALUES (ae_header_id, ae_line_num, C_OVN
4131 ,SUBSTRB(anc_id_3
4132        ,1
4133        ,INSTRB(anc_id_3,'(]',1,1) -1)
4134 ,SUBSTRB(anc_id_3
4135        ,INSTRB(anc_id_3,'(]',1,1) + 2
4136        ,INSTRB(anc_id_3,'(]',1,2) -
4137         INSTRB(anc_id_3,'(]',1,1) - 2)
4138 ,SUBSTRB(anc_id_3
4139        ,INSTRB(anc_id_3,'(]',1,2) + 2
4140        ,INSTRB(anc_id_3,'(]',1,3) -
4141         INSTRB(anc_id_3,'(]',1,2) - 2)
4142 ,SUBSTRB(anc_id_3
4143        ,INSTRB(anc_id_3,'(]',1,3) + 2
4144        ,INSTRB(anc_id_3,'(]',1,4) -
4145         INSTRB(anc_id_3,'(]',1,3) - 2)
4146 ,SUBSTRB(anc_id_3
4147        ,INSTRB(anc_id_3,'(]',1,4) + 2
4148        ,INSTRB(anc_id_3,'(]',1,5) -
4149         INSTRB(anc_id_3,'(]',1,4) - 2)
4150 ,SUBSTRB(anc_id_3
4151        ,INSTRB(anc_id_3,'(]',1,5) + 2
4152        ,INSTRB(anc_id_3,'(]',1,6) -
4153         INSTRB(anc_id_3,'(]',1,5) - 2)
4154 ,SUBSTRB(anc_id_3
4155        ,INSTRB(anc_id_3,'(]',1,6) + 2
4156        ,INSTRB(anc_id_3,'(]',1,7) -
4157         INSTRB(anc_id_3,'(]',1,6) - 2)
4158 ,SUBSTRB(anc_id_3
4159        ,INSTRB(anc_id_3,'(]',1,7) + 2
4160        ,LENGTHB(anc_id_3))
4161 )
4162 
4163 WHEN anc_id_4 IS NOT NULL THEN
4164   INTO xla_ae_line_acs (
4165         ae_header_id , ae_line_num , object_version_number
4166       , analytical_criterion_code
4167       , analytical_criterion_type_code
4168       , amb_context_code
4169       , ac1,ac2,ac3,ac4,ac5)
4170 VALUES (ae_header_id, ae_line_num, C_OVN
4171 ,SUBSTRB(anc_id_4
4172        ,1
4173        ,INSTRB(anc_id_4,'(]',1,1) -1)
4174 ,SUBSTRB(anc_id_4
4175        ,INSTRB(anc_id_4,'(]',1,1) + 2
4176        ,INSTRB(anc_id_4,'(]',1,2) -
4177         INSTRB(anc_id_4,'(]',1,1) - 2)
4178 ,SUBSTRB(anc_id_4
4179        ,INSTRB(anc_id_4,'(]',1,2) + 2
4180        ,INSTRB(anc_id_4,'(]',1,3) -
4181         INSTRB(anc_id_4,'(]',1,2) - 2)
4182 ,SUBSTRB(anc_id_4
4183        ,INSTRB(anc_id_4,'(]',1,3) + 2
4184        ,INSTRB(anc_id_4,'(]',1,4) -
4185         INSTRB(anc_id_4,'(]',1,3) - 2)
4186 ,SUBSTRB(anc_id_4
4187        ,INSTRB(anc_id_4,'(]',1,4) + 2
4188        ,INSTRB(anc_id_4,'(]',1,5) -
4189         INSTRB(anc_id_4,'(]',1,4) - 2)
4190 ,SUBSTRB(anc_id_4
4191        ,INSTRB(anc_id_4,'(]',1,5) + 2
4192        ,INSTRB(anc_id_4,'(]',1,6) -
4193         INSTRB(anc_id_4,'(]',1,5) - 2)
4194 ,SUBSTRB(anc_id_4
4195        ,INSTRB(anc_id_4,'(]',1,6) + 2
4196        ,INSTRB(anc_id_4,'(]',1,7) -
4197         INSTRB(anc_id_4,'(]',1,6) - 2)
4198 ,SUBSTRB(anc_id_4
4199        ,INSTRB(anc_id_4,'(]',1,7) + 2
4200        ,LENGTHB(anc_id_4))
4201 )
4202 
4203 WHEN anc_id_5 IS NOT NULL THEN
4204   INTO xla_ae_line_acs (
4205         ae_header_id , ae_line_num , object_version_number
4206       , analytical_criterion_code
4207       , analytical_criterion_type_code
4208       , amb_context_code
4209       , ac1,ac2,ac3,ac4,ac5)
4210 VALUES (ae_header_id, ae_line_num, C_OVN
4211 ,SUBSTRB(anc_id_5
4212        ,1
4213        ,INSTRB(anc_id_5,'(]',1,1) -1)
4214 ,SUBSTRB(anc_id_5
4215        ,INSTRB(anc_id_5,'(]',1,1) + 2
4216        ,INSTRB(anc_id_5,'(]',1,2) -
4217         INSTRB(anc_id_5,'(]',1,1) - 2)
4218 ,SUBSTRB(anc_id_5
4219        ,INSTRB(anc_id_5,'(]',1,2) + 2
4220        ,INSTRB(anc_id_5,'(]',1,3) -
4221         INSTRB(anc_id_5,'(]',1,2) - 2)
4222 ,SUBSTRB(anc_id_5
4223        ,INSTRB(anc_id_5,'(]',1,3) + 2
4224        ,INSTRB(anc_id_5,'(]',1,4) -
4225         INSTRB(anc_id_5,'(]',1,3) - 2)
4226 ,SUBSTRB(anc_id_5
4227        ,INSTRB(anc_id_5,'(]',1,4) + 2
4228        ,INSTRB(anc_id_5,'(]',1,5) -
4229         INSTRB(anc_id_5,'(]',1,4) - 2)
4230 ,SUBSTRB(anc_id_5
4231        ,INSTRB(anc_id_5,'(]',1,5) + 2
4232        ,INSTRB(anc_id_5,'(]',1,6) -
4233         INSTRB(anc_id_5,'(]',1,5) - 2)
4234 ,SUBSTRB(anc_id_5
4235        ,INSTRB(anc_id_5,'(]',1,6) + 2
4236        ,INSTRB(anc_id_5,'(]',1,7) -
4237         INSTRB(anc_id_5,'(]',1,6) - 2)
4238 ,SUBSTRB(anc_id_5
4239        ,INSTRB(anc_id_5,'(]',1,7) + 2
4240        ,LENGTHB(anc_id_5))
4241 )
4242 
4243 WHEN anc_id_6 IS NOT NULL THEN
4244   INTO xla_ae_line_acs (
4245         ae_header_id , ae_line_num , object_version_number
4246       , analytical_criterion_code
4247       , analytical_criterion_type_code
4248       , amb_context_code
4249       , ac1,ac2,ac3,ac4,ac5)
4250 VALUES (ae_header_id, ae_line_num, C_OVN
4251 ,SUBSTRB(anc_id_6
4252        ,1
4253        ,INSTRB(anc_id_6,'(]',1,1) -1)
4254 ,SUBSTRB(anc_id_6
4255        ,INSTRB(anc_id_6,'(]',1,1) + 2
4256        ,INSTRB(anc_id_6,'(]',1,2) -
4257         INSTRB(anc_id_6,'(]',1,1) - 2)
4258 ,SUBSTRB(anc_id_6
4259        ,INSTRB(anc_id_6,'(]',1,2) + 2
4260        ,INSTRB(anc_id_6,'(]',1,3) -
4261         INSTRB(anc_id_6,'(]',1,2) - 2)
4262 ,SUBSTRB(anc_id_6
4263        ,INSTRB(anc_id_6,'(]',1,3) + 2
4264        ,INSTRB(anc_id_6,'(]',1,4) -
4265         INSTRB(anc_id_6,'(]',1,3) - 2)
4266 ,SUBSTRB(anc_id_6
4267        ,INSTRB(anc_id_6,'(]',1,4) + 2
4268        ,INSTRB(anc_id_6,'(]',1,5) -
4269         INSTRB(anc_id_6,'(]',1,4) - 2)
4270 ,SUBSTRB(anc_id_6
4271        ,INSTRB(anc_id_6,'(]',1,5) + 2
4272        ,INSTRB(anc_id_6,'(]',1,6) -
4273         INSTRB(anc_id_6,'(]',1,5) - 2)
4274 ,SUBSTRB(anc_id_6
4275        ,INSTRB(anc_id_6,'(]',1,6) + 2
4276        ,INSTRB(anc_id_6,'(]',1,7) -
4277         INSTRB(anc_id_6,'(]',1,6) - 2)
4278 ,SUBSTRB(anc_id_6
4279        ,INSTRB(anc_id_6,'(]',1,7) + 2
4280        ,LENGTHB(anc_id_6))
4281 )
4282 
4283 WHEN anc_id_7 IS NOT NULL THEN
4284   INTO xla_ae_line_acs (
4285         ae_header_id , ae_line_num , object_version_number
4286       , analytical_criterion_code
4287       , analytical_criterion_type_code
4288       , amb_context_code
4289       , ac1,ac2,ac3,ac4,ac5)
4290 VALUES (ae_header_id, ae_line_num, C_OVN
4291 ,SUBSTRB(anc_id_7
4292        ,1
4293        ,INSTRB(anc_id_7,'(]',1,1) -1)
4294 ,SUBSTRB(anc_id_7
4295        ,INSTRB(anc_id_7,'(]',1,1) + 2
4296        ,INSTRB(anc_id_7,'(]',1,2) -
4297         INSTRB(anc_id_7,'(]',1,1) - 2)
4298 ,SUBSTRB(anc_id_7
4299        ,INSTRB(anc_id_7,'(]',1,2) + 2
4300        ,INSTRB(anc_id_7,'(]',1,3) -
4301         INSTRB(anc_id_7,'(]',1,2) - 2)
4302 ,SUBSTRB(anc_id_7
4303        ,INSTRB(anc_id_7,'(]',1,3) + 2
4304        ,INSTRB(anc_id_7,'(]',1,4) -
4305         INSTRB(anc_id_7,'(]',1,3) - 2)
4306 ,SUBSTRB(anc_id_7
4307        ,INSTRB(anc_id_7,'(]',1,4) + 2
4308        ,INSTRB(anc_id_7,'(]',1,5) -
4309         INSTRB(anc_id_7,'(]',1,4) - 2)
4310 ,SUBSTRB(anc_id_7
4311        ,INSTRB(anc_id_7,'(]',1,5) + 2
4312        ,INSTRB(anc_id_7,'(]',1,6) -
4313         INSTRB(anc_id_7,'(]',1,5) - 2)
4314 ,SUBSTRB(anc_id_7
4315        ,INSTRB(anc_id_7,'(]',1,6) + 2
4316        ,INSTRB(anc_id_7,'(]',1,7) -
4317         INSTRB(anc_id_7,'(]',1,6) - 2)
4318 ,SUBSTRB(anc_id_7
4319        ,INSTRB(anc_id_7,'(]',1,7) + 2
4320        ,LENGTHB(anc_id_7))
4321 )
4322 
4323 WHEN anc_id_8 IS NOT NULL THEN
4324   INTO xla_ae_line_acs (
4325         ae_header_id , ae_line_num , object_version_number
4326       , analytical_criterion_code
4327       , analytical_criterion_type_code
4328       , amb_context_code
4329       , ac1,ac2,ac3,ac4,ac5)
4330 VALUES (ae_header_id, ae_line_num, C_OVN
4331 ,SUBSTRB(anc_id_8
4332        ,1
4333        ,INSTRB(anc_id_8,'(]',1,1) -1)
4334 ,SUBSTRB(anc_id_8
4335        ,INSTRB(anc_id_8,'(]',1,1) + 2
4336        ,INSTRB(anc_id_8,'(]',1,2) -
4337         INSTRB(anc_id_8,'(]',1,1) - 2)
4338 ,SUBSTRB(anc_id_8
4339        ,INSTRB(anc_id_8,'(]',1,2) + 2
4340        ,INSTRB(anc_id_8,'(]',1,3) -
4341         INSTRB(anc_id_8,'(]',1,2) - 2)
4342 ,SUBSTRB(anc_id_8
4343        ,INSTRB(anc_id_8,'(]',1,3) + 2
4344        ,INSTRB(anc_id_8,'(]',1,4) -
4345         INSTRB(anc_id_8,'(]',1,3) - 2)
4346 ,SUBSTRB(anc_id_8
4347        ,INSTRB(anc_id_8,'(]',1,4) + 2
4348        ,INSTRB(anc_id_8,'(]',1,5) -
4349         INSTRB(anc_id_8,'(]',1,4) - 2)
4350 ,SUBSTRB(anc_id_8
4351        ,INSTRB(anc_id_8,'(]',1,5) + 2
4352        ,INSTRB(anc_id_8,'(]',1,6) -
4353         INSTRB(anc_id_8,'(]',1,5) - 2)
4354 ,SUBSTRB(anc_id_8
4355        ,INSTRB(anc_id_8,'(]',1,6) + 2
4356        ,INSTRB(anc_id_8,'(]',1,7) -
4357         INSTRB(anc_id_8,'(]',1,6) - 2)
4358 ,SUBSTRB(anc_id_8
4359        ,INSTRB(anc_id_8,'(]',1,7) + 2
4360        ,LENGTHB(anc_id_8))
4361 )
4362 
4363 WHEN anc_id_9 IS NOT NULL THEN
4364   INTO xla_ae_line_acs (
4365         ae_header_id , ae_line_num , object_version_number
4366       , analytical_criterion_code
4367       , analytical_criterion_type_code
4368       , amb_context_code
4369       , ac1,ac2,ac3,ac4,ac5)
4370 VALUES (ae_header_id, ae_line_num, C_OVN
4371 ,SUBSTRB(anc_id_9
4372        ,1
4373        ,INSTRB(anc_id_9,'(]',1,1) -1)
4374 ,SUBSTRB(anc_id_9
4375        ,INSTRB(anc_id_9,'(]',1,1) + 2
4376        ,INSTRB(anc_id_9,'(]',1,2) -
4377         INSTRB(anc_id_9,'(]',1,1) - 2)
4378 ,SUBSTRB(anc_id_9
4379        ,INSTRB(anc_id_9,'(]',1,2) + 2
4380        ,INSTRB(anc_id_9,'(]',1,3) -
4381         INSTRB(anc_id_9,'(]',1,2) - 2)
4382 ,SUBSTRB(anc_id_9
4383        ,INSTRB(anc_id_9,'(]',1,3) + 2
4384        ,INSTRB(anc_id_9,'(]',1,4) -
4385         INSTRB(anc_id_9,'(]',1,3) - 2)
4386 ,SUBSTRB(anc_id_9
4387        ,INSTRB(anc_id_9,'(]',1,4) + 2
4388        ,INSTRB(anc_id_9,'(]',1,5) -
4389         INSTRB(anc_id_9,'(]',1,4) - 2)
4390 ,SUBSTRB(anc_id_9
4391        ,INSTRB(anc_id_9,'(]',1,5) + 2
4392        ,INSTRB(anc_id_9,'(]',1,6) -
4393         INSTRB(anc_id_9,'(]',1,5) - 2)
4394 ,SUBSTRB(anc_id_9
4395        ,INSTRB(anc_id_9,'(]',1,6) + 2
4396        ,INSTRB(anc_id_9,'(]',1,7) -
4397         INSTRB(anc_id_9,'(]',1,6) - 2)
4398 ,SUBSTRB(anc_id_9
4399        ,INSTRB(anc_id_9,'(]',1,7) + 2
4400        ,LENGTHB(anc_id_9))
4401 )
4402 
4403 WHEN anc_id_10 IS NOT NULL THEN
4404   INTO xla_ae_line_acs (
4405         ae_header_id , ae_line_num , object_version_number
4406       , analytical_criterion_code
4407       , analytical_criterion_type_code
4408       , amb_context_code
4409       , ac1,ac2,ac3,ac4,ac5)
4410 VALUES (ae_header_id, ae_line_num, C_OVN
4411 ,SUBSTRB(anc_id_10
4412        ,1
4413        ,INSTRB(anc_id_10,'(]',1,1) -1)
4414 ,SUBSTRB(anc_id_10
4415        ,INSTRB(anc_id_10,'(]',1,1) + 2
4416        ,INSTRB(anc_id_10,'(]',1,2) -
4417         INSTRB(anc_id_10,'(]',1,1) - 2)
4418 ,SUBSTRB(anc_id_10
4419        ,INSTRB(anc_id_10,'(]',1,2) + 2
4420        ,INSTRB(anc_id_10,'(]',1,3) -
4421         INSTRB(anc_id_10,'(]',1,2) - 2)
4422 ,SUBSTRB(anc_id_10
4423        ,INSTRB(anc_id_10,'(]',1,3) + 2
4424        ,INSTRB(anc_id_10,'(]',1,4) -
4425         INSTRB(anc_id_10,'(]',1,3) - 2)
4426 ,SUBSTRB(anc_id_10
4427        ,INSTRB(anc_id_10,'(]',1,4) + 2
4428        ,INSTRB(anc_id_10,'(]',1,5) -
4429         INSTRB(anc_id_10,'(]',1,4) - 2)
4430 ,SUBSTRB(anc_id_10
4431        ,INSTRB(anc_id_10,'(]',1,5) + 2
4432        ,INSTRB(anc_id_10,'(]',1,6) -
4433         INSTRB(anc_id_10,'(]',1,5) - 2)
4434 ,SUBSTRB(anc_id_10
4435        ,INSTRB(anc_id_10,'(]',1,6) + 2
4436        ,INSTRB(anc_id_10,'(]',1,7) -
4437         INSTRB(anc_id_10,'(]',1,6) - 2)
4438 ,SUBSTRB(anc_id_10
4439        ,INSTRB(anc_id_10,'(]',1,7) + 2
4440        ,LENGTHB(anc_id_10))
4441 )
4442 SELECT  ae_header_id
4443       , ae_line_num
4444       , anc_id_1
4445       , anc_id_2
4446       , anc_id_3
4447       , anc_id_4
4448       , anc_id_5
4449       , anc_id_6
4450       , anc_id_7
4451       , anc_id_8
4452       , anc_id_9
4453       , anc_id_10
4454  FROM  xla_ae_lines_gt
4455 WHERE  ae_line_num is not null
4456 GROUP  BY
4457        ae_line_num
4458       ,ae_header_id
4459       ,anc_id_1
4460       ,anc_id_2
4461       ,anc_id_3
4462       ,anc_id_4
4463       ,anc_id_5
4464       ,anc_id_6
4465       ,anc_id_7
4466       ,anc_id_8
4467       ,anc_id_9
4468       ,anc_id_10
4469       ;
4470 
4471    --
4472    l_rowcount := SQL%ROWCOUNT;
4473 
4474    IF (C_LEVEL_EVENT >= g_log_level) THEN
4475       trace
4476          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
4477          ,p_level    => C_LEVEL_EVENT
4478          ,p_module   => l_log_module);
4479    END IF;
4480 
4481    EXCEPTION
4482    WHEN OTHERS  THEN
4483 
4484      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4485           trace
4486               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
4487               ,p_level    => C_LEVEL_EXCEPTION
4488               ,p_module   => l_log_module);
4489      END IF;
4490 
4491      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
4492                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
4493                                       ,p_token_1      => 'ERROR'
4494                                       ,p_value_1      => sqlerrm
4495                                       );
4496 
4497    END;
4498 
4499 EXCEPTION
4500 WHEN xla_exceptions_pkg.application_exception THEN
4501   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4502        trace
4503            (p_msg      => 'Error. = '||sqlerrm
4504            ,p_level    => C_LEVEL_PROCEDURE
4505            ,p_module   => l_log_module);
4506   END IF;
4507   RAISE;
4508 WHEN OTHERS  THEN
4509   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4510        trace
4511            (p_msg      => 'Error. = '||sqlerrm
4512            ,p_level    => C_LEVEL_PROCEDURE
4513            ,p_module   => l_log_module);
4514   END IF;
4515   xla_exceptions_pkg.raise_message
4516        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria10');
4517 END InsertAnalyticalCriteria10;
4518 
4519 
4520 --
4521 --
4522 /*======================================================================+
4523 | PRIVATE Procedure                                                     |
4524 |                                                                       |
4525 | InsertAnalyticalCriteria50                                            |
4526 |                                                                       |
4527 |                                                                       |
4528 +======================================================================*/
4529 --
4530 PROCEDURE InsertAnalyticalCriteria50
4531 IS
4532 l_rowcount           NUMBER;
4533 l_log_module         VARCHAR2(240);
4534 BEGIN
4535 --
4536 IF g_log_enabled THEN
4537       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria50';
4538 END IF;
4539 --
4540 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4541 
4542       trace
4543          (p_msg      => 'BEGIN of InsertAnalyticalCriteria50'
4544          ,p_level    => C_LEVEL_PROCEDURE
4545          ,p_module   => l_log_module);
4546 END IF;
4547 
4548 l_rowcount  := 0;
4549 
4550 BEGIN
4551 
4552    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4553 
4554       trace
4555          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
4556          ,p_level    => C_LEVEL_STATEMENT
4557          ,p_module   => l_log_module);
4558 
4559    END IF;
4560 
4561 INSERT ALL
4562 WHEN anc_id_1 IS NOT NULL and anc_id_1 not like 'DUMMY_ANC_%' THEN --Bug 8691573
4563   INTO xla_ae_line_acs (
4564         ae_header_id , ae_line_num , object_version_number
4565       , analytical_criterion_code
4566       , analytical_criterion_type_code
4567       , amb_context_code
4568       , ac1,ac2,ac3,ac4,ac5)
4569 VALUES (ae_header_id, ae_line_num, C_OVN
4570 ,SUBSTRB(anc_id_1
4571        ,1
4572        ,INSTRB(anc_id_1,'(]',1,1) -1)
4573 ,SUBSTRB(anc_id_1
4574        ,INSTRB(anc_id_1,'(]',1,1) + 2
4575        ,INSTRB(anc_id_1,'(]',1,2) -
4576         INSTRB(anc_id_1,'(]',1,1) - 2)
4577 ,SUBSTRB(anc_id_1
4578        ,INSTRB(anc_id_1,'(]',1,2) + 2
4579        ,INSTRB(anc_id_1,'(]',1,3) -
4580         INSTRB(anc_id_1,'(]',1,2) - 2)
4581 ,SUBSTRB(anc_id_1
4582        ,INSTRB(anc_id_1,'(]',1,3) + 2
4583        ,INSTRB(anc_id_1,'(]',1,4) -
4584         INSTRB(anc_id_1,'(]',1,3) - 2)
4585 ,SUBSTRB(anc_id_1
4586        ,INSTRB(anc_id_1,'(]',1,4) + 2
4587        ,INSTRB(anc_id_1,'(]',1,5) -
4588         INSTRB(anc_id_1,'(]',1,4) - 2)
4589 ,SUBSTRB(anc_id_1
4590        ,INSTRB(anc_id_1,'(]',1,5) + 2
4591        ,INSTRB(anc_id_1,'(]',1,6) -
4592         INSTRB(anc_id_1,'(]',1,5) - 2)
4593 ,SUBSTRB(anc_id_1
4594        ,INSTRB(anc_id_1,'(]',1,6) + 2
4595        ,INSTRB(anc_id_1,'(]',1,7) -
4596         INSTRB(anc_id_1,'(]',1,6) - 2)
4597 ,SUBSTRB(anc_id_1
4598        ,INSTRB(anc_id_1,'(]',1,7) + 2
4599        ,LENGTHB(anc_id_1))
4600 )
4601 
4602 WHEN anc_id_2 IS NOT NULL THEN
4603   INTO xla_ae_line_acs (
4604         ae_header_id , ae_line_num , object_version_number
4605       , analytical_criterion_code
4606       , analytical_criterion_type_code
4607       , amb_context_code
4608       , ac1,ac2,ac3,ac4,ac5)
4609 VALUES (ae_header_id, ae_line_num, C_OVN
4610 ,SUBSTRB(anc_id_2
4611        ,1
4612        ,INSTRB(anc_id_2,'(]',1,1) -1)
4613 ,SUBSTRB(anc_id_2
4614        ,INSTRB(anc_id_2,'(]',1,1) + 2
4615        ,INSTRB(anc_id_2,'(]',1,2) -
4616         INSTRB(anc_id_2,'(]',1,1) - 2)
4617 ,SUBSTRB(anc_id_2
4618        ,INSTRB(anc_id_2,'(]',1,2) + 2
4619        ,INSTRB(anc_id_2,'(]',1,3) -
4620         INSTRB(anc_id_2,'(]',1,2) - 2)
4621 ,SUBSTRB(anc_id_2
4622        ,INSTRB(anc_id_2,'(]',1,3) + 2
4623        ,INSTRB(anc_id_2,'(]',1,4) -
4624         INSTRB(anc_id_2,'(]',1,3) - 2)
4625 ,SUBSTRB(anc_id_2
4626        ,INSTRB(anc_id_2,'(]',1,4) + 2
4627        ,INSTRB(anc_id_2,'(]',1,5) -
4628         INSTRB(anc_id_2,'(]',1,4) - 2)
4629 ,SUBSTRB(anc_id_2
4630        ,INSTRB(anc_id_2,'(]',1,5) + 2
4631        ,INSTRB(anc_id_2,'(]',1,6) -
4632         INSTRB(anc_id_2,'(]',1,5) - 2)
4633 ,SUBSTRB(anc_id_2
4634        ,INSTRB(anc_id_2,'(]',1,6) + 2
4635        ,INSTRB(anc_id_2,'(]',1,7) -
4636         INSTRB(anc_id_2,'(]',1,6) - 2)
4637 ,SUBSTRB(anc_id_2
4638        ,INSTRB(anc_id_2,'(]',1,7) + 2
4639        ,LENGTHB(anc_id_2))
4640 )
4641 
4642 WHEN anc_id_3 IS NOT NULL THEN
4643   INTO xla_ae_line_acs (
4644         ae_header_id , ae_line_num , object_version_number
4645       , analytical_criterion_code
4646       , analytical_criterion_type_code
4647       , amb_context_code
4648       , ac1,ac2,ac3,ac4,ac5)
4649 VALUES (ae_header_id, ae_line_num, C_OVN
4650 ,SUBSTRB(anc_id_3
4651        ,1
4652        ,INSTRB(anc_id_3,'(]',1,1) -1)
4653 ,SUBSTRB(anc_id_3
4654        ,INSTRB(anc_id_3,'(]',1,1) + 2
4655        ,INSTRB(anc_id_3,'(]',1,2) -
4656         INSTRB(anc_id_3,'(]',1,1) - 2)
4657 ,SUBSTRB(anc_id_3
4658        ,INSTRB(anc_id_3,'(]',1,2) + 2
4659        ,INSTRB(anc_id_3,'(]',1,3) -
4660         INSTRB(anc_id_3,'(]',1,2) - 2)
4661 ,SUBSTRB(anc_id_3
4662        ,INSTRB(anc_id_3,'(]',1,3) + 2
4663        ,INSTRB(anc_id_3,'(]',1,4) -
4664         INSTRB(anc_id_3,'(]',1,3) - 2)
4665 ,SUBSTRB(anc_id_3
4666        ,INSTRB(anc_id_3,'(]',1,4) + 2
4667        ,INSTRB(anc_id_3,'(]',1,5) -
4668         INSTRB(anc_id_3,'(]',1,4) - 2)
4669 ,SUBSTRB(anc_id_3
4670        ,INSTRB(anc_id_3,'(]',1,5) + 2
4671        ,INSTRB(anc_id_3,'(]',1,6) -
4672         INSTRB(anc_id_3,'(]',1,5) - 2)
4673 ,SUBSTRB(anc_id_3
4674        ,INSTRB(anc_id_3,'(]',1,6) + 2
4675        ,INSTRB(anc_id_3,'(]',1,7) -
4676         INSTRB(anc_id_3,'(]',1,6) - 2)
4677 ,SUBSTRB(anc_id_3
4678        ,INSTRB(anc_id_3,'(]',1,7) + 2
4679        ,LENGTHB(anc_id_3))
4680 )
4681 
4682 WHEN anc_id_4 IS NOT NULL THEN
4683   INTO xla_ae_line_acs (
4684         ae_header_id , ae_line_num , object_version_number
4685       , analytical_criterion_code
4686       , analytical_criterion_type_code
4687       , amb_context_code
4688       , ac1,ac2,ac3,ac4,ac5)
4689 VALUES (ae_header_id, ae_line_num, C_OVN
4690 ,SUBSTRB(anc_id_4
4691        ,1
4692        ,INSTRB(anc_id_4,'(]',1,1) -1)
4693 ,SUBSTRB(anc_id_4
4694        ,INSTRB(anc_id_4,'(]',1,1) + 2
4695        ,INSTRB(anc_id_4,'(]',1,2) -
4696         INSTRB(anc_id_4,'(]',1,1) - 2)
4697 ,SUBSTRB(anc_id_4
4698        ,INSTRB(anc_id_4,'(]',1,2) + 2
4699        ,INSTRB(anc_id_4,'(]',1,3) -
4700         INSTRB(anc_id_4,'(]',1,2) - 2)
4701 ,SUBSTRB(anc_id_4
4702        ,INSTRB(anc_id_4,'(]',1,3) + 2
4703        ,INSTRB(anc_id_4,'(]',1,4) -
4704         INSTRB(anc_id_4,'(]',1,3) - 2)
4705 ,SUBSTRB(anc_id_4
4706        ,INSTRB(anc_id_4,'(]',1,4) + 2
4707        ,INSTRB(anc_id_4,'(]',1,5) -
4708         INSTRB(anc_id_4,'(]',1,4) - 2)
4709 ,SUBSTRB(anc_id_4
4710        ,INSTRB(anc_id_4,'(]',1,5) + 2
4711        ,INSTRB(anc_id_4,'(]',1,6) -
4712         INSTRB(anc_id_4,'(]',1,5) - 2)
4713 ,SUBSTRB(anc_id_4
4714        ,INSTRB(anc_id_4,'(]',1,6) + 2
4715        ,INSTRB(anc_id_4,'(]',1,7) -
4716         INSTRB(anc_id_4,'(]',1,6) - 2)
4717 ,SUBSTRB(anc_id_4
4718        ,INSTRB(anc_id_4,'(]',1,7) + 2
4719        ,LENGTHB(anc_id_4))
4720 )
4721 
4722 WHEN anc_id_5 IS NOT NULL THEN
4723   INTO xla_ae_line_acs (
4724         ae_header_id , ae_line_num , object_version_number
4725       , analytical_criterion_code
4726       , analytical_criterion_type_code
4727       , amb_context_code
4728       , ac1,ac2,ac3,ac4,ac5)
4729 VALUES (ae_header_id, ae_line_num, C_OVN
4730 ,SUBSTRB(anc_id_5
4731        ,1
4732        ,INSTRB(anc_id_5,'(]',1,1) -1)
4733 ,SUBSTRB(anc_id_5
4734        ,INSTRB(anc_id_5,'(]',1,1) + 2
4735        ,INSTRB(anc_id_5,'(]',1,2) -
4736         INSTRB(anc_id_5,'(]',1,1) - 2)
4737 ,SUBSTRB(anc_id_5
4738        ,INSTRB(anc_id_5,'(]',1,2) + 2
4739        ,INSTRB(anc_id_5,'(]',1,3) -
4740         INSTRB(anc_id_5,'(]',1,2) - 2)
4741 ,SUBSTRB(anc_id_5
4742        ,INSTRB(anc_id_5,'(]',1,3) + 2
4743        ,INSTRB(anc_id_5,'(]',1,4) -
4744         INSTRB(anc_id_5,'(]',1,3) - 2)
4745 ,SUBSTRB(anc_id_5
4746        ,INSTRB(anc_id_5,'(]',1,4) + 2
4747        ,INSTRB(anc_id_5,'(]',1,5) -
4748         INSTRB(anc_id_5,'(]',1,4) - 2)
4749 ,SUBSTRB(anc_id_5
4750        ,INSTRB(anc_id_5,'(]',1,5) + 2
4751        ,INSTRB(anc_id_5,'(]',1,6) -
4752         INSTRB(anc_id_5,'(]',1,5) - 2)
4753 ,SUBSTRB(anc_id_5
4754        ,INSTRB(anc_id_5,'(]',1,6) + 2
4755        ,INSTRB(anc_id_5,'(]',1,7) -
4756         INSTRB(anc_id_5,'(]',1,6) - 2)
4757 ,SUBSTRB(anc_id_5
4758        ,INSTRB(anc_id_5,'(]',1,7) + 2
4759        ,LENGTHB(anc_id_5))
4760 )
4761 
4762 WHEN anc_id_6 IS NOT NULL THEN
4763   INTO xla_ae_line_acs (
4764         ae_header_id , ae_line_num , object_version_number
4765       , analytical_criterion_code
4766       , analytical_criterion_type_code
4767       , amb_context_code
4768       , ac1,ac2,ac3,ac4,ac5)
4769 VALUES (ae_header_id, ae_line_num, C_OVN
4770 ,SUBSTRB(anc_id_6
4771        ,1
4772        ,INSTRB(anc_id_6,'(]',1,1) -1)
4773 ,SUBSTRB(anc_id_6
4774        ,INSTRB(anc_id_6,'(]',1,1) + 2
4775        ,INSTRB(anc_id_6,'(]',1,2) -
4776         INSTRB(anc_id_6,'(]',1,1) - 2)
4777 ,SUBSTRB(anc_id_6
4778        ,INSTRB(anc_id_6,'(]',1,2) + 2
4779        ,INSTRB(anc_id_6,'(]',1,3) -
4780         INSTRB(anc_id_6,'(]',1,2) - 2)
4781 ,SUBSTRB(anc_id_6
4782        ,INSTRB(anc_id_6,'(]',1,3) + 2
4783        ,INSTRB(anc_id_6,'(]',1,4) -
4784         INSTRB(anc_id_6,'(]',1,3) - 2)
4785 ,SUBSTRB(anc_id_6
4786        ,INSTRB(anc_id_6,'(]',1,4) + 2
4787        ,INSTRB(anc_id_6,'(]',1,5) -
4788         INSTRB(anc_id_6,'(]',1,4) - 2)
4789 ,SUBSTRB(anc_id_6
4790        ,INSTRB(anc_id_6,'(]',1,5) + 2
4791        ,INSTRB(anc_id_6,'(]',1,6) -
4792         INSTRB(anc_id_6,'(]',1,5) - 2)
4793 ,SUBSTRB(anc_id_6
4794        ,INSTRB(anc_id_6,'(]',1,6) + 2
4795        ,INSTRB(anc_id_6,'(]',1,7) -
4796         INSTRB(anc_id_6,'(]',1,6) - 2)
4797 ,SUBSTRB(anc_id_6
4798        ,INSTRB(anc_id_6,'(]',1,7) + 2
4799        ,LENGTHB(anc_id_6))
4800 )
4801 
4802 WHEN anc_id_7 IS NOT NULL THEN
4803   INTO xla_ae_line_acs (
4804         ae_header_id , ae_line_num , object_version_number
4805       , analytical_criterion_code
4806       , analytical_criterion_type_code
4807       , amb_context_code
4808       , ac1,ac2,ac3,ac4,ac5)
4809 VALUES (ae_header_id, ae_line_num, C_OVN
4810 ,SUBSTRB(anc_id_7
4811        ,1
4812        ,INSTRB(anc_id_7,'(]',1,1) -1)
4813 ,SUBSTRB(anc_id_7
4814        ,INSTRB(anc_id_7,'(]',1,1) + 2
4815        ,INSTRB(anc_id_7,'(]',1,2) -
4816         INSTRB(anc_id_7,'(]',1,1) - 2)
4817 ,SUBSTRB(anc_id_7
4818        ,INSTRB(anc_id_7,'(]',1,2) + 2
4819        ,INSTRB(anc_id_7,'(]',1,3) -
4820         INSTRB(anc_id_7,'(]',1,2) - 2)
4821 ,SUBSTRB(anc_id_7
4822        ,INSTRB(anc_id_7,'(]',1,3) + 2
4823        ,INSTRB(anc_id_7,'(]',1,4) -
4824         INSTRB(anc_id_7,'(]',1,3) - 2)
4825 ,SUBSTRB(anc_id_7
4826        ,INSTRB(anc_id_7,'(]',1,4) + 2
4827        ,INSTRB(anc_id_7,'(]',1,5) -
4828         INSTRB(anc_id_7,'(]',1,4) - 2)
4829 ,SUBSTRB(anc_id_7
4830        ,INSTRB(anc_id_7,'(]',1,5) + 2
4831        ,INSTRB(anc_id_7,'(]',1,6) -
4832         INSTRB(anc_id_7,'(]',1,5) - 2)
4833 ,SUBSTRB(anc_id_7
4834        ,INSTRB(anc_id_7,'(]',1,6) + 2
4835        ,INSTRB(anc_id_7,'(]',1,7) -
4836         INSTRB(anc_id_7,'(]',1,6) - 2)
4837 ,SUBSTRB(anc_id_7
4838        ,INSTRB(anc_id_7,'(]',1,7) + 2
4839        ,LENGTHB(anc_id_7))
4840 )
4841 
4842 WHEN anc_id_8 IS NOT NULL THEN
4843   INTO xla_ae_line_acs (
4844         ae_header_id , ae_line_num , object_version_number
4845       , analytical_criterion_code
4846       , analytical_criterion_type_code
4847       , amb_context_code
4848       , ac1,ac2,ac3,ac4,ac5)
4849 VALUES (ae_header_id, ae_line_num, C_OVN
4850 ,SUBSTRB(anc_id_8
4851        ,1
4852        ,INSTRB(anc_id_8,'(]',1,1) -1)
4853 ,SUBSTRB(anc_id_8
4854        ,INSTRB(anc_id_8,'(]',1,1) + 2
4855        ,INSTRB(anc_id_8,'(]',1,2) -
4856         INSTRB(anc_id_8,'(]',1,1) - 2)
4857 ,SUBSTRB(anc_id_8
4858        ,INSTRB(anc_id_8,'(]',1,2) + 2
4859        ,INSTRB(anc_id_8,'(]',1,3) -
4860         INSTRB(anc_id_8,'(]',1,2) - 2)
4861 ,SUBSTRB(anc_id_8
4862        ,INSTRB(anc_id_8,'(]',1,3) + 2
4863        ,INSTRB(anc_id_8,'(]',1,4) -
4864         INSTRB(anc_id_8,'(]',1,3) - 2)
4865 ,SUBSTRB(anc_id_8
4866        ,INSTRB(anc_id_8,'(]',1,4) + 2
4867        ,INSTRB(anc_id_8,'(]',1,5) -
4868         INSTRB(anc_id_8,'(]',1,4) - 2)
4869 ,SUBSTRB(anc_id_8
4870        ,INSTRB(anc_id_8,'(]',1,5) + 2
4871        ,INSTRB(anc_id_8,'(]',1,6) -
4872         INSTRB(anc_id_8,'(]',1,5) - 2)
4873 ,SUBSTRB(anc_id_8
4874        ,INSTRB(anc_id_8,'(]',1,6) + 2
4875        ,INSTRB(anc_id_8,'(]',1,7) -
4876         INSTRB(anc_id_8,'(]',1,6) - 2)
4877 ,SUBSTRB(anc_id_8
4878        ,INSTRB(anc_id_8,'(]',1,7) + 2
4879        ,LENGTHB(anc_id_8))
4880 )
4881 
4882 WHEN anc_id_9 IS NOT NULL THEN
4883   INTO xla_ae_line_acs (
4884         ae_header_id , ae_line_num , object_version_number
4885       , analytical_criterion_code
4886       , analytical_criterion_type_code
4887       , amb_context_code
4888       , ac1,ac2,ac3,ac4,ac5)
4889 VALUES (ae_header_id, ae_line_num, C_OVN
4890 ,SUBSTRB(anc_id_9
4891        ,1
4892        ,INSTRB(anc_id_9,'(]',1,1) -1)
4893 ,SUBSTRB(anc_id_9
4894        ,INSTRB(anc_id_9,'(]',1,1) + 2
4895        ,INSTRB(anc_id_9,'(]',1,2) -
4896         INSTRB(anc_id_9,'(]',1,1) - 2)
4897 ,SUBSTRB(anc_id_9
4898        ,INSTRB(anc_id_9,'(]',1,2) + 2
4899        ,INSTRB(anc_id_9,'(]',1,3) -
4900         INSTRB(anc_id_9,'(]',1,2) - 2)
4901 ,SUBSTRB(anc_id_9
4902        ,INSTRB(anc_id_9,'(]',1,3) + 2
4903        ,INSTRB(anc_id_9,'(]',1,4) -
4904         INSTRB(anc_id_9,'(]',1,3) - 2)
4905 ,SUBSTRB(anc_id_9
4906        ,INSTRB(anc_id_9,'(]',1,4) + 2
4907        ,INSTRB(anc_id_9,'(]',1,5) -
4908         INSTRB(anc_id_9,'(]',1,4) - 2)
4909 ,SUBSTRB(anc_id_9
4910        ,INSTRB(anc_id_9,'(]',1,5) + 2
4911        ,INSTRB(anc_id_9,'(]',1,6) -
4912         INSTRB(anc_id_9,'(]',1,5) - 2)
4913 ,SUBSTRB(anc_id_9
4914        ,INSTRB(anc_id_9,'(]',1,6) + 2
4915        ,INSTRB(anc_id_9,'(]',1,7) -
4916         INSTRB(anc_id_9,'(]',1,6) - 2)
4917 ,SUBSTRB(anc_id_9
4918        ,INSTRB(anc_id_9,'(]',1,7) + 2
4919        ,LENGTHB(anc_id_9))
4920 )
4921 
4922 WHEN anc_id_10 IS NOT NULL THEN
4923   INTO xla_ae_line_acs (
4924         ae_header_id , ae_line_num , object_version_number
4925       , analytical_criterion_code
4926       , analytical_criterion_type_code
4927       , amb_context_code
4928       , ac1,ac2,ac3,ac4,ac5)
4929 VALUES (ae_header_id, ae_line_num, C_OVN
4930 ,SUBSTRB(anc_id_10
4931        ,1
4932        ,INSTRB(anc_id_10,'(]',1,1) -1)
4933 ,SUBSTRB(anc_id_10
4934        ,INSTRB(anc_id_10,'(]',1,1) + 2
4935        ,INSTRB(anc_id_10,'(]',1,2) -
4936         INSTRB(anc_id_10,'(]',1,1) - 2)
4937 ,SUBSTRB(anc_id_10
4938        ,INSTRB(anc_id_10,'(]',1,2) + 2
4939        ,INSTRB(anc_id_10,'(]',1,3) -
4940         INSTRB(anc_id_10,'(]',1,2) - 2)
4941 ,SUBSTRB(anc_id_10
4942        ,INSTRB(anc_id_10,'(]',1,3) + 2
4943        ,INSTRB(anc_id_10,'(]',1,4) -
4944         INSTRB(anc_id_10,'(]',1,3) - 2)
4945 ,SUBSTRB(anc_id_10
4946        ,INSTRB(anc_id_10,'(]',1,4) + 2
4947        ,INSTRB(anc_id_10,'(]',1,5) -
4948         INSTRB(anc_id_10,'(]',1,4) - 2)
4949 ,SUBSTRB(anc_id_10
4950        ,INSTRB(anc_id_10,'(]',1,5) + 2
4951        ,INSTRB(anc_id_10,'(]',1,6) -
4952         INSTRB(anc_id_10,'(]',1,5) - 2)
4953 ,SUBSTRB(anc_id_10
4954        ,INSTRB(anc_id_10,'(]',1,6) + 2
4955        ,INSTRB(anc_id_10,'(]',1,7) -
4956         INSTRB(anc_id_10,'(]',1,6) - 2)
4957 ,SUBSTRB(anc_id_10
4958        ,INSTRB(anc_id_10,'(]',1,7) + 2
4959        ,LENGTHB(anc_id_10))
4960 )
4961 
4962 WHEN anc_id_11 IS NOT NULL THEN
4963   INTO xla_ae_line_acs (
4964         ae_header_id , ae_line_num , object_version_number
4965       , analytical_criterion_code
4966       , analytical_criterion_type_code
4967       , amb_context_code
4968       , ac1,ac2,ac3,ac4,ac5)
4969 VALUES (ae_header_id, ae_line_num, C_OVN
4970 ,SUBSTRB(anc_id_11
4971        ,1
4972        ,INSTRB(anc_id_11,'(]',1,1) -1)
4973 ,SUBSTRB(anc_id_11
4974        ,INSTRB(anc_id_11,'(]',1,1) + 2
4975        ,INSTRB(anc_id_11,'(]',1,2) -
4976         INSTRB(anc_id_11,'(]',1,1) - 2)
4977 ,SUBSTRB(anc_id_11
4978        ,INSTRB(anc_id_11,'(]',1,2) + 2
4979        ,INSTRB(anc_id_11,'(]',1,3) -
4980         INSTRB(anc_id_11,'(]',1,2) - 2)
4981 ,SUBSTRB(anc_id_11
4982        ,INSTRB(anc_id_11,'(]',1,3) + 2
4983        ,INSTRB(anc_id_11,'(]',1,4) -
4984         INSTRB(anc_id_11,'(]',1,3) - 2)
4985 ,SUBSTRB(anc_id_11
4986        ,INSTRB(anc_id_11,'(]',1,4) + 2
4987        ,INSTRB(anc_id_11,'(]',1,5) -
4988         INSTRB(anc_id_11,'(]',1,4) - 2)
4989 ,SUBSTRB(anc_id_11
4990        ,INSTRB(anc_id_11,'(]',1,5) + 2
4991        ,INSTRB(anc_id_11,'(]',1,6) -
4992         INSTRB(anc_id_11,'(]',1,5) - 2)
4993 ,SUBSTRB(anc_id_11
4994        ,INSTRB(anc_id_11,'(]',1,6) + 2
4995        ,INSTRB(anc_id_11,'(]',1,7) -
4996         INSTRB(anc_id_11,'(]',1,6) - 2)
4997 ,SUBSTRB(anc_id_11
4998        ,INSTRB(anc_id_11,'(]',1,7) + 2
4999        ,LENGTHB(anc_id_11))
5000 )
5001 
5002 WHEN anc_id_12 IS NOT NULL THEN
5003   INTO xla_ae_line_acs (
5004         ae_header_id , ae_line_num , object_version_number
5005       , analytical_criterion_code
5006       , analytical_criterion_type_code
5007       , amb_context_code
5008       , ac1,ac2,ac3,ac4,ac5)
5009 VALUES (ae_header_id, ae_line_num, C_OVN
5010 ,SUBSTRB(anc_id_12
5011        ,1
5012        ,INSTRB(anc_id_12,'(]',1,1) -1)
5013 ,SUBSTRB(anc_id_12
5014        ,INSTRB(anc_id_12,'(]',1,1) + 2
5015        ,INSTRB(anc_id_12,'(]',1,2) -
5016         INSTRB(anc_id_12,'(]',1,1) - 2)
5017 ,SUBSTRB(anc_id_12
5018        ,INSTRB(anc_id_12,'(]',1,2) + 2
5019        ,INSTRB(anc_id_12,'(]',1,3) -
5020         INSTRB(anc_id_12,'(]',1,2) - 2)
5021 ,SUBSTRB(anc_id_12
5022        ,INSTRB(anc_id_12,'(]',1,3) + 2
5023        ,INSTRB(anc_id_12,'(]',1,4) -
5024         INSTRB(anc_id_12,'(]',1,3) - 2)
5025 ,SUBSTRB(anc_id_12
5026        ,INSTRB(anc_id_12,'(]',1,4) + 2
5027        ,INSTRB(anc_id_12,'(]',1,5) -
5028         INSTRB(anc_id_12,'(]',1,4) - 2)
5029 ,SUBSTRB(anc_id_12
5030        ,INSTRB(anc_id_12,'(]',1,5) + 2
5031        ,INSTRB(anc_id_12,'(]',1,6) -
5032         INSTRB(anc_id_12,'(]',1,5) - 2)
5033 ,SUBSTRB(anc_id_12
5034        ,INSTRB(anc_id_12,'(]',1,6) + 2
5035        ,INSTRB(anc_id_12,'(]',1,7) -
5036         INSTRB(anc_id_12,'(]',1,6) - 2)
5037 ,SUBSTRB(anc_id_12
5038        ,INSTRB(anc_id_12,'(]',1,7) + 2
5039        ,LENGTHB(anc_id_12))
5040 )
5041 
5042 WHEN anc_id_13 IS NOT NULL THEN
5043   INTO xla_ae_line_acs (
5044         ae_header_id , ae_line_num , object_version_number
5045       , analytical_criterion_code
5046       , analytical_criterion_type_code
5047       , amb_context_code
5048       , ac1,ac2,ac3,ac4,ac5)
5049 VALUES (ae_header_id, ae_line_num, C_OVN
5050 ,SUBSTRB(anc_id_13
5051        ,1
5052        ,INSTRB(anc_id_13,'(]',1,1) -1)
5053 ,SUBSTRB(anc_id_13
5054        ,INSTRB(anc_id_13,'(]',1,1) + 2
5055        ,INSTRB(anc_id_13,'(]',1,2) -
5056         INSTRB(anc_id_13,'(]',1,1) - 2)
5057 ,SUBSTRB(anc_id_13
5058        ,INSTRB(anc_id_13,'(]',1,2) + 2
5059        ,INSTRB(anc_id_13,'(]',1,3) -
5060         INSTRB(anc_id_13,'(]',1,2) - 2)
5061 ,SUBSTRB(anc_id_13
5062        ,INSTRB(anc_id_13,'(]',1,3) + 2
5063        ,INSTRB(anc_id_13,'(]',1,4) -
5064         INSTRB(anc_id_13,'(]',1,3) - 2)
5065 ,SUBSTRB(anc_id_13
5066        ,INSTRB(anc_id_13,'(]',1,4) + 2
5067        ,INSTRB(anc_id_13,'(]',1,5) -
5068         INSTRB(anc_id_13,'(]',1,4) - 2)
5069 ,SUBSTRB(anc_id_13
5070        ,INSTRB(anc_id_13,'(]',1,5) + 2
5071        ,INSTRB(anc_id_13,'(]',1,6) -
5072         INSTRB(anc_id_13,'(]',1,5) - 2)
5073 ,SUBSTRB(anc_id_13
5074        ,INSTRB(anc_id_13,'(]',1,6) + 2
5075        ,INSTRB(anc_id_13,'(]',1,7) -
5076         INSTRB(anc_id_13,'(]',1,6) - 2)
5077 ,SUBSTRB(anc_id_13
5078        ,INSTRB(anc_id_13,'(]',1,7) + 2
5079        ,LENGTHB(anc_id_13))
5080 )
5081 
5082 WHEN anc_id_14 IS NOT NULL THEN
5083   INTO xla_ae_line_acs (
5084         ae_header_id , ae_line_num , object_version_number
5085       , analytical_criterion_code
5086       , analytical_criterion_type_code
5087       , amb_context_code
5088       , ac1,ac2,ac3,ac4,ac5)
5089 VALUES (ae_header_id, ae_line_num, C_OVN
5090 ,SUBSTRB(anc_id_14
5091        ,1
5092        ,INSTRB(anc_id_14,'(]',1,1) -1)
5093 ,SUBSTRB(anc_id_14
5094        ,INSTRB(anc_id_14,'(]',1,1) + 2
5095        ,INSTRB(anc_id_14,'(]',1,2) -
5096         INSTRB(anc_id_14,'(]',1,1) - 2)
5097 ,SUBSTRB(anc_id_14
5098        ,INSTRB(anc_id_14,'(]',1,2) + 2
5099        ,INSTRB(anc_id_14,'(]',1,3) -
5100         INSTRB(anc_id_14,'(]',1,2) - 2)
5101 ,SUBSTRB(anc_id_14
5102        ,INSTRB(anc_id_14,'(]',1,3) + 2
5103        ,INSTRB(anc_id_14,'(]',1,4) -
5104         INSTRB(anc_id_14,'(]',1,3) - 2)
5105 ,SUBSTRB(anc_id_14
5106        ,INSTRB(anc_id_14,'(]',1,4) + 2
5107        ,INSTRB(anc_id_14,'(]',1,5) -
5108         INSTRB(anc_id_14,'(]',1,4) - 2)
5109 ,SUBSTRB(anc_id_14
5110        ,INSTRB(anc_id_14,'(]',1,5) + 2
5111        ,INSTRB(anc_id_14,'(]',1,6) -
5112         INSTRB(anc_id_14,'(]',1,5) - 2)
5113 ,SUBSTRB(anc_id_14
5114        ,INSTRB(anc_id_14,'(]',1,6) + 2
5115        ,INSTRB(anc_id_14,'(]',1,7) -
5116         INSTRB(anc_id_14,'(]',1,6) - 2)
5117 ,SUBSTRB(anc_id_14
5118        ,INSTRB(anc_id_14,'(]',1,7) + 2
5119        ,LENGTHB(anc_id_14))
5120 )
5121 
5122 WHEN anc_id_15 IS NOT NULL THEN
5123   INTO xla_ae_line_acs (
5124         ae_header_id , ae_line_num , object_version_number
5125       , analytical_criterion_code
5126       , analytical_criterion_type_code
5127       , amb_context_code
5128       , ac1,ac2,ac3,ac4,ac5)
5129 VALUES (ae_header_id, ae_line_num, C_OVN
5130 ,SUBSTRB(anc_id_15
5131        ,1
5132        ,INSTRB(anc_id_15,'(]',1,1) -1)
5133 ,SUBSTRB(anc_id_15
5134        ,INSTRB(anc_id_15,'(]',1,1) + 2
5135        ,INSTRB(anc_id_15,'(]',1,2) -
5136         INSTRB(anc_id_15,'(]',1,1) - 2)
5137 ,SUBSTRB(anc_id_15
5138        ,INSTRB(anc_id_15,'(]',1,2) + 2
5139        ,INSTRB(anc_id_15,'(]',1,3) -
5140         INSTRB(anc_id_15,'(]',1,2) - 2)
5141 ,SUBSTRB(anc_id_15
5142        ,INSTRB(anc_id_15,'(]',1,3) + 2
5143        ,INSTRB(anc_id_15,'(]',1,4) -
5144         INSTRB(anc_id_15,'(]',1,3) - 2)
5145 ,SUBSTRB(anc_id_15
5146        ,INSTRB(anc_id_15,'(]',1,4) + 2
5147        ,INSTRB(anc_id_15,'(]',1,5) -
5148         INSTRB(anc_id_15,'(]',1,4) - 2)
5149 ,SUBSTRB(anc_id_15
5150        ,INSTRB(anc_id_15,'(]',1,5) + 2
5151        ,INSTRB(anc_id_15,'(]',1,6) -
5152         INSTRB(anc_id_15,'(]',1,5) - 2)
5153 ,SUBSTRB(anc_id_15
5154        ,INSTRB(anc_id_15,'(]',1,6) + 2
5155        ,INSTRB(anc_id_15,'(]',1,7) -
5156         INSTRB(anc_id_15,'(]',1,6) - 2)
5157 ,SUBSTRB(anc_id_15
5158        ,INSTRB(anc_id_15,'(]',1,7) + 2
5159        ,LENGTHB(anc_id_15))
5160 )
5161 
5162 WHEN anc_id_16 IS NOT NULL THEN
5163   INTO xla_ae_line_acs (
5164         ae_header_id , ae_line_num , object_version_number
5165       , analytical_criterion_code
5166       , analytical_criterion_type_code
5167       , amb_context_code
5168       , ac1,ac2,ac3,ac4,ac5)
5169 VALUES (ae_header_id, ae_line_num, C_OVN
5170 ,SUBSTRB(anc_id_16
5171        ,1
5172        ,INSTRB(anc_id_16,'(]',1,1) -1)
5173 ,SUBSTRB(anc_id_16
5174        ,INSTRB(anc_id_16,'(]',1,1) + 2
5175        ,INSTRB(anc_id_16,'(]',1,2) -
5176         INSTRB(anc_id_16,'(]',1,1) - 2)
5177 ,SUBSTRB(anc_id_16
5178        ,INSTRB(anc_id_16,'(]',1,2) + 2
5179        ,INSTRB(anc_id_16,'(]',1,3) -
5180         INSTRB(anc_id_16,'(]',1,2) - 2)
5181 ,SUBSTRB(anc_id_16
5182        ,INSTRB(anc_id_16,'(]',1,3) + 2
5183        ,INSTRB(anc_id_16,'(]',1,4) -
5184         INSTRB(anc_id_16,'(]',1,3) - 2)
5185 ,SUBSTRB(anc_id_16
5186        ,INSTRB(anc_id_16,'(]',1,4) + 2
5187        ,INSTRB(anc_id_16,'(]',1,5) -
5188         INSTRB(anc_id_16,'(]',1,4) - 2)
5189 ,SUBSTRB(anc_id_16
5190        ,INSTRB(anc_id_16,'(]',1,5) + 2
5191        ,INSTRB(anc_id_16,'(]',1,6) -
5192         INSTRB(anc_id_16,'(]',1,5) - 2)
5193 ,SUBSTRB(anc_id_16
5194        ,INSTRB(anc_id_16,'(]',1,6) + 2
5195        ,INSTRB(anc_id_16,'(]',1,7) -
5196         INSTRB(anc_id_16,'(]',1,6) - 2)
5197 ,SUBSTRB(anc_id_16
5198        ,INSTRB(anc_id_16,'(]',1,7) + 2
5199        ,LENGTHB(anc_id_16))
5200 )
5201 
5202 WHEN anc_id_17 IS NOT NULL THEN
5203   INTO xla_ae_line_acs (
5204         ae_header_id , ae_line_num , object_version_number
5205       , analytical_criterion_code
5206       , analytical_criterion_type_code
5207       , amb_context_code
5208       , ac1,ac2,ac3,ac4,ac5)
5209 VALUES (ae_header_id, ae_line_num, C_OVN
5210 ,SUBSTRB(anc_id_17
5211        ,1
5212        ,INSTRB(anc_id_17,'(]',1,1) -1)
5213 ,SUBSTRB(anc_id_17
5214        ,INSTRB(anc_id_17,'(]',1,1) + 2
5215        ,INSTRB(anc_id_17,'(]',1,2) -
5216         INSTRB(anc_id_17,'(]',1,1) - 2)
5217 ,SUBSTRB(anc_id_17
5218        ,INSTRB(anc_id_17,'(]',1,2) + 2
5219        ,INSTRB(anc_id_17,'(]',1,3) -
5220         INSTRB(anc_id_17,'(]',1,2) - 2)
5221 ,SUBSTRB(anc_id_17
5222        ,INSTRB(anc_id_17,'(]',1,3) + 2
5223        ,INSTRB(anc_id_17,'(]',1,4) -
5224         INSTRB(anc_id_17,'(]',1,3) - 2)
5225 ,SUBSTRB(anc_id_17
5226        ,INSTRB(anc_id_17,'(]',1,4) + 2
5227        ,INSTRB(anc_id_17,'(]',1,5) -
5228         INSTRB(anc_id_17,'(]',1,4) - 2)
5229 ,SUBSTRB(anc_id_17
5230        ,INSTRB(anc_id_17,'(]',1,5) + 2
5231        ,INSTRB(anc_id_17,'(]',1,6) -
5232         INSTRB(anc_id_17,'(]',1,5) - 2)
5233 ,SUBSTRB(anc_id_17
5234        ,INSTRB(anc_id_17,'(]',1,6) + 2
5235        ,INSTRB(anc_id_17,'(]',1,7) -
5236         INSTRB(anc_id_17,'(]',1,6) - 2)
5237 ,SUBSTRB(anc_id_17
5238        ,INSTRB(anc_id_17,'(]',1,7) + 2
5239        ,LENGTHB(anc_id_17))
5240 )
5241 
5242 WHEN anc_id_18 IS NOT NULL THEN
5243   INTO xla_ae_line_acs (
5244         ae_header_id , ae_line_num , object_version_number
5245       , analytical_criterion_code
5246       , analytical_criterion_type_code
5247       , amb_context_code
5248       , ac1,ac2,ac3,ac4,ac5)
5249 VALUES (ae_header_id, ae_line_num, C_OVN
5250 ,SUBSTRB(anc_id_18
5251        ,1
5252        ,INSTRB(anc_id_18,'(]',1,1) -1)
5253 ,SUBSTRB(anc_id_18
5254        ,INSTRB(anc_id_18,'(]',1,1) + 2
5255        ,INSTRB(anc_id_18,'(]',1,2) -
5256         INSTRB(anc_id_18,'(]',1,1) - 2)
5257 ,SUBSTRB(anc_id_18
5258        ,INSTRB(anc_id_18,'(]',1,2) + 2
5259        ,INSTRB(anc_id_18,'(]',1,3) -
5260         INSTRB(anc_id_18,'(]',1,2) - 2)
5261 ,SUBSTRB(anc_id_18
5262        ,INSTRB(anc_id_18,'(]',1,3) + 2
5263        ,INSTRB(anc_id_18,'(]',1,4) -
5264         INSTRB(anc_id_18,'(]',1,3) - 2)
5265 ,SUBSTRB(anc_id_18
5266        ,INSTRB(anc_id_18,'(]',1,4) + 2
5267        ,INSTRB(anc_id_18,'(]',1,5) -
5268         INSTRB(anc_id_18,'(]',1,4) - 2)
5269 ,SUBSTRB(anc_id_18
5270        ,INSTRB(anc_id_18,'(]',1,5) + 2
5271        ,INSTRB(anc_id_18,'(]',1,6) -
5272         INSTRB(anc_id_18,'(]',1,5) - 2)
5273 ,SUBSTRB(anc_id_18
5274        ,INSTRB(anc_id_18,'(]',1,6) + 2
5275        ,INSTRB(anc_id_18,'(]',1,7) -
5276         INSTRB(anc_id_18,'(]',1,6) - 2)
5277 ,SUBSTRB(anc_id_18
5278        ,INSTRB(anc_id_18,'(]',1,7) + 2
5279        ,LENGTHB(anc_id_18))
5280 )
5281 
5282 WHEN anc_id_19 IS NOT NULL THEN
5283   INTO xla_ae_line_acs (
5284         ae_header_id , ae_line_num , object_version_number
5285       , analytical_criterion_code
5286       , analytical_criterion_type_code
5287       , amb_context_code
5288       , ac1,ac2,ac3,ac4,ac5)
5289 VALUES (ae_header_id, ae_line_num, C_OVN
5290 ,SUBSTRB(anc_id_19
5291        ,1
5292        ,INSTRB(anc_id_19,'(]',1,1) -1)
5293 ,SUBSTRB(anc_id_19
5294        ,INSTRB(anc_id_19,'(]',1,1) + 2
5295        ,INSTRB(anc_id_19,'(]',1,2) -
5296         INSTRB(anc_id_19,'(]',1,1) - 2)
5297 ,SUBSTRB(anc_id_19
5298        ,INSTRB(anc_id_19,'(]',1,2) + 2
5299        ,INSTRB(anc_id_19,'(]',1,3) -
5300         INSTRB(anc_id_19,'(]',1,2) - 2)
5301 ,SUBSTRB(anc_id_19
5302        ,INSTRB(anc_id_19,'(]',1,3) + 2
5303        ,INSTRB(anc_id_19,'(]',1,4) -
5304         INSTRB(anc_id_19,'(]',1,3) - 2)
5305 ,SUBSTRB(anc_id_19
5306        ,INSTRB(anc_id_19,'(]',1,4) + 2
5307        ,INSTRB(anc_id_19,'(]',1,5) -
5308         INSTRB(anc_id_19,'(]',1,4) - 2)
5309 ,SUBSTRB(anc_id_19
5310        ,INSTRB(anc_id_19,'(]',1,5) + 2
5311        ,INSTRB(anc_id_19,'(]',1,6) -
5312         INSTRB(anc_id_19,'(]',1,5) - 2)
5313 ,SUBSTRB(anc_id_19
5314        ,INSTRB(anc_id_19,'(]',1,6) + 2
5315        ,INSTRB(anc_id_19,'(]',1,7) -
5316         INSTRB(anc_id_19,'(]',1,6) - 2)
5317 ,SUBSTRB(anc_id_19
5318        ,INSTRB(anc_id_19,'(]',1,7) + 2
5319        ,LENGTHB(anc_id_19))
5320 )
5321 
5322 WHEN anc_id_20 IS NOT NULL THEN
5323   INTO xla_ae_line_acs (
5324         ae_header_id , ae_line_num , object_version_number
5325       , analytical_criterion_code
5326       , analytical_criterion_type_code
5327       , amb_context_code
5328       , ac1,ac2,ac3,ac4,ac5)
5329 VALUES (ae_header_id, ae_line_num, C_OVN
5330 ,SUBSTRB(anc_id_20
5331        ,1
5332        ,INSTRB(anc_id_20,'(]',1,1) -1)
5333 ,SUBSTRB(anc_id_20
5334        ,INSTRB(anc_id_20,'(]',1,1) + 2
5335        ,INSTRB(anc_id_20,'(]',1,2) -
5336         INSTRB(anc_id_20,'(]',1,1) - 2)
5337 ,SUBSTRB(anc_id_20
5338        ,INSTRB(anc_id_20,'(]',1,2) + 2
5339        ,INSTRB(anc_id_20,'(]',1,3) -
5340         INSTRB(anc_id_20,'(]',1,2) - 2)
5341 ,SUBSTRB(anc_id_20
5342        ,INSTRB(anc_id_20,'(]',1,3) + 2
5343        ,INSTRB(anc_id_20,'(]',1,4) -
5344         INSTRB(anc_id_20,'(]',1,3) - 2)
5345 ,SUBSTRB(anc_id_20
5346        ,INSTRB(anc_id_20,'(]',1,4) + 2
5347        ,INSTRB(anc_id_20,'(]',1,5) -
5348         INSTRB(anc_id_20,'(]',1,4) - 2)
5349 ,SUBSTRB(anc_id_20
5350        ,INSTRB(anc_id_20,'(]',1,5) + 2
5351        ,INSTRB(anc_id_20,'(]',1,6) -
5352         INSTRB(anc_id_20,'(]',1,5) - 2)
5353 ,SUBSTRB(anc_id_20
5354        ,INSTRB(anc_id_20,'(]',1,6) + 2
5355        ,INSTRB(anc_id_20,'(]',1,7) -
5356         INSTRB(anc_id_20,'(]',1,6) - 2)
5357 ,SUBSTRB(anc_id_20
5358        ,INSTRB(anc_id_20,'(]',1,7) + 2
5359        ,LENGTHB(anc_id_20))
5360 )
5361 
5362 WHEN anc_id_21 IS NOT NULL THEN
5363   INTO xla_ae_line_acs (
5364         ae_header_id , ae_line_num , object_version_number
5365       , analytical_criterion_code
5366       , analytical_criterion_type_code
5367       , amb_context_code
5368       , ac1,ac2,ac3,ac4,ac5)
5369 VALUES (ae_header_id, ae_line_num, C_OVN
5370 ,SUBSTRB(anc_id_21
5371        ,1
5372        ,INSTRB(anc_id_21,'(]',1,1) -1)
5373 ,SUBSTRB(anc_id_21
5374        ,INSTRB(anc_id_21,'(]',1,1) + 2
5375        ,INSTRB(anc_id_21,'(]',1,2) -
5376         INSTRB(anc_id_21,'(]',1,1) - 2)
5377 ,SUBSTRB(anc_id_21
5378        ,INSTRB(anc_id_21,'(]',1,2) + 2
5379        ,INSTRB(anc_id_21,'(]',1,3) -
5380         INSTRB(anc_id_21,'(]',1,2) - 2)
5381 ,SUBSTRB(anc_id_21
5382        ,INSTRB(anc_id_21,'(]',1,3) + 2
5383        ,INSTRB(anc_id_21,'(]',1,4) -
5384         INSTRB(anc_id_21,'(]',1,3) - 2)
5385 ,SUBSTRB(anc_id_21
5386        ,INSTRB(anc_id_21,'(]',1,4) + 2
5387        ,INSTRB(anc_id_21,'(]',1,5) -
5388         INSTRB(anc_id_21,'(]',1,4) - 2)
5389 ,SUBSTRB(anc_id_21
5390        ,INSTRB(anc_id_21,'(]',1,5) + 2
5391        ,INSTRB(anc_id_21,'(]',1,6) -
5392         INSTRB(anc_id_21,'(]',1,5) - 2)
5393 ,SUBSTRB(anc_id_21
5394        ,INSTRB(anc_id_21,'(]',1,6) + 2
5395        ,INSTRB(anc_id_21,'(]',1,7) -
5396         INSTRB(anc_id_21,'(]',1,6) - 2)
5397 ,SUBSTRB(anc_id_21
5398        ,INSTRB(anc_id_21,'(]',1,7) + 2
5399        ,LENGTHB(anc_id_21))
5400 )
5401 
5402 WHEN anc_id_22 IS NOT NULL THEN
5403   INTO xla_ae_line_acs (
5404         ae_header_id , ae_line_num , object_version_number
5405       , analytical_criterion_code
5406       , analytical_criterion_type_code
5407       , amb_context_code
5408       , ac1,ac2,ac3,ac4,ac5)
5409 VALUES (ae_header_id, ae_line_num, C_OVN
5410 ,SUBSTRB(anc_id_22
5411        ,1
5412        ,INSTRB(anc_id_22,'(]',1,1) -1)
5413 ,SUBSTRB(anc_id_22
5414        ,INSTRB(anc_id_22,'(]',1,1) + 2
5415        ,INSTRB(anc_id_22,'(]',1,2) -
5416         INSTRB(anc_id_22,'(]',1,1) - 2)
5417 ,SUBSTRB(anc_id_22
5418        ,INSTRB(anc_id_22,'(]',1,2) + 2
5419        ,INSTRB(anc_id_22,'(]',1,3) -
5420         INSTRB(anc_id_22,'(]',1,2) - 2)
5421 ,SUBSTRB(anc_id_22
5422        ,INSTRB(anc_id_22,'(]',1,3) + 2
5423        ,INSTRB(anc_id_22,'(]',1,4) -
5424         INSTRB(anc_id_22,'(]',1,3) - 2)
5425 ,SUBSTRB(anc_id_22
5426        ,INSTRB(anc_id_22,'(]',1,4) + 2
5427        ,INSTRB(anc_id_22,'(]',1,5) -
5428         INSTRB(anc_id_22,'(]',1,4) - 2)
5429 ,SUBSTRB(anc_id_22
5430        ,INSTRB(anc_id_22,'(]',1,5) + 2
5431        ,INSTRB(anc_id_22,'(]',1,6) -
5432         INSTRB(anc_id_22,'(]',1,5) - 2)
5433 ,SUBSTRB(anc_id_22
5434        ,INSTRB(anc_id_22,'(]',1,6) + 2
5435        ,INSTRB(anc_id_22,'(]',1,7) -
5436         INSTRB(anc_id_22,'(]',1,6) - 2)
5437 ,SUBSTRB(anc_id_22
5438        ,INSTRB(anc_id_22,'(]',1,7) + 2
5439        ,LENGTHB(anc_id_22))
5440 )
5441 
5442 WHEN anc_id_23 IS NOT NULL THEN
5443   INTO xla_ae_line_acs (
5444         ae_header_id , ae_line_num , object_version_number
5445       , analytical_criterion_code
5446       , analytical_criterion_type_code
5447       , amb_context_code
5448       , ac1,ac2,ac3,ac4,ac5)
5449 VALUES (ae_header_id, ae_line_num, C_OVN
5450 ,SUBSTRB(anc_id_23
5451        ,1
5452        ,INSTRB(anc_id_23,'(]',1,1) -1)
5453 ,SUBSTRB(anc_id_23
5454        ,INSTRB(anc_id_23,'(]',1,1) + 2
5455        ,INSTRB(anc_id_23,'(]',1,2) -
5456         INSTRB(anc_id_23,'(]',1,1) - 2)
5457 ,SUBSTRB(anc_id_23
5458        ,INSTRB(anc_id_23,'(]',1,2) + 2
5459        ,INSTRB(anc_id_23,'(]',1,3) -
5460         INSTRB(anc_id_23,'(]',1,2) - 2)
5461 ,SUBSTRB(anc_id_23
5462        ,INSTRB(anc_id_23,'(]',1,3) + 2
5463        ,INSTRB(anc_id_23,'(]',1,4) -
5464         INSTRB(anc_id_23,'(]',1,3) - 2)
5465 ,SUBSTRB(anc_id_23
5466        ,INSTRB(anc_id_23,'(]',1,4) + 2
5467        ,INSTRB(anc_id_23,'(]',1,5) -
5468         INSTRB(anc_id_23,'(]',1,4) - 2)
5469 ,SUBSTRB(anc_id_23
5470        ,INSTRB(anc_id_23,'(]',1,5) + 2
5471        ,INSTRB(anc_id_23,'(]',1,6) -
5472         INSTRB(anc_id_23,'(]',1,5) - 2)
5473 ,SUBSTRB(anc_id_23
5474        ,INSTRB(anc_id_23,'(]',1,6) + 2
5475        ,INSTRB(anc_id_23,'(]',1,7) -
5476         INSTRB(anc_id_23,'(]',1,6) - 2)
5477 ,SUBSTRB(anc_id_23
5478        ,INSTRB(anc_id_23,'(]',1,7) + 2
5479        ,LENGTHB(anc_id_23))
5480 )
5481 
5482 WHEN anc_id_24 IS NOT NULL THEN
5483   INTO xla_ae_line_acs (
5484         ae_header_id , ae_line_num , object_version_number
5485       , analytical_criterion_code
5486       , analytical_criterion_type_code
5487       , amb_context_code
5488       , ac1,ac2,ac3,ac4,ac5)
5489 VALUES (ae_header_id, ae_line_num, C_OVN
5490 ,SUBSTRB(anc_id_24
5491        ,1
5492        ,INSTRB(anc_id_24,'(]',1,1) -1)
5493 ,SUBSTRB(anc_id_24
5494        ,INSTRB(anc_id_24,'(]',1,1) + 2
5495        ,INSTRB(anc_id_24,'(]',1,2) -
5496         INSTRB(anc_id_24,'(]',1,1) - 2)
5497 ,SUBSTRB(anc_id_24
5498        ,INSTRB(anc_id_24,'(]',1,2) + 2
5499        ,INSTRB(anc_id_24,'(]',1,3) -
5500         INSTRB(anc_id_24,'(]',1,2) - 2)
5501 ,SUBSTRB(anc_id_24
5502        ,INSTRB(anc_id_24,'(]',1,3) + 2
5503        ,INSTRB(anc_id_24,'(]',1,4) -
5504         INSTRB(anc_id_24,'(]',1,3) - 2)
5505 ,SUBSTRB(anc_id_24
5506        ,INSTRB(anc_id_24,'(]',1,4) + 2
5507        ,INSTRB(anc_id_24,'(]',1,5) -
5508         INSTRB(anc_id_24,'(]',1,4) - 2)
5509 ,SUBSTRB(anc_id_24
5510        ,INSTRB(anc_id_24,'(]',1,5) + 2
5511        ,INSTRB(anc_id_24,'(]',1,6) -
5512         INSTRB(anc_id_24,'(]',1,5) - 2)
5513 ,SUBSTRB(anc_id_24
5514        ,INSTRB(anc_id_24,'(]',1,6) + 2
5515        ,INSTRB(anc_id_24,'(]',1,7) -
5516         INSTRB(anc_id_24,'(]',1,6) - 2)
5517 ,SUBSTRB(anc_id_24
5518        ,INSTRB(anc_id_24,'(]',1,7) + 2
5519        ,LENGTHB(anc_id_24))
5520 )
5521 
5522 WHEN anc_id_25 IS NOT NULL THEN
5523   INTO xla_ae_line_acs (
5524         ae_header_id , ae_line_num , object_version_number
5525       , analytical_criterion_code
5526       , analytical_criterion_type_code
5527       , amb_context_code
5528       , ac1,ac2,ac3,ac4,ac5)
5529 VALUES (ae_header_id, ae_line_num, C_OVN
5530 ,SUBSTRB(anc_id_25
5531        ,1
5532        ,INSTRB(anc_id_25,'(]',1,1) -1)
5533 ,SUBSTRB(anc_id_25
5534        ,INSTRB(anc_id_25,'(]',1,1) + 2
5535        ,INSTRB(anc_id_25,'(]',1,2) -
5536         INSTRB(anc_id_25,'(]',1,1) - 2)
5537 ,SUBSTRB(anc_id_25
5538        ,INSTRB(anc_id_25,'(]',1,2) + 2
5539        ,INSTRB(anc_id_25,'(]',1,3) -
5540         INSTRB(anc_id_25,'(]',1,2) - 2)
5541 ,SUBSTRB(anc_id_25
5542        ,INSTRB(anc_id_25,'(]',1,3) + 2
5543        ,INSTRB(anc_id_25,'(]',1,4) -
5544         INSTRB(anc_id_25,'(]',1,3) - 2)
5545 ,SUBSTRB(anc_id_25
5546        ,INSTRB(anc_id_25,'(]',1,4) + 2
5547        ,INSTRB(anc_id_25,'(]',1,5) -
5548         INSTRB(anc_id_25,'(]',1,4) - 2)
5549 ,SUBSTRB(anc_id_25
5550        ,INSTRB(anc_id_25,'(]',1,5) + 2
5551        ,INSTRB(anc_id_25,'(]',1,6) -
5552         INSTRB(anc_id_25,'(]',1,5) - 2)
5553 ,SUBSTRB(anc_id_25
5554        ,INSTRB(anc_id_25,'(]',1,6) + 2
5555        ,INSTRB(anc_id_25,'(]',1,7) -
5556         INSTRB(anc_id_25,'(]',1,6) - 2)
5557 ,SUBSTRB(anc_id_25
5558        ,INSTRB(anc_id_25,'(]',1,7) + 2
5559        ,LENGTHB(anc_id_25))
5560 )
5561 
5562 WHEN anc_id_26 IS NOT NULL THEN
5563   INTO xla_ae_line_acs (
5564         ae_header_id , ae_line_num , object_version_number
5565       , analytical_criterion_code
5566       , analytical_criterion_type_code
5567       , amb_context_code
5568       , ac1,ac2,ac3,ac4,ac5)
5569 VALUES (ae_header_id, ae_line_num, C_OVN
5570 ,SUBSTRB(anc_id_26
5571        ,1
5572        ,INSTRB(anc_id_26,'(]',1,1) -1)
5573 ,SUBSTRB(anc_id_26
5574        ,INSTRB(anc_id_26,'(]',1,1) + 2
5575        ,INSTRB(anc_id_26,'(]',1,2) -
5576         INSTRB(anc_id_26,'(]',1,1) - 2)
5577 ,SUBSTRB(anc_id_26
5578        ,INSTRB(anc_id_26,'(]',1,2) + 2
5579        ,INSTRB(anc_id_26,'(]',1,3) -
5580         INSTRB(anc_id_26,'(]',1,2) - 2)
5581 ,SUBSTRB(anc_id_26
5582        ,INSTRB(anc_id_26,'(]',1,3) + 2
5583        ,INSTRB(anc_id_26,'(]',1,4) -
5584         INSTRB(anc_id_26,'(]',1,3) - 2)
5585 ,SUBSTRB(anc_id_26
5586        ,INSTRB(anc_id_26,'(]',1,4) + 2
5587        ,INSTRB(anc_id_26,'(]',1,5) -
5588         INSTRB(anc_id_26,'(]',1,4) - 2)
5589 ,SUBSTRB(anc_id_26
5590        ,INSTRB(anc_id_26,'(]',1,5) + 2
5591        ,INSTRB(anc_id_26,'(]',1,6) -
5592         INSTRB(anc_id_26,'(]',1,5) - 2)
5593 ,SUBSTRB(anc_id_26
5594        ,INSTRB(anc_id_26,'(]',1,6) + 2
5595        ,INSTRB(anc_id_26,'(]',1,7) -
5596         INSTRB(anc_id_26,'(]',1,6) - 2)
5597 ,SUBSTRB(anc_id_26
5598        ,INSTRB(anc_id_26,'(]',1,7) + 2
5599        ,LENGTHB(anc_id_26))
5600 )
5601 
5602 WHEN anc_id_27 IS NOT NULL THEN
5603   INTO xla_ae_line_acs (
5604         ae_header_id , ae_line_num , object_version_number
5605       , analytical_criterion_code
5606       , analytical_criterion_type_code
5607       , amb_context_code
5608       , ac1,ac2,ac3,ac4,ac5)
5609 VALUES (ae_header_id, ae_line_num, C_OVN
5610 ,SUBSTRB(anc_id_27
5611        ,1
5612        ,INSTRB(anc_id_27,'(]',1,1) -1)
5613 ,SUBSTRB(anc_id_27
5614        ,INSTRB(anc_id_27,'(]',1,1) + 2
5615        ,INSTRB(anc_id_27,'(]',1,2) -
5616         INSTRB(anc_id_27,'(]',1,1) - 2)
5617 ,SUBSTRB(anc_id_27
5618        ,INSTRB(anc_id_27,'(]',1,2) + 2
5619        ,INSTRB(anc_id_27,'(]',1,3) -
5620         INSTRB(anc_id_27,'(]',1,2) - 2)
5621 ,SUBSTRB(anc_id_27
5622        ,INSTRB(anc_id_27,'(]',1,3) + 2
5623        ,INSTRB(anc_id_27,'(]',1,4) -
5624         INSTRB(anc_id_27,'(]',1,3) - 2)
5625 ,SUBSTRB(anc_id_27
5626        ,INSTRB(anc_id_27,'(]',1,4) + 2
5627        ,INSTRB(anc_id_27,'(]',1,5) -
5628         INSTRB(anc_id_27,'(]',1,4) - 2)
5629 ,SUBSTRB(anc_id_27
5630        ,INSTRB(anc_id_27,'(]',1,5) + 2
5631        ,INSTRB(anc_id_27,'(]',1,6) -
5632         INSTRB(anc_id_27,'(]',1,5) - 2)
5633 ,SUBSTRB(anc_id_27
5634        ,INSTRB(anc_id_27,'(]',1,6) + 2
5635        ,INSTRB(anc_id_27,'(]',1,7) -
5636         INSTRB(anc_id_27,'(]',1,6) - 2)
5637 ,SUBSTRB(anc_id_27
5638        ,INSTRB(anc_id_27,'(]',1,7) + 2
5639        ,LENGTHB(anc_id_27))
5640 )
5641 
5642 WHEN anc_id_28 IS NOT NULL THEN
5643   INTO xla_ae_line_acs (
5644         ae_header_id , ae_line_num , object_version_number
5645       , analytical_criterion_code
5646       , analytical_criterion_type_code
5647       , amb_context_code
5648       , ac1,ac2,ac3,ac4,ac5)
5649 VALUES (ae_header_id, ae_line_num, C_OVN
5650 ,SUBSTRB(anc_id_28
5651        ,1
5652        ,INSTRB(anc_id_28,'(]',1,1) -1)
5653 ,SUBSTRB(anc_id_28
5654        ,INSTRB(anc_id_28,'(]',1,1) + 2
5655        ,INSTRB(anc_id_28,'(]',1,2) -
5656         INSTRB(anc_id_28,'(]',1,1) - 2)
5657 ,SUBSTRB(anc_id_28
5658        ,INSTRB(anc_id_28,'(]',1,2) + 2
5659        ,INSTRB(anc_id_28,'(]',1,3) -
5660         INSTRB(anc_id_28,'(]',1,2) - 2)
5661 ,SUBSTRB(anc_id_28
5662        ,INSTRB(anc_id_28,'(]',1,3) + 2
5663        ,INSTRB(anc_id_28,'(]',1,4) -
5664         INSTRB(anc_id_28,'(]',1,3) - 2)
5665 ,SUBSTRB(anc_id_28
5666        ,INSTRB(anc_id_28,'(]',1,4) + 2
5667        ,INSTRB(anc_id_28,'(]',1,5) -
5668         INSTRB(anc_id_28,'(]',1,4) - 2)
5669 ,SUBSTRB(anc_id_28
5670        ,INSTRB(anc_id_28,'(]',1,5) + 2
5671        ,INSTRB(anc_id_28,'(]',1,6) -
5672         INSTRB(anc_id_28,'(]',1,5) - 2)
5673 ,SUBSTRB(anc_id_28
5674        ,INSTRB(anc_id_28,'(]',1,6) + 2
5675        ,INSTRB(anc_id_28,'(]',1,7) -
5676         INSTRB(anc_id_28,'(]',1,6) - 2)
5677 ,SUBSTRB(anc_id_28
5678        ,INSTRB(anc_id_28,'(]',1,7) + 2
5679        ,LENGTHB(anc_id_28))
5680 )
5681 
5682 WHEN anc_id_29 IS NOT NULL THEN
5683   INTO xla_ae_line_acs (
5684         ae_header_id , ae_line_num , object_version_number
5685       , analytical_criterion_code
5686       , analytical_criterion_type_code
5687       , amb_context_code
5688       , ac1,ac2,ac3,ac4,ac5)
5689 VALUES (ae_header_id, ae_line_num, C_OVN
5690 ,SUBSTRB(anc_id_29
5691        ,1
5692        ,INSTRB(anc_id_29,'(]',1,1) -1)
5693 ,SUBSTRB(anc_id_29
5694        ,INSTRB(anc_id_29,'(]',1,1) + 2
5695        ,INSTRB(anc_id_29,'(]',1,2) -
5696         INSTRB(anc_id_29,'(]',1,1) - 2)
5697 ,SUBSTRB(anc_id_29
5698        ,INSTRB(anc_id_29,'(]',1,2) + 2
5699        ,INSTRB(anc_id_29,'(]',1,3) -
5700         INSTRB(anc_id_29,'(]',1,2) - 2)
5701 ,SUBSTRB(anc_id_29
5702        ,INSTRB(anc_id_29,'(]',1,3) + 2
5703        ,INSTRB(anc_id_29,'(]',1,4) -
5704         INSTRB(anc_id_29,'(]',1,3) - 2)
5705 ,SUBSTRB(anc_id_29
5706        ,INSTRB(anc_id_29,'(]',1,4) + 2
5707        ,INSTRB(anc_id_29,'(]',1,5) -
5708         INSTRB(anc_id_29,'(]',1,4) - 2)
5709 ,SUBSTRB(anc_id_29
5710        ,INSTRB(anc_id_29,'(]',1,5) + 2
5711        ,INSTRB(anc_id_29,'(]',1,6) -
5712         INSTRB(anc_id_29,'(]',1,5) - 2)
5713 ,SUBSTRB(anc_id_29
5714        ,INSTRB(anc_id_29,'(]',1,6) + 2
5715        ,INSTRB(anc_id_29,'(]',1,7) -
5716         INSTRB(anc_id_29,'(]',1,6) - 2)
5717 ,SUBSTRB(anc_id_29
5718        ,INSTRB(anc_id_29,'(]',1,7) + 2
5719        ,LENGTHB(anc_id_29))
5720 )
5721 
5722 WHEN anc_id_30 IS NOT NULL THEN
5723   INTO xla_ae_line_acs (
5724         ae_header_id , ae_line_num , object_version_number
5725       , analytical_criterion_code
5726       , analytical_criterion_type_code
5727       , amb_context_code
5728       , ac1,ac2,ac3,ac4,ac5)
5729 VALUES (ae_header_id, ae_line_num, C_OVN
5730 ,SUBSTRB(anc_id_30
5731        ,1
5732        ,INSTRB(anc_id_30,'(]',1,1) -1)
5733 ,SUBSTRB(anc_id_30
5734        ,INSTRB(anc_id_30,'(]',1,1) + 2
5735        ,INSTRB(anc_id_30,'(]',1,2) -
5736         INSTRB(anc_id_30,'(]',1,1) - 2)
5737 ,SUBSTRB(anc_id_30
5738        ,INSTRB(anc_id_30,'(]',1,2) + 2
5739        ,INSTRB(anc_id_30,'(]',1,3) -
5740         INSTRB(anc_id_30,'(]',1,2) - 2)
5741 ,SUBSTRB(anc_id_30
5742        ,INSTRB(anc_id_30,'(]',1,3) + 2
5743        ,INSTRB(anc_id_30,'(]',1,4) -
5744         INSTRB(anc_id_30,'(]',1,3) - 2)
5745 ,SUBSTRB(anc_id_30
5746        ,INSTRB(anc_id_30,'(]',1,4) + 2
5747        ,INSTRB(anc_id_30,'(]',1,5) -
5748         INSTRB(anc_id_30,'(]',1,4) - 2)
5749 ,SUBSTRB(anc_id_30
5750        ,INSTRB(anc_id_30,'(]',1,5) + 2
5751        ,INSTRB(anc_id_30,'(]',1,6) -
5752         INSTRB(anc_id_30,'(]',1,5) - 2)
5753 ,SUBSTRB(anc_id_30
5754        ,INSTRB(anc_id_30,'(]',1,6) + 2
5755        ,INSTRB(anc_id_30,'(]',1,7) -
5756         INSTRB(anc_id_30,'(]',1,6) - 2)
5757 ,SUBSTRB(anc_id_30
5758        ,INSTRB(anc_id_30,'(]',1,7) + 2
5759        ,LENGTHB(anc_id_30))
5760 )
5761 
5762 WHEN anc_id_31 IS NOT NULL THEN
5763   INTO xla_ae_line_acs (
5764         ae_header_id , ae_line_num , object_version_number
5765       , analytical_criterion_code
5766       , analytical_criterion_type_code
5767       , amb_context_code
5768       , ac1,ac2,ac3,ac4,ac5)
5769 VALUES (ae_header_id, ae_line_num, C_OVN
5770 ,SUBSTRB(anc_id_31
5771        ,1
5772        ,INSTRB(anc_id_31,'(]',1,1) -1)
5773 ,SUBSTRB(anc_id_31
5774        ,INSTRB(anc_id_31,'(]',1,1) + 2
5775        ,INSTRB(anc_id_31,'(]',1,2) -
5776         INSTRB(anc_id_31,'(]',1,1) - 2)
5777 ,SUBSTRB(anc_id_31
5778        ,INSTRB(anc_id_31,'(]',1,2) + 2
5779        ,INSTRB(anc_id_31,'(]',1,3) -
5780         INSTRB(anc_id_31,'(]',1,2) - 2)
5781 ,SUBSTRB(anc_id_31
5782        ,INSTRB(anc_id_31,'(]',1,3) + 2
5783        ,INSTRB(anc_id_31,'(]',1,4) -
5784         INSTRB(anc_id_31,'(]',1,3) - 2)
5785 ,SUBSTRB(anc_id_31
5786        ,INSTRB(anc_id_31,'(]',1,4) + 2
5787        ,INSTRB(anc_id_31,'(]',1,5) -
5788         INSTRB(anc_id_31,'(]',1,4) - 2)
5789 ,SUBSTRB(anc_id_31
5790        ,INSTRB(anc_id_31,'(]',1,5) + 2
5791        ,INSTRB(anc_id_31,'(]',1,6) -
5792         INSTRB(anc_id_31,'(]',1,5) - 2)
5793 ,SUBSTRB(anc_id_31
5794        ,INSTRB(anc_id_31,'(]',1,6) + 2
5795        ,INSTRB(anc_id_31,'(]',1,7) -
5796         INSTRB(anc_id_31,'(]',1,6) - 2)
5797 ,SUBSTRB(anc_id_31
5798        ,INSTRB(anc_id_31,'(]',1,7) + 2
5799        ,LENGTHB(anc_id_31))
5800 )
5801 
5802 WHEN anc_id_32 IS NOT NULL THEN
5803   INTO xla_ae_line_acs (
5804         ae_header_id , ae_line_num , object_version_number
5805       , analytical_criterion_code
5806       , analytical_criterion_type_code
5807       , amb_context_code
5808       , ac1,ac2,ac3,ac4,ac5)
5809 VALUES (ae_header_id, ae_line_num, C_OVN
5810 ,SUBSTRB(anc_id_32
5811        ,1
5812        ,INSTRB(anc_id_32,'(]',1,1) -1)
5813 ,SUBSTRB(anc_id_32
5814        ,INSTRB(anc_id_32,'(]',1,1) + 2
5815        ,INSTRB(anc_id_32,'(]',1,2) -
5816         INSTRB(anc_id_32,'(]',1,1) - 2)
5817 ,SUBSTRB(anc_id_32
5818        ,INSTRB(anc_id_32,'(]',1,2) + 2
5819        ,INSTRB(anc_id_32,'(]',1,3) -
5820         INSTRB(anc_id_32,'(]',1,2) - 2)
5821 ,SUBSTRB(anc_id_32
5822        ,INSTRB(anc_id_32,'(]',1,3) + 2
5823        ,INSTRB(anc_id_32,'(]',1,4) -
5824         INSTRB(anc_id_32,'(]',1,3) - 2)
5825 ,SUBSTRB(anc_id_32
5826        ,INSTRB(anc_id_32,'(]',1,4) + 2
5827        ,INSTRB(anc_id_32,'(]',1,5) -
5828         INSTRB(anc_id_32,'(]',1,4) - 2)
5829 ,SUBSTRB(anc_id_32
5830        ,INSTRB(anc_id_32,'(]',1,5) + 2
5831        ,INSTRB(anc_id_32,'(]',1,6) -
5832         INSTRB(anc_id_32,'(]',1,5) - 2)
5833 ,SUBSTRB(anc_id_32
5834        ,INSTRB(anc_id_32,'(]',1,6) + 2
5835        ,INSTRB(anc_id_32,'(]',1,7) -
5836         INSTRB(anc_id_32,'(]',1,6) - 2)
5837 ,SUBSTRB(anc_id_32
5838        ,INSTRB(anc_id_32,'(]',1,7) + 2
5839        ,LENGTHB(anc_id_32))
5840 )
5841 
5842 WHEN anc_id_33 IS NOT NULL THEN
5843   INTO xla_ae_line_acs (
5844         ae_header_id , ae_line_num , object_version_number
5845       , analytical_criterion_code
5846       , analytical_criterion_type_code
5847       , amb_context_code
5848       , ac1,ac2,ac3,ac4,ac5)
5849 VALUES (ae_header_id, ae_line_num, C_OVN
5850 ,SUBSTRB(anc_id_33
5851        ,1
5852        ,INSTRB(anc_id_33,'(]',1,1) -1)
5853 ,SUBSTRB(anc_id_33
5854        ,INSTRB(anc_id_33,'(]',1,1) + 2
5855        ,INSTRB(anc_id_33,'(]',1,2) -
5856         INSTRB(anc_id_33,'(]',1,1) - 2)
5857 ,SUBSTRB(anc_id_33
5858        ,INSTRB(anc_id_33,'(]',1,2) + 2
5859        ,INSTRB(anc_id_33,'(]',1,3) -
5860         INSTRB(anc_id_33,'(]',1,2) - 2)
5861 ,SUBSTRB(anc_id_33
5862        ,INSTRB(anc_id_33,'(]',1,3) + 2
5863        ,INSTRB(anc_id_33,'(]',1,4) -
5864         INSTRB(anc_id_33,'(]',1,3) - 2)
5865 ,SUBSTRB(anc_id_33
5866        ,INSTRB(anc_id_33,'(]',1,4) + 2
5867        ,INSTRB(anc_id_33,'(]',1,5) -
5868         INSTRB(anc_id_33,'(]',1,4) - 2)
5869 ,SUBSTRB(anc_id_33
5870        ,INSTRB(anc_id_33,'(]',1,5) + 2
5871        ,INSTRB(anc_id_33,'(]',1,6) -
5872         INSTRB(anc_id_33,'(]',1,5) - 2)
5873 ,SUBSTRB(anc_id_33
5874        ,INSTRB(anc_id_33,'(]',1,6) + 2
5875        ,INSTRB(anc_id_33,'(]',1,7) -
5876         INSTRB(anc_id_33,'(]',1,6) - 2)
5877 ,SUBSTRB(anc_id_33
5878        ,INSTRB(anc_id_33,'(]',1,7) + 2
5879        ,LENGTHB(anc_id_33))
5880 )
5881 
5882 WHEN anc_id_34 IS NOT NULL THEN
5883   INTO xla_ae_line_acs (
5884         ae_header_id , ae_line_num , object_version_number
5885       , analytical_criterion_code
5886       , analytical_criterion_type_code
5887       , amb_context_code
5888       , ac1,ac2,ac3,ac4,ac5)
5889 VALUES (ae_header_id, ae_line_num, C_OVN
5890 ,SUBSTRB(anc_id_34
5891        ,1
5892        ,INSTRB(anc_id_34,'(]',1,1) -1)
5893 ,SUBSTRB(anc_id_34
5894        ,INSTRB(anc_id_34,'(]',1,1) + 2
5895        ,INSTRB(anc_id_34,'(]',1,2) -
5896         INSTRB(anc_id_34,'(]',1,1) - 2)
5897 ,SUBSTRB(anc_id_34
5898        ,INSTRB(anc_id_34,'(]',1,2) + 2
5899        ,INSTRB(anc_id_34,'(]',1,3) -
5900         INSTRB(anc_id_34,'(]',1,2) - 2)
5901 ,SUBSTRB(anc_id_34
5902        ,INSTRB(anc_id_34,'(]',1,3) + 2
5903        ,INSTRB(anc_id_34,'(]',1,4) -
5904         INSTRB(anc_id_34,'(]',1,3) - 2)
5905 ,SUBSTRB(anc_id_34
5906        ,INSTRB(anc_id_34,'(]',1,4) + 2
5907        ,INSTRB(anc_id_34,'(]',1,5) -
5908         INSTRB(anc_id_34,'(]',1,4) - 2)
5909 ,SUBSTRB(anc_id_34
5910        ,INSTRB(anc_id_34,'(]',1,5) + 2
5911        ,INSTRB(anc_id_34,'(]',1,6) -
5912         INSTRB(anc_id_34,'(]',1,5) - 2)
5913 ,SUBSTRB(anc_id_34
5914        ,INSTRB(anc_id_34,'(]',1,6) + 2
5915        ,INSTRB(anc_id_34,'(]',1,7) -
5916         INSTRB(anc_id_34,'(]',1,6) - 2)
5917 ,SUBSTRB(anc_id_34
5918        ,INSTRB(anc_id_34,'(]',1,7) + 2
5919        ,LENGTHB(anc_id_34))
5920 )
5921 
5922 WHEN anc_id_35 IS NOT NULL THEN
5923   INTO xla_ae_line_acs (
5924         ae_header_id , ae_line_num , object_version_number
5925       , analytical_criterion_code
5926       , analytical_criterion_type_code
5927       , amb_context_code
5928       , ac1,ac2,ac3,ac4,ac5)
5929 VALUES (ae_header_id, ae_line_num, C_OVN
5930 ,SUBSTRB(anc_id_35
5931        ,1
5932        ,INSTRB(anc_id_35,'(]',1,1) -1)
5933 ,SUBSTRB(anc_id_35
5934        ,INSTRB(anc_id_35,'(]',1,1) + 2
5935        ,INSTRB(anc_id_35,'(]',1,2) -
5936         INSTRB(anc_id_35,'(]',1,1) - 2)
5937 ,SUBSTRB(anc_id_35
5938        ,INSTRB(anc_id_35,'(]',1,2) + 2
5939        ,INSTRB(anc_id_35,'(]',1,3) -
5940         INSTRB(anc_id_35,'(]',1,2) - 2)
5941 ,SUBSTRB(anc_id_35
5942        ,INSTRB(anc_id_35,'(]',1,3) + 2
5943        ,INSTRB(anc_id_35,'(]',1,4) -
5944         INSTRB(anc_id_35,'(]',1,3) - 2)
5945 ,SUBSTRB(anc_id_35
5946        ,INSTRB(anc_id_35,'(]',1,4) + 2
5947        ,INSTRB(anc_id_35,'(]',1,5) -
5948         INSTRB(anc_id_35,'(]',1,4) - 2)
5949 ,SUBSTRB(anc_id_35
5950        ,INSTRB(anc_id_35,'(]',1,5) + 2
5951        ,INSTRB(anc_id_35,'(]',1,6) -
5952         INSTRB(anc_id_35,'(]',1,5) - 2)
5953 ,SUBSTRB(anc_id_35
5954        ,INSTRB(anc_id_35,'(]',1,6) + 2
5955        ,INSTRB(anc_id_35,'(]',1,7) -
5956         INSTRB(anc_id_35,'(]',1,6) - 2)
5957 ,SUBSTRB(anc_id_35
5958        ,INSTRB(anc_id_35,'(]',1,7) + 2
5959        ,LENGTHB(anc_id_35))
5960 )
5961 
5962 WHEN anc_id_36 IS NOT NULL THEN
5963   INTO xla_ae_line_acs (
5964         ae_header_id , ae_line_num , object_version_number
5965       , analytical_criterion_code
5966       , analytical_criterion_type_code
5967       , amb_context_code
5968       , ac1,ac2,ac3,ac4,ac5)
5969 VALUES (ae_header_id, ae_line_num, C_OVN
5970 ,SUBSTRB(anc_id_36
5971        ,1
5972        ,INSTRB(anc_id_36,'(]',1,1) -1)
5973 ,SUBSTRB(anc_id_36
5974        ,INSTRB(anc_id_36,'(]',1,1) + 2
5975        ,INSTRB(anc_id_36,'(]',1,2) -
5976         INSTRB(anc_id_36,'(]',1,1) - 2)
5977 ,SUBSTRB(anc_id_36
5978        ,INSTRB(anc_id_36,'(]',1,2) + 2
5979        ,INSTRB(anc_id_36,'(]',1,3) -
5980         INSTRB(anc_id_36,'(]',1,2) - 2)
5981 ,SUBSTRB(anc_id_36
5982        ,INSTRB(anc_id_36,'(]',1,3) + 2
5983        ,INSTRB(anc_id_36,'(]',1,4) -
5984         INSTRB(anc_id_36,'(]',1,3) - 2)
5985 ,SUBSTRB(anc_id_36
5986        ,INSTRB(anc_id_36,'(]',1,4) + 2
5987        ,INSTRB(anc_id_36,'(]',1,5) -
5988         INSTRB(anc_id_36,'(]',1,4) - 2)
5989 ,SUBSTRB(anc_id_36
5990        ,INSTRB(anc_id_36,'(]',1,5) + 2
5991        ,INSTRB(anc_id_36,'(]',1,6) -
5992         INSTRB(anc_id_36,'(]',1,5) - 2)
5993 ,SUBSTRB(anc_id_36
5994        ,INSTRB(anc_id_36,'(]',1,6) + 2
5995        ,INSTRB(anc_id_36,'(]',1,7) -
5996         INSTRB(anc_id_36,'(]',1,6) - 2)
5997 ,SUBSTRB(anc_id_36
5998        ,INSTRB(anc_id_36,'(]',1,7) + 2
5999        ,LENGTHB(anc_id_36))
6000 )
6001 
6002 WHEN anc_id_37 IS NOT NULL THEN
6003   INTO xla_ae_line_acs (
6004         ae_header_id , ae_line_num , object_version_number
6005       , analytical_criterion_code
6006       , analytical_criterion_type_code
6007       , amb_context_code
6008       , ac1,ac2,ac3,ac4,ac5)
6009 VALUES (ae_header_id, ae_line_num, C_OVN
6010 ,SUBSTRB(anc_id_37
6011        ,1
6012        ,INSTRB(anc_id_37,'(]',1,1) -1)
6013 ,SUBSTRB(anc_id_37
6014        ,INSTRB(anc_id_37,'(]',1,1) + 2
6015        ,INSTRB(anc_id_37,'(]',1,2) -
6016         INSTRB(anc_id_37,'(]',1,1) - 2)
6017 ,SUBSTRB(anc_id_37
6018        ,INSTRB(anc_id_37,'(]',1,2) + 2
6019        ,INSTRB(anc_id_37,'(]',1,3) -
6020         INSTRB(anc_id_37,'(]',1,2) - 2)
6021 ,SUBSTRB(anc_id_37
6022        ,INSTRB(anc_id_37,'(]',1,3) + 2
6023        ,INSTRB(anc_id_37,'(]',1,4) -
6024         INSTRB(anc_id_37,'(]',1,3) - 2)
6025 ,SUBSTRB(anc_id_37
6026        ,INSTRB(anc_id_37,'(]',1,4) + 2
6027        ,INSTRB(anc_id_37,'(]',1,5) -
6028         INSTRB(anc_id_37,'(]',1,4) - 2)
6029 ,SUBSTRB(anc_id_37
6030        ,INSTRB(anc_id_37,'(]',1,5) + 2
6031        ,INSTRB(anc_id_37,'(]',1,6) -
6032         INSTRB(anc_id_37,'(]',1,5) - 2)
6033 ,SUBSTRB(anc_id_37
6034        ,INSTRB(anc_id_37,'(]',1,6) + 2
6035        ,INSTRB(anc_id_37,'(]',1,7) -
6036         INSTRB(anc_id_37,'(]',1,6) - 2)
6037 ,SUBSTRB(anc_id_37
6038        ,INSTRB(anc_id_37,'(]',1,7) + 2
6039        ,LENGTHB(anc_id_37))
6040 )
6041 
6042 WHEN anc_id_38 IS NOT NULL THEN
6043   INTO xla_ae_line_acs (
6044         ae_header_id , ae_line_num , object_version_number
6045       , analytical_criterion_code
6046       , analytical_criterion_type_code
6047       , amb_context_code
6048       , ac1,ac2,ac3,ac4,ac5)
6049 VALUES (ae_header_id, ae_line_num, C_OVN
6050 ,SUBSTRB(anc_id_38
6051        ,1
6052        ,INSTRB(anc_id_38,'(]',1,1) -1)
6053 ,SUBSTRB(anc_id_38
6054        ,INSTRB(anc_id_38,'(]',1,1) + 2
6055        ,INSTRB(anc_id_38,'(]',1,2) -
6056         INSTRB(anc_id_38,'(]',1,1) - 2)
6057 ,SUBSTRB(anc_id_38
6058        ,INSTRB(anc_id_38,'(]',1,2) + 2
6059        ,INSTRB(anc_id_38,'(]',1,3) -
6060         INSTRB(anc_id_38,'(]',1,2) - 2)
6061 ,SUBSTRB(anc_id_38
6062        ,INSTRB(anc_id_38,'(]',1,3) + 2
6063        ,INSTRB(anc_id_38,'(]',1,4) -
6064         INSTRB(anc_id_38,'(]',1,3) - 2)
6065 ,SUBSTRB(anc_id_38
6066        ,INSTRB(anc_id_38,'(]',1,4) + 2
6067        ,INSTRB(anc_id_38,'(]',1,5) -
6068         INSTRB(anc_id_38,'(]',1,4) - 2)
6069 ,SUBSTRB(anc_id_38
6070        ,INSTRB(anc_id_38,'(]',1,5) + 2
6071        ,INSTRB(anc_id_38,'(]',1,6) -
6072         INSTRB(anc_id_38,'(]',1,5) - 2)
6073 ,SUBSTRB(anc_id_38
6074        ,INSTRB(anc_id_38,'(]',1,6) + 2
6075        ,INSTRB(anc_id_38,'(]',1,7) -
6076         INSTRB(anc_id_38,'(]',1,6) - 2)
6077 ,SUBSTRB(anc_id_38
6078        ,INSTRB(anc_id_38,'(]',1,7) + 2
6079        ,LENGTHB(anc_id_38))
6080 )
6081 
6082 WHEN anc_id_39 IS NOT NULL THEN
6083   INTO xla_ae_line_acs (
6084         ae_header_id , ae_line_num , object_version_number
6085       , analytical_criterion_code
6086       , analytical_criterion_type_code
6087       , amb_context_code
6088       , ac1,ac2,ac3,ac4,ac5)
6089 VALUES (ae_header_id, ae_line_num, C_OVN
6090 ,SUBSTRB(anc_id_39
6091        ,1
6092        ,INSTRB(anc_id_39,'(]',1,1) -1)
6093 ,SUBSTRB(anc_id_39
6094        ,INSTRB(anc_id_39,'(]',1,1) + 2
6095        ,INSTRB(anc_id_39,'(]',1,2) -
6096         INSTRB(anc_id_39,'(]',1,1) - 2)
6097 ,SUBSTRB(anc_id_39
6098        ,INSTRB(anc_id_39,'(]',1,2) + 2
6099        ,INSTRB(anc_id_39,'(]',1,3) -
6100         INSTRB(anc_id_39,'(]',1,2) - 2)
6101 ,SUBSTRB(anc_id_39
6102        ,INSTRB(anc_id_39,'(]',1,3) + 2
6103        ,INSTRB(anc_id_39,'(]',1,4) -
6104         INSTRB(anc_id_39,'(]',1,3) - 2)
6105 ,SUBSTRB(anc_id_39
6106        ,INSTRB(anc_id_39,'(]',1,4) + 2
6107        ,INSTRB(anc_id_39,'(]',1,5) -
6108         INSTRB(anc_id_39,'(]',1,4) - 2)
6109 ,SUBSTRB(anc_id_39
6110        ,INSTRB(anc_id_39,'(]',1,5) + 2
6111        ,INSTRB(anc_id_39,'(]',1,6) -
6112         INSTRB(anc_id_39,'(]',1,5) - 2)
6113 ,SUBSTRB(anc_id_39
6114        ,INSTRB(anc_id_39,'(]',1,6) + 2
6115        ,INSTRB(anc_id_39,'(]',1,7) -
6116         INSTRB(anc_id_39,'(]',1,6) - 2)
6117 ,SUBSTRB(anc_id_39
6118        ,INSTRB(anc_id_39,'(]',1,7) + 2
6119        ,LENGTHB(anc_id_39))
6120 )
6121 
6122 WHEN anc_id_40 IS NOT NULL THEN
6123   INTO xla_ae_line_acs (
6124         ae_header_id , ae_line_num , object_version_number
6125       , analytical_criterion_code
6126       , analytical_criterion_type_code
6127       , amb_context_code
6128       , ac1,ac2,ac3,ac4,ac5)
6129 VALUES (ae_header_id, ae_line_num, C_OVN
6130 ,SUBSTRB(anc_id_40
6131        ,1
6132        ,INSTRB(anc_id_40,'(]',1,1) -1)
6133 ,SUBSTRB(anc_id_40
6134        ,INSTRB(anc_id_40,'(]',1,1) + 2
6135        ,INSTRB(anc_id_40,'(]',1,2) -
6136         INSTRB(anc_id_40,'(]',1,1) - 2)
6137 ,SUBSTRB(anc_id_40
6138        ,INSTRB(anc_id_40,'(]',1,2) + 2
6139        ,INSTRB(anc_id_40,'(]',1,3) -
6140         INSTRB(anc_id_40,'(]',1,2) - 2)
6141 ,SUBSTRB(anc_id_40
6142        ,INSTRB(anc_id_40,'(]',1,3) + 2
6143        ,INSTRB(anc_id_40,'(]',1,4) -
6144         INSTRB(anc_id_40,'(]',1,3) - 2)
6145 ,SUBSTRB(anc_id_40
6146        ,INSTRB(anc_id_40,'(]',1,4) + 2
6147        ,INSTRB(anc_id_40,'(]',1,5) -
6148         INSTRB(anc_id_40,'(]',1,4) - 2)
6149 ,SUBSTRB(anc_id_40
6150        ,INSTRB(anc_id_40,'(]',1,5) + 2
6151        ,INSTRB(anc_id_40,'(]',1,6) -
6152         INSTRB(anc_id_40,'(]',1,5) - 2)
6153 ,SUBSTRB(anc_id_40
6154        ,INSTRB(anc_id_40,'(]',1,6) + 2
6155        ,INSTRB(anc_id_40,'(]',1,7) -
6156         INSTRB(anc_id_40,'(]',1,6) - 2)
6157 ,SUBSTRB(anc_id_40
6158        ,INSTRB(anc_id_40,'(]',1,7) + 2
6159        ,LENGTHB(anc_id_40))
6160 )
6161 
6162 WHEN anc_id_41 IS NOT NULL THEN
6163   INTO xla_ae_line_acs (
6164         ae_header_id , ae_line_num , object_version_number
6165       , analytical_criterion_code
6166       , analytical_criterion_type_code
6167       , amb_context_code
6168       , ac1,ac2,ac3,ac4,ac5)
6169 VALUES (ae_header_id, ae_line_num, C_OVN
6170 ,SUBSTRB(anc_id_41
6171        ,1
6172        ,INSTRB(anc_id_41,'(]',1,1) -1)
6173 ,SUBSTRB(anc_id_41
6174        ,INSTRB(anc_id_41,'(]',1,1) + 2
6175        ,INSTRB(anc_id_41,'(]',1,2) -
6176         INSTRB(anc_id_41,'(]',1,1) - 2)
6177 ,SUBSTRB(anc_id_41
6178        ,INSTRB(anc_id_41,'(]',1,2) + 2
6179        ,INSTRB(anc_id_41,'(]',1,3) -
6180         INSTRB(anc_id_41,'(]',1,2) - 2)
6181 ,SUBSTRB(anc_id_41
6182        ,INSTRB(anc_id_41,'(]',1,3) + 2
6183        ,INSTRB(anc_id_41,'(]',1,4) -
6184         INSTRB(anc_id_41,'(]',1,3) - 2)
6185 ,SUBSTRB(anc_id_41
6186        ,INSTRB(anc_id_41,'(]',1,4) + 2
6187        ,INSTRB(anc_id_41,'(]',1,5) -
6188         INSTRB(anc_id_41,'(]',1,4) - 2)
6189 ,SUBSTRB(anc_id_41
6190        ,INSTRB(anc_id_41,'(]',1,5) + 2
6191        ,INSTRB(anc_id_41,'(]',1,6) -
6192         INSTRB(anc_id_41,'(]',1,5) - 2)
6193 ,SUBSTRB(anc_id_41
6194        ,INSTRB(anc_id_41,'(]',1,6) + 2
6195        ,INSTRB(anc_id_41,'(]',1,7) -
6196         INSTRB(anc_id_41,'(]',1,6) - 2)
6197 ,SUBSTRB(anc_id_41
6198        ,INSTRB(anc_id_41,'(]',1,7) + 2
6199        ,LENGTHB(anc_id_41))
6200 )
6201 
6202 WHEN anc_id_42 IS NOT NULL THEN
6203   INTO xla_ae_line_acs (
6204         ae_header_id , ae_line_num , object_version_number
6205       , analytical_criterion_code
6206       , analytical_criterion_type_code
6207       , amb_context_code
6208       , ac1,ac2,ac3,ac4,ac5)
6209 VALUES (ae_header_id, ae_line_num, C_OVN
6210 ,SUBSTRB(anc_id_42
6211        ,1
6212        ,INSTRB(anc_id_42,'(]',1,1) -1)
6213 ,SUBSTRB(anc_id_42
6214        ,INSTRB(anc_id_42,'(]',1,1) + 2
6215        ,INSTRB(anc_id_42,'(]',1,2) -
6216         INSTRB(anc_id_42,'(]',1,1) - 2)
6217 ,SUBSTRB(anc_id_42
6218        ,INSTRB(anc_id_42,'(]',1,2) + 2
6219        ,INSTRB(anc_id_42,'(]',1,3) -
6220         INSTRB(anc_id_42,'(]',1,2) - 2)
6221 ,SUBSTRB(anc_id_42
6222        ,INSTRB(anc_id_42,'(]',1,3) + 2
6223        ,INSTRB(anc_id_42,'(]',1,4) -
6224         INSTRB(anc_id_42,'(]',1,3) - 2)
6225 ,SUBSTRB(anc_id_42
6226        ,INSTRB(anc_id_42,'(]',1,4) + 2
6227        ,INSTRB(anc_id_42,'(]',1,5) -
6228         INSTRB(anc_id_42,'(]',1,4) - 2)
6229 ,SUBSTRB(anc_id_42
6230        ,INSTRB(anc_id_42,'(]',1,5) + 2
6231        ,INSTRB(anc_id_42,'(]',1,6) -
6232         INSTRB(anc_id_42,'(]',1,5) - 2)
6233 ,SUBSTRB(anc_id_42
6234        ,INSTRB(anc_id_42,'(]',1,6) + 2
6235        ,INSTRB(anc_id_42,'(]',1,7) -
6236         INSTRB(anc_id_42,'(]',1,6) - 2)
6237 ,SUBSTRB(anc_id_42
6238        ,INSTRB(anc_id_42,'(]',1,7) + 2
6239        ,LENGTHB(anc_id_42))
6240 )
6241 
6242 WHEN anc_id_43 IS NOT NULL THEN
6243   INTO xla_ae_line_acs (
6244         ae_header_id , ae_line_num , object_version_number
6245       , analytical_criterion_code
6246       , analytical_criterion_type_code
6247       , amb_context_code
6248       , ac1,ac2,ac3,ac4,ac5)
6249 VALUES (ae_header_id, ae_line_num, C_OVN
6250 ,SUBSTRB(anc_id_43
6251        ,1
6252        ,INSTRB(anc_id_43,'(]',1,1) -1)
6253 ,SUBSTRB(anc_id_43
6254        ,INSTRB(anc_id_43,'(]',1,1) + 2
6255        ,INSTRB(anc_id_43,'(]',1,2) -
6256         INSTRB(anc_id_43,'(]',1,1) - 2)
6257 ,SUBSTRB(anc_id_43
6258        ,INSTRB(anc_id_43,'(]',1,2) + 2
6259        ,INSTRB(anc_id_43,'(]',1,3) -
6260         INSTRB(anc_id_43,'(]',1,2) - 2)
6261 ,SUBSTRB(anc_id_43
6262        ,INSTRB(anc_id_43,'(]',1,3) + 2
6263        ,INSTRB(anc_id_43,'(]',1,4) -
6264         INSTRB(anc_id_43,'(]',1,3) - 2)
6265 ,SUBSTRB(anc_id_43
6266        ,INSTRB(anc_id_43,'(]',1,4) + 2
6267        ,INSTRB(anc_id_43,'(]',1,5) -
6268         INSTRB(anc_id_43,'(]',1,4) - 2)
6269 ,SUBSTRB(anc_id_43
6270        ,INSTRB(anc_id_43,'(]',1,5) + 2
6271        ,INSTRB(anc_id_43,'(]',1,6) -
6272         INSTRB(anc_id_43,'(]',1,5) - 2)
6273 ,SUBSTRB(anc_id_43
6274        ,INSTRB(anc_id_43,'(]',1,6) + 2
6275        ,INSTRB(anc_id_43,'(]',1,7) -
6276         INSTRB(anc_id_43,'(]',1,6) - 2)
6277 ,SUBSTRB(anc_id_43
6278        ,INSTRB(anc_id_43,'(]',1,7) + 2
6279        ,LENGTHB(anc_id_43))
6280 )
6281 
6282 WHEN anc_id_44 IS NOT NULL THEN
6283   INTO xla_ae_line_acs (
6284         ae_header_id , ae_line_num , object_version_number
6285       , analytical_criterion_code
6286       , analytical_criterion_type_code
6287       , amb_context_code
6288       , ac1,ac2,ac3,ac4,ac5)
6289 VALUES (ae_header_id, ae_line_num, C_OVN
6290 ,SUBSTRB(anc_id_44
6291        ,1
6292        ,INSTRB(anc_id_44,'(]',1,1) -1)
6293 ,SUBSTRB(anc_id_44
6294        ,INSTRB(anc_id_44,'(]',1,1) + 2
6295        ,INSTRB(anc_id_44,'(]',1,2) -
6296         INSTRB(anc_id_44,'(]',1,1) - 2)
6297 ,SUBSTRB(anc_id_44
6298        ,INSTRB(anc_id_44,'(]',1,2) + 2
6299        ,INSTRB(anc_id_44,'(]',1,3) -
6300         INSTRB(anc_id_44,'(]',1,2) - 2)
6301 ,SUBSTRB(anc_id_44
6302        ,INSTRB(anc_id_44,'(]',1,3) + 2
6303        ,INSTRB(anc_id_44,'(]',1,4) -
6304         INSTRB(anc_id_44,'(]',1,3) - 2)
6305 ,SUBSTRB(anc_id_44
6306        ,INSTRB(anc_id_44,'(]',1,4) + 2
6307        ,INSTRB(anc_id_44,'(]',1,5) -
6308         INSTRB(anc_id_44,'(]',1,4) - 2)
6309 ,SUBSTRB(anc_id_44
6310        ,INSTRB(anc_id_44,'(]',1,5) + 2
6311        ,INSTRB(anc_id_44,'(]',1,6) -
6312         INSTRB(anc_id_44,'(]',1,5) - 2)
6313 ,SUBSTRB(anc_id_44
6314        ,INSTRB(anc_id_44,'(]',1,6) + 2
6315        ,INSTRB(anc_id_44,'(]',1,7) -
6316         INSTRB(anc_id_44,'(]',1,6) - 2)
6317 ,SUBSTRB(anc_id_44
6318        ,INSTRB(anc_id_44,'(]',1,7) + 2
6319        ,LENGTHB(anc_id_44))
6320 )
6321 
6322 WHEN anc_id_45 IS NOT NULL THEN
6323   INTO xla_ae_line_acs (
6324         ae_header_id , ae_line_num , object_version_number
6325       , analytical_criterion_code
6326       , analytical_criterion_type_code
6327       , amb_context_code
6328       , ac1,ac2,ac3,ac4,ac5)
6329 VALUES (ae_header_id, ae_line_num, C_OVN
6330 ,SUBSTRB(anc_id_45
6331        ,1
6332        ,INSTRB(anc_id_45,'(]',1,1) -1)
6333 ,SUBSTRB(anc_id_45
6334        ,INSTRB(anc_id_45,'(]',1,1) + 2
6335        ,INSTRB(anc_id_45,'(]',1,2) -
6336         INSTRB(anc_id_45,'(]',1,1) - 2)
6337 ,SUBSTRB(anc_id_45
6338        ,INSTRB(anc_id_45,'(]',1,2) + 2
6339        ,INSTRB(anc_id_45,'(]',1,3) -
6340         INSTRB(anc_id_45,'(]',1,2) - 2)
6341 ,SUBSTRB(anc_id_45
6342        ,INSTRB(anc_id_45,'(]',1,3) + 2
6343        ,INSTRB(anc_id_45,'(]',1,4) -
6344         INSTRB(anc_id_45,'(]',1,3) - 2)
6345 ,SUBSTRB(anc_id_45
6346        ,INSTRB(anc_id_45,'(]',1,4) + 2
6347        ,INSTRB(anc_id_45,'(]',1,5) -
6348         INSTRB(anc_id_45,'(]',1,4) - 2)
6349 ,SUBSTRB(anc_id_45
6350        ,INSTRB(anc_id_45,'(]',1,5) + 2
6351        ,INSTRB(anc_id_45,'(]',1,6) -
6352         INSTRB(anc_id_45,'(]',1,5) - 2)
6353 ,SUBSTRB(anc_id_45
6354        ,INSTRB(anc_id_45,'(]',1,6) + 2
6355        ,INSTRB(anc_id_45,'(]',1,7) -
6356         INSTRB(anc_id_45,'(]',1,6) - 2)
6357 ,SUBSTRB(anc_id_45
6358        ,INSTRB(anc_id_45,'(]',1,7) + 2
6359        ,LENGTHB(anc_id_45))
6360 )
6361 
6362 WHEN anc_id_46 IS NOT NULL THEN
6363   INTO xla_ae_line_acs (
6364         ae_header_id , ae_line_num , object_version_number
6365       , analytical_criterion_code
6366       , analytical_criterion_type_code
6367       , amb_context_code
6368       , ac1,ac2,ac3,ac4,ac5)
6369 VALUES (ae_header_id, ae_line_num, C_OVN
6370 ,SUBSTRB(anc_id_46
6371        ,1
6372        ,INSTRB(anc_id_46,'(]',1,1) -1)
6373 ,SUBSTRB(anc_id_46
6374        ,INSTRB(anc_id_46,'(]',1,1) + 2
6375        ,INSTRB(anc_id_46,'(]',1,2) -
6376         INSTRB(anc_id_46,'(]',1,1) - 2)
6377 ,SUBSTRB(anc_id_46
6378        ,INSTRB(anc_id_46,'(]',1,2) + 2
6379        ,INSTRB(anc_id_46,'(]',1,3) -
6380         INSTRB(anc_id_46,'(]',1,2) - 2)
6381 ,SUBSTRB(anc_id_46
6382        ,INSTRB(anc_id_46,'(]',1,3) + 2
6383        ,INSTRB(anc_id_46,'(]',1,4) -
6384         INSTRB(anc_id_46,'(]',1,3) - 2)
6385 ,SUBSTRB(anc_id_46
6386        ,INSTRB(anc_id_46,'(]',1,4) + 2
6387        ,INSTRB(anc_id_46,'(]',1,5) -
6388         INSTRB(anc_id_46,'(]',1,4) - 2)
6389 ,SUBSTRB(anc_id_46
6390        ,INSTRB(anc_id_46,'(]',1,5) + 2
6391        ,INSTRB(anc_id_46,'(]',1,6) -
6392         INSTRB(anc_id_46,'(]',1,5) - 2)
6393 ,SUBSTRB(anc_id_46
6394        ,INSTRB(anc_id_46,'(]',1,6) + 2
6395        ,INSTRB(anc_id_46,'(]',1,7) -
6396         INSTRB(anc_id_46,'(]',1,6) - 2)
6397 ,SUBSTRB(anc_id_46
6398        ,INSTRB(anc_id_46,'(]',1,7) + 2
6399        ,LENGTHB(anc_id_46))
6400 )
6401 
6402 WHEN anc_id_47 IS NOT NULL THEN
6403   INTO xla_ae_line_acs (
6404         ae_header_id , ae_line_num , object_version_number
6405       , analytical_criterion_code
6406       , analytical_criterion_type_code
6407       , amb_context_code
6408       , ac1,ac2,ac3,ac4,ac5)
6409 VALUES (ae_header_id, ae_line_num, C_OVN
6410 ,SUBSTRB(anc_id_47
6411        ,1
6412        ,INSTRB(anc_id_47,'(]',1,1) -1)
6413 ,SUBSTRB(anc_id_47
6414        ,INSTRB(anc_id_47,'(]',1,1) + 2
6415        ,INSTRB(anc_id_47,'(]',1,2) -
6416         INSTRB(anc_id_47,'(]',1,1) - 2)
6417 ,SUBSTRB(anc_id_47
6418        ,INSTRB(anc_id_47,'(]',1,2) + 2
6419        ,INSTRB(anc_id_47,'(]',1,3) -
6420         INSTRB(anc_id_47,'(]',1,2) - 2)
6421 ,SUBSTRB(anc_id_47
6422        ,INSTRB(anc_id_47,'(]',1,3) + 2
6423        ,INSTRB(anc_id_47,'(]',1,4) -
6424         INSTRB(anc_id_47,'(]',1,3) - 2)
6425 ,SUBSTRB(anc_id_47
6426        ,INSTRB(anc_id_47,'(]',1,4) + 2
6427        ,INSTRB(anc_id_47,'(]',1,5) -
6428         INSTRB(anc_id_47,'(]',1,4) - 2)
6429 ,SUBSTRB(anc_id_47
6430        ,INSTRB(anc_id_47,'(]',1,5) + 2
6431        ,INSTRB(anc_id_47,'(]',1,6) -
6432         INSTRB(anc_id_47,'(]',1,5) - 2)
6433 ,SUBSTRB(anc_id_47
6434        ,INSTRB(anc_id_47,'(]',1,6) + 2
6435        ,INSTRB(anc_id_47,'(]',1,7) -
6436         INSTRB(anc_id_47,'(]',1,6) - 2)
6437 ,SUBSTRB(anc_id_47
6438        ,INSTRB(anc_id_47,'(]',1,7) + 2
6439        ,LENGTHB(anc_id_47))
6440 )
6441 
6442 WHEN anc_id_48 IS NOT NULL THEN
6443   INTO xla_ae_line_acs (
6444         ae_header_id , ae_line_num , object_version_number
6445       , analytical_criterion_code
6446       , analytical_criterion_type_code
6447       , amb_context_code
6448       , ac1,ac2,ac3,ac4,ac5)
6449 VALUES (ae_header_id, ae_line_num, C_OVN
6450 ,SUBSTRB(anc_id_48
6451        ,1
6452        ,INSTRB(anc_id_48,'(]',1,1) -1)
6453 ,SUBSTRB(anc_id_48
6454        ,INSTRB(anc_id_48,'(]',1,1) + 2
6455        ,INSTRB(anc_id_48,'(]',1,2) -
6456         INSTRB(anc_id_48,'(]',1,1) - 2)
6457 ,SUBSTRB(anc_id_48
6458        ,INSTRB(anc_id_48,'(]',1,2) + 2
6459        ,INSTRB(anc_id_48,'(]',1,3) -
6460         INSTRB(anc_id_48,'(]',1,2) - 2)
6461 ,SUBSTRB(anc_id_48
6462        ,INSTRB(anc_id_48,'(]',1,3) + 2
6463        ,INSTRB(anc_id_48,'(]',1,4) -
6464         INSTRB(anc_id_48,'(]',1,3) - 2)
6465 ,SUBSTRB(anc_id_48
6466        ,INSTRB(anc_id_48,'(]',1,4) + 2
6467        ,INSTRB(anc_id_48,'(]',1,5) -
6468         INSTRB(anc_id_48,'(]',1,4) - 2)
6469 ,SUBSTRB(anc_id_48
6470        ,INSTRB(anc_id_48,'(]',1,5) + 2
6471        ,INSTRB(anc_id_48,'(]',1,6) -
6472         INSTRB(anc_id_48,'(]',1,5) - 2)
6473 ,SUBSTRB(anc_id_48
6474        ,INSTRB(anc_id_48,'(]',1,6) + 2
6475        ,INSTRB(anc_id_48,'(]',1,7) -
6476         INSTRB(anc_id_48,'(]',1,6) - 2)
6477 ,SUBSTRB(anc_id_48
6478        ,INSTRB(anc_id_48,'(]',1,7) + 2
6479        ,LENGTHB(anc_id_48))
6480 )
6481 
6482 WHEN anc_id_49 IS NOT NULL THEN
6483   INTO xla_ae_line_acs (
6484         ae_header_id , ae_line_num , object_version_number
6485       , analytical_criterion_code
6486       , analytical_criterion_type_code
6487       , amb_context_code
6488       , ac1,ac2,ac3,ac4,ac5)
6489 VALUES (ae_header_id, ae_line_num, C_OVN
6490 ,SUBSTRB(anc_id_49
6491        ,1
6492        ,INSTRB(anc_id_49,'(]',1,1) -1)
6493 ,SUBSTRB(anc_id_49
6494        ,INSTRB(anc_id_49,'(]',1,1) + 2
6495        ,INSTRB(anc_id_49,'(]',1,2) -
6496         INSTRB(anc_id_49,'(]',1,1) - 2)
6497 ,SUBSTRB(anc_id_49
6498        ,INSTRB(anc_id_49,'(]',1,2) + 2
6499        ,INSTRB(anc_id_49,'(]',1,3) -
6500         INSTRB(anc_id_49,'(]',1,2) - 2)
6501 ,SUBSTRB(anc_id_49
6502        ,INSTRB(anc_id_49,'(]',1,3) + 2
6503        ,INSTRB(anc_id_49,'(]',1,4) -
6504         INSTRB(anc_id_49,'(]',1,3) - 2)
6505 ,SUBSTRB(anc_id_49
6506        ,INSTRB(anc_id_49,'(]',1,4) + 2
6507        ,INSTRB(anc_id_49,'(]',1,5) -
6508         INSTRB(anc_id_49,'(]',1,4) - 2)
6509 ,SUBSTRB(anc_id_49
6510        ,INSTRB(anc_id_49,'(]',1,5) + 2
6511        ,INSTRB(anc_id_49,'(]',1,6) -
6512         INSTRB(anc_id_49,'(]',1,5) - 2)
6513 ,SUBSTRB(anc_id_49
6514        ,INSTRB(anc_id_49,'(]',1,6) + 2
6515        ,INSTRB(anc_id_49,'(]',1,7) -
6516         INSTRB(anc_id_49,'(]',1,6) - 2)
6517 ,SUBSTRB(anc_id_49
6518        ,INSTRB(anc_id_49,'(]',1,7) + 2
6519        ,LENGTHB(anc_id_49))
6520 )
6521 
6522 WHEN anc_id_50 IS NOT NULL THEN
6523   INTO xla_ae_line_acs (
6524         ae_header_id , ae_line_num , object_version_number
6525       , analytical_criterion_code
6526       , analytical_criterion_type_code
6527       , amb_context_code
6528       , ac1,ac2,ac3,ac4,ac5)
6529 VALUES (ae_header_id, ae_line_num, C_OVN
6530 ,SUBSTRB(anc_id_50
6531        ,1
6532        ,INSTRB(anc_id_50,'(]',1,1) -1)
6533 ,SUBSTRB(anc_id_50
6534        ,INSTRB(anc_id_50,'(]',1,1) + 2
6535        ,INSTRB(anc_id_50,'(]',1,2) -
6536         INSTRB(anc_id_50,'(]',1,1) - 2)
6537 ,SUBSTRB(anc_id_50
6538        ,INSTRB(anc_id_50,'(]',1,2) + 2
6539        ,INSTRB(anc_id_50,'(]',1,3) -
6540         INSTRB(anc_id_50,'(]',1,2) - 2)
6541 ,SUBSTRB(anc_id_50
6542        ,INSTRB(anc_id_50,'(]',1,3) + 2
6543        ,INSTRB(anc_id_50,'(]',1,4) -
6544         INSTRB(anc_id_50,'(]',1,3) - 2)
6545 ,SUBSTRB(anc_id_50
6546        ,INSTRB(anc_id_50,'(]',1,4) + 2
6547        ,INSTRB(anc_id_50,'(]',1,5) -
6548         INSTRB(anc_id_50,'(]',1,4) - 2)
6549 ,SUBSTRB(anc_id_50
6550        ,INSTRB(anc_id_50,'(]',1,5) + 2
6551        ,INSTRB(anc_id_50,'(]',1,6) -
6552         INSTRB(anc_id_50,'(]',1,5) - 2)
6553 ,SUBSTRB(anc_id_50
6554        ,INSTRB(anc_id_50,'(]',1,6) + 2
6555        ,INSTRB(anc_id_50,'(]',1,7) -
6556         INSTRB(anc_id_50,'(]',1,6) - 2)
6557 ,SUBSTRB(anc_id_50
6558        ,INSTRB(anc_id_50,'(]',1,7) + 2
6559        ,LENGTHB(anc_id_50))
6560 )
6561 
6562 
6563 SELECT  ae_header_id
6564       , ae_line_num
6565       , anc_id_1
6566       , anc_id_2
6567       , anc_id_3
6568       , anc_id_4
6569       , anc_id_5
6570       , anc_id_6
6571       , anc_id_7
6572       , anc_id_8
6573       , anc_id_9
6574       , anc_id_10
6575       , anc_id_11
6576       , anc_id_12
6577       , anc_id_13
6578       , anc_id_14
6579       , anc_id_15
6580       , anc_id_16
6581       , anc_id_17
6582       , anc_id_18
6583       , anc_id_19
6584       , anc_id_20
6585       , anc_id_21
6586       , anc_id_22
6587       , anc_id_23
6588       , anc_id_24
6589       , anc_id_25
6590       , anc_id_26
6591       , anc_id_27
6592       , anc_id_28
6593       , anc_id_29
6594       , anc_id_30
6595       , anc_id_31
6596       , anc_id_32
6597       , anc_id_33
6598       , anc_id_34
6599       , anc_id_35
6600       , anc_id_36
6601       , anc_id_37
6602       , anc_id_38
6603       , anc_id_39
6604       , anc_id_40
6605       , anc_id_41
6606       , anc_id_42
6607       , anc_id_43
6608       , anc_id_44
6609       , anc_id_45
6610       , anc_id_46
6611       , anc_id_47
6612       , anc_id_48
6613       , anc_id_49
6614       , anc_id_50
6615  FROM  xla_ae_lines_gt
6616 WHERE  ae_line_num is not null
6617 GROUP  BY
6618        ae_line_num
6619       ,ae_header_id
6620       ,anc_id_1
6621       ,anc_id_2
6622       ,anc_id_3
6623       ,anc_id_4
6624       ,anc_id_5
6625       ,anc_id_6
6626       ,anc_id_7
6627       ,anc_id_8
6628       ,anc_id_9
6629       ,anc_id_10
6630       ,anc_id_11
6631       ,anc_id_12
6632       ,anc_id_13
6633       ,anc_id_14
6634       ,anc_id_15
6635       ,anc_id_16
6636       ,anc_id_17
6637       ,anc_id_18
6638       ,anc_id_19
6639       ,anc_id_20
6640       ,anc_id_21
6641       ,anc_id_22
6642       ,anc_id_23
6643       ,anc_id_24
6644       ,anc_id_25
6645       ,anc_id_26
6646       ,anc_id_27
6647       ,anc_id_28
6648       ,anc_id_29
6649       ,anc_id_30
6650       ,anc_id_31
6651       ,anc_id_32
6652       ,anc_id_33
6653       ,anc_id_34
6654       ,anc_id_35
6655       ,anc_id_36
6656       ,anc_id_37
6657       ,anc_id_38
6658       ,anc_id_39
6659       ,anc_id_40
6660       ,anc_id_41
6661       ,anc_id_42
6662       ,anc_id_43
6663       ,anc_id_44
6664       ,anc_id_45
6665       ,anc_id_46
6666       ,anc_id_47
6667       ,anc_id_48
6668       ,anc_id_49
6669       ,anc_id_50;
6670 
6671    --
6672    l_rowcount := SQL%ROWCOUNT;
6673 
6674    IF (C_LEVEL_EVENT >= g_log_level) THEN
6675       trace
6676          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
6677          ,p_level    => C_LEVEL_EVENT
6678          ,p_module   => l_log_module);
6679    END IF;
6680 
6681    EXCEPTION
6682    WHEN OTHERS  THEN
6683 
6684      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6685           trace
6686               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
6687               ,p_level    => C_LEVEL_EXCEPTION
6688               ,p_module   => l_log_module);
6689      END IF;
6690 
6691      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
6692                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
6693                                       ,p_token_1      => 'ERROR'
6694                                       ,p_value_1      => sqlerrm
6695                                       );
6696 
6697 
6698    END;
6699 
6700 EXCEPTION
6701 WHEN xla_exceptions_pkg.application_exception THEN
6702   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6703        trace
6704            (p_msg      => 'Error. = '||sqlerrm
6705            ,p_level    => C_LEVEL_PROCEDURE
6706            ,p_module   => l_log_module);
6707   END IF;
6708   RAISE;
6709 WHEN OTHERS  THEN
6710   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6711        trace
6712            (p_msg      => 'Error. = '||sqlerrm
6713            ,p_level    => C_LEVEL_PROCEDURE
6714            ,p_module   => l_log_module);
6715   END IF;
6716   xla_exceptions_pkg.raise_message
6717        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria50');
6718 END InsertAnalyticalCriteria50;
6719 
6720 --
6721 --
6722 /*======================================================================+
6723 | PRIVATE Procedure                                                     |
6724 |                                                                       |
6725 | InsertAnalyticalCriteria100                                            |
6726 |                                                                       |
6727 |                                                                       |
6728 +======================================================================*/
6729 --
6730 PROCEDURE InsertAnalyticalCriteria100
6731 IS
6732 l_rowcount           NUMBER;
6733 l_log_module         VARCHAR2(240);
6734 BEGIN
6735 --
6736 IF g_log_enabled THEN
6737       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria100';
6738 END IF;
6739 --
6740 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6741 
6742       trace
6743          (p_msg      => 'BEGIN of InsertAnalyticalCriteria100'
6744          ,p_level    => C_LEVEL_PROCEDURE
6745          ,p_module   => l_log_module);
6746 END IF;
6747 
6748 l_rowcount  := 0;
6749 
6750 BEGIN
6751 
6752    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6753 
6754       trace
6755          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
6756          ,p_level    => C_LEVEL_STATEMENT
6757          ,p_module   => l_log_module);
6758 
6759    END IF;
6760 
6761 INSERT ALL
6762 WHEN anc_id_1 IS NOT NULL and anc_id_1 not like 'DUMMY_ANC_%' THEN  --Bug 8691573
6763   INTO xla_ae_line_acs (
6764         ae_header_id , ae_line_num , object_version_number
6765       , analytical_criterion_code
6766       , analytical_criterion_type_code
6767       , amb_context_code
6768       , ac1,ac2,ac3,ac4,ac5)
6769 VALUES (ae_header_id, ae_line_num, C_OVN
6770 ,SUBSTRB(anc_id_1
6771        ,1
6772        ,INSTRB(anc_id_1,'(]',1,1) -1)
6773 ,SUBSTRB(anc_id_1
6774        ,INSTRB(anc_id_1,'(]',1,1) + 2
6775        ,INSTRB(anc_id_1,'(]',1,2) -
6776         INSTRB(anc_id_1,'(]',1,1) - 2)
6777 ,SUBSTRB(anc_id_1
6778        ,INSTRB(anc_id_1,'(]',1,2) + 2
6779        ,INSTRB(anc_id_1,'(]',1,3) -
6780         INSTRB(anc_id_1,'(]',1,2) - 2)
6781 ,SUBSTRB(anc_id_1
6782        ,INSTRB(anc_id_1,'(]',1,3) + 2
6783        ,INSTRB(anc_id_1,'(]',1,4) -
6784         INSTRB(anc_id_1,'(]',1,3) - 2)
6785 ,SUBSTRB(anc_id_1
6786        ,INSTRB(anc_id_1,'(]',1,4) + 2
6787        ,INSTRB(anc_id_1,'(]',1,5) -
6788         INSTRB(anc_id_1,'(]',1,4) - 2)
6789 ,SUBSTRB(anc_id_1
6790        ,INSTRB(anc_id_1,'(]',1,5) + 2
6791        ,INSTRB(anc_id_1,'(]',1,6) -
6792         INSTRB(anc_id_1,'(]',1,5) - 2)
6793 ,SUBSTRB(anc_id_1
6794        ,INSTRB(anc_id_1,'(]',1,6) + 2
6795        ,INSTRB(anc_id_1,'(]',1,7) -
6796         INSTRB(anc_id_1,'(]',1,6) - 2)
6797 ,SUBSTRB(anc_id_1
6798        ,INSTRB(anc_id_1,'(]',1,7) + 2
6799        ,LENGTHB(anc_id_1))
6800 )
6801 
6802 WHEN anc_id_2 IS NOT NULL THEN
6803   INTO xla_ae_line_acs (
6804         ae_header_id , ae_line_num , object_version_number
6805       , analytical_criterion_code
6806       , analytical_criterion_type_code
6807       , amb_context_code
6808       , ac1,ac2,ac3,ac4,ac5)
6809 VALUES (ae_header_id, ae_line_num, C_OVN
6810 ,SUBSTRB(anc_id_2
6811        ,1
6812        ,INSTRB(anc_id_2,'(]',1,1) -1)
6813 ,SUBSTRB(anc_id_2
6814        ,INSTRB(anc_id_2,'(]',1,1) + 2
6815        ,INSTRB(anc_id_2,'(]',1,2) -
6816         INSTRB(anc_id_2,'(]',1,1) - 2)
6817 ,SUBSTRB(anc_id_2
6818        ,INSTRB(anc_id_2,'(]',1,2) + 2
6819        ,INSTRB(anc_id_2,'(]',1,3) -
6820         INSTRB(anc_id_2,'(]',1,2) - 2)
6821 ,SUBSTRB(anc_id_2
6822        ,INSTRB(anc_id_2,'(]',1,3) + 2
6823        ,INSTRB(anc_id_2,'(]',1,4) -
6824         INSTRB(anc_id_2,'(]',1,3) - 2)
6825 ,SUBSTRB(anc_id_2
6826        ,INSTRB(anc_id_2,'(]',1,4) + 2
6827        ,INSTRB(anc_id_2,'(]',1,5) -
6828         INSTRB(anc_id_2,'(]',1,4) - 2)
6829 ,SUBSTRB(anc_id_2
6830        ,INSTRB(anc_id_2,'(]',1,5) + 2
6831        ,INSTRB(anc_id_2,'(]',1,6) -
6832         INSTRB(anc_id_2,'(]',1,5) - 2)
6833 ,SUBSTRB(anc_id_2
6834        ,INSTRB(anc_id_2,'(]',1,6) + 2
6835        ,INSTRB(anc_id_2,'(]',1,7) -
6836         INSTRB(anc_id_2,'(]',1,6) - 2)
6837 ,SUBSTRB(anc_id_2
6838        ,INSTRB(anc_id_2,'(]',1,7) + 2
6839        ,LENGTHB(anc_id_2))
6840 )
6841 
6842 WHEN anc_id_3 IS NOT NULL THEN
6843   INTO xla_ae_line_acs (
6844         ae_header_id , ae_line_num , object_version_number
6845       , analytical_criterion_code
6846       , analytical_criterion_type_code
6847       , amb_context_code
6848       , ac1,ac2,ac3,ac4,ac5)
6849 VALUES (ae_header_id, ae_line_num, C_OVN
6850 ,SUBSTRB(anc_id_3
6851        ,1
6852        ,INSTRB(anc_id_3,'(]',1,1) -1)
6853 ,SUBSTRB(anc_id_3
6854        ,INSTRB(anc_id_3,'(]',1,1) + 2
6855        ,INSTRB(anc_id_3,'(]',1,2) -
6856         INSTRB(anc_id_3,'(]',1,1) - 2)
6857 ,SUBSTRB(anc_id_3
6858        ,INSTRB(anc_id_3,'(]',1,2) + 2
6859        ,INSTRB(anc_id_3,'(]',1,3) -
6860         INSTRB(anc_id_3,'(]',1,2) - 2)
6861 ,SUBSTRB(anc_id_3
6862        ,INSTRB(anc_id_3,'(]',1,3) + 2
6863        ,INSTRB(anc_id_3,'(]',1,4) -
6864         INSTRB(anc_id_3,'(]',1,3) - 2)
6865 ,SUBSTRB(anc_id_3
6866        ,INSTRB(anc_id_3,'(]',1,4) + 2
6867        ,INSTRB(anc_id_3,'(]',1,5) -
6868         INSTRB(anc_id_3,'(]',1,4) - 2)
6869 ,SUBSTRB(anc_id_3
6870        ,INSTRB(anc_id_3,'(]',1,5) + 2
6871        ,INSTRB(anc_id_3,'(]',1,6) -
6872         INSTRB(anc_id_3,'(]',1,5) - 2)
6873 ,SUBSTRB(anc_id_3
6874        ,INSTRB(anc_id_3,'(]',1,6) + 2
6875        ,INSTRB(anc_id_3,'(]',1,7) -
6876         INSTRB(anc_id_3,'(]',1,6) - 2)
6877 ,SUBSTRB(anc_id_3
6878        ,INSTRB(anc_id_3,'(]',1,7) + 2
6879        ,LENGTHB(anc_id_3))
6880 )
6881 
6882 WHEN anc_id_4 IS NOT NULL THEN
6883   INTO xla_ae_line_acs (
6884         ae_header_id , ae_line_num , object_version_number
6885       , analytical_criterion_code
6886       , analytical_criterion_type_code
6887       , amb_context_code
6888       , ac1,ac2,ac3,ac4,ac5)
6889 VALUES (ae_header_id, ae_line_num, C_OVN
6890 ,SUBSTRB(anc_id_4
6891        ,1
6892        ,INSTRB(anc_id_4,'(]',1,1) -1)
6893 ,SUBSTRB(anc_id_4
6894        ,INSTRB(anc_id_4,'(]',1,1) + 2
6895        ,INSTRB(anc_id_4,'(]',1,2) -
6896         INSTRB(anc_id_4,'(]',1,1) - 2)
6897 ,SUBSTRB(anc_id_4
6898        ,INSTRB(anc_id_4,'(]',1,2) + 2
6899        ,INSTRB(anc_id_4,'(]',1,3) -
6900         INSTRB(anc_id_4,'(]',1,2) - 2)
6901 ,SUBSTRB(anc_id_4
6902        ,INSTRB(anc_id_4,'(]',1,3) + 2
6903        ,INSTRB(anc_id_4,'(]',1,4) -
6904         INSTRB(anc_id_4,'(]',1,3) - 2)
6905 ,SUBSTRB(anc_id_4
6906        ,INSTRB(anc_id_4,'(]',1,4) + 2
6907        ,INSTRB(anc_id_4,'(]',1,5) -
6908         INSTRB(anc_id_4,'(]',1,4) - 2)
6909 ,SUBSTRB(anc_id_4
6910        ,INSTRB(anc_id_4,'(]',1,5) + 2
6911        ,INSTRB(anc_id_4,'(]',1,6) -
6912         INSTRB(anc_id_4,'(]',1,5) - 2)
6913 ,SUBSTRB(anc_id_4
6914        ,INSTRB(anc_id_4,'(]',1,6) + 2
6915        ,INSTRB(anc_id_4,'(]',1,7) -
6916         INSTRB(anc_id_4,'(]',1,6) - 2)
6917 ,SUBSTRB(anc_id_4
6918        ,INSTRB(anc_id_4,'(]',1,7) + 2
6919        ,LENGTHB(anc_id_4))
6920 )
6921 
6922 WHEN anc_id_5 IS NOT NULL THEN
6923   INTO xla_ae_line_acs (
6924         ae_header_id , ae_line_num , object_version_number
6925       , analytical_criterion_code
6926       , analytical_criterion_type_code
6927       , amb_context_code
6928       , ac1,ac2,ac3,ac4,ac5)
6929 VALUES (ae_header_id, ae_line_num, C_OVN
6930 ,SUBSTRB(anc_id_5
6931        ,1
6932        ,INSTRB(anc_id_5,'(]',1,1) -1)
6933 ,SUBSTRB(anc_id_5
6934        ,INSTRB(anc_id_5,'(]',1,1) + 2
6935        ,INSTRB(anc_id_5,'(]',1,2) -
6936         INSTRB(anc_id_5,'(]',1,1) - 2)
6937 ,SUBSTRB(anc_id_5
6938        ,INSTRB(anc_id_5,'(]',1,2) + 2
6939        ,INSTRB(anc_id_5,'(]',1,3) -
6940         INSTRB(anc_id_5,'(]',1,2) - 2)
6941 ,SUBSTRB(anc_id_5
6942        ,INSTRB(anc_id_5,'(]',1,3) + 2
6943        ,INSTRB(anc_id_5,'(]',1,4) -
6944         INSTRB(anc_id_5,'(]',1,3) - 2)
6945 ,SUBSTRB(anc_id_5
6946        ,INSTRB(anc_id_5,'(]',1,4) + 2
6947        ,INSTRB(anc_id_5,'(]',1,5) -
6948         INSTRB(anc_id_5,'(]',1,4) - 2)
6949 ,SUBSTRB(anc_id_5
6950        ,INSTRB(anc_id_5,'(]',1,5) + 2
6951        ,INSTRB(anc_id_5,'(]',1,6) -
6952         INSTRB(anc_id_5,'(]',1,5) - 2)
6953 ,SUBSTRB(anc_id_5
6954        ,INSTRB(anc_id_5,'(]',1,6) + 2
6955        ,INSTRB(anc_id_5,'(]',1,7) -
6956         INSTRB(anc_id_5,'(]',1,6) - 2)
6957 ,SUBSTRB(anc_id_5
6958        ,INSTRB(anc_id_5,'(]',1,7) + 2
6959        ,LENGTHB(anc_id_5))
6960 )
6961 
6962 WHEN anc_id_6 IS NOT NULL THEN
6963   INTO xla_ae_line_acs (
6964         ae_header_id , ae_line_num , object_version_number
6965       , analytical_criterion_code
6966       , analytical_criterion_type_code
6967       , amb_context_code
6968       , ac1,ac2,ac3,ac4,ac5)
6969 VALUES (ae_header_id, ae_line_num, C_OVN
6970 ,SUBSTRB(anc_id_6
6971        ,1
6972        ,INSTRB(anc_id_6,'(]',1,1) -1)
6973 ,SUBSTRB(anc_id_6
6974        ,INSTRB(anc_id_6,'(]',1,1) + 2
6975        ,INSTRB(anc_id_6,'(]',1,2) -
6976         INSTRB(anc_id_6,'(]',1,1) - 2)
6977 ,SUBSTRB(anc_id_6
6978        ,INSTRB(anc_id_6,'(]',1,2) + 2
6979        ,INSTRB(anc_id_6,'(]',1,3) -
6980         INSTRB(anc_id_6,'(]',1,2) - 2)
6981 ,SUBSTRB(anc_id_6
6982        ,INSTRB(anc_id_6,'(]',1,3) + 2
6983        ,INSTRB(anc_id_6,'(]',1,4) -
6984         INSTRB(anc_id_6,'(]',1,3) - 2)
6985 ,SUBSTRB(anc_id_6
6986        ,INSTRB(anc_id_6,'(]',1,4) + 2
6987        ,INSTRB(anc_id_6,'(]',1,5) -
6988         INSTRB(anc_id_6,'(]',1,4) - 2)
6989 ,SUBSTRB(anc_id_6
6990        ,INSTRB(anc_id_6,'(]',1,5) + 2
6991        ,INSTRB(anc_id_6,'(]',1,6) -
6992         INSTRB(anc_id_6,'(]',1,5) - 2)
6993 ,SUBSTRB(anc_id_6
6994        ,INSTRB(anc_id_6,'(]',1,6) + 2
6995        ,INSTRB(anc_id_6,'(]',1,7) -
6996         INSTRB(anc_id_6,'(]',1,6) - 2)
6997 ,SUBSTRB(anc_id_6
6998        ,INSTRB(anc_id_6,'(]',1,7) + 2
6999        ,LENGTHB(anc_id_6))
7000 )
7001 
7002 WHEN anc_id_7 IS NOT NULL THEN
7003   INTO xla_ae_line_acs (
7004         ae_header_id , ae_line_num , object_version_number
7005       , analytical_criterion_code
7006       , analytical_criterion_type_code
7007       , amb_context_code
7008       , ac1,ac2,ac3,ac4,ac5)
7009 VALUES (ae_header_id, ae_line_num, C_OVN
7010 ,SUBSTRB(anc_id_7
7011        ,1
7012        ,INSTRB(anc_id_7,'(]',1,1) -1)
7013 ,SUBSTRB(anc_id_7
7014        ,INSTRB(anc_id_7,'(]',1,1) + 2
7015        ,INSTRB(anc_id_7,'(]',1,2) -
7016         INSTRB(anc_id_7,'(]',1,1) - 2)
7017 ,SUBSTRB(anc_id_7
7018        ,INSTRB(anc_id_7,'(]',1,2) + 2
7019        ,INSTRB(anc_id_7,'(]',1,3) -
7020         INSTRB(anc_id_7,'(]',1,2) - 2)
7021 ,SUBSTRB(anc_id_7
7022        ,INSTRB(anc_id_7,'(]',1,3) + 2
7023        ,INSTRB(anc_id_7,'(]',1,4) -
7024         INSTRB(anc_id_7,'(]',1,3) - 2)
7025 ,SUBSTRB(anc_id_7
7026        ,INSTRB(anc_id_7,'(]',1,4) + 2
7027        ,INSTRB(anc_id_7,'(]',1,5) -
7028         INSTRB(anc_id_7,'(]',1,4) - 2)
7029 ,SUBSTRB(anc_id_7
7030        ,INSTRB(anc_id_7,'(]',1,5) + 2
7031        ,INSTRB(anc_id_7,'(]',1,6) -
7032         INSTRB(anc_id_7,'(]',1,5) - 2)
7033 ,SUBSTRB(anc_id_7
7034        ,INSTRB(anc_id_7,'(]',1,6) + 2
7035        ,INSTRB(anc_id_7,'(]',1,7) -
7036         INSTRB(anc_id_7,'(]',1,6) - 2)
7037 ,SUBSTRB(anc_id_7
7038        ,INSTRB(anc_id_7,'(]',1,7) + 2
7039        ,LENGTHB(anc_id_7))
7040 )
7041 
7042 WHEN anc_id_8 IS NOT NULL THEN
7043   INTO xla_ae_line_acs (
7044         ae_header_id , ae_line_num , object_version_number
7045       , analytical_criterion_code
7046       , analytical_criterion_type_code
7047       , amb_context_code
7048       , ac1,ac2,ac3,ac4,ac5)
7049 VALUES (ae_header_id, ae_line_num, C_OVN
7050 ,SUBSTRB(anc_id_8
7051        ,1
7052        ,INSTRB(anc_id_8,'(]',1,1) -1)
7053 ,SUBSTRB(anc_id_8
7054        ,INSTRB(anc_id_8,'(]',1,1) + 2
7055        ,INSTRB(anc_id_8,'(]',1,2) -
7056         INSTRB(anc_id_8,'(]',1,1) - 2)
7057 ,SUBSTRB(anc_id_8
7058        ,INSTRB(anc_id_8,'(]',1,2) + 2
7059        ,INSTRB(anc_id_8,'(]',1,3) -
7060         INSTRB(anc_id_8,'(]',1,2) - 2)
7061 ,SUBSTRB(anc_id_8
7062        ,INSTRB(anc_id_8,'(]',1,3) + 2
7063        ,INSTRB(anc_id_8,'(]',1,4) -
7064         INSTRB(anc_id_8,'(]',1,3) - 2)
7065 ,SUBSTRB(anc_id_8
7066        ,INSTRB(anc_id_8,'(]',1,4) + 2
7067        ,INSTRB(anc_id_8,'(]',1,5) -
7068         INSTRB(anc_id_8,'(]',1,4) - 2)
7069 ,SUBSTRB(anc_id_8
7070        ,INSTRB(anc_id_8,'(]',1,5) + 2
7071        ,INSTRB(anc_id_8,'(]',1,6) -
7072         INSTRB(anc_id_8,'(]',1,5) - 2)
7073 ,SUBSTRB(anc_id_8
7074        ,INSTRB(anc_id_8,'(]',1,6) + 2
7075        ,INSTRB(anc_id_8,'(]',1,7) -
7076         INSTRB(anc_id_8,'(]',1,6) - 2)
7077 ,SUBSTRB(anc_id_8
7078        ,INSTRB(anc_id_8,'(]',1,7) + 2
7079        ,LENGTHB(anc_id_8))
7080 )
7081 
7082 WHEN anc_id_9 IS NOT NULL THEN
7083   INTO xla_ae_line_acs (
7084         ae_header_id , ae_line_num , object_version_number
7085       , analytical_criterion_code
7086       , analytical_criterion_type_code
7087       , amb_context_code
7088       , ac1,ac2,ac3,ac4,ac5)
7089 VALUES (ae_header_id, ae_line_num, C_OVN
7090 ,SUBSTRB(anc_id_9
7091        ,1
7092        ,INSTRB(anc_id_9,'(]',1,1) -1)
7093 ,SUBSTRB(anc_id_9
7094        ,INSTRB(anc_id_9,'(]',1,1) + 2
7095        ,INSTRB(anc_id_9,'(]',1,2) -
7096         INSTRB(anc_id_9,'(]',1,1) - 2)
7097 ,SUBSTRB(anc_id_9
7098        ,INSTRB(anc_id_9,'(]',1,2) + 2
7099        ,INSTRB(anc_id_9,'(]',1,3) -
7100         INSTRB(anc_id_9,'(]',1,2) - 2)
7101 ,SUBSTRB(anc_id_9
7102        ,INSTRB(anc_id_9,'(]',1,3) + 2
7103        ,INSTRB(anc_id_9,'(]',1,4) -
7104         INSTRB(anc_id_9,'(]',1,3) - 2)
7105 ,SUBSTRB(anc_id_9
7106        ,INSTRB(anc_id_9,'(]',1,4) + 2
7107        ,INSTRB(anc_id_9,'(]',1,5) -
7108         INSTRB(anc_id_9,'(]',1,4) - 2)
7109 ,SUBSTRB(anc_id_9
7110        ,INSTRB(anc_id_9,'(]',1,5) + 2
7111        ,INSTRB(anc_id_9,'(]',1,6) -
7112         INSTRB(anc_id_9,'(]',1,5) - 2)
7113 ,SUBSTRB(anc_id_9
7114        ,INSTRB(anc_id_9,'(]',1,6) + 2
7115        ,INSTRB(anc_id_9,'(]',1,7) -
7116         INSTRB(anc_id_9,'(]',1,6) - 2)
7117 ,SUBSTRB(anc_id_9
7118        ,INSTRB(anc_id_9,'(]',1,7) + 2
7119        ,LENGTHB(anc_id_9))
7120 )
7121 
7122 WHEN anc_id_10 IS NOT NULL THEN
7123   INTO xla_ae_line_acs (
7124         ae_header_id , ae_line_num , object_version_number
7125       , analytical_criterion_code
7126       , analytical_criterion_type_code
7127       , amb_context_code
7128       , ac1,ac2,ac3,ac4,ac5)
7129 VALUES (ae_header_id, ae_line_num, C_OVN
7130 ,SUBSTRB(anc_id_10
7131        ,1
7132        ,INSTRB(anc_id_10,'(]',1,1) -1)
7133 ,SUBSTRB(anc_id_10
7134        ,INSTRB(anc_id_10,'(]',1,1) + 2
7135        ,INSTRB(anc_id_10,'(]',1,2) -
7136         INSTRB(anc_id_10,'(]',1,1) - 2)
7137 ,SUBSTRB(anc_id_10
7138        ,INSTRB(anc_id_10,'(]',1,2) + 2
7139        ,INSTRB(anc_id_10,'(]',1,3) -
7140         INSTRB(anc_id_10,'(]',1,2) - 2)
7141 ,SUBSTRB(anc_id_10
7142        ,INSTRB(anc_id_10,'(]',1,3) + 2
7143        ,INSTRB(anc_id_10,'(]',1,4) -
7144         INSTRB(anc_id_10,'(]',1,3) - 2)
7145 ,SUBSTRB(anc_id_10
7146        ,INSTRB(anc_id_10,'(]',1,4) + 2
7147        ,INSTRB(anc_id_10,'(]',1,5) -
7148         INSTRB(anc_id_10,'(]',1,4) - 2)
7149 ,SUBSTRB(anc_id_10
7150        ,INSTRB(anc_id_10,'(]',1,5) + 2
7151        ,INSTRB(anc_id_10,'(]',1,6) -
7152         INSTRB(anc_id_10,'(]',1,5) - 2)
7153 ,SUBSTRB(anc_id_10
7154        ,INSTRB(anc_id_10,'(]',1,6) + 2
7155        ,INSTRB(anc_id_10,'(]',1,7) -
7156         INSTRB(anc_id_10,'(]',1,6) - 2)
7157 ,SUBSTRB(anc_id_10
7158        ,INSTRB(anc_id_10,'(]',1,7) + 2
7159        ,LENGTHB(anc_id_10))
7160 )
7161 
7162 WHEN anc_id_11 IS NOT NULL THEN
7163   INTO xla_ae_line_acs (
7164         ae_header_id , ae_line_num , object_version_number
7165       , analytical_criterion_code
7166       , analytical_criterion_type_code
7167       , amb_context_code
7168       , ac1,ac2,ac3,ac4,ac5)
7169 VALUES (ae_header_id, ae_line_num, C_OVN
7170 ,SUBSTRB(anc_id_11
7171        ,1
7172        ,INSTRB(anc_id_11,'(]',1,1) -1)
7173 ,SUBSTRB(anc_id_11
7174        ,INSTRB(anc_id_11,'(]',1,1) + 2
7175        ,INSTRB(anc_id_11,'(]',1,2) -
7176         INSTRB(anc_id_11,'(]',1,1) - 2)
7177 ,SUBSTRB(anc_id_11
7178        ,INSTRB(anc_id_11,'(]',1,2) + 2
7179        ,INSTRB(anc_id_11,'(]',1,3) -
7180         INSTRB(anc_id_11,'(]',1,2) - 2)
7181 ,SUBSTRB(anc_id_11
7182        ,INSTRB(anc_id_11,'(]',1,3) + 2
7183        ,INSTRB(anc_id_11,'(]',1,4) -
7184         INSTRB(anc_id_11,'(]',1,3) - 2)
7185 ,SUBSTRB(anc_id_11
7186        ,INSTRB(anc_id_11,'(]',1,4) + 2
7187        ,INSTRB(anc_id_11,'(]',1,5) -
7188         INSTRB(anc_id_11,'(]',1,4) - 2)
7189 ,SUBSTRB(anc_id_11
7190        ,INSTRB(anc_id_11,'(]',1,5) + 2
7191        ,INSTRB(anc_id_11,'(]',1,6) -
7192         INSTRB(anc_id_11,'(]',1,5) - 2)
7193 ,SUBSTRB(anc_id_11
7194        ,INSTRB(anc_id_11,'(]',1,6) + 2
7195        ,INSTRB(anc_id_11,'(]',1,7) -
7196         INSTRB(anc_id_11,'(]',1,6) - 2)
7197 ,SUBSTRB(anc_id_11
7198        ,INSTRB(anc_id_11,'(]',1,7) + 2
7199        ,LENGTHB(anc_id_11))
7200 )
7201 
7202 WHEN anc_id_12 IS NOT NULL THEN
7203   INTO xla_ae_line_acs (
7204         ae_header_id , ae_line_num , object_version_number
7205       , analytical_criterion_code
7206       , analytical_criterion_type_code
7207       , amb_context_code
7208       , ac1,ac2,ac3,ac4,ac5)
7209 VALUES (ae_header_id, ae_line_num, C_OVN
7210 ,SUBSTRB(anc_id_12
7211        ,1
7212        ,INSTRB(anc_id_12,'(]',1,1) -1)
7213 ,SUBSTRB(anc_id_12
7214        ,INSTRB(anc_id_12,'(]',1,1) + 2
7215        ,INSTRB(anc_id_12,'(]',1,2) -
7216         INSTRB(anc_id_12,'(]',1,1) - 2)
7217 ,SUBSTRB(anc_id_12
7218        ,INSTRB(anc_id_12,'(]',1,2) + 2
7219        ,INSTRB(anc_id_12,'(]',1,3) -
7220         INSTRB(anc_id_12,'(]',1,2) - 2)
7221 ,SUBSTRB(anc_id_12
7222        ,INSTRB(anc_id_12,'(]',1,3) + 2
7223        ,INSTRB(anc_id_12,'(]',1,4) -
7224         INSTRB(anc_id_12,'(]',1,3) - 2)
7225 ,SUBSTRB(anc_id_12
7226        ,INSTRB(anc_id_12,'(]',1,4) + 2
7227        ,INSTRB(anc_id_12,'(]',1,5) -
7228         INSTRB(anc_id_12,'(]',1,4) - 2)
7229 ,SUBSTRB(anc_id_12
7230        ,INSTRB(anc_id_12,'(]',1,5) + 2
7231        ,INSTRB(anc_id_12,'(]',1,6) -
7232         INSTRB(anc_id_12,'(]',1,5) - 2)
7233 ,SUBSTRB(anc_id_12
7234        ,INSTRB(anc_id_12,'(]',1,6) + 2
7235        ,INSTRB(anc_id_12,'(]',1,7) -
7236         INSTRB(anc_id_12,'(]',1,6) - 2)
7237 ,SUBSTRB(anc_id_12
7238        ,INSTRB(anc_id_12,'(]',1,7) + 2
7239        ,LENGTHB(anc_id_12))
7240 )
7241 
7242 WHEN anc_id_13 IS NOT NULL THEN
7243   INTO xla_ae_line_acs (
7244         ae_header_id , ae_line_num , object_version_number
7245       , analytical_criterion_code
7246       , analytical_criterion_type_code
7247       , amb_context_code
7248       , ac1,ac2,ac3,ac4,ac5)
7249 VALUES (ae_header_id, ae_line_num, C_OVN
7250 ,SUBSTRB(anc_id_13
7251        ,1
7252        ,INSTRB(anc_id_13,'(]',1,1) -1)
7253 ,SUBSTRB(anc_id_13
7254        ,INSTRB(anc_id_13,'(]',1,1) + 2
7255        ,INSTRB(anc_id_13,'(]',1,2) -
7256         INSTRB(anc_id_13,'(]',1,1) - 2)
7257 ,SUBSTRB(anc_id_13
7258        ,INSTRB(anc_id_13,'(]',1,2) + 2
7259        ,INSTRB(anc_id_13,'(]',1,3) -
7260         INSTRB(anc_id_13,'(]',1,2) - 2)
7261 ,SUBSTRB(anc_id_13
7262        ,INSTRB(anc_id_13,'(]',1,3) + 2
7263        ,INSTRB(anc_id_13,'(]',1,4) -
7264         INSTRB(anc_id_13,'(]',1,3) - 2)
7265 ,SUBSTRB(anc_id_13
7266        ,INSTRB(anc_id_13,'(]',1,4) + 2
7267        ,INSTRB(anc_id_13,'(]',1,5) -
7268         INSTRB(anc_id_13,'(]',1,4) - 2)
7269 ,SUBSTRB(anc_id_13
7270        ,INSTRB(anc_id_13,'(]',1,5) + 2
7271        ,INSTRB(anc_id_13,'(]',1,6) -
7272         INSTRB(anc_id_13,'(]',1,5) - 2)
7273 ,SUBSTRB(anc_id_13
7274        ,INSTRB(anc_id_13,'(]',1,6) + 2
7275        ,INSTRB(anc_id_13,'(]',1,7) -
7276         INSTRB(anc_id_13,'(]',1,6) - 2)
7277 ,SUBSTRB(anc_id_13
7278        ,INSTRB(anc_id_13,'(]',1,7) + 2
7279        ,LENGTHB(anc_id_13))
7280 )
7281 
7282 WHEN anc_id_14 IS NOT NULL THEN
7283   INTO xla_ae_line_acs (
7284         ae_header_id , ae_line_num , object_version_number
7285       , analytical_criterion_code
7286       , analytical_criterion_type_code
7287       , amb_context_code
7288       , ac1,ac2,ac3,ac4,ac5)
7289 VALUES (ae_header_id, ae_line_num, C_OVN
7290 ,SUBSTRB(anc_id_14
7291        ,1
7292        ,INSTRB(anc_id_14,'(]',1,1) -1)
7293 ,SUBSTRB(anc_id_14
7294        ,INSTRB(anc_id_14,'(]',1,1) + 2
7295        ,INSTRB(anc_id_14,'(]',1,2) -
7296         INSTRB(anc_id_14,'(]',1,1) - 2)
7297 ,SUBSTRB(anc_id_14
7298        ,INSTRB(anc_id_14,'(]',1,2) + 2
7299        ,INSTRB(anc_id_14,'(]',1,3) -
7300         INSTRB(anc_id_14,'(]',1,2) - 2)
7301 ,SUBSTRB(anc_id_14
7302        ,INSTRB(anc_id_14,'(]',1,3) + 2
7303        ,INSTRB(anc_id_14,'(]',1,4) -
7304         INSTRB(anc_id_14,'(]',1,3) - 2)
7305 ,SUBSTRB(anc_id_14
7306        ,INSTRB(anc_id_14,'(]',1,4) + 2
7307        ,INSTRB(anc_id_14,'(]',1,5) -
7308         INSTRB(anc_id_14,'(]',1,4) - 2)
7309 ,SUBSTRB(anc_id_14
7310        ,INSTRB(anc_id_14,'(]',1,5) + 2
7311        ,INSTRB(anc_id_14,'(]',1,6) -
7312         INSTRB(anc_id_14,'(]',1,5) - 2)
7313 ,SUBSTRB(anc_id_14
7314        ,INSTRB(anc_id_14,'(]',1,6) + 2
7315        ,INSTRB(anc_id_14,'(]',1,7) -
7316         INSTRB(anc_id_14,'(]',1,6) - 2)
7317 ,SUBSTRB(anc_id_14
7318        ,INSTRB(anc_id_14,'(]',1,7) + 2
7319        ,LENGTHB(anc_id_14))
7320 )
7321 
7322 WHEN anc_id_15 IS NOT NULL THEN
7323   INTO xla_ae_line_acs (
7324         ae_header_id , ae_line_num , object_version_number
7325       , analytical_criterion_code
7326       , analytical_criterion_type_code
7327       , amb_context_code
7328       , ac1,ac2,ac3,ac4,ac5)
7329 VALUES (ae_header_id, ae_line_num, C_OVN
7330 ,SUBSTRB(anc_id_15
7331        ,1
7332        ,INSTRB(anc_id_15,'(]',1,1) -1)
7333 ,SUBSTRB(anc_id_15
7334        ,INSTRB(anc_id_15,'(]',1,1) + 2
7335        ,INSTRB(anc_id_15,'(]',1,2) -
7336         INSTRB(anc_id_15,'(]',1,1) - 2)
7337 ,SUBSTRB(anc_id_15
7338        ,INSTRB(anc_id_15,'(]',1,2) + 2
7339        ,INSTRB(anc_id_15,'(]',1,3) -
7340         INSTRB(anc_id_15,'(]',1,2) - 2)
7341 ,SUBSTRB(anc_id_15
7342        ,INSTRB(anc_id_15,'(]',1,3) + 2
7343        ,INSTRB(anc_id_15,'(]',1,4) -
7344         INSTRB(anc_id_15,'(]',1,3) - 2)
7345 ,SUBSTRB(anc_id_15
7346        ,INSTRB(anc_id_15,'(]',1,4) + 2
7347        ,INSTRB(anc_id_15,'(]',1,5) -
7348         INSTRB(anc_id_15,'(]',1,4) - 2)
7349 ,SUBSTRB(anc_id_15
7350        ,INSTRB(anc_id_15,'(]',1,5) + 2
7351        ,INSTRB(anc_id_15,'(]',1,6) -
7352         INSTRB(anc_id_15,'(]',1,5) - 2)
7353 ,SUBSTRB(anc_id_15
7354        ,INSTRB(anc_id_15,'(]',1,6) + 2
7355        ,INSTRB(anc_id_15,'(]',1,7) -
7356         INSTRB(anc_id_15,'(]',1,6) - 2)
7357 ,SUBSTRB(anc_id_15
7358        ,INSTRB(anc_id_15,'(]',1,7) + 2
7359        ,LENGTHB(anc_id_15))
7360 )
7361 
7362 WHEN anc_id_16 IS NOT NULL THEN
7363   INTO xla_ae_line_acs (
7364         ae_header_id , ae_line_num , object_version_number
7365       , analytical_criterion_code
7366       , analytical_criterion_type_code
7367       , amb_context_code
7368       , ac1,ac2,ac3,ac4,ac5)
7369 VALUES (ae_header_id, ae_line_num, C_OVN
7370 ,SUBSTRB(anc_id_16
7371        ,1
7372        ,INSTRB(anc_id_16,'(]',1,1) -1)
7373 ,SUBSTRB(anc_id_16
7374        ,INSTRB(anc_id_16,'(]',1,1) + 2
7375        ,INSTRB(anc_id_16,'(]',1,2) -
7376         INSTRB(anc_id_16,'(]',1,1) - 2)
7377 ,SUBSTRB(anc_id_16
7378        ,INSTRB(anc_id_16,'(]',1,2) + 2
7379        ,INSTRB(anc_id_16,'(]',1,3) -
7380         INSTRB(anc_id_16,'(]',1,2) - 2)
7381 ,SUBSTRB(anc_id_16
7382        ,INSTRB(anc_id_16,'(]',1,3) + 2
7383        ,INSTRB(anc_id_16,'(]',1,4) -
7384         INSTRB(anc_id_16,'(]',1,3) - 2)
7385 ,SUBSTRB(anc_id_16
7386        ,INSTRB(anc_id_16,'(]',1,4) + 2
7387        ,INSTRB(anc_id_16,'(]',1,5) -
7388         INSTRB(anc_id_16,'(]',1,4) - 2)
7389 ,SUBSTRB(anc_id_16
7390        ,INSTRB(anc_id_16,'(]',1,5) + 2
7391        ,INSTRB(anc_id_16,'(]',1,6) -
7392         INSTRB(anc_id_16,'(]',1,5) - 2)
7393 ,SUBSTRB(anc_id_16
7394        ,INSTRB(anc_id_16,'(]',1,6) + 2
7395        ,INSTRB(anc_id_16,'(]',1,7) -
7396         INSTRB(anc_id_16,'(]',1,6) - 2)
7397 ,SUBSTRB(anc_id_16
7398        ,INSTRB(anc_id_16,'(]',1,7) + 2
7399        ,LENGTHB(anc_id_16))
7400 )
7401 
7402 WHEN anc_id_17 IS NOT NULL THEN
7403   INTO xla_ae_line_acs (
7404         ae_header_id , ae_line_num , object_version_number
7405       , analytical_criterion_code
7406       , analytical_criterion_type_code
7407       , amb_context_code
7408       , ac1,ac2,ac3,ac4,ac5)
7409 VALUES (ae_header_id, ae_line_num, C_OVN
7410 ,SUBSTRB(anc_id_17
7411        ,1
7412        ,INSTRB(anc_id_17,'(]',1,1) -1)
7413 ,SUBSTRB(anc_id_17
7414        ,INSTRB(anc_id_17,'(]',1,1) + 2
7415        ,INSTRB(anc_id_17,'(]',1,2) -
7416         INSTRB(anc_id_17,'(]',1,1) - 2)
7417 ,SUBSTRB(anc_id_17
7418        ,INSTRB(anc_id_17,'(]',1,2) + 2
7419        ,INSTRB(anc_id_17,'(]',1,3) -
7420         INSTRB(anc_id_17,'(]',1,2) - 2)
7421 ,SUBSTRB(anc_id_17
7422        ,INSTRB(anc_id_17,'(]',1,3) + 2
7423        ,INSTRB(anc_id_17,'(]',1,4) -
7424         INSTRB(anc_id_17,'(]',1,3) - 2)
7425 ,SUBSTRB(anc_id_17
7426        ,INSTRB(anc_id_17,'(]',1,4) + 2
7427        ,INSTRB(anc_id_17,'(]',1,5) -
7428         INSTRB(anc_id_17,'(]',1,4) - 2)
7429 ,SUBSTRB(anc_id_17
7430        ,INSTRB(anc_id_17,'(]',1,5) + 2
7431        ,INSTRB(anc_id_17,'(]',1,6) -
7432         INSTRB(anc_id_17,'(]',1,5) - 2)
7433 ,SUBSTRB(anc_id_17
7434        ,INSTRB(anc_id_17,'(]',1,6) + 2
7435        ,INSTRB(anc_id_17,'(]',1,7) -
7436         INSTRB(anc_id_17,'(]',1,6) - 2)
7437 ,SUBSTRB(anc_id_17
7438        ,INSTRB(anc_id_17,'(]',1,7) + 2
7439        ,LENGTHB(anc_id_17))
7440 )
7441 
7442 WHEN anc_id_18 IS NOT NULL THEN
7443   INTO xla_ae_line_acs (
7444         ae_header_id , ae_line_num , object_version_number
7445       , analytical_criterion_code
7446       , analytical_criterion_type_code
7447       , amb_context_code
7448       , ac1,ac2,ac3,ac4,ac5)
7449 VALUES (ae_header_id, ae_line_num, C_OVN
7450 ,SUBSTRB(anc_id_18
7451        ,1
7452        ,INSTRB(anc_id_18,'(]',1,1) -1)
7453 ,SUBSTRB(anc_id_18
7454        ,INSTRB(anc_id_18,'(]',1,1) + 2
7455        ,INSTRB(anc_id_18,'(]',1,2) -
7456         INSTRB(anc_id_18,'(]',1,1) - 2)
7457 ,SUBSTRB(anc_id_18
7458        ,INSTRB(anc_id_18,'(]',1,2) + 2
7459        ,INSTRB(anc_id_18,'(]',1,3) -
7460         INSTRB(anc_id_18,'(]',1,2) - 2)
7461 ,SUBSTRB(anc_id_18
7462        ,INSTRB(anc_id_18,'(]',1,3) + 2
7463        ,INSTRB(anc_id_18,'(]',1,4) -
7464         INSTRB(anc_id_18,'(]',1,3) - 2)
7465 ,SUBSTRB(anc_id_18
7466        ,INSTRB(anc_id_18,'(]',1,4) + 2
7467        ,INSTRB(anc_id_18,'(]',1,5) -
7468         INSTRB(anc_id_18,'(]',1,4) - 2)
7469 ,SUBSTRB(anc_id_18
7470        ,INSTRB(anc_id_18,'(]',1,5) + 2
7471        ,INSTRB(anc_id_18,'(]',1,6) -
7472         INSTRB(anc_id_18,'(]',1,5) - 2)
7473 ,SUBSTRB(anc_id_18
7474        ,INSTRB(anc_id_18,'(]',1,6) + 2
7475        ,INSTRB(anc_id_18,'(]',1,7) -
7476         INSTRB(anc_id_18,'(]',1,6) - 2)
7477 ,SUBSTRB(anc_id_18
7478        ,INSTRB(anc_id_18,'(]',1,7) + 2
7479        ,LENGTHB(anc_id_18))
7480 )
7481 
7482 WHEN anc_id_19 IS NOT NULL THEN
7483   INTO xla_ae_line_acs (
7484         ae_header_id , ae_line_num , object_version_number
7485       , analytical_criterion_code
7486       , analytical_criterion_type_code
7487       , amb_context_code
7488       , ac1,ac2,ac3,ac4,ac5)
7489 VALUES (ae_header_id, ae_line_num, C_OVN
7490 ,SUBSTRB(anc_id_19
7491        ,1
7492        ,INSTRB(anc_id_19,'(]',1,1) -1)
7493 ,SUBSTRB(anc_id_19
7494        ,INSTRB(anc_id_19,'(]',1,1) + 2
7495        ,INSTRB(anc_id_19,'(]',1,2) -
7496         INSTRB(anc_id_19,'(]',1,1) - 2)
7497 ,SUBSTRB(anc_id_19
7498        ,INSTRB(anc_id_19,'(]',1,2) + 2
7499        ,INSTRB(anc_id_19,'(]',1,3) -
7500         INSTRB(anc_id_19,'(]',1,2) - 2)
7501 ,SUBSTRB(anc_id_19
7502        ,INSTRB(anc_id_19,'(]',1,3) + 2
7503        ,INSTRB(anc_id_19,'(]',1,4) -
7504         INSTRB(anc_id_19,'(]',1,3) - 2)
7505 ,SUBSTRB(anc_id_19
7506        ,INSTRB(anc_id_19,'(]',1,4) + 2
7507        ,INSTRB(anc_id_19,'(]',1,5) -
7508         INSTRB(anc_id_19,'(]',1,4) - 2)
7509 ,SUBSTRB(anc_id_19
7510        ,INSTRB(anc_id_19,'(]',1,5) + 2
7511        ,INSTRB(anc_id_19,'(]',1,6) -
7512         INSTRB(anc_id_19,'(]',1,5) - 2)
7513 ,SUBSTRB(anc_id_19
7514        ,INSTRB(anc_id_19,'(]',1,6) + 2
7515        ,INSTRB(anc_id_19,'(]',1,7) -
7516         INSTRB(anc_id_19,'(]',1,6) - 2)
7517 ,SUBSTRB(anc_id_19
7518        ,INSTRB(anc_id_19,'(]',1,7) + 2
7519        ,LENGTHB(anc_id_19))
7520 )
7521 
7522 WHEN anc_id_20 IS NOT NULL THEN
7523   INTO xla_ae_line_acs (
7524         ae_header_id , ae_line_num , object_version_number
7525       , analytical_criterion_code
7526       , analytical_criterion_type_code
7527       , amb_context_code
7528       , ac1,ac2,ac3,ac4,ac5)
7529 VALUES (ae_header_id, ae_line_num, C_OVN
7530 ,SUBSTRB(anc_id_20
7531        ,1
7532        ,INSTRB(anc_id_20,'(]',1,1) -1)
7533 ,SUBSTRB(anc_id_20
7534        ,INSTRB(anc_id_20,'(]',1,1) + 2
7535        ,INSTRB(anc_id_20,'(]',1,2) -
7536         INSTRB(anc_id_20,'(]',1,1) - 2)
7537 ,SUBSTRB(anc_id_20
7538        ,INSTRB(anc_id_20,'(]',1,2) + 2
7539        ,INSTRB(anc_id_20,'(]',1,3) -
7540         INSTRB(anc_id_20,'(]',1,2) - 2)
7541 ,SUBSTRB(anc_id_20
7542        ,INSTRB(anc_id_20,'(]',1,3) + 2
7543        ,INSTRB(anc_id_20,'(]',1,4) -
7544         INSTRB(anc_id_20,'(]',1,3) - 2)
7545 ,SUBSTRB(anc_id_20
7546        ,INSTRB(anc_id_20,'(]',1,4) + 2
7547        ,INSTRB(anc_id_20,'(]',1,5) -
7548         INSTRB(anc_id_20,'(]',1,4) - 2)
7549 ,SUBSTRB(anc_id_20
7550        ,INSTRB(anc_id_20,'(]',1,5) + 2
7551        ,INSTRB(anc_id_20,'(]',1,6) -
7552         INSTRB(anc_id_20,'(]',1,5) - 2)
7553 ,SUBSTRB(anc_id_20
7554        ,INSTRB(anc_id_20,'(]',1,6) + 2
7555        ,INSTRB(anc_id_20,'(]',1,7) -
7556         INSTRB(anc_id_20,'(]',1,6) - 2)
7557 ,SUBSTRB(anc_id_20
7558        ,INSTRB(anc_id_20,'(]',1,7) + 2
7559        ,LENGTHB(anc_id_20))
7560 )
7561 
7562 WHEN anc_id_21 IS NOT NULL THEN
7563   INTO xla_ae_line_acs (
7564         ae_header_id , ae_line_num , object_version_number
7565       , analytical_criterion_code
7566       , analytical_criterion_type_code
7567       , amb_context_code
7568       , ac1,ac2,ac3,ac4,ac5)
7569 VALUES (ae_header_id, ae_line_num, C_OVN
7570 ,SUBSTRB(anc_id_21
7571        ,1
7572        ,INSTRB(anc_id_21,'(]',1,1) -1)
7573 ,SUBSTRB(anc_id_21
7574        ,INSTRB(anc_id_21,'(]',1,1) + 2
7575        ,INSTRB(anc_id_21,'(]',1,2) -
7576         INSTRB(anc_id_21,'(]',1,1) - 2)
7577 ,SUBSTRB(anc_id_21
7578        ,INSTRB(anc_id_21,'(]',1,2) + 2
7579        ,INSTRB(anc_id_21,'(]',1,3) -
7580         INSTRB(anc_id_21,'(]',1,2) - 2)
7581 ,SUBSTRB(anc_id_21
7582        ,INSTRB(anc_id_21,'(]',1,3) + 2
7583        ,INSTRB(anc_id_21,'(]',1,4) -
7584         INSTRB(anc_id_21,'(]',1,3) - 2)
7585 ,SUBSTRB(anc_id_21
7586        ,INSTRB(anc_id_21,'(]',1,4) + 2
7587        ,INSTRB(anc_id_21,'(]',1,5) -
7588         INSTRB(anc_id_21,'(]',1,4) - 2)
7589 ,SUBSTRB(anc_id_21
7590        ,INSTRB(anc_id_21,'(]',1,5) + 2
7591        ,INSTRB(anc_id_21,'(]',1,6) -
7592         INSTRB(anc_id_21,'(]',1,5) - 2)
7593 ,SUBSTRB(anc_id_21
7594        ,INSTRB(anc_id_21,'(]',1,6) + 2
7595        ,INSTRB(anc_id_21,'(]',1,7) -
7596         INSTRB(anc_id_21,'(]',1,6) - 2)
7597 ,SUBSTRB(anc_id_21
7598        ,INSTRB(anc_id_21,'(]',1,7) + 2
7599        ,LENGTHB(anc_id_21))
7600 )
7601 
7602 WHEN anc_id_22 IS NOT NULL THEN
7603   INTO xla_ae_line_acs (
7604         ae_header_id , ae_line_num , object_version_number
7605       , analytical_criterion_code
7606       , analytical_criterion_type_code
7607       , amb_context_code
7608       , ac1,ac2,ac3,ac4,ac5)
7609 VALUES (ae_header_id, ae_line_num, C_OVN
7610 ,SUBSTRB(anc_id_22
7611        ,1
7612        ,INSTRB(anc_id_22,'(]',1,1) -1)
7613 ,SUBSTRB(anc_id_22
7614        ,INSTRB(anc_id_22,'(]',1,1) + 2
7615        ,INSTRB(anc_id_22,'(]',1,2) -
7616         INSTRB(anc_id_22,'(]',1,1) - 2)
7617 ,SUBSTRB(anc_id_22
7618        ,INSTRB(anc_id_22,'(]',1,2) + 2
7619        ,INSTRB(anc_id_22,'(]',1,3) -
7620         INSTRB(anc_id_22,'(]',1,2) - 2)
7621 ,SUBSTRB(anc_id_22
7622        ,INSTRB(anc_id_22,'(]',1,3) + 2
7623        ,INSTRB(anc_id_22,'(]',1,4) -
7624         INSTRB(anc_id_22,'(]',1,3) - 2)
7625 ,SUBSTRB(anc_id_22
7626        ,INSTRB(anc_id_22,'(]',1,4) + 2
7627        ,INSTRB(anc_id_22,'(]',1,5) -
7628         INSTRB(anc_id_22,'(]',1,4) - 2)
7629 ,SUBSTRB(anc_id_22
7630        ,INSTRB(anc_id_22,'(]',1,5) + 2
7631        ,INSTRB(anc_id_22,'(]',1,6) -
7632         INSTRB(anc_id_22,'(]',1,5) - 2)
7633 ,SUBSTRB(anc_id_22
7634        ,INSTRB(anc_id_22,'(]',1,6) + 2
7635        ,INSTRB(anc_id_22,'(]',1,7) -
7636         INSTRB(anc_id_22,'(]',1,6) - 2)
7637 ,SUBSTRB(anc_id_22
7638        ,INSTRB(anc_id_22,'(]',1,7) + 2
7639        ,LENGTHB(anc_id_22))
7640 )
7641 
7642 WHEN anc_id_23 IS NOT NULL THEN
7643   INTO xla_ae_line_acs (
7644         ae_header_id , ae_line_num , object_version_number
7645       , analytical_criterion_code
7646       , analytical_criterion_type_code
7647       , amb_context_code
7648       , ac1,ac2,ac3,ac4,ac5)
7649 VALUES (ae_header_id, ae_line_num, C_OVN
7650 ,SUBSTRB(anc_id_23
7651        ,1
7652        ,INSTRB(anc_id_23,'(]',1,1) -1)
7653 ,SUBSTRB(anc_id_23
7654        ,INSTRB(anc_id_23,'(]',1,1) + 2
7655        ,INSTRB(anc_id_23,'(]',1,2) -
7656         INSTRB(anc_id_23,'(]',1,1) - 2)
7657 ,SUBSTRB(anc_id_23
7658        ,INSTRB(anc_id_23,'(]',1,2) + 2
7659        ,INSTRB(anc_id_23,'(]',1,3) -
7660         INSTRB(anc_id_23,'(]',1,2) - 2)
7661 ,SUBSTRB(anc_id_23
7662        ,INSTRB(anc_id_23,'(]',1,3) + 2
7663        ,INSTRB(anc_id_23,'(]',1,4) -
7664         INSTRB(anc_id_23,'(]',1,3) - 2)
7665 ,SUBSTRB(anc_id_23
7666        ,INSTRB(anc_id_23,'(]',1,4) + 2
7667        ,INSTRB(anc_id_23,'(]',1,5) -
7668         INSTRB(anc_id_23,'(]',1,4) - 2)
7669 ,SUBSTRB(anc_id_23
7670        ,INSTRB(anc_id_23,'(]',1,5) + 2
7671        ,INSTRB(anc_id_23,'(]',1,6) -
7672         INSTRB(anc_id_23,'(]',1,5) - 2)
7673 ,SUBSTRB(anc_id_23
7674        ,INSTRB(anc_id_23,'(]',1,6) + 2
7675        ,INSTRB(anc_id_23,'(]',1,7) -
7676         INSTRB(anc_id_23,'(]',1,6) - 2)
7677 ,SUBSTRB(anc_id_23
7678        ,INSTRB(anc_id_23,'(]',1,7) + 2
7679        ,LENGTHB(anc_id_23))
7680 )
7681 
7682 WHEN anc_id_24 IS NOT NULL THEN
7683   INTO xla_ae_line_acs (
7684         ae_header_id , ae_line_num , object_version_number
7685       , analytical_criterion_code
7686       , analytical_criterion_type_code
7687       , amb_context_code
7688       , ac1,ac2,ac3,ac4,ac5)
7689 VALUES (ae_header_id, ae_line_num, C_OVN
7690 ,SUBSTRB(anc_id_24
7691        ,1
7692        ,INSTRB(anc_id_24,'(]',1,1) -1)
7693 ,SUBSTRB(anc_id_24
7694        ,INSTRB(anc_id_24,'(]',1,1) + 2
7695        ,INSTRB(anc_id_24,'(]',1,2) -
7696         INSTRB(anc_id_24,'(]',1,1) - 2)
7697 ,SUBSTRB(anc_id_24
7698        ,INSTRB(anc_id_24,'(]',1,2) + 2
7699        ,INSTRB(anc_id_24,'(]',1,3) -
7700         INSTRB(anc_id_24,'(]',1,2) - 2)
7701 ,SUBSTRB(anc_id_24
7702        ,INSTRB(anc_id_24,'(]',1,3) + 2
7703        ,INSTRB(anc_id_24,'(]',1,4) -
7704         INSTRB(anc_id_24,'(]',1,3) - 2)
7705 ,SUBSTRB(anc_id_24
7706        ,INSTRB(anc_id_24,'(]',1,4) + 2
7707        ,INSTRB(anc_id_24,'(]',1,5) -
7708         INSTRB(anc_id_24,'(]',1,4) - 2)
7709 ,SUBSTRB(anc_id_24
7710        ,INSTRB(anc_id_24,'(]',1,5) + 2
7711        ,INSTRB(anc_id_24,'(]',1,6) -
7712         INSTRB(anc_id_24,'(]',1,5) - 2)
7713 ,SUBSTRB(anc_id_24
7714        ,INSTRB(anc_id_24,'(]',1,6) + 2
7715        ,INSTRB(anc_id_24,'(]',1,7) -
7716         INSTRB(anc_id_24,'(]',1,6) - 2)
7717 ,SUBSTRB(anc_id_24
7718        ,INSTRB(anc_id_24,'(]',1,7) + 2
7719        ,LENGTHB(anc_id_24))
7720 )
7721 
7722 WHEN anc_id_25 IS NOT NULL THEN
7723   INTO xla_ae_line_acs (
7724         ae_header_id , ae_line_num , object_version_number
7725       , analytical_criterion_code
7726       , analytical_criterion_type_code
7727       , amb_context_code
7728       , ac1,ac2,ac3,ac4,ac5)
7729 VALUES (ae_header_id, ae_line_num, C_OVN
7730 ,SUBSTRB(anc_id_25
7731        ,1
7732        ,INSTRB(anc_id_25,'(]',1,1) -1)
7733 ,SUBSTRB(anc_id_25
7734        ,INSTRB(anc_id_25,'(]',1,1) + 2
7735        ,INSTRB(anc_id_25,'(]',1,2) -
7736         INSTRB(anc_id_25,'(]',1,1) - 2)
7737 ,SUBSTRB(anc_id_25
7738        ,INSTRB(anc_id_25,'(]',1,2) + 2
7739        ,INSTRB(anc_id_25,'(]',1,3) -
7740         INSTRB(anc_id_25,'(]',1,2) - 2)
7741 ,SUBSTRB(anc_id_25
7742        ,INSTRB(anc_id_25,'(]',1,3) + 2
7743        ,INSTRB(anc_id_25,'(]',1,4) -
7744         INSTRB(anc_id_25,'(]',1,3) - 2)
7745 ,SUBSTRB(anc_id_25
7746        ,INSTRB(anc_id_25,'(]',1,4) + 2
7747        ,INSTRB(anc_id_25,'(]',1,5) -
7748         INSTRB(anc_id_25,'(]',1,4) - 2)
7749 ,SUBSTRB(anc_id_25
7750        ,INSTRB(anc_id_25,'(]',1,5) + 2
7751        ,INSTRB(anc_id_25,'(]',1,6) -
7752         INSTRB(anc_id_25,'(]',1,5) - 2)
7753 ,SUBSTRB(anc_id_25
7754        ,INSTRB(anc_id_25,'(]',1,6) + 2
7755        ,INSTRB(anc_id_25,'(]',1,7) -
7756         INSTRB(anc_id_25,'(]',1,6) - 2)
7757 ,SUBSTRB(anc_id_25
7758        ,INSTRB(anc_id_25,'(]',1,7) + 2
7759        ,LENGTHB(anc_id_25))
7760 )
7761 
7762 WHEN anc_id_26 IS NOT NULL THEN
7763   INTO xla_ae_line_acs (
7764         ae_header_id , ae_line_num , object_version_number
7765       , analytical_criterion_code
7766       , analytical_criterion_type_code
7767       , amb_context_code
7768       , ac1,ac2,ac3,ac4,ac5)
7769 VALUES (ae_header_id, ae_line_num, C_OVN
7770 ,SUBSTRB(anc_id_26
7771        ,1
7772        ,INSTRB(anc_id_26,'(]',1,1) -1)
7773 ,SUBSTRB(anc_id_26
7774        ,INSTRB(anc_id_26,'(]',1,1) + 2
7775        ,INSTRB(anc_id_26,'(]',1,2) -
7776         INSTRB(anc_id_26,'(]',1,1) - 2)
7777 ,SUBSTRB(anc_id_26
7778        ,INSTRB(anc_id_26,'(]',1,2) + 2
7779        ,INSTRB(anc_id_26,'(]',1,3) -
7780         INSTRB(anc_id_26,'(]',1,2) - 2)
7781 ,SUBSTRB(anc_id_26
7782        ,INSTRB(anc_id_26,'(]',1,3) + 2
7783        ,INSTRB(anc_id_26,'(]',1,4) -
7784         INSTRB(anc_id_26,'(]',1,3) - 2)
7785 ,SUBSTRB(anc_id_26
7786        ,INSTRB(anc_id_26,'(]',1,4) + 2
7787        ,INSTRB(anc_id_26,'(]',1,5) -
7788         INSTRB(anc_id_26,'(]',1,4) - 2)
7789 ,SUBSTRB(anc_id_26
7790        ,INSTRB(anc_id_26,'(]',1,5) + 2
7791        ,INSTRB(anc_id_26,'(]',1,6) -
7792         INSTRB(anc_id_26,'(]',1,5) - 2)
7793 ,SUBSTRB(anc_id_26
7794        ,INSTRB(anc_id_26,'(]',1,6) + 2
7795        ,INSTRB(anc_id_26,'(]',1,7) -
7796         INSTRB(anc_id_26,'(]',1,6) - 2)
7797 ,SUBSTRB(anc_id_26
7798        ,INSTRB(anc_id_26,'(]',1,7) + 2
7799        ,LENGTHB(anc_id_26))
7800 )
7801 
7802 WHEN anc_id_27 IS NOT NULL THEN
7803   INTO xla_ae_line_acs (
7804         ae_header_id , ae_line_num , object_version_number
7805       , analytical_criterion_code
7806       , analytical_criterion_type_code
7807       , amb_context_code
7808       , ac1,ac2,ac3,ac4,ac5)
7809 VALUES (ae_header_id, ae_line_num, C_OVN
7810 ,SUBSTRB(anc_id_27
7811        ,1
7812        ,INSTRB(anc_id_27,'(]',1,1) -1)
7813 ,SUBSTRB(anc_id_27
7814        ,INSTRB(anc_id_27,'(]',1,1) + 2
7815        ,INSTRB(anc_id_27,'(]',1,2) -
7816         INSTRB(anc_id_27,'(]',1,1) - 2)
7817 ,SUBSTRB(anc_id_27
7818        ,INSTRB(anc_id_27,'(]',1,2) + 2
7819        ,INSTRB(anc_id_27,'(]',1,3) -
7820         INSTRB(anc_id_27,'(]',1,2) - 2)
7821 ,SUBSTRB(anc_id_27
7822        ,INSTRB(anc_id_27,'(]',1,3) + 2
7823        ,INSTRB(anc_id_27,'(]',1,4) -
7824         INSTRB(anc_id_27,'(]',1,3) - 2)
7825 ,SUBSTRB(anc_id_27
7826        ,INSTRB(anc_id_27,'(]',1,4) + 2
7827        ,INSTRB(anc_id_27,'(]',1,5) -
7828         INSTRB(anc_id_27,'(]',1,4) - 2)
7829 ,SUBSTRB(anc_id_27
7830        ,INSTRB(anc_id_27,'(]',1,5) + 2
7831        ,INSTRB(anc_id_27,'(]',1,6) -
7832         INSTRB(anc_id_27,'(]',1,5) - 2)
7833 ,SUBSTRB(anc_id_27
7834        ,INSTRB(anc_id_27,'(]',1,6) + 2
7835        ,INSTRB(anc_id_27,'(]',1,7) -
7836         INSTRB(anc_id_27,'(]',1,6) - 2)
7837 ,SUBSTRB(anc_id_27
7838        ,INSTRB(anc_id_27,'(]',1,7) + 2
7839        ,LENGTHB(anc_id_27))
7840 )
7841 
7842 WHEN anc_id_28 IS NOT NULL THEN
7843   INTO xla_ae_line_acs (
7844         ae_header_id , ae_line_num , object_version_number
7845       , analytical_criterion_code
7846       , analytical_criterion_type_code
7847       , amb_context_code
7848       , ac1,ac2,ac3,ac4,ac5)
7849 VALUES (ae_header_id, ae_line_num, C_OVN
7850 ,SUBSTRB(anc_id_28
7851        ,1
7852        ,INSTRB(anc_id_28,'(]',1,1) -1)
7853 ,SUBSTRB(anc_id_28
7854        ,INSTRB(anc_id_28,'(]',1,1) + 2
7855        ,INSTRB(anc_id_28,'(]',1,2) -
7856         INSTRB(anc_id_28,'(]',1,1) - 2)
7857 ,SUBSTRB(anc_id_28
7858        ,INSTRB(anc_id_28,'(]',1,2) + 2
7859        ,INSTRB(anc_id_28,'(]',1,3) -
7860         INSTRB(anc_id_28,'(]',1,2) - 2)
7861 ,SUBSTRB(anc_id_28
7862        ,INSTRB(anc_id_28,'(]',1,3) + 2
7863        ,INSTRB(anc_id_28,'(]',1,4) -
7864         INSTRB(anc_id_28,'(]',1,3) - 2)
7865 ,SUBSTRB(anc_id_28
7866        ,INSTRB(anc_id_28,'(]',1,4) + 2
7867        ,INSTRB(anc_id_28,'(]',1,5) -
7868         INSTRB(anc_id_28,'(]',1,4) - 2)
7869 ,SUBSTRB(anc_id_28
7870        ,INSTRB(anc_id_28,'(]',1,5) + 2
7871        ,INSTRB(anc_id_28,'(]',1,6) -
7872         INSTRB(anc_id_28,'(]',1,5) - 2)
7873 ,SUBSTRB(anc_id_28
7874        ,INSTRB(anc_id_28,'(]',1,6) + 2
7875        ,INSTRB(anc_id_28,'(]',1,7) -
7876         INSTRB(anc_id_28,'(]',1,6) - 2)
7877 ,SUBSTRB(anc_id_28
7878        ,INSTRB(anc_id_28,'(]',1,7) + 2
7879        ,LENGTHB(anc_id_28))
7880 )
7881 
7882 WHEN anc_id_29 IS NOT NULL THEN
7883   INTO xla_ae_line_acs (
7884         ae_header_id , ae_line_num , object_version_number
7885       , analytical_criterion_code
7886       , analytical_criterion_type_code
7887       , amb_context_code
7888       , ac1,ac2,ac3,ac4,ac5)
7889 VALUES (ae_header_id, ae_line_num, C_OVN
7890 ,SUBSTRB(anc_id_29
7891        ,1
7892        ,INSTRB(anc_id_29,'(]',1,1) -1)
7893 ,SUBSTRB(anc_id_29
7894        ,INSTRB(anc_id_29,'(]',1,1) + 2
7895        ,INSTRB(anc_id_29,'(]',1,2) -
7896         INSTRB(anc_id_29,'(]',1,1) - 2)
7897 ,SUBSTRB(anc_id_29
7898        ,INSTRB(anc_id_29,'(]',1,2) + 2
7899        ,INSTRB(anc_id_29,'(]',1,3) -
7900         INSTRB(anc_id_29,'(]',1,2) - 2)
7901 ,SUBSTRB(anc_id_29
7902        ,INSTRB(anc_id_29,'(]',1,3) + 2
7903        ,INSTRB(anc_id_29,'(]',1,4) -
7904         INSTRB(anc_id_29,'(]',1,3) - 2)
7905 ,SUBSTRB(anc_id_29
7906        ,INSTRB(anc_id_29,'(]',1,4) + 2
7907        ,INSTRB(anc_id_29,'(]',1,5) -
7908         INSTRB(anc_id_29,'(]',1,4) - 2)
7909 ,SUBSTRB(anc_id_29
7910        ,INSTRB(anc_id_29,'(]',1,5) + 2
7911        ,INSTRB(anc_id_29,'(]',1,6) -
7912         INSTRB(anc_id_29,'(]',1,5) - 2)
7913 ,SUBSTRB(anc_id_29
7914        ,INSTRB(anc_id_29,'(]',1,6) + 2
7915        ,INSTRB(anc_id_29,'(]',1,7) -
7916         INSTRB(anc_id_29,'(]',1,6) - 2)
7917 ,SUBSTRB(anc_id_29
7918        ,INSTRB(anc_id_29,'(]',1,7) + 2
7919        ,LENGTHB(anc_id_29))
7920 )
7921 
7922 WHEN anc_id_30 IS NOT NULL THEN
7923   INTO xla_ae_line_acs (
7924         ae_header_id , ae_line_num , object_version_number
7925       , analytical_criterion_code
7926       , analytical_criterion_type_code
7927       , amb_context_code
7928       , ac1,ac2,ac3,ac4,ac5)
7929 VALUES (ae_header_id, ae_line_num, C_OVN
7930 ,SUBSTRB(anc_id_30
7931        ,1
7932        ,INSTRB(anc_id_30,'(]',1,1) -1)
7933 ,SUBSTRB(anc_id_30
7934        ,INSTRB(anc_id_30,'(]',1,1) + 2
7935        ,INSTRB(anc_id_30,'(]',1,2) -
7936         INSTRB(anc_id_30,'(]',1,1) - 2)
7937 ,SUBSTRB(anc_id_30
7938        ,INSTRB(anc_id_30,'(]',1,2) + 2
7939        ,INSTRB(anc_id_30,'(]',1,3) -
7940         INSTRB(anc_id_30,'(]',1,2) - 2)
7941 ,SUBSTRB(anc_id_30
7942        ,INSTRB(anc_id_30,'(]',1,3) + 2
7943        ,INSTRB(anc_id_30,'(]',1,4) -
7944         INSTRB(anc_id_30,'(]',1,3) - 2)
7945 ,SUBSTRB(anc_id_30
7946        ,INSTRB(anc_id_30,'(]',1,4) + 2
7947        ,INSTRB(anc_id_30,'(]',1,5) -
7948         INSTRB(anc_id_30,'(]',1,4) - 2)
7949 ,SUBSTRB(anc_id_30
7950        ,INSTRB(anc_id_30,'(]',1,5) + 2
7951        ,INSTRB(anc_id_30,'(]',1,6) -
7952         INSTRB(anc_id_30,'(]',1,5) - 2)
7953 ,SUBSTRB(anc_id_30
7954        ,INSTRB(anc_id_30,'(]',1,6) + 2
7955        ,INSTRB(anc_id_30,'(]',1,7) -
7956         INSTRB(anc_id_30,'(]',1,6) - 2)
7957 ,SUBSTRB(anc_id_30
7958        ,INSTRB(anc_id_30,'(]',1,7) + 2
7959        ,LENGTHB(anc_id_30))
7960 )
7961 
7962 WHEN anc_id_31 IS NOT NULL THEN
7963   INTO xla_ae_line_acs (
7964         ae_header_id , ae_line_num , object_version_number
7965       , analytical_criterion_code
7966       , analytical_criterion_type_code
7967       , amb_context_code
7968       , ac1,ac2,ac3,ac4,ac5)
7969 VALUES (ae_header_id, ae_line_num, C_OVN
7970 ,SUBSTRB(anc_id_31
7971        ,1
7972        ,INSTRB(anc_id_31,'(]',1,1) -1)
7973 ,SUBSTRB(anc_id_31
7974        ,INSTRB(anc_id_31,'(]',1,1) + 2
7975        ,INSTRB(anc_id_31,'(]',1,2) -
7976         INSTRB(anc_id_31,'(]',1,1) - 2)
7977 ,SUBSTRB(anc_id_31
7978        ,INSTRB(anc_id_31,'(]',1,2) + 2
7979        ,INSTRB(anc_id_31,'(]',1,3) -
7980         INSTRB(anc_id_31,'(]',1,2) - 2)
7981 ,SUBSTRB(anc_id_31
7982        ,INSTRB(anc_id_31,'(]',1,3) + 2
7983        ,INSTRB(anc_id_31,'(]',1,4) -
7984         INSTRB(anc_id_31,'(]',1,3) - 2)
7985 ,SUBSTRB(anc_id_31
7986        ,INSTRB(anc_id_31,'(]',1,4) + 2
7987        ,INSTRB(anc_id_31,'(]',1,5) -
7988         INSTRB(anc_id_31,'(]',1,4) - 2)
7989 ,SUBSTRB(anc_id_31
7990        ,INSTRB(anc_id_31,'(]',1,5) + 2
7991        ,INSTRB(anc_id_31,'(]',1,6) -
7992         INSTRB(anc_id_31,'(]',1,5) - 2)
7993 ,SUBSTRB(anc_id_31
7994        ,INSTRB(anc_id_31,'(]',1,6) + 2
7995        ,INSTRB(anc_id_31,'(]',1,7) -
7996         INSTRB(anc_id_31,'(]',1,6) - 2)
7997 ,SUBSTRB(anc_id_31
7998        ,INSTRB(anc_id_31,'(]',1,7) + 2
7999        ,LENGTHB(anc_id_31))
8000 )
8001 
8002 WHEN anc_id_32 IS NOT NULL THEN
8003   INTO xla_ae_line_acs (
8004         ae_header_id , ae_line_num , object_version_number
8005       , analytical_criterion_code
8006       , analytical_criterion_type_code
8007       , amb_context_code
8008       , ac1,ac2,ac3,ac4,ac5)
8009 VALUES (ae_header_id, ae_line_num, C_OVN
8010 ,SUBSTRB(anc_id_32
8011        ,1
8012        ,INSTRB(anc_id_32,'(]',1,1) -1)
8013 ,SUBSTRB(anc_id_32
8014        ,INSTRB(anc_id_32,'(]',1,1) + 2
8015        ,INSTRB(anc_id_32,'(]',1,2) -
8016         INSTRB(anc_id_32,'(]',1,1) - 2)
8017 ,SUBSTRB(anc_id_32
8018        ,INSTRB(anc_id_32,'(]',1,2) + 2
8019        ,INSTRB(anc_id_32,'(]',1,3) -
8020         INSTRB(anc_id_32,'(]',1,2) - 2)
8021 ,SUBSTRB(anc_id_32
8022        ,INSTRB(anc_id_32,'(]',1,3) + 2
8023        ,INSTRB(anc_id_32,'(]',1,4) -
8024         INSTRB(anc_id_32,'(]',1,3) - 2)
8025 ,SUBSTRB(anc_id_32
8026        ,INSTRB(anc_id_32,'(]',1,4) + 2
8027        ,INSTRB(anc_id_32,'(]',1,5) -
8028         INSTRB(anc_id_32,'(]',1,4) - 2)
8029 ,SUBSTRB(anc_id_32
8030        ,INSTRB(anc_id_32,'(]',1,5) + 2
8031        ,INSTRB(anc_id_32,'(]',1,6) -
8032         INSTRB(anc_id_32,'(]',1,5) - 2)
8033 ,SUBSTRB(anc_id_32
8034        ,INSTRB(anc_id_32,'(]',1,6) + 2
8035        ,INSTRB(anc_id_32,'(]',1,7) -
8036         INSTRB(anc_id_32,'(]',1,6) - 2)
8037 ,SUBSTRB(anc_id_32
8038        ,INSTRB(anc_id_32,'(]',1,7) + 2
8039        ,LENGTHB(anc_id_32))
8040 )
8041 
8042 WHEN anc_id_33 IS NOT NULL THEN
8043   INTO xla_ae_line_acs (
8044         ae_header_id , ae_line_num , object_version_number
8045       , analytical_criterion_code
8046       , analytical_criterion_type_code
8047       , amb_context_code
8048       , ac1,ac2,ac3,ac4,ac5)
8049 VALUES (ae_header_id, ae_line_num, C_OVN
8050 ,SUBSTRB(anc_id_33
8051        ,1
8052        ,INSTRB(anc_id_33,'(]',1,1) -1)
8053 ,SUBSTRB(anc_id_33
8054        ,INSTRB(anc_id_33,'(]',1,1) + 2
8055        ,INSTRB(anc_id_33,'(]',1,2) -
8056         INSTRB(anc_id_33,'(]',1,1) - 2)
8057 ,SUBSTRB(anc_id_33
8058        ,INSTRB(anc_id_33,'(]',1,2) + 2
8059        ,INSTRB(anc_id_33,'(]',1,3) -
8060         INSTRB(anc_id_33,'(]',1,2) - 2)
8061 ,SUBSTRB(anc_id_33
8062        ,INSTRB(anc_id_33,'(]',1,3) + 2
8063        ,INSTRB(anc_id_33,'(]',1,4) -
8064         INSTRB(anc_id_33,'(]',1,3) - 2)
8065 ,SUBSTRB(anc_id_33
8066        ,INSTRB(anc_id_33,'(]',1,4) + 2
8067        ,INSTRB(anc_id_33,'(]',1,5) -
8068         INSTRB(anc_id_33,'(]',1,4) - 2)
8069 ,SUBSTRB(anc_id_33
8070        ,INSTRB(anc_id_33,'(]',1,5) + 2
8071        ,INSTRB(anc_id_33,'(]',1,6) -
8072         INSTRB(anc_id_33,'(]',1,5) - 2)
8073 ,SUBSTRB(anc_id_33
8074        ,INSTRB(anc_id_33,'(]',1,6) + 2
8075        ,INSTRB(anc_id_33,'(]',1,7) -
8076         INSTRB(anc_id_33,'(]',1,6) - 2)
8077 ,SUBSTRB(anc_id_33
8078        ,INSTRB(anc_id_33,'(]',1,7) + 2
8079        ,LENGTHB(anc_id_33))
8080 )
8081 
8082 WHEN anc_id_34 IS NOT NULL THEN
8083   INTO xla_ae_line_acs (
8084         ae_header_id , ae_line_num , object_version_number
8085       , analytical_criterion_code
8086       , analytical_criterion_type_code
8087       , amb_context_code
8088       , ac1,ac2,ac3,ac4,ac5)
8089 VALUES (ae_header_id, ae_line_num, C_OVN
8090 ,SUBSTRB(anc_id_34
8091        ,1
8092        ,INSTRB(anc_id_34,'(]',1,1) -1)
8093 ,SUBSTRB(anc_id_34
8094        ,INSTRB(anc_id_34,'(]',1,1) + 2
8095        ,INSTRB(anc_id_34,'(]',1,2) -
8096         INSTRB(anc_id_34,'(]',1,1) - 2)
8097 ,SUBSTRB(anc_id_34
8098        ,INSTRB(anc_id_34,'(]',1,2) + 2
8099        ,INSTRB(anc_id_34,'(]',1,3) -
8100         INSTRB(anc_id_34,'(]',1,2) - 2)
8101 ,SUBSTRB(anc_id_34
8102        ,INSTRB(anc_id_34,'(]',1,3) + 2
8103        ,INSTRB(anc_id_34,'(]',1,4) -
8104         INSTRB(anc_id_34,'(]',1,3) - 2)
8105 ,SUBSTRB(anc_id_34
8106        ,INSTRB(anc_id_34,'(]',1,4) + 2
8107        ,INSTRB(anc_id_34,'(]',1,5) -
8108         INSTRB(anc_id_34,'(]',1,4) - 2)
8109 ,SUBSTRB(anc_id_34
8110        ,INSTRB(anc_id_34,'(]',1,5) + 2
8111        ,INSTRB(anc_id_34,'(]',1,6) -
8112         INSTRB(anc_id_34,'(]',1,5) - 2)
8113 ,SUBSTRB(anc_id_34
8114        ,INSTRB(anc_id_34,'(]',1,6) + 2
8115        ,INSTRB(anc_id_34,'(]',1,7) -
8116         INSTRB(anc_id_34,'(]',1,6) - 2)
8117 ,SUBSTRB(anc_id_34
8118        ,INSTRB(anc_id_34,'(]',1,7) + 2
8119        ,LENGTHB(anc_id_34))
8120 )
8121 
8122 WHEN anc_id_35 IS NOT NULL THEN
8123   INTO xla_ae_line_acs (
8124         ae_header_id , ae_line_num , object_version_number
8125       , analytical_criterion_code
8126       , analytical_criterion_type_code
8127       , amb_context_code
8128       , ac1,ac2,ac3,ac4,ac5)
8129 VALUES (ae_header_id, ae_line_num, C_OVN
8130 ,SUBSTRB(anc_id_35
8131        ,1
8132        ,INSTRB(anc_id_35,'(]',1,1) -1)
8133 ,SUBSTRB(anc_id_35
8134        ,INSTRB(anc_id_35,'(]',1,1) + 2
8135        ,INSTRB(anc_id_35,'(]',1,2) -
8136         INSTRB(anc_id_35,'(]',1,1) - 2)
8137 ,SUBSTRB(anc_id_35
8138        ,INSTRB(anc_id_35,'(]',1,2) + 2
8139        ,INSTRB(anc_id_35,'(]',1,3) -
8140         INSTRB(anc_id_35,'(]',1,2) - 2)
8141 ,SUBSTRB(anc_id_35
8142        ,INSTRB(anc_id_35,'(]',1,3) + 2
8143        ,INSTRB(anc_id_35,'(]',1,4) -
8144         INSTRB(anc_id_35,'(]',1,3) - 2)
8145 ,SUBSTRB(anc_id_35
8146        ,INSTRB(anc_id_35,'(]',1,4) + 2
8147        ,INSTRB(anc_id_35,'(]',1,5) -
8148         INSTRB(anc_id_35,'(]',1,4) - 2)
8149 ,SUBSTRB(anc_id_35
8150        ,INSTRB(anc_id_35,'(]',1,5) + 2
8151        ,INSTRB(anc_id_35,'(]',1,6) -
8152         INSTRB(anc_id_35,'(]',1,5) - 2)
8153 ,SUBSTRB(anc_id_35
8154        ,INSTRB(anc_id_35,'(]',1,6) + 2
8155        ,INSTRB(anc_id_35,'(]',1,7) -
8156         INSTRB(anc_id_35,'(]',1,6) - 2)
8157 ,SUBSTRB(anc_id_35
8158        ,INSTRB(anc_id_35,'(]',1,7) + 2
8159        ,LENGTHB(anc_id_35))
8160 )
8161 
8162 WHEN anc_id_36 IS NOT NULL THEN
8163   INTO xla_ae_line_acs (
8164         ae_header_id , ae_line_num , object_version_number
8165       , analytical_criterion_code
8166       , analytical_criterion_type_code
8167       , amb_context_code
8168       , ac1,ac2,ac3,ac4,ac5)
8169 VALUES (ae_header_id, ae_line_num, C_OVN
8170 ,SUBSTRB(anc_id_36
8171        ,1
8172        ,INSTRB(anc_id_36,'(]',1,1) -1)
8173 ,SUBSTRB(anc_id_36
8174        ,INSTRB(anc_id_36,'(]',1,1) + 2
8175        ,INSTRB(anc_id_36,'(]',1,2) -
8176         INSTRB(anc_id_36,'(]',1,1) - 2)
8177 ,SUBSTRB(anc_id_36
8178        ,INSTRB(anc_id_36,'(]',1,2) + 2
8179        ,INSTRB(anc_id_36,'(]',1,3) -
8180         INSTRB(anc_id_36,'(]',1,2) - 2)
8181 ,SUBSTRB(anc_id_36
8182        ,INSTRB(anc_id_36,'(]',1,3) + 2
8183        ,INSTRB(anc_id_36,'(]',1,4) -
8184         INSTRB(anc_id_36,'(]',1,3) - 2)
8185 ,SUBSTRB(anc_id_36
8186        ,INSTRB(anc_id_36,'(]',1,4) + 2
8187        ,INSTRB(anc_id_36,'(]',1,5) -
8188         INSTRB(anc_id_36,'(]',1,4) - 2)
8189 ,SUBSTRB(anc_id_36
8190        ,INSTRB(anc_id_36,'(]',1,5) + 2
8191        ,INSTRB(anc_id_36,'(]',1,6) -
8192         INSTRB(anc_id_36,'(]',1,5) - 2)
8193 ,SUBSTRB(anc_id_36
8194        ,INSTRB(anc_id_36,'(]',1,6) + 2
8195        ,INSTRB(anc_id_36,'(]',1,7) -
8196         INSTRB(anc_id_36,'(]',1,6) - 2)
8197 ,SUBSTRB(anc_id_36
8198        ,INSTRB(anc_id_36,'(]',1,7) + 2
8199        ,LENGTHB(anc_id_36))
8200 )
8201 
8202 WHEN anc_id_37 IS NOT NULL THEN
8203   INTO xla_ae_line_acs (
8204         ae_header_id , ae_line_num , object_version_number
8205       , analytical_criterion_code
8206       , analytical_criterion_type_code
8207       , amb_context_code
8208       , ac1,ac2,ac3,ac4,ac5)
8209 VALUES (ae_header_id, ae_line_num, C_OVN
8210 ,SUBSTRB(anc_id_37
8211        ,1
8212        ,INSTRB(anc_id_37,'(]',1,1) -1)
8213 ,SUBSTRB(anc_id_37
8214        ,INSTRB(anc_id_37,'(]',1,1) + 2
8215        ,INSTRB(anc_id_37,'(]',1,2) -
8216         INSTRB(anc_id_37,'(]',1,1) - 2)
8217 ,SUBSTRB(anc_id_37
8218        ,INSTRB(anc_id_37,'(]',1,2) + 2
8219        ,INSTRB(anc_id_37,'(]',1,3) -
8220         INSTRB(anc_id_37,'(]',1,2) - 2)
8221 ,SUBSTRB(anc_id_37
8222        ,INSTRB(anc_id_37,'(]',1,3) + 2
8223        ,INSTRB(anc_id_37,'(]',1,4) -
8224         INSTRB(anc_id_37,'(]',1,3) - 2)
8225 ,SUBSTRB(anc_id_37
8226        ,INSTRB(anc_id_37,'(]',1,4) + 2
8227        ,INSTRB(anc_id_37,'(]',1,5) -
8228         INSTRB(anc_id_37,'(]',1,4) - 2)
8229 ,SUBSTRB(anc_id_37
8230        ,INSTRB(anc_id_37,'(]',1,5) + 2
8231        ,INSTRB(anc_id_37,'(]',1,6) -
8232         INSTRB(anc_id_37,'(]',1,5) - 2)
8233 ,SUBSTRB(anc_id_37
8234        ,INSTRB(anc_id_37,'(]',1,6) + 2
8235        ,INSTRB(anc_id_37,'(]',1,7) -
8236         INSTRB(anc_id_37,'(]',1,6) - 2)
8237 ,SUBSTRB(anc_id_37
8238        ,INSTRB(anc_id_37,'(]',1,7) + 2
8239        ,LENGTHB(anc_id_37))
8240 )
8241 
8242 WHEN anc_id_38 IS NOT NULL THEN
8243   INTO xla_ae_line_acs (
8244         ae_header_id , ae_line_num , object_version_number
8245       , analytical_criterion_code
8246       , analytical_criterion_type_code
8247       , amb_context_code
8248       , ac1,ac2,ac3,ac4,ac5)
8249 VALUES (ae_header_id, ae_line_num, C_OVN
8250 ,SUBSTRB(anc_id_38
8251        ,1
8252        ,INSTRB(anc_id_38,'(]',1,1) -1)
8253 ,SUBSTRB(anc_id_38
8254        ,INSTRB(anc_id_38,'(]',1,1) + 2
8255        ,INSTRB(anc_id_38,'(]',1,2) -
8256         INSTRB(anc_id_38,'(]',1,1) - 2)
8257 ,SUBSTRB(anc_id_38
8258        ,INSTRB(anc_id_38,'(]',1,2) + 2
8259        ,INSTRB(anc_id_38,'(]',1,3) -
8260         INSTRB(anc_id_38,'(]',1,2) - 2)
8261 ,SUBSTRB(anc_id_38
8262        ,INSTRB(anc_id_38,'(]',1,3) + 2
8263        ,INSTRB(anc_id_38,'(]',1,4) -
8264         INSTRB(anc_id_38,'(]',1,3) - 2)
8265 ,SUBSTRB(anc_id_38
8266        ,INSTRB(anc_id_38,'(]',1,4) + 2
8267        ,INSTRB(anc_id_38,'(]',1,5) -
8268         INSTRB(anc_id_38,'(]',1,4) - 2)
8269 ,SUBSTRB(anc_id_38
8270        ,INSTRB(anc_id_38,'(]',1,5) + 2
8271        ,INSTRB(anc_id_38,'(]',1,6) -
8272         INSTRB(anc_id_38,'(]',1,5) - 2)
8273 ,SUBSTRB(anc_id_38
8274        ,INSTRB(anc_id_38,'(]',1,6) + 2
8275        ,INSTRB(anc_id_38,'(]',1,7) -
8276         INSTRB(anc_id_38,'(]',1,6) - 2)
8277 ,SUBSTRB(anc_id_38
8278        ,INSTRB(anc_id_38,'(]',1,7) + 2
8279        ,LENGTHB(anc_id_38))
8280 )
8281 
8282 WHEN anc_id_39 IS NOT NULL THEN
8283   INTO xla_ae_line_acs (
8284         ae_header_id , ae_line_num , object_version_number
8285       , analytical_criterion_code
8286       , analytical_criterion_type_code
8287       , amb_context_code
8288       , ac1,ac2,ac3,ac4,ac5)
8289 VALUES (ae_header_id, ae_line_num, C_OVN
8290 ,SUBSTRB(anc_id_39
8291        ,1
8292        ,INSTRB(anc_id_39,'(]',1,1) -1)
8293 ,SUBSTRB(anc_id_39
8294        ,INSTRB(anc_id_39,'(]',1,1) + 2
8295        ,INSTRB(anc_id_39,'(]',1,2) -
8296         INSTRB(anc_id_39,'(]',1,1) - 2)
8297 ,SUBSTRB(anc_id_39
8298        ,INSTRB(anc_id_39,'(]',1,2) + 2
8299        ,INSTRB(anc_id_39,'(]',1,3) -
8300         INSTRB(anc_id_39,'(]',1,2) - 2)
8301 ,SUBSTRB(anc_id_39
8302        ,INSTRB(anc_id_39,'(]',1,3) + 2
8303        ,INSTRB(anc_id_39,'(]',1,4) -
8304         INSTRB(anc_id_39,'(]',1,3) - 2)
8305 ,SUBSTRB(anc_id_39
8306        ,INSTRB(anc_id_39,'(]',1,4) + 2
8307        ,INSTRB(anc_id_39,'(]',1,5) -
8308         INSTRB(anc_id_39,'(]',1,4) - 2)
8309 ,SUBSTRB(anc_id_39
8310        ,INSTRB(anc_id_39,'(]',1,5) + 2
8311        ,INSTRB(anc_id_39,'(]',1,6) -
8312         INSTRB(anc_id_39,'(]',1,5) - 2)
8313 ,SUBSTRB(anc_id_39
8314        ,INSTRB(anc_id_39,'(]',1,6) + 2
8315        ,INSTRB(anc_id_39,'(]',1,7) -
8316         INSTRB(anc_id_39,'(]',1,6) - 2)
8317 ,SUBSTRB(anc_id_39
8318        ,INSTRB(anc_id_39,'(]',1,7) + 2
8319        ,LENGTHB(anc_id_39))
8320 )
8321 
8322 WHEN anc_id_40 IS NOT NULL THEN
8323   INTO xla_ae_line_acs (
8324         ae_header_id , ae_line_num , object_version_number
8325       , analytical_criterion_code
8326       , analytical_criterion_type_code
8327       , amb_context_code
8328       , ac1,ac2,ac3,ac4,ac5)
8329 VALUES (ae_header_id, ae_line_num, C_OVN
8330 ,SUBSTRB(anc_id_40
8331        ,1
8332        ,INSTRB(anc_id_40,'(]',1,1) -1)
8333 ,SUBSTRB(anc_id_40
8334        ,INSTRB(anc_id_40,'(]',1,1) + 2
8335        ,INSTRB(anc_id_40,'(]',1,2) -
8336         INSTRB(anc_id_40,'(]',1,1) - 2)
8337 ,SUBSTRB(anc_id_40
8338        ,INSTRB(anc_id_40,'(]',1,2) + 2
8339        ,INSTRB(anc_id_40,'(]',1,3) -
8340         INSTRB(anc_id_40,'(]',1,2) - 2)
8341 ,SUBSTRB(anc_id_40
8342        ,INSTRB(anc_id_40,'(]',1,3) + 2
8343        ,INSTRB(anc_id_40,'(]',1,4) -
8344         INSTRB(anc_id_40,'(]',1,3) - 2)
8345 ,SUBSTRB(anc_id_40
8346        ,INSTRB(anc_id_40,'(]',1,4) + 2
8347        ,INSTRB(anc_id_40,'(]',1,5) -
8348         INSTRB(anc_id_40,'(]',1,4) - 2)
8349 ,SUBSTRB(anc_id_40
8350        ,INSTRB(anc_id_40,'(]',1,5) + 2
8351        ,INSTRB(anc_id_40,'(]',1,6) -
8352         INSTRB(anc_id_40,'(]',1,5) - 2)
8353 ,SUBSTRB(anc_id_40
8354        ,INSTRB(anc_id_40,'(]',1,6) + 2
8355        ,INSTRB(anc_id_40,'(]',1,7) -
8356         INSTRB(anc_id_40,'(]',1,6) - 2)
8357 ,SUBSTRB(anc_id_40
8358        ,INSTRB(anc_id_40,'(]',1,7) + 2
8359        ,LENGTHB(anc_id_40))
8360 )
8361 
8362 WHEN anc_id_41 IS NOT NULL THEN
8363   INTO xla_ae_line_acs (
8364         ae_header_id , ae_line_num , object_version_number
8365       , analytical_criterion_code
8366       , analytical_criterion_type_code
8367       , amb_context_code
8368       , ac1,ac2,ac3,ac4,ac5)
8369 VALUES (ae_header_id, ae_line_num, C_OVN
8370 ,SUBSTRB(anc_id_41
8371        ,1
8372        ,INSTRB(anc_id_41,'(]',1,1) -1)
8373 ,SUBSTRB(anc_id_41
8374        ,INSTRB(anc_id_41,'(]',1,1) + 2
8375        ,INSTRB(anc_id_41,'(]',1,2) -
8376         INSTRB(anc_id_41,'(]',1,1) - 2)
8377 ,SUBSTRB(anc_id_41
8378        ,INSTRB(anc_id_41,'(]',1,2) + 2
8379        ,INSTRB(anc_id_41,'(]',1,3) -
8380         INSTRB(anc_id_41,'(]',1,2) - 2)
8381 ,SUBSTRB(anc_id_41
8382        ,INSTRB(anc_id_41,'(]',1,3) + 2
8383        ,INSTRB(anc_id_41,'(]',1,4) -
8384         INSTRB(anc_id_41,'(]',1,3) - 2)
8385 ,SUBSTRB(anc_id_41
8386        ,INSTRB(anc_id_41,'(]',1,4) + 2
8387        ,INSTRB(anc_id_41,'(]',1,5) -
8388         INSTRB(anc_id_41,'(]',1,4) - 2)
8389 ,SUBSTRB(anc_id_41
8390        ,INSTRB(anc_id_41,'(]',1,5) + 2
8391        ,INSTRB(anc_id_41,'(]',1,6) -
8392         INSTRB(anc_id_41,'(]',1,5) - 2)
8393 ,SUBSTRB(anc_id_41
8394        ,INSTRB(anc_id_41,'(]',1,6) + 2
8395        ,INSTRB(anc_id_41,'(]',1,7) -
8396         INSTRB(anc_id_41,'(]',1,6) - 2)
8397 ,SUBSTRB(anc_id_41
8398        ,INSTRB(anc_id_41,'(]',1,7) + 2
8399        ,LENGTHB(anc_id_41))
8400 )
8401 
8402 WHEN anc_id_42 IS NOT NULL THEN
8403   INTO xla_ae_line_acs (
8404         ae_header_id , ae_line_num , object_version_number
8405       , analytical_criterion_code
8406       , analytical_criterion_type_code
8407       , amb_context_code
8408       , ac1,ac2,ac3,ac4,ac5)
8409 VALUES (ae_header_id, ae_line_num, C_OVN
8410 ,SUBSTRB(anc_id_42
8411        ,1
8412        ,INSTRB(anc_id_42,'(]',1,1) -1)
8413 ,SUBSTRB(anc_id_42
8414        ,INSTRB(anc_id_42,'(]',1,1) + 2
8415        ,INSTRB(anc_id_42,'(]',1,2) -
8416         INSTRB(anc_id_42,'(]',1,1) - 2)
8417 ,SUBSTRB(anc_id_42
8418        ,INSTRB(anc_id_42,'(]',1,2) + 2
8419        ,INSTRB(anc_id_42,'(]',1,3) -
8420         INSTRB(anc_id_42,'(]',1,2) - 2)
8421 ,SUBSTRB(anc_id_42
8422        ,INSTRB(anc_id_42,'(]',1,3) + 2
8423        ,INSTRB(anc_id_42,'(]',1,4) -
8424         INSTRB(anc_id_42,'(]',1,3) - 2)
8425 ,SUBSTRB(anc_id_42
8426        ,INSTRB(anc_id_42,'(]',1,4) + 2
8427        ,INSTRB(anc_id_42,'(]',1,5) -
8428         INSTRB(anc_id_42,'(]',1,4) - 2)
8429 ,SUBSTRB(anc_id_42
8430        ,INSTRB(anc_id_42,'(]',1,5) + 2
8431        ,INSTRB(anc_id_42,'(]',1,6) -
8432         INSTRB(anc_id_42,'(]',1,5) - 2)
8433 ,SUBSTRB(anc_id_42
8434        ,INSTRB(anc_id_42,'(]',1,6) + 2
8435        ,INSTRB(anc_id_42,'(]',1,7) -
8436         INSTRB(anc_id_42,'(]',1,6) - 2)
8437 ,SUBSTRB(anc_id_42
8438        ,INSTRB(anc_id_42,'(]',1,7) + 2
8439        ,LENGTHB(anc_id_42))
8440 )
8441 
8442 WHEN anc_id_43 IS NOT NULL THEN
8443   INTO xla_ae_line_acs (
8444         ae_header_id , ae_line_num , object_version_number
8445       , analytical_criterion_code
8446       , analytical_criterion_type_code
8447       , amb_context_code
8448       , ac1,ac2,ac3,ac4,ac5)
8449 VALUES (ae_header_id, ae_line_num, C_OVN
8450 ,SUBSTRB(anc_id_43
8451        ,1
8452        ,INSTRB(anc_id_43,'(]',1,1) -1)
8453 ,SUBSTRB(anc_id_43
8454        ,INSTRB(anc_id_43,'(]',1,1) + 2
8455        ,INSTRB(anc_id_43,'(]',1,2) -
8456         INSTRB(anc_id_43,'(]',1,1) - 2)
8457 ,SUBSTRB(anc_id_43
8458        ,INSTRB(anc_id_43,'(]',1,2) + 2
8459        ,INSTRB(anc_id_43,'(]',1,3) -
8460         INSTRB(anc_id_43,'(]',1,2) - 2)
8461 ,SUBSTRB(anc_id_43
8462        ,INSTRB(anc_id_43,'(]',1,3) + 2
8463        ,INSTRB(anc_id_43,'(]',1,4) -
8464         INSTRB(anc_id_43,'(]',1,3) - 2)
8465 ,SUBSTRB(anc_id_43
8466        ,INSTRB(anc_id_43,'(]',1,4) + 2
8467        ,INSTRB(anc_id_43,'(]',1,5) -
8468         INSTRB(anc_id_43,'(]',1,4) - 2)
8469 ,SUBSTRB(anc_id_43
8470        ,INSTRB(anc_id_43,'(]',1,5) + 2
8471        ,INSTRB(anc_id_43,'(]',1,6) -
8472         INSTRB(anc_id_43,'(]',1,5) - 2)
8473 ,SUBSTRB(anc_id_43
8474        ,INSTRB(anc_id_43,'(]',1,6) + 2
8475        ,INSTRB(anc_id_43,'(]',1,7) -
8476         INSTRB(anc_id_43,'(]',1,6) - 2)
8477 ,SUBSTRB(anc_id_43
8478        ,INSTRB(anc_id_43,'(]',1,7) + 2
8479        ,LENGTHB(anc_id_43))
8480 )
8481 
8482 WHEN anc_id_44 IS NOT NULL THEN
8483   INTO xla_ae_line_acs (
8484         ae_header_id , ae_line_num , object_version_number
8485       , analytical_criterion_code
8486       , analytical_criterion_type_code
8487       , amb_context_code
8488       , ac1,ac2,ac3,ac4,ac5)
8489 VALUES (ae_header_id, ae_line_num, C_OVN
8490 ,SUBSTRB(anc_id_44
8491        ,1
8492        ,INSTRB(anc_id_44,'(]',1,1) -1)
8493 ,SUBSTRB(anc_id_44
8494        ,INSTRB(anc_id_44,'(]',1,1) + 2
8495        ,INSTRB(anc_id_44,'(]',1,2) -
8496         INSTRB(anc_id_44,'(]',1,1) - 2)
8497 ,SUBSTRB(anc_id_44
8498        ,INSTRB(anc_id_44,'(]',1,2) + 2
8499        ,INSTRB(anc_id_44,'(]',1,3) -
8500         INSTRB(anc_id_44,'(]',1,2) - 2)
8501 ,SUBSTRB(anc_id_44
8502        ,INSTRB(anc_id_44,'(]',1,3) + 2
8503        ,INSTRB(anc_id_44,'(]',1,4) -
8504         INSTRB(anc_id_44,'(]',1,3) - 2)
8505 ,SUBSTRB(anc_id_44
8506        ,INSTRB(anc_id_44,'(]',1,4) + 2
8507        ,INSTRB(anc_id_44,'(]',1,5) -
8508         INSTRB(anc_id_44,'(]',1,4) - 2)
8509 ,SUBSTRB(anc_id_44
8510        ,INSTRB(anc_id_44,'(]',1,5) + 2
8511        ,INSTRB(anc_id_44,'(]',1,6) -
8512         INSTRB(anc_id_44,'(]',1,5) - 2)
8513 ,SUBSTRB(anc_id_44
8514        ,INSTRB(anc_id_44,'(]',1,6) + 2
8515        ,INSTRB(anc_id_44,'(]',1,7) -
8516         INSTRB(anc_id_44,'(]',1,6) - 2)
8517 ,SUBSTRB(anc_id_44
8518        ,INSTRB(anc_id_44,'(]',1,7) + 2
8519        ,LENGTHB(anc_id_44))
8520 )
8521 
8522 WHEN anc_id_45 IS NOT NULL THEN
8523   INTO xla_ae_line_acs (
8524         ae_header_id , ae_line_num , object_version_number
8525       , analytical_criterion_code
8526       , analytical_criterion_type_code
8527       , amb_context_code
8528       , ac1,ac2,ac3,ac4,ac5)
8529 VALUES (ae_header_id, ae_line_num, C_OVN
8530 ,SUBSTRB(anc_id_45
8531        ,1
8532        ,INSTRB(anc_id_45,'(]',1,1) -1)
8533 ,SUBSTRB(anc_id_45
8534        ,INSTRB(anc_id_45,'(]',1,1) + 2
8535        ,INSTRB(anc_id_45,'(]',1,2) -
8536         INSTRB(anc_id_45,'(]',1,1) - 2)
8537 ,SUBSTRB(anc_id_45
8538        ,INSTRB(anc_id_45,'(]',1,2) + 2
8539        ,INSTRB(anc_id_45,'(]',1,3) -
8540         INSTRB(anc_id_45,'(]',1,2) - 2)
8541 ,SUBSTRB(anc_id_45
8542        ,INSTRB(anc_id_45,'(]',1,3) + 2
8543        ,INSTRB(anc_id_45,'(]',1,4) -
8544         INSTRB(anc_id_45,'(]',1,3) - 2)
8545 ,SUBSTRB(anc_id_45
8546        ,INSTRB(anc_id_45,'(]',1,4) + 2
8547        ,INSTRB(anc_id_45,'(]',1,5) -
8548         INSTRB(anc_id_45,'(]',1,4) - 2)
8549 ,SUBSTRB(anc_id_45
8550        ,INSTRB(anc_id_45,'(]',1,5) + 2
8551        ,INSTRB(anc_id_45,'(]',1,6) -
8552         INSTRB(anc_id_45,'(]',1,5) - 2)
8553 ,SUBSTRB(anc_id_45
8554        ,INSTRB(anc_id_45,'(]',1,6) + 2
8555        ,INSTRB(anc_id_45,'(]',1,7) -
8556         INSTRB(anc_id_45,'(]',1,6) - 2)
8557 ,SUBSTRB(anc_id_45
8558        ,INSTRB(anc_id_45,'(]',1,7) + 2
8559        ,LENGTHB(anc_id_45))
8560 )
8561 
8562 WHEN anc_id_46 IS NOT NULL THEN
8563   INTO xla_ae_line_acs (
8564         ae_header_id , ae_line_num , object_version_number
8565       , analytical_criterion_code
8566       , analytical_criterion_type_code
8567       , amb_context_code
8568       , ac1,ac2,ac3,ac4,ac5)
8569 VALUES (ae_header_id, ae_line_num, C_OVN
8570 ,SUBSTRB(anc_id_46
8571        ,1
8572        ,INSTRB(anc_id_46,'(]',1,1) -1)
8573 ,SUBSTRB(anc_id_46
8574        ,INSTRB(anc_id_46,'(]',1,1) + 2
8575        ,INSTRB(anc_id_46,'(]',1,2) -
8576         INSTRB(anc_id_46,'(]',1,1) - 2)
8577 ,SUBSTRB(anc_id_46
8578        ,INSTRB(anc_id_46,'(]',1,2) + 2
8579        ,INSTRB(anc_id_46,'(]',1,3) -
8580         INSTRB(anc_id_46,'(]',1,2) - 2)
8581 ,SUBSTRB(anc_id_46
8582        ,INSTRB(anc_id_46,'(]',1,3) + 2
8583        ,INSTRB(anc_id_46,'(]',1,4) -
8584         INSTRB(anc_id_46,'(]',1,3) - 2)
8585 ,SUBSTRB(anc_id_46
8586        ,INSTRB(anc_id_46,'(]',1,4) + 2
8587        ,INSTRB(anc_id_46,'(]',1,5) -
8588         INSTRB(anc_id_46,'(]',1,4) - 2)
8589 ,SUBSTRB(anc_id_46
8590        ,INSTRB(anc_id_46,'(]',1,5) + 2
8591        ,INSTRB(anc_id_46,'(]',1,6) -
8592         INSTRB(anc_id_46,'(]',1,5) - 2)
8593 ,SUBSTRB(anc_id_46
8594        ,INSTRB(anc_id_46,'(]',1,6) + 2
8595        ,INSTRB(anc_id_46,'(]',1,7) -
8596         INSTRB(anc_id_46,'(]',1,6) - 2)
8597 ,SUBSTRB(anc_id_46
8598        ,INSTRB(anc_id_46,'(]',1,7) + 2
8599        ,LENGTHB(anc_id_46))
8600 )
8601 
8602 WHEN anc_id_47 IS NOT NULL THEN
8603   INTO xla_ae_line_acs (
8604         ae_header_id , ae_line_num , object_version_number
8605       , analytical_criterion_code
8606       , analytical_criterion_type_code
8607       , amb_context_code
8608       , ac1,ac2,ac3,ac4,ac5)
8609 VALUES (ae_header_id, ae_line_num, C_OVN
8610 ,SUBSTRB(anc_id_47
8611        ,1
8612        ,INSTRB(anc_id_47,'(]',1,1) -1)
8613 ,SUBSTRB(anc_id_47
8614        ,INSTRB(anc_id_47,'(]',1,1) + 2
8615        ,INSTRB(anc_id_47,'(]',1,2) -
8616         INSTRB(anc_id_47,'(]',1,1) - 2)
8617 ,SUBSTRB(anc_id_47
8618        ,INSTRB(anc_id_47,'(]',1,2) + 2
8619        ,INSTRB(anc_id_47,'(]',1,3) -
8620         INSTRB(anc_id_47,'(]',1,2) - 2)
8621 ,SUBSTRB(anc_id_47
8622        ,INSTRB(anc_id_47,'(]',1,3) + 2
8623        ,INSTRB(anc_id_47,'(]',1,4) -
8624         INSTRB(anc_id_47,'(]',1,3) - 2)
8625 ,SUBSTRB(anc_id_47
8626        ,INSTRB(anc_id_47,'(]',1,4) + 2
8627        ,INSTRB(anc_id_47,'(]',1,5) -
8628         INSTRB(anc_id_47,'(]',1,4) - 2)
8629 ,SUBSTRB(anc_id_47
8630        ,INSTRB(anc_id_47,'(]',1,5) + 2
8631        ,INSTRB(anc_id_47,'(]',1,6) -
8632         INSTRB(anc_id_47,'(]',1,5) - 2)
8633 ,SUBSTRB(anc_id_47
8634        ,INSTRB(anc_id_47,'(]',1,6) + 2
8635        ,INSTRB(anc_id_47,'(]',1,7) -
8636         INSTRB(anc_id_47,'(]',1,6) - 2)
8637 ,SUBSTRB(anc_id_47
8638        ,INSTRB(anc_id_47,'(]',1,7) + 2
8639        ,LENGTHB(anc_id_47))
8640 )
8641 
8642 WHEN anc_id_48 IS NOT NULL THEN
8643   INTO xla_ae_line_acs (
8644         ae_header_id , ae_line_num , object_version_number
8645       , analytical_criterion_code
8646       , analytical_criterion_type_code
8647       , amb_context_code
8648       , ac1,ac2,ac3,ac4,ac5)
8649 VALUES (ae_header_id, ae_line_num, C_OVN
8650 ,SUBSTRB(anc_id_48
8651        ,1
8652        ,INSTRB(anc_id_48,'(]',1,1) -1)
8653 ,SUBSTRB(anc_id_48
8654        ,INSTRB(anc_id_48,'(]',1,1) + 2
8655        ,INSTRB(anc_id_48,'(]',1,2) -
8656         INSTRB(anc_id_48,'(]',1,1) - 2)
8657 ,SUBSTRB(anc_id_48
8658        ,INSTRB(anc_id_48,'(]',1,2) + 2
8659        ,INSTRB(anc_id_48,'(]',1,3) -
8660         INSTRB(anc_id_48,'(]',1,2) - 2)
8661 ,SUBSTRB(anc_id_48
8662        ,INSTRB(anc_id_48,'(]',1,3) + 2
8663        ,INSTRB(anc_id_48,'(]',1,4) -
8664         INSTRB(anc_id_48,'(]',1,3) - 2)
8665 ,SUBSTRB(anc_id_48
8666        ,INSTRB(anc_id_48,'(]',1,4) + 2
8667        ,INSTRB(anc_id_48,'(]',1,5) -
8668         INSTRB(anc_id_48,'(]',1,4) - 2)
8669 ,SUBSTRB(anc_id_48
8670        ,INSTRB(anc_id_48,'(]',1,5) + 2
8671        ,INSTRB(anc_id_48,'(]',1,6) -
8672         INSTRB(anc_id_48,'(]',1,5) - 2)
8673 ,SUBSTRB(anc_id_48
8674        ,INSTRB(anc_id_48,'(]',1,6) + 2
8675        ,INSTRB(anc_id_48,'(]',1,7) -
8676         INSTRB(anc_id_48,'(]',1,6) - 2)
8677 ,SUBSTRB(anc_id_48
8678        ,INSTRB(anc_id_48,'(]',1,7) + 2
8679        ,LENGTHB(anc_id_48))
8680 )
8681 
8682 WHEN anc_id_49 IS NOT NULL THEN
8683   INTO xla_ae_line_acs (
8684         ae_header_id , ae_line_num , object_version_number
8685       , analytical_criterion_code
8686       , analytical_criterion_type_code
8687       , amb_context_code
8688       , ac1,ac2,ac3,ac4,ac5)
8689 VALUES (ae_header_id, ae_line_num, C_OVN
8690 ,SUBSTRB(anc_id_49
8691        ,1
8692        ,INSTRB(anc_id_49,'(]',1,1) -1)
8693 ,SUBSTRB(anc_id_49
8694        ,INSTRB(anc_id_49,'(]',1,1) + 2
8695        ,INSTRB(anc_id_49,'(]',1,2) -
8696         INSTRB(anc_id_49,'(]',1,1) - 2)
8697 ,SUBSTRB(anc_id_49
8698        ,INSTRB(anc_id_49,'(]',1,2) + 2
8699        ,INSTRB(anc_id_49,'(]',1,3) -
8700         INSTRB(anc_id_49,'(]',1,2) - 2)
8701 ,SUBSTRB(anc_id_49
8702        ,INSTRB(anc_id_49,'(]',1,3) + 2
8703        ,INSTRB(anc_id_49,'(]',1,4) -
8704         INSTRB(anc_id_49,'(]',1,3) - 2)
8705 ,SUBSTRB(anc_id_49
8706        ,INSTRB(anc_id_49,'(]',1,4) + 2
8707        ,INSTRB(anc_id_49,'(]',1,5) -
8708         INSTRB(anc_id_49,'(]',1,4) - 2)
8709 ,SUBSTRB(anc_id_49
8710        ,INSTRB(anc_id_49,'(]',1,5) + 2
8711        ,INSTRB(anc_id_49,'(]',1,6) -
8712         INSTRB(anc_id_49,'(]',1,5) - 2)
8713 ,SUBSTRB(anc_id_49
8714        ,INSTRB(anc_id_49,'(]',1,6) + 2
8715        ,INSTRB(anc_id_49,'(]',1,7) -
8716         INSTRB(anc_id_49,'(]',1,6) - 2)
8717 ,SUBSTRB(anc_id_49
8718        ,INSTRB(anc_id_49,'(]',1,7) + 2
8719        ,LENGTHB(anc_id_49))
8720 )
8721 
8722 WHEN anc_id_50 IS NOT NULL THEN
8723   INTO xla_ae_line_acs (
8724         ae_header_id , ae_line_num , object_version_number
8725       , analytical_criterion_code
8726       , analytical_criterion_type_code
8727       , amb_context_code
8728       , ac1,ac2,ac3,ac4,ac5)
8729 VALUES (ae_header_id, ae_line_num, C_OVN
8730 ,SUBSTRB(anc_id_50
8731        ,1
8732        ,INSTRB(anc_id_50,'(]',1,1) -1)
8733 ,SUBSTRB(anc_id_50
8734        ,INSTRB(anc_id_50,'(]',1,1) + 2
8735        ,INSTRB(anc_id_50,'(]',1,2) -
8736         INSTRB(anc_id_50,'(]',1,1) - 2)
8737 ,SUBSTRB(anc_id_50
8738        ,INSTRB(anc_id_50,'(]',1,2) + 2
8739        ,INSTRB(anc_id_50,'(]',1,3) -
8740         INSTRB(anc_id_50,'(]',1,2) - 2)
8741 ,SUBSTRB(anc_id_50
8742        ,INSTRB(anc_id_50,'(]',1,3) + 2
8743        ,INSTRB(anc_id_50,'(]',1,4) -
8744         INSTRB(anc_id_50,'(]',1,3) - 2)
8745 ,SUBSTRB(anc_id_50
8746        ,INSTRB(anc_id_50,'(]',1,4) + 2
8747        ,INSTRB(anc_id_50,'(]',1,5) -
8748         INSTRB(anc_id_50,'(]',1,4) - 2)
8749 ,SUBSTRB(anc_id_50
8750        ,INSTRB(anc_id_50,'(]',1,5) + 2
8751        ,INSTRB(anc_id_50,'(]',1,6) -
8752         INSTRB(anc_id_50,'(]',1,5) - 2)
8753 ,SUBSTRB(anc_id_50
8754        ,INSTRB(anc_id_50,'(]',1,6) + 2
8755        ,INSTRB(anc_id_50,'(]',1,7) -
8756         INSTRB(anc_id_50,'(]',1,6) - 2)
8757 ,SUBSTRB(anc_id_50
8758        ,INSTRB(anc_id_50,'(]',1,7) + 2
8759        ,LENGTHB(anc_id_50))
8760 )
8761 
8762 WHEN anc_id_51 IS NOT NULL THEN
8763   INTO xla_ae_line_acs (
8764         ae_header_id , ae_line_num , object_version_number
8765       , analytical_criterion_code
8766       , analytical_criterion_type_code
8767       , amb_context_code
8768       , ac1,ac2,ac3,ac4,ac5)
8769 VALUES (ae_header_id, ae_line_num, C_OVN
8770 ,SUBSTRB(anc_id_51
8771        ,1
8772        ,INSTRB(anc_id_51,'(]',1,1) -1)
8773 ,SUBSTRB(anc_id_51
8774        ,INSTRB(anc_id_51,'(]',1,1) + 2
8775        ,INSTRB(anc_id_51,'(]',1,2) -
8776         INSTRB(anc_id_51,'(]',1,1) - 2)
8777 ,SUBSTRB(anc_id_51
8778        ,INSTRB(anc_id_51,'(]',1,2) + 2
8779        ,INSTRB(anc_id_51,'(]',1,3) -
8780         INSTRB(anc_id_51,'(]',1,2) - 2)
8781 ,SUBSTRB(anc_id_51
8782        ,INSTRB(anc_id_51,'(]',1,3) + 2
8783        ,INSTRB(anc_id_51,'(]',1,4) -
8784         INSTRB(anc_id_51,'(]',1,3) - 2)
8785 ,SUBSTRB(anc_id_51
8786        ,INSTRB(anc_id_51,'(]',1,4) + 2
8787        ,INSTRB(anc_id_51,'(]',1,5) -
8788         INSTRB(anc_id_51,'(]',1,4) - 2)
8789 ,SUBSTRB(anc_id_51
8790        ,INSTRB(anc_id_51,'(]',1,5) + 2
8791        ,INSTRB(anc_id_51,'(]',1,6) -
8792         INSTRB(anc_id_51,'(]',1,5) - 2)
8793 ,SUBSTRB(anc_id_51
8794        ,INSTRB(anc_id_51,'(]',1,6) + 2
8795        ,INSTRB(anc_id_51,'(]',1,7) -
8796         INSTRB(anc_id_51,'(]',1,6) - 2)
8797 ,SUBSTRB(anc_id_51
8798        ,INSTRB(anc_id_51,'(]',1,7) + 2
8799        ,LENGTHB(anc_id_51))
8800 )
8801 
8802 WHEN anc_id_52 IS NOT NULL THEN
8803   INTO xla_ae_line_acs (
8804         ae_header_id , ae_line_num , object_version_number
8805       , analytical_criterion_code
8806       , analytical_criterion_type_code
8807       , amb_context_code
8808       , ac1,ac2,ac3,ac4,ac5)
8809 VALUES (ae_header_id, ae_line_num, C_OVN
8810 ,SUBSTRB(anc_id_52
8811        ,1
8812        ,INSTRB(anc_id_52,'(]',1,1) -1)
8813 ,SUBSTRB(anc_id_52
8814        ,INSTRB(anc_id_52,'(]',1,1) + 2
8815        ,INSTRB(anc_id_52,'(]',1,2) -
8816         INSTRB(anc_id_52,'(]',1,1) - 2)
8817 ,SUBSTRB(anc_id_52
8818        ,INSTRB(anc_id_52,'(]',1,2) + 2
8819        ,INSTRB(anc_id_52,'(]',1,3) -
8820         INSTRB(anc_id_52,'(]',1,2) - 2)
8821 ,SUBSTRB(anc_id_52
8822        ,INSTRB(anc_id_52,'(]',1,3) + 2
8823        ,INSTRB(anc_id_52,'(]',1,4) -
8824         INSTRB(anc_id_52,'(]',1,3) - 2)
8825 ,SUBSTRB(anc_id_52
8826        ,INSTRB(anc_id_52,'(]',1,4) + 2
8827        ,INSTRB(anc_id_52,'(]',1,5) -
8828         INSTRB(anc_id_52,'(]',1,4) - 2)
8829 ,SUBSTRB(anc_id_52
8830        ,INSTRB(anc_id_52,'(]',1,5) + 2
8831        ,INSTRB(anc_id_52,'(]',1,6) -
8832         INSTRB(anc_id_52,'(]',1,5) - 2)
8833 ,SUBSTRB(anc_id_52
8834        ,INSTRB(anc_id_52,'(]',1,6) + 2
8835        ,INSTRB(anc_id_52,'(]',1,7) -
8836         INSTRB(anc_id_52,'(]',1,6) - 2)
8837 ,SUBSTRB(anc_id_52
8838        ,INSTRB(anc_id_52,'(]',1,7) + 2
8839        ,LENGTHB(anc_id_52))
8840 )
8841 
8842 WHEN anc_id_53 IS NOT NULL THEN
8843   INTO xla_ae_line_acs (
8844         ae_header_id , ae_line_num , object_version_number
8845       , analytical_criterion_code
8846       , analytical_criterion_type_code
8847       , amb_context_code
8848       , ac1,ac2,ac3,ac4,ac5)
8849 VALUES (ae_header_id, ae_line_num, C_OVN
8850 ,SUBSTRB(anc_id_53
8851        ,1
8852        ,INSTRB(anc_id_53,'(]',1,1) -1)
8853 ,SUBSTRB(anc_id_53
8854        ,INSTRB(anc_id_53,'(]',1,1) + 2
8855        ,INSTRB(anc_id_53,'(]',1,2) -
8856         INSTRB(anc_id_53,'(]',1,1) - 2)
8857 ,SUBSTRB(anc_id_53
8858        ,INSTRB(anc_id_53,'(]',1,2) + 2
8859        ,INSTRB(anc_id_53,'(]',1,3) -
8860         INSTRB(anc_id_53,'(]',1,2) - 2)
8861 ,SUBSTRB(anc_id_53
8862        ,INSTRB(anc_id_53,'(]',1,3) + 2
8863        ,INSTRB(anc_id_53,'(]',1,4) -
8864         INSTRB(anc_id_53,'(]',1,3) - 2)
8865 ,SUBSTRB(anc_id_53
8866        ,INSTRB(anc_id_53,'(]',1,4) + 2
8867        ,INSTRB(anc_id_53,'(]',1,5) -
8868         INSTRB(anc_id_53,'(]',1,4) - 2)
8869 ,SUBSTRB(anc_id_53
8870        ,INSTRB(anc_id_53,'(]',1,5) + 2
8871        ,INSTRB(anc_id_53,'(]',1,6) -
8872         INSTRB(anc_id_53,'(]',1,5) - 2)
8873 ,SUBSTRB(anc_id_53
8874        ,INSTRB(anc_id_53,'(]',1,6) + 2
8875        ,INSTRB(anc_id_53,'(]',1,7) -
8876         INSTRB(anc_id_53,'(]',1,6) - 2)
8877 ,SUBSTRB(anc_id_53
8878        ,INSTRB(anc_id_53,'(]',1,7) + 2
8879        ,LENGTHB(anc_id_53))
8880 )
8881 
8882 WHEN anc_id_54 IS NOT NULL THEN
8883   INTO xla_ae_line_acs (
8884         ae_header_id , ae_line_num , object_version_number
8885       , analytical_criterion_code
8886       , analytical_criterion_type_code
8887       , amb_context_code
8888       , ac1,ac2,ac3,ac4,ac5)
8889 VALUES (ae_header_id, ae_line_num, C_OVN
8890 ,SUBSTRB(anc_id_54
8891        ,1
8892        ,INSTRB(anc_id_54,'(]',1,1) -1)
8893 ,SUBSTRB(anc_id_54
8894        ,INSTRB(anc_id_54,'(]',1,1) + 2
8895        ,INSTRB(anc_id_54,'(]',1,2) -
8896         INSTRB(anc_id_54,'(]',1,1) - 2)
8897 ,SUBSTRB(anc_id_54
8898        ,INSTRB(anc_id_54,'(]',1,2) + 2
8899        ,INSTRB(anc_id_54,'(]',1,3) -
8900         INSTRB(anc_id_54,'(]',1,2) - 2)
8901 ,SUBSTRB(anc_id_54
8902        ,INSTRB(anc_id_54,'(]',1,3) + 2
8903        ,INSTRB(anc_id_54,'(]',1,4) -
8904         INSTRB(anc_id_54,'(]',1,3) - 2)
8905 ,SUBSTRB(anc_id_54
8906        ,INSTRB(anc_id_54,'(]',1,4) + 2
8907        ,INSTRB(anc_id_54,'(]',1,5) -
8908         INSTRB(anc_id_54,'(]',1,4) - 2)
8909 ,SUBSTRB(anc_id_54
8910        ,INSTRB(anc_id_54,'(]',1,5) + 2
8911        ,INSTRB(anc_id_54,'(]',1,6) -
8912         INSTRB(anc_id_54,'(]',1,5) - 2)
8913 ,SUBSTRB(anc_id_54
8914        ,INSTRB(anc_id_54,'(]',1,6) + 2
8915        ,INSTRB(anc_id_54,'(]',1,7) -
8916         INSTRB(anc_id_54,'(]',1,6) - 2)
8917 ,SUBSTRB(anc_id_54
8918        ,INSTRB(anc_id_54,'(]',1,7) + 2
8919        ,LENGTHB(anc_id_54))
8920 )
8921 
8922 WHEN anc_id_55 IS NOT NULL THEN
8923   INTO xla_ae_line_acs (
8924         ae_header_id , ae_line_num , object_version_number
8925       , analytical_criterion_code
8926       , analytical_criterion_type_code
8927       , amb_context_code
8928       , ac1,ac2,ac3,ac4,ac5)
8929 VALUES (ae_header_id, ae_line_num, C_OVN
8930 ,SUBSTRB(anc_id_55
8931        ,1
8932        ,INSTRB(anc_id_55,'(]',1,1) -1)
8933 ,SUBSTRB(anc_id_55
8934        ,INSTRB(anc_id_55,'(]',1,1) + 2
8935        ,INSTRB(anc_id_55,'(]',1,2) -
8936         INSTRB(anc_id_55,'(]',1,1) - 2)
8937 ,SUBSTRB(anc_id_55
8938        ,INSTRB(anc_id_55,'(]',1,2) + 2
8939        ,INSTRB(anc_id_55,'(]',1,3) -
8940         INSTRB(anc_id_55,'(]',1,2) - 2)
8941 ,SUBSTRB(anc_id_55
8942        ,INSTRB(anc_id_55,'(]',1,3) + 2
8943        ,INSTRB(anc_id_55,'(]',1,4) -
8944         INSTRB(anc_id_55,'(]',1,3) - 2)
8945 ,SUBSTRB(anc_id_55
8946        ,INSTRB(anc_id_55,'(]',1,4) + 2
8947        ,INSTRB(anc_id_55,'(]',1,5) -
8948         INSTRB(anc_id_55,'(]',1,4) - 2)
8949 ,SUBSTRB(anc_id_55
8950        ,INSTRB(anc_id_55,'(]',1,5) + 2
8951        ,INSTRB(anc_id_55,'(]',1,6) -
8952         INSTRB(anc_id_55,'(]',1,5) - 2)
8953 ,SUBSTRB(anc_id_55
8954        ,INSTRB(anc_id_55,'(]',1,6) + 2
8955        ,INSTRB(anc_id_55,'(]',1,7) -
8956         INSTRB(anc_id_55,'(]',1,6) - 2)
8957 ,SUBSTRB(anc_id_55
8958        ,INSTRB(anc_id_55,'(]',1,7) + 2
8959        ,LENGTHB(anc_id_55))
8960 )
8961 
8962 WHEN anc_id_56 IS NOT NULL THEN
8963   INTO xla_ae_line_acs (
8964         ae_header_id , ae_line_num , object_version_number
8965       , analytical_criterion_code
8966       , analytical_criterion_type_code
8967       , amb_context_code
8968       , ac1,ac2,ac3,ac4,ac5)
8969 VALUES (ae_header_id, ae_line_num, C_OVN
8970 ,SUBSTRB(anc_id_56
8971        ,1
8972        ,INSTRB(anc_id_56,'(]',1,1) -1)
8973 ,SUBSTRB(anc_id_56
8974        ,INSTRB(anc_id_56,'(]',1,1) + 2
8975        ,INSTRB(anc_id_56,'(]',1,2) -
8976         INSTRB(anc_id_56,'(]',1,1) - 2)
8977 ,SUBSTRB(anc_id_56
8978        ,INSTRB(anc_id_56,'(]',1,2) + 2
8979        ,INSTRB(anc_id_56,'(]',1,3) -
8980         INSTRB(anc_id_56,'(]',1,2) - 2)
8981 ,SUBSTRB(anc_id_56
8982        ,INSTRB(anc_id_56,'(]',1,3) + 2
8983        ,INSTRB(anc_id_56,'(]',1,4) -
8984         INSTRB(anc_id_56,'(]',1,3) - 2)
8985 ,SUBSTRB(anc_id_56
8986        ,INSTRB(anc_id_56,'(]',1,4) + 2
8987        ,INSTRB(anc_id_56,'(]',1,5) -
8988         INSTRB(anc_id_56,'(]',1,4) - 2)
8989 ,SUBSTRB(anc_id_56
8990        ,INSTRB(anc_id_56,'(]',1,5) + 2
8991        ,INSTRB(anc_id_56,'(]',1,6) -
8992         INSTRB(anc_id_56,'(]',1,5) - 2)
8993 ,SUBSTRB(anc_id_56
8994        ,INSTRB(anc_id_56,'(]',1,6) + 2
8995        ,INSTRB(anc_id_56,'(]',1,7) -
8996         INSTRB(anc_id_56,'(]',1,6) - 2)
8997 ,SUBSTRB(anc_id_56
8998        ,INSTRB(anc_id_56,'(]',1,7) + 2
8999        ,LENGTHB(anc_id_56))
9000 )
9001 
9002 WHEN anc_id_57 IS NOT NULL THEN
9003   INTO xla_ae_line_acs (
9004         ae_header_id , ae_line_num , object_version_number
9005       , analytical_criterion_code
9006       , analytical_criterion_type_code
9007       , amb_context_code
9008       , ac1,ac2,ac3,ac4,ac5)
9009 VALUES (ae_header_id, ae_line_num, C_OVN
9010 ,SUBSTRB(anc_id_57
9011        ,1
9012        ,INSTRB(anc_id_57,'(]',1,1) -1)
9013 ,SUBSTRB(anc_id_57
9014        ,INSTRB(anc_id_57,'(]',1,1) + 2
9015        ,INSTRB(anc_id_57,'(]',1,2) -
9016         INSTRB(anc_id_57,'(]',1,1) - 2)
9017 ,SUBSTRB(anc_id_57
9018        ,INSTRB(anc_id_57,'(]',1,2) + 2
9019        ,INSTRB(anc_id_57,'(]',1,3) -
9020         INSTRB(anc_id_57,'(]',1,2) - 2)
9021 ,SUBSTRB(anc_id_57
9022        ,INSTRB(anc_id_57,'(]',1,3) + 2
9023        ,INSTRB(anc_id_57,'(]',1,4) -
9024         INSTRB(anc_id_57,'(]',1,3) - 2)
9025 ,SUBSTRB(anc_id_57
9026        ,INSTRB(anc_id_57,'(]',1,4) + 2
9027        ,INSTRB(anc_id_57,'(]',1,5) -
9028         INSTRB(anc_id_57,'(]',1,4) - 2)
9029 ,SUBSTRB(anc_id_57
9030        ,INSTRB(anc_id_57,'(]',1,5) + 2
9031        ,INSTRB(anc_id_57,'(]',1,6) -
9032         INSTRB(anc_id_57,'(]',1,5) - 2)
9033 ,SUBSTRB(anc_id_57
9034        ,INSTRB(anc_id_57,'(]',1,6) + 2
9035        ,INSTRB(anc_id_57,'(]',1,7) -
9036         INSTRB(anc_id_57,'(]',1,6) - 2)
9037 ,SUBSTRB(anc_id_57
9038        ,INSTRB(anc_id_57,'(]',1,7) + 2
9039        ,LENGTHB(anc_id_57))
9040 )
9041 
9042 WHEN anc_id_58 IS NOT NULL THEN
9043   INTO xla_ae_line_acs (
9044         ae_header_id , ae_line_num , object_version_number
9045       , analytical_criterion_code
9046       , analytical_criterion_type_code
9047       , amb_context_code
9048       , ac1,ac2,ac3,ac4,ac5)
9049 VALUES (ae_header_id, ae_line_num, C_OVN
9050 ,SUBSTRB(anc_id_58
9051        ,1
9052        ,INSTRB(anc_id_58,'(]',1,1) -1)
9053 ,SUBSTRB(anc_id_58
9054        ,INSTRB(anc_id_58,'(]',1,1) + 2
9055        ,INSTRB(anc_id_58,'(]',1,2) -
9056         INSTRB(anc_id_58,'(]',1,1) - 2)
9057 ,SUBSTRB(anc_id_58
9058        ,INSTRB(anc_id_58,'(]',1,2) + 2
9059        ,INSTRB(anc_id_58,'(]',1,3) -
9060         INSTRB(anc_id_58,'(]',1,2) - 2)
9061 ,SUBSTRB(anc_id_58
9062        ,INSTRB(anc_id_58,'(]',1,3) + 2
9063        ,INSTRB(anc_id_58,'(]',1,4) -
9064         INSTRB(anc_id_58,'(]',1,3) - 2)
9065 ,SUBSTRB(anc_id_58
9066        ,INSTRB(anc_id_58,'(]',1,4) + 2
9067        ,INSTRB(anc_id_58,'(]',1,5) -
9068         INSTRB(anc_id_58,'(]',1,4) - 2)
9069 ,SUBSTRB(anc_id_58
9070        ,INSTRB(anc_id_58,'(]',1,5) + 2
9071        ,INSTRB(anc_id_58,'(]',1,6) -
9072         INSTRB(anc_id_58,'(]',1,5) - 2)
9073 ,SUBSTRB(anc_id_58
9074        ,INSTRB(anc_id_58,'(]',1,6) + 2
9075        ,INSTRB(anc_id_58,'(]',1,7) -
9076         INSTRB(anc_id_58,'(]',1,6) - 2)
9077 ,SUBSTRB(anc_id_58
9078        ,INSTRB(anc_id_58,'(]',1,7) + 2
9079        ,LENGTHB(anc_id_58))
9080 )
9081 
9082 WHEN anc_id_59 IS NOT NULL THEN
9083   INTO xla_ae_line_acs (
9084         ae_header_id , ae_line_num , object_version_number
9085       , analytical_criterion_code
9086       , analytical_criterion_type_code
9087       , amb_context_code
9088       , ac1,ac2,ac3,ac4,ac5)
9089 VALUES (ae_header_id, ae_line_num, C_OVN
9090 ,SUBSTRB(anc_id_59
9091        ,1
9092        ,INSTRB(anc_id_59,'(]',1,1) -1)
9093 ,SUBSTRB(anc_id_59
9094        ,INSTRB(anc_id_59,'(]',1,1) + 2
9095        ,INSTRB(anc_id_59,'(]',1,2) -
9096         INSTRB(anc_id_59,'(]',1,1) - 2)
9097 ,SUBSTRB(anc_id_59
9098        ,INSTRB(anc_id_59,'(]',1,2) + 2
9099        ,INSTRB(anc_id_59,'(]',1,3) -
9100         INSTRB(anc_id_59,'(]',1,2) - 2)
9101 ,SUBSTRB(anc_id_59
9102        ,INSTRB(anc_id_59,'(]',1,3) + 2
9103        ,INSTRB(anc_id_59,'(]',1,4) -
9104         INSTRB(anc_id_59,'(]',1,3) - 2)
9105 ,SUBSTRB(anc_id_59
9106        ,INSTRB(anc_id_59,'(]',1,4) + 2
9107        ,INSTRB(anc_id_59,'(]',1,5) -
9108         INSTRB(anc_id_59,'(]',1,4) - 2)
9109 ,SUBSTRB(anc_id_59
9110        ,INSTRB(anc_id_59,'(]',1,5) + 2
9111        ,INSTRB(anc_id_59,'(]',1,6) -
9112         INSTRB(anc_id_59,'(]',1,5) - 2)
9113 ,SUBSTRB(anc_id_59
9114        ,INSTRB(anc_id_59,'(]',1,6) + 2
9115        ,INSTRB(anc_id_59,'(]',1,7) -
9116         INSTRB(anc_id_59,'(]',1,6) - 2)
9117 ,SUBSTRB(anc_id_59
9118        ,INSTRB(anc_id_59,'(]',1,7) + 2
9119        ,LENGTHB(anc_id_59))
9120 )
9121 
9122 WHEN anc_id_60 IS NOT NULL THEN
9123   INTO xla_ae_line_acs (
9124         ae_header_id , ae_line_num , object_version_number
9125       , analytical_criterion_code
9126       , analytical_criterion_type_code
9127       , amb_context_code
9128       , ac1,ac2,ac3,ac4,ac5)
9129 VALUES (ae_header_id, ae_line_num, C_OVN
9130 ,SUBSTRB(anc_id_60
9131        ,1
9132        ,INSTRB(anc_id_60,'(]',1,1) -1)
9133 ,SUBSTRB(anc_id_60
9134        ,INSTRB(anc_id_60,'(]',1,1) + 2
9135        ,INSTRB(anc_id_60,'(]',1,2) -
9136         INSTRB(anc_id_60,'(]',1,1) - 2)
9137 ,SUBSTRB(anc_id_60
9138        ,INSTRB(anc_id_60,'(]',1,2) + 2
9139        ,INSTRB(anc_id_60,'(]',1,3) -
9140         INSTRB(anc_id_60,'(]',1,2) - 2)
9141 ,SUBSTRB(anc_id_60
9142        ,INSTRB(anc_id_60,'(]',1,3) + 2
9143        ,INSTRB(anc_id_60,'(]',1,4) -
9144         INSTRB(anc_id_60,'(]',1,3) - 2)
9145 ,SUBSTRB(anc_id_60
9146        ,INSTRB(anc_id_60,'(]',1,4) + 2
9147        ,INSTRB(anc_id_60,'(]',1,5) -
9148         INSTRB(anc_id_60,'(]',1,4) - 2)
9149 ,SUBSTRB(anc_id_60
9150        ,INSTRB(anc_id_60,'(]',1,5) + 2
9151        ,INSTRB(anc_id_60,'(]',1,6) -
9152         INSTRB(anc_id_60,'(]',1,5) - 2)
9153 ,SUBSTRB(anc_id_60
9154        ,INSTRB(anc_id_60,'(]',1,6) + 2
9155        ,INSTRB(anc_id_60,'(]',1,7) -
9156         INSTRB(anc_id_60,'(]',1,6) - 2)
9157 ,SUBSTRB(anc_id_60
9158        ,INSTRB(anc_id_60,'(]',1,7) + 2
9159        ,LENGTHB(anc_id_60))
9160 )
9161 
9162 WHEN anc_id_61 IS NOT NULL THEN
9163   INTO xla_ae_line_acs (
9164         ae_header_id , ae_line_num , object_version_number
9165       , analytical_criterion_code
9166       , analytical_criterion_type_code
9167       , amb_context_code
9168       , ac1,ac2,ac3,ac4,ac5)
9169 VALUES (ae_header_id, ae_line_num, C_OVN
9170 ,SUBSTRB(anc_id_61
9171        ,1
9172        ,INSTRB(anc_id_61,'(]',1,1) -1)
9173 ,SUBSTRB(anc_id_61
9174        ,INSTRB(anc_id_61,'(]',1,1) + 2
9175        ,INSTRB(anc_id_61,'(]',1,2) -
9176         INSTRB(anc_id_61,'(]',1,1) - 2)
9177 ,SUBSTRB(anc_id_61
9178        ,INSTRB(anc_id_61,'(]',1,2) + 2
9179        ,INSTRB(anc_id_61,'(]',1,3) -
9180         INSTRB(anc_id_61,'(]',1,2) - 2)
9181 ,SUBSTRB(anc_id_61
9182        ,INSTRB(anc_id_61,'(]',1,3) + 2
9183        ,INSTRB(anc_id_61,'(]',1,4) -
9184         INSTRB(anc_id_61,'(]',1,3) - 2)
9185 ,SUBSTRB(anc_id_61
9186        ,INSTRB(anc_id_61,'(]',1,4) + 2
9187        ,INSTRB(anc_id_61,'(]',1,5) -
9188         INSTRB(anc_id_61,'(]',1,4) - 2)
9189 ,SUBSTRB(anc_id_61
9190        ,INSTRB(anc_id_61,'(]',1,5) + 2
9191        ,INSTRB(anc_id_61,'(]',1,6) -
9192         INSTRB(anc_id_61,'(]',1,5) - 2)
9193 ,SUBSTRB(anc_id_61
9194        ,INSTRB(anc_id_61,'(]',1,6) + 2
9195        ,INSTRB(anc_id_61,'(]',1,7) -
9196         INSTRB(anc_id_61,'(]',1,6) - 2)
9197 ,SUBSTRB(anc_id_61
9198        ,INSTRB(anc_id_61,'(]',1,7) + 2
9199        ,LENGTHB(anc_id_61))
9200 )
9201 
9202 WHEN anc_id_62 IS NOT NULL THEN
9203   INTO xla_ae_line_acs (
9204         ae_header_id , ae_line_num , object_version_number
9205       , analytical_criterion_code
9206       , analytical_criterion_type_code
9207       , amb_context_code
9208       , ac1,ac2,ac3,ac4,ac5)
9209 VALUES (ae_header_id, ae_line_num, C_OVN
9210 ,SUBSTRB(anc_id_62
9211        ,1
9212        ,INSTRB(anc_id_62,'(]',1,1) -1)
9213 ,SUBSTRB(anc_id_62
9214        ,INSTRB(anc_id_62,'(]',1,1) + 2
9215        ,INSTRB(anc_id_62,'(]',1,2) -
9216         INSTRB(anc_id_62,'(]',1,1) - 2)
9217 ,SUBSTRB(anc_id_62
9218        ,INSTRB(anc_id_62,'(]',1,2) + 2
9219        ,INSTRB(anc_id_62,'(]',1,3) -
9220         INSTRB(anc_id_62,'(]',1,2) - 2)
9221 ,SUBSTRB(anc_id_62
9222        ,INSTRB(anc_id_62,'(]',1,3) + 2
9223        ,INSTRB(anc_id_62,'(]',1,4) -
9224         INSTRB(anc_id_62,'(]',1,3) - 2)
9225 ,SUBSTRB(anc_id_62
9226        ,INSTRB(anc_id_62,'(]',1,4) + 2
9227        ,INSTRB(anc_id_62,'(]',1,5) -
9228         INSTRB(anc_id_62,'(]',1,4) - 2)
9229 ,SUBSTRB(anc_id_62
9230        ,INSTRB(anc_id_62,'(]',1,5) + 2
9231        ,INSTRB(anc_id_62,'(]',1,6) -
9232         INSTRB(anc_id_62,'(]',1,5) - 2)
9233 ,SUBSTRB(anc_id_62
9234        ,INSTRB(anc_id_62,'(]',1,6) + 2
9235        ,INSTRB(anc_id_62,'(]',1,7) -
9236         INSTRB(anc_id_62,'(]',1,6) - 2)
9237 ,SUBSTRB(anc_id_62
9238        ,INSTRB(anc_id_62,'(]',1,7) + 2
9239        ,LENGTHB(anc_id_62))
9240 )
9241 
9242 WHEN anc_id_63 IS NOT NULL THEN
9243   INTO xla_ae_line_acs (
9244         ae_header_id , ae_line_num , object_version_number
9245       , analytical_criterion_code
9246       , analytical_criterion_type_code
9247       , amb_context_code
9248       , ac1,ac2,ac3,ac4,ac5)
9249 VALUES (ae_header_id, ae_line_num, C_OVN
9250 ,SUBSTRB(anc_id_63
9251        ,1
9252        ,INSTRB(anc_id_63,'(]',1,1) -1)
9253 ,SUBSTRB(anc_id_63
9254        ,INSTRB(anc_id_63,'(]',1,1) + 2
9255        ,INSTRB(anc_id_63,'(]',1,2) -
9256         INSTRB(anc_id_63,'(]',1,1) - 2)
9257 ,SUBSTRB(anc_id_63
9258        ,INSTRB(anc_id_63,'(]',1,2) + 2
9259        ,INSTRB(anc_id_63,'(]',1,3) -
9260         INSTRB(anc_id_63,'(]',1,2) - 2)
9261 ,SUBSTRB(anc_id_63
9262        ,INSTRB(anc_id_63,'(]',1,3) + 2
9263        ,INSTRB(anc_id_63,'(]',1,4) -
9264         INSTRB(anc_id_63,'(]',1,3) - 2)
9265 ,SUBSTRB(anc_id_63
9266        ,INSTRB(anc_id_63,'(]',1,4) + 2
9267        ,INSTRB(anc_id_63,'(]',1,5) -
9268         INSTRB(anc_id_63,'(]',1,4) - 2)
9269 ,SUBSTRB(anc_id_63
9270        ,INSTRB(anc_id_63,'(]',1,5) + 2
9271        ,INSTRB(anc_id_63,'(]',1,6) -
9272         INSTRB(anc_id_63,'(]',1,5) - 2)
9273 ,SUBSTRB(anc_id_63
9274        ,INSTRB(anc_id_63,'(]',1,6) + 2
9275        ,INSTRB(anc_id_63,'(]',1,7) -
9276         INSTRB(anc_id_63,'(]',1,6) - 2)
9277 ,SUBSTRB(anc_id_63
9278        ,INSTRB(anc_id_63,'(]',1,7) + 2
9279        ,LENGTHB(anc_id_63))
9280 )
9281 
9282 WHEN anc_id_64 IS NOT NULL THEN
9283   INTO xla_ae_line_acs (
9284         ae_header_id , ae_line_num , object_version_number
9285       , analytical_criterion_code
9286       , analytical_criterion_type_code
9287       , amb_context_code
9288       , ac1,ac2,ac3,ac4,ac5)
9289 VALUES (ae_header_id, ae_line_num, C_OVN
9290 ,SUBSTRB(anc_id_64
9291        ,1
9292        ,INSTRB(anc_id_64,'(]',1,1) -1)
9293 ,SUBSTRB(anc_id_64
9294        ,INSTRB(anc_id_64,'(]',1,1) + 2
9295        ,INSTRB(anc_id_64,'(]',1,2) -
9296         INSTRB(anc_id_64,'(]',1,1) - 2)
9297 ,SUBSTRB(anc_id_64
9298        ,INSTRB(anc_id_64,'(]',1,2) + 2
9299        ,INSTRB(anc_id_64,'(]',1,3) -
9300         INSTRB(anc_id_64,'(]',1,2) - 2)
9301 ,SUBSTRB(anc_id_64
9302        ,INSTRB(anc_id_64,'(]',1,3) + 2
9303        ,INSTRB(anc_id_64,'(]',1,4) -
9304         INSTRB(anc_id_64,'(]',1,3) - 2)
9305 ,SUBSTRB(anc_id_64
9306        ,INSTRB(anc_id_64,'(]',1,4) + 2
9307        ,INSTRB(anc_id_64,'(]',1,5) -
9308         INSTRB(anc_id_64,'(]',1,4) - 2)
9309 ,SUBSTRB(anc_id_64
9310        ,INSTRB(anc_id_64,'(]',1,5) + 2
9311        ,INSTRB(anc_id_64,'(]',1,6) -
9312         INSTRB(anc_id_64,'(]',1,5) - 2)
9313 ,SUBSTRB(anc_id_64
9314        ,INSTRB(anc_id_64,'(]',1,6) + 2
9315        ,INSTRB(anc_id_64,'(]',1,7) -
9316         INSTRB(anc_id_64,'(]',1,6) - 2)
9317 ,SUBSTRB(anc_id_64
9318        ,INSTRB(anc_id_64,'(]',1,7) + 2
9319        ,LENGTHB(anc_id_64))
9320 )
9321 
9322 WHEN anc_id_65 IS NOT NULL THEN
9323   INTO xla_ae_line_acs (
9324         ae_header_id , ae_line_num , object_version_number
9325       , analytical_criterion_code
9326       , analytical_criterion_type_code
9327       , amb_context_code
9328       , ac1,ac2,ac3,ac4,ac5)
9329 VALUES (ae_header_id, ae_line_num, C_OVN
9330 ,SUBSTRB(anc_id_65
9331        ,1
9332        ,INSTRB(anc_id_65,'(]',1,1) -1)
9333 ,SUBSTRB(anc_id_65
9334        ,INSTRB(anc_id_65,'(]',1,1) + 2
9335        ,INSTRB(anc_id_65,'(]',1,2) -
9336         INSTRB(anc_id_65,'(]',1,1) - 2)
9337 ,SUBSTRB(anc_id_65
9338        ,INSTRB(anc_id_65,'(]',1,2) + 2
9339        ,INSTRB(anc_id_65,'(]',1,3) -
9340         INSTRB(anc_id_65,'(]',1,2) - 2)
9341 ,SUBSTRB(anc_id_65
9342        ,INSTRB(anc_id_65,'(]',1,3) + 2
9343        ,INSTRB(anc_id_65,'(]',1,4) -
9344         INSTRB(anc_id_65,'(]',1,3) - 2)
9345 ,SUBSTRB(anc_id_65
9346        ,INSTRB(anc_id_65,'(]',1,4) + 2
9347        ,INSTRB(anc_id_65,'(]',1,5) -
9348         INSTRB(anc_id_65,'(]',1,4) - 2)
9349 ,SUBSTRB(anc_id_65
9350        ,INSTRB(anc_id_65,'(]',1,5) + 2
9351        ,INSTRB(anc_id_65,'(]',1,6) -
9352         INSTRB(anc_id_65,'(]',1,5) - 2)
9353 ,SUBSTRB(anc_id_65
9354        ,INSTRB(anc_id_65,'(]',1,6) + 2
9355        ,INSTRB(anc_id_65,'(]',1,7) -
9356         INSTRB(anc_id_65,'(]',1,6) - 2)
9357 ,SUBSTRB(anc_id_65
9358        ,INSTRB(anc_id_65,'(]',1,7) + 2
9359        ,LENGTHB(anc_id_65))
9360 )
9361 
9362 WHEN anc_id_66 IS NOT NULL THEN
9363   INTO xla_ae_line_acs (
9364         ae_header_id , ae_line_num , object_version_number
9365       , analytical_criterion_code
9366       , analytical_criterion_type_code
9367       , amb_context_code
9368       , ac1,ac2,ac3,ac4,ac5)
9369 VALUES (ae_header_id, ae_line_num, C_OVN
9370 ,SUBSTRB(anc_id_66
9371        ,1
9372        ,INSTRB(anc_id_66,'(]',1,1) -1)
9373 ,SUBSTRB(anc_id_66
9374        ,INSTRB(anc_id_66,'(]',1,1) + 2
9375        ,INSTRB(anc_id_66,'(]',1,2) -
9376         INSTRB(anc_id_66,'(]',1,1) - 2)
9377 ,SUBSTRB(anc_id_66
9378        ,INSTRB(anc_id_66,'(]',1,2) + 2
9379        ,INSTRB(anc_id_66,'(]',1,3) -
9380         INSTRB(anc_id_66,'(]',1,2) - 2)
9381 ,SUBSTRB(anc_id_66
9382        ,INSTRB(anc_id_66,'(]',1,3) + 2
9383        ,INSTRB(anc_id_66,'(]',1,4) -
9384         INSTRB(anc_id_66,'(]',1,3) - 2)
9385 ,SUBSTRB(anc_id_66
9386        ,INSTRB(anc_id_66,'(]',1,4) + 2
9387        ,INSTRB(anc_id_66,'(]',1,5) -
9388         INSTRB(anc_id_66,'(]',1,4) - 2)
9389 ,SUBSTRB(anc_id_66
9390        ,INSTRB(anc_id_66,'(]',1,5) + 2
9391        ,INSTRB(anc_id_66,'(]',1,6) -
9392         INSTRB(anc_id_66,'(]',1,5) - 2)
9393 ,SUBSTRB(anc_id_66
9394        ,INSTRB(anc_id_66,'(]',1,6) + 2
9395        ,INSTRB(anc_id_66,'(]',1,7) -
9396         INSTRB(anc_id_66,'(]',1,6) - 2)
9397 ,SUBSTRB(anc_id_66
9398        ,INSTRB(anc_id_66,'(]',1,7) + 2
9399        ,LENGTHB(anc_id_66))
9400 )
9401 
9402 WHEN anc_id_67 IS NOT NULL THEN
9403   INTO xla_ae_line_acs (
9404         ae_header_id , ae_line_num , object_version_number
9405       , analytical_criterion_code
9406       , analytical_criterion_type_code
9407       , amb_context_code
9408       , ac1,ac2,ac3,ac4,ac5)
9409 VALUES (ae_header_id, ae_line_num, C_OVN
9410 ,SUBSTRB(anc_id_67
9411        ,1
9412        ,INSTRB(anc_id_67,'(]',1,1) -1)
9413 ,SUBSTRB(anc_id_67
9414        ,INSTRB(anc_id_67,'(]',1,1) + 2
9415        ,INSTRB(anc_id_67,'(]',1,2) -
9416         INSTRB(anc_id_67,'(]',1,1) - 2)
9417 ,SUBSTRB(anc_id_67
9418        ,INSTRB(anc_id_67,'(]',1,2) + 2
9419        ,INSTRB(anc_id_67,'(]',1,3) -
9420         INSTRB(anc_id_67,'(]',1,2) - 2)
9421 ,SUBSTRB(anc_id_67
9422        ,INSTRB(anc_id_67,'(]',1,3) + 2
9423        ,INSTRB(anc_id_67,'(]',1,4) -
9424         INSTRB(anc_id_67,'(]',1,3) - 2)
9425 ,SUBSTRB(anc_id_67
9426        ,INSTRB(anc_id_67,'(]',1,4) + 2
9427        ,INSTRB(anc_id_67,'(]',1,5) -
9428         INSTRB(anc_id_67,'(]',1,4) - 2)
9429 ,SUBSTRB(anc_id_67
9430        ,INSTRB(anc_id_67,'(]',1,5) + 2
9431        ,INSTRB(anc_id_67,'(]',1,6) -
9432         INSTRB(anc_id_67,'(]',1,5) - 2)
9433 ,SUBSTRB(anc_id_67
9434        ,INSTRB(anc_id_67,'(]',1,6) + 2
9435        ,INSTRB(anc_id_67,'(]',1,7) -
9436         INSTRB(anc_id_67,'(]',1,6) - 2)
9437 ,SUBSTRB(anc_id_67
9438        ,INSTRB(anc_id_67,'(]',1,7) + 2
9439        ,LENGTHB(anc_id_67))
9440 )
9441 
9442 WHEN anc_id_68 IS NOT NULL THEN
9443   INTO xla_ae_line_acs (
9444         ae_header_id , ae_line_num , object_version_number
9445       , analytical_criterion_code
9446       , analytical_criterion_type_code
9447       , amb_context_code
9448       , ac1,ac2,ac3,ac4,ac5)
9449 VALUES (ae_header_id, ae_line_num, C_OVN
9450 ,SUBSTRB(anc_id_68
9451        ,1
9452        ,INSTRB(anc_id_68,'(]',1,1) -1)
9453 ,SUBSTRB(anc_id_68
9454        ,INSTRB(anc_id_68,'(]',1,1) + 2
9455        ,INSTRB(anc_id_68,'(]',1,2) -
9456         INSTRB(anc_id_68,'(]',1,1) - 2)
9457 ,SUBSTRB(anc_id_68
9458        ,INSTRB(anc_id_68,'(]',1,2) + 2
9459        ,INSTRB(anc_id_68,'(]',1,3) -
9460         INSTRB(anc_id_68,'(]',1,2) - 2)
9461 ,SUBSTRB(anc_id_68
9462        ,INSTRB(anc_id_68,'(]',1,3) + 2
9463        ,INSTRB(anc_id_68,'(]',1,4) -
9464         INSTRB(anc_id_68,'(]',1,3) - 2)
9465 ,SUBSTRB(anc_id_68
9466        ,INSTRB(anc_id_68,'(]',1,4) + 2
9467        ,INSTRB(anc_id_68,'(]',1,5) -
9468         INSTRB(anc_id_68,'(]',1,4) - 2)
9469 ,SUBSTRB(anc_id_68
9470        ,INSTRB(anc_id_68,'(]',1,5) + 2
9471        ,INSTRB(anc_id_68,'(]',1,6) -
9472         INSTRB(anc_id_68,'(]',1,5) - 2)
9473 ,SUBSTRB(anc_id_68
9474        ,INSTRB(anc_id_68,'(]',1,6) + 2
9475        ,INSTRB(anc_id_68,'(]',1,7) -
9476         INSTRB(anc_id_68,'(]',1,6) - 2)
9477 ,SUBSTRB(anc_id_68
9478        ,INSTRB(anc_id_68,'(]',1,7) + 2
9479        ,LENGTHB(anc_id_68))
9480 )
9481 
9482 WHEN anc_id_69 IS NOT NULL THEN
9483   INTO xla_ae_line_acs (
9484         ae_header_id , ae_line_num , object_version_number
9485       , analytical_criterion_code
9486       , analytical_criterion_type_code
9487       , amb_context_code
9488       , ac1,ac2,ac3,ac4,ac5)
9489 VALUES (ae_header_id, ae_line_num, C_OVN
9490 ,SUBSTRB(anc_id_69
9491        ,1
9492        ,INSTRB(anc_id_69,'(]',1,1) -1)
9493 ,SUBSTRB(anc_id_69
9494        ,INSTRB(anc_id_69,'(]',1,1) + 2
9495        ,INSTRB(anc_id_69,'(]',1,2) -
9496         INSTRB(anc_id_69,'(]',1,1) - 2)
9497 ,SUBSTRB(anc_id_69
9498        ,INSTRB(anc_id_69,'(]',1,2) + 2
9499        ,INSTRB(anc_id_69,'(]',1,3) -
9500         INSTRB(anc_id_69,'(]',1,2) - 2)
9501 ,SUBSTRB(anc_id_69
9502        ,INSTRB(anc_id_69,'(]',1,3) + 2
9503        ,INSTRB(anc_id_69,'(]',1,4) -
9504         INSTRB(anc_id_69,'(]',1,3) - 2)
9505 ,SUBSTRB(anc_id_69
9506        ,INSTRB(anc_id_69,'(]',1,4) + 2
9507        ,INSTRB(anc_id_69,'(]',1,5) -
9508         INSTRB(anc_id_69,'(]',1,4) - 2)
9509 ,SUBSTRB(anc_id_69
9510        ,INSTRB(anc_id_69,'(]',1,5) + 2
9511        ,INSTRB(anc_id_69,'(]',1,6) -
9512         INSTRB(anc_id_69,'(]',1,5) - 2)
9513 ,SUBSTRB(anc_id_69
9514        ,INSTRB(anc_id_69,'(]',1,6) + 2
9515        ,INSTRB(anc_id_69,'(]',1,7) -
9516         INSTRB(anc_id_69,'(]',1,6) - 2)
9517 ,SUBSTRB(anc_id_69
9518        ,INSTRB(anc_id_69,'(]',1,7) + 2
9519        ,LENGTHB(anc_id_69))
9520 )
9521 
9522 WHEN anc_id_70 IS NOT NULL THEN
9523   INTO xla_ae_line_acs (
9524         ae_header_id , ae_line_num , object_version_number
9525       , analytical_criterion_code
9526       , analytical_criterion_type_code
9527       , amb_context_code
9528       , ac1,ac2,ac3,ac4,ac5)
9529 VALUES (ae_header_id, ae_line_num, C_OVN
9530 ,SUBSTRB(anc_id_70
9531        ,1
9532        ,INSTRB(anc_id_70,'(]',1,1) -1)
9533 ,SUBSTRB(anc_id_70
9534        ,INSTRB(anc_id_70,'(]',1,1) + 2
9535        ,INSTRB(anc_id_70,'(]',1,2) -
9536         INSTRB(anc_id_70,'(]',1,1) - 2)
9537 ,SUBSTRB(anc_id_70
9538        ,INSTRB(anc_id_70,'(]',1,2) + 2
9539        ,INSTRB(anc_id_70,'(]',1,3) -
9540         INSTRB(anc_id_70,'(]',1,2) - 2)
9541 ,SUBSTRB(anc_id_70
9542        ,INSTRB(anc_id_70,'(]',1,3) + 2
9543        ,INSTRB(anc_id_70,'(]',1,4) -
9544         INSTRB(anc_id_70,'(]',1,3) - 2)
9545 ,SUBSTRB(anc_id_70
9546        ,INSTRB(anc_id_70,'(]',1,4) + 2
9547        ,INSTRB(anc_id_70,'(]',1,5) -
9548         INSTRB(anc_id_70,'(]',1,4) - 2)
9549 ,SUBSTRB(anc_id_70
9550        ,INSTRB(anc_id_70,'(]',1,5) + 2
9551        ,INSTRB(anc_id_70,'(]',1,6) -
9552         INSTRB(anc_id_70,'(]',1,5) - 2)
9553 ,SUBSTRB(anc_id_70
9554        ,INSTRB(anc_id_70,'(]',1,6) + 2
9555        ,INSTRB(anc_id_70,'(]',1,7) -
9556         INSTRB(anc_id_70,'(]',1,6) - 2)
9557 ,SUBSTRB(anc_id_70
9558        ,INSTRB(anc_id_70,'(]',1,7) + 2
9559        ,LENGTHB(anc_id_70))
9560 )
9561 
9562 WHEN anc_id_71 IS NOT NULL THEN
9563   INTO xla_ae_line_acs (
9564         ae_header_id , ae_line_num , object_version_number
9565       , analytical_criterion_code
9566       , analytical_criterion_type_code
9567       , amb_context_code
9568       , ac1,ac2,ac3,ac4,ac5)
9569 VALUES (ae_header_id, ae_line_num, C_OVN
9570 ,SUBSTRB(anc_id_71
9571        ,1
9572        ,INSTRB(anc_id_71,'(]',1,1) -1)
9573 ,SUBSTRB(anc_id_71
9574        ,INSTRB(anc_id_71,'(]',1,1) + 2
9575        ,INSTRB(anc_id_71,'(]',1,2) -
9576         INSTRB(anc_id_71,'(]',1,1) - 2)
9577 ,SUBSTRB(anc_id_71
9578        ,INSTRB(anc_id_71,'(]',1,2) + 2
9579        ,INSTRB(anc_id_71,'(]',1,3) -
9580         INSTRB(anc_id_71,'(]',1,2) - 2)
9581 ,SUBSTRB(anc_id_71
9582        ,INSTRB(anc_id_71,'(]',1,3) + 2
9583        ,INSTRB(anc_id_71,'(]',1,4) -
9584         INSTRB(anc_id_71,'(]',1,3) - 2)
9585 ,SUBSTRB(anc_id_71
9586        ,INSTRB(anc_id_71,'(]',1,4) + 2
9587        ,INSTRB(anc_id_71,'(]',1,5) -
9588         INSTRB(anc_id_71,'(]',1,4) - 2)
9589 ,SUBSTRB(anc_id_71
9590        ,INSTRB(anc_id_71,'(]',1,5) + 2
9591        ,INSTRB(anc_id_71,'(]',1,6) -
9592         INSTRB(anc_id_71,'(]',1,5) - 2)
9593 ,SUBSTRB(anc_id_71
9594        ,INSTRB(anc_id_71,'(]',1,6) + 2
9595        ,INSTRB(anc_id_71,'(]',1,7) -
9596         INSTRB(anc_id_71,'(]',1,6) - 2)
9597 ,SUBSTRB(anc_id_71
9598        ,INSTRB(anc_id_71,'(]',1,7) + 2
9599        ,LENGTHB(anc_id_71))
9600 )
9601 
9602 WHEN anc_id_72 IS NOT NULL THEN
9603   INTO xla_ae_line_acs (
9604         ae_header_id , ae_line_num , object_version_number
9605       , analytical_criterion_code
9606       , analytical_criterion_type_code
9607       , amb_context_code
9608       , ac1,ac2,ac3,ac4,ac5)
9609 VALUES (ae_header_id, ae_line_num, C_OVN
9610 ,SUBSTRB(anc_id_72
9611        ,1
9612        ,INSTRB(anc_id_72,'(]',1,1) -1)
9613 ,SUBSTRB(anc_id_72
9614        ,INSTRB(anc_id_72,'(]',1,1) + 2
9615        ,INSTRB(anc_id_72,'(]',1,2) -
9616         INSTRB(anc_id_72,'(]',1,1) - 2)
9617 ,SUBSTRB(anc_id_72
9618        ,INSTRB(anc_id_72,'(]',1,2) + 2
9619        ,INSTRB(anc_id_72,'(]',1,3) -
9620         INSTRB(anc_id_72,'(]',1,2) - 2)
9621 ,SUBSTRB(anc_id_72
9622        ,INSTRB(anc_id_72,'(]',1,3) + 2
9623        ,INSTRB(anc_id_72,'(]',1,4) -
9624         INSTRB(anc_id_72,'(]',1,3) - 2)
9625 ,SUBSTRB(anc_id_72
9626        ,INSTRB(anc_id_72,'(]',1,4) + 2
9627        ,INSTRB(anc_id_72,'(]',1,5) -
9628         INSTRB(anc_id_72,'(]',1,4) - 2)
9629 ,SUBSTRB(anc_id_72
9630        ,INSTRB(anc_id_72,'(]',1,5) + 2
9631        ,INSTRB(anc_id_72,'(]',1,6) -
9632         INSTRB(anc_id_72,'(]',1,5) - 2)
9633 ,SUBSTRB(anc_id_72
9634        ,INSTRB(anc_id_72,'(]',1,6) + 2
9635        ,INSTRB(anc_id_72,'(]',1,7) -
9636         INSTRB(anc_id_72,'(]',1,6) - 2)
9637 ,SUBSTRB(anc_id_72
9638        ,INSTRB(anc_id_72,'(]',1,7) + 2
9639        ,LENGTHB(anc_id_72))
9640 )
9641 
9642 WHEN anc_id_73 IS NOT NULL THEN
9643   INTO xla_ae_line_acs (
9644         ae_header_id , ae_line_num , object_version_number
9645       , analytical_criterion_code
9646       , analytical_criterion_type_code
9647       , amb_context_code
9648       , ac1,ac2,ac3,ac4,ac5)
9649 VALUES (ae_header_id, ae_line_num, C_OVN
9650 ,SUBSTRB(anc_id_73
9651        ,1
9652        ,INSTRB(anc_id_73,'(]',1,1) -1)
9653 ,SUBSTRB(anc_id_73
9654        ,INSTRB(anc_id_73,'(]',1,1) + 2
9655        ,INSTRB(anc_id_73,'(]',1,2) -
9656         INSTRB(anc_id_73,'(]',1,1) - 2)
9657 ,SUBSTRB(anc_id_73
9658        ,INSTRB(anc_id_73,'(]',1,2) + 2
9659        ,INSTRB(anc_id_73,'(]',1,3) -
9660         INSTRB(anc_id_73,'(]',1,2) - 2)
9661 ,SUBSTRB(anc_id_73
9662        ,INSTRB(anc_id_73,'(]',1,3) + 2
9663        ,INSTRB(anc_id_73,'(]',1,4) -
9664         INSTRB(anc_id_73,'(]',1,3) - 2)
9665 ,SUBSTRB(anc_id_73
9666        ,INSTRB(anc_id_73,'(]',1,4) + 2
9667        ,INSTRB(anc_id_73,'(]',1,5) -
9668         INSTRB(anc_id_73,'(]',1,4) - 2)
9669 ,SUBSTRB(anc_id_73
9670        ,INSTRB(anc_id_73,'(]',1,5) + 2
9671        ,INSTRB(anc_id_73,'(]',1,6) -
9672         INSTRB(anc_id_73,'(]',1,5) - 2)
9673 ,SUBSTRB(anc_id_73
9674        ,INSTRB(anc_id_73,'(]',1,6) + 2
9675        ,INSTRB(anc_id_73,'(]',1,7) -
9676         INSTRB(anc_id_73,'(]',1,6) - 2)
9677 ,SUBSTRB(anc_id_73
9678        ,INSTRB(anc_id_73,'(]',1,7) + 2
9679        ,LENGTHB(anc_id_73))
9680 )
9681 
9682 WHEN anc_id_74 IS NOT NULL THEN
9683   INTO xla_ae_line_acs (
9684         ae_header_id , ae_line_num , object_version_number
9685       , analytical_criterion_code
9686       , analytical_criterion_type_code
9687       , amb_context_code
9688       , ac1,ac2,ac3,ac4,ac5)
9689 VALUES (ae_header_id, ae_line_num, C_OVN
9690 ,SUBSTRB(anc_id_74
9691        ,1
9692        ,INSTRB(anc_id_74,'(]',1,1) -1)
9693 ,SUBSTRB(anc_id_74
9694        ,INSTRB(anc_id_74,'(]',1,1) + 2
9695        ,INSTRB(anc_id_74,'(]',1,2) -
9696         INSTRB(anc_id_74,'(]',1,1) - 2)
9697 ,SUBSTRB(anc_id_74
9698        ,INSTRB(anc_id_74,'(]',1,2) + 2
9699        ,INSTRB(anc_id_74,'(]',1,3) -
9700         INSTRB(anc_id_74,'(]',1,2) - 2)
9701 ,SUBSTRB(anc_id_74
9702        ,INSTRB(anc_id_74,'(]',1,3) + 2
9703        ,INSTRB(anc_id_74,'(]',1,4) -
9704         INSTRB(anc_id_74,'(]',1,3) - 2)
9705 ,SUBSTRB(anc_id_74
9706        ,INSTRB(anc_id_74,'(]',1,4) + 2
9707        ,INSTRB(anc_id_74,'(]',1,5) -
9708         INSTRB(anc_id_74,'(]',1,4) - 2)
9709 ,SUBSTRB(anc_id_74
9710        ,INSTRB(anc_id_74,'(]',1,5) + 2
9711        ,INSTRB(anc_id_74,'(]',1,6) -
9712         INSTRB(anc_id_74,'(]',1,5) - 2)
9713 ,SUBSTRB(anc_id_74
9714        ,INSTRB(anc_id_74,'(]',1,6) + 2
9715        ,INSTRB(anc_id_74,'(]',1,7) -
9716         INSTRB(anc_id_74,'(]',1,6) - 2)
9717 ,SUBSTRB(anc_id_74
9718        ,INSTRB(anc_id_74,'(]',1,7) + 2
9719        ,LENGTHB(anc_id_74))
9720 )
9721 
9722 WHEN anc_id_75 IS NOT NULL THEN
9723   INTO xla_ae_line_acs (
9724         ae_header_id , ae_line_num , object_version_number
9725       , analytical_criterion_code
9726       , analytical_criterion_type_code
9727       , amb_context_code
9728       , ac1,ac2,ac3,ac4,ac5)
9729 VALUES (ae_header_id, ae_line_num, C_OVN
9730 ,SUBSTRB(anc_id_75
9731        ,1
9732        ,INSTRB(anc_id_75,'(]',1,1) -1)
9733 ,SUBSTRB(anc_id_75
9734        ,INSTRB(anc_id_75,'(]',1,1) + 2
9735        ,INSTRB(anc_id_75,'(]',1,2) -
9736         INSTRB(anc_id_75,'(]',1,1) - 2)
9737 ,SUBSTRB(anc_id_75
9738        ,INSTRB(anc_id_75,'(]',1,2) + 2
9739        ,INSTRB(anc_id_75,'(]',1,3) -
9740         INSTRB(anc_id_75,'(]',1,2) - 2)
9741 ,SUBSTRB(anc_id_75
9742        ,INSTRB(anc_id_75,'(]',1,3) + 2
9743        ,INSTRB(anc_id_75,'(]',1,4) -
9744         INSTRB(anc_id_75,'(]',1,3) - 2)
9745 ,SUBSTRB(anc_id_75
9746        ,INSTRB(anc_id_75,'(]',1,4) + 2
9747        ,INSTRB(anc_id_75,'(]',1,5) -
9748         INSTRB(anc_id_75,'(]',1,4) - 2)
9749 ,SUBSTRB(anc_id_75
9750        ,INSTRB(anc_id_75,'(]',1,5) + 2
9751        ,INSTRB(anc_id_75,'(]',1,6) -
9752         INSTRB(anc_id_75,'(]',1,5) - 2)
9753 ,SUBSTRB(anc_id_75
9754        ,INSTRB(anc_id_75,'(]',1,6) + 2
9755        ,INSTRB(anc_id_75,'(]',1,7) -
9756         INSTRB(anc_id_75,'(]',1,6) - 2)
9757 ,SUBSTRB(anc_id_75
9758        ,INSTRB(anc_id_75,'(]',1,7) + 2
9759        ,LENGTHB(anc_id_75))
9760 )
9761 
9762 WHEN anc_id_76 IS NOT NULL THEN
9763   INTO xla_ae_line_acs (
9764         ae_header_id , ae_line_num , object_version_number
9765       , analytical_criterion_code
9766       , analytical_criterion_type_code
9767       , amb_context_code
9768       , ac1,ac2,ac3,ac4,ac5)
9769 VALUES (ae_header_id, ae_line_num, C_OVN
9770 ,SUBSTRB(anc_id_76
9771        ,1
9772        ,INSTRB(anc_id_76,'(]',1,1) -1)
9773 ,SUBSTRB(anc_id_76
9774        ,INSTRB(anc_id_76,'(]',1,1) + 2
9775        ,INSTRB(anc_id_76,'(]',1,2) -
9776         INSTRB(anc_id_76,'(]',1,1) - 2)
9777 ,SUBSTRB(anc_id_76
9778        ,INSTRB(anc_id_76,'(]',1,2) + 2
9779        ,INSTRB(anc_id_76,'(]',1,3) -
9780         INSTRB(anc_id_76,'(]',1,2) - 2)
9781 ,SUBSTRB(anc_id_76
9782        ,INSTRB(anc_id_76,'(]',1,3) + 2
9783        ,INSTRB(anc_id_76,'(]',1,4) -
9784         INSTRB(anc_id_76,'(]',1,3) - 2)
9785 ,SUBSTRB(anc_id_76
9786        ,INSTRB(anc_id_76,'(]',1,4) + 2
9787        ,INSTRB(anc_id_76,'(]',1,5) -
9788         INSTRB(anc_id_76,'(]',1,4) - 2)
9789 ,SUBSTRB(anc_id_76
9790        ,INSTRB(anc_id_76,'(]',1,5) + 2
9791        ,INSTRB(anc_id_76,'(]',1,6) -
9792         INSTRB(anc_id_76,'(]',1,5) - 2)
9793 ,SUBSTRB(anc_id_76
9794        ,INSTRB(anc_id_76,'(]',1,6) + 2
9795        ,INSTRB(anc_id_76,'(]',1,7) -
9796         INSTRB(anc_id_76,'(]',1,6) - 2)
9797 ,SUBSTRB(anc_id_76
9798        ,INSTRB(anc_id_76,'(]',1,7) + 2
9799        ,LENGTHB(anc_id_76))
9800 )
9801 
9802 WHEN anc_id_77 IS NOT NULL THEN
9803   INTO xla_ae_line_acs (
9804         ae_header_id , ae_line_num , object_version_number
9805       , analytical_criterion_code
9806       , analytical_criterion_type_code
9807       , amb_context_code
9808       , ac1,ac2,ac3,ac4,ac5)
9809 VALUES (ae_header_id, ae_line_num, C_OVN
9810 ,SUBSTRB(anc_id_77
9811        ,1
9812        ,INSTRB(anc_id_77,'(]',1,1) -1)
9813 ,SUBSTRB(anc_id_77
9814        ,INSTRB(anc_id_77,'(]',1,1) + 2
9815        ,INSTRB(anc_id_77,'(]',1,2) -
9816         INSTRB(anc_id_77,'(]',1,1) - 2)
9817 ,SUBSTRB(anc_id_77
9818        ,INSTRB(anc_id_77,'(]',1,2) + 2
9819        ,INSTRB(anc_id_77,'(]',1,3) -
9820         INSTRB(anc_id_77,'(]',1,2) - 2)
9821 ,SUBSTRB(anc_id_77
9822        ,INSTRB(anc_id_77,'(]',1,3) + 2
9823        ,INSTRB(anc_id_77,'(]',1,4) -
9824         INSTRB(anc_id_77,'(]',1,3) - 2)
9825 ,SUBSTRB(anc_id_77
9826        ,INSTRB(anc_id_77,'(]',1,4) + 2
9827        ,INSTRB(anc_id_77,'(]',1,5) -
9828         INSTRB(anc_id_77,'(]',1,4) - 2)
9829 ,SUBSTRB(anc_id_77
9830        ,INSTRB(anc_id_77,'(]',1,5) + 2
9831        ,INSTRB(anc_id_77,'(]',1,6) -
9832         INSTRB(anc_id_77,'(]',1,5) - 2)
9833 ,SUBSTRB(anc_id_77
9834        ,INSTRB(anc_id_77,'(]',1,6) + 2
9835        ,INSTRB(anc_id_77,'(]',1,7) -
9836         INSTRB(anc_id_77,'(]',1,6) - 2)
9837 ,SUBSTRB(anc_id_77
9838        ,INSTRB(anc_id_77,'(]',1,7) + 2
9839        ,LENGTHB(anc_id_77))
9840 )
9841 
9842 WHEN anc_id_78 IS NOT NULL THEN
9843   INTO xla_ae_line_acs (
9844         ae_header_id , ae_line_num , object_version_number
9845       , analytical_criterion_code
9846       , analytical_criterion_type_code
9847       , amb_context_code
9848       , ac1,ac2,ac3,ac4,ac5)
9849 VALUES (ae_header_id, ae_line_num, C_OVN
9850 ,SUBSTRB(anc_id_78
9851        ,1
9852        ,INSTRB(anc_id_78,'(]',1,1) -1)
9853 ,SUBSTRB(anc_id_78
9854        ,INSTRB(anc_id_78,'(]',1,1) + 2
9855        ,INSTRB(anc_id_78,'(]',1,2) -
9856         INSTRB(anc_id_78,'(]',1,1) - 2)
9857 ,SUBSTRB(anc_id_78
9858        ,INSTRB(anc_id_78,'(]',1,2) + 2
9859        ,INSTRB(anc_id_78,'(]',1,3) -
9860         INSTRB(anc_id_78,'(]',1,2) - 2)
9861 ,SUBSTRB(anc_id_78
9862        ,INSTRB(anc_id_78,'(]',1,3) + 2
9863        ,INSTRB(anc_id_78,'(]',1,4) -
9864         INSTRB(anc_id_78,'(]',1,3) - 2)
9865 ,SUBSTRB(anc_id_78
9866        ,INSTRB(anc_id_78,'(]',1,4) + 2
9867        ,INSTRB(anc_id_78,'(]',1,5) -
9868         INSTRB(anc_id_78,'(]',1,4) - 2)
9869 ,SUBSTRB(anc_id_78
9870        ,INSTRB(anc_id_78,'(]',1,5) + 2
9871        ,INSTRB(anc_id_78,'(]',1,6) -
9872         INSTRB(anc_id_78,'(]',1,5) - 2)
9873 ,SUBSTRB(anc_id_78
9874        ,INSTRB(anc_id_78,'(]',1,6) + 2
9875        ,INSTRB(anc_id_78,'(]',1,7) -
9876         INSTRB(anc_id_78,'(]',1,6) - 2)
9877 ,SUBSTRB(anc_id_78
9878        ,INSTRB(anc_id_78,'(]',1,7) + 2
9879        ,LENGTHB(anc_id_78))
9880 )
9881 
9882 WHEN anc_id_79 IS NOT NULL THEN
9883   INTO xla_ae_line_acs (
9884         ae_header_id , ae_line_num , object_version_number
9885       , analytical_criterion_code
9886       , analytical_criterion_type_code
9887       , amb_context_code
9888       , ac1,ac2,ac3,ac4,ac5)
9889 VALUES (ae_header_id, ae_line_num, C_OVN
9890 ,SUBSTRB(anc_id_79
9891        ,1
9892        ,INSTRB(anc_id_79,'(]',1,1) -1)
9893 ,SUBSTRB(anc_id_79
9894        ,INSTRB(anc_id_79,'(]',1,1) + 2
9895        ,INSTRB(anc_id_79,'(]',1,2) -
9896         INSTRB(anc_id_79,'(]',1,1) - 2)
9897 ,SUBSTRB(anc_id_79
9898        ,INSTRB(anc_id_79,'(]',1,2) + 2
9899        ,INSTRB(anc_id_79,'(]',1,3) -
9900         INSTRB(anc_id_79,'(]',1,2) - 2)
9901 ,SUBSTRB(anc_id_79
9902        ,INSTRB(anc_id_79,'(]',1,3) + 2
9903        ,INSTRB(anc_id_79,'(]',1,4) -
9904         INSTRB(anc_id_79,'(]',1,3) - 2)
9905 ,SUBSTRB(anc_id_79
9906        ,INSTRB(anc_id_79,'(]',1,4) + 2
9907        ,INSTRB(anc_id_79,'(]',1,5) -
9908         INSTRB(anc_id_79,'(]',1,4) - 2)
9909 ,SUBSTRB(anc_id_79
9910        ,INSTRB(anc_id_79,'(]',1,5) + 2
9911        ,INSTRB(anc_id_79,'(]',1,6) -
9912         INSTRB(anc_id_79,'(]',1,5) - 2)
9913 ,SUBSTRB(anc_id_79
9914        ,INSTRB(anc_id_79,'(]',1,6) + 2
9915        ,INSTRB(anc_id_79,'(]',1,7) -
9916         INSTRB(anc_id_79,'(]',1,6) - 2)
9917 ,SUBSTRB(anc_id_79
9918        ,INSTRB(anc_id_79,'(]',1,7) + 2
9919        ,LENGTHB(anc_id_79))
9920 )
9921 
9922 WHEN anc_id_80 IS NOT NULL THEN
9923   INTO xla_ae_line_acs (
9924         ae_header_id , ae_line_num , object_version_number
9925       , analytical_criterion_code
9926       , analytical_criterion_type_code
9927       , amb_context_code
9928       , ac1,ac2,ac3,ac4,ac5)
9929 VALUES (ae_header_id, ae_line_num, C_OVN
9930 ,SUBSTRB(anc_id_80
9931        ,1
9932        ,INSTRB(anc_id_80,'(]',1,1) -1)
9933 ,SUBSTRB(anc_id_80
9934        ,INSTRB(anc_id_80,'(]',1,1) + 2
9935        ,INSTRB(anc_id_80,'(]',1,2) -
9936         INSTRB(anc_id_80,'(]',1,1) - 2)
9937 ,SUBSTRB(anc_id_80
9938        ,INSTRB(anc_id_80,'(]',1,2) + 2
9939        ,INSTRB(anc_id_80,'(]',1,3) -
9940         INSTRB(anc_id_80,'(]',1,2) - 2)
9941 ,SUBSTRB(anc_id_80
9942        ,INSTRB(anc_id_80,'(]',1,3) + 2
9943        ,INSTRB(anc_id_80,'(]',1,4) -
9944         INSTRB(anc_id_80,'(]',1,3) - 2)
9945 ,SUBSTRB(anc_id_80
9946        ,INSTRB(anc_id_80,'(]',1,4) + 2
9947        ,INSTRB(anc_id_80,'(]',1,5) -
9948         INSTRB(anc_id_80,'(]',1,4) - 2)
9949 ,SUBSTRB(anc_id_80
9950        ,INSTRB(anc_id_80,'(]',1,5) + 2
9951        ,INSTRB(anc_id_80,'(]',1,6) -
9952         INSTRB(anc_id_80,'(]',1,5) - 2)
9953 ,SUBSTRB(anc_id_80
9954        ,INSTRB(anc_id_80,'(]',1,6) + 2
9955        ,INSTRB(anc_id_80,'(]',1,7) -
9956         INSTRB(anc_id_80,'(]',1,6) - 2)
9957 ,SUBSTRB(anc_id_80
9958        ,INSTRB(anc_id_80,'(]',1,7) + 2
9959        ,LENGTHB(anc_id_80))
9960 )
9961 
9962 WHEN anc_id_81 IS NOT NULL THEN
9963   INTO xla_ae_line_acs (
9964         ae_header_id , ae_line_num , object_version_number
9965       , analytical_criterion_code
9966       , analytical_criterion_type_code
9967       , amb_context_code
9968       , ac1,ac2,ac3,ac4,ac5)
9969 VALUES (ae_header_id, ae_line_num, C_OVN
9970 ,SUBSTRB(anc_id_81
9971        ,1
9972        ,INSTRB(anc_id_81,'(]',1,1) -1)
9973 ,SUBSTRB(anc_id_81
9974        ,INSTRB(anc_id_81,'(]',1,1) + 2
9975        ,INSTRB(anc_id_81,'(]',1,2) -
9976         INSTRB(anc_id_81,'(]',1,1) - 2)
9977 ,SUBSTRB(anc_id_81
9978        ,INSTRB(anc_id_81,'(]',1,2) + 2
9979        ,INSTRB(anc_id_81,'(]',1,3) -
9980         INSTRB(anc_id_81,'(]',1,2) - 2)
9981 ,SUBSTRB(anc_id_81
9982        ,INSTRB(anc_id_81,'(]',1,3) + 2
9983        ,INSTRB(anc_id_81,'(]',1,4) -
9984         INSTRB(anc_id_81,'(]',1,3) - 2)
9985 ,SUBSTRB(anc_id_81
9986        ,INSTRB(anc_id_81,'(]',1,4) + 2
9987        ,INSTRB(anc_id_81,'(]',1,5) -
9988         INSTRB(anc_id_81,'(]',1,4) - 2)
9989 ,SUBSTRB(anc_id_81
9990        ,INSTRB(anc_id_81,'(]',1,5) + 2
9991        ,INSTRB(anc_id_81,'(]',1,6) -
9992         INSTRB(anc_id_81,'(]',1,5) - 2)
9993 ,SUBSTRB(anc_id_81
9994        ,INSTRB(anc_id_81,'(]',1,6) + 2
9995        ,INSTRB(anc_id_81,'(]',1,7) -
9996         INSTRB(anc_id_81,'(]',1,6) - 2)
9997 ,SUBSTRB(anc_id_81
9998        ,INSTRB(anc_id_81,'(]',1,7) + 2
9999        ,LENGTHB(anc_id_81))
10000 )
10001 
10002 WHEN anc_id_82 IS NOT NULL THEN
10003   INTO xla_ae_line_acs (
10004         ae_header_id , ae_line_num , object_version_number
10005       , analytical_criterion_code
10006       , analytical_criterion_type_code
10007       , amb_context_code
10008       , ac1,ac2,ac3,ac4,ac5)
10009 VALUES (ae_header_id, ae_line_num, C_OVN
10010 ,SUBSTRB(anc_id_82
10011        ,1
10012        ,INSTRB(anc_id_82,'(]',1,1) -1)
10013 ,SUBSTRB(anc_id_82
10014        ,INSTRB(anc_id_82,'(]',1,1) + 2
10015        ,INSTRB(anc_id_82,'(]',1,2) -
10016         INSTRB(anc_id_82,'(]',1,1) - 2)
10017 ,SUBSTRB(anc_id_82
10018        ,INSTRB(anc_id_82,'(]',1,2) + 2
10019        ,INSTRB(anc_id_82,'(]',1,3) -
10020         INSTRB(anc_id_82,'(]',1,2) - 2)
10021 ,SUBSTRB(anc_id_82
10022        ,INSTRB(anc_id_82,'(]',1,3) + 2
10023        ,INSTRB(anc_id_82,'(]',1,4) -
10024         INSTRB(anc_id_82,'(]',1,3) - 2)
10025 ,SUBSTRB(anc_id_82
10026        ,INSTRB(anc_id_82,'(]',1,4) + 2
10027        ,INSTRB(anc_id_82,'(]',1,5) -
10028         INSTRB(anc_id_82,'(]',1,4) - 2)
10029 ,SUBSTRB(anc_id_82
10030        ,INSTRB(anc_id_82,'(]',1,5) + 2
10031        ,INSTRB(anc_id_82,'(]',1,6) -
10032         INSTRB(anc_id_82,'(]',1,5) - 2)
10033 ,SUBSTRB(anc_id_82
10034        ,INSTRB(anc_id_82,'(]',1,6) + 2
10035        ,INSTRB(anc_id_82,'(]',1,7) -
10036         INSTRB(anc_id_82,'(]',1,6) - 2)
10037 ,SUBSTRB(anc_id_82
10038        ,INSTRB(anc_id_82,'(]',1,7) + 2
10039        ,LENGTHB(anc_id_82))
10040 )
10041 
10042 WHEN anc_id_83 IS NOT NULL THEN
10043   INTO xla_ae_line_acs (
10044         ae_header_id , ae_line_num , object_version_number
10045       , analytical_criterion_code
10046       , analytical_criterion_type_code
10047       , amb_context_code
10048       , ac1,ac2,ac3,ac4,ac5)
10049 VALUES (ae_header_id, ae_line_num, C_OVN
10050 ,SUBSTRB(anc_id_83
10051        ,1
10052        ,INSTRB(anc_id_83,'(]',1,1) -1)
10053 ,SUBSTRB(anc_id_83
10054        ,INSTRB(anc_id_83,'(]',1,1) + 2
10055        ,INSTRB(anc_id_83,'(]',1,2) -
10056         INSTRB(anc_id_83,'(]',1,1) - 2)
10057 ,SUBSTRB(anc_id_83
10058        ,INSTRB(anc_id_83,'(]',1,2) + 2
10059        ,INSTRB(anc_id_83,'(]',1,3) -
10060         INSTRB(anc_id_83,'(]',1,2) - 2)
10061 ,SUBSTRB(anc_id_83
10062        ,INSTRB(anc_id_83,'(]',1,3) + 2
10063        ,INSTRB(anc_id_83,'(]',1,4) -
10064         INSTRB(anc_id_83,'(]',1,3) - 2)
10065 ,SUBSTRB(anc_id_83
10066        ,INSTRB(anc_id_83,'(]',1,4) + 2
10067        ,INSTRB(anc_id_83,'(]',1,5) -
10068         INSTRB(anc_id_83,'(]',1,4) - 2)
10069 ,SUBSTRB(anc_id_83
10070        ,INSTRB(anc_id_83,'(]',1,5) + 2
10071        ,INSTRB(anc_id_83,'(]',1,6) -
10072         INSTRB(anc_id_83,'(]',1,5) - 2)
10073 ,SUBSTRB(anc_id_83
10074        ,INSTRB(anc_id_83,'(]',1,6) + 2
10075        ,INSTRB(anc_id_83,'(]',1,7) -
10076         INSTRB(anc_id_83,'(]',1,6) - 2)
10077 ,SUBSTRB(anc_id_83
10078        ,INSTRB(anc_id_83,'(]',1,7) + 2
10079        ,LENGTHB(anc_id_83))
10080 )
10081 
10082 WHEN anc_id_84 IS NOT NULL THEN
10083   INTO xla_ae_line_acs (
10084         ae_header_id , ae_line_num , object_version_number
10085       , analytical_criterion_code
10086       , analytical_criterion_type_code
10087       , amb_context_code
10088       , ac1,ac2,ac3,ac4,ac5)
10089 VALUES (ae_header_id, ae_line_num, C_OVN
10090 ,SUBSTRB(anc_id_84
10091        ,1
10092        ,INSTRB(anc_id_84,'(]',1,1) -1)
10093 ,SUBSTRB(anc_id_84
10094        ,INSTRB(anc_id_84,'(]',1,1) + 2
10095        ,INSTRB(anc_id_84,'(]',1,2) -
10096         INSTRB(anc_id_84,'(]',1,1) - 2)
10097 ,SUBSTRB(anc_id_84
10098        ,INSTRB(anc_id_84,'(]',1,2) + 2
10099        ,INSTRB(anc_id_84,'(]',1,3) -
10100         INSTRB(anc_id_84,'(]',1,2) - 2)
10101 ,SUBSTRB(anc_id_84
10102        ,INSTRB(anc_id_84,'(]',1,3) + 2
10103        ,INSTRB(anc_id_84,'(]',1,4) -
10104         INSTRB(anc_id_84,'(]',1,3) - 2)
10105 ,SUBSTRB(anc_id_84
10106        ,INSTRB(anc_id_84,'(]',1,4) + 2
10107        ,INSTRB(anc_id_84,'(]',1,5) -
10108         INSTRB(anc_id_84,'(]',1,4) - 2)
10109 ,SUBSTRB(anc_id_84
10110        ,INSTRB(anc_id_84,'(]',1,5) + 2
10111        ,INSTRB(anc_id_84,'(]',1,6) -
10112         INSTRB(anc_id_84,'(]',1,5) - 2)
10113 ,SUBSTRB(anc_id_84
10114        ,INSTRB(anc_id_84,'(]',1,6) + 2
10115        ,INSTRB(anc_id_84,'(]',1,7) -
10116         INSTRB(anc_id_84,'(]',1,6) - 2)
10117 ,SUBSTRB(anc_id_84
10118        ,INSTRB(anc_id_84,'(]',1,7) + 2
10119        ,LENGTHB(anc_id_84))
10120 )
10121 
10122 WHEN anc_id_85 IS NOT NULL THEN
10123   INTO xla_ae_line_acs (
10124         ae_header_id , ae_line_num , object_version_number
10125       , analytical_criterion_code
10126       , analytical_criterion_type_code
10127       , amb_context_code
10128       , ac1,ac2,ac3,ac4,ac5)
10129 VALUES (ae_header_id, ae_line_num, C_OVN
10130 ,SUBSTRB(anc_id_85
10131        ,1
10132        ,INSTRB(anc_id_85,'(]',1,1) -1)
10133 ,SUBSTRB(anc_id_85
10134        ,INSTRB(anc_id_85,'(]',1,1) + 2
10135        ,INSTRB(anc_id_85,'(]',1,2) -
10136         INSTRB(anc_id_85,'(]',1,1) - 2)
10137 ,SUBSTRB(anc_id_85
10138        ,INSTRB(anc_id_85,'(]',1,2) + 2
10139        ,INSTRB(anc_id_85,'(]',1,3) -
10140         INSTRB(anc_id_85,'(]',1,2) - 2)
10141 ,SUBSTRB(anc_id_85
10142        ,INSTRB(anc_id_85,'(]',1,3) + 2
10143        ,INSTRB(anc_id_85,'(]',1,4) -
10144         INSTRB(anc_id_85,'(]',1,3) - 2)
10145 ,SUBSTRB(anc_id_85
10146        ,INSTRB(anc_id_85,'(]',1,4) + 2
10147        ,INSTRB(anc_id_85,'(]',1,5) -
10148         INSTRB(anc_id_85,'(]',1,4) - 2)
10149 ,SUBSTRB(anc_id_85
10150        ,INSTRB(anc_id_85,'(]',1,5) + 2
10151        ,INSTRB(anc_id_85,'(]',1,6) -
10152         INSTRB(anc_id_85,'(]',1,5) - 2)
10153 ,SUBSTRB(anc_id_85
10154        ,INSTRB(anc_id_85,'(]',1,6) + 2
10155        ,INSTRB(anc_id_85,'(]',1,7) -
10156         INSTRB(anc_id_85,'(]',1,6) - 2)
10157 ,SUBSTRB(anc_id_85
10158        ,INSTRB(anc_id_85,'(]',1,7) + 2
10159        ,LENGTHB(anc_id_85))
10160 )
10161 
10162 WHEN anc_id_86 IS NOT NULL THEN
10163   INTO xla_ae_line_acs (
10164         ae_header_id , ae_line_num , object_version_number
10165       , analytical_criterion_code
10166       , analytical_criterion_type_code
10167       , amb_context_code
10168       , ac1,ac2,ac3,ac4,ac5)
10169 VALUES (ae_header_id, ae_line_num, C_OVN
10170 ,SUBSTRB(anc_id_86
10171        ,1
10172        ,INSTRB(anc_id_86,'(]',1,1) -1)
10173 ,SUBSTRB(anc_id_86
10174        ,INSTRB(anc_id_86,'(]',1,1) + 2
10175        ,INSTRB(anc_id_86,'(]',1,2) -
10176         INSTRB(anc_id_86,'(]',1,1) - 2)
10177 ,SUBSTRB(anc_id_86
10178        ,INSTRB(anc_id_86,'(]',1,2) + 2
10179        ,INSTRB(anc_id_86,'(]',1,3) -
10180         INSTRB(anc_id_86,'(]',1,2) - 2)
10181 ,SUBSTRB(anc_id_86
10182        ,INSTRB(anc_id_86,'(]',1,3) + 2
10183        ,INSTRB(anc_id_86,'(]',1,4) -
10184         INSTRB(anc_id_86,'(]',1,3) - 2)
10185 ,SUBSTRB(anc_id_86
10186        ,INSTRB(anc_id_86,'(]',1,4) + 2
10187        ,INSTRB(anc_id_86,'(]',1,5) -
10188         INSTRB(anc_id_86,'(]',1,4) - 2)
10189 ,SUBSTRB(anc_id_86
10190        ,INSTRB(anc_id_86,'(]',1,5) + 2
10191        ,INSTRB(anc_id_86,'(]',1,6) -
10192         INSTRB(anc_id_86,'(]',1,5) - 2)
10193 ,SUBSTRB(anc_id_86
10194        ,INSTRB(anc_id_86,'(]',1,6) + 2
10195        ,INSTRB(anc_id_86,'(]',1,7) -
10196         INSTRB(anc_id_86,'(]',1,6) - 2)
10197 ,SUBSTRB(anc_id_86
10198        ,INSTRB(anc_id_86,'(]',1,7) + 2
10199        ,LENGTHB(anc_id_86))
10200 )
10201 
10202 WHEN anc_id_87 IS NOT NULL THEN
10203   INTO xla_ae_line_acs (
10204         ae_header_id , ae_line_num , object_version_number
10205       , analytical_criterion_code
10206       , analytical_criterion_type_code
10207       , amb_context_code
10208       , ac1,ac2,ac3,ac4,ac5)
10209 VALUES (ae_header_id, ae_line_num, C_OVN
10210 ,SUBSTRB(anc_id_87
10211        ,1
10212        ,INSTRB(anc_id_87,'(]',1,1) -1)
10213 ,SUBSTRB(anc_id_87
10214        ,INSTRB(anc_id_87,'(]',1,1) + 2
10215        ,INSTRB(anc_id_87,'(]',1,2) -
10216         INSTRB(anc_id_87,'(]',1,1) - 2)
10217 ,SUBSTRB(anc_id_87
10218        ,INSTRB(anc_id_87,'(]',1,2) + 2
10219        ,INSTRB(anc_id_87,'(]',1,3) -
10220         INSTRB(anc_id_87,'(]',1,2) - 2)
10221 ,SUBSTRB(anc_id_87
10222        ,INSTRB(anc_id_87,'(]',1,3) + 2
10223        ,INSTRB(anc_id_87,'(]',1,4) -
10224         INSTRB(anc_id_87,'(]',1,3) - 2)
10225 ,SUBSTRB(anc_id_87
10226        ,INSTRB(anc_id_87,'(]',1,4) + 2
10227        ,INSTRB(anc_id_87,'(]',1,5) -
10228         INSTRB(anc_id_87,'(]',1,4) - 2)
10229 ,SUBSTRB(anc_id_87
10230        ,INSTRB(anc_id_87,'(]',1,5) + 2
10231        ,INSTRB(anc_id_87,'(]',1,6) -
10232         INSTRB(anc_id_87,'(]',1,5) - 2)
10233 ,SUBSTRB(anc_id_87
10234        ,INSTRB(anc_id_87,'(]',1,6) + 2
10235        ,INSTRB(anc_id_87,'(]',1,7) -
10236         INSTRB(anc_id_87,'(]',1,6) - 2)
10237 ,SUBSTRB(anc_id_87
10238        ,INSTRB(anc_id_87,'(]',1,7) + 2
10239        ,LENGTHB(anc_id_87))
10240 )
10241 
10242 WHEN anc_id_88 IS NOT NULL THEN
10243   INTO xla_ae_line_acs (
10244         ae_header_id , ae_line_num , object_version_number
10245       , analytical_criterion_code
10246       , analytical_criterion_type_code
10247       , amb_context_code
10248       , ac1,ac2,ac3,ac4,ac5)
10249 VALUES (ae_header_id, ae_line_num, C_OVN
10250 ,SUBSTRB(anc_id_88
10251        ,1
10252        ,INSTRB(anc_id_88,'(]',1,1) -1)
10253 ,SUBSTRB(anc_id_88
10254        ,INSTRB(anc_id_88,'(]',1,1) + 2
10255        ,INSTRB(anc_id_88,'(]',1,2) -
10256         INSTRB(anc_id_88,'(]',1,1) - 2)
10257 ,SUBSTRB(anc_id_88
10258        ,INSTRB(anc_id_88,'(]',1,2) + 2
10259        ,INSTRB(anc_id_88,'(]',1,3) -
10260         INSTRB(anc_id_88,'(]',1,2) - 2)
10261 ,SUBSTRB(anc_id_88
10262        ,INSTRB(anc_id_88,'(]',1,3) + 2
10263        ,INSTRB(anc_id_88,'(]',1,4) -
10264         INSTRB(anc_id_88,'(]',1,3) - 2)
10265 ,SUBSTRB(anc_id_88
10266        ,INSTRB(anc_id_88,'(]',1,4) + 2
10267        ,INSTRB(anc_id_88,'(]',1,5) -
10268         INSTRB(anc_id_88,'(]',1,4) - 2)
10269 ,SUBSTRB(anc_id_88
10270        ,INSTRB(anc_id_88,'(]',1,5) + 2
10271        ,INSTRB(anc_id_88,'(]',1,6) -
10272         INSTRB(anc_id_88,'(]',1,5) - 2)
10273 ,SUBSTRB(anc_id_88
10274        ,INSTRB(anc_id_88,'(]',1,6) + 2
10275        ,INSTRB(anc_id_88,'(]',1,7) -
10276         INSTRB(anc_id_88,'(]',1,6) - 2)
10277 ,SUBSTRB(anc_id_88
10278        ,INSTRB(anc_id_88,'(]',1,7) + 2
10279        ,LENGTHB(anc_id_88))
10280 )
10281 
10282 WHEN anc_id_89 IS NOT NULL THEN
10283   INTO xla_ae_line_acs (
10284         ae_header_id , ae_line_num , object_version_number
10285       , analytical_criterion_code
10286       , analytical_criterion_type_code
10287       , amb_context_code
10288       , ac1,ac2,ac3,ac4,ac5)
10289 VALUES (ae_header_id, ae_line_num, C_OVN
10290 ,SUBSTRB(anc_id_89
10291        ,1
10292        ,INSTRB(anc_id_89,'(]',1,1) -1)
10293 ,SUBSTRB(anc_id_89
10294        ,INSTRB(anc_id_89,'(]',1,1) + 2
10295        ,INSTRB(anc_id_89,'(]',1,2) -
10296         INSTRB(anc_id_89,'(]',1,1) - 2)
10297 ,SUBSTRB(anc_id_89
10298        ,INSTRB(anc_id_89,'(]',1,2) + 2
10299        ,INSTRB(anc_id_89,'(]',1,3) -
10300         INSTRB(anc_id_89,'(]',1,2) - 2)
10301 ,SUBSTRB(anc_id_89
10302        ,INSTRB(anc_id_89,'(]',1,3) + 2
10303        ,INSTRB(anc_id_89,'(]',1,4) -
10304         INSTRB(anc_id_89,'(]',1,3) - 2)
10305 ,SUBSTRB(anc_id_89
10306        ,INSTRB(anc_id_89,'(]',1,4) + 2
10307        ,INSTRB(anc_id_89,'(]',1,5) -
10308         INSTRB(anc_id_89,'(]',1,4) - 2)
10309 ,SUBSTRB(anc_id_89
10310        ,INSTRB(anc_id_89,'(]',1,5) + 2
10311        ,INSTRB(anc_id_89,'(]',1,6) -
10312         INSTRB(anc_id_89,'(]',1,5) - 2)
10313 ,SUBSTRB(anc_id_89
10314        ,INSTRB(anc_id_89,'(]',1,6) + 2
10315        ,INSTRB(anc_id_89,'(]',1,7) -
10316         INSTRB(anc_id_89,'(]',1,6) - 2)
10317 ,SUBSTRB(anc_id_89
10318        ,INSTRB(anc_id_89,'(]',1,7) + 2
10319        ,LENGTHB(anc_id_89))
10320 )
10321 
10322 WHEN anc_id_90 IS NOT NULL THEN
10323   INTO xla_ae_line_acs (
10324         ae_header_id , ae_line_num , object_version_number
10325       , analytical_criterion_code
10326       , analytical_criterion_type_code
10327       , amb_context_code
10328       , ac1,ac2,ac3,ac4,ac5)
10329 VALUES (ae_header_id, ae_line_num, C_OVN
10330 ,SUBSTRB(anc_id_90
10331        ,1
10332        ,INSTRB(anc_id_90,'(]',1,1) -1)
10333 ,SUBSTRB(anc_id_90
10334        ,INSTRB(anc_id_90,'(]',1,1) + 2
10335        ,INSTRB(anc_id_90,'(]',1,2) -
10336         INSTRB(anc_id_90,'(]',1,1) - 2)
10337 ,SUBSTRB(anc_id_90
10338        ,INSTRB(anc_id_90,'(]',1,2) + 2
10339        ,INSTRB(anc_id_90,'(]',1,3) -
10340         INSTRB(anc_id_90,'(]',1,2) - 2)
10341 ,SUBSTRB(anc_id_90
10342        ,INSTRB(anc_id_90,'(]',1,3) + 2
10343        ,INSTRB(anc_id_90,'(]',1,4) -
10344         INSTRB(anc_id_90,'(]',1,3) - 2)
10345 ,SUBSTRB(anc_id_90
10346        ,INSTRB(anc_id_90,'(]',1,4) + 2
10347        ,INSTRB(anc_id_90,'(]',1,5) -
10348         INSTRB(anc_id_90,'(]',1,4) - 2)
10349 ,SUBSTRB(anc_id_90
10350        ,INSTRB(anc_id_90,'(]',1,5) + 2
10351        ,INSTRB(anc_id_90,'(]',1,6) -
10352         INSTRB(anc_id_90,'(]',1,5) - 2)
10353 ,SUBSTRB(anc_id_90
10354        ,INSTRB(anc_id_90,'(]',1,6) + 2
10355        ,INSTRB(anc_id_90,'(]',1,7) -
10356         INSTRB(anc_id_90,'(]',1,6) - 2)
10357 ,SUBSTRB(anc_id_90
10358        ,INSTRB(anc_id_90,'(]',1,7) + 2
10359        ,LENGTHB(anc_id_90))
10360 )
10361 
10362 WHEN anc_id_91 IS NOT NULL THEN
10363   INTO xla_ae_line_acs (
10364         ae_header_id , ae_line_num , object_version_number
10365       , analytical_criterion_code
10366       , analytical_criterion_type_code
10367       , amb_context_code
10368       , ac1,ac2,ac3,ac4,ac5)
10369 VALUES (ae_header_id, ae_line_num, C_OVN
10370 ,SUBSTRB(anc_id_91
10371        ,1
10372        ,INSTRB(anc_id_91,'(]',1,1) -1)
10373 ,SUBSTRB(anc_id_91
10374        ,INSTRB(anc_id_91,'(]',1,1) + 2
10375        ,INSTRB(anc_id_91,'(]',1,2) -
10376         INSTRB(anc_id_91,'(]',1,1) - 2)
10377 ,SUBSTRB(anc_id_91
10378        ,INSTRB(anc_id_91,'(]',1,2) + 2
10379        ,INSTRB(anc_id_91,'(]',1,3) -
10380         INSTRB(anc_id_91,'(]',1,2) - 2)
10381 ,SUBSTRB(anc_id_91
10382        ,INSTRB(anc_id_91,'(]',1,3) + 2
10383        ,INSTRB(anc_id_91,'(]',1,4) -
10384         INSTRB(anc_id_91,'(]',1,3) - 2)
10385 ,SUBSTRB(anc_id_91
10386        ,INSTRB(anc_id_91,'(]',1,4) + 2
10387        ,INSTRB(anc_id_91,'(]',1,5) -
10388         INSTRB(anc_id_91,'(]',1,4) - 2)
10389 ,SUBSTRB(anc_id_91
10390        ,INSTRB(anc_id_91,'(]',1,5) + 2
10391        ,INSTRB(anc_id_91,'(]',1,6) -
10392         INSTRB(anc_id_91,'(]',1,5) - 2)
10393 ,SUBSTRB(anc_id_91
10394        ,INSTRB(anc_id_91,'(]',1,6) + 2
10395        ,INSTRB(anc_id_91,'(]',1,7) -
10396         INSTRB(anc_id_91,'(]',1,6) - 2)
10397 ,SUBSTRB(anc_id_91
10398        ,INSTRB(anc_id_91,'(]',1,7) + 2
10399        ,LENGTHB(anc_id_91))
10400 )
10401 
10402 WHEN anc_id_92 IS NOT NULL THEN
10403   INTO xla_ae_line_acs (
10404         ae_header_id , ae_line_num , object_version_number
10405       , analytical_criterion_code
10406       , analytical_criterion_type_code
10407       , amb_context_code
10408       , ac1,ac2,ac3,ac4,ac5)
10409 VALUES (ae_header_id, ae_line_num, C_OVN
10410 ,SUBSTRB(anc_id_92
10411        ,1
10412        ,INSTRB(anc_id_92,'(]',1,1) -1)
10413 ,SUBSTRB(anc_id_92
10414        ,INSTRB(anc_id_92,'(]',1,1) + 2
10415        ,INSTRB(anc_id_92,'(]',1,2) -
10416         INSTRB(anc_id_92,'(]',1,1) - 2)
10417 ,SUBSTRB(anc_id_92
10418        ,INSTRB(anc_id_92,'(]',1,2) + 2
10419        ,INSTRB(anc_id_92,'(]',1,3) -
10420         INSTRB(anc_id_92,'(]',1,2) - 2)
10421 ,SUBSTRB(anc_id_92
10422        ,INSTRB(anc_id_92,'(]',1,3) + 2
10423        ,INSTRB(anc_id_92,'(]',1,4) -
10424         INSTRB(anc_id_92,'(]',1,3) - 2)
10425 ,SUBSTRB(anc_id_92
10426        ,INSTRB(anc_id_92,'(]',1,4) + 2
10427        ,INSTRB(anc_id_92,'(]',1,5) -
10428         INSTRB(anc_id_92,'(]',1,4) - 2)
10429 ,SUBSTRB(anc_id_92
10430        ,INSTRB(anc_id_92,'(]',1,5) + 2
10431        ,INSTRB(anc_id_92,'(]',1,6) -
10432         INSTRB(anc_id_92,'(]',1,5) - 2)
10433 ,SUBSTRB(anc_id_92
10434        ,INSTRB(anc_id_92,'(]',1,6) + 2
10435        ,INSTRB(anc_id_92,'(]',1,7) -
10436         INSTRB(anc_id_92,'(]',1,6) - 2)
10437 ,SUBSTRB(anc_id_92
10438        ,INSTRB(anc_id_92,'(]',1,7) + 2
10439        ,LENGTHB(anc_id_92))
10440 )
10441 
10442 WHEN anc_id_93 IS NOT NULL THEN
10443   INTO xla_ae_line_acs (
10444         ae_header_id , ae_line_num , object_version_number
10445       , analytical_criterion_code
10446       , analytical_criterion_type_code
10447       , amb_context_code
10448       , ac1,ac2,ac3,ac4,ac5)
10449 VALUES (ae_header_id, ae_line_num, C_OVN
10450 ,SUBSTRB(anc_id_93
10451        ,1
10452        ,INSTRB(anc_id_93,'(]',1,1) -1)
10453 ,SUBSTRB(anc_id_93
10454        ,INSTRB(anc_id_93,'(]',1,1) + 2
10455        ,INSTRB(anc_id_93,'(]',1,2) -
10456         INSTRB(anc_id_93,'(]',1,1) - 2)
10457 ,SUBSTRB(anc_id_93
10458        ,INSTRB(anc_id_93,'(]',1,2) + 2
10459        ,INSTRB(anc_id_93,'(]',1,3) -
10460         INSTRB(anc_id_93,'(]',1,2) - 2)
10461 ,SUBSTRB(anc_id_93
10462        ,INSTRB(anc_id_93,'(]',1,3) + 2
10463        ,INSTRB(anc_id_93,'(]',1,4) -
10464         INSTRB(anc_id_93,'(]',1,3) - 2)
10465 ,SUBSTRB(anc_id_93
10466        ,INSTRB(anc_id_93,'(]',1,4) + 2
10467        ,INSTRB(anc_id_93,'(]',1,5) -
10468         INSTRB(anc_id_93,'(]',1,4) - 2)
10469 ,SUBSTRB(anc_id_93
10470        ,INSTRB(anc_id_93,'(]',1,5) + 2
10471        ,INSTRB(anc_id_93,'(]',1,6) -
10472         INSTRB(anc_id_93,'(]',1,5) - 2)
10473 ,SUBSTRB(anc_id_93
10474        ,INSTRB(anc_id_93,'(]',1,6) + 2
10475        ,INSTRB(anc_id_93,'(]',1,7) -
10476         INSTRB(anc_id_93,'(]',1,6) - 2)
10477 ,SUBSTRB(anc_id_93
10478        ,INSTRB(anc_id_93,'(]',1,7) + 2
10479        ,LENGTHB(anc_id_93))
10480 )
10481 
10482 WHEN anc_id_94 IS NOT NULL THEN
10483   INTO xla_ae_line_acs (
10484         ae_header_id , ae_line_num , object_version_number
10485       , analytical_criterion_code
10486       , analytical_criterion_type_code
10487       , amb_context_code
10488       , ac1,ac2,ac3,ac4,ac5)
10489 VALUES (ae_header_id, ae_line_num, C_OVN
10490 ,SUBSTRB(anc_id_94
10491        ,1
10492        ,INSTRB(anc_id_94,'(]',1,1) -1)
10493 ,SUBSTRB(anc_id_94
10494        ,INSTRB(anc_id_94,'(]',1,1) + 2
10495        ,INSTRB(anc_id_94,'(]',1,2) -
10496         INSTRB(anc_id_94,'(]',1,1) - 2)
10497 ,SUBSTRB(anc_id_94
10498        ,INSTRB(anc_id_94,'(]',1,2) + 2
10499        ,INSTRB(anc_id_94,'(]',1,3) -
10500         INSTRB(anc_id_94,'(]',1,2) - 2)
10501 ,SUBSTRB(anc_id_94
10502        ,INSTRB(anc_id_94,'(]',1,3) + 2
10503        ,INSTRB(anc_id_94,'(]',1,4) -
10504         INSTRB(anc_id_94,'(]',1,3) - 2)
10505 ,SUBSTRB(anc_id_94
10506        ,INSTRB(anc_id_94,'(]',1,4) + 2
10507        ,INSTRB(anc_id_94,'(]',1,5) -
10508         INSTRB(anc_id_94,'(]',1,4) - 2)
10509 ,SUBSTRB(anc_id_94
10510        ,INSTRB(anc_id_94,'(]',1,5) + 2
10511        ,INSTRB(anc_id_94,'(]',1,6) -
10512         INSTRB(anc_id_94,'(]',1,5) - 2)
10513 ,SUBSTRB(anc_id_94
10514        ,INSTRB(anc_id_94,'(]',1,6) + 2
10515        ,INSTRB(anc_id_94,'(]',1,7) -
10516         INSTRB(anc_id_94,'(]',1,6) - 2)
10517 ,SUBSTRB(anc_id_94
10518        ,INSTRB(anc_id_94,'(]',1,7) + 2
10519        ,LENGTHB(anc_id_94))
10520 )
10521 
10522 WHEN anc_id_95 IS NOT NULL THEN
10523   INTO xla_ae_line_acs (
10524         ae_header_id , ae_line_num , object_version_number
10525       , analytical_criterion_code
10526       , analytical_criterion_type_code
10527       , amb_context_code
10528       , ac1,ac2,ac3,ac4,ac5)
10529 VALUES (ae_header_id, ae_line_num, C_OVN
10530 ,SUBSTRB(anc_id_95
10531        ,1
10532        ,INSTRB(anc_id_95,'(]',1,1) -1)
10533 ,SUBSTRB(anc_id_95
10534        ,INSTRB(anc_id_95,'(]',1,1) + 2
10535        ,INSTRB(anc_id_95,'(]',1,2) -
10536         INSTRB(anc_id_95,'(]',1,1) - 2)
10537 ,SUBSTRB(anc_id_95
10538        ,INSTRB(anc_id_95,'(]',1,2) + 2
10539        ,INSTRB(anc_id_95,'(]',1,3) -
10540         INSTRB(anc_id_95,'(]',1,2) - 2)
10541 ,SUBSTRB(anc_id_95
10542        ,INSTRB(anc_id_95,'(]',1,3) + 2
10543        ,INSTRB(anc_id_95,'(]',1,4) -
10544         INSTRB(anc_id_95,'(]',1,3) - 2)
10545 ,SUBSTRB(anc_id_95
10546        ,INSTRB(anc_id_95,'(]',1,4) + 2
10547        ,INSTRB(anc_id_95,'(]',1,5) -
10548         INSTRB(anc_id_95,'(]',1,4) - 2)
10549 ,SUBSTRB(anc_id_95
10550        ,INSTRB(anc_id_95,'(]',1,5) + 2
10551        ,INSTRB(anc_id_95,'(]',1,6) -
10552         INSTRB(anc_id_95,'(]',1,5) - 2)
10553 ,SUBSTRB(anc_id_95
10554        ,INSTRB(anc_id_95,'(]',1,6) + 2
10555        ,INSTRB(anc_id_95,'(]',1,7) -
10556         INSTRB(anc_id_95,'(]',1,6) - 2)
10557 ,SUBSTRB(anc_id_95
10558        ,INSTRB(anc_id_95,'(]',1,7) + 2
10559        ,LENGTHB(anc_id_95))
10560 )
10561 
10562 WHEN anc_id_96 IS NOT NULL THEN
10563   INTO xla_ae_line_acs (
10564         ae_header_id , ae_line_num , object_version_number
10565       , analytical_criterion_code
10566       , analytical_criterion_type_code
10567       , amb_context_code
10568       , ac1,ac2,ac3,ac4,ac5)
10569 VALUES (ae_header_id, ae_line_num, C_OVN
10570 ,SUBSTRB(anc_id_96
10571        ,1
10572        ,INSTRB(anc_id_96,'(]',1,1) -1)
10573 ,SUBSTRB(anc_id_96
10574        ,INSTRB(anc_id_96,'(]',1,1) + 2
10575        ,INSTRB(anc_id_96,'(]',1,2) -
10576         INSTRB(anc_id_96,'(]',1,1) - 2)
10577 ,SUBSTRB(anc_id_96
10578        ,INSTRB(anc_id_96,'(]',1,2) + 2
10579        ,INSTRB(anc_id_96,'(]',1,3) -
10580         INSTRB(anc_id_96,'(]',1,2) - 2)
10581 ,SUBSTRB(anc_id_96
10582        ,INSTRB(anc_id_96,'(]',1,3) + 2
10583        ,INSTRB(anc_id_96,'(]',1,4) -
10584         INSTRB(anc_id_96,'(]',1,3) - 2)
10585 ,SUBSTRB(anc_id_96
10586        ,INSTRB(anc_id_96,'(]',1,4) + 2
10587        ,INSTRB(anc_id_96,'(]',1,5) -
10588         INSTRB(anc_id_96,'(]',1,4) - 2)
10589 ,SUBSTRB(anc_id_96
10590        ,INSTRB(anc_id_96,'(]',1,5) + 2
10591        ,INSTRB(anc_id_96,'(]',1,6) -
10592         INSTRB(anc_id_96,'(]',1,5) - 2)
10593 ,SUBSTRB(anc_id_96
10594        ,INSTRB(anc_id_96,'(]',1,6) + 2
10595        ,INSTRB(anc_id_96,'(]',1,7) -
10596         INSTRB(anc_id_96,'(]',1,6) - 2)
10597 ,SUBSTRB(anc_id_96
10598        ,INSTRB(anc_id_96,'(]',1,7) + 2
10599        ,LENGTHB(anc_id_96))
10600 )
10601 
10602 WHEN anc_id_97 IS NOT NULL THEN
10603   INTO xla_ae_line_acs (
10604         ae_header_id , ae_line_num , object_version_number
10605       , analytical_criterion_code
10606       , analytical_criterion_type_code
10607       , amb_context_code
10608       , ac1,ac2,ac3,ac4,ac5)
10609 VALUES (ae_header_id, ae_line_num, C_OVN
10610 ,SUBSTRB(anc_id_97
10611        ,1
10612        ,INSTRB(anc_id_97,'(]',1,1) -1)
10613 ,SUBSTRB(anc_id_97
10614        ,INSTRB(anc_id_97,'(]',1,1) + 2
10615        ,INSTRB(anc_id_97,'(]',1,2) -
10616         INSTRB(anc_id_97,'(]',1,1) - 2)
10617 ,SUBSTRB(anc_id_97
10618        ,INSTRB(anc_id_97,'(]',1,2) + 2
10619        ,INSTRB(anc_id_97,'(]',1,3) -
10620         INSTRB(anc_id_97,'(]',1,2) - 2)
10621 ,SUBSTRB(anc_id_97
10622        ,INSTRB(anc_id_97,'(]',1,3) + 2
10623        ,INSTRB(anc_id_97,'(]',1,4) -
10624         INSTRB(anc_id_97,'(]',1,3) - 2)
10625 ,SUBSTRB(anc_id_97
10626        ,INSTRB(anc_id_97,'(]',1,4) + 2
10627        ,INSTRB(anc_id_97,'(]',1,5) -
10628         INSTRB(anc_id_97,'(]',1,4) - 2)
10629 ,SUBSTRB(anc_id_97
10630        ,INSTRB(anc_id_97,'(]',1,5) + 2
10631        ,INSTRB(anc_id_97,'(]',1,6) -
10632         INSTRB(anc_id_97,'(]',1,5) - 2)
10633 ,SUBSTRB(anc_id_97
10634        ,INSTRB(anc_id_97,'(]',1,6) + 2
10635        ,INSTRB(anc_id_97,'(]',1,7) -
10636         INSTRB(anc_id_97,'(]',1,6) - 2)
10637 ,SUBSTRB(anc_id_97
10638        ,INSTRB(anc_id_97,'(]',1,7) + 2
10639        ,LENGTHB(anc_id_97))
10640 )
10641 
10642 WHEN anc_id_98 IS NOT NULL THEN
10643   INTO xla_ae_line_acs (
10644         ae_header_id , ae_line_num , object_version_number
10645       , analytical_criterion_code
10646       , analytical_criterion_type_code
10647       , amb_context_code
10648       , ac1,ac2,ac3,ac4,ac5)
10649 VALUES (ae_header_id, ae_line_num, C_OVN
10650 ,SUBSTRB(anc_id_98
10651        ,1
10652        ,INSTRB(anc_id_98,'(]',1,1) -1)
10653 ,SUBSTRB(anc_id_98
10654        ,INSTRB(anc_id_98,'(]',1,1) + 2
10655        ,INSTRB(anc_id_98,'(]',1,2) -
10656         INSTRB(anc_id_98,'(]',1,1) - 2)
10657 ,SUBSTRB(anc_id_98
10658        ,INSTRB(anc_id_98,'(]',1,2) + 2
10659        ,INSTRB(anc_id_98,'(]',1,3) -
10660         INSTRB(anc_id_98,'(]',1,2) - 2)
10661 ,SUBSTRB(anc_id_98
10662        ,INSTRB(anc_id_98,'(]',1,3) + 2
10663        ,INSTRB(anc_id_98,'(]',1,4) -
10664         INSTRB(anc_id_98,'(]',1,3) - 2)
10665 ,SUBSTRB(anc_id_98
10666        ,INSTRB(anc_id_98,'(]',1,4) + 2
10667        ,INSTRB(anc_id_98,'(]',1,5) -
10668         INSTRB(anc_id_98,'(]',1,4) - 2)
10669 ,SUBSTRB(anc_id_98
10670        ,INSTRB(anc_id_98,'(]',1,5) + 2
10671        ,INSTRB(anc_id_98,'(]',1,6) -
10672         INSTRB(anc_id_98,'(]',1,5) - 2)
10673 ,SUBSTRB(anc_id_98
10674        ,INSTRB(anc_id_98,'(]',1,6) + 2
10675        ,INSTRB(anc_id_98,'(]',1,7) -
10676         INSTRB(anc_id_98,'(]',1,6) - 2)
10677 ,SUBSTRB(anc_id_98
10678        ,INSTRB(anc_id_98,'(]',1,7) + 2
10679        ,LENGTHB(anc_id_98))
10680 )
10681 
10682 WHEN anc_id_99 IS NOT NULL THEN
10683   INTO xla_ae_line_acs (
10684         ae_header_id , ae_line_num , object_version_number
10685       , analytical_criterion_code
10686       , analytical_criterion_type_code
10687       , amb_context_code
10688       , ac1,ac2,ac3,ac4,ac5)
10689 VALUES (ae_header_id, ae_line_num, C_OVN
10690 ,SUBSTRB(anc_id_99
10691        ,1
10692        ,INSTRB(anc_id_99,'(]',1,1) -1)
10693 ,SUBSTRB(anc_id_99
10694        ,INSTRB(anc_id_99,'(]',1,1) + 2
10695        ,INSTRB(anc_id_99,'(]',1,2) -
10696         INSTRB(anc_id_99,'(]',1,1) - 2)
10697 ,SUBSTRB(anc_id_99
10698        ,INSTRB(anc_id_99,'(]',1,2) + 2
10699        ,INSTRB(anc_id_99,'(]',1,3) -
10700         INSTRB(anc_id_99,'(]',1,2) - 2)
10701 ,SUBSTRB(anc_id_99
10702        ,INSTRB(anc_id_99,'(]',1,3) + 2
10703        ,INSTRB(anc_id_99,'(]',1,4) -
10704         INSTRB(anc_id_99,'(]',1,3) - 2)
10705 ,SUBSTRB(anc_id_99
10706        ,INSTRB(anc_id_99,'(]',1,4) + 2
10707        ,INSTRB(anc_id_99,'(]',1,5) -
10708         INSTRB(anc_id_99,'(]',1,4) - 2)
10709 ,SUBSTRB(anc_id_99
10710        ,INSTRB(anc_id_99,'(]',1,5) + 2
10711        ,INSTRB(anc_id_99,'(]',1,6) -
10712         INSTRB(anc_id_99,'(]',1,5) - 2)
10713 ,SUBSTRB(anc_id_99
10714        ,INSTRB(anc_id_99,'(]',1,6) + 2
10715        ,INSTRB(anc_id_99,'(]',1,7) -
10716         INSTRB(anc_id_99,'(]',1,6) - 2)
10717 ,SUBSTRB(anc_id_99
10718        ,INSTRB(anc_id_99,'(]',1,7) + 2
10719        ,LENGTHB(anc_id_99))
10720 )
10721 
10722 WHEN anc_id_100 IS NOT NULL THEN
10723   INTO xla_ae_line_acs (
10724         ae_header_id , ae_line_num , object_version_number
10725       , analytical_criterion_code
10726       , analytical_criterion_type_code
10727       , amb_context_code
10728       , ac1,ac2,ac3,ac4,ac5)
10729 VALUES (ae_header_id, ae_line_num, C_OVN
10730 ,SUBSTRB(anc_id_100
10731        ,1
10732        ,INSTRB(anc_id_100,'(]',1,1) -1)
10733 ,SUBSTRB(anc_id_100
10734        ,INSTRB(anc_id_100,'(]',1,1) + 2
10735        ,INSTRB(anc_id_100,'(]',1,2) -
10736         INSTRB(anc_id_100,'(]',1,1) - 2)
10737 ,SUBSTRB(anc_id_100
10738        ,INSTRB(anc_id_100,'(]',1,2) + 2
10739        ,INSTRB(anc_id_100,'(]',1,3) -
10740         INSTRB(anc_id_100,'(]',1,2) - 2)
10741 ,SUBSTRB(anc_id_100
10742        ,INSTRB(anc_id_100,'(]',1,3) + 2
10743        ,INSTRB(anc_id_100,'(]',1,4) -
10744         INSTRB(anc_id_100,'(]',1,3) - 2)
10745 ,SUBSTRB(anc_id_100
10746        ,INSTRB(anc_id_100,'(]',1,4) + 2
10747        ,INSTRB(anc_id_100,'(]',1,5) -
10748         INSTRB(anc_id_100,'(]',1,4) - 2)
10749 ,SUBSTRB(anc_id_100
10750        ,INSTRB(anc_id_100,'(]',1,5) + 2
10751        ,INSTRB(anc_id_100,'(]',1,6) -
10752         INSTRB(anc_id_100,'(]',1,5) - 2)
10753 ,SUBSTRB(anc_id_100
10754        ,INSTRB(anc_id_100,'(]',1,6) + 2
10755        ,INSTRB(anc_id_100,'(]',1,7) -
10756         INSTRB(anc_id_100,'(]',1,6) - 2)
10757 ,SUBSTRB(anc_id_100
10758        ,INSTRB(anc_id_100,'(]',1,7) + 2
10759        ,LENGTHB(anc_id_100))
10760 )
10761 
10762 
10763 SELECT  ae_header_id
10764       , ae_line_num
10765       , anc_id_1
10766       , anc_id_2
10767       , anc_id_3
10768       , anc_id_4
10769       , anc_id_5
10770       , anc_id_6
10771       , anc_id_7
10772       , anc_id_8
10773       , anc_id_9
10774       , anc_id_10
10775       , anc_id_11
10776       , anc_id_12
10777       , anc_id_13
10778       , anc_id_14
10779       , anc_id_15
10780       , anc_id_16
10781       , anc_id_17
10782       , anc_id_18
10783       , anc_id_19
10784       , anc_id_20
10785       , anc_id_21
10786       , anc_id_22
10787       , anc_id_23
10788       , anc_id_24
10789       , anc_id_25
10790       , anc_id_26
10791       , anc_id_27
10792       , anc_id_28
10793       , anc_id_29
10794       , anc_id_30
10795       , anc_id_31
10796       , anc_id_32
10797       , anc_id_33
10798       , anc_id_34
10799       , anc_id_35
10800       , anc_id_36
10801       , anc_id_37
10802       , anc_id_38
10803       , anc_id_39
10804       , anc_id_40
10805       , anc_id_41
10806       , anc_id_42
10807       , anc_id_43
10808       , anc_id_44
10809       , anc_id_45
10810       , anc_id_46
10811       , anc_id_47
10812       , anc_id_48
10813       , anc_id_49
10814       , anc_id_50
10815       , anc_id_51
10816       , anc_id_52
10817       , anc_id_53
10818       , anc_id_54
10819       , anc_id_55
10820       , anc_id_56
10821       , anc_id_57
10822       , anc_id_58
10823       , anc_id_59
10824       , anc_id_60
10825       , anc_id_61
10826       , anc_id_62
10827       , anc_id_63
10828       , anc_id_64
10829       , anc_id_65
10830       , anc_id_66
10831       , anc_id_67
10832       , anc_id_68
10833       , anc_id_69
10834       , anc_id_70
10835       , anc_id_71
10836       , anc_id_72
10837       , anc_id_73
10838       , anc_id_74
10839       , anc_id_75
10840       , anc_id_76
10841       , anc_id_77
10842       , anc_id_78
10843       , anc_id_79
10844       , anc_id_80
10845       , anc_id_81
10846       , anc_id_82
10847       , anc_id_83
10848       , anc_id_84
10849       , anc_id_85
10850       , anc_id_86
10851       , anc_id_87
10852       , anc_id_88
10853       , anc_id_89
10854       , anc_id_90
10855       , anc_id_91
10856       , anc_id_92
10857       , anc_id_93
10858       , anc_id_94
10859       , anc_id_95
10860       , anc_id_96
10861       , anc_id_97
10862       , anc_id_98
10863       , anc_id_99
10864       , anc_id_100
10865  FROM  xla_ae_lines_gt
10866 WHERE  ae_line_num is not null
10867 GROUP  BY
10868        ae_line_num
10869       ,ae_header_id
10870       ,anc_id_1
10871       ,anc_id_2
10872       ,anc_id_3
10873       ,anc_id_4
10874       ,anc_id_5
10875       ,anc_id_6
10876       ,anc_id_7
10877       ,anc_id_8
10878       ,anc_id_9
10879       ,anc_id_10
10880       ,anc_id_11
10881       ,anc_id_12
10882       ,anc_id_13
10883       ,anc_id_14
10884       ,anc_id_15
10885       ,anc_id_16
10886       ,anc_id_17
10887       ,anc_id_18
10888       ,anc_id_19
10889       ,anc_id_20
10890       ,anc_id_21
10891       ,anc_id_22
10892       ,anc_id_23
10893       ,anc_id_24
10894       ,anc_id_25
10895       ,anc_id_26
10896       ,anc_id_27
10897       ,anc_id_28
10898       ,anc_id_29
10899       ,anc_id_30
10900       ,anc_id_31
10901       ,anc_id_32
10902       ,anc_id_33
10903       ,anc_id_34
10904       ,anc_id_35
10905       ,anc_id_36
10906       ,anc_id_37
10907       ,anc_id_38
10908       ,anc_id_39
10909       ,anc_id_40
10910       ,anc_id_41
10911       ,anc_id_42
10912       ,anc_id_43
10913       ,anc_id_44
10914       ,anc_id_45
10915       ,anc_id_46
10916       ,anc_id_47
10917       ,anc_id_48
10918       ,anc_id_49
10919       ,anc_id_50
10920       ,anc_id_51
10921       ,anc_id_52
10922       ,anc_id_53
10923       ,anc_id_54
10924       ,anc_id_55
10925       ,anc_id_56
10926       ,anc_id_57
10927       ,anc_id_58
10928       ,anc_id_59
10929       ,anc_id_60
10930       ,anc_id_61
10931       ,anc_id_62
10932       ,anc_id_63
10933       ,anc_id_64
10934       ,anc_id_65
10935       ,anc_id_66
10936       ,anc_id_67
10937       ,anc_id_68
10938       ,anc_id_69
10939       ,anc_id_70
10940       ,anc_id_71
10941       ,anc_id_72
10942       ,anc_id_73
10943       ,anc_id_74
10944       ,anc_id_75
10945       ,anc_id_76
10946       ,anc_id_77
10947       ,anc_id_78
10948       ,anc_id_79
10949       ,anc_id_80
10950       ,anc_id_81
10951       ,anc_id_82
10952       ,anc_id_83
10953       ,anc_id_84
10954       ,anc_id_85
10955       ,anc_id_86
10956       ,anc_id_87
10957       ,anc_id_88
10958       ,anc_id_89
10959       ,anc_id_90
10960       ,anc_id_91
10961       ,anc_id_92
10962       ,anc_id_93
10963       ,anc_id_94
10964       ,anc_id_95
10965       ,anc_id_96
10966       ,anc_id_97
10967       ,anc_id_98
10968       ,anc_id_99
10969       ,anc_id_100;
10970 
10971    --
10972    l_rowcount := SQL%ROWCOUNT;
10973 
10974    IF (C_LEVEL_EVENT >= g_log_level) THEN
10975       trace
10976          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
10977          ,p_level    => C_LEVEL_EVENT
10978          ,p_module   => l_log_module);
10979    END IF;
10980 
10981    EXCEPTION
10982    WHEN OTHERS  THEN
10983 
10984      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10985           trace
10986               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
10987               ,p_level    => C_LEVEL_EXCEPTION
10988               ,p_module   => l_log_module);
10989      END IF;
10990 
10991      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
10992                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
10993                                       ,p_token_1      => 'ERROR'
10994                                       ,p_value_1      => sqlerrm
10995                                       );
10996 
10997 
10998    END;
10999 
11000 EXCEPTION
11001 WHEN xla_exceptions_pkg.application_exception THEN
11002   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11003        trace
11004            (p_msg      => 'Error. = '||sqlerrm
11005            ,p_level    => C_LEVEL_PROCEDURE
11006            ,p_module   => l_log_module);
11007   END IF;
11008   RAISE;
11009 WHEN OTHERS  THEN
11010   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11011        trace
11012            (p_msg      => 'Error. = '||sqlerrm
11013            ,p_level    => C_LEVEL_PROCEDURE
11014            ,p_module   => l_log_module);
11015   END IF;
11016   xla_exceptions_pkg.raise_message
11017        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria100');
11018 END InsertAnalyticalCriteria100;
11019 --
11020 /*======================================================================+
11021 |                                                                       |
11022 | 4669308  - Adjust Final MPA Line                                      |
11023 |                                                                       |
11024 | This is to back calculate the rounded amounts on the final period of  |
11025 | MPA reversal lines.  It should only be necessary if all recogniton    |
11026 | periods are reversed.                                                 |
11027 |                                                                       |
11028 +======================================================================*/
11029 --
11030 PROCEDURE AdjustMpaLine(p_application_id  IN INTEGER)
11031 IS
11032 l_log_module         VARCHAR2(240);
11033 l_count number;
11034 
11035 CURSOR cur_mpa_lines IS
11036 SELECT parent_header_id
11037       ,parent_ae_line_num
11038       ,MIN(ae_header_id)
11039       ,MAX(ae_header_id)
11040       ,MAX(accounting_date)  --added for bug#10242870
11041 FROM   xla_ae_headers_gt
11042 WHERE  parent_header_id IS NOT NULL
11043 AND    parent_ae_line_num  IS NOT NULL
11044 AND    balance_type_code = 'A' -- added for bug:7377888
11045 AND    NVL(accrual_reversal_flag,'N') = 'N'
11046 GROUP BY parent_header_id, parent_ae_line_num
11047 HAVING COUNT(*) > 1;
11048 
11049 l_array_parent_hdr_idx      t_array_Num;
11050 l_array_parent_line_idx     t_array_Num;
11051 l_array_min_hdr_idx         t_array_Num;
11052 l_array_max_hdr_idx         t_array_Num;
11053 
11054 l_array_entered_amt         t_array_Num;
11055 l_array_accted_amt          t_array_Num;
11056 l_array_unround_entered_amt t_array_Num;
11057 l_array_unround_accted_amt  t_array_Num;
11058 
11059 l_array_mpa_header_idx      t_array_Num;  -- 5017009
11060 l_array_mpa_line_idx        t_array_Num;  -- 5017009
11061 
11062 l_array_max_act_date        t_array_Date;  --added for bug#10242870
11063 l_max_amount                NUMBER;        --added for bug#10242870
11064 l_max_hdr_id                NUMBER;        --added for bug#10242870
11065 
11066 --added for bug10394715
11067 l_array_parent_line_side         t_array_V1L ;
11068 l_array_recog_line_num           t_array_Num;
11069 C_CR_SIDE VARCHAR2(1):= 'C' ;
11070 C_DR_SIDE VARCHAR2(1):= 'D' ;
11071 
11072 BEGIN
11073 --
11074 IF g_log_enabled THEN
11075       l_log_module := C_DEFAULT_MODULE||'.AdjustMpaLine';
11076 END IF;
11077 --
11078 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11079 
11080       trace
11081          (p_msg      => 'BEGIN of AdjustMpaLine'
11082          ,p_level    => C_LEVEL_PROCEDURE
11083          ,p_module   => l_log_module);
11084 
11085 END IF;
11086 
11087    ------------------------------------------------------------
11088    -- Find the MPA lines
11089    ------------------------------------------------------------
11090    OPEN  cur_mpa_lines;
11091    FETCH cur_mpa_lines BULK COLLECT INTO l_array_parent_hdr_idx,l_array_parent_line_idx,l_array_min_hdr_idx,l_array_max_hdr_idx,l_array_max_act_date;
11092    CLOSE cur_mpa_lines;
11093    -- accounting date added for bug10242870
11094 
11095    ------------------------------------------------------------
11096    -- Find the original amounts
11097    ------------------------------------------------------------
11098    FOR i IN 1..l_array_parent_hdr_idx.COUNT LOOP
11099      /* Excluding the join with XLA_DISTRIBUTION_LINKS bug:7230462 */
11100     -- SELECT NVL(l.entered_cr, l.entered_dr)
11101     --        ,NVL(l.accounted_cr, l.accounted_dr)
11102     --        ,NVL(l.unrounded_entered_cr, l.unrounded_entered_dr)
11103     --        ,NVL(l.unrounded_accounted_cr, l.unrounded_accounted_dr)
11104     --  INTO   l_array_entered_amt(i)
11105     --        ,l_array_accted_amt(i)
11106     --        ,l_array_unround_entered_amt(i)
11107     --        ,l_array_unround_accted_amt(i)
11108     --  FROM   xla_ae_lines l,
11109     --         xla_distribution_links d                     -- added for bug 7377888
11110     --  /*WHERE  ae_header_id   = l_array_parent_hdr_idx(i)
11111     --  AND    ae_line_num    = l_array_parent_line_idx(i)
11112     --  AND    application_id = p_application_id;*/         -- commented for bug 7377888
11113     --  WHERE  l.ae_header_id   = d.ae_header_id
11114     --  AND    l.ae_line_num    = d.ae_line_num
11115     --  AND    l.application_id = p_application_id
11116     --  AND    d.application_id = p_application_id
11117     --  AND    d.ae_header_id = l_array_parent_hdr_idx(i)
11118     --  AND    d.temp_line_num = l_array_parent_line_idx(i); -- added new WHERE Clause for bug 7377888
11119 
11120     /* Changes for the bug:7230462 */
11121     SELECT NVL(l.entered_cr, l.entered_dr)
11122            ,NVL(l.accounted_cr, l.accounted_dr)
11123            ,NVL(l.unrounded_entered_cr, l.unrounded_entered_dr)
11124            ,NVL(l.unrounded_accounted_cr, l.unrounded_accounted_dr)
11125 	   ,NVL2(l.entered_cr , C_CR_SIDE , C_DR_SIDE ) -- added for bug 10394715
11126      INTO  l_array_entered_amt(i)
11127            ,l_array_accted_amt(i)
11128            ,l_array_unround_entered_amt(i)
11129            ,l_array_unround_accted_amt(i)
11130 	   ,l_array_parent_line_side(i) -- added for bug 10394715
11131     FROM   xla_ae_lines l
11132     WHERE  l.ae_header_id   = l_array_parent_hdr_idx(i)
11133     AND    l.ae_line_num    = l_array_parent_line_idx(i)
11134     AND    l.application_id = p_application_id ;
11135 
11136     --added for bug#10242870
11137     l_max_hdr_id := NULL ;
11138     l_max_amount := NULL ;
11139     BEGIN
11140 
11141       SELECT /*+ leading(aeh) */ MAX(ABS(NVL(xal2.entered_cr,xal2.entered_dr)))
11142       INTO l_max_amount
11143       FROM   xla_ae_lines xal2
11144           , ( SELECT xah.ae_header_id
11145       	      FROM xla_ae_headers_gt xah
11146       	      WHERE xah.parent_header_id = l_array_parent_hdr_idx(i)
11147       	      AND   xah.parent_ae_line_num = l_array_parent_line_idx(i)
11148       	      AND   xah.accounting_date    = l_array_max_act_date(i)
11149               AND   xah.parent_header_id IS NOT NULL
11150               AND   xah.parent_ae_line_num IS NOT NULL
11151     	      )   aeh
11152        WHERE xal2.application_id = p_application_id
11153          AND   xal2.ae_header_id = aeh.ae_header_id ;
11154 
11155 
11156     	WITH aeh AS
11157 	    ( SELECT xah.ae_header_id
11158       	      FROM xla_ae_headers_gt xah
11159       	      WHERE xah.parent_header_id = l_array_parent_hdr_idx(i)
11160       	      AND   xah.parent_ae_line_num = l_array_parent_line_idx(i)
11161       	      AND   xah.accounting_date    = l_array_max_act_date(i)
11162               AND   xah.parent_header_id IS NOT NULL
11163               AND   xah.parent_ae_line_num IS NOT NULL
11164     	    )
11165     	SELECT MAX(xal.ae_header_id)
11166     	INTO l_max_hdr_id
11167     	FROM   XLA_AE_LINES xal
11168              , aeh
11169     	WHERE  xal.ae_header_id = aeh.ae_header_id
11170         AND    xal.application_id = p_application_id
11171     	AND    ABS(NVL(xal.entered_cr,xal.entered_dr))  = l_max_amount ;
11172 
11173 
11174    EXCEPTION
11175    WHEN NO_DATA_FOUND THEN
11176        l_max_hdr_id := NULL ;
11177    END ;
11178 
11179    l_array_max_hdr_idx(i) := NVL(l_max_hdr_id,l_array_max_hdr_idx(i) );
11180 
11181 
11182    END LOOP;
11183 
11184    -----------------------------------------------------------------------------------------------------------
11185    -- 5017009 - Update the unrounded amounts with the rounded amounts for each line except the last MPA entry
11186    -----------------------------------------------------------------------------------------------------------
11187    FOR i in 1..l_array_parent_hdr_idx.COUNT LOOP
11188 
11189        SELECT xel2.ae_header_id
11190              ,xel2.ae_line_num
11191        BULK COLLECT INTO
11192               l_array_mpa_header_idx
11193              ,l_array_mpa_line_idx
11194        FROM   xla_ae_lines   xel2
11195              --,xla_ae_headers xeh
11196 	     ,xla_ae_headers_gt xeh -- added for bug#16446642
11197        WHERE  xel2.ae_header_id       = xeh.ae_header_id
11198        AND    xel2.application_id     = p_application_id
11199        AND    xel2.ae_header_id      <> l_array_max_hdr_idx(i)
11200        --AND    xeh.application_id      = p_application_id ----  bug#16446642
11201        -- START FIX ... Bug 14246749
11202        AND xeh.parent_ae_line_num = l_array_parent_line_idx(i)
11203        -- END FIX Bug 14246749
11204        AND    xeh.parent_header_id = l_array_parent_hdr_idx(i);
11205 
11206        IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11207           trace
11208                 (p_msg      => 'MPA count='||l_array_mpa_header_idx.COUNT
11209                 ,p_level    => C_LEVEL_STATEMENT
11210                 ,p_module   => l_log_module);
11211           FOR j IN 1..l_array_mpa_header_idx.COUNT LOOP
11212              trace
11213                 (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||' parent_line='||l_array_parent_line_idx(i)||
11214                                ' mpa_header='||l_array_mpa_header_idx(j)||
11215                                ' line='||l_array_mpa_line_idx(j)
11216                 ,p_level    => C_LEVEL_STATEMENT
11217                 ,p_module   => l_log_module);
11218           END LOOP;
11219        END IF;
11220 
11221        FORALL j IN 1..l_array_mpa_header_idx.COUNT
11222           UPDATE xla_ae_lines xel
11223           SET    unrounded_entered_cr   = entered_cr
11224                 ,unrounded_entered_dr   = entered_dr
11225                 ,unrounded_accounted_cr = accounted_cr
11226                 ,unrounded_accounted_dr = accounted_dr
11227           WHERE application_id = p_application_id
11228           AND   ae_header_id   = l_array_mpa_header_idx(j)
11229           AND   ae_line_num    = l_array_mpa_line_idx(j);
11230 
11231        FORALL j IN 1..l_array_mpa_header_idx.COUNT
11232    -- Begin Bug 14246749
11233    --       UPDATE xla_distribution_links xdl
11234    --     SET   (unrounded_entered_cr
11235    --           ,unrounded_entered_dr
11236    --           ,unrounded_accounted_cr
11237    --           ,unrounded_accounted_dr) =
11238    --           (SELECT unrounded_entered_cr
11239    --                  ,unrounded_entered_dr
11240    --                  ,unrounded_accounted_cr
11241    --                  ,unrounded_accounted_dr
11242    --            FROM  xla_ae_lines   xel2
11243    --            WHERE xel2.ae_header_id = xdl.ae_header_id
11244    --            AND   xel2.ae_line_num  = xdl.ae_line_num)
11245    --     WHERE application_id = p_application_id  -- 4585874
11246    --     AND   ae_header_id = l_array_mpa_header_idx(j)
11247    --     AND   ae_line_num  = l_array_mpa_line_idx(j);
11248    --
11249 
11250        merge into xla_distribution_links xdl
11251        using (SELECT unrounded_entered_cr
11252                                ,unrounded_entered_dr
11253                                ,unrounded_accounted_cr
11254                                ,unrounded_accounted_dr
11255                                , ae_header_id,  ae_line_num ,
11256                                application_id
11257                          FROM  xla_ae_lines   xel2
11258                          WHERE xel2.application_id = p_application_id
11259                          AND   xel2.ae_header_id = l_array_mpa_header_idx(j)
11260                          AND   xel2.ae_line_num  = l_array_mpa_line_idx(j) )   xel2
11261        on ( xel2.ae_header_id = xdl.ae_header_id
11262             AND   xel2.ae_line_num  = xdl.ae_line_num
11263             AND XEL2.application_id = xDL.application_id )
11264        when MATCHED THEN UPDATE SET
11265                      Xdl.unrounded_entered_cr  = XEL2.unrounded_entered_cr
11266                         ,xdl.unrounded_entered_dr  = XEL2.unrounded_entered_dr
11267                         ,xdl.unrounded_accounted_cr  = XEL2.unrounded_accounted_cr
11268                         ,xdl.unrounded_accounted_dr = XEL2.unrounded_accounted_dr;
11269      -- End Bug 14246749
11270 
11271 
11272    END LOOP;
11273    --------------------------------------------------------------------------------------------
11274    -- added for bug#10394715
11275    FOR i IN 1..l_array_max_hdr_idx.COUNT
11276    LOOP
11277       -- Recognition JLT is the only JLT that would NOT BE available in the
11278       -- Parent accounting XDL,hence, MPA Accounting would be on the same SIDE of
11279       -- the Parent Accounting.
11280        SELECT xdlmp.ae_line_num
11281        INTO   l_array_recog_line_num(i)
11282        FROM  xla_distribution_links xdlmp
11283        WHERE xdlmp.application_id = p_application_id
11284        AND   xdlmp.ae_header_id = l_array_max_hdr_idx(i)
11285        AND   NOT EXISTS
11286             ( SELECT 1
11287               FROM xla_distribution_links xdlp
11288               WHERE xdlp.application_id = p_application_id
11289               AND   xdlp.ae_header_id   = l_array_parent_hdr_idx(i)
11290               AND   xdlp.ae_line_num    = l_array_parent_line_idx(i)
11291               AND   xdlp.accounting_line_code = xdlmp.accounting_line_code
11292               AND   xdlp.accounting_line_type_code = xdlmp.accounting_line_type_code
11293              ) ;
11294    END LOOP ;
11295 
11296    ------------------------------------------------------------
11297    -- Update the AMOUNTs for the last MPA line amount
11298    ------------------------------------------------------------
11299    /* commented for bug#10394715
11300    FORALL i IN 1..l_array_parent_hdr_idx.COUNT
11301       UPDATE xla_ae_lines xel
11302       SET   (entered_cr
11303             ,entered_dr
11304             ,accounted_cr
11305             ,accounted_dr
11306             ,unrounded_entered_cr
11307             ,unrounded_entered_dr
11308             ,unrounded_accounted_cr
11309             ,unrounded_accounted_dr) =
11310             (SELECT DECODE(MIN(entered_cr),             NULL,NULL, l_array_entered_amt(i)         - SUM(entered_cr))
11311                    ,DECODE(MIN(entered_dr),             NULL,NULL, l_array_entered_amt(i)         - SUM(entered_dr))
11312                    ,DECODE(MIN(accounted_cr),           NULL,NULL, l_array_accted_amt(i)          - SUM(accounted_cr))
11313                    ,DECODE(MIN(accounted_dr),           NULL,NULL, l_array_accted_amt(i)          - SUM(accounted_dr))
11314                    ,DECODE(MIN(unrounded_entered_cr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(unrounded_entered_cr))
11315                    ,DECODE(MIN(unrounded_entered_dr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(unrounded_entered_dr))
11316                    ,DECODE(MIN(unrounded_accounted_cr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(unrounded_accounted_cr))
11317                    ,DECODE(MIN(unrounded_accounted_dr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(unrounded_accounted_dr))
11318              FROM  xla_ae_lines   xel2
11319                   ,xla_ae_headers xeh
11320              WHERE xel2.ae_header_id       = xeh.ae_header_id
11321              AND   xel2.ae_line_num        = xel.ae_line_num
11322              AND   xel2.application_id     = p_application_id  -- 4585874
11323              AND   xel2.ae_header_id      <> l_array_max_hdr_idx(i)
11324              AND   xeh.application_id      = p_application_id  -- 4585874
11325              AND   xeh.parent_ae_header_id = l_array_parent_hdr_idx(i)
11326              AND   xeh.parent_ae_line_num  = l_array_parent_line_idx(i))
11327       WHERE ae_header_id   = l_array_max_hdr_idx(i)
11328       AND   application_id = p_application_id;
11329    */
11330    -- added for bug#10394715
11331    FORALL i IN 1..l_array_parent_hdr_idx.COUNT
11332    UPDATE xla_ae_lines xel
11333       SET   (xel.entered_cr
11334             ,xel.entered_dr
11335             ,xel.accounted_cr
11336             ,xel.accounted_dr
11337             ,xel.unrounded_entered_cr
11338             ,xel.unrounded_entered_dr
11339             ,xel.unrounded_accounted_cr
11340             ,xel.unrounded_accounted_dr) =
11341             (SELECT CASE
11342                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11343                         CASE l_array_parent_line_side(i)
11344                              WHEN C_CR_SIDE THEN
11345                                   l_array_entered_amt(i)         - SUM(NVL(xel2.entered_cr,0) - NVL(xel2.entered_dr,0) )
11346                              ELSE NULL
11347                         END
11348                     ELSE
11349                         CASE l_array_parent_line_side(i)
11350                             WHEN C_CR_SIDE THEN
11351                                   NULL
11352                              ELSE l_array_entered_amt(i)         - SUM(NVL(xel2.entered_cr,0) - NVL(xel2.entered_dr,0) )
11353                         END
11354                     END   ENTERED_CR ,
11355                     CASE
11356                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11357                          CASE l_array_parent_line_side(i)
11358                               WHEN C_DR_SIDE THEN
11359                                    l_array_entered_amt(i)         - SUM(NVL(xel2.entered_dr,0) - NVL(xel2.entered_cr,0) )
11360                               ELSE NULL
11361                          END
11362                     ELSE
11363                          CASE l_array_parent_line_side(i)
11364                               WHEN C_DR_SIDE THEN
11365                                    NULL
11366                               ELSE l_array_entered_amt(i)         - SUM(NVL(xel2.entered_dr,0) - NVL(xel2.entered_cr,0) )
11367                          END
11368                     END  ENTERED_DR ,
11369                     CASE
11370                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11371                          CASE l_array_parent_line_side(i)
11372                              WHEN C_CR_SIDE THEN
11373                                   l_array_accted_amt(i)         - SUM(NVL(xel2.accounted_cr,0) - NVL(xel2.accounted_dr,0) )
11374                              ELSE NULL
11375                          END
11376                     ELSE
11377                          CASE l_array_parent_line_side(i)
11378                              WHEN C_CR_SIDE THEN
11379                                   NULL
11380                              ELSE l_array_accted_amt(i)         - SUM(NVL(xel2.accounted_cr,0) - NVL(xel2.accounted_dr,0) )
11381                          END
11382                     END  ACCOUNTED_CR  ,
11383                     CASE
11384                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11385                          CASE l_array_parent_line_side(i)
11386                               WHEN C_DR_SIDE THEN
11387                                    l_array_accted_amt(i)         - SUM(NVL(xel2.accounted_dr,0) - NVL(xel2.accounted_cr,0) )
11388                               ELSE NULL
11389                          END
11390                     ELSE
11391                          CASE l_array_parent_line_side(i)
11392                               WHEN C_DR_SIDE THEN
11393                                    NULL
11394                               ELSE l_array_accted_amt(i)         - SUM(NVL(xel2.accounted_dr,0) - NVL(xel2.accounted_cr,0) )
11395                          END
11396                     END   ACCOUNTED_DR ,
11397                     CASE
11398                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11399                          CASE l_array_parent_line_side(i)
11400                               WHEN C_CR_SIDE THEN
11401                                    l_array_unround_entered_amt(i)  - SUM(NVL(xel2.unrounded_entered_cr,0) - NVL(xel2.unrounded_entered_dr,0) )
11402                               ELSE NULL
11403                          END
11404                     ELSE
11405                          CASE l_array_parent_line_side(i)
11406                               WHEN C_CR_SIDE THEN
11407                                    NULL
11408                               ELSE l_array_unround_entered_amt(i)  - SUM(NVL(xel2.unrounded_entered_cr,0) - NVL(xel2.unrounded_entered_dr,0) )
11409                          END
11410                     END  UNROUNDED_ENTERED_CR  ,
11411 
11412                     CASE
11413                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11414                          CASE l_array_parent_line_side(i)
11415                               WHEN C_DR_SIDE THEN
11416                                    l_array_unround_entered_amt(i)  - SUM(NVL(xel2.unrounded_entered_dr,0) - NVL(xel2.unrounded_entered_cr,0) )
11417                               ELSE NULL
11418                          END
11419                     ELSE
11420                          CASE l_array_parent_line_side(i)
11421                               WHEN C_DR_SIDE THEN
11422                                    NULL
11423                               ELSE l_array_unround_entered_amt(i)  - SUM(NVL(xel2.unrounded_entered_dr,0) - NVL(xel2.unrounded_entered_cr,0) )
11424                          END
11425                     END   UNROUNDED_ENTERED_DR ,
11426 
11427                     CASE
11428                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11429                          CASE l_array_parent_line_side(i)
11430                               WHEN C_CR_SIDE THEN
11431                                    l_array_unround_accted_amt(i)   - SUM(NVL(xel2.unrounded_accounted_cr,0) - NVL(xel2.unrounded_accounted_dr,0) )
11432                               ELSE NULL
11433                          END
11434                     ELSE
11435                          CASE l_array_parent_line_side(i)
11436                               WHEN C_CR_SIDE THEN
11437                                    NULL
11438                               ELSE l_array_unround_accted_amt(i)   - SUM(NVL(xel2.unrounded_accounted_cr,0) - NVL(xel2.unrounded_accounted_dr,0) )
11439                          END
11440                     END   UNROUNDED_ACCOUNTED_CR ,
11441 
11442                     CASE
11443                     WHEN xel.ae_line_num = l_array_recog_line_num(i) THEN
11444                          CASE l_array_parent_line_side(i)
11445                               WHEN C_DR_SIDE THEN
11446                                    l_array_unround_accted_amt(i)   - SUM(NVL(xel2.unrounded_accounted_dr,0) - NVL(xel2.unrounded_accounted_cr,0) )
11447                               ELSE NULL
11448                          END
11449                     ELSE
11450                          CASE l_array_parent_line_side(i)
11451                               WHEN C_DR_SIDE THEN
11452                                    NULL
11453                               ELSE l_array_unround_accted_amt(i)   - SUM(NVL(xel2.unrounded_accounted_dr,0) - NVL(xel2.unrounded_accounted_cr,0) )
11454                          END
11455                     END  UNROUNDED_ACCOUNTED_DR
11456              FROM  xla_ae_lines   xel2
11457                   --,xla_ae_headers xeh
11458 		  ,xla_ae_headers_gt xeh -- added for bug#16446642
11459              WHERE xel2.ae_header_id       = xeh.ae_header_id
11460              AND   xel2.ae_line_num        = xel.ae_line_num
11461              AND   xel2.application_id     = p_application_id  -- 4585874
11462              AND   xel2.ae_header_id      <> l_array_max_hdr_idx(i)
11463              --AND   xeh.application_id      = p_application_id  -- 4585874 --bug 16446642
11464              AND   xeh.parent_header_id = l_array_parent_hdr_idx(i)
11465              AND   xeh.parent_ae_line_num  = l_array_parent_line_idx(i))
11466       WHERE xel.ae_header_id   = l_array_max_hdr_idx(i)
11467       AND   xel.application_id = p_application_id ;
11468 
11469    --------------------------------------------------------------------------------------------
11470    -- Update the DOC_ROUNDING values for the corresponding MPA line
11471    --------------------------------------------------------------------------------------------
11472    FORALL i IN 1..l_array_parent_hdr_idx.COUNT
11473       UPDATE xla_distribution_links xdl
11474       SET   (doc_rounding_acctd_amt
11475             ,doc_rounding_entered_amt
11476             ,unrounded_entered_cr       -- 4669308
11477             ,unrounded_entered_dr       -- 4669308
11478             ,unrounded_accounted_cr     -- 4669308
11479             ,unrounded_accounted_dr     -- 4669308
11480             ) =
11481             (SELECT DECODE(unrounded_accounted_cr,NULL,DECODE(unrounded_accounted_dr - accounted_dr,0,NULL,
11482                                                               unrounded_accounted_dr - accounted_dr)
11483                                                       ,DECODE(unrounded_accounted_cr - accounted_cr,0,NULL,
11484                                                               unrounded_accounted_cr - accounted_cr))
11485                    ,DECODE(unrounded_entered_cr,  NULL,DECODE(unrounded_entered_dr   - entered_dr,0,NULL,
11486                                                               unrounded_entered_dr   - entered_dr)
11487                                                       ,DECODE(unrounded_entered_cr   - entered_cr,0,NULL,
11488                                                               unrounded_entered_cr   - entered_cr))
11489                    ,unrounded_entered_cr
11490                    ,unrounded_entered_dr
11491                    ,unrounded_accounted_cr
11492                    ,unrounded_accounted_dr
11493              FROM  xla_ae_lines   xel2
11494              WHERE xel2.ae_header_id = xdl.ae_header_id
11495              AND   xel2.ae_line_num  = xdl.ae_line_num)
11496       WHERE application_id = p_application_id  -- 4585874
11497       AND   ae_header_id = l_array_max_hdr_idx(i);
11498 
11499 EXCEPTION
11500 WHEN xla_exceptions_pkg.application_exception THEN
11501   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11502        trace
11503            (p_msg      => 'Error. = '||sqlerrm
11504            ,p_level    => C_LEVEL_PROCEDURE
11505            ,p_module   => l_log_module);
11506   END IF;
11507   RAISE;
11508 WHEN OTHERS  THEN
11509   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11510        trace
11511            (p_msg      => 'Error. = '||sqlerrm
11512            ,p_level    => C_LEVEL_PROCEDURE
11513            ,p_module   => l_log_module);
11514   END IF;
11515   xla_exceptions_pkg.raise_message
11516                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.AdjustMpaLine');
11517 END AdjustMpaLine;
11518 --
11519 
11520 /*======================================================================+
11521 |                                                                       |
11522 | 4669308 - Adjust Final MPA Reversal Line                              |
11523 |                                                                       |
11524 +======================================================================*/
11525 --
11526 /*
11527 PROCEDURE AdjustMpaRevLine(p_application_id  IN INTEGER)
11528 IS
11529 
11530 l_log_module         VARCHAR2(240);
11531 
11532 -- find the reversed parent entry which has all MPA lines reversed. Ignore Accrual reversal and if last MPA period is not reversed
11533 CURSOR cur_mpa_rev_lines IS
11534 SELECT MIN(xdl1.ref_ae_header_id)   -- parent ae_header_id
11535       ,MAX(xdl1.ae_line_num)
11536       ,xdl1.ae_header_id
11537       ,xdl1.ref_event_id
11538       ,xeh1.ledger_id
11539 FROM   xla_distribution_links xdl1
11540       ,xla_ae_headers         xeh1
11541       ,xla_ae_headers_gt      xehg
11542 WHERE xdl1.application_id = p_application_id
11543 AND   xeh1.application_id = p_application_id
11544 AND   xdl1.ae_header_id   = xehg.ae_header_id
11545 AND   xdl1.ae_header_id   = xeh1.ae_header_id
11546 AND   xdl1.temp_line_num  = xdl1.ref_temp_line_num*-1  -- is a reversal
11547 AND   EXISTS (SELECT 1
11548               FROM   xla_ae_headers
11549               WHERE  application_id      = p_application_id
11550               AND    parent_ae_header_id = xdl1.ref_ae_header_id
11551               AND    parent_ae_line_num IS NOT NULL)                         -- MPA only, not for Accrual Reversal
11552 GROUP BY xdl1.ref_ae_header_id, xdl1.ref_event_id, xdl1.application_id, xeh1.ledger_id, xdl1.ae_header_id
11553 HAVING (SELECT COUNT(*) FROM xla_distribution_links xdl2                     -- count of reversal lines
11554         WHERE  xdl2.application_id     = p_application_id
11555         AND    xdl2.ae_header_id       = xdl1.ae_header_id
11556         AND    xdl2.temp_line_num      = xdl2.ref_temp_line_num*-1
11557         AND    xdl2.ref_ae_header_id  <> xdl1.ref_ae_header_id
11558         AND    xdl2.ref_event_id       = xdl1.ref_event_id ) =
11559        (SELECT COUNT(*) FROM xla_distribution_links xdl3,xla_ae_headers xeh  -- count of original lines
11560         WHERE  xdl3.application_id     = p_application_id
11561         AND    xeh.application_id      = p_application_id
11562         AND    xdl3.ae_header_id       = xeh.ae_header_id
11563         AND    xdl3.event_id           = xdl1.ref_event_id
11564         AND    xdl3.ref_temp_line_num IS NULL
11565         AND    xeh.parent_ae_header_id = xdl1.ref_ae_header_id
11566         AND    xeh.parent_ae_line_num IS NOT NULL)
11567 ORDER BY xeh1.ledger_id, xdl1.ref_event_id;
11568      --(SELECT COUNT(*) FROM xla_ae_lines xel,xla_ae_headers xeh    -- count of original lines
11569      -- WHERE  xeh.application_id      = p_application_id
11570      -- AND    xel.ae_header_id        = xeh.ae_header_id
11571      -- AND    xeh.parent_ae_header_id = xdl1.ref_ae_header_id
11572      -- AND    xeh.parent_ae_line_num IS NOT NULL)
11573 
11574 CURSOR cur_last_mpa (l_ae_header   NUMBER, l_max_ae_header  NUMBER) is
11575 SELECT xel.rowid,  xel.*
11576 FROM   xla_ae_lines xel ,
11577        xla_distribution_links xdl2
11578 WHERE xel.application_id    = p_application_id
11579   AND xel.ae_header_id      = l_ae_header
11580   AND xdl2.application_id   = p_application_id
11581   AND xdl2.ae_header_id     = xel.ae_header_id
11582   AND xdl2.ref_ae_header_id = l_max_ae_header
11583   AND xel.ae_line_num       = xdl2.ae_line_num;
11584 
11585 l_last_mpa                  cur_last_mpa%ROWTYPE;
11586 
11587 l_array_parent_hdr_idx      xla_cmp_source_pkg.t_array_Num;
11588 l_array_parent_max_line     xla_cmp_source_pkg.t_array_Num;
11589 l_array_ae_header_id        xla_cmp_source_pkg.t_array_Num;
11590 l_array_ref_event_id        xla_cmp_source_pkg.t_array_Num;
11591 l_array_ledger_id           xla_cmp_source_pkg.t_array_Num;
11592 
11593 l_array_entered_amt         xla_ae_journal_entry_pkg.t_array_Num;
11594 l_array_accted_amt          xla_ae_journal_entry_pkg.t_array_Num;
11595 l_array_unround_entered_amt xla_ae_journal_entry_pkg.t_array_Num;
11596 l_array_unround_accted_amt  xla_ae_journal_entry_pkg.t_array_Num;
11597 
11598 l_max_hdr_id                NUMBER;
11599 l_max_lin_id                NUMBER;
11600 
11601 BEGIN
11602    --
11603    IF g_log_enabled THEN
11604       l_log_module := C_DEFAULT_MODULE||'.AdjustMpaRevLine';
11605    END IF;
11606    --
11607    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11608 
11609       trace
11610          (p_msg      => 'BEGIN of AdjustMpaRevLine'
11611          ,p_level    => C_LEVEL_PROCEDURE
11612          ,p_module   => l_log_module);
11613 
11614    END IF;
11615 
11616    ------------------------------------------------------------
11617    -- Find the MPA Reversal lines
11618    ------------------------------------------------------------
11619    OPEN  cur_mpa_rev_lines;
11620    FETCH cur_mpa_rev_lines BULK COLLECT INTO  l_array_parent_hdr_idx
11621                                              ,l_array_parent_max_line  -- find the original amount
11622                                              ,l_array_ae_header_id
11623                                              ,l_array_ref_event_id
11624                                              ,l_array_ledger_id;
11625    CLOSE cur_mpa_rev_lines;
11626 
11627 
11628    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11629      for  i in 1..l_array_parent_hdr_idx.COUNT loop
11630       trace
11631          (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11632                         ' max_line_id='||l_array_parent_max_line(i)||
11633                         ' rev_ae_header='||l_array_ae_header_id(i)||
11634                         ' ref_event='||l_array_ref_event_id(i)||
11635                         ' ledger='||l_array_ledger_id(i)
11636          ,p_level    => C_LEVEL_STATEMENT
11637          ,p_module   => l_log_module);
11638      end loop;
11639    END IF;
11640 
11641    ------------------------------------------------------------
11642    -- Find the original amounts for each parent
11643    ------------------------------------------------------------
11644    FOR i IN 1..l_array_ae_header_id.COUNT LOOP
11645       SELECT NVL(entered_cr, entered_dr)
11646             ,NVL(accounted_cr, accounted_dr)
11647             ,NVL(unrounded_entered_cr, unrounded_entered_dr)
11648             ,NVL(unrounded_accounted_cr, unrounded_accounted_dr)
11649       INTO   l_array_entered_amt(i)
11650             ,l_array_accted_amt(i)
11651             ,l_array_unround_entered_amt(i)
11652             ,l_array_unround_accted_amt(i)
11653       FROM   xla_ae_lines
11654       WHERE  application_id = p_application_id
11655       AND    ae_header_id   = l_array_ae_header_id(i)
11656       AND    ae_line_num    = l_array_parent_max_line(i);
11657    END LOOP;
11658 
11659    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11660      for  i in 1..l_array_parent_hdr_idx.COUNT loop
11661       trace
11662          (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11663                         ' ent='||l_array_entered_amt(i)||
11664                         ' acc='||l_array_accted_amt(i)||
11665                         ' unr_ent='||l_array_unround_entered_amt(i)||
11666                         ' unr_acc='||l_array_unround_accted_amt(i)
11667          ,p_level    => C_LEVEL_STATEMENT
11668          ,p_module   => l_log_module);
11669      end loop;
11670    END IF;
11671 
11672    ------------------------------------------------------------
11673    -- Update the AMOUNTs for the last MPA line amount
11674    ------------------------------------------------------------
11675    FOR i IN 1..l_array_parent_hdr_idx.COUNT LOOP
11676 
11677       l_max_hdr_id := NULL;
11678       l_max_lin_id := NULL;
11679 
11680       SELECT MAX(xdl1.ref_ae_header_id)  -- last recognition header
11681       INTO   l_max_hdr_id
11682       FROM   xla_distribution_links xdl1
11683             ,xla_ae_headers         xeh1
11684       WHERE  xdl1.application_id      = p_application_id
11685       AND    xdl1.ae_header_id        = l_array_ae_header_id(i)
11686       AND    xdl1.temp_line_num       = xdl1.ref_temp_line_num*-1
11687       AND    xdl1.ref_ae_header_id    <> l_array_parent_hdr_idx(i)
11688       AND    xdl1.ref_event_id        = l_array_ref_event_id(i)
11689       AND    xeh1.application_id      = p_application_id
11690       AND    xeh1.parent_ae_header_id = l_array_parent_hdr_idx(i)
11691       AND    xeh1.parent_ae_line_num IS NOT NULL
11692       AND    xeh1.ledger_id           = l_array_ledger_id(i);
11693 
11694       IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11695           trace
11696              (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11697                             ' last_recog_header='||l_max_hdr_id
11698              ,p_level    => C_LEVEL_STATEMENT
11699              ,p_module   => l_log_module);
11700       END IF;
11701 
11702       IF l_max_hdr_id IS NOT NULL THEN
11703 
11704        OPEN  cur_last_mpa(l_array_ae_header_id(i), l_max_hdr_id);
11705        FETCH cur_last_mpa INTO l_last_mpa;
11706        WHILE cur_last_mpa%FOUND LOOP
11707 
11708          UPDATE xla_ae_lines xel
11709          SET (entered_cr
11710              ,entered_dr
11711              ,accounted_cr
11712              ,accounted_dr
11713              ,unrounded_entered_cr
11714              ,unrounded_entered_dr
11715              ,unrounded_accounted_cr
11716              ,unrounded_accounted_dr) =
11717             (SELECT DECODE((l_last_mpa.entered_cr),             NULL,NULL, l_array_entered_amt(i)         - SUM(xel2.entered_cr))
11718                    ,DECODE((l_last_mpa.entered_dr),             NULL,NULL, l_array_entered_amt(i)         - SUM(xel2.entered_dr))
11719                    ,DECODE((l_last_mpa.accounted_cr),           NULL,NULL, l_array_accted_amt(i)          - SUM(xel2.accounted_cr))
11720                    ,DECODE((l_last_mpa.accounted_dr),           NULL,NULL, l_array_accted_amt(i)          - SUM(xel2.accounted_dr))
11721                    ,DECODE((l_last_mpa.unrounded_entered_cr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(xel2.unrounded_entered_cr))
11722                    ,DECODE((l_last_mpa.unrounded_entered_dr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(xel2.unrounded_entered_dr))
11723                    ,DECODE((l_last_mpa.unrounded_accounted_cr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(xel2.unrounded_accounted_cr))
11724                    ,DECODE((l_last_mpa.unrounded_accounted_dr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(xel2.unrounded_accounted_dr))
11725              FROM   xla_ae_lines xel2
11726                    ,xla_distribution_links xdl1
11727                    ,xla_ae_headers         xeh1
11728              WHERE xel2.application_id      = p_application_id
11729              AND   xel2.ae_header_id        = xdl1.ae_header_id
11730              AND   xel2.ae_line_num         = xdl1.ae_line_num
11731              AND   xdl1.application_id      = p_application_id
11732              AND   xdl1.ae_header_id        = l_array_ae_header_id(i)
11733              AND   xdl1.temp_line_num       = xdl1.ref_temp_line_num*-1
11734              AND   xeh1.application_id      = p_application_id
11735              AND   xeh1.parent_ae_header_id = l_array_parent_hdr_idx(i)
11736              AND   xeh1.parent_ae_line_num IS NOT NULL
11737              AND   xdl1.ref_ae_header_id    = xeh1.ae_header_id
11738              AND   xdl1.ref_ae_header_id NOT IN (l_array_parent_hdr_idx(i),l_max_hdr_id) -- not the parent or the last period
11739              AND   xdl1.ref_event_id       = l_array_ref_event_id(i)
11740              AND   xeh1.ledger_id          = l_array_ledger_id(i))
11741          WHERE rowid = l_last_mpa.rowid;
11742 
11743          IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11744               trace
11745                  (p_msg      => 'update xla_ae_lines count='||SQL%ROWCOUNT||
11746                                 ' ae_header='||l_last_mpa.ae_header_id||
11747                                 ' ae_line='||l_last_mpa.ae_line_num
11748                  ,p_level    => C_LEVEL_STATEMENT
11749                  ,p_module   => l_log_module);
11750          END IF;
11751 
11752          --------------------------------------------------------------------------------------------
11753          -- Update the DOC_ROUNDING values for the corresponding MPA line
11754          --------------------------------------------------------------------------------------------
11755          UPDATE xla_distribution_links xdl
11756          SET   (doc_rounding_acctd_amt
11757                ,doc_rounding_entered_amt
11758                ,unrounded_entered_cr
11759                ,unrounded_entered_dr
11760                ,unrounded_accounted_cr
11761                ,unrounded_accounted_dr
11762                ) =
11763             (SELECT DECODE(xel.unrounded_accounted_cr,NULL,DECODE(xel.unrounded_accounted_dr - xel.accounted_dr,0,NULL,
11764                                                                   xel.unrounded_accounted_dr - xel.accounted_dr)
11765                                                           ,DECODE(xel.unrounded_accounted_cr - xel.accounted_cr,0,NULL,
11766                                                                   xel.unrounded_accounted_cr - xel.accounted_cr))
11767                    ,DECODE(xel.unrounded_entered_cr,  NULL,DECODE(xel.unrounded_entered_dr   - xel.entered_dr,0,NULL,
11768                                                                   xel.unrounded_entered_dr   - xel.entered_dr)
11769                                                           ,DECODE(xel.unrounded_entered_cr   - xel.entered_cr,0,NULL,
11770                                                                   xel.unrounded_entered_cr   - xel.entered_cr))
11771                    ,xel.unrounded_entered_cr
11772                    ,xel.unrounded_entered_dr
11773                    ,xel.unrounded_accounted_cr
11774                    ,xel.unrounded_accounted_dr
11775              FROM   xla_ae_lines xel
11776                    ,xla_distribution_links xdl1
11777              WHERE xel.application_id    = p_application_id
11778              AND   xel.ae_header_id      = xdl1.ae_header_id
11779              AND   xel.ae_line_num       = xdl1.ae_line_num
11780              AND   xdl1.application_id   = p_application_id
11781              AND   xdl1.ae_header_id     = l_array_ae_header_id(i)
11782              AND   xdl1.temp_line_num    = xdl1.ref_temp_line_num*-1
11783              AND   xdl1.ref_ae_header_id = l_max_hdr_id           -- the last
11784              AND   xel.ae_line_num       = xdl.ae_line_num
11785              AND   xdl1.ref_event_id     = l_array_ref_event_id(i))
11786          WHERE application_id = p_application_id
11787          AND   ae_header_id   = l_last_mpa.ae_header_id
11788          AND   ae_line_num    = l_last_mpa.ae_line_num;
11789 
11790 
11791          IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11792               trace
11793                  (p_msg      => 'update xla_dist_link count='||SQL%ROWCOUNT||
11794                                 ' ae_header='||l_last_mpa.ae_header_id||
11795                                 ' ae_line='||l_last_mpa.ae_line_num
11796                  ,p_level    => C_LEVEL_STATEMENT
11797                  ,p_module   => l_log_module);
11798          END IF;
11799 
11800          FETCH cur_last_mpa INTO l_last_mpa;
11801 
11802        END LOOP;  --  cur_last_mpa%FOUND
11803 
11804        CLOSE cur_last_mpa;
11805 
11806 
11807       END IF; -- l_max_hdr_id IS NOT NULL
11808 
11809    END LOOP;  -- l_array_parent_hdr_idx.COUNT
11810 
11811 
11812 EXCEPTION
11813 WHEN xla_exceptions_pkg.application_exception THEN
11814   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11815        trace
11816            (p_msg      => 'Error. = '||sqlerrm
11817            ,p_level    => C_LEVEL_PROCEDURE
11818            ,p_module   => l_log_module);
11819   END IF;
11820   RAISE;
11821 WHEN OTHERS  THEN
11822   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11823        trace
11824            (p_msg      => 'Error. = '||sqlerrm
11825            ,p_level    => C_LEVEL_PROCEDURE
11826            ,p_module   => l_log_module);
11827   END IF;
11828   xla_exceptions_pkg.raise_message
11829                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.AdjustMpaRevLine');
11830 END AdjustMpaRevLine;
11831 */
11832 
11833 --
11834 /*======================================================================+
11835 | PRIVATE procedure: InsertLinks                                        |
11836 |                                                                       |
11837 | Description: Inserts distribution links                               |
11838 |                                                                       |
11839 |                                                                       |
11840 |                                                                       |
11841 +======================================================================*/
11842 --
11843 PROCEDURE InsertLinks(p_application_id    IN INTEGER)
11844 IS
11845 l_rowcount           NUMBER;
11846 l_log_module         VARCHAR2(240);
11847 BEGIN
11848 --
11849 IF g_log_enabled THEN
11850       l_log_module := C_DEFAULT_MODULE||'.InsertLinks';
11851 END IF;
11852 --
11853 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11854 
11855       trace
11856          (p_msg      => 'BEGIN of InsertLinks'
11857          ,p_level    => C_LEVEL_PROCEDURE
11858          ,p_module   => l_log_module);
11859 END IF;
11860 --
11861 BEGIN
11862 
11863  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11864 
11865       trace
11866          (p_msg      => 'SQL - Insert into xla_distribution_links'
11867          ,p_level    => C_LEVEL_EXCEPTION
11868          ,p_module   => l_log_module);
11869 
11870  END IF;
11871 
11872 l_rowcount := 0;
11873 
11874 INSERT INTO xla_distribution_links
11875 (
11876    application_id
11877  , event_id
11878  , source_distribution_id_char_1
11879  , source_distribution_id_char_2
11880  , source_distribution_id_char_3
11881  , source_distribution_id_char_4
11882  , source_distribution_id_char_5
11883  , source_distribution_id_num_1
11884  , source_distribution_id_num_2
11885  , source_distribution_id_num_3
11886  , source_distribution_id_num_4
11887  , source_distribution_id_num_5
11888  , source_distribution_type
11889  , APPLIED_TO_APPLICATION_ID
11890  , APPLIED_TO_ENTITY_CODE
11891  , APPLIED_TO_ENTITY_ID
11892  , APPLIED_TO_SOURCE_ID_NUM_1
11893  , APPLIED_TO_SOURCE_ID_NUM_2
11894  , APPLIED_TO_SOURCE_ID_NUM_3
11895  , APPLIED_TO_SOURCE_ID_NUM_4
11896  , APPLIED_TO_SOURCE_ID_CHAR_1
11897  , APPLIED_TO_SOURCE_ID_CHAR_2
11898  , APPLIED_TO_SOURCE_ID_CHAR_3
11899  , APPLIED_TO_SOURCE_ID_CHAR_4
11900  , APPLIED_TO_DISTRIBUTION_TYPE
11901  , APPLIED_TO_DIST_ID_NUM_1
11902  , APPLIED_TO_DIST_ID_NUM_2
11903  , APPLIED_TO_DIST_ID_NUM_3
11904  , APPLIED_TO_DIST_ID_NUM_4
11905  , APPLIED_TO_DIST_ID_NUM_5
11906  , APPLIED_TO_DIST_ID_CHAR_1
11907  , APPLIED_TO_DIST_ID_CHAR_2
11908  , APPLIED_TO_DIST_ID_CHAR_3
11909  , APPLIED_TO_DIST_ID_CHAR_4
11910  , APPLIED_TO_DIST_ID_CHAR_5
11911  , unrounded_entered_cr
11912  , unrounded_entered_dr
11913  , unrounded_accounted_cr
11914  , unrounded_accounted_dr
11915  , ae_header_id
11916  , ae_line_num
11917  , temp_line_num
11918  , tax_line_ref_id
11919  , tax_summary_line_ref_id
11920  , tax_rec_nrec_dist_ref_id
11921  , statistical_amount
11922  , event_class_code
11923  , event_type_code
11924  , line_definition_owner_code
11925  , line_definition_code
11926  , accounting_line_type_code
11927  , accounting_line_code
11928  , ref_event_id
11929  , ref_ae_header_id
11930  , ref_temp_line_num
11931  , gain_or_loss_ref
11932  , merge_duplicate_code
11933  , calculate_acctd_amts_flag
11934  , calculate_g_l_amts_flag
11935  , rounding_class_code
11936  , document_rounding_level
11937  , doc_rounding_acctd_amt
11938  , doc_rounding_entered_amt
11939  --
11940  -- Allocation Attributes
11941  --
11942  , alloc_to_application_id
11943  , alloc_to_entity_code
11944  , alloc_to_source_id_num_1
11945  , alloc_to_source_id_num_2
11946  , alloc_to_source_id_num_3
11947  , alloc_to_source_id_num_4
11948  , alloc_to_source_id_char_1
11949  , alloc_to_source_id_char_2
11950  , alloc_to_source_id_char_3
11951  , alloc_to_source_id_char_4
11952  , alloc_to_distribution_type
11953  , alloc_to_dist_id_char_1
11954  , alloc_to_dist_id_char_2
11955  , alloc_to_dist_id_char_3
11956  , alloc_to_dist_id_char_4
11957  , alloc_to_dist_id_char_5
11958  , alloc_to_dist_id_num_1
11959  , alloc_to_dist_id_num_2
11960  , alloc_to_dist_id_num_3
11961  , alloc_to_dist_id_num_4
11962  , alloc_to_dist_id_num_5
11963 )
11964 SELECT
11965           p_application_id
11966         , event_id
11967         , source_distribution_id_char_1
11968         , source_distribution_id_char_2
11969         , source_distribution_id_char_3
11970         , source_distribution_id_char_4
11971         , source_distribution_id_char_5
11972         , source_distribution_id_num_1
11973         , source_distribution_id_num_2
11974         , source_distribution_id_num_3
11975         , source_distribution_id_num_4
11976         , source_distribution_id_num_5
11977         , source_distribution_type
11978         , BFLOW_APPLICATION_ID
11979         , BFLOW_ENTITY_CODE
11980         , APPLIED_TO_ENTITY_ID
11981         , BFLOW_SOURCE_ID_NUM_1
11982         , BFLOW_SOURCE_ID_NUM_2
11983         , BFLOW_SOURCE_ID_NUM_3
11984         , BFLOW_SOURCE_ID_NUM_4
11985         , BFLOW_SOURCE_ID_CHAR_1
11986         , BFLOW_SOURCE_ID_CHAR_2
11987         , BFLOW_SOURCE_ID_CHAR_3
11988         , BFLOW_SOURCE_ID_CHAR_4
11989         , BFLOW_DISTRIBUTION_TYPE
11990         , BFLOW_DIST_ID_NUM_1
11991         , BFLOW_DIST_ID_NUM_2
11992         , BFLOW_DIST_ID_NUM_3
11993         , BFLOW_DIST_ID_NUM_4
11994         , BFLOW_DIST_ID_NUM_5
11995         , BFLOW_DIST_ID_CHAR_1
11996         , BFLOW_DIST_ID_CHAR_2
11997         , BFLOW_DIST_ID_CHAR_3
11998         , BFLOW_DIST_ID_CHAR_4
11999         , BFLOW_DIST_ID_CHAR_5
12000         , unrounded_entered_cr
12001         , unrounded_entered_dr
12002         , unrounded_accounted_cr
12003         , unrounded_accounted_dr
12004         , ae_header_id
12005         , ae_line_num
12006         , temp_line_num
12007         , tax_line_ref_id
12008         , tax_summary_line_ref_id
12009         , tax_rec_nrec_dist_ref_id
12010         , statistical_amount
12011         , event_class_code
12012         , event_type_code
12013         , line_definition_owner_code
12014         , line_definition_code
12015         , accounting_line_type_code
12016         , accounting_line_code
12017         , ref_event_id
12018         , ref_ae_header_id
12019         , ref_temp_line_num
12020         , gain_or_loss_ref
12021         , merge_duplicate_code
12022         , calculate_acctd_amts_flag
12023         , calculate_g_l_amts_flag
12024         , rounding_class_code
12025         , document_rounding_level
12026         , doc_rounding_acctd_amt
12027         , doc_rounding_entered_amt
12028         --
12029         -- Allocation Attributes
12030         --
12031         , alloc_to_application_id
12032         , alloc_to_entity_code
12033         , alloc_to_source_id_num_1
12034         , alloc_to_source_id_num_2
12035         , alloc_to_source_id_num_3
12036         , alloc_to_source_id_num_4
12037         , alloc_to_source_id_char_1
12038         , alloc_to_source_id_char_2
12039         , alloc_to_source_id_char_3
12040         , alloc_to_source_id_char_4
12041         , alloc_to_distribution_type
12042         , alloc_to_dist_id_char_1
12043         , alloc_to_dist_id_char_2
12044         , alloc_to_dist_id_char_3
12045         , alloc_to_dist_id_char_4
12046         , alloc_to_dist_id_char_5
12047         , alloc_to_dist_id_num_1
12048         , alloc_to_dist_id_num_2
12049         , alloc_to_dist_id_num_3
12050         , alloc_to_dist_id_num_4
12051         , alloc_to_dist_id_num_5
12052 FROM xla_ae_lines_gt
12053 WHERE ae_line_num IS NOT NULL;
12054 
12055 l_rowcount:= SQL%ROWCOUNT;
12056 
12057 IF (C_LEVEL_EVENT >= g_log_level) THEN
12058       trace
12059          (p_msg      => '# lines inserted into xla_distribution_links = '||l_rowcount
12060          ,p_level    => C_LEVEL_EVENT
12061          ,p_module   => l_log_module);
12062 END IF;
12063 
12064 EXCEPTION
12065 WHEN OTHERS  THEN
12066 
12067   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12068          trace
12069             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
12070             ,p_level    => C_LEVEL_EXCEPTION
12071             ,p_module   => l_log_module);
12072   END IF;
12073 
12074   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12075                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
12076                                     ,p_token_1      => 'ERROR'
12077                                     ,p_value_1      => sqlerrm
12078                                     );
12079 END;
12080 
12081 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12082 
12083       trace
12084          (p_msg      => 'END of InsertLinks'
12085          ,p_level    => C_LEVEL_PROCEDURE
12086          ,p_module   => l_log_module);
12087 END IF;
12088 
12089 EXCEPTION
12090 WHEN xla_exceptions_pkg.application_exception THEN
12091   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12092        trace
12093            (p_msg      => 'Error. = '||sqlerrm
12094            ,p_level    => C_LEVEL_PROCEDURE
12095            ,p_module   => l_log_module);
12096   END IF;
12097   RAISE;
12098 WHEN OTHERS  THEN
12099   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12100        trace
12101            (p_msg      => 'Error. = '||sqlerrm
12102            ,p_level    => C_LEVEL_PROCEDURE
12103            ,p_module   => l_log_module);
12104   END IF;
12105   xla_exceptions_pkg.raise_message
12106                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertLinks');
12107 END InsertLinks;
12108 --
12109 /*======================================================================+
12110 |                                                                       |
12111 | Insert final headers and distribution links                           |
12112 |                                                                       |
12113 |                                                                       |
12114 +======================================================================*/
12115 --
12116 FUNCTION InsertHeaders(p_application_id                 IN INTEGER
12117                       ,p_accounting_batch_id            IN NUMBER
12118                       ,p_end_date                       IN DATE        -- 4262811
12119                       -- bulk performance
12120                       ,p_accounting_mode                 in varchar)
12121 RETURN NUMBER
12122 IS
12123 l_rowcount           NUMBER;
12124 l_log_module         VARCHAR2(240);
12125 i                    NUMBER;     -- 4262811
12126 l_error_msg          VARCHAR2(2000);
12127 l_prod_rule_name      VARCHAR2(80);
12128 l_event_class_name    VARCHAR2(80);
12129 l_event_type_name     VARCHAR2(80);
12130 
12131 cursor csr_null_gl_date is
12132     SELECT  pr.name, ec.name, et.name
12133     FROM    xla_product_rules_tl    pr
12134             ,xla_event_classes_tl   ec
12135             ,xla_event_types_tl     et
12136             ,xla_ae_headers_gt      h
12137     WHERE   pr.amb_context_code(+)       = h.amb_context_code
12138       AND   pr.application_id(+)         = p_application_id
12139       AND   pr.product_rule_type_code(+) = h.product_rule_type_code
12140       AND   pr.product_rule_code(+)      = h.product_rule_code
12141       AND   pr.language(+)               = USERENV('LANG')
12142       AND   ec.application_id(+)         = et.application_id
12143       AND   ec.event_class_code(+)       = et.event_class_code
12144       AND   ec.language(+)               = USERENV('LANG')
12145       AND   et.application_id(+)         = p_application_id
12146       AND   et.event_type_code(+)        = h.event_type_code
12147       AND   et.language(+)               = USERENV('LANG')
12148       AND   h.balance_type_code <> 'X'
12149       AND   h.accounting_date is null;
12150 
12151 BEGIN
12152 --
12153 IF g_log_enabled THEN
12154       l_log_module := C_DEFAULT_MODULE||'.InsertHeaders';
12155 END IF;
12156 --
12157 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12158 
12159       trace
12160          (p_msg      => 'BEGIN of InsertHeaders'
12161          ,p_level    => C_LEVEL_PROCEDURE
12162          ,p_module   => l_log_module);
12163 END IF;
12164 --
12165 l_rowcount := 0;
12166 BEGIN
12167 
12168  IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12169 
12170       trace
12171          (p_msg      => 'SQL - Insert into xla_ae_headers'
12172          ,p_level    => C_LEVEL_STATEMENT
12173          ,p_module   => l_log_module);
12174 
12175  END IF;
12176 
12177 
12178 --------------------------------------------------------
12179 -- 4262811
12180 --------------------------------------------------------
12181  IF xla_accounting_pkg.g_mpa_accrual_exists = 'Y' THEN      --4752807
12182    FORALL i IN 1..g_array_ae_header_id.COUNT
12183      UPDATE /*+ index(XLA_AE_HEADERS_GT, XLA_AE_HEADERS_GT_N1) */ --4918497
12184             xla_ae_headers_gt
12185         SET parent_header_id      = g_array_ae_header_id(i)
12186       WHERE parent_header_id      = g_array_event_id(i)    --  instead of ae_header_id
12187         AND ledger_id             = g_array_ledger_id(i)
12188         AND balance_type_code     = g_array_balance_type(i)
12189         AND g_array_header_num(i) = 0;
12190  END IF;
12191 --------------------------------------------------------
12192 
12193 --------------------------------------------------------
12194 -- always insert into headers table with zero amount flag 'N'.
12195 -- will update it in the validation package */
12196 --
12197 --
12198 -- Bug 5056632
12199 -- if there is no group_id (no transfer requested)
12200 --    do a simple insert
12201 -- else there is group_id (transfer requested along with accounting)
12202 --    do forall insert
12203 -- end if
12204 --------------------------------------------------------
12205 
12206 IF xla_accounting_pkg.g_array_group_id.COUNT = 0 THEN
12207 INSERT INTO xla_ae_headers
12208 (
12209    ae_header_id
12210  , application_id
12211  , ledger_id
12212  , entity_id
12213  , event_id
12214  , event_type_code
12215  , accounting_date
12216  , gl_transfer_status_code
12217  , je_category_name
12218  , accounting_entry_status_code
12219  , accounting_entry_type_code
12220  , product_rule_type_code
12221  , product_rule_code
12222  , product_rule_version
12223  , description
12224  , creation_date
12225  , created_by
12226  , last_update_date
12227  , last_updated_by
12228  , last_update_login
12229  , doc_sequence_id
12230  , doc_sequence_value
12231  , doc_category_code
12232  , program_update_date
12233  , program_application_id
12234  , program_id
12235  , request_id
12236  , budget_version_id
12237  --, encumbrance_type_id  -- 3358381
12238  , balance_type_code
12239  , completed_date
12240  , period_name
12241  , accounting_batch_id
12242  , amb_context_code
12243  , zero_amount_flag
12244  , parent_ae_header_id   -- 4262811
12245  , parent_ae_line_num    -- 4262811
12246  , accrual_reversal_flag -- 4262811
12247  , group_id              -- 5056632
12248 )
12249 SELECT
12250            hed.ae_header_id
12251          , p_application_id
12252          , hed.ledger_id
12253          , hed.entity_id
12254          , hed.event_id
12255          , hed.event_type_code
12256          , hed.accounting_date
12257          , hed.gl_transfer_status_code
12258          , hed.je_category_name
12259 --       , hed.accounting_entry_status_code
12260        -- 4262811
12261        --, decode(hed.accounting_entry_status_code,C_VALID, p_accounting_mode,C_INVALID,'I',C_RELATED_INVALID, 'R', NULL)
12262          , decode(hed.accounting_entry_status_code
12263                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
12264                                      p_accounting_mode
12265                                 WHEN hed.accounting_date > p_end_date -- AND hed.accrual_reversal_flag = 'N' -- commented for 8505463
12266 				     AND hed.parent_header_id IS NULL -- non MPA/Accrual Reversal's have PARENT_HEADER_ID as NULL for bug8505463
12267 				THEN                                 -- MPA/Accrual Reversal's and Regular Accounting have accrual_reversal_flag as N
12268 				     p_accounting_mode
12269 				ELSE
12270 				     'N'
12271                            END
12272                  ,C_INVALID,'I'
12273                  ,C_RELATED_INVALID, 'R'
12274                  ,NULL)
12275          , hed.accounting_entry_type_code
12276          , hed.product_rule_type_code
12277          , hed.product_rule_code
12278          , hed.product_rule_version
12279          , hed.description
12280          , g_who_columns.creation_date
12281          , g_who_columns.created_by
12282          , g_who_columns.last_update_date
12283          , g_who_columns.last_updated_by
12284          , g_who_columns.last_update_login
12285          , hed.doc_sequence_id
12286          , hed.doc_sequence_value
12287          , hed.doc_category_code
12288          , g_who_columns.program_update_date
12289          , g_who_columns.program_application_id
12290          , g_who_columns.program_id
12291          , g_who_columns.request_id
12292          , CASE hed.balance_type_code
12293              WHEN 'B' THEN hed.budget_version_id
12294              ELSE NULL
12295            END
12296          -- , CASE hed.balance_type_code  -- 34458381 Public Sector Enh
12297          --     WHEN 'E' THEN hed.encumbrance_type_id
12298          --     ELSE NULL
12299          --   END
12300          , hed.balance_type_code
12301          , sysdate
12302          , hed.period_name
12303          , p_accounting_batch_id
12304          , hed.amb_context_code
12305          , 'N'
12306          , hed.parent_header_id      -- 4262811
12307          , hed.parent_ae_line_num    -- 4262811
12308          , hed.accrual_reversal_flag -- 4262811
12309          , NULL                      -- group_id
12310           FROM xla_ae_headers_gt hed
12311           where hed.balance_type_code <> 'X';
12312 ELSE  -- xla_accounting_pkg.g_array_group_id.COUNT > 0
12313 FORALL i IN 1..xla_accounting_pkg.g_array_group_id.COUNT
12314 INSERT INTO xla_ae_headers
12315 (
12316    ae_header_id
12317  , application_id
12318  , ledger_id
12319  , entity_id
12320  , event_id
12321  , event_type_code
12322  , accounting_date
12323  , gl_transfer_status_code
12324  , je_category_name
12325  , accounting_entry_status_code
12326  , accounting_entry_type_code
12327  , product_rule_type_code
12328  , product_rule_code
12329  , product_rule_version
12330  , description
12331  , creation_date
12332  , created_by
12333  , last_update_date
12334  , last_updated_by
12335  , last_update_login
12336  , doc_sequence_id
12337  , doc_sequence_value
12338  , doc_category_code
12339  , program_update_date
12340  , program_application_id
12341  , program_id
12342  , request_id
12343  , budget_version_id
12344  --, encumbrance_type_id  -- 3358381
12345  , balance_type_code
12346  , completed_date
12347  , period_name
12348  , accounting_batch_id
12349  , amb_context_code
12350  , zero_amount_flag
12351  , parent_ae_header_id   -- 4262811
12352  , parent_ae_line_num    -- 4262811
12353  , accrual_reversal_flag -- 4262811
12354  , group_id
12355 )
12356 SELECT
12357            hed.ae_header_id
12358          , p_application_id
12359          , hed.ledger_id
12360          , hed.entity_id
12361          , hed.event_id
12362          , hed.event_type_code
12363          , hed.accounting_date
12364          , hed.gl_transfer_status_code
12365          , hed.je_category_name
12366 --       , hed.accounting_entry_status_code
12367        -- 4262811
12368        --, decode(hed.accounting_entry_status_code,C_VALID, p_accounting_mode,C_INVALID,'I',C_RELATED_INVALID, 'R', NULL)
12369          , decode(hed.accounting_entry_status_code
12370                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
12371                                      p_accounting_mode
12372                                 WHEN hed.accounting_date > p_end_date -- AND hed.accrual_reversal_flag = 'N' -- commented for 8505463
12373 				     AND hed.parent_header_id IS NULL -- non MPA/Accrual Reversal's have PARENT_HEADER_ID as NULL for bug8505463
12374 				THEN                                 -- MPA/Accrual Reversal's and Regular Accounting have accrual_reversal_flag as N
12375 				     p_accounting_mode
12376 				ELSE
12377 				     'N'
12378                            END
12379                  ,C_INVALID,'I'
12380                  ,C_RELATED_INVALID, 'R'
12381                  ,NULL)
12382          , hed.accounting_entry_type_code
12383          , hed.product_rule_type_code
12384          , hed.product_rule_code
12385          , hed.product_rule_version
12386          , hed.description
12387          , g_who_columns.creation_date
12388          , g_who_columns.created_by
12389          , g_who_columns.last_update_date
12390          , g_who_columns.last_updated_by
12391          , g_who_columns.last_update_login
12392          , hed.doc_sequence_id
12393          , hed.doc_sequence_value
12394          , hed.doc_category_code
12395          , g_who_columns.program_update_date
12396          , g_who_columns.program_application_id
12397          , g_who_columns.program_id
12398          , g_who_columns.request_id
12399          , CASE hed.balance_type_code
12400              WHEN 'B' THEN hed.budget_version_id
12401              ELSE NULL
12402            END
12403          -- , CASE hed.balance_type_code  -- 34458381 Public Sector Enh
12404          --     WHEN 'E' THEN hed.encumbrance_type_id
12405          --     ELSE NULL
12406          --   END
12407          , hed.balance_type_code
12408          , sysdate
12409          , hed.period_name
12410          , p_accounting_batch_id
12411          , hed.amb_context_code
12412          , 'N'
12413          , hed.parent_header_id      -- 4262811
12414          , hed.parent_ae_line_num    -- 4262811
12415          , hed.accrual_reversal_flag -- 4262811
12416          , DECODE(hed.accounting_entry_status_code
12417                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
12418                 --Added for 10124492
12419                                      decode(hed.gl_transfer_status_code,'NT', null,xla_accounting_pkg.g_array_group_id(i))
12420 				--Added for 10124492
12421                                 ELSE NULL
12422                            END
12423                  ,NULL)
12424           FROM xla_ae_headers_gt hed
12425           where hed.balance_type_code <> 'X'
12426           and hed.ledger_id = xla_accounting_pkg.g_array_ledger_id(i);
12427 END IF;
12428 
12429 l_rowcount := SQL%ROWCOUNT;
12430 
12431 IF (C_LEVEL_EVENT >= g_log_level) THEN
12432       trace
12433          (p_msg      => '# journal entry headers inserted into xla_ae_headers = '||l_rowcount
12434          ,p_level    => C_LEVEL_EVENT
12435          ,p_module   => l_log_module);
12436 END IF;
12437 
12438 
12439 EXCEPTION
12440 WHEN OTHERS  THEN
12441 
12442   l_error_msg :=substr(sqlerrm, 1, 1999);
12443 
12444   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12445          trace
12446             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||l_error_msg
12447             ,p_level    => C_LEVEL_EXCEPTION
12448             ,p_module   => l_log_module);
12449   END IF;
12450 
12451   open csr_null_gl_date;
12452   fetch csr_null_gl_date into l_prod_rule_name, l_event_class_name, l_event_type_name;
12453   IF(csr_null_gl_date%NOTFOUND) THEN
12454     close csr_null_gl_date;
12455     xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12456                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
12457                                     ,p_token_1      => 'ERROR'
12458                                     ,p_value_1      => l_error_msg
12459                                     );
12460   ELSE
12461     close csr_null_gl_date;
12462     xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12463                                     ,p_msg_name     => 'XLA_AP_NULL_GL_DATE'
12464                                     ,p_token_1      => 'EVENT_CLASS_NAME'
12465                                     ,p_value_1      => l_event_class_name
12466                                     ,p_token_2      => 'EVENT_TYPE_NAME'
12467                                     ,p_value_2      => l_event_type_name
12468                                     ,p_token_3      => 'PRODUCT_RULE_NAME'
12469                                     ,p_value_3      => l_prod_rule_name
12470                                     );
12471   END IF;
12472 END;
12473 
12474 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12475 
12476       trace
12477          (p_msg      => 'return value. = '||TO_CHAR(l_rowcount)
12478          ,p_level    => C_LEVEL_PROCEDURE
12479          ,p_module   => l_log_module);
12480 
12481       trace
12482          (p_msg      => 'END of InsertHeaders'
12483          ,p_level    => C_LEVEL_PROCEDURE
12484          ,p_module   => l_log_module);
12485 END IF;
12486 --
12487 RETURN l_rowcount;
12488 EXCEPTION
12489 WHEN xla_exceptions_pkg.application_exception THEN
12490   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12491        trace
12492            (p_msg      => 'Error. = '||sqlerrm
12493            ,p_level    => C_LEVEL_PROCEDURE
12494            ,p_module   => l_log_module);
12495   END IF;
12496   RAISE;
12497 WHEN OTHERS  THEN
12498   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12499        trace
12500            (p_msg      => 'Error. = '||sqlerrm
12501            ,p_level    => C_LEVEL_PROCEDURE
12502            ,p_module   => l_log_module);
12503   END IF;
12504   xla_exceptions_pkg.raise_message
12505                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHeaders');
12506    --
12507 END InsertHeaders;
12508 --
12509 /*======================================================================+
12510 |                                                                       |
12511 | Insert final Lines                                                    |
12512 |                                                                       |
12513 |                                                                       |
12514 +======================================================================*/
12515 --
12516 PROCEDURE InsertHdrAnalyticalCriteria
12517 IS
12518 l_log_module         VARCHAR2(240);
12519 BEGIN
12520 --
12521 IF g_log_enabled THEN
12522       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria';
12523 END IF;
12524 --
12525 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12526 
12527       trace
12528          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria'
12529          ,p_level    => C_LEVEL_PROCEDURE
12530          ,p_module   => l_log_module);
12531 END IF;
12532 --
12533 BEGIN
12534 
12535    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12536 
12537       trace
12538          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
12539          ,p_level    => C_LEVEL_STATEMENT
12540          ,p_module   => l_log_module);
12541 
12542    END IF;
12543 --
12544 
12545    IF g_hdr_ac_count <= 10 THEN
12546 
12547       InsertHdrAnalyticalCriteria10;
12548 
12549    ELSIF g_hdr_ac_count <= 50 THEN
12550 
12551       InsertHdrAnalyticalCriteria50;
12552 
12553    ELSIF g_hdr_ac_count <= 100 THEN
12554 
12555       InsertHdrAnalyticalCriteria100;
12556 
12557    END IF;
12558 
12559 
12560 --
12561 IF (C_LEVEL_EVENT >= g_log_level) THEN
12562       trace
12563          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
12564          ,p_level    => C_LEVEL_EVENT
12565          ,p_module   => l_log_module);
12566 END IF;
12567 
12568 --
12569 EXCEPTION
12570 WHEN OTHERS THEN
12571   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12572          trace
12573             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
12574             ,p_level    => C_LEVEL_EXCEPTION
12575             ,p_module   => l_log_module);
12576   END IF;
12577 
12578   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12579                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
12580                                     ,p_token_1      => 'ERROR'
12581                                     ,p_value_1      => sqlerrm
12582                                     );
12583 END;
12584 --
12585 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12586 
12587       trace
12588          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
12589          ,p_level    => C_LEVEL_PROCEDURE
12590          ,p_module   => l_log_module);
12591 
12592       trace
12593          (p_msg      => 'END of InsertHdrAnalyticalCriteria'
12594          ,p_level    => C_LEVEL_PROCEDURE
12595          ,p_module   => l_log_module);
12596 END IF;
12597 --
12598 EXCEPTION
12599 WHEN xla_exceptions_pkg.application_exception THEN
12600   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12601        trace
12602            (p_msg      => 'Error. = '||sqlerrm
12603            ,p_level    => C_LEVEL_PROCEDURE
12604            ,p_module   => l_log_module);
12605   END IF;
12606   RAISE;
12607 WHEN OTHERS  THEN
12608  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12609        trace
12610            (p_msg      => 'Error. = '||sqlerrm
12611            ,p_level    => C_LEVEL_PROCEDURE
12612            ,p_module   => l_log_module);
12613   END IF;
12614   xla_exceptions_pkg.raise_message
12615                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria');
12616    --
12617 END InsertHdrAnalyticalCriteria;
12618 
12619 --
12620 /*======================================================================+
12621 |                                                                       |
12622 | Insert Header Analytical Criteria 10                                  |
12623 |                                                                       |
12624 |                                                                       |
12625 +======================================================================*/
12626 --
12627 PROCEDURE InsertHdrAnalyticalCriteria10
12628 IS
12629 l_log_module         VARCHAR2(240);
12630 BEGIN
12631 --
12632 IF g_log_enabled THEN
12633       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria10';
12634 END IF;
12635 --
12636 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12637 
12638       trace
12639          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria10'
12640          ,p_level    => C_LEVEL_PROCEDURE
12641          ,p_module   => l_log_module);
12642 END IF;
12643 --
12644 BEGIN
12645 
12646    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12647 
12648       trace
12649          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
12650          ,p_level    => C_LEVEL_STATEMENT
12651          ,p_module   => l_log_module);
12652 
12653    END IF;
12654 --
12655 
12656 INSERT ALL
12657 WHEN anc_id_1 IS NOT NULL THEN
12658   INTO xla_ae_header_acs (
12659         ae_header_id , object_version_number
12660       , analytical_criterion_code
12661       , analytical_criterion_type_code
12662       , amb_context_code
12663       , ac1,ac2,ac3,ac4,ac5)
12664 VALUES (ae_header_id, C_OVN
12665 ,SUBSTRB(anc_id_1
12666        ,1
12667        ,INSTRB(anc_id_1,'(]',1,1) -1)
12668 ,SUBSTRB(anc_id_1
12669        ,INSTRB(anc_id_1,'(]',1,1) + 2
12670        ,INSTRB(anc_id_1,'(]',1,2) -
12671         INSTRB(anc_id_1,'(]',1,1) - 2)
12672 ,SUBSTRB(anc_id_1
12673        ,INSTRB(anc_id_1,'(]',1,2) + 2
12674        ,INSTRB(anc_id_1,'(]',1,3) -
12675         INSTRB(anc_id_1,'(]',1,2) - 2)
12676 ,SUBSTRB(anc_id_1
12677        ,INSTRB(anc_id_1,'(]',1,3) + 2
12678        ,INSTRB(anc_id_1,'(]',1,4) -
12679         INSTRB(anc_id_1,'(]',1,3) - 2)
12680 ,SUBSTRB(anc_id_1
12681        ,INSTRB(anc_id_1,'(]',1,4) + 2
12682        ,INSTRB(anc_id_1,'(]',1,5) -
12683         INSTRB(anc_id_1,'(]',1,4) - 2)
12684 ,SUBSTRB(anc_id_1
12685        ,INSTRB(anc_id_1,'(]',1,5) + 2
12686        ,INSTRB(anc_id_1,'(]',1,6) -
12687         INSTRB(anc_id_1,'(]',1,5) - 2)
12688 ,SUBSTRB(anc_id_1
12689        ,INSTRB(anc_id_1,'(]',1,6) + 2
12690        ,INSTRB(anc_id_1,'(]',1,7) -
12691         INSTRB(anc_id_1,'(]',1,6) - 2)
12692 ,SUBSTRB(anc_id_1
12693        ,INSTRB(anc_id_1,'(]',1,7) + 2
12694        ,LENGTHB(anc_id_1))
12695 )
12696 
12697 WHEN anc_id_2 IS NOT NULL THEN
12698   INTO xla_ae_header_acs (
12699         ae_header_id , object_version_number
12700       , analytical_criterion_code
12701       , analytical_criterion_type_code
12702       , amb_context_code
12703       , ac1,ac2,ac3,ac4,ac5)
12704 VALUES (ae_header_id, C_OVN
12705 ,SUBSTRB(anc_id_2
12706        ,1
12707        ,INSTRB(anc_id_2,'(]',1,1) -1)
12708 ,SUBSTRB(anc_id_2
12709        ,INSTRB(anc_id_2,'(]',1,1) + 2
12710        ,INSTRB(anc_id_2,'(]',1,2) -
12711         INSTRB(anc_id_2,'(]',1,1) - 2)
12712 ,SUBSTRB(anc_id_2
12713        ,INSTRB(anc_id_2,'(]',1,2) + 2
12714        ,INSTRB(anc_id_2,'(]',1,3) -
12715         INSTRB(anc_id_2,'(]',1,2) - 2)
12716 ,SUBSTRB(anc_id_2
12717        ,INSTRB(anc_id_2,'(]',1,3) + 2
12718        ,INSTRB(anc_id_2,'(]',1,4) -
12719         INSTRB(anc_id_2,'(]',1,3) - 2)
12720 ,SUBSTRB(anc_id_2
12721        ,INSTRB(anc_id_2,'(]',1,4) + 2
12722        ,INSTRB(anc_id_2,'(]',1,5) -
12723         INSTRB(anc_id_2,'(]',1,4) - 2)
12724 ,SUBSTRB(anc_id_2
12725        ,INSTRB(anc_id_2,'(]',1,5) + 2
12726        ,INSTRB(anc_id_2,'(]',1,6) -
12727         INSTRB(anc_id_2,'(]',1,5) - 2)
12728 ,SUBSTRB(anc_id_2
12729        ,INSTRB(anc_id_2,'(]',1,6) + 2
12730        ,INSTRB(anc_id_2,'(]',1,7) -
12731         INSTRB(anc_id_2,'(]',1,6) - 2)
12732 ,SUBSTRB(anc_id_2
12733        ,INSTRB(anc_id_2,'(]',1,7) + 2
12734        ,LENGTHB(anc_id_2))
12735 )
12736 
12737 WHEN anc_id_3 IS NOT NULL THEN
12738   INTO xla_ae_header_acs (
12739         ae_header_id , object_version_number
12740       , analytical_criterion_code
12741       , analytical_criterion_type_code
12742       , amb_context_code
12743       , ac1,ac2,ac3,ac4,ac5)
12744 VALUES (ae_header_id, C_OVN
12745 ,SUBSTRB(anc_id_3
12746        ,1
12747        ,INSTRB(anc_id_3,'(]',1,1) -1)
12748 ,SUBSTRB(anc_id_3
12749        ,INSTRB(anc_id_3,'(]',1,1) + 2
12750        ,INSTRB(anc_id_3,'(]',1,2) -
12751         INSTRB(anc_id_3,'(]',1,1) - 2)
12752 ,SUBSTRB(anc_id_3
12753        ,INSTRB(anc_id_3,'(]',1,2) + 2
12754        ,INSTRB(anc_id_3,'(]',1,3) -
12755         INSTRB(anc_id_3,'(]',1,2) - 2)
12756 ,SUBSTRB(anc_id_3
12757        ,INSTRB(anc_id_3,'(]',1,3) + 2
12758        ,INSTRB(anc_id_3,'(]',1,4) -
12759         INSTRB(anc_id_3,'(]',1,3) - 2)
12760 ,SUBSTRB(anc_id_3
12761        ,INSTRB(anc_id_3,'(]',1,4) + 2
12762        ,INSTRB(anc_id_3,'(]',1,5) -
12763         INSTRB(anc_id_3,'(]',1,4) - 2)
12764 ,SUBSTRB(anc_id_3
12765        ,INSTRB(anc_id_3,'(]',1,5) + 2
12766        ,INSTRB(anc_id_3,'(]',1,6) -
12767         INSTRB(anc_id_3,'(]',1,5) - 2)
12768 ,SUBSTRB(anc_id_3
12769        ,INSTRB(anc_id_3,'(]',1,6) + 2
12770        ,INSTRB(anc_id_3,'(]',1,7) -
12771         INSTRB(anc_id_3,'(]',1,6) - 2)
12772 ,SUBSTRB(anc_id_3
12773        ,INSTRB(anc_id_3,'(]',1,7) + 2
12774        ,LENGTHB(anc_id_3))
12775 )
12776 
12777 WHEN anc_id_4 IS NOT NULL THEN
12778   INTO xla_ae_header_acs (
12779         ae_header_id , object_version_number
12780       , analytical_criterion_code
12781       , analytical_criterion_type_code
12782       , amb_context_code
12783       , ac1,ac2,ac3,ac4,ac5)
12784 VALUES (ae_header_id, C_OVN
12785 ,SUBSTRB(anc_id_4
12786        ,1
12787        ,INSTRB(anc_id_4,'(]',1,1) -1)
12788 ,SUBSTRB(anc_id_4
12789        ,INSTRB(anc_id_4,'(]',1,1) + 2
12790        ,INSTRB(anc_id_4,'(]',1,2) -
12791         INSTRB(anc_id_4,'(]',1,1) - 2)
12792 ,SUBSTRB(anc_id_4
12793        ,INSTRB(anc_id_4,'(]',1,2) + 2
12794        ,INSTRB(anc_id_4,'(]',1,3) -
12795         INSTRB(anc_id_4,'(]',1,2) - 2)
12796 ,SUBSTRB(anc_id_4
12797        ,INSTRB(anc_id_4,'(]',1,3) + 2
12798        ,INSTRB(anc_id_4,'(]',1,4) -
12799         INSTRB(anc_id_4,'(]',1,3) - 2)
12800 ,SUBSTRB(anc_id_4
12801        ,INSTRB(anc_id_4,'(]',1,4) + 2
12802        ,INSTRB(anc_id_4,'(]',1,5) -
12803         INSTRB(anc_id_4,'(]',1,4) - 2)
12804 ,SUBSTRB(anc_id_4
12805        ,INSTRB(anc_id_4,'(]',1,5) + 2
12806        ,INSTRB(anc_id_4,'(]',1,6) -
12807         INSTRB(anc_id_4,'(]',1,5) - 2)
12808 ,SUBSTRB(anc_id_4
12809        ,INSTRB(anc_id_4,'(]',1,6) + 2
12810        ,INSTRB(anc_id_4,'(]',1,7) -
12811         INSTRB(anc_id_4,'(]',1,6) - 2)
12812 ,SUBSTRB(anc_id_4
12813        ,INSTRB(anc_id_4,'(]',1,7) + 2
12814        ,LENGTHB(anc_id_4))
12815 )
12816 
12817 WHEN anc_id_5 IS NOT NULL THEN
12818   INTO xla_ae_header_acs (
12819         ae_header_id , object_version_number
12820       , analytical_criterion_code
12821       , analytical_criterion_type_code
12822       , amb_context_code
12823       , ac1,ac2,ac3,ac4,ac5)
12824 VALUES (ae_header_id, C_OVN
12825 ,SUBSTRB(anc_id_5
12826        ,1
12827        ,INSTRB(anc_id_5,'(]',1,1) -1)
12828 ,SUBSTRB(anc_id_5
12829        ,INSTRB(anc_id_5,'(]',1,1) + 2
12830        ,INSTRB(anc_id_5,'(]',1,2) -
12831         INSTRB(anc_id_5,'(]',1,1) - 2)
12832 ,SUBSTRB(anc_id_5
12833        ,INSTRB(anc_id_5,'(]',1,2) + 2
12834        ,INSTRB(anc_id_5,'(]',1,3) -
12835         INSTRB(anc_id_5,'(]',1,2) - 2)
12836 ,SUBSTRB(anc_id_5
12837        ,INSTRB(anc_id_5,'(]',1,3) + 2
12838        ,INSTRB(anc_id_5,'(]',1,4) -
12839         INSTRB(anc_id_5,'(]',1,3) - 2)
12840 ,SUBSTRB(anc_id_5
12841        ,INSTRB(anc_id_5,'(]',1,4) + 2
12842        ,INSTRB(anc_id_5,'(]',1,5) -
12843         INSTRB(anc_id_5,'(]',1,4) - 2)
12844 ,SUBSTRB(anc_id_5
12845        ,INSTRB(anc_id_5,'(]',1,5) + 2
12846        ,INSTRB(anc_id_5,'(]',1,6) -
12847         INSTRB(anc_id_5,'(]',1,5) - 2)
12848 ,SUBSTRB(anc_id_5
12849        ,INSTRB(anc_id_5,'(]',1,6) + 2
12850        ,INSTRB(anc_id_5,'(]',1,7) -
12851         INSTRB(anc_id_5,'(]',1,6) - 2)
12852 ,SUBSTRB(anc_id_5
12853        ,INSTRB(anc_id_5,'(]',1,7) + 2
12854        ,LENGTHB(anc_id_5))
12855 )
12856 
12857 WHEN anc_id_6 IS NOT NULL THEN
12858   INTO xla_ae_header_acs (
12859         ae_header_id , object_version_number
12860       , analytical_criterion_code
12861       , analytical_criterion_type_code
12862       , amb_context_code
12863       , ac1,ac2,ac3,ac4,ac5)
12864 VALUES (ae_header_id, C_OVN
12865 ,SUBSTRB(anc_id_6
12866        ,1
12867        ,INSTRB(anc_id_6,'(]',1,1) -1)
12868 ,SUBSTRB(anc_id_6
12869        ,INSTRB(anc_id_6,'(]',1,1) + 2
12870        ,INSTRB(anc_id_6,'(]',1,2) -
12871         INSTRB(anc_id_6,'(]',1,1) - 2)
12872 ,SUBSTRB(anc_id_6
12873        ,INSTRB(anc_id_6,'(]',1,2) + 2
12874        ,INSTRB(anc_id_6,'(]',1,3) -
12875         INSTRB(anc_id_6,'(]',1,2) - 2)
12876 ,SUBSTRB(anc_id_6
12877        ,INSTRB(anc_id_6,'(]',1,3) + 2
12878        ,INSTRB(anc_id_6,'(]',1,4) -
12879         INSTRB(anc_id_6,'(]',1,3) - 2)
12880 ,SUBSTRB(anc_id_6
12881        ,INSTRB(anc_id_6,'(]',1,4) + 2
12882        ,INSTRB(anc_id_6,'(]',1,5) -
12883         INSTRB(anc_id_6,'(]',1,4) - 2)
12884 ,SUBSTRB(anc_id_6
12885        ,INSTRB(anc_id_6,'(]',1,5) + 2
12886        ,INSTRB(anc_id_6,'(]',1,6) -
12887         INSTRB(anc_id_6,'(]',1,5) - 2)
12888 ,SUBSTRB(anc_id_6
12889        ,INSTRB(anc_id_6,'(]',1,6) + 2
12890        ,INSTRB(anc_id_6,'(]',1,7) -
12891         INSTRB(anc_id_6,'(]',1,6) - 2)
12892 ,SUBSTRB(anc_id_6
12893        ,INSTRB(anc_id_6,'(]',1,7) + 2
12894        ,LENGTHB(anc_id_6))
12895 )
12896 
12897 WHEN anc_id_7 IS NOT NULL THEN
12898   INTO xla_ae_header_acs (
12899         ae_header_id , object_version_number
12900       , analytical_criterion_code
12901       , analytical_criterion_type_code
12902       , amb_context_code
12903       , ac1,ac2,ac3,ac4,ac5)
12904 VALUES (ae_header_id, C_OVN
12905 ,SUBSTRB(anc_id_7
12906        ,1
12907        ,INSTRB(anc_id_7,'(]',1,1) -1)
12908 ,SUBSTRB(anc_id_7
12909        ,INSTRB(anc_id_7,'(]',1,1) + 2
12910        ,INSTRB(anc_id_7,'(]',1,2) -
12911         INSTRB(anc_id_7,'(]',1,1) - 2)
12912 ,SUBSTRB(anc_id_7
12913        ,INSTRB(anc_id_7,'(]',1,2) + 2
12914        ,INSTRB(anc_id_7,'(]',1,3) -
12915         INSTRB(anc_id_7,'(]',1,2) - 2)
12916 ,SUBSTRB(anc_id_7
12917        ,INSTRB(anc_id_7,'(]',1,3) + 2
12918        ,INSTRB(anc_id_7,'(]',1,4) -
12919         INSTRB(anc_id_7,'(]',1,3) - 2)
12920 ,SUBSTRB(anc_id_7
12921        ,INSTRB(anc_id_7,'(]',1,4) + 2
12922        ,INSTRB(anc_id_7,'(]',1,5) -
12923         INSTRB(anc_id_7,'(]',1,4) - 2)
12924 ,SUBSTRB(anc_id_7
12925        ,INSTRB(anc_id_7,'(]',1,5) + 2
12926        ,INSTRB(anc_id_7,'(]',1,6) -
12927         INSTRB(anc_id_7,'(]',1,5) - 2)
12928 ,SUBSTRB(anc_id_7
12929        ,INSTRB(anc_id_7,'(]',1,6) + 2
12930        ,INSTRB(anc_id_7,'(]',1,7) -
12931         INSTRB(anc_id_7,'(]',1,6) - 2)
12932 ,SUBSTRB(anc_id_7
12933        ,INSTRB(anc_id_7,'(]',1,7) + 2
12934        ,LENGTHB(anc_id_7))
12935 )
12936 
12937 WHEN anc_id_8 IS NOT NULL THEN
12938   INTO xla_ae_header_acs (
12939         ae_header_id , object_version_number
12940       , analytical_criterion_code
12941       , analytical_criterion_type_code
12942       , amb_context_code
12943       , ac1,ac2,ac3,ac4,ac5)
12944 VALUES (ae_header_id, C_OVN
12945 ,SUBSTRB(anc_id_8
12946        ,1
12947        ,INSTRB(anc_id_8,'(]',1,1) -1)
12948 ,SUBSTRB(anc_id_8
12949        ,INSTRB(anc_id_8,'(]',1,1) + 2
12950        ,INSTRB(anc_id_8,'(]',1,2) -
12951         INSTRB(anc_id_8,'(]',1,1) - 2)
12952 ,SUBSTRB(anc_id_8
12953        ,INSTRB(anc_id_8,'(]',1,2) + 2
12954        ,INSTRB(anc_id_8,'(]',1,3) -
12955         INSTRB(anc_id_8,'(]',1,2) - 2)
12956 ,SUBSTRB(anc_id_8
12957        ,INSTRB(anc_id_8,'(]',1,3) + 2
12958        ,INSTRB(anc_id_8,'(]',1,4) -
12959         INSTRB(anc_id_8,'(]',1,3) - 2)
12960 ,SUBSTRB(anc_id_8
12961        ,INSTRB(anc_id_8,'(]',1,4) + 2
12962        ,INSTRB(anc_id_8,'(]',1,5) -
12963         INSTRB(anc_id_8,'(]',1,4) - 2)
12964 ,SUBSTRB(anc_id_8
12965        ,INSTRB(anc_id_8,'(]',1,5) + 2
12966        ,INSTRB(anc_id_8,'(]',1,6) -
12967         INSTRB(anc_id_8,'(]',1,5) - 2)
12968 ,SUBSTRB(anc_id_8
12969        ,INSTRB(anc_id_8,'(]',1,6) + 2
12970        ,INSTRB(anc_id_8,'(]',1,7) -
12971         INSTRB(anc_id_8,'(]',1,6) - 2)
12972 ,SUBSTRB(anc_id_8
12973        ,INSTRB(anc_id_8,'(]',1,7) + 2
12974        ,LENGTHB(anc_id_8))
12975 )
12976 
12977 WHEN anc_id_9 IS NOT NULL THEN
12978   INTO xla_ae_header_acs (
12979         ae_header_id , object_version_number
12980       , analytical_criterion_code
12981       , analytical_criterion_type_code
12982       , amb_context_code
12983       , ac1,ac2,ac3,ac4,ac5)
12984 VALUES (ae_header_id, C_OVN
12985 ,SUBSTRB(anc_id_9
12986        ,1
12987        ,INSTRB(anc_id_9,'(]',1,1) -1)
12988 ,SUBSTRB(anc_id_9
12989        ,INSTRB(anc_id_9,'(]',1,1) + 2
12990        ,INSTRB(anc_id_9,'(]',1,2) -
12991         INSTRB(anc_id_9,'(]',1,1) - 2)
12992 ,SUBSTRB(anc_id_9
12993        ,INSTRB(anc_id_9,'(]',1,2) + 2
12994        ,INSTRB(anc_id_9,'(]',1,3) -
12995         INSTRB(anc_id_9,'(]',1,2) - 2)
12996 ,SUBSTRB(anc_id_9
12997        ,INSTRB(anc_id_9,'(]',1,3) + 2
12998        ,INSTRB(anc_id_9,'(]',1,4) -
12999         INSTRB(anc_id_9,'(]',1,3) - 2)
13000 ,SUBSTRB(anc_id_9
13001        ,INSTRB(anc_id_9,'(]',1,4) + 2
13002        ,INSTRB(anc_id_9,'(]',1,5) -
13003         INSTRB(anc_id_9,'(]',1,4) - 2)
13004 ,SUBSTRB(anc_id_9
13005        ,INSTRB(anc_id_9,'(]',1,5) + 2
13006        ,INSTRB(anc_id_9,'(]',1,6) -
13007         INSTRB(anc_id_9,'(]',1,5) - 2)
13008 ,SUBSTRB(anc_id_9
13009        ,INSTRB(anc_id_9,'(]',1,6) + 2
13010        ,INSTRB(anc_id_9,'(]',1,7) -
13011         INSTRB(anc_id_9,'(]',1,6) - 2)
13012 ,SUBSTRB(anc_id_9
13013        ,INSTRB(anc_id_9,'(]',1,7) + 2
13014        ,LENGTHB(anc_id_9))
13015 )
13016 
13017 WHEN anc_id_10 IS NOT NULL THEN
13018   INTO xla_ae_header_acs (
13019         ae_header_id , object_version_number
13020       , analytical_criterion_code
13021       , analytical_criterion_type_code
13022       , amb_context_code
13023       , ac1,ac2,ac3,ac4,ac5)
13024 VALUES (ae_header_id, C_OVN
13025 ,SUBSTRB(anc_id_10
13026        ,1
13027        ,INSTRB(anc_id_10,'(]',1,1) -1)
13028 ,SUBSTRB(anc_id_10
13029        ,INSTRB(anc_id_10,'(]',1,1) + 2
13030        ,INSTRB(anc_id_10,'(]',1,2) -
13031         INSTRB(anc_id_10,'(]',1,1) - 2)
13032 ,SUBSTRB(anc_id_10
13033        ,INSTRB(anc_id_10,'(]',1,2) + 2
13034        ,INSTRB(anc_id_10,'(]',1,3) -
13035         INSTRB(anc_id_10,'(]',1,2) - 2)
13036 ,SUBSTRB(anc_id_10
13037        ,INSTRB(anc_id_10,'(]',1,3) + 2
13038        ,INSTRB(anc_id_10,'(]',1,4) -
13039         INSTRB(anc_id_10,'(]',1,3) - 2)
13040 ,SUBSTRB(anc_id_10
13041        ,INSTRB(anc_id_10,'(]',1,4) + 2
13042        ,INSTRB(anc_id_10,'(]',1,5) -
13043         INSTRB(anc_id_10,'(]',1,4) - 2)
13044 ,SUBSTRB(anc_id_10
13045        ,INSTRB(anc_id_10,'(]',1,5) + 2
13046        ,INSTRB(anc_id_10,'(]',1,6) -
13047         INSTRB(anc_id_10,'(]',1,5) - 2)
13048 ,SUBSTRB(anc_id_10
13049        ,INSTRB(anc_id_10,'(]',1,6) + 2
13050        ,INSTRB(anc_id_10,'(]',1,7) -
13051         INSTRB(anc_id_10,'(]',1,6) - 2)
13052 ,SUBSTRB(anc_id_10
13053        ,INSTRB(anc_id_10,'(]',1,7) + 2
13054        ,LENGTHB(anc_id_10))
13055 )
13056 
13057 SELECT  ae_header_id
13058       , anc_id_1
13059       , anc_id_2
13060       , anc_id_3
13061       , anc_id_4
13062       , anc_id_5
13063       , anc_id_6
13064       , anc_id_7
13065       , anc_id_8
13066       , anc_id_9
13067       , anc_id_10
13068  FROM  xla_ae_headers_gt
13069 WHERE  ae_header_id is not null;
13070 
13071 --
13072 IF (C_LEVEL_EVENT >= g_log_level) THEN
13073       trace
13074          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
13075          ,p_level    => C_LEVEL_EVENT
13076          ,p_module   => l_log_module);
13077 END IF;
13078 
13079 --
13080 EXCEPTION
13081 WHEN OTHERS THEN
13082   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
13083          trace
13084             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
13085             ,p_level    => C_LEVEL_EXCEPTION
13086             ,p_module   => l_log_module);
13087   END IF;
13088 
13089   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
13090                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
13091                                     ,p_token_1      => 'ERROR'
13092                                     ,p_value_1      => sqlerrm
13093                                     );
13094 END;
13095 --
13096 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13097 
13098       trace
13099          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
13100          ,p_level    => C_LEVEL_PROCEDURE
13101          ,p_module   => l_log_module);
13102 
13103       trace
13104          (p_msg      => 'END of InsertHdrAnalyticalCriteria10'
13105          ,p_level    => C_LEVEL_PROCEDURE
13106          ,p_module   => l_log_module);
13107 END IF;
13108 --
13109 EXCEPTION
13110 WHEN xla_exceptions_pkg.application_exception THEN
13111   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
13112        trace
13113            (p_msg      => 'Error. = '||sqlerrm
13114            ,p_level    => C_LEVEL_PROCEDURE
13115            ,p_module   => l_log_module);
13116   END IF;
13117   RAISE;
13118 WHEN OTHERS  THEN
13119  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
13120        trace
13121            (p_msg      => 'Error. = '||sqlerrm
13122            ,p_level    => C_LEVEL_PROCEDURE
13123            ,p_module   => l_log_module);
13124   END IF;
13125   xla_exceptions_pkg.raise_message
13126                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria10');
13127    --
13128 END InsertHdrAnalyticalCriteria10;
13129 
13130 --
13131 /*======================================================================+
13132 |                                                                       |
13133 | Insert Header Analytical Criteria 50                                  |
13134 |                                                                       |
13135 |                                                                       |
13136 +======================================================================*/
13137 --
13138 PROCEDURE InsertHdrAnalyticalCriteria50
13139 IS
13140 l_log_module         VARCHAR2(240);
13141 BEGIN
13142 --
13143 IF g_log_enabled THEN
13144       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria50';
13145 END IF;
13146 --
13147 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
13148 
13149       trace
13150          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria50'
13151          ,p_level    => C_LEVEL_PROCEDURE
13152          ,p_module   => l_log_module);
13153 END IF;
13154 --
13155 BEGIN
13156 
13157    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
13158 
13159       trace
13160          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
13161          ,p_level    => C_LEVEL_STATEMENT
13162          ,p_module   => l_log_module);
13163 
13164    END IF;
13165 --
13166 
13167 INSERT ALL
13168 WHEN anc_id_1 IS NOT NULL THEN
13169   INTO xla_ae_header_acs (
13170         ae_header_id , object_version_number
13171       , analytical_criterion_code
13172       , analytical_criterion_type_code
13173       , amb_context_code
13174       , ac1,ac2,ac3,ac4,ac5)
13175 VALUES (ae_header_id, C_OVN
13176 ,SUBSTRB(anc_id_1
13177        ,1
13178        ,INSTRB(anc_id_1,'(]',1,1) -1)
13179 ,SUBSTRB(anc_id_1
13180        ,INSTRB(anc_id_1,'(]',1,1) + 2
13181        ,INSTRB(anc_id_1,'(]',1,2) -
13182         INSTRB(anc_id_1,'(]',1,1) - 2)
13183 ,SUBSTRB(anc_id_1
13184        ,INSTRB(anc_id_1,'(]',1,2) + 2
13185        ,INSTRB(anc_id_1,'(]',1,3) -
13186         INSTRB(anc_id_1,'(]',1,2) - 2)
13187 ,SUBSTRB(anc_id_1
13188        ,INSTRB(anc_id_1,'(]',1,3) + 2
13189        ,INSTRB(anc_id_1,'(]',1,4) -
13190         INSTRB(anc_id_1,'(]',1,3) - 2)
13191 ,SUBSTRB(anc_id_1
13192        ,INSTRB(anc_id_1,'(]',1,4) + 2
13193        ,INSTRB(anc_id_1,'(]',1,5) -
13194         INSTRB(anc_id_1,'(]',1,4) - 2)
13195 ,SUBSTRB(anc_id_1
13196        ,INSTRB(anc_id_1,'(]',1,5) + 2
13197        ,INSTRB(anc_id_1,'(]',1,6) -
13198         INSTRB(anc_id_1,'(]',1,5) - 2)
13199 ,SUBSTRB(anc_id_1
13200        ,INSTRB(anc_id_1,'(]',1,6) + 2
13201        ,INSTRB(anc_id_1,'(]',1,7) -
13202         INSTRB(anc_id_1,'(]',1,6) - 2)
13203 ,SUBSTRB(anc_id_1
13204        ,INSTRB(anc_id_1,'(]',1,7) + 2
13205        ,LENGTHB(anc_id_1))
13206 )
13207 
13208 WHEN anc_id_2 IS NOT NULL THEN
13209   INTO xla_ae_header_acs (
13210         ae_header_id , object_version_number
13211       , analytical_criterion_code
13212       , analytical_criterion_type_code
13213       , amb_context_code
13214       , ac1,ac2,ac3,ac4,ac5)
13215 VALUES (ae_header_id, C_OVN
13216 ,SUBSTRB(anc_id_2
13217        ,1
13218        ,INSTRB(anc_id_2,'(]',1,1) -1)
13219 ,SUBSTRB(anc_id_2
13220        ,INSTRB(anc_id_2,'(]',1,1) + 2
13221        ,INSTRB(anc_id_2,'(]',1,2) -
13222         INSTRB(anc_id_2,'(]',1,1) - 2)
13223 ,SUBSTRB(anc_id_2
13224        ,INSTRB(anc_id_2,'(]',1,2) + 2
13225        ,INSTRB(anc_id_2,'(]',1,3) -
13226         INSTRB(anc_id_2,'(]',1,2) - 2)
13227 ,SUBSTRB(anc_id_2
13228        ,INSTRB(anc_id_2,'(]',1,3) + 2
13229        ,INSTRB(anc_id_2,'(]',1,4) -
13230         INSTRB(anc_id_2,'(]',1,3) - 2)
13231 ,SUBSTRB(anc_id_2
13232        ,INSTRB(anc_id_2,'(]',1,4) + 2
13233        ,INSTRB(anc_id_2,'(]',1,5) -
13234         INSTRB(anc_id_2,'(]',1,4) - 2)
13235 ,SUBSTRB(anc_id_2
13236        ,INSTRB(anc_id_2,'(]',1,5) + 2
13237        ,INSTRB(anc_id_2,'(]',1,6) -
13238         INSTRB(anc_id_2,'(]',1,5) - 2)
13239 ,SUBSTRB(anc_id_2
13240        ,INSTRB(anc_id_2,'(]',1,6) + 2
13241        ,INSTRB(anc_id_2,'(]',1,7) -
13242         INSTRB(anc_id_2,'(]',1,6) - 2)
13243 ,SUBSTRB(anc_id_2
13244        ,INSTRB(anc_id_2,'(]',1,7) + 2
13245        ,LENGTHB(anc_id_2))
13246 )
13247 
13248 WHEN anc_id_3 IS NOT NULL THEN
13249   INTO xla_ae_header_acs (
13250         ae_header_id , object_version_number
13251       , analytical_criterion_code
13252       , analytical_criterion_type_code
13253       , amb_context_code
13254       , ac1,ac2,ac3,ac4,ac5)
13255 VALUES (ae_header_id, C_OVN
13256 ,SUBSTRB(anc_id_3
13257        ,1
13258        ,INSTRB(anc_id_3,'(]',1,1) -1)
13259 ,SUBSTRB(anc_id_3
13260        ,INSTRB(anc_id_3,'(]',1,1) + 2
13261        ,INSTRB(anc_id_3,'(]',1,2) -
13262         INSTRB(anc_id_3,'(]',1,1) - 2)
13263 ,SUBSTRB(anc_id_3
13264        ,INSTRB(anc_id_3,'(]',1,2) + 2
13265        ,INSTRB(anc_id_3,'(]',1,3) -
13266         INSTRB(anc_id_3,'(]',1,2) - 2)
13267 ,SUBSTRB(anc_id_3
13268        ,INSTRB(anc_id_3,'(]',1,3) + 2
13269        ,INSTRB(anc_id_3,'(]',1,4) -
13270         INSTRB(anc_id_3,'(]',1,3) - 2)
13271 ,SUBSTRB(anc_id_3
13272        ,INSTRB(anc_id_3,'(]',1,4) + 2
13273        ,INSTRB(anc_id_3,'(]',1,5) -
13274         INSTRB(anc_id_3,'(]',1,4) - 2)
13275 ,SUBSTRB(anc_id_3
13276        ,INSTRB(anc_id_3,'(]',1,5) + 2
13277        ,INSTRB(anc_id_3,'(]',1,6) -
13278         INSTRB(anc_id_3,'(]',1,5) - 2)
13279 ,SUBSTRB(anc_id_3
13280        ,INSTRB(anc_id_3,'(]',1,6) + 2
13281        ,INSTRB(anc_id_3,'(]',1,7) -
13282         INSTRB(anc_id_3,'(]',1,6) - 2)
13283 ,SUBSTRB(anc_id_3
13284        ,INSTRB(anc_id_3,'(]',1,7) + 2
13285        ,LENGTHB(anc_id_3))
13286 )
13287 
13288 WHEN anc_id_4 IS NOT NULL THEN
13289   INTO xla_ae_header_acs (
13290         ae_header_id , object_version_number
13291       , analytical_criterion_code
13292       , analytical_criterion_type_code
13293       , amb_context_code
13294       , ac1,ac2,ac3,ac4,ac5)
13295 VALUES (ae_header_id, C_OVN
13296 ,SUBSTRB(anc_id_4
13297        ,1
13298        ,INSTRB(anc_id_4,'(]',1,1) -1)
13299 ,SUBSTRB(anc_id_4
13300        ,INSTRB(anc_id_4,'(]',1,1) + 2
13301        ,INSTRB(anc_id_4,'(]',1,2) -
13302         INSTRB(anc_id_4,'(]',1,1) - 2)
13303 ,SUBSTRB(anc_id_4
13304        ,INSTRB(anc_id_4,'(]',1,2) + 2
13305        ,INSTRB(anc_id_4,'(]',1,3) -
13306         INSTRB(anc_id_4,'(]',1,2) - 2)
13307 ,SUBSTRB(anc_id_4
13308        ,INSTRB(anc_id_4,'(]',1,3) + 2
13309        ,INSTRB(anc_id_4,'(]',1,4) -
13310         INSTRB(anc_id_4,'(]',1,3) - 2)
13311 ,SUBSTRB(anc_id_4
13312        ,INSTRB(anc_id_4,'(]',1,4) + 2
13313        ,INSTRB(anc_id_4,'(]',1,5) -
13314         INSTRB(anc_id_4,'(]',1,4) - 2)
13315 ,SUBSTRB(anc_id_4
13316        ,INSTRB(anc_id_4,'(]',1,5) + 2
13317        ,INSTRB(anc_id_4,'(]',1,6) -
13318         INSTRB(anc_id_4,'(]',1,5) - 2)
13319 ,SUBSTRB(anc_id_4
13320        ,INSTRB(anc_id_4,'(]',1,6) + 2
13321        ,INSTRB(anc_id_4,'(]',1,7) -
13322         INSTRB(anc_id_4,'(]',1,6) - 2)
13323 ,SUBSTRB(anc_id_4
13324        ,INSTRB(anc_id_4,'(]',1,7) + 2
13325        ,LENGTHB(anc_id_4))
13326 )
13327 
13328 WHEN anc_id_5 IS NOT NULL THEN
13329   INTO xla_ae_header_acs (
13330         ae_header_id , object_version_number
13331       , analytical_criterion_code
13332       , analytical_criterion_type_code
13333       , amb_context_code
13334       , ac1,ac2,ac3,ac4,ac5)
13335 VALUES (ae_header_id, C_OVN
13336 ,SUBSTRB(anc_id_5
13337        ,1
13338        ,INSTRB(anc_id_5,'(]',1,1) -1)
13339 ,SUBSTRB(anc_id_5
13340        ,INSTRB(anc_id_5,'(]',1,1) + 2
13341        ,INSTRB(anc_id_5,'(]',1,2) -
13342         INSTRB(anc_id_5,'(]',1,1) - 2)
13343 ,SUBSTRB(anc_id_5
13344        ,INSTRB(anc_id_5,'(]',1,2) + 2
13345        ,INSTRB(anc_id_5,'(]',1,3) -
13346         INSTRB(anc_id_5,'(]',1,2) - 2)
13347 ,SUBSTRB(anc_id_5
13348        ,INSTRB(anc_id_5,'(]',1,3) + 2
13349        ,INSTRB(anc_id_5,'(]',1,4) -
13350         INSTRB(anc_id_5,'(]',1,3) - 2)
13351 ,SUBSTRB(anc_id_5
13352        ,INSTRB(anc_id_5,'(]',1,4) + 2
13353        ,INSTRB(anc_id_5,'(]',1,5) -
13354         INSTRB(anc_id_5,'(]',1,4) - 2)
13355 ,SUBSTRB(anc_id_5
13356        ,INSTRB(anc_id_5,'(]',1,5) + 2
13357        ,INSTRB(anc_id_5,'(]',1,6) -
13358         INSTRB(anc_id_5,'(]',1,5) - 2)
13359 ,SUBSTRB(anc_id_5
13360        ,INSTRB(anc_id_5,'(]',1,6) + 2
13361        ,INSTRB(anc_id_5,'(]',1,7) -
13362         INSTRB(anc_id_5,'(]',1,6) - 2)
13363 ,SUBSTRB(anc_id_5
13364        ,INSTRB(anc_id_5,'(]',1,7) + 2
13365        ,LENGTHB(anc_id_5))
13366 )
13367 
13368 WHEN anc_id_6 IS NOT NULL THEN
13369   INTO xla_ae_header_acs (
13370         ae_header_id , object_version_number
13371       , analytical_criterion_code
13372       , analytical_criterion_type_code
13373       , amb_context_code
13374       , ac1,ac2,ac3,ac4,ac5)
13375 VALUES (ae_header_id, C_OVN
13376 ,SUBSTRB(anc_id_6
13377        ,1
13378        ,INSTRB(anc_id_6,'(]',1,1) -1)
13379 ,SUBSTRB(anc_id_6
13380        ,INSTRB(anc_id_6,'(]',1,1) + 2
13381        ,INSTRB(anc_id_6,'(]',1,2) -
13382         INSTRB(anc_id_6,'(]',1,1) - 2)
13383 ,SUBSTRB(anc_id_6
13384        ,INSTRB(anc_id_6,'(]',1,2) + 2
13385        ,INSTRB(anc_id_6,'(]',1,3) -
13386         INSTRB(anc_id_6,'(]',1,2) - 2)
13387 ,SUBSTRB(anc_id_6
13388        ,INSTRB(anc_id_6,'(]',1,3) + 2
13389        ,INSTRB(anc_id_6,'(]',1,4) -
13390         INSTRB(anc_id_6,'(]',1,3) - 2)
13391 ,SUBSTRB(anc_id_6
13392        ,INSTRB(anc_id_6,'(]',1,4) + 2
13393        ,INSTRB(anc_id_6,'(]',1,5) -
13394         INSTRB(anc_id_6,'(]',1,4) - 2)
13395 ,SUBSTRB(anc_id_6
13396        ,INSTRB(anc_id_6,'(]',1,5) + 2
13397        ,INSTRB(anc_id_6,'(]',1,6) -
13398         INSTRB(anc_id_6,'(]',1,5) - 2)
13399 ,SUBSTRB(anc_id_6
13400        ,INSTRB(anc_id_6,'(]',1,6) + 2
13401        ,INSTRB(anc_id_6,'(]',1,7) -
13402         INSTRB(anc_id_6,'(]',1,6) - 2)
13403 ,SUBSTRB(anc_id_6
13404        ,INSTRB(anc_id_6,'(]',1,7) + 2
13405        ,LENGTHB(anc_id_6))
13406 )
13407 
13408 WHEN anc_id_7 IS NOT NULL THEN
13409   INTO xla_ae_header_acs (
13410         ae_header_id , object_version_number
13411       , analytical_criterion_code
13412       , analytical_criterion_type_code
13413       , amb_context_code
13414       , ac1,ac2,ac3,ac4,ac5)
13415 VALUES (ae_header_id, C_OVN
13416 ,SUBSTRB(anc_id_7
13417        ,1
13418        ,INSTRB(anc_id_7,'(]',1,1) -1)
13419 ,SUBSTRB(anc_id_7
13420        ,INSTRB(anc_id_7,'(]',1,1) + 2
13421        ,INSTRB(anc_id_7,'(]',1,2) -
13422         INSTRB(anc_id_7,'(]',1,1) - 2)
13423 ,SUBSTRB(anc_id_7
13424        ,INSTRB(anc_id_7,'(]',1,2) + 2
13425        ,INSTRB(anc_id_7,'(]',1,3) -
13426         INSTRB(anc_id_7,'(]',1,2) - 2)
13427 ,SUBSTRB(anc_id_7
13428        ,INSTRB(anc_id_7,'(]',1,3) + 2
13429        ,INSTRB(anc_id_7,'(]',1,4) -
13430         INSTRB(anc_id_7,'(]',1,3) - 2)
13431 ,SUBSTRB(anc_id_7
13432        ,INSTRB(anc_id_7,'(]',1,4) + 2
13433        ,INSTRB(anc_id_7,'(]',1,5) -
13434         INSTRB(anc_id_7,'(]',1,4) - 2)
13435 ,SUBSTRB(anc_id_7
13436        ,INSTRB(anc_id_7,'(]',1,5) + 2
13437        ,INSTRB(anc_id_7,'(]',1,6) -
13438         INSTRB(anc_id_7,'(]',1,5) - 2)
13439 ,SUBSTRB(anc_id_7
13440        ,INSTRB(anc_id_7,'(]',1,6) + 2
13441        ,INSTRB(anc_id_7,'(]',1,7) -
13442         INSTRB(anc_id_7,'(]',1,6) - 2)
13443 ,SUBSTRB(anc_id_7
13444        ,INSTRB(anc_id_7,'(]',1,7) + 2
13445        ,LENGTHB(anc_id_7))
13446 )
13447 
13448 WHEN anc_id_8 IS NOT NULL THEN
13449   INTO xla_ae_header_acs (
13450         ae_header_id , object_version_number
13451       , analytical_criterion_code
13452       , analytical_criterion_type_code
13453       , amb_context_code
13454       , ac1,ac2,ac3,ac4,ac5)
13455 VALUES (ae_header_id, C_OVN
13456 ,SUBSTRB(anc_id_8
13457        ,1
13458        ,INSTRB(anc_id_8,'(]',1,1) -1)
13459 ,SUBSTRB(anc_id_8
13460        ,INSTRB(anc_id_8,'(]',1,1) + 2
13461        ,INSTRB(anc_id_8,'(]',1,2) -
13462         INSTRB(anc_id_8,'(]',1,1) - 2)
13463 ,SUBSTRB(anc_id_8
13464        ,INSTRB(anc_id_8,'(]',1,2) + 2
13465        ,INSTRB(anc_id_8,'(]',1,3) -
13466         INSTRB(anc_id_8,'(]',1,2) - 2)
13467 ,SUBSTRB(anc_id_8
13468        ,INSTRB(anc_id_8,'(]',1,3) + 2
13469        ,INSTRB(anc_id_8,'(]',1,4) -
13470         INSTRB(anc_id_8,'(]',1,3) - 2)
13471 ,SUBSTRB(anc_id_8
13472        ,INSTRB(anc_id_8,'(]',1,4) + 2
13473        ,INSTRB(anc_id_8,'(]',1,5) -
13474         INSTRB(anc_id_8,'(]',1,4) - 2)
13475 ,SUBSTRB(anc_id_8
13476        ,INSTRB(anc_id_8,'(]',1,5) + 2
13477        ,INSTRB(anc_id_8,'(]',1,6) -
13478         INSTRB(anc_id_8,'(]',1,5) - 2)
13479 ,SUBSTRB(anc_id_8
13480        ,INSTRB(anc_id_8,'(]',1,6) + 2
13481        ,INSTRB(anc_id_8,'(]',1,7) -
13482         INSTRB(anc_id_8,'(]',1,6) - 2)
13483 ,SUBSTRB(anc_id_8
13484        ,INSTRB(anc_id_8,'(]',1,7) + 2
13485        ,LENGTHB(anc_id_8))
13486 )
13487 
13488 WHEN anc_id_9 IS NOT NULL THEN
13489   INTO xla_ae_header_acs (
13490         ae_header_id , object_version_number
13491       , analytical_criterion_code
13492       , analytical_criterion_type_code
13493       , amb_context_code
13494       , ac1,ac2,ac3,ac4,ac5)
13495 VALUES (ae_header_id, C_OVN
13496 ,SUBSTRB(anc_id_9
13497        ,1
13498        ,INSTRB(anc_id_9,'(]',1,1) -1)
13499 ,SUBSTRB(anc_id_9
13500        ,INSTRB(anc_id_9,'(]',1,1) + 2
13501        ,INSTRB(anc_id_9,'(]',1,2) -
13502         INSTRB(anc_id_9,'(]',1,1) - 2)
13503 ,SUBSTRB(anc_id_9
13504        ,INSTRB(anc_id_9,'(]',1,2) + 2
13505        ,INSTRB(anc_id_9,'(]',1,3) -
13506         INSTRB(anc_id_9,'(]',1,2) - 2)
13507 ,SUBSTRB(anc_id_9
13508        ,INSTRB(anc_id_9,'(]',1,3) + 2
13509        ,INSTRB(anc_id_9,'(]',1,4) -
13510         INSTRB(anc_id_9,'(]',1,3) - 2)
13511 ,SUBSTRB(anc_id_9
13512        ,INSTRB(anc_id_9,'(]',1,4) + 2
13513        ,INSTRB(anc_id_9,'(]',1,5) -
13514         INSTRB(anc_id_9,'(]',1,4) - 2)
13515 ,SUBSTRB(anc_id_9
13516        ,INSTRB(anc_id_9,'(]',1,5) + 2
13517        ,INSTRB(anc_id_9,'(]',1,6) -
13518         INSTRB(anc_id_9,'(]',1,5) - 2)
13519 ,SUBSTRB(anc_id_9
13520        ,INSTRB(anc_id_9,'(]',1,6) + 2
13521        ,INSTRB(anc_id_9,'(]',1,7) -
13522         INSTRB(anc_id_9,'(]',1,6) - 2)
13523 ,SUBSTRB(anc_id_9
13524        ,INSTRB(anc_id_9,'(]',1,7) + 2
13525        ,LENGTHB(anc_id_9))
13526 )
13527 
13528 WHEN anc_id_10 IS NOT NULL THEN
13529   INTO xla_ae_header_acs (
13530         ae_header_id , object_version_number
13531       , analytical_criterion_code
13532       , analytical_criterion_type_code
13533       , amb_context_code
13534       , ac1,ac2,ac3,ac4,ac5)
13535 VALUES (ae_header_id, C_OVN
13536 ,SUBSTRB(anc_id_10
13537        ,1
13538        ,INSTRB(anc_id_10,'(]',1,1) -1)
13539 ,SUBSTRB(anc_id_10
13540        ,INSTRB(anc_id_10,'(]',1,1) + 2
13541        ,INSTRB(anc_id_10,'(]',1,2) -
13542         INSTRB(anc_id_10,'(]',1,1) - 2)
13543 ,SUBSTRB(anc_id_10
13544        ,INSTRB(anc_id_10,'(]',1,2) + 2
13545        ,INSTRB(anc_id_10,'(]',1,3) -
13546         INSTRB(anc_id_10,'(]',1,2) - 2)
13547 ,SUBSTRB(anc_id_10
13548        ,INSTRB(anc_id_10,'(]',1,3) + 2
13549        ,INSTRB(anc_id_10,'(]',1,4) -
13550         INSTRB(anc_id_10,'(]',1,3) - 2)
13551 ,SUBSTRB(anc_id_10
13552        ,INSTRB(anc_id_10,'(]',1,4) + 2
13553        ,INSTRB(anc_id_10,'(]',1,5) -
13554         INSTRB(anc_id_10,'(]',1,4) - 2)
13555 ,SUBSTRB(anc_id_10
13556        ,INSTRB(anc_id_10,'(]',1,5) + 2
13557        ,INSTRB(anc_id_10,'(]',1,6) -
13558         INSTRB(anc_id_10,'(]',1,5) - 2)
13559 ,SUBSTRB(anc_id_10
13560        ,INSTRB(anc_id_10,'(]',1,6) + 2
13561        ,INSTRB(anc_id_10,'(]',1,7) -
13562         INSTRB(anc_id_10,'(]',1,6) - 2)
13563 ,SUBSTRB(anc_id_10
13564        ,INSTRB(anc_id_10,'(]',1,7) + 2
13565        ,LENGTHB(anc_id_10))
13566 )
13567 
13568 WHEN anc_id_11 IS NOT NULL THEN
13569   INTO xla_ae_header_acs (
13570         ae_header_id , object_version_number
13571       , analytical_criterion_code
13572       , analytical_criterion_type_code
13573       , amb_context_code
13574       , ac1,ac2,ac3,ac4,ac5)
13575 VALUES (ae_header_id, C_OVN
13576 ,SUBSTRB(anc_id_11
13577        ,1
13578        ,INSTRB(anc_id_11,'(]',1,1) -1)
13579 ,SUBSTRB(anc_id_11
13580        ,INSTRB(anc_id_11,'(]',1,1) + 2
13581        ,INSTRB(anc_id_11,'(]',1,2) -
13582         INSTRB(anc_id_11,'(]',1,1) - 2)
13583 ,SUBSTRB(anc_id_11
13584        ,INSTRB(anc_id_11,'(]',1,2) + 2
13585        ,INSTRB(anc_id_11,'(]',1,3) -
13586         INSTRB(anc_id_11,'(]',1,2) - 2)
13587 ,SUBSTRB(anc_id_11
13588        ,INSTRB(anc_id_11,'(]',1,3) + 2
13589        ,INSTRB(anc_id_11,'(]',1,4) -
13590         INSTRB(anc_id_11,'(]',1,3) - 2)
13591 ,SUBSTRB(anc_id_11
13592        ,INSTRB(anc_id_11,'(]',1,4) + 2
13593        ,INSTRB(anc_id_11,'(]',1,5) -
13594         INSTRB(anc_id_11,'(]',1,4) - 2)
13595 ,SUBSTRB(anc_id_11
13596        ,INSTRB(anc_id_11,'(]',1,5) + 2
13597        ,INSTRB(anc_id_11,'(]',1,6) -
13598         INSTRB(anc_id_11,'(]',1,5) - 2)
13599 ,SUBSTRB(anc_id_11
13600        ,INSTRB(anc_id_11,'(]',1,6) + 2
13601        ,INSTRB(anc_id_11,'(]',1,7) -
13602         INSTRB(anc_id_11,'(]',1,6) - 2)
13603 ,SUBSTRB(anc_id_11
13604        ,INSTRB(anc_id_11,'(]',1,7) + 2
13605        ,LENGTHB(anc_id_11))
13606 )
13607 
13608 WHEN anc_id_12 IS NOT NULL THEN
13609   INTO xla_ae_header_acs (
13610         ae_header_id , object_version_number
13611       , analytical_criterion_code
13612       , analytical_criterion_type_code
13613       , amb_context_code
13614       , ac1,ac2,ac3,ac4,ac5)
13615 VALUES (ae_header_id, C_OVN
13616 ,SUBSTRB(anc_id_12
13617        ,1
13618        ,INSTRB(anc_id_12,'(]',1,1) -1)
13619 ,SUBSTRB(anc_id_12
13620        ,INSTRB(anc_id_12,'(]',1,1) + 2
13621        ,INSTRB(anc_id_12,'(]',1,2) -
13622         INSTRB(anc_id_12,'(]',1,1) - 2)
13623 ,SUBSTRB(anc_id_12
13624        ,INSTRB(anc_id_12,'(]',1,2) + 2
13625        ,INSTRB(anc_id_12,'(]',1,3) -
13626         INSTRB(anc_id_12,'(]',1,2) - 2)
13627 ,SUBSTRB(anc_id_12
13628        ,INSTRB(anc_id_12,'(]',1,3) + 2
13629        ,INSTRB(anc_id_12,'(]',1,4) -
13630         INSTRB(anc_id_12,'(]',1,3) - 2)
13631 ,SUBSTRB(anc_id_12
13632        ,INSTRB(anc_id_12,'(]',1,4) + 2
13633        ,INSTRB(anc_id_12,'(]',1,5) -
13634         INSTRB(anc_id_12,'(]',1,4) - 2)
13635 ,SUBSTRB(anc_id_12
13636        ,INSTRB(anc_id_12,'(]',1,5) + 2
13637        ,INSTRB(anc_id_12,'(]',1,6) -
13638         INSTRB(anc_id_12,'(]',1,5) - 2)
13639 ,SUBSTRB(anc_id_12
13640        ,INSTRB(anc_id_12,'(]',1,6) + 2
13641        ,INSTRB(anc_id_12,'(]',1,7) -
13642         INSTRB(anc_id_12,'(]',1,6) - 2)
13643 ,SUBSTRB(anc_id_12
13644        ,INSTRB(anc_id_12,'(]',1,7) + 2
13645        ,LENGTHB(anc_id_12))
13646 )
13647 
13648 WHEN anc_id_13 IS NOT NULL THEN
13649   INTO xla_ae_header_acs (
13650         ae_header_id , object_version_number
13651       , analytical_criterion_code
13652       , analytical_criterion_type_code
13653       , amb_context_code
13654       , ac1,ac2,ac3,ac4,ac5)
13655 VALUES (ae_header_id, C_OVN
13656 ,SUBSTRB(anc_id_13
13657        ,1
13658        ,INSTRB(anc_id_13,'(]',1,1) -1)
13659 ,SUBSTRB(anc_id_13
13660        ,INSTRB(anc_id_13,'(]',1,1) + 2
13661        ,INSTRB(anc_id_13,'(]',1,2) -
13662         INSTRB(anc_id_13,'(]',1,1) - 2)
13663 ,SUBSTRB(anc_id_13
13664        ,INSTRB(anc_id_13,'(]',1,2) + 2
13665        ,INSTRB(anc_id_13,'(]',1,3) -
13666         INSTRB(anc_id_13,'(]',1,2) - 2)
13667 ,SUBSTRB(anc_id_13
13668        ,INSTRB(anc_id_13,'(]',1,3) + 2
13669        ,INSTRB(anc_id_13,'(]',1,4) -
13670         INSTRB(anc_id_13,'(]',1,3) - 2)
13671 ,SUBSTRB(anc_id_13
13672        ,INSTRB(anc_id_13,'(]',1,4) + 2
13673        ,INSTRB(anc_id_13,'(]',1,5) -
13674         INSTRB(anc_id_13,'(]',1,4) - 2)
13675 ,SUBSTRB(anc_id_13
13676        ,INSTRB(anc_id_13,'(]',1,5) + 2
13677        ,INSTRB(anc_id_13,'(]',1,6) -
13678         INSTRB(anc_id_13,'(]',1,5) - 2)
13679 ,SUBSTRB(anc_id_13
13680        ,INSTRB(anc_id_13,'(]',1,6) + 2
13681        ,INSTRB(anc_id_13,'(]',1,7) -
13682         INSTRB(anc_id_13,'(]',1,6) - 2)
13683 ,SUBSTRB(anc_id_13
13684        ,INSTRB(anc_id_13,'(]',1,7) + 2
13685        ,LENGTHB(anc_id_13))
13686 )
13687 
13688 WHEN anc_id_14 IS NOT NULL THEN
13689   INTO xla_ae_header_acs (
13690         ae_header_id , object_version_number
13691       , analytical_criterion_code
13692       , analytical_criterion_type_code
13693       , amb_context_code
13694       , ac1,ac2,ac3,ac4,ac5)
13695 VALUES (ae_header_id, C_OVN
13696 ,SUBSTRB(anc_id_14
13697        ,1
13698        ,INSTRB(anc_id_14,'(]',1,1) -1)
13699 ,SUBSTRB(anc_id_14
13700        ,INSTRB(anc_id_14,'(]',1,1) + 2
13701        ,INSTRB(anc_id_14,'(]',1,2) -
13702         INSTRB(anc_id_14,'(]',1,1) - 2)
13703 ,SUBSTRB(anc_id_14
13704        ,INSTRB(anc_id_14,'(]',1,2) + 2
13705        ,INSTRB(anc_id_14,'(]',1,3) -
13706         INSTRB(anc_id_14,'(]',1,2) - 2)
13707 ,SUBSTRB(anc_id_14
13708        ,INSTRB(anc_id_14,'(]',1,3) + 2
13709        ,INSTRB(anc_id_14,'(]',1,4) -
13710         INSTRB(anc_id_14,'(]',1,3) - 2)
13711 ,SUBSTRB(anc_id_14
13712        ,INSTRB(anc_id_14,'(]',1,4) + 2
13713        ,INSTRB(anc_id_14,'(]',1,5) -
13714         INSTRB(anc_id_14,'(]',1,4) - 2)
13715 ,SUBSTRB(anc_id_14
13716        ,INSTRB(anc_id_14,'(]',1,5) + 2
13717        ,INSTRB(anc_id_14,'(]',1,6) -
13718         INSTRB(anc_id_14,'(]',1,5) - 2)
13719 ,SUBSTRB(anc_id_14
13720        ,INSTRB(anc_id_14,'(]',1,6) + 2
13721        ,INSTRB(anc_id_14,'(]',1,7) -
13722         INSTRB(anc_id_14,'(]',1,6) - 2)
13723 ,SUBSTRB(anc_id_14
13724        ,INSTRB(anc_id_14,'(]',1,7) + 2
13725        ,LENGTHB(anc_id_14))
13726 )
13727 
13728 WHEN anc_id_15 IS NOT NULL THEN
13729   INTO xla_ae_header_acs (
13730         ae_header_id , object_version_number
13731       , analytical_criterion_code
13732       , analytical_criterion_type_code
13733       , amb_context_code
13734       , ac1,ac2,ac3,ac4,ac5)
13735 VALUES (ae_header_id, C_OVN
13736 ,SUBSTRB(anc_id_15
13737        ,1
13738        ,INSTRB(anc_id_15,'(]',1,1) -1)
13739 ,SUBSTRB(anc_id_15
13740        ,INSTRB(anc_id_15,'(]',1,1) + 2
13741        ,INSTRB(anc_id_15,'(]',1,2) -
13742         INSTRB(anc_id_15,'(]',1,1) - 2)
13743 ,SUBSTRB(anc_id_15
13744        ,INSTRB(anc_id_15,'(]',1,2) + 2
13745        ,INSTRB(anc_id_15,'(]',1,3) -
13746         INSTRB(anc_id_15,'(]',1,2) - 2)
13747 ,SUBSTRB(anc_id_15
13748        ,INSTRB(anc_id_15,'(]',1,3) + 2
13749        ,INSTRB(anc_id_15,'(]',1,4) -
13750         INSTRB(anc_id_15,'(]',1,3) - 2)
13751 ,SUBSTRB(anc_id_15
13752        ,INSTRB(anc_id_15,'(]',1,4) + 2
13753        ,INSTRB(anc_id_15,'(]',1,5) -
13754         INSTRB(anc_id_15,'(]',1,4) - 2)
13755 ,SUBSTRB(anc_id_15
13756        ,INSTRB(anc_id_15,'(]',1,5) + 2
13757        ,INSTRB(anc_id_15,'(]',1,6) -
13758         INSTRB(anc_id_15,'(]',1,5) - 2)
13759 ,SUBSTRB(anc_id_15
13760        ,INSTRB(anc_id_15,'(]',1,6) + 2
13761        ,INSTRB(anc_id_15,'(]',1,7) -
13762         INSTRB(anc_id_15,'(]',1,6) - 2)
13763 ,SUBSTRB(anc_id_15
13764        ,INSTRB(anc_id_15,'(]',1,7) + 2
13765        ,LENGTHB(anc_id_15))
13766 )
13767 
13768 WHEN anc_id_16 IS NOT NULL THEN
13769   INTO xla_ae_header_acs (
13770         ae_header_id , object_version_number
13771       , analytical_criterion_code
13772       , analytical_criterion_type_code
13773       , amb_context_code
13774       , ac1,ac2,ac3,ac4,ac5)
13775 VALUES (ae_header_id, C_OVN
13776 ,SUBSTRB(anc_id_16
13777        ,1
13778        ,INSTRB(anc_id_16,'(]',1,1) -1)
13779 ,SUBSTRB(anc_id_16
13780        ,INSTRB(anc_id_16,'(]',1,1) + 2
13781        ,INSTRB(anc_id_16,'(]',1,2) -
13782         INSTRB(anc_id_16,'(]',1,1) - 2)
13783 ,SUBSTRB(anc_id_16
13784        ,INSTRB(anc_id_16,'(]',1,2) + 2
13785        ,INSTRB(anc_id_16,'(]',1,3) -
13786         INSTRB(anc_id_16,'(]',1,2) - 2)
13787 ,SUBSTRB(anc_id_16
13788        ,INSTRB(anc_id_16,'(]',1,3) + 2
13789        ,INSTRB(anc_id_16,'(]',1,4) -
13790         INSTRB(anc_id_16,'(]',1,3) - 2)
13791 ,SUBSTRB(anc_id_16
13792        ,INSTRB(anc_id_16,'(]',1,4) + 2
13793        ,INSTRB(anc_id_16,'(]',1,5) -
13794         INSTRB(anc_id_16,'(]',1,4) - 2)
13795 ,SUBSTRB(anc_id_16
13796        ,INSTRB(anc_id_16,'(]',1,5) + 2
13797        ,INSTRB(anc_id_16,'(]',1,6) -
13798         INSTRB(anc_id_16,'(]',1,5) - 2)
13799 ,SUBSTRB(anc_id_16
13800        ,INSTRB(anc_id_16,'(]',1,6) + 2
13801        ,INSTRB(anc_id_16,'(]',1,7) -
13802         INSTRB(anc_id_16,'(]',1,6) - 2)
13803 ,SUBSTRB(anc_id_16
13804        ,INSTRB(anc_id_16,'(]',1,7) + 2
13805        ,LENGTHB(anc_id_16))
13806 )
13807 
13808 WHEN anc_id_17 IS NOT NULL THEN
13809   INTO xla_ae_header_acs (
13810         ae_header_id , object_version_number
13811       , analytical_criterion_code
13812       , analytical_criterion_type_code
13813       , amb_context_code
13814       , ac1,ac2,ac3,ac4,ac5)
13815 VALUES (ae_header_id, C_OVN
13816 ,SUBSTRB(anc_id_17
13817        ,1
13818        ,INSTRB(anc_id_17,'(]',1,1) -1)
13819 ,SUBSTRB(anc_id_17
13820        ,INSTRB(anc_id_17,'(]',1,1) + 2
13821        ,INSTRB(anc_id_17,'(]',1,2) -
13822         INSTRB(anc_id_17,'(]',1,1) - 2)
13823 ,SUBSTRB(anc_id_17
13824        ,INSTRB(anc_id_17,'(]',1,2) + 2
13825        ,INSTRB(anc_id_17,'(]',1,3) -
13826         INSTRB(anc_id_17,'(]',1,2) - 2)
13827 ,SUBSTRB(anc_id_17
13828        ,INSTRB(anc_id_17,'(]',1,3) + 2
13829        ,INSTRB(anc_id_17,'(]',1,4) -
13830         INSTRB(anc_id_17,'(]',1,3) - 2)
13831 ,SUBSTRB(anc_id_17
13832        ,INSTRB(anc_id_17,'(]',1,4) + 2
13833        ,INSTRB(anc_id_17,'(]',1,5) -
13834         INSTRB(anc_id_17,'(]',1,4) - 2)
13835 ,SUBSTRB(anc_id_17
13836        ,INSTRB(anc_id_17,'(]',1,5) + 2
13837        ,INSTRB(anc_id_17,'(]',1,6) -
13838         INSTRB(anc_id_17,'(]',1,5) - 2)
13839 ,SUBSTRB(anc_id_17
13840        ,INSTRB(anc_id_17,'(]',1,6) + 2
13841        ,INSTRB(anc_id_17,'(]',1,7) -
13842         INSTRB(anc_id_17,'(]',1,6) - 2)
13843 ,SUBSTRB(anc_id_17
13844        ,INSTRB(anc_id_17,'(]',1,7) + 2
13845        ,LENGTHB(anc_id_17))
13846 )
13847 
13848 WHEN anc_id_18 IS NOT NULL THEN
13849   INTO xla_ae_header_acs (
13850         ae_header_id , object_version_number
13851       , analytical_criterion_code
13852       , analytical_criterion_type_code
13853       , amb_context_code
13854       , ac1,ac2,ac3,ac4,ac5)
13855 VALUES (ae_header_id, C_OVN
13856 ,SUBSTRB(anc_id_18
13857        ,1
13858        ,INSTRB(anc_id_18,'(]',1,1) -1)
13859 ,SUBSTRB(anc_id_18
13860        ,INSTRB(anc_id_18,'(]',1,1) + 2
13861        ,INSTRB(anc_id_18,'(]',1,2) -
13862         INSTRB(anc_id_18,'(]',1,1) - 2)
13863 ,SUBSTRB(anc_id_18
13864        ,INSTRB(anc_id_18,'(]',1,2) + 2
13865        ,INSTRB(anc_id_18,'(]',1,3) -
13866         INSTRB(anc_id_18,'(]',1,2) - 2)
13867 ,SUBSTRB(anc_id_18
13868        ,INSTRB(anc_id_18,'(]',1,3) + 2
13869        ,INSTRB(anc_id_18,'(]',1,4) -
13870         INSTRB(anc_id_18,'(]',1,3) - 2)
13871 ,SUBSTRB(anc_id_18
13872        ,INSTRB(anc_id_18,'(]',1,4) + 2
13873        ,INSTRB(anc_id_18,'(]',1,5) -
13874         INSTRB(anc_id_18,'(]',1,4) - 2)
13875 ,SUBSTRB(anc_id_18
13876        ,INSTRB(anc_id_18,'(]',1,5) + 2
13877        ,INSTRB(anc_id_18,'(]',1,6) -
13878         INSTRB(anc_id_18,'(]',1,5) - 2)
13879 ,SUBSTRB(anc_id_18
13880        ,INSTRB(anc_id_18,'(]',1,6) + 2
13881        ,INSTRB(anc_id_18,'(]',1,7) -
13882         INSTRB(anc_id_18,'(]',1,6) - 2)
13883 ,SUBSTRB(anc_id_18
13884        ,INSTRB(anc_id_18,'(]',1,7) + 2
13885        ,LENGTHB(anc_id_18))
13886 )
13887 
13888 WHEN anc_id_19 IS NOT NULL THEN
13889   INTO xla_ae_header_acs (
13890         ae_header_id , object_version_number
13891       , analytical_criterion_code
13892       , analytical_criterion_type_code
13893       , amb_context_code
13894       , ac1,ac2,ac3,ac4,ac5)
13895 VALUES (ae_header_id, C_OVN
13896 ,SUBSTRB(anc_id_19
13897        ,1
13898        ,INSTRB(anc_id_19,'(]',1,1) -1)
13899 ,SUBSTRB(anc_id_19
13900        ,INSTRB(anc_id_19,'(]',1,1) + 2
13901        ,INSTRB(anc_id_19,'(]',1,2) -
13902         INSTRB(anc_id_19,'(]',1,1) - 2)
13903 ,SUBSTRB(anc_id_19
13904        ,INSTRB(anc_id_19,'(]',1,2) + 2
13905        ,INSTRB(anc_id_19,'(]',1,3) -
13906         INSTRB(anc_id_19,'(]',1,2) - 2)
13907 ,SUBSTRB(anc_id_19
13908        ,INSTRB(anc_id_19,'(]',1,3) + 2
13909        ,INSTRB(anc_id_19,'(]',1,4) -
13910         INSTRB(anc_id_19,'(]',1,3) - 2)
13911 ,SUBSTRB(anc_id_19
13912        ,INSTRB(anc_id_19,'(]',1,4) + 2
13913        ,INSTRB(anc_id_19,'(]',1,5) -
13914         INSTRB(anc_id_19,'(]',1,4) - 2)
13915 ,SUBSTRB(anc_id_19
13916        ,INSTRB(anc_id_19,'(]',1,5) + 2
13917        ,INSTRB(anc_id_19,'(]',1,6) -
13918         INSTRB(anc_id_19,'(]',1,5) - 2)
13919 ,SUBSTRB(anc_id_19
13920        ,INSTRB(anc_id_19,'(]',1,6) + 2
13921        ,INSTRB(anc_id_19,'(]',1,7) -
13922         INSTRB(anc_id_19,'(]',1,6) - 2)
13923 ,SUBSTRB(anc_id_19
13924        ,INSTRB(anc_id_19,'(]',1,7) + 2
13925        ,LENGTHB(anc_id_19))
13926 )
13927 
13928 WHEN anc_id_20 IS NOT NULL THEN
13929   INTO xla_ae_header_acs (
13930         ae_header_id , object_version_number
13931       , analytical_criterion_code
13932       , analytical_criterion_type_code
13933       , amb_context_code
13934       , ac1,ac2,ac3,ac4,ac5)
13935 VALUES (ae_header_id, C_OVN
13936 ,SUBSTRB(anc_id_20
13937        ,1
13938        ,INSTRB(anc_id_20,'(]',1,1) -1)
13939 ,SUBSTRB(anc_id_20
13940        ,INSTRB(anc_id_20,'(]',1,1) + 2
13941        ,INSTRB(anc_id_20,'(]',1,2) -
13942         INSTRB(anc_id_20,'(]',1,1) - 2)
13943 ,SUBSTRB(anc_id_20
13944        ,INSTRB(anc_id_20,'(]',1,2) + 2
13945        ,INSTRB(anc_id_20,'(]',1,3) -
13946         INSTRB(anc_id_20,'(]',1,2) - 2)
13947 ,SUBSTRB(anc_id_20
13948        ,INSTRB(anc_id_20,'(]',1,3) + 2
13949        ,INSTRB(anc_id_20,'(]',1,4) -
13950         INSTRB(anc_id_20,'(]',1,3) - 2)
13951 ,SUBSTRB(anc_id_20
13952        ,INSTRB(anc_id_20,'(]',1,4) + 2
13953        ,INSTRB(anc_id_20,'(]',1,5) -
13954         INSTRB(anc_id_20,'(]',1,4) - 2)
13955 ,SUBSTRB(anc_id_20
13956        ,INSTRB(anc_id_20,'(]',1,5) + 2
13957        ,INSTRB(anc_id_20,'(]',1,6) -
13958         INSTRB(anc_id_20,'(]',1,5) - 2)
13959 ,SUBSTRB(anc_id_20
13960        ,INSTRB(anc_id_20,'(]',1,6) + 2
13961        ,INSTRB(anc_id_20,'(]',1,7) -
13962         INSTRB(anc_id_20,'(]',1,6) - 2)
13963 ,SUBSTRB(anc_id_20
13964        ,INSTRB(anc_id_20,'(]',1,7) + 2
13965        ,LENGTHB(anc_id_20))
13966 )
13967 
13968 WHEN anc_id_21 IS NOT NULL THEN
13969   INTO xla_ae_header_acs (
13970         ae_header_id , object_version_number
13971       , analytical_criterion_code
13972       , analytical_criterion_type_code
13973       , amb_context_code
13974       , ac1,ac2,ac3,ac4,ac5)
13975 VALUES (ae_header_id, C_OVN
13976 ,SUBSTRB(anc_id_21
13977        ,1
13978        ,INSTRB(anc_id_21,'(]',1,1) -1)
13979 ,SUBSTRB(anc_id_21
13980        ,INSTRB(anc_id_21,'(]',1,1) + 2
13981        ,INSTRB(anc_id_21,'(]',1,2) -
13982         INSTRB(anc_id_21,'(]',1,1) - 2)
13983 ,SUBSTRB(anc_id_21
13984        ,INSTRB(anc_id_21,'(]',1,2) + 2
13985        ,INSTRB(anc_id_21,'(]',1,3) -
13986         INSTRB(anc_id_21,'(]',1,2) - 2)
13987 ,SUBSTRB(anc_id_21
13988        ,INSTRB(anc_id_21,'(]',1,3) + 2
13989        ,INSTRB(anc_id_21,'(]',1,4) -
13990         INSTRB(anc_id_21,'(]',1,3) - 2)
13991 ,SUBSTRB(anc_id_21
13992        ,INSTRB(anc_id_21,'(]',1,4) + 2
13993        ,INSTRB(anc_id_21,'(]',1,5) -
13994         INSTRB(anc_id_21,'(]',1,4) - 2)
13995 ,SUBSTRB(anc_id_21
13996        ,INSTRB(anc_id_21,'(]',1,5) + 2
13997        ,INSTRB(anc_id_21,'(]',1,6) -
13998         INSTRB(anc_id_21,'(]',1,5) - 2)
13999 ,SUBSTRB(anc_id_21
14000        ,INSTRB(anc_id_21,'(]',1,6) + 2
14001        ,INSTRB(anc_id_21,'(]',1,7) -
14002         INSTRB(anc_id_21,'(]',1,6) - 2)
14003 ,SUBSTRB(anc_id_21
14004        ,INSTRB(anc_id_21,'(]',1,7) + 2
14005        ,LENGTHB(anc_id_21))
14006 )
14007 
14008 WHEN anc_id_22 IS NOT NULL THEN
14009   INTO xla_ae_header_acs (
14010         ae_header_id , object_version_number
14011       , analytical_criterion_code
14012       , analytical_criterion_type_code
14013       , amb_context_code
14014       , ac1,ac2,ac3,ac4,ac5)
14015 VALUES (ae_header_id, C_OVN
14016 ,SUBSTRB(anc_id_22
14017        ,1
14018        ,INSTRB(anc_id_22,'(]',1,1) -1)
14019 ,SUBSTRB(anc_id_22
14020        ,INSTRB(anc_id_22,'(]',1,1) + 2
14021        ,INSTRB(anc_id_22,'(]',1,2) -
14022         INSTRB(anc_id_22,'(]',1,1) - 2)
14023 ,SUBSTRB(anc_id_22
14024        ,INSTRB(anc_id_22,'(]',1,2) + 2
14025        ,INSTRB(anc_id_22,'(]',1,3) -
14026         INSTRB(anc_id_22,'(]',1,2) - 2)
14027 ,SUBSTRB(anc_id_22
14028        ,INSTRB(anc_id_22,'(]',1,3) + 2
14029        ,INSTRB(anc_id_22,'(]',1,4) -
14030         INSTRB(anc_id_22,'(]',1,3) - 2)
14031 ,SUBSTRB(anc_id_22
14032        ,INSTRB(anc_id_22,'(]',1,4) + 2
14033        ,INSTRB(anc_id_22,'(]',1,5) -
14034         INSTRB(anc_id_22,'(]',1,4) - 2)
14035 ,SUBSTRB(anc_id_22
14036        ,INSTRB(anc_id_22,'(]',1,5) + 2
14037        ,INSTRB(anc_id_22,'(]',1,6) -
14038         INSTRB(anc_id_22,'(]',1,5) - 2)
14039 ,SUBSTRB(anc_id_22
14040        ,INSTRB(anc_id_22,'(]',1,6) + 2
14041        ,INSTRB(anc_id_22,'(]',1,7) -
14042         INSTRB(anc_id_22,'(]',1,6) - 2)
14043 ,SUBSTRB(anc_id_22
14044        ,INSTRB(anc_id_22,'(]',1,7) + 2
14045        ,LENGTHB(anc_id_22))
14046 )
14047 
14048 WHEN anc_id_23 IS NOT NULL THEN
14049   INTO xla_ae_header_acs (
14050         ae_header_id , object_version_number
14051       , analytical_criterion_code
14052       , analytical_criterion_type_code
14053       , amb_context_code
14054       , ac1,ac2,ac3,ac4,ac5)
14055 VALUES (ae_header_id, C_OVN
14056 ,SUBSTRB(anc_id_23
14057        ,1
14058        ,INSTRB(anc_id_23,'(]',1,1) -1)
14059 ,SUBSTRB(anc_id_23
14060        ,INSTRB(anc_id_23,'(]',1,1) + 2
14061        ,INSTRB(anc_id_23,'(]',1,2) -
14062         INSTRB(anc_id_23,'(]',1,1) - 2)
14063 ,SUBSTRB(anc_id_23
14064        ,INSTRB(anc_id_23,'(]',1,2) + 2
14065        ,INSTRB(anc_id_23,'(]',1,3) -
14066         INSTRB(anc_id_23,'(]',1,2) - 2)
14067 ,SUBSTRB(anc_id_23
14068        ,INSTRB(anc_id_23,'(]',1,3) + 2
14069        ,INSTRB(anc_id_23,'(]',1,4) -
14070         INSTRB(anc_id_23,'(]',1,3) - 2)
14071 ,SUBSTRB(anc_id_23
14072        ,INSTRB(anc_id_23,'(]',1,4) + 2
14073        ,INSTRB(anc_id_23,'(]',1,5) -
14074         INSTRB(anc_id_23,'(]',1,4) - 2)
14075 ,SUBSTRB(anc_id_23
14076        ,INSTRB(anc_id_23,'(]',1,5) + 2
14077        ,INSTRB(anc_id_23,'(]',1,6) -
14078         INSTRB(anc_id_23,'(]',1,5) - 2)
14079 ,SUBSTRB(anc_id_23
14080        ,INSTRB(anc_id_23,'(]',1,6) + 2
14081        ,INSTRB(anc_id_23,'(]',1,7) -
14082         INSTRB(anc_id_23,'(]',1,6) - 2)
14083 ,SUBSTRB(anc_id_23
14084        ,INSTRB(anc_id_23,'(]',1,7) + 2
14085        ,LENGTHB(anc_id_23))
14086 )
14087 
14088 WHEN anc_id_24 IS NOT NULL THEN
14089   INTO xla_ae_header_acs (
14090         ae_header_id , object_version_number
14091       , analytical_criterion_code
14092       , analytical_criterion_type_code
14093       , amb_context_code
14094       , ac1,ac2,ac3,ac4,ac5)
14095 VALUES (ae_header_id, C_OVN
14096 ,SUBSTRB(anc_id_24
14097        ,1
14098        ,INSTRB(anc_id_24,'(]',1,1) -1)
14099 ,SUBSTRB(anc_id_24
14100        ,INSTRB(anc_id_24,'(]',1,1) + 2
14101        ,INSTRB(anc_id_24,'(]',1,2) -
14102         INSTRB(anc_id_24,'(]',1,1) - 2)
14103 ,SUBSTRB(anc_id_24
14104        ,INSTRB(anc_id_24,'(]',1,2) + 2
14105        ,INSTRB(anc_id_24,'(]',1,3) -
14106         INSTRB(anc_id_24,'(]',1,2) - 2)
14107 ,SUBSTRB(anc_id_24
14108        ,INSTRB(anc_id_24,'(]',1,3) + 2
14109        ,INSTRB(anc_id_24,'(]',1,4) -
14110         INSTRB(anc_id_24,'(]',1,3) - 2)
14111 ,SUBSTRB(anc_id_24
14112        ,INSTRB(anc_id_24,'(]',1,4) + 2
14113        ,INSTRB(anc_id_24,'(]',1,5) -
14114         INSTRB(anc_id_24,'(]',1,4) - 2)
14115 ,SUBSTRB(anc_id_24
14116        ,INSTRB(anc_id_24,'(]',1,5) + 2
14117        ,INSTRB(anc_id_24,'(]',1,6) -
14118         INSTRB(anc_id_24,'(]',1,5) - 2)
14119 ,SUBSTRB(anc_id_24
14120        ,INSTRB(anc_id_24,'(]',1,6) + 2
14121        ,INSTRB(anc_id_24,'(]',1,7) -
14122         INSTRB(anc_id_24,'(]',1,6) - 2)
14123 ,SUBSTRB(anc_id_24
14124        ,INSTRB(anc_id_24,'(]',1,7) + 2
14125        ,LENGTHB(anc_id_24))
14126 )
14127 
14128 WHEN anc_id_25 IS NOT NULL THEN
14129   INTO xla_ae_header_acs (
14130         ae_header_id , object_version_number
14131       , analytical_criterion_code
14132       , analytical_criterion_type_code
14133       , amb_context_code
14134       , ac1,ac2,ac3,ac4,ac5)
14135 VALUES (ae_header_id, C_OVN
14136 ,SUBSTRB(anc_id_25
14137        ,1
14138        ,INSTRB(anc_id_25,'(]',1,1) -1)
14139 ,SUBSTRB(anc_id_25
14140        ,INSTRB(anc_id_25,'(]',1,1) + 2
14141        ,INSTRB(anc_id_25,'(]',1,2) -
14142         INSTRB(anc_id_25,'(]',1,1) - 2)
14143 ,SUBSTRB(anc_id_25
14144        ,INSTRB(anc_id_25,'(]',1,2) + 2
14145        ,INSTRB(anc_id_25,'(]',1,3) -
14146         INSTRB(anc_id_25,'(]',1,2) - 2)
14147 ,SUBSTRB(anc_id_25
14148        ,INSTRB(anc_id_25,'(]',1,3) + 2
14149        ,INSTRB(anc_id_25,'(]',1,4) -
14150         INSTRB(anc_id_25,'(]',1,3) - 2)
14151 ,SUBSTRB(anc_id_25
14152        ,INSTRB(anc_id_25,'(]',1,4) + 2
14153        ,INSTRB(anc_id_25,'(]',1,5) -
14154         INSTRB(anc_id_25,'(]',1,4) - 2)
14155 ,SUBSTRB(anc_id_25
14156        ,INSTRB(anc_id_25,'(]',1,5) + 2
14157        ,INSTRB(anc_id_25,'(]',1,6) -
14158         INSTRB(anc_id_25,'(]',1,5) - 2)
14159 ,SUBSTRB(anc_id_25
14160        ,INSTRB(anc_id_25,'(]',1,6) + 2
14161        ,INSTRB(anc_id_25,'(]',1,7) -
14162         INSTRB(anc_id_25,'(]',1,6) - 2)
14163 ,SUBSTRB(anc_id_25
14164        ,INSTRB(anc_id_25,'(]',1,7) + 2
14165        ,LENGTHB(anc_id_25))
14166 )
14167 
14168 WHEN anc_id_26 IS NOT NULL THEN
14169   INTO xla_ae_header_acs (
14170         ae_header_id , object_version_number
14171       , analytical_criterion_code
14172       , analytical_criterion_type_code
14173       , amb_context_code
14174       , ac1,ac2,ac3,ac4,ac5)
14175 VALUES (ae_header_id, C_OVN
14176 ,SUBSTRB(anc_id_26
14177        ,1
14178        ,INSTRB(anc_id_26,'(]',1,1) -1)
14179 ,SUBSTRB(anc_id_26
14180        ,INSTRB(anc_id_26,'(]',1,1) + 2
14181        ,INSTRB(anc_id_26,'(]',1,2) -
14182         INSTRB(anc_id_26,'(]',1,1) - 2)
14183 ,SUBSTRB(anc_id_26
14184        ,INSTRB(anc_id_26,'(]',1,2) + 2
14185        ,INSTRB(anc_id_26,'(]',1,3) -
14186         INSTRB(anc_id_26,'(]',1,2) - 2)
14187 ,SUBSTRB(anc_id_26
14188        ,INSTRB(anc_id_26,'(]',1,3) + 2
14189        ,INSTRB(anc_id_26,'(]',1,4) -
14190         INSTRB(anc_id_26,'(]',1,3) - 2)
14191 ,SUBSTRB(anc_id_26
14192        ,INSTRB(anc_id_26,'(]',1,4) + 2
14193        ,INSTRB(anc_id_26,'(]',1,5) -
14194         INSTRB(anc_id_26,'(]',1,4) - 2)
14195 ,SUBSTRB(anc_id_26
14196        ,INSTRB(anc_id_26,'(]',1,5) + 2
14197        ,INSTRB(anc_id_26,'(]',1,6) -
14198         INSTRB(anc_id_26,'(]',1,5) - 2)
14199 ,SUBSTRB(anc_id_26
14200        ,INSTRB(anc_id_26,'(]',1,6) + 2
14201        ,INSTRB(anc_id_26,'(]',1,7) -
14202         INSTRB(anc_id_26,'(]',1,6) - 2)
14203 ,SUBSTRB(anc_id_26
14204        ,INSTRB(anc_id_26,'(]',1,7) + 2
14205        ,LENGTHB(anc_id_26))
14206 )
14207 
14208 WHEN anc_id_27 IS NOT NULL THEN
14209   INTO xla_ae_header_acs (
14210         ae_header_id , object_version_number
14211       , analytical_criterion_code
14212       , analytical_criterion_type_code
14213       , amb_context_code
14214       , ac1,ac2,ac3,ac4,ac5)
14215 VALUES (ae_header_id, C_OVN
14216 ,SUBSTRB(anc_id_27
14217        ,1
14218        ,INSTRB(anc_id_27,'(]',1,1) -1)
14219 ,SUBSTRB(anc_id_27
14220        ,INSTRB(anc_id_27,'(]',1,1) + 2
14221        ,INSTRB(anc_id_27,'(]',1,2) -
14222         INSTRB(anc_id_27,'(]',1,1) - 2)
14223 ,SUBSTRB(anc_id_27
14224        ,INSTRB(anc_id_27,'(]',1,2) + 2
14225        ,INSTRB(anc_id_27,'(]',1,3) -
14226         INSTRB(anc_id_27,'(]',1,2) - 2)
14227 ,SUBSTRB(anc_id_27
14228        ,INSTRB(anc_id_27,'(]',1,3) + 2
14229        ,INSTRB(anc_id_27,'(]',1,4) -
14230         INSTRB(anc_id_27,'(]',1,3) - 2)
14231 ,SUBSTRB(anc_id_27
14232        ,INSTRB(anc_id_27,'(]',1,4) + 2
14233        ,INSTRB(anc_id_27,'(]',1,5) -
14234         INSTRB(anc_id_27,'(]',1,4) - 2)
14235 ,SUBSTRB(anc_id_27
14236        ,INSTRB(anc_id_27,'(]',1,5) + 2
14237        ,INSTRB(anc_id_27,'(]',1,6) -
14238         INSTRB(anc_id_27,'(]',1,5) - 2)
14239 ,SUBSTRB(anc_id_27
14240        ,INSTRB(anc_id_27,'(]',1,6) + 2
14241        ,INSTRB(anc_id_27,'(]',1,7) -
14242         INSTRB(anc_id_27,'(]',1,6) - 2)
14243 ,SUBSTRB(anc_id_27
14244        ,INSTRB(anc_id_27,'(]',1,7) + 2
14245        ,LENGTHB(anc_id_27))
14246 )
14247 
14248 WHEN anc_id_28 IS NOT NULL THEN
14249   INTO xla_ae_header_acs (
14250         ae_header_id , object_version_number
14251       , analytical_criterion_code
14252       , analytical_criterion_type_code
14253       , amb_context_code
14254       , ac1,ac2,ac3,ac4,ac5)
14255 VALUES (ae_header_id, C_OVN
14256 ,SUBSTRB(anc_id_28
14257        ,1
14258        ,INSTRB(anc_id_28,'(]',1,1) -1)
14259 ,SUBSTRB(anc_id_28
14260        ,INSTRB(anc_id_28,'(]',1,1) + 2
14261        ,INSTRB(anc_id_28,'(]',1,2) -
14262         INSTRB(anc_id_28,'(]',1,1) - 2)
14263 ,SUBSTRB(anc_id_28
14264        ,INSTRB(anc_id_28,'(]',1,2) + 2
14265        ,INSTRB(anc_id_28,'(]',1,3) -
14266         INSTRB(anc_id_28,'(]',1,2) - 2)
14267 ,SUBSTRB(anc_id_28
14268        ,INSTRB(anc_id_28,'(]',1,3) + 2
14269        ,INSTRB(anc_id_28,'(]',1,4) -
14270         INSTRB(anc_id_28,'(]',1,3) - 2)
14271 ,SUBSTRB(anc_id_28
14272        ,INSTRB(anc_id_28,'(]',1,4) + 2
14273        ,INSTRB(anc_id_28,'(]',1,5) -
14274         INSTRB(anc_id_28,'(]',1,4) - 2)
14275 ,SUBSTRB(anc_id_28
14276        ,INSTRB(anc_id_28,'(]',1,5) + 2
14277        ,INSTRB(anc_id_28,'(]',1,6) -
14278         INSTRB(anc_id_28,'(]',1,5) - 2)
14279 ,SUBSTRB(anc_id_28
14280        ,INSTRB(anc_id_28,'(]',1,6) + 2
14281        ,INSTRB(anc_id_28,'(]',1,7) -
14282         INSTRB(anc_id_28,'(]',1,6) - 2)
14283 ,SUBSTRB(anc_id_28
14284        ,INSTRB(anc_id_28,'(]',1,7) + 2
14285        ,LENGTHB(anc_id_28))
14286 )
14287 
14288 WHEN anc_id_29 IS NOT NULL THEN
14289   INTO xla_ae_header_acs (
14290         ae_header_id , object_version_number
14291       , analytical_criterion_code
14292       , analytical_criterion_type_code
14293       , amb_context_code
14294       , ac1,ac2,ac3,ac4,ac5)
14295 VALUES (ae_header_id, C_OVN
14296 ,SUBSTRB(anc_id_29
14297        ,1
14298        ,INSTRB(anc_id_29,'(]',1,1) -1)
14299 ,SUBSTRB(anc_id_29
14300        ,INSTRB(anc_id_29,'(]',1,1) + 2
14301        ,INSTRB(anc_id_29,'(]',1,2) -
14302         INSTRB(anc_id_29,'(]',1,1) - 2)
14303 ,SUBSTRB(anc_id_29
14304        ,INSTRB(anc_id_29,'(]',1,2) + 2
14305        ,INSTRB(anc_id_29,'(]',1,3) -
14306         INSTRB(anc_id_29,'(]',1,2) - 2)
14307 ,SUBSTRB(anc_id_29
14308        ,INSTRB(anc_id_29,'(]',1,3) + 2
14309        ,INSTRB(anc_id_29,'(]',1,4) -
14310         INSTRB(anc_id_29,'(]',1,3) - 2)
14311 ,SUBSTRB(anc_id_29
14312        ,INSTRB(anc_id_29,'(]',1,4) + 2
14313        ,INSTRB(anc_id_29,'(]',1,5) -
14314         INSTRB(anc_id_29,'(]',1,4) - 2)
14315 ,SUBSTRB(anc_id_29
14316        ,INSTRB(anc_id_29,'(]',1,5) + 2
14317        ,INSTRB(anc_id_29,'(]',1,6) -
14318         INSTRB(anc_id_29,'(]',1,5) - 2)
14319 ,SUBSTRB(anc_id_29
14320        ,INSTRB(anc_id_29,'(]',1,6) + 2
14321        ,INSTRB(anc_id_29,'(]',1,7) -
14322         INSTRB(anc_id_29,'(]',1,6) - 2)
14323 ,SUBSTRB(anc_id_29
14324        ,INSTRB(anc_id_29,'(]',1,7) + 2
14325        ,LENGTHB(anc_id_29))
14326 )
14327 
14328 WHEN anc_id_30 IS NOT NULL THEN
14329   INTO xla_ae_header_acs (
14330         ae_header_id , object_version_number
14331       , analytical_criterion_code
14332       , analytical_criterion_type_code
14333       , amb_context_code
14334       , ac1,ac2,ac3,ac4,ac5)
14335 VALUES (ae_header_id, C_OVN
14336 ,SUBSTRB(anc_id_30
14337        ,1
14338        ,INSTRB(anc_id_30,'(]',1,1) -1)
14339 ,SUBSTRB(anc_id_30
14340        ,INSTRB(anc_id_30,'(]',1,1) + 2
14341        ,INSTRB(anc_id_30,'(]',1,2) -
14342         INSTRB(anc_id_30,'(]',1,1) - 2)
14343 ,SUBSTRB(anc_id_30
14344        ,INSTRB(anc_id_30,'(]',1,2) + 2
14345        ,INSTRB(anc_id_30,'(]',1,3) -
14346         INSTRB(anc_id_30,'(]',1,2) - 2)
14347 ,SUBSTRB(anc_id_30
14348        ,INSTRB(anc_id_30,'(]',1,3) + 2
14349        ,INSTRB(anc_id_30,'(]',1,4) -
14350         INSTRB(anc_id_30,'(]',1,3) - 2)
14351 ,SUBSTRB(anc_id_30
14352        ,INSTRB(anc_id_30,'(]',1,4) + 2
14353        ,INSTRB(anc_id_30,'(]',1,5) -
14354         INSTRB(anc_id_30,'(]',1,4) - 2)
14355 ,SUBSTRB(anc_id_30
14356        ,INSTRB(anc_id_30,'(]',1,5) + 2
14357        ,INSTRB(anc_id_30,'(]',1,6) -
14358         INSTRB(anc_id_30,'(]',1,5) - 2)
14359 ,SUBSTRB(anc_id_30
14360        ,INSTRB(anc_id_30,'(]',1,6) + 2
14361        ,INSTRB(anc_id_30,'(]',1,7) -
14362         INSTRB(anc_id_30,'(]',1,6) - 2)
14363 ,SUBSTRB(anc_id_30
14364        ,INSTRB(anc_id_30,'(]',1,7) + 2
14365        ,LENGTHB(anc_id_30))
14366 )
14367 
14368 WHEN anc_id_31 IS NOT NULL THEN
14369   INTO xla_ae_header_acs (
14370         ae_header_id , object_version_number
14371       , analytical_criterion_code
14372       , analytical_criterion_type_code
14373       , amb_context_code
14374       , ac1,ac2,ac3,ac4,ac5)
14375 VALUES (ae_header_id, C_OVN
14376 ,SUBSTRB(anc_id_31
14377        ,1
14378        ,INSTRB(anc_id_31,'(]',1,1) -1)
14379 ,SUBSTRB(anc_id_31
14380        ,INSTRB(anc_id_31,'(]',1,1) + 2
14381        ,INSTRB(anc_id_31,'(]',1,2) -
14382         INSTRB(anc_id_31,'(]',1,1) - 2)
14383 ,SUBSTRB(anc_id_31
14384        ,INSTRB(anc_id_31,'(]',1,2) + 2
14385        ,INSTRB(anc_id_31,'(]',1,3) -
14386         INSTRB(anc_id_31,'(]',1,2) - 2)
14387 ,SUBSTRB(anc_id_31
14388        ,INSTRB(anc_id_31,'(]',1,3) + 2
14389        ,INSTRB(anc_id_31,'(]',1,4) -
14390         INSTRB(anc_id_31,'(]',1,3) - 2)
14391 ,SUBSTRB(anc_id_31
14392        ,INSTRB(anc_id_31,'(]',1,4) + 2
14393        ,INSTRB(anc_id_31,'(]',1,5) -
14394         INSTRB(anc_id_31,'(]',1,4) - 2)
14395 ,SUBSTRB(anc_id_31
14396        ,INSTRB(anc_id_31,'(]',1,5) + 2
14397        ,INSTRB(anc_id_31,'(]',1,6) -
14398         INSTRB(anc_id_31,'(]',1,5) - 2)
14399 ,SUBSTRB(anc_id_31
14400        ,INSTRB(anc_id_31,'(]',1,6) + 2
14401        ,INSTRB(anc_id_31,'(]',1,7) -
14402         INSTRB(anc_id_31,'(]',1,6) - 2)
14403 ,SUBSTRB(anc_id_31
14404        ,INSTRB(anc_id_31,'(]',1,7) + 2
14405        ,LENGTHB(anc_id_31))
14406 )
14407 
14408 WHEN anc_id_32 IS NOT NULL THEN
14409   INTO xla_ae_header_acs (
14410         ae_header_id , object_version_number
14411       , analytical_criterion_code
14412       , analytical_criterion_type_code
14413       , amb_context_code
14414       , ac1,ac2,ac3,ac4,ac5)
14415 VALUES (ae_header_id, C_OVN
14416 ,SUBSTRB(anc_id_32
14417        ,1
14418        ,INSTRB(anc_id_32,'(]',1,1) -1)
14419 ,SUBSTRB(anc_id_32
14420        ,INSTRB(anc_id_32,'(]',1,1) + 2
14421        ,INSTRB(anc_id_32,'(]',1,2) -
14422         INSTRB(anc_id_32,'(]',1,1) - 2)
14423 ,SUBSTRB(anc_id_32
14424        ,INSTRB(anc_id_32,'(]',1,2) + 2
14425        ,INSTRB(anc_id_32,'(]',1,3) -
14426         INSTRB(anc_id_32,'(]',1,2) - 2)
14427 ,SUBSTRB(anc_id_32
14428        ,INSTRB(anc_id_32,'(]',1,3) + 2
14429        ,INSTRB(anc_id_32,'(]',1,4) -
14430         INSTRB(anc_id_32,'(]',1,3) - 2)
14431 ,SUBSTRB(anc_id_32
14432        ,INSTRB(anc_id_32,'(]',1,4) + 2
14433        ,INSTRB(anc_id_32,'(]',1,5) -
14434         INSTRB(anc_id_32,'(]',1,4) - 2)
14435 ,SUBSTRB(anc_id_32
14436        ,INSTRB(anc_id_32,'(]',1,5) + 2
14437        ,INSTRB(anc_id_32,'(]',1,6) -
14438         INSTRB(anc_id_32,'(]',1,5) - 2)
14439 ,SUBSTRB(anc_id_32
14440        ,INSTRB(anc_id_32,'(]',1,6) + 2
14441        ,INSTRB(anc_id_32,'(]',1,7) -
14442         INSTRB(anc_id_32,'(]',1,6) - 2)
14443 ,SUBSTRB(anc_id_32
14444        ,INSTRB(anc_id_32,'(]',1,7) + 2
14445        ,LENGTHB(anc_id_32))
14446 )
14447 
14448 WHEN anc_id_33 IS NOT NULL THEN
14449   INTO xla_ae_header_acs (
14450         ae_header_id , object_version_number
14451       , analytical_criterion_code
14452       , analytical_criterion_type_code
14453       , amb_context_code
14454       , ac1,ac2,ac3,ac4,ac5)
14455 VALUES (ae_header_id, C_OVN
14456 ,SUBSTRB(anc_id_33
14457        ,1
14458        ,INSTRB(anc_id_33,'(]',1,1) -1)
14459 ,SUBSTRB(anc_id_33
14460        ,INSTRB(anc_id_33,'(]',1,1) + 2
14461        ,INSTRB(anc_id_33,'(]',1,2) -
14462         INSTRB(anc_id_33,'(]',1,1) - 2)
14463 ,SUBSTRB(anc_id_33
14464        ,INSTRB(anc_id_33,'(]',1,2) + 2
14465        ,INSTRB(anc_id_33,'(]',1,3) -
14466         INSTRB(anc_id_33,'(]',1,2) - 2)
14467 ,SUBSTRB(anc_id_33
14468        ,INSTRB(anc_id_33,'(]',1,3) + 2
14469        ,INSTRB(anc_id_33,'(]',1,4) -
14470         INSTRB(anc_id_33,'(]',1,3) - 2)
14471 ,SUBSTRB(anc_id_33
14472        ,INSTRB(anc_id_33,'(]',1,4) + 2
14473        ,INSTRB(anc_id_33,'(]',1,5) -
14474         INSTRB(anc_id_33,'(]',1,4) - 2)
14475 ,SUBSTRB(anc_id_33
14476        ,INSTRB(anc_id_33,'(]',1,5) + 2
14477        ,INSTRB(anc_id_33,'(]',1,6) -
14478         INSTRB(anc_id_33,'(]',1,5) - 2)
14479 ,SUBSTRB(anc_id_33
14480        ,INSTRB(anc_id_33,'(]',1,6) + 2
14481        ,INSTRB(anc_id_33,'(]',1,7) -
14482         INSTRB(anc_id_33,'(]',1,6) - 2)
14483 ,SUBSTRB(anc_id_33
14484        ,INSTRB(anc_id_33,'(]',1,7) + 2
14485        ,LENGTHB(anc_id_33))
14486 )
14487 
14488 WHEN anc_id_34 IS NOT NULL THEN
14489   INTO xla_ae_header_acs (
14490         ae_header_id , object_version_number
14491       , analytical_criterion_code
14492       , analytical_criterion_type_code
14493       , amb_context_code
14494       , ac1,ac2,ac3,ac4,ac5)
14495 VALUES (ae_header_id, C_OVN
14496 ,SUBSTRB(anc_id_34
14497        ,1
14498        ,INSTRB(anc_id_34,'(]',1,1) -1)
14499 ,SUBSTRB(anc_id_34
14500        ,INSTRB(anc_id_34,'(]',1,1) + 2
14501        ,INSTRB(anc_id_34,'(]',1,2) -
14502         INSTRB(anc_id_34,'(]',1,1) - 2)
14503 ,SUBSTRB(anc_id_34
14504        ,INSTRB(anc_id_34,'(]',1,2) + 2
14505        ,INSTRB(anc_id_34,'(]',1,3) -
14506         INSTRB(anc_id_34,'(]',1,2) - 2)
14507 ,SUBSTRB(anc_id_34
14508        ,INSTRB(anc_id_34,'(]',1,3) + 2
14509        ,INSTRB(anc_id_34,'(]',1,4) -
14510         INSTRB(anc_id_34,'(]',1,3) - 2)
14511 ,SUBSTRB(anc_id_34
14512        ,INSTRB(anc_id_34,'(]',1,4) + 2
14513        ,INSTRB(anc_id_34,'(]',1,5) -
14514         INSTRB(anc_id_34,'(]',1,4) - 2)
14515 ,SUBSTRB(anc_id_34
14516        ,INSTRB(anc_id_34,'(]',1,5) + 2
14517        ,INSTRB(anc_id_34,'(]',1,6) -
14518         INSTRB(anc_id_34,'(]',1,5) - 2)
14519 ,SUBSTRB(anc_id_34
14520        ,INSTRB(anc_id_34,'(]',1,6) + 2
14521        ,INSTRB(anc_id_34,'(]',1,7) -
14522         INSTRB(anc_id_34,'(]',1,6) - 2)
14523 ,SUBSTRB(anc_id_34
14524        ,INSTRB(anc_id_34,'(]',1,7) + 2
14525        ,LENGTHB(anc_id_34))
14526 )
14527 
14528 WHEN anc_id_35 IS NOT NULL THEN
14529   INTO xla_ae_header_acs (
14530         ae_header_id , object_version_number
14531       , analytical_criterion_code
14532       , analytical_criterion_type_code
14533       , amb_context_code
14534       , ac1,ac2,ac3,ac4,ac5)
14535 VALUES (ae_header_id, C_OVN
14536 ,SUBSTRB(anc_id_35
14537        ,1
14538        ,INSTRB(anc_id_35,'(]',1,1) -1)
14539 ,SUBSTRB(anc_id_35
14540        ,INSTRB(anc_id_35,'(]',1,1) + 2
14541        ,INSTRB(anc_id_35,'(]',1,2) -
14542         INSTRB(anc_id_35,'(]',1,1) - 2)
14543 ,SUBSTRB(anc_id_35
14544        ,INSTRB(anc_id_35,'(]',1,2) + 2
14545        ,INSTRB(anc_id_35,'(]',1,3) -
14546         INSTRB(anc_id_35,'(]',1,2) - 2)
14547 ,SUBSTRB(anc_id_35
14548        ,INSTRB(anc_id_35,'(]',1,3) + 2
14549        ,INSTRB(anc_id_35,'(]',1,4) -
14550         INSTRB(anc_id_35,'(]',1,3) - 2)
14551 ,SUBSTRB(anc_id_35
14552        ,INSTRB(anc_id_35,'(]',1,4) + 2
14553        ,INSTRB(anc_id_35,'(]',1,5) -
14554         INSTRB(anc_id_35,'(]',1,4) - 2)
14555 ,SUBSTRB(anc_id_35
14556        ,INSTRB(anc_id_35,'(]',1,5) + 2
14557        ,INSTRB(anc_id_35,'(]',1,6) -
14558         INSTRB(anc_id_35,'(]',1,5) - 2)
14559 ,SUBSTRB(anc_id_35
14560        ,INSTRB(anc_id_35,'(]',1,6) + 2
14561        ,INSTRB(anc_id_35,'(]',1,7) -
14562         INSTRB(anc_id_35,'(]',1,6) - 2)
14563 ,SUBSTRB(anc_id_35
14564        ,INSTRB(anc_id_35,'(]',1,7) + 2
14565        ,LENGTHB(anc_id_35))
14566 )
14567 
14568 WHEN anc_id_36 IS NOT NULL THEN
14569   INTO xla_ae_header_acs (
14570         ae_header_id , object_version_number
14571       , analytical_criterion_code
14572       , analytical_criterion_type_code
14573       , amb_context_code
14574       , ac1,ac2,ac3,ac4,ac5)
14575 VALUES (ae_header_id, C_OVN
14576 ,SUBSTRB(anc_id_36
14577        ,1
14578        ,INSTRB(anc_id_36,'(]',1,1) -1)
14579 ,SUBSTRB(anc_id_36
14580        ,INSTRB(anc_id_36,'(]',1,1) + 2
14581        ,INSTRB(anc_id_36,'(]',1,2) -
14582         INSTRB(anc_id_36,'(]',1,1) - 2)
14583 ,SUBSTRB(anc_id_36
14584        ,INSTRB(anc_id_36,'(]',1,2) + 2
14585        ,INSTRB(anc_id_36,'(]',1,3) -
14586         INSTRB(anc_id_36,'(]',1,2) - 2)
14587 ,SUBSTRB(anc_id_36
14588        ,INSTRB(anc_id_36,'(]',1,3) + 2
14589        ,INSTRB(anc_id_36,'(]',1,4) -
14590         INSTRB(anc_id_36,'(]',1,3) - 2)
14591 ,SUBSTRB(anc_id_36
14592        ,INSTRB(anc_id_36,'(]',1,4) + 2
14593        ,INSTRB(anc_id_36,'(]',1,5) -
14594         INSTRB(anc_id_36,'(]',1,4) - 2)
14595 ,SUBSTRB(anc_id_36
14596        ,INSTRB(anc_id_36,'(]',1,5) + 2
14597        ,INSTRB(anc_id_36,'(]',1,6) -
14598         INSTRB(anc_id_36,'(]',1,5) - 2)
14599 ,SUBSTRB(anc_id_36
14600        ,INSTRB(anc_id_36,'(]',1,6) + 2
14601        ,INSTRB(anc_id_36,'(]',1,7) -
14602         INSTRB(anc_id_36,'(]',1,6) - 2)
14603 ,SUBSTRB(anc_id_36
14604        ,INSTRB(anc_id_36,'(]',1,7) + 2
14605        ,LENGTHB(anc_id_36))
14606 )
14607 
14608 WHEN anc_id_37 IS NOT NULL THEN
14609   INTO xla_ae_header_acs (
14610         ae_header_id , object_version_number
14611       , analytical_criterion_code
14612       , analytical_criterion_type_code
14613       , amb_context_code
14614       , ac1,ac2,ac3,ac4,ac5)
14615 VALUES (ae_header_id, C_OVN
14616 ,SUBSTRB(anc_id_37
14617        ,1
14618        ,INSTRB(anc_id_37,'(]',1,1) -1)
14619 ,SUBSTRB(anc_id_37
14620        ,INSTRB(anc_id_37,'(]',1,1) + 2
14621        ,INSTRB(anc_id_37,'(]',1,2) -
14622         INSTRB(anc_id_37,'(]',1,1) - 2)
14623 ,SUBSTRB(anc_id_37
14624        ,INSTRB(anc_id_37,'(]',1,2) + 2
14625        ,INSTRB(anc_id_37,'(]',1,3) -
14626         INSTRB(anc_id_37,'(]',1,2) - 2)
14627 ,SUBSTRB(anc_id_37
14628        ,INSTRB(anc_id_37,'(]',1,3) + 2
14629        ,INSTRB(anc_id_37,'(]',1,4) -
14630         INSTRB(anc_id_37,'(]',1,3) - 2)
14631 ,SUBSTRB(anc_id_37
14632        ,INSTRB(anc_id_37,'(]',1,4) + 2
14633        ,INSTRB(anc_id_37,'(]',1,5) -
14634         INSTRB(anc_id_37,'(]',1,4) - 2)
14635 ,SUBSTRB(anc_id_37
14636        ,INSTRB(anc_id_37,'(]',1,5) + 2
14637        ,INSTRB(anc_id_37,'(]',1,6) -
14638         INSTRB(anc_id_37,'(]',1,5) - 2)
14639 ,SUBSTRB(anc_id_37
14640        ,INSTRB(anc_id_37,'(]',1,6) + 2
14641        ,INSTRB(anc_id_37,'(]',1,7) -
14642         INSTRB(anc_id_37,'(]',1,6) - 2)
14643 ,SUBSTRB(anc_id_37
14644        ,INSTRB(anc_id_37,'(]',1,7) + 2
14645        ,LENGTHB(anc_id_37))
14646 )
14647 
14648 WHEN anc_id_38 IS NOT NULL THEN
14649   INTO xla_ae_header_acs (
14650         ae_header_id , object_version_number
14651       , analytical_criterion_code
14652       , analytical_criterion_type_code
14653       , amb_context_code
14654       , ac1,ac2,ac3,ac4,ac5)
14655 VALUES (ae_header_id, C_OVN
14656 ,SUBSTRB(anc_id_38
14657        ,1
14658        ,INSTRB(anc_id_38,'(]',1,1) -1)
14659 ,SUBSTRB(anc_id_38
14660        ,INSTRB(anc_id_38,'(]',1,1) + 2
14661        ,INSTRB(anc_id_38,'(]',1,2) -
14662         INSTRB(anc_id_38,'(]',1,1) - 2)
14663 ,SUBSTRB(anc_id_38
14664        ,INSTRB(anc_id_38,'(]',1,2) + 2
14665        ,INSTRB(anc_id_38,'(]',1,3) -
14666         INSTRB(anc_id_38,'(]',1,2) - 2)
14667 ,SUBSTRB(anc_id_38
14668        ,INSTRB(anc_id_38,'(]',1,3) + 2
14669        ,INSTRB(anc_id_38,'(]',1,4) -
14670         INSTRB(anc_id_38,'(]',1,3) - 2)
14671 ,SUBSTRB(anc_id_38
14672        ,INSTRB(anc_id_38,'(]',1,4) + 2
14673        ,INSTRB(anc_id_38,'(]',1,5) -
14674         INSTRB(anc_id_38,'(]',1,4) - 2)
14675 ,SUBSTRB(anc_id_38
14676        ,INSTRB(anc_id_38,'(]',1,5) + 2
14677        ,INSTRB(anc_id_38,'(]',1,6) -
14678         INSTRB(anc_id_38,'(]',1,5) - 2)
14679 ,SUBSTRB(anc_id_38
14680        ,INSTRB(anc_id_38,'(]',1,6) + 2
14681        ,INSTRB(anc_id_38,'(]',1,7) -
14682         INSTRB(anc_id_38,'(]',1,6) - 2)
14683 ,SUBSTRB(anc_id_38
14684        ,INSTRB(anc_id_38,'(]',1,7) + 2
14685        ,LENGTHB(anc_id_38))
14686 )
14687 
14688 WHEN anc_id_39 IS NOT NULL THEN
14689   INTO xla_ae_header_acs (
14690         ae_header_id , object_version_number
14691       , analytical_criterion_code
14692       , analytical_criterion_type_code
14693       , amb_context_code
14694       , ac1,ac2,ac3,ac4,ac5)
14695 VALUES (ae_header_id, C_OVN
14696 ,SUBSTRB(anc_id_39
14697        ,1
14698        ,INSTRB(anc_id_39,'(]',1,1) -1)
14699 ,SUBSTRB(anc_id_39
14700        ,INSTRB(anc_id_39,'(]',1,1) + 2
14701        ,INSTRB(anc_id_39,'(]',1,2) -
14702         INSTRB(anc_id_39,'(]',1,1) - 2)
14703 ,SUBSTRB(anc_id_39
14704        ,INSTRB(anc_id_39,'(]',1,2) + 2
14705        ,INSTRB(anc_id_39,'(]',1,3) -
14706         INSTRB(anc_id_39,'(]',1,2) - 2)
14707 ,SUBSTRB(anc_id_39
14708        ,INSTRB(anc_id_39,'(]',1,3) + 2
14709        ,INSTRB(anc_id_39,'(]',1,4) -
14710         INSTRB(anc_id_39,'(]',1,3) - 2)
14711 ,SUBSTRB(anc_id_39
14712        ,INSTRB(anc_id_39,'(]',1,4) + 2
14713        ,INSTRB(anc_id_39,'(]',1,5) -
14714         INSTRB(anc_id_39,'(]',1,4) - 2)
14715 ,SUBSTRB(anc_id_39
14716        ,INSTRB(anc_id_39,'(]',1,5) + 2
14717        ,INSTRB(anc_id_39,'(]',1,6) -
14718         INSTRB(anc_id_39,'(]',1,5) - 2)
14719 ,SUBSTRB(anc_id_39
14720        ,INSTRB(anc_id_39,'(]',1,6) + 2
14721        ,INSTRB(anc_id_39,'(]',1,7) -
14722         INSTRB(anc_id_39,'(]',1,6) - 2)
14723 ,SUBSTRB(anc_id_39
14724        ,INSTRB(anc_id_39,'(]',1,7) + 2
14725        ,LENGTHB(anc_id_39))
14726 )
14727 
14728 WHEN anc_id_40 IS NOT NULL THEN
14729   INTO xla_ae_header_acs (
14730         ae_header_id , object_version_number
14731       , analytical_criterion_code
14732       , analytical_criterion_type_code
14733       , amb_context_code
14734       , ac1,ac2,ac3,ac4,ac5)
14735 VALUES (ae_header_id, C_OVN
14736 ,SUBSTRB(anc_id_40
14737        ,1
14738        ,INSTRB(anc_id_40,'(]',1,1) -1)
14739 ,SUBSTRB(anc_id_40
14740        ,INSTRB(anc_id_40,'(]',1,1) + 2
14741        ,INSTRB(anc_id_40,'(]',1,2) -
14742         INSTRB(anc_id_40,'(]',1,1) - 2)
14743 ,SUBSTRB(anc_id_40
14744        ,INSTRB(anc_id_40,'(]',1,2) + 2
14745        ,INSTRB(anc_id_40,'(]',1,3) -
14746         INSTRB(anc_id_40,'(]',1,2) - 2)
14747 ,SUBSTRB(anc_id_40
14748        ,INSTRB(anc_id_40,'(]',1,3) + 2
14749        ,INSTRB(anc_id_40,'(]',1,4) -
14750         INSTRB(anc_id_40,'(]',1,3) - 2)
14751 ,SUBSTRB(anc_id_40
14752        ,INSTRB(anc_id_40,'(]',1,4) + 2
14753        ,INSTRB(anc_id_40,'(]',1,5) -
14754         INSTRB(anc_id_40,'(]',1,4) - 2)
14755 ,SUBSTRB(anc_id_40
14756        ,INSTRB(anc_id_40,'(]',1,5) + 2
14757        ,INSTRB(anc_id_40,'(]',1,6) -
14758         INSTRB(anc_id_40,'(]',1,5) - 2)
14759 ,SUBSTRB(anc_id_40
14760        ,INSTRB(anc_id_40,'(]',1,6) + 2
14761        ,INSTRB(anc_id_40,'(]',1,7) -
14762         INSTRB(anc_id_40,'(]',1,6) - 2)
14763 ,SUBSTRB(anc_id_40
14764        ,INSTRB(anc_id_40,'(]',1,7) + 2
14765        ,LENGTHB(anc_id_40))
14766 )
14767 
14768 WHEN anc_id_41 IS NOT NULL THEN
14769   INTO xla_ae_header_acs (
14770         ae_header_id , object_version_number
14771       , analytical_criterion_code
14772       , analytical_criterion_type_code
14773       , amb_context_code
14774       , ac1,ac2,ac3,ac4,ac5)
14775 VALUES (ae_header_id, C_OVN
14776 ,SUBSTRB(anc_id_41
14777        ,1
14778        ,INSTRB(anc_id_41,'(]',1,1) -1)
14779 ,SUBSTRB(anc_id_41
14780        ,INSTRB(anc_id_41,'(]',1,1) + 2
14781        ,INSTRB(anc_id_41,'(]',1,2) -
14782         INSTRB(anc_id_41,'(]',1,1) - 2)
14783 ,SUBSTRB(anc_id_41
14784        ,INSTRB(anc_id_41,'(]',1,2) + 2
14785        ,INSTRB(anc_id_41,'(]',1,3) -
14786         INSTRB(anc_id_41,'(]',1,2) - 2)
14787 ,SUBSTRB(anc_id_41
14788        ,INSTRB(anc_id_41,'(]',1,3) + 2
14789        ,INSTRB(anc_id_41,'(]',1,4) -
14790         INSTRB(anc_id_41,'(]',1,3) - 2)
14791 ,SUBSTRB(anc_id_41
14792        ,INSTRB(anc_id_41,'(]',1,4) + 2
14793        ,INSTRB(anc_id_41,'(]',1,5) -
14794         INSTRB(anc_id_41,'(]',1,4) - 2)
14795 ,SUBSTRB(anc_id_41
14796        ,INSTRB(anc_id_41,'(]',1,5) + 2
14797        ,INSTRB(anc_id_41,'(]',1,6) -
14798         INSTRB(anc_id_41,'(]',1,5) - 2)
14799 ,SUBSTRB(anc_id_41
14800        ,INSTRB(anc_id_41,'(]',1,6) + 2
14801        ,INSTRB(anc_id_41,'(]',1,7) -
14802         INSTRB(anc_id_41,'(]',1,6) - 2)
14803 ,SUBSTRB(anc_id_41
14804        ,INSTRB(anc_id_41,'(]',1,7) + 2
14805        ,LENGTHB(anc_id_41))
14806 )
14807 
14808 WHEN anc_id_42 IS NOT NULL THEN
14809   INTO xla_ae_header_acs (
14810         ae_header_id , object_version_number
14811       , analytical_criterion_code
14812       , analytical_criterion_type_code
14813       , amb_context_code
14814       , ac1,ac2,ac3,ac4,ac5)
14815 VALUES (ae_header_id, C_OVN
14816 ,SUBSTRB(anc_id_42
14817        ,1
14818        ,INSTRB(anc_id_42,'(]',1,1) -1)
14819 ,SUBSTRB(anc_id_42
14820        ,INSTRB(anc_id_42,'(]',1,1) + 2
14821        ,INSTRB(anc_id_42,'(]',1,2) -
14822         INSTRB(anc_id_42,'(]',1,1) - 2)
14823 ,SUBSTRB(anc_id_42
14824        ,INSTRB(anc_id_42,'(]',1,2) + 2
14825        ,INSTRB(anc_id_42,'(]',1,3) -
14826         INSTRB(anc_id_42,'(]',1,2) - 2)
14827 ,SUBSTRB(anc_id_42
14828        ,INSTRB(anc_id_42,'(]',1,3) + 2
14829        ,INSTRB(anc_id_42,'(]',1,4) -
14830         INSTRB(anc_id_42,'(]',1,3) - 2)
14831 ,SUBSTRB(anc_id_42
14832        ,INSTRB(anc_id_42,'(]',1,4) + 2
14833        ,INSTRB(anc_id_42,'(]',1,5) -
14834         INSTRB(anc_id_42,'(]',1,4) - 2)
14835 ,SUBSTRB(anc_id_42
14836        ,INSTRB(anc_id_42,'(]',1,5) + 2
14837        ,INSTRB(anc_id_42,'(]',1,6) -
14838         INSTRB(anc_id_42,'(]',1,5) - 2)
14839 ,SUBSTRB(anc_id_42
14840        ,INSTRB(anc_id_42,'(]',1,6) + 2
14841        ,INSTRB(anc_id_42,'(]',1,7) -
14842         INSTRB(anc_id_42,'(]',1,6) - 2)
14843 ,SUBSTRB(anc_id_42
14844        ,INSTRB(anc_id_42,'(]',1,7) + 2
14845        ,LENGTHB(anc_id_42))
14846 )
14847 
14848 WHEN anc_id_43 IS NOT NULL THEN
14849   INTO xla_ae_header_acs (
14850         ae_header_id , object_version_number
14851       , analytical_criterion_code
14852       , analytical_criterion_type_code
14853       , amb_context_code
14854       , ac1,ac2,ac3,ac4,ac5)
14855 VALUES (ae_header_id, C_OVN
14856 ,SUBSTRB(anc_id_43
14857        ,1
14858        ,INSTRB(anc_id_43,'(]',1,1) -1)
14859 ,SUBSTRB(anc_id_43
14860        ,INSTRB(anc_id_43,'(]',1,1) + 2
14861        ,INSTRB(anc_id_43,'(]',1,2) -
14862         INSTRB(anc_id_43,'(]',1,1) - 2)
14863 ,SUBSTRB(anc_id_43
14864        ,INSTRB(anc_id_43,'(]',1,2) + 2
14865        ,INSTRB(anc_id_43,'(]',1,3) -
14866         INSTRB(anc_id_43,'(]',1,2) - 2)
14867 ,SUBSTRB(anc_id_43
14868        ,INSTRB(anc_id_43,'(]',1,3) + 2
14869        ,INSTRB(anc_id_43,'(]',1,4) -
14870         INSTRB(anc_id_43,'(]',1,3) - 2)
14871 ,SUBSTRB(anc_id_43
14872        ,INSTRB(anc_id_43,'(]',1,4) + 2
14873        ,INSTRB(anc_id_43,'(]',1,5) -
14874         INSTRB(anc_id_43,'(]',1,4) - 2)
14875 ,SUBSTRB(anc_id_43
14876        ,INSTRB(anc_id_43,'(]',1,5) + 2
14877        ,INSTRB(anc_id_43,'(]',1,6) -
14878         INSTRB(anc_id_43,'(]',1,5) - 2)
14879 ,SUBSTRB(anc_id_43
14880        ,INSTRB(anc_id_43,'(]',1,6) + 2
14881        ,INSTRB(anc_id_43,'(]',1,7) -
14882         INSTRB(anc_id_43,'(]',1,6) - 2)
14883 ,SUBSTRB(anc_id_43
14884        ,INSTRB(anc_id_43,'(]',1,7) + 2
14885        ,LENGTHB(anc_id_43))
14886 )
14887 
14888 WHEN anc_id_44 IS NOT NULL THEN
14889   INTO xla_ae_header_acs (
14890         ae_header_id , object_version_number
14891       , analytical_criterion_code
14892       , analytical_criterion_type_code
14893       , amb_context_code
14894       , ac1,ac2,ac3,ac4,ac5)
14895 VALUES (ae_header_id, C_OVN
14896 ,SUBSTRB(anc_id_44
14897        ,1
14898        ,INSTRB(anc_id_44,'(]',1,1) -1)
14899 ,SUBSTRB(anc_id_44
14900        ,INSTRB(anc_id_44,'(]',1,1) + 2
14901        ,INSTRB(anc_id_44,'(]',1,2) -
14902         INSTRB(anc_id_44,'(]',1,1) - 2)
14903 ,SUBSTRB(anc_id_44
14904        ,INSTRB(anc_id_44,'(]',1,2) + 2
14905        ,INSTRB(anc_id_44,'(]',1,3) -
14906         INSTRB(anc_id_44,'(]',1,2) - 2)
14907 ,SUBSTRB(anc_id_44
14908        ,INSTRB(anc_id_44,'(]',1,3) + 2
14909        ,INSTRB(anc_id_44,'(]',1,4) -
14910         INSTRB(anc_id_44,'(]',1,3) - 2)
14911 ,SUBSTRB(anc_id_44
14912        ,INSTRB(anc_id_44,'(]',1,4) + 2
14913        ,INSTRB(anc_id_44,'(]',1,5) -
14914         INSTRB(anc_id_44,'(]',1,4) - 2)
14915 ,SUBSTRB(anc_id_44
14916        ,INSTRB(anc_id_44,'(]',1,5) + 2
14917        ,INSTRB(anc_id_44,'(]',1,6) -
14918         INSTRB(anc_id_44,'(]',1,5) - 2)
14919 ,SUBSTRB(anc_id_44
14920        ,INSTRB(anc_id_44,'(]',1,6) + 2
14921        ,INSTRB(anc_id_44,'(]',1,7) -
14922         INSTRB(anc_id_44,'(]',1,6) - 2)
14923 ,SUBSTRB(anc_id_44
14924        ,INSTRB(anc_id_44,'(]',1,7) + 2
14925        ,LENGTHB(anc_id_44))
14926 )
14927 
14928 WHEN anc_id_45 IS NOT NULL THEN
14929   INTO xla_ae_header_acs (
14930         ae_header_id , object_version_number
14931       , analytical_criterion_code
14932       , analytical_criterion_type_code
14933       , amb_context_code
14934       , ac1,ac2,ac3,ac4,ac5)
14935 VALUES (ae_header_id, C_OVN
14936 ,SUBSTRB(anc_id_45
14937        ,1
14938        ,INSTRB(anc_id_45,'(]',1,1) -1)
14939 ,SUBSTRB(anc_id_45
14940        ,INSTRB(anc_id_45,'(]',1,1) + 2
14941        ,INSTRB(anc_id_45,'(]',1,2) -
14942         INSTRB(anc_id_45,'(]',1,1) - 2)
14943 ,SUBSTRB(anc_id_45
14944        ,INSTRB(anc_id_45,'(]',1,2) + 2
14945        ,INSTRB(anc_id_45,'(]',1,3) -
14946         INSTRB(anc_id_45,'(]',1,2) - 2)
14947 ,SUBSTRB(anc_id_45
14948        ,INSTRB(anc_id_45,'(]',1,3) + 2
14949        ,INSTRB(anc_id_45,'(]',1,4) -
14950         INSTRB(anc_id_45,'(]',1,3) - 2)
14951 ,SUBSTRB(anc_id_45
14952        ,INSTRB(anc_id_45,'(]',1,4) + 2
14953        ,INSTRB(anc_id_45,'(]',1,5) -
14954         INSTRB(anc_id_45,'(]',1,4) - 2)
14955 ,SUBSTRB(anc_id_45
14956        ,INSTRB(anc_id_45,'(]',1,5) + 2
14957        ,INSTRB(anc_id_45,'(]',1,6) -
14958         INSTRB(anc_id_45,'(]',1,5) - 2)
14959 ,SUBSTRB(anc_id_45
14960        ,INSTRB(anc_id_45,'(]',1,6) + 2
14961        ,INSTRB(anc_id_45,'(]',1,7) -
14962         INSTRB(anc_id_45,'(]',1,6) - 2)
14963 ,SUBSTRB(anc_id_45
14964        ,INSTRB(anc_id_45,'(]',1,7) + 2
14965        ,LENGTHB(anc_id_45))
14966 )
14967 
14968 WHEN anc_id_46 IS NOT NULL THEN
14969   INTO xla_ae_header_acs (
14970         ae_header_id , object_version_number
14971       , analytical_criterion_code
14972       , analytical_criterion_type_code
14973       , amb_context_code
14974       , ac1,ac2,ac3,ac4,ac5)
14975 VALUES (ae_header_id, C_OVN
14976 ,SUBSTRB(anc_id_46
14977        ,1
14978        ,INSTRB(anc_id_46,'(]',1,1) -1)
14979 ,SUBSTRB(anc_id_46
14980        ,INSTRB(anc_id_46,'(]',1,1) + 2
14981        ,INSTRB(anc_id_46,'(]',1,2) -
14982         INSTRB(anc_id_46,'(]',1,1) - 2)
14983 ,SUBSTRB(anc_id_46
14984        ,INSTRB(anc_id_46,'(]',1,2) + 2
14985        ,INSTRB(anc_id_46,'(]',1,3) -
14986         INSTRB(anc_id_46,'(]',1,2) - 2)
14987 ,SUBSTRB(anc_id_46
14988        ,INSTRB(anc_id_46,'(]',1,3) + 2
14989        ,INSTRB(anc_id_46,'(]',1,4) -
14990         INSTRB(anc_id_46,'(]',1,3) - 2)
14991 ,SUBSTRB(anc_id_46
14992        ,INSTRB(anc_id_46,'(]',1,4) + 2
14993        ,INSTRB(anc_id_46,'(]',1,5) -
14994         INSTRB(anc_id_46,'(]',1,4) - 2)
14995 ,SUBSTRB(anc_id_46
14996        ,INSTRB(anc_id_46,'(]',1,5) + 2
14997        ,INSTRB(anc_id_46,'(]',1,6) -
14998         INSTRB(anc_id_46,'(]',1,5) - 2)
14999 ,SUBSTRB(anc_id_46
15000        ,INSTRB(anc_id_46,'(]',1,6) + 2
15001        ,INSTRB(anc_id_46,'(]',1,7) -
15002         INSTRB(anc_id_46,'(]',1,6) - 2)
15003 ,SUBSTRB(anc_id_46
15004        ,INSTRB(anc_id_46,'(]',1,7) + 2
15005        ,LENGTHB(anc_id_46))
15006 )
15007 
15008 WHEN anc_id_47 IS NOT NULL THEN
15009   INTO xla_ae_header_acs (
15010         ae_header_id , object_version_number
15011       , analytical_criterion_code
15012       , analytical_criterion_type_code
15013       , amb_context_code
15014       , ac1,ac2,ac3,ac4,ac5)
15015 VALUES (ae_header_id, C_OVN
15016 ,SUBSTRB(anc_id_47
15017        ,1
15018        ,INSTRB(anc_id_47,'(]',1,1) -1)
15019 ,SUBSTRB(anc_id_47
15020        ,INSTRB(anc_id_47,'(]',1,1) + 2
15021        ,INSTRB(anc_id_47,'(]',1,2) -
15022         INSTRB(anc_id_47,'(]',1,1) - 2)
15023 ,SUBSTRB(anc_id_47
15024        ,INSTRB(anc_id_47,'(]',1,2) + 2
15025        ,INSTRB(anc_id_47,'(]',1,3) -
15026         INSTRB(anc_id_47,'(]',1,2) - 2)
15027 ,SUBSTRB(anc_id_47
15028        ,INSTRB(anc_id_47,'(]',1,3) + 2
15029        ,INSTRB(anc_id_47,'(]',1,4) -
15030         INSTRB(anc_id_47,'(]',1,3) - 2)
15031 ,SUBSTRB(anc_id_47
15032        ,INSTRB(anc_id_47,'(]',1,4) + 2
15033        ,INSTRB(anc_id_47,'(]',1,5) -
15034         INSTRB(anc_id_47,'(]',1,4) - 2)
15035 ,SUBSTRB(anc_id_47
15036        ,INSTRB(anc_id_47,'(]',1,5) + 2
15037        ,INSTRB(anc_id_47,'(]',1,6) -
15038         INSTRB(anc_id_47,'(]',1,5) - 2)
15039 ,SUBSTRB(anc_id_47
15040        ,INSTRB(anc_id_47,'(]',1,6) + 2
15041        ,INSTRB(anc_id_47,'(]',1,7) -
15042         INSTRB(anc_id_47,'(]',1,6) - 2)
15043 ,SUBSTRB(anc_id_47
15044        ,INSTRB(anc_id_47,'(]',1,7) + 2
15045        ,LENGTHB(anc_id_47))
15046 )
15047 
15048 WHEN anc_id_48 IS NOT NULL THEN
15049   INTO xla_ae_header_acs (
15050         ae_header_id , object_version_number
15051       , analytical_criterion_code
15052       , analytical_criterion_type_code
15053       , amb_context_code
15054       , ac1,ac2,ac3,ac4,ac5)
15055 VALUES (ae_header_id, C_OVN
15056 ,SUBSTRB(anc_id_48
15057        ,1
15058        ,INSTRB(anc_id_48,'(]',1,1) -1)
15059 ,SUBSTRB(anc_id_48
15060        ,INSTRB(anc_id_48,'(]',1,1) + 2
15061        ,INSTRB(anc_id_48,'(]',1,2) -
15062         INSTRB(anc_id_48,'(]',1,1) - 2)
15063 ,SUBSTRB(anc_id_48
15064        ,INSTRB(anc_id_48,'(]',1,2) + 2
15065        ,INSTRB(anc_id_48,'(]',1,3) -
15066         INSTRB(anc_id_48,'(]',1,2) - 2)
15067 ,SUBSTRB(anc_id_48
15068        ,INSTRB(anc_id_48,'(]',1,3) + 2
15069        ,INSTRB(anc_id_48,'(]',1,4) -
15070         INSTRB(anc_id_48,'(]',1,3) - 2)
15071 ,SUBSTRB(anc_id_48
15072        ,INSTRB(anc_id_48,'(]',1,4) + 2
15073        ,INSTRB(anc_id_48,'(]',1,5) -
15074         INSTRB(anc_id_48,'(]',1,4) - 2)
15075 ,SUBSTRB(anc_id_48
15076        ,INSTRB(anc_id_48,'(]',1,5) + 2
15077        ,INSTRB(anc_id_48,'(]',1,6) -
15078         INSTRB(anc_id_48,'(]',1,5) - 2)
15079 ,SUBSTRB(anc_id_48
15080        ,INSTRB(anc_id_48,'(]',1,6) + 2
15081        ,INSTRB(anc_id_48,'(]',1,7) -
15082         INSTRB(anc_id_48,'(]',1,6) - 2)
15083 ,SUBSTRB(anc_id_48
15084        ,INSTRB(anc_id_48,'(]',1,7) + 2
15085        ,LENGTHB(anc_id_48))
15086 )
15087 
15088 WHEN anc_id_49 IS NOT NULL THEN
15089   INTO xla_ae_header_acs (
15090         ae_header_id , object_version_number
15091       , analytical_criterion_code
15092       , analytical_criterion_type_code
15093       , amb_context_code
15094       , ac1,ac2,ac3,ac4,ac5)
15095 VALUES (ae_header_id, C_OVN
15096 ,SUBSTRB(anc_id_49
15097        ,1
15098        ,INSTRB(anc_id_49,'(]',1,1) -1)
15099 ,SUBSTRB(anc_id_49
15100        ,INSTRB(anc_id_49,'(]',1,1) + 2
15101        ,INSTRB(anc_id_49,'(]',1,2) -
15102         INSTRB(anc_id_49,'(]',1,1) - 2)
15103 ,SUBSTRB(anc_id_49
15104        ,INSTRB(anc_id_49,'(]',1,2) + 2
15105        ,INSTRB(anc_id_49,'(]',1,3) -
15106         INSTRB(anc_id_49,'(]',1,2) - 2)
15107 ,SUBSTRB(anc_id_49
15108        ,INSTRB(anc_id_49,'(]',1,3) + 2
15109        ,INSTRB(anc_id_49,'(]',1,4) -
15110         INSTRB(anc_id_49,'(]',1,3) - 2)
15111 ,SUBSTRB(anc_id_49
15112        ,INSTRB(anc_id_49,'(]',1,4) + 2
15113        ,INSTRB(anc_id_49,'(]',1,5) -
15114         INSTRB(anc_id_49,'(]',1,4) - 2)
15115 ,SUBSTRB(anc_id_49
15116        ,INSTRB(anc_id_49,'(]',1,5) + 2
15117        ,INSTRB(anc_id_49,'(]',1,6) -
15118         INSTRB(anc_id_49,'(]',1,5) - 2)
15119 ,SUBSTRB(anc_id_49
15120        ,INSTRB(anc_id_49,'(]',1,6) + 2
15121        ,INSTRB(anc_id_49,'(]',1,7) -
15122         INSTRB(anc_id_49,'(]',1,6) - 2)
15123 ,SUBSTRB(anc_id_49
15124        ,INSTRB(anc_id_49,'(]',1,7) + 2
15125        ,LENGTHB(anc_id_49))
15126 )
15127 
15128 WHEN anc_id_50 IS NOT NULL THEN
15129   INTO xla_ae_header_acs (
15130         ae_header_id , object_version_number
15131       , analytical_criterion_code
15132       , analytical_criterion_type_code
15133       , amb_context_code
15134       , ac1,ac2,ac3,ac4,ac5)
15135 VALUES (ae_header_id, C_OVN
15136 ,SUBSTRB(anc_id_50
15137        ,1
15138        ,INSTRB(anc_id_50,'(]',1,1) -1)
15139 ,SUBSTRB(anc_id_50
15140        ,INSTRB(anc_id_50,'(]',1,1) + 2
15141        ,INSTRB(anc_id_50,'(]',1,2) -
15142         INSTRB(anc_id_50,'(]',1,1) - 2)
15143 ,SUBSTRB(anc_id_50
15144        ,INSTRB(anc_id_50,'(]',1,2) + 2
15145        ,INSTRB(anc_id_50,'(]',1,3) -
15146         INSTRB(anc_id_50,'(]',1,2) - 2)
15147 ,SUBSTRB(anc_id_50
15148        ,INSTRB(anc_id_50,'(]',1,3) + 2
15149        ,INSTRB(anc_id_50,'(]',1,4) -
15150         INSTRB(anc_id_50,'(]',1,3) - 2)
15151 ,SUBSTRB(anc_id_50
15152        ,INSTRB(anc_id_50,'(]',1,4) + 2
15153        ,INSTRB(anc_id_50,'(]',1,5) -
15154         INSTRB(anc_id_50,'(]',1,4) - 2)
15155 ,SUBSTRB(anc_id_50
15156        ,INSTRB(anc_id_50,'(]',1,5) + 2
15157        ,INSTRB(anc_id_50,'(]',1,6) -
15158         INSTRB(anc_id_50,'(]',1,5) - 2)
15159 ,SUBSTRB(anc_id_50
15160        ,INSTRB(anc_id_50,'(]',1,6) + 2
15161        ,INSTRB(anc_id_50,'(]',1,7) -
15162         INSTRB(anc_id_50,'(]',1,6) - 2)
15163 ,SUBSTRB(anc_id_50
15164        ,INSTRB(anc_id_50,'(]',1,7) + 2
15165        ,LENGTHB(anc_id_50))
15166 )
15167 
15168 SELECT  ae_header_id
15169       , anc_id_1
15170       , anc_id_2
15171       , anc_id_3
15172       , anc_id_4
15173       , anc_id_5
15174       , anc_id_6
15175       , anc_id_7
15176       , anc_id_8
15177       , anc_id_9
15178       , anc_id_10
15179       , anc_id_11
15180       , anc_id_12
15181       , anc_id_13
15182       , anc_id_14
15183       , anc_id_15
15184       , anc_id_16
15185       , anc_id_17
15186       , anc_id_18
15187       , anc_id_19
15188       , anc_id_20
15189       , anc_id_21
15190       , anc_id_22
15191       , anc_id_23
15192       , anc_id_24
15193       , anc_id_25
15194       , anc_id_26
15195       , anc_id_27
15196       , anc_id_28
15197       , anc_id_29
15198       , anc_id_30
15199       , anc_id_31
15200       , anc_id_32
15201       , anc_id_33
15202       , anc_id_34
15203       , anc_id_35
15204       , anc_id_36
15205       , anc_id_37
15206       , anc_id_38
15207       , anc_id_39
15208       , anc_id_40
15209       , anc_id_41
15210       , anc_id_42
15211       , anc_id_43
15212       , anc_id_44
15213       , anc_id_45
15214       , anc_id_46
15215       , anc_id_47
15216       , anc_id_48
15217       , anc_id_49
15218       , anc_id_50
15219  FROM  xla_ae_headers_gt
15220 WHERE  ae_header_id is not null;
15221 
15222 --
15223 IF (C_LEVEL_EVENT >= g_log_level) THEN
15224       trace
15225          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
15226          ,p_level    => C_LEVEL_EVENT
15227          ,p_module   => l_log_module);
15228 END IF;
15229 
15230 --
15231 EXCEPTION
15232 WHEN OTHERS THEN
15233   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
15234          trace
15235             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
15236             ,p_level    => C_LEVEL_EXCEPTION
15237             ,p_module   => l_log_module);
15238   END IF;
15239 
15240   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
15241                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
15242                                     ,p_token_1      => 'ERROR'
15243                                     ,p_value_1      => sqlerrm
15244                                     );
15245 END;
15246 --
15247 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15248 
15249       trace
15250          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
15251          ,p_level    => C_LEVEL_PROCEDURE
15252          ,p_module   => l_log_module);
15253 
15254       trace
15255          (p_msg      => 'END of InsertHdrAnalyticalCriteria50'
15256          ,p_level    => C_LEVEL_PROCEDURE
15257          ,p_module   => l_log_module);
15258 END IF;
15259 --
15260 EXCEPTION
15261 WHEN xla_exceptions_pkg.application_exception THEN
15262   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
15263        trace
15264            (p_msg      => 'Error. = '||sqlerrm
15265            ,p_level    => C_LEVEL_PROCEDURE
15266            ,p_module   => l_log_module);
15267   END IF;
15268   RAISE;
15269 WHEN OTHERS  THEN
15270  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
15271        trace
15272            (p_msg      => 'Error. = '||sqlerrm
15273            ,p_level    => C_LEVEL_PROCEDURE
15274            ,p_module   => l_log_module);
15275   END IF;
15276   xla_exceptions_pkg.raise_message
15277                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria50');
15278    --
15279 END InsertHdrAnalyticalCriteria50;
15280 
15281 --
15282 /*======================================================================+
15283 |                                                                       |
15284 | Insert Header Analytical Criteria 100                                 |
15285 |                                                                       |
15286 |                                                                       |
15287 +======================================================================*/
15288 --
15289 PROCEDURE InsertHdrAnalyticalCriteria100
15290 IS
15291 l_log_module         VARCHAR2(240);
15292 BEGIN
15293 --
15294 IF g_log_enabled THEN
15295       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria100';
15296 END IF;
15297 --
15298 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
15299 
15300       trace
15301          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria100'
15302          ,p_level    => C_LEVEL_PROCEDURE
15303          ,p_module   => l_log_module);
15304 END IF;
15305 --
15306 BEGIN
15307 
15308    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
15309 
15310       trace
15311          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
15312          ,p_level    => C_LEVEL_STATEMENT
15313          ,p_module   => l_log_module);
15314 
15315    END IF;
15316 --
15317 
15318 INSERT ALL
15319 WHEN anc_id_1 IS NOT NULL THEN
15320   INTO xla_ae_header_acs (
15321         ae_header_id , object_version_number
15322       , analytical_criterion_code
15323       , analytical_criterion_type_code
15324       , amb_context_code
15325       , ac1,ac2,ac3,ac4,ac5)
15326 VALUES (ae_header_id, C_OVN
15327 ,SUBSTRB(anc_id_1
15328        ,1
15329        ,INSTRB(anc_id_1,'(]',1,1) -1)
15330 ,SUBSTRB(anc_id_1
15331        ,INSTRB(anc_id_1,'(]',1,1) + 2
15332        ,INSTRB(anc_id_1,'(]',1,2) -
15333         INSTRB(anc_id_1,'(]',1,1) - 2)
15334 ,SUBSTRB(anc_id_1
15335        ,INSTRB(anc_id_1,'(]',1,2) + 2
15336        ,INSTRB(anc_id_1,'(]',1,3) -
15337         INSTRB(anc_id_1,'(]',1,2) - 2)
15338 ,SUBSTRB(anc_id_1
15339        ,INSTRB(anc_id_1,'(]',1,3) + 2
15340        ,INSTRB(anc_id_1,'(]',1,4) -
15341         INSTRB(anc_id_1,'(]',1,3) - 2)
15342 ,SUBSTRB(anc_id_1
15343        ,INSTRB(anc_id_1,'(]',1,4) + 2
15344        ,INSTRB(anc_id_1,'(]',1,5) -
15345         INSTRB(anc_id_1,'(]',1,4) - 2)
15346 ,SUBSTRB(anc_id_1
15347        ,INSTRB(anc_id_1,'(]',1,5) + 2
15348        ,INSTRB(anc_id_1,'(]',1,6) -
15349         INSTRB(anc_id_1,'(]',1,5) - 2)
15350 ,SUBSTRB(anc_id_1
15351        ,INSTRB(anc_id_1,'(]',1,6) + 2
15352        ,INSTRB(anc_id_1,'(]',1,7) -
15353         INSTRB(anc_id_1,'(]',1,6) - 2)
15354 ,SUBSTRB(anc_id_1
15355        ,INSTRB(anc_id_1,'(]',1,7) + 2
15356        ,LENGTHB(anc_id_1))
15357 )
15358 
15359 WHEN anc_id_2 IS NOT NULL THEN
15360   INTO xla_ae_header_acs (
15361         ae_header_id , object_version_number
15362       , analytical_criterion_code
15363       , analytical_criterion_type_code
15364       , amb_context_code
15365       , ac1,ac2,ac3,ac4,ac5)
15366 VALUES (ae_header_id, C_OVN
15367 ,SUBSTRB(anc_id_2
15368        ,1
15369        ,INSTRB(anc_id_2,'(]',1,1) -1)
15370 ,SUBSTRB(anc_id_2
15371        ,INSTRB(anc_id_2,'(]',1,1) + 2
15372        ,INSTRB(anc_id_2,'(]',1,2) -
15373         INSTRB(anc_id_2,'(]',1,1) - 2)
15374 ,SUBSTRB(anc_id_2
15375        ,INSTRB(anc_id_2,'(]',1,2) + 2
15376        ,INSTRB(anc_id_2,'(]',1,3) -
15377         INSTRB(anc_id_2,'(]',1,2) - 2)
15378 ,SUBSTRB(anc_id_2
15379        ,INSTRB(anc_id_2,'(]',1,3) + 2
15380        ,INSTRB(anc_id_2,'(]',1,4) -
15381         INSTRB(anc_id_2,'(]',1,3) - 2)
15382 ,SUBSTRB(anc_id_2
15383        ,INSTRB(anc_id_2,'(]',1,4) + 2
15384        ,INSTRB(anc_id_2,'(]',1,5) -
15385         INSTRB(anc_id_2,'(]',1,4) - 2)
15386 ,SUBSTRB(anc_id_2
15387        ,INSTRB(anc_id_2,'(]',1,5) + 2
15388        ,INSTRB(anc_id_2,'(]',1,6) -
15389         INSTRB(anc_id_2,'(]',1,5) - 2)
15390 ,SUBSTRB(anc_id_2
15391        ,INSTRB(anc_id_2,'(]',1,6) + 2
15392        ,INSTRB(anc_id_2,'(]',1,7) -
15393         INSTRB(anc_id_2,'(]',1,6) - 2)
15394 ,SUBSTRB(anc_id_2
15395        ,INSTRB(anc_id_2,'(]',1,7) + 2
15396        ,LENGTHB(anc_id_2))
15397 )
15398 
15399 WHEN anc_id_3 IS NOT NULL THEN
15400   INTO xla_ae_header_acs (
15401         ae_header_id , object_version_number
15402       , analytical_criterion_code
15403       , analytical_criterion_type_code
15404       , amb_context_code
15405       , ac1,ac2,ac3,ac4,ac5)
15406 VALUES (ae_header_id, C_OVN
15407 ,SUBSTRB(anc_id_3
15408        ,1
15409        ,INSTRB(anc_id_3,'(]',1,1) -1)
15410 ,SUBSTRB(anc_id_3
15411        ,INSTRB(anc_id_3,'(]',1,1) + 2
15412        ,INSTRB(anc_id_3,'(]',1,2) -
15413         INSTRB(anc_id_3,'(]',1,1) - 2)
15414 ,SUBSTRB(anc_id_3
15415        ,INSTRB(anc_id_3,'(]',1,2) + 2
15416        ,INSTRB(anc_id_3,'(]',1,3) -
15417         INSTRB(anc_id_3,'(]',1,2) - 2)
15418 ,SUBSTRB(anc_id_3
15419        ,INSTRB(anc_id_3,'(]',1,3) + 2
15420        ,INSTRB(anc_id_3,'(]',1,4) -
15421         INSTRB(anc_id_3,'(]',1,3) - 2)
15422 ,SUBSTRB(anc_id_3
15423        ,INSTRB(anc_id_3,'(]',1,4) + 2
15424        ,INSTRB(anc_id_3,'(]',1,5) -
15425         INSTRB(anc_id_3,'(]',1,4) - 2)
15426 ,SUBSTRB(anc_id_3
15427        ,INSTRB(anc_id_3,'(]',1,5) + 2
15428        ,INSTRB(anc_id_3,'(]',1,6) -
15429         INSTRB(anc_id_3,'(]',1,5) - 2)
15430 ,SUBSTRB(anc_id_3
15431        ,INSTRB(anc_id_3,'(]',1,6) + 2
15432        ,INSTRB(anc_id_3,'(]',1,7) -
15433         INSTRB(anc_id_3,'(]',1,6) - 2)
15434 ,SUBSTRB(anc_id_3
15435        ,INSTRB(anc_id_3,'(]',1,7) + 2
15436        ,LENGTHB(anc_id_3))
15437 )
15438 
15439 WHEN anc_id_4 IS NOT NULL THEN
15440   INTO xla_ae_header_acs (
15441         ae_header_id , object_version_number
15442       , analytical_criterion_code
15443       , analytical_criterion_type_code
15444       , amb_context_code
15445       , ac1,ac2,ac3,ac4,ac5)
15446 VALUES (ae_header_id, C_OVN
15447 ,SUBSTRB(anc_id_4
15448        ,1
15449        ,INSTRB(anc_id_4,'(]',1,1) -1)
15450 ,SUBSTRB(anc_id_4
15451        ,INSTRB(anc_id_4,'(]',1,1) + 2
15452        ,INSTRB(anc_id_4,'(]',1,2) -
15453         INSTRB(anc_id_4,'(]',1,1) - 2)
15454 ,SUBSTRB(anc_id_4
15455        ,INSTRB(anc_id_4,'(]',1,2) + 2
15456        ,INSTRB(anc_id_4,'(]',1,3) -
15457         INSTRB(anc_id_4,'(]',1,2) - 2)
15458 ,SUBSTRB(anc_id_4
15459        ,INSTRB(anc_id_4,'(]',1,3) + 2
15460        ,INSTRB(anc_id_4,'(]',1,4) -
15461         INSTRB(anc_id_4,'(]',1,3) - 2)
15462 ,SUBSTRB(anc_id_4
15463        ,INSTRB(anc_id_4,'(]',1,4) + 2
15464        ,INSTRB(anc_id_4,'(]',1,5) -
15465         INSTRB(anc_id_4,'(]',1,4) - 2)
15466 ,SUBSTRB(anc_id_4
15467        ,INSTRB(anc_id_4,'(]',1,5) + 2
15468        ,INSTRB(anc_id_4,'(]',1,6) -
15469         INSTRB(anc_id_4,'(]',1,5) - 2)
15470 ,SUBSTRB(anc_id_4
15471        ,INSTRB(anc_id_4,'(]',1,6) + 2
15472        ,INSTRB(anc_id_4,'(]',1,7) -
15473         INSTRB(anc_id_4,'(]',1,6) - 2)
15474 ,SUBSTRB(anc_id_4
15475        ,INSTRB(anc_id_4,'(]',1,7) + 2
15476        ,LENGTHB(anc_id_4))
15477 )
15478 
15479 WHEN anc_id_5 IS NOT NULL THEN
15480   INTO xla_ae_header_acs (
15481         ae_header_id , object_version_number
15482       , analytical_criterion_code
15483       , analytical_criterion_type_code
15484       , amb_context_code
15485       , ac1,ac2,ac3,ac4,ac5)
15486 VALUES (ae_header_id, C_OVN
15487 ,SUBSTRB(anc_id_5
15488        ,1
15489        ,INSTRB(anc_id_5,'(]',1,1) -1)
15490 ,SUBSTRB(anc_id_5
15491        ,INSTRB(anc_id_5,'(]',1,1) + 2
15492        ,INSTRB(anc_id_5,'(]',1,2) -
15493         INSTRB(anc_id_5,'(]',1,1) - 2)
15494 ,SUBSTRB(anc_id_5
15495        ,INSTRB(anc_id_5,'(]',1,2) + 2
15496        ,INSTRB(anc_id_5,'(]',1,3) -
15497         INSTRB(anc_id_5,'(]',1,2) - 2)
15498 ,SUBSTRB(anc_id_5
15499        ,INSTRB(anc_id_5,'(]',1,3) + 2
15500        ,INSTRB(anc_id_5,'(]',1,4) -
15501         INSTRB(anc_id_5,'(]',1,3) - 2)
15502 ,SUBSTRB(anc_id_5
15503        ,INSTRB(anc_id_5,'(]',1,4) + 2
15504        ,INSTRB(anc_id_5,'(]',1,5) -
15505         INSTRB(anc_id_5,'(]',1,4) - 2)
15506 ,SUBSTRB(anc_id_5
15507        ,INSTRB(anc_id_5,'(]',1,5) + 2
15508        ,INSTRB(anc_id_5,'(]',1,6) -
15509         INSTRB(anc_id_5,'(]',1,5) - 2)
15510 ,SUBSTRB(anc_id_5
15511        ,INSTRB(anc_id_5,'(]',1,6) + 2
15512        ,INSTRB(anc_id_5,'(]',1,7) -
15513         INSTRB(anc_id_5,'(]',1,6) - 2)
15514 ,SUBSTRB(anc_id_5
15515        ,INSTRB(anc_id_5,'(]',1,7) + 2
15516        ,LENGTHB(anc_id_5))
15517 )
15518 
15519 WHEN anc_id_6 IS NOT NULL THEN
15520   INTO xla_ae_header_acs (
15521         ae_header_id , object_version_number
15522       , analytical_criterion_code
15523       , analytical_criterion_type_code
15524       , amb_context_code
15525       , ac1,ac2,ac3,ac4,ac5)
15526 VALUES (ae_header_id, C_OVN
15527 ,SUBSTRB(anc_id_6
15528        ,1
15529        ,INSTRB(anc_id_6,'(]',1,1) -1)
15530 ,SUBSTRB(anc_id_6
15531        ,INSTRB(anc_id_6,'(]',1,1) + 2
15532        ,INSTRB(anc_id_6,'(]',1,2) -
15533         INSTRB(anc_id_6,'(]',1,1) - 2)
15534 ,SUBSTRB(anc_id_6
15535        ,INSTRB(anc_id_6,'(]',1,2) + 2
15536        ,INSTRB(anc_id_6,'(]',1,3) -
15537         INSTRB(anc_id_6,'(]',1,2) - 2)
15538 ,SUBSTRB(anc_id_6
15539        ,INSTRB(anc_id_6,'(]',1,3) + 2
15540        ,INSTRB(anc_id_6,'(]',1,4) -
15541         INSTRB(anc_id_6,'(]',1,3) - 2)
15542 ,SUBSTRB(anc_id_6
15543        ,INSTRB(anc_id_6,'(]',1,4) + 2
15544        ,INSTRB(anc_id_6,'(]',1,5) -
15545         INSTRB(anc_id_6,'(]',1,4) - 2)
15546 ,SUBSTRB(anc_id_6
15547        ,INSTRB(anc_id_6,'(]',1,5) + 2
15548        ,INSTRB(anc_id_6,'(]',1,6) -
15549         INSTRB(anc_id_6,'(]',1,5) - 2)
15550 ,SUBSTRB(anc_id_6
15551        ,INSTRB(anc_id_6,'(]',1,6) + 2
15552        ,INSTRB(anc_id_6,'(]',1,7) -
15553         INSTRB(anc_id_6,'(]',1,6) - 2)
15554 ,SUBSTRB(anc_id_6
15555        ,INSTRB(anc_id_6,'(]',1,7) + 2
15556        ,LENGTHB(anc_id_6))
15557 )
15558 
15559 WHEN anc_id_7 IS NOT NULL THEN
15560   INTO xla_ae_header_acs (
15561         ae_header_id , object_version_number
15562       , analytical_criterion_code
15563       , analytical_criterion_type_code
15564       , amb_context_code
15565       , ac1,ac2,ac3,ac4,ac5)
15566 VALUES (ae_header_id, C_OVN
15567 ,SUBSTRB(anc_id_7
15568        ,1
15569        ,INSTRB(anc_id_7,'(]',1,1) -1)
15570 ,SUBSTRB(anc_id_7
15571        ,INSTRB(anc_id_7,'(]',1,1) + 2
15572        ,INSTRB(anc_id_7,'(]',1,2) -
15573         INSTRB(anc_id_7,'(]',1,1) - 2)
15574 ,SUBSTRB(anc_id_7
15575        ,INSTRB(anc_id_7,'(]',1,2) + 2
15576        ,INSTRB(anc_id_7,'(]',1,3) -
15577         INSTRB(anc_id_7,'(]',1,2) - 2)
15578 ,SUBSTRB(anc_id_7
15579        ,INSTRB(anc_id_7,'(]',1,3) + 2
15580        ,INSTRB(anc_id_7,'(]',1,4) -
15581         INSTRB(anc_id_7,'(]',1,3) - 2)
15582 ,SUBSTRB(anc_id_7
15583        ,INSTRB(anc_id_7,'(]',1,4) + 2
15584        ,INSTRB(anc_id_7,'(]',1,5) -
15585         INSTRB(anc_id_7,'(]',1,4) - 2)
15586 ,SUBSTRB(anc_id_7
15587        ,INSTRB(anc_id_7,'(]',1,5) + 2
15588        ,INSTRB(anc_id_7,'(]',1,6) -
15589         INSTRB(anc_id_7,'(]',1,5) - 2)
15590 ,SUBSTRB(anc_id_7
15591        ,INSTRB(anc_id_7,'(]',1,6) + 2
15592        ,INSTRB(anc_id_7,'(]',1,7) -
15593         INSTRB(anc_id_7,'(]',1,6) - 2)
15594 ,SUBSTRB(anc_id_7
15595        ,INSTRB(anc_id_7,'(]',1,7) + 2
15596        ,LENGTHB(anc_id_7))
15597 )
15598 
15599 WHEN anc_id_8 IS NOT NULL THEN
15600   INTO xla_ae_header_acs (
15601         ae_header_id , object_version_number
15602       , analytical_criterion_code
15603       , analytical_criterion_type_code
15604       , amb_context_code
15605       , ac1,ac2,ac3,ac4,ac5)
15606 VALUES (ae_header_id, C_OVN
15607 ,SUBSTRB(anc_id_8
15608        ,1
15609        ,INSTRB(anc_id_8,'(]',1,1) -1)
15610 ,SUBSTRB(anc_id_8
15611        ,INSTRB(anc_id_8,'(]',1,1) + 2
15612        ,INSTRB(anc_id_8,'(]',1,2) -
15613         INSTRB(anc_id_8,'(]',1,1) - 2)
15614 ,SUBSTRB(anc_id_8
15615        ,INSTRB(anc_id_8,'(]',1,2) + 2
15616        ,INSTRB(anc_id_8,'(]',1,3) -
15617         INSTRB(anc_id_8,'(]',1,2) - 2)
15618 ,SUBSTRB(anc_id_8
15619        ,INSTRB(anc_id_8,'(]',1,3) + 2
15620        ,INSTRB(anc_id_8,'(]',1,4) -
15621         INSTRB(anc_id_8,'(]',1,3) - 2)
15622 ,SUBSTRB(anc_id_8
15623        ,INSTRB(anc_id_8,'(]',1,4) + 2
15624        ,INSTRB(anc_id_8,'(]',1,5) -
15625         INSTRB(anc_id_8,'(]',1,4) - 2)
15626 ,SUBSTRB(anc_id_8
15627        ,INSTRB(anc_id_8,'(]',1,5) + 2
15628        ,INSTRB(anc_id_8,'(]',1,6) -
15629         INSTRB(anc_id_8,'(]',1,5) - 2)
15630 ,SUBSTRB(anc_id_8
15631        ,INSTRB(anc_id_8,'(]',1,6) + 2
15632        ,INSTRB(anc_id_8,'(]',1,7) -
15633         INSTRB(anc_id_8,'(]',1,6) - 2)
15634 ,SUBSTRB(anc_id_8
15635        ,INSTRB(anc_id_8,'(]',1,7) + 2
15636        ,LENGTHB(anc_id_8))
15637 )
15638 
15639 WHEN anc_id_9 IS NOT NULL THEN
15640   INTO xla_ae_header_acs (
15641         ae_header_id , object_version_number
15642       , analytical_criterion_code
15643       , analytical_criterion_type_code
15644       , amb_context_code
15645       , ac1,ac2,ac3,ac4,ac5)
15646 VALUES (ae_header_id, C_OVN
15647 ,SUBSTRB(anc_id_9
15648        ,1
15649        ,INSTRB(anc_id_9,'(]',1,1) -1)
15650 ,SUBSTRB(anc_id_9
15651        ,INSTRB(anc_id_9,'(]',1,1) + 2
15652        ,INSTRB(anc_id_9,'(]',1,2) -
15653         INSTRB(anc_id_9,'(]',1,1) - 2)
15654 ,SUBSTRB(anc_id_9
15655        ,INSTRB(anc_id_9,'(]',1,2) + 2
15656        ,INSTRB(anc_id_9,'(]',1,3) -
15657         INSTRB(anc_id_9,'(]',1,2) - 2)
15658 ,SUBSTRB(anc_id_9
15659        ,INSTRB(anc_id_9,'(]',1,3) + 2
15660        ,INSTRB(anc_id_9,'(]',1,4) -
15661         INSTRB(anc_id_9,'(]',1,3) - 2)
15662 ,SUBSTRB(anc_id_9
15663        ,INSTRB(anc_id_9,'(]',1,4) + 2
15664        ,INSTRB(anc_id_9,'(]',1,5) -
15665         INSTRB(anc_id_9,'(]',1,4) - 2)
15666 ,SUBSTRB(anc_id_9
15667        ,INSTRB(anc_id_9,'(]',1,5) + 2
15668        ,INSTRB(anc_id_9,'(]',1,6) -
15669         INSTRB(anc_id_9,'(]',1,5) - 2)
15670 ,SUBSTRB(anc_id_9
15671        ,INSTRB(anc_id_9,'(]',1,6) + 2
15672        ,INSTRB(anc_id_9,'(]',1,7) -
15673         INSTRB(anc_id_9,'(]',1,6) - 2)
15674 ,SUBSTRB(anc_id_9
15675        ,INSTRB(anc_id_9,'(]',1,7) + 2
15676        ,LENGTHB(anc_id_9))
15677 )
15678 
15679 WHEN anc_id_10 IS NOT NULL THEN
15680   INTO xla_ae_header_acs (
15681         ae_header_id , object_version_number
15682       , analytical_criterion_code
15683       , analytical_criterion_type_code
15684       , amb_context_code
15685       , ac1,ac2,ac3,ac4,ac5)
15686 VALUES (ae_header_id, C_OVN
15687 ,SUBSTRB(anc_id_10
15688        ,1
15689        ,INSTRB(anc_id_10,'(]',1,1) -1)
15690 ,SUBSTRB(anc_id_10
15691        ,INSTRB(anc_id_10,'(]',1,1) + 2
15692        ,INSTRB(anc_id_10,'(]',1,2) -
15693         INSTRB(anc_id_10,'(]',1,1) - 2)
15694 ,SUBSTRB(anc_id_10
15695        ,INSTRB(anc_id_10,'(]',1,2) + 2
15696        ,INSTRB(anc_id_10,'(]',1,3) -
15697         INSTRB(anc_id_10,'(]',1,2) - 2)
15698 ,SUBSTRB(anc_id_10
15699        ,INSTRB(anc_id_10,'(]',1,3) + 2
15700        ,INSTRB(anc_id_10,'(]',1,4) -
15701         INSTRB(anc_id_10,'(]',1,3) - 2)
15702 ,SUBSTRB(anc_id_10
15703        ,INSTRB(anc_id_10,'(]',1,4) + 2
15704        ,INSTRB(anc_id_10,'(]',1,5) -
15705         INSTRB(anc_id_10,'(]',1,4) - 2)
15706 ,SUBSTRB(anc_id_10
15707        ,INSTRB(anc_id_10,'(]',1,5) + 2
15708        ,INSTRB(anc_id_10,'(]',1,6) -
15709         INSTRB(anc_id_10,'(]',1,5) - 2)
15710 ,SUBSTRB(anc_id_10
15711        ,INSTRB(anc_id_10,'(]',1,6) + 2
15712        ,INSTRB(anc_id_10,'(]',1,7) -
15713         INSTRB(anc_id_10,'(]',1,6) - 2)
15714 ,SUBSTRB(anc_id_10
15715        ,INSTRB(anc_id_10,'(]',1,7) + 2
15716        ,LENGTHB(anc_id_10))
15717 )
15718 
15719 WHEN anc_id_11 IS NOT NULL THEN
15720   INTO xla_ae_header_acs (
15721         ae_header_id , object_version_number
15722       , analytical_criterion_code
15723       , analytical_criterion_type_code
15724       , amb_context_code
15725       , ac1,ac2,ac3,ac4,ac5)
15726 VALUES (ae_header_id, C_OVN
15727 ,SUBSTRB(anc_id_11
15728        ,1
15729        ,INSTRB(anc_id_11,'(]',1,1) -1)
15730 ,SUBSTRB(anc_id_11
15731        ,INSTRB(anc_id_11,'(]',1,1) + 2
15732        ,INSTRB(anc_id_11,'(]',1,2) -
15733         INSTRB(anc_id_11,'(]',1,1) - 2)
15734 ,SUBSTRB(anc_id_11
15735        ,INSTRB(anc_id_11,'(]',1,2) + 2
15736        ,INSTRB(anc_id_11,'(]',1,3) -
15737         INSTRB(anc_id_11,'(]',1,2) - 2)
15738 ,SUBSTRB(anc_id_11
15739        ,INSTRB(anc_id_11,'(]',1,3) + 2
15740        ,INSTRB(anc_id_11,'(]',1,4) -
15741         INSTRB(anc_id_11,'(]',1,3) - 2)
15742 ,SUBSTRB(anc_id_11
15743        ,INSTRB(anc_id_11,'(]',1,4) + 2
15744        ,INSTRB(anc_id_11,'(]',1,5) -
15745         INSTRB(anc_id_11,'(]',1,4) - 2)
15746 ,SUBSTRB(anc_id_11
15747        ,INSTRB(anc_id_11,'(]',1,5) + 2
15748        ,INSTRB(anc_id_11,'(]',1,6) -
15749         INSTRB(anc_id_11,'(]',1,5) - 2)
15750 ,SUBSTRB(anc_id_11
15751        ,INSTRB(anc_id_11,'(]',1,6) + 2
15752        ,INSTRB(anc_id_11,'(]',1,7) -
15753         INSTRB(anc_id_11,'(]',1,6) - 2)
15754 ,SUBSTRB(anc_id_11
15755        ,INSTRB(anc_id_11,'(]',1,7) + 2
15756        ,LENGTHB(anc_id_11))
15757 )
15758 
15759 WHEN anc_id_12 IS NOT NULL THEN
15760   INTO xla_ae_header_acs (
15761         ae_header_id , object_version_number
15762       , analytical_criterion_code
15763       , analytical_criterion_type_code
15764       , amb_context_code
15765       , ac1,ac2,ac3,ac4,ac5)
15766 VALUES (ae_header_id, C_OVN
15767 ,SUBSTRB(anc_id_12
15768        ,1
15769        ,INSTRB(anc_id_12,'(]',1,1) -1)
15770 ,SUBSTRB(anc_id_12
15771        ,INSTRB(anc_id_12,'(]',1,1) + 2
15772        ,INSTRB(anc_id_12,'(]',1,2) -
15773         INSTRB(anc_id_12,'(]',1,1) - 2)
15774 ,SUBSTRB(anc_id_12
15775        ,INSTRB(anc_id_12,'(]',1,2) + 2
15776        ,INSTRB(anc_id_12,'(]',1,3) -
15777         INSTRB(anc_id_12,'(]',1,2) - 2)
15778 ,SUBSTRB(anc_id_12
15779        ,INSTRB(anc_id_12,'(]',1,3) + 2
15780        ,INSTRB(anc_id_12,'(]',1,4) -
15781         INSTRB(anc_id_12,'(]',1,3) - 2)
15782 ,SUBSTRB(anc_id_12
15783        ,INSTRB(anc_id_12,'(]',1,4) + 2
15784        ,INSTRB(anc_id_12,'(]',1,5) -
15785         INSTRB(anc_id_12,'(]',1,4) - 2)
15786 ,SUBSTRB(anc_id_12
15787        ,INSTRB(anc_id_12,'(]',1,5) + 2
15788        ,INSTRB(anc_id_12,'(]',1,6) -
15789         INSTRB(anc_id_12,'(]',1,5) - 2)
15790 ,SUBSTRB(anc_id_12
15791        ,INSTRB(anc_id_12,'(]',1,6) + 2
15792        ,INSTRB(anc_id_12,'(]',1,7) -
15793         INSTRB(anc_id_12,'(]',1,6) - 2)
15794 ,SUBSTRB(anc_id_12
15795        ,INSTRB(anc_id_12,'(]',1,7) + 2
15796        ,LENGTHB(anc_id_12))
15797 )
15798 
15799 WHEN anc_id_13 IS NOT NULL THEN
15800   INTO xla_ae_header_acs (
15801         ae_header_id , object_version_number
15802       , analytical_criterion_code
15803       , analytical_criterion_type_code
15804       , amb_context_code
15805       , ac1,ac2,ac3,ac4,ac5)
15806 VALUES (ae_header_id, C_OVN
15807 ,SUBSTRB(anc_id_13
15808        ,1
15809        ,INSTRB(anc_id_13,'(]',1,1) -1)
15810 ,SUBSTRB(anc_id_13
15811        ,INSTRB(anc_id_13,'(]',1,1) + 2
15812        ,INSTRB(anc_id_13,'(]',1,2) -
15813         INSTRB(anc_id_13,'(]',1,1) - 2)
15814 ,SUBSTRB(anc_id_13
15815        ,INSTRB(anc_id_13,'(]',1,2) + 2
15816        ,INSTRB(anc_id_13,'(]',1,3) -
15817         INSTRB(anc_id_13,'(]',1,2) - 2)
15818 ,SUBSTRB(anc_id_13
15819        ,INSTRB(anc_id_13,'(]',1,3) + 2
15820        ,INSTRB(anc_id_13,'(]',1,4) -
15821         INSTRB(anc_id_13,'(]',1,3) - 2)
15822 ,SUBSTRB(anc_id_13
15823        ,INSTRB(anc_id_13,'(]',1,4) + 2
15824        ,INSTRB(anc_id_13,'(]',1,5) -
15825         INSTRB(anc_id_13,'(]',1,4) - 2)
15826 ,SUBSTRB(anc_id_13
15827        ,INSTRB(anc_id_13,'(]',1,5) + 2
15828        ,INSTRB(anc_id_13,'(]',1,6) -
15829         INSTRB(anc_id_13,'(]',1,5) - 2)
15830 ,SUBSTRB(anc_id_13
15831        ,INSTRB(anc_id_13,'(]',1,6) + 2
15832        ,INSTRB(anc_id_13,'(]',1,7) -
15833         INSTRB(anc_id_13,'(]',1,6) - 2)
15834 ,SUBSTRB(anc_id_13
15835        ,INSTRB(anc_id_13,'(]',1,7) + 2
15836        ,LENGTHB(anc_id_13))
15837 )
15838 
15839 WHEN anc_id_14 IS NOT NULL THEN
15840   INTO xla_ae_header_acs (
15841         ae_header_id , object_version_number
15842       , analytical_criterion_code
15843       , analytical_criterion_type_code
15844       , amb_context_code
15845       , ac1,ac2,ac3,ac4,ac5)
15846 VALUES (ae_header_id, C_OVN
15847 ,SUBSTRB(anc_id_14
15848        ,1
15849        ,INSTRB(anc_id_14,'(]',1,1) -1)
15850 ,SUBSTRB(anc_id_14
15851        ,INSTRB(anc_id_14,'(]',1,1) + 2
15852        ,INSTRB(anc_id_14,'(]',1,2) -
15853         INSTRB(anc_id_14,'(]',1,1) - 2)
15854 ,SUBSTRB(anc_id_14
15855        ,INSTRB(anc_id_14,'(]',1,2) + 2
15856        ,INSTRB(anc_id_14,'(]',1,3) -
15857         INSTRB(anc_id_14,'(]',1,2) - 2)
15858 ,SUBSTRB(anc_id_14
15859        ,INSTRB(anc_id_14,'(]',1,3) + 2
15860        ,INSTRB(anc_id_14,'(]',1,4) -
15861         INSTRB(anc_id_14,'(]',1,3) - 2)
15862 ,SUBSTRB(anc_id_14
15863        ,INSTRB(anc_id_14,'(]',1,4) + 2
15864        ,INSTRB(anc_id_14,'(]',1,5) -
15865         INSTRB(anc_id_14,'(]',1,4) - 2)
15866 ,SUBSTRB(anc_id_14
15867        ,INSTRB(anc_id_14,'(]',1,5) + 2
15868        ,INSTRB(anc_id_14,'(]',1,6) -
15869         INSTRB(anc_id_14,'(]',1,5) - 2)
15870 ,SUBSTRB(anc_id_14
15871        ,INSTRB(anc_id_14,'(]',1,6) + 2
15872        ,INSTRB(anc_id_14,'(]',1,7) -
15873         INSTRB(anc_id_14,'(]',1,6) - 2)
15874 ,SUBSTRB(anc_id_14
15875        ,INSTRB(anc_id_14,'(]',1,7) + 2
15876        ,LENGTHB(anc_id_14))
15877 )
15878 
15879 WHEN anc_id_15 IS NOT NULL THEN
15880   INTO xla_ae_header_acs (
15881         ae_header_id , object_version_number
15882       , analytical_criterion_code
15883       , analytical_criterion_type_code
15884       , amb_context_code
15885       , ac1,ac2,ac3,ac4,ac5)
15886 VALUES (ae_header_id, C_OVN
15887 ,SUBSTRB(anc_id_15
15888        ,1
15889        ,INSTRB(anc_id_15,'(]',1,1) -1)
15890 ,SUBSTRB(anc_id_15
15891        ,INSTRB(anc_id_15,'(]',1,1) + 2
15892        ,INSTRB(anc_id_15,'(]',1,2) -
15893         INSTRB(anc_id_15,'(]',1,1) - 2)
15894 ,SUBSTRB(anc_id_15
15895        ,INSTRB(anc_id_15,'(]',1,2) + 2
15896        ,INSTRB(anc_id_15,'(]',1,3) -
15897         INSTRB(anc_id_15,'(]',1,2) - 2)
15898 ,SUBSTRB(anc_id_15
15899        ,INSTRB(anc_id_15,'(]',1,3) + 2
15900        ,INSTRB(anc_id_15,'(]',1,4) -
15901         INSTRB(anc_id_15,'(]',1,3) - 2)
15902 ,SUBSTRB(anc_id_15
15903        ,INSTRB(anc_id_15,'(]',1,4) + 2
15904        ,INSTRB(anc_id_15,'(]',1,5) -
15905         INSTRB(anc_id_15,'(]',1,4) - 2)
15906 ,SUBSTRB(anc_id_15
15907        ,INSTRB(anc_id_15,'(]',1,5) + 2
15908        ,INSTRB(anc_id_15,'(]',1,6) -
15909         INSTRB(anc_id_15,'(]',1,5) - 2)
15910 ,SUBSTRB(anc_id_15
15911        ,INSTRB(anc_id_15,'(]',1,6) + 2
15912        ,INSTRB(anc_id_15,'(]',1,7) -
15913         INSTRB(anc_id_15,'(]',1,6) - 2)
15914 ,SUBSTRB(anc_id_15
15915        ,INSTRB(anc_id_15,'(]',1,7) + 2
15916        ,LENGTHB(anc_id_15))
15917 )
15918 
15919 WHEN anc_id_16 IS NOT NULL THEN
15920   INTO xla_ae_header_acs (
15921         ae_header_id , object_version_number
15922       , analytical_criterion_code
15923       , analytical_criterion_type_code
15924       , amb_context_code
15925       , ac1,ac2,ac3,ac4,ac5)
15926 VALUES (ae_header_id, C_OVN
15927 ,SUBSTRB(anc_id_16
15928        ,1
15929        ,INSTRB(anc_id_16,'(]',1,1) -1)
15930 ,SUBSTRB(anc_id_16
15931        ,INSTRB(anc_id_16,'(]',1,1) + 2
15932        ,INSTRB(anc_id_16,'(]',1,2) -
15933         INSTRB(anc_id_16,'(]',1,1) - 2)
15934 ,SUBSTRB(anc_id_16
15935        ,INSTRB(anc_id_16,'(]',1,2) + 2
15936        ,INSTRB(anc_id_16,'(]',1,3) -
15937         INSTRB(anc_id_16,'(]',1,2) - 2)
15938 ,SUBSTRB(anc_id_16
15939        ,INSTRB(anc_id_16,'(]',1,3) + 2
15940        ,INSTRB(anc_id_16,'(]',1,4) -
15941         INSTRB(anc_id_16,'(]',1,3) - 2)
15942 ,SUBSTRB(anc_id_16
15943        ,INSTRB(anc_id_16,'(]',1,4) + 2
15944        ,INSTRB(anc_id_16,'(]',1,5) -
15945         INSTRB(anc_id_16,'(]',1,4) - 2)
15946 ,SUBSTRB(anc_id_16
15947        ,INSTRB(anc_id_16,'(]',1,5) + 2
15948        ,INSTRB(anc_id_16,'(]',1,6) -
15949         INSTRB(anc_id_16,'(]',1,5) - 2)
15950 ,SUBSTRB(anc_id_16
15951        ,INSTRB(anc_id_16,'(]',1,6) + 2
15952        ,INSTRB(anc_id_16,'(]',1,7) -
15953         INSTRB(anc_id_16,'(]',1,6) - 2)
15954 ,SUBSTRB(anc_id_16
15955        ,INSTRB(anc_id_16,'(]',1,7) + 2
15956        ,LENGTHB(anc_id_16))
15957 )
15958 
15959 WHEN anc_id_17 IS NOT NULL THEN
15960   INTO xla_ae_header_acs (
15961         ae_header_id , object_version_number
15962       , analytical_criterion_code
15963       , analytical_criterion_type_code
15964       , amb_context_code
15965       , ac1,ac2,ac3,ac4,ac5)
15966 VALUES (ae_header_id, C_OVN
15967 ,SUBSTRB(anc_id_17
15968        ,1
15969        ,INSTRB(anc_id_17,'(]',1,1) -1)
15970 ,SUBSTRB(anc_id_17
15971        ,INSTRB(anc_id_17,'(]',1,1) + 2
15972        ,INSTRB(anc_id_17,'(]',1,2) -
15973         INSTRB(anc_id_17,'(]',1,1) - 2)
15974 ,SUBSTRB(anc_id_17
15975        ,INSTRB(anc_id_17,'(]',1,2) + 2
15976        ,INSTRB(anc_id_17,'(]',1,3) -
15977         INSTRB(anc_id_17,'(]',1,2) - 2)
15978 ,SUBSTRB(anc_id_17
15979        ,INSTRB(anc_id_17,'(]',1,3) + 2
15980        ,INSTRB(anc_id_17,'(]',1,4) -
15981         INSTRB(anc_id_17,'(]',1,3) - 2)
15982 ,SUBSTRB(anc_id_17
15983        ,INSTRB(anc_id_17,'(]',1,4) + 2
15984        ,INSTRB(anc_id_17,'(]',1,5) -
15985         INSTRB(anc_id_17,'(]',1,4) - 2)
15986 ,SUBSTRB(anc_id_17
15987        ,INSTRB(anc_id_17,'(]',1,5) + 2
15988        ,INSTRB(anc_id_17,'(]',1,6) -
15989         INSTRB(anc_id_17,'(]',1,5) - 2)
15990 ,SUBSTRB(anc_id_17
15991        ,INSTRB(anc_id_17,'(]',1,6) + 2
15992        ,INSTRB(anc_id_17,'(]',1,7) -
15993         INSTRB(anc_id_17,'(]',1,6) - 2)
15994 ,SUBSTRB(anc_id_17
15995        ,INSTRB(anc_id_17,'(]',1,7) + 2
15996        ,LENGTHB(anc_id_17))
15997 )
15998 
15999 WHEN anc_id_18 IS NOT NULL THEN
16000   INTO xla_ae_header_acs (
16001         ae_header_id , object_version_number
16002       , analytical_criterion_code
16003       , analytical_criterion_type_code
16004       , amb_context_code
16005       , ac1,ac2,ac3,ac4,ac5)
16006 VALUES (ae_header_id, C_OVN
16007 ,SUBSTRB(anc_id_18
16008        ,1
16009        ,INSTRB(anc_id_18,'(]',1,1) -1)
16010 ,SUBSTRB(anc_id_18
16011        ,INSTRB(anc_id_18,'(]',1,1) + 2
16012        ,INSTRB(anc_id_18,'(]',1,2) -
16013         INSTRB(anc_id_18,'(]',1,1) - 2)
16014 ,SUBSTRB(anc_id_18
16015        ,INSTRB(anc_id_18,'(]',1,2) + 2
16016        ,INSTRB(anc_id_18,'(]',1,3) -
16017         INSTRB(anc_id_18,'(]',1,2) - 2)
16018 ,SUBSTRB(anc_id_18
16019        ,INSTRB(anc_id_18,'(]',1,3) + 2
16020        ,INSTRB(anc_id_18,'(]',1,4) -
16021         INSTRB(anc_id_18,'(]',1,3) - 2)
16022 ,SUBSTRB(anc_id_18
16023        ,INSTRB(anc_id_18,'(]',1,4) + 2
16024        ,INSTRB(anc_id_18,'(]',1,5) -
16025         INSTRB(anc_id_18,'(]',1,4) - 2)
16026 ,SUBSTRB(anc_id_18
16027        ,INSTRB(anc_id_18,'(]',1,5) + 2
16028        ,INSTRB(anc_id_18,'(]',1,6) -
16029         INSTRB(anc_id_18,'(]',1,5) - 2)
16030 ,SUBSTRB(anc_id_18
16031        ,INSTRB(anc_id_18,'(]',1,6) + 2
16032        ,INSTRB(anc_id_18,'(]',1,7) -
16033         INSTRB(anc_id_18,'(]',1,6) - 2)
16034 ,SUBSTRB(anc_id_18
16035        ,INSTRB(anc_id_18,'(]',1,7) + 2
16036        ,LENGTHB(anc_id_18))
16037 )
16038 
16039 WHEN anc_id_19 IS NOT NULL THEN
16040   INTO xla_ae_header_acs (
16041         ae_header_id , object_version_number
16042       , analytical_criterion_code
16043       , analytical_criterion_type_code
16044       , amb_context_code
16045       , ac1,ac2,ac3,ac4,ac5)
16046 VALUES (ae_header_id, C_OVN
16047 ,SUBSTRB(anc_id_19
16048        ,1
16049        ,INSTRB(anc_id_19,'(]',1,1) -1)
16050 ,SUBSTRB(anc_id_19
16051        ,INSTRB(anc_id_19,'(]',1,1) + 2
16052        ,INSTRB(anc_id_19,'(]',1,2) -
16053         INSTRB(anc_id_19,'(]',1,1) - 2)
16054 ,SUBSTRB(anc_id_19
16055        ,INSTRB(anc_id_19,'(]',1,2) + 2
16056        ,INSTRB(anc_id_19,'(]',1,3) -
16057         INSTRB(anc_id_19,'(]',1,2) - 2)
16058 ,SUBSTRB(anc_id_19
16059        ,INSTRB(anc_id_19,'(]',1,3) + 2
16060        ,INSTRB(anc_id_19,'(]',1,4) -
16061         INSTRB(anc_id_19,'(]',1,3) - 2)
16062 ,SUBSTRB(anc_id_19
16063        ,INSTRB(anc_id_19,'(]',1,4) + 2
16064        ,INSTRB(anc_id_19,'(]',1,5) -
16065         INSTRB(anc_id_19,'(]',1,4) - 2)
16066 ,SUBSTRB(anc_id_19
16067        ,INSTRB(anc_id_19,'(]',1,5) + 2
16068        ,INSTRB(anc_id_19,'(]',1,6) -
16069         INSTRB(anc_id_19,'(]',1,5) - 2)
16070 ,SUBSTRB(anc_id_19
16071        ,INSTRB(anc_id_19,'(]',1,6) + 2
16072        ,INSTRB(anc_id_19,'(]',1,7) -
16073         INSTRB(anc_id_19,'(]',1,6) - 2)
16074 ,SUBSTRB(anc_id_19
16075        ,INSTRB(anc_id_19,'(]',1,7) + 2
16076        ,LENGTHB(anc_id_19))
16077 )
16078 
16079 WHEN anc_id_20 IS NOT NULL THEN
16080   INTO xla_ae_header_acs (
16081         ae_header_id , object_version_number
16082       , analytical_criterion_code
16083       , analytical_criterion_type_code
16084       , amb_context_code
16085       , ac1,ac2,ac3,ac4,ac5)
16086 VALUES (ae_header_id, C_OVN
16087 ,SUBSTRB(anc_id_20
16088        ,1
16089        ,INSTRB(anc_id_20,'(]',1,1) -1)
16090 ,SUBSTRB(anc_id_20
16091        ,INSTRB(anc_id_20,'(]',1,1) + 2
16092        ,INSTRB(anc_id_20,'(]',1,2) -
16093         INSTRB(anc_id_20,'(]',1,1) - 2)
16094 ,SUBSTRB(anc_id_20
16095        ,INSTRB(anc_id_20,'(]',1,2) + 2
16096        ,INSTRB(anc_id_20,'(]',1,3) -
16097         INSTRB(anc_id_20,'(]',1,2) - 2)
16098 ,SUBSTRB(anc_id_20
16099        ,INSTRB(anc_id_20,'(]',1,3) + 2
16100        ,INSTRB(anc_id_20,'(]',1,4) -
16101         INSTRB(anc_id_20,'(]',1,3) - 2)
16102 ,SUBSTRB(anc_id_20
16103        ,INSTRB(anc_id_20,'(]',1,4) + 2
16104        ,INSTRB(anc_id_20,'(]',1,5) -
16105         INSTRB(anc_id_20,'(]',1,4) - 2)
16106 ,SUBSTRB(anc_id_20
16107        ,INSTRB(anc_id_20,'(]',1,5) + 2
16108        ,INSTRB(anc_id_20,'(]',1,6) -
16109         INSTRB(anc_id_20,'(]',1,5) - 2)
16110 ,SUBSTRB(anc_id_20
16111        ,INSTRB(anc_id_20,'(]',1,6) + 2
16112        ,INSTRB(anc_id_20,'(]',1,7) -
16113         INSTRB(anc_id_20,'(]',1,6) - 2)
16114 ,SUBSTRB(anc_id_20
16115        ,INSTRB(anc_id_20,'(]',1,7) + 2
16116        ,LENGTHB(anc_id_20))
16117 )
16118 
16119 WHEN anc_id_21 IS NOT NULL THEN
16120   INTO xla_ae_header_acs (
16121         ae_header_id , object_version_number
16122       , analytical_criterion_code
16123       , analytical_criterion_type_code
16124       , amb_context_code
16125       , ac1,ac2,ac3,ac4,ac5)
16126 VALUES (ae_header_id, C_OVN
16127 ,SUBSTRB(anc_id_21
16128        ,1
16129        ,INSTRB(anc_id_21,'(]',1,1) -1)
16130 ,SUBSTRB(anc_id_21
16131        ,INSTRB(anc_id_21,'(]',1,1) + 2
16132        ,INSTRB(anc_id_21,'(]',1,2) -
16133         INSTRB(anc_id_21,'(]',1,1) - 2)
16134 ,SUBSTRB(anc_id_21
16135        ,INSTRB(anc_id_21,'(]',1,2) + 2
16136        ,INSTRB(anc_id_21,'(]',1,3) -
16137         INSTRB(anc_id_21,'(]',1,2) - 2)
16138 ,SUBSTRB(anc_id_21
16139        ,INSTRB(anc_id_21,'(]',1,3) + 2
16140        ,INSTRB(anc_id_21,'(]',1,4) -
16141         INSTRB(anc_id_21,'(]',1,3) - 2)
16142 ,SUBSTRB(anc_id_21
16143        ,INSTRB(anc_id_21,'(]',1,4) + 2
16144        ,INSTRB(anc_id_21,'(]',1,5) -
16145         INSTRB(anc_id_21,'(]',1,4) - 2)
16146 ,SUBSTRB(anc_id_21
16147        ,INSTRB(anc_id_21,'(]',1,5) + 2
16148        ,INSTRB(anc_id_21,'(]',1,6) -
16149         INSTRB(anc_id_21,'(]',1,5) - 2)
16150 ,SUBSTRB(anc_id_21
16151        ,INSTRB(anc_id_21,'(]',1,6) + 2
16152        ,INSTRB(anc_id_21,'(]',1,7) -
16153         INSTRB(anc_id_21,'(]',1,6) - 2)
16154 ,SUBSTRB(anc_id_21
16155        ,INSTRB(anc_id_21,'(]',1,7) + 2
16156        ,LENGTHB(anc_id_21))
16157 )
16158 
16159 WHEN anc_id_22 IS NOT NULL THEN
16160   INTO xla_ae_header_acs (
16161         ae_header_id , object_version_number
16162       , analytical_criterion_code
16163       , analytical_criterion_type_code
16164       , amb_context_code
16165       , ac1,ac2,ac3,ac4,ac5)
16166 VALUES (ae_header_id, C_OVN
16167 ,SUBSTRB(anc_id_22
16168        ,1
16169        ,INSTRB(anc_id_22,'(]',1,1) -1)
16170 ,SUBSTRB(anc_id_22
16171        ,INSTRB(anc_id_22,'(]',1,1) + 2
16172        ,INSTRB(anc_id_22,'(]',1,2) -
16173         INSTRB(anc_id_22,'(]',1,1) - 2)
16174 ,SUBSTRB(anc_id_22
16175        ,INSTRB(anc_id_22,'(]',1,2) + 2
16176        ,INSTRB(anc_id_22,'(]',1,3) -
16177         INSTRB(anc_id_22,'(]',1,2) - 2)
16178 ,SUBSTRB(anc_id_22
16179        ,INSTRB(anc_id_22,'(]',1,3) + 2
16180        ,INSTRB(anc_id_22,'(]',1,4) -
16181         INSTRB(anc_id_22,'(]',1,3) - 2)
16182 ,SUBSTRB(anc_id_22
16183        ,INSTRB(anc_id_22,'(]',1,4) + 2
16184        ,INSTRB(anc_id_22,'(]',1,5) -
16185         INSTRB(anc_id_22,'(]',1,4) - 2)
16186 ,SUBSTRB(anc_id_22
16187        ,INSTRB(anc_id_22,'(]',1,5) + 2
16188        ,INSTRB(anc_id_22,'(]',1,6) -
16189         INSTRB(anc_id_22,'(]',1,5) - 2)
16190 ,SUBSTRB(anc_id_22
16191        ,INSTRB(anc_id_22,'(]',1,6) + 2
16192        ,INSTRB(anc_id_22,'(]',1,7) -
16193         INSTRB(anc_id_22,'(]',1,6) - 2)
16194 ,SUBSTRB(anc_id_22
16195        ,INSTRB(anc_id_22,'(]',1,7) + 2
16196        ,LENGTHB(anc_id_22))
16197 )
16198 
16199 WHEN anc_id_23 IS NOT NULL THEN
16200   INTO xla_ae_header_acs (
16201         ae_header_id , object_version_number
16202       , analytical_criterion_code
16203       , analytical_criterion_type_code
16204       , amb_context_code
16205       , ac1,ac2,ac3,ac4,ac5)
16206 VALUES (ae_header_id, C_OVN
16207 ,SUBSTRB(anc_id_23
16208        ,1
16209        ,INSTRB(anc_id_23,'(]',1,1) -1)
16210 ,SUBSTRB(anc_id_23
16211        ,INSTRB(anc_id_23,'(]',1,1) + 2
16212        ,INSTRB(anc_id_23,'(]',1,2) -
16213         INSTRB(anc_id_23,'(]',1,1) - 2)
16214 ,SUBSTRB(anc_id_23
16215        ,INSTRB(anc_id_23,'(]',1,2) + 2
16216        ,INSTRB(anc_id_23,'(]',1,3) -
16217         INSTRB(anc_id_23,'(]',1,2) - 2)
16218 ,SUBSTRB(anc_id_23
16219        ,INSTRB(anc_id_23,'(]',1,3) + 2
16220        ,INSTRB(anc_id_23,'(]',1,4) -
16221         INSTRB(anc_id_23,'(]',1,3) - 2)
16222 ,SUBSTRB(anc_id_23
16223        ,INSTRB(anc_id_23,'(]',1,4) + 2
16224        ,INSTRB(anc_id_23,'(]',1,5) -
16225         INSTRB(anc_id_23,'(]',1,4) - 2)
16226 ,SUBSTRB(anc_id_23
16227        ,INSTRB(anc_id_23,'(]',1,5) + 2
16228        ,INSTRB(anc_id_23,'(]',1,6) -
16229         INSTRB(anc_id_23,'(]',1,5) - 2)
16230 ,SUBSTRB(anc_id_23
16231        ,INSTRB(anc_id_23,'(]',1,6) + 2
16232        ,INSTRB(anc_id_23,'(]',1,7) -
16233         INSTRB(anc_id_23,'(]',1,6) - 2)
16234 ,SUBSTRB(anc_id_23
16235        ,INSTRB(anc_id_23,'(]',1,7) + 2
16236        ,LENGTHB(anc_id_23))
16237 )
16238 
16239 WHEN anc_id_24 IS NOT NULL THEN
16240   INTO xla_ae_header_acs (
16241         ae_header_id , object_version_number
16242       , analytical_criterion_code
16243       , analytical_criterion_type_code
16244       , amb_context_code
16245       , ac1,ac2,ac3,ac4,ac5)
16246 VALUES (ae_header_id, C_OVN
16247 ,SUBSTRB(anc_id_24
16248        ,1
16249        ,INSTRB(anc_id_24,'(]',1,1) -1)
16250 ,SUBSTRB(anc_id_24
16251        ,INSTRB(anc_id_24,'(]',1,1) + 2
16252        ,INSTRB(anc_id_24,'(]',1,2) -
16253         INSTRB(anc_id_24,'(]',1,1) - 2)
16254 ,SUBSTRB(anc_id_24
16255        ,INSTRB(anc_id_24,'(]',1,2) + 2
16256        ,INSTRB(anc_id_24,'(]',1,3) -
16257         INSTRB(anc_id_24,'(]',1,2) - 2)
16258 ,SUBSTRB(anc_id_24
16259        ,INSTRB(anc_id_24,'(]',1,3) + 2
16260        ,INSTRB(anc_id_24,'(]',1,4) -
16261         INSTRB(anc_id_24,'(]',1,3) - 2)
16262 ,SUBSTRB(anc_id_24
16263        ,INSTRB(anc_id_24,'(]',1,4) + 2
16264        ,INSTRB(anc_id_24,'(]',1,5) -
16265         INSTRB(anc_id_24,'(]',1,4) - 2)
16266 ,SUBSTRB(anc_id_24
16267        ,INSTRB(anc_id_24,'(]',1,5) + 2
16268        ,INSTRB(anc_id_24,'(]',1,6) -
16269         INSTRB(anc_id_24,'(]',1,5) - 2)
16270 ,SUBSTRB(anc_id_24
16271        ,INSTRB(anc_id_24,'(]',1,6) + 2
16272        ,INSTRB(anc_id_24,'(]',1,7) -
16273         INSTRB(anc_id_24,'(]',1,6) - 2)
16274 ,SUBSTRB(anc_id_24
16275        ,INSTRB(anc_id_24,'(]',1,7) + 2
16276        ,LENGTHB(anc_id_24))
16277 )
16278 
16279 WHEN anc_id_25 IS NOT NULL THEN
16280   INTO xla_ae_header_acs (
16281         ae_header_id , object_version_number
16282       , analytical_criterion_code
16283       , analytical_criterion_type_code
16284       , amb_context_code
16285       , ac1,ac2,ac3,ac4,ac5)
16286 VALUES (ae_header_id, C_OVN
16287 ,SUBSTRB(anc_id_25
16288        ,1
16289        ,INSTRB(anc_id_25,'(]',1,1) -1)
16290 ,SUBSTRB(anc_id_25
16291        ,INSTRB(anc_id_25,'(]',1,1) + 2
16292        ,INSTRB(anc_id_25,'(]',1,2) -
16293         INSTRB(anc_id_25,'(]',1,1) - 2)
16294 ,SUBSTRB(anc_id_25
16295        ,INSTRB(anc_id_25,'(]',1,2) + 2
16296        ,INSTRB(anc_id_25,'(]',1,3) -
16297         INSTRB(anc_id_25,'(]',1,2) - 2)
16298 ,SUBSTRB(anc_id_25
16299        ,INSTRB(anc_id_25,'(]',1,3) + 2
16300        ,INSTRB(anc_id_25,'(]',1,4) -
16301         INSTRB(anc_id_25,'(]',1,3) - 2)
16302 ,SUBSTRB(anc_id_25
16303        ,INSTRB(anc_id_25,'(]',1,4) + 2
16304        ,INSTRB(anc_id_25,'(]',1,5) -
16305         INSTRB(anc_id_25,'(]',1,4) - 2)
16306 ,SUBSTRB(anc_id_25
16307        ,INSTRB(anc_id_25,'(]',1,5) + 2
16308        ,INSTRB(anc_id_25,'(]',1,6) -
16309         INSTRB(anc_id_25,'(]',1,5) - 2)
16310 ,SUBSTRB(anc_id_25
16311        ,INSTRB(anc_id_25,'(]',1,6) + 2
16312        ,INSTRB(anc_id_25,'(]',1,7) -
16313         INSTRB(anc_id_25,'(]',1,6) - 2)
16314 ,SUBSTRB(anc_id_25
16315        ,INSTRB(anc_id_25,'(]',1,7) + 2
16316        ,LENGTHB(anc_id_25))
16317 )
16318 
16319 WHEN anc_id_26 IS NOT NULL THEN
16320   INTO xla_ae_header_acs (
16321         ae_header_id , object_version_number
16322       , analytical_criterion_code
16323       , analytical_criterion_type_code
16324       , amb_context_code
16325       , ac1,ac2,ac3,ac4,ac5)
16326 VALUES (ae_header_id, C_OVN
16327 ,SUBSTRB(anc_id_26
16328        ,1
16329        ,INSTRB(anc_id_26,'(]',1,1) -1)
16330 ,SUBSTRB(anc_id_26
16331        ,INSTRB(anc_id_26,'(]',1,1) + 2
16332        ,INSTRB(anc_id_26,'(]',1,2) -
16333         INSTRB(anc_id_26,'(]',1,1) - 2)
16334 ,SUBSTRB(anc_id_26
16335        ,INSTRB(anc_id_26,'(]',1,2) + 2
16336        ,INSTRB(anc_id_26,'(]',1,3) -
16337         INSTRB(anc_id_26,'(]',1,2) - 2)
16338 ,SUBSTRB(anc_id_26
16339        ,INSTRB(anc_id_26,'(]',1,3) + 2
16340        ,INSTRB(anc_id_26,'(]',1,4) -
16341         INSTRB(anc_id_26,'(]',1,3) - 2)
16342 ,SUBSTRB(anc_id_26
16343        ,INSTRB(anc_id_26,'(]',1,4) + 2
16344        ,INSTRB(anc_id_26,'(]',1,5) -
16345         INSTRB(anc_id_26,'(]',1,4) - 2)
16346 ,SUBSTRB(anc_id_26
16347        ,INSTRB(anc_id_26,'(]',1,5) + 2
16348        ,INSTRB(anc_id_26,'(]',1,6) -
16349         INSTRB(anc_id_26,'(]',1,5) - 2)
16350 ,SUBSTRB(anc_id_26
16351        ,INSTRB(anc_id_26,'(]',1,6) + 2
16352        ,INSTRB(anc_id_26,'(]',1,7) -
16353         INSTRB(anc_id_26,'(]',1,6) - 2)
16354 ,SUBSTRB(anc_id_26
16355        ,INSTRB(anc_id_26,'(]',1,7) + 2
16356        ,LENGTHB(anc_id_26))
16357 )
16358 
16359 WHEN anc_id_27 IS NOT NULL THEN
16360   INTO xla_ae_header_acs (
16361         ae_header_id , object_version_number
16362       , analytical_criterion_code
16363       , analytical_criterion_type_code
16364       , amb_context_code
16365       , ac1,ac2,ac3,ac4,ac5)
16366 VALUES (ae_header_id, C_OVN
16367 ,SUBSTRB(anc_id_27
16368        ,1
16369        ,INSTRB(anc_id_27,'(]',1,1) -1)
16370 ,SUBSTRB(anc_id_27
16371        ,INSTRB(anc_id_27,'(]',1,1) + 2
16372        ,INSTRB(anc_id_27,'(]',1,2) -
16373         INSTRB(anc_id_27,'(]',1,1) - 2)
16374 ,SUBSTRB(anc_id_27
16375        ,INSTRB(anc_id_27,'(]',1,2) + 2
16376        ,INSTRB(anc_id_27,'(]',1,3) -
16377         INSTRB(anc_id_27,'(]',1,2) - 2)
16378 ,SUBSTRB(anc_id_27
16379        ,INSTRB(anc_id_27,'(]',1,3) + 2
16380        ,INSTRB(anc_id_27,'(]',1,4) -
16381         INSTRB(anc_id_27,'(]',1,3) - 2)
16382 ,SUBSTRB(anc_id_27
16383        ,INSTRB(anc_id_27,'(]',1,4) + 2
16384        ,INSTRB(anc_id_27,'(]',1,5) -
16385         INSTRB(anc_id_27,'(]',1,4) - 2)
16386 ,SUBSTRB(anc_id_27
16387        ,INSTRB(anc_id_27,'(]',1,5) + 2
16388        ,INSTRB(anc_id_27,'(]',1,6) -
16389         INSTRB(anc_id_27,'(]',1,5) - 2)
16390 ,SUBSTRB(anc_id_27
16391        ,INSTRB(anc_id_27,'(]',1,6) + 2
16392        ,INSTRB(anc_id_27,'(]',1,7) -
16393         INSTRB(anc_id_27,'(]',1,6) - 2)
16394 ,SUBSTRB(anc_id_27
16395        ,INSTRB(anc_id_27,'(]',1,7) + 2
16396        ,LENGTHB(anc_id_27))
16397 )
16398 
16399 WHEN anc_id_28 IS NOT NULL THEN
16400   INTO xla_ae_header_acs (
16401         ae_header_id , object_version_number
16402       , analytical_criterion_code
16403       , analytical_criterion_type_code
16404       , amb_context_code
16405       , ac1,ac2,ac3,ac4,ac5)
16406 VALUES (ae_header_id, C_OVN
16407 ,SUBSTRB(anc_id_28
16408        ,1
16409        ,INSTRB(anc_id_28,'(]',1,1) -1)
16410 ,SUBSTRB(anc_id_28
16411        ,INSTRB(anc_id_28,'(]',1,1) + 2
16412        ,INSTRB(anc_id_28,'(]',1,2) -
16413         INSTRB(anc_id_28,'(]',1,1) - 2)
16414 ,SUBSTRB(anc_id_28
16415        ,INSTRB(anc_id_28,'(]',1,2) + 2
16416        ,INSTRB(anc_id_28,'(]',1,3) -
16417         INSTRB(anc_id_28,'(]',1,2) - 2)
16418 ,SUBSTRB(anc_id_28
16419        ,INSTRB(anc_id_28,'(]',1,3) + 2
16420        ,INSTRB(anc_id_28,'(]',1,4) -
16421         INSTRB(anc_id_28,'(]',1,3) - 2)
16422 ,SUBSTRB(anc_id_28
16423        ,INSTRB(anc_id_28,'(]',1,4) + 2
16424        ,INSTRB(anc_id_28,'(]',1,5) -
16425         INSTRB(anc_id_28,'(]',1,4) - 2)
16426 ,SUBSTRB(anc_id_28
16427        ,INSTRB(anc_id_28,'(]',1,5) + 2
16428        ,INSTRB(anc_id_28,'(]',1,6) -
16429         INSTRB(anc_id_28,'(]',1,5) - 2)
16430 ,SUBSTRB(anc_id_28
16431        ,INSTRB(anc_id_28,'(]',1,6) + 2
16432        ,INSTRB(anc_id_28,'(]',1,7) -
16433         INSTRB(anc_id_28,'(]',1,6) - 2)
16434 ,SUBSTRB(anc_id_28
16435        ,INSTRB(anc_id_28,'(]',1,7) + 2
16436        ,LENGTHB(anc_id_28))
16437 )
16438 
16439 WHEN anc_id_29 IS NOT NULL THEN
16440   INTO xla_ae_header_acs (
16441         ae_header_id , object_version_number
16442       , analytical_criterion_code
16443       , analytical_criterion_type_code
16444       , amb_context_code
16445       , ac1,ac2,ac3,ac4,ac5)
16446 VALUES (ae_header_id, C_OVN
16447 ,SUBSTRB(anc_id_29
16448        ,1
16449        ,INSTRB(anc_id_29,'(]',1,1) -1)
16450 ,SUBSTRB(anc_id_29
16451        ,INSTRB(anc_id_29,'(]',1,1) + 2
16452        ,INSTRB(anc_id_29,'(]',1,2) -
16453         INSTRB(anc_id_29,'(]',1,1) - 2)
16454 ,SUBSTRB(anc_id_29
16455        ,INSTRB(anc_id_29,'(]',1,2) + 2
16456        ,INSTRB(anc_id_29,'(]',1,3) -
16457         INSTRB(anc_id_29,'(]',1,2) - 2)
16458 ,SUBSTRB(anc_id_29
16459        ,INSTRB(anc_id_29,'(]',1,3) + 2
16460        ,INSTRB(anc_id_29,'(]',1,4) -
16461         INSTRB(anc_id_29,'(]',1,3) - 2)
16462 ,SUBSTRB(anc_id_29
16463        ,INSTRB(anc_id_29,'(]',1,4) + 2
16464        ,INSTRB(anc_id_29,'(]',1,5) -
16465         INSTRB(anc_id_29,'(]',1,4) - 2)
16466 ,SUBSTRB(anc_id_29
16467        ,INSTRB(anc_id_29,'(]',1,5) + 2
16468        ,INSTRB(anc_id_29,'(]',1,6) -
16469         INSTRB(anc_id_29,'(]',1,5) - 2)
16470 ,SUBSTRB(anc_id_29
16471        ,INSTRB(anc_id_29,'(]',1,6) + 2
16472        ,INSTRB(anc_id_29,'(]',1,7) -
16473         INSTRB(anc_id_29,'(]',1,6) - 2)
16474 ,SUBSTRB(anc_id_29
16475        ,INSTRB(anc_id_29,'(]',1,7) + 2
16476        ,LENGTHB(anc_id_29))
16477 )
16478 
16479 WHEN anc_id_30 IS NOT NULL THEN
16480   INTO xla_ae_header_acs (
16481         ae_header_id , object_version_number
16482       , analytical_criterion_code
16483       , analytical_criterion_type_code
16484       , amb_context_code
16485       , ac1,ac2,ac3,ac4,ac5)
16486 VALUES (ae_header_id, C_OVN
16487 ,SUBSTRB(anc_id_30
16488        ,1
16489        ,INSTRB(anc_id_30,'(]',1,1) -1)
16490 ,SUBSTRB(anc_id_30
16491        ,INSTRB(anc_id_30,'(]',1,1) + 2
16492        ,INSTRB(anc_id_30,'(]',1,2) -
16493         INSTRB(anc_id_30,'(]',1,1) - 2)
16494 ,SUBSTRB(anc_id_30
16495        ,INSTRB(anc_id_30,'(]',1,2) + 2
16496        ,INSTRB(anc_id_30,'(]',1,3) -
16497         INSTRB(anc_id_30,'(]',1,2) - 2)
16498 ,SUBSTRB(anc_id_30
16499        ,INSTRB(anc_id_30,'(]',1,3) + 2
16500        ,INSTRB(anc_id_30,'(]',1,4) -
16501         INSTRB(anc_id_30,'(]',1,3) - 2)
16502 ,SUBSTRB(anc_id_30
16503        ,INSTRB(anc_id_30,'(]',1,4) + 2
16504        ,INSTRB(anc_id_30,'(]',1,5) -
16505         INSTRB(anc_id_30,'(]',1,4) - 2)
16506 ,SUBSTRB(anc_id_30
16507        ,INSTRB(anc_id_30,'(]',1,5) + 2
16508        ,INSTRB(anc_id_30,'(]',1,6) -
16509         INSTRB(anc_id_30,'(]',1,5) - 2)
16510 ,SUBSTRB(anc_id_30
16511        ,INSTRB(anc_id_30,'(]',1,6) + 2
16512        ,INSTRB(anc_id_30,'(]',1,7) -
16513         INSTRB(anc_id_30,'(]',1,6) - 2)
16514 ,SUBSTRB(anc_id_30
16515        ,INSTRB(anc_id_30,'(]',1,7) + 2
16516        ,LENGTHB(anc_id_30))
16517 )
16518 
16519 WHEN anc_id_31 IS NOT NULL THEN
16520   INTO xla_ae_header_acs (
16521         ae_header_id , object_version_number
16522       , analytical_criterion_code
16523       , analytical_criterion_type_code
16524       , amb_context_code
16525       , ac1,ac2,ac3,ac4,ac5)
16526 VALUES (ae_header_id, C_OVN
16527 ,SUBSTRB(anc_id_31
16528        ,1
16529        ,INSTRB(anc_id_31,'(]',1,1) -1)
16530 ,SUBSTRB(anc_id_31
16531        ,INSTRB(anc_id_31,'(]',1,1) + 2
16532        ,INSTRB(anc_id_31,'(]',1,2) -
16533         INSTRB(anc_id_31,'(]',1,1) - 2)
16534 ,SUBSTRB(anc_id_31
16535        ,INSTRB(anc_id_31,'(]',1,2) + 2
16536        ,INSTRB(anc_id_31,'(]',1,3) -
16537         INSTRB(anc_id_31,'(]',1,2) - 2)
16538 ,SUBSTRB(anc_id_31
16539        ,INSTRB(anc_id_31,'(]',1,3) + 2
16540        ,INSTRB(anc_id_31,'(]',1,4) -
16541         INSTRB(anc_id_31,'(]',1,3) - 2)
16542 ,SUBSTRB(anc_id_31
16543        ,INSTRB(anc_id_31,'(]',1,4) + 2
16544        ,INSTRB(anc_id_31,'(]',1,5) -
16545         INSTRB(anc_id_31,'(]',1,4) - 2)
16546 ,SUBSTRB(anc_id_31
16547        ,INSTRB(anc_id_31,'(]',1,5) + 2
16548        ,INSTRB(anc_id_31,'(]',1,6) -
16549         INSTRB(anc_id_31,'(]',1,5) - 2)
16550 ,SUBSTRB(anc_id_31
16551        ,INSTRB(anc_id_31,'(]',1,6) + 2
16552        ,INSTRB(anc_id_31,'(]',1,7) -
16553         INSTRB(anc_id_31,'(]',1,6) - 2)
16554 ,SUBSTRB(anc_id_31
16555        ,INSTRB(anc_id_31,'(]',1,7) + 2
16556        ,LENGTHB(anc_id_31))
16557 )
16558 
16559 WHEN anc_id_32 IS NOT NULL THEN
16560   INTO xla_ae_header_acs (
16561         ae_header_id , object_version_number
16562       , analytical_criterion_code
16563       , analytical_criterion_type_code
16564       , amb_context_code
16565       , ac1,ac2,ac3,ac4,ac5)
16566 VALUES (ae_header_id, C_OVN
16567 ,SUBSTRB(anc_id_32
16568        ,1
16569        ,INSTRB(anc_id_32,'(]',1,1) -1)
16570 ,SUBSTRB(anc_id_32
16571        ,INSTRB(anc_id_32,'(]',1,1) + 2
16572        ,INSTRB(anc_id_32,'(]',1,2) -
16573         INSTRB(anc_id_32,'(]',1,1) - 2)
16574 ,SUBSTRB(anc_id_32
16575        ,INSTRB(anc_id_32,'(]',1,2) + 2
16576        ,INSTRB(anc_id_32,'(]',1,3) -
16577         INSTRB(anc_id_32,'(]',1,2) - 2)
16578 ,SUBSTRB(anc_id_32
16579        ,INSTRB(anc_id_32,'(]',1,3) + 2
16580        ,INSTRB(anc_id_32,'(]',1,4) -
16581         INSTRB(anc_id_32,'(]',1,3) - 2)
16582 ,SUBSTRB(anc_id_32
16583        ,INSTRB(anc_id_32,'(]',1,4) + 2
16584        ,INSTRB(anc_id_32,'(]',1,5) -
16585         INSTRB(anc_id_32,'(]',1,4) - 2)
16586 ,SUBSTRB(anc_id_32
16587        ,INSTRB(anc_id_32,'(]',1,5) + 2
16588        ,INSTRB(anc_id_32,'(]',1,6) -
16589         INSTRB(anc_id_32,'(]',1,5) - 2)
16590 ,SUBSTRB(anc_id_32
16591        ,INSTRB(anc_id_32,'(]',1,6) + 2
16592        ,INSTRB(anc_id_32,'(]',1,7) -
16593         INSTRB(anc_id_32,'(]',1,6) - 2)
16594 ,SUBSTRB(anc_id_32
16595        ,INSTRB(anc_id_32,'(]',1,7) + 2
16596        ,LENGTHB(anc_id_32))
16597 )
16598 
16599 WHEN anc_id_33 IS NOT NULL THEN
16600   INTO xla_ae_header_acs (
16601         ae_header_id , object_version_number
16602       , analytical_criterion_code
16603       , analytical_criterion_type_code
16604       , amb_context_code
16605       , ac1,ac2,ac3,ac4,ac5)
16606 VALUES (ae_header_id, C_OVN
16607 ,SUBSTRB(anc_id_33
16608        ,1
16609        ,INSTRB(anc_id_33,'(]',1,1) -1)
16610 ,SUBSTRB(anc_id_33
16611        ,INSTRB(anc_id_33,'(]',1,1) + 2
16612        ,INSTRB(anc_id_33,'(]',1,2) -
16613         INSTRB(anc_id_33,'(]',1,1) - 2)
16614 ,SUBSTRB(anc_id_33
16615        ,INSTRB(anc_id_33,'(]',1,2) + 2
16616        ,INSTRB(anc_id_33,'(]',1,3) -
16617         INSTRB(anc_id_33,'(]',1,2) - 2)
16618 ,SUBSTRB(anc_id_33
16619        ,INSTRB(anc_id_33,'(]',1,3) + 2
16620        ,INSTRB(anc_id_33,'(]',1,4) -
16621         INSTRB(anc_id_33,'(]',1,3) - 2)
16622 ,SUBSTRB(anc_id_33
16623        ,INSTRB(anc_id_33,'(]',1,4) + 2
16624        ,INSTRB(anc_id_33,'(]',1,5) -
16625         INSTRB(anc_id_33,'(]',1,4) - 2)
16626 ,SUBSTRB(anc_id_33
16627        ,INSTRB(anc_id_33,'(]',1,5) + 2
16628        ,INSTRB(anc_id_33,'(]',1,6) -
16629         INSTRB(anc_id_33,'(]',1,5) - 2)
16630 ,SUBSTRB(anc_id_33
16631        ,INSTRB(anc_id_33,'(]',1,6) + 2
16632        ,INSTRB(anc_id_33,'(]',1,7) -
16633         INSTRB(anc_id_33,'(]',1,6) - 2)
16634 ,SUBSTRB(anc_id_33
16635        ,INSTRB(anc_id_33,'(]',1,7) + 2
16636        ,LENGTHB(anc_id_33))
16637 )
16638 
16639 WHEN anc_id_34 IS NOT NULL THEN
16640   INTO xla_ae_header_acs (
16641         ae_header_id , object_version_number
16642       , analytical_criterion_code
16643       , analytical_criterion_type_code
16644       , amb_context_code
16645       , ac1,ac2,ac3,ac4,ac5)
16646 VALUES (ae_header_id, C_OVN
16647 ,SUBSTRB(anc_id_34
16648        ,1
16649        ,INSTRB(anc_id_34,'(]',1,1) -1)
16650 ,SUBSTRB(anc_id_34
16651        ,INSTRB(anc_id_34,'(]',1,1) + 2
16652        ,INSTRB(anc_id_34,'(]',1,2) -
16653         INSTRB(anc_id_34,'(]',1,1) - 2)
16654 ,SUBSTRB(anc_id_34
16655        ,INSTRB(anc_id_34,'(]',1,2) + 2
16656        ,INSTRB(anc_id_34,'(]',1,3) -
16657         INSTRB(anc_id_34,'(]',1,2) - 2)
16658 ,SUBSTRB(anc_id_34
16659        ,INSTRB(anc_id_34,'(]',1,3) + 2
16660        ,INSTRB(anc_id_34,'(]',1,4) -
16661         INSTRB(anc_id_34,'(]',1,3) - 2)
16662 ,SUBSTRB(anc_id_34
16663        ,INSTRB(anc_id_34,'(]',1,4) + 2
16664        ,INSTRB(anc_id_34,'(]',1,5) -
16665         INSTRB(anc_id_34,'(]',1,4) - 2)
16666 ,SUBSTRB(anc_id_34
16667        ,INSTRB(anc_id_34,'(]',1,5) + 2
16668        ,INSTRB(anc_id_34,'(]',1,6) -
16669         INSTRB(anc_id_34,'(]',1,5) - 2)
16670 ,SUBSTRB(anc_id_34
16671        ,INSTRB(anc_id_34,'(]',1,6) + 2
16672        ,INSTRB(anc_id_34,'(]',1,7) -
16673         INSTRB(anc_id_34,'(]',1,6) - 2)
16674 ,SUBSTRB(anc_id_34
16675        ,INSTRB(anc_id_34,'(]',1,7) + 2
16676        ,LENGTHB(anc_id_34))
16677 )
16678 
16679 WHEN anc_id_35 IS NOT NULL THEN
16680   INTO xla_ae_header_acs (
16681         ae_header_id , object_version_number
16682       , analytical_criterion_code
16683       , analytical_criterion_type_code
16684       , amb_context_code
16685       , ac1,ac2,ac3,ac4,ac5)
16686 VALUES (ae_header_id, C_OVN
16687 ,SUBSTRB(anc_id_35
16688        ,1
16689        ,INSTRB(anc_id_35,'(]',1,1) -1)
16690 ,SUBSTRB(anc_id_35
16691        ,INSTRB(anc_id_35,'(]',1,1) + 2
16692        ,INSTRB(anc_id_35,'(]',1,2) -
16693         INSTRB(anc_id_35,'(]',1,1) - 2)
16694 ,SUBSTRB(anc_id_35
16695        ,INSTRB(anc_id_35,'(]',1,2) + 2
16696        ,INSTRB(anc_id_35,'(]',1,3) -
16697         INSTRB(anc_id_35,'(]',1,2) - 2)
16698 ,SUBSTRB(anc_id_35
16699        ,INSTRB(anc_id_35,'(]',1,3) + 2
16700        ,INSTRB(anc_id_35,'(]',1,4) -
16701         INSTRB(anc_id_35,'(]',1,3) - 2)
16702 ,SUBSTRB(anc_id_35
16703        ,INSTRB(anc_id_35,'(]',1,4) + 2
16704        ,INSTRB(anc_id_35,'(]',1,5) -
16705         INSTRB(anc_id_35,'(]',1,4) - 2)
16706 ,SUBSTRB(anc_id_35
16707        ,INSTRB(anc_id_35,'(]',1,5) + 2
16708        ,INSTRB(anc_id_35,'(]',1,6) -
16709         INSTRB(anc_id_35,'(]',1,5) - 2)
16710 ,SUBSTRB(anc_id_35
16711        ,INSTRB(anc_id_35,'(]',1,6) + 2
16712        ,INSTRB(anc_id_35,'(]',1,7) -
16713         INSTRB(anc_id_35,'(]',1,6) - 2)
16714 ,SUBSTRB(anc_id_35
16715        ,INSTRB(anc_id_35,'(]',1,7) + 2
16716        ,LENGTHB(anc_id_35))
16717 )
16718 
16719 WHEN anc_id_36 IS NOT NULL THEN
16720   INTO xla_ae_header_acs (
16721         ae_header_id , object_version_number
16722       , analytical_criterion_code
16723       , analytical_criterion_type_code
16724       , amb_context_code
16725       , ac1,ac2,ac3,ac4,ac5)
16726 VALUES (ae_header_id, C_OVN
16727 ,SUBSTRB(anc_id_36
16728        ,1
16729        ,INSTRB(anc_id_36,'(]',1,1) -1)
16730 ,SUBSTRB(anc_id_36
16731        ,INSTRB(anc_id_36,'(]',1,1) + 2
16732        ,INSTRB(anc_id_36,'(]',1,2) -
16733         INSTRB(anc_id_36,'(]',1,1) - 2)
16734 ,SUBSTRB(anc_id_36
16735        ,INSTRB(anc_id_36,'(]',1,2) + 2
16736        ,INSTRB(anc_id_36,'(]',1,3) -
16737         INSTRB(anc_id_36,'(]',1,2) - 2)
16738 ,SUBSTRB(anc_id_36
16739        ,INSTRB(anc_id_36,'(]',1,3) + 2
16740        ,INSTRB(anc_id_36,'(]',1,4) -
16741         INSTRB(anc_id_36,'(]',1,3) - 2)
16742 ,SUBSTRB(anc_id_36
16743        ,INSTRB(anc_id_36,'(]',1,4) + 2
16744        ,INSTRB(anc_id_36,'(]',1,5) -
16745         INSTRB(anc_id_36,'(]',1,4) - 2)
16746 ,SUBSTRB(anc_id_36
16747        ,INSTRB(anc_id_36,'(]',1,5) + 2
16748        ,INSTRB(anc_id_36,'(]',1,6) -
16749         INSTRB(anc_id_36,'(]',1,5) - 2)
16750 ,SUBSTRB(anc_id_36
16751        ,INSTRB(anc_id_36,'(]',1,6) + 2
16752        ,INSTRB(anc_id_36,'(]',1,7) -
16753         INSTRB(anc_id_36,'(]',1,6) - 2)
16754 ,SUBSTRB(anc_id_36
16755        ,INSTRB(anc_id_36,'(]',1,7) + 2
16756        ,LENGTHB(anc_id_36))
16757 )
16758 
16759 WHEN anc_id_37 IS NOT NULL THEN
16760   INTO xla_ae_header_acs (
16761         ae_header_id , object_version_number
16762       , analytical_criterion_code
16763       , analytical_criterion_type_code
16764       , amb_context_code
16765       , ac1,ac2,ac3,ac4,ac5)
16766 VALUES (ae_header_id, C_OVN
16767 ,SUBSTRB(anc_id_37
16768        ,1
16769        ,INSTRB(anc_id_37,'(]',1,1) -1)
16770 ,SUBSTRB(anc_id_37
16771        ,INSTRB(anc_id_37,'(]',1,1) + 2
16772        ,INSTRB(anc_id_37,'(]',1,2) -
16773         INSTRB(anc_id_37,'(]',1,1) - 2)
16774 ,SUBSTRB(anc_id_37
16775        ,INSTRB(anc_id_37,'(]',1,2) + 2
16776        ,INSTRB(anc_id_37,'(]',1,3) -
16777         INSTRB(anc_id_37,'(]',1,2) - 2)
16778 ,SUBSTRB(anc_id_37
16779        ,INSTRB(anc_id_37,'(]',1,3) + 2
16780        ,INSTRB(anc_id_37,'(]',1,4) -
16781         INSTRB(anc_id_37,'(]',1,3) - 2)
16782 ,SUBSTRB(anc_id_37
16783        ,INSTRB(anc_id_37,'(]',1,4) + 2
16784        ,INSTRB(anc_id_37,'(]',1,5) -
16785         INSTRB(anc_id_37,'(]',1,4) - 2)
16786 ,SUBSTRB(anc_id_37
16787        ,INSTRB(anc_id_37,'(]',1,5) + 2
16788        ,INSTRB(anc_id_37,'(]',1,6) -
16789         INSTRB(anc_id_37,'(]',1,5) - 2)
16790 ,SUBSTRB(anc_id_37
16791        ,INSTRB(anc_id_37,'(]',1,6) + 2
16792        ,INSTRB(anc_id_37,'(]',1,7) -
16793         INSTRB(anc_id_37,'(]',1,6) - 2)
16794 ,SUBSTRB(anc_id_37
16795        ,INSTRB(anc_id_37,'(]',1,7) + 2
16796        ,LENGTHB(anc_id_37))
16797 )
16798 
16799 WHEN anc_id_38 IS NOT NULL THEN
16800   INTO xla_ae_header_acs (
16801         ae_header_id , object_version_number
16802       , analytical_criterion_code
16803       , analytical_criterion_type_code
16804       , amb_context_code
16805       , ac1,ac2,ac3,ac4,ac5)
16806 VALUES (ae_header_id, C_OVN
16807 ,SUBSTRB(anc_id_38
16808        ,1
16809        ,INSTRB(anc_id_38,'(]',1,1) -1)
16810 ,SUBSTRB(anc_id_38
16811        ,INSTRB(anc_id_38,'(]',1,1) + 2
16812        ,INSTRB(anc_id_38,'(]',1,2) -
16813         INSTRB(anc_id_38,'(]',1,1) - 2)
16814 ,SUBSTRB(anc_id_38
16815        ,INSTRB(anc_id_38,'(]',1,2) + 2
16816        ,INSTRB(anc_id_38,'(]',1,3) -
16817         INSTRB(anc_id_38,'(]',1,2) - 2)
16818 ,SUBSTRB(anc_id_38
16819        ,INSTRB(anc_id_38,'(]',1,3) + 2
16820        ,INSTRB(anc_id_38,'(]',1,4) -
16821         INSTRB(anc_id_38,'(]',1,3) - 2)
16822 ,SUBSTRB(anc_id_38
16823        ,INSTRB(anc_id_38,'(]',1,4) + 2
16824        ,INSTRB(anc_id_38,'(]',1,5) -
16825         INSTRB(anc_id_38,'(]',1,4) - 2)
16826 ,SUBSTRB(anc_id_38
16827        ,INSTRB(anc_id_38,'(]',1,5) + 2
16828        ,INSTRB(anc_id_38,'(]',1,6) -
16829         INSTRB(anc_id_38,'(]',1,5) - 2)
16830 ,SUBSTRB(anc_id_38
16831        ,INSTRB(anc_id_38,'(]',1,6) + 2
16832        ,INSTRB(anc_id_38,'(]',1,7) -
16833         INSTRB(anc_id_38,'(]',1,6) - 2)
16834 ,SUBSTRB(anc_id_38
16835        ,INSTRB(anc_id_38,'(]',1,7) + 2
16836        ,LENGTHB(anc_id_38))
16837 )
16838 
16839 WHEN anc_id_39 IS NOT NULL THEN
16840   INTO xla_ae_header_acs (
16841         ae_header_id , object_version_number
16842       , analytical_criterion_code
16843       , analytical_criterion_type_code
16844       , amb_context_code
16845       , ac1,ac2,ac3,ac4,ac5)
16846 VALUES (ae_header_id, C_OVN
16847 ,SUBSTRB(anc_id_39
16848        ,1
16849        ,INSTRB(anc_id_39,'(]',1,1) -1)
16850 ,SUBSTRB(anc_id_39
16851        ,INSTRB(anc_id_39,'(]',1,1) + 2
16852        ,INSTRB(anc_id_39,'(]',1,2) -
16853         INSTRB(anc_id_39,'(]',1,1) - 2)
16854 ,SUBSTRB(anc_id_39
16855        ,INSTRB(anc_id_39,'(]',1,2) + 2
16856        ,INSTRB(anc_id_39,'(]',1,3) -
16857         INSTRB(anc_id_39,'(]',1,2) - 2)
16858 ,SUBSTRB(anc_id_39
16859        ,INSTRB(anc_id_39,'(]',1,3) + 2
16860        ,INSTRB(anc_id_39,'(]',1,4) -
16861         INSTRB(anc_id_39,'(]',1,3) - 2)
16862 ,SUBSTRB(anc_id_39
16863        ,INSTRB(anc_id_39,'(]',1,4) + 2
16864        ,INSTRB(anc_id_39,'(]',1,5) -
16865         INSTRB(anc_id_39,'(]',1,4) - 2)
16866 ,SUBSTRB(anc_id_39
16867        ,INSTRB(anc_id_39,'(]',1,5) + 2
16868        ,INSTRB(anc_id_39,'(]',1,6) -
16869         INSTRB(anc_id_39,'(]',1,5) - 2)
16870 ,SUBSTRB(anc_id_39
16871        ,INSTRB(anc_id_39,'(]',1,6) + 2
16872        ,INSTRB(anc_id_39,'(]',1,7) -
16873         INSTRB(anc_id_39,'(]',1,6) - 2)
16874 ,SUBSTRB(anc_id_39
16875        ,INSTRB(anc_id_39,'(]',1,7) + 2
16876        ,LENGTHB(anc_id_39))
16877 )
16878 
16879 WHEN anc_id_40 IS NOT NULL THEN
16880   INTO xla_ae_header_acs (
16881         ae_header_id , object_version_number
16882       , analytical_criterion_code
16883       , analytical_criterion_type_code
16884       , amb_context_code
16885       , ac1,ac2,ac3,ac4,ac5)
16886 VALUES (ae_header_id, C_OVN
16887 ,SUBSTRB(anc_id_40
16888        ,1
16889        ,INSTRB(anc_id_40,'(]',1,1) -1)
16890 ,SUBSTRB(anc_id_40
16891        ,INSTRB(anc_id_40,'(]',1,1) + 2
16892        ,INSTRB(anc_id_40,'(]',1,2) -
16893         INSTRB(anc_id_40,'(]',1,1) - 2)
16894 ,SUBSTRB(anc_id_40
16895        ,INSTRB(anc_id_40,'(]',1,2) + 2
16896        ,INSTRB(anc_id_40,'(]',1,3) -
16897         INSTRB(anc_id_40,'(]',1,2) - 2)
16898 ,SUBSTRB(anc_id_40
16899        ,INSTRB(anc_id_40,'(]',1,3) + 2
16900        ,INSTRB(anc_id_40,'(]',1,4) -
16901         INSTRB(anc_id_40,'(]',1,3) - 2)
16902 ,SUBSTRB(anc_id_40
16903        ,INSTRB(anc_id_40,'(]',1,4) + 2
16904        ,INSTRB(anc_id_40,'(]',1,5) -
16905         INSTRB(anc_id_40,'(]',1,4) - 2)
16906 ,SUBSTRB(anc_id_40
16907        ,INSTRB(anc_id_40,'(]',1,5) + 2
16908        ,INSTRB(anc_id_40,'(]',1,6) -
16909         INSTRB(anc_id_40,'(]',1,5) - 2)
16910 ,SUBSTRB(anc_id_40
16911        ,INSTRB(anc_id_40,'(]',1,6) + 2
16912        ,INSTRB(anc_id_40,'(]',1,7) -
16913         INSTRB(anc_id_40,'(]',1,6) - 2)
16914 ,SUBSTRB(anc_id_40
16915        ,INSTRB(anc_id_40,'(]',1,7) + 2
16916        ,LENGTHB(anc_id_40))
16917 )
16918 
16919 WHEN anc_id_41 IS NOT NULL THEN
16920   INTO xla_ae_header_acs (
16921         ae_header_id , object_version_number
16922       , analytical_criterion_code
16923       , analytical_criterion_type_code
16924       , amb_context_code
16925       , ac1,ac2,ac3,ac4,ac5)
16926 VALUES (ae_header_id, C_OVN
16927 ,SUBSTRB(anc_id_41
16928        ,1
16929        ,INSTRB(anc_id_41,'(]',1,1) -1)
16930 ,SUBSTRB(anc_id_41
16931        ,INSTRB(anc_id_41,'(]',1,1) + 2
16932        ,INSTRB(anc_id_41,'(]',1,2) -
16933         INSTRB(anc_id_41,'(]',1,1) - 2)
16934 ,SUBSTRB(anc_id_41
16935        ,INSTRB(anc_id_41,'(]',1,2) + 2
16936        ,INSTRB(anc_id_41,'(]',1,3) -
16937         INSTRB(anc_id_41,'(]',1,2) - 2)
16938 ,SUBSTRB(anc_id_41
16939        ,INSTRB(anc_id_41,'(]',1,3) + 2
16940        ,INSTRB(anc_id_41,'(]',1,4) -
16941         INSTRB(anc_id_41,'(]',1,3) - 2)
16942 ,SUBSTRB(anc_id_41
16943        ,INSTRB(anc_id_41,'(]',1,4) + 2
16944        ,INSTRB(anc_id_41,'(]',1,5) -
16945         INSTRB(anc_id_41,'(]',1,4) - 2)
16946 ,SUBSTRB(anc_id_41
16947        ,INSTRB(anc_id_41,'(]',1,5) + 2
16948        ,INSTRB(anc_id_41,'(]',1,6) -
16949         INSTRB(anc_id_41,'(]',1,5) - 2)
16950 ,SUBSTRB(anc_id_41
16951        ,INSTRB(anc_id_41,'(]',1,6) + 2
16952        ,INSTRB(anc_id_41,'(]',1,7) -
16953         INSTRB(anc_id_41,'(]',1,6) - 2)
16954 ,SUBSTRB(anc_id_41
16955        ,INSTRB(anc_id_41,'(]',1,7) + 2
16956        ,LENGTHB(anc_id_41))
16957 )
16958 
16959 WHEN anc_id_42 IS NOT NULL THEN
16960   INTO xla_ae_header_acs (
16961         ae_header_id , object_version_number
16962       , analytical_criterion_code
16963       , analytical_criterion_type_code
16964       , amb_context_code
16965       , ac1,ac2,ac3,ac4,ac5)
16966 VALUES (ae_header_id, C_OVN
16967 ,SUBSTRB(anc_id_42
16968        ,1
16969        ,INSTRB(anc_id_42,'(]',1,1) -1)
16970 ,SUBSTRB(anc_id_42
16971        ,INSTRB(anc_id_42,'(]',1,1) + 2
16972        ,INSTRB(anc_id_42,'(]',1,2) -
16973         INSTRB(anc_id_42,'(]',1,1) - 2)
16974 ,SUBSTRB(anc_id_42
16975        ,INSTRB(anc_id_42,'(]',1,2) + 2
16976        ,INSTRB(anc_id_42,'(]',1,3) -
16977         INSTRB(anc_id_42,'(]',1,2) - 2)
16978 ,SUBSTRB(anc_id_42
16979        ,INSTRB(anc_id_42,'(]',1,3) + 2
16980        ,INSTRB(anc_id_42,'(]',1,4) -
16981         INSTRB(anc_id_42,'(]',1,3) - 2)
16982 ,SUBSTRB(anc_id_42
16983        ,INSTRB(anc_id_42,'(]',1,4) + 2
16984        ,INSTRB(anc_id_42,'(]',1,5) -
16985         INSTRB(anc_id_42,'(]',1,4) - 2)
16986 ,SUBSTRB(anc_id_42
16987        ,INSTRB(anc_id_42,'(]',1,5) + 2
16988        ,INSTRB(anc_id_42,'(]',1,6) -
16989         INSTRB(anc_id_42,'(]',1,5) - 2)
16990 ,SUBSTRB(anc_id_42
16991        ,INSTRB(anc_id_42,'(]',1,6) + 2
16992        ,INSTRB(anc_id_42,'(]',1,7) -
16993         INSTRB(anc_id_42,'(]',1,6) - 2)
16994 ,SUBSTRB(anc_id_42
16995        ,INSTRB(anc_id_42,'(]',1,7) + 2
16996        ,LENGTHB(anc_id_42))
16997 )
16998 
16999 WHEN anc_id_43 IS NOT NULL THEN
17000   INTO xla_ae_header_acs (
17001         ae_header_id , object_version_number
17002       , analytical_criterion_code
17003       , analytical_criterion_type_code
17004       , amb_context_code
17005       , ac1,ac2,ac3,ac4,ac5)
17006 VALUES (ae_header_id, C_OVN
17007 ,SUBSTRB(anc_id_43
17008        ,1
17009        ,INSTRB(anc_id_43,'(]',1,1) -1)
17010 ,SUBSTRB(anc_id_43
17011        ,INSTRB(anc_id_43,'(]',1,1) + 2
17012        ,INSTRB(anc_id_43,'(]',1,2) -
17013         INSTRB(anc_id_43,'(]',1,1) - 2)
17014 ,SUBSTRB(anc_id_43
17015        ,INSTRB(anc_id_43,'(]',1,2) + 2
17016        ,INSTRB(anc_id_43,'(]',1,3) -
17017         INSTRB(anc_id_43,'(]',1,2) - 2)
17018 ,SUBSTRB(anc_id_43
17019        ,INSTRB(anc_id_43,'(]',1,3) + 2
17020        ,INSTRB(anc_id_43,'(]',1,4) -
17021         INSTRB(anc_id_43,'(]',1,3) - 2)
17022 ,SUBSTRB(anc_id_43
17023        ,INSTRB(anc_id_43,'(]',1,4) + 2
17024        ,INSTRB(anc_id_43,'(]',1,5) -
17025         INSTRB(anc_id_43,'(]',1,4) - 2)
17026 ,SUBSTRB(anc_id_43
17027        ,INSTRB(anc_id_43,'(]',1,5) + 2
17028        ,INSTRB(anc_id_43,'(]',1,6) -
17029         INSTRB(anc_id_43,'(]',1,5) - 2)
17030 ,SUBSTRB(anc_id_43
17031        ,INSTRB(anc_id_43,'(]',1,6) + 2
17032        ,INSTRB(anc_id_43,'(]',1,7) -
17033         INSTRB(anc_id_43,'(]',1,6) - 2)
17034 ,SUBSTRB(anc_id_43
17035        ,INSTRB(anc_id_43,'(]',1,7) + 2
17036        ,LENGTHB(anc_id_43))
17037 )
17038 
17039 WHEN anc_id_44 IS NOT NULL THEN
17040   INTO xla_ae_header_acs (
17041         ae_header_id , object_version_number
17042       , analytical_criterion_code
17043       , analytical_criterion_type_code
17044       , amb_context_code
17045       , ac1,ac2,ac3,ac4,ac5)
17046 VALUES (ae_header_id, C_OVN
17047 ,SUBSTRB(anc_id_44
17048        ,1
17049        ,INSTRB(anc_id_44,'(]',1,1) -1)
17050 ,SUBSTRB(anc_id_44
17051        ,INSTRB(anc_id_44,'(]',1,1) + 2
17052        ,INSTRB(anc_id_44,'(]',1,2) -
17053         INSTRB(anc_id_44,'(]',1,1) - 2)
17054 ,SUBSTRB(anc_id_44
17055        ,INSTRB(anc_id_44,'(]',1,2) + 2
17056        ,INSTRB(anc_id_44,'(]',1,3) -
17057         INSTRB(anc_id_44,'(]',1,2) - 2)
17058 ,SUBSTRB(anc_id_44
17059        ,INSTRB(anc_id_44,'(]',1,3) + 2
17060        ,INSTRB(anc_id_44,'(]',1,4) -
17061         INSTRB(anc_id_44,'(]',1,3) - 2)
17062 ,SUBSTRB(anc_id_44
17063        ,INSTRB(anc_id_44,'(]',1,4) + 2
17064        ,INSTRB(anc_id_44,'(]',1,5) -
17065         INSTRB(anc_id_44,'(]',1,4) - 2)
17066 ,SUBSTRB(anc_id_44
17067        ,INSTRB(anc_id_44,'(]',1,5) + 2
17068        ,INSTRB(anc_id_44,'(]',1,6) -
17069         INSTRB(anc_id_44,'(]',1,5) - 2)
17070 ,SUBSTRB(anc_id_44
17071        ,INSTRB(anc_id_44,'(]',1,6) + 2
17072        ,INSTRB(anc_id_44,'(]',1,7) -
17073         INSTRB(anc_id_44,'(]',1,6) - 2)
17074 ,SUBSTRB(anc_id_44
17075        ,INSTRB(anc_id_44,'(]',1,7) + 2
17076        ,LENGTHB(anc_id_44))
17077 )
17078 
17079 WHEN anc_id_45 IS NOT NULL THEN
17080   INTO xla_ae_header_acs (
17081         ae_header_id , object_version_number
17082       , analytical_criterion_code
17083       , analytical_criterion_type_code
17084       , amb_context_code
17085       , ac1,ac2,ac3,ac4,ac5)
17086 VALUES (ae_header_id, C_OVN
17087 ,SUBSTRB(anc_id_45
17088        ,1
17089        ,INSTRB(anc_id_45,'(]',1,1) -1)
17090 ,SUBSTRB(anc_id_45
17091        ,INSTRB(anc_id_45,'(]',1,1) + 2
17092        ,INSTRB(anc_id_45,'(]',1,2) -
17093         INSTRB(anc_id_45,'(]',1,1) - 2)
17094 ,SUBSTRB(anc_id_45
17095        ,INSTRB(anc_id_45,'(]',1,2) + 2
17096        ,INSTRB(anc_id_45,'(]',1,3) -
17097         INSTRB(anc_id_45,'(]',1,2) - 2)
17098 ,SUBSTRB(anc_id_45
17099        ,INSTRB(anc_id_45,'(]',1,3) + 2
17100        ,INSTRB(anc_id_45,'(]',1,4) -
17101         INSTRB(anc_id_45,'(]',1,3) - 2)
17102 ,SUBSTRB(anc_id_45
17103        ,INSTRB(anc_id_45,'(]',1,4) + 2
17104        ,INSTRB(anc_id_45,'(]',1,5) -
17105         INSTRB(anc_id_45,'(]',1,4) - 2)
17106 ,SUBSTRB(anc_id_45
17107        ,INSTRB(anc_id_45,'(]',1,5) + 2
17108        ,INSTRB(anc_id_45,'(]',1,6) -
17109         INSTRB(anc_id_45,'(]',1,5) - 2)
17110 ,SUBSTRB(anc_id_45
17111        ,INSTRB(anc_id_45,'(]',1,6) + 2
17112        ,INSTRB(anc_id_45,'(]',1,7) -
17113         INSTRB(anc_id_45,'(]',1,6) - 2)
17114 ,SUBSTRB(anc_id_45
17115        ,INSTRB(anc_id_45,'(]',1,7) + 2
17116        ,LENGTHB(anc_id_45))
17117 )
17118 
17119 WHEN anc_id_46 IS NOT NULL THEN
17120   INTO xla_ae_header_acs (
17121         ae_header_id , object_version_number
17122       , analytical_criterion_code
17123       , analytical_criterion_type_code
17124       , amb_context_code
17125       , ac1,ac2,ac3,ac4,ac5)
17126 VALUES (ae_header_id, C_OVN
17127 ,SUBSTRB(anc_id_46
17128        ,1
17129        ,INSTRB(anc_id_46,'(]',1,1) -1)
17130 ,SUBSTRB(anc_id_46
17131        ,INSTRB(anc_id_46,'(]',1,1) + 2
17132        ,INSTRB(anc_id_46,'(]',1,2) -
17133         INSTRB(anc_id_46,'(]',1,1) - 2)
17134 ,SUBSTRB(anc_id_46
17135        ,INSTRB(anc_id_46,'(]',1,2) + 2
17136        ,INSTRB(anc_id_46,'(]',1,3) -
17137         INSTRB(anc_id_46,'(]',1,2) - 2)
17138 ,SUBSTRB(anc_id_46
17139        ,INSTRB(anc_id_46,'(]',1,3) + 2
17140        ,INSTRB(anc_id_46,'(]',1,4) -
17141         INSTRB(anc_id_46,'(]',1,3) - 2)
17142 ,SUBSTRB(anc_id_46
17143        ,INSTRB(anc_id_46,'(]',1,4) + 2
17144        ,INSTRB(anc_id_46,'(]',1,5) -
17145         INSTRB(anc_id_46,'(]',1,4) - 2)
17146 ,SUBSTRB(anc_id_46
17147        ,INSTRB(anc_id_46,'(]',1,5) + 2
17148        ,INSTRB(anc_id_46,'(]',1,6) -
17149         INSTRB(anc_id_46,'(]',1,5) - 2)
17150 ,SUBSTRB(anc_id_46
17151        ,INSTRB(anc_id_46,'(]',1,6) + 2
17152        ,INSTRB(anc_id_46,'(]',1,7) -
17153         INSTRB(anc_id_46,'(]',1,6) - 2)
17154 ,SUBSTRB(anc_id_46
17155        ,INSTRB(anc_id_46,'(]',1,7) + 2
17156        ,LENGTHB(anc_id_46))
17157 )
17158 
17159 WHEN anc_id_47 IS NOT NULL THEN
17160   INTO xla_ae_header_acs (
17161         ae_header_id , object_version_number
17162       , analytical_criterion_code
17163       , analytical_criterion_type_code
17164       , amb_context_code
17165       , ac1,ac2,ac3,ac4,ac5)
17166 VALUES (ae_header_id, C_OVN
17167 ,SUBSTRB(anc_id_47
17168        ,1
17169        ,INSTRB(anc_id_47,'(]',1,1) -1)
17170 ,SUBSTRB(anc_id_47
17171        ,INSTRB(anc_id_47,'(]',1,1) + 2
17172        ,INSTRB(anc_id_47,'(]',1,2) -
17173         INSTRB(anc_id_47,'(]',1,1) - 2)
17174 ,SUBSTRB(anc_id_47
17175        ,INSTRB(anc_id_47,'(]',1,2) + 2
17176        ,INSTRB(anc_id_47,'(]',1,3) -
17177         INSTRB(anc_id_47,'(]',1,2) - 2)
17178 ,SUBSTRB(anc_id_47
17179        ,INSTRB(anc_id_47,'(]',1,3) + 2
17180        ,INSTRB(anc_id_47,'(]',1,4) -
17181         INSTRB(anc_id_47,'(]',1,3) - 2)
17182 ,SUBSTRB(anc_id_47
17183        ,INSTRB(anc_id_47,'(]',1,4) + 2
17184        ,INSTRB(anc_id_47,'(]',1,5) -
17185         INSTRB(anc_id_47,'(]',1,4) - 2)
17186 ,SUBSTRB(anc_id_47
17187        ,INSTRB(anc_id_47,'(]',1,5) + 2
17188        ,INSTRB(anc_id_47,'(]',1,6) -
17189         INSTRB(anc_id_47,'(]',1,5) - 2)
17190 ,SUBSTRB(anc_id_47
17191        ,INSTRB(anc_id_47,'(]',1,6) + 2
17192        ,INSTRB(anc_id_47,'(]',1,7) -
17193         INSTRB(anc_id_47,'(]',1,6) - 2)
17194 ,SUBSTRB(anc_id_47
17195        ,INSTRB(anc_id_47,'(]',1,7) + 2
17196        ,LENGTHB(anc_id_47))
17197 )
17198 
17199 WHEN anc_id_48 IS NOT NULL THEN
17200   INTO xla_ae_header_acs (
17201         ae_header_id , object_version_number
17202       , analytical_criterion_code
17203       , analytical_criterion_type_code
17204       , amb_context_code
17205       , ac1,ac2,ac3,ac4,ac5)
17206 VALUES (ae_header_id, C_OVN
17207 ,SUBSTRB(anc_id_48
17208        ,1
17209        ,INSTRB(anc_id_48,'(]',1,1) -1)
17210 ,SUBSTRB(anc_id_48
17211        ,INSTRB(anc_id_48,'(]',1,1) + 2
17212        ,INSTRB(anc_id_48,'(]',1,2) -
17213         INSTRB(anc_id_48,'(]',1,1) - 2)
17214 ,SUBSTRB(anc_id_48
17215        ,INSTRB(anc_id_48,'(]',1,2) + 2
17216        ,INSTRB(anc_id_48,'(]',1,3) -
17217         INSTRB(anc_id_48,'(]',1,2) - 2)
17218 ,SUBSTRB(anc_id_48
17219        ,INSTRB(anc_id_48,'(]',1,3) + 2
17220        ,INSTRB(anc_id_48,'(]',1,4) -
17221         INSTRB(anc_id_48,'(]',1,3) - 2)
17222 ,SUBSTRB(anc_id_48
17223        ,INSTRB(anc_id_48,'(]',1,4) + 2
17224        ,INSTRB(anc_id_48,'(]',1,5) -
17225         INSTRB(anc_id_48,'(]',1,4) - 2)
17226 ,SUBSTRB(anc_id_48
17227        ,INSTRB(anc_id_48,'(]',1,5) + 2
17228        ,INSTRB(anc_id_48,'(]',1,6) -
17229         INSTRB(anc_id_48,'(]',1,5) - 2)
17230 ,SUBSTRB(anc_id_48
17231        ,INSTRB(anc_id_48,'(]',1,6) + 2
17232        ,INSTRB(anc_id_48,'(]',1,7) -
17233         INSTRB(anc_id_48,'(]',1,6) - 2)
17234 ,SUBSTRB(anc_id_48
17235        ,INSTRB(anc_id_48,'(]',1,7) + 2
17236        ,LENGTHB(anc_id_48))
17237 )
17238 
17239 WHEN anc_id_49 IS NOT NULL THEN
17240   INTO xla_ae_header_acs (
17241         ae_header_id , object_version_number
17242       , analytical_criterion_code
17243       , analytical_criterion_type_code
17244       , amb_context_code
17245       , ac1,ac2,ac3,ac4,ac5)
17246 VALUES (ae_header_id, C_OVN
17247 ,SUBSTRB(anc_id_49
17248        ,1
17249        ,INSTRB(anc_id_49,'(]',1,1) -1)
17250 ,SUBSTRB(anc_id_49
17251        ,INSTRB(anc_id_49,'(]',1,1) + 2
17252        ,INSTRB(anc_id_49,'(]',1,2) -
17253         INSTRB(anc_id_49,'(]',1,1) - 2)
17254 ,SUBSTRB(anc_id_49
17255        ,INSTRB(anc_id_49,'(]',1,2) + 2
17256        ,INSTRB(anc_id_49,'(]',1,3) -
17257         INSTRB(anc_id_49,'(]',1,2) - 2)
17258 ,SUBSTRB(anc_id_49
17259        ,INSTRB(anc_id_49,'(]',1,3) + 2
17260        ,INSTRB(anc_id_49,'(]',1,4) -
17261         INSTRB(anc_id_49,'(]',1,3) - 2)
17262 ,SUBSTRB(anc_id_49
17263        ,INSTRB(anc_id_49,'(]',1,4) + 2
17264        ,INSTRB(anc_id_49,'(]',1,5) -
17265         INSTRB(anc_id_49,'(]',1,4) - 2)
17266 ,SUBSTRB(anc_id_49
17267        ,INSTRB(anc_id_49,'(]',1,5) + 2
17268        ,INSTRB(anc_id_49,'(]',1,6) -
17269         INSTRB(anc_id_49,'(]',1,5) - 2)
17270 ,SUBSTRB(anc_id_49
17271        ,INSTRB(anc_id_49,'(]',1,6) + 2
17272        ,INSTRB(anc_id_49,'(]',1,7) -
17273         INSTRB(anc_id_49,'(]',1,6) - 2)
17274 ,SUBSTRB(anc_id_49
17275        ,INSTRB(anc_id_49,'(]',1,7) + 2
17276        ,LENGTHB(anc_id_49))
17277 )
17278 
17279 WHEN anc_id_50 IS NOT NULL THEN
17280   INTO xla_ae_header_acs (
17281         ae_header_id , object_version_number
17282       , analytical_criterion_code
17283       , analytical_criterion_type_code
17284       , amb_context_code
17285       , ac1,ac2,ac3,ac4,ac5)
17286 VALUES (ae_header_id, C_OVN
17287 ,SUBSTRB(anc_id_50
17288        ,1
17289        ,INSTRB(anc_id_50,'(]',1,1) -1)
17290 ,SUBSTRB(anc_id_50
17291        ,INSTRB(anc_id_50,'(]',1,1) + 2
17292        ,INSTRB(anc_id_50,'(]',1,2) -
17293         INSTRB(anc_id_50,'(]',1,1) - 2)
17294 ,SUBSTRB(anc_id_50
17295        ,INSTRB(anc_id_50,'(]',1,2) + 2
17296        ,INSTRB(anc_id_50,'(]',1,3) -
17297         INSTRB(anc_id_50,'(]',1,2) - 2)
17298 ,SUBSTRB(anc_id_50
17299        ,INSTRB(anc_id_50,'(]',1,3) + 2
17300        ,INSTRB(anc_id_50,'(]',1,4) -
17301         INSTRB(anc_id_50,'(]',1,3) - 2)
17302 ,SUBSTRB(anc_id_50
17303        ,INSTRB(anc_id_50,'(]',1,4) + 2
17304        ,INSTRB(anc_id_50,'(]',1,5) -
17305         INSTRB(anc_id_50,'(]',1,4) - 2)
17306 ,SUBSTRB(anc_id_50
17307        ,INSTRB(anc_id_50,'(]',1,5) + 2
17308        ,INSTRB(anc_id_50,'(]',1,6) -
17309         INSTRB(anc_id_50,'(]',1,5) - 2)
17310 ,SUBSTRB(anc_id_50
17311        ,INSTRB(anc_id_50,'(]',1,6) + 2
17312        ,INSTRB(anc_id_50,'(]',1,7) -
17313         INSTRB(anc_id_50,'(]',1,6) - 2)
17314 ,SUBSTRB(anc_id_50
17315        ,INSTRB(anc_id_50,'(]',1,7) + 2
17316        ,LENGTHB(anc_id_50))
17317 )
17318 
17319 WHEN anc_id_51 IS NOT NULL THEN
17320   INTO xla_ae_header_acs (
17321         ae_header_id , object_version_number
17322       , analytical_criterion_code
17323       , analytical_criterion_type_code
17324       , amb_context_code
17325       , ac1,ac2,ac3,ac4,ac5)
17326 VALUES (ae_header_id, C_OVN
17327 ,SUBSTRB(anc_id_51
17328        ,1
17329        ,INSTRB(anc_id_51,'(]',1,1) -1)
17330 ,SUBSTRB(anc_id_51
17331        ,INSTRB(anc_id_51,'(]',1,1) + 2
17332        ,INSTRB(anc_id_51,'(]',1,2) -
17333         INSTRB(anc_id_51,'(]',1,1) - 2)
17334 ,SUBSTRB(anc_id_51
17335        ,INSTRB(anc_id_51,'(]',1,2) + 2
17336        ,INSTRB(anc_id_51,'(]',1,3) -
17337         INSTRB(anc_id_51,'(]',1,2) - 2)
17338 ,SUBSTRB(anc_id_51
17339        ,INSTRB(anc_id_51,'(]',1,3) + 2
17340        ,INSTRB(anc_id_51,'(]',1,4) -
17341         INSTRB(anc_id_51,'(]',1,3) - 2)
17342 ,SUBSTRB(anc_id_51
17343        ,INSTRB(anc_id_51,'(]',1,4) + 2
17344        ,INSTRB(anc_id_51,'(]',1,5) -
17345         INSTRB(anc_id_51,'(]',1,4) - 2)
17346 ,SUBSTRB(anc_id_51
17347        ,INSTRB(anc_id_51,'(]',1,5) + 2
17348        ,INSTRB(anc_id_51,'(]',1,6) -
17349         INSTRB(anc_id_51,'(]',1,5) - 2)
17350 ,SUBSTRB(anc_id_51
17351        ,INSTRB(anc_id_51,'(]',1,6) + 2
17352        ,INSTRB(anc_id_51,'(]',1,7) -
17353         INSTRB(anc_id_51,'(]',1,6) - 2)
17354 ,SUBSTRB(anc_id_51
17355        ,INSTRB(anc_id_51,'(]',1,7) + 2
17356        ,LENGTHB(anc_id_51))
17357 )
17358 
17359 WHEN anc_id_52 IS NOT NULL THEN
17360   INTO xla_ae_header_acs (
17361         ae_header_id , object_version_number
17362       , analytical_criterion_code
17363       , analytical_criterion_type_code
17364       , amb_context_code
17365       , ac1,ac2,ac3,ac4,ac5)
17366 VALUES (ae_header_id, C_OVN
17367 ,SUBSTRB(anc_id_52
17368        ,1
17369        ,INSTRB(anc_id_52,'(]',1,1) -1)
17370 ,SUBSTRB(anc_id_52
17371        ,INSTRB(anc_id_52,'(]',1,1) + 2
17372        ,INSTRB(anc_id_52,'(]',1,2) -
17373         INSTRB(anc_id_52,'(]',1,1) - 2)
17374 ,SUBSTRB(anc_id_52
17375        ,INSTRB(anc_id_52,'(]',1,2) + 2
17376        ,INSTRB(anc_id_52,'(]',1,3) -
17377         INSTRB(anc_id_52,'(]',1,2) - 2)
17378 ,SUBSTRB(anc_id_52
17379        ,INSTRB(anc_id_52,'(]',1,3) + 2
17380        ,INSTRB(anc_id_52,'(]',1,4) -
17381         INSTRB(anc_id_52,'(]',1,3) - 2)
17382 ,SUBSTRB(anc_id_52
17383        ,INSTRB(anc_id_52,'(]',1,4) + 2
17384        ,INSTRB(anc_id_52,'(]',1,5) -
17385         INSTRB(anc_id_52,'(]',1,4) - 2)
17386 ,SUBSTRB(anc_id_52
17387        ,INSTRB(anc_id_52,'(]',1,5) + 2
17388        ,INSTRB(anc_id_52,'(]',1,6) -
17389         INSTRB(anc_id_52,'(]',1,5) - 2)
17390 ,SUBSTRB(anc_id_52
17391        ,INSTRB(anc_id_52,'(]',1,6) + 2
17392        ,INSTRB(anc_id_52,'(]',1,7) -
17393         INSTRB(anc_id_52,'(]',1,6) - 2)
17394 ,SUBSTRB(anc_id_52
17395        ,INSTRB(anc_id_52,'(]',1,7) + 2
17396        ,LENGTHB(anc_id_52))
17397 )
17398 
17399 WHEN anc_id_53 IS NOT NULL THEN
17400   INTO xla_ae_header_acs (
17401         ae_header_id , object_version_number
17402       , analytical_criterion_code
17403       , analytical_criterion_type_code
17404       , amb_context_code
17405       , ac1,ac2,ac3,ac4,ac5)
17406 VALUES (ae_header_id, C_OVN
17407 ,SUBSTRB(anc_id_53
17408        ,1
17409        ,INSTRB(anc_id_53,'(]',1,1) -1)
17410 ,SUBSTRB(anc_id_53
17411        ,INSTRB(anc_id_53,'(]',1,1) + 2
17412        ,INSTRB(anc_id_53,'(]',1,2) -
17413         INSTRB(anc_id_53,'(]',1,1) - 2)
17414 ,SUBSTRB(anc_id_53
17415        ,INSTRB(anc_id_53,'(]',1,2) + 2
17416        ,INSTRB(anc_id_53,'(]',1,3) -
17417         INSTRB(anc_id_53,'(]',1,2) - 2)
17418 ,SUBSTRB(anc_id_53
17419        ,INSTRB(anc_id_53,'(]',1,3) + 2
17420        ,INSTRB(anc_id_53,'(]',1,4) -
17421         INSTRB(anc_id_53,'(]',1,3) - 2)
17422 ,SUBSTRB(anc_id_53
17423        ,INSTRB(anc_id_53,'(]',1,4) + 2
17424        ,INSTRB(anc_id_53,'(]',1,5) -
17425         INSTRB(anc_id_53,'(]',1,4) - 2)
17426 ,SUBSTRB(anc_id_53
17427        ,INSTRB(anc_id_53,'(]',1,5) + 2
17428        ,INSTRB(anc_id_53,'(]',1,6) -
17429         INSTRB(anc_id_53,'(]',1,5) - 2)
17430 ,SUBSTRB(anc_id_53
17431        ,INSTRB(anc_id_53,'(]',1,6) + 2
17432        ,INSTRB(anc_id_53,'(]',1,7) -
17433         INSTRB(anc_id_53,'(]',1,6) - 2)
17434 ,SUBSTRB(anc_id_53
17435        ,INSTRB(anc_id_53,'(]',1,7) + 2
17436        ,LENGTHB(anc_id_53))
17437 )
17438 
17439 WHEN anc_id_54 IS NOT NULL THEN
17440   INTO xla_ae_header_acs (
17441         ae_header_id , object_version_number
17442       , analytical_criterion_code
17443       , analytical_criterion_type_code
17444       , amb_context_code
17445       , ac1,ac2,ac3,ac4,ac5)
17446 VALUES (ae_header_id, C_OVN
17447 ,SUBSTRB(anc_id_54
17448        ,1
17449        ,INSTRB(anc_id_54,'(]',1,1) -1)
17450 ,SUBSTRB(anc_id_54
17451        ,INSTRB(anc_id_54,'(]',1,1) + 2
17452        ,INSTRB(anc_id_54,'(]',1,2) -
17453         INSTRB(anc_id_54,'(]',1,1) - 2)
17454 ,SUBSTRB(anc_id_54
17455        ,INSTRB(anc_id_54,'(]',1,2) + 2
17456        ,INSTRB(anc_id_54,'(]',1,3) -
17457         INSTRB(anc_id_54,'(]',1,2) - 2)
17458 ,SUBSTRB(anc_id_54
17459        ,INSTRB(anc_id_54,'(]',1,3) + 2
17460        ,INSTRB(anc_id_54,'(]',1,4) -
17461         INSTRB(anc_id_54,'(]',1,3) - 2)
17462 ,SUBSTRB(anc_id_54
17463        ,INSTRB(anc_id_54,'(]',1,4) + 2
17464        ,INSTRB(anc_id_54,'(]',1,5) -
17465         INSTRB(anc_id_54,'(]',1,4) - 2)
17466 ,SUBSTRB(anc_id_54
17467        ,INSTRB(anc_id_54,'(]',1,5) + 2
17468        ,INSTRB(anc_id_54,'(]',1,6) -
17469         INSTRB(anc_id_54,'(]',1,5) - 2)
17470 ,SUBSTRB(anc_id_54
17471        ,INSTRB(anc_id_54,'(]',1,6) + 2
17472        ,INSTRB(anc_id_54,'(]',1,7) -
17473         INSTRB(anc_id_54,'(]',1,6) - 2)
17474 ,SUBSTRB(anc_id_54
17475        ,INSTRB(anc_id_54,'(]',1,7) + 2
17476        ,LENGTHB(anc_id_54))
17477 )
17478 
17479 WHEN anc_id_55 IS NOT NULL THEN
17480   INTO xla_ae_header_acs (
17481         ae_header_id , object_version_number
17482       , analytical_criterion_code
17483       , analytical_criterion_type_code
17484       , amb_context_code
17485       , ac1,ac2,ac3,ac4,ac5)
17486 VALUES (ae_header_id, C_OVN
17487 ,SUBSTRB(anc_id_55
17488        ,1
17489        ,INSTRB(anc_id_55,'(]',1,1) -1)
17490 ,SUBSTRB(anc_id_55
17491        ,INSTRB(anc_id_55,'(]',1,1) + 2
17492        ,INSTRB(anc_id_55,'(]',1,2) -
17493         INSTRB(anc_id_55,'(]',1,1) - 2)
17494 ,SUBSTRB(anc_id_55
17495        ,INSTRB(anc_id_55,'(]',1,2) + 2
17496        ,INSTRB(anc_id_55,'(]',1,3) -
17497         INSTRB(anc_id_55,'(]',1,2) - 2)
17498 ,SUBSTRB(anc_id_55
17499        ,INSTRB(anc_id_55,'(]',1,3) + 2
17500        ,INSTRB(anc_id_55,'(]',1,4) -
17501         INSTRB(anc_id_55,'(]',1,3) - 2)
17502 ,SUBSTRB(anc_id_55
17503        ,INSTRB(anc_id_55,'(]',1,4) + 2
17504        ,INSTRB(anc_id_55,'(]',1,5) -
17505         INSTRB(anc_id_55,'(]',1,4) - 2)
17506 ,SUBSTRB(anc_id_55
17507        ,INSTRB(anc_id_55,'(]',1,5) + 2
17508        ,INSTRB(anc_id_55,'(]',1,6) -
17509         INSTRB(anc_id_55,'(]',1,5) - 2)
17510 ,SUBSTRB(anc_id_55
17511        ,INSTRB(anc_id_55,'(]',1,6) + 2
17512        ,INSTRB(anc_id_55,'(]',1,7) -
17513         INSTRB(anc_id_55,'(]',1,6) - 2)
17514 ,SUBSTRB(anc_id_55
17515        ,INSTRB(anc_id_55,'(]',1,7) + 2
17516        ,LENGTHB(anc_id_55))
17517 )
17518 
17519 WHEN anc_id_56 IS NOT NULL THEN
17520   INTO xla_ae_header_acs (
17521         ae_header_id , object_version_number
17522       , analytical_criterion_code
17523       , analytical_criterion_type_code
17524       , amb_context_code
17525       , ac1,ac2,ac3,ac4,ac5)
17526 VALUES (ae_header_id, C_OVN
17527 ,SUBSTRB(anc_id_56
17528        ,1
17529        ,INSTRB(anc_id_56,'(]',1,1) -1)
17530 ,SUBSTRB(anc_id_56
17531        ,INSTRB(anc_id_56,'(]',1,1) + 2
17532        ,INSTRB(anc_id_56,'(]',1,2) -
17533         INSTRB(anc_id_56,'(]',1,1) - 2)
17534 ,SUBSTRB(anc_id_56
17535        ,INSTRB(anc_id_56,'(]',1,2) + 2
17536        ,INSTRB(anc_id_56,'(]',1,3) -
17537         INSTRB(anc_id_56,'(]',1,2) - 2)
17538 ,SUBSTRB(anc_id_56
17539        ,INSTRB(anc_id_56,'(]',1,3) + 2
17540        ,INSTRB(anc_id_56,'(]',1,4) -
17541         INSTRB(anc_id_56,'(]',1,3) - 2)
17542 ,SUBSTRB(anc_id_56
17543        ,INSTRB(anc_id_56,'(]',1,4) + 2
17544        ,INSTRB(anc_id_56,'(]',1,5) -
17545         INSTRB(anc_id_56,'(]',1,4) - 2)
17546 ,SUBSTRB(anc_id_56
17547        ,INSTRB(anc_id_56,'(]',1,5) + 2
17548        ,INSTRB(anc_id_56,'(]',1,6) -
17549         INSTRB(anc_id_56,'(]',1,5) - 2)
17550 ,SUBSTRB(anc_id_56
17551        ,INSTRB(anc_id_56,'(]',1,6) + 2
17552        ,INSTRB(anc_id_56,'(]',1,7) -
17553         INSTRB(anc_id_56,'(]',1,6) - 2)
17554 ,SUBSTRB(anc_id_56
17555        ,INSTRB(anc_id_56,'(]',1,7) + 2
17556        ,LENGTHB(anc_id_56))
17557 )
17558 
17559 WHEN anc_id_57 IS NOT NULL THEN
17560   INTO xla_ae_header_acs (
17561         ae_header_id , object_version_number
17562       , analytical_criterion_code
17563       , analytical_criterion_type_code
17564       , amb_context_code
17565       , ac1,ac2,ac3,ac4,ac5)
17566 VALUES (ae_header_id, C_OVN
17567 ,SUBSTRB(anc_id_57
17568        ,1
17569        ,INSTRB(anc_id_57,'(]',1,1) -1)
17570 ,SUBSTRB(anc_id_57
17571        ,INSTRB(anc_id_57,'(]',1,1) + 2
17572        ,INSTRB(anc_id_57,'(]',1,2) -
17573         INSTRB(anc_id_57,'(]',1,1) - 2)
17574 ,SUBSTRB(anc_id_57
17575        ,INSTRB(anc_id_57,'(]',1,2) + 2
17576        ,INSTRB(anc_id_57,'(]',1,3) -
17577         INSTRB(anc_id_57,'(]',1,2) - 2)
17578 ,SUBSTRB(anc_id_57
17579        ,INSTRB(anc_id_57,'(]',1,3) + 2
17580        ,INSTRB(anc_id_57,'(]',1,4) -
17581         INSTRB(anc_id_57,'(]',1,3) - 2)
17582 ,SUBSTRB(anc_id_57
17583        ,INSTRB(anc_id_57,'(]',1,4) + 2
17584        ,INSTRB(anc_id_57,'(]',1,5) -
17585         INSTRB(anc_id_57,'(]',1,4) - 2)
17586 ,SUBSTRB(anc_id_57
17587        ,INSTRB(anc_id_57,'(]',1,5) + 2
17588        ,INSTRB(anc_id_57,'(]',1,6) -
17589         INSTRB(anc_id_57,'(]',1,5) - 2)
17590 ,SUBSTRB(anc_id_57
17591        ,INSTRB(anc_id_57,'(]',1,6) + 2
17592        ,INSTRB(anc_id_57,'(]',1,7) -
17593         INSTRB(anc_id_57,'(]',1,6) - 2)
17594 ,SUBSTRB(anc_id_57
17595        ,INSTRB(anc_id_57,'(]',1,7) + 2
17596        ,LENGTHB(anc_id_57))
17597 )
17598 
17599 WHEN anc_id_58 IS NOT NULL THEN
17600   INTO xla_ae_header_acs (
17601         ae_header_id , object_version_number
17602       , analytical_criterion_code
17603       , analytical_criterion_type_code
17604       , amb_context_code
17605       , ac1,ac2,ac3,ac4,ac5)
17606 VALUES (ae_header_id, C_OVN
17607 ,SUBSTRB(anc_id_58
17608        ,1
17609        ,INSTRB(anc_id_58,'(]',1,1) -1)
17610 ,SUBSTRB(anc_id_58
17611        ,INSTRB(anc_id_58,'(]',1,1) + 2
17612        ,INSTRB(anc_id_58,'(]',1,2) -
17613         INSTRB(anc_id_58,'(]',1,1) - 2)
17614 ,SUBSTRB(anc_id_58
17615        ,INSTRB(anc_id_58,'(]',1,2) + 2
17616        ,INSTRB(anc_id_58,'(]',1,3) -
17617         INSTRB(anc_id_58,'(]',1,2) - 2)
17618 ,SUBSTRB(anc_id_58
17619        ,INSTRB(anc_id_58,'(]',1,3) + 2
17620        ,INSTRB(anc_id_58,'(]',1,4) -
17621         INSTRB(anc_id_58,'(]',1,3) - 2)
17622 ,SUBSTRB(anc_id_58
17623        ,INSTRB(anc_id_58,'(]',1,4) + 2
17624        ,INSTRB(anc_id_58,'(]',1,5) -
17625         INSTRB(anc_id_58,'(]',1,4) - 2)
17626 ,SUBSTRB(anc_id_58
17627        ,INSTRB(anc_id_58,'(]',1,5) + 2
17628        ,INSTRB(anc_id_58,'(]',1,6) -
17629         INSTRB(anc_id_58,'(]',1,5) - 2)
17630 ,SUBSTRB(anc_id_58
17631        ,INSTRB(anc_id_58,'(]',1,6) + 2
17632        ,INSTRB(anc_id_58,'(]',1,7) -
17633         INSTRB(anc_id_58,'(]',1,6) - 2)
17634 ,SUBSTRB(anc_id_58
17635        ,INSTRB(anc_id_58,'(]',1,7) + 2
17636        ,LENGTHB(anc_id_58))
17637 )
17638 
17639 WHEN anc_id_59 IS NOT NULL THEN
17640   INTO xla_ae_header_acs (
17641         ae_header_id , object_version_number
17642       , analytical_criterion_code
17643       , analytical_criterion_type_code
17644       , amb_context_code
17645       , ac1,ac2,ac3,ac4,ac5)
17646 VALUES (ae_header_id, C_OVN
17647 ,SUBSTRB(anc_id_59
17648        ,1
17649        ,INSTRB(anc_id_59,'(]',1,1) -1)
17650 ,SUBSTRB(anc_id_59
17651        ,INSTRB(anc_id_59,'(]',1,1) + 2
17652        ,INSTRB(anc_id_59,'(]',1,2) -
17653         INSTRB(anc_id_59,'(]',1,1) - 2)
17654 ,SUBSTRB(anc_id_59
17655        ,INSTRB(anc_id_59,'(]',1,2) + 2
17656        ,INSTRB(anc_id_59,'(]',1,3) -
17657         INSTRB(anc_id_59,'(]',1,2) - 2)
17658 ,SUBSTRB(anc_id_59
17659        ,INSTRB(anc_id_59,'(]',1,3) + 2
17660        ,INSTRB(anc_id_59,'(]',1,4) -
17661         INSTRB(anc_id_59,'(]',1,3) - 2)
17662 ,SUBSTRB(anc_id_59
17663        ,INSTRB(anc_id_59,'(]',1,4) + 2
17664        ,INSTRB(anc_id_59,'(]',1,5) -
17665         INSTRB(anc_id_59,'(]',1,4) - 2)
17666 ,SUBSTRB(anc_id_59
17667        ,INSTRB(anc_id_59,'(]',1,5) + 2
17668        ,INSTRB(anc_id_59,'(]',1,6) -
17669         INSTRB(anc_id_59,'(]',1,5) - 2)
17670 ,SUBSTRB(anc_id_59
17671        ,INSTRB(anc_id_59,'(]',1,6) + 2
17672        ,INSTRB(anc_id_59,'(]',1,7) -
17673         INSTRB(anc_id_59,'(]',1,6) - 2)
17674 ,SUBSTRB(anc_id_59
17675        ,INSTRB(anc_id_59,'(]',1,7) + 2
17676        ,LENGTHB(anc_id_59))
17677 )
17678 
17679 WHEN anc_id_60 IS NOT NULL THEN
17680   INTO xla_ae_header_acs (
17681         ae_header_id , object_version_number
17682       , analytical_criterion_code
17683       , analytical_criterion_type_code
17684       , amb_context_code
17685       , ac1,ac2,ac3,ac4,ac5)
17686 VALUES (ae_header_id, C_OVN
17687 ,SUBSTRB(anc_id_60
17688        ,1
17689        ,INSTRB(anc_id_60,'(]',1,1) -1)
17690 ,SUBSTRB(anc_id_60
17691        ,INSTRB(anc_id_60,'(]',1,1) + 2
17692        ,INSTRB(anc_id_60,'(]',1,2) -
17693         INSTRB(anc_id_60,'(]',1,1) - 2)
17694 ,SUBSTRB(anc_id_60
17695        ,INSTRB(anc_id_60,'(]',1,2) + 2
17696        ,INSTRB(anc_id_60,'(]',1,3) -
17697         INSTRB(anc_id_60,'(]',1,2) - 2)
17698 ,SUBSTRB(anc_id_60
17699        ,INSTRB(anc_id_60,'(]',1,3) + 2
17700        ,INSTRB(anc_id_60,'(]',1,4) -
17701         INSTRB(anc_id_60,'(]',1,3) - 2)
17702 ,SUBSTRB(anc_id_60
17703        ,INSTRB(anc_id_60,'(]',1,4) + 2
17704        ,INSTRB(anc_id_60,'(]',1,5) -
17705         INSTRB(anc_id_60,'(]',1,4) - 2)
17706 ,SUBSTRB(anc_id_60
17707        ,INSTRB(anc_id_60,'(]',1,5) + 2
17708        ,INSTRB(anc_id_60,'(]',1,6) -
17709         INSTRB(anc_id_60,'(]',1,5) - 2)
17710 ,SUBSTRB(anc_id_60
17711        ,INSTRB(anc_id_60,'(]',1,6) + 2
17712        ,INSTRB(anc_id_60,'(]',1,7) -
17713         INSTRB(anc_id_60,'(]',1,6) - 2)
17714 ,SUBSTRB(anc_id_60
17715        ,INSTRB(anc_id_60,'(]',1,7) + 2
17716        ,LENGTHB(anc_id_60))
17717 )
17718 
17719 WHEN anc_id_61 IS NOT NULL THEN
17720   INTO xla_ae_header_acs (
17721         ae_header_id , object_version_number
17722       , analytical_criterion_code
17723       , analytical_criterion_type_code
17724       , amb_context_code
17725       , ac1,ac2,ac3,ac4,ac5)
17726 VALUES (ae_header_id, C_OVN
17727 ,SUBSTRB(anc_id_61
17728        ,1
17729        ,INSTRB(anc_id_61,'(]',1,1) -1)
17730 ,SUBSTRB(anc_id_61
17731        ,INSTRB(anc_id_61,'(]',1,1) + 2
17732        ,INSTRB(anc_id_61,'(]',1,2) -
17733         INSTRB(anc_id_61,'(]',1,1) - 2)
17734 ,SUBSTRB(anc_id_61
17735        ,INSTRB(anc_id_61,'(]',1,2) + 2
17736        ,INSTRB(anc_id_61,'(]',1,3) -
17737         INSTRB(anc_id_61,'(]',1,2) - 2)
17738 ,SUBSTRB(anc_id_61
17739        ,INSTRB(anc_id_61,'(]',1,3) + 2
17740        ,INSTRB(anc_id_61,'(]',1,4) -
17741         INSTRB(anc_id_61,'(]',1,3) - 2)
17742 ,SUBSTRB(anc_id_61
17743        ,INSTRB(anc_id_61,'(]',1,4) + 2
17744        ,INSTRB(anc_id_61,'(]',1,5) -
17745         INSTRB(anc_id_61,'(]',1,4) - 2)
17746 ,SUBSTRB(anc_id_61
17747        ,INSTRB(anc_id_61,'(]',1,5) + 2
17748        ,INSTRB(anc_id_61,'(]',1,6) -
17749         INSTRB(anc_id_61,'(]',1,5) - 2)
17750 ,SUBSTRB(anc_id_61
17751        ,INSTRB(anc_id_61,'(]',1,6) + 2
17752        ,INSTRB(anc_id_61,'(]',1,7) -
17753         INSTRB(anc_id_61,'(]',1,6) - 2)
17754 ,SUBSTRB(anc_id_61
17755        ,INSTRB(anc_id_61,'(]',1,7) + 2
17756        ,LENGTHB(anc_id_61))
17757 )
17758 
17759 WHEN anc_id_62 IS NOT NULL THEN
17760   INTO xla_ae_header_acs (
17761         ae_header_id , object_version_number
17762       , analytical_criterion_code
17763       , analytical_criterion_type_code
17764       , amb_context_code
17765       , ac1,ac2,ac3,ac4,ac5)
17766 VALUES (ae_header_id, C_OVN
17767 ,SUBSTRB(anc_id_62
17768        ,1
17769        ,INSTRB(anc_id_62,'(]',1,1) -1)
17770 ,SUBSTRB(anc_id_62
17771        ,INSTRB(anc_id_62,'(]',1,1) + 2
17772        ,INSTRB(anc_id_62,'(]',1,2) -
17773         INSTRB(anc_id_62,'(]',1,1) - 2)
17774 ,SUBSTRB(anc_id_62
17775        ,INSTRB(anc_id_62,'(]',1,2) + 2
17776        ,INSTRB(anc_id_62,'(]',1,3) -
17777         INSTRB(anc_id_62,'(]',1,2) - 2)
17778 ,SUBSTRB(anc_id_62
17779        ,INSTRB(anc_id_62,'(]',1,3) + 2
17780        ,INSTRB(anc_id_62,'(]',1,4) -
17781         INSTRB(anc_id_62,'(]',1,3) - 2)
17782 ,SUBSTRB(anc_id_62
17783        ,INSTRB(anc_id_62,'(]',1,4) + 2
17784        ,INSTRB(anc_id_62,'(]',1,5) -
17785         INSTRB(anc_id_62,'(]',1,4) - 2)
17786 ,SUBSTRB(anc_id_62
17787        ,INSTRB(anc_id_62,'(]',1,5) + 2
17788        ,INSTRB(anc_id_62,'(]',1,6) -
17789         INSTRB(anc_id_62,'(]',1,5) - 2)
17790 ,SUBSTRB(anc_id_62
17791        ,INSTRB(anc_id_62,'(]',1,6) + 2
17792        ,INSTRB(anc_id_62,'(]',1,7) -
17793         INSTRB(anc_id_62,'(]',1,6) - 2)
17794 ,SUBSTRB(anc_id_62
17795        ,INSTRB(anc_id_62,'(]',1,7) + 2
17796        ,LENGTHB(anc_id_62))
17797 )
17798 
17799 WHEN anc_id_63 IS NOT NULL THEN
17800   INTO xla_ae_header_acs (
17801         ae_header_id , object_version_number
17802       , analytical_criterion_code
17803       , analytical_criterion_type_code
17804       , amb_context_code
17805       , ac1,ac2,ac3,ac4,ac5)
17806 VALUES (ae_header_id, C_OVN
17807 ,SUBSTRB(anc_id_63
17808        ,1
17809        ,INSTRB(anc_id_63,'(]',1,1) -1)
17810 ,SUBSTRB(anc_id_63
17811        ,INSTRB(anc_id_63,'(]',1,1) + 2
17812        ,INSTRB(anc_id_63,'(]',1,2) -
17813         INSTRB(anc_id_63,'(]',1,1) - 2)
17814 ,SUBSTRB(anc_id_63
17815        ,INSTRB(anc_id_63,'(]',1,2) + 2
17816        ,INSTRB(anc_id_63,'(]',1,3) -
17817         INSTRB(anc_id_63,'(]',1,2) - 2)
17818 ,SUBSTRB(anc_id_63
17819        ,INSTRB(anc_id_63,'(]',1,3) + 2
17820        ,INSTRB(anc_id_63,'(]',1,4) -
17821         INSTRB(anc_id_63,'(]',1,3) - 2)
17822 ,SUBSTRB(anc_id_63
17823        ,INSTRB(anc_id_63,'(]',1,4) + 2
17824        ,INSTRB(anc_id_63,'(]',1,5) -
17825         INSTRB(anc_id_63,'(]',1,4) - 2)
17826 ,SUBSTRB(anc_id_63
17827        ,INSTRB(anc_id_63,'(]',1,5) + 2
17828        ,INSTRB(anc_id_63,'(]',1,6) -
17829         INSTRB(anc_id_63,'(]',1,5) - 2)
17830 ,SUBSTRB(anc_id_63
17831        ,INSTRB(anc_id_63,'(]',1,6) + 2
17832        ,INSTRB(anc_id_63,'(]',1,7) -
17833         INSTRB(anc_id_63,'(]',1,6) - 2)
17834 ,SUBSTRB(anc_id_63
17835        ,INSTRB(anc_id_63,'(]',1,7) + 2
17836        ,LENGTHB(anc_id_63))
17837 )
17838 
17839 WHEN anc_id_64 IS NOT NULL THEN
17840   INTO xla_ae_header_acs (
17841         ae_header_id , object_version_number
17842       , analytical_criterion_code
17843       , analytical_criterion_type_code
17844       , amb_context_code
17845       , ac1,ac2,ac3,ac4,ac5)
17846 VALUES (ae_header_id, C_OVN
17847 ,SUBSTRB(anc_id_64
17848        ,1
17849        ,INSTRB(anc_id_64,'(]',1,1) -1)
17850 ,SUBSTRB(anc_id_64
17851        ,INSTRB(anc_id_64,'(]',1,1) + 2
17852        ,INSTRB(anc_id_64,'(]',1,2) -
17853         INSTRB(anc_id_64,'(]',1,1) - 2)
17854 ,SUBSTRB(anc_id_64
17855        ,INSTRB(anc_id_64,'(]',1,2) + 2
17856        ,INSTRB(anc_id_64,'(]',1,3) -
17857         INSTRB(anc_id_64,'(]',1,2) - 2)
17858 ,SUBSTRB(anc_id_64
17859        ,INSTRB(anc_id_64,'(]',1,3) + 2
17860        ,INSTRB(anc_id_64,'(]',1,4) -
17861         INSTRB(anc_id_64,'(]',1,3) - 2)
17862 ,SUBSTRB(anc_id_64
17863        ,INSTRB(anc_id_64,'(]',1,4) + 2
17864        ,INSTRB(anc_id_64,'(]',1,5) -
17865         INSTRB(anc_id_64,'(]',1,4) - 2)
17866 ,SUBSTRB(anc_id_64
17867        ,INSTRB(anc_id_64,'(]',1,5) + 2
17868        ,INSTRB(anc_id_64,'(]',1,6) -
17869         INSTRB(anc_id_64,'(]',1,5) - 2)
17870 ,SUBSTRB(anc_id_64
17871        ,INSTRB(anc_id_64,'(]',1,6) + 2
17872        ,INSTRB(anc_id_64,'(]',1,7) -
17873         INSTRB(anc_id_64,'(]',1,6) - 2)
17874 ,SUBSTRB(anc_id_64
17875        ,INSTRB(anc_id_64,'(]',1,7) + 2
17876        ,LENGTHB(anc_id_64))
17877 )
17878 
17879 WHEN anc_id_65 IS NOT NULL THEN
17880   INTO xla_ae_header_acs (
17881         ae_header_id , object_version_number
17882       , analytical_criterion_code
17883       , analytical_criterion_type_code
17884       , amb_context_code
17885       , ac1,ac2,ac3,ac4,ac5)
17886 VALUES (ae_header_id, C_OVN
17887 ,SUBSTRB(anc_id_65
17888        ,1
17889        ,INSTRB(anc_id_65,'(]',1,1) -1)
17890 ,SUBSTRB(anc_id_65
17891        ,INSTRB(anc_id_65,'(]',1,1) + 2
17892        ,INSTRB(anc_id_65,'(]',1,2) -
17893         INSTRB(anc_id_65,'(]',1,1) - 2)
17894 ,SUBSTRB(anc_id_65
17895        ,INSTRB(anc_id_65,'(]',1,2) + 2
17896        ,INSTRB(anc_id_65,'(]',1,3) -
17897         INSTRB(anc_id_65,'(]',1,2) - 2)
17898 ,SUBSTRB(anc_id_65
17899        ,INSTRB(anc_id_65,'(]',1,3) + 2
17900        ,INSTRB(anc_id_65,'(]',1,4) -
17901         INSTRB(anc_id_65,'(]',1,3) - 2)
17902 ,SUBSTRB(anc_id_65
17903        ,INSTRB(anc_id_65,'(]',1,4) + 2
17904        ,INSTRB(anc_id_65,'(]',1,5) -
17905         INSTRB(anc_id_65,'(]',1,4) - 2)
17906 ,SUBSTRB(anc_id_65
17907        ,INSTRB(anc_id_65,'(]',1,5) + 2
17908        ,INSTRB(anc_id_65,'(]',1,6) -
17909         INSTRB(anc_id_65,'(]',1,5) - 2)
17910 ,SUBSTRB(anc_id_65
17911        ,INSTRB(anc_id_65,'(]',1,6) + 2
17912        ,INSTRB(anc_id_65,'(]',1,7) -
17913         INSTRB(anc_id_65,'(]',1,6) - 2)
17914 ,SUBSTRB(anc_id_65
17915        ,INSTRB(anc_id_65,'(]',1,7) + 2
17916        ,LENGTHB(anc_id_65))
17917 )
17918 
17919 WHEN anc_id_66 IS NOT NULL THEN
17920   INTO xla_ae_header_acs (
17921         ae_header_id , object_version_number
17922       , analytical_criterion_code
17923       , analytical_criterion_type_code
17924       , amb_context_code
17925       , ac1,ac2,ac3,ac4,ac5)
17926 VALUES (ae_header_id, C_OVN
17927 ,SUBSTRB(anc_id_66
17928        ,1
17929        ,INSTRB(anc_id_66,'(]',1,1) -1)
17930 ,SUBSTRB(anc_id_66
17931        ,INSTRB(anc_id_66,'(]',1,1) + 2
17932        ,INSTRB(anc_id_66,'(]',1,2) -
17933         INSTRB(anc_id_66,'(]',1,1) - 2)
17934 ,SUBSTRB(anc_id_66
17935        ,INSTRB(anc_id_66,'(]',1,2) + 2
17936        ,INSTRB(anc_id_66,'(]',1,3) -
17937         INSTRB(anc_id_66,'(]',1,2) - 2)
17938 ,SUBSTRB(anc_id_66
17939        ,INSTRB(anc_id_66,'(]',1,3) + 2
17940        ,INSTRB(anc_id_66,'(]',1,4) -
17941         INSTRB(anc_id_66,'(]',1,3) - 2)
17942 ,SUBSTRB(anc_id_66
17943        ,INSTRB(anc_id_66,'(]',1,4) + 2
17944        ,INSTRB(anc_id_66,'(]',1,5) -
17945         INSTRB(anc_id_66,'(]',1,4) - 2)
17946 ,SUBSTRB(anc_id_66
17947        ,INSTRB(anc_id_66,'(]',1,5) + 2
17948        ,INSTRB(anc_id_66,'(]',1,6) -
17949         INSTRB(anc_id_66,'(]',1,5) - 2)
17950 ,SUBSTRB(anc_id_66
17951        ,INSTRB(anc_id_66,'(]',1,6) + 2
17952        ,INSTRB(anc_id_66,'(]',1,7) -
17953         INSTRB(anc_id_66,'(]',1,6) - 2)
17954 ,SUBSTRB(anc_id_66
17955        ,INSTRB(anc_id_66,'(]',1,7) + 2
17956        ,LENGTHB(anc_id_66))
17957 )
17958 
17959 WHEN anc_id_67 IS NOT NULL THEN
17960   INTO xla_ae_header_acs (
17961         ae_header_id , object_version_number
17962       , analytical_criterion_code
17963       , analytical_criterion_type_code
17964       , amb_context_code
17965       , ac1,ac2,ac3,ac4,ac5)
17966 VALUES (ae_header_id, C_OVN
17967 ,SUBSTRB(anc_id_67
17968        ,1
17969        ,INSTRB(anc_id_67,'(]',1,1) -1)
17970 ,SUBSTRB(anc_id_67
17971        ,INSTRB(anc_id_67,'(]',1,1) + 2
17972        ,INSTRB(anc_id_67,'(]',1,2) -
17973         INSTRB(anc_id_67,'(]',1,1) - 2)
17974 ,SUBSTRB(anc_id_67
17975        ,INSTRB(anc_id_67,'(]',1,2) + 2
17976        ,INSTRB(anc_id_67,'(]',1,3) -
17977         INSTRB(anc_id_67,'(]',1,2) - 2)
17978 ,SUBSTRB(anc_id_67
17979        ,INSTRB(anc_id_67,'(]',1,3) + 2
17980        ,INSTRB(anc_id_67,'(]',1,4) -
17981         INSTRB(anc_id_67,'(]',1,3) - 2)
17982 ,SUBSTRB(anc_id_67
17983        ,INSTRB(anc_id_67,'(]',1,4) + 2
17984        ,INSTRB(anc_id_67,'(]',1,5) -
17985         INSTRB(anc_id_67,'(]',1,4) - 2)
17986 ,SUBSTRB(anc_id_67
17987        ,INSTRB(anc_id_67,'(]',1,5) + 2
17988        ,INSTRB(anc_id_67,'(]',1,6) -
17989         INSTRB(anc_id_67,'(]',1,5) - 2)
17990 ,SUBSTRB(anc_id_67
17991        ,INSTRB(anc_id_67,'(]',1,6) + 2
17992        ,INSTRB(anc_id_67,'(]',1,7) -
17993         INSTRB(anc_id_67,'(]',1,6) - 2)
17994 ,SUBSTRB(anc_id_67
17995        ,INSTRB(anc_id_67,'(]',1,7) + 2
17996        ,LENGTHB(anc_id_67))
17997 )
17998 
17999 WHEN anc_id_68 IS NOT NULL THEN
18000   INTO xla_ae_header_acs (
18001         ae_header_id , object_version_number
18002       , analytical_criterion_code
18003       , analytical_criterion_type_code
18004       , amb_context_code
18005       , ac1,ac2,ac3,ac4,ac5)
18006 VALUES (ae_header_id, C_OVN
18007 ,SUBSTRB(anc_id_68
18008        ,1
18009        ,INSTRB(anc_id_68,'(]',1,1) -1)
18010 ,SUBSTRB(anc_id_68
18011        ,INSTRB(anc_id_68,'(]',1,1) + 2
18012        ,INSTRB(anc_id_68,'(]',1,2) -
18013         INSTRB(anc_id_68,'(]',1,1) - 2)
18014 ,SUBSTRB(anc_id_68
18015        ,INSTRB(anc_id_68,'(]',1,2) + 2
18016        ,INSTRB(anc_id_68,'(]',1,3) -
18017         INSTRB(anc_id_68,'(]',1,2) - 2)
18018 ,SUBSTRB(anc_id_68
18019        ,INSTRB(anc_id_68,'(]',1,3) + 2
18020        ,INSTRB(anc_id_68,'(]',1,4) -
18021         INSTRB(anc_id_68,'(]',1,3) - 2)
18022 ,SUBSTRB(anc_id_68
18023        ,INSTRB(anc_id_68,'(]',1,4) + 2
18024        ,INSTRB(anc_id_68,'(]',1,5) -
18025         INSTRB(anc_id_68,'(]',1,4) - 2)
18026 ,SUBSTRB(anc_id_68
18027        ,INSTRB(anc_id_68,'(]',1,5) + 2
18028        ,INSTRB(anc_id_68,'(]',1,6) -
18029         INSTRB(anc_id_68,'(]',1,5) - 2)
18030 ,SUBSTRB(anc_id_68
18031        ,INSTRB(anc_id_68,'(]',1,6) + 2
18032        ,INSTRB(anc_id_68,'(]',1,7) -
18033         INSTRB(anc_id_68,'(]',1,6) - 2)
18034 ,SUBSTRB(anc_id_68
18035        ,INSTRB(anc_id_68,'(]',1,7) + 2
18036        ,LENGTHB(anc_id_68))
18037 )
18038 
18039 WHEN anc_id_69 IS NOT NULL THEN
18040   INTO xla_ae_header_acs (
18041         ae_header_id , object_version_number
18042       , analytical_criterion_code
18043       , analytical_criterion_type_code
18044       , amb_context_code
18045       , ac1,ac2,ac3,ac4,ac5)
18046 VALUES (ae_header_id, C_OVN
18047 ,SUBSTRB(anc_id_69
18048        ,1
18049        ,INSTRB(anc_id_69,'(]',1,1) -1)
18050 ,SUBSTRB(anc_id_69
18051        ,INSTRB(anc_id_69,'(]',1,1) + 2
18052        ,INSTRB(anc_id_69,'(]',1,2) -
18053         INSTRB(anc_id_69,'(]',1,1) - 2)
18054 ,SUBSTRB(anc_id_69
18055        ,INSTRB(anc_id_69,'(]',1,2) + 2
18056        ,INSTRB(anc_id_69,'(]',1,3) -
18057         INSTRB(anc_id_69,'(]',1,2) - 2)
18058 ,SUBSTRB(anc_id_69
18059        ,INSTRB(anc_id_69,'(]',1,3) + 2
18060        ,INSTRB(anc_id_69,'(]',1,4) -
18061         INSTRB(anc_id_69,'(]',1,3) - 2)
18062 ,SUBSTRB(anc_id_69
18063        ,INSTRB(anc_id_69,'(]',1,4) + 2
18064        ,INSTRB(anc_id_69,'(]',1,5) -
18065         INSTRB(anc_id_69,'(]',1,4) - 2)
18066 ,SUBSTRB(anc_id_69
18067        ,INSTRB(anc_id_69,'(]',1,5) + 2
18068        ,INSTRB(anc_id_69,'(]',1,6) -
18069         INSTRB(anc_id_69,'(]',1,5) - 2)
18070 ,SUBSTRB(anc_id_69
18071        ,INSTRB(anc_id_69,'(]',1,6) + 2
18072        ,INSTRB(anc_id_69,'(]',1,7) -
18073         INSTRB(anc_id_69,'(]',1,6) - 2)
18074 ,SUBSTRB(anc_id_69
18075        ,INSTRB(anc_id_69,'(]',1,7) + 2
18076        ,LENGTHB(anc_id_69))
18077 )
18078 
18079 WHEN anc_id_70 IS NOT NULL THEN
18080   INTO xla_ae_header_acs (
18081         ae_header_id , object_version_number
18082       , analytical_criterion_code
18083       , analytical_criterion_type_code
18084       , amb_context_code
18085       , ac1,ac2,ac3,ac4,ac5)
18086 VALUES (ae_header_id, C_OVN
18087 ,SUBSTRB(anc_id_70
18088        ,1
18089        ,INSTRB(anc_id_70,'(]',1,1) -1)
18090 ,SUBSTRB(anc_id_70
18091        ,INSTRB(anc_id_70,'(]',1,1) + 2
18092        ,INSTRB(anc_id_70,'(]',1,2) -
18093         INSTRB(anc_id_70,'(]',1,1) - 2)
18094 ,SUBSTRB(anc_id_70
18095        ,INSTRB(anc_id_70,'(]',1,2) + 2
18096        ,INSTRB(anc_id_70,'(]',1,3) -
18097         INSTRB(anc_id_70,'(]',1,2) - 2)
18098 ,SUBSTRB(anc_id_70
18099        ,INSTRB(anc_id_70,'(]',1,3) + 2
18100        ,INSTRB(anc_id_70,'(]',1,4) -
18101         INSTRB(anc_id_70,'(]',1,3) - 2)
18102 ,SUBSTRB(anc_id_70
18103        ,INSTRB(anc_id_70,'(]',1,4) + 2
18104        ,INSTRB(anc_id_70,'(]',1,5) -
18105         INSTRB(anc_id_70,'(]',1,4) - 2)
18106 ,SUBSTRB(anc_id_70
18107        ,INSTRB(anc_id_70,'(]',1,5) + 2
18108        ,INSTRB(anc_id_70,'(]',1,6) -
18109         INSTRB(anc_id_70,'(]',1,5) - 2)
18110 ,SUBSTRB(anc_id_70
18111        ,INSTRB(anc_id_70,'(]',1,6) + 2
18112        ,INSTRB(anc_id_70,'(]',1,7) -
18113         INSTRB(anc_id_70,'(]',1,6) - 2)
18114 ,SUBSTRB(anc_id_70
18115        ,INSTRB(anc_id_70,'(]',1,7) + 2
18116        ,LENGTHB(anc_id_70))
18117 )
18118 
18119 WHEN anc_id_71 IS NOT NULL THEN
18120   INTO xla_ae_header_acs (
18121         ae_header_id , object_version_number
18122       , analytical_criterion_code
18123       , analytical_criterion_type_code
18124       , amb_context_code
18125       , ac1,ac2,ac3,ac4,ac5)
18126 VALUES (ae_header_id, C_OVN
18127 ,SUBSTRB(anc_id_71
18128        ,1
18129        ,INSTRB(anc_id_71,'(]',1,1) -1)
18130 ,SUBSTRB(anc_id_71
18131        ,INSTRB(anc_id_71,'(]',1,1) + 2
18132        ,INSTRB(anc_id_71,'(]',1,2) -
18133         INSTRB(anc_id_71,'(]',1,1) - 2)
18134 ,SUBSTRB(anc_id_71
18135        ,INSTRB(anc_id_71,'(]',1,2) + 2
18136        ,INSTRB(anc_id_71,'(]',1,3) -
18137         INSTRB(anc_id_71,'(]',1,2) - 2)
18138 ,SUBSTRB(anc_id_71
18139        ,INSTRB(anc_id_71,'(]',1,3) + 2
18140        ,INSTRB(anc_id_71,'(]',1,4) -
18141         INSTRB(anc_id_71,'(]',1,3) - 2)
18142 ,SUBSTRB(anc_id_71
18143        ,INSTRB(anc_id_71,'(]',1,4) + 2
18144        ,INSTRB(anc_id_71,'(]',1,5) -
18145         INSTRB(anc_id_71,'(]',1,4) - 2)
18146 ,SUBSTRB(anc_id_71
18147        ,INSTRB(anc_id_71,'(]',1,5) + 2
18148        ,INSTRB(anc_id_71,'(]',1,6) -
18149         INSTRB(anc_id_71,'(]',1,5) - 2)
18150 ,SUBSTRB(anc_id_71
18151        ,INSTRB(anc_id_71,'(]',1,6) + 2
18152        ,INSTRB(anc_id_71,'(]',1,7) -
18153         INSTRB(anc_id_71,'(]',1,6) - 2)
18154 ,SUBSTRB(anc_id_71
18155        ,INSTRB(anc_id_71,'(]',1,7) + 2
18156        ,LENGTHB(anc_id_71))
18157 )
18158 
18159 WHEN anc_id_72 IS NOT NULL THEN
18160   INTO xla_ae_header_acs (
18161         ae_header_id , object_version_number
18162       , analytical_criterion_code
18163       , analytical_criterion_type_code
18164       , amb_context_code
18165       , ac1,ac2,ac3,ac4,ac5)
18166 VALUES (ae_header_id, C_OVN
18167 ,SUBSTRB(anc_id_72
18168        ,1
18169        ,INSTRB(anc_id_72,'(]',1,1) -1)
18170 ,SUBSTRB(anc_id_72
18171        ,INSTRB(anc_id_72,'(]',1,1) + 2
18172        ,INSTRB(anc_id_72,'(]',1,2) -
18173         INSTRB(anc_id_72,'(]',1,1) - 2)
18174 ,SUBSTRB(anc_id_72
18175        ,INSTRB(anc_id_72,'(]',1,2) + 2
18176        ,INSTRB(anc_id_72,'(]',1,3) -
18177         INSTRB(anc_id_72,'(]',1,2) - 2)
18178 ,SUBSTRB(anc_id_72
18179        ,INSTRB(anc_id_72,'(]',1,3) + 2
18180        ,INSTRB(anc_id_72,'(]',1,4) -
18181         INSTRB(anc_id_72,'(]',1,3) - 2)
18182 ,SUBSTRB(anc_id_72
18183        ,INSTRB(anc_id_72,'(]',1,4) + 2
18184        ,INSTRB(anc_id_72,'(]',1,5) -
18185         INSTRB(anc_id_72,'(]',1,4) - 2)
18186 ,SUBSTRB(anc_id_72
18187        ,INSTRB(anc_id_72,'(]',1,5) + 2
18188        ,INSTRB(anc_id_72,'(]',1,6) -
18189         INSTRB(anc_id_72,'(]',1,5) - 2)
18190 ,SUBSTRB(anc_id_72
18191        ,INSTRB(anc_id_72,'(]',1,6) + 2
18192        ,INSTRB(anc_id_72,'(]',1,7) -
18193         INSTRB(anc_id_72,'(]',1,6) - 2)
18194 ,SUBSTRB(anc_id_72
18195        ,INSTRB(anc_id_72,'(]',1,7) + 2
18196        ,LENGTHB(anc_id_72))
18197 )
18198 
18199 WHEN anc_id_73 IS NOT NULL THEN
18200   INTO xla_ae_header_acs (
18201         ae_header_id , object_version_number
18202       , analytical_criterion_code
18203       , analytical_criterion_type_code
18204       , amb_context_code
18205       , ac1,ac2,ac3,ac4,ac5)
18206 VALUES (ae_header_id, C_OVN
18207 ,SUBSTRB(anc_id_73
18208        ,1
18209        ,INSTRB(anc_id_73,'(]',1,1) -1)
18210 ,SUBSTRB(anc_id_73
18211        ,INSTRB(anc_id_73,'(]',1,1) + 2
18212        ,INSTRB(anc_id_73,'(]',1,2) -
18213         INSTRB(anc_id_73,'(]',1,1) - 2)
18214 ,SUBSTRB(anc_id_73
18215        ,INSTRB(anc_id_73,'(]',1,2) + 2
18216        ,INSTRB(anc_id_73,'(]',1,3) -
18217         INSTRB(anc_id_73,'(]',1,2) - 2)
18218 ,SUBSTRB(anc_id_73
18219        ,INSTRB(anc_id_73,'(]',1,3) + 2
18220        ,INSTRB(anc_id_73,'(]',1,4) -
18221         INSTRB(anc_id_73,'(]',1,3) - 2)
18222 ,SUBSTRB(anc_id_73
18223        ,INSTRB(anc_id_73,'(]',1,4) + 2
18224        ,INSTRB(anc_id_73,'(]',1,5) -
18225         INSTRB(anc_id_73,'(]',1,4) - 2)
18226 ,SUBSTRB(anc_id_73
18227        ,INSTRB(anc_id_73,'(]',1,5) + 2
18228        ,INSTRB(anc_id_73,'(]',1,6) -
18229         INSTRB(anc_id_73,'(]',1,5) - 2)
18230 ,SUBSTRB(anc_id_73
18231        ,INSTRB(anc_id_73,'(]',1,6) + 2
18232        ,INSTRB(anc_id_73,'(]',1,7) -
18233         INSTRB(anc_id_73,'(]',1,6) - 2)
18234 ,SUBSTRB(anc_id_73
18235        ,INSTRB(anc_id_73,'(]',1,7) + 2
18236        ,LENGTHB(anc_id_73))
18237 )
18238 
18239 WHEN anc_id_74 IS NOT NULL THEN
18240   INTO xla_ae_header_acs (
18241         ae_header_id , object_version_number
18242       , analytical_criterion_code
18243       , analytical_criterion_type_code
18244       , amb_context_code
18245       , ac1,ac2,ac3,ac4,ac5)
18246 VALUES (ae_header_id, C_OVN
18247 ,SUBSTRB(anc_id_74
18248        ,1
18249        ,INSTRB(anc_id_74,'(]',1,1) -1)
18250 ,SUBSTRB(anc_id_74
18251        ,INSTRB(anc_id_74,'(]',1,1) + 2
18252        ,INSTRB(anc_id_74,'(]',1,2) -
18253         INSTRB(anc_id_74,'(]',1,1) - 2)
18254 ,SUBSTRB(anc_id_74
18255        ,INSTRB(anc_id_74,'(]',1,2) + 2
18256        ,INSTRB(anc_id_74,'(]',1,3) -
18257         INSTRB(anc_id_74,'(]',1,2) - 2)
18258 ,SUBSTRB(anc_id_74
18259        ,INSTRB(anc_id_74,'(]',1,3) + 2
18260        ,INSTRB(anc_id_74,'(]',1,4) -
18261         INSTRB(anc_id_74,'(]',1,3) - 2)
18262 ,SUBSTRB(anc_id_74
18263        ,INSTRB(anc_id_74,'(]',1,4) + 2
18264        ,INSTRB(anc_id_74,'(]',1,5) -
18265         INSTRB(anc_id_74,'(]',1,4) - 2)
18266 ,SUBSTRB(anc_id_74
18267        ,INSTRB(anc_id_74,'(]',1,5) + 2
18268        ,INSTRB(anc_id_74,'(]',1,6) -
18269         INSTRB(anc_id_74,'(]',1,5) - 2)
18270 ,SUBSTRB(anc_id_74
18271        ,INSTRB(anc_id_74,'(]',1,6) + 2
18272        ,INSTRB(anc_id_74,'(]',1,7) -
18273         INSTRB(anc_id_74,'(]',1,6) - 2)
18274 ,SUBSTRB(anc_id_74
18275        ,INSTRB(anc_id_74,'(]',1,7) + 2
18276        ,LENGTHB(anc_id_74))
18277 )
18278 
18279 WHEN anc_id_75 IS NOT NULL THEN
18280   INTO xla_ae_header_acs (
18281         ae_header_id , object_version_number
18282       , analytical_criterion_code
18283       , analytical_criterion_type_code
18284       , amb_context_code
18285       , ac1,ac2,ac3,ac4,ac5)
18286 VALUES (ae_header_id, C_OVN
18287 ,SUBSTRB(anc_id_75
18288        ,1
18289        ,INSTRB(anc_id_75,'(]',1,1) -1)
18290 ,SUBSTRB(anc_id_75
18291        ,INSTRB(anc_id_75,'(]',1,1) + 2
18292        ,INSTRB(anc_id_75,'(]',1,2) -
18293         INSTRB(anc_id_75,'(]',1,1) - 2)
18294 ,SUBSTRB(anc_id_75
18295        ,INSTRB(anc_id_75,'(]',1,2) + 2
18296        ,INSTRB(anc_id_75,'(]',1,3) -
18297         INSTRB(anc_id_75,'(]',1,2) - 2)
18298 ,SUBSTRB(anc_id_75
18299        ,INSTRB(anc_id_75,'(]',1,3) + 2
18300        ,INSTRB(anc_id_75,'(]',1,4) -
18301         INSTRB(anc_id_75,'(]',1,3) - 2)
18302 ,SUBSTRB(anc_id_75
18303        ,INSTRB(anc_id_75,'(]',1,4) + 2
18304        ,INSTRB(anc_id_75,'(]',1,5) -
18305         INSTRB(anc_id_75,'(]',1,4) - 2)
18306 ,SUBSTRB(anc_id_75
18307        ,INSTRB(anc_id_75,'(]',1,5) + 2
18308        ,INSTRB(anc_id_75,'(]',1,6) -
18309         INSTRB(anc_id_75,'(]',1,5) - 2)
18310 ,SUBSTRB(anc_id_75
18311        ,INSTRB(anc_id_75,'(]',1,6) + 2
18312        ,INSTRB(anc_id_75,'(]',1,7) -
18313         INSTRB(anc_id_75,'(]',1,6) - 2)
18314 ,SUBSTRB(anc_id_75
18315        ,INSTRB(anc_id_75,'(]',1,7) + 2
18316        ,LENGTHB(anc_id_75))
18317 )
18318 
18319 WHEN anc_id_76 IS NOT NULL THEN
18320   INTO xla_ae_header_acs (
18321         ae_header_id , object_version_number
18322       , analytical_criterion_code
18323       , analytical_criterion_type_code
18324       , amb_context_code
18325       , ac1,ac2,ac3,ac4,ac5)
18326 VALUES (ae_header_id, C_OVN
18327 ,SUBSTRB(anc_id_76
18328        ,1
18329        ,INSTRB(anc_id_76,'(]',1,1) -1)
18330 ,SUBSTRB(anc_id_76
18331        ,INSTRB(anc_id_76,'(]',1,1) + 2
18332        ,INSTRB(anc_id_76,'(]',1,2) -
18333         INSTRB(anc_id_76,'(]',1,1) - 2)
18334 ,SUBSTRB(anc_id_76
18335        ,INSTRB(anc_id_76,'(]',1,2) + 2
18336        ,INSTRB(anc_id_76,'(]',1,3) -
18337         INSTRB(anc_id_76,'(]',1,2) - 2)
18338 ,SUBSTRB(anc_id_76
18339        ,INSTRB(anc_id_76,'(]',1,3) + 2
18340        ,INSTRB(anc_id_76,'(]',1,4) -
18341         INSTRB(anc_id_76,'(]',1,3) - 2)
18342 ,SUBSTRB(anc_id_76
18343        ,INSTRB(anc_id_76,'(]',1,4) + 2
18344        ,INSTRB(anc_id_76,'(]',1,5) -
18345         INSTRB(anc_id_76,'(]',1,4) - 2)
18346 ,SUBSTRB(anc_id_76
18347        ,INSTRB(anc_id_76,'(]',1,5) + 2
18348        ,INSTRB(anc_id_76,'(]',1,6) -
18349         INSTRB(anc_id_76,'(]',1,5) - 2)
18350 ,SUBSTRB(anc_id_76
18351        ,INSTRB(anc_id_76,'(]',1,6) + 2
18352        ,INSTRB(anc_id_76,'(]',1,7) -
18353         INSTRB(anc_id_76,'(]',1,6) - 2)
18354 ,SUBSTRB(anc_id_76
18355        ,INSTRB(anc_id_76,'(]',1,7) + 2
18356        ,LENGTHB(anc_id_76))
18357 )
18358 
18359 WHEN anc_id_77 IS NOT NULL THEN
18360   INTO xla_ae_header_acs (
18361         ae_header_id , object_version_number
18362       , analytical_criterion_code
18363       , analytical_criterion_type_code
18364       , amb_context_code
18365       , ac1,ac2,ac3,ac4,ac5)
18366 VALUES (ae_header_id, C_OVN
18367 ,SUBSTRB(anc_id_77
18368        ,1
18369        ,INSTRB(anc_id_77,'(]',1,1) -1)
18370 ,SUBSTRB(anc_id_77
18371        ,INSTRB(anc_id_77,'(]',1,1) + 2
18372        ,INSTRB(anc_id_77,'(]',1,2) -
18373         INSTRB(anc_id_77,'(]',1,1) - 2)
18374 ,SUBSTRB(anc_id_77
18375        ,INSTRB(anc_id_77,'(]',1,2) + 2
18376        ,INSTRB(anc_id_77,'(]',1,3) -
18377         INSTRB(anc_id_77,'(]',1,2) - 2)
18378 ,SUBSTRB(anc_id_77
18379        ,INSTRB(anc_id_77,'(]',1,3) + 2
18380        ,INSTRB(anc_id_77,'(]',1,4) -
18381         INSTRB(anc_id_77,'(]',1,3) - 2)
18382 ,SUBSTRB(anc_id_77
18383        ,INSTRB(anc_id_77,'(]',1,4) + 2
18384        ,INSTRB(anc_id_77,'(]',1,5) -
18385         INSTRB(anc_id_77,'(]',1,4) - 2)
18386 ,SUBSTRB(anc_id_77
18387        ,INSTRB(anc_id_77,'(]',1,5) + 2
18388        ,INSTRB(anc_id_77,'(]',1,6) -
18389         INSTRB(anc_id_77,'(]',1,5) - 2)
18390 ,SUBSTRB(anc_id_77
18391        ,INSTRB(anc_id_77,'(]',1,6) + 2
18392        ,INSTRB(anc_id_77,'(]',1,7) -
18393         INSTRB(anc_id_77,'(]',1,6) - 2)
18394 ,SUBSTRB(anc_id_77
18395        ,INSTRB(anc_id_77,'(]',1,7) + 2
18396        ,LENGTHB(anc_id_77))
18397 )
18398 
18399 WHEN anc_id_78 IS NOT NULL THEN
18400   INTO xla_ae_header_acs (
18401         ae_header_id , object_version_number
18402       , analytical_criterion_code
18403       , analytical_criterion_type_code
18404       , amb_context_code
18405       , ac1,ac2,ac3,ac4,ac5)
18406 VALUES (ae_header_id, C_OVN
18407 ,SUBSTRB(anc_id_78
18408        ,1
18409        ,INSTRB(anc_id_78,'(]',1,1) -1)
18410 ,SUBSTRB(anc_id_78
18411        ,INSTRB(anc_id_78,'(]',1,1) + 2
18412        ,INSTRB(anc_id_78,'(]',1,2) -
18413         INSTRB(anc_id_78,'(]',1,1) - 2)
18414 ,SUBSTRB(anc_id_78
18415        ,INSTRB(anc_id_78,'(]',1,2) + 2
18416        ,INSTRB(anc_id_78,'(]',1,3) -
18417         INSTRB(anc_id_78,'(]',1,2) - 2)
18418 ,SUBSTRB(anc_id_78
18419        ,INSTRB(anc_id_78,'(]',1,3) + 2
18420        ,INSTRB(anc_id_78,'(]',1,4) -
18421         INSTRB(anc_id_78,'(]',1,3) - 2)
18422 ,SUBSTRB(anc_id_78
18423        ,INSTRB(anc_id_78,'(]',1,4) + 2
18424        ,INSTRB(anc_id_78,'(]',1,5) -
18425         INSTRB(anc_id_78,'(]',1,4) - 2)
18426 ,SUBSTRB(anc_id_78
18427        ,INSTRB(anc_id_78,'(]',1,5) + 2
18428        ,INSTRB(anc_id_78,'(]',1,6) -
18429         INSTRB(anc_id_78,'(]',1,5) - 2)
18430 ,SUBSTRB(anc_id_78
18431        ,INSTRB(anc_id_78,'(]',1,6) + 2
18432        ,INSTRB(anc_id_78,'(]',1,7) -
18433         INSTRB(anc_id_78,'(]',1,6) - 2)
18434 ,SUBSTRB(anc_id_78
18435        ,INSTRB(anc_id_78,'(]',1,7) + 2
18436        ,LENGTHB(anc_id_78))
18437 )
18438 
18439 WHEN anc_id_79 IS NOT NULL THEN
18440   INTO xla_ae_header_acs (
18441         ae_header_id , object_version_number
18442       , analytical_criterion_code
18443       , analytical_criterion_type_code
18444       , amb_context_code
18445       , ac1,ac2,ac3,ac4,ac5)
18446 VALUES (ae_header_id, C_OVN
18447 ,SUBSTRB(anc_id_79
18448        ,1
18449        ,INSTRB(anc_id_79,'(]',1,1) -1)
18450 ,SUBSTRB(anc_id_79
18451        ,INSTRB(anc_id_79,'(]',1,1) + 2
18452        ,INSTRB(anc_id_79,'(]',1,2) -
18453         INSTRB(anc_id_79,'(]',1,1) - 2)
18454 ,SUBSTRB(anc_id_79
18455        ,INSTRB(anc_id_79,'(]',1,2) + 2
18456        ,INSTRB(anc_id_79,'(]',1,3) -
18457         INSTRB(anc_id_79,'(]',1,2) - 2)
18458 ,SUBSTRB(anc_id_79
18459        ,INSTRB(anc_id_79,'(]',1,3) + 2
18460        ,INSTRB(anc_id_79,'(]',1,4) -
18461         INSTRB(anc_id_79,'(]',1,3) - 2)
18462 ,SUBSTRB(anc_id_79
18463        ,INSTRB(anc_id_79,'(]',1,4) + 2
18464        ,INSTRB(anc_id_79,'(]',1,5) -
18465         INSTRB(anc_id_79,'(]',1,4) - 2)
18466 ,SUBSTRB(anc_id_79
18467        ,INSTRB(anc_id_79,'(]',1,5) + 2
18468        ,INSTRB(anc_id_79,'(]',1,6) -
18469         INSTRB(anc_id_79,'(]',1,5) - 2)
18470 ,SUBSTRB(anc_id_79
18471        ,INSTRB(anc_id_79,'(]',1,6) + 2
18472        ,INSTRB(anc_id_79,'(]',1,7) -
18473         INSTRB(anc_id_79,'(]',1,6) - 2)
18474 ,SUBSTRB(anc_id_79
18475        ,INSTRB(anc_id_79,'(]',1,7) + 2
18476        ,LENGTHB(anc_id_79))
18477 )
18478 
18479 WHEN anc_id_80 IS NOT NULL THEN
18480   INTO xla_ae_header_acs (
18481         ae_header_id , object_version_number
18482       , analytical_criterion_code
18483       , analytical_criterion_type_code
18484       , amb_context_code
18485       , ac1,ac2,ac3,ac4,ac5)
18486 VALUES (ae_header_id, C_OVN
18487 ,SUBSTRB(anc_id_80
18488        ,1
18489        ,INSTRB(anc_id_80,'(]',1,1) -1)
18490 ,SUBSTRB(anc_id_80
18491        ,INSTRB(anc_id_80,'(]',1,1) + 2
18492        ,INSTRB(anc_id_80,'(]',1,2) -
18493         INSTRB(anc_id_80,'(]',1,1) - 2)
18494 ,SUBSTRB(anc_id_80
18495        ,INSTRB(anc_id_80,'(]',1,2) + 2
18496        ,INSTRB(anc_id_80,'(]',1,3) -
18497         INSTRB(anc_id_80,'(]',1,2) - 2)
18498 ,SUBSTRB(anc_id_80
18499        ,INSTRB(anc_id_80,'(]',1,3) + 2
18500        ,INSTRB(anc_id_80,'(]',1,4) -
18501         INSTRB(anc_id_80,'(]',1,3) - 2)
18502 ,SUBSTRB(anc_id_80
18503        ,INSTRB(anc_id_80,'(]',1,4) + 2
18504        ,INSTRB(anc_id_80,'(]',1,5) -
18505         INSTRB(anc_id_80,'(]',1,4) - 2)
18506 ,SUBSTRB(anc_id_80
18507        ,INSTRB(anc_id_80,'(]',1,5) + 2
18508        ,INSTRB(anc_id_80,'(]',1,6) -
18509         INSTRB(anc_id_80,'(]',1,5) - 2)
18510 ,SUBSTRB(anc_id_80
18511        ,INSTRB(anc_id_80,'(]',1,6) + 2
18512        ,INSTRB(anc_id_80,'(]',1,7) -
18513         INSTRB(anc_id_80,'(]',1,6) - 2)
18514 ,SUBSTRB(anc_id_80
18515        ,INSTRB(anc_id_80,'(]',1,7) + 2
18516        ,LENGTHB(anc_id_80))
18517 )
18518 
18519 WHEN anc_id_81 IS NOT NULL THEN
18520   INTO xla_ae_header_acs (
18521         ae_header_id , object_version_number
18522       , analytical_criterion_code
18523       , analytical_criterion_type_code
18524       , amb_context_code
18525       , ac1,ac2,ac3,ac4,ac5)
18526 VALUES (ae_header_id, C_OVN
18527 ,SUBSTRB(anc_id_81
18528        ,1
18529        ,INSTRB(anc_id_81,'(]',1,1) -1)
18530 ,SUBSTRB(anc_id_81
18531        ,INSTRB(anc_id_81,'(]',1,1) + 2
18532        ,INSTRB(anc_id_81,'(]',1,2) -
18533         INSTRB(anc_id_81,'(]',1,1) - 2)
18534 ,SUBSTRB(anc_id_81
18535        ,INSTRB(anc_id_81,'(]',1,2) + 2
18536        ,INSTRB(anc_id_81,'(]',1,3) -
18537         INSTRB(anc_id_81,'(]',1,2) - 2)
18538 ,SUBSTRB(anc_id_81
18539        ,INSTRB(anc_id_81,'(]',1,3) + 2
18540        ,INSTRB(anc_id_81,'(]',1,4) -
18541         INSTRB(anc_id_81,'(]',1,3) - 2)
18542 ,SUBSTRB(anc_id_81
18543        ,INSTRB(anc_id_81,'(]',1,4) + 2
18544        ,INSTRB(anc_id_81,'(]',1,5) -
18545         INSTRB(anc_id_81,'(]',1,4) - 2)
18546 ,SUBSTRB(anc_id_81
18547        ,INSTRB(anc_id_81,'(]',1,5) + 2
18548        ,INSTRB(anc_id_81,'(]',1,6) -
18549         INSTRB(anc_id_81,'(]',1,5) - 2)
18550 ,SUBSTRB(anc_id_81
18551        ,INSTRB(anc_id_81,'(]',1,6) + 2
18552        ,INSTRB(anc_id_81,'(]',1,7) -
18553         INSTRB(anc_id_81,'(]',1,6) - 2)
18554 ,SUBSTRB(anc_id_81
18555        ,INSTRB(anc_id_81,'(]',1,7) + 2
18556        ,LENGTHB(anc_id_81))
18557 )
18558 
18559 WHEN anc_id_82 IS NOT NULL THEN
18560   INTO xla_ae_header_acs (
18561         ae_header_id , object_version_number
18562       , analytical_criterion_code
18563       , analytical_criterion_type_code
18564       , amb_context_code
18565       , ac1,ac2,ac3,ac4,ac5)
18566 VALUES (ae_header_id, C_OVN
18567 ,SUBSTRB(anc_id_82
18568        ,1
18569        ,INSTRB(anc_id_82,'(]',1,1) -1)
18570 ,SUBSTRB(anc_id_82
18571        ,INSTRB(anc_id_82,'(]',1,1) + 2
18572        ,INSTRB(anc_id_82,'(]',1,2) -
18573         INSTRB(anc_id_82,'(]',1,1) - 2)
18574 ,SUBSTRB(anc_id_82
18575        ,INSTRB(anc_id_82,'(]',1,2) + 2
18576        ,INSTRB(anc_id_82,'(]',1,3) -
18577         INSTRB(anc_id_82,'(]',1,2) - 2)
18578 ,SUBSTRB(anc_id_82
18579        ,INSTRB(anc_id_82,'(]',1,3) + 2
18580        ,INSTRB(anc_id_82,'(]',1,4) -
18581         INSTRB(anc_id_82,'(]',1,3) - 2)
18582 ,SUBSTRB(anc_id_82
18583        ,INSTRB(anc_id_82,'(]',1,4) + 2
18584        ,INSTRB(anc_id_82,'(]',1,5) -
18585         INSTRB(anc_id_82,'(]',1,4) - 2)
18586 ,SUBSTRB(anc_id_82
18587        ,INSTRB(anc_id_82,'(]',1,5) + 2
18588        ,INSTRB(anc_id_82,'(]',1,6) -
18589         INSTRB(anc_id_82,'(]',1,5) - 2)
18590 ,SUBSTRB(anc_id_82
18591        ,INSTRB(anc_id_82,'(]',1,6) + 2
18592        ,INSTRB(anc_id_82,'(]',1,7) -
18593         INSTRB(anc_id_82,'(]',1,6) - 2)
18594 ,SUBSTRB(anc_id_82
18595        ,INSTRB(anc_id_82,'(]',1,7) + 2
18596        ,LENGTHB(anc_id_82))
18597 )
18598 
18599 WHEN anc_id_83 IS NOT NULL THEN
18600   INTO xla_ae_header_acs (
18601         ae_header_id , object_version_number
18602       , analytical_criterion_code
18603       , analytical_criterion_type_code
18604       , amb_context_code
18605       , ac1,ac2,ac3,ac4,ac5)
18606 VALUES (ae_header_id, C_OVN
18607 ,SUBSTRB(anc_id_83
18608        ,1
18609        ,INSTRB(anc_id_83,'(]',1,1) -1)
18610 ,SUBSTRB(anc_id_83
18611        ,INSTRB(anc_id_83,'(]',1,1) + 2
18612        ,INSTRB(anc_id_83,'(]',1,2) -
18613         INSTRB(anc_id_83,'(]',1,1) - 2)
18614 ,SUBSTRB(anc_id_83
18615        ,INSTRB(anc_id_83,'(]',1,2) + 2
18616        ,INSTRB(anc_id_83,'(]',1,3) -
18617         INSTRB(anc_id_83,'(]',1,2) - 2)
18618 ,SUBSTRB(anc_id_83
18619        ,INSTRB(anc_id_83,'(]',1,3) + 2
18620        ,INSTRB(anc_id_83,'(]',1,4) -
18621         INSTRB(anc_id_83,'(]',1,3) - 2)
18622 ,SUBSTRB(anc_id_83
18623        ,INSTRB(anc_id_83,'(]',1,4) + 2
18624        ,INSTRB(anc_id_83,'(]',1,5) -
18625         INSTRB(anc_id_83,'(]',1,4) - 2)
18626 ,SUBSTRB(anc_id_83
18627        ,INSTRB(anc_id_83,'(]',1,5) + 2
18628        ,INSTRB(anc_id_83,'(]',1,6) -
18629         INSTRB(anc_id_83,'(]',1,5) - 2)
18630 ,SUBSTRB(anc_id_83
18631        ,INSTRB(anc_id_83,'(]',1,6) + 2
18632        ,INSTRB(anc_id_83,'(]',1,7) -
18633         INSTRB(anc_id_83,'(]',1,6) - 2)
18634 ,SUBSTRB(anc_id_83
18635        ,INSTRB(anc_id_83,'(]',1,7) + 2
18636        ,LENGTHB(anc_id_83))
18637 )
18638 
18639 WHEN anc_id_84 IS NOT NULL THEN
18640   INTO xla_ae_header_acs (
18641         ae_header_id , object_version_number
18642       , analytical_criterion_code
18643       , analytical_criterion_type_code
18644       , amb_context_code
18645       , ac1,ac2,ac3,ac4,ac5)
18646 VALUES (ae_header_id, C_OVN
18647 ,SUBSTRB(anc_id_84
18648        ,1
18649        ,INSTRB(anc_id_84,'(]',1,1) -1)
18650 ,SUBSTRB(anc_id_84
18651        ,INSTRB(anc_id_84,'(]',1,1) + 2
18652        ,INSTRB(anc_id_84,'(]',1,2) -
18653         INSTRB(anc_id_84,'(]',1,1) - 2)
18654 ,SUBSTRB(anc_id_84
18655        ,INSTRB(anc_id_84,'(]',1,2) + 2
18656        ,INSTRB(anc_id_84,'(]',1,3) -
18657         INSTRB(anc_id_84,'(]',1,2) - 2)
18658 ,SUBSTRB(anc_id_84
18659        ,INSTRB(anc_id_84,'(]',1,3) + 2
18660        ,INSTRB(anc_id_84,'(]',1,4) -
18661         INSTRB(anc_id_84,'(]',1,3) - 2)
18662 ,SUBSTRB(anc_id_84
18663        ,INSTRB(anc_id_84,'(]',1,4) + 2
18664        ,INSTRB(anc_id_84,'(]',1,5) -
18665         INSTRB(anc_id_84,'(]',1,4) - 2)
18666 ,SUBSTRB(anc_id_84
18667        ,INSTRB(anc_id_84,'(]',1,5) + 2
18668        ,INSTRB(anc_id_84,'(]',1,6) -
18669         INSTRB(anc_id_84,'(]',1,5) - 2)
18670 ,SUBSTRB(anc_id_84
18671        ,INSTRB(anc_id_84,'(]',1,6) + 2
18672        ,INSTRB(anc_id_84,'(]',1,7) -
18673         INSTRB(anc_id_84,'(]',1,6) - 2)
18674 ,SUBSTRB(anc_id_84
18675        ,INSTRB(anc_id_84,'(]',1,7) + 2
18676        ,LENGTHB(anc_id_84))
18677 )
18678 
18679 WHEN anc_id_85 IS NOT NULL THEN
18680   INTO xla_ae_header_acs (
18681         ae_header_id , object_version_number
18682       , analytical_criterion_code
18683       , analytical_criterion_type_code
18684       , amb_context_code
18685       , ac1,ac2,ac3,ac4,ac5)
18686 VALUES (ae_header_id, C_OVN
18687 ,SUBSTRB(anc_id_85
18688        ,1
18689        ,INSTRB(anc_id_85,'(]',1,1) -1)
18690 ,SUBSTRB(anc_id_85
18691        ,INSTRB(anc_id_85,'(]',1,1) + 2
18692        ,INSTRB(anc_id_85,'(]',1,2) -
18693         INSTRB(anc_id_85,'(]',1,1) - 2)
18694 ,SUBSTRB(anc_id_85
18695        ,INSTRB(anc_id_85,'(]',1,2) + 2
18696        ,INSTRB(anc_id_85,'(]',1,3) -
18697         INSTRB(anc_id_85,'(]',1,2) - 2)
18698 ,SUBSTRB(anc_id_85
18699        ,INSTRB(anc_id_85,'(]',1,3) + 2
18700        ,INSTRB(anc_id_85,'(]',1,4) -
18701         INSTRB(anc_id_85,'(]',1,3) - 2)
18702 ,SUBSTRB(anc_id_85
18703        ,INSTRB(anc_id_85,'(]',1,4) + 2
18704        ,INSTRB(anc_id_85,'(]',1,5) -
18705         INSTRB(anc_id_85,'(]',1,4) - 2)
18706 ,SUBSTRB(anc_id_85
18707        ,INSTRB(anc_id_85,'(]',1,5) + 2
18708        ,INSTRB(anc_id_85,'(]',1,6) -
18709         INSTRB(anc_id_85,'(]',1,5) - 2)
18710 ,SUBSTRB(anc_id_85
18711        ,INSTRB(anc_id_85,'(]',1,6) + 2
18712        ,INSTRB(anc_id_85,'(]',1,7) -
18713         INSTRB(anc_id_85,'(]',1,6) - 2)
18714 ,SUBSTRB(anc_id_85
18715        ,INSTRB(anc_id_85,'(]',1,7) + 2
18716        ,LENGTHB(anc_id_85))
18717 )
18718 
18719 WHEN anc_id_86 IS NOT NULL THEN
18720   INTO xla_ae_header_acs (
18721         ae_header_id , object_version_number
18722       , analytical_criterion_code
18723       , analytical_criterion_type_code
18724       , amb_context_code
18725       , ac1,ac2,ac3,ac4,ac5)
18726 VALUES (ae_header_id, C_OVN
18727 ,SUBSTRB(anc_id_86
18728        ,1
18729        ,INSTRB(anc_id_86,'(]',1,1) -1)
18730 ,SUBSTRB(anc_id_86
18731        ,INSTRB(anc_id_86,'(]',1,1) + 2
18732        ,INSTRB(anc_id_86,'(]',1,2) -
18733         INSTRB(anc_id_86,'(]',1,1) - 2)
18734 ,SUBSTRB(anc_id_86
18735        ,INSTRB(anc_id_86,'(]',1,2) + 2
18736        ,INSTRB(anc_id_86,'(]',1,3) -
18737         INSTRB(anc_id_86,'(]',1,2) - 2)
18738 ,SUBSTRB(anc_id_86
18739        ,INSTRB(anc_id_86,'(]',1,3) + 2
18740        ,INSTRB(anc_id_86,'(]',1,4) -
18741         INSTRB(anc_id_86,'(]',1,3) - 2)
18742 ,SUBSTRB(anc_id_86
18743        ,INSTRB(anc_id_86,'(]',1,4) + 2
18744        ,INSTRB(anc_id_86,'(]',1,5) -
18745         INSTRB(anc_id_86,'(]',1,4) - 2)
18746 ,SUBSTRB(anc_id_86
18747        ,INSTRB(anc_id_86,'(]',1,5) + 2
18748        ,INSTRB(anc_id_86,'(]',1,6) -
18749         INSTRB(anc_id_86,'(]',1,5) - 2)
18750 ,SUBSTRB(anc_id_86
18751        ,INSTRB(anc_id_86,'(]',1,6) + 2
18752        ,INSTRB(anc_id_86,'(]',1,7) -
18753         INSTRB(anc_id_86,'(]',1,6) - 2)
18754 ,SUBSTRB(anc_id_86
18755        ,INSTRB(anc_id_86,'(]',1,7) + 2
18756        ,LENGTHB(anc_id_86))
18757 )
18758 
18759 WHEN anc_id_87 IS NOT NULL THEN
18760   INTO xla_ae_header_acs (
18761         ae_header_id , object_version_number
18762       , analytical_criterion_code
18763       , analytical_criterion_type_code
18764       , amb_context_code
18765       , ac1,ac2,ac3,ac4,ac5)
18766 VALUES (ae_header_id, C_OVN
18767 ,SUBSTRB(anc_id_87
18768        ,1
18769        ,INSTRB(anc_id_87,'(]',1,1) -1)
18770 ,SUBSTRB(anc_id_87
18771        ,INSTRB(anc_id_87,'(]',1,1) + 2
18772        ,INSTRB(anc_id_87,'(]',1,2) -
18773         INSTRB(anc_id_87,'(]',1,1) - 2)
18774 ,SUBSTRB(anc_id_87
18775        ,INSTRB(anc_id_87,'(]',1,2) + 2
18776        ,INSTRB(anc_id_87,'(]',1,3) -
18777         INSTRB(anc_id_87,'(]',1,2) - 2)
18778 ,SUBSTRB(anc_id_87
18779        ,INSTRB(anc_id_87,'(]',1,3) + 2
18780        ,INSTRB(anc_id_87,'(]',1,4) -
18781         INSTRB(anc_id_87,'(]',1,3) - 2)
18782 ,SUBSTRB(anc_id_87
18783        ,INSTRB(anc_id_87,'(]',1,4) + 2
18784        ,INSTRB(anc_id_87,'(]',1,5) -
18785         INSTRB(anc_id_87,'(]',1,4) - 2)
18786 ,SUBSTRB(anc_id_87
18787        ,INSTRB(anc_id_87,'(]',1,5) + 2
18788        ,INSTRB(anc_id_87,'(]',1,6) -
18789         INSTRB(anc_id_87,'(]',1,5) - 2)
18790 ,SUBSTRB(anc_id_87
18791        ,INSTRB(anc_id_87,'(]',1,6) + 2
18792        ,INSTRB(anc_id_87,'(]',1,7) -
18793         INSTRB(anc_id_87,'(]',1,6) - 2)
18794 ,SUBSTRB(anc_id_87
18795        ,INSTRB(anc_id_87,'(]',1,7) + 2
18796        ,LENGTHB(anc_id_87))
18797 )
18798 
18799 WHEN anc_id_88 IS NOT NULL THEN
18800   INTO xla_ae_header_acs (
18801         ae_header_id , object_version_number
18802       , analytical_criterion_code
18803       , analytical_criterion_type_code
18804       , amb_context_code
18805       , ac1,ac2,ac3,ac4,ac5)
18806 VALUES (ae_header_id, C_OVN
18807 ,SUBSTRB(anc_id_88
18808        ,1
18809        ,INSTRB(anc_id_88,'(]',1,1) -1)
18810 ,SUBSTRB(anc_id_88
18811        ,INSTRB(anc_id_88,'(]',1,1) + 2
18812        ,INSTRB(anc_id_88,'(]',1,2) -
18813         INSTRB(anc_id_88,'(]',1,1) - 2)
18814 ,SUBSTRB(anc_id_88
18815        ,INSTRB(anc_id_88,'(]',1,2) + 2
18816        ,INSTRB(anc_id_88,'(]',1,3) -
18817         INSTRB(anc_id_88,'(]',1,2) - 2)
18818 ,SUBSTRB(anc_id_88
18819        ,INSTRB(anc_id_88,'(]',1,3) + 2
18820        ,INSTRB(anc_id_88,'(]',1,4) -
18821         INSTRB(anc_id_88,'(]',1,3) - 2)
18822 ,SUBSTRB(anc_id_88
18823        ,INSTRB(anc_id_88,'(]',1,4) + 2
18824        ,INSTRB(anc_id_88,'(]',1,5) -
18825         INSTRB(anc_id_88,'(]',1,4) - 2)
18826 ,SUBSTRB(anc_id_88
18827        ,INSTRB(anc_id_88,'(]',1,5) + 2
18828        ,INSTRB(anc_id_88,'(]',1,6) -
18829         INSTRB(anc_id_88,'(]',1,5) - 2)
18830 ,SUBSTRB(anc_id_88
18831        ,INSTRB(anc_id_88,'(]',1,6) + 2
18832        ,INSTRB(anc_id_88,'(]',1,7) -
18833         INSTRB(anc_id_88,'(]',1,6) - 2)
18834 ,SUBSTRB(anc_id_88
18835        ,INSTRB(anc_id_88,'(]',1,7) + 2
18836        ,LENGTHB(anc_id_88))
18837 )
18838 
18839 WHEN anc_id_89 IS NOT NULL THEN
18840   INTO xla_ae_header_acs (
18841         ae_header_id , object_version_number
18842       , analytical_criterion_code
18843       , analytical_criterion_type_code
18844       , amb_context_code
18845       , ac1,ac2,ac3,ac4,ac5)
18846 VALUES (ae_header_id, C_OVN
18847 ,SUBSTRB(anc_id_89
18848        ,1
18849        ,INSTRB(anc_id_89,'(]',1,1) -1)
18850 ,SUBSTRB(anc_id_89
18851        ,INSTRB(anc_id_89,'(]',1,1) + 2
18852        ,INSTRB(anc_id_89,'(]',1,2) -
18853         INSTRB(anc_id_89,'(]',1,1) - 2)
18854 ,SUBSTRB(anc_id_89
18855        ,INSTRB(anc_id_89,'(]',1,2) + 2
18856        ,INSTRB(anc_id_89,'(]',1,3) -
18857         INSTRB(anc_id_89,'(]',1,2) - 2)
18858 ,SUBSTRB(anc_id_89
18859        ,INSTRB(anc_id_89,'(]',1,3) + 2
18860        ,INSTRB(anc_id_89,'(]',1,4) -
18861         INSTRB(anc_id_89,'(]',1,3) - 2)
18862 ,SUBSTRB(anc_id_89
18863        ,INSTRB(anc_id_89,'(]',1,4) + 2
18864        ,INSTRB(anc_id_89,'(]',1,5) -
18865         INSTRB(anc_id_89,'(]',1,4) - 2)
18866 ,SUBSTRB(anc_id_89
18867        ,INSTRB(anc_id_89,'(]',1,5) + 2
18868        ,INSTRB(anc_id_89,'(]',1,6) -
18869         INSTRB(anc_id_89,'(]',1,5) - 2)
18870 ,SUBSTRB(anc_id_89
18871        ,INSTRB(anc_id_89,'(]',1,6) + 2
18872        ,INSTRB(anc_id_89,'(]',1,7) -
18873         INSTRB(anc_id_89,'(]',1,6) - 2)
18874 ,SUBSTRB(anc_id_89
18875        ,INSTRB(anc_id_89,'(]',1,7) + 2
18876        ,LENGTHB(anc_id_89))
18877 )
18878 
18879 WHEN anc_id_90 IS NOT NULL THEN
18880   INTO xla_ae_header_acs (
18881         ae_header_id , object_version_number
18882       , analytical_criterion_code
18883       , analytical_criterion_type_code
18884       , amb_context_code
18885       , ac1,ac2,ac3,ac4,ac5)
18886 VALUES (ae_header_id, C_OVN
18887 ,SUBSTRB(anc_id_90
18888        ,1
18889        ,INSTRB(anc_id_90,'(]',1,1) -1)
18890 ,SUBSTRB(anc_id_90
18891        ,INSTRB(anc_id_90,'(]',1,1) + 2
18892        ,INSTRB(anc_id_90,'(]',1,2) -
18893         INSTRB(anc_id_90,'(]',1,1) - 2)
18894 ,SUBSTRB(anc_id_90
18895        ,INSTRB(anc_id_90,'(]',1,2) + 2
18896        ,INSTRB(anc_id_90,'(]',1,3) -
18897         INSTRB(anc_id_90,'(]',1,2) - 2)
18898 ,SUBSTRB(anc_id_90
18899        ,INSTRB(anc_id_90,'(]',1,3) + 2
18900        ,INSTRB(anc_id_90,'(]',1,4) -
18901         INSTRB(anc_id_90,'(]',1,3) - 2)
18902 ,SUBSTRB(anc_id_90
18903        ,INSTRB(anc_id_90,'(]',1,4) + 2
18904        ,INSTRB(anc_id_90,'(]',1,5) -
18905         INSTRB(anc_id_90,'(]',1,4) - 2)
18906 ,SUBSTRB(anc_id_90
18907        ,INSTRB(anc_id_90,'(]',1,5) + 2
18908        ,INSTRB(anc_id_90,'(]',1,6) -
18909         INSTRB(anc_id_90,'(]',1,5) - 2)
18910 ,SUBSTRB(anc_id_90
18911        ,INSTRB(anc_id_90,'(]',1,6) + 2
18912        ,INSTRB(anc_id_90,'(]',1,7) -
18913         INSTRB(anc_id_90,'(]',1,6) - 2)
18914 ,SUBSTRB(anc_id_90
18915        ,INSTRB(anc_id_90,'(]',1,7) + 2
18916        ,LENGTHB(anc_id_90))
18917 )
18918 
18919 WHEN anc_id_91 IS NOT NULL THEN
18920   INTO xla_ae_header_acs (
18921         ae_header_id , object_version_number
18922       , analytical_criterion_code
18923       , analytical_criterion_type_code
18924       , amb_context_code
18925       , ac1,ac2,ac3,ac4,ac5)
18926 VALUES (ae_header_id, C_OVN
18927 ,SUBSTRB(anc_id_91
18928        ,1
18929        ,INSTRB(anc_id_91,'(]',1,1) -1)
18930 ,SUBSTRB(anc_id_91
18931        ,INSTRB(anc_id_91,'(]',1,1) + 2
18932        ,INSTRB(anc_id_91,'(]',1,2) -
18933         INSTRB(anc_id_91,'(]',1,1) - 2)
18934 ,SUBSTRB(anc_id_91
18935        ,INSTRB(anc_id_91,'(]',1,2) + 2
18936        ,INSTRB(anc_id_91,'(]',1,3) -
18937         INSTRB(anc_id_91,'(]',1,2) - 2)
18938 ,SUBSTRB(anc_id_91
18939        ,INSTRB(anc_id_91,'(]',1,3) + 2
18940        ,INSTRB(anc_id_91,'(]',1,4) -
18941         INSTRB(anc_id_91,'(]',1,3) - 2)
18942 ,SUBSTRB(anc_id_91
18943        ,INSTRB(anc_id_91,'(]',1,4) + 2
18944        ,INSTRB(anc_id_91,'(]',1,5) -
18945         INSTRB(anc_id_91,'(]',1,4) - 2)
18946 ,SUBSTRB(anc_id_91
18947        ,INSTRB(anc_id_91,'(]',1,5) + 2
18948        ,INSTRB(anc_id_91,'(]',1,6) -
18949         INSTRB(anc_id_91,'(]',1,5) - 2)
18950 ,SUBSTRB(anc_id_91
18951        ,INSTRB(anc_id_91,'(]',1,6) + 2
18952        ,INSTRB(anc_id_91,'(]',1,7) -
18953         INSTRB(anc_id_91,'(]',1,6) - 2)
18954 ,SUBSTRB(anc_id_91
18955        ,INSTRB(anc_id_91,'(]',1,7) + 2
18956        ,LENGTHB(anc_id_91))
18957 )
18958 
18959 WHEN anc_id_92 IS NOT NULL THEN
18960   INTO xla_ae_header_acs (
18961         ae_header_id , object_version_number
18962       , analytical_criterion_code
18963       , analytical_criterion_type_code
18964       , amb_context_code
18965       , ac1,ac2,ac3,ac4,ac5)
18966 VALUES (ae_header_id, C_OVN
18967 ,SUBSTRB(anc_id_92
18968        ,1
18969        ,INSTRB(anc_id_92,'(]',1,1) -1)
18970 ,SUBSTRB(anc_id_92
18971        ,INSTRB(anc_id_92,'(]',1,1) + 2
18972        ,INSTRB(anc_id_92,'(]',1,2) -
18973         INSTRB(anc_id_92,'(]',1,1) - 2)
18974 ,SUBSTRB(anc_id_92
18975        ,INSTRB(anc_id_92,'(]',1,2) + 2
18976        ,INSTRB(anc_id_92,'(]',1,3) -
18977         INSTRB(anc_id_92,'(]',1,2) - 2)
18978 ,SUBSTRB(anc_id_92
18979        ,INSTRB(anc_id_92,'(]',1,3) + 2
18980        ,INSTRB(anc_id_92,'(]',1,4) -
18981         INSTRB(anc_id_92,'(]',1,3) - 2)
18982 ,SUBSTRB(anc_id_92
18983        ,INSTRB(anc_id_92,'(]',1,4) + 2
18984        ,INSTRB(anc_id_92,'(]',1,5) -
18985         INSTRB(anc_id_92,'(]',1,4) - 2)
18986 ,SUBSTRB(anc_id_92
18987        ,INSTRB(anc_id_92,'(]',1,5) + 2
18988        ,INSTRB(anc_id_92,'(]',1,6) -
18989         INSTRB(anc_id_92,'(]',1,5) - 2)
18990 ,SUBSTRB(anc_id_92
18991        ,INSTRB(anc_id_92,'(]',1,6) + 2
18992        ,INSTRB(anc_id_92,'(]',1,7) -
18993         INSTRB(anc_id_92,'(]',1,6) - 2)
18994 ,SUBSTRB(anc_id_92
18995        ,INSTRB(anc_id_92,'(]',1,7) + 2
18996        ,LENGTHB(anc_id_92))
18997 )
18998 
18999 WHEN anc_id_93 IS NOT NULL THEN
19000   INTO xla_ae_header_acs (
19001         ae_header_id , object_version_number
19002       , analytical_criterion_code
19003       , analytical_criterion_type_code
19004       , amb_context_code
19005       , ac1,ac2,ac3,ac4,ac5)
19006 VALUES (ae_header_id, C_OVN
19007 ,SUBSTRB(anc_id_93
19008        ,1
19009        ,INSTRB(anc_id_93,'(]',1,1) -1)
19010 ,SUBSTRB(anc_id_93
19011        ,INSTRB(anc_id_93,'(]',1,1) + 2
19012        ,INSTRB(anc_id_93,'(]',1,2) -
19013         INSTRB(anc_id_93,'(]',1,1) - 2)
19014 ,SUBSTRB(anc_id_93
19015        ,INSTRB(anc_id_93,'(]',1,2) + 2
19016        ,INSTRB(anc_id_93,'(]',1,3) -
19017         INSTRB(anc_id_93,'(]',1,2) - 2)
19018 ,SUBSTRB(anc_id_93
19019        ,INSTRB(anc_id_93,'(]',1,3) + 2
19020        ,INSTRB(anc_id_93,'(]',1,4) -
19021         INSTRB(anc_id_93,'(]',1,3) - 2)
19022 ,SUBSTRB(anc_id_93
19023        ,INSTRB(anc_id_93,'(]',1,4) + 2
19024        ,INSTRB(anc_id_93,'(]',1,5) -
19025         INSTRB(anc_id_93,'(]',1,4) - 2)
19026 ,SUBSTRB(anc_id_93
19027        ,INSTRB(anc_id_93,'(]',1,5) + 2
19028        ,INSTRB(anc_id_93,'(]',1,6) -
19029         INSTRB(anc_id_93,'(]',1,5) - 2)
19030 ,SUBSTRB(anc_id_93
19031        ,INSTRB(anc_id_93,'(]',1,6) + 2
19032        ,INSTRB(anc_id_93,'(]',1,7) -
19033         INSTRB(anc_id_93,'(]',1,6) - 2)
19034 ,SUBSTRB(anc_id_93
19035        ,INSTRB(anc_id_93,'(]',1,7) + 2
19036        ,LENGTHB(anc_id_93))
19037 )
19038 
19039 WHEN anc_id_94 IS NOT NULL THEN
19040   INTO xla_ae_header_acs (
19041         ae_header_id , object_version_number
19042       , analytical_criterion_code
19043       , analytical_criterion_type_code
19044       , amb_context_code
19045       , ac1,ac2,ac3,ac4,ac5)
19046 VALUES (ae_header_id, C_OVN
19047 ,SUBSTRB(anc_id_94
19048        ,1
19049        ,INSTRB(anc_id_94,'(]',1,1) -1)
19050 ,SUBSTRB(anc_id_94
19051        ,INSTRB(anc_id_94,'(]',1,1) + 2
19052        ,INSTRB(anc_id_94,'(]',1,2) -
19053         INSTRB(anc_id_94,'(]',1,1) - 2)
19054 ,SUBSTRB(anc_id_94
19055        ,INSTRB(anc_id_94,'(]',1,2) + 2
19056        ,INSTRB(anc_id_94,'(]',1,3) -
19057         INSTRB(anc_id_94,'(]',1,2) - 2)
19058 ,SUBSTRB(anc_id_94
19059        ,INSTRB(anc_id_94,'(]',1,3) + 2
19060        ,INSTRB(anc_id_94,'(]',1,4) -
19061         INSTRB(anc_id_94,'(]',1,3) - 2)
19062 ,SUBSTRB(anc_id_94
19063        ,INSTRB(anc_id_94,'(]',1,4) + 2
19064        ,INSTRB(anc_id_94,'(]',1,5) -
19065         INSTRB(anc_id_94,'(]',1,4) - 2)
19066 ,SUBSTRB(anc_id_94
19067        ,INSTRB(anc_id_94,'(]',1,5) + 2
19068        ,INSTRB(anc_id_94,'(]',1,6) -
19069         INSTRB(anc_id_94,'(]',1,5) - 2)
19070 ,SUBSTRB(anc_id_94
19071        ,INSTRB(anc_id_94,'(]',1,6) + 2
19072        ,INSTRB(anc_id_94,'(]',1,7) -
19073         INSTRB(anc_id_94,'(]',1,6) - 2)
19074 ,SUBSTRB(anc_id_94
19075        ,INSTRB(anc_id_94,'(]',1,7) + 2
19076        ,LENGTHB(anc_id_94))
19077 )
19078 
19079 WHEN anc_id_95 IS NOT NULL THEN
19080   INTO xla_ae_header_acs (
19081         ae_header_id , object_version_number
19082       , analytical_criterion_code
19083       , analytical_criterion_type_code
19084       , amb_context_code
19085       , ac1,ac2,ac3,ac4,ac5)
19086 VALUES (ae_header_id, C_OVN
19087 ,SUBSTRB(anc_id_95
19088        ,1
19089        ,INSTRB(anc_id_95,'(]',1,1) -1)
19090 ,SUBSTRB(anc_id_95
19091        ,INSTRB(anc_id_95,'(]',1,1) + 2
19092        ,INSTRB(anc_id_95,'(]',1,2) -
19093         INSTRB(anc_id_95,'(]',1,1) - 2)
19094 ,SUBSTRB(anc_id_95
19095        ,INSTRB(anc_id_95,'(]',1,2) + 2
19096        ,INSTRB(anc_id_95,'(]',1,3) -
19097         INSTRB(anc_id_95,'(]',1,2) - 2)
19098 ,SUBSTRB(anc_id_95
19099        ,INSTRB(anc_id_95,'(]',1,3) + 2
19100        ,INSTRB(anc_id_95,'(]',1,4) -
19101         INSTRB(anc_id_95,'(]',1,3) - 2)
19102 ,SUBSTRB(anc_id_95
19103        ,INSTRB(anc_id_95,'(]',1,4) + 2
19104        ,INSTRB(anc_id_95,'(]',1,5) -
19105         INSTRB(anc_id_95,'(]',1,4) - 2)
19106 ,SUBSTRB(anc_id_95
19107        ,INSTRB(anc_id_95,'(]',1,5) + 2
19108        ,INSTRB(anc_id_95,'(]',1,6) -
19109         INSTRB(anc_id_95,'(]',1,5) - 2)
19110 ,SUBSTRB(anc_id_95
19111        ,INSTRB(anc_id_95,'(]',1,6) + 2
19112        ,INSTRB(anc_id_95,'(]',1,7) -
19113         INSTRB(anc_id_95,'(]',1,6) - 2)
19114 ,SUBSTRB(anc_id_95
19115        ,INSTRB(anc_id_95,'(]',1,7) + 2
19116        ,LENGTHB(anc_id_95))
19117 )
19118 
19119 WHEN anc_id_96 IS NOT NULL THEN
19120   INTO xla_ae_header_acs (
19121         ae_header_id , object_version_number
19122       , analytical_criterion_code
19123       , analytical_criterion_type_code
19124       , amb_context_code
19125       , ac1,ac2,ac3,ac4,ac5)
19126 VALUES (ae_header_id, C_OVN
19127 ,SUBSTRB(anc_id_96
19128        ,1
19129        ,INSTRB(anc_id_96,'(]',1,1) -1)
19130 ,SUBSTRB(anc_id_96
19131        ,INSTRB(anc_id_96,'(]',1,1) + 2
19132        ,INSTRB(anc_id_96,'(]',1,2) -
19133         INSTRB(anc_id_96,'(]',1,1) - 2)
19134 ,SUBSTRB(anc_id_96
19135        ,INSTRB(anc_id_96,'(]',1,2) + 2
19136        ,INSTRB(anc_id_96,'(]',1,3) -
19137         INSTRB(anc_id_96,'(]',1,2) - 2)
19138 ,SUBSTRB(anc_id_96
19139        ,INSTRB(anc_id_96,'(]',1,3) + 2
19140        ,INSTRB(anc_id_96,'(]',1,4) -
19141         INSTRB(anc_id_96,'(]',1,3) - 2)
19142 ,SUBSTRB(anc_id_96
19143        ,INSTRB(anc_id_96,'(]',1,4) + 2
19144        ,INSTRB(anc_id_96,'(]',1,5) -
19145         INSTRB(anc_id_96,'(]',1,4) - 2)
19146 ,SUBSTRB(anc_id_96
19147        ,INSTRB(anc_id_96,'(]',1,5) + 2
19148        ,INSTRB(anc_id_96,'(]',1,6) -
19149         INSTRB(anc_id_96,'(]',1,5) - 2)
19150 ,SUBSTRB(anc_id_96
19151        ,INSTRB(anc_id_96,'(]',1,6) + 2
19152        ,INSTRB(anc_id_96,'(]',1,7) -
19153         INSTRB(anc_id_96,'(]',1,6) - 2)
19154 ,SUBSTRB(anc_id_96
19155        ,INSTRB(anc_id_96,'(]',1,7) + 2
19156        ,LENGTHB(anc_id_96))
19157 )
19158 
19159 WHEN anc_id_97 IS NOT NULL THEN
19160   INTO xla_ae_header_acs (
19161         ae_header_id , object_version_number
19162       , analytical_criterion_code
19163       , analytical_criterion_type_code
19164       , amb_context_code
19165       , ac1,ac2,ac3,ac4,ac5)
19166 VALUES (ae_header_id, C_OVN
19167 ,SUBSTRB(anc_id_97
19168        ,1
19169        ,INSTRB(anc_id_97,'(]',1,1) -1)
19170 ,SUBSTRB(anc_id_97
19171        ,INSTRB(anc_id_97,'(]',1,1) + 2
19172        ,INSTRB(anc_id_97,'(]',1,2) -
19173         INSTRB(anc_id_97,'(]',1,1) - 2)
19174 ,SUBSTRB(anc_id_97
19175        ,INSTRB(anc_id_97,'(]',1,2) + 2
19176        ,INSTRB(anc_id_97,'(]',1,3) -
19177         INSTRB(anc_id_97,'(]',1,2) - 2)
19178 ,SUBSTRB(anc_id_97
19179        ,INSTRB(anc_id_97,'(]',1,3) + 2
19180        ,INSTRB(anc_id_97,'(]',1,4) -
19181         INSTRB(anc_id_97,'(]',1,3) - 2)
19182 ,SUBSTRB(anc_id_97
19183        ,INSTRB(anc_id_97,'(]',1,4) + 2
19184        ,INSTRB(anc_id_97,'(]',1,5) -
19185         INSTRB(anc_id_97,'(]',1,4) - 2)
19186 ,SUBSTRB(anc_id_97
19187        ,INSTRB(anc_id_97,'(]',1,5) + 2
19188        ,INSTRB(anc_id_97,'(]',1,6) -
19189         INSTRB(anc_id_97,'(]',1,5) - 2)
19190 ,SUBSTRB(anc_id_97
19191        ,INSTRB(anc_id_97,'(]',1,6) + 2
19192        ,INSTRB(anc_id_97,'(]',1,7) -
19193         INSTRB(anc_id_97,'(]',1,6) - 2)
19194 ,SUBSTRB(anc_id_97
19195        ,INSTRB(anc_id_97,'(]',1,7) + 2
19196        ,LENGTHB(anc_id_97))
19197 )
19198 
19199 WHEN anc_id_98 IS NOT NULL THEN
19200   INTO xla_ae_header_acs (
19201         ae_header_id , object_version_number
19202       , analytical_criterion_code
19203       , analytical_criterion_type_code
19204       , amb_context_code
19205       , ac1,ac2,ac3,ac4,ac5)
19206 VALUES (ae_header_id, C_OVN
19207 ,SUBSTRB(anc_id_98
19208        ,1
19209        ,INSTRB(anc_id_98,'(]',1,1) -1)
19210 ,SUBSTRB(anc_id_98
19211        ,INSTRB(anc_id_98,'(]',1,1) + 2
19212        ,INSTRB(anc_id_98,'(]',1,2) -
19213         INSTRB(anc_id_98,'(]',1,1) - 2)
19214 ,SUBSTRB(anc_id_98
19215        ,INSTRB(anc_id_98,'(]',1,2) + 2
19216        ,INSTRB(anc_id_98,'(]',1,3) -
19217         INSTRB(anc_id_98,'(]',1,2) - 2)
19218 ,SUBSTRB(anc_id_98
19219        ,INSTRB(anc_id_98,'(]',1,3) + 2
19220        ,INSTRB(anc_id_98,'(]',1,4) -
19221         INSTRB(anc_id_98,'(]',1,3) - 2)
19222 ,SUBSTRB(anc_id_98
19223        ,INSTRB(anc_id_98,'(]',1,4) + 2
19224        ,INSTRB(anc_id_98,'(]',1,5) -
19225         INSTRB(anc_id_98,'(]',1,4) - 2)
19226 ,SUBSTRB(anc_id_98
19227        ,INSTRB(anc_id_98,'(]',1,5) + 2
19228        ,INSTRB(anc_id_98,'(]',1,6) -
19229         INSTRB(anc_id_98,'(]',1,5) - 2)
19230 ,SUBSTRB(anc_id_98
19231        ,INSTRB(anc_id_98,'(]',1,6) + 2
19232        ,INSTRB(anc_id_98,'(]',1,7) -
19233         INSTRB(anc_id_98,'(]',1,6) - 2)
19234 ,SUBSTRB(anc_id_98
19235        ,INSTRB(anc_id_98,'(]',1,7) + 2
19236        ,LENGTHB(anc_id_98))
19237 )
19238 
19239 WHEN anc_id_99 IS NOT NULL THEN
19240   INTO xla_ae_header_acs (
19241         ae_header_id , object_version_number
19242       , analytical_criterion_code
19243       , analytical_criterion_type_code
19244       , amb_context_code
19245       , ac1,ac2,ac3,ac4,ac5)
19246 VALUES (ae_header_id, C_OVN
19247 ,SUBSTRB(anc_id_99
19248        ,1
19249        ,INSTRB(anc_id_99,'(]',1,1) -1)
19250 ,SUBSTRB(anc_id_99
19251        ,INSTRB(anc_id_99,'(]',1,1) + 2
19252        ,INSTRB(anc_id_99,'(]',1,2) -
19253         INSTRB(anc_id_99,'(]',1,1) - 2)
19254 ,SUBSTRB(anc_id_99
19255        ,INSTRB(anc_id_99,'(]',1,2) + 2
19256        ,INSTRB(anc_id_99,'(]',1,3) -
19257         INSTRB(anc_id_99,'(]',1,2) - 2)
19258 ,SUBSTRB(anc_id_99
19259        ,INSTRB(anc_id_99,'(]',1,3) + 2
19260        ,INSTRB(anc_id_99,'(]',1,4) -
19261         INSTRB(anc_id_99,'(]',1,3) - 2)
19262 ,SUBSTRB(anc_id_99
19263        ,INSTRB(anc_id_99,'(]',1,4) + 2
19264        ,INSTRB(anc_id_99,'(]',1,5) -
19265         INSTRB(anc_id_99,'(]',1,4) - 2)
19266 ,SUBSTRB(anc_id_99
19267        ,INSTRB(anc_id_99,'(]',1,5) + 2
19268        ,INSTRB(anc_id_99,'(]',1,6) -
19269         INSTRB(anc_id_99,'(]',1,5) - 2)
19270 ,SUBSTRB(anc_id_99
19271        ,INSTRB(anc_id_99,'(]',1,6) + 2
19272        ,INSTRB(anc_id_99,'(]',1,7) -
19273         INSTRB(anc_id_99,'(]',1,6) - 2)
19274 ,SUBSTRB(anc_id_99
19275        ,INSTRB(anc_id_99,'(]',1,7) + 2
19276        ,LENGTHB(anc_id_99))
19277 )
19278 
19279 WHEN anc_id_100 IS NOT NULL THEN
19280   INTO xla_ae_header_acs (
19281         ae_header_id , object_version_number
19282       , analytical_criterion_code
19283       , analytical_criterion_type_code
19284       , amb_context_code
19285       , ac1,ac2,ac3,ac4,ac5)
19286 VALUES (ae_header_id, C_OVN
19287 ,SUBSTRB(anc_id_100
19288        ,1
19289        ,INSTRB(anc_id_100,'(]',1,1) -1)
19290 ,SUBSTRB(anc_id_100
19291        ,INSTRB(anc_id_100,'(]',1,1) + 2
19292        ,INSTRB(anc_id_100,'(]',1,2) -
19293         INSTRB(anc_id_100,'(]',1,1) - 2)
19294 ,SUBSTRB(anc_id_100
19295        ,INSTRB(anc_id_100,'(]',1,2) + 2
19296        ,INSTRB(anc_id_100,'(]',1,3) -
19297         INSTRB(anc_id_100,'(]',1,2) - 2)
19298 ,SUBSTRB(anc_id_100
19299        ,INSTRB(anc_id_100,'(]',1,3) + 2
19300        ,INSTRB(anc_id_100,'(]',1,4) -
19301         INSTRB(anc_id_100,'(]',1,3) - 2)
19302 ,SUBSTRB(anc_id_100
19303        ,INSTRB(anc_id_100,'(]',1,4) + 2
19304        ,INSTRB(anc_id_100,'(]',1,5) -
19305         INSTRB(anc_id_100,'(]',1,4) - 2)
19306 ,SUBSTRB(anc_id_100
19307        ,INSTRB(anc_id_100,'(]',1,5) + 2
19308        ,INSTRB(anc_id_100,'(]',1,6) -
19309         INSTRB(anc_id_100,'(]',1,5) - 2)
19310 ,SUBSTRB(anc_id_100
19311        ,INSTRB(anc_id_100,'(]',1,6) + 2
19312        ,INSTRB(anc_id_100,'(]',1,7) -
19313         INSTRB(anc_id_100,'(]',1,6) - 2)
19314 ,SUBSTRB(anc_id_100
19315        ,INSTRB(anc_id_100,'(]',1,7) + 2
19316        ,LENGTHB(anc_id_100))
19317 )
19318 SELECT  ae_header_id
19319       , anc_id_1
19320       , anc_id_2
19321       , anc_id_3
19322       , anc_id_4
19323       , anc_id_5
19324       , anc_id_6
19325       , anc_id_7
19326       , anc_id_8
19327       , anc_id_9
19328       , anc_id_10
19329       , anc_id_11
19330       , anc_id_12
19331       , anc_id_13
19332       , anc_id_14
19333       , anc_id_15
19334       , anc_id_16
19335       , anc_id_17
19336       , anc_id_18
19337       , anc_id_19
19338       , anc_id_20
19339       , anc_id_21
19340       , anc_id_22
19341       , anc_id_23
19342       , anc_id_24
19343       , anc_id_25
19344       , anc_id_26
19345       , anc_id_27
19346       , anc_id_28
19347       , anc_id_29
19348       , anc_id_30
19349       , anc_id_31
19350       , anc_id_32
19351       , anc_id_33
19352       , anc_id_34
19353       , anc_id_35
19354       , anc_id_36
19355       , anc_id_37
19356       , anc_id_38
19357       , anc_id_39
19358       , anc_id_40
19359       , anc_id_41
19360       , anc_id_42
19361       , anc_id_43
19362       , anc_id_44
19363       , anc_id_45
19364       , anc_id_46
19365       , anc_id_47
19366       , anc_id_48
19367       , anc_id_49
19368       , anc_id_50
19369       , anc_id_51
19370       , anc_id_52
19371       , anc_id_53
19372       , anc_id_54
19373       , anc_id_55
19374       , anc_id_56
19375       , anc_id_57
19376       , anc_id_58
19377       , anc_id_59
19378       , anc_id_60
19379       , anc_id_61
19380       , anc_id_62
19381       , anc_id_63
19382       , anc_id_64
19383       , anc_id_65
19384       , anc_id_66
19385       , anc_id_67
19386       , anc_id_68
19387       , anc_id_69
19388       , anc_id_70
19389       , anc_id_71
19390       , anc_id_72
19391       , anc_id_73
19392       , anc_id_74
19393       , anc_id_75
19394       , anc_id_76
19395       , anc_id_77
19396       , anc_id_78
19397       , anc_id_79
19398       , anc_id_80
19399       , anc_id_81
19400       , anc_id_82
19401       , anc_id_83
19402       , anc_id_84
19403       , anc_id_85
19404       , anc_id_86
19405       , anc_id_87
19406       , anc_id_88
19407       , anc_id_89
19408       , anc_id_90
19409       , anc_id_91
19410       , anc_id_92
19411       , anc_id_93
19412       , anc_id_94
19413       , anc_id_95
19414       , anc_id_96
19415       , anc_id_97
19416       , anc_id_98
19417       , anc_id_99
19418       , anc_id_100
19419  FROM  xla_ae_headers_gt
19420 WHERE  ae_header_id is not null;
19421 
19422 --
19423 IF (C_LEVEL_EVENT >= g_log_level) THEN
19424       trace
19425          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
19426          ,p_level    => C_LEVEL_EVENT
19427          ,p_module   => l_log_module);
19428 END IF;
19429 
19430 --
19431 EXCEPTION
19432 WHEN OTHERS THEN
19433   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19434          trace
19435             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
19436             ,p_level    => C_LEVEL_EXCEPTION
19437             ,p_module   => l_log_module);
19438   END IF;
19439 
19440   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
19441                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
19442                                     ,p_token_1      => 'ERROR'
19443                                     ,p_value_1      => sqlerrm
19444                                     );
19445 END;
19446 --
19447 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19448 
19449       trace
19450          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
19451          ,p_level    => C_LEVEL_PROCEDURE
19452          ,p_module   => l_log_module);
19453 
19454       trace
19455          (p_msg      => 'END of InsertHdrAnalyticalCriteria100'
19456          ,p_level    => C_LEVEL_PROCEDURE
19457          ,p_module   => l_log_module);
19458 END IF;
19459 --
19460 EXCEPTION
19461 WHEN xla_exceptions_pkg.application_exception THEN
19462   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19463        trace
19464            (p_msg      => 'Error. = '||sqlerrm
19465            ,p_level    => C_LEVEL_PROCEDURE
19466            ,p_module   => l_log_module);
19467   END IF;
19468   RAISE;
19469 WHEN OTHERS  THEN
19470  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19471        trace
19472            (p_msg      => 'Error. = '||sqlerrm
19473            ,p_level    => C_LEVEL_PROCEDURE
19474            ,p_module   => l_log_module);
19475   END IF;
19476   xla_exceptions_pkg.raise_message
19477                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria100');
19478    --
19479 END InsertHdrAnalyticalCriteria100;
19480 --
19481 /*======================================================================+
19482 |                                                                       |
19483 | Insert final headers and distribution links                           |
19484 |                                                                       |
19485 | Returns 0 if lines inserted in final tables                           |
19486 | Otherwise 2 (if no lines inserted in final tables)                    |
19487 +======================================================================*/
19488 --
19489 FUNCTION InsertJournalEntries
19490 (p_application_id         IN INTEGER
19491 ,p_accounting_batch_id    IN NUMBER
19492 ,p_end_date               IN DATE     -- 4262811
19493 -- bulk performance
19494 ,p_accounting_mode        IN VARCHAR2
19495 ,p_budgetary_control_mode IN VARCHAR2) -- 4458381 Public Sector Enh
19496 RETURN NUMBER
19497 IS
19498   l_result             NUMBER;
19499   l_log_module         VARCHAR2(240);
19500 BEGIN
19501 
19502   --
19503   IF g_log_enabled THEN
19504     l_log_module := C_DEFAULT_MODULE||'.InsertJournalEntries';
19505   END IF;
19506   --
19507   IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19508     trace(p_msg      => 'BEGIN of InsertJournalEntries'
19509          ,p_level    => C_LEVEL_PROCEDURE
19510          ,p_module   => l_log_module);
19511   END IF;
19512   --
19513   SetStandardWhoColumn;
19514   --l_result := XLA_AE_CODE_COMBINATION_PKG.BuildCcids;
19515 
19516   --=========================
19517   -- Insert journal entries
19518   --=========================
19519 
19520   l_result := 0;
19521   GetLineNumber;
19522 
19523   IF (InsertLines(p_application_id, p_budgetary_control_mode) +
19524       InsertHeaders(p_application_id,p_accounting_batch_id
19525                    ,p_end_date  -- 4262811
19526                    -- bulk performance
19527                    ,p_accounting_mode) > 0 ) THEN
19528 
19529       InsertLinks(p_application_id);
19530       AdjustMpaLine(p_application_id);   -- 4262811b
19531 
19532       --
19533       -- Retrieve the number ACs assigned. Call Insert ACs only when
19534       -- ACs are assigned.
19535       --
19536       g_line_ac_count := xla_analytical_criteria_pkg.get_line_ac_count;
19537       g_hdr_ac_count  := xla_analytical_criteria_pkg.get_hdr_ac_count;
19538 
19539       IF g_line_ac_count > 0 THEN
19540          InsertAnalyticalCriteria;
19541       END IF;
19542 
19543       IF g_hdr_ac_count > 0 THEN
19544          InsertHdrAnalyticalCriteria;
19545       END IF;
19546    -- AdjustMpaRevLine(p_application_id);   -- added for 4669308, removed for 5017009
19547 
19548       l_result := 0;
19549 
19550     ELSE
19551       l_result:= 2;
19552     END IF;
19553 
19554   --
19555   IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19556       trace(p_msg      => 'return value. = '||TO_CHAR(l_result)
19557            ,p_level    => C_LEVEL_PROCEDURE
19558            ,p_module   => l_log_module);
19559       trace(p_msg      => 'END of InsertJournalEntries'
19560            ,p_level    => C_LEVEL_PROCEDURE
19561            ,p_module   => l_log_module);
19562   END IF;
19563   --
19564   RETURN l_result;
19565 EXCEPTION
19566 WHEN xla_exceptions_pkg.application_exception THEN
19567  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19568        trace
19569            (p_msg      => 'Error. = '||sqlerrm
19570            ,p_level    => C_LEVEL_PROCEDURE
19571            ,p_module   => l_log_module);
19572   END IF;
19573   RAISE;
19574 WHEN OTHERS  THEN
19575   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19576        trace
19577            (p_msg      => 'Error. = '||sqlerrm
19578            ,p_level    => C_LEVEL_PROCEDURE
19579            ,p_module   => l_log_module);
19580   END IF;
19581   xla_exceptions_pkg.raise_message
19582                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertJournalEntries');
19583    --
19584 END InsertJournalEntries;
19585 --
19586 
19587 /*======================================================================+
19588 |                                                                       |
19589 | Public PROCEDURE - 4219869                                            |
19590 |                                                                       |
19591 |  Update the journal entry header status for specified balance type.   |
19592 +======================================================================*/
19593 --
19594 PROCEDURE UpdateJournalEntryStatus(  p_hdr_idx              IN NUMBER
19595                                    , p_balance_type_code    IN VARCHAR2
19596 )
19597 IS
19598 l_log_module         VARCHAR2(240);
19599 BEGIN
19600 IF g_log_enabled THEN
19601       l_log_module := C_DEFAULT_MODULE||'.UpdateJournalEntryStatus';
19602 END IF;
19603 --
19604 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19605 trace
19606      (p_msg      => 'BEGIN of UpdateJournalEntryStatus'
19607      ,p_level    => C_LEVEL_PROCEDURE
19608      ,p_module   => l_log_module);
19609 END IF;
19610 
19611 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19612     trace
19613          (p_msg      => 'g_global_status [0 is valid, 1 is invalid] = '||g_global_status
19614          ,p_level    => C_LEVEL_STATEMENT
19615          ,p_module   => l_log_module);
19616 END IF;
19617 
19618 IF g_global_status = C_INVALID THEN
19619    CASE p_balance_type_code
19620       WHEN 'A' THEN
19621          XLA_AE_HEADER_PKG.g_rec_header_new.array_actual_status(p_hdr_idx) := C_INVALID;
19622       WHEN 'B' THEN
19623          XLA_AE_HEADER_PKG.g_rec_header_new.array_budget_status(p_hdr_idx) := C_INVALID;
19624       WHEN 'E' THEN
19625          XLA_AE_HEADER_PKG.g_rec_header_new.array_encumbrance_status(p_hdr_idx) := C_INVALID;
19626    END CASE;
19627    --
19628    -- update event status on the header record to invalid if the line created is invalid.
19629    --
19630    XLA_AE_HEADER_PKG.g_rec_header_new.array_event_status(p_hdr_idx) := 'I';
19631    --
19632    -- reset the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
19633    --
19634    g_global_status := C_VALID;
19635    --
19636 END IF;
19637 
19638 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19639 trace
19640      (p_msg      => 'END of UpdateJournalEntryStatus'
19641      ,p_level    => C_LEVEL_PROCEDURE
19642      ,p_module   => l_log_module);
19643 END IF;
19644 
19645 EXCEPTION
19646 --
19647 WHEN xla_exceptions_pkg.application_exception THEN
19648   RAISE;
19649 WHEN OTHERS  THEN
19650        xla_exceptions_pkg.raise_message
19651                (p_location => 'xla_ae_journal_entry_pkg.UpdateJournalEntryStatus');
19652   --
19653 END UpdateJournalEntryStatus;
19654 
19655 /*======================================================================+
19656 |                                                                       |
19657 | Public PROCEDURE - 4262811 (for MPA)                                  |
19658 |                                                                       |
19659 |  Update the journal entry header status for specified balance type.   |
19660 |                                                                       |
19661 |  Parameter: p_hdr_idx                                                 |
19662 |                                                                       |
19663 +======================================================================*/
19664 --
19665 PROCEDURE UpdateJournalEntryStatus(  p_hdr_idx              IN NUMBER
19666 )
19667 IS
19668 l_log_module         VARCHAR2(240);
19669 BEGIN
19670 IF g_log_enabled THEN
19671       l_log_module := C_DEFAULT_MODULE||'.UpdateJournalEntryStatus - p_hdr_idx';
19672 END IF;
19673 --
19674 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19675 trace
19676      (p_msg      => 'BEGIN of UpdateJournalEntryStatus - p_hdr_idx'
19677      ,p_level    => C_LEVEL_PROCEDURE
19678      ,p_module   => l_log_module);
19679 END IF;
19680 
19681 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19682     trace
19683          (p_msg      => 'g_global_status [0 is valid, 1 is invalid] = '||g_global_status -- 5019460
19684          ,p_level    => C_LEVEL_STATEMENT
19685          ,p_module   => l_log_module);
19686 END IF;
19687 
19688 IF g_global_status = C_INVALID THEN
19689 
19690    XLA_AE_HEADER_PKG.g_rec_header_new.array_actual_status(p_hdr_idx)      := C_INVALID;
19691    XLA_AE_HEADER_PKG.g_rec_header_new.array_budget_status(p_hdr_idx)      := C_INVALID;
19692    XLA_AE_HEADER_PKG.g_rec_header_new.array_encumbrance_status(p_hdr_idx) := C_INVALID;
19693    --
19694    -- update event status on the header record to invalid if the line created is invalid.
19695    --
19696    XLA_AE_HEADER_PKG.g_rec_header_new.array_event_status(p_hdr_idx) := 'I';
19697    --
19698    -- reset the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
19699    --
19700    g_global_status := C_VALID;
19701    --
19702 END IF;
19703 
19704 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19705 trace
19706      (p_msg      => 'END of UpdateJournalEntryStatus - p_hdr_idx'
19707      ,p_level    => C_LEVEL_PROCEDURE
19708      ,p_module   => l_log_module);
19709 END IF;
19710 
19711 EXCEPTION
19712 --
19713 WHEN xla_exceptions_pkg.application_exception THEN
19714   RAISE;
19715 WHEN OTHERS  THEN
19716        xla_exceptions_pkg.raise_message
19717                (p_location => 'xla_ae_journal_entry_pkg.UpdateJournalEntryStatus - p_hdr_idx');
19718   --
19719 END UpdateJournalEntryStatus;
19720 
19721 
19722 /*======================================================================+
19723 |                                                                       |
19724 | PRIVATE Procedure: insert_diag_event                                  |
19725 |                                                                       |
19726 |    Called by Diagnostic framework to store event info.                |
19727 +======================================================================*/
19728 --
19729 PROCEDURE insert_diag_event(
19730                                p_event_id                       IN NUMBER
19731                               ,p_application_id                 IN NUMBER
19732                               ,p_ledger_id                      IN NUMBER
19733                               ,p_transaction_num                IN VARCHAR2
19734                               ,p_entity_code                    IN VARCHAR2
19735                               ,p_event_class_code               IN VARCHAR2
19736                               ,p_event_type_code                IN VARCHAR2
19737                               ,p_event_number                   IN NUMBER
19738                               ,p_event_date                     IN DATE
19739 )
19740 IS
19741 l_log_module         VARCHAR2(240);
19742 l_count              NUMBER;
19743 BEGIN
19744 IF g_log_enabled THEN
19745       l_log_module := C_DEFAULT_MODULE||'.insert_diag_event';
19746 END IF;
19747 --
19748 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19749 trace
19750      (p_msg      => 'BEGIN of insert_diag_event'
19751      ,p_level    => C_LEVEL_PROCEDURE
19752      ,p_module   => l_log_module);
19753 END IF;
19754 
19755 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19756      trace
19757          (p_msg      => 'SQL- Insert xla_diag_events the event_id ='||p_event_id
19758          ,p_level    => C_LEVEL_STATEMENT
19759          ,p_module   => l_log_module);
19760 END IF;
19761 
19762 INSERT INTO xla_diag_events
19763    (
19764         event_id
19765       , application_id
19766       , ledger_id
19767       , transaction_number
19768       , event_number
19769       , event_date
19770       , entity_code
19771       , event_class_code
19772       , event_type_code
19773       , created_by
19774       , creation_date
19775       , last_update_date
19776       , last_updated_by
19777       , last_update_login
19778       , program_update_date
19779       , program_application_id
19780       , program_id
19781       , request_id
19782    )
19783  SELECT
19784        xe.event_id
19785      , p_application_id
19786      , p_ledger_id
19787      , p_transaction_num
19788      , p_event_number
19789      , p_event_date
19790      , p_entity_code
19791      , p_event_class_code
19792      , p_event_type_code
19793      , xla_environment_pkg.g_Usr_Id
19794      , TRUNC(SYSDATE)
19795      , TRUNC(SYSDATE)
19796      , xla_environment_pkg.g_Usr_Id
19797      , xla_environment_pkg.g_Login_Id
19798      , TRUNC(SYSDATE)
19799      , xla_environment_pkg.g_Prog_Appl_Id
19800      , xla_environment_pkg.g_Prog_Id
19801      , xla_environment_pkg.g_Req_Id
19802   FROM xla_events_gt xe
19803  WHERE xe.event_id = p_event_id
19804    AND NOT EXISTS ( SELECT 'x'
19805                        FROM xla_diag_events
19806                       WHERE event_id       = p_event_id
19807                         AND application_id = p_application_id
19808                         AND ledger_id      = p_ledger_id
19809                    )
19810  ;
19811 
19812 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19813     trace
19814          (p_msg      => 'Number of Diagnostic events inserted = '||SQL%ROWCOUNT
19815          ,p_level    => C_LEVEL_STATEMENT
19816          ,p_module   => l_log_module);
19817 END IF;
19818 
19819 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19820 trace
19821      (p_msg      => 'END of insert_diag_event'
19822      ,p_level    => C_LEVEL_PROCEDURE
19823      ,p_module   => l_log_module);
19824 END IF;
19825 
19826 EXCEPTION
19827 --
19828 WHEN xla_exceptions_pkg.application_exception THEN
19829   RAISE;
19830 WHEN OTHERS  THEN
19831        xla_exceptions_pkg.raise_message
19832                (p_location => 'xla_ae_journal_entry_pkg.insert_diag_event');
19833   --
19834 END insert_diag_event;
19835 
19836 /*======================================================================+
19837 |                                                                       |
19838 +======================================================================*/
19839 PROCEDURE set_event_info
19840    (p_application_id          IN NUMBER
19841    ,p_primary_ledger_id       IN NUMBER
19842    ,p_base_ledger_id          IN NUMBER
19843    ,p_target_ledger_id        IN NUMBER
19844    ,p_entity_id               IN NUMBER
19845    ,p_legal_entity_id         IN NUMBER
19846    ,p_entity_code             IN VARCHAR2
19847    ,p_transaction_num         IN VARCHAR2
19848    ,p_event_id                IN NUMBER
19849    ,p_event_class_code        IN VARCHAR2
19850    ,p_event_type_code         IN VARCHAR2
19851    ,p_event_number            IN NUMBER
19852    ,p_event_date              IN DATE
19853    ,p_transaction_date        IN DATE
19854    ,p_reference_num_1         IN NUMBER
19855    ,p_reference_num_2         IN NUMBER
19856    ,p_reference_num_3         IN NUMBER
19857    ,p_reference_num_4         IN NUMBER
19858    ,p_reference_char_1        IN VARCHAR2
19859    ,p_reference_char_2        IN VARCHAR2
19860    ,p_reference_char_3        IN VARCHAR2
19861    ,p_reference_char_4        IN VARCHAR2
19862    ,p_reference_date_1        IN DATE
19863    ,p_reference_date_2        IN DATE
19864    ,p_reference_date_3        IN DATE
19865    ,p_reference_date_4        IN DATE
19866    ,p_event_created_by        IN VARCHAR2
19867    ,p_budgetary_control_flag  IN VARCHAR2  -- 4458381 Public Sector Enh
19868 ) IS
19869 l_temp               BOOLEAN;
19870 l_log_module         VARCHAR2(240);
19871 BEGIN
19872 --
19873 IF g_log_enabled THEN
19874       l_log_module := C_DEFAULT_MODULE||'.set_event_info';
19875 END IF;
19876 --
19877 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19878       trace
19879          (p_msg      => 'BEGIN of set_event_info'
19880          ,p_level    => C_LEVEL_PROCEDURE
19881          ,p_module   => l_log_module);
19882 
19883       trace
19884          (p_msg      => 'p_event_id = '||p_event_id
19885          ,p_level    => C_LEVEL_PROCEDURE
19886          ,p_module   => l_log_module);
19887 END IF;
19888 --
19889 g_cache_event.application_id       := p_application_id;
19890 --g_cache_event.application_name     := g_array_event(p_event_id).array_value_char('application_name');
19891 g_cache_event.ledger_id            := p_primary_ledger_id;
19892 g_cache_event.base_ledger_id       := p_base_ledger_id;
19893 g_cache_event.target_ledger_id     := p_target_ledger_id;
19894 g_cache_event.legal_entity_id      := p_legal_entity_id;
19895 g_cache_event.entity_id            := p_entity_id;
19896 g_cache_event.entity_code          := p_entity_code;
19897 g_cache_event.transaction_num      := p_transaction_num;
19898 g_cache_event.event_id             := p_event_id;
19899 g_cache_event.event_class          := p_event_class_code;
19900 g_cache_event.event_type           := p_event_type_code;
19901 g_cache_event.event_number         := p_event_number;
19902 g_cache_event.event_date           := p_event_date;
19903 g_cache_event.transaction_date     := p_transaction_date;
19904 g_cache_event.reference_num_1      := p_reference_num_1;
19905 g_cache_event.reference_num_2      := p_reference_num_2;
19906 g_cache_event.reference_num_3      := p_reference_num_3;
19907 g_cache_event.reference_num_4      := p_reference_num_4;
19908 g_cache_event.reference_char_1     := p_reference_char_1;
19909 g_cache_event.reference_char_2     := p_reference_char_2;
19910 g_cache_event.reference_char_3     := p_reference_char_3;
19911 g_cache_event.reference_char_4     := p_reference_char_4;
19912 g_cache_event.reference_date_1     := p_reference_date_1;
19913 g_cache_event.reference_date_2     := p_reference_date_2;
19914 g_cache_event.reference_date_3     := p_reference_date_3;
19915 g_cache_event.reference_date_4     := p_reference_date_4;
19916 g_cache_event.event_created_by     := p_event_created_by;
19917 g_cache_event.budgetary_control_flag:= p_budgetary_control_flag; -- 4458381 Public Sector Enh
19918 --g_cache_event.accounting_mode      := g_array_event(p_event_id).array_value_char('accounting_mode');
19919 --g_cache_event.accounting_batch_id  := g_array_event(p_event_id).array_value_num('accounting_batch_id');
19920 
19921 l_temp := GetTranslatedEventInfo;
19922 
19923 IF ( xla_accounting_engine_pkg.g_diagnostics_mode = 'Y' )THEN
19924 
19925    trace
19926          (p_msg      => '-> Call Extract Source Values Disagnostics routine'
19927          ,p_level    => C_LEVEL_STATEMENT
19928          ,p_module   => l_log_module);
19929 
19930    insert_diag_event ( p_event_id         => p_event_id
19931                       ,p_application_id   => p_application_id
19932                       ,p_ledger_id        => p_primary_ledger_id
19933                       ,p_transaction_num  => p_transaction_num
19934                       ,p_entity_code      => p_entity_code
19935                       ,p_event_class_code => p_event_class_code
19936                       ,p_event_type_code  => p_event_type_code
19937                       ,p_event_number     => p_event_number
19938                       ,p_event_date       => p_event_date
19939                       );
19940 END IF;
19941 
19942 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19943       trace
19944          (p_msg      => 'END of set_event_info'
19945          ,p_level    => C_LEVEL_PROCEDURE
19946          ,p_module   => l_log_module);
19947 END IF;
19948 END set_event_info;
19949 
19950 /*======================================================================+
19951 |   PRIVATE PROCEDURE :   Insert_ANC_Inv_Canc                           |
19952 |   Bug# 7382288:Insert analytical criteria for invoice cancellation    |
19953 |    into xla_ae_line_acs table if analytical criteria exists for       |
19954 |   invoice validation event.                                           |
19955 +======================================================================*/
19956 procedure Insert_ANC_Inv_Canc
19957 is
19958 l_rowcount           NUMBER;
19959 l_log_module         VARCHAR2(240);
19960 l_array_base_ledgers    xla_accounting_cache_pkg.t_array_ledger_id;
19961 BEGIN
19962 IF g_log_enabled THEN
19963       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria_Inv_canc';
19964 END IF;
19965 --
19966 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19967 
19968       trace
19969          (p_msg      => 'BEGIN of InsertAnalyticalCriteria_Inv_canc'
19970          ,p_level    => C_LEVEL_PROCEDURE
19971          ,p_module   => l_log_module);
19972 END IF;
19973 
19974 l_rowcount  := 0;
19975 l_array_base_ledgers := xla_accounting_cache_pkg.GetLedgers;
19976 
19977 for i in 1..l_array_base_ledgers.count loop
19978 insert into xla_ae_line_acs (
19979 	ae_header_id,
19980 	ae_line_num,
19981 	analytical_criterion_code,
19982 	analytical_criterion_type_code,
19983 	amb_context_code,
19984 	object_version_number,
19985 	ac1,
19986 	ac2,
19987 	ac3,
19988 	ac4,
19989 	ac5)
19990 	(select    /*+ index(gt XLA_AE_LINES_GT_U1) */
19991                        gt.ae_header_id,
19992                        gt.ae_line_num,
19993                        la.analytical_criterion_code,
19994                        la.analytical_criterion_type_code,
19995                        la.amb_context_code,
19996                        la.object_version_number,
19997                        la.ac1,
19998                        la.ac2,
19999                        la.ac3,
20000                        la.ac4,
20001                        la.ac5
20002                 from xla_ae_line_acs la,
20003                      xla_ae_lines_gt gt
20004                 where la.ae_header_id=gt.ref_ae_header_id
20005                 and gt.ref_ae_header_id<> gt.ae_header_id
20006                 and la.ae_line_num = gt.ref_ae_line_num
20007                 and gt.ref_ae_line_num is not null
20008                 and gt.temp_line_num <0
20009                 and gt.ledger_id = l_array_base_ledgers(i)
20010                 and gt.reversal_code='REVERSAL'
20011 		group by
20012                        gt.ae_header_id,
20013                        gt.ae_line_num,
20014                        la.analytical_criterion_code,
20015                        la.analytical_criterion_type_code,
20016                        la.amb_context_code,
20017                        la.object_version_number,
20018                        la.ac1,
20019                        la.ac2,
20020                        la.ac3,
20021                        la.ac4,
20022                        la.ac5
20023 	);
20024   end loop;
20025 
20026 
20027 
20028    l_rowcount := SQL%ROWCOUNT;
20029 
20030    IF (C_LEVEL_EVENT >= g_log_level) THEN
20031       trace
20032          (p_msg      => '# line analytical criteria inserted in xla_ae_line_acs for invoice cancellation = '||l_rowcount
20033          ,p_level    => C_LEVEL_EVENT
20034          ,p_module   => l_log_module);
20035    END IF;
20036 
20037 
20038 END Insert_ANC_Inv_Canc;
20039 --=============================================================================
20040 --
20041 --
20042 --
20043 --
20044 --
20045 --
20046 --
20047 --
20048 --
20049 --
20050 --
20051 --
20052 --
20053 --
20054 --
20055 --
20056 --
20057 --
20058 --
20059 --
20060 --
20061 --
20062 --=============================================================================
20063 --=============================================================================
20064 --          *********** Initialization routine **********
20065 --=============================================================================
20066 
20067 BEGIN
20068 
20069    g_log_level      := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
20070    g_log_enabled    := fnd_log.test
20071                           (log_level  => g_log_level
20072                           ,module     => C_DEFAULT_MODULE);
20073 
20074    IF NOT g_log_enabled  THEN
20075       g_log_level := C_LEVEL_LOG_DISABLED;
20076    END IF;
20077 
20078 END xla_ae_journal_entry_pkg;