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.112.12010000.10 2008/12/08 11:01:07 kapkumar 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 +===========================================================================*/
163 --
164 -- legal_entity_name value is missing
165 --
166 --
167 TYPE t_rec_who_columns IS RECORD
168 (
169   creation_date                  DATE
170 , created_by                     INTEGER
171 , last_update_date               DATE
172 , last_updated_by                INTEGER
173 , last_update_login              INTEGER
174 , program_update_date            DATE
175 , program_application_id         INTEGER
176 , program_id                     INTEGER
177 , request_id                     NUMBER
178 )
179 ;
180 --
181 TYPE t_array_rowid IS TABLE OF ROWID INDEX BY BINARY_INTEGER;
182 --+==========================================================================+
183 --|                                                                          |
184 --|                                                                          |
185 --| Global variables                                                         |
186 --|                                                                          |
187 --|                                                                          |
188 --+==========================================================================+
189 --
190 g_who_columns                         t_rec_who_columns;
191 
192 --+==========================================================================+
193 --|                                                                          |
194 --|                                                                          |
195 --| Global constant                                                          |
196 --|                                                                          |
197 --|                                                                          |
198 --+==========================================================================+
199 --
200 C_CCID_CREATED                            CONSTANT VARCHAR2(30)  := 'CREATED';
201 C_CCID_INVALID                            CONSTANT VARCHAR2(30)  := 'INVALID';
202 --
203 C_DRAFT_STATUS                            CONSTANT VARCHAR2(1)   := 'D';
204 C_FINAL_STATUS                            CONSTANT VARCHAR2(1)   := 'F';
205 
206 C_BULK_LIMIT                              CONSTANT NUMBER        :=2000;
207 C_OVN                                     CONSTANT NUMBER        :=1;
208 
209 --+==========================================================================+
210 --|                                                                          |
211 --|                                                                          |
212 --| Local Trace Routine                                                      |
213 --|                                                                          |
214 --|                                                                          |
215 --+==========================================================================+
216 --=============================================================================
217 --               *********** Local Trace Routine **********
218 --=============================================================================
219 
220 C_LEVEL_STATEMENT     CONSTANT NUMBER := FND_LOG.LEVEL_STATEMENT;
221 C_LEVEL_PROCEDURE     CONSTANT NUMBER := FND_LOG.LEVEL_PROCEDURE;
222 C_LEVEL_EVENT         CONSTANT NUMBER := FND_LOG.LEVEL_EVENT;
223 C_LEVEL_EXCEPTION     CONSTANT NUMBER := FND_LOG.LEVEL_EXCEPTION;
224 C_LEVEL_ERROR         CONSTANT NUMBER := FND_LOG.LEVEL_ERROR;
225 C_LEVEL_UNEXPECTED    CONSTANT NUMBER := FND_LOG.LEVEL_UNEXPECTED;
226 
227 C_LEVEL_LOG_DISABLED  CONSTANT NUMBER := 99;
228 C_DEFAULT_MODULE      CONSTANT VARCHAR2(240) := 'xla.plsql.XLA_AE_JOURNAL_ENTRY_PKG';
229 
230 g_line_ac_count       PLS_INTEGER;
231 g_hdr_ac_count        PLS_INTEGER;
232 
233 g_log_level           NUMBER;
234 g_log_enabled         BOOLEAN;
235 
236 PROCEDURE trace
237            (p_msg                        IN VARCHAR2
238            ,p_level                      IN NUMBER
239            ,p_module                     IN VARCHAR2) IS
240 BEGIN
241        ----------------------------------------------------------------------------
242        -- Following is for FND log.
243        ----------------------------------------------------------------------------
244        IF (p_msg IS NULL AND p_level >= g_log_level) THEN
245           fnd_log.message(p_level, p_module);
246        ELSIF p_level >= g_log_level THEN
247           fnd_log.string(p_level, p_module, p_msg);
248        END IF;
249 
250 EXCEPTION
251        WHEN xla_exceptions_pkg.application_exception THEN
252           RAISE;
253        WHEN OTHERS THEN
254           xla_exceptions_pkg.raise_message
255              (p_location   => 'XLA_AE_JOURNAL_ENTRY_PKG.trace');
256 END trace;
257 
258 --
259 --====================================================================
260 --
261 --
262 --
263 --
264 -- Forward declaration of local routines
265 --
266 --
267 --
268 --
269 --======================================================================
270 --
271 PROCEDURE  SetStandardWhoColumn
272 ;
273 --
274 PROCEDURE GetLineNumber
275 ;
276 --
277 PROCEDURE UpdateLineNumber
278 ;
279 --
280 PROCEDURE UpdateLineNumber0
281 ;
282 --
283 PROCEDURE UpdateLineNumber10
284 ;
285 --
286 PROCEDURE UpdateLineNumber50
287 ;
288 --
289 PROCEDURE UpdateLineNumber100
290 ;
291 --
292 
293 FUNCTION InsertLines(p_application_id         IN INTEGER
294                     ,p_budgetary_control_mode IN VARCHAR2)
295 RETURN NUMBER
296 ;
297 PROCEDURE AdjustMpaLine(p_application_id  IN INTEGER)     -- 4262811b
298 ;
299 -- PROCEDURE AdjustMpaRevLine(p_application_id  IN INTEGER);  -- 4669308
300 
301 PROCEDURE InsertAnalyticalCriteria
302 ;
303 PROCEDURE InsertAnalyticalCriteria10
304 ;
305 PROCEDURE InsertAnalyticalCriteria50
306 ;
307 PROCEDURE InsertAnalyticalCriteria100
308 ;
309 --
310 PROCEDURE InsertLinks(p_application_id    IN INTEGER)
311 ;
312 --
313 FUNCTION InsertHeaders(p_application_id                 IN INTEGER
314                       ,p_accounting_batch_id            IN NUMBER
315                       ,p_end_date                       IN DATE        -- 4262811
316                       -- bulk perfromance
317                       ,p_accounting_mode                in varchar)
318 RETURN NUMBER
319 ;
320 PROCEDURE InsertHdrAnalyticalCriteria
321 ;
322 PROCEDURE InsertHdrAnalyticalCriteria10
323 ;
324 PROCEDURE InsertHdrAnalyticalCriteria50
325 ;
326 PROCEDURE InsertHdrAnalyticalCriteria100
327 ;
328 --
329 --
330 PROCEDURE insert_diag_event(
331                                p_event_id                       IN NUMBER
332                               ,p_application_id                 IN NUMBER
333                               ,p_ledger_id                      IN NUMBER
334                               ,p_transaction_num                IN VARCHAR2
335                               ,p_entity_code                    IN VARCHAR2
336                               ,p_event_class_code               IN VARCHAR2
337                               ,p_event_type_code                IN VARCHAR2
338                               ,p_event_number                   IN NUMBER
339                               ,p_event_date                     IN DATE
340 )
341 ;
342 --
343 PROCEDURE insert_diag_ledger (  p_application_id    IN NUMBER
344                               , p_ledger_id         IN NUMBER
345                               , p_primary_ledger_id IN NUMBER
346                               , p_pad_start_date    IN DATE
347                               , p_pad_end_date      IN DATE
348 )
349 ;
350 --
351 PROCEDURE Insert_ANC_Inv_Canc;
352 /*======================================================================+
353 |                                                                       |
354 | PRIVATE Procedure                                                     |
355 |                                                                       |
356 |                                                                       |
357 +======================================================================*/
358 PROCEDURE  SetStandardWhoColumn
359 IS
360 l_log_module         VARCHAR2(240);
361 BEGIN
362 IF g_log_enabled THEN
363       l_log_module := C_DEFAULT_MODULE||'.SetStandardWhoColumn';
364 END IF;
365 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
366       trace
367          (p_msg      => 'BEGIN of SetStandardWhoColumn'
368          ,p_level    => C_LEVEL_PROCEDURE
369          ,p_module   => l_log_module);
370 
371 END IF;
372 
373 g_who_columns.creation_date                   := TRUNC(SYSDATE) ;
374 g_who_columns.created_by                      := xla_environment_pkg.g_Usr_Id ;
375 g_who_columns.last_update_date                := TRUNC(SYSDATE) ;
376 g_who_columns.last_updated_by                 := xla_environment_pkg.g_Usr_Id ;
377 g_who_columns.last_update_login               := xla_environment_pkg.g_Login_Id  ;
378 g_who_columns.program_update_date             := TRUNC(SYSDATE) ;
379 g_who_columns.program_application_id          := xla_environment_pkg.g_Prog_Appl_Id ;
380 g_who_columns.program_id                      := xla_environment_pkg.g_Prog_Id ;
381 g_who_columns.request_id                      := xla_environment_pkg.g_Req_Id ;
382 
383 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
384       trace
385          (p_msg      => 'END of SetStandardWhoColumn'
386          ,p_level    => C_LEVEL_PROCEDURE
387          ,p_module   => l_log_module);
388 
389 END IF;
390 EXCEPTION
391 WHEN xla_exceptions_pkg.application_exception THEN
392   RAISE;
393 WHEN OTHERS  THEN
394        xla_exceptions_pkg.raise_message
395                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.SetStandardWhoColumn');
396 END SetStandardWhoColumn;
397 --
398 /*======================================================================+
399 |                                                                       |
400 | Public Function                                                       |
401 |                                                                       |
402 |                                                                       |
403 +======================================================================*/
404 --
405 FUNCTION GetAlternateCurrencyLedger(p_base_ledger_id           IN NUMBER )
406 RETURN xla_accounting_cache_pkg.t_array_ledger_id
407 IS
408 l_array_alc_ledgers       xla_accounting_cache_pkg.t_array_ledger_id ;
409 l_array_ledgers           xla_accounting_cache_pkg.t_array_ledger_id ;
410 l_log_module              VARCHAR2(240);
411 BEGIN
412 --
413 IF g_log_enabled THEN
414       l_log_module := C_DEFAULT_MODULE||'.GetAlternateCurrencyLedger';
415 END IF;
416 --
417 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
418       trace
419          (p_msg      => 'BEGIN of GetAlternateCurrencyLedger'
420          ,p_level    => C_LEVEL_PROCEDURE
421          ,p_module   => l_log_module);
422 
423       trace
424           (p_msg      =>'p_base_ledger_id = '||TO_CHAR( p_base_ledger_id)
425          ,p_level    => C_LEVEL_PROCEDURE
426          ,p_module   => l_log_module);
427 
428       trace
429           (p_msg      =>'-> CALL xla_accounting_cache_pkg.GetAlcLedgers API'
430          ,p_level    => C_LEVEL_PROCEDURE
431          ,p_module   => l_log_module);
432 
433 END IF;
434 --
435 l_array_ledgers(1)   := p_base_ledger_id;
436 --
437 l_array_alc_ledgers  := xla_accounting_cache_pkg.GetAlcLedgers(
438                                           p_primary_ledger_id => p_base_ledger_id
439                                         );
440 
441 IF (C_LEVEL_EVENT >= g_log_level) THEN
442           trace
443              (p_msg      => '# of alternate ledgers = '||TO_CHAR(l_array_alc_ledgers.COUNT)
444              ,p_level    => C_LEVEL_EVENT
445              ,p_module   => l_log_module);
446 END IF;
447 
448 IF  l_array_alc_ledgers.COUNT > 0 THEN
449 
450 FOR Idx IN l_array_alc_ledgers.FIRST .. l_array_alc_ledgers.LAST LOOP
451 
452   l_array_ledgers(l_array_ledgers.LAST + 1) := l_array_alc_ledgers(Idx);
453 
454 END LOOP;
455 
456 END IF;
457 --
458 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
459       trace
460          (p_msg      => 'END of GetAlternateCurrencyLedger'
461          ,p_level    => C_LEVEL_PROCEDURE
462          ,p_module   => l_log_module);
463 END IF;
464 
465 RETURN l_array_ledgers ;
466 EXCEPTION
467 WHEN xla_exceptions_pkg.application_exception THEN
468    xla_accounting_err_pkg.build_message
469                                        (p_appli_s_name            => 'XLA'
470                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
471                                        ,p_token_1                 => 'PROCEDURE'
472                                        ,p_value_1                 => 'xla_accounting_cache_pkg.GetAlcLedgers'
473                                        ,p_entity_id               => g_cache_event.entity_id
474                                        ,p_event_id                => g_cache_event.event_id
475                                        ,p_ledger_id               => g_cache_event.target_ledger_id
476                               );
477 
478   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
479                            trace
480                               (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
481                               ,p_level    => C_LEVEL_EXCEPTION
482                               ,p_module   => l_log_module);
483   END IF;
484 
485   RAISE;
486 WHEN OTHERS  THEN
487      xla_exceptions_pkg.raise_message
488              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetAlternateCurrencyLedger');
489        --
490 END GetAlternateCurrencyLedger;
491 
492 /*======================================================================+
493 |                                                                       |
494 | Public Procedure                                                      |
495 |                                                                       |
496 |                                                                       |
497 +======================================================================*/
498 --
499 PROCEDURE cache_event_ledgers(
500     p_base_ledger_id                 IN NUMBER
501    ,p_target_ledger_id               IN NUMBER
502  )
503 IS
504 l_log_module         VARCHAR2(240);
505 BEGIN
506 --
507 IF g_log_enabled THEN
508       l_log_module := C_DEFAULT_MODULE||'.cache_event_ledgers';
509 END IF;
510 --
511 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
512       trace
513          (p_msg      => 'BEGIN of cache_event_ledgers'
514          ,p_level    => C_LEVEL_PROCEDURE
515          ,p_module   => l_log_module);
516       trace
517           (p_msg      =>'p_base_ledger_id = '||TO_CHAR(p_base_ledger_id)||
518                         ' - p_target_ledger_id = '||TO_CHAR(p_target_ledger_id)
519          ,p_level    => C_LEVEL_PROCEDURE
520          ,p_module   => l_log_module);
521 
522 END IF;
523 
524    g_cache_event.base_ledger_id                 := p_base_ledger_id;
525    g_cache_event.target_ledger_id               := p_target_ledger_id;
526 --
527 --
528 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
529       trace
530          (p_msg      => 'END of cache_event_ledgers'
531          ,p_level    => C_LEVEL_PROCEDURE
532          ,p_module   => l_log_module);
533 
534 END IF;
535 
536 EXCEPTION
537 WHEN xla_exceptions_pkg.application_exception THEN
538   RAISE;
539 WHEN OTHERS  THEN
540        xla_exceptions_pkg.raise_message
541                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.cache_event_ledgers');
542 END cache_event_ledgers;
543 
544 /*======================================================================+
545 |                                                                       |
546 | Public PROCEDURE                                                      |
547 |                                                                       |
548 |  Update the stats of the journal entries creation (0,1,2)             |
549 +======================================================================*/
550 --
551 PROCEDURE UpdateResult(  p_old_status           IN OUT NOCOPY NUMBER
552                        , p_new_status           IN NUMBER
553 )
554 IS
555 l_old_status         NUMBER;
556 l_log_module         VARCHAR2(240);
557 BEGIN
558 --
559 IF g_log_enabled THEN
560       l_log_module := C_DEFAULT_MODULE||'.UpdateResult';
561 END IF;
562 --
563 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
564 
565       trace
566          (p_msg      => 'BEGIN of UpdateResult'
567          ,p_level    => C_LEVEL_PROCEDURE
568          ,p_module   => l_log_module);
569 
570       trace
571           (p_msg      => 'p_old_status = '||p_old_status
572          ,p_level    => C_LEVEL_PROCEDURE
573          ,p_module   => l_log_module);
574 
575      trace
576          (p_msg      => 'p_new_status = '||p_new_status
577          ,p_level    => C_LEVEL_PROCEDURE
578          ,p_module   => l_log_module);
579 
580 END IF;
581 
582 l_old_status   := p_old_status;
583 IF l_old_status = -1 OR
584    (p_new_status = 2 AND l_old_status = 2 ) OR
585    (p_new_status = 0 AND l_old_status = 0 ) OR
586    (p_new_status = 0 AND l_old_status = 2 )
587 THEN
588   p_old_status := p_new_status;
589 ELSE
590   p_old_status := 1;
591 END IF;
592 
593 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
594 
595       trace
596          (p_msg      => 'return value. = '||p_old_status
597          ,p_level    => C_LEVEL_PROCEDURE
598          ,p_module   => l_log_module);
599 
600       trace
601          (p_msg      => 'END of UpdateResult'
602          ,p_level    => C_LEVEL_PROCEDURE
603          ,p_module   => l_log_module);
604 
605 END IF;
606 
607 EXCEPTION
608 WHEN xla_exceptions_pkg.application_exception THEN
609   RAISE;
610 WHEN OTHERS  THEN
611    xla_exceptions_pkg.raise_message
612            (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateResult');
613        --
614 END UpdateResult;
615 --
616 --
617 /*======================================================================+
618 |                                                                       |
619 | Public Procedure                                                      |
620 |                                                                       |
621 |                                                                       |
622 +======================================================================*/
623 PROCEDURE  SetProductAcctDefinition(
624   p_product_rule_code      IN VARCHAR2
625 , p_product_rule_type_code IN VARCHAR2
626 , p_product_rule_version   IN VARCHAR2
627 , p_product_rule_name      IN VARCHAR2
628 , p_amb_context_code       IN VARCHAR2
629 )
630 IS
631 l_log_module         VARCHAR2(240);
632 BEGIN
633 --
634 IF g_log_enabled THEN
635       l_log_module := C_DEFAULT_MODULE||'.SetProductAcctDefinition';
636 END IF;
637 --
638 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
639 
640       trace
641          (p_msg      => 'BEGIN of SetProductAcctDefinition'
642          ,p_level    => C_LEVEL_PROCEDURE
643          ,p_module   => l_log_module);
644 
645 END IF;
646 
647   g_cache_pad.product_rule_code        := p_product_rule_code      ;
648   g_cache_pad.product_rule_type_code   := p_product_rule_type_code ;
649   g_cache_pad.product_rule_name        := p_product_rule_name      ;
650   g_cache_pad.product_rule_version     := p_product_rule_version   ;
651   g_cache_pad.amb_context_code         := p_amb_context_code       ;
652 
653 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
654 
655       trace
656          (p_msg      => 'p_product_rule_code = '||p_product_rule_code||
657                         ' - p_product_rule_type_code = '||p_product_rule_type_code||
658                         ' - p_product_rule_version = '||p_product_rule_version||
659                         ' - p_product_rule_name = '||p_product_rule_name||
660                         ' -p_amb_context_code = '||p_amb_context_code
661          ,p_level    => C_LEVEL_STATEMENT
662          ,p_module   => l_log_module);
663 END IF;
664 
665 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
666       trace
667          (p_msg      => 'END of SetProductAcctDefinition'
668          ,p_level    => C_LEVEL_PROCEDURE
669          ,p_module   => l_log_module);
670 END IF;
671 EXCEPTION
672 WHEN xla_exceptions_pkg.application_exception THEN
673   RAISE;
674 WHEN OTHERS  THEN
675    xla_exceptions_pkg.raise_message
676            (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.SetProductAcctDefinition');
677 END SetProductAcctDefinition;
678 
679 /*======================================================================+
680 |                                                                       |
681 | PRIVATE Procedure                                                     |
682 |                                                                       |
683 |    Called by Diagnostic Framework to store event info.                |
684 +======================================================================*/
685 --
686 PROCEDURE insert_diag_ledger (
687   p_application_id    IN NUMBER
688 , p_ledger_id         IN NUMBER
689 , p_primary_ledger_id IN NUMBER
690 , p_pad_start_date    IN DATE
691 , p_pad_end_date      IN DATE
692 )
693 IS
694 l_log_module         VARCHAR2(240);
695 l_request_id         NUMBER;
696 BEGIN
697 IF g_log_enabled THEN
698       l_log_module := C_DEFAULT_MODULE||'.insert_diag_ledger';
699 END IF;
700 --
701 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
702     trace
703      (p_msg      => 'BEGIN of insert_diag_ledger'
704      ,p_level    => C_LEVEL_PROCEDURE
705      ,p_module   => l_log_module);
706 END IF;
707 
708 l_request_id := xla_environment_pkg.g_Req_Id ;
709 
710    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
711      trace
712          (p_msg      => 'SQL- Insert xla_diag_ledgers  the ledger_id ='||p_ledger_id
713          ,p_level    => C_LEVEL_STATEMENT
714          ,p_module   => l_log_module);
715    END IF;
716 
717    INSERT INTO xla_diag_ledgers
718    (
719         application_id
720       , ledger_id
721       , primary_ledger_id
722       , sla_ledger_id
723       , description_language
724       , nls_desc_language
725       , currency_code
726       , product_rule_code
727       , product_rule_type_code
728       , amb_context_code
729       , start_date_active
730       , end_date_active
731       , accounting_request_id
732       , created_by
733       , creation_date
734       , last_update_date
735       , last_updated_by
736       , last_update_login
737       , program_update_date
738       , program_application_id
739       , program_id
740       , request_id
741    )
742    SELECT
743        p_application_id
744      , p_ledger_id
745      , p_primary_ledger_id
746      , g_cache_ledgers_info.sla_ledger_id
747      , g_cache_ledgers_info.description_language
748      , g_cache_ledgers_info.nls_desc_language
749      , g_cache_ledgers_info.currency_code
750      , g_cache_pad.product_rule_code
751      , g_cache_pad.product_rule_type_code
752      , g_cache_pad.amb_context_code
753      , p_pad_start_date
754      , p_pad_end_date
755      , l_request_id
756      , xla_environment_pkg.g_Usr_Id
757      , TRUNC(SYSDATE)
758      , TRUNC(SYSDATE)
759      , xla_environment_pkg.g_Usr_Id
760      , xla_environment_pkg.g_Login_Id
761      , TRUNC(SYSDATE)
762      , xla_environment_pkg.g_Prog_Appl_Id
763      , xla_environment_pkg.g_Prog_Id
764      , xla_environment_pkg.g_Req_Id
765     FROM xla_subledger_options_v
766    WHERE application_id         = p_application_id
767      AND ledger_id              = p_ledger_id
768      AND primary_ledger_id      = p_primary_ledger_id
769      AND not exists (SELECT 'x'
770                        FROM xla_diag_ledgers
771                       WHERE application_id         = p_application_id
772                         AND ledger_id              = p_ledger_id
773                         AND primary_ledger_id      = p_primary_ledger_id
774                         AND accounting_request_id  = l_request_id
775                     )
776     ;
777 
778 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
779     trace
780          (p_msg      => 'Number of Extract ledgers Inserted = '||SQL%ROWCOUNT
781          ,p_level    => C_LEVEL_STATEMENT
782          ,p_module   => l_log_module);
783 END IF;
784 
785 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
786 trace
787      (p_msg      => 'END of insert_diag_ledger'
788      ,p_level    => C_LEVEL_PROCEDURE
789      ,p_module   => l_log_module);
790 END IF;
791 EXCEPTION
792 WHEN xla_exceptions_pkg.application_exception THEN
793   RAISE;
794 WHEN OTHERS  THEN
795        xla_exceptions_pkg.raise_message
796                (p_location => 'xla_ae_journal_entry_pkg.insert_diag_ledger');
797   --
798 END insert_diag_ledger;
799 --
800 /*======================================================================+
801 |                                                                       |
802 | Public Procedure                                                      |
803 |                                                                       |
804 |                                                                       |
805 +======================================================================*/
806 --
807 FUNCTION  GetLedgersInfo(
808  p_application_id           IN NUMBER
809 ,p_base_ledger_id           IN NUMBER
810 ,p_target_ledger_id         IN NUMBER
811 -- bulk performance
812 ,p_primary_ledger_id        in number
813 ,p_pad_start_date           IN DATE
814 ,p_pad_end_date             IN DATE
815 --
816 )
817 RETURN BOOLEAN
818 IS
819 l_result               BOOLEAN:=TRUE;
820 l_api_name             VARCHAR2(30);
821 l_log_module           VARCHAR2(240);
822 l_sl_coa_mapping_id    NUMBER:=NULL;
823 l_category_code        VARCHAR2(30);
824 l_primary_currency     VARCHAR2(30);
825 l_currency             VARCHAR2(30);
826 l_alc_enabled_flag   VARCHAR2(1);
827 BEGIN
828 --
829 IF g_log_enabled THEN
830       l_log_module := C_DEFAULT_MODULE||'.GetLedgersInfo';
831 END IF;
832 --
833 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
834 
835       trace
836          (p_msg      => 'BEGIN of GetLedgersInfo'
837          ,p_level    => C_LEVEL_PROCEDURE
838          ,p_module   => l_log_module);
839 
840       trace
841          (p_msg      => '-> CALL xla_accounting_cache_pkg.GetValueChar/Num/Date APIs'
842          ,p_level    => C_LEVEL_PROCEDURE
843          ,p_module   => l_log_module);
844 
845 END IF;
846 --
847    g_cache_event.base_ledger_id                 := p_base_ledger_id;
848    g_cache_event.target_ledger_id               := p_target_ledger_id;
849 
850   --
851   -- target ledger language
852   --
853   l_api_name:= 'GetValueChar';
854   g_cache_ledgers_info.description_language := xla_accounting_cache_pkg.GetValueChar(
855                                   p_source_code        => 'XLA_DESCRIPTION_LANGUAGE'
856                                 , p_target_ledger_id   => p_target_ledger_id
857                                 );
858 
859   IF g_cache_ledgers_info.description_language IS NULL THEN
860 
861   l_result := FALSE;
862 
863           xla_accounting_err_pkg.build_message
864                    (p_appli_s_name            => 'XLA'
865                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
866                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
867                    ,p_value_1                 => 'Description Language'
868                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
869                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
870                    ,p_ledger_id               => p_target_ledger_id
871          );
872 
873          IF (C_LEVEL_ERROR >= g_log_level) THEN
874              trace
875                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
876                   ,p_level    => C_LEVEL_ERROR
877                   ,p_module   => l_log_module);
878          END IF;
879   END IF;
880 
881 
882   --
883   -- target minimum accountable unit
884   --
885   l_api_name:= 'GetValueNum';
886   g_cache_ledgers_info.minimum_accountable_unit:= xla_accounting_cache_pkg.GetValueNum(
887                                   p_source_code        => 'XLA_CURRENCY_MAU'
888                                 , p_target_ledger_id   => p_target_ledger_id
889                                 );
890 
891   IF g_cache_ledgers_info.minimum_accountable_unit IS NULL THEN
892 
893   l_result := FALSE;
894 
895           xla_accounting_err_pkg.build_message
896                    (p_appli_s_name            => 'XLA'
897                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
898                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
899                    ,p_value_1                 => 'Minimum Accountable Unit'
900                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
901                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
902                    ,p_ledger_id               => p_target_ledger_id
903          );
904 
905          IF (C_LEVEL_ERROR >= g_log_level) THEN
906              trace
907                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
908                   ,p_level    => C_LEVEL_ERROR
909                   ,p_module   => l_log_module);
910          END IF;
911   END IF;
912 
913   --
914   -- Rounding rule code
915   --
916   l_api_name:= 'GetValueChar';
917   g_cache_ledgers_info.rounding_rule_code:= xla_accounting_cache_pkg.GetValueChar(
918                                   p_source_code        => 'XLA_ROUNDING_RULE_CODE'
919                                 , p_target_ledger_id   => p_target_ledger_id
920                                 );
921 
922   IF g_cache_ledgers_info.rounding_rule_code IS NULL THEN
923 
924   l_result := FALSE;
925 
926           xla_accounting_err_pkg.build_message
927                    (p_appli_s_name            => 'XLA'
928                    ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
929                    ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
930                    ,p_value_1                 => 'Rounding Rule Code'
931                    ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
932                    ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
933                    ,p_ledger_id               => p_target_ledger_id
934          );
935 
936          IF (C_LEVEL_ERROR >= g_log_level) THEN
937              trace
938                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
939                   ,p_level    => C_LEVEL_ERROR
940                   ,p_module   => l_log_module);
941          END IF;
942   END IF;
943   --
944   -- SLA ledger id
945   --
946   l_api_name:= 'GetValueNum';
947   g_cache_ledgers_info.sla_ledger_id      := xla_accounting_cache_pkg.GetValueNum(
948                                     p_source_code        => 'SLA_LEDGER_ID'
949                                   , p_target_ledger_id   => p_target_ledger_id
950                                   );
951 
952   IF g_cache_ledgers_info.sla_ledger_id IS NULL THEN
953 
954       l_result := FALSE;
955 
956       xla_accounting_err_pkg.build_message
957                          (p_appli_s_name            => 'XLA'
958                          ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
959                          ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
960                          ,p_value_1                 => 'Sla ledger id'
961                          ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
962                          ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
963                          ,p_ledger_id               => p_target_ledger_id
964            );
965 
966        IF (C_LEVEL_ERROR >= g_log_level) THEN
967              trace
968                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
969                   ,p_level    => C_LEVEL_ERROR
970                   ,p_module   => l_log_module);
971        END IF;
972   END IF;
973   --
974   -- target currency code
975   --
976   l_api_name:= 'GetValueChar';
977   l_currency := xla_accounting_cache_pkg.GetValueChar(
978                                   p_source_code        => 'XLA_CURRENCY_CODE'
979                                 , p_target_ledger_id   => p_target_ledger_id
980                                 );
981   g_cache_ledgers_info.currency_code      := l_currency;
982 
983   IF g_cache_ledgers_info.currency_code IS NULL THEN
984 
985     xla_accounting_err_pkg.build_message
986                        (p_appli_s_name            => 'XLA'
987                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
988                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
989                        ,p_value_1                 => 'Ledger Currency Code'
990                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
991                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
992                        ,p_ledger_id               => p_target_ledger_id
993          );
994 
995     IF (C_LEVEL_ERROR >= g_log_level) THEN
996              trace
997                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
998                   ,p_level    => C_LEVEL_ERROR
999                   ,p_module   => l_log_module);
1000     END IF;
1001 
1002   END IF;
1003 
1004   --
1005   -- get primary coa id
1006   --
1007   l_api_name:= 'GetValueNum';
1008   g_cache_ledgers_info.source_coa_id  := xla_accounting_cache_pkg.GetValueNum(
1009                                   p_source_code       => 'XLA_COA_ID'
1010                                 , p_target_ledger_id  => p_primary_ledger_id --g_cache_event.ledger_id
1011                                  );
1012 
1013   IF g_cache_ledgers_info.source_coa_id IS NULL THEN
1014 
1015     l_result := FALSE;
1016 
1017      xla_accounting_err_pkg.build_message
1018                        (p_appli_s_name            => 'XLA'
1019                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1020                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1021                        ,p_value_1                 => 'Chart of accounts'
1022                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1023                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1024                        ,p_ledger_id               => p_base_ledger_id
1025          );
1026 
1027     IF (C_LEVEL_ERROR >= g_log_level) THEN
1028              trace
1029                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1030                   ,p_level    => C_LEVEL_ERROR
1031                   ,p_module   => l_log_module);
1032     END IF;
1033   ELSE
1034   --
1035   -- cache source coa info
1036   --
1037     XLA_AE_CODE_COMBINATION_PKG.cache_coa(p_coa_id => g_cache_ledgers_info.source_coa_id);
1038   --
1039   END IF;
1040   --
1041   -- target coa id, used to build the target code combination
1042   --
1043   l_api_name:= 'GetValueNum';
1044   g_cache_ledgers_info.target_coa_id  := xla_accounting_cache_pkg.GetValueNum(
1045                                   p_source_code       => 'XLA_COA_ID'
1046                                 , p_target_ledger_id  => p_target_ledger_id
1047                                  );
1048 
1049   IF g_cache_ledgers_info.target_coa_id IS NULL THEN
1050 
1051     l_result := FALSE;
1052 
1053     xla_accounting_err_pkg.build_message
1054                            (p_appli_s_name            => 'XLA'
1055                            ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1056                            ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1057                            ,p_value_1                 => 'Chart of accounts'
1058                            ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1059                            ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1060                            ,p_ledger_id               => p_target_ledger_id
1061          );
1062 
1063     IF (C_LEVEL_ERROR >= g_log_level) THEN
1064              trace
1065                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1066                   ,p_level    => C_LEVEL_ERROR
1067                   ,p_module   => l_log_module);
1068     END IF;
1069 
1070   ELSE
1071   --
1072   -- cache target coa info
1073   --
1074     XLA_AE_CODE_COMBINATION_PKG.cache_coa( p_coa_id => g_cache_ledgers_info.target_coa_id);
1075   --
1076   END IF;
1077   --
1078   -- Get multiple posting information
1079   --
1080   l_api_name:= 'GetValueChar';
1081   g_cache_ledgers_info.sl_coa_mapping_name  :=  xla_accounting_cache_pkg.GetValueChar(
1082                                       p_source_code       => 'GL_COA_MAPPING_NAME'
1083                                     , p_target_ledger_id  => p_base_ledger_id
1084                                      );
1085 
1086  --
1087  -- get SL coa mapping id
1088  --
1089     l_api_name:= 'GetValueNum';
1090 
1091     l_sl_coa_mapping_id   :=  xla_accounting_cache_pkg.GetValueNum(
1092                                           p_source_code       => 'SL_COA_MAPPING_ID'
1093                                         , p_target_ledger_id  => p_base_ledger_id
1094                                      );
1095 
1096      g_cache_ledgers_info.sl_coa_mapping_id:= l_sl_coa_mapping_id;
1097 
1098  IF g_cache_ledgers_info.sl_coa_mapping_name IS NOT NULL  AND
1099     l_sl_coa_mapping_id IS NOT NULL
1100  THEN
1101        --
1102        -- get coa dynamic insert flag
1103        --
1104        l_api_name:= 'GetValueChar';
1105 
1106        g_cache_ledgers_info.dynamic_insert_flag  :=  xla_accounting_cache_pkg.GetValueChar(
1107                                           p_source_code       => 'DYNAMIC_INSERTS_ALLOWED_FLAG'
1108                                         , p_target_ledger_id  => p_base_ledger_id
1109                                      );
1110 
1111       --
1112         XLA_AE_CODE_COMBINATION_PKG.cacheGLMapping(
1113                          p_sla_coa_mapping_name => g_cache_ledgers_info.sl_coa_mapping_name
1114                        , p_sla_coa_mapping_id   => g_cache_ledgers_info.sl_coa_mapping_id
1115                        , p_dynamic_inserts_flag => g_cache_ledgers_info.dynamic_insert_flag
1116                         );
1117 
1118  END IF;
1119   --
1120   -- nls descriptions  of target ledger
1121   --
1122   l_api_name:= 'GetValueChar';
1123   g_cache_ledgers_info.nls_desc_language := xla_accounting_cache_pkg.GetValueChar(
1124                                   p_source_code        => 'XLA_NLS_DESC_LANGUAGE'
1125                                 , p_target_ledger_id   =>  p_target_ledger_id
1126                                  );
1127 
1128   IF g_cache_ledgers_info.nls_desc_language IS NULL THEN
1129 
1130     l_result := FALSE;
1131 
1132         xla_accounting_err_pkg.build_message
1133                                (p_appli_s_name            => 'XLA'
1134                                ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1135                                ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1136                                ,p_value_1                 => 'NLS description language'
1137                                ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1138                                ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1139                                ,p_ledger_id               => p_target_ledger_id
1140          );
1141 
1142     IF (C_LEVEL_ERROR >= g_log_level) THEN
1143              trace
1144                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1145                   ,p_level    => C_LEVEL_ERROR
1146                   ,p_module   => l_log_module);
1147     END IF;
1148 
1149   END IF;
1150   --
1151   -- target reversal option
1152   --
1153   l_api_name:= 'GetValueChar';
1154   g_cache_ledgers_info.ledger_reversal_option  :=  xla_accounting_cache_pkg.GetValueChar(
1155                                   p_source_code       => 'XLA_ACCT_REVERSAL_OPTION'
1156                                 , p_target_ledger_id  => p_target_ledger_id
1157                                 );
1158 
1159 
1160 
1161   --
1162   IF g_cache_ledgers_info.ledger_reversal_option IS NOT NULL AND
1163      g_cache_ledgers_info.ledger_reversal_option NOT IN ('SIDE','SIGN') THEN
1164 
1165     l_result := FALSE;
1166 
1167     xla_accounting_err_pkg.build_message
1168                            (p_appli_s_name            => 'XLA'
1169                            ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1170                            ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1171                            ,p_value_1                 => 'Accounting Reversal Option'
1172                            ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1173                            ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1174                            ,p_ledger_id               => p_target_ledger_id
1175          );
1176 
1177     IF (C_LEVEL_ERROR >= g_log_level) THEN
1178               trace
1179                    (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1180                    ,p_level    => C_LEVEL_ERROR
1181                    ,p_module   => l_log_module);
1182     END IF;
1183 
1184   END IF;
1185   --
1186   --
1187 
1188   -- ledger category code
1189   --
1190   l_api_name:= 'GetValueChar';
1191   l_category_code:= xla_accounting_cache_pkg.GetValueChar(
1192                                   p_source_code        => 'LEDGER_CATEGORY_CODE'
1193                                 , p_target_ledger_id   => p_target_ledger_id
1194                                 );
1195 
1196   g_cache_ledgers_info.ledger_category_code :=l_category_code;
1197 
1198   IF l_category_code IS NULL THEN
1199 
1200     xla_accounting_err_pkg.build_message
1201                        (p_appli_s_name            => 'XLA'
1202                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1203                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1204                        ,p_value_1                 => 'Ledger Category Code'
1205                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1206                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1207                        ,p_ledger_id               => p_primary_ledger_id
1208          );
1209 
1210     IF (C_LEVEL_ERROR >= g_log_level) THEN
1211              trace
1212                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1213                   ,p_level    => C_LEVEL_ERROR
1214                   ,p_module   => l_log_module);
1215     END IF;
1216 
1217   END IF;
1218 
1219   g_cache_ledgers_info.calculate_amts_flag:='Y';
1220 
1221 
1222   IF(l_category_code= 'SECONDARY') THEN
1223 
1224     -- primary currency code
1225     --
1226     l_api_name:= 'GetValueChar';
1227     l_primary_currency:= xla_accounting_cache_pkg.GetValueChar(
1228                                   p_source_code        => 'XLA_CURRENCY_CODE'
1229                                 , p_target_ledger_id   => p_primary_ledger_id
1230                                 );
1231 
1232     IF l_primary_currency IS NULL THEN
1233 
1234       xla_accounting_err_pkg.build_message
1235                        (p_appli_s_name            => 'XLA'
1236                        ,p_msg_name                => 'XLA_AP_INVALID_SYSTEM_SOURCE'
1237                        ,p_token_1                 => 'SYSTEM_SOURCE_NAME'
1238                        ,p_value_1                 => 'Ledger Currency Code'
1239                        ,p_entity_id               => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.entity_id
1240                        ,p_event_id                => XLA_AE_JOURNAL_ENTRY_PKG.g_cache_event.event_id
1241                        ,p_ledger_id               => p_primary_ledger_id
1242          );
1243 
1244       IF (C_LEVEL_ERROR >= g_log_level) THEN
1245              trace
1246                   (p_msg      => 'ERROR: XLA_AP_INVALID_SYSTEM_SOURCE'
1247                   ,p_level    => C_LEVEL_ERROR
1248                   ,p_module   => l_log_module);
1249       END IF;
1250 
1251     END IF;
1252     IF l_primary_currency = l_currency THEN
1253       g_cache_ledgers_info.calculate_amts_flag:='N';
1254     END IF;
1255   ELSIF l_category_code= 'ALC' THEN
1256     l_alc_enabled_flag :=xla_accounting_cache_pkg.GetValueChar('XLA_ALC_ENABLED_FLAG');
1257     IF(l_alc_enabled_flag = 'N') THEN
1258       g_cache_ledgers_info.calculate_amts_flag:='N';
1259     END IF;
1260   END IF;
1261 
1262 
1263 -----------------------------------------------------------------------
1264 --
1265 -- Call insert_diag_ledger to store event information
1266 --
1267 -----------------------------------------------------------------------
1268 IF ( xla_accounting_engine_pkg.g_diagnostics_mode = 'Y') THEN
1269 
1270    trace
1271          (p_msg      => '-> Call Extract Source Values Diagnostics routine'
1272          ,p_level    => C_LEVEL_STATEMENT
1273          ,p_module   => l_log_module);
1274 
1275    insert_diag_ledger(
1276                         p_application_id      => p_application_id
1277                        ,p_ledger_id           => p_target_ledger_id
1278                        ,p_primary_ledger_id   => p_primary_ledger_id
1279                        ,p_pad_start_date      => p_pad_start_date
1280                        ,p_pad_end_date        => p_pad_end_date
1281                        );
1282 END IF;
1283 
1284 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1285       trace
1286          (p_msg      => 'description_language = '||g_cache_ledgers_info.description_language||
1287                          ' - sla_ledger_id = '||g_cache_ledgers_info.sla_ledger_id||
1288                          ' - currency_code = '||g_cache_ledgers_info.currency_code||
1289                          ' - source_coa_id = '||g_cache_ledgers_info.source_coa_id||
1290                          ' - target_coa_id = '||g_cache_ledgers_info.target_coa_id||
1291                          ' - sl_coa_mapping_name = '||g_cache_ledgers_info.sl_coa_mapping_name||
1292                          ' - dynamic_insert_flag = '||g_cache_ledgers_info.dynamic_insert_flag||
1293                          ' - nls_desc_language = '||g_cache_ledgers_info.nls_desc_language||
1294                          ' - calculate_amts_flag= '||g_cache_ledgers_info.calculate_amts_flag||
1295                          ' - ledger_category_code= '||g_cache_ledgers_info.ledger_category_code||
1296                          ' - ledger_reversal_option = '||g_cache_ledgers_info.ledger_reversal_option
1297 
1298          ,p_level    => C_LEVEL_STATEMENT
1299          ,p_module   => l_log_module);
1300 END IF;
1301 --
1302 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1303       trace
1304          (p_msg      => 'END of GetLedgersInfo'
1305          ,p_level    => C_LEVEL_PROCEDURE
1306          ,p_module   => l_log_module);
1307 END IF;
1308 --
1309 RETURN l_result;
1310 --
1311 EXCEPTION
1312   --
1313 WHEN xla_exceptions_pkg.application_exception THEN
1314    xla_accounting_err_pkg.build_message
1315                                        (p_appli_s_name            => 'XLA'
1316                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
1317                                        ,p_token_1                 => 'PROCEDURE'
1318                                        ,p_value_1                 => 'xla_accounting_cache_pkg.'||l_api_name
1319                                        ,p_entity_id               => g_cache_event.entity_id
1320                                        ,p_event_id                => g_cache_event.event_id
1321                                        ,p_ledger_id               => g_cache_event.target_ledger_id
1322                               );
1323 
1324   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1325      trace
1326          (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
1327          ,p_level    => C_LEVEL_EXCEPTION
1328          ,p_module   => l_log_module);
1329 
1330   END IF;
1331   RAISE;
1332 WHEN OTHERS  THEN
1333      xla_exceptions_pkg.raise_message
1334              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetLedgersInfo');
1335        --
1336 END GetLedgersInfo;
1337 --
1338 --
1339 /*======================================================================+
1340 |                                                                       |
1341 | Public Procedure                                                      |
1342 |                                                                       |
1343 |                                                                       |
1344 +======================================================================*/
1345 --
1346 FUNCTION  GetTranslatedEventInfo
1347 RETURN BOOLEAN
1348 IS
1349 l_log_module         VARCHAR2(240);
1350 BEGIN
1351 --
1352 IF g_log_enabled THEN
1353       l_log_module := C_DEFAULT_MODULE||'.GetTranslatedEventInfo';
1354 END IF;
1355 --
1356 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1357 
1358       trace
1359          (p_msg      => 'BEGIN of  GetTranslatedEventInfo'
1360          ,p_level    => C_LEVEL_PROCEDURE
1361          ,p_module   => l_log_module);
1362 
1363        trace
1364          (p_msg      => '-> CALL xla_accounting_cache_pkg.get_event_info API'
1365          ,p_level    => C_LEVEL_PROCEDURE
1366          ,p_module   => l_log_module);
1367 END IF;
1368 
1369  xla_accounting_cache_pkg.get_event_info
1370         (p_ledger_id                  => g_cache_event.target_ledger_id
1371         ,p_event_class_code           => g_cache_event.event_class
1372         ,p_event_type_code            => g_cache_event.event_type
1373         ,p_ledger_event_class_name    => g_cache_event_tl.event_class_name
1374         ,p_session_event_class_name   => g_cache_event_tl.session_event_class
1375         ,p_ledger_event_type_name     => g_cache_event_tl.event_type_name
1376         ,p_session_event_type_name    => g_cache_event_tl.session_event_type
1377        );
1378 
1379 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1380 
1381       trace
1382          (p_msg      => 'END of  GetTranslatedEventInfo'
1383          ,p_level    => C_LEVEL_PROCEDURE
1384          ,p_module   => l_log_module);
1385 
1386 END IF;
1387 RETURN TRUE;
1388 EXCEPTION
1389 WHEN xla_exceptions_pkg.application_exception THEN
1390    xla_accounting_err_pkg.build_message
1391                                        (p_appli_s_name            => 'XLA'
1392                                        ,p_msg_name                => 'XLA_AP_ACCT_ENGINE_ERROR'
1393                                        ,p_token_1                 => 'PROCEDURE'
1394                                        ,p_value_1                 => 'xla_accounting_cache_pkg.get_event_info'
1395                                        ,p_entity_id               => g_cache_event.entity_id
1396                                        ,p_event_id                => g_cache_event.event_id
1397                                        ,p_ledger_id               => g_cache_event.target_ledger_id
1398                               );
1399 
1400 
1401   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
1402 
1403          trace
1404              (p_msg      => 'ERROR: XLA_AP_ACCT_ENGINE_ERROR'
1405              ,p_level    => C_LEVEL_EXCEPTION
1406              ,p_module   => l_log_module);
1407 
1408   END IF;
1409   RAISE;
1410 WHEN OTHERS  THEN
1411      xla_exceptions_pkg.raise_message
1412              (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetTranslatedEventInfo');
1413 END GetTranslatedEventInfo;
1414 --
1415 --
1416 /*======================================================================+
1417 |                                                                       |
1418 | Public Procedure                                                      |
1419 |                                                                       |
1420 |                                                                       |
1421 +======================================================================*/
1422 --
1423 PROCEDURE free_ae_cache
1424 IS
1425 l_null_event             t_rec_event;
1426 l_null_pad               t_rec_product_rule;
1427 l_null_ledgers_info      t_rec_ledgers_info;
1428 l_null_event_tl          t_rec_event_tl;
1429 l_null_sc_value_set      XLA_AE_SOURCES_PKG.t_array_meaning;
1430 --
1431 l_log_module         VARCHAR2(240);
1432 --
1433 BEGIN
1434 --
1435 IF g_log_enabled THEN
1436       l_log_module := C_DEFAULT_MODULE||'.free_ae_cache';
1437 END IF;
1438 --
1439 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1440 
1441       trace
1442          (p_msg      => 'BEGIN of free_ae_cache'
1443          ,p_level    => C_LEVEL_PROCEDURE
1444          ,p_module   => l_log_module);
1445 
1446 END IF;
1447 
1448    g_global_status             := 2;
1449    g_cache_event               := l_null_event;
1450    g_cache_pad                 := l_null_pad;
1451    g_cache_ledgers_info        := l_null_ledgers_info;
1452    g_cache_event_tl            := l_null_event_tl;
1453    --
1454    XLA_AE_HEADER_PKG.RefreshHeader;
1455    XLA_AE_LINES_PKG.RefreshLines;
1456    --
1457    -- free source value set cache
1458    --
1459    XLA_AE_SOURCES_PKG.g_array_meaning:= l_null_sc_value_set;
1460    --
1461 --
1462 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1463 
1464       trace
1465          (p_msg      => 'END of free_ae_cache'
1466          ,p_level    => C_LEVEL_PROCEDURE
1467          ,p_module   => l_log_module);
1468 
1469 END IF;
1470 --
1471 EXCEPTION
1472 WHEN xla_exceptions_pkg.application_exception THEN
1473   RAISE;
1474 WHEN OTHERS  THEN
1475        xla_exceptions_pkg.raise_message
1476                (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.free_ae_cache');
1477 --
1478 END free_ae_cache;
1479 --
1480 --
1481 /*======================================================================+
1482 |                                                                       |
1483 | GetLineNumber                                                         |
1484 |                                                                       |
1485 |                                                                       |
1486 +======================================================================*/
1487 --
1488 PROCEDURE GetLineNumber
1489 IS
1490 --
1491 l_ae_line_num   NUMBER;
1492 l_ae_header_id  NUMBER;
1493 l_log_module         VARCHAR2(240);
1494 --
1495 type t_array_rowid is table of rowid index by binary_integer;
1496 
1497 
1498 l_array_rowid        t_array_rowid;
1499 l_array_rowid1       t_array_rowid;
1500 l_array_ae_line_num  t_array_Num;
1501 l_array_doc_rounding_amt1   t_array_Num;
1502 l_array_rounding_entd_amt1   t_array_Num;
1503 l_array_ledger_id    t_array_ledger_id;
1504 l_array_header_id    t_array_Num;
1505 /*
1506 l_array_base_ledgers      xla_accounting_cache_pkg.t_array_ledger_id;
1507 l_array_alc_ledgers       xla_accounting_cache_pkg.t_array_ledger_id ;
1508 l_array_ledgers           xla_accounting_cache_pkg.t_array_ledger_id ;
1509 */
1510 l_rounding_rule_code VARCHAR2(30);
1511 l_array_rounding_offset  t_array_Num;
1512 l_array_mau              t_array_Num;
1513 l_array_rounding_class_code  t_array_V30L;
1514 l_array_doc_rounding_level   t_array_V30L;
1515 l_array_unrounded_amount     t_array_Num;
1516 l_array_unrounded_entd_amount     t_array_Num;
1517 l_array_entd_mau              t_array_Num;
1518 
1519 l_curr_rounding_class_code VARCHAR2(30);
1520 l_curr_doc_rounding_level  VARCHAR2(30);
1521 l_curr_doc_rounding_amount NUMBER;
1522 l_curr_entd_rounding_amount NUMBER;
1523 l_curr_total_unrounded     NUMBER;
1524 l_curr_total_rounded       NUMBER;
1525 l_curr_entd_total_unrounded     NUMBER;
1526 l_curr_entd_total_rounded       NUMBER;
1527 l_curr_max_rowid           ROWID;
1528 l_curr_max_amount          NUMBER;
1529 l_curr_ledger_id           NUMBER;
1530 l_curr_header_id           NUMBER;
1531 l_curr_mau                 NUMBER;
1532 l_curr_entd_mau            NUMBER;
1533 l_curr_offset              NUMBER;
1534 j                          NUMBER;
1535 
1536 
1537 l_count             NUMBER :=1;
1538 
1539 l_ledger_attrs       xla_accounting_cache_pkg.t_array_ledger_attrs;
1540 
1541 CURSOR csr_rounding_lines is
1542 SELECT max(xalg.rowid)
1543        ,rounding_class_code
1544        ,document_rounding_level
1545        ,NVL(SUM(unrounded_accounted_cr), 0)
1546                 - NVL(SUM(unrounded_accounted_dr), 0) unrounded_amount
1547        ,ledger_id
1548        ,ae_header_id
1549        ,NVL(SUM(unrounded_entered_cr), 0)
1550                 - NVL(SUM(unrounded_entered_dr), 0) unrounded_entered_amount
1551        ,entered_currency_mau
1552 FROM   xla_ae_lines_gt xalg
1553 WHERE temp_line_num <> 0
1554 GROUP BY ledger_id, event_id, ae_header_id,
1555          rounding_class_code, document_rounding_level, ae_line_num
1556          ,entered_currency_mau
1557 HAVING document_rounding_level is not null
1558    AND rounding_class_code is not null
1559 ORDER BY document_rounding_level, rounding_class_code;
1560 
1561 
1562 BEGIN
1563 IF g_log_enabled THEN
1564       l_log_module := C_DEFAULT_MODULE||'.GetLineNumber';
1565 END IF;
1566 --
1567 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
1568 
1569       trace
1570          (p_msg      => 'BEGIN of GetLineNumber'
1571          ,p_level    => C_LEVEL_PROCEDURE
1572          ,p_module   => l_log_module);
1573 END IF;
1574 
1575 xla_accounting_cache_pkg.GetLedgerArray(l_ledger_attrs);
1576 
1577 For i in 1..l_ledger_attrs.array_ledger_id.COUNT LOOP
1578   l_array_mau(l_ledger_attrs.array_ledger_id(i)) := l_ledger_attrs.array_mau(i);
1579   l_array_rounding_offset(l_ledger_attrs.array_ledger_id(i)) :=
1580                                         l_ledger_attrs.array_rounding_offset(i);
1581 END LOOP;
1582 
1583 BEGIN
1584 
1585    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1586 
1587       trace
1588          (p_msg      => 'SQL - Update xla_ae_lines_gt'
1589          ,p_level    => C_LEVEL_STATEMENT
1590          ,p_module   => l_log_module);
1591 
1592    END IF;
1593 
1594 IF g_array_event_id.count > 0 then
1595 forall i in 1..g_array_event_id.count
1596 update xla_ae_lines_gt  ael
1597 set ae_header_id = g_array_ae_header_id(i)
1598    ,ref_ae_header_id = DECODE(ref_event_id,NULL,g_array_ae_header_id(i),ref_ae_header_id)
1599 /* Calling get_hash_value for each row is expensive.
1600    Moved the columns to the select statement to retrieve ae_line_num.
1601 
1602    ,line_hash_num =
1603 DBMS_UTILITY.GET_HASH_VALUE
1604         (ae_header_id
1605         ||gl_transfer_mode_code
1606         ||accounting_class_code
1607         ||rounding_class_code
1608         ||document_rounding_level
1609         ||currency_code
1610         ||currency_conversion_type
1611         ||currency_conversion_date
1612         ||currency_conversion_rate
1613         ||party_id
1614         ||party_site_id
1615         ||party_type_code
1616         ||code_combination_id
1617         ||code_combination_status_code
1618         ||segment1
1619         ||segment2
1620         ||segment3
1621         ||segment4
1622         ||segment5
1623         ||segment6
1624         ||segment7
1625         ||segment8
1626         ||segment9
1627         ||segment10
1628         ||segment11
1629         ||segment12
1630         ||segment13
1631         ||segment14
1632         ||segment15
1633         ||segment16
1634         ||segment17
1635         ||segment18
1636         ||segment19
1637         ||segment20
1638         ||segment21
1639         ||segment22
1640         ||segment23
1641         ||segment24
1642         ||segment25
1643         ||segment26
1644         ||segment27
1645         ||segment28
1646         ||segment29
1647         ||segment30
1648         ||alt_code_combination_id
1649         ||alt_ccid_status_code
1650         ||alt_segment1
1651         ||alt_segment2
1652         ||alt_segment3
1653         ||alt_segment4
1654         ||alt_segment5
1655         ||alt_segment6
1656         ||alt_segment7
1657         ||alt_segment8
1658         ||alt_segment9
1659         ||alt_segment10
1660         ||alt_segment11
1661         ||alt_segment12
1662         ||alt_segment13
1663         ||alt_segment14
1664         ||alt_segment15
1665         ||alt_segment16
1666         ||alt_segment17
1667         ||alt_segment18
1668         ||alt_segment19
1669         ||alt_segment20
1670         ||alt_segment21
1671         ||alt_segment22
1672         ||alt_segment23
1673         ||alt_segment24
1674         ||alt_segment25
1675         ||alt_segment26
1676         ||alt_segment27
1677         ||alt_segment28
1678         ||alt_segment29
1679         ||alt_segment30
1680         ||description
1681         ||jgzz_recon_ref
1682         ||ussgl_transaction_code
1683         ||merge_duplicate_code
1684         ||line_definition_owner_code
1685         ||line_definition_code
1686         ||business_class_code
1687         ||mpa_accrual_entry_flag
1688         ||encumbrance_type_id,
1689        1,
1690        1073741824)
1691 */
1692    , merge_index = CASE accounting_class_code
1693                    WHEN 'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY' THEN -1
1694                    ELSE
1695                      CASE nvl(code_combination_id,0)
1696                      WHEN -1 THEN temp_line_num
1697                      ELSE CASE nvl(alt_code_combination_id,0)
1698                          WHEN -1 THEN temp_line_num
1699                          ELSE
1700                           CASE merge_duplicate_code
1701                             WHEN 'A' THEN
1702                               CASE switch_side_flag
1703                               WHEN 'Y' THEN -1
1704                               ELSE
1705                                 CASE
1706                                   WHEN unrounded_accounted_cr is null THEN -2
1707                                   ELSE -3
1708                                 END
1709                               END
1710                             WHEN 'W' THEN
1711                                CASE
1712                                  WHEN unrounded_accounted_cr is null THEN -2
1713                                  ELSE -3
1714                                END
1715                             WHEN 'N' THEN temp_line_num
1716                            END
1717                          END
1718                       END
1719                     END
1720     /* CASE merge_duplicate_code
1721                     WHEN 'A' THEN
1722                       CASE switch_side_flag
1723                        WHEN 'Y' THEN -1
1724                        ELSE
1725                          CASE
1726                           WHEN accounted_cr is null THEN -2
1727                           ELSE -3
1728                          END
1729                        END
1730                     WHEN 'W' THEN
1731                       CASE
1732                        WHEN accounted_cr is null THEN -2
1733                        ELSE -3
1734                       END
1735                     WHEN 'N' THEN temp_line_num
1736                    END*/
1737 where ae_header_id = g_array_event_id(i)
1738   and event_id = g_array_event_id(i)
1739   and ledger_id = g_array_ledger_id(i)
1740   and balance_type_code = g_array_balance_type(i)
1741   --
1742   -- Bug 4719297 added NVL to the following.
1743   --
1744 -- 4669308 NVL(-1) creates a separate header for MPA reversal. NVL(0) combines original reversal and MPA reversal into 1 header
1745 --         Also, this was causing XLA_AE_LINES_U1 error
1746 --and nvl(header_num,-1) = nvl(g_array_header_num(i),-1)
1747   and     header_num     = nvl(g_array_header_num(i), 0);  -- 5100860 instead of nvl(header_num, 0)
1748 --and temp_line_num <> 0;                                  -- 5100860 should never be zero
1749 end if;
1750 
1751    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1752 
1753       trace
1754          (p_msg      => 'SQL - Update xla_ae_lines_gt 2'
1755          ,p_level    => C_LEVEL_STATEMENT
1756          ,p_module   => l_log_module);
1757 
1758    END IF;
1759 
1760    UpdateLineNumber;
1761 
1762 -- 4262811 ------------------------------------------------------------------
1763    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1764 
1765       trace
1766          (p_msg      => 'SQL - Update xla_ae_lines_gt 3.5'
1767          ,p_level    => C_LEVEL_STATEMENT
1768          ,p_module   => l_log_module);
1769 
1770    END IF;
1771 
1772 
1773 ----------------------------------------------------------
1774 -- Populate the parent_ae_line_num by the real ae_line_num
1775 ----------------------------------------------------------
1776 /* PROBLEM: incorrectly sets parent_ae_line_num to NULL
1777 forall i in 1..l_array_rowid.count
1778 update xla_ae_headers_gt h
1779    set parent_ae_line_num =
1780        (select l_array_ae_line_num(i)
1781           from xla_ae_lines_gt l
1782          where h.parent_header_id    = l.event_id   -- awan l.ae_header_id no rows
1783            and h.ledger_id           = l.ledger_id
1784            and h.balance_type_code   = l.balance_type_code
1785            and h.event_id            = l.event_id
1786            and l.header_num          = 0
1787            and l.rowid               = l_array_rowid(i))
1788  where parent_ae_line_num IS NOT NULL;
1789 */
1790   -- IF l_array_rowid.count > 0 THEN      commented IF for 7230462
1791       UPDATE xla_ae_headers_gt h
1792       SET    parent_ae_line_num =
1793           (SELECT ae_line_num
1794              FROM xla_ae_lines_gt l
1795             WHERE h.parent_header_id    = l.event_id   -- awan l.ae_header_id no rows
1796               AND h.ledger_id           = l.ledger_id
1797               AND h.balance_type_code   = l.balance_type_code
1798               AND h.event_id            = l.event_id
1799               AND h.event_id            = l.event_id
1800               AND h.parent_ae_line_num  = l.temp_line_num
1801               AND l.header_num          = 0)
1802       WHERE parent_ae_line_num IS NOT NULL;
1803   -- END IF;
1804 
1805 -----------------------------------------------------------------------------
1806 
1807    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1808 
1809       trace
1810          (p_msg      => 'SQL - Update xla_ae_lines_gt 4'
1811          ,p_level    => C_LEVEL_STATEMENT
1812          ,p_module   => l_log_module);
1813 
1814    END IF;
1815 
1816 UPDATE xla_ae_lines_gt  ael
1817    SET (ref_ae_header_id, ref_temp_line_num) =
1818           (SELECT ae_header_id, temp_line_num
1819              FROM xla_ae_lines_gt
1820             WHERE event_id = ael.ref_event_id
1821               AND ledger_id = ael.ledger_id
1822               AND balance_type_code = ael.balance_type_code
1823               AND temp_line_num = ael.temp_line_num * -1)
1824  WHERE ref_event_id IS NOT NULL
1825    AND ref_temp_line_num IS NULL;
1826 
1827    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1828       trace
1829          (p_msg      => 'SQL - Update xla_ae_lines_gt 5'
1830          ,p_level    => C_LEVEL_STATEMENT
1831          ,p_module   => l_log_module);
1832    END IF;
1833 
1834 open csr_rounding_lines;
1835   j:=1;
1836 /*
1837   l_curr_rounding_class_code := l_array_rounding_class_code(1);
1838   l_curr_doc_rounding_level := l_array_doc_rounding_level(1);
1839   l_curr_total_unrounded :=0;
1840   l_curr_total_rounded :=0;
1841   l_curr_max_rowid := l_array_rowid(1);
1842   l_curr_max_amount := ABS(l_array_unrounded_amount(1));
1843   l_curr_ledger_id :=l_array_ledger_id(1);
1844   l_curr_header_id :=l_array_header_id(1);
1845   l_curr_mau := l_array_mau(l_curr_ledger_id);
1846   l_curr_offset := l_array_rounding_offset(l_curr_ledger_id);
1847 */
1848   l_curr_rounding_class_code := null;
1849   l_curr_doc_rounding_level := null;
1850   l_curr_total_unrounded :=null;
1851   l_curr_total_rounded :=null;
1852   l_curr_max_rowid :=null;
1853   l_curr_max_amount := null;
1854   l_curr_ledger_id :=null;
1855   l_curr_header_id :=null;
1856   l_curr_mau := null;
1857   l_curr_entd_mau := null;
1858   l_curr_offset := null;
1859   l_curr_entd_rounding_amount := null;
1860   l_curr_entd_total_unrounded :=null;
1861   l_curr_entd_total_rounded :=null;
1862 
1863 LOOP
1864   FETCH csr_rounding_lines
1865   BULK COLLECT INTO l_array_rowid
1866                  ,l_array_rounding_class_code
1867                  ,l_array_doc_rounding_level
1868                  ,l_array_unrounded_amount
1869                  ,l_array_ledger_id
1870                  ,l_array_header_id
1871                  ,l_array_unrounded_entd_amount
1872                  ,l_array_entd_mau
1873   LIMIT C_BULK_LIMIT;
1874 
1875   IF(l_array_rounding_class_code.COUNT=0) THEN
1876     EXIT;
1877   END IF;
1878   IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1879       trace
1880          (p_msg      => 'SQL - Update xla_ae_lines_gt 6'
1881          ,p_level    => C_LEVEL_STATEMENT
1882          ,p_module   => l_log_module);
1883       trace
1884          (p_msg      => 'count:'||to_char(l_array_rounding_class_code.count)
1885          ,p_level    => C_LEVEL_STATEMENT
1886          ,p_module   => l_log_module);
1887   END IF;
1888 
1889   FOR Idx IN l_array_rounding_class_code.FIRST .. l_array_rounding_class_code.LAST LOOP
1890     IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1891       trace
1892          (p_msg      => 'Ixd:'||to_char(Idx) ||' rounding class code:'||l_array_rounding_class_code(Idx) || ' rounding level:'||l_array_doc_rounding_level(Idx)
1893                            || ' ledgerid:'||to_char(l_array_ledger_id(Idx))||' unrounded:'|| to_char(l_curr_total_unrounded)
1894                            ||' rounded:'|| to_char(l_curr_total_rounded)
1895          ,p_level    => C_LEVEL_STATEMENT
1896          ,p_module   => l_log_module);
1897       trace
1898          (p_msg      => 'amount:'||to_char(l_array_unrounded_amount(Idx))||'curr mau:'||to_char(l_curr_mau)||' curr offset:'||to_char(l_curr_offset)
1899          ,p_level    => C_LEVEL_STATEMENT
1900          ,p_module   => l_log_module);
1901       trace
1902          (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)
1903          ,p_level    => C_LEVEL_STATEMENT
1904          ,p_module   => l_log_module);
1905       trace
1906          (p_msg      => ' unrounded entered:'|| to_char(l_curr_entd_total_unrounded)
1907                            ||' rounded entered:'|| to_char(l_curr_entd_total_rounded)
1908                            ||' amount:'|| to_char(l_array_unrounded_entd_amount(Idx))
1909                            ||' mau:'|| to_char(l_array_entd_mau(Idx))
1910          ,p_level    => C_LEVEL_STATEMENT
1911          ,p_module   => l_log_module);
1912     END IF;
1913 
1914     IF(l_array_rounding_class_code(Idx) = l_curr_rounding_class_code
1915          AND l_array_doc_rounding_level(Idx) = l_curr_doc_rounding_level
1916          AND  l_array_header_id(Idx) = l_curr_header_id
1917          AND  l_array_ledger_id(Idx) = l_curr_ledger_id) THEN
1918       l_curr_total_unrounded:= l_curr_total_unrounded + l_array_unrounded_amount(Idx);
1919       l_curr_total_rounded:= l_curr_total_rounded
1920              + ROUND( l_array_unrounded_amount(Idx)/l_curr_mau + l_curr_offset)
1921              *l_curr_mau;
1922       l_curr_entd_total_unrounded:= l_curr_entd_total_unrounded + l_array_unrounded_entd_amount(Idx);
1923       l_curr_entd_total_rounded:= l_curr_entd_total_rounded
1924              + ROUND( l_array_unrounded_entd_amount(Idx)/l_array_entd_mau(Idx)+ l_curr_offset)
1925              *l_array_entd_mau(Idx);
1926       IF(l_curr_max_amount < ABS(l_array_unrounded_amount(Idx))) THEN
1927         l_curr_max_amount := ABS(l_array_unrounded_amount(Idx));
1928         l_curr_max_rowid := l_array_rowid(Idx);
1929       END IF;
1930     ELSE
1931       IF(l_curr_total_unrounded is not null) THEN
1932         l_curr_doc_rounding_amount :=
1933              ROUND(l_curr_total_unrounded/l_curr_mau + l_curr_offset)
1934              *l_curr_mau -l_curr_total_rounded;
1935         l_curr_entd_rounding_amount :=
1936              ROUND(l_curr_entd_total_unrounded/l_curr_entd_mau + l_curr_offset)
1937              *l_curr_entd_mau -l_curr_entd_total_rounded;
1938         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1939            trace
1940             (p_msg      => 'doc rounding is:'||to_char(l_curr_doc_rounding_amount)
1941                            ||' unrounded:'|| to_char(l_curr_total_unrounded)
1942                            ||' rounded:'|| to_char(l_curr_total_rounded)
1943             ,p_level    => C_LEVEL_STATEMENT
1944             ,p_module   => l_log_module);
1945            trace
1946             (p_msg      => 'entd rounding is:'||to_char(l_curr_entd_rounding_amount)
1947                            ||' unrounded:'|| to_char(l_curr_entd_total_unrounded)
1948                            ||' rounded:'|| to_char(l_curr_entd_total_rounded)
1949             ,p_level    => C_LEVEL_STATEMENT
1950             ,p_module   => l_log_module);
1951         END IF;
1952         IF(l_curr_doc_rounding_amount <>0 or l_curr_entd_rounding_amount <> 0) THEN
1953           l_array_rowid1(j):= l_curr_max_rowid;
1954           l_array_doc_rounding_amt1(j) := l_curr_doc_rounding_amount;
1955           l_array_rounding_entd_amt1(j) := l_curr_entd_rounding_amount;
1956           j:= j+1;
1957           IF (j> C_BULK_LIMIT) THEN
1958             FORALL i in 1..j-1
1959               update xla_ae_lines_gt
1960               set doc_rounding_acctd_amt = l_array_doc_rounding_amt1(i)
1961                  ,doc_rounding_entered_amt = l_array_rounding_entd_amt1(i)
1962               where rowid = l_array_rowid1(i);
1963             j:=1;
1964           END IF;
1965         END IF;
1966       END IF;
1967       IF(l_curr_ledger_id is null or
1968              l_curr_ledger_id <> l_array_ledger_id(Idx)) THEN
1969         l_curr_ledger_id :=l_array_ledger_id(Idx);
1970         l_curr_mau := l_array_mau(l_curr_ledger_id);
1971         l_curr_offset := l_array_rounding_offset(l_curr_ledger_id);
1972       END IF;
1973       l_curr_entd_mau:=l_array_entd_mau(Idx);
1974       l_curr_header_id :=l_array_header_id(Idx);
1975       l_curr_rounding_class_code := l_array_rounding_class_code(Idx);
1976       l_curr_doc_rounding_level := l_array_doc_rounding_level(Idx);
1977       l_curr_total_unrounded:= l_array_unrounded_amount(Idx);
1978       l_curr_total_rounded:=
1979              ROUND( l_array_unrounded_amount(Idx)/l_curr_mau + l_curr_offset)
1980              *l_curr_mau;
1981       l_curr_entd_total_unrounded:= l_array_unrounded_entd_amount(Idx);
1982         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1983            trace
1984             (p_msg      => '----l_curr_entd_total_rounded:'||to_char(l_curr_entd_total_rounded)
1985                            ||' l_array_unrounded_entd_amount(Idx):'|| to_char(l_array_unrounded_entd_amount(Idx))
1986                            ||' l_curr_entd_mau:'|| to_char(l_curr_entd_mau)
1987                            ||'l_curr_offset :'|| to_char(l_curr_offset)
1988             ,p_level    => C_LEVEL_STATEMENT
1989             ,p_module   => l_log_module);
1990         END IF;
1991       l_curr_entd_total_rounded:=
1992              ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)
1993              *l_curr_entd_mau;
1994         IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1995            trace
1996             (p_msg      => '----l_curr_entd_total_rounded:'||to_char(l_curr_entd_total_rounded)
1997                            ||' l_array_unrounded_entd_amount(Idx):'|| to_char(l_array_unrounded_entd_amount(Idx))
1998                            ||' l_curr_entd_mau:'|| to_char(l_curr_entd_mau)
1999                            ||'l_curr_offset :'|| to_char(l_curr_offset)
2000             ,p_level    => C_LEVEL_STATEMENT
2001             ,p_module   => l_log_module);
2002            trace
2003             (p_msg      => '----test:'||to_char(l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau)
2004                            ||' :'|| to_char(l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)
2005                            ||' :'|| to_char(ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset))
2006                            ||':'|| to_char(ROUND( l_array_unrounded_entd_amount(Idx)/l_curr_entd_mau+ l_curr_offset)*l_curr_entd_mau)
2007             ,p_level    => C_LEVEL_STATEMENT
2008             ,p_module   => l_log_module);
2009         END IF;
2010       l_curr_max_rowid := l_array_rowid(Idx);
2011       l_curr_max_amount := ABS(l_array_unrounded_amount(Idx));
2012     END IF;
2013   END LOOP;
2014 END LOOP;
2015 -- process the last one
2016 IF(l_curr_total_unrounded is not null) THEN
2017   l_curr_doc_rounding_amount :=
2018              ROUND(l_curr_total_unrounded/l_curr_mau + l_curr_offset)
2019              *l_curr_mau -l_curr_total_rounded;
2020   l_curr_entd_rounding_amount :=
2021              ROUND(l_curr_entd_total_unrounded/l_curr_entd_mau + l_curr_offset)
2022              *l_curr_entd_mau -l_curr_entd_total_rounded;
2023   IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2024          trace
2025             (p_msg      => 'doc rounding is:'||to_char(l_curr_doc_rounding_amount)
2026                            ||' unrounded:'|| to_char(l_curr_total_unrounded)
2027                            ||' rounded:'|| to_char(l_curr_total_rounded)
2028             ,p_level    => C_LEVEL_STATEMENT
2029             ,p_module   => l_log_module);
2030   END IF;
2031 END IF;
2032 IF(l_curr_doc_rounding_amount <>0  or l_curr_entd_rounding_amount <> 0) THEN
2033   l_array_rowid1(j):= l_curr_max_rowid;
2034   l_array_doc_rounding_amt1(j) := l_curr_doc_rounding_amount;
2035   l_array_rounding_entd_amt1(j) := l_curr_entd_rounding_amount;
2036   j:= j+1;
2037 END IF;
2038 
2039 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2040     trace
2041          (p_msg      => 'SQL - Update xla_ae_lines_gt 7, j='||to_char(j)
2042          ,p_level    => C_LEVEL_STATEMENT
2043          ,p_module   => l_log_module);
2044 END IF;
2045 
2046 IF j>1 THEN
2047   FORALL i in 1..j-1
2048     update xla_ae_lines_gt
2049     set doc_rounding_acctd_amt = l_array_doc_rounding_amt1(i)
2050        ,doc_rounding_entered_amt = l_array_rounding_entd_amt1(i)
2051     where rowid = l_array_rowid1(i);
2052 END IF;
2053 
2054 EXCEPTION
2055 WHEN OTHERS  THEN
2056 
2057   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
2058          trace
2059             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
2060             ,p_level    => C_LEVEL_EXCEPTION
2061             ,p_module   => l_log_module);
2062   END IF;
2063 
2064   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
2065                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
2066                                     ,p_token_1      => 'ERROR'
2067                                     ,p_value_1      => sqlerrm
2068                                     );
2069 END;
2070 
2071 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2072 
2073       trace
2074          (p_msg      => 'END of GetLineNumber'
2075          ,p_level    => C_LEVEL_PROCEDURE
2076          ,p_module   => l_log_module);
2077 END IF;
2078 
2079 EXCEPTION
2080 WHEN xla_exceptions_pkg.application_exception THEN
2081   RAISE;
2082 WHEN OTHERS  THEN
2083   xla_exceptions_pkg.raise_message
2084                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.GetLineNumber');
2085 END GetLineNumber;
2086 
2087 PROCEDURE UpdateLineNumber IS
2088 
2089    l_line_ac_count      PLS_INTEGER;
2090    l_log_module         VARCHAR2(240);
2091 
2092 BEGIN
2093 
2094    IF g_log_enabled THEN
2095       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber0';
2096    END IF;
2097    --
2098    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2099 
2100       trace
2101          (p_msg      => 'BEGIN of UpdateLineNumber0'
2102          ,p_level    => C_LEVEL_PROCEDURE
2103          ,p_module   => l_log_module);
2104 
2105    END IF;
2106 
2107    l_line_ac_count := xla_analytical_criteria_pkg.get_line_ac_count;
2108 
2109    IF l_line_ac_count = 0 THEN
2110 
2111       UpdateLineNumber0;
2112 
2113    ELSIF l_line_ac_count <= 10 THEN
2114 
2115       UpdateLineNumber10;
2116 
2117    ELSIF l_line_ac_count <= 50 THEN
2118 
2119       UpdateLineNumber50;
2120 
2121    ELSIF l_line_ac_count <= 100 THEN
2122 
2123       UpdateLineNumber100;
2124 
2125    END IF;
2126 
2127    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2128 
2129       trace
2130          (p_msg      => 'END of UpdateLineNumber'
2131          ,p_level    => C_LEVEL_PROCEDURE
2132          ,p_module   => l_log_module);
2133    END IF;
2134 
2135 EXCEPTION
2136 WHEN xla_exceptions_pkg.application_exception THEN
2137   RAISE;
2138 WHEN OTHERS  THEN
2139   xla_exceptions_pkg.raise_message
2140                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber');
2141 END UpdateLineNumber;
2142 
2143 
2144 PROCEDURE UpdateLineNumber0 IS
2145 
2146    l_array_rowid        t_array_rowid;
2147    l_array_ae_line_num  t_array_Num;
2148 
2149    l_log_module         VARCHAR2(240);
2150 
2151 BEGIN
2152 
2153    IF g_log_enabled THEN
2154       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber0';
2155    END IF;
2156    --
2157    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2158 
2159       trace
2160          (p_msg      => 'BEGIN of UpdateLineNumber0'
2161          ,p_level    => C_LEVEL_PROCEDURE
2162          ,p_module   => l_log_module);
2163 
2164    END IF;
2165 
2166    SELECT ROWID
2167          ,DENSE_RANK() OVER
2168           (PARTITION BY ae_header_id
2169                ORDER BY ae_header_id
2170                        ,gl_transfer_mode_code
2171                        ,accounting_class_code
2172 		       ,event_type_code
2173                        ,rounding_class_code
2174                        ,document_rounding_level
2175                        ,currency_code
2176                        ,currency_conversion_type
2177                        ,currency_conversion_date
2178                        ,currency_conversion_rate
2179                        ,party_id
2180                        ,party_site_id
2181                        ,party_type_code
2182                        ,code_combination_id
2183                        ,code_combination_status_code
2184                        ,segment1
2185                        ,segment2
2186                        ,segment3
2187                        ,segment4
2188                        ,segment5
2189                        ,segment6
2190                        ,segment7
2191                        ,segment8
2192                        ,segment9
2193                        ,segment10
2194                        ,segment11
2195                        ,segment12
2196                        ,segment13
2197                        ,segment14
2198                        ,segment15
2199                        ,segment16
2200                        ,segment17
2201                        ,segment18
2202                        ,segment19
2203                        ,segment20
2204                        ,segment21
2205                        ,segment22
2206                        ,segment23
2207                        ,segment24
2208                        ,segment25
2209                        ,segment26
2210                        ,segment27
2211                        ,segment28
2212                        ,segment29
2213                        ,segment30
2214                        ,alt_code_combination_id
2215                        ,alt_ccid_status_code
2216                        ,alt_segment1
2217                        ,alt_segment2
2218                        ,alt_segment3
2219                        ,alt_segment4
2220                        ,alt_segment5
2221                        ,alt_segment6
2222                        ,alt_segment7
2223                        ,alt_segment8
2224                        ,alt_segment9
2225                        ,alt_segment10
2226                        ,alt_segment11
2227                        ,alt_segment12
2228                        ,alt_segment13
2229                        ,alt_segment14
2230                        ,alt_segment15
2231                        ,alt_segment16
2232                        ,alt_segment17
2233                        ,alt_segment18
2234                        ,alt_segment19
2235                        ,alt_segment20
2236                        ,alt_segment21
2237                        ,alt_segment22
2238                        ,alt_segment23
2239                        ,alt_segment24
2240                        ,alt_segment25
2241                        ,alt_segment26
2242                        ,alt_segment27
2243                        ,alt_segment28
2244                        ,alt_segment29
2245                        ,alt_segment30
2246                        ,description
2247                        ,jgzz_recon_ref
2248                        ,ussgl_transaction_code
2249                        ,merge_duplicate_code
2250                        ,line_definition_owner_code
2251                        ,line_definition_code
2252                        ,business_class_code
2253                        ,mpa_accrual_entry_flag
2254                        ,encumbrance_type_id
2255                        ,merge_index)
2256 
2257                         ae_line_num
2258     BULK COLLECT
2259     INTO l_array_rowid
2260         ,l_array_ae_line_num
2261     FROM xla_ae_lines_gt
2262    WHERE temp_line_num <> 0;
2263 
2264    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2265 
2266       trace
2267          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
2268          ,p_level    => C_LEVEL_STATEMENT
2269          ,p_module   => l_log_module);
2270 
2271    END IF;
2272 
2273    FORALL i IN 1..l_array_rowid.COUNT
2274      UPDATE xla_ae_lines_gt
2275         SET ae_line_num = l_array_ae_line_num(i)
2276       WHERE rowid = l_array_rowid(i);
2277 
2278    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2279 
2280       trace
2281          (p_msg      => 'END of UpdateLineNumber0'
2282          ,p_level    => C_LEVEL_PROCEDURE
2283          ,p_module   => l_log_module);
2284    END IF;
2285 
2286 EXCEPTION
2287 WHEN xla_exceptions_pkg.application_exception THEN
2288   RAISE;
2289 WHEN OTHERS  THEN
2290   xla_exceptions_pkg.raise_message
2291                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber0');
2292 END UpdateLineNumber0;
2293 
2294 
2295 PROCEDURE UpdateLineNumber10 IS
2296 
2297    l_array_rowid        t_array_rowid;
2298    l_array_ae_line_num  t_array_Num;
2299 
2300    l_log_module         VARCHAR2(240);
2301 
2302 BEGIN
2303 
2304    IF g_log_enabled THEN
2305       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber10';
2306    END IF;
2307    --
2308    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2309 
2310       trace
2311          (p_msg      => 'BEGIN of UpdateLineNumber10'
2312          ,p_level    => C_LEVEL_PROCEDURE
2313          ,p_module   => l_log_module);
2314 
2315    END IF;
2316 
2317 SELECT ROWID
2318       ,DENSE_RANK() OVER
2319           (PARTITION BY ae_header_id
2320                ORDER BY ae_header_id
2321                        ,gl_transfer_mode_code
2322                        ,accounting_class_code
2323                        ,event_type_code
2324                        ,rounding_class_code
2325                        ,document_rounding_level
2326                        ,currency_code
2327                        ,currency_conversion_type
2328                        ,currency_conversion_date
2329                        ,currency_conversion_rate
2330                        ,party_id
2331                        ,party_site_id
2332                        ,party_type_code
2333                        ,code_combination_id
2334                        ,code_combination_status_code
2335                        ,segment1
2336                        ,segment2
2337                        ,segment3
2338                        ,segment4
2339                        ,segment5
2340                        ,segment6
2341                        ,segment7
2342                        ,segment8
2343                        ,segment9
2344                        ,segment10
2345                        ,segment11
2346                        ,segment12
2347                        ,segment13
2348                        ,segment14
2349                        ,segment15
2350                        ,segment16
2351                        ,segment17
2352                        ,segment18
2353                        ,segment19
2354                        ,segment20
2355                        ,segment21
2356                        ,segment22
2357                        ,segment23
2358                        ,segment24
2359                        ,segment25
2360                        ,segment26
2361                        ,segment27
2362                        ,segment28
2363                        ,segment29
2364                        ,segment30
2365                        ,alt_code_combination_id
2366                        ,alt_ccid_status_code
2367                        ,alt_segment1
2368                        ,alt_segment2
2369                        ,alt_segment3
2370                        ,alt_segment4
2371                        ,alt_segment5
2372                        ,alt_segment6
2373                        ,alt_segment7
2374                        ,alt_segment8
2375                        ,alt_segment9
2376                        ,alt_segment10
2377                        ,alt_segment11
2378                        ,alt_segment12
2379                        ,alt_segment13
2380                        ,alt_segment14
2381                        ,alt_segment15
2382                        ,alt_segment16
2383                        ,alt_segment17
2384                        ,alt_segment18
2385                        ,alt_segment19
2386                        ,alt_segment20
2387                        ,alt_segment21
2388                        ,alt_segment22
2389                        ,alt_segment23
2390                        ,alt_segment24
2391                        ,alt_segment25
2392                        ,alt_segment26
2393                        ,alt_segment27
2394                        ,alt_segment28
2395                        ,alt_segment29
2396                        ,alt_segment30
2397                        ,description
2398                        ,jgzz_recon_ref
2399                        ,ussgl_transaction_code
2400                        ,merge_duplicate_code
2401                        ,analytical_balance_flag
2402                        ,anc_id_1
2403                        ,anc_id_2
2404                        ,anc_id_3
2405                        ,anc_id_4
2406                        ,anc_id_5
2407                        ,anc_id_6
2408                        ,anc_id_7
2409                        ,anc_id_8
2410                        ,anc_id_9
2411                        ,anc_id_10
2412                        ,anc_id_11
2413                        ,anc_id_12
2414                        ,anc_id_13
2415                        ,anc_id_14
2416                        ,anc_id_15
2417                        ,anc_id_16
2418                        ,anc_id_17
2419                        ,anc_id_18
2420                        ,anc_id_19
2421                        ,anc_id_20
2422                        ,anc_id_21
2423                        ,anc_id_22
2424                        ,anc_id_23
2425                        ,anc_id_24
2426                        ,anc_id_25
2427                        ,anc_id_26
2428                        ,anc_id_27
2429                        ,anc_id_28
2430                        ,anc_id_29
2431                        ,anc_id_30
2432                        ,anc_id_31
2433                        ,anc_id_32
2434                        ,anc_id_33
2435                        ,anc_id_34
2436                        ,anc_id_35
2437                        ,anc_id_36
2438                        ,anc_id_37
2439                        ,anc_id_38
2440                        ,anc_id_39
2441                        ,anc_id_40
2442                        ,anc_id_41
2443                        ,anc_id_42
2444                        ,anc_id_43
2445                        ,anc_id_44
2446                        ,anc_id_45
2447                        ,anc_id_46
2448                        ,anc_id_47
2449                        ,anc_id_48
2450                        ,anc_id_49
2451                        ,anc_id_50
2452                        ,anc_id_51
2453                        ,anc_id_52
2454                        ,anc_id_53
2455                        ,anc_id_54
2456                        ,anc_id_55
2457                        ,anc_id_56
2458                        ,anc_id_57
2459                        ,anc_id_58
2460                        ,anc_id_59
2461                        ,anc_id_60
2462                        ,anc_id_61
2463                        ,anc_id_62
2464                        ,anc_id_63
2465                        ,anc_id_64
2466                        ,anc_id_65
2467                        ,anc_id_66
2468                        ,anc_id_67
2469                        ,anc_id_68
2470                        ,anc_id_69
2471                        ,anc_id_70
2472                        ,anc_id_71
2473                        ,anc_id_72
2474                        ,anc_id_73
2475                        ,anc_id_74
2476                        ,anc_id_75
2477                        ,anc_id_76
2478                        ,anc_id_77
2479                        ,anc_id_78
2480                        ,anc_id_79
2481                        ,anc_id_80
2482                        ,anc_id_81
2483                        ,anc_id_82
2484                        ,anc_id_83
2485                        ,anc_id_84
2486                        ,anc_id_85
2487                        ,anc_id_86
2488                        ,anc_id_87
2489                        ,anc_id_88
2490                        ,anc_id_89
2491                        ,anc_id_90
2492                        ,anc_id_91
2493                        ,anc_id_92
2494                        ,anc_id_93
2495                        ,anc_id_94
2496                        ,anc_id_95
2497                        ,anc_id_96
2498                        ,anc_id_97
2499                        ,anc_id_98
2500                        ,anc_id_99
2501                        ,anc_id_100
2502                        ,line_definition_owner_code
2503                        ,line_definition_code
2504                        ,business_class_code
2505                        ,mpa_accrual_entry_flag
2506                        ,encumbrance_type_id
2507                        ,merge_index)
2508 
2509                         ae_line_num
2510 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
2511 FROM xla_ae_lines_gt
2512 WHERE temp_line_num <> 0;
2513 
2514    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2515 
2516       trace
2517          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
2518          ,p_level    => C_LEVEL_STATEMENT
2519          ,p_module   => l_log_module);
2520 
2521    END IF;
2522 
2523 forall i in 1..l_array_rowid.count
2524 update xla_ae_lines_gt
2525 set ae_line_num = l_array_ae_line_num(i)
2526 where rowid = l_array_rowid(i);
2527 
2528 
2529 
2530    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2531 
2532       trace
2533          (p_msg      => 'END of UpdateLineNumber10'
2534          ,p_level    => C_LEVEL_PROCEDURE
2535          ,p_module   => l_log_module);
2536    END IF;
2537 
2538 EXCEPTION
2539 WHEN xla_exceptions_pkg.application_exception THEN
2540   RAISE;
2541 WHEN OTHERS  THEN
2542   xla_exceptions_pkg.raise_message
2543                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber10');
2544 END UpdateLineNumber10;
2545 
2546 
2547 PROCEDURE UpdateLineNumber50 IS
2548 
2549    l_array_rowid        t_array_rowid;
2550    l_array_ae_line_num  t_array_Num;
2551 
2552    l_log_module         VARCHAR2(240);
2553 
2554 BEGIN
2555 
2556    IF g_log_enabled THEN
2557       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber50';
2558    END IF;
2559    --
2560    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2561 
2562       trace
2563          (p_msg      => 'BEGIN of UpdateLineNumber50'
2564          ,p_level    => C_LEVEL_PROCEDURE
2565          ,p_module   => l_log_module);
2566 
2567    END IF;
2568 
2569 SELECT ROWID
2570       ,DENSE_RANK() OVER
2571           (PARTITION BY ae_header_id
2572                ORDER BY ae_header_id
2573                        ,gl_transfer_mode_code
2574                        ,accounting_class_code
2575                        ,event_type_code
2576                        ,rounding_class_code
2577                        ,document_rounding_level
2578                        ,currency_code
2579                        ,currency_conversion_type
2580                        ,currency_conversion_date
2581                        ,currency_conversion_rate
2582                        ,party_id
2583                        ,party_site_id
2584                        ,party_type_code
2585                        ,code_combination_id
2586                        ,code_combination_status_code
2587                        ,segment1
2588                        ,segment2
2589                        ,segment3
2590                        ,segment4
2591                        ,segment5
2592                        ,segment6
2593                        ,segment7
2594                        ,segment8
2595                        ,segment9
2596                        ,segment10
2597                        ,segment11
2598                        ,segment12
2599                        ,segment13
2600                        ,segment14
2601                        ,segment15
2602                        ,segment16
2603                        ,segment17
2604                        ,segment18
2605                        ,segment19
2606                        ,segment20
2607                        ,segment21
2608                        ,segment22
2609                        ,segment23
2610                        ,segment24
2611                        ,segment25
2612                        ,segment26
2613                        ,segment27
2614                        ,segment28
2615                        ,segment29
2616                        ,segment30
2617                        ,alt_code_combination_id
2618                        ,alt_ccid_status_code
2619                        ,alt_segment1
2620                        ,alt_segment2
2621                        ,alt_segment3
2622                        ,alt_segment4
2623                        ,alt_segment5
2624                        ,alt_segment6
2625                        ,alt_segment7
2626                        ,alt_segment8
2627                        ,alt_segment9
2628                        ,alt_segment10
2629                        ,alt_segment11
2630                        ,alt_segment12
2631                        ,alt_segment13
2632                        ,alt_segment14
2633                        ,alt_segment15
2634                        ,alt_segment16
2635                        ,alt_segment17
2636                        ,alt_segment18
2637                        ,alt_segment19
2638                        ,alt_segment20
2639                        ,alt_segment21
2640                        ,alt_segment22
2641                        ,alt_segment23
2642                        ,alt_segment24
2643                        ,alt_segment25
2644                        ,alt_segment26
2645                        ,alt_segment27
2646                        ,alt_segment28
2647                        ,alt_segment29
2648                        ,alt_segment30
2649                        ,description
2650                        ,jgzz_recon_ref
2651                        ,ussgl_transaction_code
2652                        ,merge_duplicate_code
2653                        ,analytical_balance_flag
2654                        ,anc_id_1
2655                        ,anc_id_2
2656                        ,anc_id_3
2657                        ,anc_id_4
2658                        ,anc_id_5
2659                        ,anc_id_6
2660                        ,anc_id_7
2661                        ,anc_id_8
2662                        ,anc_id_9
2663                        ,anc_id_10
2664                        ,anc_id_11
2665                        ,anc_id_12
2666                        ,anc_id_13
2667                        ,anc_id_14
2668                        ,anc_id_15
2669                        ,anc_id_16
2670                        ,anc_id_17
2671                        ,anc_id_18
2672                        ,anc_id_19
2673                        ,anc_id_20
2674                        ,anc_id_21
2675                        ,anc_id_22
2676                        ,anc_id_23
2677                        ,anc_id_24
2678                        ,anc_id_25
2679                        ,anc_id_26
2680                        ,anc_id_27
2681                        ,anc_id_28
2682                        ,anc_id_29
2683                        ,anc_id_30
2684                        ,anc_id_31
2685                        ,anc_id_32
2686                        ,anc_id_33
2687                        ,anc_id_34
2688                        ,anc_id_35
2689                        ,anc_id_36
2690                        ,anc_id_37
2691                        ,anc_id_38
2692                        ,anc_id_39
2693                        ,anc_id_40
2694                        ,anc_id_41
2695                        ,anc_id_42
2696                        ,anc_id_43
2697                        ,anc_id_44
2698                        ,anc_id_45
2699                        ,anc_id_46
2700                        ,anc_id_47
2701                        ,anc_id_48
2702                        ,anc_id_49
2703                        ,anc_id_50
2704                        ,anc_id_51
2705                        ,anc_id_52
2706                        ,anc_id_53
2707                        ,anc_id_54
2708                        ,anc_id_55
2709                        ,anc_id_56
2710                        ,anc_id_57
2711                        ,anc_id_58
2712                        ,anc_id_59
2713                        ,anc_id_60
2714                        ,anc_id_61
2715                        ,anc_id_62
2716                        ,anc_id_63
2717                        ,anc_id_64
2718                        ,anc_id_65
2719                        ,anc_id_66
2720                        ,anc_id_67
2721                        ,anc_id_68
2722                        ,anc_id_69
2723                        ,anc_id_70
2724                        ,anc_id_71
2725                        ,anc_id_72
2726                        ,anc_id_73
2727                        ,anc_id_74
2728                        ,anc_id_75
2729                        ,anc_id_76
2730                        ,anc_id_77
2731                        ,anc_id_78
2732                        ,anc_id_79
2733                        ,anc_id_80
2734                        ,anc_id_81
2735                        ,anc_id_82
2736                        ,anc_id_83
2737                        ,anc_id_84
2738                        ,anc_id_85
2739                        ,anc_id_86
2740                        ,anc_id_87
2741                        ,anc_id_88
2742                        ,anc_id_89
2743                        ,anc_id_90
2744                        ,anc_id_91
2745                        ,anc_id_92
2746                        ,anc_id_93
2747                        ,anc_id_94
2748                        ,anc_id_95
2749                        ,anc_id_96
2750                        ,anc_id_97
2751                        ,anc_id_98
2752                        ,anc_id_99
2753                        ,anc_id_100
2754                        ,line_definition_owner_code
2755                        ,line_definition_code
2756                        ,business_class_code
2757                        ,mpa_accrual_entry_flag
2758                        ,encumbrance_type_id
2759                        ,merge_index)
2760 
2761                         ae_line_num
2762 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
2763 FROM xla_ae_lines_gt
2764 WHERE temp_line_num <> 0;
2765 
2766    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
2767 
2768       trace
2769          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
2770          ,p_level    => C_LEVEL_STATEMENT
2771          ,p_module   => l_log_module);
2772 
2773    END IF;
2774 
2775 forall i in 1..l_array_rowid.count
2776 update xla_ae_lines_gt
2777 set ae_line_num = l_array_ae_line_num(i)
2778 where rowid = l_array_rowid(i);
2779 
2780 
2781    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2782 
2783       trace
2784          (p_msg      => 'END of UpdateLineNumber50'
2785          ,p_level    => C_LEVEL_PROCEDURE
2786          ,p_module   => l_log_module);
2787 
2788    END IF;
2789 
2790 EXCEPTION
2791 WHEN xla_exceptions_pkg.application_exception THEN
2792   RAISE;
2793 WHEN OTHERS  THEN
2794   xla_exceptions_pkg.raise_message
2795                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber50');
2796 END UpdateLineNumber50;
2797 
2798 PROCEDURE UpdateLineNumber100 IS
2799 
2800    l_array_rowid        t_array_rowid;
2801    l_array_ae_line_num  t_array_Num;
2802 
2803    l_log_module         VARCHAR2(240);
2804 
2805 BEGIN
2806 
2807    IF g_log_enabled THEN
2808       l_log_module := C_DEFAULT_MODULE||'.UpdateLineNumber100';
2809    END IF;
2810    --
2811    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
2812 
2813       trace
2814          (p_msg      => 'BEGIN of UpdateLineNumber100'
2815          ,p_level    => C_LEVEL_PROCEDURE
2816          ,p_module   => l_log_module);
2817 
2818    END IF;
2819 
2820 SELECT ROWID
2821       ,DENSE_RANK() OVER
2822           (PARTITION BY ae_header_id
2823                ORDER BY ae_header_id
2824                        ,gl_transfer_mode_code
2825                        ,accounting_class_code
2826                        ,event_type_code
2827                        ,rounding_class_code
2828                        ,document_rounding_level
2829                        ,currency_code
2830                        ,currency_conversion_type
2831                        ,currency_conversion_date
2832                        ,currency_conversion_rate
2833                        ,party_id
2834                        ,party_site_id
2835                        ,party_type_code
2836                        ,code_combination_id
2837                        ,code_combination_status_code
2838                        ,segment1
2839                        ,segment2
2840                        ,segment3
2841                        ,segment4
2842                        ,segment5
2843                        ,segment6
2844                        ,segment7
2845                        ,segment8
2846                        ,segment9
2847                        ,segment10
2848                        ,segment11
2849                        ,segment12
2850                        ,segment13
2851                        ,segment14
2852                        ,segment15
2853                        ,segment16
2854                        ,segment17
2855                        ,segment18
2856                        ,segment19
2857                        ,segment20
2858                        ,segment21
2859                        ,segment22
2860                        ,segment23
2861                        ,segment24
2862                        ,segment25
2863                        ,segment26
2864                        ,segment27
2865                        ,segment28
2866                        ,segment29
2867                        ,segment30
2868                        ,alt_code_combination_id
2869                        ,alt_ccid_status_code
2870                        ,alt_segment1
2871                        ,alt_segment2
2872                        ,alt_segment3
2873                        ,alt_segment4
2874                        ,alt_segment5
2875                        ,alt_segment6
2876                        ,alt_segment7
2877                        ,alt_segment8
2878                        ,alt_segment9
2879                        ,alt_segment10
2880                        ,alt_segment11
2881                        ,alt_segment12
2882                        ,alt_segment13
2883                        ,alt_segment14
2884                        ,alt_segment15
2885                        ,alt_segment16
2886                        ,alt_segment17
2887                        ,alt_segment18
2888                        ,alt_segment19
2889                        ,alt_segment20
2890                        ,alt_segment21
2891                        ,alt_segment22
2892                        ,alt_segment23
2893                        ,alt_segment24
2894                        ,alt_segment25
2895                        ,alt_segment26
2896                        ,alt_segment27
2897                        ,alt_segment28
2898                        ,alt_segment29
2899                        ,alt_segment30
2900                        ,description
2901                        ,jgzz_recon_ref
2902                        ,ussgl_transaction_code
2903                        ,merge_duplicate_code
2904                        ,analytical_balance_flag
2905                        ,anc_id_1
2906                        ,anc_id_2
2907                        ,anc_id_3
2908                        ,anc_id_4
2909                        ,anc_id_5
2910                        ,anc_id_6
2911                        ,anc_id_7
2912                        ,anc_id_8
2913                        ,anc_id_9
2914                        ,anc_id_10
2915                        ,anc_id_11
2916                        ,anc_id_12
2917                        ,anc_id_13
2918                        ,anc_id_14
2919                        ,anc_id_15
2920                        ,anc_id_16
2921                        ,anc_id_17
2922                        ,anc_id_18
2923                        ,anc_id_19
2924                        ,anc_id_20
2925                        ,anc_id_21
2926                        ,anc_id_22
2927                        ,anc_id_23
2928                        ,anc_id_24
2929                        ,anc_id_25
2930                        ,anc_id_26
2931                        ,anc_id_27
2932                        ,anc_id_28
2933                        ,anc_id_29
2934                        ,anc_id_30
2935                        ,anc_id_31
2936                        ,anc_id_32
2937                        ,anc_id_33
2938                        ,anc_id_34
2939                        ,anc_id_35
2940                        ,anc_id_36
2941                        ,anc_id_37
2942                        ,anc_id_38
2943                        ,anc_id_39
2944                        ,anc_id_40
2945                        ,anc_id_41
2946                        ,anc_id_42
2947                        ,anc_id_43
2948                        ,anc_id_44
2949                        ,anc_id_45
2950                        ,anc_id_46
2951                        ,anc_id_47
2952                        ,anc_id_48
2953                        ,anc_id_49
2954                        ,anc_id_50
2955                        ,anc_id_51
2956                        ,anc_id_52
2957                        ,anc_id_53
2958                        ,anc_id_54
2959                        ,anc_id_55
2960                        ,anc_id_56
2961                        ,anc_id_57
2962                        ,anc_id_58
2963                        ,anc_id_59
2964                        ,anc_id_60
2965                        ,anc_id_61
2966                        ,anc_id_62
2967                        ,anc_id_63
2968                        ,anc_id_64
2969                        ,anc_id_65
2970                        ,anc_id_66
2971                        ,anc_id_67
2972                        ,anc_id_68
2973                        ,anc_id_69
2974                        ,anc_id_70
2975                        ,anc_id_71
2976                        ,anc_id_72
2977                        ,anc_id_73
2978                        ,anc_id_74
2979                        ,anc_id_75
2980                        ,anc_id_76
2981                        ,anc_id_77
2982                        ,anc_id_78
2983                        ,anc_id_79
2984                        ,anc_id_80
2985                        ,anc_id_81
2986                        ,anc_id_82
2987                        ,anc_id_83
2988                        ,anc_id_84
2989                        ,anc_id_85
2990                        ,anc_id_86
2991                        ,anc_id_87
2992                        ,anc_id_88
2993                        ,anc_id_89
2994                        ,anc_id_90
2995                        ,anc_id_91
2996                        ,anc_id_92
2997                        ,anc_id_93
2998                        ,anc_id_94
2999                        ,anc_id_95
3000                        ,anc_id_96
3001                        ,anc_id_97
3002                        ,anc_id_98
3003                        ,anc_id_99
3004                        ,anc_id_100
3005                        ,line_definition_owner_code
3006                        ,line_definition_code
3007                        ,business_class_code
3008                        ,mpa_accrual_entry_flag
3009                        ,encumbrance_type_id
3010                        ,merge_index)
3011 
3012                         ae_line_num
3013 BULK COLLECT INTO l_array_rowid, l_array_ae_line_num
3014 FROM xla_ae_lines_gt
3015 WHERE temp_line_num <> 0;
3016 
3017    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3018 
3019       trace
3020          (p_msg      => 'SQL - Update xla_ae_lines_gt 3'
3021          ,p_level    => C_LEVEL_STATEMENT
3022          ,p_module   => l_log_module);
3023 
3024    END IF;
3025 
3026 forall i in 1..l_array_rowid.count
3027 update xla_ae_lines_gt
3028 set ae_line_num = l_array_ae_line_num(i)
3029 where rowid = l_array_rowid(i);
3030 
3031 
3032    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3033 
3034       trace
3035          (p_msg      => 'END of UpdateLineNumber100'
3036          ,p_level    => C_LEVEL_PROCEDURE
3037          ,p_module   => l_log_module);
3038 
3039    END IF;
3040 
3041 EXCEPTION
3042 WHEN xla_exceptions_pkg.application_exception THEN
3043   RAISE;
3044 WHEN OTHERS  THEN
3045   xla_exceptions_pkg.raise_message
3046                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.UpdateLineNumber100');
3047 END UpdateLineNumber100;
3048 --
3049 --
3050 /*======================================================================+
3051 |                                                                       |
3052 | Insert final Lines                                                    |
3053 |                                                                       |
3054 |                                                                       |
3055 +======================================================================*/
3056 --
3057 
3058 FUNCTION InsertLines(p_application_id         IN INTEGER
3059                     ,p_budgetary_control_mode IN VARCHAR2)
3060 RETURN NUMBER
3061 IS
3062 l_log_module         VARCHAR2(240);
3063 l_count number;
3064 l_ledger_attrs       xla_accounting_cache_pkg.t_array_ledger_attrs;
3065 l_accounting_mode    VARCHAR2(1);
3066 
3067 BEGIN
3068 --
3069 IF g_log_enabled THEN
3070       l_log_module := C_DEFAULT_MODULE||'.InsertLines';
3071 END IF;
3072 --
3073 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3074 
3075       trace
3076          (p_msg      => 'BEGIN of InsertLines'
3077          ,p_level    => C_LEVEL_PROCEDURE
3078          ,p_module   => l_log_module);
3079 
3080 END IF;
3081 l_accounting_mode := xla_accounting_pkg.g_accounting_mode;
3082 IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3083       trace
3084          (p_msg      => 'Accounting_mode = '||l_accounting_mode
3085          ,p_level    => C_LEVEL_STATEMENT
3086          ,p_module   => l_log_module);
3087 END IF;
3088 
3089 --
3090 BEGIN
3091 
3092    IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3093       trace
3094          (p_msg      => 'SQL - Insert into xla_ae_lines'
3095          ,p_level    => C_LEVEL_STATEMENT
3096          ,p_module   => l_log_module);
3097    END IF;
3098 --
3099 xla_accounting_cache_pkg.GetLedgerArray(l_ledger_attrs);
3100 
3101 
3102    IF (C_LEVEL_STATEMENT>= g_log_level) THEN
3103       trace
3104          (p_msg      => 'Before insert...'
3105          ,p_level    => C_LEVEL_STATEMENT
3106          ,p_module   => l_log_module);
3107    END IF;
3108 
3109 
3110 FORALL i in 1..l_ledger_attrs.array_ledger_id.count
3111   INSERT INTO xla_ae_lines
3112   (
3113      ae_header_id
3114    , ae_line_num
3115    , displayed_line_number
3116    , code_combination_id
3117    , gl_transfer_mode_code
3118    , creation_date
3119    , accounted_cr
3120    , accounted_dr
3121    , unrounded_accounted_cr
3122    , unrounded_accounted_dr
3123    , gain_or_loss_flag
3124    , accounting_class_code
3125    , currency_code
3126    , currency_conversion_date
3127    , currency_conversion_rate
3128    , currency_conversion_type
3129    , description
3130    , entered_cr
3131    , entered_dr
3132    , unrounded_entered_cr
3133    , unrounded_entered_dr
3134    , last_update_date
3135    , last_update_login
3136    , party_id
3137    , party_site_id
3138    , party_type_code
3139    , statistical_amount
3140    , ussgl_transaction_code
3141    , created_by
3142    , last_updated_by
3143    , jgzz_recon_ref
3144    , program_update_date
3145    , program_application_id
3146    , program_id
3147    , analytical_balance_flag
3148    , application_id
3149    , request_id
3150    , gl_sl_link_table
3151    , business_class_code    -- 4336173
3152    , mpa_accrual_entry_flag -- 4262811
3153    , encumbrance_type_id    -- 4458381 Public Sector Enh
3154    , ledger_id              --4955764
3155    , accounting_date        --4955764
3156    , gl_sl_link_id          --5041325
3157    , control_balance_flag   --4930177
3158   )
3159   (SELECT
3160       ae_header_id
3161      ,ae_line_num
3162      ,decode(nvl(accounted_cr, 0) + nvl(accounted_dr, 0), 0, -1, 1) *
3163          (ROW_NUMBER() over (PARTITION BY ae_header_id order by
3164                       DECODE(SIGN(abs(nvl(accounted_dr, 0)) - abs(nvl(accounted_cr, 0))), 1, 3, -1, 2, 0) desc,
3165                       abs(nvl(accounted_dr, 0) + nvl(accounted_cr, 0)) desc,
3166                       SIGN(nvl(accounted_dr, 0) + nvl(accounted_cr, 0)) desc))
3167      ,code_combination_id
3168      ,gl_transfer_mode_code
3169      ,creation_date
3170      ,accounted_cr
3171      ,accounted_dr
3172      ,unrounded_accounted_cr
3173      ,unrounded_accounted_dr
3174      ,gain_or_loss_flag
3175      ,decode(accounting_class_code, 'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY', 'EXCHANGE_GAIN_LOSS', accounting_class_code)
3176      ,currency_code
3177      ,currency_conversion_date
3178      ,currency_conversion_rate
3179      ,currency_conversion_type
3180      ,description
3181      ,entered_cr
3182      ,entered_dr
3183      ,unrounded_entered_cr
3184      ,unrounded_entered_dr
3185      ,last_update_date
3186      ,last_update_login
3187      ,party_id
3188      ,party_site_id
3189      ,party_type_code
3190      ,statistical_amount
3191      ,ussgl_transaction_code
3192      ,created_by
3193      ,last_updated_by
3194      ,jgzz_recon_ref
3195      ,program_update_date
3196      ,program_application_id
3197      ,program_id
3198      ,analytical_balance_flag
3199      ,application_id
3200      ,request_id
3201      ,gl_sl_link_table
3202      ,business_class_code
3203      ,mpa_accrual_entry_flag
3204      ,encumbrance_type_id
3205      ,ledger_id
3206      ,accounting_date
3207      ,Decode(l_accounting_mode,'F',xla_gl_sl_link_id_s.nextval,NULL)
3208      ,Decode(control_balance_flag,'Y','P'
3209 	                         ,'CUSTOMER','P'
3210 			         ,'SUPPLIER','P'
3211                                  ,NULL)
3212    FROM
3213   (SELECT /*+ Leading (LIN) Cardinality(LIN 1) use_nl(GCC) */
3214      lin.ae_header_id  ae_header_id
3215    , ae_line_num
3216    , CASE gain_or_loss_flag
3217      WHEN 'Y' THEN
3218        CASE calculate_g_l_amts_flag
3219        WHEN 'Y' THEN
3220            decode(SIGN(SUM(nvl(unrounded_accounted_cr, 0)-
3221              nvl(unrounded_accounted_dr, 0))),
3222              1,
3223                decode(code_combination_status_code
3224                   ,C_CCID_CREATED,lin.code_combination_id
3225                   , -1 ),
3226                decode(alt_ccid_status_code
3227                   ,C_CCID_CREATED,alt_code_combination_id
3228                   , -1 ))
3229        ELSE
3230            DECODE(code_combination_status_code
3231                 ,C_CCID_CREATED,lin.code_combination_id
3232                 , -1 )
3233        END
3234      ELSE
3235        DECODE(code_combination_status_code
3236             ,C_CCID_CREATED,lin.code_combination_id
3237             , -1 )
3238      END       code_combination_id
3239    , gl_transfer_mode_code
3240    , g_who_columns.creation_date  creation_date
3241 -- accounted_cr
3242    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, null,
3243        CASE switch_side_flag
3244        WHEN 'Y' THEN
3245          CASE SIGN(
3246                   NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)+
3247                   NVL(SUM(doc_rounding_acctd_amt), 0)
3248                 )
3249          WHEN -1 THEN null
3250          WHEN 1 THEN
3251               ROUND(
3252                 (NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)+
3253                 NVL(SUM(doc_rounding_acctd_amt), 0))
3254                 /l_ledger_attrs.array_mau(i)
3255                 +l_ledger_attrs.array_rounding_offset(i))
3256               *l_ledger_attrs.array_mau(i)
3257          ELSE
3258            CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)+
3259                   NVL(SUM(doc_rounding_entered_amt), 0))
3260            WHEN -1 THEN null
3261            WHEN 1 THEN 0
3262            ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3263            END
3264          END
3265        ELSE DECODE(SUM(unrounded_accounted_cr), null, to_number(null) ,
3266               ROUND(
3267                 (SUM(unrounded_accounted_cr) +
3268                 NVL(SUM(doc_rounding_acctd_amt), 0))
3269                 /l_ledger_attrs.array_mau(i)
3270                 +l_ledger_attrs.array_rounding_offset(i))
3271               *l_ledger_attrs.array_mau(i))
3272        END) accounted_cr
3273    -- accounted_dr
3274    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, null,
3275      CASE switch_side_flag
3276      WHEN 'Y' THEN
3277        CASE SIGN(
3278                   NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)-
3279                   NVL(SUM(doc_rounding_acctd_amt), 0)
3280                 )
3281        WHEN -1 THEN null
3282        WHEN 1 THEN
3283             ROUND(
3284                 (NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)-
3285                 NVL(SUM(doc_rounding_acctd_amt), 0))
3286                 /l_ledger_attrs.array_mau(i)
3287                 +l_ledger_attrs.array_rounding_offset(i))
3288               *l_ledger_attrs.array_mau(i)
3289        ELSE
3290          CASE SIGN(NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)-
3291                    NVL(SUM(doc_rounding_entered_amt), 0))
3292          WHEN -1 THEN null
3293          WHEN 1 THEN 0
3294          ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3295          END
3296        END
3297      ELSE
3298        decode(SUM(unrounded_accounted_cr), null,
3299             ROUND(
3300               (SUM(unrounded_accounted_dr)-NVL(SUM(doc_rounding_acctd_amt), 0))
3301               /l_ledger_attrs.array_mau(i)
3302               +l_ledger_attrs.array_rounding_offset(i))
3303               *l_ledger_attrs.array_mau(i)
3304            ,ROUND(
3305               SUM(unrounded_accounted_dr) /l_ledger_attrs.array_mau(i)
3306               +l_ledger_attrs.array_rounding_offset(i))
3307               *l_ledger_attrs.array_mau(i)
3308        )
3309      END) accounted_dr
3310    -- unrounded_accounted_cr
3311    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, null,
3312        CASE switch_side_flag
3313        WHEN 'Y' THEN
3314          CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3315          WHEN -1 THEN null
3316          WHEN 1 THEN
3317            NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)
3318          ELSE
3319            CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3320            WHEN -1 THEN null
3321            WHEN 1 THEN 0
3322            ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3323            END
3324          END
3325        ELSE SUM(unrounded_accounted_cr)
3326        END) unrounded_accounted_cr
3327    -- unrounded_accounted_dr
3328    , decode(nvl(sum(unrounded_accounted_cr), sum(unrounded_accounted_dr)), null, null,
3329        CASE switch_side_flag
3330        WHEN 'Y' THEN
3331          CASE SIGN(NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0))
3332          WHEN 1 THEN
3333            NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)
3334          WHEN -1 THEN null
3335          ELSE
3336            CASE SIGN(NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0))
3337            WHEN -1 THEN null
3338            WHEN 1 THEN 0
3339            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3340            END
3341          END
3342        ELSE SUM(unrounded_accounted_dr)
3343        END) unrounded_accounted_dr
3344    , gain_or_loss_flag
3345    , accounting_class_code
3346    , currency_code
3347    --, currency_conversion_date   new condition added below for bug7253542
3348    , DECODE(l_ledger_attrs.array_ledger_type(i),
3349             'PRIMARY',
3350             (DECODE(currency_code,
3351 		    l_ledger_attrs.array_ledger_currency_code(i),
3352                     NULL,
3353 		    currency_conversion_date)),
3354              currency_conversion_date) currency_conversion_date
3355    , currency_conversion_rate
3356    , currency_conversion_type
3357    , lin.description   description
3358    -- entered_cr
3359    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, null,
3360        CASE switch_side_flag
3361        WHEN 'Y' THEN
3362          CASE SIGN(
3363                   NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)+
3364                   NVL(SUM(doc_rounding_entered_amt), 0)
3365                 )
3366          WHEN -1 THEN null
3367          WHEN 1 THEN
3368               ROUND(
3369                 (NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)+
3370                 NVL(SUM(doc_rounding_entered_amt), 0))
3371                 /entered_currency_mau
3372                 +l_ledger_attrs.array_rounding_offset(i))
3373               *entered_currency_mau
3374          ELSE
3375                CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0)
3376                          +NVL(SUM(doc_rounding_acctd_amt), 0))
3377                WHEN -1 THEN null
3378                WHEN 1 THEN 0
3379                ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3380                END
3381          END
3382        ELSE DECODE(SUM(unrounded_entered_cr), null, to_number(null) ,
3383               ROUND(
3384                 (SUM(unrounded_entered_cr) +
3385                 NVL(SUM(doc_rounding_entered_amt), 0))
3386                 /entered_currency_mau
3387                 +l_ledger_attrs.array_rounding_offset(i))
3388               *entered_currency_mau)
3389        END) entered_cr
3390    -- entered_dr
3391    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, null,
3392        CASE switch_side_flag
3393        WHEN 'Y' THEN
3394          CASE SIGN(
3395                   NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)-
3396                   NVL(SUM(doc_rounding_entered_amt), 0)
3397                 )
3398          WHEN -1 THEN null
3399          WHEN 1 THEN
3400             ROUND(
3401                 (NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)-
3402                 NVL(SUM(doc_rounding_entered_amt), 0))
3403                 /entered_currency_mau
3404                 +l_ledger_attrs.array_rounding_offset(i))
3405               *entered_currency_mau
3406          ELSE
3407            CASE SIGN(NVL(SUM(unrounded_accounted_dr),0) - NVL(SUM(unrounded_accounted_cr),0)
3408                      -NVL(SUM(doc_rounding_acctd_amt), 0))
3409            WHEN -1 THEN null
3410            WHEN 1 THEN 0
3411            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3412            END
3413          END
3414        ELSE
3415            decode(SUM(unrounded_entered_cr), null,
3416             ROUND(
3417               (SUM(unrounded_entered_dr)-NVL(SUM(doc_rounding_entered_amt), 0))
3418               /entered_currency_mau
3419               +l_ledger_attrs.array_rounding_offset(i))
3420               *entered_currency_mau
3421            ,ROUND(
3422               SUM(unrounded_entered_dr) /entered_currency_mau
3423               +l_ledger_attrs.array_rounding_offset(i))
3424               *entered_currency_mau
3425            )
3426        END) entered_dr
3427    -- unrounded_entered_cr
3428    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, null,
3429        CASE switch_side_flag
3430        WHEN 'Y' THEN
3431          CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3432          WHEN -1 THEN null
3433          WHEN 1 THEN NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0)
3434          ELSE
3435            CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3436            WHEN -1 THEN null
3437            WHEN 1 THEN 0
3438            ELSE DECODE(sum(unrounded_accounted_cr), 0, 0, null)
3439            END
3440          END
3441        ELSE SUM(unrounded_entered_cr)
3442        END) unrounded_entered_cr
3443    -- unrounded_entered_dr
3444    , decode(nvl(sum(unrounded_entered_cr), sum(unrounded_entered_dr)), null, null,
3445        CASE switch_side_flag
3446        WHEN 'Y' THEN
3447          CASE SIGN(NVL(SUM(unrounded_entered_cr),0) - NVL(SUM(unrounded_entered_dr),0))
3448          WHEN 1 THEN null
3449          WHEN -1 THEN NVL(SUM(unrounded_entered_dr),0) - NVL(SUM(unrounded_entered_cr),0)
3450          ELSE
3451            CASE SIGN(NVL(SUM(unrounded_accounted_cr),0) - NVL(SUM(unrounded_accounted_dr),0))
3452            WHEN 1 THEN null
3453            WHEN -1 THEN 0
3454            ELSE DECODE(sum(unrounded_accounted_cr), 0, to_number(null), 0)
3455            END
3456          END
3457        ELSE SUM(unrounded_entered_dr)
3458        END) unrounded_entered_dr
3459    , g_who_columns.last_update_date      last_update_date
3460    , g_who_columns.last_update_login     last_update_login
3461    , party_id
3462    , party_site_id
3463    , party_type_code
3464    , sum(statistical_amount)            statistical_amount
3465    , ussgl_transaction_code
3466    , g_who_columns.created_by           created_by
3467    , g_who_columns.last_updated_by      last_updated_by
3468    , jgzz_recon_ref
3469    , g_who_columns.program_update_date  program_update_date
3470    , g_who_columns.program_application_id  program_application_id
3471    , g_who_columns.program_id           program_id
3472    , analytical_balance_flag            analytical_balance_flag
3473    , p_application_id                   application_id
3474    , g_who_columns.request_id           request_id
3475    , 'XLAJEL'                           gl_sl_link_table
3476    , business_class_code    -- 4336173
3477    , mpa_accrual_entry_flag -- 4262811
3478    , encumbrance_type_id    -- 4458381 Public Sector Enh
3479    , ledger_id              -- 4955764
3480    , accounting_date        -- 4955764
3481    , gcc.reference3                     control_balance_flag   --4930177
3482   FROM xla_ae_lines_gt     lin
3483       ,gl_code_combinations gcc
3484   WHERE ledger_id = l_ledger_attrs.array_ledger_id(i)
3485     AND ae_line_num is not NULL
3486     AND lin.code_combination_id = gcc.code_combination_id(+)     --5261785
3487  GROUP BY lin.ae_header_id
3488         , ae_line_num
3489         , header_num                    -- 4262811c  MPA reversal lines
3490         , gl_transfer_mode_code
3491         , g_who_columns.creation_date
3492         , g_who_columns.last_update_date
3493         , g_who_columns.last_update_login
3494         , g_who_columns.created_by
3495         , g_who_columns.last_updated_by
3496         , g_who_columns.program_update_date
3497         , g_who_columns.program_application_id
3498         , g_who_columns.program_id
3499         , g_who_columns.request_id
3500         , 'XLAJEL'
3501         , p_application_id
3502         , accounting_class_code
3503         , event_class_code
3504         , event_type_code
3505         , line_definition_owner_code
3506         , line_definition_code
3507         , entered_currency_mau
3508         , currency_code
3509         , currency_conversion_type
3510         , currency_conversion_date
3511         , currency_conversion_rate
3512         , party_id
3513         , party_site_id
3514         , party_type_code
3515         , lin.code_combination_id
3516         , C_CCID_CREATED
3517         , code_combination_status_code
3518         , lin.description
3519         , jgzz_recon_ref
3520         , ussgl_transaction_code
3521         , merge_duplicate_code
3522         , analytical_balance_flag
3523         , switch_side_flag
3524         , gain_or_loss_flag
3525         , calculate_g_l_amts_flag
3526         , alt_ccid_status_code
3527         , alt_code_combination_id
3528         , lin.business_class_code    -- 4336173
3529         , lin.mpa_accrual_entry_flag -- 4262811
3530         , encumbrance_type_id -- 4458381 Public Sector Enh
3531         , merge_index
3532         , ledger_id
3533         , accounting_date
3534         , gcc.reference3
3535         )
3536   WHERE accounting_class_code <>'DUMMY_EXCHANGE_GAIN_LOSS_DUMMY' or nvl(accounted_cr, 0) <> nvl(accounted_dr, 0)
3537 );
3538 --
3539 
3540 EXCEPTION
3541 WHEN OTHERS  THEN
3542 
3543   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3544          trace
3545             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
3546             ,p_level    => C_LEVEL_EXCEPTION
3547             ,p_module   => l_log_module);
3548   END IF;
3549 
3550   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
3551                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
3552                                     ,p_token_1      => 'ERROR'
3553                                     ,p_value_1      => sqlerrm
3554                                     );
3555 END;
3556 
3557 --
3558 l_count := SQL%ROWCOUNT;
3559 IF (C_LEVEL_EVENT >= g_log_level) THEN
3560       trace
3561          (p_msg      => '# journal entry lines inserted into xla_ae_lines = '||to_char(l_count)
3562          ,p_level    => C_LEVEL_EVENT
3563          ,p_module   => l_log_module);
3564 END IF;
3565 
3566 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3567 
3568       trace
3569          (p_msg      => 'return value. = '||TO_CHAR(l_count)
3570          ,p_level    => C_LEVEL_PROCEDURE
3571          ,p_module   => l_log_module);
3572 
3573 
3574       trace
3575          (p_msg      => 'END of InsertLines'
3576          ,p_level    => C_LEVEL_PROCEDURE
3577          ,p_module   => l_log_module);
3578 END IF;
3579 
3580 RETURN l_count;
3581 
3582 EXCEPTION
3583 WHEN xla_exceptions_pkg.application_exception THEN
3584   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3585        trace
3586            (p_msg      => 'Error. = '||sqlerrm
3587            ,p_level    => C_LEVEL_PROCEDURE
3588            ,p_module   => l_log_module);
3589   END IF;
3590   RAISE;
3591 WHEN OTHERS  THEN
3592   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3593        trace
3594            (p_msg      => 'Error. = '||sqlerrm
3595            ,p_level    => C_LEVEL_PROCEDURE
3596            ,p_module   => l_log_module);
3597   END IF;
3598   xla_exceptions_pkg.raise_message
3599                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertLines');
3600 END InsertLines;
3601 --
3602 --
3603 /*======================================================================+
3604 | PRIVATE Procedure                                                     |
3605 |                                                                       |
3606 | InsertAnalyticalCriteria                                              |
3607 |                                                                       |
3608 |                                                                       |
3609 +======================================================================*/
3610 --
3611 PROCEDURE InsertAnalyticalCriteria
3612 IS
3613 l_rowcount           NUMBER;
3614 l_log_module         VARCHAR2(240);
3615 l_reversal_flag      VARCHAR2(1);
3616 BEGIN
3617 --
3618 IF g_log_enabled THEN
3619       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria';
3620 END IF;
3621 --
3622 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3623 
3624       trace
3625          (p_msg      => 'BEGIN of InsertAnalyticalCriteria'
3626          ,p_level    => C_LEVEL_PROCEDURE
3627          ,p_module   => l_log_module);
3628 END IF;
3629 
3630 l_rowcount  := 0;
3631 
3632 BEGIN
3633 
3634    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3635 
3636       trace
3637          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
3638          ,p_level    => C_LEVEL_STATEMENT
3639          ,p_module   => l_log_module);
3640 
3641       trace
3642          (p_msg      => '# of line ACs: ' || g_line_ac_count
3643          ,p_level    => C_LEVEL_STATEMENT
3644          ,p_module   => l_log_module);
3645 
3646    END IF;
3647    BEGIN
3648 	SELECT 'Y' into l_reversal_flag
3649 	FROM dual
3650 	WHERE exists
3651 	(SELECT 1 FROM xla_ae_lines_gt WHERE reversal_code='REVERSAL');
3652 
3653 	IF l_reversal_flag='Y' THEN
3654 	    Insert_ANC_Inv_Canc;
3655 	END IF;
3656 
3657         EXCEPTION
3658 	WHEN NO_DATA_FOUND THEN
3659 	null;
3660    END;
3661 
3662 
3663    IF g_line_ac_count <= 10 THEN
3664 
3665       InsertAnalyticalCriteria10;
3666 
3667    ELSIF g_line_ac_count <= 50 THEN
3668 
3669       InsertAnalyticalCriteria50;
3670 
3671    ELSIF g_line_ac_count <= 100 THEN
3672 
3673       InsertAnalyticalCriteria100;
3674 
3675    END IF;
3676 
3677    --
3678    l_rowcount := SQL%ROWCOUNT;
3679 
3680    IF (C_LEVEL_EVENT >= g_log_level) THEN
3681       trace
3682          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
3683          ,p_level    => C_LEVEL_EVENT
3684          ,p_module   => l_log_module);
3685    END IF;
3686 
3687    EXCEPTION
3688    WHEN OTHERS  THEN
3689 
3690      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3691           trace
3692               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
3693               ,p_level    => C_LEVEL_EXCEPTION
3694               ,p_module   => l_log_module);
3695      END IF;
3696 
3697      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
3698                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
3699                                       ,p_token_1      => 'ERROR'
3700                                       ,p_value_1      => sqlerrm
3701                                       );
3702 
3703 
3704    END;
3705 
3706 EXCEPTION
3707 WHEN xla_exceptions_pkg.application_exception THEN
3708   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3709        trace
3710            (p_msg      => 'Error. = '||sqlerrm
3711            ,p_level    => C_LEVEL_PROCEDURE
3712            ,p_module   => l_log_module);
3713   END IF;
3714   RAISE;
3715 WHEN OTHERS  THEN
3716   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
3717        trace
3718            (p_msg      => 'Error. = '||sqlerrm
3719            ,p_level    => C_LEVEL_PROCEDURE
3720            ,p_module   => l_log_module);
3721   END IF;
3722   xla_exceptions_pkg.raise_message
3723                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria');
3724 END InsertAnalyticalCriteria;
3725 
3726 --
3727 --
3728 /*======================================================================+
3729 | PRIVATE Procedure                                                     |
3730 |                                                                       |
3731 | InsertAnalyticalCriteria10                                            |
3732 |                                                                       |
3733 |                                                                       |
3734 +======================================================================*/
3735 --
3736 PROCEDURE InsertAnalyticalCriteria10
3737 IS
3738 l_rowcount           NUMBER;
3739 l_log_module         VARCHAR2(240);
3740 BEGIN
3741 --
3742 IF g_log_enabled THEN
3743       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria10';
3744 END IF;
3745 --
3746 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
3747 
3748       trace
3749          (p_msg      => 'BEGIN of InsertAnalyticalCriteria10'
3750          ,p_level    => C_LEVEL_PROCEDURE
3751          ,p_module   => l_log_module);
3752 END IF;
3753 
3754 l_rowcount  := 0;
3755 
3756 BEGIN
3757 
3758    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
3759 
3760       trace
3761          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
3762          ,p_level    => C_LEVEL_STATEMENT
3763          ,p_module   => l_log_module);
3764 
3765    END IF;
3766 
3767 INSERT ALL
3768 WHEN anc_id_1 IS NOT NULL THEN
3769   INTO xla_ae_line_acs (
3770         ae_header_id , ae_line_num , object_version_number
3771       , analytical_criterion_code
3772       , analytical_criterion_type_code
3773       , amb_context_code
3774       , ac1,ac2,ac3,ac4,ac5)
3775 VALUES (ae_header_id, ae_line_num, C_OVN
3776 ,SUBSTRB(anc_id_1
3777        ,1
3778        ,INSTRB(anc_id_1,'(]',1,1) -1)
3779 ,SUBSTRB(anc_id_1
3780        ,INSTRB(anc_id_1,'(]',1,1) + 2
3781        ,INSTRB(anc_id_1,'(]',1,2) -
3782         INSTRB(anc_id_1,'(]',1,1) - 2)
3783 ,SUBSTRB(anc_id_1
3784        ,INSTRB(anc_id_1,'(]',1,2) + 2
3785        ,INSTRB(anc_id_1,'(]',1,3) -
3786         INSTRB(anc_id_1,'(]',1,2) - 2)
3787 ,SUBSTRB(anc_id_1
3788        ,INSTRB(anc_id_1,'(]',1,3) + 2
3789        ,INSTRB(anc_id_1,'(]',1,4) -
3790         INSTRB(anc_id_1,'(]',1,3) - 2)
3791 ,SUBSTRB(anc_id_1
3792        ,INSTRB(anc_id_1,'(]',1,4) + 2
3793        ,INSTRB(anc_id_1,'(]',1,5) -
3794         INSTRB(anc_id_1,'(]',1,4) - 2)
3795 ,SUBSTRB(anc_id_1
3796        ,INSTRB(anc_id_1,'(]',1,5) + 2
3797        ,INSTRB(anc_id_1,'(]',1,6) -
3798         INSTRB(anc_id_1,'(]',1,5) - 2)
3799 ,SUBSTRB(anc_id_1
3800        ,INSTRB(anc_id_1,'(]',1,6) + 2
3801        ,INSTRB(anc_id_1,'(]',1,7) -
3802         INSTRB(anc_id_1,'(]',1,6) - 2)
3803 ,SUBSTRB(anc_id_1
3804        ,INSTRB(anc_id_1,'(]',1,7) + 2
3805        ,LENGTHB(anc_id_1))
3806 )
3807 
3808 WHEN anc_id_2 IS NOT NULL THEN
3809   INTO xla_ae_line_acs (
3810         ae_header_id , ae_line_num , object_version_number
3811       , analytical_criterion_code
3812       , analytical_criterion_type_code
3813       , amb_context_code
3814       , ac1,ac2,ac3,ac4,ac5)
3815 VALUES (ae_header_id, ae_line_num, C_OVN
3816 ,SUBSTRB(anc_id_2
3817        ,1
3818        ,INSTRB(anc_id_2,'(]',1,1) -1)
3819 ,SUBSTRB(anc_id_2
3820        ,INSTRB(anc_id_2,'(]',1,1) + 2
3821        ,INSTRB(anc_id_2,'(]',1,2) -
3822         INSTRB(anc_id_2,'(]',1,1) - 2)
3823 ,SUBSTRB(anc_id_2
3824        ,INSTRB(anc_id_2,'(]',1,2) + 2
3825        ,INSTRB(anc_id_2,'(]',1,3) -
3826         INSTRB(anc_id_2,'(]',1,2) - 2)
3827 ,SUBSTRB(anc_id_2
3828        ,INSTRB(anc_id_2,'(]',1,3) + 2
3829        ,INSTRB(anc_id_2,'(]',1,4) -
3830         INSTRB(anc_id_2,'(]',1,3) - 2)
3831 ,SUBSTRB(anc_id_2
3832        ,INSTRB(anc_id_2,'(]',1,4) + 2
3833        ,INSTRB(anc_id_2,'(]',1,5) -
3834         INSTRB(anc_id_2,'(]',1,4) - 2)
3835 ,SUBSTRB(anc_id_2
3836        ,INSTRB(anc_id_2,'(]',1,5) + 2
3837        ,INSTRB(anc_id_2,'(]',1,6) -
3838         INSTRB(anc_id_2,'(]',1,5) - 2)
3839 ,SUBSTRB(anc_id_2
3840        ,INSTRB(anc_id_2,'(]',1,6) + 2
3841        ,INSTRB(anc_id_2,'(]',1,7) -
3842         INSTRB(anc_id_2,'(]',1,6) - 2)
3843 ,SUBSTRB(anc_id_2
3844        ,INSTRB(anc_id_2,'(]',1,7) + 2
3845        ,LENGTHB(anc_id_2))
3846 )
3847 
3848 WHEN anc_id_3 IS NOT NULL THEN
3849   INTO xla_ae_line_acs (
3850         ae_header_id , ae_line_num , object_version_number
3851       , analytical_criterion_code
3852       , analytical_criterion_type_code
3853       , amb_context_code
3854       , ac1,ac2,ac3,ac4,ac5)
3855 VALUES (ae_header_id, ae_line_num, C_OVN
3856 ,SUBSTRB(anc_id_3
3857        ,1
3858        ,INSTRB(anc_id_3,'(]',1,1) -1)
3859 ,SUBSTRB(anc_id_3
3860        ,INSTRB(anc_id_3,'(]',1,1) + 2
3861        ,INSTRB(anc_id_3,'(]',1,2) -
3862         INSTRB(anc_id_3,'(]',1,1) - 2)
3863 ,SUBSTRB(anc_id_3
3864        ,INSTRB(anc_id_3,'(]',1,2) + 2
3865        ,INSTRB(anc_id_3,'(]',1,3) -
3866         INSTRB(anc_id_3,'(]',1,2) - 2)
3867 ,SUBSTRB(anc_id_3
3868        ,INSTRB(anc_id_3,'(]',1,3) + 2
3869        ,INSTRB(anc_id_3,'(]',1,4) -
3870         INSTRB(anc_id_3,'(]',1,3) - 2)
3871 ,SUBSTRB(anc_id_3
3872        ,INSTRB(anc_id_3,'(]',1,4) + 2
3873        ,INSTRB(anc_id_3,'(]',1,5) -
3874         INSTRB(anc_id_3,'(]',1,4) - 2)
3875 ,SUBSTRB(anc_id_3
3876        ,INSTRB(anc_id_3,'(]',1,5) + 2
3877        ,INSTRB(anc_id_3,'(]',1,6) -
3878         INSTRB(anc_id_3,'(]',1,5) - 2)
3879 ,SUBSTRB(anc_id_3
3880        ,INSTRB(anc_id_3,'(]',1,6) + 2
3881        ,INSTRB(anc_id_3,'(]',1,7) -
3882         INSTRB(anc_id_3,'(]',1,6) - 2)
3883 ,SUBSTRB(anc_id_3
3884        ,INSTRB(anc_id_3,'(]',1,7) + 2
3885        ,LENGTHB(anc_id_3))
3886 )
3887 
3888 WHEN anc_id_4 IS NOT NULL THEN
3889   INTO xla_ae_line_acs (
3890         ae_header_id , ae_line_num , object_version_number
3891       , analytical_criterion_code
3892       , analytical_criterion_type_code
3893       , amb_context_code
3894       , ac1,ac2,ac3,ac4,ac5)
3895 VALUES (ae_header_id, ae_line_num, C_OVN
3896 ,SUBSTRB(anc_id_4
3897        ,1
3898        ,INSTRB(anc_id_4,'(]',1,1) -1)
3899 ,SUBSTRB(anc_id_4
3900        ,INSTRB(anc_id_4,'(]',1,1) + 2
3901        ,INSTRB(anc_id_4,'(]',1,2) -
3902         INSTRB(anc_id_4,'(]',1,1) - 2)
3903 ,SUBSTRB(anc_id_4
3904        ,INSTRB(anc_id_4,'(]',1,2) + 2
3905        ,INSTRB(anc_id_4,'(]',1,3) -
3906         INSTRB(anc_id_4,'(]',1,2) - 2)
3907 ,SUBSTRB(anc_id_4
3908        ,INSTRB(anc_id_4,'(]',1,3) + 2
3909        ,INSTRB(anc_id_4,'(]',1,4) -
3910         INSTRB(anc_id_4,'(]',1,3) - 2)
3911 ,SUBSTRB(anc_id_4
3912        ,INSTRB(anc_id_4,'(]',1,4) + 2
3913        ,INSTRB(anc_id_4,'(]',1,5) -
3914         INSTRB(anc_id_4,'(]',1,4) - 2)
3915 ,SUBSTRB(anc_id_4
3916        ,INSTRB(anc_id_4,'(]',1,5) + 2
3917        ,INSTRB(anc_id_4,'(]',1,6) -
3918         INSTRB(anc_id_4,'(]',1,5) - 2)
3919 ,SUBSTRB(anc_id_4
3920        ,INSTRB(anc_id_4,'(]',1,6) + 2
3921        ,INSTRB(anc_id_4,'(]',1,7) -
3922         INSTRB(anc_id_4,'(]',1,6) - 2)
3923 ,SUBSTRB(anc_id_4
3924        ,INSTRB(anc_id_4,'(]',1,7) + 2
3925        ,LENGTHB(anc_id_4))
3926 )
3927 
3928 WHEN anc_id_5 IS NOT NULL THEN
3929   INTO xla_ae_line_acs (
3930         ae_header_id , ae_line_num , object_version_number
3931       , analytical_criterion_code
3932       , analytical_criterion_type_code
3933       , amb_context_code
3934       , ac1,ac2,ac3,ac4,ac5)
3935 VALUES (ae_header_id, ae_line_num, C_OVN
3936 ,SUBSTRB(anc_id_5
3937        ,1
3938        ,INSTRB(anc_id_5,'(]',1,1) -1)
3939 ,SUBSTRB(anc_id_5
3940        ,INSTRB(anc_id_5,'(]',1,1) + 2
3941        ,INSTRB(anc_id_5,'(]',1,2) -
3942         INSTRB(anc_id_5,'(]',1,1) - 2)
3943 ,SUBSTRB(anc_id_5
3944        ,INSTRB(anc_id_5,'(]',1,2) + 2
3945        ,INSTRB(anc_id_5,'(]',1,3) -
3946         INSTRB(anc_id_5,'(]',1,2) - 2)
3947 ,SUBSTRB(anc_id_5
3948        ,INSTRB(anc_id_5,'(]',1,3) + 2
3949        ,INSTRB(anc_id_5,'(]',1,4) -
3950         INSTRB(anc_id_5,'(]',1,3) - 2)
3951 ,SUBSTRB(anc_id_5
3952        ,INSTRB(anc_id_5,'(]',1,4) + 2
3953        ,INSTRB(anc_id_5,'(]',1,5) -
3954         INSTRB(anc_id_5,'(]',1,4) - 2)
3955 ,SUBSTRB(anc_id_5
3956        ,INSTRB(anc_id_5,'(]',1,5) + 2
3957        ,INSTRB(anc_id_5,'(]',1,6) -
3958         INSTRB(anc_id_5,'(]',1,5) - 2)
3959 ,SUBSTRB(anc_id_5
3960        ,INSTRB(anc_id_5,'(]',1,6) + 2
3961        ,INSTRB(anc_id_5,'(]',1,7) -
3962         INSTRB(anc_id_5,'(]',1,6) - 2)
3963 ,SUBSTRB(anc_id_5
3964        ,INSTRB(anc_id_5,'(]',1,7) + 2
3965        ,LENGTHB(anc_id_5))
3966 )
3967 
3968 WHEN anc_id_6 IS NOT NULL THEN
3969   INTO xla_ae_line_acs (
3970         ae_header_id , ae_line_num , object_version_number
3971       , analytical_criterion_code
3972       , analytical_criterion_type_code
3973       , amb_context_code
3974       , ac1,ac2,ac3,ac4,ac5)
3975 VALUES (ae_header_id, ae_line_num, C_OVN
3976 ,SUBSTRB(anc_id_6
3977        ,1
3978        ,INSTRB(anc_id_6,'(]',1,1) -1)
3979 ,SUBSTRB(anc_id_6
3980        ,INSTRB(anc_id_6,'(]',1,1) + 2
3981        ,INSTRB(anc_id_6,'(]',1,2) -
3982         INSTRB(anc_id_6,'(]',1,1) - 2)
3983 ,SUBSTRB(anc_id_6
3984        ,INSTRB(anc_id_6,'(]',1,2) + 2
3985        ,INSTRB(anc_id_6,'(]',1,3) -
3986         INSTRB(anc_id_6,'(]',1,2) - 2)
3987 ,SUBSTRB(anc_id_6
3988        ,INSTRB(anc_id_6,'(]',1,3) + 2
3989        ,INSTRB(anc_id_6,'(]',1,4) -
3990         INSTRB(anc_id_6,'(]',1,3) - 2)
3991 ,SUBSTRB(anc_id_6
3992        ,INSTRB(anc_id_6,'(]',1,4) + 2
3993        ,INSTRB(anc_id_6,'(]',1,5) -
3994         INSTRB(anc_id_6,'(]',1,4) - 2)
3995 ,SUBSTRB(anc_id_6
3996        ,INSTRB(anc_id_6,'(]',1,5) + 2
3997        ,INSTRB(anc_id_6,'(]',1,6) -
3998         INSTRB(anc_id_6,'(]',1,5) - 2)
3999 ,SUBSTRB(anc_id_6
4000        ,INSTRB(anc_id_6,'(]',1,6) + 2
4001        ,INSTRB(anc_id_6,'(]',1,7) -
4002         INSTRB(anc_id_6,'(]',1,6) - 2)
4003 ,SUBSTRB(anc_id_6
4004        ,INSTRB(anc_id_6,'(]',1,7) + 2
4005        ,LENGTHB(anc_id_6))
4006 )
4007 
4008 WHEN anc_id_7 IS NOT NULL THEN
4009   INTO xla_ae_line_acs (
4010         ae_header_id , ae_line_num , object_version_number
4011       , analytical_criterion_code
4012       , analytical_criterion_type_code
4013       , amb_context_code
4014       , ac1,ac2,ac3,ac4,ac5)
4015 VALUES (ae_header_id, ae_line_num, C_OVN
4016 ,SUBSTRB(anc_id_7
4017        ,1
4018        ,INSTRB(anc_id_7,'(]',1,1) -1)
4019 ,SUBSTRB(anc_id_7
4020        ,INSTRB(anc_id_7,'(]',1,1) + 2
4021        ,INSTRB(anc_id_7,'(]',1,2) -
4022         INSTRB(anc_id_7,'(]',1,1) - 2)
4023 ,SUBSTRB(anc_id_7
4024        ,INSTRB(anc_id_7,'(]',1,2) + 2
4025        ,INSTRB(anc_id_7,'(]',1,3) -
4026         INSTRB(anc_id_7,'(]',1,2) - 2)
4027 ,SUBSTRB(anc_id_7
4028        ,INSTRB(anc_id_7,'(]',1,3) + 2
4029        ,INSTRB(anc_id_7,'(]',1,4) -
4030         INSTRB(anc_id_7,'(]',1,3) - 2)
4031 ,SUBSTRB(anc_id_7
4032        ,INSTRB(anc_id_7,'(]',1,4) + 2
4033        ,INSTRB(anc_id_7,'(]',1,5) -
4034         INSTRB(anc_id_7,'(]',1,4) - 2)
4035 ,SUBSTRB(anc_id_7
4036        ,INSTRB(anc_id_7,'(]',1,5) + 2
4037        ,INSTRB(anc_id_7,'(]',1,6) -
4038         INSTRB(anc_id_7,'(]',1,5) - 2)
4039 ,SUBSTRB(anc_id_7
4040        ,INSTRB(anc_id_7,'(]',1,6) + 2
4041        ,INSTRB(anc_id_7,'(]',1,7) -
4042         INSTRB(anc_id_7,'(]',1,6) - 2)
4043 ,SUBSTRB(anc_id_7
4044        ,INSTRB(anc_id_7,'(]',1,7) + 2
4045        ,LENGTHB(anc_id_7))
4046 )
4047 
4048 WHEN anc_id_8 IS NOT NULL THEN
4049   INTO xla_ae_line_acs (
4050         ae_header_id , ae_line_num , object_version_number
4051       , analytical_criterion_code
4052       , analytical_criterion_type_code
4053       , amb_context_code
4054       , ac1,ac2,ac3,ac4,ac5)
4055 VALUES (ae_header_id, ae_line_num, C_OVN
4056 ,SUBSTRB(anc_id_8
4057        ,1
4058        ,INSTRB(anc_id_8,'(]',1,1) -1)
4059 ,SUBSTRB(anc_id_8
4060        ,INSTRB(anc_id_8,'(]',1,1) + 2
4061        ,INSTRB(anc_id_8,'(]',1,2) -
4062         INSTRB(anc_id_8,'(]',1,1) - 2)
4063 ,SUBSTRB(anc_id_8
4064        ,INSTRB(anc_id_8,'(]',1,2) + 2
4065        ,INSTRB(anc_id_8,'(]',1,3) -
4066         INSTRB(anc_id_8,'(]',1,2) - 2)
4067 ,SUBSTRB(anc_id_8
4068        ,INSTRB(anc_id_8,'(]',1,3) + 2
4069        ,INSTRB(anc_id_8,'(]',1,4) -
4070         INSTRB(anc_id_8,'(]',1,3) - 2)
4071 ,SUBSTRB(anc_id_8
4072        ,INSTRB(anc_id_8,'(]',1,4) + 2
4073        ,INSTRB(anc_id_8,'(]',1,5) -
4074         INSTRB(anc_id_8,'(]',1,4) - 2)
4075 ,SUBSTRB(anc_id_8
4076        ,INSTRB(anc_id_8,'(]',1,5) + 2
4077        ,INSTRB(anc_id_8,'(]',1,6) -
4078         INSTRB(anc_id_8,'(]',1,5) - 2)
4079 ,SUBSTRB(anc_id_8
4080        ,INSTRB(anc_id_8,'(]',1,6) + 2
4081        ,INSTRB(anc_id_8,'(]',1,7) -
4082         INSTRB(anc_id_8,'(]',1,6) - 2)
4083 ,SUBSTRB(anc_id_8
4084        ,INSTRB(anc_id_8,'(]',1,7) + 2
4085        ,LENGTHB(anc_id_8))
4086 )
4087 
4088 WHEN anc_id_9 IS NOT NULL THEN
4089   INTO xla_ae_line_acs (
4090         ae_header_id , ae_line_num , object_version_number
4091       , analytical_criterion_code
4092       , analytical_criterion_type_code
4093       , amb_context_code
4094       , ac1,ac2,ac3,ac4,ac5)
4095 VALUES (ae_header_id, ae_line_num, C_OVN
4096 ,SUBSTRB(anc_id_9
4097        ,1
4098        ,INSTRB(anc_id_9,'(]',1,1) -1)
4099 ,SUBSTRB(anc_id_9
4100        ,INSTRB(anc_id_9,'(]',1,1) + 2
4101        ,INSTRB(anc_id_9,'(]',1,2) -
4102         INSTRB(anc_id_9,'(]',1,1) - 2)
4103 ,SUBSTRB(anc_id_9
4104        ,INSTRB(anc_id_9,'(]',1,2) + 2
4105        ,INSTRB(anc_id_9,'(]',1,3) -
4106         INSTRB(anc_id_9,'(]',1,2) - 2)
4107 ,SUBSTRB(anc_id_9
4108        ,INSTRB(anc_id_9,'(]',1,3) + 2
4109        ,INSTRB(anc_id_9,'(]',1,4) -
4110         INSTRB(anc_id_9,'(]',1,3) - 2)
4111 ,SUBSTRB(anc_id_9
4112        ,INSTRB(anc_id_9,'(]',1,4) + 2
4113        ,INSTRB(anc_id_9,'(]',1,5) -
4114         INSTRB(anc_id_9,'(]',1,4) - 2)
4115 ,SUBSTRB(anc_id_9
4116        ,INSTRB(anc_id_9,'(]',1,5) + 2
4117        ,INSTRB(anc_id_9,'(]',1,6) -
4118         INSTRB(anc_id_9,'(]',1,5) - 2)
4119 ,SUBSTRB(anc_id_9
4120        ,INSTRB(anc_id_9,'(]',1,6) + 2
4121        ,INSTRB(anc_id_9,'(]',1,7) -
4122         INSTRB(anc_id_9,'(]',1,6) - 2)
4123 ,SUBSTRB(anc_id_9
4124        ,INSTRB(anc_id_9,'(]',1,7) + 2
4125        ,LENGTHB(anc_id_9))
4126 )
4127 
4128 WHEN anc_id_10 IS NOT NULL THEN
4129   INTO xla_ae_line_acs (
4130         ae_header_id , ae_line_num , object_version_number
4131       , analytical_criterion_code
4132       , analytical_criterion_type_code
4133       , amb_context_code
4134       , ac1,ac2,ac3,ac4,ac5)
4135 VALUES (ae_header_id, ae_line_num, C_OVN
4136 ,SUBSTRB(anc_id_10
4137        ,1
4138        ,INSTRB(anc_id_10,'(]',1,1) -1)
4139 ,SUBSTRB(anc_id_10
4140        ,INSTRB(anc_id_10,'(]',1,1) + 2
4141        ,INSTRB(anc_id_10,'(]',1,2) -
4142         INSTRB(anc_id_10,'(]',1,1) - 2)
4143 ,SUBSTRB(anc_id_10
4144        ,INSTRB(anc_id_10,'(]',1,2) + 2
4145        ,INSTRB(anc_id_10,'(]',1,3) -
4146         INSTRB(anc_id_10,'(]',1,2) - 2)
4147 ,SUBSTRB(anc_id_10
4148        ,INSTRB(anc_id_10,'(]',1,3) + 2
4149        ,INSTRB(anc_id_10,'(]',1,4) -
4150         INSTRB(anc_id_10,'(]',1,3) - 2)
4151 ,SUBSTRB(anc_id_10
4152        ,INSTRB(anc_id_10,'(]',1,4) + 2
4153        ,INSTRB(anc_id_10,'(]',1,5) -
4154         INSTRB(anc_id_10,'(]',1,4) - 2)
4155 ,SUBSTRB(anc_id_10
4156        ,INSTRB(anc_id_10,'(]',1,5) + 2
4157        ,INSTRB(anc_id_10,'(]',1,6) -
4158         INSTRB(anc_id_10,'(]',1,5) - 2)
4159 ,SUBSTRB(anc_id_10
4160        ,INSTRB(anc_id_10,'(]',1,6) + 2
4161        ,INSTRB(anc_id_10,'(]',1,7) -
4162         INSTRB(anc_id_10,'(]',1,6) - 2)
4163 ,SUBSTRB(anc_id_10
4164        ,INSTRB(anc_id_10,'(]',1,7) + 2
4165        ,LENGTHB(anc_id_10))
4166 )
4167 SELECT  ae_header_id
4168       , ae_line_num
4169       , anc_id_1
4170       , anc_id_2
4171       , anc_id_3
4172       , anc_id_4
4173       , anc_id_5
4174       , anc_id_6
4175       , anc_id_7
4176       , anc_id_8
4177       , anc_id_9
4178       , anc_id_10
4179  FROM  xla_ae_lines_gt
4180 WHERE  ae_line_num is not null
4181 GROUP  BY
4182        ae_line_num
4183       ,ae_header_id
4184       ,anc_id_1
4185       ,anc_id_2
4186       ,anc_id_3
4187       ,anc_id_4
4188       ,anc_id_5
4189       ,anc_id_6
4190       ,anc_id_7
4191       ,anc_id_8
4192       ,anc_id_9
4193       ,anc_id_10
4194       ;
4195 
4196    --
4197    l_rowcount := SQL%ROWCOUNT;
4198 
4199    IF (C_LEVEL_EVENT >= g_log_level) THEN
4200       trace
4201          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
4202          ,p_level    => C_LEVEL_EVENT
4203          ,p_module   => l_log_module);
4204    END IF;
4205 
4206    EXCEPTION
4207    WHEN OTHERS  THEN
4208 
4209      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4210           trace
4211               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
4212               ,p_level    => C_LEVEL_EXCEPTION
4213               ,p_module   => l_log_module);
4214      END IF;
4215 
4216      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
4217                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
4218                                       ,p_token_1      => 'ERROR'
4219                                       ,p_value_1      => sqlerrm
4220                                       );
4221 
4222    END;
4223 
4224 EXCEPTION
4225 WHEN xla_exceptions_pkg.application_exception THEN
4226   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4227        trace
4228            (p_msg      => 'Error. = '||sqlerrm
4229            ,p_level    => C_LEVEL_PROCEDURE
4230            ,p_module   => l_log_module);
4231   END IF;
4232   RAISE;
4233 WHEN OTHERS  THEN
4234   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
4235        trace
4236            (p_msg      => 'Error. = '||sqlerrm
4237            ,p_level    => C_LEVEL_PROCEDURE
4238            ,p_module   => l_log_module);
4239   END IF;
4240   xla_exceptions_pkg.raise_message
4241        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria10');
4242 END InsertAnalyticalCriteria10;
4243 
4244 
4245 --
4246 --
4247 /*======================================================================+
4248 | PRIVATE Procedure                                                     |
4249 |                                                                       |
4250 | InsertAnalyticalCriteria50                                            |
4251 |                                                                       |
4252 |                                                                       |
4253 +======================================================================*/
4254 --
4255 PROCEDURE InsertAnalyticalCriteria50
4256 IS
4257 l_rowcount           NUMBER;
4258 l_log_module         VARCHAR2(240);
4259 BEGIN
4260 --
4261 IF g_log_enabled THEN
4262       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria50';
4263 END IF;
4264 --
4265 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
4266 
4267       trace
4268          (p_msg      => 'BEGIN of InsertAnalyticalCriteria50'
4269          ,p_level    => C_LEVEL_PROCEDURE
4270          ,p_module   => l_log_module);
4271 END IF;
4272 
4273 l_rowcount  := 0;
4274 
4275 BEGIN
4276 
4277    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
4278 
4279       trace
4280          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
4281          ,p_level    => C_LEVEL_STATEMENT
4282          ,p_module   => l_log_module);
4283 
4284    END IF;
4285 
4286 INSERT ALL
4287 WHEN anc_id_1 IS NOT NULL THEN
4288   INTO xla_ae_line_acs (
4289         ae_header_id , ae_line_num , object_version_number
4290       , analytical_criterion_code
4291       , analytical_criterion_type_code
4292       , amb_context_code
4293       , ac1,ac2,ac3,ac4,ac5)
4294 VALUES (ae_header_id, ae_line_num, C_OVN
4295 ,SUBSTRB(anc_id_1
4296        ,1
4297        ,INSTRB(anc_id_1,'(]',1,1) -1)
4298 ,SUBSTRB(anc_id_1
4299        ,INSTRB(anc_id_1,'(]',1,1) + 2
4300        ,INSTRB(anc_id_1,'(]',1,2) -
4301         INSTRB(anc_id_1,'(]',1,1) - 2)
4302 ,SUBSTRB(anc_id_1
4303        ,INSTRB(anc_id_1,'(]',1,2) + 2
4304        ,INSTRB(anc_id_1,'(]',1,3) -
4305         INSTRB(anc_id_1,'(]',1,2) - 2)
4306 ,SUBSTRB(anc_id_1
4307        ,INSTRB(anc_id_1,'(]',1,3) + 2
4308        ,INSTRB(anc_id_1,'(]',1,4) -
4309         INSTRB(anc_id_1,'(]',1,3) - 2)
4310 ,SUBSTRB(anc_id_1
4311        ,INSTRB(anc_id_1,'(]',1,4) + 2
4312        ,INSTRB(anc_id_1,'(]',1,5) -
4313         INSTRB(anc_id_1,'(]',1,4) - 2)
4314 ,SUBSTRB(anc_id_1
4315        ,INSTRB(anc_id_1,'(]',1,5) + 2
4316        ,INSTRB(anc_id_1,'(]',1,6) -
4317         INSTRB(anc_id_1,'(]',1,5) - 2)
4318 ,SUBSTRB(anc_id_1
4319        ,INSTRB(anc_id_1,'(]',1,6) + 2
4320        ,INSTRB(anc_id_1,'(]',1,7) -
4321         INSTRB(anc_id_1,'(]',1,6) - 2)
4322 ,SUBSTRB(anc_id_1
4323        ,INSTRB(anc_id_1,'(]',1,7) + 2
4324        ,LENGTHB(anc_id_1))
4325 )
4326 
4327 WHEN anc_id_2 IS NOT NULL THEN
4328   INTO xla_ae_line_acs (
4329         ae_header_id , ae_line_num , object_version_number
4330       , analytical_criterion_code
4331       , analytical_criterion_type_code
4332       , amb_context_code
4333       , ac1,ac2,ac3,ac4,ac5)
4334 VALUES (ae_header_id, ae_line_num, C_OVN
4335 ,SUBSTRB(anc_id_2
4336        ,1
4337        ,INSTRB(anc_id_2,'(]',1,1) -1)
4338 ,SUBSTRB(anc_id_2
4339        ,INSTRB(anc_id_2,'(]',1,1) + 2
4340        ,INSTRB(anc_id_2,'(]',1,2) -
4341         INSTRB(anc_id_2,'(]',1,1) - 2)
4342 ,SUBSTRB(anc_id_2
4343        ,INSTRB(anc_id_2,'(]',1,2) + 2
4344        ,INSTRB(anc_id_2,'(]',1,3) -
4345         INSTRB(anc_id_2,'(]',1,2) - 2)
4346 ,SUBSTRB(anc_id_2
4347        ,INSTRB(anc_id_2,'(]',1,3) + 2
4348        ,INSTRB(anc_id_2,'(]',1,4) -
4349         INSTRB(anc_id_2,'(]',1,3) - 2)
4350 ,SUBSTRB(anc_id_2
4351        ,INSTRB(anc_id_2,'(]',1,4) + 2
4352        ,INSTRB(anc_id_2,'(]',1,5) -
4353         INSTRB(anc_id_2,'(]',1,4) - 2)
4354 ,SUBSTRB(anc_id_2
4355        ,INSTRB(anc_id_2,'(]',1,5) + 2
4356        ,INSTRB(anc_id_2,'(]',1,6) -
4357         INSTRB(anc_id_2,'(]',1,5) - 2)
4358 ,SUBSTRB(anc_id_2
4359        ,INSTRB(anc_id_2,'(]',1,6) + 2
4360        ,INSTRB(anc_id_2,'(]',1,7) -
4361         INSTRB(anc_id_2,'(]',1,6) - 2)
4362 ,SUBSTRB(anc_id_2
4363        ,INSTRB(anc_id_2,'(]',1,7) + 2
4364        ,LENGTHB(anc_id_2))
4365 )
4366 
4367 WHEN anc_id_3 IS NOT NULL THEN
4368   INTO xla_ae_line_acs (
4369         ae_header_id , ae_line_num , object_version_number
4370       , analytical_criterion_code
4371       , analytical_criterion_type_code
4372       , amb_context_code
4373       , ac1,ac2,ac3,ac4,ac5)
4374 VALUES (ae_header_id, ae_line_num, C_OVN
4375 ,SUBSTRB(anc_id_3
4376        ,1
4377        ,INSTRB(anc_id_3,'(]',1,1) -1)
4378 ,SUBSTRB(anc_id_3
4379        ,INSTRB(anc_id_3,'(]',1,1) + 2
4380        ,INSTRB(anc_id_3,'(]',1,2) -
4381         INSTRB(anc_id_3,'(]',1,1) - 2)
4382 ,SUBSTRB(anc_id_3
4383        ,INSTRB(anc_id_3,'(]',1,2) + 2
4384        ,INSTRB(anc_id_3,'(]',1,3) -
4385         INSTRB(anc_id_3,'(]',1,2) - 2)
4386 ,SUBSTRB(anc_id_3
4387        ,INSTRB(anc_id_3,'(]',1,3) + 2
4388        ,INSTRB(anc_id_3,'(]',1,4) -
4389         INSTRB(anc_id_3,'(]',1,3) - 2)
4390 ,SUBSTRB(anc_id_3
4391        ,INSTRB(anc_id_3,'(]',1,4) + 2
4392        ,INSTRB(anc_id_3,'(]',1,5) -
4393         INSTRB(anc_id_3,'(]',1,4) - 2)
4394 ,SUBSTRB(anc_id_3
4395        ,INSTRB(anc_id_3,'(]',1,5) + 2
4396        ,INSTRB(anc_id_3,'(]',1,6) -
4397         INSTRB(anc_id_3,'(]',1,5) - 2)
4398 ,SUBSTRB(anc_id_3
4399        ,INSTRB(anc_id_3,'(]',1,6) + 2
4400        ,INSTRB(anc_id_3,'(]',1,7) -
4401         INSTRB(anc_id_3,'(]',1,6) - 2)
4402 ,SUBSTRB(anc_id_3
4403        ,INSTRB(anc_id_3,'(]',1,7) + 2
4404        ,LENGTHB(anc_id_3))
4405 )
4406 
4407 WHEN anc_id_4 IS NOT NULL THEN
4408   INTO xla_ae_line_acs (
4409         ae_header_id , ae_line_num , object_version_number
4410       , analytical_criterion_code
4411       , analytical_criterion_type_code
4412       , amb_context_code
4413       , ac1,ac2,ac3,ac4,ac5)
4414 VALUES (ae_header_id, ae_line_num, C_OVN
4415 ,SUBSTRB(anc_id_4
4416        ,1
4417        ,INSTRB(anc_id_4,'(]',1,1) -1)
4418 ,SUBSTRB(anc_id_4
4419        ,INSTRB(anc_id_4,'(]',1,1) + 2
4420        ,INSTRB(anc_id_4,'(]',1,2) -
4421         INSTRB(anc_id_4,'(]',1,1) - 2)
4422 ,SUBSTRB(anc_id_4
4423        ,INSTRB(anc_id_4,'(]',1,2) + 2
4424        ,INSTRB(anc_id_4,'(]',1,3) -
4425         INSTRB(anc_id_4,'(]',1,2) - 2)
4426 ,SUBSTRB(anc_id_4
4427        ,INSTRB(anc_id_4,'(]',1,3) + 2
4428        ,INSTRB(anc_id_4,'(]',1,4) -
4429         INSTRB(anc_id_4,'(]',1,3) - 2)
4430 ,SUBSTRB(anc_id_4
4431        ,INSTRB(anc_id_4,'(]',1,4) + 2
4432        ,INSTRB(anc_id_4,'(]',1,5) -
4433         INSTRB(anc_id_4,'(]',1,4) - 2)
4434 ,SUBSTRB(anc_id_4
4435        ,INSTRB(anc_id_4,'(]',1,5) + 2
4436        ,INSTRB(anc_id_4,'(]',1,6) -
4437         INSTRB(anc_id_4,'(]',1,5) - 2)
4438 ,SUBSTRB(anc_id_4
4439        ,INSTRB(anc_id_4,'(]',1,6) + 2
4440        ,INSTRB(anc_id_4,'(]',1,7) -
4441         INSTRB(anc_id_4,'(]',1,6) - 2)
4442 ,SUBSTRB(anc_id_4
4443        ,INSTRB(anc_id_4,'(]',1,7) + 2
4444        ,LENGTHB(anc_id_4))
4445 )
4446 
4447 WHEN anc_id_5 IS NOT NULL THEN
4448   INTO xla_ae_line_acs (
4449         ae_header_id , ae_line_num , object_version_number
4450       , analytical_criterion_code
4451       , analytical_criterion_type_code
4452       , amb_context_code
4453       , ac1,ac2,ac3,ac4,ac5)
4454 VALUES (ae_header_id, ae_line_num, C_OVN
4455 ,SUBSTRB(anc_id_5
4456        ,1
4457        ,INSTRB(anc_id_5,'(]',1,1) -1)
4458 ,SUBSTRB(anc_id_5
4459        ,INSTRB(anc_id_5,'(]',1,1) + 2
4460        ,INSTRB(anc_id_5,'(]',1,2) -
4461         INSTRB(anc_id_5,'(]',1,1) - 2)
4462 ,SUBSTRB(anc_id_5
4463        ,INSTRB(anc_id_5,'(]',1,2) + 2
4464        ,INSTRB(anc_id_5,'(]',1,3) -
4465         INSTRB(anc_id_5,'(]',1,2) - 2)
4466 ,SUBSTRB(anc_id_5
4467        ,INSTRB(anc_id_5,'(]',1,3) + 2
4468        ,INSTRB(anc_id_5,'(]',1,4) -
4469         INSTRB(anc_id_5,'(]',1,3) - 2)
4470 ,SUBSTRB(anc_id_5
4471        ,INSTRB(anc_id_5,'(]',1,4) + 2
4472        ,INSTRB(anc_id_5,'(]',1,5) -
4473         INSTRB(anc_id_5,'(]',1,4) - 2)
4474 ,SUBSTRB(anc_id_5
4475        ,INSTRB(anc_id_5,'(]',1,5) + 2
4476        ,INSTRB(anc_id_5,'(]',1,6) -
4477         INSTRB(anc_id_5,'(]',1,5) - 2)
4478 ,SUBSTRB(anc_id_5
4479        ,INSTRB(anc_id_5,'(]',1,6) + 2
4480        ,INSTRB(anc_id_5,'(]',1,7) -
4481         INSTRB(anc_id_5,'(]',1,6) - 2)
4482 ,SUBSTRB(anc_id_5
4483        ,INSTRB(anc_id_5,'(]',1,7) + 2
4484        ,LENGTHB(anc_id_5))
4485 )
4486 
4487 WHEN anc_id_6 IS NOT NULL THEN
4488   INTO xla_ae_line_acs (
4489         ae_header_id , ae_line_num , object_version_number
4490       , analytical_criterion_code
4491       , analytical_criterion_type_code
4492       , amb_context_code
4493       , ac1,ac2,ac3,ac4,ac5)
4494 VALUES (ae_header_id, ae_line_num, C_OVN
4495 ,SUBSTRB(anc_id_6
4496        ,1
4497        ,INSTRB(anc_id_6,'(]',1,1) -1)
4498 ,SUBSTRB(anc_id_6
4499        ,INSTRB(anc_id_6,'(]',1,1) + 2
4500        ,INSTRB(anc_id_6,'(]',1,2) -
4501         INSTRB(anc_id_6,'(]',1,1) - 2)
4502 ,SUBSTRB(anc_id_6
4503        ,INSTRB(anc_id_6,'(]',1,2) + 2
4504        ,INSTRB(anc_id_6,'(]',1,3) -
4505         INSTRB(anc_id_6,'(]',1,2) - 2)
4506 ,SUBSTRB(anc_id_6
4507        ,INSTRB(anc_id_6,'(]',1,3) + 2
4508        ,INSTRB(anc_id_6,'(]',1,4) -
4509         INSTRB(anc_id_6,'(]',1,3) - 2)
4510 ,SUBSTRB(anc_id_6
4511        ,INSTRB(anc_id_6,'(]',1,4) + 2
4512        ,INSTRB(anc_id_6,'(]',1,5) -
4513         INSTRB(anc_id_6,'(]',1,4) - 2)
4514 ,SUBSTRB(anc_id_6
4515        ,INSTRB(anc_id_6,'(]',1,5) + 2
4516        ,INSTRB(anc_id_6,'(]',1,6) -
4517         INSTRB(anc_id_6,'(]',1,5) - 2)
4518 ,SUBSTRB(anc_id_6
4519        ,INSTRB(anc_id_6,'(]',1,6) + 2
4520        ,INSTRB(anc_id_6,'(]',1,7) -
4521         INSTRB(anc_id_6,'(]',1,6) - 2)
4522 ,SUBSTRB(anc_id_6
4523        ,INSTRB(anc_id_6,'(]',1,7) + 2
4524        ,LENGTHB(anc_id_6))
4525 )
4526 
4527 WHEN anc_id_7 IS NOT NULL THEN
4528   INTO xla_ae_line_acs (
4529         ae_header_id , ae_line_num , object_version_number
4530       , analytical_criterion_code
4531       , analytical_criterion_type_code
4532       , amb_context_code
4533       , ac1,ac2,ac3,ac4,ac5)
4534 VALUES (ae_header_id, ae_line_num, C_OVN
4535 ,SUBSTRB(anc_id_7
4536        ,1
4537        ,INSTRB(anc_id_7,'(]',1,1) -1)
4538 ,SUBSTRB(anc_id_7
4539        ,INSTRB(anc_id_7,'(]',1,1) + 2
4540        ,INSTRB(anc_id_7,'(]',1,2) -
4541         INSTRB(anc_id_7,'(]',1,1) - 2)
4542 ,SUBSTRB(anc_id_7
4543        ,INSTRB(anc_id_7,'(]',1,2) + 2
4544        ,INSTRB(anc_id_7,'(]',1,3) -
4545         INSTRB(anc_id_7,'(]',1,2) - 2)
4546 ,SUBSTRB(anc_id_7
4547        ,INSTRB(anc_id_7,'(]',1,3) + 2
4548        ,INSTRB(anc_id_7,'(]',1,4) -
4549         INSTRB(anc_id_7,'(]',1,3) - 2)
4550 ,SUBSTRB(anc_id_7
4551        ,INSTRB(anc_id_7,'(]',1,4) + 2
4552        ,INSTRB(anc_id_7,'(]',1,5) -
4553         INSTRB(anc_id_7,'(]',1,4) - 2)
4554 ,SUBSTRB(anc_id_7
4555        ,INSTRB(anc_id_7,'(]',1,5) + 2
4556        ,INSTRB(anc_id_7,'(]',1,6) -
4557         INSTRB(anc_id_7,'(]',1,5) - 2)
4558 ,SUBSTRB(anc_id_7
4559        ,INSTRB(anc_id_7,'(]',1,6) + 2
4560        ,INSTRB(anc_id_7,'(]',1,7) -
4561         INSTRB(anc_id_7,'(]',1,6) - 2)
4562 ,SUBSTRB(anc_id_7
4563        ,INSTRB(anc_id_7,'(]',1,7) + 2
4564        ,LENGTHB(anc_id_7))
4565 )
4566 
4567 WHEN anc_id_8 IS NOT NULL THEN
4568   INTO xla_ae_line_acs (
4569         ae_header_id , ae_line_num , object_version_number
4570       , analytical_criterion_code
4571       , analytical_criterion_type_code
4572       , amb_context_code
4573       , ac1,ac2,ac3,ac4,ac5)
4574 VALUES (ae_header_id, ae_line_num, C_OVN
4575 ,SUBSTRB(anc_id_8
4576        ,1
4577        ,INSTRB(anc_id_8,'(]',1,1) -1)
4578 ,SUBSTRB(anc_id_8
4579        ,INSTRB(anc_id_8,'(]',1,1) + 2
4580        ,INSTRB(anc_id_8,'(]',1,2) -
4581         INSTRB(anc_id_8,'(]',1,1) - 2)
4582 ,SUBSTRB(anc_id_8
4583        ,INSTRB(anc_id_8,'(]',1,2) + 2
4584        ,INSTRB(anc_id_8,'(]',1,3) -
4585         INSTRB(anc_id_8,'(]',1,2) - 2)
4586 ,SUBSTRB(anc_id_8
4587        ,INSTRB(anc_id_8,'(]',1,3) + 2
4588        ,INSTRB(anc_id_8,'(]',1,4) -
4589         INSTRB(anc_id_8,'(]',1,3) - 2)
4590 ,SUBSTRB(anc_id_8
4591        ,INSTRB(anc_id_8,'(]',1,4) + 2
4592        ,INSTRB(anc_id_8,'(]',1,5) -
4593         INSTRB(anc_id_8,'(]',1,4) - 2)
4594 ,SUBSTRB(anc_id_8
4595        ,INSTRB(anc_id_8,'(]',1,5) + 2
4596        ,INSTRB(anc_id_8,'(]',1,6) -
4597         INSTRB(anc_id_8,'(]',1,5) - 2)
4598 ,SUBSTRB(anc_id_8
4599        ,INSTRB(anc_id_8,'(]',1,6) + 2
4600        ,INSTRB(anc_id_8,'(]',1,7) -
4601         INSTRB(anc_id_8,'(]',1,6) - 2)
4602 ,SUBSTRB(anc_id_8
4603        ,INSTRB(anc_id_8,'(]',1,7) + 2
4604        ,LENGTHB(anc_id_8))
4605 )
4606 
4607 WHEN anc_id_9 IS NOT NULL THEN
4608   INTO xla_ae_line_acs (
4609         ae_header_id , ae_line_num , object_version_number
4610       , analytical_criterion_code
4611       , analytical_criterion_type_code
4612       , amb_context_code
4613       , ac1,ac2,ac3,ac4,ac5)
4614 VALUES (ae_header_id, ae_line_num, C_OVN
4615 ,SUBSTRB(anc_id_9
4616        ,1
4617        ,INSTRB(anc_id_9,'(]',1,1) -1)
4618 ,SUBSTRB(anc_id_9
4619        ,INSTRB(anc_id_9,'(]',1,1) + 2
4620        ,INSTRB(anc_id_9,'(]',1,2) -
4621         INSTRB(anc_id_9,'(]',1,1) - 2)
4622 ,SUBSTRB(anc_id_9
4623        ,INSTRB(anc_id_9,'(]',1,2) + 2
4624        ,INSTRB(anc_id_9,'(]',1,3) -
4625         INSTRB(anc_id_9,'(]',1,2) - 2)
4626 ,SUBSTRB(anc_id_9
4627        ,INSTRB(anc_id_9,'(]',1,3) + 2
4628        ,INSTRB(anc_id_9,'(]',1,4) -
4629         INSTRB(anc_id_9,'(]',1,3) - 2)
4630 ,SUBSTRB(anc_id_9
4631        ,INSTRB(anc_id_9,'(]',1,4) + 2
4632        ,INSTRB(anc_id_9,'(]',1,5) -
4633         INSTRB(anc_id_9,'(]',1,4) - 2)
4634 ,SUBSTRB(anc_id_9
4635        ,INSTRB(anc_id_9,'(]',1,5) + 2
4636        ,INSTRB(anc_id_9,'(]',1,6) -
4637         INSTRB(anc_id_9,'(]',1,5) - 2)
4638 ,SUBSTRB(anc_id_9
4639        ,INSTRB(anc_id_9,'(]',1,6) + 2
4640        ,INSTRB(anc_id_9,'(]',1,7) -
4641         INSTRB(anc_id_9,'(]',1,6) - 2)
4642 ,SUBSTRB(anc_id_9
4643        ,INSTRB(anc_id_9,'(]',1,7) + 2
4644        ,LENGTHB(anc_id_9))
4645 )
4646 
4647 WHEN anc_id_10 IS NOT NULL THEN
4648   INTO xla_ae_line_acs (
4649         ae_header_id , ae_line_num , object_version_number
4650       , analytical_criterion_code
4651       , analytical_criterion_type_code
4652       , amb_context_code
4653       , ac1,ac2,ac3,ac4,ac5)
4654 VALUES (ae_header_id, ae_line_num, C_OVN
4655 ,SUBSTRB(anc_id_10
4656        ,1
4657        ,INSTRB(anc_id_10,'(]',1,1) -1)
4658 ,SUBSTRB(anc_id_10
4659        ,INSTRB(anc_id_10,'(]',1,1) + 2
4660        ,INSTRB(anc_id_10,'(]',1,2) -
4661         INSTRB(anc_id_10,'(]',1,1) - 2)
4662 ,SUBSTRB(anc_id_10
4663        ,INSTRB(anc_id_10,'(]',1,2) + 2
4664        ,INSTRB(anc_id_10,'(]',1,3) -
4665         INSTRB(anc_id_10,'(]',1,2) - 2)
4666 ,SUBSTRB(anc_id_10
4667        ,INSTRB(anc_id_10,'(]',1,3) + 2
4668        ,INSTRB(anc_id_10,'(]',1,4) -
4669         INSTRB(anc_id_10,'(]',1,3) - 2)
4670 ,SUBSTRB(anc_id_10
4671        ,INSTRB(anc_id_10,'(]',1,4) + 2
4672        ,INSTRB(anc_id_10,'(]',1,5) -
4673         INSTRB(anc_id_10,'(]',1,4) - 2)
4674 ,SUBSTRB(anc_id_10
4675        ,INSTRB(anc_id_10,'(]',1,5) + 2
4676        ,INSTRB(anc_id_10,'(]',1,6) -
4677         INSTRB(anc_id_10,'(]',1,5) - 2)
4678 ,SUBSTRB(anc_id_10
4679        ,INSTRB(anc_id_10,'(]',1,6) + 2
4680        ,INSTRB(anc_id_10,'(]',1,7) -
4681         INSTRB(anc_id_10,'(]',1,6) - 2)
4682 ,SUBSTRB(anc_id_10
4683        ,INSTRB(anc_id_10,'(]',1,7) + 2
4684        ,LENGTHB(anc_id_10))
4685 )
4686 
4687 WHEN anc_id_11 IS NOT NULL THEN
4688   INTO xla_ae_line_acs (
4689         ae_header_id , ae_line_num , object_version_number
4690       , analytical_criterion_code
4691       , analytical_criterion_type_code
4692       , amb_context_code
4693       , ac1,ac2,ac3,ac4,ac5)
4694 VALUES (ae_header_id, ae_line_num, C_OVN
4695 ,SUBSTRB(anc_id_11
4696        ,1
4697        ,INSTRB(anc_id_11,'(]',1,1) -1)
4698 ,SUBSTRB(anc_id_11
4699        ,INSTRB(anc_id_11,'(]',1,1) + 2
4700        ,INSTRB(anc_id_11,'(]',1,2) -
4701         INSTRB(anc_id_11,'(]',1,1) - 2)
4702 ,SUBSTRB(anc_id_11
4703        ,INSTRB(anc_id_11,'(]',1,2) + 2
4704        ,INSTRB(anc_id_11,'(]',1,3) -
4705         INSTRB(anc_id_11,'(]',1,2) - 2)
4706 ,SUBSTRB(anc_id_11
4707        ,INSTRB(anc_id_11,'(]',1,3) + 2
4708        ,INSTRB(anc_id_11,'(]',1,4) -
4709         INSTRB(anc_id_11,'(]',1,3) - 2)
4710 ,SUBSTRB(anc_id_11
4711        ,INSTRB(anc_id_11,'(]',1,4) + 2
4712        ,INSTRB(anc_id_11,'(]',1,5) -
4713         INSTRB(anc_id_11,'(]',1,4) - 2)
4714 ,SUBSTRB(anc_id_11
4715        ,INSTRB(anc_id_11,'(]',1,5) + 2
4716        ,INSTRB(anc_id_11,'(]',1,6) -
4717         INSTRB(anc_id_11,'(]',1,5) - 2)
4718 ,SUBSTRB(anc_id_11
4719        ,INSTRB(anc_id_11,'(]',1,6) + 2
4720        ,INSTRB(anc_id_11,'(]',1,7) -
4721         INSTRB(anc_id_11,'(]',1,6) - 2)
4722 ,SUBSTRB(anc_id_11
4723        ,INSTRB(anc_id_11,'(]',1,7) + 2
4724        ,LENGTHB(anc_id_11))
4725 )
4726 
4727 WHEN anc_id_12 IS NOT NULL THEN
4728   INTO xla_ae_line_acs (
4729         ae_header_id , ae_line_num , object_version_number
4730       , analytical_criterion_code
4731       , analytical_criterion_type_code
4732       , amb_context_code
4733       , ac1,ac2,ac3,ac4,ac5)
4734 VALUES (ae_header_id, ae_line_num, C_OVN
4735 ,SUBSTRB(anc_id_12
4736        ,1
4737        ,INSTRB(anc_id_12,'(]',1,1) -1)
4738 ,SUBSTRB(anc_id_12
4739        ,INSTRB(anc_id_12,'(]',1,1) + 2
4740        ,INSTRB(anc_id_12,'(]',1,2) -
4741         INSTRB(anc_id_12,'(]',1,1) - 2)
4742 ,SUBSTRB(anc_id_12
4743        ,INSTRB(anc_id_12,'(]',1,2) + 2
4744        ,INSTRB(anc_id_12,'(]',1,3) -
4745         INSTRB(anc_id_12,'(]',1,2) - 2)
4746 ,SUBSTRB(anc_id_12
4747        ,INSTRB(anc_id_12,'(]',1,3) + 2
4748        ,INSTRB(anc_id_12,'(]',1,4) -
4749         INSTRB(anc_id_12,'(]',1,3) - 2)
4750 ,SUBSTRB(anc_id_12
4751        ,INSTRB(anc_id_12,'(]',1,4) + 2
4752        ,INSTRB(anc_id_12,'(]',1,5) -
4753         INSTRB(anc_id_12,'(]',1,4) - 2)
4754 ,SUBSTRB(anc_id_12
4755        ,INSTRB(anc_id_12,'(]',1,5) + 2
4756        ,INSTRB(anc_id_12,'(]',1,6) -
4757         INSTRB(anc_id_12,'(]',1,5) - 2)
4758 ,SUBSTRB(anc_id_12
4759        ,INSTRB(anc_id_12,'(]',1,6) + 2
4760        ,INSTRB(anc_id_12,'(]',1,7) -
4761         INSTRB(anc_id_12,'(]',1,6) - 2)
4762 ,SUBSTRB(anc_id_12
4763        ,INSTRB(anc_id_12,'(]',1,7) + 2
4764        ,LENGTHB(anc_id_12))
4765 )
4766 
4767 WHEN anc_id_13 IS NOT NULL THEN
4768   INTO xla_ae_line_acs (
4769         ae_header_id , ae_line_num , object_version_number
4770       , analytical_criterion_code
4771       , analytical_criterion_type_code
4772       , amb_context_code
4773       , ac1,ac2,ac3,ac4,ac5)
4774 VALUES (ae_header_id, ae_line_num, C_OVN
4775 ,SUBSTRB(anc_id_13
4776        ,1
4777        ,INSTRB(anc_id_13,'(]',1,1) -1)
4778 ,SUBSTRB(anc_id_13
4779        ,INSTRB(anc_id_13,'(]',1,1) + 2
4780        ,INSTRB(anc_id_13,'(]',1,2) -
4781         INSTRB(anc_id_13,'(]',1,1) - 2)
4782 ,SUBSTRB(anc_id_13
4783        ,INSTRB(anc_id_13,'(]',1,2) + 2
4784        ,INSTRB(anc_id_13,'(]',1,3) -
4785         INSTRB(anc_id_13,'(]',1,2) - 2)
4786 ,SUBSTRB(anc_id_13
4787        ,INSTRB(anc_id_13,'(]',1,3) + 2
4788        ,INSTRB(anc_id_13,'(]',1,4) -
4789         INSTRB(anc_id_13,'(]',1,3) - 2)
4790 ,SUBSTRB(anc_id_13
4791        ,INSTRB(anc_id_13,'(]',1,4) + 2
4792        ,INSTRB(anc_id_13,'(]',1,5) -
4793         INSTRB(anc_id_13,'(]',1,4) - 2)
4794 ,SUBSTRB(anc_id_13
4795        ,INSTRB(anc_id_13,'(]',1,5) + 2
4796        ,INSTRB(anc_id_13,'(]',1,6) -
4797         INSTRB(anc_id_13,'(]',1,5) - 2)
4798 ,SUBSTRB(anc_id_13
4799        ,INSTRB(anc_id_13,'(]',1,6) + 2
4800        ,INSTRB(anc_id_13,'(]',1,7) -
4801         INSTRB(anc_id_13,'(]',1,6) - 2)
4802 ,SUBSTRB(anc_id_13
4803        ,INSTRB(anc_id_13,'(]',1,7) + 2
4804        ,LENGTHB(anc_id_13))
4805 )
4806 
4807 WHEN anc_id_14 IS NOT NULL THEN
4808   INTO xla_ae_line_acs (
4809         ae_header_id , ae_line_num , object_version_number
4810       , analytical_criterion_code
4811       , analytical_criterion_type_code
4812       , amb_context_code
4813       , ac1,ac2,ac3,ac4,ac5)
4814 VALUES (ae_header_id, ae_line_num, C_OVN
4815 ,SUBSTRB(anc_id_14
4816        ,1
4817        ,INSTRB(anc_id_14,'(]',1,1) -1)
4818 ,SUBSTRB(anc_id_14
4819        ,INSTRB(anc_id_14,'(]',1,1) + 2
4820        ,INSTRB(anc_id_14,'(]',1,2) -
4821         INSTRB(anc_id_14,'(]',1,1) - 2)
4822 ,SUBSTRB(anc_id_14
4823        ,INSTRB(anc_id_14,'(]',1,2) + 2
4824        ,INSTRB(anc_id_14,'(]',1,3) -
4825         INSTRB(anc_id_14,'(]',1,2) - 2)
4826 ,SUBSTRB(anc_id_14
4827        ,INSTRB(anc_id_14,'(]',1,3) + 2
4828        ,INSTRB(anc_id_14,'(]',1,4) -
4829         INSTRB(anc_id_14,'(]',1,3) - 2)
4830 ,SUBSTRB(anc_id_14
4831        ,INSTRB(anc_id_14,'(]',1,4) + 2
4832        ,INSTRB(anc_id_14,'(]',1,5) -
4833         INSTRB(anc_id_14,'(]',1,4) - 2)
4834 ,SUBSTRB(anc_id_14
4835        ,INSTRB(anc_id_14,'(]',1,5) + 2
4836        ,INSTRB(anc_id_14,'(]',1,6) -
4837         INSTRB(anc_id_14,'(]',1,5) - 2)
4838 ,SUBSTRB(anc_id_14
4839        ,INSTRB(anc_id_14,'(]',1,6) + 2
4840        ,INSTRB(anc_id_14,'(]',1,7) -
4841         INSTRB(anc_id_14,'(]',1,6) - 2)
4842 ,SUBSTRB(anc_id_14
4843        ,INSTRB(anc_id_14,'(]',1,7) + 2
4844        ,LENGTHB(anc_id_14))
4845 )
4846 
4847 WHEN anc_id_15 IS NOT NULL THEN
4848   INTO xla_ae_line_acs (
4849         ae_header_id , ae_line_num , object_version_number
4850       , analytical_criterion_code
4851       , analytical_criterion_type_code
4852       , amb_context_code
4853       , ac1,ac2,ac3,ac4,ac5)
4854 VALUES (ae_header_id, ae_line_num, C_OVN
4855 ,SUBSTRB(anc_id_15
4856        ,1
4857        ,INSTRB(anc_id_15,'(]',1,1) -1)
4858 ,SUBSTRB(anc_id_15
4859        ,INSTRB(anc_id_15,'(]',1,1) + 2
4860        ,INSTRB(anc_id_15,'(]',1,2) -
4861         INSTRB(anc_id_15,'(]',1,1) - 2)
4862 ,SUBSTRB(anc_id_15
4863        ,INSTRB(anc_id_15,'(]',1,2) + 2
4864        ,INSTRB(anc_id_15,'(]',1,3) -
4865         INSTRB(anc_id_15,'(]',1,2) - 2)
4866 ,SUBSTRB(anc_id_15
4867        ,INSTRB(anc_id_15,'(]',1,3) + 2
4868        ,INSTRB(anc_id_15,'(]',1,4) -
4869         INSTRB(anc_id_15,'(]',1,3) - 2)
4870 ,SUBSTRB(anc_id_15
4871        ,INSTRB(anc_id_15,'(]',1,4) + 2
4872        ,INSTRB(anc_id_15,'(]',1,5) -
4873         INSTRB(anc_id_15,'(]',1,4) - 2)
4874 ,SUBSTRB(anc_id_15
4875        ,INSTRB(anc_id_15,'(]',1,5) + 2
4876        ,INSTRB(anc_id_15,'(]',1,6) -
4877         INSTRB(anc_id_15,'(]',1,5) - 2)
4878 ,SUBSTRB(anc_id_15
4879        ,INSTRB(anc_id_15,'(]',1,6) + 2
4880        ,INSTRB(anc_id_15,'(]',1,7) -
4881         INSTRB(anc_id_15,'(]',1,6) - 2)
4882 ,SUBSTRB(anc_id_15
4883        ,INSTRB(anc_id_15,'(]',1,7) + 2
4884        ,LENGTHB(anc_id_15))
4885 )
4886 
4887 WHEN anc_id_16 IS NOT NULL THEN
4888   INTO xla_ae_line_acs (
4889         ae_header_id , ae_line_num , object_version_number
4890       , analytical_criterion_code
4891       , analytical_criterion_type_code
4892       , amb_context_code
4893       , ac1,ac2,ac3,ac4,ac5)
4894 VALUES (ae_header_id, ae_line_num, C_OVN
4895 ,SUBSTRB(anc_id_16
4896        ,1
4897        ,INSTRB(anc_id_16,'(]',1,1) -1)
4898 ,SUBSTRB(anc_id_16
4899        ,INSTRB(anc_id_16,'(]',1,1) + 2
4900        ,INSTRB(anc_id_16,'(]',1,2) -
4901         INSTRB(anc_id_16,'(]',1,1) - 2)
4902 ,SUBSTRB(anc_id_16
4903        ,INSTRB(anc_id_16,'(]',1,2) + 2
4904        ,INSTRB(anc_id_16,'(]',1,3) -
4905         INSTRB(anc_id_16,'(]',1,2) - 2)
4906 ,SUBSTRB(anc_id_16
4907        ,INSTRB(anc_id_16,'(]',1,3) + 2
4908        ,INSTRB(anc_id_16,'(]',1,4) -
4909         INSTRB(anc_id_16,'(]',1,3) - 2)
4910 ,SUBSTRB(anc_id_16
4911        ,INSTRB(anc_id_16,'(]',1,4) + 2
4912        ,INSTRB(anc_id_16,'(]',1,5) -
4913         INSTRB(anc_id_16,'(]',1,4) - 2)
4914 ,SUBSTRB(anc_id_16
4915        ,INSTRB(anc_id_16,'(]',1,5) + 2
4916        ,INSTRB(anc_id_16,'(]',1,6) -
4917         INSTRB(anc_id_16,'(]',1,5) - 2)
4918 ,SUBSTRB(anc_id_16
4919        ,INSTRB(anc_id_16,'(]',1,6) + 2
4920        ,INSTRB(anc_id_16,'(]',1,7) -
4921         INSTRB(anc_id_16,'(]',1,6) - 2)
4922 ,SUBSTRB(anc_id_16
4923        ,INSTRB(anc_id_16,'(]',1,7) + 2
4924        ,LENGTHB(anc_id_16))
4925 )
4926 
4927 WHEN anc_id_17 IS NOT NULL THEN
4928   INTO xla_ae_line_acs (
4929         ae_header_id , ae_line_num , object_version_number
4930       , analytical_criterion_code
4931       , analytical_criterion_type_code
4932       , amb_context_code
4933       , ac1,ac2,ac3,ac4,ac5)
4934 VALUES (ae_header_id, ae_line_num, C_OVN
4935 ,SUBSTRB(anc_id_17
4936        ,1
4937        ,INSTRB(anc_id_17,'(]',1,1) -1)
4938 ,SUBSTRB(anc_id_17
4939        ,INSTRB(anc_id_17,'(]',1,1) + 2
4940        ,INSTRB(anc_id_17,'(]',1,2) -
4941         INSTRB(anc_id_17,'(]',1,1) - 2)
4942 ,SUBSTRB(anc_id_17
4943        ,INSTRB(anc_id_17,'(]',1,2) + 2
4944        ,INSTRB(anc_id_17,'(]',1,3) -
4945         INSTRB(anc_id_17,'(]',1,2) - 2)
4946 ,SUBSTRB(anc_id_17
4947        ,INSTRB(anc_id_17,'(]',1,3) + 2
4948        ,INSTRB(anc_id_17,'(]',1,4) -
4949         INSTRB(anc_id_17,'(]',1,3) - 2)
4950 ,SUBSTRB(anc_id_17
4951        ,INSTRB(anc_id_17,'(]',1,4) + 2
4952        ,INSTRB(anc_id_17,'(]',1,5) -
4953         INSTRB(anc_id_17,'(]',1,4) - 2)
4954 ,SUBSTRB(anc_id_17
4955        ,INSTRB(anc_id_17,'(]',1,5) + 2
4956        ,INSTRB(anc_id_17,'(]',1,6) -
4957         INSTRB(anc_id_17,'(]',1,5) - 2)
4958 ,SUBSTRB(anc_id_17
4959        ,INSTRB(anc_id_17,'(]',1,6) + 2
4960        ,INSTRB(anc_id_17,'(]',1,7) -
4961         INSTRB(anc_id_17,'(]',1,6) - 2)
4962 ,SUBSTRB(anc_id_17
4963        ,INSTRB(anc_id_17,'(]',1,7) + 2
4964        ,LENGTHB(anc_id_17))
4965 )
4966 
4967 WHEN anc_id_18 IS NOT NULL THEN
4968   INTO xla_ae_line_acs (
4969         ae_header_id , ae_line_num , object_version_number
4970       , analytical_criterion_code
4971       , analytical_criterion_type_code
4972       , amb_context_code
4973       , ac1,ac2,ac3,ac4,ac5)
4974 VALUES (ae_header_id, ae_line_num, C_OVN
4975 ,SUBSTRB(anc_id_18
4976        ,1
4977        ,INSTRB(anc_id_18,'(]',1,1) -1)
4978 ,SUBSTRB(anc_id_18
4979        ,INSTRB(anc_id_18,'(]',1,1) + 2
4980        ,INSTRB(anc_id_18,'(]',1,2) -
4981         INSTRB(anc_id_18,'(]',1,1) - 2)
4982 ,SUBSTRB(anc_id_18
4983        ,INSTRB(anc_id_18,'(]',1,2) + 2
4984        ,INSTRB(anc_id_18,'(]',1,3) -
4985         INSTRB(anc_id_18,'(]',1,2) - 2)
4986 ,SUBSTRB(anc_id_18
4987        ,INSTRB(anc_id_18,'(]',1,3) + 2
4988        ,INSTRB(anc_id_18,'(]',1,4) -
4989         INSTRB(anc_id_18,'(]',1,3) - 2)
4990 ,SUBSTRB(anc_id_18
4991        ,INSTRB(anc_id_18,'(]',1,4) + 2
4992        ,INSTRB(anc_id_18,'(]',1,5) -
4993         INSTRB(anc_id_18,'(]',1,4) - 2)
4994 ,SUBSTRB(anc_id_18
4995        ,INSTRB(anc_id_18,'(]',1,5) + 2
4996        ,INSTRB(anc_id_18,'(]',1,6) -
4997         INSTRB(anc_id_18,'(]',1,5) - 2)
4998 ,SUBSTRB(anc_id_18
4999        ,INSTRB(anc_id_18,'(]',1,6) + 2
5000        ,INSTRB(anc_id_18,'(]',1,7) -
5001         INSTRB(anc_id_18,'(]',1,6) - 2)
5002 ,SUBSTRB(anc_id_18
5003        ,INSTRB(anc_id_18,'(]',1,7) + 2
5004        ,LENGTHB(anc_id_18))
5005 )
5006 
5007 WHEN anc_id_19 IS NOT NULL THEN
5008   INTO xla_ae_line_acs (
5009         ae_header_id , ae_line_num , object_version_number
5010       , analytical_criterion_code
5011       , analytical_criterion_type_code
5012       , amb_context_code
5013       , ac1,ac2,ac3,ac4,ac5)
5014 VALUES (ae_header_id, ae_line_num, C_OVN
5015 ,SUBSTRB(anc_id_19
5016        ,1
5017        ,INSTRB(anc_id_19,'(]',1,1) -1)
5018 ,SUBSTRB(anc_id_19
5019        ,INSTRB(anc_id_19,'(]',1,1) + 2
5020        ,INSTRB(anc_id_19,'(]',1,2) -
5021         INSTRB(anc_id_19,'(]',1,1) - 2)
5022 ,SUBSTRB(anc_id_19
5023        ,INSTRB(anc_id_19,'(]',1,2) + 2
5024        ,INSTRB(anc_id_19,'(]',1,3) -
5025         INSTRB(anc_id_19,'(]',1,2) - 2)
5026 ,SUBSTRB(anc_id_19
5027        ,INSTRB(anc_id_19,'(]',1,3) + 2
5028        ,INSTRB(anc_id_19,'(]',1,4) -
5029         INSTRB(anc_id_19,'(]',1,3) - 2)
5030 ,SUBSTRB(anc_id_19
5031        ,INSTRB(anc_id_19,'(]',1,4) + 2
5032        ,INSTRB(anc_id_19,'(]',1,5) -
5033         INSTRB(anc_id_19,'(]',1,4) - 2)
5034 ,SUBSTRB(anc_id_19
5035        ,INSTRB(anc_id_19,'(]',1,5) + 2
5036        ,INSTRB(anc_id_19,'(]',1,6) -
5037         INSTRB(anc_id_19,'(]',1,5) - 2)
5038 ,SUBSTRB(anc_id_19
5039        ,INSTRB(anc_id_19,'(]',1,6) + 2
5040        ,INSTRB(anc_id_19,'(]',1,7) -
5041         INSTRB(anc_id_19,'(]',1,6) - 2)
5042 ,SUBSTRB(anc_id_19
5043        ,INSTRB(anc_id_19,'(]',1,7) + 2
5044        ,LENGTHB(anc_id_19))
5045 )
5046 
5047 WHEN anc_id_20 IS NOT NULL THEN
5048   INTO xla_ae_line_acs (
5049         ae_header_id , ae_line_num , object_version_number
5050       , analytical_criterion_code
5051       , analytical_criterion_type_code
5052       , amb_context_code
5053       , ac1,ac2,ac3,ac4,ac5)
5054 VALUES (ae_header_id, ae_line_num, C_OVN
5055 ,SUBSTRB(anc_id_20
5056        ,1
5057        ,INSTRB(anc_id_20,'(]',1,1) -1)
5058 ,SUBSTRB(anc_id_20
5059        ,INSTRB(anc_id_20,'(]',1,1) + 2
5060        ,INSTRB(anc_id_20,'(]',1,2) -
5061         INSTRB(anc_id_20,'(]',1,1) - 2)
5062 ,SUBSTRB(anc_id_20
5063        ,INSTRB(anc_id_20,'(]',1,2) + 2
5064        ,INSTRB(anc_id_20,'(]',1,3) -
5065         INSTRB(anc_id_20,'(]',1,2) - 2)
5066 ,SUBSTRB(anc_id_20
5067        ,INSTRB(anc_id_20,'(]',1,3) + 2
5068        ,INSTRB(anc_id_20,'(]',1,4) -
5069         INSTRB(anc_id_20,'(]',1,3) - 2)
5070 ,SUBSTRB(anc_id_20
5071        ,INSTRB(anc_id_20,'(]',1,4) + 2
5072        ,INSTRB(anc_id_20,'(]',1,5) -
5073         INSTRB(anc_id_20,'(]',1,4) - 2)
5074 ,SUBSTRB(anc_id_20
5075        ,INSTRB(anc_id_20,'(]',1,5) + 2
5076        ,INSTRB(anc_id_20,'(]',1,6) -
5077         INSTRB(anc_id_20,'(]',1,5) - 2)
5078 ,SUBSTRB(anc_id_20
5079        ,INSTRB(anc_id_20,'(]',1,6) + 2
5080        ,INSTRB(anc_id_20,'(]',1,7) -
5081         INSTRB(anc_id_20,'(]',1,6) - 2)
5082 ,SUBSTRB(anc_id_20
5083        ,INSTRB(anc_id_20,'(]',1,7) + 2
5084        ,LENGTHB(anc_id_20))
5085 )
5086 
5087 WHEN anc_id_21 IS NOT NULL THEN
5088   INTO xla_ae_line_acs (
5089         ae_header_id , ae_line_num , object_version_number
5090       , analytical_criterion_code
5091       , analytical_criterion_type_code
5092       , amb_context_code
5093       , ac1,ac2,ac3,ac4,ac5)
5094 VALUES (ae_header_id, ae_line_num, C_OVN
5095 ,SUBSTRB(anc_id_21
5096        ,1
5097        ,INSTRB(anc_id_21,'(]',1,1) -1)
5098 ,SUBSTRB(anc_id_21
5099        ,INSTRB(anc_id_21,'(]',1,1) + 2
5100        ,INSTRB(anc_id_21,'(]',1,2) -
5101         INSTRB(anc_id_21,'(]',1,1) - 2)
5102 ,SUBSTRB(anc_id_21
5103        ,INSTRB(anc_id_21,'(]',1,2) + 2
5104        ,INSTRB(anc_id_21,'(]',1,3) -
5105         INSTRB(anc_id_21,'(]',1,2) - 2)
5106 ,SUBSTRB(anc_id_21
5107        ,INSTRB(anc_id_21,'(]',1,3) + 2
5108        ,INSTRB(anc_id_21,'(]',1,4) -
5109         INSTRB(anc_id_21,'(]',1,3) - 2)
5110 ,SUBSTRB(anc_id_21
5111        ,INSTRB(anc_id_21,'(]',1,4) + 2
5112        ,INSTRB(anc_id_21,'(]',1,5) -
5113         INSTRB(anc_id_21,'(]',1,4) - 2)
5114 ,SUBSTRB(anc_id_21
5115        ,INSTRB(anc_id_21,'(]',1,5) + 2
5116        ,INSTRB(anc_id_21,'(]',1,6) -
5117         INSTRB(anc_id_21,'(]',1,5) - 2)
5118 ,SUBSTRB(anc_id_21
5119        ,INSTRB(anc_id_21,'(]',1,6) + 2
5120        ,INSTRB(anc_id_21,'(]',1,7) -
5121         INSTRB(anc_id_21,'(]',1,6) - 2)
5122 ,SUBSTRB(anc_id_21
5123        ,INSTRB(anc_id_21,'(]',1,7) + 2
5124        ,LENGTHB(anc_id_21))
5125 )
5126 
5127 WHEN anc_id_22 IS NOT NULL THEN
5128   INTO xla_ae_line_acs (
5129         ae_header_id , ae_line_num , object_version_number
5130       , analytical_criterion_code
5131       , analytical_criterion_type_code
5132       , amb_context_code
5133       , ac1,ac2,ac3,ac4,ac5)
5134 VALUES (ae_header_id, ae_line_num, C_OVN
5135 ,SUBSTRB(anc_id_22
5136        ,1
5137        ,INSTRB(anc_id_22,'(]',1,1) -1)
5138 ,SUBSTRB(anc_id_22
5139        ,INSTRB(anc_id_22,'(]',1,1) + 2
5140        ,INSTRB(anc_id_22,'(]',1,2) -
5141         INSTRB(anc_id_22,'(]',1,1) - 2)
5142 ,SUBSTRB(anc_id_22
5143        ,INSTRB(anc_id_22,'(]',1,2) + 2
5144        ,INSTRB(anc_id_22,'(]',1,3) -
5145         INSTRB(anc_id_22,'(]',1,2) - 2)
5146 ,SUBSTRB(anc_id_22
5147        ,INSTRB(anc_id_22,'(]',1,3) + 2
5148        ,INSTRB(anc_id_22,'(]',1,4) -
5149         INSTRB(anc_id_22,'(]',1,3) - 2)
5150 ,SUBSTRB(anc_id_22
5151        ,INSTRB(anc_id_22,'(]',1,4) + 2
5152        ,INSTRB(anc_id_22,'(]',1,5) -
5153         INSTRB(anc_id_22,'(]',1,4) - 2)
5154 ,SUBSTRB(anc_id_22
5155        ,INSTRB(anc_id_22,'(]',1,5) + 2
5156        ,INSTRB(anc_id_22,'(]',1,6) -
5157         INSTRB(anc_id_22,'(]',1,5) - 2)
5158 ,SUBSTRB(anc_id_22
5159        ,INSTRB(anc_id_22,'(]',1,6) + 2
5160        ,INSTRB(anc_id_22,'(]',1,7) -
5161         INSTRB(anc_id_22,'(]',1,6) - 2)
5162 ,SUBSTRB(anc_id_22
5163        ,INSTRB(anc_id_22,'(]',1,7) + 2
5164        ,LENGTHB(anc_id_22))
5165 )
5166 
5167 WHEN anc_id_23 IS NOT NULL THEN
5168   INTO xla_ae_line_acs (
5169         ae_header_id , ae_line_num , object_version_number
5170       , analytical_criterion_code
5171       , analytical_criterion_type_code
5172       , amb_context_code
5173       , ac1,ac2,ac3,ac4,ac5)
5174 VALUES (ae_header_id, ae_line_num, C_OVN
5175 ,SUBSTRB(anc_id_23
5176        ,1
5177        ,INSTRB(anc_id_23,'(]',1,1) -1)
5178 ,SUBSTRB(anc_id_23
5179        ,INSTRB(anc_id_23,'(]',1,1) + 2
5180        ,INSTRB(anc_id_23,'(]',1,2) -
5181         INSTRB(anc_id_23,'(]',1,1) - 2)
5182 ,SUBSTRB(anc_id_23
5183        ,INSTRB(anc_id_23,'(]',1,2) + 2
5184        ,INSTRB(anc_id_23,'(]',1,3) -
5185         INSTRB(anc_id_23,'(]',1,2) - 2)
5186 ,SUBSTRB(anc_id_23
5187        ,INSTRB(anc_id_23,'(]',1,3) + 2
5188        ,INSTRB(anc_id_23,'(]',1,4) -
5189         INSTRB(anc_id_23,'(]',1,3) - 2)
5190 ,SUBSTRB(anc_id_23
5191        ,INSTRB(anc_id_23,'(]',1,4) + 2
5192        ,INSTRB(anc_id_23,'(]',1,5) -
5193         INSTRB(anc_id_23,'(]',1,4) - 2)
5194 ,SUBSTRB(anc_id_23
5195        ,INSTRB(anc_id_23,'(]',1,5) + 2
5196        ,INSTRB(anc_id_23,'(]',1,6) -
5197         INSTRB(anc_id_23,'(]',1,5) - 2)
5198 ,SUBSTRB(anc_id_23
5199        ,INSTRB(anc_id_23,'(]',1,6) + 2
5200        ,INSTRB(anc_id_23,'(]',1,7) -
5201         INSTRB(anc_id_23,'(]',1,6) - 2)
5202 ,SUBSTRB(anc_id_23
5203        ,INSTRB(anc_id_23,'(]',1,7) + 2
5204        ,LENGTHB(anc_id_23))
5205 )
5206 
5207 WHEN anc_id_24 IS NOT NULL THEN
5208   INTO xla_ae_line_acs (
5209         ae_header_id , ae_line_num , object_version_number
5210       , analytical_criterion_code
5211       , analytical_criterion_type_code
5212       , amb_context_code
5213       , ac1,ac2,ac3,ac4,ac5)
5214 VALUES (ae_header_id, ae_line_num, C_OVN
5215 ,SUBSTRB(anc_id_24
5216        ,1
5217        ,INSTRB(anc_id_24,'(]',1,1) -1)
5218 ,SUBSTRB(anc_id_24
5219        ,INSTRB(anc_id_24,'(]',1,1) + 2
5220        ,INSTRB(anc_id_24,'(]',1,2) -
5221         INSTRB(anc_id_24,'(]',1,1) - 2)
5222 ,SUBSTRB(anc_id_24
5223        ,INSTRB(anc_id_24,'(]',1,2) + 2
5224        ,INSTRB(anc_id_24,'(]',1,3) -
5225         INSTRB(anc_id_24,'(]',1,2) - 2)
5226 ,SUBSTRB(anc_id_24
5227        ,INSTRB(anc_id_24,'(]',1,3) + 2
5228        ,INSTRB(anc_id_24,'(]',1,4) -
5229         INSTRB(anc_id_24,'(]',1,3) - 2)
5230 ,SUBSTRB(anc_id_24
5231        ,INSTRB(anc_id_24,'(]',1,4) + 2
5232        ,INSTRB(anc_id_24,'(]',1,5) -
5233         INSTRB(anc_id_24,'(]',1,4) - 2)
5234 ,SUBSTRB(anc_id_24
5235        ,INSTRB(anc_id_24,'(]',1,5) + 2
5236        ,INSTRB(anc_id_24,'(]',1,6) -
5237         INSTRB(anc_id_24,'(]',1,5) - 2)
5238 ,SUBSTRB(anc_id_24
5239        ,INSTRB(anc_id_24,'(]',1,6) + 2
5240        ,INSTRB(anc_id_24,'(]',1,7) -
5241         INSTRB(anc_id_24,'(]',1,6) - 2)
5242 ,SUBSTRB(anc_id_24
5243        ,INSTRB(anc_id_24,'(]',1,7) + 2
5244        ,LENGTHB(anc_id_24))
5245 )
5246 
5247 WHEN anc_id_25 IS NOT NULL THEN
5248   INTO xla_ae_line_acs (
5249         ae_header_id , ae_line_num , object_version_number
5250       , analytical_criterion_code
5251       , analytical_criterion_type_code
5252       , amb_context_code
5253       , ac1,ac2,ac3,ac4,ac5)
5254 VALUES (ae_header_id, ae_line_num, C_OVN
5255 ,SUBSTRB(anc_id_25
5256        ,1
5257        ,INSTRB(anc_id_25,'(]',1,1) -1)
5258 ,SUBSTRB(anc_id_25
5259        ,INSTRB(anc_id_25,'(]',1,1) + 2
5260        ,INSTRB(anc_id_25,'(]',1,2) -
5261         INSTRB(anc_id_25,'(]',1,1) - 2)
5262 ,SUBSTRB(anc_id_25
5263        ,INSTRB(anc_id_25,'(]',1,2) + 2
5264        ,INSTRB(anc_id_25,'(]',1,3) -
5265         INSTRB(anc_id_25,'(]',1,2) - 2)
5266 ,SUBSTRB(anc_id_25
5267        ,INSTRB(anc_id_25,'(]',1,3) + 2
5268        ,INSTRB(anc_id_25,'(]',1,4) -
5269         INSTRB(anc_id_25,'(]',1,3) - 2)
5270 ,SUBSTRB(anc_id_25
5271        ,INSTRB(anc_id_25,'(]',1,4) + 2
5272        ,INSTRB(anc_id_25,'(]',1,5) -
5273         INSTRB(anc_id_25,'(]',1,4) - 2)
5274 ,SUBSTRB(anc_id_25
5275        ,INSTRB(anc_id_25,'(]',1,5) + 2
5276        ,INSTRB(anc_id_25,'(]',1,6) -
5277         INSTRB(anc_id_25,'(]',1,5) - 2)
5278 ,SUBSTRB(anc_id_25
5279        ,INSTRB(anc_id_25,'(]',1,6) + 2
5280        ,INSTRB(anc_id_25,'(]',1,7) -
5281         INSTRB(anc_id_25,'(]',1,6) - 2)
5282 ,SUBSTRB(anc_id_25
5283        ,INSTRB(anc_id_25,'(]',1,7) + 2
5284        ,LENGTHB(anc_id_25))
5285 )
5286 
5287 WHEN anc_id_26 IS NOT NULL THEN
5288   INTO xla_ae_line_acs (
5289         ae_header_id , ae_line_num , object_version_number
5290       , analytical_criterion_code
5291       , analytical_criterion_type_code
5292       , amb_context_code
5293       , ac1,ac2,ac3,ac4,ac5)
5294 VALUES (ae_header_id, ae_line_num, C_OVN
5295 ,SUBSTRB(anc_id_26
5296        ,1
5297        ,INSTRB(anc_id_26,'(]',1,1) -1)
5298 ,SUBSTRB(anc_id_26
5299        ,INSTRB(anc_id_26,'(]',1,1) + 2
5300        ,INSTRB(anc_id_26,'(]',1,2) -
5301         INSTRB(anc_id_26,'(]',1,1) - 2)
5302 ,SUBSTRB(anc_id_26
5303        ,INSTRB(anc_id_26,'(]',1,2) + 2
5304        ,INSTRB(anc_id_26,'(]',1,3) -
5305         INSTRB(anc_id_26,'(]',1,2) - 2)
5306 ,SUBSTRB(anc_id_26
5307        ,INSTRB(anc_id_26,'(]',1,3) + 2
5308        ,INSTRB(anc_id_26,'(]',1,4) -
5309         INSTRB(anc_id_26,'(]',1,3) - 2)
5310 ,SUBSTRB(anc_id_26
5311        ,INSTRB(anc_id_26,'(]',1,4) + 2
5312        ,INSTRB(anc_id_26,'(]',1,5) -
5313         INSTRB(anc_id_26,'(]',1,4) - 2)
5314 ,SUBSTRB(anc_id_26
5315        ,INSTRB(anc_id_26,'(]',1,5) + 2
5316        ,INSTRB(anc_id_26,'(]',1,6) -
5317         INSTRB(anc_id_26,'(]',1,5) - 2)
5318 ,SUBSTRB(anc_id_26
5319        ,INSTRB(anc_id_26,'(]',1,6) + 2
5320        ,INSTRB(anc_id_26,'(]',1,7) -
5321         INSTRB(anc_id_26,'(]',1,6) - 2)
5322 ,SUBSTRB(anc_id_26
5323        ,INSTRB(anc_id_26,'(]',1,7) + 2
5324        ,LENGTHB(anc_id_26))
5325 )
5326 
5327 WHEN anc_id_27 IS NOT NULL THEN
5328   INTO xla_ae_line_acs (
5329         ae_header_id , ae_line_num , object_version_number
5330       , analytical_criterion_code
5331       , analytical_criterion_type_code
5332       , amb_context_code
5333       , ac1,ac2,ac3,ac4,ac5)
5334 VALUES (ae_header_id, ae_line_num, C_OVN
5335 ,SUBSTRB(anc_id_27
5336        ,1
5337        ,INSTRB(anc_id_27,'(]',1,1) -1)
5338 ,SUBSTRB(anc_id_27
5339        ,INSTRB(anc_id_27,'(]',1,1) + 2
5340        ,INSTRB(anc_id_27,'(]',1,2) -
5341         INSTRB(anc_id_27,'(]',1,1) - 2)
5342 ,SUBSTRB(anc_id_27
5343        ,INSTRB(anc_id_27,'(]',1,2) + 2
5344        ,INSTRB(anc_id_27,'(]',1,3) -
5345         INSTRB(anc_id_27,'(]',1,2) - 2)
5346 ,SUBSTRB(anc_id_27
5347        ,INSTRB(anc_id_27,'(]',1,3) + 2
5348        ,INSTRB(anc_id_27,'(]',1,4) -
5349         INSTRB(anc_id_27,'(]',1,3) - 2)
5350 ,SUBSTRB(anc_id_27
5351        ,INSTRB(anc_id_27,'(]',1,4) + 2
5352        ,INSTRB(anc_id_27,'(]',1,5) -
5353         INSTRB(anc_id_27,'(]',1,4) - 2)
5354 ,SUBSTRB(anc_id_27
5355        ,INSTRB(anc_id_27,'(]',1,5) + 2
5356        ,INSTRB(anc_id_27,'(]',1,6) -
5357         INSTRB(anc_id_27,'(]',1,5) - 2)
5358 ,SUBSTRB(anc_id_27
5359        ,INSTRB(anc_id_27,'(]',1,6) + 2
5360        ,INSTRB(anc_id_27,'(]',1,7) -
5361         INSTRB(anc_id_27,'(]',1,6) - 2)
5362 ,SUBSTRB(anc_id_27
5363        ,INSTRB(anc_id_27,'(]',1,7) + 2
5364        ,LENGTHB(anc_id_27))
5365 )
5366 
5367 WHEN anc_id_28 IS NOT NULL THEN
5368   INTO xla_ae_line_acs (
5369         ae_header_id , ae_line_num , object_version_number
5370       , analytical_criterion_code
5371       , analytical_criterion_type_code
5372       , amb_context_code
5373       , ac1,ac2,ac3,ac4,ac5)
5374 VALUES (ae_header_id, ae_line_num, C_OVN
5375 ,SUBSTRB(anc_id_28
5376        ,1
5377        ,INSTRB(anc_id_28,'(]',1,1) -1)
5378 ,SUBSTRB(anc_id_28
5379        ,INSTRB(anc_id_28,'(]',1,1) + 2
5380        ,INSTRB(anc_id_28,'(]',1,2) -
5381         INSTRB(anc_id_28,'(]',1,1) - 2)
5382 ,SUBSTRB(anc_id_28
5383        ,INSTRB(anc_id_28,'(]',1,2) + 2
5384        ,INSTRB(anc_id_28,'(]',1,3) -
5385         INSTRB(anc_id_28,'(]',1,2) - 2)
5386 ,SUBSTRB(anc_id_28
5387        ,INSTRB(anc_id_28,'(]',1,3) + 2
5388        ,INSTRB(anc_id_28,'(]',1,4) -
5389         INSTRB(anc_id_28,'(]',1,3) - 2)
5390 ,SUBSTRB(anc_id_28
5391        ,INSTRB(anc_id_28,'(]',1,4) + 2
5392        ,INSTRB(anc_id_28,'(]',1,5) -
5393         INSTRB(anc_id_28,'(]',1,4) - 2)
5394 ,SUBSTRB(anc_id_28
5395        ,INSTRB(anc_id_28,'(]',1,5) + 2
5396        ,INSTRB(anc_id_28,'(]',1,6) -
5397         INSTRB(anc_id_28,'(]',1,5) - 2)
5398 ,SUBSTRB(anc_id_28
5399        ,INSTRB(anc_id_28,'(]',1,6) + 2
5400        ,INSTRB(anc_id_28,'(]',1,7) -
5401         INSTRB(anc_id_28,'(]',1,6) - 2)
5402 ,SUBSTRB(anc_id_28
5403        ,INSTRB(anc_id_28,'(]',1,7) + 2
5404        ,LENGTHB(anc_id_28))
5405 )
5406 
5407 WHEN anc_id_29 IS NOT NULL THEN
5408   INTO xla_ae_line_acs (
5409         ae_header_id , ae_line_num , object_version_number
5410       , analytical_criterion_code
5411       , analytical_criterion_type_code
5412       , amb_context_code
5413       , ac1,ac2,ac3,ac4,ac5)
5414 VALUES (ae_header_id, ae_line_num, C_OVN
5415 ,SUBSTRB(anc_id_29
5416        ,1
5417        ,INSTRB(anc_id_29,'(]',1,1) -1)
5418 ,SUBSTRB(anc_id_29
5419        ,INSTRB(anc_id_29,'(]',1,1) + 2
5420        ,INSTRB(anc_id_29,'(]',1,2) -
5421         INSTRB(anc_id_29,'(]',1,1) - 2)
5422 ,SUBSTRB(anc_id_29
5423        ,INSTRB(anc_id_29,'(]',1,2) + 2
5424        ,INSTRB(anc_id_29,'(]',1,3) -
5425         INSTRB(anc_id_29,'(]',1,2) - 2)
5426 ,SUBSTRB(anc_id_29
5427        ,INSTRB(anc_id_29,'(]',1,3) + 2
5428        ,INSTRB(anc_id_29,'(]',1,4) -
5429         INSTRB(anc_id_29,'(]',1,3) - 2)
5430 ,SUBSTRB(anc_id_29
5431        ,INSTRB(anc_id_29,'(]',1,4) + 2
5432        ,INSTRB(anc_id_29,'(]',1,5) -
5433         INSTRB(anc_id_29,'(]',1,4) - 2)
5434 ,SUBSTRB(anc_id_29
5435        ,INSTRB(anc_id_29,'(]',1,5) + 2
5436        ,INSTRB(anc_id_29,'(]',1,6) -
5437         INSTRB(anc_id_29,'(]',1,5) - 2)
5438 ,SUBSTRB(anc_id_29
5439        ,INSTRB(anc_id_29,'(]',1,6) + 2
5440        ,INSTRB(anc_id_29,'(]',1,7) -
5441         INSTRB(anc_id_29,'(]',1,6) - 2)
5442 ,SUBSTRB(anc_id_29
5443        ,INSTRB(anc_id_29,'(]',1,7) + 2
5444        ,LENGTHB(anc_id_29))
5445 )
5446 
5447 WHEN anc_id_30 IS NOT NULL THEN
5448   INTO xla_ae_line_acs (
5449         ae_header_id , ae_line_num , object_version_number
5450       , analytical_criterion_code
5451       , analytical_criterion_type_code
5452       , amb_context_code
5453       , ac1,ac2,ac3,ac4,ac5)
5454 VALUES (ae_header_id, ae_line_num, C_OVN
5455 ,SUBSTRB(anc_id_30
5456        ,1
5457        ,INSTRB(anc_id_30,'(]',1,1) -1)
5458 ,SUBSTRB(anc_id_30
5459        ,INSTRB(anc_id_30,'(]',1,1) + 2
5460        ,INSTRB(anc_id_30,'(]',1,2) -
5461         INSTRB(anc_id_30,'(]',1,1) - 2)
5462 ,SUBSTRB(anc_id_30
5463        ,INSTRB(anc_id_30,'(]',1,2) + 2
5464        ,INSTRB(anc_id_30,'(]',1,3) -
5465         INSTRB(anc_id_30,'(]',1,2) - 2)
5466 ,SUBSTRB(anc_id_30
5467        ,INSTRB(anc_id_30,'(]',1,3) + 2
5468        ,INSTRB(anc_id_30,'(]',1,4) -
5469         INSTRB(anc_id_30,'(]',1,3) - 2)
5470 ,SUBSTRB(anc_id_30
5471        ,INSTRB(anc_id_30,'(]',1,4) + 2
5472        ,INSTRB(anc_id_30,'(]',1,5) -
5473         INSTRB(anc_id_30,'(]',1,4) - 2)
5474 ,SUBSTRB(anc_id_30
5475        ,INSTRB(anc_id_30,'(]',1,5) + 2
5476        ,INSTRB(anc_id_30,'(]',1,6) -
5477         INSTRB(anc_id_30,'(]',1,5) - 2)
5478 ,SUBSTRB(anc_id_30
5479        ,INSTRB(anc_id_30,'(]',1,6) + 2
5480        ,INSTRB(anc_id_30,'(]',1,7) -
5481         INSTRB(anc_id_30,'(]',1,6) - 2)
5482 ,SUBSTRB(anc_id_30
5483        ,INSTRB(anc_id_30,'(]',1,7) + 2
5484        ,LENGTHB(anc_id_30))
5485 )
5486 
5487 WHEN anc_id_31 IS NOT NULL THEN
5488   INTO xla_ae_line_acs (
5489         ae_header_id , ae_line_num , object_version_number
5490       , analytical_criterion_code
5491       , analytical_criterion_type_code
5492       , amb_context_code
5493       , ac1,ac2,ac3,ac4,ac5)
5494 VALUES (ae_header_id, ae_line_num, C_OVN
5495 ,SUBSTRB(anc_id_31
5496        ,1
5497        ,INSTRB(anc_id_31,'(]',1,1) -1)
5498 ,SUBSTRB(anc_id_31
5499        ,INSTRB(anc_id_31,'(]',1,1) + 2
5500        ,INSTRB(anc_id_31,'(]',1,2) -
5501         INSTRB(anc_id_31,'(]',1,1) - 2)
5502 ,SUBSTRB(anc_id_31
5503        ,INSTRB(anc_id_31,'(]',1,2) + 2
5504        ,INSTRB(anc_id_31,'(]',1,3) -
5505         INSTRB(anc_id_31,'(]',1,2) - 2)
5506 ,SUBSTRB(anc_id_31
5507        ,INSTRB(anc_id_31,'(]',1,3) + 2
5508        ,INSTRB(anc_id_31,'(]',1,4) -
5509         INSTRB(anc_id_31,'(]',1,3) - 2)
5510 ,SUBSTRB(anc_id_31
5511        ,INSTRB(anc_id_31,'(]',1,4) + 2
5512        ,INSTRB(anc_id_31,'(]',1,5) -
5513         INSTRB(anc_id_31,'(]',1,4) - 2)
5514 ,SUBSTRB(anc_id_31
5515        ,INSTRB(anc_id_31,'(]',1,5) + 2
5516        ,INSTRB(anc_id_31,'(]',1,6) -
5517         INSTRB(anc_id_31,'(]',1,5) - 2)
5518 ,SUBSTRB(anc_id_31
5519        ,INSTRB(anc_id_31,'(]',1,6) + 2
5520        ,INSTRB(anc_id_31,'(]',1,7) -
5521         INSTRB(anc_id_31,'(]',1,6) - 2)
5522 ,SUBSTRB(anc_id_31
5523        ,INSTRB(anc_id_31,'(]',1,7) + 2
5524        ,LENGTHB(anc_id_31))
5525 )
5526 
5527 WHEN anc_id_32 IS NOT NULL THEN
5528   INTO xla_ae_line_acs (
5529         ae_header_id , ae_line_num , object_version_number
5530       , analytical_criterion_code
5531       , analytical_criterion_type_code
5532       , amb_context_code
5533       , ac1,ac2,ac3,ac4,ac5)
5534 VALUES (ae_header_id, ae_line_num, C_OVN
5535 ,SUBSTRB(anc_id_32
5536        ,1
5537        ,INSTRB(anc_id_32,'(]',1,1) -1)
5538 ,SUBSTRB(anc_id_32
5539        ,INSTRB(anc_id_32,'(]',1,1) + 2
5540        ,INSTRB(anc_id_32,'(]',1,2) -
5541         INSTRB(anc_id_32,'(]',1,1) - 2)
5542 ,SUBSTRB(anc_id_32
5543        ,INSTRB(anc_id_32,'(]',1,2) + 2
5544        ,INSTRB(anc_id_32,'(]',1,3) -
5545         INSTRB(anc_id_32,'(]',1,2) - 2)
5546 ,SUBSTRB(anc_id_32
5547        ,INSTRB(anc_id_32,'(]',1,3) + 2
5548        ,INSTRB(anc_id_32,'(]',1,4) -
5549         INSTRB(anc_id_32,'(]',1,3) - 2)
5550 ,SUBSTRB(anc_id_32
5551        ,INSTRB(anc_id_32,'(]',1,4) + 2
5552        ,INSTRB(anc_id_32,'(]',1,5) -
5553         INSTRB(anc_id_32,'(]',1,4) - 2)
5554 ,SUBSTRB(anc_id_32
5555        ,INSTRB(anc_id_32,'(]',1,5) + 2
5556        ,INSTRB(anc_id_32,'(]',1,6) -
5557         INSTRB(anc_id_32,'(]',1,5) - 2)
5558 ,SUBSTRB(anc_id_32
5559        ,INSTRB(anc_id_32,'(]',1,6) + 2
5560        ,INSTRB(anc_id_32,'(]',1,7) -
5561         INSTRB(anc_id_32,'(]',1,6) - 2)
5562 ,SUBSTRB(anc_id_32
5563        ,INSTRB(anc_id_32,'(]',1,7) + 2
5564        ,LENGTHB(anc_id_32))
5565 )
5566 
5567 WHEN anc_id_33 IS NOT NULL THEN
5568   INTO xla_ae_line_acs (
5569         ae_header_id , ae_line_num , object_version_number
5570       , analytical_criterion_code
5571       , analytical_criterion_type_code
5572       , amb_context_code
5573       , ac1,ac2,ac3,ac4,ac5)
5574 VALUES (ae_header_id, ae_line_num, C_OVN
5575 ,SUBSTRB(anc_id_33
5576        ,1
5577        ,INSTRB(anc_id_33,'(]',1,1) -1)
5578 ,SUBSTRB(anc_id_33
5579        ,INSTRB(anc_id_33,'(]',1,1) + 2
5580        ,INSTRB(anc_id_33,'(]',1,2) -
5581         INSTRB(anc_id_33,'(]',1,1) - 2)
5582 ,SUBSTRB(anc_id_33
5583        ,INSTRB(anc_id_33,'(]',1,2) + 2
5584        ,INSTRB(anc_id_33,'(]',1,3) -
5585         INSTRB(anc_id_33,'(]',1,2) - 2)
5586 ,SUBSTRB(anc_id_33
5587        ,INSTRB(anc_id_33,'(]',1,3) + 2
5588        ,INSTRB(anc_id_33,'(]',1,4) -
5589         INSTRB(anc_id_33,'(]',1,3) - 2)
5590 ,SUBSTRB(anc_id_33
5591        ,INSTRB(anc_id_33,'(]',1,4) + 2
5592        ,INSTRB(anc_id_33,'(]',1,5) -
5593         INSTRB(anc_id_33,'(]',1,4) - 2)
5594 ,SUBSTRB(anc_id_33
5595        ,INSTRB(anc_id_33,'(]',1,5) + 2
5596        ,INSTRB(anc_id_33,'(]',1,6) -
5597         INSTRB(anc_id_33,'(]',1,5) - 2)
5598 ,SUBSTRB(anc_id_33
5599        ,INSTRB(anc_id_33,'(]',1,6) + 2
5600        ,INSTRB(anc_id_33,'(]',1,7) -
5601         INSTRB(anc_id_33,'(]',1,6) - 2)
5602 ,SUBSTRB(anc_id_33
5603        ,INSTRB(anc_id_33,'(]',1,7) + 2
5604        ,LENGTHB(anc_id_33))
5605 )
5606 
5607 WHEN anc_id_34 IS NOT NULL THEN
5608   INTO xla_ae_line_acs (
5609         ae_header_id , ae_line_num , object_version_number
5610       , analytical_criterion_code
5611       , analytical_criterion_type_code
5612       , amb_context_code
5613       , ac1,ac2,ac3,ac4,ac5)
5614 VALUES (ae_header_id, ae_line_num, C_OVN
5615 ,SUBSTRB(anc_id_34
5616        ,1
5617        ,INSTRB(anc_id_34,'(]',1,1) -1)
5618 ,SUBSTRB(anc_id_34
5619        ,INSTRB(anc_id_34,'(]',1,1) + 2
5620        ,INSTRB(anc_id_34,'(]',1,2) -
5621         INSTRB(anc_id_34,'(]',1,1) - 2)
5622 ,SUBSTRB(anc_id_34
5623        ,INSTRB(anc_id_34,'(]',1,2) + 2
5624        ,INSTRB(anc_id_34,'(]',1,3) -
5625         INSTRB(anc_id_34,'(]',1,2) - 2)
5626 ,SUBSTRB(anc_id_34
5627        ,INSTRB(anc_id_34,'(]',1,3) + 2
5628        ,INSTRB(anc_id_34,'(]',1,4) -
5629         INSTRB(anc_id_34,'(]',1,3) - 2)
5630 ,SUBSTRB(anc_id_34
5631        ,INSTRB(anc_id_34,'(]',1,4) + 2
5632        ,INSTRB(anc_id_34,'(]',1,5) -
5633         INSTRB(anc_id_34,'(]',1,4) - 2)
5634 ,SUBSTRB(anc_id_34
5635        ,INSTRB(anc_id_34,'(]',1,5) + 2
5636        ,INSTRB(anc_id_34,'(]',1,6) -
5637         INSTRB(anc_id_34,'(]',1,5) - 2)
5638 ,SUBSTRB(anc_id_34
5639        ,INSTRB(anc_id_34,'(]',1,6) + 2
5640        ,INSTRB(anc_id_34,'(]',1,7) -
5641         INSTRB(anc_id_34,'(]',1,6) - 2)
5642 ,SUBSTRB(anc_id_34
5643        ,INSTRB(anc_id_34,'(]',1,7) + 2
5644        ,LENGTHB(anc_id_34))
5645 )
5646 
5647 WHEN anc_id_35 IS NOT NULL THEN
5648   INTO xla_ae_line_acs (
5649         ae_header_id , ae_line_num , object_version_number
5650       , analytical_criterion_code
5651       , analytical_criterion_type_code
5652       , amb_context_code
5653       , ac1,ac2,ac3,ac4,ac5)
5654 VALUES (ae_header_id, ae_line_num, C_OVN
5655 ,SUBSTRB(anc_id_35
5656        ,1
5657        ,INSTRB(anc_id_35,'(]',1,1) -1)
5658 ,SUBSTRB(anc_id_35
5659        ,INSTRB(anc_id_35,'(]',1,1) + 2
5660        ,INSTRB(anc_id_35,'(]',1,2) -
5661         INSTRB(anc_id_35,'(]',1,1) - 2)
5662 ,SUBSTRB(anc_id_35
5663        ,INSTRB(anc_id_35,'(]',1,2) + 2
5664        ,INSTRB(anc_id_35,'(]',1,3) -
5665         INSTRB(anc_id_35,'(]',1,2) - 2)
5666 ,SUBSTRB(anc_id_35
5667        ,INSTRB(anc_id_35,'(]',1,3) + 2
5668        ,INSTRB(anc_id_35,'(]',1,4) -
5669         INSTRB(anc_id_35,'(]',1,3) - 2)
5670 ,SUBSTRB(anc_id_35
5671        ,INSTRB(anc_id_35,'(]',1,4) + 2
5672        ,INSTRB(anc_id_35,'(]',1,5) -
5673         INSTRB(anc_id_35,'(]',1,4) - 2)
5674 ,SUBSTRB(anc_id_35
5675        ,INSTRB(anc_id_35,'(]',1,5) + 2
5676        ,INSTRB(anc_id_35,'(]',1,6) -
5677         INSTRB(anc_id_35,'(]',1,5) - 2)
5678 ,SUBSTRB(anc_id_35
5679        ,INSTRB(anc_id_35,'(]',1,6) + 2
5680        ,INSTRB(anc_id_35,'(]',1,7) -
5681         INSTRB(anc_id_35,'(]',1,6) - 2)
5682 ,SUBSTRB(anc_id_35
5683        ,INSTRB(anc_id_35,'(]',1,7) + 2
5684        ,LENGTHB(anc_id_35))
5685 )
5686 
5687 WHEN anc_id_36 IS NOT NULL THEN
5688   INTO xla_ae_line_acs (
5689         ae_header_id , ae_line_num , object_version_number
5690       , analytical_criterion_code
5691       , analytical_criterion_type_code
5692       , amb_context_code
5693       , ac1,ac2,ac3,ac4,ac5)
5694 VALUES (ae_header_id, ae_line_num, C_OVN
5695 ,SUBSTRB(anc_id_36
5696        ,1
5697        ,INSTRB(anc_id_36,'(]',1,1) -1)
5698 ,SUBSTRB(anc_id_36
5699        ,INSTRB(anc_id_36,'(]',1,1) + 2
5700        ,INSTRB(anc_id_36,'(]',1,2) -
5701         INSTRB(anc_id_36,'(]',1,1) - 2)
5702 ,SUBSTRB(anc_id_36
5703        ,INSTRB(anc_id_36,'(]',1,2) + 2
5704        ,INSTRB(anc_id_36,'(]',1,3) -
5705         INSTRB(anc_id_36,'(]',1,2) - 2)
5706 ,SUBSTRB(anc_id_36
5707        ,INSTRB(anc_id_36,'(]',1,3) + 2
5708        ,INSTRB(anc_id_36,'(]',1,4) -
5709         INSTRB(anc_id_36,'(]',1,3) - 2)
5710 ,SUBSTRB(anc_id_36
5711        ,INSTRB(anc_id_36,'(]',1,4) + 2
5712        ,INSTRB(anc_id_36,'(]',1,5) -
5713         INSTRB(anc_id_36,'(]',1,4) - 2)
5714 ,SUBSTRB(anc_id_36
5715        ,INSTRB(anc_id_36,'(]',1,5) + 2
5716        ,INSTRB(anc_id_36,'(]',1,6) -
5717         INSTRB(anc_id_36,'(]',1,5) - 2)
5718 ,SUBSTRB(anc_id_36
5719        ,INSTRB(anc_id_36,'(]',1,6) + 2
5720        ,INSTRB(anc_id_36,'(]',1,7) -
5721         INSTRB(anc_id_36,'(]',1,6) - 2)
5722 ,SUBSTRB(anc_id_36
5723        ,INSTRB(anc_id_36,'(]',1,7) + 2
5724        ,LENGTHB(anc_id_36))
5725 )
5726 
5727 WHEN anc_id_37 IS NOT NULL THEN
5728   INTO xla_ae_line_acs (
5729         ae_header_id , ae_line_num , object_version_number
5730       , analytical_criterion_code
5731       , analytical_criterion_type_code
5732       , amb_context_code
5733       , ac1,ac2,ac3,ac4,ac5)
5734 VALUES (ae_header_id, ae_line_num, C_OVN
5735 ,SUBSTRB(anc_id_37
5736        ,1
5737        ,INSTRB(anc_id_37,'(]',1,1) -1)
5738 ,SUBSTRB(anc_id_37
5739        ,INSTRB(anc_id_37,'(]',1,1) + 2
5740        ,INSTRB(anc_id_37,'(]',1,2) -
5741         INSTRB(anc_id_37,'(]',1,1) - 2)
5742 ,SUBSTRB(anc_id_37
5743        ,INSTRB(anc_id_37,'(]',1,2) + 2
5744        ,INSTRB(anc_id_37,'(]',1,3) -
5745         INSTRB(anc_id_37,'(]',1,2) - 2)
5746 ,SUBSTRB(anc_id_37
5747        ,INSTRB(anc_id_37,'(]',1,3) + 2
5748        ,INSTRB(anc_id_37,'(]',1,4) -
5749         INSTRB(anc_id_37,'(]',1,3) - 2)
5750 ,SUBSTRB(anc_id_37
5751        ,INSTRB(anc_id_37,'(]',1,4) + 2
5752        ,INSTRB(anc_id_37,'(]',1,5) -
5753         INSTRB(anc_id_37,'(]',1,4) - 2)
5754 ,SUBSTRB(anc_id_37
5755        ,INSTRB(anc_id_37,'(]',1,5) + 2
5756        ,INSTRB(anc_id_37,'(]',1,6) -
5757         INSTRB(anc_id_37,'(]',1,5) - 2)
5758 ,SUBSTRB(anc_id_37
5759        ,INSTRB(anc_id_37,'(]',1,6) + 2
5760        ,INSTRB(anc_id_37,'(]',1,7) -
5761         INSTRB(anc_id_37,'(]',1,6) - 2)
5762 ,SUBSTRB(anc_id_37
5763        ,INSTRB(anc_id_37,'(]',1,7) + 2
5764        ,LENGTHB(anc_id_37))
5765 )
5766 
5767 WHEN anc_id_38 IS NOT NULL THEN
5768   INTO xla_ae_line_acs (
5769         ae_header_id , ae_line_num , object_version_number
5770       , analytical_criterion_code
5771       , analytical_criterion_type_code
5772       , amb_context_code
5773       , ac1,ac2,ac3,ac4,ac5)
5774 VALUES (ae_header_id, ae_line_num, C_OVN
5775 ,SUBSTRB(anc_id_38
5776        ,1
5777        ,INSTRB(anc_id_38,'(]',1,1) -1)
5778 ,SUBSTRB(anc_id_38
5779        ,INSTRB(anc_id_38,'(]',1,1) + 2
5780        ,INSTRB(anc_id_38,'(]',1,2) -
5781         INSTRB(anc_id_38,'(]',1,1) - 2)
5782 ,SUBSTRB(anc_id_38
5783        ,INSTRB(anc_id_38,'(]',1,2) + 2
5784        ,INSTRB(anc_id_38,'(]',1,3) -
5785         INSTRB(anc_id_38,'(]',1,2) - 2)
5786 ,SUBSTRB(anc_id_38
5787        ,INSTRB(anc_id_38,'(]',1,3) + 2
5788        ,INSTRB(anc_id_38,'(]',1,4) -
5789         INSTRB(anc_id_38,'(]',1,3) - 2)
5790 ,SUBSTRB(anc_id_38
5791        ,INSTRB(anc_id_38,'(]',1,4) + 2
5792        ,INSTRB(anc_id_38,'(]',1,5) -
5793         INSTRB(anc_id_38,'(]',1,4) - 2)
5794 ,SUBSTRB(anc_id_38
5795        ,INSTRB(anc_id_38,'(]',1,5) + 2
5796        ,INSTRB(anc_id_38,'(]',1,6) -
5797         INSTRB(anc_id_38,'(]',1,5) - 2)
5798 ,SUBSTRB(anc_id_38
5799        ,INSTRB(anc_id_38,'(]',1,6) + 2
5800        ,INSTRB(anc_id_38,'(]',1,7) -
5801         INSTRB(anc_id_38,'(]',1,6) - 2)
5802 ,SUBSTRB(anc_id_38
5803        ,INSTRB(anc_id_38,'(]',1,7) + 2
5804        ,LENGTHB(anc_id_38))
5805 )
5806 
5807 WHEN anc_id_39 IS NOT NULL THEN
5808   INTO xla_ae_line_acs (
5809         ae_header_id , ae_line_num , object_version_number
5810       , analytical_criterion_code
5811       , analytical_criterion_type_code
5812       , amb_context_code
5813       , ac1,ac2,ac3,ac4,ac5)
5814 VALUES (ae_header_id, ae_line_num, C_OVN
5815 ,SUBSTRB(anc_id_39
5816        ,1
5817        ,INSTRB(anc_id_39,'(]',1,1) -1)
5818 ,SUBSTRB(anc_id_39
5819        ,INSTRB(anc_id_39,'(]',1,1) + 2
5820        ,INSTRB(anc_id_39,'(]',1,2) -
5821         INSTRB(anc_id_39,'(]',1,1) - 2)
5822 ,SUBSTRB(anc_id_39
5823        ,INSTRB(anc_id_39,'(]',1,2) + 2
5824        ,INSTRB(anc_id_39,'(]',1,3) -
5825         INSTRB(anc_id_39,'(]',1,2) - 2)
5826 ,SUBSTRB(anc_id_39
5827        ,INSTRB(anc_id_39,'(]',1,3) + 2
5828        ,INSTRB(anc_id_39,'(]',1,4) -
5829         INSTRB(anc_id_39,'(]',1,3) - 2)
5830 ,SUBSTRB(anc_id_39
5831        ,INSTRB(anc_id_39,'(]',1,4) + 2
5832        ,INSTRB(anc_id_39,'(]',1,5) -
5833         INSTRB(anc_id_39,'(]',1,4) - 2)
5834 ,SUBSTRB(anc_id_39
5835        ,INSTRB(anc_id_39,'(]',1,5) + 2
5836        ,INSTRB(anc_id_39,'(]',1,6) -
5837         INSTRB(anc_id_39,'(]',1,5) - 2)
5838 ,SUBSTRB(anc_id_39
5839        ,INSTRB(anc_id_39,'(]',1,6) + 2
5840        ,INSTRB(anc_id_39,'(]',1,7) -
5841         INSTRB(anc_id_39,'(]',1,6) - 2)
5842 ,SUBSTRB(anc_id_39
5843        ,INSTRB(anc_id_39,'(]',1,7) + 2
5844        ,LENGTHB(anc_id_39))
5845 )
5846 
5847 WHEN anc_id_40 IS NOT NULL THEN
5848   INTO xla_ae_line_acs (
5849         ae_header_id , ae_line_num , object_version_number
5850       , analytical_criterion_code
5851       , analytical_criterion_type_code
5852       , amb_context_code
5853       , ac1,ac2,ac3,ac4,ac5)
5854 VALUES (ae_header_id, ae_line_num, C_OVN
5855 ,SUBSTRB(anc_id_40
5856        ,1
5857        ,INSTRB(anc_id_40,'(]',1,1) -1)
5858 ,SUBSTRB(anc_id_40
5859        ,INSTRB(anc_id_40,'(]',1,1) + 2
5860        ,INSTRB(anc_id_40,'(]',1,2) -
5861         INSTRB(anc_id_40,'(]',1,1) - 2)
5862 ,SUBSTRB(anc_id_40
5863        ,INSTRB(anc_id_40,'(]',1,2) + 2
5864        ,INSTRB(anc_id_40,'(]',1,3) -
5865         INSTRB(anc_id_40,'(]',1,2) - 2)
5866 ,SUBSTRB(anc_id_40
5867        ,INSTRB(anc_id_40,'(]',1,3) + 2
5868        ,INSTRB(anc_id_40,'(]',1,4) -
5869         INSTRB(anc_id_40,'(]',1,3) - 2)
5870 ,SUBSTRB(anc_id_40
5871        ,INSTRB(anc_id_40,'(]',1,4) + 2
5872        ,INSTRB(anc_id_40,'(]',1,5) -
5873         INSTRB(anc_id_40,'(]',1,4) - 2)
5874 ,SUBSTRB(anc_id_40
5875        ,INSTRB(anc_id_40,'(]',1,5) + 2
5876        ,INSTRB(anc_id_40,'(]',1,6) -
5877         INSTRB(anc_id_40,'(]',1,5) - 2)
5878 ,SUBSTRB(anc_id_40
5879        ,INSTRB(anc_id_40,'(]',1,6) + 2
5880        ,INSTRB(anc_id_40,'(]',1,7) -
5881         INSTRB(anc_id_40,'(]',1,6) - 2)
5882 ,SUBSTRB(anc_id_40
5883        ,INSTRB(anc_id_40,'(]',1,7) + 2
5884        ,LENGTHB(anc_id_40))
5885 )
5886 
5887 WHEN anc_id_41 IS NOT NULL THEN
5888   INTO xla_ae_line_acs (
5889         ae_header_id , ae_line_num , object_version_number
5890       , analytical_criterion_code
5891       , analytical_criterion_type_code
5892       , amb_context_code
5893       , ac1,ac2,ac3,ac4,ac5)
5894 VALUES (ae_header_id, ae_line_num, C_OVN
5895 ,SUBSTRB(anc_id_41
5896        ,1
5897        ,INSTRB(anc_id_41,'(]',1,1) -1)
5898 ,SUBSTRB(anc_id_41
5899        ,INSTRB(anc_id_41,'(]',1,1) + 2
5900        ,INSTRB(anc_id_41,'(]',1,2) -
5901         INSTRB(anc_id_41,'(]',1,1) - 2)
5902 ,SUBSTRB(anc_id_41
5903        ,INSTRB(anc_id_41,'(]',1,2) + 2
5904        ,INSTRB(anc_id_41,'(]',1,3) -
5905         INSTRB(anc_id_41,'(]',1,2) - 2)
5906 ,SUBSTRB(anc_id_41
5907        ,INSTRB(anc_id_41,'(]',1,3) + 2
5908        ,INSTRB(anc_id_41,'(]',1,4) -
5909         INSTRB(anc_id_41,'(]',1,3) - 2)
5910 ,SUBSTRB(anc_id_41
5911        ,INSTRB(anc_id_41,'(]',1,4) + 2
5912        ,INSTRB(anc_id_41,'(]',1,5) -
5913         INSTRB(anc_id_41,'(]',1,4) - 2)
5914 ,SUBSTRB(anc_id_41
5915        ,INSTRB(anc_id_41,'(]',1,5) + 2
5916        ,INSTRB(anc_id_41,'(]',1,6) -
5917         INSTRB(anc_id_41,'(]',1,5) - 2)
5918 ,SUBSTRB(anc_id_41
5919        ,INSTRB(anc_id_41,'(]',1,6) + 2
5920        ,INSTRB(anc_id_41,'(]',1,7) -
5921         INSTRB(anc_id_41,'(]',1,6) - 2)
5922 ,SUBSTRB(anc_id_41
5923        ,INSTRB(anc_id_41,'(]',1,7) + 2
5924        ,LENGTHB(anc_id_41))
5925 )
5926 
5927 WHEN anc_id_42 IS NOT NULL THEN
5928   INTO xla_ae_line_acs (
5929         ae_header_id , ae_line_num , object_version_number
5930       , analytical_criterion_code
5931       , analytical_criterion_type_code
5932       , amb_context_code
5933       , ac1,ac2,ac3,ac4,ac5)
5934 VALUES (ae_header_id, ae_line_num, C_OVN
5935 ,SUBSTRB(anc_id_42
5936        ,1
5937        ,INSTRB(anc_id_42,'(]',1,1) -1)
5938 ,SUBSTRB(anc_id_42
5939        ,INSTRB(anc_id_42,'(]',1,1) + 2
5940        ,INSTRB(anc_id_42,'(]',1,2) -
5941         INSTRB(anc_id_42,'(]',1,1) - 2)
5942 ,SUBSTRB(anc_id_42
5943        ,INSTRB(anc_id_42,'(]',1,2) + 2
5944        ,INSTRB(anc_id_42,'(]',1,3) -
5945         INSTRB(anc_id_42,'(]',1,2) - 2)
5946 ,SUBSTRB(anc_id_42
5947        ,INSTRB(anc_id_42,'(]',1,3) + 2
5948        ,INSTRB(anc_id_42,'(]',1,4) -
5949         INSTRB(anc_id_42,'(]',1,3) - 2)
5950 ,SUBSTRB(anc_id_42
5951        ,INSTRB(anc_id_42,'(]',1,4) + 2
5952        ,INSTRB(anc_id_42,'(]',1,5) -
5953         INSTRB(anc_id_42,'(]',1,4) - 2)
5954 ,SUBSTRB(anc_id_42
5955        ,INSTRB(anc_id_42,'(]',1,5) + 2
5956        ,INSTRB(anc_id_42,'(]',1,6) -
5957         INSTRB(anc_id_42,'(]',1,5) - 2)
5958 ,SUBSTRB(anc_id_42
5959        ,INSTRB(anc_id_42,'(]',1,6) + 2
5960        ,INSTRB(anc_id_42,'(]',1,7) -
5961         INSTRB(anc_id_42,'(]',1,6) - 2)
5962 ,SUBSTRB(anc_id_42
5963        ,INSTRB(anc_id_42,'(]',1,7) + 2
5964        ,LENGTHB(anc_id_42))
5965 )
5966 
5967 WHEN anc_id_43 IS NOT NULL THEN
5968   INTO xla_ae_line_acs (
5969         ae_header_id , ae_line_num , object_version_number
5970       , analytical_criterion_code
5971       , analytical_criterion_type_code
5972       , amb_context_code
5973       , ac1,ac2,ac3,ac4,ac5)
5974 VALUES (ae_header_id, ae_line_num, C_OVN
5975 ,SUBSTRB(anc_id_43
5976        ,1
5977        ,INSTRB(anc_id_43,'(]',1,1) -1)
5978 ,SUBSTRB(anc_id_43
5979        ,INSTRB(anc_id_43,'(]',1,1) + 2
5980        ,INSTRB(anc_id_43,'(]',1,2) -
5981         INSTRB(anc_id_43,'(]',1,1) - 2)
5982 ,SUBSTRB(anc_id_43
5983        ,INSTRB(anc_id_43,'(]',1,2) + 2
5984        ,INSTRB(anc_id_43,'(]',1,3) -
5985         INSTRB(anc_id_43,'(]',1,2) - 2)
5986 ,SUBSTRB(anc_id_43
5987        ,INSTRB(anc_id_43,'(]',1,3) + 2
5988        ,INSTRB(anc_id_43,'(]',1,4) -
5989         INSTRB(anc_id_43,'(]',1,3) - 2)
5990 ,SUBSTRB(anc_id_43
5991        ,INSTRB(anc_id_43,'(]',1,4) + 2
5992        ,INSTRB(anc_id_43,'(]',1,5) -
5993         INSTRB(anc_id_43,'(]',1,4) - 2)
5994 ,SUBSTRB(anc_id_43
5995        ,INSTRB(anc_id_43,'(]',1,5) + 2
5996        ,INSTRB(anc_id_43,'(]',1,6) -
5997         INSTRB(anc_id_43,'(]',1,5) - 2)
5998 ,SUBSTRB(anc_id_43
5999        ,INSTRB(anc_id_43,'(]',1,6) + 2
6000        ,INSTRB(anc_id_43,'(]',1,7) -
6001         INSTRB(anc_id_43,'(]',1,6) - 2)
6002 ,SUBSTRB(anc_id_43
6003        ,INSTRB(anc_id_43,'(]',1,7) + 2
6004        ,LENGTHB(anc_id_43))
6005 )
6006 
6007 WHEN anc_id_44 IS NOT NULL THEN
6008   INTO xla_ae_line_acs (
6009         ae_header_id , ae_line_num , object_version_number
6010       , analytical_criterion_code
6011       , analytical_criterion_type_code
6012       , amb_context_code
6013       , ac1,ac2,ac3,ac4,ac5)
6014 VALUES (ae_header_id, ae_line_num, C_OVN
6015 ,SUBSTRB(anc_id_44
6016        ,1
6017        ,INSTRB(anc_id_44,'(]',1,1) -1)
6018 ,SUBSTRB(anc_id_44
6019        ,INSTRB(anc_id_44,'(]',1,1) + 2
6020        ,INSTRB(anc_id_44,'(]',1,2) -
6021         INSTRB(anc_id_44,'(]',1,1) - 2)
6022 ,SUBSTRB(anc_id_44
6023        ,INSTRB(anc_id_44,'(]',1,2) + 2
6024        ,INSTRB(anc_id_44,'(]',1,3) -
6025         INSTRB(anc_id_44,'(]',1,2) - 2)
6026 ,SUBSTRB(anc_id_44
6027        ,INSTRB(anc_id_44,'(]',1,3) + 2
6028        ,INSTRB(anc_id_44,'(]',1,4) -
6029         INSTRB(anc_id_44,'(]',1,3) - 2)
6030 ,SUBSTRB(anc_id_44
6031        ,INSTRB(anc_id_44,'(]',1,4) + 2
6032        ,INSTRB(anc_id_44,'(]',1,5) -
6033         INSTRB(anc_id_44,'(]',1,4) - 2)
6034 ,SUBSTRB(anc_id_44
6035        ,INSTRB(anc_id_44,'(]',1,5) + 2
6036        ,INSTRB(anc_id_44,'(]',1,6) -
6037         INSTRB(anc_id_44,'(]',1,5) - 2)
6038 ,SUBSTRB(anc_id_44
6039        ,INSTRB(anc_id_44,'(]',1,6) + 2
6040        ,INSTRB(anc_id_44,'(]',1,7) -
6041         INSTRB(anc_id_44,'(]',1,6) - 2)
6042 ,SUBSTRB(anc_id_44
6043        ,INSTRB(anc_id_44,'(]',1,7) + 2
6044        ,LENGTHB(anc_id_44))
6045 )
6046 
6047 WHEN anc_id_45 IS NOT NULL THEN
6048   INTO xla_ae_line_acs (
6049         ae_header_id , ae_line_num , object_version_number
6050       , analytical_criterion_code
6051       , analytical_criterion_type_code
6052       , amb_context_code
6053       , ac1,ac2,ac3,ac4,ac5)
6054 VALUES (ae_header_id, ae_line_num, C_OVN
6055 ,SUBSTRB(anc_id_45
6056        ,1
6057        ,INSTRB(anc_id_45,'(]',1,1) -1)
6058 ,SUBSTRB(anc_id_45
6059        ,INSTRB(anc_id_45,'(]',1,1) + 2
6060        ,INSTRB(anc_id_45,'(]',1,2) -
6061         INSTRB(anc_id_45,'(]',1,1) - 2)
6062 ,SUBSTRB(anc_id_45
6063        ,INSTRB(anc_id_45,'(]',1,2) + 2
6064        ,INSTRB(anc_id_45,'(]',1,3) -
6065         INSTRB(anc_id_45,'(]',1,2) - 2)
6066 ,SUBSTRB(anc_id_45
6067        ,INSTRB(anc_id_45,'(]',1,3) + 2
6068        ,INSTRB(anc_id_45,'(]',1,4) -
6069         INSTRB(anc_id_45,'(]',1,3) - 2)
6070 ,SUBSTRB(anc_id_45
6071        ,INSTRB(anc_id_45,'(]',1,4) + 2
6072        ,INSTRB(anc_id_45,'(]',1,5) -
6073         INSTRB(anc_id_45,'(]',1,4) - 2)
6074 ,SUBSTRB(anc_id_45
6075        ,INSTRB(anc_id_45,'(]',1,5) + 2
6076        ,INSTRB(anc_id_45,'(]',1,6) -
6077         INSTRB(anc_id_45,'(]',1,5) - 2)
6078 ,SUBSTRB(anc_id_45
6079        ,INSTRB(anc_id_45,'(]',1,6) + 2
6080        ,INSTRB(anc_id_45,'(]',1,7) -
6081         INSTRB(anc_id_45,'(]',1,6) - 2)
6082 ,SUBSTRB(anc_id_45
6083        ,INSTRB(anc_id_45,'(]',1,7) + 2
6084        ,LENGTHB(anc_id_45))
6085 )
6086 
6087 WHEN anc_id_46 IS NOT NULL THEN
6088   INTO xla_ae_line_acs (
6089         ae_header_id , ae_line_num , object_version_number
6090       , analytical_criterion_code
6091       , analytical_criterion_type_code
6092       , amb_context_code
6093       , ac1,ac2,ac3,ac4,ac5)
6094 VALUES (ae_header_id, ae_line_num, C_OVN
6095 ,SUBSTRB(anc_id_46
6096        ,1
6097        ,INSTRB(anc_id_46,'(]',1,1) -1)
6098 ,SUBSTRB(anc_id_46
6099        ,INSTRB(anc_id_46,'(]',1,1) + 2
6100        ,INSTRB(anc_id_46,'(]',1,2) -
6101         INSTRB(anc_id_46,'(]',1,1) - 2)
6102 ,SUBSTRB(anc_id_46
6103        ,INSTRB(anc_id_46,'(]',1,2) + 2
6104        ,INSTRB(anc_id_46,'(]',1,3) -
6105         INSTRB(anc_id_46,'(]',1,2) - 2)
6106 ,SUBSTRB(anc_id_46
6107        ,INSTRB(anc_id_46,'(]',1,3) + 2
6108        ,INSTRB(anc_id_46,'(]',1,4) -
6109         INSTRB(anc_id_46,'(]',1,3) - 2)
6110 ,SUBSTRB(anc_id_46
6111        ,INSTRB(anc_id_46,'(]',1,4) + 2
6112        ,INSTRB(anc_id_46,'(]',1,5) -
6113         INSTRB(anc_id_46,'(]',1,4) - 2)
6114 ,SUBSTRB(anc_id_46
6115        ,INSTRB(anc_id_46,'(]',1,5) + 2
6116        ,INSTRB(anc_id_46,'(]',1,6) -
6117         INSTRB(anc_id_46,'(]',1,5) - 2)
6118 ,SUBSTRB(anc_id_46
6119        ,INSTRB(anc_id_46,'(]',1,6) + 2
6120        ,INSTRB(anc_id_46,'(]',1,7) -
6121         INSTRB(anc_id_46,'(]',1,6) - 2)
6122 ,SUBSTRB(anc_id_46
6123        ,INSTRB(anc_id_46,'(]',1,7) + 2
6124        ,LENGTHB(anc_id_46))
6125 )
6126 
6127 WHEN anc_id_47 IS NOT NULL THEN
6128   INTO xla_ae_line_acs (
6129         ae_header_id , ae_line_num , object_version_number
6130       , analytical_criterion_code
6131       , analytical_criterion_type_code
6132       , amb_context_code
6133       , ac1,ac2,ac3,ac4,ac5)
6134 VALUES (ae_header_id, ae_line_num, C_OVN
6135 ,SUBSTRB(anc_id_47
6136        ,1
6137        ,INSTRB(anc_id_47,'(]',1,1) -1)
6138 ,SUBSTRB(anc_id_47
6139        ,INSTRB(anc_id_47,'(]',1,1) + 2
6140        ,INSTRB(anc_id_47,'(]',1,2) -
6141         INSTRB(anc_id_47,'(]',1,1) - 2)
6142 ,SUBSTRB(anc_id_47
6143        ,INSTRB(anc_id_47,'(]',1,2) + 2
6144        ,INSTRB(anc_id_47,'(]',1,3) -
6145         INSTRB(anc_id_47,'(]',1,2) - 2)
6146 ,SUBSTRB(anc_id_47
6147        ,INSTRB(anc_id_47,'(]',1,3) + 2
6148        ,INSTRB(anc_id_47,'(]',1,4) -
6149         INSTRB(anc_id_47,'(]',1,3) - 2)
6150 ,SUBSTRB(anc_id_47
6151        ,INSTRB(anc_id_47,'(]',1,4) + 2
6152        ,INSTRB(anc_id_47,'(]',1,5) -
6153         INSTRB(anc_id_47,'(]',1,4) - 2)
6154 ,SUBSTRB(anc_id_47
6155        ,INSTRB(anc_id_47,'(]',1,5) + 2
6156        ,INSTRB(anc_id_47,'(]',1,6) -
6157         INSTRB(anc_id_47,'(]',1,5) - 2)
6158 ,SUBSTRB(anc_id_47
6159        ,INSTRB(anc_id_47,'(]',1,6) + 2
6160        ,INSTRB(anc_id_47,'(]',1,7) -
6161         INSTRB(anc_id_47,'(]',1,6) - 2)
6162 ,SUBSTRB(anc_id_47
6163        ,INSTRB(anc_id_47,'(]',1,7) + 2
6164        ,LENGTHB(anc_id_47))
6165 )
6166 
6167 WHEN anc_id_48 IS NOT NULL THEN
6168   INTO xla_ae_line_acs (
6169         ae_header_id , ae_line_num , object_version_number
6170       , analytical_criterion_code
6171       , analytical_criterion_type_code
6172       , amb_context_code
6173       , ac1,ac2,ac3,ac4,ac5)
6174 VALUES (ae_header_id, ae_line_num, C_OVN
6175 ,SUBSTRB(anc_id_48
6176        ,1
6177        ,INSTRB(anc_id_48,'(]',1,1) -1)
6178 ,SUBSTRB(anc_id_48
6179        ,INSTRB(anc_id_48,'(]',1,1) + 2
6180        ,INSTRB(anc_id_48,'(]',1,2) -
6181         INSTRB(anc_id_48,'(]',1,1) - 2)
6182 ,SUBSTRB(anc_id_48
6183        ,INSTRB(anc_id_48,'(]',1,2) + 2
6184        ,INSTRB(anc_id_48,'(]',1,3) -
6185         INSTRB(anc_id_48,'(]',1,2) - 2)
6186 ,SUBSTRB(anc_id_48
6187        ,INSTRB(anc_id_48,'(]',1,3) + 2
6188        ,INSTRB(anc_id_48,'(]',1,4) -
6189         INSTRB(anc_id_48,'(]',1,3) - 2)
6190 ,SUBSTRB(anc_id_48
6191        ,INSTRB(anc_id_48,'(]',1,4) + 2
6192        ,INSTRB(anc_id_48,'(]',1,5) -
6193         INSTRB(anc_id_48,'(]',1,4) - 2)
6194 ,SUBSTRB(anc_id_48
6195        ,INSTRB(anc_id_48,'(]',1,5) + 2
6196        ,INSTRB(anc_id_48,'(]',1,6) -
6197         INSTRB(anc_id_48,'(]',1,5) - 2)
6198 ,SUBSTRB(anc_id_48
6199        ,INSTRB(anc_id_48,'(]',1,6) + 2
6200        ,INSTRB(anc_id_48,'(]',1,7) -
6201         INSTRB(anc_id_48,'(]',1,6) - 2)
6202 ,SUBSTRB(anc_id_48
6203        ,INSTRB(anc_id_48,'(]',1,7) + 2
6204        ,LENGTHB(anc_id_48))
6205 )
6206 
6207 WHEN anc_id_49 IS NOT NULL THEN
6208   INTO xla_ae_line_acs (
6209         ae_header_id , ae_line_num , object_version_number
6210       , analytical_criterion_code
6211       , analytical_criterion_type_code
6212       , amb_context_code
6213       , ac1,ac2,ac3,ac4,ac5)
6214 VALUES (ae_header_id, ae_line_num, C_OVN
6215 ,SUBSTRB(anc_id_49
6216        ,1
6217        ,INSTRB(anc_id_49,'(]',1,1) -1)
6218 ,SUBSTRB(anc_id_49
6219        ,INSTRB(anc_id_49,'(]',1,1) + 2
6220        ,INSTRB(anc_id_49,'(]',1,2) -
6221         INSTRB(anc_id_49,'(]',1,1) - 2)
6222 ,SUBSTRB(anc_id_49
6223        ,INSTRB(anc_id_49,'(]',1,2) + 2
6224        ,INSTRB(anc_id_49,'(]',1,3) -
6225         INSTRB(anc_id_49,'(]',1,2) - 2)
6226 ,SUBSTRB(anc_id_49
6227        ,INSTRB(anc_id_49,'(]',1,3) + 2
6228        ,INSTRB(anc_id_49,'(]',1,4) -
6229         INSTRB(anc_id_49,'(]',1,3) - 2)
6230 ,SUBSTRB(anc_id_49
6231        ,INSTRB(anc_id_49,'(]',1,4) + 2
6232        ,INSTRB(anc_id_49,'(]',1,5) -
6233         INSTRB(anc_id_49,'(]',1,4) - 2)
6234 ,SUBSTRB(anc_id_49
6235        ,INSTRB(anc_id_49,'(]',1,5) + 2
6236        ,INSTRB(anc_id_49,'(]',1,6) -
6237         INSTRB(anc_id_49,'(]',1,5) - 2)
6238 ,SUBSTRB(anc_id_49
6239        ,INSTRB(anc_id_49,'(]',1,6) + 2
6240        ,INSTRB(anc_id_49,'(]',1,7) -
6241         INSTRB(anc_id_49,'(]',1,6) - 2)
6242 ,SUBSTRB(anc_id_49
6243        ,INSTRB(anc_id_49,'(]',1,7) + 2
6244        ,LENGTHB(anc_id_49))
6245 )
6246 
6247 WHEN anc_id_50 IS NOT NULL THEN
6248   INTO xla_ae_line_acs (
6249         ae_header_id , ae_line_num , object_version_number
6250       , analytical_criterion_code
6251       , analytical_criterion_type_code
6252       , amb_context_code
6253       , ac1,ac2,ac3,ac4,ac5)
6254 VALUES (ae_header_id, ae_line_num, C_OVN
6255 ,SUBSTRB(anc_id_50
6256        ,1
6257        ,INSTRB(anc_id_50,'(]',1,1) -1)
6258 ,SUBSTRB(anc_id_50
6259        ,INSTRB(anc_id_50,'(]',1,1) + 2
6260        ,INSTRB(anc_id_50,'(]',1,2) -
6261         INSTRB(anc_id_50,'(]',1,1) - 2)
6262 ,SUBSTRB(anc_id_50
6263        ,INSTRB(anc_id_50,'(]',1,2) + 2
6264        ,INSTRB(anc_id_50,'(]',1,3) -
6265         INSTRB(anc_id_50,'(]',1,2) - 2)
6266 ,SUBSTRB(anc_id_50
6267        ,INSTRB(anc_id_50,'(]',1,3) + 2
6268        ,INSTRB(anc_id_50,'(]',1,4) -
6269         INSTRB(anc_id_50,'(]',1,3) - 2)
6270 ,SUBSTRB(anc_id_50
6271        ,INSTRB(anc_id_50,'(]',1,4) + 2
6272        ,INSTRB(anc_id_50,'(]',1,5) -
6273         INSTRB(anc_id_50,'(]',1,4) - 2)
6274 ,SUBSTRB(anc_id_50
6275        ,INSTRB(anc_id_50,'(]',1,5) + 2
6276        ,INSTRB(anc_id_50,'(]',1,6) -
6277         INSTRB(anc_id_50,'(]',1,5) - 2)
6278 ,SUBSTRB(anc_id_50
6279        ,INSTRB(anc_id_50,'(]',1,6) + 2
6280        ,INSTRB(anc_id_50,'(]',1,7) -
6281         INSTRB(anc_id_50,'(]',1,6) - 2)
6282 ,SUBSTRB(anc_id_50
6283        ,INSTRB(anc_id_50,'(]',1,7) + 2
6284        ,LENGTHB(anc_id_50))
6285 )
6286 
6287 
6288 SELECT  ae_header_id
6289       , ae_line_num
6290       , anc_id_1
6291       , anc_id_2
6292       , anc_id_3
6293       , anc_id_4
6294       , anc_id_5
6295       , anc_id_6
6296       , anc_id_7
6297       , anc_id_8
6298       , anc_id_9
6299       , anc_id_10
6300       , anc_id_11
6301       , anc_id_12
6302       , anc_id_13
6303       , anc_id_14
6304       , anc_id_15
6305       , anc_id_16
6306       , anc_id_17
6307       , anc_id_18
6308       , anc_id_19
6309       , anc_id_20
6310       , anc_id_21
6311       , anc_id_22
6312       , anc_id_23
6313       , anc_id_24
6314       , anc_id_25
6315       , anc_id_26
6316       , anc_id_27
6317       , anc_id_28
6318       , anc_id_29
6319       , anc_id_30
6320       , anc_id_31
6321       , anc_id_32
6322       , anc_id_33
6323       , anc_id_34
6324       , anc_id_35
6325       , anc_id_36
6326       , anc_id_37
6327       , anc_id_38
6328       , anc_id_39
6329       , anc_id_40
6330       , anc_id_41
6331       , anc_id_42
6332       , anc_id_43
6333       , anc_id_44
6334       , anc_id_45
6335       , anc_id_46
6336       , anc_id_47
6337       , anc_id_48
6338       , anc_id_49
6339       , anc_id_50
6340  FROM  xla_ae_lines_gt
6341 WHERE  ae_line_num is not null
6342 GROUP  BY
6343        ae_line_num
6344       ,ae_header_id
6345       ,anc_id_1
6346       ,anc_id_2
6347       ,anc_id_3
6348       ,anc_id_4
6349       ,anc_id_5
6350       ,anc_id_6
6351       ,anc_id_7
6352       ,anc_id_8
6353       ,anc_id_9
6354       ,anc_id_10
6355       ,anc_id_11
6356       ,anc_id_12
6357       ,anc_id_13
6358       ,anc_id_14
6359       ,anc_id_15
6360       ,anc_id_16
6361       ,anc_id_17
6362       ,anc_id_18
6363       ,anc_id_19
6364       ,anc_id_20
6365       ,anc_id_21
6366       ,anc_id_22
6367       ,anc_id_23
6368       ,anc_id_24
6369       ,anc_id_25
6370       ,anc_id_26
6371       ,anc_id_27
6372       ,anc_id_28
6373       ,anc_id_29
6374       ,anc_id_30
6375       ,anc_id_31
6376       ,anc_id_32
6377       ,anc_id_33
6378       ,anc_id_34
6379       ,anc_id_35
6380       ,anc_id_36
6381       ,anc_id_37
6382       ,anc_id_38
6383       ,anc_id_39
6384       ,anc_id_40
6385       ,anc_id_41
6386       ,anc_id_42
6387       ,anc_id_43
6388       ,anc_id_44
6389       ,anc_id_45
6390       ,anc_id_46
6391       ,anc_id_47
6392       ,anc_id_48
6393       ,anc_id_49
6394       ,anc_id_50;
6395 
6396    --
6397    l_rowcount := SQL%ROWCOUNT;
6398 
6399    IF (C_LEVEL_EVENT >= g_log_level) THEN
6400       trace
6401          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
6402          ,p_level    => C_LEVEL_EVENT
6403          ,p_module   => l_log_module);
6404    END IF;
6405 
6406    EXCEPTION
6407    WHEN OTHERS  THEN
6408 
6409      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6410           trace
6411               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
6412               ,p_level    => C_LEVEL_EXCEPTION
6413               ,p_module   => l_log_module);
6414      END IF;
6415 
6416      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
6417                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
6418                                       ,p_token_1      => 'ERROR'
6419                                       ,p_value_1      => sqlerrm
6420                                       );
6421 
6422 
6423    END;
6424 
6425 EXCEPTION
6426 WHEN xla_exceptions_pkg.application_exception THEN
6427   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6428        trace
6429            (p_msg      => 'Error. = '||sqlerrm
6430            ,p_level    => C_LEVEL_PROCEDURE
6431            ,p_module   => l_log_module);
6432   END IF;
6433   RAISE;
6434 WHEN OTHERS  THEN
6435   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
6436        trace
6437            (p_msg      => 'Error. = '||sqlerrm
6438            ,p_level    => C_LEVEL_PROCEDURE
6439            ,p_module   => l_log_module);
6440   END IF;
6441   xla_exceptions_pkg.raise_message
6442        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria50');
6443 END InsertAnalyticalCriteria50;
6444 
6445 --
6446 --
6447 /*======================================================================+
6448 | PRIVATE Procedure                                                     |
6449 |                                                                       |
6450 | InsertAnalyticalCriteria100                                            |
6451 |                                                                       |
6452 |                                                                       |
6453 +======================================================================*/
6454 --
6455 PROCEDURE InsertAnalyticalCriteria100
6456 IS
6457 l_rowcount           NUMBER;
6458 l_log_module         VARCHAR2(240);
6459 BEGIN
6460 --
6461 IF g_log_enabled THEN
6462       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria100';
6463 END IF;
6464 --
6465 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
6466 
6467       trace
6468          (p_msg      => 'BEGIN of InsertAnalyticalCriteria100'
6469          ,p_level    => C_LEVEL_PROCEDURE
6470          ,p_module   => l_log_module);
6471 END IF;
6472 
6473 l_rowcount  := 0;
6474 
6475 BEGIN
6476 
6477    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
6478 
6479       trace
6480          (p_msg      => 'SQL - Insert into xla_ae_line_acs'
6481          ,p_level    => C_LEVEL_STATEMENT
6482          ,p_module   => l_log_module);
6483 
6484    END IF;
6485 
6486 INSERT ALL
6487 WHEN anc_id_1 IS NOT NULL THEN
6488   INTO xla_ae_line_acs (
6489         ae_header_id , ae_line_num , object_version_number
6490       , analytical_criterion_code
6491       , analytical_criterion_type_code
6492       , amb_context_code
6493       , ac1,ac2,ac3,ac4,ac5)
6494 VALUES (ae_header_id, ae_line_num, C_OVN
6495 ,SUBSTRB(anc_id_1
6496        ,1
6497        ,INSTRB(anc_id_1,'(]',1,1) -1)
6498 ,SUBSTRB(anc_id_1
6499        ,INSTRB(anc_id_1,'(]',1,1) + 2
6500        ,INSTRB(anc_id_1,'(]',1,2) -
6501         INSTRB(anc_id_1,'(]',1,1) - 2)
6502 ,SUBSTRB(anc_id_1
6503        ,INSTRB(anc_id_1,'(]',1,2) + 2
6504        ,INSTRB(anc_id_1,'(]',1,3) -
6505         INSTRB(anc_id_1,'(]',1,2) - 2)
6506 ,SUBSTRB(anc_id_1
6507        ,INSTRB(anc_id_1,'(]',1,3) + 2
6508        ,INSTRB(anc_id_1,'(]',1,4) -
6509         INSTRB(anc_id_1,'(]',1,3) - 2)
6510 ,SUBSTRB(anc_id_1
6511        ,INSTRB(anc_id_1,'(]',1,4) + 2
6512        ,INSTRB(anc_id_1,'(]',1,5) -
6513         INSTRB(anc_id_1,'(]',1,4) - 2)
6514 ,SUBSTRB(anc_id_1
6515        ,INSTRB(anc_id_1,'(]',1,5) + 2
6516        ,INSTRB(anc_id_1,'(]',1,6) -
6517         INSTRB(anc_id_1,'(]',1,5) - 2)
6518 ,SUBSTRB(anc_id_1
6519        ,INSTRB(anc_id_1,'(]',1,6) + 2
6520        ,INSTRB(anc_id_1,'(]',1,7) -
6521         INSTRB(anc_id_1,'(]',1,6) - 2)
6522 ,SUBSTRB(anc_id_1
6523        ,INSTRB(anc_id_1,'(]',1,7) + 2
6524        ,LENGTHB(anc_id_1))
6525 )
6526 
6527 WHEN anc_id_2 IS NOT NULL THEN
6528   INTO xla_ae_line_acs (
6529         ae_header_id , ae_line_num , object_version_number
6530       , analytical_criterion_code
6531       , analytical_criterion_type_code
6532       , amb_context_code
6533       , ac1,ac2,ac3,ac4,ac5)
6534 VALUES (ae_header_id, ae_line_num, C_OVN
6535 ,SUBSTRB(anc_id_2
6536        ,1
6537        ,INSTRB(anc_id_2,'(]',1,1) -1)
6538 ,SUBSTRB(anc_id_2
6539        ,INSTRB(anc_id_2,'(]',1,1) + 2
6540        ,INSTRB(anc_id_2,'(]',1,2) -
6541         INSTRB(anc_id_2,'(]',1,1) - 2)
6542 ,SUBSTRB(anc_id_2
6543        ,INSTRB(anc_id_2,'(]',1,2) + 2
6544        ,INSTRB(anc_id_2,'(]',1,3) -
6545         INSTRB(anc_id_2,'(]',1,2) - 2)
6546 ,SUBSTRB(anc_id_2
6547        ,INSTRB(anc_id_2,'(]',1,3) + 2
6548        ,INSTRB(anc_id_2,'(]',1,4) -
6549         INSTRB(anc_id_2,'(]',1,3) - 2)
6550 ,SUBSTRB(anc_id_2
6551        ,INSTRB(anc_id_2,'(]',1,4) + 2
6552        ,INSTRB(anc_id_2,'(]',1,5) -
6553         INSTRB(anc_id_2,'(]',1,4) - 2)
6554 ,SUBSTRB(anc_id_2
6555        ,INSTRB(anc_id_2,'(]',1,5) + 2
6556        ,INSTRB(anc_id_2,'(]',1,6) -
6557         INSTRB(anc_id_2,'(]',1,5) - 2)
6558 ,SUBSTRB(anc_id_2
6559        ,INSTRB(anc_id_2,'(]',1,6) + 2
6560        ,INSTRB(anc_id_2,'(]',1,7) -
6561         INSTRB(anc_id_2,'(]',1,6) - 2)
6562 ,SUBSTRB(anc_id_2
6563        ,INSTRB(anc_id_2,'(]',1,7) + 2
6564        ,LENGTHB(anc_id_2))
6565 )
6566 
6567 WHEN anc_id_3 IS NOT NULL THEN
6568   INTO xla_ae_line_acs (
6569         ae_header_id , ae_line_num , object_version_number
6570       , analytical_criterion_code
6571       , analytical_criterion_type_code
6572       , amb_context_code
6573       , ac1,ac2,ac3,ac4,ac5)
6574 VALUES (ae_header_id, ae_line_num, C_OVN
6575 ,SUBSTRB(anc_id_3
6576        ,1
6577        ,INSTRB(anc_id_3,'(]',1,1) -1)
6578 ,SUBSTRB(anc_id_3
6579        ,INSTRB(anc_id_3,'(]',1,1) + 2
6580        ,INSTRB(anc_id_3,'(]',1,2) -
6581         INSTRB(anc_id_3,'(]',1,1) - 2)
6582 ,SUBSTRB(anc_id_3
6583        ,INSTRB(anc_id_3,'(]',1,2) + 2
6584        ,INSTRB(anc_id_3,'(]',1,3) -
6585         INSTRB(anc_id_3,'(]',1,2) - 2)
6586 ,SUBSTRB(anc_id_3
6587        ,INSTRB(anc_id_3,'(]',1,3) + 2
6588        ,INSTRB(anc_id_3,'(]',1,4) -
6589         INSTRB(anc_id_3,'(]',1,3) - 2)
6590 ,SUBSTRB(anc_id_3
6591        ,INSTRB(anc_id_3,'(]',1,4) + 2
6592        ,INSTRB(anc_id_3,'(]',1,5) -
6593         INSTRB(anc_id_3,'(]',1,4) - 2)
6594 ,SUBSTRB(anc_id_3
6595        ,INSTRB(anc_id_3,'(]',1,5) + 2
6596        ,INSTRB(anc_id_3,'(]',1,6) -
6597         INSTRB(anc_id_3,'(]',1,5) - 2)
6598 ,SUBSTRB(anc_id_3
6599        ,INSTRB(anc_id_3,'(]',1,6) + 2
6600        ,INSTRB(anc_id_3,'(]',1,7) -
6601         INSTRB(anc_id_3,'(]',1,6) - 2)
6602 ,SUBSTRB(anc_id_3
6603        ,INSTRB(anc_id_3,'(]',1,7) + 2
6604        ,LENGTHB(anc_id_3))
6605 )
6606 
6607 WHEN anc_id_4 IS NOT NULL THEN
6608   INTO xla_ae_line_acs (
6609         ae_header_id , ae_line_num , object_version_number
6610       , analytical_criterion_code
6611       , analytical_criterion_type_code
6612       , amb_context_code
6613       , ac1,ac2,ac3,ac4,ac5)
6614 VALUES (ae_header_id, ae_line_num, C_OVN
6615 ,SUBSTRB(anc_id_4
6616        ,1
6617        ,INSTRB(anc_id_4,'(]',1,1) -1)
6618 ,SUBSTRB(anc_id_4
6619        ,INSTRB(anc_id_4,'(]',1,1) + 2
6620        ,INSTRB(anc_id_4,'(]',1,2) -
6621         INSTRB(anc_id_4,'(]',1,1) - 2)
6622 ,SUBSTRB(anc_id_4
6623        ,INSTRB(anc_id_4,'(]',1,2) + 2
6624        ,INSTRB(anc_id_4,'(]',1,3) -
6625         INSTRB(anc_id_4,'(]',1,2) - 2)
6626 ,SUBSTRB(anc_id_4
6627        ,INSTRB(anc_id_4,'(]',1,3) + 2
6628        ,INSTRB(anc_id_4,'(]',1,4) -
6629         INSTRB(anc_id_4,'(]',1,3) - 2)
6630 ,SUBSTRB(anc_id_4
6631        ,INSTRB(anc_id_4,'(]',1,4) + 2
6632        ,INSTRB(anc_id_4,'(]',1,5) -
6633         INSTRB(anc_id_4,'(]',1,4) - 2)
6634 ,SUBSTRB(anc_id_4
6635        ,INSTRB(anc_id_4,'(]',1,5) + 2
6636        ,INSTRB(anc_id_4,'(]',1,6) -
6637         INSTRB(anc_id_4,'(]',1,5) - 2)
6638 ,SUBSTRB(anc_id_4
6639        ,INSTRB(anc_id_4,'(]',1,6) + 2
6640        ,INSTRB(anc_id_4,'(]',1,7) -
6641         INSTRB(anc_id_4,'(]',1,6) - 2)
6642 ,SUBSTRB(anc_id_4
6643        ,INSTRB(anc_id_4,'(]',1,7) + 2
6644        ,LENGTHB(anc_id_4))
6645 )
6646 
6647 WHEN anc_id_5 IS NOT NULL THEN
6648   INTO xla_ae_line_acs (
6649         ae_header_id , ae_line_num , object_version_number
6650       , analytical_criterion_code
6651       , analytical_criterion_type_code
6652       , amb_context_code
6653       , ac1,ac2,ac3,ac4,ac5)
6654 VALUES (ae_header_id, ae_line_num, C_OVN
6655 ,SUBSTRB(anc_id_5
6656        ,1
6657        ,INSTRB(anc_id_5,'(]',1,1) -1)
6658 ,SUBSTRB(anc_id_5
6659        ,INSTRB(anc_id_5,'(]',1,1) + 2
6660        ,INSTRB(anc_id_5,'(]',1,2) -
6661         INSTRB(anc_id_5,'(]',1,1) - 2)
6662 ,SUBSTRB(anc_id_5
6663        ,INSTRB(anc_id_5,'(]',1,2) + 2
6664        ,INSTRB(anc_id_5,'(]',1,3) -
6665         INSTRB(anc_id_5,'(]',1,2) - 2)
6666 ,SUBSTRB(anc_id_5
6667        ,INSTRB(anc_id_5,'(]',1,3) + 2
6668        ,INSTRB(anc_id_5,'(]',1,4) -
6669         INSTRB(anc_id_5,'(]',1,3) - 2)
6670 ,SUBSTRB(anc_id_5
6671        ,INSTRB(anc_id_5,'(]',1,4) + 2
6672        ,INSTRB(anc_id_5,'(]',1,5) -
6673         INSTRB(anc_id_5,'(]',1,4) - 2)
6674 ,SUBSTRB(anc_id_5
6675        ,INSTRB(anc_id_5,'(]',1,5) + 2
6676        ,INSTRB(anc_id_5,'(]',1,6) -
6677         INSTRB(anc_id_5,'(]',1,5) - 2)
6678 ,SUBSTRB(anc_id_5
6679        ,INSTRB(anc_id_5,'(]',1,6) + 2
6680        ,INSTRB(anc_id_5,'(]',1,7) -
6681         INSTRB(anc_id_5,'(]',1,6) - 2)
6682 ,SUBSTRB(anc_id_5
6683        ,INSTRB(anc_id_5,'(]',1,7) + 2
6684        ,LENGTHB(anc_id_5))
6685 )
6686 
6687 WHEN anc_id_6 IS NOT NULL THEN
6688   INTO xla_ae_line_acs (
6689         ae_header_id , ae_line_num , object_version_number
6690       , analytical_criterion_code
6691       , analytical_criterion_type_code
6692       , amb_context_code
6693       , ac1,ac2,ac3,ac4,ac5)
6694 VALUES (ae_header_id, ae_line_num, C_OVN
6695 ,SUBSTRB(anc_id_6
6696        ,1
6697        ,INSTRB(anc_id_6,'(]',1,1) -1)
6698 ,SUBSTRB(anc_id_6
6699        ,INSTRB(anc_id_6,'(]',1,1) + 2
6700        ,INSTRB(anc_id_6,'(]',1,2) -
6701         INSTRB(anc_id_6,'(]',1,1) - 2)
6702 ,SUBSTRB(anc_id_6
6703        ,INSTRB(anc_id_6,'(]',1,2) + 2
6704        ,INSTRB(anc_id_6,'(]',1,3) -
6705         INSTRB(anc_id_6,'(]',1,2) - 2)
6706 ,SUBSTRB(anc_id_6
6707        ,INSTRB(anc_id_6,'(]',1,3) + 2
6708        ,INSTRB(anc_id_6,'(]',1,4) -
6709         INSTRB(anc_id_6,'(]',1,3) - 2)
6710 ,SUBSTRB(anc_id_6
6711        ,INSTRB(anc_id_6,'(]',1,4) + 2
6712        ,INSTRB(anc_id_6,'(]',1,5) -
6713         INSTRB(anc_id_6,'(]',1,4) - 2)
6714 ,SUBSTRB(anc_id_6
6715        ,INSTRB(anc_id_6,'(]',1,5) + 2
6716        ,INSTRB(anc_id_6,'(]',1,6) -
6717         INSTRB(anc_id_6,'(]',1,5) - 2)
6718 ,SUBSTRB(anc_id_6
6719        ,INSTRB(anc_id_6,'(]',1,6) + 2
6720        ,INSTRB(anc_id_6,'(]',1,7) -
6721         INSTRB(anc_id_6,'(]',1,6) - 2)
6722 ,SUBSTRB(anc_id_6
6723        ,INSTRB(anc_id_6,'(]',1,7) + 2
6724        ,LENGTHB(anc_id_6))
6725 )
6726 
6727 WHEN anc_id_7 IS NOT NULL THEN
6728   INTO xla_ae_line_acs (
6729         ae_header_id , ae_line_num , object_version_number
6730       , analytical_criterion_code
6731       , analytical_criterion_type_code
6732       , amb_context_code
6733       , ac1,ac2,ac3,ac4,ac5)
6734 VALUES (ae_header_id, ae_line_num, C_OVN
6735 ,SUBSTRB(anc_id_7
6736        ,1
6737        ,INSTRB(anc_id_7,'(]',1,1) -1)
6738 ,SUBSTRB(anc_id_7
6739        ,INSTRB(anc_id_7,'(]',1,1) + 2
6740        ,INSTRB(anc_id_7,'(]',1,2) -
6741         INSTRB(anc_id_7,'(]',1,1) - 2)
6742 ,SUBSTRB(anc_id_7
6743        ,INSTRB(anc_id_7,'(]',1,2) + 2
6744        ,INSTRB(anc_id_7,'(]',1,3) -
6745         INSTRB(anc_id_7,'(]',1,2) - 2)
6746 ,SUBSTRB(anc_id_7
6747        ,INSTRB(anc_id_7,'(]',1,3) + 2
6748        ,INSTRB(anc_id_7,'(]',1,4) -
6749         INSTRB(anc_id_7,'(]',1,3) - 2)
6750 ,SUBSTRB(anc_id_7
6751        ,INSTRB(anc_id_7,'(]',1,4) + 2
6752        ,INSTRB(anc_id_7,'(]',1,5) -
6753         INSTRB(anc_id_7,'(]',1,4) - 2)
6754 ,SUBSTRB(anc_id_7
6755        ,INSTRB(anc_id_7,'(]',1,5) + 2
6756        ,INSTRB(anc_id_7,'(]',1,6) -
6757         INSTRB(anc_id_7,'(]',1,5) - 2)
6758 ,SUBSTRB(anc_id_7
6759        ,INSTRB(anc_id_7,'(]',1,6) + 2
6760        ,INSTRB(anc_id_7,'(]',1,7) -
6761         INSTRB(anc_id_7,'(]',1,6) - 2)
6762 ,SUBSTRB(anc_id_7
6763        ,INSTRB(anc_id_7,'(]',1,7) + 2
6764        ,LENGTHB(anc_id_7))
6765 )
6766 
6767 WHEN anc_id_8 IS NOT NULL THEN
6768   INTO xla_ae_line_acs (
6769         ae_header_id , ae_line_num , object_version_number
6770       , analytical_criterion_code
6771       , analytical_criterion_type_code
6772       , amb_context_code
6773       , ac1,ac2,ac3,ac4,ac5)
6774 VALUES (ae_header_id, ae_line_num, C_OVN
6775 ,SUBSTRB(anc_id_8
6776        ,1
6777        ,INSTRB(anc_id_8,'(]',1,1) -1)
6778 ,SUBSTRB(anc_id_8
6779        ,INSTRB(anc_id_8,'(]',1,1) + 2
6780        ,INSTRB(anc_id_8,'(]',1,2) -
6781         INSTRB(anc_id_8,'(]',1,1) - 2)
6782 ,SUBSTRB(anc_id_8
6783        ,INSTRB(anc_id_8,'(]',1,2) + 2
6784        ,INSTRB(anc_id_8,'(]',1,3) -
6785         INSTRB(anc_id_8,'(]',1,2) - 2)
6786 ,SUBSTRB(anc_id_8
6787        ,INSTRB(anc_id_8,'(]',1,3) + 2
6788        ,INSTRB(anc_id_8,'(]',1,4) -
6789         INSTRB(anc_id_8,'(]',1,3) - 2)
6790 ,SUBSTRB(anc_id_8
6791        ,INSTRB(anc_id_8,'(]',1,4) + 2
6792        ,INSTRB(anc_id_8,'(]',1,5) -
6793         INSTRB(anc_id_8,'(]',1,4) - 2)
6794 ,SUBSTRB(anc_id_8
6795        ,INSTRB(anc_id_8,'(]',1,5) + 2
6796        ,INSTRB(anc_id_8,'(]',1,6) -
6797         INSTRB(anc_id_8,'(]',1,5) - 2)
6798 ,SUBSTRB(anc_id_8
6799        ,INSTRB(anc_id_8,'(]',1,6) + 2
6800        ,INSTRB(anc_id_8,'(]',1,7) -
6801         INSTRB(anc_id_8,'(]',1,6) - 2)
6802 ,SUBSTRB(anc_id_8
6803        ,INSTRB(anc_id_8,'(]',1,7) + 2
6804        ,LENGTHB(anc_id_8))
6805 )
6806 
6807 WHEN anc_id_9 IS NOT NULL THEN
6808   INTO xla_ae_line_acs (
6809         ae_header_id , ae_line_num , object_version_number
6810       , analytical_criterion_code
6811       , analytical_criterion_type_code
6812       , amb_context_code
6813       , ac1,ac2,ac3,ac4,ac5)
6814 VALUES (ae_header_id, ae_line_num, C_OVN
6815 ,SUBSTRB(anc_id_9
6816        ,1
6817        ,INSTRB(anc_id_9,'(]',1,1) -1)
6818 ,SUBSTRB(anc_id_9
6819        ,INSTRB(anc_id_9,'(]',1,1) + 2
6820        ,INSTRB(anc_id_9,'(]',1,2) -
6821         INSTRB(anc_id_9,'(]',1,1) - 2)
6822 ,SUBSTRB(anc_id_9
6823        ,INSTRB(anc_id_9,'(]',1,2) + 2
6824        ,INSTRB(anc_id_9,'(]',1,3) -
6825         INSTRB(anc_id_9,'(]',1,2) - 2)
6826 ,SUBSTRB(anc_id_9
6827        ,INSTRB(anc_id_9,'(]',1,3) + 2
6828        ,INSTRB(anc_id_9,'(]',1,4) -
6829         INSTRB(anc_id_9,'(]',1,3) - 2)
6830 ,SUBSTRB(anc_id_9
6831        ,INSTRB(anc_id_9,'(]',1,4) + 2
6832        ,INSTRB(anc_id_9,'(]',1,5) -
6833         INSTRB(anc_id_9,'(]',1,4) - 2)
6834 ,SUBSTRB(anc_id_9
6835        ,INSTRB(anc_id_9,'(]',1,5) + 2
6836        ,INSTRB(anc_id_9,'(]',1,6) -
6837         INSTRB(anc_id_9,'(]',1,5) - 2)
6838 ,SUBSTRB(anc_id_9
6839        ,INSTRB(anc_id_9,'(]',1,6) + 2
6840        ,INSTRB(anc_id_9,'(]',1,7) -
6841         INSTRB(anc_id_9,'(]',1,6) - 2)
6842 ,SUBSTRB(anc_id_9
6843        ,INSTRB(anc_id_9,'(]',1,7) + 2
6844        ,LENGTHB(anc_id_9))
6845 )
6846 
6847 WHEN anc_id_10 IS NOT NULL THEN
6848   INTO xla_ae_line_acs (
6849         ae_header_id , ae_line_num , object_version_number
6850       , analytical_criterion_code
6851       , analytical_criterion_type_code
6852       , amb_context_code
6853       , ac1,ac2,ac3,ac4,ac5)
6854 VALUES (ae_header_id, ae_line_num, C_OVN
6855 ,SUBSTRB(anc_id_10
6856        ,1
6857        ,INSTRB(anc_id_10,'(]',1,1) -1)
6858 ,SUBSTRB(anc_id_10
6859        ,INSTRB(anc_id_10,'(]',1,1) + 2
6860        ,INSTRB(anc_id_10,'(]',1,2) -
6861         INSTRB(anc_id_10,'(]',1,1) - 2)
6862 ,SUBSTRB(anc_id_10
6863        ,INSTRB(anc_id_10,'(]',1,2) + 2
6864        ,INSTRB(anc_id_10,'(]',1,3) -
6865         INSTRB(anc_id_10,'(]',1,2) - 2)
6866 ,SUBSTRB(anc_id_10
6867        ,INSTRB(anc_id_10,'(]',1,3) + 2
6868        ,INSTRB(anc_id_10,'(]',1,4) -
6869         INSTRB(anc_id_10,'(]',1,3) - 2)
6870 ,SUBSTRB(anc_id_10
6871        ,INSTRB(anc_id_10,'(]',1,4) + 2
6872        ,INSTRB(anc_id_10,'(]',1,5) -
6873         INSTRB(anc_id_10,'(]',1,4) - 2)
6874 ,SUBSTRB(anc_id_10
6875        ,INSTRB(anc_id_10,'(]',1,5) + 2
6876        ,INSTRB(anc_id_10,'(]',1,6) -
6877         INSTRB(anc_id_10,'(]',1,5) - 2)
6878 ,SUBSTRB(anc_id_10
6879        ,INSTRB(anc_id_10,'(]',1,6) + 2
6880        ,INSTRB(anc_id_10,'(]',1,7) -
6881         INSTRB(anc_id_10,'(]',1,6) - 2)
6882 ,SUBSTRB(anc_id_10
6883        ,INSTRB(anc_id_10,'(]',1,7) + 2
6884        ,LENGTHB(anc_id_10))
6885 )
6886 
6887 WHEN anc_id_11 IS NOT NULL THEN
6888   INTO xla_ae_line_acs (
6889         ae_header_id , ae_line_num , object_version_number
6890       , analytical_criterion_code
6891       , analytical_criterion_type_code
6892       , amb_context_code
6893       , ac1,ac2,ac3,ac4,ac5)
6894 VALUES (ae_header_id, ae_line_num, C_OVN
6895 ,SUBSTRB(anc_id_11
6896        ,1
6897        ,INSTRB(anc_id_11,'(]',1,1) -1)
6898 ,SUBSTRB(anc_id_11
6899        ,INSTRB(anc_id_11,'(]',1,1) + 2
6900        ,INSTRB(anc_id_11,'(]',1,2) -
6901         INSTRB(anc_id_11,'(]',1,1) - 2)
6902 ,SUBSTRB(anc_id_11
6903        ,INSTRB(anc_id_11,'(]',1,2) + 2
6904        ,INSTRB(anc_id_11,'(]',1,3) -
6905         INSTRB(anc_id_11,'(]',1,2) - 2)
6906 ,SUBSTRB(anc_id_11
6907        ,INSTRB(anc_id_11,'(]',1,3) + 2
6908        ,INSTRB(anc_id_11,'(]',1,4) -
6909         INSTRB(anc_id_11,'(]',1,3) - 2)
6910 ,SUBSTRB(anc_id_11
6911        ,INSTRB(anc_id_11,'(]',1,4) + 2
6912        ,INSTRB(anc_id_11,'(]',1,5) -
6913         INSTRB(anc_id_11,'(]',1,4) - 2)
6914 ,SUBSTRB(anc_id_11
6915        ,INSTRB(anc_id_11,'(]',1,5) + 2
6916        ,INSTRB(anc_id_11,'(]',1,6) -
6917         INSTRB(anc_id_11,'(]',1,5) - 2)
6918 ,SUBSTRB(anc_id_11
6919        ,INSTRB(anc_id_11,'(]',1,6) + 2
6920        ,INSTRB(anc_id_11,'(]',1,7) -
6921         INSTRB(anc_id_11,'(]',1,6) - 2)
6922 ,SUBSTRB(anc_id_11
6923        ,INSTRB(anc_id_11,'(]',1,7) + 2
6924        ,LENGTHB(anc_id_11))
6925 )
6926 
6927 WHEN anc_id_12 IS NOT NULL THEN
6928   INTO xla_ae_line_acs (
6929         ae_header_id , ae_line_num , object_version_number
6930       , analytical_criterion_code
6931       , analytical_criterion_type_code
6932       , amb_context_code
6933       , ac1,ac2,ac3,ac4,ac5)
6934 VALUES (ae_header_id, ae_line_num, C_OVN
6935 ,SUBSTRB(anc_id_12
6936        ,1
6937        ,INSTRB(anc_id_12,'(]',1,1) -1)
6938 ,SUBSTRB(anc_id_12
6939        ,INSTRB(anc_id_12,'(]',1,1) + 2
6940        ,INSTRB(anc_id_12,'(]',1,2) -
6941         INSTRB(anc_id_12,'(]',1,1) - 2)
6942 ,SUBSTRB(anc_id_12
6943        ,INSTRB(anc_id_12,'(]',1,2) + 2
6944        ,INSTRB(anc_id_12,'(]',1,3) -
6945         INSTRB(anc_id_12,'(]',1,2) - 2)
6946 ,SUBSTRB(anc_id_12
6947        ,INSTRB(anc_id_12,'(]',1,3) + 2
6948        ,INSTRB(anc_id_12,'(]',1,4) -
6949         INSTRB(anc_id_12,'(]',1,3) - 2)
6950 ,SUBSTRB(anc_id_12
6951        ,INSTRB(anc_id_12,'(]',1,4) + 2
6952        ,INSTRB(anc_id_12,'(]',1,5) -
6953         INSTRB(anc_id_12,'(]',1,4) - 2)
6954 ,SUBSTRB(anc_id_12
6955        ,INSTRB(anc_id_12,'(]',1,5) + 2
6956        ,INSTRB(anc_id_12,'(]',1,6) -
6957         INSTRB(anc_id_12,'(]',1,5) - 2)
6958 ,SUBSTRB(anc_id_12
6959        ,INSTRB(anc_id_12,'(]',1,6) + 2
6960        ,INSTRB(anc_id_12,'(]',1,7) -
6961         INSTRB(anc_id_12,'(]',1,6) - 2)
6962 ,SUBSTRB(anc_id_12
6963        ,INSTRB(anc_id_12,'(]',1,7) + 2
6964        ,LENGTHB(anc_id_12))
6965 )
6966 
6967 WHEN anc_id_13 IS NOT NULL THEN
6968   INTO xla_ae_line_acs (
6969         ae_header_id , ae_line_num , object_version_number
6970       , analytical_criterion_code
6971       , analytical_criterion_type_code
6972       , amb_context_code
6973       , ac1,ac2,ac3,ac4,ac5)
6974 VALUES (ae_header_id, ae_line_num, C_OVN
6975 ,SUBSTRB(anc_id_13
6976        ,1
6977        ,INSTRB(anc_id_13,'(]',1,1) -1)
6978 ,SUBSTRB(anc_id_13
6979        ,INSTRB(anc_id_13,'(]',1,1) + 2
6980        ,INSTRB(anc_id_13,'(]',1,2) -
6981         INSTRB(anc_id_13,'(]',1,1) - 2)
6982 ,SUBSTRB(anc_id_13
6983        ,INSTRB(anc_id_13,'(]',1,2) + 2
6984        ,INSTRB(anc_id_13,'(]',1,3) -
6985         INSTRB(anc_id_13,'(]',1,2) - 2)
6986 ,SUBSTRB(anc_id_13
6987        ,INSTRB(anc_id_13,'(]',1,3) + 2
6988        ,INSTRB(anc_id_13,'(]',1,4) -
6989         INSTRB(anc_id_13,'(]',1,3) - 2)
6990 ,SUBSTRB(anc_id_13
6991        ,INSTRB(anc_id_13,'(]',1,4) + 2
6992        ,INSTRB(anc_id_13,'(]',1,5) -
6993         INSTRB(anc_id_13,'(]',1,4) - 2)
6994 ,SUBSTRB(anc_id_13
6995        ,INSTRB(anc_id_13,'(]',1,5) + 2
6996        ,INSTRB(anc_id_13,'(]',1,6) -
6997         INSTRB(anc_id_13,'(]',1,5) - 2)
6998 ,SUBSTRB(anc_id_13
6999        ,INSTRB(anc_id_13,'(]',1,6) + 2
7000        ,INSTRB(anc_id_13,'(]',1,7) -
7001         INSTRB(anc_id_13,'(]',1,6) - 2)
7002 ,SUBSTRB(anc_id_13
7003        ,INSTRB(anc_id_13,'(]',1,7) + 2
7004        ,LENGTHB(anc_id_13))
7005 )
7006 
7007 WHEN anc_id_14 IS NOT NULL THEN
7008   INTO xla_ae_line_acs (
7009         ae_header_id , ae_line_num , object_version_number
7010       , analytical_criterion_code
7011       , analytical_criterion_type_code
7012       , amb_context_code
7013       , ac1,ac2,ac3,ac4,ac5)
7014 VALUES (ae_header_id, ae_line_num, C_OVN
7015 ,SUBSTRB(anc_id_14
7016        ,1
7017        ,INSTRB(anc_id_14,'(]',1,1) -1)
7018 ,SUBSTRB(anc_id_14
7019        ,INSTRB(anc_id_14,'(]',1,1) + 2
7020        ,INSTRB(anc_id_14,'(]',1,2) -
7021         INSTRB(anc_id_14,'(]',1,1) - 2)
7022 ,SUBSTRB(anc_id_14
7023        ,INSTRB(anc_id_14,'(]',1,2) + 2
7024        ,INSTRB(anc_id_14,'(]',1,3) -
7025         INSTRB(anc_id_14,'(]',1,2) - 2)
7026 ,SUBSTRB(anc_id_14
7027        ,INSTRB(anc_id_14,'(]',1,3) + 2
7028        ,INSTRB(anc_id_14,'(]',1,4) -
7029         INSTRB(anc_id_14,'(]',1,3) - 2)
7030 ,SUBSTRB(anc_id_14
7031        ,INSTRB(anc_id_14,'(]',1,4) + 2
7032        ,INSTRB(anc_id_14,'(]',1,5) -
7033         INSTRB(anc_id_14,'(]',1,4) - 2)
7034 ,SUBSTRB(anc_id_14
7035        ,INSTRB(anc_id_14,'(]',1,5) + 2
7036        ,INSTRB(anc_id_14,'(]',1,6) -
7037         INSTRB(anc_id_14,'(]',1,5) - 2)
7038 ,SUBSTRB(anc_id_14
7039        ,INSTRB(anc_id_14,'(]',1,6) + 2
7040        ,INSTRB(anc_id_14,'(]',1,7) -
7041         INSTRB(anc_id_14,'(]',1,6) - 2)
7042 ,SUBSTRB(anc_id_14
7043        ,INSTRB(anc_id_14,'(]',1,7) + 2
7044        ,LENGTHB(anc_id_14))
7045 )
7046 
7047 WHEN anc_id_15 IS NOT NULL THEN
7048   INTO xla_ae_line_acs (
7049         ae_header_id , ae_line_num , object_version_number
7050       , analytical_criterion_code
7051       , analytical_criterion_type_code
7052       , amb_context_code
7053       , ac1,ac2,ac3,ac4,ac5)
7054 VALUES (ae_header_id, ae_line_num, C_OVN
7055 ,SUBSTRB(anc_id_15
7056        ,1
7057        ,INSTRB(anc_id_15,'(]',1,1) -1)
7058 ,SUBSTRB(anc_id_15
7059        ,INSTRB(anc_id_15,'(]',1,1) + 2
7060        ,INSTRB(anc_id_15,'(]',1,2) -
7061         INSTRB(anc_id_15,'(]',1,1) - 2)
7062 ,SUBSTRB(anc_id_15
7063        ,INSTRB(anc_id_15,'(]',1,2) + 2
7064        ,INSTRB(anc_id_15,'(]',1,3) -
7065         INSTRB(anc_id_15,'(]',1,2) - 2)
7066 ,SUBSTRB(anc_id_15
7067        ,INSTRB(anc_id_15,'(]',1,3) + 2
7068        ,INSTRB(anc_id_15,'(]',1,4) -
7069         INSTRB(anc_id_15,'(]',1,3) - 2)
7070 ,SUBSTRB(anc_id_15
7071        ,INSTRB(anc_id_15,'(]',1,4) + 2
7072        ,INSTRB(anc_id_15,'(]',1,5) -
7073         INSTRB(anc_id_15,'(]',1,4) - 2)
7074 ,SUBSTRB(anc_id_15
7075        ,INSTRB(anc_id_15,'(]',1,5) + 2
7076        ,INSTRB(anc_id_15,'(]',1,6) -
7077         INSTRB(anc_id_15,'(]',1,5) - 2)
7078 ,SUBSTRB(anc_id_15
7079        ,INSTRB(anc_id_15,'(]',1,6) + 2
7080        ,INSTRB(anc_id_15,'(]',1,7) -
7081         INSTRB(anc_id_15,'(]',1,6) - 2)
7082 ,SUBSTRB(anc_id_15
7083        ,INSTRB(anc_id_15,'(]',1,7) + 2
7084        ,LENGTHB(anc_id_15))
7085 )
7086 
7087 WHEN anc_id_16 IS NOT NULL THEN
7088   INTO xla_ae_line_acs (
7089         ae_header_id , ae_line_num , object_version_number
7090       , analytical_criterion_code
7091       , analytical_criterion_type_code
7092       , amb_context_code
7093       , ac1,ac2,ac3,ac4,ac5)
7094 VALUES (ae_header_id, ae_line_num, C_OVN
7095 ,SUBSTRB(anc_id_16
7096        ,1
7097        ,INSTRB(anc_id_16,'(]',1,1) -1)
7098 ,SUBSTRB(anc_id_16
7099        ,INSTRB(anc_id_16,'(]',1,1) + 2
7100        ,INSTRB(anc_id_16,'(]',1,2) -
7101         INSTRB(anc_id_16,'(]',1,1) - 2)
7102 ,SUBSTRB(anc_id_16
7103        ,INSTRB(anc_id_16,'(]',1,2) + 2
7104        ,INSTRB(anc_id_16,'(]',1,3) -
7105         INSTRB(anc_id_16,'(]',1,2) - 2)
7106 ,SUBSTRB(anc_id_16
7107        ,INSTRB(anc_id_16,'(]',1,3) + 2
7108        ,INSTRB(anc_id_16,'(]',1,4) -
7109         INSTRB(anc_id_16,'(]',1,3) - 2)
7110 ,SUBSTRB(anc_id_16
7111        ,INSTRB(anc_id_16,'(]',1,4) + 2
7112        ,INSTRB(anc_id_16,'(]',1,5) -
7113         INSTRB(anc_id_16,'(]',1,4) - 2)
7114 ,SUBSTRB(anc_id_16
7115        ,INSTRB(anc_id_16,'(]',1,5) + 2
7116        ,INSTRB(anc_id_16,'(]',1,6) -
7117         INSTRB(anc_id_16,'(]',1,5) - 2)
7118 ,SUBSTRB(anc_id_16
7119        ,INSTRB(anc_id_16,'(]',1,6) + 2
7120        ,INSTRB(anc_id_16,'(]',1,7) -
7121         INSTRB(anc_id_16,'(]',1,6) - 2)
7122 ,SUBSTRB(anc_id_16
7123        ,INSTRB(anc_id_16,'(]',1,7) + 2
7124        ,LENGTHB(anc_id_16))
7125 )
7126 
7127 WHEN anc_id_17 IS NOT NULL THEN
7128   INTO xla_ae_line_acs (
7129         ae_header_id , ae_line_num , object_version_number
7130       , analytical_criterion_code
7131       , analytical_criterion_type_code
7132       , amb_context_code
7133       , ac1,ac2,ac3,ac4,ac5)
7134 VALUES (ae_header_id, ae_line_num, C_OVN
7135 ,SUBSTRB(anc_id_17
7136        ,1
7137        ,INSTRB(anc_id_17,'(]',1,1) -1)
7138 ,SUBSTRB(anc_id_17
7139        ,INSTRB(anc_id_17,'(]',1,1) + 2
7140        ,INSTRB(anc_id_17,'(]',1,2) -
7141         INSTRB(anc_id_17,'(]',1,1) - 2)
7142 ,SUBSTRB(anc_id_17
7143        ,INSTRB(anc_id_17,'(]',1,2) + 2
7144        ,INSTRB(anc_id_17,'(]',1,3) -
7145         INSTRB(anc_id_17,'(]',1,2) - 2)
7146 ,SUBSTRB(anc_id_17
7147        ,INSTRB(anc_id_17,'(]',1,3) + 2
7148        ,INSTRB(anc_id_17,'(]',1,4) -
7149         INSTRB(anc_id_17,'(]',1,3) - 2)
7150 ,SUBSTRB(anc_id_17
7151        ,INSTRB(anc_id_17,'(]',1,4) + 2
7152        ,INSTRB(anc_id_17,'(]',1,5) -
7153         INSTRB(anc_id_17,'(]',1,4) - 2)
7154 ,SUBSTRB(anc_id_17
7155        ,INSTRB(anc_id_17,'(]',1,5) + 2
7156        ,INSTRB(anc_id_17,'(]',1,6) -
7157         INSTRB(anc_id_17,'(]',1,5) - 2)
7158 ,SUBSTRB(anc_id_17
7159        ,INSTRB(anc_id_17,'(]',1,6) + 2
7160        ,INSTRB(anc_id_17,'(]',1,7) -
7161         INSTRB(anc_id_17,'(]',1,6) - 2)
7162 ,SUBSTRB(anc_id_17
7163        ,INSTRB(anc_id_17,'(]',1,7) + 2
7164        ,LENGTHB(anc_id_17))
7165 )
7166 
7167 WHEN anc_id_18 IS NOT NULL THEN
7168   INTO xla_ae_line_acs (
7169         ae_header_id , ae_line_num , object_version_number
7170       , analytical_criterion_code
7171       , analytical_criterion_type_code
7172       , amb_context_code
7173       , ac1,ac2,ac3,ac4,ac5)
7174 VALUES (ae_header_id, ae_line_num, C_OVN
7175 ,SUBSTRB(anc_id_18
7176        ,1
7177        ,INSTRB(anc_id_18,'(]',1,1) -1)
7178 ,SUBSTRB(anc_id_18
7179        ,INSTRB(anc_id_18,'(]',1,1) + 2
7180        ,INSTRB(anc_id_18,'(]',1,2) -
7181         INSTRB(anc_id_18,'(]',1,1) - 2)
7182 ,SUBSTRB(anc_id_18
7183        ,INSTRB(anc_id_18,'(]',1,2) + 2
7184        ,INSTRB(anc_id_18,'(]',1,3) -
7185         INSTRB(anc_id_18,'(]',1,2) - 2)
7186 ,SUBSTRB(anc_id_18
7187        ,INSTRB(anc_id_18,'(]',1,3) + 2
7188        ,INSTRB(anc_id_18,'(]',1,4) -
7189         INSTRB(anc_id_18,'(]',1,3) - 2)
7190 ,SUBSTRB(anc_id_18
7191        ,INSTRB(anc_id_18,'(]',1,4) + 2
7192        ,INSTRB(anc_id_18,'(]',1,5) -
7193         INSTRB(anc_id_18,'(]',1,4) - 2)
7194 ,SUBSTRB(anc_id_18
7195        ,INSTRB(anc_id_18,'(]',1,5) + 2
7196        ,INSTRB(anc_id_18,'(]',1,6) -
7197         INSTRB(anc_id_18,'(]',1,5) - 2)
7198 ,SUBSTRB(anc_id_18
7199        ,INSTRB(anc_id_18,'(]',1,6) + 2
7200        ,INSTRB(anc_id_18,'(]',1,7) -
7201         INSTRB(anc_id_18,'(]',1,6) - 2)
7202 ,SUBSTRB(anc_id_18
7203        ,INSTRB(anc_id_18,'(]',1,7) + 2
7204        ,LENGTHB(anc_id_18))
7205 )
7206 
7207 WHEN anc_id_19 IS NOT NULL THEN
7208   INTO xla_ae_line_acs (
7209         ae_header_id , ae_line_num , object_version_number
7210       , analytical_criterion_code
7211       , analytical_criterion_type_code
7212       , amb_context_code
7213       , ac1,ac2,ac3,ac4,ac5)
7214 VALUES (ae_header_id, ae_line_num, C_OVN
7215 ,SUBSTRB(anc_id_19
7216        ,1
7217        ,INSTRB(anc_id_19,'(]',1,1) -1)
7218 ,SUBSTRB(anc_id_19
7219        ,INSTRB(anc_id_19,'(]',1,1) + 2
7220        ,INSTRB(anc_id_19,'(]',1,2) -
7221         INSTRB(anc_id_19,'(]',1,1) - 2)
7222 ,SUBSTRB(anc_id_19
7223        ,INSTRB(anc_id_19,'(]',1,2) + 2
7224        ,INSTRB(anc_id_19,'(]',1,3) -
7225         INSTRB(anc_id_19,'(]',1,2) - 2)
7226 ,SUBSTRB(anc_id_19
7227        ,INSTRB(anc_id_19,'(]',1,3) + 2
7228        ,INSTRB(anc_id_19,'(]',1,4) -
7229         INSTRB(anc_id_19,'(]',1,3) - 2)
7230 ,SUBSTRB(anc_id_19
7231        ,INSTRB(anc_id_19,'(]',1,4) + 2
7232        ,INSTRB(anc_id_19,'(]',1,5) -
7233         INSTRB(anc_id_19,'(]',1,4) - 2)
7234 ,SUBSTRB(anc_id_19
7235        ,INSTRB(anc_id_19,'(]',1,5) + 2
7236        ,INSTRB(anc_id_19,'(]',1,6) -
7237         INSTRB(anc_id_19,'(]',1,5) - 2)
7238 ,SUBSTRB(anc_id_19
7239        ,INSTRB(anc_id_19,'(]',1,6) + 2
7240        ,INSTRB(anc_id_19,'(]',1,7) -
7241         INSTRB(anc_id_19,'(]',1,6) - 2)
7242 ,SUBSTRB(anc_id_19
7243        ,INSTRB(anc_id_19,'(]',1,7) + 2
7244        ,LENGTHB(anc_id_19))
7245 )
7246 
7247 WHEN anc_id_20 IS NOT NULL THEN
7248   INTO xla_ae_line_acs (
7249         ae_header_id , ae_line_num , object_version_number
7250       , analytical_criterion_code
7251       , analytical_criterion_type_code
7252       , amb_context_code
7253       , ac1,ac2,ac3,ac4,ac5)
7254 VALUES (ae_header_id, ae_line_num, C_OVN
7255 ,SUBSTRB(anc_id_20
7256        ,1
7257        ,INSTRB(anc_id_20,'(]',1,1) -1)
7258 ,SUBSTRB(anc_id_20
7259        ,INSTRB(anc_id_20,'(]',1,1) + 2
7260        ,INSTRB(anc_id_20,'(]',1,2) -
7261         INSTRB(anc_id_20,'(]',1,1) - 2)
7262 ,SUBSTRB(anc_id_20
7263        ,INSTRB(anc_id_20,'(]',1,2) + 2
7264        ,INSTRB(anc_id_20,'(]',1,3) -
7265         INSTRB(anc_id_20,'(]',1,2) - 2)
7266 ,SUBSTRB(anc_id_20
7267        ,INSTRB(anc_id_20,'(]',1,3) + 2
7268        ,INSTRB(anc_id_20,'(]',1,4) -
7269         INSTRB(anc_id_20,'(]',1,3) - 2)
7270 ,SUBSTRB(anc_id_20
7271        ,INSTRB(anc_id_20,'(]',1,4) + 2
7272        ,INSTRB(anc_id_20,'(]',1,5) -
7273         INSTRB(anc_id_20,'(]',1,4) - 2)
7274 ,SUBSTRB(anc_id_20
7275        ,INSTRB(anc_id_20,'(]',1,5) + 2
7276        ,INSTRB(anc_id_20,'(]',1,6) -
7277         INSTRB(anc_id_20,'(]',1,5) - 2)
7278 ,SUBSTRB(anc_id_20
7279        ,INSTRB(anc_id_20,'(]',1,6) + 2
7280        ,INSTRB(anc_id_20,'(]',1,7) -
7281         INSTRB(anc_id_20,'(]',1,6) - 2)
7282 ,SUBSTRB(anc_id_20
7283        ,INSTRB(anc_id_20,'(]',1,7) + 2
7284        ,LENGTHB(anc_id_20))
7285 )
7286 
7287 WHEN anc_id_21 IS NOT NULL THEN
7288   INTO xla_ae_line_acs (
7289         ae_header_id , ae_line_num , object_version_number
7290       , analytical_criterion_code
7291       , analytical_criterion_type_code
7292       , amb_context_code
7293       , ac1,ac2,ac3,ac4,ac5)
7294 VALUES (ae_header_id, ae_line_num, C_OVN
7295 ,SUBSTRB(anc_id_21
7296        ,1
7297        ,INSTRB(anc_id_21,'(]',1,1) -1)
7298 ,SUBSTRB(anc_id_21
7299        ,INSTRB(anc_id_21,'(]',1,1) + 2
7300        ,INSTRB(anc_id_21,'(]',1,2) -
7301         INSTRB(anc_id_21,'(]',1,1) - 2)
7302 ,SUBSTRB(anc_id_21
7303        ,INSTRB(anc_id_21,'(]',1,2) + 2
7304        ,INSTRB(anc_id_21,'(]',1,3) -
7305         INSTRB(anc_id_21,'(]',1,2) - 2)
7306 ,SUBSTRB(anc_id_21
7307        ,INSTRB(anc_id_21,'(]',1,3) + 2
7308        ,INSTRB(anc_id_21,'(]',1,4) -
7309         INSTRB(anc_id_21,'(]',1,3) - 2)
7310 ,SUBSTRB(anc_id_21
7311        ,INSTRB(anc_id_21,'(]',1,4) + 2
7312        ,INSTRB(anc_id_21,'(]',1,5) -
7313         INSTRB(anc_id_21,'(]',1,4) - 2)
7314 ,SUBSTRB(anc_id_21
7315        ,INSTRB(anc_id_21,'(]',1,5) + 2
7316        ,INSTRB(anc_id_21,'(]',1,6) -
7317         INSTRB(anc_id_21,'(]',1,5) - 2)
7318 ,SUBSTRB(anc_id_21
7319        ,INSTRB(anc_id_21,'(]',1,6) + 2
7320        ,INSTRB(anc_id_21,'(]',1,7) -
7321         INSTRB(anc_id_21,'(]',1,6) - 2)
7322 ,SUBSTRB(anc_id_21
7323        ,INSTRB(anc_id_21,'(]',1,7) + 2
7324        ,LENGTHB(anc_id_21))
7325 )
7326 
7327 WHEN anc_id_22 IS NOT NULL THEN
7328   INTO xla_ae_line_acs (
7329         ae_header_id , ae_line_num , object_version_number
7330       , analytical_criterion_code
7331       , analytical_criterion_type_code
7332       , amb_context_code
7333       , ac1,ac2,ac3,ac4,ac5)
7334 VALUES (ae_header_id, ae_line_num, C_OVN
7335 ,SUBSTRB(anc_id_22
7336        ,1
7337        ,INSTRB(anc_id_22,'(]',1,1) -1)
7338 ,SUBSTRB(anc_id_22
7339        ,INSTRB(anc_id_22,'(]',1,1) + 2
7340        ,INSTRB(anc_id_22,'(]',1,2) -
7341         INSTRB(anc_id_22,'(]',1,1) - 2)
7342 ,SUBSTRB(anc_id_22
7343        ,INSTRB(anc_id_22,'(]',1,2) + 2
7344        ,INSTRB(anc_id_22,'(]',1,3) -
7345         INSTRB(anc_id_22,'(]',1,2) - 2)
7346 ,SUBSTRB(anc_id_22
7347        ,INSTRB(anc_id_22,'(]',1,3) + 2
7348        ,INSTRB(anc_id_22,'(]',1,4) -
7349         INSTRB(anc_id_22,'(]',1,3) - 2)
7350 ,SUBSTRB(anc_id_22
7351        ,INSTRB(anc_id_22,'(]',1,4) + 2
7352        ,INSTRB(anc_id_22,'(]',1,5) -
7353         INSTRB(anc_id_22,'(]',1,4) - 2)
7354 ,SUBSTRB(anc_id_22
7355        ,INSTRB(anc_id_22,'(]',1,5) + 2
7356        ,INSTRB(anc_id_22,'(]',1,6) -
7357         INSTRB(anc_id_22,'(]',1,5) - 2)
7358 ,SUBSTRB(anc_id_22
7359        ,INSTRB(anc_id_22,'(]',1,6) + 2
7360        ,INSTRB(anc_id_22,'(]',1,7) -
7361         INSTRB(anc_id_22,'(]',1,6) - 2)
7362 ,SUBSTRB(anc_id_22
7363        ,INSTRB(anc_id_22,'(]',1,7) + 2
7364        ,LENGTHB(anc_id_22))
7365 )
7366 
7367 WHEN anc_id_23 IS NOT NULL THEN
7368   INTO xla_ae_line_acs (
7369         ae_header_id , ae_line_num , object_version_number
7370       , analytical_criterion_code
7371       , analytical_criterion_type_code
7372       , amb_context_code
7373       , ac1,ac2,ac3,ac4,ac5)
7374 VALUES (ae_header_id, ae_line_num, C_OVN
7375 ,SUBSTRB(anc_id_23
7376        ,1
7377        ,INSTRB(anc_id_23,'(]',1,1) -1)
7378 ,SUBSTRB(anc_id_23
7379        ,INSTRB(anc_id_23,'(]',1,1) + 2
7380        ,INSTRB(anc_id_23,'(]',1,2) -
7381         INSTRB(anc_id_23,'(]',1,1) - 2)
7382 ,SUBSTRB(anc_id_23
7383        ,INSTRB(anc_id_23,'(]',1,2) + 2
7384        ,INSTRB(anc_id_23,'(]',1,3) -
7385         INSTRB(anc_id_23,'(]',1,2) - 2)
7386 ,SUBSTRB(anc_id_23
7387        ,INSTRB(anc_id_23,'(]',1,3) + 2
7388        ,INSTRB(anc_id_23,'(]',1,4) -
7389         INSTRB(anc_id_23,'(]',1,3) - 2)
7390 ,SUBSTRB(anc_id_23
7391        ,INSTRB(anc_id_23,'(]',1,4) + 2
7392        ,INSTRB(anc_id_23,'(]',1,5) -
7393         INSTRB(anc_id_23,'(]',1,4) - 2)
7394 ,SUBSTRB(anc_id_23
7395        ,INSTRB(anc_id_23,'(]',1,5) + 2
7396        ,INSTRB(anc_id_23,'(]',1,6) -
7397         INSTRB(anc_id_23,'(]',1,5) - 2)
7398 ,SUBSTRB(anc_id_23
7399        ,INSTRB(anc_id_23,'(]',1,6) + 2
7400        ,INSTRB(anc_id_23,'(]',1,7) -
7401         INSTRB(anc_id_23,'(]',1,6) - 2)
7402 ,SUBSTRB(anc_id_23
7403        ,INSTRB(anc_id_23,'(]',1,7) + 2
7404        ,LENGTHB(anc_id_23))
7405 )
7406 
7407 WHEN anc_id_24 IS NOT NULL THEN
7408   INTO xla_ae_line_acs (
7409         ae_header_id , ae_line_num , object_version_number
7410       , analytical_criterion_code
7411       , analytical_criterion_type_code
7412       , amb_context_code
7413       , ac1,ac2,ac3,ac4,ac5)
7414 VALUES (ae_header_id, ae_line_num, C_OVN
7415 ,SUBSTRB(anc_id_24
7416        ,1
7417        ,INSTRB(anc_id_24,'(]',1,1) -1)
7418 ,SUBSTRB(anc_id_24
7419        ,INSTRB(anc_id_24,'(]',1,1) + 2
7420        ,INSTRB(anc_id_24,'(]',1,2) -
7421         INSTRB(anc_id_24,'(]',1,1) - 2)
7422 ,SUBSTRB(anc_id_24
7423        ,INSTRB(anc_id_24,'(]',1,2) + 2
7424        ,INSTRB(anc_id_24,'(]',1,3) -
7425         INSTRB(anc_id_24,'(]',1,2) - 2)
7426 ,SUBSTRB(anc_id_24
7427        ,INSTRB(anc_id_24,'(]',1,3) + 2
7428        ,INSTRB(anc_id_24,'(]',1,4) -
7429         INSTRB(anc_id_24,'(]',1,3) - 2)
7430 ,SUBSTRB(anc_id_24
7431        ,INSTRB(anc_id_24,'(]',1,4) + 2
7432        ,INSTRB(anc_id_24,'(]',1,5) -
7433         INSTRB(anc_id_24,'(]',1,4) - 2)
7434 ,SUBSTRB(anc_id_24
7435        ,INSTRB(anc_id_24,'(]',1,5) + 2
7436        ,INSTRB(anc_id_24,'(]',1,6) -
7437         INSTRB(anc_id_24,'(]',1,5) - 2)
7438 ,SUBSTRB(anc_id_24
7439        ,INSTRB(anc_id_24,'(]',1,6) + 2
7440        ,INSTRB(anc_id_24,'(]',1,7) -
7441         INSTRB(anc_id_24,'(]',1,6) - 2)
7442 ,SUBSTRB(anc_id_24
7443        ,INSTRB(anc_id_24,'(]',1,7) + 2
7444        ,LENGTHB(anc_id_24))
7445 )
7446 
7447 WHEN anc_id_25 IS NOT NULL THEN
7448   INTO xla_ae_line_acs (
7449         ae_header_id , ae_line_num , object_version_number
7450       , analytical_criterion_code
7451       , analytical_criterion_type_code
7452       , amb_context_code
7453       , ac1,ac2,ac3,ac4,ac5)
7454 VALUES (ae_header_id, ae_line_num, C_OVN
7455 ,SUBSTRB(anc_id_25
7456        ,1
7457        ,INSTRB(anc_id_25,'(]',1,1) -1)
7458 ,SUBSTRB(anc_id_25
7459        ,INSTRB(anc_id_25,'(]',1,1) + 2
7460        ,INSTRB(anc_id_25,'(]',1,2) -
7461         INSTRB(anc_id_25,'(]',1,1) - 2)
7462 ,SUBSTRB(anc_id_25
7463        ,INSTRB(anc_id_25,'(]',1,2) + 2
7464        ,INSTRB(anc_id_25,'(]',1,3) -
7465         INSTRB(anc_id_25,'(]',1,2) - 2)
7466 ,SUBSTRB(anc_id_25
7467        ,INSTRB(anc_id_25,'(]',1,3) + 2
7468        ,INSTRB(anc_id_25,'(]',1,4) -
7469         INSTRB(anc_id_25,'(]',1,3) - 2)
7470 ,SUBSTRB(anc_id_25
7471        ,INSTRB(anc_id_25,'(]',1,4) + 2
7472        ,INSTRB(anc_id_25,'(]',1,5) -
7473         INSTRB(anc_id_25,'(]',1,4) - 2)
7474 ,SUBSTRB(anc_id_25
7475        ,INSTRB(anc_id_25,'(]',1,5) + 2
7476        ,INSTRB(anc_id_25,'(]',1,6) -
7477         INSTRB(anc_id_25,'(]',1,5) - 2)
7478 ,SUBSTRB(anc_id_25
7479        ,INSTRB(anc_id_25,'(]',1,6) + 2
7480        ,INSTRB(anc_id_25,'(]',1,7) -
7481         INSTRB(anc_id_25,'(]',1,6) - 2)
7482 ,SUBSTRB(anc_id_25
7483        ,INSTRB(anc_id_25,'(]',1,7) + 2
7484        ,LENGTHB(anc_id_25))
7485 )
7486 
7487 WHEN anc_id_26 IS NOT NULL THEN
7488   INTO xla_ae_line_acs (
7489         ae_header_id , ae_line_num , object_version_number
7490       , analytical_criterion_code
7491       , analytical_criterion_type_code
7492       , amb_context_code
7493       , ac1,ac2,ac3,ac4,ac5)
7494 VALUES (ae_header_id, ae_line_num, C_OVN
7495 ,SUBSTRB(anc_id_26
7496        ,1
7497        ,INSTRB(anc_id_26,'(]',1,1) -1)
7498 ,SUBSTRB(anc_id_26
7499        ,INSTRB(anc_id_26,'(]',1,1) + 2
7500        ,INSTRB(anc_id_26,'(]',1,2) -
7501         INSTRB(anc_id_26,'(]',1,1) - 2)
7502 ,SUBSTRB(anc_id_26
7503        ,INSTRB(anc_id_26,'(]',1,2) + 2
7504        ,INSTRB(anc_id_26,'(]',1,3) -
7505         INSTRB(anc_id_26,'(]',1,2) - 2)
7506 ,SUBSTRB(anc_id_26
7507        ,INSTRB(anc_id_26,'(]',1,3) + 2
7508        ,INSTRB(anc_id_26,'(]',1,4) -
7509         INSTRB(anc_id_26,'(]',1,3) - 2)
7510 ,SUBSTRB(anc_id_26
7511        ,INSTRB(anc_id_26,'(]',1,4) + 2
7512        ,INSTRB(anc_id_26,'(]',1,5) -
7513         INSTRB(anc_id_26,'(]',1,4) - 2)
7514 ,SUBSTRB(anc_id_26
7515        ,INSTRB(anc_id_26,'(]',1,5) + 2
7516        ,INSTRB(anc_id_26,'(]',1,6) -
7517         INSTRB(anc_id_26,'(]',1,5) - 2)
7518 ,SUBSTRB(anc_id_26
7519        ,INSTRB(anc_id_26,'(]',1,6) + 2
7520        ,INSTRB(anc_id_26,'(]',1,7) -
7521         INSTRB(anc_id_26,'(]',1,6) - 2)
7522 ,SUBSTRB(anc_id_26
7523        ,INSTRB(anc_id_26,'(]',1,7) + 2
7524        ,LENGTHB(anc_id_26))
7525 )
7526 
7527 WHEN anc_id_27 IS NOT NULL THEN
7528   INTO xla_ae_line_acs (
7529         ae_header_id , ae_line_num , object_version_number
7530       , analytical_criterion_code
7531       , analytical_criterion_type_code
7532       , amb_context_code
7533       , ac1,ac2,ac3,ac4,ac5)
7534 VALUES (ae_header_id, ae_line_num, C_OVN
7535 ,SUBSTRB(anc_id_27
7536        ,1
7537        ,INSTRB(anc_id_27,'(]',1,1) -1)
7538 ,SUBSTRB(anc_id_27
7539        ,INSTRB(anc_id_27,'(]',1,1) + 2
7540        ,INSTRB(anc_id_27,'(]',1,2) -
7541         INSTRB(anc_id_27,'(]',1,1) - 2)
7542 ,SUBSTRB(anc_id_27
7543        ,INSTRB(anc_id_27,'(]',1,2) + 2
7544        ,INSTRB(anc_id_27,'(]',1,3) -
7545         INSTRB(anc_id_27,'(]',1,2) - 2)
7546 ,SUBSTRB(anc_id_27
7547        ,INSTRB(anc_id_27,'(]',1,3) + 2
7548        ,INSTRB(anc_id_27,'(]',1,4) -
7549         INSTRB(anc_id_27,'(]',1,3) - 2)
7550 ,SUBSTRB(anc_id_27
7551        ,INSTRB(anc_id_27,'(]',1,4) + 2
7552        ,INSTRB(anc_id_27,'(]',1,5) -
7553         INSTRB(anc_id_27,'(]',1,4) - 2)
7554 ,SUBSTRB(anc_id_27
7555        ,INSTRB(anc_id_27,'(]',1,5) + 2
7556        ,INSTRB(anc_id_27,'(]',1,6) -
7557         INSTRB(anc_id_27,'(]',1,5) - 2)
7558 ,SUBSTRB(anc_id_27
7559        ,INSTRB(anc_id_27,'(]',1,6) + 2
7560        ,INSTRB(anc_id_27,'(]',1,7) -
7561         INSTRB(anc_id_27,'(]',1,6) - 2)
7562 ,SUBSTRB(anc_id_27
7563        ,INSTRB(anc_id_27,'(]',1,7) + 2
7564        ,LENGTHB(anc_id_27))
7565 )
7566 
7567 WHEN anc_id_28 IS NOT NULL THEN
7568   INTO xla_ae_line_acs (
7569         ae_header_id , ae_line_num , object_version_number
7570       , analytical_criterion_code
7571       , analytical_criterion_type_code
7572       , amb_context_code
7573       , ac1,ac2,ac3,ac4,ac5)
7574 VALUES (ae_header_id, ae_line_num, C_OVN
7575 ,SUBSTRB(anc_id_28
7576        ,1
7577        ,INSTRB(anc_id_28,'(]',1,1) -1)
7578 ,SUBSTRB(anc_id_28
7579        ,INSTRB(anc_id_28,'(]',1,1) + 2
7580        ,INSTRB(anc_id_28,'(]',1,2) -
7581         INSTRB(anc_id_28,'(]',1,1) - 2)
7582 ,SUBSTRB(anc_id_28
7583        ,INSTRB(anc_id_28,'(]',1,2) + 2
7584        ,INSTRB(anc_id_28,'(]',1,3) -
7585         INSTRB(anc_id_28,'(]',1,2) - 2)
7586 ,SUBSTRB(anc_id_28
7587        ,INSTRB(anc_id_28,'(]',1,3) + 2
7588        ,INSTRB(anc_id_28,'(]',1,4) -
7589         INSTRB(anc_id_28,'(]',1,3) - 2)
7590 ,SUBSTRB(anc_id_28
7591        ,INSTRB(anc_id_28,'(]',1,4) + 2
7592        ,INSTRB(anc_id_28,'(]',1,5) -
7593         INSTRB(anc_id_28,'(]',1,4) - 2)
7594 ,SUBSTRB(anc_id_28
7595        ,INSTRB(anc_id_28,'(]',1,5) + 2
7596        ,INSTRB(anc_id_28,'(]',1,6) -
7597         INSTRB(anc_id_28,'(]',1,5) - 2)
7598 ,SUBSTRB(anc_id_28
7599        ,INSTRB(anc_id_28,'(]',1,6) + 2
7600        ,INSTRB(anc_id_28,'(]',1,7) -
7601         INSTRB(anc_id_28,'(]',1,6) - 2)
7602 ,SUBSTRB(anc_id_28
7603        ,INSTRB(anc_id_28,'(]',1,7) + 2
7604        ,LENGTHB(anc_id_28))
7605 )
7606 
7607 WHEN anc_id_29 IS NOT NULL THEN
7608   INTO xla_ae_line_acs (
7609         ae_header_id , ae_line_num , object_version_number
7610       , analytical_criterion_code
7611       , analytical_criterion_type_code
7612       , amb_context_code
7613       , ac1,ac2,ac3,ac4,ac5)
7614 VALUES (ae_header_id, ae_line_num, C_OVN
7615 ,SUBSTRB(anc_id_29
7616        ,1
7617        ,INSTRB(anc_id_29,'(]',1,1) -1)
7618 ,SUBSTRB(anc_id_29
7619        ,INSTRB(anc_id_29,'(]',1,1) + 2
7620        ,INSTRB(anc_id_29,'(]',1,2) -
7621         INSTRB(anc_id_29,'(]',1,1) - 2)
7622 ,SUBSTRB(anc_id_29
7623        ,INSTRB(anc_id_29,'(]',1,2) + 2
7624        ,INSTRB(anc_id_29,'(]',1,3) -
7625         INSTRB(anc_id_29,'(]',1,2) - 2)
7626 ,SUBSTRB(anc_id_29
7627        ,INSTRB(anc_id_29,'(]',1,3) + 2
7628        ,INSTRB(anc_id_29,'(]',1,4) -
7629         INSTRB(anc_id_29,'(]',1,3) - 2)
7630 ,SUBSTRB(anc_id_29
7631        ,INSTRB(anc_id_29,'(]',1,4) + 2
7632        ,INSTRB(anc_id_29,'(]',1,5) -
7633         INSTRB(anc_id_29,'(]',1,4) - 2)
7634 ,SUBSTRB(anc_id_29
7635        ,INSTRB(anc_id_29,'(]',1,5) + 2
7636        ,INSTRB(anc_id_29,'(]',1,6) -
7637         INSTRB(anc_id_29,'(]',1,5) - 2)
7638 ,SUBSTRB(anc_id_29
7639        ,INSTRB(anc_id_29,'(]',1,6) + 2
7640        ,INSTRB(anc_id_29,'(]',1,7) -
7641         INSTRB(anc_id_29,'(]',1,6) - 2)
7642 ,SUBSTRB(anc_id_29
7643        ,INSTRB(anc_id_29,'(]',1,7) + 2
7644        ,LENGTHB(anc_id_29))
7645 )
7646 
7647 WHEN anc_id_30 IS NOT NULL THEN
7648   INTO xla_ae_line_acs (
7649         ae_header_id , ae_line_num , object_version_number
7650       , analytical_criterion_code
7651       , analytical_criterion_type_code
7652       , amb_context_code
7653       , ac1,ac2,ac3,ac4,ac5)
7654 VALUES (ae_header_id, ae_line_num, C_OVN
7655 ,SUBSTRB(anc_id_30
7656        ,1
7657        ,INSTRB(anc_id_30,'(]',1,1) -1)
7658 ,SUBSTRB(anc_id_30
7659        ,INSTRB(anc_id_30,'(]',1,1) + 2
7660        ,INSTRB(anc_id_30,'(]',1,2) -
7661         INSTRB(anc_id_30,'(]',1,1) - 2)
7662 ,SUBSTRB(anc_id_30
7663        ,INSTRB(anc_id_30,'(]',1,2) + 2
7664        ,INSTRB(anc_id_30,'(]',1,3) -
7665         INSTRB(anc_id_30,'(]',1,2) - 2)
7666 ,SUBSTRB(anc_id_30
7667        ,INSTRB(anc_id_30,'(]',1,3) + 2
7668        ,INSTRB(anc_id_30,'(]',1,4) -
7669         INSTRB(anc_id_30,'(]',1,3) - 2)
7670 ,SUBSTRB(anc_id_30
7671        ,INSTRB(anc_id_30,'(]',1,4) + 2
7672        ,INSTRB(anc_id_30,'(]',1,5) -
7673         INSTRB(anc_id_30,'(]',1,4) - 2)
7674 ,SUBSTRB(anc_id_30
7675        ,INSTRB(anc_id_30,'(]',1,5) + 2
7676        ,INSTRB(anc_id_30,'(]',1,6) -
7677         INSTRB(anc_id_30,'(]',1,5) - 2)
7678 ,SUBSTRB(anc_id_30
7679        ,INSTRB(anc_id_30,'(]',1,6) + 2
7680        ,INSTRB(anc_id_30,'(]',1,7) -
7681         INSTRB(anc_id_30,'(]',1,6) - 2)
7682 ,SUBSTRB(anc_id_30
7683        ,INSTRB(anc_id_30,'(]',1,7) + 2
7684        ,LENGTHB(anc_id_30))
7685 )
7686 
7687 WHEN anc_id_31 IS NOT NULL THEN
7688   INTO xla_ae_line_acs (
7689         ae_header_id , ae_line_num , object_version_number
7690       , analytical_criterion_code
7691       , analytical_criterion_type_code
7692       , amb_context_code
7693       , ac1,ac2,ac3,ac4,ac5)
7694 VALUES (ae_header_id, ae_line_num, C_OVN
7695 ,SUBSTRB(anc_id_31
7696        ,1
7697        ,INSTRB(anc_id_31,'(]',1,1) -1)
7698 ,SUBSTRB(anc_id_31
7699        ,INSTRB(anc_id_31,'(]',1,1) + 2
7700        ,INSTRB(anc_id_31,'(]',1,2) -
7701         INSTRB(anc_id_31,'(]',1,1) - 2)
7702 ,SUBSTRB(anc_id_31
7703        ,INSTRB(anc_id_31,'(]',1,2) + 2
7704        ,INSTRB(anc_id_31,'(]',1,3) -
7705         INSTRB(anc_id_31,'(]',1,2) - 2)
7706 ,SUBSTRB(anc_id_31
7707        ,INSTRB(anc_id_31,'(]',1,3) + 2
7708        ,INSTRB(anc_id_31,'(]',1,4) -
7709         INSTRB(anc_id_31,'(]',1,3) - 2)
7710 ,SUBSTRB(anc_id_31
7711        ,INSTRB(anc_id_31,'(]',1,4) + 2
7712        ,INSTRB(anc_id_31,'(]',1,5) -
7713         INSTRB(anc_id_31,'(]',1,4) - 2)
7714 ,SUBSTRB(anc_id_31
7715        ,INSTRB(anc_id_31,'(]',1,5) + 2
7716        ,INSTRB(anc_id_31,'(]',1,6) -
7717         INSTRB(anc_id_31,'(]',1,5) - 2)
7718 ,SUBSTRB(anc_id_31
7719        ,INSTRB(anc_id_31,'(]',1,6) + 2
7720        ,INSTRB(anc_id_31,'(]',1,7) -
7721         INSTRB(anc_id_31,'(]',1,6) - 2)
7722 ,SUBSTRB(anc_id_31
7723        ,INSTRB(anc_id_31,'(]',1,7) + 2
7724        ,LENGTHB(anc_id_31))
7725 )
7726 
7727 WHEN anc_id_32 IS NOT NULL THEN
7728   INTO xla_ae_line_acs (
7729         ae_header_id , ae_line_num , object_version_number
7730       , analytical_criterion_code
7731       , analytical_criterion_type_code
7732       , amb_context_code
7733       , ac1,ac2,ac3,ac4,ac5)
7734 VALUES (ae_header_id, ae_line_num, C_OVN
7735 ,SUBSTRB(anc_id_32
7736        ,1
7737        ,INSTRB(anc_id_32,'(]',1,1) -1)
7738 ,SUBSTRB(anc_id_32
7739        ,INSTRB(anc_id_32,'(]',1,1) + 2
7740        ,INSTRB(anc_id_32,'(]',1,2) -
7741         INSTRB(anc_id_32,'(]',1,1) - 2)
7742 ,SUBSTRB(anc_id_32
7743        ,INSTRB(anc_id_32,'(]',1,2) + 2
7744        ,INSTRB(anc_id_32,'(]',1,3) -
7745         INSTRB(anc_id_32,'(]',1,2) - 2)
7746 ,SUBSTRB(anc_id_32
7747        ,INSTRB(anc_id_32,'(]',1,3) + 2
7748        ,INSTRB(anc_id_32,'(]',1,4) -
7749         INSTRB(anc_id_32,'(]',1,3) - 2)
7750 ,SUBSTRB(anc_id_32
7751        ,INSTRB(anc_id_32,'(]',1,4) + 2
7752        ,INSTRB(anc_id_32,'(]',1,5) -
7753         INSTRB(anc_id_32,'(]',1,4) - 2)
7754 ,SUBSTRB(anc_id_32
7755        ,INSTRB(anc_id_32,'(]',1,5) + 2
7756        ,INSTRB(anc_id_32,'(]',1,6) -
7757         INSTRB(anc_id_32,'(]',1,5) - 2)
7758 ,SUBSTRB(anc_id_32
7759        ,INSTRB(anc_id_32,'(]',1,6) + 2
7760        ,INSTRB(anc_id_32,'(]',1,7) -
7761         INSTRB(anc_id_32,'(]',1,6) - 2)
7762 ,SUBSTRB(anc_id_32
7763        ,INSTRB(anc_id_32,'(]',1,7) + 2
7764        ,LENGTHB(anc_id_32))
7765 )
7766 
7767 WHEN anc_id_33 IS NOT NULL THEN
7768   INTO xla_ae_line_acs (
7769         ae_header_id , ae_line_num , object_version_number
7770       , analytical_criterion_code
7771       , analytical_criterion_type_code
7772       , amb_context_code
7773       , ac1,ac2,ac3,ac4,ac5)
7774 VALUES (ae_header_id, ae_line_num, C_OVN
7775 ,SUBSTRB(anc_id_33
7776        ,1
7777        ,INSTRB(anc_id_33,'(]',1,1) -1)
7778 ,SUBSTRB(anc_id_33
7779        ,INSTRB(anc_id_33,'(]',1,1) + 2
7780        ,INSTRB(anc_id_33,'(]',1,2) -
7781         INSTRB(anc_id_33,'(]',1,1) - 2)
7782 ,SUBSTRB(anc_id_33
7783        ,INSTRB(anc_id_33,'(]',1,2) + 2
7784        ,INSTRB(anc_id_33,'(]',1,3) -
7785         INSTRB(anc_id_33,'(]',1,2) - 2)
7786 ,SUBSTRB(anc_id_33
7787        ,INSTRB(anc_id_33,'(]',1,3) + 2
7788        ,INSTRB(anc_id_33,'(]',1,4) -
7789         INSTRB(anc_id_33,'(]',1,3) - 2)
7790 ,SUBSTRB(anc_id_33
7791        ,INSTRB(anc_id_33,'(]',1,4) + 2
7792        ,INSTRB(anc_id_33,'(]',1,5) -
7793         INSTRB(anc_id_33,'(]',1,4) - 2)
7794 ,SUBSTRB(anc_id_33
7795        ,INSTRB(anc_id_33,'(]',1,5) + 2
7796        ,INSTRB(anc_id_33,'(]',1,6) -
7797         INSTRB(anc_id_33,'(]',1,5) - 2)
7798 ,SUBSTRB(anc_id_33
7799        ,INSTRB(anc_id_33,'(]',1,6) + 2
7800        ,INSTRB(anc_id_33,'(]',1,7) -
7801         INSTRB(anc_id_33,'(]',1,6) - 2)
7802 ,SUBSTRB(anc_id_33
7803        ,INSTRB(anc_id_33,'(]',1,7) + 2
7804        ,LENGTHB(anc_id_33))
7805 )
7806 
7807 WHEN anc_id_34 IS NOT NULL THEN
7808   INTO xla_ae_line_acs (
7809         ae_header_id , ae_line_num , object_version_number
7810       , analytical_criterion_code
7811       , analytical_criterion_type_code
7812       , amb_context_code
7813       , ac1,ac2,ac3,ac4,ac5)
7814 VALUES (ae_header_id, ae_line_num, C_OVN
7815 ,SUBSTRB(anc_id_34
7816        ,1
7817        ,INSTRB(anc_id_34,'(]',1,1) -1)
7818 ,SUBSTRB(anc_id_34
7819        ,INSTRB(anc_id_34,'(]',1,1) + 2
7820        ,INSTRB(anc_id_34,'(]',1,2) -
7821         INSTRB(anc_id_34,'(]',1,1) - 2)
7822 ,SUBSTRB(anc_id_34
7823        ,INSTRB(anc_id_34,'(]',1,2) + 2
7824        ,INSTRB(anc_id_34,'(]',1,3) -
7825         INSTRB(anc_id_34,'(]',1,2) - 2)
7826 ,SUBSTRB(anc_id_34
7827        ,INSTRB(anc_id_34,'(]',1,3) + 2
7828        ,INSTRB(anc_id_34,'(]',1,4) -
7829         INSTRB(anc_id_34,'(]',1,3) - 2)
7830 ,SUBSTRB(anc_id_34
7831        ,INSTRB(anc_id_34,'(]',1,4) + 2
7832        ,INSTRB(anc_id_34,'(]',1,5) -
7833         INSTRB(anc_id_34,'(]',1,4) - 2)
7834 ,SUBSTRB(anc_id_34
7835        ,INSTRB(anc_id_34,'(]',1,5) + 2
7836        ,INSTRB(anc_id_34,'(]',1,6) -
7837         INSTRB(anc_id_34,'(]',1,5) - 2)
7838 ,SUBSTRB(anc_id_34
7839        ,INSTRB(anc_id_34,'(]',1,6) + 2
7840        ,INSTRB(anc_id_34,'(]',1,7) -
7841         INSTRB(anc_id_34,'(]',1,6) - 2)
7842 ,SUBSTRB(anc_id_34
7843        ,INSTRB(anc_id_34,'(]',1,7) + 2
7844        ,LENGTHB(anc_id_34))
7845 )
7846 
7847 WHEN anc_id_35 IS NOT NULL THEN
7848   INTO xla_ae_line_acs (
7849         ae_header_id , ae_line_num , object_version_number
7850       , analytical_criterion_code
7851       , analytical_criterion_type_code
7852       , amb_context_code
7853       , ac1,ac2,ac3,ac4,ac5)
7854 VALUES (ae_header_id, ae_line_num, C_OVN
7855 ,SUBSTRB(anc_id_35
7856        ,1
7857        ,INSTRB(anc_id_35,'(]',1,1) -1)
7858 ,SUBSTRB(anc_id_35
7859        ,INSTRB(anc_id_35,'(]',1,1) + 2
7860        ,INSTRB(anc_id_35,'(]',1,2) -
7861         INSTRB(anc_id_35,'(]',1,1) - 2)
7862 ,SUBSTRB(anc_id_35
7863        ,INSTRB(anc_id_35,'(]',1,2) + 2
7864        ,INSTRB(anc_id_35,'(]',1,3) -
7865         INSTRB(anc_id_35,'(]',1,2) - 2)
7866 ,SUBSTRB(anc_id_35
7867        ,INSTRB(anc_id_35,'(]',1,3) + 2
7868        ,INSTRB(anc_id_35,'(]',1,4) -
7869         INSTRB(anc_id_35,'(]',1,3) - 2)
7870 ,SUBSTRB(anc_id_35
7871        ,INSTRB(anc_id_35,'(]',1,4) + 2
7872        ,INSTRB(anc_id_35,'(]',1,5) -
7873         INSTRB(anc_id_35,'(]',1,4) - 2)
7874 ,SUBSTRB(anc_id_35
7875        ,INSTRB(anc_id_35,'(]',1,5) + 2
7876        ,INSTRB(anc_id_35,'(]',1,6) -
7877         INSTRB(anc_id_35,'(]',1,5) - 2)
7878 ,SUBSTRB(anc_id_35
7879        ,INSTRB(anc_id_35,'(]',1,6) + 2
7880        ,INSTRB(anc_id_35,'(]',1,7) -
7881         INSTRB(anc_id_35,'(]',1,6) - 2)
7882 ,SUBSTRB(anc_id_35
7883        ,INSTRB(anc_id_35,'(]',1,7) + 2
7884        ,LENGTHB(anc_id_35))
7885 )
7886 
7887 WHEN anc_id_36 IS NOT NULL THEN
7888   INTO xla_ae_line_acs (
7889         ae_header_id , ae_line_num , object_version_number
7890       , analytical_criterion_code
7891       , analytical_criterion_type_code
7892       , amb_context_code
7893       , ac1,ac2,ac3,ac4,ac5)
7894 VALUES (ae_header_id, ae_line_num, C_OVN
7895 ,SUBSTRB(anc_id_36
7896        ,1
7897        ,INSTRB(anc_id_36,'(]',1,1) -1)
7898 ,SUBSTRB(anc_id_36
7899        ,INSTRB(anc_id_36,'(]',1,1) + 2
7900        ,INSTRB(anc_id_36,'(]',1,2) -
7901         INSTRB(anc_id_36,'(]',1,1) - 2)
7902 ,SUBSTRB(anc_id_36
7903        ,INSTRB(anc_id_36,'(]',1,2) + 2
7904        ,INSTRB(anc_id_36,'(]',1,3) -
7905         INSTRB(anc_id_36,'(]',1,2) - 2)
7906 ,SUBSTRB(anc_id_36
7907        ,INSTRB(anc_id_36,'(]',1,3) + 2
7908        ,INSTRB(anc_id_36,'(]',1,4) -
7909         INSTRB(anc_id_36,'(]',1,3) - 2)
7910 ,SUBSTRB(anc_id_36
7911        ,INSTRB(anc_id_36,'(]',1,4) + 2
7912        ,INSTRB(anc_id_36,'(]',1,5) -
7913         INSTRB(anc_id_36,'(]',1,4) - 2)
7914 ,SUBSTRB(anc_id_36
7915        ,INSTRB(anc_id_36,'(]',1,5) + 2
7916        ,INSTRB(anc_id_36,'(]',1,6) -
7917         INSTRB(anc_id_36,'(]',1,5) - 2)
7918 ,SUBSTRB(anc_id_36
7919        ,INSTRB(anc_id_36,'(]',1,6) + 2
7920        ,INSTRB(anc_id_36,'(]',1,7) -
7921         INSTRB(anc_id_36,'(]',1,6) - 2)
7922 ,SUBSTRB(anc_id_36
7923        ,INSTRB(anc_id_36,'(]',1,7) + 2
7924        ,LENGTHB(anc_id_36))
7925 )
7926 
7927 WHEN anc_id_37 IS NOT NULL THEN
7928   INTO xla_ae_line_acs (
7929         ae_header_id , ae_line_num , object_version_number
7930       , analytical_criterion_code
7931       , analytical_criterion_type_code
7932       , amb_context_code
7933       , ac1,ac2,ac3,ac4,ac5)
7934 VALUES (ae_header_id, ae_line_num, C_OVN
7935 ,SUBSTRB(anc_id_37
7936        ,1
7937        ,INSTRB(anc_id_37,'(]',1,1) -1)
7938 ,SUBSTRB(anc_id_37
7939        ,INSTRB(anc_id_37,'(]',1,1) + 2
7940        ,INSTRB(anc_id_37,'(]',1,2) -
7941         INSTRB(anc_id_37,'(]',1,1) - 2)
7942 ,SUBSTRB(anc_id_37
7943        ,INSTRB(anc_id_37,'(]',1,2) + 2
7944        ,INSTRB(anc_id_37,'(]',1,3) -
7945         INSTRB(anc_id_37,'(]',1,2) - 2)
7946 ,SUBSTRB(anc_id_37
7947        ,INSTRB(anc_id_37,'(]',1,3) + 2
7948        ,INSTRB(anc_id_37,'(]',1,4) -
7949         INSTRB(anc_id_37,'(]',1,3) - 2)
7950 ,SUBSTRB(anc_id_37
7951        ,INSTRB(anc_id_37,'(]',1,4) + 2
7952        ,INSTRB(anc_id_37,'(]',1,5) -
7953         INSTRB(anc_id_37,'(]',1,4) - 2)
7954 ,SUBSTRB(anc_id_37
7955        ,INSTRB(anc_id_37,'(]',1,5) + 2
7956        ,INSTRB(anc_id_37,'(]',1,6) -
7957         INSTRB(anc_id_37,'(]',1,5) - 2)
7958 ,SUBSTRB(anc_id_37
7959        ,INSTRB(anc_id_37,'(]',1,6) + 2
7960        ,INSTRB(anc_id_37,'(]',1,7) -
7961         INSTRB(anc_id_37,'(]',1,6) - 2)
7962 ,SUBSTRB(anc_id_37
7963        ,INSTRB(anc_id_37,'(]',1,7) + 2
7964        ,LENGTHB(anc_id_37))
7965 )
7966 
7967 WHEN anc_id_38 IS NOT NULL THEN
7968   INTO xla_ae_line_acs (
7969         ae_header_id , ae_line_num , object_version_number
7970       , analytical_criterion_code
7971       , analytical_criterion_type_code
7972       , amb_context_code
7973       , ac1,ac2,ac3,ac4,ac5)
7974 VALUES (ae_header_id, ae_line_num, C_OVN
7975 ,SUBSTRB(anc_id_38
7976        ,1
7977        ,INSTRB(anc_id_38,'(]',1,1) -1)
7978 ,SUBSTRB(anc_id_38
7979        ,INSTRB(anc_id_38,'(]',1,1) + 2
7980        ,INSTRB(anc_id_38,'(]',1,2) -
7981         INSTRB(anc_id_38,'(]',1,1) - 2)
7982 ,SUBSTRB(anc_id_38
7983        ,INSTRB(anc_id_38,'(]',1,2) + 2
7984        ,INSTRB(anc_id_38,'(]',1,3) -
7985         INSTRB(anc_id_38,'(]',1,2) - 2)
7986 ,SUBSTRB(anc_id_38
7987        ,INSTRB(anc_id_38,'(]',1,3) + 2
7988        ,INSTRB(anc_id_38,'(]',1,4) -
7989         INSTRB(anc_id_38,'(]',1,3) - 2)
7990 ,SUBSTRB(anc_id_38
7991        ,INSTRB(anc_id_38,'(]',1,4) + 2
7992        ,INSTRB(anc_id_38,'(]',1,5) -
7993         INSTRB(anc_id_38,'(]',1,4) - 2)
7994 ,SUBSTRB(anc_id_38
7995        ,INSTRB(anc_id_38,'(]',1,5) + 2
7996        ,INSTRB(anc_id_38,'(]',1,6) -
7997         INSTRB(anc_id_38,'(]',1,5) - 2)
7998 ,SUBSTRB(anc_id_38
7999        ,INSTRB(anc_id_38,'(]',1,6) + 2
8000        ,INSTRB(anc_id_38,'(]',1,7) -
8001         INSTRB(anc_id_38,'(]',1,6) - 2)
8002 ,SUBSTRB(anc_id_38
8003        ,INSTRB(anc_id_38,'(]',1,7) + 2
8004        ,LENGTHB(anc_id_38))
8005 )
8006 
8007 WHEN anc_id_39 IS NOT NULL THEN
8008   INTO xla_ae_line_acs (
8009         ae_header_id , ae_line_num , object_version_number
8010       , analytical_criterion_code
8011       , analytical_criterion_type_code
8012       , amb_context_code
8013       , ac1,ac2,ac3,ac4,ac5)
8014 VALUES (ae_header_id, ae_line_num, C_OVN
8015 ,SUBSTRB(anc_id_39
8016        ,1
8017        ,INSTRB(anc_id_39,'(]',1,1) -1)
8018 ,SUBSTRB(anc_id_39
8019        ,INSTRB(anc_id_39,'(]',1,1) + 2
8020        ,INSTRB(anc_id_39,'(]',1,2) -
8021         INSTRB(anc_id_39,'(]',1,1) - 2)
8022 ,SUBSTRB(anc_id_39
8023        ,INSTRB(anc_id_39,'(]',1,2) + 2
8024        ,INSTRB(anc_id_39,'(]',1,3) -
8025         INSTRB(anc_id_39,'(]',1,2) - 2)
8026 ,SUBSTRB(anc_id_39
8027        ,INSTRB(anc_id_39,'(]',1,3) + 2
8028        ,INSTRB(anc_id_39,'(]',1,4) -
8029         INSTRB(anc_id_39,'(]',1,3) - 2)
8030 ,SUBSTRB(anc_id_39
8031        ,INSTRB(anc_id_39,'(]',1,4) + 2
8032        ,INSTRB(anc_id_39,'(]',1,5) -
8033         INSTRB(anc_id_39,'(]',1,4) - 2)
8034 ,SUBSTRB(anc_id_39
8035        ,INSTRB(anc_id_39,'(]',1,5) + 2
8036        ,INSTRB(anc_id_39,'(]',1,6) -
8037         INSTRB(anc_id_39,'(]',1,5) - 2)
8038 ,SUBSTRB(anc_id_39
8039        ,INSTRB(anc_id_39,'(]',1,6) + 2
8040        ,INSTRB(anc_id_39,'(]',1,7) -
8041         INSTRB(anc_id_39,'(]',1,6) - 2)
8042 ,SUBSTRB(anc_id_39
8043        ,INSTRB(anc_id_39,'(]',1,7) + 2
8044        ,LENGTHB(anc_id_39))
8045 )
8046 
8047 WHEN anc_id_40 IS NOT NULL THEN
8048   INTO xla_ae_line_acs (
8049         ae_header_id , ae_line_num , object_version_number
8050       , analytical_criterion_code
8051       , analytical_criterion_type_code
8052       , amb_context_code
8053       , ac1,ac2,ac3,ac4,ac5)
8054 VALUES (ae_header_id, ae_line_num, C_OVN
8055 ,SUBSTRB(anc_id_40
8056        ,1
8057        ,INSTRB(anc_id_40,'(]',1,1) -1)
8058 ,SUBSTRB(anc_id_40
8059        ,INSTRB(anc_id_40,'(]',1,1) + 2
8060        ,INSTRB(anc_id_40,'(]',1,2) -
8061         INSTRB(anc_id_40,'(]',1,1) - 2)
8062 ,SUBSTRB(anc_id_40
8063        ,INSTRB(anc_id_40,'(]',1,2) + 2
8064        ,INSTRB(anc_id_40,'(]',1,3) -
8065         INSTRB(anc_id_40,'(]',1,2) - 2)
8066 ,SUBSTRB(anc_id_40
8067        ,INSTRB(anc_id_40,'(]',1,3) + 2
8068        ,INSTRB(anc_id_40,'(]',1,4) -
8069         INSTRB(anc_id_40,'(]',1,3) - 2)
8070 ,SUBSTRB(anc_id_40
8071        ,INSTRB(anc_id_40,'(]',1,4) + 2
8072        ,INSTRB(anc_id_40,'(]',1,5) -
8073         INSTRB(anc_id_40,'(]',1,4) - 2)
8074 ,SUBSTRB(anc_id_40
8075        ,INSTRB(anc_id_40,'(]',1,5) + 2
8076        ,INSTRB(anc_id_40,'(]',1,6) -
8077         INSTRB(anc_id_40,'(]',1,5) - 2)
8078 ,SUBSTRB(anc_id_40
8079        ,INSTRB(anc_id_40,'(]',1,6) + 2
8080        ,INSTRB(anc_id_40,'(]',1,7) -
8081         INSTRB(anc_id_40,'(]',1,6) - 2)
8082 ,SUBSTRB(anc_id_40
8083        ,INSTRB(anc_id_40,'(]',1,7) + 2
8084        ,LENGTHB(anc_id_40))
8085 )
8086 
8087 WHEN anc_id_41 IS NOT NULL THEN
8088   INTO xla_ae_line_acs (
8089         ae_header_id , ae_line_num , object_version_number
8090       , analytical_criterion_code
8091       , analytical_criterion_type_code
8092       , amb_context_code
8093       , ac1,ac2,ac3,ac4,ac5)
8094 VALUES (ae_header_id, ae_line_num, C_OVN
8095 ,SUBSTRB(anc_id_41
8096        ,1
8097        ,INSTRB(anc_id_41,'(]',1,1) -1)
8098 ,SUBSTRB(anc_id_41
8099        ,INSTRB(anc_id_41,'(]',1,1) + 2
8100        ,INSTRB(anc_id_41,'(]',1,2) -
8101         INSTRB(anc_id_41,'(]',1,1) - 2)
8102 ,SUBSTRB(anc_id_41
8103        ,INSTRB(anc_id_41,'(]',1,2) + 2
8104        ,INSTRB(anc_id_41,'(]',1,3) -
8105         INSTRB(anc_id_41,'(]',1,2) - 2)
8106 ,SUBSTRB(anc_id_41
8107        ,INSTRB(anc_id_41,'(]',1,3) + 2
8108        ,INSTRB(anc_id_41,'(]',1,4) -
8109         INSTRB(anc_id_41,'(]',1,3) - 2)
8110 ,SUBSTRB(anc_id_41
8111        ,INSTRB(anc_id_41,'(]',1,4) + 2
8112        ,INSTRB(anc_id_41,'(]',1,5) -
8113         INSTRB(anc_id_41,'(]',1,4) - 2)
8114 ,SUBSTRB(anc_id_41
8115        ,INSTRB(anc_id_41,'(]',1,5) + 2
8116        ,INSTRB(anc_id_41,'(]',1,6) -
8117         INSTRB(anc_id_41,'(]',1,5) - 2)
8118 ,SUBSTRB(anc_id_41
8119        ,INSTRB(anc_id_41,'(]',1,6) + 2
8120        ,INSTRB(anc_id_41,'(]',1,7) -
8121         INSTRB(anc_id_41,'(]',1,6) - 2)
8122 ,SUBSTRB(anc_id_41
8123        ,INSTRB(anc_id_41,'(]',1,7) + 2
8124        ,LENGTHB(anc_id_41))
8125 )
8126 
8127 WHEN anc_id_42 IS NOT NULL THEN
8128   INTO xla_ae_line_acs (
8129         ae_header_id , ae_line_num , object_version_number
8130       , analytical_criterion_code
8131       , analytical_criterion_type_code
8132       , amb_context_code
8133       , ac1,ac2,ac3,ac4,ac5)
8134 VALUES (ae_header_id, ae_line_num, C_OVN
8135 ,SUBSTRB(anc_id_42
8136        ,1
8137        ,INSTRB(anc_id_42,'(]',1,1) -1)
8138 ,SUBSTRB(anc_id_42
8139        ,INSTRB(anc_id_42,'(]',1,1) + 2
8140        ,INSTRB(anc_id_42,'(]',1,2) -
8141         INSTRB(anc_id_42,'(]',1,1) - 2)
8142 ,SUBSTRB(anc_id_42
8143        ,INSTRB(anc_id_42,'(]',1,2) + 2
8144        ,INSTRB(anc_id_42,'(]',1,3) -
8145         INSTRB(anc_id_42,'(]',1,2) - 2)
8146 ,SUBSTRB(anc_id_42
8147        ,INSTRB(anc_id_42,'(]',1,3) + 2
8148        ,INSTRB(anc_id_42,'(]',1,4) -
8149         INSTRB(anc_id_42,'(]',1,3) - 2)
8150 ,SUBSTRB(anc_id_42
8151        ,INSTRB(anc_id_42,'(]',1,4) + 2
8152        ,INSTRB(anc_id_42,'(]',1,5) -
8153         INSTRB(anc_id_42,'(]',1,4) - 2)
8154 ,SUBSTRB(anc_id_42
8155        ,INSTRB(anc_id_42,'(]',1,5) + 2
8156        ,INSTRB(anc_id_42,'(]',1,6) -
8157         INSTRB(anc_id_42,'(]',1,5) - 2)
8158 ,SUBSTRB(anc_id_42
8159        ,INSTRB(anc_id_42,'(]',1,6) + 2
8160        ,INSTRB(anc_id_42,'(]',1,7) -
8161         INSTRB(anc_id_42,'(]',1,6) - 2)
8162 ,SUBSTRB(anc_id_42
8163        ,INSTRB(anc_id_42,'(]',1,7) + 2
8164        ,LENGTHB(anc_id_42))
8165 )
8166 
8167 WHEN anc_id_43 IS NOT NULL THEN
8168   INTO xla_ae_line_acs (
8169         ae_header_id , ae_line_num , object_version_number
8170       , analytical_criterion_code
8171       , analytical_criterion_type_code
8172       , amb_context_code
8173       , ac1,ac2,ac3,ac4,ac5)
8174 VALUES (ae_header_id, ae_line_num, C_OVN
8175 ,SUBSTRB(anc_id_43
8176        ,1
8177        ,INSTRB(anc_id_43,'(]',1,1) -1)
8178 ,SUBSTRB(anc_id_43
8179        ,INSTRB(anc_id_43,'(]',1,1) + 2
8180        ,INSTRB(anc_id_43,'(]',1,2) -
8181         INSTRB(anc_id_43,'(]',1,1) - 2)
8182 ,SUBSTRB(anc_id_43
8183        ,INSTRB(anc_id_43,'(]',1,2) + 2
8184        ,INSTRB(anc_id_43,'(]',1,3) -
8185         INSTRB(anc_id_43,'(]',1,2) - 2)
8186 ,SUBSTRB(anc_id_43
8187        ,INSTRB(anc_id_43,'(]',1,3) + 2
8188        ,INSTRB(anc_id_43,'(]',1,4) -
8189         INSTRB(anc_id_43,'(]',1,3) - 2)
8190 ,SUBSTRB(anc_id_43
8191        ,INSTRB(anc_id_43,'(]',1,4) + 2
8192        ,INSTRB(anc_id_43,'(]',1,5) -
8193         INSTRB(anc_id_43,'(]',1,4) - 2)
8194 ,SUBSTRB(anc_id_43
8195        ,INSTRB(anc_id_43,'(]',1,5) + 2
8196        ,INSTRB(anc_id_43,'(]',1,6) -
8197         INSTRB(anc_id_43,'(]',1,5) - 2)
8198 ,SUBSTRB(anc_id_43
8199        ,INSTRB(anc_id_43,'(]',1,6) + 2
8200        ,INSTRB(anc_id_43,'(]',1,7) -
8201         INSTRB(anc_id_43,'(]',1,6) - 2)
8202 ,SUBSTRB(anc_id_43
8203        ,INSTRB(anc_id_43,'(]',1,7) + 2
8204        ,LENGTHB(anc_id_43))
8205 )
8206 
8207 WHEN anc_id_44 IS NOT NULL THEN
8208   INTO xla_ae_line_acs (
8209         ae_header_id , ae_line_num , object_version_number
8210       , analytical_criterion_code
8211       , analytical_criterion_type_code
8212       , amb_context_code
8213       , ac1,ac2,ac3,ac4,ac5)
8214 VALUES (ae_header_id, ae_line_num, C_OVN
8215 ,SUBSTRB(anc_id_44
8216        ,1
8217        ,INSTRB(anc_id_44,'(]',1,1) -1)
8218 ,SUBSTRB(anc_id_44
8219        ,INSTRB(anc_id_44,'(]',1,1) + 2
8220        ,INSTRB(anc_id_44,'(]',1,2) -
8221         INSTRB(anc_id_44,'(]',1,1) - 2)
8222 ,SUBSTRB(anc_id_44
8223        ,INSTRB(anc_id_44,'(]',1,2) + 2
8224        ,INSTRB(anc_id_44,'(]',1,3) -
8225         INSTRB(anc_id_44,'(]',1,2) - 2)
8226 ,SUBSTRB(anc_id_44
8227        ,INSTRB(anc_id_44,'(]',1,3) + 2
8228        ,INSTRB(anc_id_44,'(]',1,4) -
8229         INSTRB(anc_id_44,'(]',1,3) - 2)
8230 ,SUBSTRB(anc_id_44
8231        ,INSTRB(anc_id_44,'(]',1,4) + 2
8232        ,INSTRB(anc_id_44,'(]',1,5) -
8233         INSTRB(anc_id_44,'(]',1,4) - 2)
8234 ,SUBSTRB(anc_id_44
8235        ,INSTRB(anc_id_44,'(]',1,5) + 2
8236        ,INSTRB(anc_id_44,'(]',1,6) -
8237         INSTRB(anc_id_44,'(]',1,5) - 2)
8238 ,SUBSTRB(anc_id_44
8239        ,INSTRB(anc_id_44,'(]',1,6) + 2
8240        ,INSTRB(anc_id_44,'(]',1,7) -
8241         INSTRB(anc_id_44,'(]',1,6) - 2)
8242 ,SUBSTRB(anc_id_44
8243        ,INSTRB(anc_id_44,'(]',1,7) + 2
8244        ,LENGTHB(anc_id_44))
8245 )
8246 
8247 WHEN anc_id_45 IS NOT NULL THEN
8248   INTO xla_ae_line_acs (
8249         ae_header_id , ae_line_num , object_version_number
8250       , analytical_criterion_code
8251       , analytical_criterion_type_code
8252       , amb_context_code
8253       , ac1,ac2,ac3,ac4,ac5)
8254 VALUES (ae_header_id, ae_line_num, C_OVN
8255 ,SUBSTRB(anc_id_45
8256        ,1
8257        ,INSTRB(anc_id_45,'(]',1,1) -1)
8258 ,SUBSTRB(anc_id_45
8259        ,INSTRB(anc_id_45,'(]',1,1) + 2
8260        ,INSTRB(anc_id_45,'(]',1,2) -
8261         INSTRB(anc_id_45,'(]',1,1) - 2)
8262 ,SUBSTRB(anc_id_45
8263        ,INSTRB(anc_id_45,'(]',1,2) + 2
8264        ,INSTRB(anc_id_45,'(]',1,3) -
8265         INSTRB(anc_id_45,'(]',1,2) - 2)
8266 ,SUBSTRB(anc_id_45
8267        ,INSTRB(anc_id_45,'(]',1,3) + 2
8268        ,INSTRB(anc_id_45,'(]',1,4) -
8269         INSTRB(anc_id_45,'(]',1,3) - 2)
8270 ,SUBSTRB(anc_id_45
8271        ,INSTRB(anc_id_45,'(]',1,4) + 2
8272        ,INSTRB(anc_id_45,'(]',1,5) -
8273         INSTRB(anc_id_45,'(]',1,4) - 2)
8274 ,SUBSTRB(anc_id_45
8275        ,INSTRB(anc_id_45,'(]',1,5) + 2
8276        ,INSTRB(anc_id_45,'(]',1,6) -
8277         INSTRB(anc_id_45,'(]',1,5) - 2)
8278 ,SUBSTRB(anc_id_45
8279        ,INSTRB(anc_id_45,'(]',1,6) + 2
8280        ,INSTRB(anc_id_45,'(]',1,7) -
8281         INSTRB(anc_id_45,'(]',1,6) - 2)
8282 ,SUBSTRB(anc_id_45
8283        ,INSTRB(anc_id_45,'(]',1,7) + 2
8284        ,LENGTHB(anc_id_45))
8285 )
8286 
8287 WHEN anc_id_46 IS NOT NULL THEN
8288   INTO xla_ae_line_acs (
8289         ae_header_id , ae_line_num , object_version_number
8290       , analytical_criterion_code
8291       , analytical_criterion_type_code
8292       , amb_context_code
8293       , ac1,ac2,ac3,ac4,ac5)
8294 VALUES (ae_header_id, ae_line_num, C_OVN
8295 ,SUBSTRB(anc_id_46
8296        ,1
8297        ,INSTRB(anc_id_46,'(]',1,1) -1)
8298 ,SUBSTRB(anc_id_46
8299        ,INSTRB(anc_id_46,'(]',1,1) + 2
8300        ,INSTRB(anc_id_46,'(]',1,2) -
8301         INSTRB(anc_id_46,'(]',1,1) - 2)
8302 ,SUBSTRB(anc_id_46
8303        ,INSTRB(anc_id_46,'(]',1,2) + 2
8304        ,INSTRB(anc_id_46,'(]',1,3) -
8305         INSTRB(anc_id_46,'(]',1,2) - 2)
8306 ,SUBSTRB(anc_id_46
8307        ,INSTRB(anc_id_46,'(]',1,3) + 2
8308        ,INSTRB(anc_id_46,'(]',1,4) -
8309         INSTRB(anc_id_46,'(]',1,3) - 2)
8310 ,SUBSTRB(anc_id_46
8311        ,INSTRB(anc_id_46,'(]',1,4) + 2
8312        ,INSTRB(anc_id_46,'(]',1,5) -
8313         INSTRB(anc_id_46,'(]',1,4) - 2)
8314 ,SUBSTRB(anc_id_46
8315        ,INSTRB(anc_id_46,'(]',1,5) + 2
8316        ,INSTRB(anc_id_46,'(]',1,6) -
8317         INSTRB(anc_id_46,'(]',1,5) - 2)
8318 ,SUBSTRB(anc_id_46
8319        ,INSTRB(anc_id_46,'(]',1,6) + 2
8320        ,INSTRB(anc_id_46,'(]',1,7) -
8321         INSTRB(anc_id_46,'(]',1,6) - 2)
8322 ,SUBSTRB(anc_id_46
8323        ,INSTRB(anc_id_46,'(]',1,7) + 2
8324        ,LENGTHB(anc_id_46))
8325 )
8326 
8327 WHEN anc_id_47 IS NOT NULL THEN
8328   INTO xla_ae_line_acs (
8329         ae_header_id , ae_line_num , object_version_number
8330       , analytical_criterion_code
8331       , analytical_criterion_type_code
8332       , amb_context_code
8333       , ac1,ac2,ac3,ac4,ac5)
8334 VALUES (ae_header_id, ae_line_num, C_OVN
8335 ,SUBSTRB(anc_id_47
8336        ,1
8337        ,INSTRB(anc_id_47,'(]',1,1) -1)
8338 ,SUBSTRB(anc_id_47
8339        ,INSTRB(anc_id_47,'(]',1,1) + 2
8340        ,INSTRB(anc_id_47,'(]',1,2) -
8341         INSTRB(anc_id_47,'(]',1,1) - 2)
8342 ,SUBSTRB(anc_id_47
8343        ,INSTRB(anc_id_47,'(]',1,2) + 2
8344        ,INSTRB(anc_id_47,'(]',1,3) -
8345         INSTRB(anc_id_47,'(]',1,2) - 2)
8346 ,SUBSTRB(anc_id_47
8347        ,INSTRB(anc_id_47,'(]',1,3) + 2
8348        ,INSTRB(anc_id_47,'(]',1,4) -
8349         INSTRB(anc_id_47,'(]',1,3) - 2)
8350 ,SUBSTRB(anc_id_47
8351        ,INSTRB(anc_id_47,'(]',1,4) + 2
8352        ,INSTRB(anc_id_47,'(]',1,5) -
8353         INSTRB(anc_id_47,'(]',1,4) - 2)
8354 ,SUBSTRB(anc_id_47
8355        ,INSTRB(anc_id_47,'(]',1,5) + 2
8356        ,INSTRB(anc_id_47,'(]',1,6) -
8357         INSTRB(anc_id_47,'(]',1,5) - 2)
8358 ,SUBSTRB(anc_id_47
8359        ,INSTRB(anc_id_47,'(]',1,6) + 2
8360        ,INSTRB(anc_id_47,'(]',1,7) -
8361         INSTRB(anc_id_47,'(]',1,6) - 2)
8362 ,SUBSTRB(anc_id_47
8363        ,INSTRB(anc_id_47,'(]',1,7) + 2
8364        ,LENGTHB(anc_id_47))
8365 )
8366 
8367 WHEN anc_id_48 IS NOT NULL THEN
8368   INTO xla_ae_line_acs (
8369         ae_header_id , ae_line_num , object_version_number
8370       , analytical_criterion_code
8371       , analytical_criterion_type_code
8372       , amb_context_code
8373       , ac1,ac2,ac3,ac4,ac5)
8374 VALUES (ae_header_id, ae_line_num, C_OVN
8375 ,SUBSTRB(anc_id_48
8376        ,1
8377        ,INSTRB(anc_id_48,'(]',1,1) -1)
8378 ,SUBSTRB(anc_id_48
8379        ,INSTRB(anc_id_48,'(]',1,1) + 2
8380        ,INSTRB(anc_id_48,'(]',1,2) -
8381         INSTRB(anc_id_48,'(]',1,1) - 2)
8382 ,SUBSTRB(anc_id_48
8383        ,INSTRB(anc_id_48,'(]',1,2) + 2
8384        ,INSTRB(anc_id_48,'(]',1,3) -
8385         INSTRB(anc_id_48,'(]',1,2) - 2)
8386 ,SUBSTRB(anc_id_48
8387        ,INSTRB(anc_id_48,'(]',1,3) + 2
8388        ,INSTRB(anc_id_48,'(]',1,4) -
8389         INSTRB(anc_id_48,'(]',1,3) - 2)
8390 ,SUBSTRB(anc_id_48
8391        ,INSTRB(anc_id_48,'(]',1,4) + 2
8392        ,INSTRB(anc_id_48,'(]',1,5) -
8393         INSTRB(anc_id_48,'(]',1,4) - 2)
8394 ,SUBSTRB(anc_id_48
8395        ,INSTRB(anc_id_48,'(]',1,5) + 2
8396        ,INSTRB(anc_id_48,'(]',1,6) -
8397         INSTRB(anc_id_48,'(]',1,5) - 2)
8398 ,SUBSTRB(anc_id_48
8399        ,INSTRB(anc_id_48,'(]',1,6) + 2
8400        ,INSTRB(anc_id_48,'(]',1,7) -
8401         INSTRB(anc_id_48,'(]',1,6) - 2)
8402 ,SUBSTRB(anc_id_48
8403        ,INSTRB(anc_id_48,'(]',1,7) + 2
8404        ,LENGTHB(anc_id_48))
8405 )
8406 
8407 WHEN anc_id_49 IS NOT NULL THEN
8408   INTO xla_ae_line_acs (
8409         ae_header_id , ae_line_num , object_version_number
8410       , analytical_criterion_code
8411       , analytical_criterion_type_code
8412       , amb_context_code
8413       , ac1,ac2,ac3,ac4,ac5)
8414 VALUES (ae_header_id, ae_line_num, C_OVN
8415 ,SUBSTRB(anc_id_49
8416        ,1
8417        ,INSTRB(anc_id_49,'(]',1,1) -1)
8418 ,SUBSTRB(anc_id_49
8419        ,INSTRB(anc_id_49,'(]',1,1) + 2
8420        ,INSTRB(anc_id_49,'(]',1,2) -
8421         INSTRB(anc_id_49,'(]',1,1) - 2)
8422 ,SUBSTRB(anc_id_49
8423        ,INSTRB(anc_id_49,'(]',1,2) + 2
8424        ,INSTRB(anc_id_49,'(]',1,3) -
8425         INSTRB(anc_id_49,'(]',1,2) - 2)
8426 ,SUBSTRB(anc_id_49
8427        ,INSTRB(anc_id_49,'(]',1,3) + 2
8428        ,INSTRB(anc_id_49,'(]',1,4) -
8429         INSTRB(anc_id_49,'(]',1,3) - 2)
8430 ,SUBSTRB(anc_id_49
8431        ,INSTRB(anc_id_49,'(]',1,4) + 2
8432        ,INSTRB(anc_id_49,'(]',1,5) -
8433         INSTRB(anc_id_49,'(]',1,4) - 2)
8434 ,SUBSTRB(anc_id_49
8435        ,INSTRB(anc_id_49,'(]',1,5) + 2
8436        ,INSTRB(anc_id_49,'(]',1,6) -
8437         INSTRB(anc_id_49,'(]',1,5) - 2)
8438 ,SUBSTRB(anc_id_49
8439        ,INSTRB(anc_id_49,'(]',1,6) + 2
8440        ,INSTRB(anc_id_49,'(]',1,7) -
8441         INSTRB(anc_id_49,'(]',1,6) - 2)
8442 ,SUBSTRB(anc_id_49
8443        ,INSTRB(anc_id_49,'(]',1,7) + 2
8444        ,LENGTHB(anc_id_49))
8445 )
8446 
8447 WHEN anc_id_50 IS NOT NULL THEN
8448   INTO xla_ae_line_acs (
8449         ae_header_id , ae_line_num , object_version_number
8450       , analytical_criterion_code
8451       , analytical_criterion_type_code
8452       , amb_context_code
8453       , ac1,ac2,ac3,ac4,ac5)
8454 VALUES (ae_header_id, ae_line_num, C_OVN
8455 ,SUBSTRB(anc_id_50
8456        ,1
8457        ,INSTRB(anc_id_50,'(]',1,1) -1)
8458 ,SUBSTRB(anc_id_50
8459        ,INSTRB(anc_id_50,'(]',1,1) + 2
8460        ,INSTRB(anc_id_50,'(]',1,2) -
8461         INSTRB(anc_id_50,'(]',1,1) - 2)
8462 ,SUBSTRB(anc_id_50
8463        ,INSTRB(anc_id_50,'(]',1,2) + 2
8464        ,INSTRB(anc_id_50,'(]',1,3) -
8465         INSTRB(anc_id_50,'(]',1,2) - 2)
8466 ,SUBSTRB(anc_id_50
8467        ,INSTRB(anc_id_50,'(]',1,3) + 2
8468        ,INSTRB(anc_id_50,'(]',1,4) -
8469         INSTRB(anc_id_50,'(]',1,3) - 2)
8470 ,SUBSTRB(anc_id_50
8471        ,INSTRB(anc_id_50,'(]',1,4) + 2
8472        ,INSTRB(anc_id_50,'(]',1,5) -
8473         INSTRB(anc_id_50,'(]',1,4) - 2)
8474 ,SUBSTRB(anc_id_50
8475        ,INSTRB(anc_id_50,'(]',1,5) + 2
8476        ,INSTRB(anc_id_50,'(]',1,6) -
8477         INSTRB(anc_id_50,'(]',1,5) - 2)
8478 ,SUBSTRB(anc_id_50
8479        ,INSTRB(anc_id_50,'(]',1,6) + 2
8480        ,INSTRB(anc_id_50,'(]',1,7) -
8481         INSTRB(anc_id_50,'(]',1,6) - 2)
8482 ,SUBSTRB(anc_id_50
8483        ,INSTRB(anc_id_50,'(]',1,7) + 2
8484        ,LENGTHB(anc_id_50))
8485 )
8486 
8487 WHEN anc_id_51 IS NOT NULL THEN
8488   INTO xla_ae_line_acs (
8489         ae_header_id , ae_line_num , object_version_number
8490       , analytical_criterion_code
8491       , analytical_criterion_type_code
8492       , amb_context_code
8493       , ac1,ac2,ac3,ac4,ac5)
8494 VALUES (ae_header_id, ae_line_num, C_OVN
8495 ,SUBSTRB(anc_id_51
8496        ,1
8497        ,INSTRB(anc_id_51,'(]',1,1) -1)
8498 ,SUBSTRB(anc_id_51
8499        ,INSTRB(anc_id_51,'(]',1,1) + 2
8500        ,INSTRB(anc_id_51,'(]',1,2) -
8501         INSTRB(anc_id_51,'(]',1,1) - 2)
8502 ,SUBSTRB(anc_id_51
8503        ,INSTRB(anc_id_51,'(]',1,2) + 2
8504        ,INSTRB(anc_id_51,'(]',1,3) -
8505         INSTRB(anc_id_51,'(]',1,2) - 2)
8506 ,SUBSTRB(anc_id_51
8507        ,INSTRB(anc_id_51,'(]',1,3) + 2
8508        ,INSTRB(anc_id_51,'(]',1,4) -
8509         INSTRB(anc_id_51,'(]',1,3) - 2)
8510 ,SUBSTRB(anc_id_51
8511        ,INSTRB(anc_id_51,'(]',1,4) + 2
8512        ,INSTRB(anc_id_51,'(]',1,5) -
8513         INSTRB(anc_id_51,'(]',1,4) - 2)
8514 ,SUBSTRB(anc_id_51
8515        ,INSTRB(anc_id_51,'(]',1,5) + 2
8516        ,INSTRB(anc_id_51,'(]',1,6) -
8517         INSTRB(anc_id_51,'(]',1,5) - 2)
8518 ,SUBSTRB(anc_id_51
8519        ,INSTRB(anc_id_51,'(]',1,6) + 2
8520        ,INSTRB(anc_id_51,'(]',1,7) -
8521         INSTRB(anc_id_51,'(]',1,6) - 2)
8522 ,SUBSTRB(anc_id_51
8523        ,INSTRB(anc_id_51,'(]',1,7) + 2
8524        ,LENGTHB(anc_id_51))
8525 )
8526 
8527 WHEN anc_id_52 IS NOT NULL THEN
8528   INTO xla_ae_line_acs (
8529         ae_header_id , ae_line_num , object_version_number
8530       , analytical_criterion_code
8531       , analytical_criterion_type_code
8532       , amb_context_code
8533       , ac1,ac2,ac3,ac4,ac5)
8534 VALUES (ae_header_id, ae_line_num, C_OVN
8535 ,SUBSTRB(anc_id_52
8536        ,1
8537        ,INSTRB(anc_id_52,'(]',1,1) -1)
8538 ,SUBSTRB(anc_id_52
8539        ,INSTRB(anc_id_52,'(]',1,1) + 2
8540        ,INSTRB(anc_id_52,'(]',1,2) -
8541         INSTRB(anc_id_52,'(]',1,1) - 2)
8542 ,SUBSTRB(anc_id_52
8543        ,INSTRB(anc_id_52,'(]',1,2) + 2
8544        ,INSTRB(anc_id_52,'(]',1,3) -
8545         INSTRB(anc_id_52,'(]',1,2) - 2)
8546 ,SUBSTRB(anc_id_52
8547        ,INSTRB(anc_id_52,'(]',1,3) + 2
8548        ,INSTRB(anc_id_52,'(]',1,4) -
8549         INSTRB(anc_id_52,'(]',1,3) - 2)
8550 ,SUBSTRB(anc_id_52
8551        ,INSTRB(anc_id_52,'(]',1,4) + 2
8552        ,INSTRB(anc_id_52,'(]',1,5) -
8553         INSTRB(anc_id_52,'(]',1,4) - 2)
8554 ,SUBSTRB(anc_id_52
8555        ,INSTRB(anc_id_52,'(]',1,5) + 2
8556        ,INSTRB(anc_id_52,'(]',1,6) -
8557         INSTRB(anc_id_52,'(]',1,5) - 2)
8558 ,SUBSTRB(anc_id_52
8559        ,INSTRB(anc_id_52,'(]',1,6) + 2
8560        ,INSTRB(anc_id_52,'(]',1,7) -
8561         INSTRB(anc_id_52,'(]',1,6) - 2)
8562 ,SUBSTRB(anc_id_52
8563        ,INSTRB(anc_id_52,'(]',1,7) + 2
8564        ,LENGTHB(anc_id_52))
8565 )
8566 
8567 WHEN anc_id_53 IS NOT NULL THEN
8568   INTO xla_ae_line_acs (
8569         ae_header_id , ae_line_num , object_version_number
8570       , analytical_criterion_code
8571       , analytical_criterion_type_code
8572       , amb_context_code
8573       , ac1,ac2,ac3,ac4,ac5)
8574 VALUES (ae_header_id, ae_line_num, C_OVN
8575 ,SUBSTRB(anc_id_53
8576        ,1
8577        ,INSTRB(anc_id_53,'(]',1,1) -1)
8578 ,SUBSTRB(anc_id_53
8579        ,INSTRB(anc_id_53,'(]',1,1) + 2
8580        ,INSTRB(anc_id_53,'(]',1,2) -
8581         INSTRB(anc_id_53,'(]',1,1) - 2)
8582 ,SUBSTRB(anc_id_53
8583        ,INSTRB(anc_id_53,'(]',1,2) + 2
8584        ,INSTRB(anc_id_53,'(]',1,3) -
8585         INSTRB(anc_id_53,'(]',1,2) - 2)
8586 ,SUBSTRB(anc_id_53
8587        ,INSTRB(anc_id_53,'(]',1,3) + 2
8588        ,INSTRB(anc_id_53,'(]',1,4) -
8589         INSTRB(anc_id_53,'(]',1,3) - 2)
8590 ,SUBSTRB(anc_id_53
8591        ,INSTRB(anc_id_53,'(]',1,4) + 2
8592        ,INSTRB(anc_id_53,'(]',1,5) -
8593         INSTRB(anc_id_53,'(]',1,4) - 2)
8594 ,SUBSTRB(anc_id_53
8595        ,INSTRB(anc_id_53,'(]',1,5) + 2
8596        ,INSTRB(anc_id_53,'(]',1,6) -
8597         INSTRB(anc_id_53,'(]',1,5) - 2)
8598 ,SUBSTRB(anc_id_53
8599        ,INSTRB(anc_id_53,'(]',1,6) + 2
8600        ,INSTRB(anc_id_53,'(]',1,7) -
8601         INSTRB(anc_id_53,'(]',1,6) - 2)
8602 ,SUBSTRB(anc_id_53
8603        ,INSTRB(anc_id_53,'(]',1,7) + 2
8604        ,LENGTHB(anc_id_53))
8605 )
8606 
8607 WHEN anc_id_54 IS NOT NULL THEN
8608   INTO xla_ae_line_acs (
8609         ae_header_id , ae_line_num , object_version_number
8610       , analytical_criterion_code
8611       , analytical_criterion_type_code
8612       , amb_context_code
8613       , ac1,ac2,ac3,ac4,ac5)
8614 VALUES (ae_header_id, ae_line_num, C_OVN
8615 ,SUBSTRB(anc_id_54
8616        ,1
8617        ,INSTRB(anc_id_54,'(]',1,1) -1)
8618 ,SUBSTRB(anc_id_54
8619        ,INSTRB(anc_id_54,'(]',1,1) + 2
8620        ,INSTRB(anc_id_54,'(]',1,2) -
8621         INSTRB(anc_id_54,'(]',1,1) - 2)
8622 ,SUBSTRB(anc_id_54
8623        ,INSTRB(anc_id_54,'(]',1,2) + 2
8624        ,INSTRB(anc_id_54,'(]',1,3) -
8625         INSTRB(anc_id_54,'(]',1,2) - 2)
8626 ,SUBSTRB(anc_id_54
8627        ,INSTRB(anc_id_54,'(]',1,3) + 2
8628        ,INSTRB(anc_id_54,'(]',1,4) -
8629         INSTRB(anc_id_54,'(]',1,3) - 2)
8630 ,SUBSTRB(anc_id_54
8631        ,INSTRB(anc_id_54,'(]',1,4) + 2
8632        ,INSTRB(anc_id_54,'(]',1,5) -
8633         INSTRB(anc_id_54,'(]',1,4) - 2)
8634 ,SUBSTRB(anc_id_54
8635        ,INSTRB(anc_id_54,'(]',1,5) + 2
8636        ,INSTRB(anc_id_54,'(]',1,6) -
8637         INSTRB(anc_id_54,'(]',1,5) - 2)
8638 ,SUBSTRB(anc_id_54
8639        ,INSTRB(anc_id_54,'(]',1,6) + 2
8640        ,INSTRB(anc_id_54,'(]',1,7) -
8641         INSTRB(anc_id_54,'(]',1,6) - 2)
8642 ,SUBSTRB(anc_id_54
8643        ,INSTRB(anc_id_54,'(]',1,7) + 2
8644        ,LENGTHB(anc_id_54))
8645 )
8646 
8647 WHEN anc_id_55 IS NOT NULL THEN
8648   INTO xla_ae_line_acs (
8649         ae_header_id , ae_line_num , object_version_number
8650       , analytical_criterion_code
8651       , analytical_criterion_type_code
8652       , amb_context_code
8653       , ac1,ac2,ac3,ac4,ac5)
8654 VALUES (ae_header_id, ae_line_num, C_OVN
8655 ,SUBSTRB(anc_id_55
8656        ,1
8657        ,INSTRB(anc_id_55,'(]',1,1) -1)
8658 ,SUBSTRB(anc_id_55
8659        ,INSTRB(anc_id_55,'(]',1,1) + 2
8660        ,INSTRB(anc_id_55,'(]',1,2) -
8661         INSTRB(anc_id_55,'(]',1,1) - 2)
8662 ,SUBSTRB(anc_id_55
8663        ,INSTRB(anc_id_55,'(]',1,2) + 2
8664        ,INSTRB(anc_id_55,'(]',1,3) -
8665         INSTRB(anc_id_55,'(]',1,2) - 2)
8666 ,SUBSTRB(anc_id_55
8667        ,INSTRB(anc_id_55,'(]',1,3) + 2
8668        ,INSTRB(anc_id_55,'(]',1,4) -
8669         INSTRB(anc_id_55,'(]',1,3) - 2)
8670 ,SUBSTRB(anc_id_55
8671        ,INSTRB(anc_id_55,'(]',1,4) + 2
8672        ,INSTRB(anc_id_55,'(]',1,5) -
8673         INSTRB(anc_id_55,'(]',1,4) - 2)
8674 ,SUBSTRB(anc_id_55
8675        ,INSTRB(anc_id_55,'(]',1,5) + 2
8676        ,INSTRB(anc_id_55,'(]',1,6) -
8677         INSTRB(anc_id_55,'(]',1,5) - 2)
8678 ,SUBSTRB(anc_id_55
8679        ,INSTRB(anc_id_55,'(]',1,6) + 2
8680        ,INSTRB(anc_id_55,'(]',1,7) -
8681         INSTRB(anc_id_55,'(]',1,6) - 2)
8682 ,SUBSTRB(anc_id_55
8683        ,INSTRB(anc_id_55,'(]',1,7) + 2
8684        ,LENGTHB(anc_id_55))
8685 )
8686 
8687 WHEN anc_id_56 IS NOT NULL THEN
8688   INTO xla_ae_line_acs (
8689         ae_header_id , ae_line_num , object_version_number
8690       , analytical_criterion_code
8691       , analytical_criterion_type_code
8692       , amb_context_code
8693       , ac1,ac2,ac3,ac4,ac5)
8694 VALUES (ae_header_id, ae_line_num, C_OVN
8695 ,SUBSTRB(anc_id_56
8696        ,1
8697        ,INSTRB(anc_id_56,'(]',1,1) -1)
8698 ,SUBSTRB(anc_id_56
8699        ,INSTRB(anc_id_56,'(]',1,1) + 2
8700        ,INSTRB(anc_id_56,'(]',1,2) -
8701         INSTRB(anc_id_56,'(]',1,1) - 2)
8702 ,SUBSTRB(anc_id_56
8703        ,INSTRB(anc_id_56,'(]',1,2) + 2
8704        ,INSTRB(anc_id_56,'(]',1,3) -
8705         INSTRB(anc_id_56,'(]',1,2) - 2)
8706 ,SUBSTRB(anc_id_56
8707        ,INSTRB(anc_id_56,'(]',1,3) + 2
8708        ,INSTRB(anc_id_56,'(]',1,4) -
8709         INSTRB(anc_id_56,'(]',1,3) - 2)
8710 ,SUBSTRB(anc_id_56
8711        ,INSTRB(anc_id_56,'(]',1,4) + 2
8712        ,INSTRB(anc_id_56,'(]',1,5) -
8713         INSTRB(anc_id_56,'(]',1,4) - 2)
8714 ,SUBSTRB(anc_id_56
8715        ,INSTRB(anc_id_56,'(]',1,5) + 2
8716        ,INSTRB(anc_id_56,'(]',1,6) -
8717         INSTRB(anc_id_56,'(]',1,5) - 2)
8718 ,SUBSTRB(anc_id_56
8719        ,INSTRB(anc_id_56,'(]',1,6) + 2
8720        ,INSTRB(anc_id_56,'(]',1,7) -
8721         INSTRB(anc_id_56,'(]',1,6) - 2)
8722 ,SUBSTRB(anc_id_56
8723        ,INSTRB(anc_id_56,'(]',1,7) + 2
8724        ,LENGTHB(anc_id_56))
8725 )
8726 
8727 WHEN anc_id_57 IS NOT NULL THEN
8728   INTO xla_ae_line_acs (
8729         ae_header_id , ae_line_num , object_version_number
8730       , analytical_criterion_code
8731       , analytical_criterion_type_code
8732       , amb_context_code
8733       , ac1,ac2,ac3,ac4,ac5)
8734 VALUES (ae_header_id, ae_line_num, C_OVN
8735 ,SUBSTRB(anc_id_57
8736        ,1
8737        ,INSTRB(anc_id_57,'(]',1,1) -1)
8738 ,SUBSTRB(anc_id_57
8739        ,INSTRB(anc_id_57,'(]',1,1) + 2
8740        ,INSTRB(anc_id_57,'(]',1,2) -
8741         INSTRB(anc_id_57,'(]',1,1) - 2)
8742 ,SUBSTRB(anc_id_57
8743        ,INSTRB(anc_id_57,'(]',1,2) + 2
8744        ,INSTRB(anc_id_57,'(]',1,3) -
8745         INSTRB(anc_id_57,'(]',1,2) - 2)
8746 ,SUBSTRB(anc_id_57
8747        ,INSTRB(anc_id_57,'(]',1,3) + 2
8748        ,INSTRB(anc_id_57,'(]',1,4) -
8749         INSTRB(anc_id_57,'(]',1,3) - 2)
8750 ,SUBSTRB(anc_id_57
8751        ,INSTRB(anc_id_57,'(]',1,4) + 2
8752        ,INSTRB(anc_id_57,'(]',1,5) -
8753         INSTRB(anc_id_57,'(]',1,4) - 2)
8754 ,SUBSTRB(anc_id_57
8755        ,INSTRB(anc_id_57,'(]',1,5) + 2
8756        ,INSTRB(anc_id_57,'(]',1,6) -
8757         INSTRB(anc_id_57,'(]',1,5) - 2)
8758 ,SUBSTRB(anc_id_57
8759        ,INSTRB(anc_id_57,'(]',1,6) + 2
8760        ,INSTRB(anc_id_57,'(]',1,7) -
8761         INSTRB(anc_id_57,'(]',1,6) - 2)
8762 ,SUBSTRB(anc_id_57
8763        ,INSTRB(anc_id_57,'(]',1,7) + 2
8764        ,LENGTHB(anc_id_57))
8765 )
8766 
8767 WHEN anc_id_58 IS NOT NULL THEN
8768   INTO xla_ae_line_acs (
8769         ae_header_id , ae_line_num , object_version_number
8770       , analytical_criterion_code
8771       , analytical_criterion_type_code
8772       , amb_context_code
8773       , ac1,ac2,ac3,ac4,ac5)
8774 VALUES (ae_header_id, ae_line_num, C_OVN
8775 ,SUBSTRB(anc_id_58
8776        ,1
8777        ,INSTRB(anc_id_58,'(]',1,1) -1)
8778 ,SUBSTRB(anc_id_58
8779        ,INSTRB(anc_id_58,'(]',1,1) + 2
8780        ,INSTRB(anc_id_58,'(]',1,2) -
8781         INSTRB(anc_id_58,'(]',1,1) - 2)
8782 ,SUBSTRB(anc_id_58
8783        ,INSTRB(anc_id_58,'(]',1,2) + 2
8784        ,INSTRB(anc_id_58,'(]',1,3) -
8785         INSTRB(anc_id_58,'(]',1,2) - 2)
8786 ,SUBSTRB(anc_id_58
8787        ,INSTRB(anc_id_58,'(]',1,3) + 2
8788        ,INSTRB(anc_id_58,'(]',1,4) -
8789         INSTRB(anc_id_58,'(]',1,3) - 2)
8790 ,SUBSTRB(anc_id_58
8791        ,INSTRB(anc_id_58,'(]',1,4) + 2
8792        ,INSTRB(anc_id_58,'(]',1,5) -
8793         INSTRB(anc_id_58,'(]',1,4) - 2)
8794 ,SUBSTRB(anc_id_58
8795        ,INSTRB(anc_id_58,'(]',1,5) + 2
8796        ,INSTRB(anc_id_58,'(]',1,6) -
8797         INSTRB(anc_id_58,'(]',1,5) - 2)
8798 ,SUBSTRB(anc_id_58
8799        ,INSTRB(anc_id_58,'(]',1,6) + 2
8800        ,INSTRB(anc_id_58,'(]',1,7) -
8801         INSTRB(anc_id_58,'(]',1,6) - 2)
8802 ,SUBSTRB(anc_id_58
8803        ,INSTRB(anc_id_58,'(]',1,7) + 2
8804        ,LENGTHB(anc_id_58))
8805 )
8806 
8807 WHEN anc_id_59 IS NOT NULL THEN
8808   INTO xla_ae_line_acs (
8809         ae_header_id , ae_line_num , object_version_number
8810       , analytical_criterion_code
8811       , analytical_criterion_type_code
8812       , amb_context_code
8813       , ac1,ac2,ac3,ac4,ac5)
8814 VALUES (ae_header_id, ae_line_num, C_OVN
8815 ,SUBSTRB(anc_id_59
8816        ,1
8817        ,INSTRB(anc_id_59,'(]',1,1) -1)
8818 ,SUBSTRB(anc_id_59
8819        ,INSTRB(anc_id_59,'(]',1,1) + 2
8820        ,INSTRB(anc_id_59,'(]',1,2) -
8821         INSTRB(anc_id_59,'(]',1,1) - 2)
8822 ,SUBSTRB(anc_id_59
8823        ,INSTRB(anc_id_59,'(]',1,2) + 2
8824        ,INSTRB(anc_id_59,'(]',1,3) -
8825         INSTRB(anc_id_59,'(]',1,2) - 2)
8826 ,SUBSTRB(anc_id_59
8827        ,INSTRB(anc_id_59,'(]',1,3) + 2
8828        ,INSTRB(anc_id_59,'(]',1,4) -
8829         INSTRB(anc_id_59,'(]',1,3) - 2)
8830 ,SUBSTRB(anc_id_59
8831        ,INSTRB(anc_id_59,'(]',1,4) + 2
8832        ,INSTRB(anc_id_59,'(]',1,5) -
8833         INSTRB(anc_id_59,'(]',1,4) - 2)
8834 ,SUBSTRB(anc_id_59
8835        ,INSTRB(anc_id_59,'(]',1,5) + 2
8836        ,INSTRB(anc_id_59,'(]',1,6) -
8837         INSTRB(anc_id_59,'(]',1,5) - 2)
8838 ,SUBSTRB(anc_id_59
8839        ,INSTRB(anc_id_59,'(]',1,6) + 2
8840        ,INSTRB(anc_id_59,'(]',1,7) -
8841         INSTRB(anc_id_59,'(]',1,6) - 2)
8842 ,SUBSTRB(anc_id_59
8843        ,INSTRB(anc_id_59,'(]',1,7) + 2
8844        ,LENGTHB(anc_id_59))
8845 )
8846 
8847 WHEN anc_id_60 IS NOT NULL THEN
8848   INTO xla_ae_line_acs (
8849         ae_header_id , ae_line_num , object_version_number
8850       , analytical_criterion_code
8851       , analytical_criterion_type_code
8852       , amb_context_code
8853       , ac1,ac2,ac3,ac4,ac5)
8854 VALUES (ae_header_id, ae_line_num, C_OVN
8855 ,SUBSTRB(anc_id_60
8856        ,1
8857        ,INSTRB(anc_id_60,'(]',1,1) -1)
8858 ,SUBSTRB(anc_id_60
8859        ,INSTRB(anc_id_60,'(]',1,1) + 2
8860        ,INSTRB(anc_id_60,'(]',1,2) -
8861         INSTRB(anc_id_60,'(]',1,1) - 2)
8862 ,SUBSTRB(anc_id_60
8863        ,INSTRB(anc_id_60,'(]',1,2) + 2
8864        ,INSTRB(anc_id_60,'(]',1,3) -
8865         INSTRB(anc_id_60,'(]',1,2) - 2)
8866 ,SUBSTRB(anc_id_60
8867        ,INSTRB(anc_id_60,'(]',1,3) + 2
8868        ,INSTRB(anc_id_60,'(]',1,4) -
8869         INSTRB(anc_id_60,'(]',1,3) - 2)
8870 ,SUBSTRB(anc_id_60
8871        ,INSTRB(anc_id_60,'(]',1,4) + 2
8872        ,INSTRB(anc_id_60,'(]',1,5) -
8873         INSTRB(anc_id_60,'(]',1,4) - 2)
8874 ,SUBSTRB(anc_id_60
8875        ,INSTRB(anc_id_60,'(]',1,5) + 2
8876        ,INSTRB(anc_id_60,'(]',1,6) -
8877         INSTRB(anc_id_60,'(]',1,5) - 2)
8878 ,SUBSTRB(anc_id_60
8879        ,INSTRB(anc_id_60,'(]',1,6) + 2
8880        ,INSTRB(anc_id_60,'(]',1,7) -
8881         INSTRB(anc_id_60,'(]',1,6) - 2)
8882 ,SUBSTRB(anc_id_60
8883        ,INSTRB(anc_id_60,'(]',1,7) + 2
8884        ,LENGTHB(anc_id_60))
8885 )
8886 
8887 WHEN anc_id_61 IS NOT NULL THEN
8888   INTO xla_ae_line_acs (
8889         ae_header_id , ae_line_num , object_version_number
8890       , analytical_criterion_code
8891       , analytical_criterion_type_code
8892       , amb_context_code
8893       , ac1,ac2,ac3,ac4,ac5)
8894 VALUES (ae_header_id, ae_line_num, C_OVN
8895 ,SUBSTRB(anc_id_61
8896        ,1
8897        ,INSTRB(anc_id_61,'(]',1,1) -1)
8898 ,SUBSTRB(anc_id_61
8899        ,INSTRB(anc_id_61,'(]',1,1) + 2
8900        ,INSTRB(anc_id_61,'(]',1,2) -
8901         INSTRB(anc_id_61,'(]',1,1) - 2)
8902 ,SUBSTRB(anc_id_61
8903        ,INSTRB(anc_id_61,'(]',1,2) + 2
8904        ,INSTRB(anc_id_61,'(]',1,3) -
8905         INSTRB(anc_id_61,'(]',1,2) - 2)
8906 ,SUBSTRB(anc_id_61
8907        ,INSTRB(anc_id_61,'(]',1,3) + 2
8908        ,INSTRB(anc_id_61,'(]',1,4) -
8909         INSTRB(anc_id_61,'(]',1,3) - 2)
8910 ,SUBSTRB(anc_id_61
8911        ,INSTRB(anc_id_61,'(]',1,4) + 2
8912        ,INSTRB(anc_id_61,'(]',1,5) -
8913         INSTRB(anc_id_61,'(]',1,4) - 2)
8914 ,SUBSTRB(anc_id_61
8915        ,INSTRB(anc_id_61,'(]',1,5) + 2
8916        ,INSTRB(anc_id_61,'(]',1,6) -
8917         INSTRB(anc_id_61,'(]',1,5) - 2)
8918 ,SUBSTRB(anc_id_61
8919        ,INSTRB(anc_id_61,'(]',1,6) + 2
8920        ,INSTRB(anc_id_61,'(]',1,7) -
8921         INSTRB(anc_id_61,'(]',1,6) - 2)
8922 ,SUBSTRB(anc_id_61
8923        ,INSTRB(anc_id_61,'(]',1,7) + 2
8924        ,LENGTHB(anc_id_61))
8925 )
8926 
8927 WHEN anc_id_62 IS NOT NULL THEN
8928   INTO xla_ae_line_acs (
8929         ae_header_id , ae_line_num , object_version_number
8930       , analytical_criterion_code
8931       , analytical_criterion_type_code
8932       , amb_context_code
8933       , ac1,ac2,ac3,ac4,ac5)
8934 VALUES (ae_header_id, ae_line_num, C_OVN
8935 ,SUBSTRB(anc_id_62
8936        ,1
8937        ,INSTRB(anc_id_62,'(]',1,1) -1)
8938 ,SUBSTRB(anc_id_62
8939        ,INSTRB(anc_id_62,'(]',1,1) + 2
8940        ,INSTRB(anc_id_62,'(]',1,2) -
8941         INSTRB(anc_id_62,'(]',1,1) - 2)
8942 ,SUBSTRB(anc_id_62
8943        ,INSTRB(anc_id_62,'(]',1,2) + 2
8944        ,INSTRB(anc_id_62,'(]',1,3) -
8945         INSTRB(anc_id_62,'(]',1,2) - 2)
8946 ,SUBSTRB(anc_id_62
8947        ,INSTRB(anc_id_62,'(]',1,3) + 2
8948        ,INSTRB(anc_id_62,'(]',1,4) -
8949         INSTRB(anc_id_62,'(]',1,3) - 2)
8950 ,SUBSTRB(anc_id_62
8951        ,INSTRB(anc_id_62,'(]',1,4) + 2
8952        ,INSTRB(anc_id_62,'(]',1,5) -
8953         INSTRB(anc_id_62,'(]',1,4) - 2)
8954 ,SUBSTRB(anc_id_62
8955        ,INSTRB(anc_id_62,'(]',1,5) + 2
8956        ,INSTRB(anc_id_62,'(]',1,6) -
8957         INSTRB(anc_id_62,'(]',1,5) - 2)
8958 ,SUBSTRB(anc_id_62
8959        ,INSTRB(anc_id_62,'(]',1,6) + 2
8960        ,INSTRB(anc_id_62,'(]',1,7) -
8961         INSTRB(anc_id_62,'(]',1,6) - 2)
8962 ,SUBSTRB(anc_id_62
8963        ,INSTRB(anc_id_62,'(]',1,7) + 2
8964        ,LENGTHB(anc_id_62))
8965 )
8966 
8967 WHEN anc_id_63 IS NOT NULL THEN
8968   INTO xla_ae_line_acs (
8969         ae_header_id , ae_line_num , object_version_number
8970       , analytical_criterion_code
8971       , analytical_criterion_type_code
8972       , amb_context_code
8973       , ac1,ac2,ac3,ac4,ac5)
8974 VALUES (ae_header_id, ae_line_num, C_OVN
8975 ,SUBSTRB(anc_id_63
8976        ,1
8977        ,INSTRB(anc_id_63,'(]',1,1) -1)
8978 ,SUBSTRB(anc_id_63
8979        ,INSTRB(anc_id_63,'(]',1,1) + 2
8980        ,INSTRB(anc_id_63,'(]',1,2) -
8981         INSTRB(anc_id_63,'(]',1,1) - 2)
8982 ,SUBSTRB(anc_id_63
8983        ,INSTRB(anc_id_63,'(]',1,2) + 2
8984        ,INSTRB(anc_id_63,'(]',1,3) -
8985         INSTRB(anc_id_63,'(]',1,2) - 2)
8986 ,SUBSTRB(anc_id_63
8987        ,INSTRB(anc_id_63,'(]',1,3) + 2
8988        ,INSTRB(anc_id_63,'(]',1,4) -
8989         INSTRB(anc_id_63,'(]',1,3) - 2)
8990 ,SUBSTRB(anc_id_63
8991        ,INSTRB(anc_id_63,'(]',1,4) + 2
8992        ,INSTRB(anc_id_63,'(]',1,5) -
8993         INSTRB(anc_id_63,'(]',1,4) - 2)
8994 ,SUBSTRB(anc_id_63
8995        ,INSTRB(anc_id_63,'(]',1,5) + 2
8996        ,INSTRB(anc_id_63,'(]',1,6) -
8997         INSTRB(anc_id_63,'(]',1,5) - 2)
8998 ,SUBSTRB(anc_id_63
8999        ,INSTRB(anc_id_63,'(]',1,6) + 2
9000        ,INSTRB(anc_id_63,'(]',1,7) -
9001         INSTRB(anc_id_63,'(]',1,6) - 2)
9002 ,SUBSTRB(anc_id_63
9003        ,INSTRB(anc_id_63,'(]',1,7) + 2
9004        ,LENGTHB(anc_id_63))
9005 )
9006 
9007 WHEN anc_id_64 IS NOT NULL THEN
9008   INTO xla_ae_line_acs (
9009         ae_header_id , ae_line_num , object_version_number
9010       , analytical_criterion_code
9011       , analytical_criterion_type_code
9012       , amb_context_code
9013       , ac1,ac2,ac3,ac4,ac5)
9014 VALUES (ae_header_id, ae_line_num, C_OVN
9015 ,SUBSTRB(anc_id_64
9016        ,1
9017        ,INSTRB(anc_id_64,'(]',1,1) -1)
9018 ,SUBSTRB(anc_id_64
9019        ,INSTRB(anc_id_64,'(]',1,1) + 2
9020        ,INSTRB(anc_id_64,'(]',1,2) -
9021         INSTRB(anc_id_64,'(]',1,1) - 2)
9022 ,SUBSTRB(anc_id_64
9023        ,INSTRB(anc_id_64,'(]',1,2) + 2
9024        ,INSTRB(anc_id_64,'(]',1,3) -
9025         INSTRB(anc_id_64,'(]',1,2) - 2)
9026 ,SUBSTRB(anc_id_64
9027        ,INSTRB(anc_id_64,'(]',1,3) + 2
9028        ,INSTRB(anc_id_64,'(]',1,4) -
9029         INSTRB(anc_id_64,'(]',1,3) - 2)
9030 ,SUBSTRB(anc_id_64
9031        ,INSTRB(anc_id_64,'(]',1,4) + 2
9032        ,INSTRB(anc_id_64,'(]',1,5) -
9033         INSTRB(anc_id_64,'(]',1,4) - 2)
9034 ,SUBSTRB(anc_id_64
9035        ,INSTRB(anc_id_64,'(]',1,5) + 2
9036        ,INSTRB(anc_id_64,'(]',1,6) -
9037         INSTRB(anc_id_64,'(]',1,5) - 2)
9038 ,SUBSTRB(anc_id_64
9039        ,INSTRB(anc_id_64,'(]',1,6) + 2
9040        ,INSTRB(anc_id_64,'(]',1,7) -
9041         INSTRB(anc_id_64,'(]',1,6) - 2)
9042 ,SUBSTRB(anc_id_64
9043        ,INSTRB(anc_id_64,'(]',1,7) + 2
9044        ,LENGTHB(anc_id_64))
9045 )
9046 
9047 WHEN anc_id_65 IS NOT NULL THEN
9048   INTO xla_ae_line_acs (
9049         ae_header_id , ae_line_num , object_version_number
9050       , analytical_criterion_code
9051       , analytical_criterion_type_code
9052       , amb_context_code
9053       , ac1,ac2,ac3,ac4,ac5)
9054 VALUES (ae_header_id, ae_line_num, C_OVN
9055 ,SUBSTRB(anc_id_65
9056        ,1
9057        ,INSTRB(anc_id_65,'(]',1,1) -1)
9058 ,SUBSTRB(anc_id_65
9059        ,INSTRB(anc_id_65,'(]',1,1) + 2
9060        ,INSTRB(anc_id_65,'(]',1,2) -
9061         INSTRB(anc_id_65,'(]',1,1) - 2)
9062 ,SUBSTRB(anc_id_65
9063        ,INSTRB(anc_id_65,'(]',1,2) + 2
9064        ,INSTRB(anc_id_65,'(]',1,3) -
9065         INSTRB(anc_id_65,'(]',1,2) - 2)
9066 ,SUBSTRB(anc_id_65
9067        ,INSTRB(anc_id_65,'(]',1,3) + 2
9068        ,INSTRB(anc_id_65,'(]',1,4) -
9069         INSTRB(anc_id_65,'(]',1,3) - 2)
9070 ,SUBSTRB(anc_id_65
9071        ,INSTRB(anc_id_65,'(]',1,4) + 2
9072        ,INSTRB(anc_id_65,'(]',1,5) -
9073         INSTRB(anc_id_65,'(]',1,4) - 2)
9074 ,SUBSTRB(anc_id_65
9075        ,INSTRB(anc_id_65,'(]',1,5) + 2
9076        ,INSTRB(anc_id_65,'(]',1,6) -
9077         INSTRB(anc_id_65,'(]',1,5) - 2)
9078 ,SUBSTRB(anc_id_65
9079        ,INSTRB(anc_id_65,'(]',1,6) + 2
9080        ,INSTRB(anc_id_65,'(]',1,7) -
9081         INSTRB(anc_id_65,'(]',1,6) - 2)
9082 ,SUBSTRB(anc_id_65
9083        ,INSTRB(anc_id_65,'(]',1,7) + 2
9084        ,LENGTHB(anc_id_65))
9085 )
9086 
9087 WHEN anc_id_66 IS NOT NULL THEN
9088   INTO xla_ae_line_acs (
9089         ae_header_id , ae_line_num , object_version_number
9090       , analytical_criterion_code
9091       , analytical_criterion_type_code
9092       , amb_context_code
9093       , ac1,ac2,ac3,ac4,ac5)
9094 VALUES (ae_header_id, ae_line_num, C_OVN
9095 ,SUBSTRB(anc_id_66
9096        ,1
9097        ,INSTRB(anc_id_66,'(]',1,1) -1)
9098 ,SUBSTRB(anc_id_66
9099        ,INSTRB(anc_id_66,'(]',1,1) + 2
9100        ,INSTRB(anc_id_66,'(]',1,2) -
9101         INSTRB(anc_id_66,'(]',1,1) - 2)
9102 ,SUBSTRB(anc_id_66
9103        ,INSTRB(anc_id_66,'(]',1,2) + 2
9104        ,INSTRB(anc_id_66,'(]',1,3) -
9105         INSTRB(anc_id_66,'(]',1,2) - 2)
9106 ,SUBSTRB(anc_id_66
9107        ,INSTRB(anc_id_66,'(]',1,3) + 2
9108        ,INSTRB(anc_id_66,'(]',1,4) -
9109         INSTRB(anc_id_66,'(]',1,3) - 2)
9110 ,SUBSTRB(anc_id_66
9111        ,INSTRB(anc_id_66,'(]',1,4) + 2
9112        ,INSTRB(anc_id_66,'(]',1,5) -
9113         INSTRB(anc_id_66,'(]',1,4) - 2)
9114 ,SUBSTRB(anc_id_66
9115        ,INSTRB(anc_id_66,'(]',1,5) + 2
9116        ,INSTRB(anc_id_66,'(]',1,6) -
9117         INSTRB(anc_id_66,'(]',1,5) - 2)
9118 ,SUBSTRB(anc_id_66
9119        ,INSTRB(anc_id_66,'(]',1,6) + 2
9120        ,INSTRB(anc_id_66,'(]',1,7) -
9121         INSTRB(anc_id_66,'(]',1,6) - 2)
9122 ,SUBSTRB(anc_id_66
9123        ,INSTRB(anc_id_66,'(]',1,7) + 2
9124        ,LENGTHB(anc_id_66))
9125 )
9126 
9127 WHEN anc_id_67 IS NOT NULL THEN
9128   INTO xla_ae_line_acs (
9129         ae_header_id , ae_line_num , object_version_number
9130       , analytical_criterion_code
9131       , analytical_criterion_type_code
9132       , amb_context_code
9133       , ac1,ac2,ac3,ac4,ac5)
9134 VALUES (ae_header_id, ae_line_num, C_OVN
9135 ,SUBSTRB(anc_id_67
9136        ,1
9137        ,INSTRB(anc_id_67,'(]',1,1) -1)
9138 ,SUBSTRB(anc_id_67
9139        ,INSTRB(anc_id_67,'(]',1,1) + 2
9140        ,INSTRB(anc_id_67,'(]',1,2) -
9141         INSTRB(anc_id_67,'(]',1,1) - 2)
9142 ,SUBSTRB(anc_id_67
9143        ,INSTRB(anc_id_67,'(]',1,2) + 2
9144        ,INSTRB(anc_id_67,'(]',1,3) -
9145         INSTRB(anc_id_67,'(]',1,2) - 2)
9146 ,SUBSTRB(anc_id_67
9147        ,INSTRB(anc_id_67,'(]',1,3) + 2
9148        ,INSTRB(anc_id_67,'(]',1,4) -
9149         INSTRB(anc_id_67,'(]',1,3) - 2)
9150 ,SUBSTRB(anc_id_67
9151        ,INSTRB(anc_id_67,'(]',1,4) + 2
9152        ,INSTRB(anc_id_67,'(]',1,5) -
9153         INSTRB(anc_id_67,'(]',1,4) - 2)
9154 ,SUBSTRB(anc_id_67
9155        ,INSTRB(anc_id_67,'(]',1,5) + 2
9156        ,INSTRB(anc_id_67,'(]',1,6) -
9157         INSTRB(anc_id_67,'(]',1,5) - 2)
9158 ,SUBSTRB(anc_id_67
9159        ,INSTRB(anc_id_67,'(]',1,6) + 2
9160        ,INSTRB(anc_id_67,'(]',1,7) -
9161         INSTRB(anc_id_67,'(]',1,6) - 2)
9162 ,SUBSTRB(anc_id_67
9163        ,INSTRB(anc_id_67,'(]',1,7) + 2
9164        ,LENGTHB(anc_id_67))
9165 )
9166 
9167 WHEN anc_id_68 IS NOT NULL THEN
9168   INTO xla_ae_line_acs (
9169         ae_header_id , ae_line_num , object_version_number
9170       , analytical_criterion_code
9171       , analytical_criterion_type_code
9172       , amb_context_code
9173       , ac1,ac2,ac3,ac4,ac5)
9174 VALUES (ae_header_id, ae_line_num, C_OVN
9175 ,SUBSTRB(anc_id_68
9176        ,1
9177        ,INSTRB(anc_id_68,'(]',1,1) -1)
9178 ,SUBSTRB(anc_id_68
9179        ,INSTRB(anc_id_68,'(]',1,1) + 2
9180        ,INSTRB(anc_id_68,'(]',1,2) -
9181         INSTRB(anc_id_68,'(]',1,1) - 2)
9182 ,SUBSTRB(anc_id_68
9183        ,INSTRB(anc_id_68,'(]',1,2) + 2
9184        ,INSTRB(anc_id_68,'(]',1,3) -
9185         INSTRB(anc_id_68,'(]',1,2) - 2)
9186 ,SUBSTRB(anc_id_68
9187        ,INSTRB(anc_id_68,'(]',1,3) + 2
9188        ,INSTRB(anc_id_68,'(]',1,4) -
9189         INSTRB(anc_id_68,'(]',1,3) - 2)
9190 ,SUBSTRB(anc_id_68
9191        ,INSTRB(anc_id_68,'(]',1,4) + 2
9192        ,INSTRB(anc_id_68,'(]',1,5) -
9193         INSTRB(anc_id_68,'(]',1,4) - 2)
9194 ,SUBSTRB(anc_id_68
9195        ,INSTRB(anc_id_68,'(]',1,5) + 2
9196        ,INSTRB(anc_id_68,'(]',1,6) -
9197         INSTRB(anc_id_68,'(]',1,5) - 2)
9198 ,SUBSTRB(anc_id_68
9199        ,INSTRB(anc_id_68,'(]',1,6) + 2
9200        ,INSTRB(anc_id_68,'(]',1,7) -
9201         INSTRB(anc_id_68,'(]',1,6) - 2)
9202 ,SUBSTRB(anc_id_68
9203        ,INSTRB(anc_id_68,'(]',1,7) + 2
9204        ,LENGTHB(anc_id_68))
9205 )
9206 
9207 WHEN anc_id_69 IS NOT NULL THEN
9208   INTO xla_ae_line_acs (
9209         ae_header_id , ae_line_num , object_version_number
9210       , analytical_criterion_code
9211       , analytical_criterion_type_code
9212       , amb_context_code
9213       , ac1,ac2,ac3,ac4,ac5)
9214 VALUES (ae_header_id, ae_line_num, C_OVN
9215 ,SUBSTRB(anc_id_69
9216        ,1
9217        ,INSTRB(anc_id_69,'(]',1,1) -1)
9218 ,SUBSTRB(anc_id_69
9219        ,INSTRB(anc_id_69,'(]',1,1) + 2
9220        ,INSTRB(anc_id_69,'(]',1,2) -
9221         INSTRB(anc_id_69,'(]',1,1) - 2)
9222 ,SUBSTRB(anc_id_69
9223        ,INSTRB(anc_id_69,'(]',1,2) + 2
9224        ,INSTRB(anc_id_69,'(]',1,3) -
9225         INSTRB(anc_id_69,'(]',1,2) - 2)
9226 ,SUBSTRB(anc_id_69
9227        ,INSTRB(anc_id_69,'(]',1,3) + 2
9228        ,INSTRB(anc_id_69,'(]',1,4) -
9229         INSTRB(anc_id_69,'(]',1,3) - 2)
9230 ,SUBSTRB(anc_id_69
9231        ,INSTRB(anc_id_69,'(]',1,4) + 2
9232        ,INSTRB(anc_id_69,'(]',1,5) -
9233         INSTRB(anc_id_69,'(]',1,4) - 2)
9234 ,SUBSTRB(anc_id_69
9235        ,INSTRB(anc_id_69,'(]',1,5) + 2
9236        ,INSTRB(anc_id_69,'(]',1,6) -
9237         INSTRB(anc_id_69,'(]',1,5) - 2)
9238 ,SUBSTRB(anc_id_69
9239        ,INSTRB(anc_id_69,'(]',1,6) + 2
9240        ,INSTRB(anc_id_69,'(]',1,7) -
9241         INSTRB(anc_id_69,'(]',1,6) - 2)
9242 ,SUBSTRB(anc_id_69
9243        ,INSTRB(anc_id_69,'(]',1,7) + 2
9244        ,LENGTHB(anc_id_69))
9245 )
9246 
9247 WHEN anc_id_70 IS NOT NULL THEN
9248   INTO xla_ae_line_acs (
9249         ae_header_id , ae_line_num , object_version_number
9250       , analytical_criterion_code
9251       , analytical_criterion_type_code
9252       , amb_context_code
9253       , ac1,ac2,ac3,ac4,ac5)
9254 VALUES (ae_header_id, ae_line_num, C_OVN
9255 ,SUBSTRB(anc_id_70
9256        ,1
9257        ,INSTRB(anc_id_70,'(]',1,1) -1)
9258 ,SUBSTRB(anc_id_70
9259        ,INSTRB(anc_id_70,'(]',1,1) + 2
9260        ,INSTRB(anc_id_70,'(]',1,2) -
9261         INSTRB(anc_id_70,'(]',1,1) - 2)
9262 ,SUBSTRB(anc_id_70
9263        ,INSTRB(anc_id_70,'(]',1,2) + 2
9264        ,INSTRB(anc_id_70,'(]',1,3) -
9265         INSTRB(anc_id_70,'(]',1,2) - 2)
9266 ,SUBSTRB(anc_id_70
9267        ,INSTRB(anc_id_70,'(]',1,3) + 2
9268        ,INSTRB(anc_id_70,'(]',1,4) -
9269         INSTRB(anc_id_70,'(]',1,3) - 2)
9270 ,SUBSTRB(anc_id_70
9271        ,INSTRB(anc_id_70,'(]',1,4) + 2
9272        ,INSTRB(anc_id_70,'(]',1,5) -
9273         INSTRB(anc_id_70,'(]',1,4) - 2)
9274 ,SUBSTRB(anc_id_70
9275        ,INSTRB(anc_id_70,'(]',1,5) + 2
9276        ,INSTRB(anc_id_70,'(]',1,6) -
9277         INSTRB(anc_id_70,'(]',1,5) - 2)
9278 ,SUBSTRB(anc_id_70
9279        ,INSTRB(anc_id_70,'(]',1,6) + 2
9280        ,INSTRB(anc_id_70,'(]',1,7) -
9281         INSTRB(anc_id_70,'(]',1,6) - 2)
9282 ,SUBSTRB(anc_id_70
9283        ,INSTRB(anc_id_70,'(]',1,7) + 2
9284        ,LENGTHB(anc_id_70))
9285 )
9286 
9287 WHEN anc_id_71 IS NOT NULL THEN
9288   INTO xla_ae_line_acs (
9289         ae_header_id , ae_line_num , object_version_number
9290       , analytical_criterion_code
9291       , analytical_criterion_type_code
9292       , amb_context_code
9293       , ac1,ac2,ac3,ac4,ac5)
9294 VALUES (ae_header_id, ae_line_num, C_OVN
9295 ,SUBSTRB(anc_id_71
9296        ,1
9297        ,INSTRB(anc_id_71,'(]',1,1) -1)
9298 ,SUBSTRB(anc_id_71
9299        ,INSTRB(anc_id_71,'(]',1,1) + 2
9300        ,INSTRB(anc_id_71,'(]',1,2) -
9301         INSTRB(anc_id_71,'(]',1,1) - 2)
9302 ,SUBSTRB(anc_id_71
9303        ,INSTRB(anc_id_71,'(]',1,2) + 2
9304        ,INSTRB(anc_id_71,'(]',1,3) -
9305         INSTRB(anc_id_71,'(]',1,2) - 2)
9306 ,SUBSTRB(anc_id_71
9307        ,INSTRB(anc_id_71,'(]',1,3) + 2
9308        ,INSTRB(anc_id_71,'(]',1,4) -
9309         INSTRB(anc_id_71,'(]',1,3) - 2)
9310 ,SUBSTRB(anc_id_71
9311        ,INSTRB(anc_id_71,'(]',1,4) + 2
9312        ,INSTRB(anc_id_71,'(]',1,5) -
9313         INSTRB(anc_id_71,'(]',1,4) - 2)
9314 ,SUBSTRB(anc_id_71
9315        ,INSTRB(anc_id_71,'(]',1,5) + 2
9316        ,INSTRB(anc_id_71,'(]',1,6) -
9317         INSTRB(anc_id_71,'(]',1,5) - 2)
9318 ,SUBSTRB(anc_id_71
9319        ,INSTRB(anc_id_71,'(]',1,6) + 2
9320        ,INSTRB(anc_id_71,'(]',1,7) -
9321         INSTRB(anc_id_71,'(]',1,6) - 2)
9322 ,SUBSTRB(anc_id_71
9323        ,INSTRB(anc_id_71,'(]',1,7) + 2
9324        ,LENGTHB(anc_id_71))
9325 )
9326 
9327 WHEN anc_id_72 IS NOT NULL THEN
9328   INTO xla_ae_line_acs (
9329         ae_header_id , ae_line_num , object_version_number
9330       , analytical_criterion_code
9331       , analytical_criterion_type_code
9332       , amb_context_code
9333       , ac1,ac2,ac3,ac4,ac5)
9334 VALUES (ae_header_id, ae_line_num, C_OVN
9335 ,SUBSTRB(anc_id_72
9336        ,1
9337        ,INSTRB(anc_id_72,'(]',1,1) -1)
9338 ,SUBSTRB(anc_id_72
9339        ,INSTRB(anc_id_72,'(]',1,1) + 2
9340        ,INSTRB(anc_id_72,'(]',1,2) -
9341         INSTRB(anc_id_72,'(]',1,1) - 2)
9342 ,SUBSTRB(anc_id_72
9343        ,INSTRB(anc_id_72,'(]',1,2) + 2
9344        ,INSTRB(anc_id_72,'(]',1,3) -
9345         INSTRB(anc_id_72,'(]',1,2) - 2)
9346 ,SUBSTRB(anc_id_72
9347        ,INSTRB(anc_id_72,'(]',1,3) + 2
9348        ,INSTRB(anc_id_72,'(]',1,4) -
9349         INSTRB(anc_id_72,'(]',1,3) - 2)
9350 ,SUBSTRB(anc_id_72
9351        ,INSTRB(anc_id_72,'(]',1,4) + 2
9352        ,INSTRB(anc_id_72,'(]',1,5) -
9353         INSTRB(anc_id_72,'(]',1,4) - 2)
9354 ,SUBSTRB(anc_id_72
9355        ,INSTRB(anc_id_72,'(]',1,5) + 2
9356        ,INSTRB(anc_id_72,'(]',1,6) -
9357         INSTRB(anc_id_72,'(]',1,5) - 2)
9358 ,SUBSTRB(anc_id_72
9359        ,INSTRB(anc_id_72,'(]',1,6) + 2
9360        ,INSTRB(anc_id_72,'(]',1,7) -
9361         INSTRB(anc_id_72,'(]',1,6) - 2)
9362 ,SUBSTRB(anc_id_72
9363        ,INSTRB(anc_id_72,'(]',1,7) + 2
9364        ,LENGTHB(anc_id_72))
9365 )
9366 
9367 WHEN anc_id_73 IS NOT NULL THEN
9368   INTO xla_ae_line_acs (
9369         ae_header_id , ae_line_num , object_version_number
9370       , analytical_criterion_code
9371       , analytical_criterion_type_code
9372       , amb_context_code
9373       , ac1,ac2,ac3,ac4,ac5)
9374 VALUES (ae_header_id, ae_line_num, C_OVN
9375 ,SUBSTRB(anc_id_73
9376        ,1
9377        ,INSTRB(anc_id_73,'(]',1,1) -1)
9378 ,SUBSTRB(anc_id_73
9379        ,INSTRB(anc_id_73,'(]',1,1) + 2
9380        ,INSTRB(anc_id_73,'(]',1,2) -
9381         INSTRB(anc_id_73,'(]',1,1) - 2)
9382 ,SUBSTRB(anc_id_73
9383        ,INSTRB(anc_id_73,'(]',1,2) + 2
9384        ,INSTRB(anc_id_73,'(]',1,3) -
9385         INSTRB(anc_id_73,'(]',1,2) - 2)
9386 ,SUBSTRB(anc_id_73
9387        ,INSTRB(anc_id_73,'(]',1,3) + 2
9388        ,INSTRB(anc_id_73,'(]',1,4) -
9389         INSTRB(anc_id_73,'(]',1,3) - 2)
9390 ,SUBSTRB(anc_id_73
9391        ,INSTRB(anc_id_73,'(]',1,4) + 2
9392        ,INSTRB(anc_id_73,'(]',1,5) -
9393         INSTRB(anc_id_73,'(]',1,4) - 2)
9394 ,SUBSTRB(anc_id_73
9395        ,INSTRB(anc_id_73,'(]',1,5) + 2
9396        ,INSTRB(anc_id_73,'(]',1,6) -
9397         INSTRB(anc_id_73,'(]',1,5) - 2)
9398 ,SUBSTRB(anc_id_73
9399        ,INSTRB(anc_id_73,'(]',1,6) + 2
9400        ,INSTRB(anc_id_73,'(]',1,7) -
9401         INSTRB(anc_id_73,'(]',1,6) - 2)
9402 ,SUBSTRB(anc_id_73
9403        ,INSTRB(anc_id_73,'(]',1,7) + 2
9404        ,LENGTHB(anc_id_73))
9405 )
9406 
9407 WHEN anc_id_74 IS NOT NULL THEN
9408   INTO xla_ae_line_acs (
9409         ae_header_id , ae_line_num , object_version_number
9410       , analytical_criterion_code
9411       , analytical_criterion_type_code
9412       , amb_context_code
9413       , ac1,ac2,ac3,ac4,ac5)
9414 VALUES (ae_header_id, ae_line_num, C_OVN
9415 ,SUBSTRB(anc_id_74
9416        ,1
9417        ,INSTRB(anc_id_74,'(]',1,1) -1)
9418 ,SUBSTRB(anc_id_74
9419        ,INSTRB(anc_id_74,'(]',1,1) + 2
9420        ,INSTRB(anc_id_74,'(]',1,2) -
9421         INSTRB(anc_id_74,'(]',1,1) - 2)
9422 ,SUBSTRB(anc_id_74
9423        ,INSTRB(anc_id_74,'(]',1,2) + 2
9424        ,INSTRB(anc_id_74,'(]',1,3) -
9425         INSTRB(anc_id_74,'(]',1,2) - 2)
9426 ,SUBSTRB(anc_id_74
9427        ,INSTRB(anc_id_74,'(]',1,3) + 2
9428        ,INSTRB(anc_id_74,'(]',1,4) -
9429         INSTRB(anc_id_74,'(]',1,3) - 2)
9430 ,SUBSTRB(anc_id_74
9431        ,INSTRB(anc_id_74,'(]',1,4) + 2
9432        ,INSTRB(anc_id_74,'(]',1,5) -
9433         INSTRB(anc_id_74,'(]',1,4) - 2)
9434 ,SUBSTRB(anc_id_74
9435        ,INSTRB(anc_id_74,'(]',1,5) + 2
9436        ,INSTRB(anc_id_74,'(]',1,6) -
9437         INSTRB(anc_id_74,'(]',1,5) - 2)
9438 ,SUBSTRB(anc_id_74
9439        ,INSTRB(anc_id_74,'(]',1,6) + 2
9440        ,INSTRB(anc_id_74,'(]',1,7) -
9441         INSTRB(anc_id_74,'(]',1,6) - 2)
9442 ,SUBSTRB(anc_id_74
9443        ,INSTRB(anc_id_74,'(]',1,7) + 2
9444        ,LENGTHB(anc_id_74))
9445 )
9446 
9447 WHEN anc_id_75 IS NOT NULL THEN
9448   INTO xla_ae_line_acs (
9449         ae_header_id , ae_line_num , object_version_number
9450       , analytical_criterion_code
9451       , analytical_criterion_type_code
9452       , amb_context_code
9453       , ac1,ac2,ac3,ac4,ac5)
9454 VALUES (ae_header_id, ae_line_num, C_OVN
9455 ,SUBSTRB(anc_id_75
9456        ,1
9457        ,INSTRB(anc_id_75,'(]',1,1) -1)
9458 ,SUBSTRB(anc_id_75
9459        ,INSTRB(anc_id_75,'(]',1,1) + 2
9460        ,INSTRB(anc_id_75,'(]',1,2) -
9461         INSTRB(anc_id_75,'(]',1,1) - 2)
9462 ,SUBSTRB(anc_id_75
9463        ,INSTRB(anc_id_75,'(]',1,2) + 2
9464        ,INSTRB(anc_id_75,'(]',1,3) -
9465         INSTRB(anc_id_75,'(]',1,2) - 2)
9466 ,SUBSTRB(anc_id_75
9467        ,INSTRB(anc_id_75,'(]',1,3) + 2
9468        ,INSTRB(anc_id_75,'(]',1,4) -
9469         INSTRB(anc_id_75,'(]',1,3) - 2)
9470 ,SUBSTRB(anc_id_75
9471        ,INSTRB(anc_id_75,'(]',1,4) + 2
9472        ,INSTRB(anc_id_75,'(]',1,5) -
9473         INSTRB(anc_id_75,'(]',1,4) - 2)
9474 ,SUBSTRB(anc_id_75
9475        ,INSTRB(anc_id_75,'(]',1,5) + 2
9476        ,INSTRB(anc_id_75,'(]',1,6) -
9477         INSTRB(anc_id_75,'(]',1,5) - 2)
9478 ,SUBSTRB(anc_id_75
9479        ,INSTRB(anc_id_75,'(]',1,6) + 2
9480        ,INSTRB(anc_id_75,'(]',1,7) -
9481         INSTRB(anc_id_75,'(]',1,6) - 2)
9482 ,SUBSTRB(anc_id_75
9483        ,INSTRB(anc_id_75,'(]',1,7) + 2
9484        ,LENGTHB(anc_id_75))
9485 )
9486 
9487 WHEN anc_id_76 IS NOT NULL THEN
9488   INTO xla_ae_line_acs (
9489         ae_header_id , ae_line_num , object_version_number
9490       , analytical_criterion_code
9491       , analytical_criterion_type_code
9492       , amb_context_code
9493       , ac1,ac2,ac3,ac4,ac5)
9494 VALUES (ae_header_id, ae_line_num, C_OVN
9495 ,SUBSTRB(anc_id_76
9496        ,1
9497        ,INSTRB(anc_id_76,'(]',1,1) -1)
9498 ,SUBSTRB(anc_id_76
9499        ,INSTRB(anc_id_76,'(]',1,1) + 2
9500        ,INSTRB(anc_id_76,'(]',1,2) -
9501         INSTRB(anc_id_76,'(]',1,1) - 2)
9502 ,SUBSTRB(anc_id_76
9503        ,INSTRB(anc_id_76,'(]',1,2) + 2
9504        ,INSTRB(anc_id_76,'(]',1,3) -
9505         INSTRB(anc_id_76,'(]',1,2) - 2)
9506 ,SUBSTRB(anc_id_76
9507        ,INSTRB(anc_id_76,'(]',1,3) + 2
9508        ,INSTRB(anc_id_76,'(]',1,4) -
9509         INSTRB(anc_id_76,'(]',1,3) - 2)
9510 ,SUBSTRB(anc_id_76
9511        ,INSTRB(anc_id_76,'(]',1,4) + 2
9512        ,INSTRB(anc_id_76,'(]',1,5) -
9513         INSTRB(anc_id_76,'(]',1,4) - 2)
9514 ,SUBSTRB(anc_id_76
9515        ,INSTRB(anc_id_76,'(]',1,5) + 2
9516        ,INSTRB(anc_id_76,'(]',1,6) -
9517         INSTRB(anc_id_76,'(]',1,5) - 2)
9518 ,SUBSTRB(anc_id_76
9519        ,INSTRB(anc_id_76,'(]',1,6) + 2
9520        ,INSTRB(anc_id_76,'(]',1,7) -
9521         INSTRB(anc_id_76,'(]',1,6) - 2)
9522 ,SUBSTRB(anc_id_76
9523        ,INSTRB(anc_id_76,'(]',1,7) + 2
9524        ,LENGTHB(anc_id_76))
9525 )
9526 
9527 WHEN anc_id_77 IS NOT NULL THEN
9528   INTO xla_ae_line_acs (
9529         ae_header_id , ae_line_num , object_version_number
9530       , analytical_criterion_code
9531       , analytical_criterion_type_code
9532       , amb_context_code
9533       , ac1,ac2,ac3,ac4,ac5)
9534 VALUES (ae_header_id, ae_line_num, C_OVN
9535 ,SUBSTRB(anc_id_77
9536        ,1
9537        ,INSTRB(anc_id_77,'(]',1,1) -1)
9538 ,SUBSTRB(anc_id_77
9539        ,INSTRB(anc_id_77,'(]',1,1) + 2
9540        ,INSTRB(anc_id_77,'(]',1,2) -
9541         INSTRB(anc_id_77,'(]',1,1) - 2)
9542 ,SUBSTRB(anc_id_77
9543        ,INSTRB(anc_id_77,'(]',1,2) + 2
9544        ,INSTRB(anc_id_77,'(]',1,3) -
9545         INSTRB(anc_id_77,'(]',1,2) - 2)
9546 ,SUBSTRB(anc_id_77
9547        ,INSTRB(anc_id_77,'(]',1,3) + 2
9548        ,INSTRB(anc_id_77,'(]',1,4) -
9549         INSTRB(anc_id_77,'(]',1,3) - 2)
9550 ,SUBSTRB(anc_id_77
9551        ,INSTRB(anc_id_77,'(]',1,4) + 2
9552        ,INSTRB(anc_id_77,'(]',1,5) -
9553         INSTRB(anc_id_77,'(]',1,4) - 2)
9554 ,SUBSTRB(anc_id_77
9555        ,INSTRB(anc_id_77,'(]',1,5) + 2
9556        ,INSTRB(anc_id_77,'(]',1,6) -
9557         INSTRB(anc_id_77,'(]',1,5) - 2)
9558 ,SUBSTRB(anc_id_77
9559        ,INSTRB(anc_id_77,'(]',1,6) + 2
9560        ,INSTRB(anc_id_77,'(]',1,7) -
9561         INSTRB(anc_id_77,'(]',1,6) - 2)
9562 ,SUBSTRB(anc_id_77
9563        ,INSTRB(anc_id_77,'(]',1,7) + 2
9564        ,LENGTHB(anc_id_77))
9565 )
9566 
9567 WHEN anc_id_78 IS NOT NULL THEN
9568   INTO xla_ae_line_acs (
9569         ae_header_id , ae_line_num , object_version_number
9570       , analytical_criterion_code
9571       , analytical_criterion_type_code
9572       , amb_context_code
9573       , ac1,ac2,ac3,ac4,ac5)
9574 VALUES (ae_header_id, ae_line_num, C_OVN
9575 ,SUBSTRB(anc_id_78
9576        ,1
9577        ,INSTRB(anc_id_78,'(]',1,1) -1)
9578 ,SUBSTRB(anc_id_78
9579        ,INSTRB(anc_id_78,'(]',1,1) + 2
9580        ,INSTRB(anc_id_78,'(]',1,2) -
9581         INSTRB(anc_id_78,'(]',1,1) - 2)
9582 ,SUBSTRB(anc_id_78
9583        ,INSTRB(anc_id_78,'(]',1,2) + 2
9584        ,INSTRB(anc_id_78,'(]',1,3) -
9585         INSTRB(anc_id_78,'(]',1,2) - 2)
9586 ,SUBSTRB(anc_id_78
9587        ,INSTRB(anc_id_78,'(]',1,3) + 2
9588        ,INSTRB(anc_id_78,'(]',1,4) -
9589         INSTRB(anc_id_78,'(]',1,3) - 2)
9590 ,SUBSTRB(anc_id_78
9591        ,INSTRB(anc_id_78,'(]',1,4) + 2
9592        ,INSTRB(anc_id_78,'(]',1,5) -
9593         INSTRB(anc_id_78,'(]',1,4) - 2)
9594 ,SUBSTRB(anc_id_78
9595        ,INSTRB(anc_id_78,'(]',1,5) + 2
9596        ,INSTRB(anc_id_78,'(]',1,6) -
9597         INSTRB(anc_id_78,'(]',1,5) - 2)
9598 ,SUBSTRB(anc_id_78
9599        ,INSTRB(anc_id_78,'(]',1,6) + 2
9600        ,INSTRB(anc_id_78,'(]',1,7) -
9601         INSTRB(anc_id_78,'(]',1,6) - 2)
9602 ,SUBSTRB(anc_id_78
9603        ,INSTRB(anc_id_78,'(]',1,7) + 2
9604        ,LENGTHB(anc_id_78))
9605 )
9606 
9607 WHEN anc_id_79 IS NOT NULL THEN
9608   INTO xla_ae_line_acs (
9609         ae_header_id , ae_line_num , object_version_number
9610       , analytical_criterion_code
9611       , analytical_criterion_type_code
9612       , amb_context_code
9613       , ac1,ac2,ac3,ac4,ac5)
9614 VALUES (ae_header_id, ae_line_num, C_OVN
9615 ,SUBSTRB(anc_id_79
9616        ,1
9617        ,INSTRB(anc_id_79,'(]',1,1) -1)
9618 ,SUBSTRB(anc_id_79
9619        ,INSTRB(anc_id_79,'(]',1,1) + 2
9620        ,INSTRB(anc_id_79,'(]',1,2) -
9621         INSTRB(anc_id_79,'(]',1,1) - 2)
9622 ,SUBSTRB(anc_id_79
9623        ,INSTRB(anc_id_79,'(]',1,2) + 2
9624        ,INSTRB(anc_id_79,'(]',1,3) -
9625         INSTRB(anc_id_79,'(]',1,2) - 2)
9626 ,SUBSTRB(anc_id_79
9627        ,INSTRB(anc_id_79,'(]',1,3) + 2
9628        ,INSTRB(anc_id_79,'(]',1,4) -
9629         INSTRB(anc_id_79,'(]',1,3) - 2)
9630 ,SUBSTRB(anc_id_79
9631        ,INSTRB(anc_id_79,'(]',1,4) + 2
9632        ,INSTRB(anc_id_79,'(]',1,5) -
9633         INSTRB(anc_id_79,'(]',1,4) - 2)
9634 ,SUBSTRB(anc_id_79
9635        ,INSTRB(anc_id_79,'(]',1,5) + 2
9636        ,INSTRB(anc_id_79,'(]',1,6) -
9637         INSTRB(anc_id_79,'(]',1,5) - 2)
9638 ,SUBSTRB(anc_id_79
9639        ,INSTRB(anc_id_79,'(]',1,6) + 2
9640        ,INSTRB(anc_id_79,'(]',1,7) -
9641         INSTRB(anc_id_79,'(]',1,6) - 2)
9642 ,SUBSTRB(anc_id_79
9643        ,INSTRB(anc_id_79,'(]',1,7) + 2
9644        ,LENGTHB(anc_id_79))
9645 )
9646 
9647 WHEN anc_id_80 IS NOT NULL THEN
9648   INTO xla_ae_line_acs (
9649         ae_header_id , ae_line_num , object_version_number
9650       , analytical_criterion_code
9651       , analytical_criterion_type_code
9652       , amb_context_code
9653       , ac1,ac2,ac3,ac4,ac5)
9654 VALUES (ae_header_id, ae_line_num, C_OVN
9655 ,SUBSTRB(anc_id_80
9656        ,1
9657        ,INSTRB(anc_id_80,'(]',1,1) -1)
9658 ,SUBSTRB(anc_id_80
9659        ,INSTRB(anc_id_80,'(]',1,1) + 2
9660        ,INSTRB(anc_id_80,'(]',1,2) -
9661         INSTRB(anc_id_80,'(]',1,1) - 2)
9662 ,SUBSTRB(anc_id_80
9663        ,INSTRB(anc_id_80,'(]',1,2) + 2
9664        ,INSTRB(anc_id_80,'(]',1,3) -
9665         INSTRB(anc_id_80,'(]',1,2) - 2)
9666 ,SUBSTRB(anc_id_80
9667        ,INSTRB(anc_id_80,'(]',1,3) + 2
9668        ,INSTRB(anc_id_80,'(]',1,4) -
9669         INSTRB(anc_id_80,'(]',1,3) - 2)
9670 ,SUBSTRB(anc_id_80
9671        ,INSTRB(anc_id_80,'(]',1,4) + 2
9672        ,INSTRB(anc_id_80,'(]',1,5) -
9673         INSTRB(anc_id_80,'(]',1,4) - 2)
9674 ,SUBSTRB(anc_id_80
9675        ,INSTRB(anc_id_80,'(]',1,5) + 2
9676        ,INSTRB(anc_id_80,'(]',1,6) -
9677         INSTRB(anc_id_80,'(]',1,5) - 2)
9678 ,SUBSTRB(anc_id_80
9679        ,INSTRB(anc_id_80,'(]',1,6) + 2
9680        ,INSTRB(anc_id_80,'(]',1,7) -
9681         INSTRB(anc_id_80,'(]',1,6) - 2)
9682 ,SUBSTRB(anc_id_80
9683        ,INSTRB(anc_id_80,'(]',1,7) + 2
9684        ,LENGTHB(anc_id_80))
9685 )
9686 
9687 WHEN anc_id_81 IS NOT NULL THEN
9688   INTO xla_ae_line_acs (
9689         ae_header_id , ae_line_num , object_version_number
9690       , analytical_criterion_code
9691       , analytical_criterion_type_code
9692       , amb_context_code
9693       , ac1,ac2,ac3,ac4,ac5)
9694 VALUES (ae_header_id, ae_line_num, C_OVN
9695 ,SUBSTRB(anc_id_81
9696        ,1
9697        ,INSTRB(anc_id_81,'(]',1,1) -1)
9698 ,SUBSTRB(anc_id_81
9699        ,INSTRB(anc_id_81,'(]',1,1) + 2
9700        ,INSTRB(anc_id_81,'(]',1,2) -
9701         INSTRB(anc_id_81,'(]',1,1) - 2)
9702 ,SUBSTRB(anc_id_81
9703        ,INSTRB(anc_id_81,'(]',1,2) + 2
9704        ,INSTRB(anc_id_81,'(]',1,3) -
9705         INSTRB(anc_id_81,'(]',1,2) - 2)
9706 ,SUBSTRB(anc_id_81
9707        ,INSTRB(anc_id_81,'(]',1,3) + 2
9708        ,INSTRB(anc_id_81,'(]',1,4) -
9709         INSTRB(anc_id_81,'(]',1,3) - 2)
9710 ,SUBSTRB(anc_id_81
9711        ,INSTRB(anc_id_81,'(]',1,4) + 2
9712        ,INSTRB(anc_id_81,'(]',1,5) -
9713         INSTRB(anc_id_81,'(]',1,4) - 2)
9714 ,SUBSTRB(anc_id_81
9715        ,INSTRB(anc_id_81,'(]',1,5) + 2
9716        ,INSTRB(anc_id_81,'(]',1,6) -
9717         INSTRB(anc_id_81,'(]',1,5) - 2)
9718 ,SUBSTRB(anc_id_81
9719        ,INSTRB(anc_id_81,'(]',1,6) + 2
9720        ,INSTRB(anc_id_81,'(]',1,7) -
9721         INSTRB(anc_id_81,'(]',1,6) - 2)
9722 ,SUBSTRB(anc_id_81
9723        ,INSTRB(anc_id_81,'(]',1,7) + 2
9724        ,LENGTHB(anc_id_81))
9725 )
9726 
9727 WHEN anc_id_82 IS NOT NULL THEN
9728   INTO xla_ae_line_acs (
9729         ae_header_id , ae_line_num , object_version_number
9730       , analytical_criterion_code
9731       , analytical_criterion_type_code
9732       , amb_context_code
9733       , ac1,ac2,ac3,ac4,ac5)
9734 VALUES (ae_header_id, ae_line_num, C_OVN
9735 ,SUBSTRB(anc_id_82
9736        ,1
9737        ,INSTRB(anc_id_82,'(]',1,1) -1)
9738 ,SUBSTRB(anc_id_82
9739        ,INSTRB(anc_id_82,'(]',1,1) + 2
9740        ,INSTRB(anc_id_82,'(]',1,2) -
9741         INSTRB(anc_id_82,'(]',1,1) - 2)
9742 ,SUBSTRB(anc_id_82
9743        ,INSTRB(anc_id_82,'(]',1,2) + 2
9744        ,INSTRB(anc_id_82,'(]',1,3) -
9745         INSTRB(anc_id_82,'(]',1,2) - 2)
9746 ,SUBSTRB(anc_id_82
9747        ,INSTRB(anc_id_82,'(]',1,3) + 2
9748        ,INSTRB(anc_id_82,'(]',1,4) -
9749         INSTRB(anc_id_82,'(]',1,3) - 2)
9750 ,SUBSTRB(anc_id_82
9751        ,INSTRB(anc_id_82,'(]',1,4) + 2
9752        ,INSTRB(anc_id_82,'(]',1,5) -
9753         INSTRB(anc_id_82,'(]',1,4) - 2)
9754 ,SUBSTRB(anc_id_82
9755        ,INSTRB(anc_id_82,'(]',1,5) + 2
9756        ,INSTRB(anc_id_82,'(]',1,6) -
9757         INSTRB(anc_id_82,'(]',1,5) - 2)
9758 ,SUBSTRB(anc_id_82
9759        ,INSTRB(anc_id_82,'(]',1,6) + 2
9760        ,INSTRB(anc_id_82,'(]',1,7) -
9761         INSTRB(anc_id_82,'(]',1,6) - 2)
9762 ,SUBSTRB(anc_id_82
9763        ,INSTRB(anc_id_82,'(]',1,7) + 2
9764        ,LENGTHB(anc_id_82))
9765 )
9766 
9767 WHEN anc_id_83 IS NOT NULL THEN
9768   INTO xla_ae_line_acs (
9769         ae_header_id , ae_line_num , object_version_number
9770       , analytical_criterion_code
9771       , analytical_criterion_type_code
9772       , amb_context_code
9773       , ac1,ac2,ac3,ac4,ac5)
9774 VALUES (ae_header_id, ae_line_num, C_OVN
9775 ,SUBSTRB(anc_id_83
9776        ,1
9777        ,INSTRB(anc_id_83,'(]',1,1) -1)
9778 ,SUBSTRB(anc_id_83
9779        ,INSTRB(anc_id_83,'(]',1,1) + 2
9780        ,INSTRB(anc_id_83,'(]',1,2) -
9781         INSTRB(anc_id_83,'(]',1,1) - 2)
9782 ,SUBSTRB(anc_id_83
9783        ,INSTRB(anc_id_83,'(]',1,2) + 2
9784        ,INSTRB(anc_id_83,'(]',1,3) -
9785         INSTRB(anc_id_83,'(]',1,2) - 2)
9786 ,SUBSTRB(anc_id_83
9787        ,INSTRB(anc_id_83,'(]',1,3) + 2
9788        ,INSTRB(anc_id_83,'(]',1,4) -
9789         INSTRB(anc_id_83,'(]',1,3) - 2)
9790 ,SUBSTRB(anc_id_83
9791        ,INSTRB(anc_id_83,'(]',1,4) + 2
9792        ,INSTRB(anc_id_83,'(]',1,5) -
9793         INSTRB(anc_id_83,'(]',1,4) - 2)
9794 ,SUBSTRB(anc_id_83
9795        ,INSTRB(anc_id_83,'(]',1,5) + 2
9796        ,INSTRB(anc_id_83,'(]',1,6) -
9797         INSTRB(anc_id_83,'(]',1,5) - 2)
9798 ,SUBSTRB(anc_id_83
9799        ,INSTRB(anc_id_83,'(]',1,6) + 2
9800        ,INSTRB(anc_id_83,'(]',1,7) -
9801         INSTRB(anc_id_83,'(]',1,6) - 2)
9802 ,SUBSTRB(anc_id_83
9803        ,INSTRB(anc_id_83,'(]',1,7) + 2
9804        ,LENGTHB(anc_id_83))
9805 )
9806 
9807 WHEN anc_id_84 IS NOT NULL THEN
9808   INTO xla_ae_line_acs (
9809         ae_header_id , ae_line_num , object_version_number
9810       , analytical_criterion_code
9811       , analytical_criterion_type_code
9812       , amb_context_code
9813       , ac1,ac2,ac3,ac4,ac5)
9814 VALUES (ae_header_id, ae_line_num, C_OVN
9815 ,SUBSTRB(anc_id_84
9816        ,1
9817        ,INSTRB(anc_id_84,'(]',1,1) -1)
9818 ,SUBSTRB(anc_id_84
9819        ,INSTRB(anc_id_84,'(]',1,1) + 2
9820        ,INSTRB(anc_id_84,'(]',1,2) -
9821         INSTRB(anc_id_84,'(]',1,1) - 2)
9822 ,SUBSTRB(anc_id_84
9823        ,INSTRB(anc_id_84,'(]',1,2) + 2
9824        ,INSTRB(anc_id_84,'(]',1,3) -
9825         INSTRB(anc_id_84,'(]',1,2) - 2)
9826 ,SUBSTRB(anc_id_84
9827        ,INSTRB(anc_id_84,'(]',1,3) + 2
9828        ,INSTRB(anc_id_84,'(]',1,4) -
9829         INSTRB(anc_id_84,'(]',1,3) - 2)
9830 ,SUBSTRB(anc_id_84
9831        ,INSTRB(anc_id_84,'(]',1,4) + 2
9832        ,INSTRB(anc_id_84,'(]',1,5) -
9833         INSTRB(anc_id_84,'(]',1,4) - 2)
9834 ,SUBSTRB(anc_id_84
9835        ,INSTRB(anc_id_84,'(]',1,5) + 2
9836        ,INSTRB(anc_id_84,'(]',1,6) -
9837         INSTRB(anc_id_84,'(]',1,5) - 2)
9838 ,SUBSTRB(anc_id_84
9839        ,INSTRB(anc_id_84,'(]',1,6) + 2
9840        ,INSTRB(anc_id_84,'(]',1,7) -
9841         INSTRB(anc_id_84,'(]',1,6) - 2)
9842 ,SUBSTRB(anc_id_84
9843        ,INSTRB(anc_id_84,'(]',1,7) + 2
9844        ,LENGTHB(anc_id_84))
9845 )
9846 
9847 WHEN anc_id_85 IS NOT NULL THEN
9848   INTO xla_ae_line_acs (
9849         ae_header_id , ae_line_num , object_version_number
9850       , analytical_criterion_code
9851       , analytical_criterion_type_code
9852       , amb_context_code
9853       , ac1,ac2,ac3,ac4,ac5)
9854 VALUES (ae_header_id, ae_line_num, C_OVN
9855 ,SUBSTRB(anc_id_85
9856        ,1
9857        ,INSTRB(anc_id_85,'(]',1,1) -1)
9858 ,SUBSTRB(anc_id_85
9859        ,INSTRB(anc_id_85,'(]',1,1) + 2
9860        ,INSTRB(anc_id_85,'(]',1,2) -
9861         INSTRB(anc_id_85,'(]',1,1) - 2)
9862 ,SUBSTRB(anc_id_85
9863        ,INSTRB(anc_id_85,'(]',1,2) + 2
9864        ,INSTRB(anc_id_85,'(]',1,3) -
9865         INSTRB(anc_id_85,'(]',1,2) - 2)
9866 ,SUBSTRB(anc_id_85
9867        ,INSTRB(anc_id_85,'(]',1,3) + 2
9868        ,INSTRB(anc_id_85,'(]',1,4) -
9869         INSTRB(anc_id_85,'(]',1,3) - 2)
9870 ,SUBSTRB(anc_id_85
9871        ,INSTRB(anc_id_85,'(]',1,4) + 2
9872        ,INSTRB(anc_id_85,'(]',1,5) -
9873         INSTRB(anc_id_85,'(]',1,4) - 2)
9874 ,SUBSTRB(anc_id_85
9875        ,INSTRB(anc_id_85,'(]',1,5) + 2
9876        ,INSTRB(anc_id_85,'(]',1,6) -
9877         INSTRB(anc_id_85,'(]',1,5) - 2)
9878 ,SUBSTRB(anc_id_85
9879        ,INSTRB(anc_id_85,'(]',1,6) + 2
9880        ,INSTRB(anc_id_85,'(]',1,7) -
9881         INSTRB(anc_id_85,'(]',1,6) - 2)
9882 ,SUBSTRB(anc_id_85
9883        ,INSTRB(anc_id_85,'(]',1,7) + 2
9884        ,LENGTHB(anc_id_85))
9885 )
9886 
9887 WHEN anc_id_86 IS NOT NULL THEN
9888   INTO xla_ae_line_acs (
9889         ae_header_id , ae_line_num , object_version_number
9890       , analytical_criterion_code
9891       , analytical_criterion_type_code
9892       , amb_context_code
9893       , ac1,ac2,ac3,ac4,ac5)
9894 VALUES (ae_header_id, ae_line_num, C_OVN
9895 ,SUBSTRB(anc_id_86
9896        ,1
9897        ,INSTRB(anc_id_86,'(]',1,1) -1)
9898 ,SUBSTRB(anc_id_86
9899        ,INSTRB(anc_id_86,'(]',1,1) + 2
9900        ,INSTRB(anc_id_86,'(]',1,2) -
9901         INSTRB(anc_id_86,'(]',1,1) - 2)
9902 ,SUBSTRB(anc_id_86
9903        ,INSTRB(anc_id_86,'(]',1,2) + 2
9904        ,INSTRB(anc_id_86,'(]',1,3) -
9905         INSTRB(anc_id_86,'(]',1,2) - 2)
9906 ,SUBSTRB(anc_id_86
9907        ,INSTRB(anc_id_86,'(]',1,3) + 2
9908        ,INSTRB(anc_id_86,'(]',1,4) -
9909         INSTRB(anc_id_86,'(]',1,3) - 2)
9910 ,SUBSTRB(anc_id_86
9911        ,INSTRB(anc_id_86,'(]',1,4) + 2
9912        ,INSTRB(anc_id_86,'(]',1,5) -
9913         INSTRB(anc_id_86,'(]',1,4) - 2)
9914 ,SUBSTRB(anc_id_86
9915        ,INSTRB(anc_id_86,'(]',1,5) + 2
9916        ,INSTRB(anc_id_86,'(]',1,6) -
9917         INSTRB(anc_id_86,'(]',1,5) - 2)
9918 ,SUBSTRB(anc_id_86
9919        ,INSTRB(anc_id_86,'(]',1,6) + 2
9920        ,INSTRB(anc_id_86,'(]',1,7) -
9921         INSTRB(anc_id_86,'(]',1,6) - 2)
9922 ,SUBSTRB(anc_id_86
9923        ,INSTRB(anc_id_86,'(]',1,7) + 2
9924        ,LENGTHB(anc_id_86))
9925 )
9926 
9927 WHEN anc_id_87 IS NOT NULL THEN
9928   INTO xla_ae_line_acs (
9929         ae_header_id , ae_line_num , object_version_number
9930       , analytical_criterion_code
9931       , analytical_criterion_type_code
9932       , amb_context_code
9933       , ac1,ac2,ac3,ac4,ac5)
9934 VALUES (ae_header_id, ae_line_num, C_OVN
9935 ,SUBSTRB(anc_id_87
9936        ,1
9937        ,INSTRB(anc_id_87,'(]',1,1) -1)
9938 ,SUBSTRB(anc_id_87
9939        ,INSTRB(anc_id_87,'(]',1,1) + 2
9940        ,INSTRB(anc_id_87,'(]',1,2) -
9941         INSTRB(anc_id_87,'(]',1,1) - 2)
9942 ,SUBSTRB(anc_id_87
9943        ,INSTRB(anc_id_87,'(]',1,2) + 2
9944        ,INSTRB(anc_id_87,'(]',1,3) -
9945         INSTRB(anc_id_87,'(]',1,2) - 2)
9946 ,SUBSTRB(anc_id_87
9947        ,INSTRB(anc_id_87,'(]',1,3) + 2
9948        ,INSTRB(anc_id_87,'(]',1,4) -
9949         INSTRB(anc_id_87,'(]',1,3) - 2)
9950 ,SUBSTRB(anc_id_87
9951        ,INSTRB(anc_id_87,'(]',1,4) + 2
9952        ,INSTRB(anc_id_87,'(]',1,5) -
9953         INSTRB(anc_id_87,'(]',1,4) - 2)
9954 ,SUBSTRB(anc_id_87
9955        ,INSTRB(anc_id_87,'(]',1,5) + 2
9956        ,INSTRB(anc_id_87,'(]',1,6) -
9957         INSTRB(anc_id_87,'(]',1,5) - 2)
9958 ,SUBSTRB(anc_id_87
9959        ,INSTRB(anc_id_87,'(]',1,6) + 2
9960        ,INSTRB(anc_id_87,'(]',1,7) -
9961         INSTRB(anc_id_87,'(]',1,6) - 2)
9962 ,SUBSTRB(anc_id_87
9963        ,INSTRB(anc_id_87,'(]',1,7) + 2
9964        ,LENGTHB(anc_id_87))
9965 )
9966 
9967 WHEN anc_id_88 IS NOT NULL THEN
9968   INTO xla_ae_line_acs (
9969         ae_header_id , ae_line_num , object_version_number
9970       , analytical_criterion_code
9971       , analytical_criterion_type_code
9972       , amb_context_code
9973       , ac1,ac2,ac3,ac4,ac5)
9974 VALUES (ae_header_id, ae_line_num, C_OVN
9975 ,SUBSTRB(anc_id_88
9976        ,1
9977        ,INSTRB(anc_id_88,'(]',1,1) -1)
9978 ,SUBSTRB(anc_id_88
9979        ,INSTRB(anc_id_88,'(]',1,1) + 2
9980        ,INSTRB(anc_id_88,'(]',1,2) -
9981         INSTRB(anc_id_88,'(]',1,1) - 2)
9982 ,SUBSTRB(anc_id_88
9983        ,INSTRB(anc_id_88,'(]',1,2) + 2
9984        ,INSTRB(anc_id_88,'(]',1,3) -
9985         INSTRB(anc_id_88,'(]',1,2) - 2)
9986 ,SUBSTRB(anc_id_88
9987        ,INSTRB(anc_id_88,'(]',1,3) + 2
9988        ,INSTRB(anc_id_88,'(]',1,4) -
9989         INSTRB(anc_id_88,'(]',1,3) - 2)
9990 ,SUBSTRB(anc_id_88
9991        ,INSTRB(anc_id_88,'(]',1,4) + 2
9992        ,INSTRB(anc_id_88,'(]',1,5) -
9993         INSTRB(anc_id_88,'(]',1,4) - 2)
9994 ,SUBSTRB(anc_id_88
9995        ,INSTRB(anc_id_88,'(]',1,5) + 2
9996        ,INSTRB(anc_id_88,'(]',1,6) -
9997         INSTRB(anc_id_88,'(]',1,5) - 2)
9998 ,SUBSTRB(anc_id_88
9999        ,INSTRB(anc_id_88,'(]',1,6) + 2
10000        ,INSTRB(anc_id_88,'(]',1,7) -
10001         INSTRB(anc_id_88,'(]',1,6) - 2)
10002 ,SUBSTRB(anc_id_88
10003        ,INSTRB(anc_id_88,'(]',1,7) + 2
10004        ,LENGTHB(anc_id_88))
10005 )
10006 
10007 WHEN anc_id_89 IS NOT NULL THEN
10008   INTO xla_ae_line_acs (
10009         ae_header_id , ae_line_num , object_version_number
10010       , analytical_criterion_code
10011       , analytical_criterion_type_code
10012       , amb_context_code
10013       , ac1,ac2,ac3,ac4,ac5)
10014 VALUES (ae_header_id, ae_line_num, C_OVN
10015 ,SUBSTRB(anc_id_89
10016        ,1
10017        ,INSTRB(anc_id_89,'(]',1,1) -1)
10018 ,SUBSTRB(anc_id_89
10019        ,INSTRB(anc_id_89,'(]',1,1) + 2
10020        ,INSTRB(anc_id_89,'(]',1,2) -
10021         INSTRB(anc_id_89,'(]',1,1) - 2)
10022 ,SUBSTRB(anc_id_89
10023        ,INSTRB(anc_id_89,'(]',1,2) + 2
10024        ,INSTRB(anc_id_89,'(]',1,3) -
10025         INSTRB(anc_id_89,'(]',1,2) - 2)
10026 ,SUBSTRB(anc_id_89
10027        ,INSTRB(anc_id_89,'(]',1,3) + 2
10028        ,INSTRB(anc_id_89,'(]',1,4) -
10029         INSTRB(anc_id_89,'(]',1,3) - 2)
10030 ,SUBSTRB(anc_id_89
10031        ,INSTRB(anc_id_89,'(]',1,4) + 2
10032        ,INSTRB(anc_id_89,'(]',1,5) -
10033         INSTRB(anc_id_89,'(]',1,4) - 2)
10034 ,SUBSTRB(anc_id_89
10035        ,INSTRB(anc_id_89,'(]',1,5) + 2
10036        ,INSTRB(anc_id_89,'(]',1,6) -
10037         INSTRB(anc_id_89,'(]',1,5) - 2)
10038 ,SUBSTRB(anc_id_89
10039        ,INSTRB(anc_id_89,'(]',1,6) + 2
10040        ,INSTRB(anc_id_89,'(]',1,7) -
10041         INSTRB(anc_id_89,'(]',1,6) - 2)
10042 ,SUBSTRB(anc_id_89
10043        ,INSTRB(anc_id_89,'(]',1,7) + 2
10044        ,LENGTHB(anc_id_89))
10045 )
10046 
10047 WHEN anc_id_90 IS NOT NULL THEN
10048   INTO xla_ae_line_acs (
10049         ae_header_id , ae_line_num , object_version_number
10050       , analytical_criterion_code
10051       , analytical_criterion_type_code
10052       , amb_context_code
10053       , ac1,ac2,ac3,ac4,ac5)
10054 VALUES (ae_header_id, ae_line_num, C_OVN
10055 ,SUBSTRB(anc_id_90
10056        ,1
10057        ,INSTRB(anc_id_90,'(]',1,1) -1)
10058 ,SUBSTRB(anc_id_90
10059        ,INSTRB(anc_id_90,'(]',1,1) + 2
10060        ,INSTRB(anc_id_90,'(]',1,2) -
10061         INSTRB(anc_id_90,'(]',1,1) - 2)
10062 ,SUBSTRB(anc_id_90
10063        ,INSTRB(anc_id_90,'(]',1,2) + 2
10064        ,INSTRB(anc_id_90,'(]',1,3) -
10065         INSTRB(anc_id_90,'(]',1,2) - 2)
10066 ,SUBSTRB(anc_id_90
10067        ,INSTRB(anc_id_90,'(]',1,3) + 2
10068        ,INSTRB(anc_id_90,'(]',1,4) -
10069         INSTRB(anc_id_90,'(]',1,3) - 2)
10070 ,SUBSTRB(anc_id_90
10071        ,INSTRB(anc_id_90,'(]',1,4) + 2
10072        ,INSTRB(anc_id_90,'(]',1,5) -
10073         INSTRB(anc_id_90,'(]',1,4) - 2)
10074 ,SUBSTRB(anc_id_90
10075        ,INSTRB(anc_id_90,'(]',1,5) + 2
10076        ,INSTRB(anc_id_90,'(]',1,6) -
10077         INSTRB(anc_id_90,'(]',1,5) - 2)
10078 ,SUBSTRB(anc_id_90
10079        ,INSTRB(anc_id_90,'(]',1,6) + 2
10080        ,INSTRB(anc_id_90,'(]',1,7) -
10081         INSTRB(anc_id_90,'(]',1,6) - 2)
10082 ,SUBSTRB(anc_id_90
10083        ,INSTRB(anc_id_90,'(]',1,7) + 2
10084        ,LENGTHB(anc_id_90))
10085 )
10086 
10087 WHEN anc_id_91 IS NOT NULL THEN
10088   INTO xla_ae_line_acs (
10089         ae_header_id , ae_line_num , object_version_number
10090       , analytical_criterion_code
10091       , analytical_criterion_type_code
10092       , amb_context_code
10093       , ac1,ac2,ac3,ac4,ac5)
10094 VALUES (ae_header_id, ae_line_num, C_OVN
10095 ,SUBSTRB(anc_id_91
10096        ,1
10097        ,INSTRB(anc_id_91,'(]',1,1) -1)
10098 ,SUBSTRB(anc_id_91
10099        ,INSTRB(anc_id_91,'(]',1,1) + 2
10100        ,INSTRB(anc_id_91,'(]',1,2) -
10101         INSTRB(anc_id_91,'(]',1,1) - 2)
10102 ,SUBSTRB(anc_id_91
10103        ,INSTRB(anc_id_91,'(]',1,2) + 2
10104        ,INSTRB(anc_id_91,'(]',1,3) -
10105         INSTRB(anc_id_91,'(]',1,2) - 2)
10106 ,SUBSTRB(anc_id_91
10107        ,INSTRB(anc_id_91,'(]',1,3) + 2
10108        ,INSTRB(anc_id_91,'(]',1,4) -
10109         INSTRB(anc_id_91,'(]',1,3) - 2)
10110 ,SUBSTRB(anc_id_91
10111        ,INSTRB(anc_id_91,'(]',1,4) + 2
10112        ,INSTRB(anc_id_91,'(]',1,5) -
10113         INSTRB(anc_id_91,'(]',1,4) - 2)
10114 ,SUBSTRB(anc_id_91
10115        ,INSTRB(anc_id_91,'(]',1,5) + 2
10116        ,INSTRB(anc_id_91,'(]',1,6) -
10117         INSTRB(anc_id_91,'(]',1,5) - 2)
10118 ,SUBSTRB(anc_id_91
10119        ,INSTRB(anc_id_91,'(]',1,6) + 2
10120        ,INSTRB(anc_id_91,'(]',1,7) -
10121         INSTRB(anc_id_91,'(]',1,6) - 2)
10122 ,SUBSTRB(anc_id_91
10123        ,INSTRB(anc_id_91,'(]',1,7) + 2
10124        ,LENGTHB(anc_id_91))
10125 )
10126 
10127 WHEN anc_id_92 IS NOT NULL THEN
10128   INTO xla_ae_line_acs (
10129         ae_header_id , ae_line_num , object_version_number
10130       , analytical_criterion_code
10131       , analytical_criterion_type_code
10132       , amb_context_code
10133       , ac1,ac2,ac3,ac4,ac5)
10134 VALUES (ae_header_id, ae_line_num, C_OVN
10135 ,SUBSTRB(anc_id_92
10136        ,1
10137        ,INSTRB(anc_id_92,'(]',1,1) -1)
10138 ,SUBSTRB(anc_id_92
10139        ,INSTRB(anc_id_92,'(]',1,1) + 2
10140        ,INSTRB(anc_id_92,'(]',1,2) -
10141         INSTRB(anc_id_92,'(]',1,1) - 2)
10142 ,SUBSTRB(anc_id_92
10143        ,INSTRB(anc_id_92,'(]',1,2) + 2
10144        ,INSTRB(anc_id_92,'(]',1,3) -
10145         INSTRB(anc_id_92,'(]',1,2) - 2)
10146 ,SUBSTRB(anc_id_92
10147        ,INSTRB(anc_id_92,'(]',1,3) + 2
10148        ,INSTRB(anc_id_92,'(]',1,4) -
10149         INSTRB(anc_id_92,'(]',1,3) - 2)
10150 ,SUBSTRB(anc_id_92
10151        ,INSTRB(anc_id_92,'(]',1,4) + 2
10152        ,INSTRB(anc_id_92,'(]',1,5) -
10153         INSTRB(anc_id_92,'(]',1,4) - 2)
10154 ,SUBSTRB(anc_id_92
10155        ,INSTRB(anc_id_92,'(]',1,5) + 2
10156        ,INSTRB(anc_id_92,'(]',1,6) -
10157         INSTRB(anc_id_92,'(]',1,5) - 2)
10158 ,SUBSTRB(anc_id_92
10159        ,INSTRB(anc_id_92,'(]',1,6) + 2
10160        ,INSTRB(anc_id_92,'(]',1,7) -
10161         INSTRB(anc_id_92,'(]',1,6) - 2)
10162 ,SUBSTRB(anc_id_92
10163        ,INSTRB(anc_id_92,'(]',1,7) + 2
10164        ,LENGTHB(anc_id_92))
10165 )
10166 
10167 WHEN anc_id_93 IS NOT NULL THEN
10168   INTO xla_ae_line_acs (
10169         ae_header_id , ae_line_num , object_version_number
10170       , analytical_criterion_code
10171       , analytical_criterion_type_code
10172       , amb_context_code
10173       , ac1,ac2,ac3,ac4,ac5)
10174 VALUES (ae_header_id, ae_line_num, C_OVN
10175 ,SUBSTRB(anc_id_93
10176        ,1
10177        ,INSTRB(anc_id_93,'(]',1,1) -1)
10178 ,SUBSTRB(anc_id_93
10179        ,INSTRB(anc_id_93,'(]',1,1) + 2
10180        ,INSTRB(anc_id_93,'(]',1,2) -
10181         INSTRB(anc_id_93,'(]',1,1) - 2)
10182 ,SUBSTRB(anc_id_93
10183        ,INSTRB(anc_id_93,'(]',1,2) + 2
10184        ,INSTRB(anc_id_93,'(]',1,3) -
10185         INSTRB(anc_id_93,'(]',1,2) - 2)
10186 ,SUBSTRB(anc_id_93
10187        ,INSTRB(anc_id_93,'(]',1,3) + 2
10188        ,INSTRB(anc_id_93,'(]',1,4) -
10189         INSTRB(anc_id_93,'(]',1,3) - 2)
10190 ,SUBSTRB(anc_id_93
10191        ,INSTRB(anc_id_93,'(]',1,4) + 2
10192        ,INSTRB(anc_id_93,'(]',1,5) -
10193         INSTRB(anc_id_93,'(]',1,4) - 2)
10194 ,SUBSTRB(anc_id_93
10195        ,INSTRB(anc_id_93,'(]',1,5) + 2
10196        ,INSTRB(anc_id_93,'(]',1,6) -
10197         INSTRB(anc_id_93,'(]',1,5) - 2)
10198 ,SUBSTRB(anc_id_93
10199        ,INSTRB(anc_id_93,'(]',1,6) + 2
10200        ,INSTRB(anc_id_93,'(]',1,7) -
10201         INSTRB(anc_id_93,'(]',1,6) - 2)
10202 ,SUBSTRB(anc_id_93
10203        ,INSTRB(anc_id_93,'(]',1,7) + 2
10204        ,LENGTHB(anc_id_93))
10205 )
10206 
10207 WHEN anc_id_94 IS NOT NULL THEN
10208   INTO xla_ae_line_acs (
10209         ae_header_id , ae_line_num , object_version_number
10210       , analytical_criterion_code
10211       , analytical_criterion_type_code
10212       , amb_context_code
10213       , ac1,ac2,ac3,ac4,ac5)
10214 VALUES (ae_header_id, ae_line_num, C_OVN
10215 ,SUBSTRB(anc_id_94
10216        ,1
10217        ,INSTRB(anc_id_94,'(]',1,1) -1)
10218 ,SUBSTRB(anc_id_94
10219        ,INSTRB(anc_id_94,'(]',1,1) + 2
10220        ,INSTRB(anc_id_94,'(]',1,2) -
10221         INSTRB(anc_id_94,'(]',1,1) - 2)
10222 ,SUBSTRB(anc_id_94
10223        ,INSTRB(anc_id_94,'(]',1,2) + 2
10224        ,INSTRB(anc_id_94,'(]',1,3) -
10225         INSTRB(anc_id_94,'(]',1,2) - 2)
10226 ,SUBSTRB(anc_id_94
10227        ,INSTRB(anc_id_94,'(]',1,3) + 2
10228        ,INSTRB(anc_id_94,'(]',1,4) -
10229         INSTRB(anc_id_94,'(]',1,3) - 2)
10230 ,SUBSTRB(anc_id_94
10231        ,INSTRB(anc_id_94,'(]',1,4) + 2
10232        ,INSTRB(anc_id_94,'(]',1,5) -
10233         INSTRB(anc_id_94,'(]',1,4) - 2)
10234 ,SUBSTRB(anc_id_94
10235        ,INSTRB(anc_id_94,'(]',1,5) + 2
10236        ,INSTRB(anc_id_94,'(]',1,6) -
10237         INSTRB(anc_id_94,'(]',1,5) - 2)
10238 ,SUBSTRB(anc_id_94
10239        ,INSTRB(anc_id_94,'(]',1,6) + 2
10240        ,INSTRB(anc_id_94,'(]',1,7) -
10241         INSTRB(anc_id_94,'(]',1,6) - 2)
10242 ,SUBSTRB(anc_id_94
10243        ,INSTRB(anc_id_94,'(]',1,7) + 2
10244        ,LENGTHB(anc_id_94))
10245 )
10246 
10247 WHEN anc_id_95 IS NOT NULL THEN
10248   INTO xla_ae_line_acs (
10249         ae_header_id , ae_line_num , object_version_number
10250       , analytical_criterion_code
10251       , analytical_criterion_type_code
10252       , amb_context_code
10253       , ac1,ac2,ac3,ac4,ac5)
10254 VALUES (ae_header_id, ae_line_num, C_OVN
10255 ,SUBSTRB(anc_id_95
10256        ,1
10257        ,INSTRB(anc_id_95,'(]',1,1) -1)
10258 ,SUBSTRB(anc_id_95
10259        ,INSTRB(anc_id_95,'(]',1,1) + 2
10260        ,INSTRB(anc_id_95,'(]',1,2) -
10261         INSTRB(anc_id_95,'(]',1,1) - 2)
10262 ,SUBSTRB(anc_id_95
10263        ,INSTRB(anc_id_95,'(]',1,2) + 2
10264        ,INSTRB(anc_id_95,'(]',1,3) -
10265         INSTRB(anc_id_95,'(]',1,2) - 2)
10266 ,SUBSTRB(anc_id_95
10267        ,INSTRB(anc_id_95,'(]',1,3) + 2
10268        ,INSTRB(anc_id_95,'(]',1,4) -
10269         INSTRB(anc_id_95,'(]',1,3) - 2)
10270 ,SUBSTRB(anc_id_95
10271        ,INSTRB(anc_id_95,'(]',1,4) + 2
10272        ,INSTRB(anc_id_95,'(]',1,5) -
10273         INSTRB(anc_id_95,'(]',1,4) - 2)
10274 ,SUBSTRB(anc_id_95
10275        ,INSTRB(anc_id_95,'(]',1,5) + 2
10276        ,INSTRB(anc_id_95,'(]',1,6) -
10277         INSTRB(anc_id_95,'(]',1,5) - 2)
10278 ,SUBSTRB(anc_id_95
10279        ,INSTRB(anc_id_95,'(]',1,6) + 2
10280        ,INSTRB(anc_id_95,'(]',1,7) -
10281         INSTRB(anc_id_95,'(]',1,6) - 2)
10282 ,SUBSTRB(anc_id_95
10283        ,INSTRB(anc_id_95,'(]',1,7) + 2
10284        ,LENGTHB(anc_id_95))
10285 )
10286 
10287 WHEN anc_id_96 IS NOT NULL THEN
10288   INTO xla_ae_line_acs (
10289         ae_header_id , ae_line_num , object_version_number
10290       , analytical_criterion_code
10291       , analytical_criterion_type_code
10292       , amb_context_code
10293       , ac1,ac2,ac3,ac4,ac5)
10294 VALUES (ae_header_id, ae_line_num, C_OVN
10295 ,SUBSTRB(anc_id_96
10296        ,1
10297        ,INSTRB(anc_id_96,'(]',1,1) -1)
10298 ,SUBSTRB(anc_id_96
10299        ,INSTRB(anc_id_96,'(]',1,1) + 2
10300        ,INSTRB(anc_id_96,'(]',1,2) -
10301         INSTRB(anc_id_96,'(]',1,1) - 2)
10302 ,SUBSTRB(anc_id_96
10303        ,INSTRB(anc_id_96,'(]',1,2) + 2
10304        ,INSTRB(anc_id_96,'(]',1,3) -
10305         INSTRB(anc_id_96,'(]',1,2) - 2)
10306 ,SUBSTRB(anc_id_96
10307        ,INSTRB(anc_id_96,'(]',1,3) + 2
10308        ,INSTRB(anc_id_96,'(]',1,4) -
10309         INSTRB(anc_id_96,'(]',1,3) - 2)
10310 ,SUBSTRB(anc_id_96
10311        ,INSTRB(anc_id_96,'(]',1,4) + 2
10312        ,INSTRB(anc_id_96,'(]',1,5) -
10313         INSTRB(anc_id_96,'(]',1,4) - 2)
10314 ,SUBSTRB(anc_id_96
10315        ,INSTRB(anc_id_96,'(]',1,5) + 2
10316        ,INSTRB(anc_id_96,'(]',1,6) -
10317         INSTRB(anc_id_96,'(]',1,5) - 2)
10318 ,SUBSTRB(anc_id_96
10319        ,INSTRB(anc_id_96,'(]',1,6) + 2
10320        ,INSTRB(anc_id_96,'(]',1,7) -
10321         INSTRB(anc_id_96,'(]',1,6) - 2)
10322 ,SUBSTRB(anc_id_96
10323        ,INSTRB(anc_id_96,'(]',1,7) + 2
10324        ,LENGTHB(anc_id_96))
10325 )
10326 
10327 WHEN anc_id_97 IS NOT NULL THEN
10328   INTO xla_ae_line_acs (
10329         ae_header_id , ae_line_num , object_version_number
10330       , analytical_criterion_code
10331       , analytical_criterion_type_code
10332       , amb_context_code
10333       , ac1,ac2,ac3,ac4,ac5)
10334 VALUES (ae_header_id, ae_line_num, C_OVN
10335 ,SUBSTRB(anc_id_97
10336        ,1
10337        ,INSTRB(anc_id_97,'(]',1,1) -1)
10338 ,SUBSTRB(anc_id_97
10339        ,INSTRB(anc_id_97,'(]',1,1) + 2
10340        ,INSTRB(anc_id_97,'(]',1,2) -
10341         INSTRB(anc_id_97,'(]',1,1) - 2)
10342 ,SUBSTRB(anc_id_97
10343        ,INSTRB(anc_id_97,'(]',1,2) + 2
10344        ,INSTRB(anc_id_97,'(]',1,3) -
10345         INSTRB(anc_id_97,'(]',1,2) - 2)
10346 ,SUBSTRB(anc_id_97
10347        ,INSTRB(anc_id_97,'(]',1,3) + 2
10348        ,INSTRB(anc_id_97,'(]',1,4) -
10349         INSTRB(anc_id_97,'(]',1,3) - 2)
10350 ,SUBSTRB(anc_id_97
10351        ,INSTRB(anc_id_97,'(]',1,4) + 2
10352        ,INSTRB(anc_id_97,'(]',1,5) -
10353         INSTRB(anc_id_97,'(]',1,4) - 2)
10354 ,SUBSTRB(anc_id_97
10355        ,INSTRB(anc_id_97,'(]',1,5) + 2
10356        ,INSTRB(anc_id_97,'(]',1,6) -
10357         INSTRB(anc_id_97,'(]',1,5) - 2)
10358 ,SUBSTRB(anc_id_97
10359        ,INSTRB(anc_id_97,'(]',1,6) + 2
10360        ,INSTRB(anc_id_97,'(]',1,7) -
10361         INSTRB(anc_id_97,'(]',1,6) - 2)
10362 ,SUBSTRB(anc_id_97
10363        ,INSTRB(anc_id_97,'(]',1,7) + 2
10364        ,LENGTHB(anc_id_97))
10365 )
10366 
10367 WHEN anc_id_98 IS NOT NULL THEN
10368   INTO xla_ae_line_acs (
10369         ae_header_id , ae_line_num , object_version_number
10370       , analytical_criterion_code
10371       , analytical_criterion_type_code
10372       , amb_context_code
10373       , ac1,ac2,ac3,ac4,ac5)
10374 VALUES (ae_header_id, ae_line_num, C_OVN
10375 ,SUBSTRB(anc_id_98
10376        ,1
10377        ,INSTRB(anc_id_98,'(]',1,1) -1)
10378 ,SUBSTRB(anc_id_98
10379        ,INSTRB(anc_id_98,'(]',1,1) + 2
10380        ,INSTRB(anc_id_98,'(]',1,2) -
10381         INSTRB(anc_id_98,'(]',1,1) - 2)
10382 ,SUBSTRB(anc_id_98
10383        ,INSTRB(anc_id_98,'(]',1,2) + 2
10384        ,INSTRB(anc_id_98,'(]',1,3) -
10385         INSTRB(anc_id_98,'(]',1,2) - 2)
10386 ,SUBSTRB(anc_id_98
10387        ,INSTRB(anc_id_98,'(]',1,3) + 2
10388        ,INSTRB(anc_id_98,'(]',1,4) -
10389         INSTRB(anc_id_98,'(]',1,3) - 2)
10390 ,SUBSTRB(anc_id_98
10391        ,INSTRB(anc_id_98,'(]',1,4) + 2
10392        ,INSTRB(anc_id_98,'(]',1,5) -
10393         INSTRB(anc_id_98,'(]',1,4) - 2)
10394 ,SUBSTRB(anc_id_98
10395        ,INSTRB(anc_id_98,'(]',1,5) + 2
10396        ,INSTRB(anc_id_98,'(]',1,6) -
10397         INSTRB(anc_id_98,'(]',1,5) - 2)
10398 ,SUBSTRB(anc_id_98
10399        ,INSTRB(anc_id_98,'(]',1,6) + 2
10400        ,INSTRB(anc_id_98,'(]',1,7) -
10401         INSTRB(anc_id_98,'(]',1,6) - 2)
10402 ,SUBSTRB(anc_id_98
10403        ,INSTRB(anc_id_98,'(]',1,7) + 2
10404        ,LENGTHB(anc_id_98))
10405 )
10406 
10407 WHEN anc_id_99 IS NOT NULL THEN
10408   INTO xla_ae_line_acs (
10409         ae_header_id , ae_line_num , object_version_number
10410       , analytical_criterion_code
10411       , analytical_criterion_type_code
10412       , amb_context_code
10413       , ac1,ac2,ac3,ac4,ac5)
10414 VALUES (ae_header_id, ae_line_num, C_OVN
10415 ,SUBSTRB(anc_id_99
10416        ,1
10417        ,INSTRB(anc_id_99,'(]',1,1) -1)
10418 ,SUBSTRB(anc_id_99
10419        ,INSTRB(anc_id_99,'(]',1,1) + 2
10420        ,INSTRB(anc_id_99,'(]',1,2) -
10421         INSTRB(anc_id_99,'(]',1,1) - 2)
10422 ,SUBSTRB(anc_id_99
10423        ,INSTRB(anc_id_99,'(]',1,2) + 2
10424        ,INSTRB(anc_id_99,'(]',1,3) -
10425         INSTRB(anc_id_99,'(]',1,2) - 2)
10426 ,SUBSTRB(anc_id_99
10427        ,INSTRB(anc_id_99,'(]',1,3) + 2
10428        ,INSTRB(anc_id_99,'(]',1,4) -
10429         INSTRB(anc_id_99,'(]',1,3) - 2)
10430 ,SUBSTRB(anc_id_99
10431        ,INSTRB(anc_id_99,'(]',1,4) + 2
10432        ,INSTRB(anc_id_99,'(]',1,5) -
10433         INSTRB(anc_id_99,'(]',1,4) - 2)
10434 ,SUBSTRB(anc_id_99
10435        ,INSTRB(anc_id_99,'(]',1,5) + 2
10436        ,INSTRB(anc_id_99,'(]',1,6) -
10437         INSTRB(anc_id_99,'(]',1,5) - 2)
10438 ,SUBSTRB(anc_id_99
10439        ,INSTRB(anc_id_99,'(]',1,6) + 2
10440        ,INSTRB(anc_id_99,'(]',1,7) -
10441         INSTRB(anc_id_99,'(]',1,6) - 2)
10442 ,SUBSTRB(anc_id_99
10443        ,INSTRB(anc_id_99,'(]',1,7) + 2
10444        ,LENGTHB(anc_id_99))
10445 )
10446 
10447 WHEN anc_id_100 IS NOT NULL THEN
10448   INTO xla_ae_line_acs (
10449         ae_header_id , ae_line_num , object_version_number
10450       , analytical_criterion_code
10451       , analytical_criterion_type_code
10452       , amb_context_code
10453       , ac1,ac2,ac3,ac4,ac5)
10454 VALUES (ae_header_id, ae_line_num, C_OVN
10455 ,SUBSTRB(anc_id_100
10456        ,1
10457        ,INSTRB(anc_id_100,'(]',1,1) -1)
10458 ,SUBSTRB(anc_id_100
10459        ,INSTRB(anc_id_100,'(]',1,1) + 2
10460        ,INSTRB(anc_id_100,'(]',1,2) -
10461         INSTRB(anc_id_100,'(]',1,1) - 2)
10462 ,SUBSTRB(anc_id_100
10463        ,INSTRB(anc_id_100,'(]',1,2) + 2
10464        ,INSTRB(anc_id_100,'(]',1,3) -
10465         INSTRB(anc_id_100,'(]',1,2) - 2)
10466 ,SUBSTRB(anc_id_100
10467        ,INSTRB(anc_id_100,'(]',1,3) + 2
10468        ,INSTRB(anc_id_100,'(]',1,4) -
10469         INSTRB(anc_id_100,'(]',1,3) - 2)
10470 ,SUBSTRB(anc_id_100
10471        ,INSTRB(anc_id_100,'(]',1,4) + 2
10472        ,INSTRB(anc_id_100,'(]',1,5) -
10473         INSTRB(anc_id_100,'(]',1,4) - 2)
10474 ,SUBSTRB(anc_id_100
10475        ,INSTRB(anc_id_100,'(]',1,5) + 2
10476        ,INSTRB(anc_id_100,'(]',1,6) -
10477         INSTRB(anc_id_100,'(]',1,5) - 2)
10478 ,SUBSTRB(anc_id_100
10479        ,INSTRB(anc_id_100,'(]',1,6) + 2
10480        ,INSTRB(anc_id_100,'(]',1,7) -
10481         INSTRB(anc_id_100,'(]',1,6) - 2)
10482 ,SUBSTRB(anc_id_100
10483        ,INSTRB(anc_id_100,'(]',1,7) + 2
10484        ,LENGTHB(anc_id_100))
10485 )
10486 
10487 
10488 SELECT  ae_header_id
10489       , ae_line_num
10490       , anc_id_1
10491       , anc_id_2
10492       , anc_id_3
10493       , anc_id_4
10494       , anc_id_5
10495       , anc_id_6
10496       , anc_id_7
10497       , anc_id_8
10498       , anc_id_9
10499       , anc_id_10
10500       , anc_id_11
10501       , anc_id_12
10502       , anc_id_13
10503       , anc_id_14
10504       , anc_id_15
10505       , anc_id_16
10506       , anc_id_17
10507       , anc_id_18
10508       , anc_id_19
10509       , anc_id_20
10510       , anc_id_21
10511       , anc_id_22
10512       , anc_id_23
10513       , anc_id_24
10514       , anc_id_25
10515       , anc_id_26
10516       , anc_id_27
10517       , anc_id_28
10518       , anc_id_29
10519       , anc_id_30
10520       , anc_id_31
10521       , anc_id_32
10522       , anc_id_33
10523       , anc_id_34
10524       , anc_id_35
10525       , anc_id_36
10526       , anc_id_37
10527       , anc_id_38
10528       , anc_id_39
10529       , anc_id_40
10530       , anc_id_41
10531       , anc_id_42
10532       , anc_id_43
10533       , anc_id_44
10534       , anc_id_45
10535       , anc_id_46
10536       , anc_id_47
10537       , anc_id_48
10538       , anc_id_49
10539       , anc_id_50
10540       , anc_id_51
10541       , anc_id_52
10542       , anc_id_53
10543       , anc_id_54
10544       , anc_id_55
10545       , anc_id_56
10546       , anc_id_57
10547       , anc_id_58
10548       , anc_id_59
10549       , anc_id_60
10550       , anc_id_61
10551       , anc_id_62
10552       , anc_id_63
10553       , anc_id_64
10554       , anc_id_65
10555       , anc_id_66
10556       , anc_id_67
10557       , anc_id_68
10558       , anc_id_69
10559       , anc_id_70
10560       , anc_id_71
10561       , anc_id_72
10562       , anc_id_73
10563       , anc_id_74
10564       , anc_id_75
10565       , anc_id_76
10566       , anc_id_77
10567       , anc_id_78
10568       , anc_id_79
10569       , anc_id_80
10570       , anc_id_81
10571       , anc_id_82
10572       , anc_id_83
10573       , anc_id_84
10574       , anc_id_85
10575       , anc_id_86
10576       , anc_id_87
10577       , anc_id_88
10578       , anc_id_89
10579       , anc_id_90
10580       , anc_id_91
10581       , anc_id_92
10582       , anc_id_93
10583       , anc_id_94
10584       , anc_id_95
10585       , anc_id_96
10586       , anc_id_97
10587       , anc_id_98
10588       , anc_id_99
10589       , anc_id_100
10590  FROM  xla_ae_lines_gt
10591 WHERE  ae_line_num is not null
10592 GROUP  BY
10593        ae_line_num
10594       ,ae_header_id
10595       ,anc_id_1
10596       ,anc_id_2
10597       ,anc_id_3
10598       ,anc_id_4
10599       ,anc_id_5
10600       ,anc_id_6
10601       ,anc_id_7
10602       ,anc_id_8
10603       ,anc_id_9
10604       ,anc_id_10
10605       ,anc_id_11
10606       ,anc_id_12
10607       ,anc_id_13
10608       ,anc_id_14
10609       ,anc_id_15
10610       ,anc_id_16
10611       ,anc_id_17
10612       ,anc_id_18
10613       ,anc_id_19
10614       ,anc_id_20
10615       ,anc_id_21
10616       ,anc_id_22
10617       ,anc_id_23
10618       ,anc_id_24
10619       ,anc_id_25
10620       ,anc_id_26
10621       ,anc_id_27
10622       ,anc_id_28
10623       ,anc_id_29
10624       ,anc_id_30
10625       ,anc_id_31
10626       ,anc_id_32
10627       ,anc_id_33
10628       ,anc_id_34
10629       ,anc_id_35
10630       ,anc_id_36
10631       ,anc_id_37
10632       ,anc_id_38
10633       ,anc_id_39
10634       ,anc_id_40
10635       ,anc_id_41
10636       ,anc_id_42
10637       ,anc_id_43
10638       ,anc_id_44
10639       ,anc_id_45
10640       ,anc_id_46
10641       ,anc_id_47
10642       ,anc_id_48
10643       ,anc_id_49
10644       ,anc_id_50
10645       ,anc_id_51
10646       ,anc_id_52
10647       ,anc_id_53
10648       ,anc_id_54
10649       ,anc_id_55
10650       ,anc_id_56
10651       ,anc_id_57
10652       ,anc_id_58
10653       ,anc_id_59
10654       ,anc_id_60
10655       ,anc_id_61
10656       ,anc_id_62
10657       ,anc_id_63
10658       ,anc_id_64
10659       ,anc_id_65
10660       ,anc_id_66
10661       ,anc_id_67
10662       ,anc_id_68
10663       ,anc_id_69
10664       ,anc_id_70
10665       ,anc_id_71
10666       ,anc_id_72
10667       ,anc_id_73
10668       ,anc_id_74
10669       ,anc_id_75
10670       ,anc_id_76
10671       ,anc_id_77
10672       ,anc_id_78
10673       ,anc_id_79
10674       ,anc_id_80
10675       ,anc_id_81
10676       ,anc_id_82
10677       ,anc_id_83
10678       ,anc_id_84
10679       ,anc_id_85
10680       ,anc_id_86
10681       ,anc_id_87
10682       ,anc_id_88
10683       ,anc_id_89
10684       ,anc_id_90
10685       ,anc_id_91
10686       ,anc_id_92
10687       ,anc_id_93
10688       ,anc_id_94
10689       ,anc_id_95
10690       ,anc_id_96
10691       ,anc_id_97
10692       ,anc_id_98
10693       ,anc_id_99
10694       ,anc_id_100;
10695 
10696    --
10697    l_rowcount := SQL%ROWCOUNT;
10698 
10699    IF (C_LEVEL_EVENT >= g_log_level) THEN
10700       trace
10701          (p_msg      => '# line analytical criteria inserted into xla_ae_line_acs = '||l_rowcount
10702          ,p_level    => C_LEVEL_EVENT
10703          ,p_module   => l_log_module);
10704    END IF;
10705 
10706    EXCEPTION
10707    WHEN OTHERS  THEN
10708 
10709      IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10710           trace
10711               (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
10712               ,p_level    => C_LEVEL_EXCEPTION
10713               ,p_module   => l_log_module);
10714      END IF;
10715 
10716      xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
10717                                       ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
10718                                       ,p_token_1      => 'ERROR'
10719                                       ,p_value_1      => sqlerrm
10720                                       );
10721 
10722 
10723    END;
10724 
10725 EXCEPTION
10726 WHEN xla_exceptions_pkg.application_exception THEN
10727   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10728        trace
10729            (p_msg      => 'Error. = '||sqlerrm
10730            ,p_level    => C_LEVEL_PROCEDURE
10731            ,p_module   => l_log_module);
10732   END IF;
10733   RAISE;
10734 WHEN OTHERS  THEN
10735   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10736        trace
10737            (p_msg      => 'Error. = '||sqlerrm
10738            ,p_level    => C_LEVEL_PROCEDURE
10739            ,p_module   => l_log_module);
10740   END IF;
10741   xla_exceptions_pkg.raise_message
10742        (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertAnalyticalCriteria100');
10743 END InsertAnalyticalCriteria100;
10744 --
10745 /*======================================================================+
10746 |                                                                       |
10747 | 4669308  - Adjust Final MPA Line                                      |
10748 |                                                                       |
10749 | This is to back calculate the rounded amounts on the final period of  |
10750 | MPA reversal lines.  It should only be necessary if all recogniton    |
10751 | periods are reversed.                                                 |
10752 |                                                                       |
10753 +======================================================================*/
10754 --
10755 PROCEDURE AdjustMpaLine(p_application_id  IN INTEGER)
10756 IS
10757 l_log_module         VARCHAR2(240);
10758 l_count number;
10759 
10760 CURSOR cur_mpa_lines IS
10761 SELECT parent_header_id
10762       ,parent_ae_line_num
10763       ,MIN(ae_header_id)
10764       ,MAX(ae_header_id)
10765 FROM   xla_ae_headers_gt
10766 WHERE  parent_header_id IS NOT NULL
10767 AND    parent_ae_line_num  IS NOT NULL
10768 AND    balance_type_code = 'A' -- added for bug:7377888
10769 AND    NVL(accrual_reversal_flag,'N') = 'N'
10770 GROUP BY parent_header_id, parent_ae_line_num
10771 HAVING COUNT(*) > 1;
10772 
10773 l_array_parent_hdr_idx      t_array_Num;
10774 l_array_parent_line_idx     t_array_Num;
10775 l_array_min_hdr_idx         t_array_Num;
10776 l_array_max_hdr_idx         t_array_Num;
10777 
10778 l_array_entered_amt         t_array_Num;
10779 l_array_accted_amt          t_array_Num;
10780 l_array_unround_entered_amt t_array_Num;
10781 l_array_unround_accted_amt  t_array_Num;
10782 
10783 l_array_mpa_header_idx      t_array_Num;  -- 5017009
10784 l_array_mpa_line_idx        t_array_Num;  -- 5017009
10785 
10786 BEGIN
10787 --
10788 IF g_log_enabled THEN
10789       l_log_module := C_DEFAULT_MODULE||'.AdjustMpaLine';
10790 END IF;
10791 --
10792 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
10793 
10794       trace
10795          (p_msg      => 'BEGIN of AdjustMpaLine'
10796          ,p_level    => C_LEVEL_PROCEDURE
10797          ,p_module   => l_log_module);
10798 
10799 END IF;
10800 
10801    ------------------------------------------------------------
10802    -- Find the MPA lines
10803    ------------------------------------------------------------
10804    OPEN  cur_mpa_lines;
10805    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;
10806    CLOSE cur_mpa_lines;
10807 
10808 
10809    ------------------------------------------------------------
10810    -- Find the original amounts
10811    ------------------------------------------------------------
10812    FOR i IN 1..l_array_parent_hdr_idx.COUNT LOOP
10813      /* Excluding the join with XLA_DISTRIBUTION_LINKS bug:7230462 */
10814     -- SELECT NVL(l.entered_cr, l.entered_dr)
10815     --        ,NVL(l.accounted_cr, l.accounted_dr)
10816     --        ,NVL(l.unrounded_entered_cr, l.unrounded_entered_dr)
10817     --        ,NVL(l.unrounded_accounted_cr, l.unrounded_accounted_dr)
10818     --  INTO   l_array_entered_amt(i)
10819     --        ,l_array_accted_amt(i)
10820     --        ,l_array_unround_entered_amt(i)
10821     --        ,l_array_unround_accted_amt(i)
10822     --  FROM   xla_ae_lines l,
10823     --         xla_distribution_links d                     -- added for bug 7377888
10824     --  /*WHERE  ae_header_id   = l_array_parent_hdr_idx(i)
10825     --  AND    ae_line_num    = l_array_parent_line_idx(i)
10826     --  AND    application_id = p_application_id;*/         -- commented for bug 7377888
10827     --  WHERE  l.ae_header_id   = d.ae_header_id
10828     --  AND    l.ae_line_num    = d.ae_line_num
10829     --  AND    l.application_id = p_application_id
10830     --  AND    d.application_id = p_application_id
10831     --  AND    d.ae_header_id = l_array_parent_hdr_idx(i)
10832     --  AND    d.temp_line_num = l_array_parent_line_idx(i); -- added new WHERE Clause for bug 7377888
10833 
10834     /* Changes for the bug:7230462 */
10835     SELECT NVL(l.entered_cr, l.entered_dr)
10836            ,NVL(l.accounted_cr, l.accounted_dr)
10837            ,NVL(l.unrounded_entered_cr, l.unrounded_entered_dr)
10838            ,NVL(l.unrounded_accounted_cr, l.unrounded_accounted_dr)
10839      INTO  l_array_entered_amt(i)
10840            ,l_array_accted_amt(i)
10841            ,l_array_unround_entered_amt(i)
10842            ,l_array_unround_accted_amt(i)
10843     FROM   xla_ae_lines l
10844     WHERE  l.ae_header_id   = l_array_parent_hdr_idx(i)
10845     AND    l.ae_line_num    = l_array_parent_line_idx(i)
10846     AND    l.application_id = p_application_id ;
10847 
10848 
10849    END LOOP;
10850 
10851    -----------------------------------------------------------------------------------------------------------
10852    -- 5017009 - Update the unrounded amounts with the rounded amounts for each line except the last MPA entry
10853    -----------------------------------------------------------------------------------------------------------
10854    FOR i in 1..l_array_parent_hdr_idx.COUNT LOOP
10855 
10856        SELECT xel2.ae_header_id
10857              ,xel2.ae_line_num
10858        BULK COLLECT INTO
10859               l_array_mpa_header_idx
10860              ,l_array_mpa_line_idx
10861        FROM   xla_ae_lines   xel2
10862              ,xla_ae_headers xeh
10863        WHERE  xel2.ae_header_id       = xeh.ae_header_id
10864        AND    xel2.application_id     = p_application_id
10865        AND    xel2.ae_header_id      <> l_array_max_hdr_idx(i)
10866        AND    xeh.application_id      = p_application_id
10867        AND    xeh.parent_ae_header_id = l_array_parent_hdr_idx(i);
10868 
10869        IF (C_LEVEL_STATEMENT >= g_log_level) THEN
10870           trace
10871                 (p_msg      => 'MPA count='||l_array_mpa_header_idx.COUNT
10872                 ,p_level    => C_LEVEL_STATEMENT
10873                 ,p_module   => l_log_module);
10874           FOR j IN 1..l_array_mpa_header_idx.COUNT LOOP
10875              trace
10876                 (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||' parent_line='||l_array_parent_line_idx(i)||
10877                                ' mpa_header='||l_array_mpa_header_idx(j)||
10878                                ' line='||l_array_mpa_line_idx(j)
10879                 ,p_level    => C_LEVEL_STATEMENT
10880                 ,p_module   => l_log_module);
10881           END LOOP;
10882        END IF;
10883 
10884        FORALL j IN 1..l_array_mpa_header_idx.COUNT
10885           UPDATE xla_ae_lines xel
10886           SET    unrounded_entered_cr   = entered_cr
10887                 ,unrounded_entered_dr   = entered_dr
10888                 ,unrounded_accounted_cr = accounted_cr
10889                 ,unrounded_accounted_dr = accounted_dr
10890           WHERE application_id = p_application_id
10891           AND   ae_header_id   = l_array_mpa_header_idx(j)
10892           AND   ae_line_num    = l_array_mpa_line_idx(j);
10893 
10894        FORALL j IN 1..l_array_mpa_header_idx.COUNT
10895           UPDATE xla_distribution_links xdl
10896           SET   (unrounded_entered_cr
10897                 ,unrounded_entered_dr
10898                 ,unrounded_accounted_cr
10899                 ,unrounded_accounted_dr) =
10900                 (SELECT unrounded_entered_cr
10901                        ,unrounded_entered_dr
10902                        ,unrounded_accounted_cr
10903                        ,unrounded_accounted_dr
10904                  FROM  xla_ae_lines   xel2
10905                  WHERE xel2.ae_header_id = xdl.ae_header_id
10906                  AND   xel2.ae_line_num  = xdl.ae_line_num)
10907           WHERE application_id = p_application_id  -- 4585874
10908           AND   ae_header_id = l_array_mpa_header_idx(j)
10909           AND   ae_line_num  = l_array_mpa_line_idx(j);
10910 
10911    END LOOP;
10912    --------------------------------------------------------------------------------------------
10913 
10914    ------------------------------------------------------------
10915    -- Update the AMOUNTs for the last MPA line amount
10916    ------------------------------------------------------------
10917    FORALL i IN 1..l_array_parent_hdr_idx.COUNT
10918       UPDATE xla_ae_lines xel
10919       SET   (entered_cr
10920             ,entered_dr
10921             ,accounted_cr
10922             ,accounted_dr
10923             ,unrounded_entered_cr
10924             ,unrounded_entered_dr
10925             ,unrounded_accounted_cr
10926             ,unrounded_accounted_dr) =
10927             (SELECT DECODE(MIN(entered_cr),             NULL,NULL, l_array_entered_amt(i)         - SUM(entered_cr))
10928                    ,DECODE(MIN(entered_dr),             NULL,NULL, l_array_entered_amt(i)         - SUM(entered_dr))
10929                    ,DECODE(MIN(accounted_cr),           NULL,NULL, l_array_accted_amt(i)          - SUM(accounted_cr))
10930                    ,DECODE(MIN(accounted_dr),           NULL,NULL, l_array_accted_amt(i)          - SUM(accounted_dr))
10931                    ,DECODE(MIN(unrounded_entered_cr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(unrounded_entered_cr))
10932                    ,DECODE(MIN(unrounded_entered_dr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(unrounded_entered_dr))
10933                    ,DECODE(MIN(unrounded_accounted_cr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(unrounded_accounted_cr))
10934                    ,DECODE(MIN(unrounded_accounted_dr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(unrounded_accounted_dr))
10935              FROM  xla_ae_lines   xel2
10936                   ,xla_ae_headers xeh
10937              WHERE xel2.ae_header_id       = xeh.ae_header_id
10938              AND   xel2.ae_line_num        = xel.ae_line_num
10939              AND   xel2.application_id     = p_application_id  -- 4585874
10940              AND   xel2.ae_header_id      <> l_array_max_hdr_idx(i)
10941              AND   xeh.application_id      = p_application_id  -- 4585874
10942              AND   xeh.parent_ae_header_id = l_array_parent_hdr_idx(i)
10943              AND   xeh.parent_ae_line_num  = l_array_parent_line_idx(i))
10944       WHERE ae_header_id   = l_array_max_hdr_idx(i)
10945       AND   application_id = p_application_id;
10946 
10947    --------------------------------------------------------------------------------------------
10948    -- Update the DOC_ROUNDING values for the corresponding MPA line
10949    --------------------------------------------------------------------------------------------
10950    FORALL i IN 1..l_array_parent_hdr_idx.COUNT
10951       UPDATE xla_distribution_links xdl
10952       SET   (doc_rounding_acctd_amt
10953             ,doc_rounding_entered_amt
10954             ,unrounded_entered_cr       -- 4669308
10955             ,unrounded_entered_dr       -- 4669308
10956             ,unrounded_accounted_cr     -- 4669308
10957             ,unrounded_accounted_dr     -- 4669308
10958             ) =
10959             (SELECT DECODE(unrounded_accounted_cr,NULL,DECODE(unrounded_accounted_dr - accounted_dr,0,NULL,
10960                                                               unrounded_accounted_dr - accounted_dr)
10961                                                       ,DECODE(unrounded_accounted_cr - accounted_cr,0,NULL,
10962                                                               unrounded_accounted_cr - accounted_cr))
10963                    ,DECODE(unrounded_entered_cr,  NULL,DECODE(unrounded_entered_dr   - entered_dr,0,NULL,
10964                                                               unrounded_entered_dr   - entered_dr)
10965                                                       ,DECODE(unrounded_entered_cr   - entered_cr,0,NULL,
10966                                                               unrounded_entered_cr   - entered_cr))
10967                    ,unrounded_entered_cr
10968                    ,unrounded_entered_dr
10969                    ,unrounded_accounted_cr
10970                    ,unrounded_accounted_dr
10971              FROM  xla_ae_lines   xel2
10972              WHERE xel2.ae_header_id = xdl.ae_header_id
10973              AND   xel2.ae_line_num  = xdl.ae_line_num)
10974       WHERE application_id = p_application_id  -- 4585874
10975       AND   ae_header_id = l_array_max_hdr_idx(i);
10976 
10977 EXCEPTION
10978 WHEN xla_exceptions_pkg.application_exception THEN
10979   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10980        trace
10981            (p_msg      => 'Error. = '||sqlerrm
10982            ,p_level    => C_LEVEL_PROCEDURE
10983            ,p_module   => l_log_module);
10984   END IF;
10985   RAISE;
10986 WHEN OTHERS  THEN
10987   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
10988        trace
10989            (p_msg      => 'Error. = '||sqlerrm
10990            ,p_level    => C_LEVEL_PROCEDURE
10991            ,p_module   => l_log_module);
10992   END IF;
10993   xla_exceptions_pkg.raise_message
10994                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.AdjustMpaLine');
10995 END AdjustMpaLine;
10996 --
10997 
10998 /*======================================================================+
10999 |                                                                       |
11000 | 4669308 - Adjust Final MPA Reversal Line                              |
11001 |                                                                       |
11002 +======================================================================*/
11003 --
11004 /*
11005 PROCEDURE AdjustMpaRevLine(p_application_id  IN INTEGER)
11006 IS
11007 
11008 l_log_module         VARCHAR2(240);
11009 
11010 -- find the reversed parent entry which has all MPA lines reversed. Ignore Accrual reversal and if last MPA period is not reversed
11011 CURSOR cur_mpa_rev_lines IS
11012 SELECT MIN(xdl1.ref_ae_header_id)   -- parent ae_header_id
11013       ,MAX(xdl1.ae_line_num)
11014       ,xdl1.ae_header_id
11015       ,xdl1.ref_event_id
11016       ,xeh1.ledger_id
11017 FROM   xla_distribution_links xdl1
11018       ,xla_ae_headers         xeh1
11019       ,xla_ae_headers_gt      xehg
11020 WHERE xdl1.application_id = p_application_id
11021 AND   xeh1.application_id = p_application_id
11022 AND   xdl1.ae_header_id   = xehg.ae_header_id
11023 AND   xdl1.ae_header_id   = xeh1.ae_header_id
11024 AND   xdl1.temp_line_num  = xdl1.ref_temp_line_num*-1  -- is a reversal
11025 AND   EXISTS (SELECT 1
11026               FROM   xla_ae_headers
11027               WHERE  application_id      = p_application_id
11028               AND    parent_ae_header_id = xdl1.ref_ae_header_id
11029               AND    parent_ae_line_num IS NOT NULL)                         -- MPA only, not for Accrual Reversal
11030 GROUP BY xdl1.ref_ae_header_id, xdl1.ref_event_id, xdl1.application_id, xeh1.ledger_id, xdl1.ae_header_id
11031 HAVING (SELECT COUNT(*) FROM xla_distribution_links xdl2                     -- count of reversal lines
11032         WHERE  xdl2.application_id     = p_application_id
11033         AND    xdl2.ae_header_id       = xdl1.ae_header_id
11034         AND    xdl2.temp_line_num      = xdl2.ref_temp_line_num*-1
11035         AND    xdl2.ref_ae_header_id  <> xdl1.ref_ae_header_id
11036         AND    xdl2.ref_event_id       = xdl1.ref_event_id ) =
11037        (SELECT COUNT(*) FROM xla_distribution_links xdl3,xla_ae_headers xeh  -- count of original lines
11038         WHERE  xdl3.application_id     = p_application_id
11039         AND    xeh.application_id      = p_application_id
11040         AND    xdl3.ae_header_id       = xeh.ae_header_id
11041         AND    xdl3.event_id           = xdl1.ref_event_id
11042         AND    xdl3.ref_temp_line_num IS NULL
11043         AND    xeh.parent_ae_header_id = xdl1.ref_ae_header_id
11044         AND    xeh.parent_ae_line_num IS NOT NULL)
11045 ORDER BY xeh1.ledger_id, xdl1.ref_event_id;
11046      --(SELECT COUNT(*) FROM xla_ae_lines xel,xla_ae_headers xeh    -- count of original lines
11047      -- WHERE  xeh.application_id      = p_application_id
11048      -- AND    xel.ae_header_id        = xeh.ae_header_id
11049      -- AND    xeh.parent_ae_header_id = xdl1.ref_ae_header_id
11050      -- AND    xeh.parent_ae_line_num IS NOT NULL)
11051 
11052 CURSOR cur_last_mpa (l_ae_header   NUMBER, l_max_ae_header  NUMBER) is
11053 SELECT xel.rowid,  xel.*
11054 FROM   xla_ae_lines xel ,
11055        xla_distribution_links xdl2
11056 WHERE xel.application_id    = p_application_id
11057   AND xel.ae_header_id      = l_ae_header
11058   AND xdl2.application_id   = p_application_id
11059   AND xdl2.ae_header_id     = xel.ae_header_id
11060   AND xdl2.ref_ae_header_id = l_max_ae_header
11061   AND xel.ae_line_num       = xdl2.ae_line_num;
11062 
11063 l_last_mpa                  cur_last_mpa%ROWTYPE;
11064 
11065 l_array_parent_hdr_idx      xla_cmp_source_pkg.t_array_Num;
11066 l_array_parent_max_line     xla_cmp_source_pkg.t_array_Num;
11067 l_array_ae_header_id        xla_cmp_source_pkg.t_array_Num;
11068 l_array_ref_event_id        xla_cmp_source_pkg.t_array_Num;
11069 l_array_ledger_id           xla_cmp_source_pkg.t_array_Num;
11070 
11071 l_array_entered_amt         xla_ae_journal_entry_pkg.t_array_Num;
11072 l_array_accted_amt          xla_ae_journal_entry_pkg.t_array_Num;
11073 l_array_unround_entered_amt xla_ae_journal_entry_pkg.t_array_Num;
11074 l_array_unround_accted_amt  xla_ae_journal_entry_pkg.t_array_Num;
11075 
11076 l_max_hdr_id                NUMBER;
11077 l_max_lin_id                NUMBER;
11078 
11079 BEGIN
11080    --
11081    IF g_log_enabled THEN
11082       l_log_module := C_DEFAULT_MODULE||'.AdjustMpaRevLine';
11083    END IF;
11084    --
11085    IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11086 
11087       trace
11088          (p_msg      => 'BEGIN of AdjustMpaRevLine'
11089          ,p_level    => C_LEVEL_PROCEDURE
11090          ,p_module   => l_log_module);
11091 
11092    END IF;
11093 
11094    ------------------------------------------------------------
11095    -- Find the MPA Reversal lines
11096    ------------------------------------------------------------
11097    OPEN  cur_mpa_rev_lines;
11098    FETCH cur_mpa_rev_lines BULK COLLECT INTO  l_array_parent_hdr_idx
11099                                              ,l_array_parent_max_line  -- find the original amount
11100                                              ,l_array_ae_header_id
11101                                              ,l_array_ref_event_id
11102                                              ,l_array_ledger_id;
11103    CLOSE cur_mpa_rev_lines;
11104 
11105 
11106    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11107      for  i in 1..l_array_parent_hdr_idx.COUNT loop
11108       trace
11109          (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11110                         ' max_line_id='||l_array_parent_max_line(i)||
11111                         ' rev_ae_header='||l_array_ae_header_id(i)||
11112                         ' ref_event='||l_array_ref_event_id(i)||
11113                         ' ledger='||l_array_ledger_id(i)
11114          ,p_level    => C_LEVEL_STATEMENT
11115          ,p_module   => l_log_module);
11116      end loop;
11117    END IF;
11118 
11119    ------------------------------------------------------------
11120    -- Find the original amounts for each parent
11121    ------------------------------------------------------------
11122    FOR i IN 1..l_array_ae_header_id.COUNT LOOP
11123       SELECT NVL(entered_cr, entered_dr)
11124             ,NVL(accounted_cr, accounted_dr)
11125             ,NVL(unrounded_entered_cr, unrounded_entered_dr)
11126             ,NVL(unrounded_accounted_cr, unrounded_accounted_dr)
11127       INTO   l_array_entered_amt(i)
11128             ,l_array_accted_amt(i)
11129             ,l_array_unround_entered_amt(i)
11130             ,l_array_unround_accted_amt(i)
11131       FROM   xla_ae_lines
11132       WHERE  application_id = p_application_id
11133       AND    ae_header_id   = l_array_ae_header_id(i)
11134       AND    ae_line_num    = l_array_parent_max_line(i);
11135    END LOOP;
11136 
11137    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11138      for  i in 1..l_array_parent_hdr_idx.COUNT loop
11139       trace
11140          (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11141                         ' ent='||l_array_entered_amt(i)||
11142                         ' acc='||l_array_accted_amt(i)||
11143                         ' unr_ent='||l_array_unround_entered_amt(i)||
11144                         ' unr_acc='||l_array_unround_accted_amt(i)
11145          ,p_level    => C_LEVEL_STATEMENT
11146          ,p_module   => l_log_module);
11147      end loop;
11148    END IF;
11149 
11150    ------------------------------------------------------------
11151    -- Update the AMOUNTs for the last MPA line amount
11152    ------------------------------------------------------------
11153    FOR i IN 1..l_array_parent_hdr_idx.COUNT LOOP
11154 
11155       l_max_hdr_id := NULL;
11156       l_max_lin_id := NULL;
11157 
11158       SELECT MAX(xdl1.ref_ae_header_id)  -- last recognition header
11159       INTO   l_max_hdr_id
11160       FROM   xla_distribution_links xdl1
11161             ,xla_ae_headers         xeh1
11162       WHERE  xdl1.application_id      = p_application_id
11163       AND    xdl1.ae_header_id        = l_array_ae_header_id(i)
11164       AND    xdl1.temp_line_num       = xdl1.ref_temp_line_num*-1
11165       AND    xdl1.ref_ae_header_id    <> l_array_parent_hdr_idx(i)
11166       AND    xdl1.ref_event_id        = l_array_ref_event_id(i)
11167       AND    xeh1.application_id      = p_application_id
11168       AND    xeh1.parent_ae_header_id = l_array_parent_hdr_idx(i)
11169       AND    xeh1.parent_ae_line_num IS NOT NULL
11170       AND    xeh1.ledger_id           = l_array_ledger_id(i);
11171 
11172       IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11173           trace
11174              (p_msg      => 'parent='||l_array_parent_hdr_idx(i)||
11175                             ' last_recog_header='||l_max_hdr_id
11176              ,p_level    => C_LEVEL_STATEMENT
11177              ,p_module   => l_log_module);
11178       END IF;
11179 
11180       IF l_max_hdr_id IS NOT NULL THEN
11181 
11182        OPEN  cur_last_mpa(l_array_ae_header_id(i), l_max_hdr_id);
11183        FETCH cur_last_mpa INTO l_last_mpa;
11184        WHILE cur_last_mpa%FOUND LOOP
11185 
11186          UPDATE xla_ae_lines xel
11187          SET (entered_cr
11188              ,entered_dr
11189              ,accounted_cr
11190              ,accounted_dr
11191              ,unrounded_entered_cr
11192              ,unrounded_entered_dr
11193              ,unrounded_accounted_cr
11194              ,unrounded_accounted_dr) =
11195             (SELECT DECODE((l_last_mpa.entered_cr),             NULL,NULL, l_array_entered_amt(i)         - SUM(xel2.entered_cr))
11196                    ,DECODE((l_last_mpa.entered_dr),             NULL,NULL, l_array_entered_amt(i)         - SUM(xel2.entered_dr))
11197                    ,DECODE((l_last_mpa.accounted_cr),           NULL,NULL, l_array_accted_amt(i)          - SUM(xel2.accounted_cr))
11198                    ,DECODE((l_last_mpa.accounted_dr),           NULL,NULL, l_array_accted_amt(i)          - SUM(xel2.accounted_dr))
11199                    ,DECODE((l_last_mpa.unrounded_entered_cr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(xel2.unrounded_entered_cr))
11200                    ,DECODE((l_last_mpa.unrounded_entered_dr),   NULL,NULL, l_array_unround_entered_amt(i) - SUM(xel2.unrounded_entered_dr))
11201                    ,DECODE((l_last_mpa.unrounded_accounted_cr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(xel2.unrounded_accounted_cr))
11202                    ,DECODE((l_last_mpa.unrounded_accounted_dr), NULL,NULL, l_array_unround_accted_amt(i)  - SUM(xel2.unrounded_accounted_dr))
11203              FROM   xla_ae_lines xel2
11204                    ,xla_distribution_links xdl1
11205                    ,xla_ae_headers         xeh1
11206              WHERE xel2.application_id      = p_application_id
11207              AND   xel2.ae_header_id        = xdl1.ae_header_id
11208              AND   xel2.ae_line_num         = xdl1.ae_line_num
11209              AND   xdl1.application_id      = p_application_id
11210              AND   xdl1.ae_header_id        = l_array_ae_header_id(i)
11211              AND   xdl1.temp_line_num       = xdl1.ref_temp_line_num*-1
11212              AND   xeh1.application_id      = p_application_id
11213              AND   xeh1.parent_ae_header_id = l_array_parent_hdr_idx(i)
11214              AND   xeh1.parent_ae_line_num IS NOT NULL
11215              AND   xdl1.ref_ae_header_id    = xeh1.ae_header_id
11216              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
11217              AND   xdl1.ref_event_id       = l_array_ref_event_id(i)
11218              AND   xeh1.ledger_id          = l_array_ledger_id(i))
11219          WHERE rowid = l_last_mpa.rowid;
11220 
11221          IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11222               trace
11223                  (p_msg      => 'update xla_ae_lines count='||SQL%ROWCOUNT||
11224                                 ' ae_header='||l_last_mpa.ae_header_id||
11225                                 ' ae_line='||l_last_mpa.ae_line_num
11226                  ,p_level    => C_LEVEL_STATEMENT
11227                  ,p_module   => l_log_module);
11228          END IF;
11229 
11230          --------------------------------------------------------------------------------------------
11231          -- Update the DOC_ROUNDING values for the corresponding MPA line
11232          --------------------------------------------------------------------------------------------
11233          UPDATE xla_distribution_links xdl
11234          SET   (doc_rounding_acctd_amt
11235                ,doc_rounding_entered_amt
11236                ,unrounded_entered_cr
11237                ,unrounded_entered_dr
11238                ,unrounded_accounted_cr
11239                ,unrounded_accounted_dr
11240                ) =
11241             (SELECT DECODE(xel.unrounded_accounted_cr,NULL,DECODE(xel.unrounded_accounted_dr - xel.accounted_dr,0,NULL,
11242                                                                   xel.unrounded_accounted_dr - xel.accounted_dr)
11243                                                           ,DECODE(xel.unrounded_accounted_cr - xel.accounted_cr,0,NULL,
11244                                                                   xel.unrounded_accounted_cr - xel.accounted_cr))
11245                    ,DECODE(xel.unrounded_entered_cr,  NULL,DECODE(xel.unrounded_entered_dr   - xel.entered_dr,0,NULL,
11246                                                                   xel.unrounded_entered_dr   - xel.entered_dr)
11247                                                           ,DECODE(xel.unrounded_entered_cr   - xel.entered_cr,0,NULL,
11248                                                                   xel.unrounded_entered_cr   - xel.entered_cr))
11249                    ,xel.unrounded_entered_cr
11250                    ,xel.unrounded_entered_dr
11251                    ,xel.unrounded_accounted_cr
11252                    ,xel.unrounded_accounted_dr
11253              FROM   xla_ae_lines xel
11254                    ,xla_distribution_links xdl1
11255              WHERE xel.application_id    = p_application_id
11256              AND   xel.ae_header_id      = xdl1.ae_header_id
11257              AND   xel.ae_line_num       = xdl1.ae_line_num
11258              AND   xdl1.application_id   = p_application_id
11259              AND   xdl1.ae_header_id     = l_array_ae_header_id(i)
11260              AND   xdl1.temp_line_num    = xdl1.ref_temp_line_num*-1
11261              AND   xdl1.ref_ae_header_id = l_max_hdr_id           -- the last
11262              AND   xel.ae_line_num       = xdl.ae_line_num
11263              AND   xdl1.ref_event_id     = l_array_ref_event_id(i))
11264          WHERE application_id = p_application_id
11265          AND   ae_header_id   = l_last_mpa.ae_header_id
11266          AND   ae_line_num    = l_last_mpa.ae_line_num;
11267 
11268 
11269          IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11270               trace
11271                  (p_msg      => 'update xla_dist_link count='||SQL%ROWCOUNT||
11272                                 ' ae_header='||l_last_mpa.ae_header_id||
11273                                 ' ae_line='||l_last_mpa.ae_line_num
11274                  ,p_level    => C_LEVEL_STATEMENT
11275                  ,p_module   => l_log_module);
11276          END IF;
11277 
11278          FETCH cur_last_mpa INTO l_last_mpa;
11279 
11280        END LOOP;  --  cur_last_mpa%FOUND
11281 
11282        CLOSE cur_last_mpa;
11283 
11284 
11285       END IF; -- l_max_hdr_id IS NOT NULL
11286 
11287    END LOOP;  -- l_array_parent_hdr_idx.COUNT
11288 
11289 
11290 EXCEPTION
11291 WHEN xla_exceptions_pkg.application_exception THEN
11292   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11293        trace
11294            (p_msg      => 'Error. = '||sqlerrm
11295            ,p_level    => C_LEVEL_PROCEDURE
11296            ,p_module   => l_log_module);
11297   END IF;
11298   RAISE;
11299 WHEN OTHERS  THEN
11300   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11301        trace
11302            (p_msg      => 'Error. = '||sqlerrm
11303            ,p_level    => C_LEVEL_PROCEDURE
11304            ,p_module   => l_log_module);
11305   END IF;
11306   xla_exceptions_pkg.raise_message
11307                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.AdjustMpaRevLine');
11308 END AdjustMpaRevLine;
11309 */
11310 
11311 --
11312 /*======================================================================+
11313 | PRIVATE procedure: InsertLinks                                        |
11314 |                                                                       |
11315 | Description: Inserts distribution links                               |
11316 |                                                                       |
11317 |                                                                       |
11318 |                                                                       |
11319 +======================================================================*/
11320 --
11321 PROCEDURE InsertLinks(p_application_id    IN INTEGER)
11322 IS
11323 l_rowcount           NUMBER;
11324 l_log_module         VARCHAR2(240);
11325 BEGIN
11326 --
11327 IF g_log_enabled THEN
11328       l_log_module := C_DEFAULT_MODULE||'.InsertLinks';
11329 END IF;
11330 --
11331 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11332 
11333       trace
11334          (p_msg      => 'BEGIN of InsertLinks'
11335          ,p_level    => C_LEVEL_PROCEDURE
11336          ,p_module   => l_log_module);
11337 END IF;
11338 --
11339 BEGIN
11340 
11341  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11342 
11343       trace
11344          (p_msg      => 'SQL - Insert into xla_distribution_links'
11345          ,p_level    => C_LEVEL_EXCEPTION
11346          ,p_module   => l_log_module);
11347 
11348  END IF;
11349 
11350 l_rowcount := 0;
11351 
11352 INSERT INTO xla_distribution_links
11353 (
11354    application_id
11355  , event_id
11356  , source_distribution_id_char_1
11357  , source_distribution_id_char_2
11358  , source_distribution_id_char_3
11359  , source_distribution_id_char_4
11360  , source_distribution_id_char_5
11361  , source_distribution_id_num_1
11362  , source_distribution_id_num_2
11363  , source_distribution_id_num_3
11364  , source_distribution_id_num_4
11365  , source_distribution_id_num_5
11366  , source_distribution_type
11367  , APPLIED_TO_APPLICATION_ID
11368  , APPLIED_TO_ENTITY_CODE
11369  , APPLIED_TO_ENTITY_ID
11370  , APPLIED_TO_SOURCE_ID_NUM_1
11371  , APPLIED_TO_SOURCE_ID_NUM_2
11372  , APPLIED_TO_SOURCE_ID_NUM_3
11373  , APPLIED_TO_SOURCE_ID_NUM_4
11374  , APPLIED_TO_SOURCE_ID_CHAR_1
11375  , APPLIED_TO_SOURCE_ID_CHAR_2
11376  , APPLIED_TO_SOURCE_ID_CHAR_3
11377  , APPLIED_TO_SOURCE_ID_CHAR_4
11378  , APPLIED_TO_DISTRIBUTION_TYPE
11379  , APPLIED_TO_DIST_ID_NUM_1
11380  , APPLIED_TO_DIST_ID_NUM_2
11381  , APPLIED_TO_DIST_ID_NUM_3
11382  , APPLIED_TO_DIST_ID_NUM_4
11383  , APPLIED_TO_DIST_ID_NUM_5
11384  , APPLIED_TO_DIST_ID_CHAR_1
11385  , APPLIED_TO_DIST_ID_CHAR_2
11386  , APPLIED_TO_DIST_ID_CHAR_3
11387  , APPLIED_TO_DIST_ID_CHAR_4
11388  , APPLIED_TO_DIST_ID_CHAR_5
11389  , unrounded_entered_cr
11390  , unrounded_entered_dr
11391  , unrounded_accounted_cr
11392  , unrounded_accounted_dr
11393  , ae_header_id
11394  , ae_line_num
11395  , temp_line_num
11396  , tax_line_ref_id
11397  , tax_summary_line_ref_id
11398  , tax_rec_nrec_dist_ref_id
11399  , statistical_amount
11400  , event_class_code
11401  , event_type_code
11402  , line_definition_owner_code
11403  , line_definition_code
11404  , accounting_line_type_code
11405  , accounting_line_code
11406  , ref_event_id
11407  , ref_ae_header_id
11408  , ref_temp_line_num
11409  , gain_or_loss_ref
11410  , merge_duplicate_code
11411  , calculate_acctd_amts_flag
11412  , calculate_g_l_amts_flag
11413  , rounding_class_code
11414  , document_rounding_level
11415  , doc_rounding_acctd_amt
11416  , doc_rounding_entered_amt
11417  --
11418  -- Allocation Attributes
11419  --
11420  , alloc_to_application_id
11421  , alloc_to_entity_code
11422  , alloc_to_source_id_num_1
11423  , alloc_to_source_id_num_2
11424  , alloc_to_source_id_num_3
11425  , alloc_to_source_id_num_4
11426  , alloc_to_source_id_char_1
11427  , alloc_to_source_id_char_2
11428  , alloc_to_source_id_char_3
11429  , alloc_to_source_id_char_4
11430  , alloc_to_distribution_type
11431  , alloc_to_dist_id_char_1
11432  , alloc_to_dist_id_char_2
11433  , alloc_to_dist_id_char_3
11434  , alloc_to_dist_id_char_4
11435  , alloc_to_dist_id_char_5
11436  , alloc_to_dist_id_num_1
11437  , alloc_to_dist_id_num_2
11438  , alloc_to_dist_id_num_3
11439  , alloc_to_dist_id_num_4
11440  , alloc_to_dist_id_num_5
11441 )
11442 SELECT
11443           p_application_id
11444         , event_id
11445         , source_distribution_id_char_1
11446         , source_distribution_id_char_2
11447         , source_distribution_id_char_3
11448         , source_distribution_id_char_4
11449         , source_distribution_id_char_5
11450         , source_distribution_id_num_1
11451         , source_distribution_id_num_2
11452         , source_distribution_id_num_3
11453         , source_distribution_id_num_4
11454         , source_distribution_id_num_5
11455         , source_distribution_type
11456         , BFLOW_APPLICATION_ID
11457         , BFLOW_ENTITY_CODE
11458         , APPLIED_TO_ENTITY_ID
11459         , BFLOW_SOURCE_ID_NUM_1
11460         , BFLOW_SOURCE_ID_NUM_2
11461         , BFLOW_SOURCE_ID_NUM_3
11462         , BFLOW_SOURCE_ID_NUM_4
11463         , BFLOW_SOURCE_ID_CHAR_1
11464         , BFLOW_SOURCE_ID_CHAR_2
11465         , BFLOW_SOURCE_ID_CHAR_3
11466         , BFLOW_SOURCE_ID_CHAR_4
11467         , BFLOW_DISTRIBUTION_TYPE
11468         , BFLOW_DIST_ID_NUM_1
11469         , BFLOW_DIST_ID_NUM_2
11470         , BFLOW_DIST_ID_NUM_3
11471         , BFLOW_DIST_ID_NUM_4
11472         , BFLOW_DIST_ID_NUM_5
11473         , BFLOW_DIST_ID_CHAR_1
11474         , BFLOW_DIST_ID_CHAR_2
11475         , BFLOW_DIST_ID_CHAR_3
11476         , BFLOW_DIST_ID_CHAR_4
11477         , BFLOW_DIST_ID_CHAR_5
11478         , unrounded_entered_cr
11479         , unrounded_entered_dr
11480         , unrounded_accounted_cr
11481         , unrounded_accounted_dr
11482         , ae_header_id
11483         , ae_line_num
11484         , temp_line_num
11485         , tax_line_ref_id
11486         , tax_summary_line_ref_id
11487         , tax_rec_nrec_dist_ref_id
11488         , statistical_amount
11489         , event_class_code
11490         , event_type_code
11491         , line_definition_owner_code
11492         , line_definition_code
11493         , accounting_line_type_code
11494         , accounting_line_code
11495         , ref_event_id
11496         , ref_ae_header_id
11497         , ref_temp_line_num
11498         , gain_or_loss_ref
11499         , merge_duplicate_code
11500         , calculate_acctd_amts_flag
11501         , calculate_g_l_amts_flag
11502         , rounding_class_code
11503         , document_rounding_level
11504         , doc_rounding_acctd_amt
11505         , doc_rounding_entered_amt
11506         --
11507         -- Allocation Attributes
11508         --
11509         , alloc_to_application_id
11510         , alloc_to_entity_code
11511         , alloc_to_source_id_num_1
11512         , alloc_to_source_id_num_2
11513         , alloc_to_source_id_num_3
11514         , alloc_to_source_id_num_4
11515         , alloc_to_source_id_char_1
11516         , alloc_to_source_id_char_2
11517         , alloc_to_source_id_char_3
11518         , alloc_to_source_id_char_4
11519         , alloc_to_distribution_type
11520         , alloc_to_dist_id_char_1
11521         , alloc_to_dist_id_char_2
11522         , alloc_to_dist_id_char_3
11523         , alloc_to_dist_id_char_4
11524         , alloc_to_dist_id_char_5
11525         , alloc_to_dist_id_num_1
11526         , alloc_to_dist_id_num_2
11527         , alloc_to_dist_id_num_3
11528         , alloc_to_dist_id_num_4
11529         , alloc_to_dist_id_num_5
11530 FROM xla_ae_lines_gt
11531 WHERE ae_line_num IS NOT NULL;
11532 
11533 l_rowcount:= SQL%ROWCOUNT;
11534 
11535 IF (C_LEVEL_EVENT >= g_log_level) THEN
11536       trace
11537          (p_msg      => '# lines inserted into xla_distribution_links = '||l_rowcount
11538          ,p_level    => C_LEVEL_EVENT
11539          ,p_module   => l_log_module);
11540 END IF;
11541 
11542 EXCEPTION
11543 WHEN OTHERS  THEN
11544 
11545   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11546          trace
11547             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
11548             ,p_level    => C_LEVEL_EXCEPTION
11549             ,p_module   => l_log_module);
11550   END IF;
11551 
11552   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
11553                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
11554                                     ,p_token_1      => 'ERROR'
11555                                     ,p_value_1      => sqlerrm
11556                                     );
11557 END;
11558 
11559 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11560 
11561       trace
11562          (p_msg      => 'END of InsertLinks'
11563          ,p_level    => C_LEVEL_PROCEDURE
11564          ,p_module   => l_log_module);
11565 END IF;
11566 
11567 EXCEPTION
11568 WHEN xla_exceptions_pkg.application_exception THEN
11569   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11570        trace
11571            (p_msg      => 'Error. = '||sqlerrm
11572            ,p_level    => C_LEVEL_PROCEDURE
11573            ,p_module   => l_log_module);
11574   END IF;
11575   RAISE;
11576 WHEN OTHERS  THEN
11577   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11578        trace
11579            (p_msg      => 'Error. = '||sqlerrm
11580            ,p_level    => C_LEVEL_PROCEDURE
11581            ,p_module   => l_log_module);
11582   END IF;
11583   xla_exceptions_pkg.raise_message
11584                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertLinks');
11585 END InsertLinks;
11586 --
11587 /*======================================================================+
11588 |                                                                       |
11589 | Insert final headers and distribution links                           |
11590 |                                                                       |
11591 |                                                                       |
11592 +======================================================================*/
11593 --
11594 FUNCTION InsertHeaders(p_application_id                 IN INTEGER
11595                       ,p_accounting_batch_id            IN NUMBER
11596                       ,p_end_date                       IN DATE        -- 4262811
11597                       -- bulk performance
11598                       ,p_accounting_mode                 in varchar)
11599 RETURN NUMBER
11600 IS
11601 l_rowcount           NUMBER;
11602 l_log_module         VARCHAR2(240);
11603 i                    NUMBER;     -- 4262811
11604 l_error_msg          VARCHAR2(2000);
11605 l_prod_rule_name      VARCHAR2(80);
11606 l_event_class_name    VARCHAR2(80);
11607 l_event_type_name     VARCHAR2(80);
11608 
11609 cursor csr_null_gl_date is
11610     SELECT  pr.name, ec.name, et.name
11611     FROM    xla_product_rules_tl    pr
11612             ,xla_event_classes_tl   ec
11613             ,xla_event_types_tl     et
11614             ,xla_ae_headers_gt      h
11615     WHERE   pr.amb_context_code(+)       = h.amb_context_code
11616       AND   pr.application_id(+)         = p_application_id
11617       AND   pr.product_rule_type_code(+) = h.product_rule_type_code
11618       AND   pr.product_rule_code(+)      = h.product_rule_code
11619       AND   pr.language(+)               = USERENV('LANG')
11620       AND   ec.application_id(+)         = et.application_id
11621       AND   ec.event_class_code(+)       = et.event_class_code
11622       AND   ec.language(+)               = USERENV('LANG')
11623       AND   et.application_id(+)         = p_application_id
11624       AND   et.event_type_code(+)        = h.event_type_code
11625       AND   et.language(+)               = USERENV('LANG')
11626       AND   h.balance_type_code <> 'X'
11627       AND   h.accounting_date is null;
11628 
11629 BEGIN
11630 --
11631 IF g_log_enabled THEN
11632       l_log_module := C_DEFAULT_MODULE||'.InsertHeaders';
11633 END IF;
11634 --
11635 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11636 
11637       trace
11638          (p_msg      => 'BEGIN of InsertHeaders'
11639          ,p_level    => C_LEVEL_PROCEDURE
11640          ,p_module   => l_log_module);
11641 END IF;
11642 --
11643 l_rowcount := 0;
11644 BEGIN
11645 
11646  IF (C_LEVEL_STATEMENT >= g_log_level) THEN
11647 
11648       trace
11649          (p_msg      => 'SQL - Insert into xla_ae_headers'
11650          ,p_level    => C_LEVEL_STATEMENT
11651          ,p_module   => l_log_module);
11652 
11653  END IF;
11654 
11655 
11656 --------------------------------------------------------
11657 -- 4262811
11658 --------------------------------------------------------
11659  IF xla_accounting_pkg.g_mpa_accrual_exists = 'Y' THEN      --4752807
11660    FORALL i IN 1..g_array_ae_header_id.COUNT
11661      UPDATE /*+ index(XLA_AE_HEADERS_GT, XLA_AE_HEADERS_GT_N1) */ --4918497
11662             xla_ae_headers_gt
11663         SET parent_header_id      = g_array_ae_header_id(i)
11664       WHERE parent_header_id      = g_array_event_id(i)    --  instead of ae_header_id
11665         AND ledger_id             = g_array_ledger_id(i)
11666         AND balance_type_code     = g_array_balance_type(i)
11667         AND g_array_header_num(i) = 0;
11668  END IF;
11669 --------------------------------------------------------
11670 
11671 --------------------------------------------------------
11672 -- always insert into headers table with zero amount flag 'N'.
11673 -- will update it in the validation package */
11674 --
11675 --
11676 -- Bug 5056632
11677 -- if there is no group_id (no transfer requested)
11678 --    do a simple insert
11679 -- else there is group_id (transfer requested along with accounting)
11680 --    do forall insert
11681 -- end if
11682 --------------------------------------------------------
11683 
11684 IF xla_accounting_pkg.g_array_group_id.COUNT = 0 THEN
11685 INSERT INTO xla_ae_headers
11686 (
11687    ae_header_id
11688  , application_id
11689  , ledger_id
11690  , entity_id
11691  , event_id
11692  , event_type_code
11693  , accounting_date
11694  , gl_transfer_status_code
11695  , je_category_name
11696  , accounting_entry_status_code
11697  , accounting_entry_type_code
11698  , product_rule_type_code
11699  , product_rule_code
11700  , product_rule_version
11701  , description
11702  , creation_date
11703  , created_by
11704  , last_update_date
11705  , last_updated_by
11706  , last_update_login
11707  , doc_sequence_id
11708  , doc_sequence_value
11709  , doc_category_code
11710  , program_update_date
11711  , program_application_id
11712  , program_id
11713  , request_id
11714  , budget_version_id
11715  --, encumbrance_type_id  -- 3358381
11716  , balance_type_code
11717  , completed_date
11718  , period_name
11719  , accounting_batch_id
11720  , amb_context_code
11721  , zero_amount_flag
11722  , parent_ae_header_id   -- 4262811
11723  , parent_ae_line_num    -- 4262811
11724  , accrual_reversal_flag -- 4262811
11725  , group_id              -- 5056632
11726 )
11727 SELECT
11728            hed.ae_header_id
11729          , p_application_id
11730          , hed.ledger_id
11731          , hed.entity_id
11732          , hed.event_id
11733          , hed.event_type_code
11734          , hed.accounting_date
11735          , hed.gl_transfer_status_code
11736          , hed.je_category_name
11737 --       , hed.accounting_entry_status_code
11738        -- 4262811
11739        --, decode(hed.accounting_entry_status_code,C_VALID, p_accounting_mode,C_INVALID,'I',C_RELATED_INVALID, 'R', NULL)
11740          , decode(hed.accounting_entry_status_code
11741                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
11742                                      p_accounting_mode
11743                                 WHEN hed.accounting_date > p_end_date AND hed.accrual_reversal_flag = 'N' THEN
11744 				     p_accounting_mode
11745 				ELSE
11746 				     'N'
11747                            END
11748                  ,C_INVALID,'I'
11749                  ,C_RELATED_INVALID, 'R'
11750                  ,NULL)
11751          , hed.accounting_entry_type_code
11752          , hed.product_rule_type_code
11753          , hed.product_rule_code
11754          , hed.product_rule_version
11755          , hed.description
11756          , g_who_columns.creation_date
11757          , g_who_columns.created_by
11758          , g_who_columns.last_update_date
11759          , g_who_columns.last_updated_by
11760          , g_who_columns.last_update_login
11761          , hed.doc_sequence_id
11762          , hed.doc_sequence_value
11763          , hed.doc_category_code
11764          , g_who_columns.program_update_date
11765          , g_who_columns.program_application_id
11766          , g_who_columns.program_id
11767          , g_who_columns.request_id
11768          , CASE hed.balance_type_code
11769              WHEN 'B' THEN hed.budget_version_id
11770              ELSE NULL
11771            END
11772          -- , CASE hed.balance_type_code  -- 34458381 Public Sector Enh
11773          --     WHEN 'E' THEN hed.encumbrance_type_id
11774          --     ELSE NULL
11775          --   END
11776          , hed.balance_type_code
11777          , sysdate
11778          , hed.period_name
11779          , p_accounting_batch_id
11780          , hed.amb_context_code
11781          , 'N'
11782          , hed.parent_header_id      -- 4262811
11783          , hed.parent_ae_line_num    -- 4262811
11784          , hed.accrual_reversal_flag -- 4262811
11785          , NULL                      -- group_id
11786           FROM xla_ae_headers_gt hed
11787           where hed.balance_type_code <> 'X';
11788 ELSE  -- xla_accounting_pkg.g_array_group_id.COUNT > 0
11789 FORALL i IN 1..xla_accounting_pkg.g_array_group_id.COUNT
11790 INSERT INTO xla_ae_headers
11791 (
11792    ae_header_id
11793  , application_id
11794  , ledger_id
11795  , entity_id
11796  , event_id
11797  , event_type_code
11798  , accounting_date
11799  , gl_transfer_status_code
11800  , je_category_name
11801  , accounting_entry_status_code
11802  , accounting_entry_type_code
11803  , product_rule_type_code
11804  , product_rule_code
11805  , product_rule_version
11806  , description
11807  , creation_date
11808  , created_by
11809  , last_update_date
11810  , last_updated_by
11811  , last_update_login
11812  , doc_sequence_id
11813  , doc_sequence_value
11814  , doc_category_code
11815  , program_update_date
11816  , program_application_id
11817  , program_id
11818  , request_id
11819  , budget_version_id
11820  --, encumbrance_type_id  -- 3358381
11821  , balance_type_code
11822  , completed_date
11823  , period_name
11824  , accounting_batch_id
11825  , amb_context_code
11826  , zero_amount_flag
11827  , parent_ae_header_id   -- 4262811
11828  , parent_ae_line_num    -- 4262811
11829  , accrual_reversal_flag -- 4262811
11830  , group_id
11831 )
11832 SELECT
11833            hed.ae_header_id
11834          , p_application_id
11835          , hed.ledger_id
11836          , hed.entity_id
11837          , hed.event_id
11838          , hed.event_type_code
11839          , hed.accounting_date
11840          , hed.gl_transfer_status_code
11841          , hed.je_category_name
11842 --       , hed.accounting_entry_status_code
11843        -- 4262811
11844        --, decode(hed.accounting_entry_status_code,C_VALID, p_accounting_mode,C_INVALID,'I',C_RELATED_INVALID, 'R', NULL)
11845          , decode(hed.accounting_entry_status_code
11846                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
11847                                      p_accounting_mode
11848                                 WHEN hed.accounting_date > p_end_date AND hed.accrual_reversal_flag = 'N' THEN
11849 				     p_accounting_mode
11850 				ELSE 'N'
11851                            END
11852                  ,C_INVALID,'I'
11853                  ,C_RELATED_INVALID, 'R'
11854                  ,NULL)
11855          , hed.accounting_entry_type_code
11856          , hed.product_rule_type_code
11857          , hed.product_rule_code
11858          , hed.product_rule_version
11859          , hed.description
11860          , g_who_columns.creation_date
11861          , g_who_columns.created_by
11862          , g_who_columns.last_update_date
11863          , g_who_columns.last_updated_by
11864          , g_who_columns.last_update_login
11865          , hed.doc_sequence_id
11866          , hed.doc_sequence_value
11867          , hed.doc_category_code
11868          , g_who_columns.program_update_date
11869          , g_who_columns.program_application_id
11870          , g_who_columns.program_id
11871          , g_who_columns.request_id
11872          , CASE hed.balance_type_code
11873              WHEN 'B' THEN hed.budget_version_id
11874              ELSE NULL
11875            END
11876          -- , CASE hed.balance_type_code  -- 34458381 Public Sector Enh
11877          --     WHEN 'E' THEN hed.encumbrance_type_id
11878          --     ELSE NULL
11879          --   END
11880          , hed.balance_type_code
11881          , sysdate
11882          , hed.period_name
11883          , p_accounting_batch_id
11884          , hed.amb_context_code
11885          , 'N'
11886          , hed.parent_header_id      -- 4262811
11887          , hed.parent_ae_line_num    -- 4262811
11888          , hed.accrual_reversal_flag -- 4262811
11889          , DECODE(hed.accounting_entry_status_code
11890                  ,C_VALID, CASE WHEN hed.accounting_date<=p_end_date THEN
11891                                      xla_accounting_pkg.g_array_group_id(i)
11892                                 ELSE NULL
11893                            END
11894                  ,NULL)
11895           FROM xla_ae_headers_gt hed
11896           where hed.balance_type_code <> 'X'
11897           and hed.ledger_id = xla_accounting_pkg.g_array_ledger_id(i);
11898 END IF;
11899 
11900 l_rowcount := SQL%ROWCOUNT;
11901 
11902 IF (C_LEVEL_EVENT >= g_log_level) THEN
11903       trace
11904          (p_msg      => '# journal entry headers inserted into xla_ae_headers = '||l_rowcount
11905          ,p_level    => C_LEVEL_EVENT
11906          ,p_module   => l_log_module);
11907 END IF;
11908 
11909 
11910 EXCEPTION
11911 WHEN OTHERS  THEN
11912 
11913   l_error_msg :=substr(sqlerrm, 1, 1999);
11914 
11915   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11916          trace
11917             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||l_error_msg
11918             ,p_level    => C_LEVEL_EXCEPTION
11919             ,p_module   => l_log_module);
11920   END IF;
11921 
11922   open csr_null_gl_date;
11923   fetch csr_null_gl_date into l_prod_rule_name, l_event_class_name, l_event_type_name;
11924   IF(csr_null_gl_date%NOTFOUND) THEN
11925     close csr_null_gl_date;
11926     xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
11927                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
11928                                     ,p_token_1      => 'ERROR'
11929                                     ,p_value_1      => l_error_msg
11930                                     );
11931   ELSE
11932     close csr_null_gl_date;
11933     xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
11934                                     ,p_msg_name     => 'XLA_AP_NULL_GL_DATE'
11935                                     ,p_token_1      => 'EVENT_CLASS_NAME'
11936                                     ,p_value_1      => l_event_class_name
11937                                     ,p_token_2      => 'EVENT_TYPE_NAME'
11938                                     ,p_value_2      => l_event_type_name
11939                                     ,p_token_3      => 'PRODUCT_RULE_NAME'
11940                                     ,p_value_3      => l_prod_rule_name
11941                                     );
11942   END IF;
11943 END;
11944 
11945 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11946 
11947       trace
11948          (p_msg      => 'return value. = '||TO_CHAR(l_rowcount)
11949          ,p_level    => C_LEVEL_PROCEDURE
11950          ,p_module   => l_log_module);
11951 
11952       trace
11953          (p_msg      => 'END of InsertHeaders'
11954          ,p_level    => C_LEVEL_PROCEDURE
11955          ,p_module   => l_log_module);
11956 END IF;
11957 --
11958 RETURN l_rowcount;
11959 EXCEPTION
11960 WHEN xla_exceptions_pkg.application_exception THEN
11961   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11962        trace
11963            (p_msg      => 'Error. = '||sqlerrm
11964            ,p_level    => C_LEVEL_PROCEDURE
11965            ,p_module   => l_log_module);
11966   END IF;
11967   RAISE;
11968 WHEN OTHERS  THEN
11969   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
11970        trace
11971            (p_msg      => 'Error. = '||sqlerrm
11972            ,p_level    => C_LEVEL_PROCEDURE
11973            ,p_module   => l_log_module);
11974   END IF;
11975   xla_exceptions_pkg.raise_message
11976                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHeaders');
11977    --
11978 END InsertHeaders;
11979 --
11980 /*======================================================================+
11981 |                                                                       |
11982 | Insert final Lines                                                    |
11983 |                                                                       |
11984 |                                                                       |
11985 +======================================================================*/
11986 --
11987 PROCEDURE InsertHdrAnalyticalCriteria
11988 IS
11989 l_log_module         VARCHAR2(240);
11990 BEGIN
11991 --
11992 IF g_log_enabled THEN
11993       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria';
11994 END IF;
11995 --
11996 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
11997 
11998       trace
11999          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria'
12000          ,p_level    => C_LEVEL_PROCEDURE
12001          ,p_module   => l_log_module);
12002 END IF;
12003 --
12004 BEGIN
12005 
12006    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12007 
12008       trace
12009          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
12010          ,p_level    => C_LEVEL_STATEMENT
12011          ,p_module   => l_log_module);
12012 
12013    END IF;
12014 --
12015 
12016    IF g_hdr_ac_count <= 10 THEN
12017 
12018       InsertHdrAnalyticalCriteria10;
12019 
12020    ELSIF g_hdr_ac_count <= 50 THEN
12021 
12022       InsertHdrAnalyticalCriteria50;
12023 
12024    ELSIF g_hdr_ac_count <= 100 THEN
12025 
12026       InsertHdrAnalyticalCriteria100;
12027 
12028    END IF;
12029 
12030 
12031 --
12032 IF (C_LEVEL_EVENT >= g_log_level) THEN
12033       trace
12034          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
12035          ,p_level    => C_LEVEL_EVENT
12036          ,p_module   => l_log_module);
12037 END IF;
12038 
12039 --
12040 EXCEPTION
12041 WHEN OTHERS THEN
12042   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12043          trace
12044             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
12045             ,p_level    => C_LEVEL_EXCEPTION
12046             ,p_module   => l_log_module);
12047   END IF;
12048 
12049   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12050                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
12051                                     ,p_token_1      => 'ERROR'
12052                                     ,p_value_1      => sqlerrm
12053                                     );
12054 END;
12055 --
12056 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12057 
12058       trace
12059          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
12060          ,p_level    => C_LEVEL_PROCEDURE
12061          ,p_module   => l_log_module);
12062 
12063       trace
12064          (p_msg      => 'END of InsertHdrAnalyticalCriteria'
12065          ,p_level    => C_LEVEL_PROCEDURE
12066          ,p_module   => l_log_module);
12067 END IF;
12068 --
12069 EXCEPTION
12070 WHEN xla_exceptions_pkg.application_exception THEN
12071   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12072        trace
12073            (p_msg      => 'Error. = '||sqlerrm
12074            ,p_level    => C_LEVEL_PROCEDURE
12075            ,p_module   => l_log_module);
12076   END IF;
12077   RAISE;
12078 WHEN OTHERS  THEN
12079  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12080        trace
12081            (p_msg      => 'Error. = '||sqlerrm
12082            ,p_level    => C_LEVEL_PROCEDURE
12083            ,p_module   => l_log_module);
12084   END IF;
12085   xla_exceptions_pkg.raise_message
12086                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria');
12087    --
12088 END InsertHdrAnalyticalCriteria;
12089 
12090 --
12091 /*======================================================================+
12092 |                                                                       |
12093 | Insert Header Analytical Criteria 10                                  |
12094 |                                                                       |
12095 |                                                                       |
12096 +======================================================================*/
12097 --
12098 PROCEDURE InsertHdrAnalyticalCriteria10
12099 IS
12100 l_log_module         VARCHAR2(240);
12101 BEGIN
12102 --
12103 IF g_log_enabled THEN
12104       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria10';
12105 END IF;
12106 --
12107 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12108 
12109       trace
12110          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria10'
12111          ,p_level    => C_LEVEL_PROCEDURE
12112          ,p_module   => l_log_module);
12113 END IF;
12114 --
12115 BEGIN
12116 
12117    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12118 
12119       trace
12120          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
12121          ,p_level    => C_LEVEL_STATEMENT
12122          ,p_module   => l_log_module);
12123 
12124    END IF;
12125 --
12126 
12127 INSERT ALL
12128 WHEN anc_id_1 IS NOT NULL THEN
12129   INTO xla_ae_header_acs (
12130         ae_header_id , object_version_number
12131       , analytical_criterion_code
12132       , analytical_criterion_type_code
12133       , amb_context_code
12134       , ac1,ac2,ac3,ac4,ac5)
12135 VALUES (ae_header_id, C_OVN
12136 ,SUBSTRB(anc_id_1
12137        ,1
12138        ,INSTRB(anc_id_1,'(]',1,1) -1)
12139 ,SUBSTRB(anc_id_1
12140        ,INSTRB(anc_id_1,'(]',1,1) + 2
12141        ,INSTRB(anc_id_1,'(]',1,2) -
12142         INSTRB(anc_id_1,'(]',1,1) - 2)
12143 ,SUBSTRB(anc_id_1
12144        ,INSTRB(anc_id_1,'(]',1,2) + 2
12145        ,INSTRB(anc_id_1,'(]',1,3) -
12146         INSTRB(anc_id_1,'(]',1,2) - 2)
12147 ,SUBSTRB(anc_id_1
12148        ,INSTRB(anc_id_1,'(]',1,3) + 2
12149        ,INSTRB(anc_id_1,'(]',1,4) -
12150         INSTRB(anc_id_1,'(]',1,3) - 2)
12151 ,SUBSTRB(anc_id_1
12152        ,INSTRB(anc_id_1,'(]',1,4) + 2
12153        ,INSTRB(anc_id_1,'(]',1,5) -
12154         INSTRB(anc_id_1,'(]',1,4) - 2)
12155 ,SUBSTRB(anc_id_1
12156        ,INSTRB(anc_id_1,'(]',1,5) + 2
12157        ,INSTRB(anc_id_1,'(]',1,6) -
12158         INSTRB(anc_id_1,'(]',1,5) - 2)
12159 ,SUBSTRB(anc_id_1
12160        ,INSTRB(anc_id_1,'(]',1,6) + 2
12161        ,INSTRB(anc_id_1,'(]',1,7) -
12162         INSTRB(anc_id_1,'(]',1,6) - 2)
12163 ,SUBSTRB(anc_id_1
12164        ,INSTRB(anc_id_1,'(]',1,7) + 2
12165        ,LENGTHB(anc_id_1))
12166 )
12167 
12168 WHEN anc_id_2 IS NOT NULL THEN
12169   INTO xla_ae_header_acs (
12170         ae_header_id , object_version_number
12171       , analytical_criterion_code
12172       , analytical_criterion_type_code
12173       , amb_context_code
12174       , ac1,ac2,ac3,ac4,ac5)
12175 VALUES (ae_header_id, C_OVN
12176 ,SUBSTRB(anc_id_2
12177        ,1
12178        ,INSTRB(anc_id_2,'(]',1,1) -1)
12179 ,SUBSTRB(anc_id_2
12180        ,INSTRB(anc_id_2,'(]',1,1) + 2
12181        ,INSTRB(anc_id_2,'(]',1,2) -
12182         INSTRB(anc_id_2,'(]',1,1) - 2)
12183 ,SUBSTRB(anc_id_2
12184        ,INSTRB(anc_id_2,'(]',1,2) + 2
12185        ,INSTRB(anc_id_2,'(]',1,3) -
12186         INSTRB(anc_id_2,'(]',1,2) - 2)
12187 ,SUBSTRB(anc_id_2
12188        ,INSTRB(anc_id_2,'(]',1,3) + 2
12189        ,INSTRB(anc_id_2,'(]',1,4) -
12190         INSTRB(anc_id_2,'(]',1,3) - 2)
12191 ,SUBSTRB(anc_id_2
12192        ,INSTRB(anc_id_2,'(]',1,4) + 2
12193        ,INSTRB(anc_id_2,'(]',1,5) -
12194         INSTRB(anc_id_2,'(]',1,4) - 2)
12195 ,SUBSTRB(anc_id_2
12196        ,INSTRB(anc_id_2,'(]',1,5) + 2
12197        ,INSTRB(anc_id_2,'(]',1,6) -
12198         INSTRB(anc_id_2,'(]',1,5) - 2)
12199 ,SUBSTRB(anc_id_2
12200        ,INSTRB(anc_id_2,'(]',1,6) + 2
12201        ,INSTRB(anc_id_2,'(]',1,7) -
12202         INSTRB(anc_id_2,'(]',1,6) - 2)
12203 ,SUBSTRB(anc_id_2
12204        ,INSTRB(anc_id_2,'(]',1,7) + 2
12205        ,LENGTHB(anc_id_2))
12206 )
12207 
12208 WHEN anc_id_3 IS NOT NULL THEN
12209   INTO xla_ae_header_acs (
12210         ae_header_id , object_version_number
12211       , analytical_criterion_code
12212       , analytical_criterion_type_code
12213       , amb_context_code
12214       , ac1,ac2,ac3,ac4,ac5)
12215 VALUES (ae_header_id, C_OVN
12216 ,SUBSTRB(anc_id_3
12217        ,1
12218        ,INSTRB(anc_id_3,'(]',1,1) -1)
12219 ,SUBSTRB(anc_id_3
12220        ,INSTRB(anc_id_3,'(]',1,1) + 2
12221        ,INSTRB(anc_id_3,'(]',1,2) -
12222         INSTRB(anc_id_3,'(]',1,1) - 2)
12223 ,SUBSTRB(anc_id_3
12224        ,INSTRB(anc_id_3,'(]',1,2) + 2
12225        ,INSTRB(anc_id_3,'(]',1,3) -
12226         INSTRB(anc_id_3,'(]',1,2) - 2)
12227 ,SUBSTRB(anc_id_3
12228        ,INSTRB(anc_id_3,'(]',1,3) + 2
12229        ,INSTRB(anc_id_3,'(]',1,4) -
12230         INSTRB(anc_id_3,'(]',1,3) - 2)
12231 ,SUBSTRB(anc_id_3
12232        ,INSTRB(anc_id_3,'(]',1,4) + 2
12233        ,INSTRB(anc_id_3,'(]',1,5) -
12234         INSTRB(anc_id_3,'(]',1,4) - 2)
12235 ,SUBSTRB(anc_id_3
12236        ,INSTRB(anc_id_3,'(]',1,5) + 2
12237        ,INSTRB(anc_id_3,'(]',1,6) -
12238         INSTRB(anc_id_3,'(]',1,5) - 2)
12239 ,SUBSTRB(anc_id_3
12240        ,INSTRB(anc_id_3,'(]',1,6) + 2
12241        ,INSTRB(anc_id_3,'(]',1,7) -
12242         INSTRB(anc_id_3,'(]',1,6) - 2)
12243 ,SUBSTRB(anc_id_3
12244        ,INSTRB(anc_id_3,'(]',1,7) + 2
12245        ,LENGTHB(anc_id_3))
12246 )
12247 
12248 WHEN anc_id_4 IS NOT NULL THEN
12249   INTO xla_ae_header_acs (
12250         ae_header_id , object_version_number
12251       , analytical_criterion_code
12252       , analytical_criterion_type_code
12253       , amb_context_code
12254       , ac1,ac2,ac3,ac4,ac5)
12255 VALUES (ae_header_id, C_OVN
12256 ,SUBSTRB(anc_id_4
12257        ,1
12258        ,INSTRB(anc_id_4,'(]',1,1) -1)
12259 ,SUBSTRB(anc_id_4
12260        ,INSTRB(anc_id_4,'(]',1,1) + 2
12261        ,INSTRB(anc_id_4,'(]',1,2) -
12262         INSTRB(anc_id_4,'(]',1,1) - 2)
12263 ,SUBSTRB(anc_id_4
12264        ,INSTRB(anc_id_4,'(]',1,2) + 2
12265        ,INSTRB(anc_id_4,'(]',1,3) -
12266         INSTRB(anc_id_4,'(]',1,2) - 2)
12267 ,SUBSTRB(anc_id_4
12268        ,INSTRB(anc_id_4,'(]',1,3) + 2
12269        ,INSTRB(anc_id_4,'(]',1,4) -
12270         INSTRB(anc_id_4,'(]',1,3) - 2)
12271 ,SUBSTRB(anc_id_4
12272        ,INSTRB(anc_id_4,'(]',1,4) + 2
12273        ,INSTRB(anc_id_4,'(]',1,5) -
12274         INSTRB(anc_id_4,'(]',1,4) - 2)
12275 ,SUBSTRB(anc_id_4
12276        ,INSTRB(anc_id_4,'(]',1,5) + 2
12277        ,INSTRB(anc_id_4,'(]',1,6) -
12278         INSTRB(anc_id_4,'(]',1,5) - 2)
12279 ,SUBSTRB(anc_id_4
12280        ,INSTRB(anc_id_4,'(]',1,6) + 2
12281        ,INSTRB(anc_id_4,'(]',1,7) -
12282         INSTRB(anc_id_4,'(]',1,6) - 2)
12283 ,SUBSTRB(anc_id_4
12284        ,INSTRB(anc_id_4,'(]',1,7) + 2
12285        ,LENGTHB(anc_id_4))
12286 )
12287 
12288 WHEN anc_id_5 IS NOT NULL THEN
12289   INTO xla_ae_header_acs (
12290         ae_header_id , object_version_number
12291       , analytical_criterion_code
12292       , analytical_criterion_type_code
12293       , amb_context_code
12294       , ac1,ac2,ac3,ac4,ac5)
12295 VALUES (ae_header_id, C_OVN
12296 ,SUBSTRB(anc_id_5
12297        ,1
12298        ,INSTRB(anc_id_5,'(]',1,1) -1)
12299 ,SUBSTRB(anc_id_5
12300        ,INSTRB(anc_id_5,'(]',1,1) + 2
12301        ,INSTRB(anc_id_5,'(]',1,2) -
12302         INSTRB(anc_id_5,'(]',1,1) - 2)
12303 ,SUBSTRB(anc_id_5
12304        ,INSTRB(anc_id_5,'(]',1,2) + 2
12305        ,INSTRB(anc_id_5,'(]',1,3) -
12306         INSTRB(anc_id_5,'(]',1,2) - 2)
12307 ,SUBSTRB(anc_id_5
12308        ,INSTRB(anc_id_5,'(]',1,3) + 2
12309        ,INSTRB(anc_id_5,'(]',1,4) -
12310         INSTRB(anc_id_5,'(]',1,3) - 2)
12311 ,SUBSTRB(anc_id_5
12312        ,INSTRB(anc_id_5,'(]',1,4) + 2
12313        ,INSTRB(anc_id_5,'(]',1,5) -
12314         INSTRB(anc_id_5,'(]',1,4) - 2)
12315 ,SUBSTRB(anc_id_5
12316        ,INSTRB(anc_id_5,'(]',1,5) + 2
12317        ,INSTRB(anc_id_5,'(]',1,6) -
12318         INSTRB(anc_id_5,'(]',1,5) - 2)
12319 ,SUBSTRB(anc_id_5
12320        ,INSTRB(anc_id_5,'(]',1,6) + 2
12321        ,INSTRB(anc_id_5,'(]',1,7) -
12322         INSTRB(anc_id_5,'(]',1,6) - 2)
12323 ,SUBSTRB(anc_id_5
12324        ,INSTRB(anc_id_5,'(]',1,7) + 2
12325        ,LENGTHB(anc_id_5))
12326 )
12327 
12328 WHEN anc_id_6 IS NOT NULL THEN
12329   INTO xla_ae_header_acs (
12330         ae_header_id , object_version_number
12331       , analytical_criterion_code
12332       , analytical_criterion_type_code
12333       , amb_context_code
12334       , ac1,ac2,ac3,ac4,ac5)
12335 VALUES (ae_header_id, C_OVN
12336 ,SUBSTRB(anc_id_6
12337        ,1
12338        ,INSTRB(anc_id_6,'(]',1,1) -1)
12339 ,SUBSTRB(anc_id_6
12340        ,INSTRB(anc_id_6,'(]',1,1) + 2
12341        ,INSTRB(anc_id_6,'(]',1,2) -
12342         INSTRB(anc_id_6,'(]',1,1) - 2)
12343 ,SUBSTRB(anc_id_6
12344        ,INSTRB(anc_id_6,'(]',1,2) + 2
12345        ,INSTRB(anc_id_6,'(]',1,3) -
12346         INSTRB(anc_id_6,'(]',1,2) - 2)
12347 ,SUBSTRB(anc_id_6
12348        ,INSTRB(anc_id_6,'(]',1,3) + 2
12349        ,INSTRB(anc_id_6,'(]',1,4) -
12350         INSTRB(anc_id_6,'(]',1,3) - 2)
12351 ,SUBSTRB(anc_id_6
12352        ,INSTRB(anc_id_6,'(]',1,4) + 2
12353        ,INSTRB(anc_id_6,'(]',1,5) -
12354         INSTRB(anc_id_6,'(]',1,4) - 2)
12355 ,SUBSTRB(anc_id_6
12356        ,INSTRB(anc_id_6,'(]',1,5) + 2
12357        ,INSTRB(anc_id_6,'(]',1,6) -
12358         INSTRB(anc_id_6,'(]',1,5) - 2)
12359 ,SUBSTRB(anc_id_6
12360        ,INSTRB(anc_id_6,'(]',1,6) + 2
12361        ,INSTRB(anc_id_6,'(]',1,7) -
12362         INSTRB(anc_id_6,'(]',1,6) - 2)
12363 ,SUBSTRB(anc_id_6
12364        ,INSTRB(anc_id_6,'(]',1,7) + 2
12365        ,LENGTHB(anc_id_6))
12366 )
12367 
12368 WHEN anc_id_7 IS NOT NULL THEN
12369   INTO xla_ae_header_acs (
12370         ae_header_id , object_version_number
12371       , analytical_criterion_code
12372       , analytical_criterion_type_code
12373       , amb_context_code
12374       , ac1,ac2,ac3,ac4,ac5)
12375 VALUES (ae_header_id, C_OVN
12376 ,SUBSTRB(anc_id_7
12377        ,1
12378        ,INSTRB(anc_id_7,'(]',1,1) -1)
12379 ,SUBSTRB(anc_id_7
12380        ,INSTRB(anc_id_7,'(]',1,1) + 2
12381        ,INSTRB(anc_id_7,'(]',1,2) -
12382         INSTRB(anc_id_7,'(]',1,1) - 2)
12383 ,SUBSTRB(anc_id_7
12384        ,INSTRB(anc_id_7,'(]',1,2) + 2
12385        ,INSTRB(anc_id_7,'(]',1,3) -
12386         INSTRB(anc_id_7,'(]',1,2) - 2)
12387 ,SUBSTRB(anc_id_7
12388        ,INSTRB(anc_id_7,'(]',1,3) + 2
12389        ,INSTRB(anc_id_7,'(]',1,4) -
12390         INSTRB(anc_id_7,'(]',1,3) - 2)
12391 ,SUBSTRB(anc_id_7
12392        ,INSTRB(anc_id_7,'(]',1,4) + 2
12393        ,INSTRB(anc_id_7,'(]',1,5) -
12394         INSTRB(anc_id_7,'(]',1,4) - 2)
12395 ,SUBSTRB(anc_id_7
12396        ,INSTRB(anc_id_7,'(]',1,5) + 2
12397        ,INSTRB(anc_id_7,'(]',1,6) -
12398         INSTRB(anc_id_7,'(]',1,5) - 2)
12399 ,SUBSTRB(anc_id_7
12400        ,INSTRB(anc_id_7,'(]',1,6) + 2
12401        ,INSTRB(anc_id_7,'(]',1,7) -
12402         INSTRB(anc_id_7,'(]',1,6) - 2)
12403 ,SUBSTRB(anc_id_7
12404        ,INSTRB(anc_id_7,'(]',1,7) + 2
12405        ,LENGTHB(anc_id_7))
12406 )
12407 
12408 WHEN anc_id_8 IS NOT NULL THEN
12409   INTO xla_ae_header_acs (
12410         ae_header_id , object_version_number
12411       , analytical_criterion_code
12412       , analytical_criterion_type_code
12413       , amb_context_code
12414       , ac1,ac2,ac3,ac4,ac5)
12415 VALUES (ae_header_id, C_OVN
12416 ,SUBSTRB(anc_id_8
12417        ,1
12418        ,INSTRB(anc_id_8,'(]',1,1) -1)
12419 ,SUBSTRB(anc_id_8
12420        ,INSTRB(anc_id_8,'(]',1,1) + 2
12421        ,INSTRB(anc_id_8,'(]',1,2) -
12422         INSTRB(anc_id_8,'(]',1,1) - 2)
12423 ,SUBSTRB(anc_id_8
12424        ,INSTRB(anc_id_8,'(]',1,2) + 2
12425        ,INSTRB(anc_id_8,'(]',1,3) -
12426         INSTRB(anc_id_8,'(]',1,2) - 2)
12427 ,SUBSTRB(anc_id_8
12428        ,INSTRB(anc_id_8,'(]',1,3) + 2
12429        ,INSTRB(anc_id_8,'(]',1,4) -
12430         INSTRB(anc_id_8,'(]',1,3) - 2)
12431 ,SUBSTRB(anc_id_8
12432        ,INSTRB(anc_id_8,'(]',1,4) + 2
12433        ,INSTRB(anc_id_8,'(]',1,5) -
12434         INSTRB(anc_id_8,'(]',1,4) - 2)
12435 ,SUBSTRB(anc_id_8
12436        ,INSTRB(anc_id_8,'(]',1,5) + 2
12437        ,INSTRB(anc_id_8,'(]',1,6) -
12438         INSTRB(anc_id_8,'(]',1,5) - 2)
12439 ,SUBSTRB(anc_id_8
12440        ,INSTRB(anc_id_8,'(]',1,6) + 2
12441        ,INSTRB(anc_id_8,'(]',1,7) -
12442         INSTRB(anc_id_8,'(]',1,6) - 2)
12443 ,SUBSTRB(anc_id_8
12444        ,INSTRB(anc_id_8,'(]',1,7) + 2
12445        ,LENGTHB(anc_id_8))
12446 )
12447 
12448 WHEN anc_id_9 IS NOT NULL THEN
12449   INTO xla_ae_header_acs (
12450         ae_header_id , object_version_number
12451       , analytical_criterion_code
12452       , analytical_criterion_type_code
12453       , amb_context_code
12454       , ac1,ac2,ac3,ac4,ac5)
12455 VALUES (ae_header_id, C_OVN
12456 ,SUBSTRB(anc_id_9
12457        ,1
12458        ,INSTRB(anc_id_9,'(]',1,1) -1)
12459 ,SUBSTRB(anc_id_9
12460        ,INSTRB(anc_id_9,'(]',1,1) + 2
12461        ,INSTRB(anc_id_9,'(]',1,2) -
12462         INSTRB(anc_id_9,'(]',1,1) - 2)
12463 ,SUBSTRB(anc_id_9
12464        ,INSTRB(anc_id_9,'(]',1,2) + 2
12465        ,INSTRB(anc_id_9,'(]',1,3) -
12466         INSTRB(anc_id_9,'(]',1,2) - 2)
12467 ,SUBSTRB(anc_id_9
12468        ,INSTRB(anc_id_9,'(]',1,3) + 2
12469        ,INSTRB(anc_id_9,'(]',1,4) -
12470         INSTRB(anc_id_9,'(]',1,3) - 2)
12471 ,SUBSTRB(anc_id_9
12472        ,INSTRB(anc_id_9,'(]',1,4) + 2
12473        ,INSTRB(anc_id_9,'(]',1,5) -
12474         INSTRB(anc_id_9,'(]',1,4) - 2)
12475 ,SUBSTRB(anc_id_9
12476        ,INSTRB(anc_id_9,'(]',1,5) + 2
12477        ,INSTRB(anc_id_9,'(]',1,6) -
12478         INSTRB(anc_id_9,'(]',1,5) - 2)
12479 ,SUBSTRB(anc_id_9
12480        ,INSTRB(anc_id_9,'(]',1,6) + 2
12481        ,INSTRB(anc_id_9,'(]',1,7) -
12482         INSTRB(anc_id_9,'(]',1,6) - 2)
12483 ,SUBSTRB(anc_id_9
12484        ,INSTRB(anc_id_9,'(]',1,7) + 2
12485        ,LENGTHB(anc_id_9))
12486 )
12487 
12488 WHEN anc_id_10 IS NOT NULL THEN
12489   INTO xla_ae_header_acs (
12490         ae_header_id , object_version_number
12491       , analytical_criterion_code
12492       , analytical_criterion_type_code
12493       , amb_context_code
12494       , ac1,ac2,ac3,ac4,ac5)
12495 VALUES (ae_header_id, C_OVN
12496 ,SUBSTRB(anc_id_10
12497        ,1
12498        ,INSTRB(anc_id_10,'(]',1,1) -1)
12499 ,SUBSTRB(anc_id_10
12500        ,INSTRB(anc_id_10,'(]',1,1) + 2
12501        ,INSTRB(anc_id_10,'(]',1,2) -
12502         INSTRB(anc_id_10,'(]',1,1) - 2)
12503 ,SUBSTRB(anc_id_10
12504        ,INSTRB(anc_id_10,'(]',1,2) + 2
12505        ,INSTRB(anc_id_10,'(]',1,3) -
12506         INSTRB(anc_id_10,'(]',1,2) - 2)
12507 ,SUBSTRB(anc_id_10
12508        ,INSTRB(anc_id_10,'(]',1,3) + 2
12509        ,INSTRB(anc_id_10,'(]',1,4) -
12510         INSTRB(anc_id_10,'(]',1,3) - 2)
12511 ,SUBSTRB(anc_id_10
12512        ,INSTRB(anc_id_10,'(]',1,4) + 2
12513        ,INSTRB(anc_id_10,'(]',1,5) -
12514         INSTRB(anc_id_10,'(]',1,4) - 2)
12515 ,SUBSTRB(anc_id_10
12516        ,INSTRB(anc_id_10,'(]',1,5) + 2
12517        ,INSTRB(anc_id_10,'(]',1,6) -
12518         INSTRB(anc_id_10,'(]',1,5) - 2)
12519 ,SUBSTRB(anc_id_10
12520        ,INSTRB(anc_id_10,'(]',1,6) + 2
12521        ,INSTRB(anc_id_10,'(]',1,7) -
12522         INSTRB(anc_id_10,'(]',1,6) - 2)
12523 ,SUBSTRB(anc_id_10
12524        ,INSTRB(anc_id_10,'(]',1,7) + 2
12525        ,LENGTHB(anc_id_10))
12526 )
12527 
12528 SELECT  ae_header_id
12529       , anc_id_1
12530       , anc_id_2
12531       , anc_id_3
12532       , anc_id_4
12533       , anc_id_5
12534       , anc_id_6
12535       , anc_id_7
12536       , anc_id_8
12537       , anc_id_9
12538       , anc_id_10
12539  FROM  xla_ae_headers_gt
12540 WHERE  ae_header_id is not null;
12541 
12542 --
12543 IF (C_LEVEL_EVENT >= g_log_level) THEN
12544       trace
12545          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
12546          ,p_level    => C_LEVEL_EVENT
12547          ,p_module   => l_log_module);
12548 END IF;
12549 
12550 --
12551 EXCEPTION
12552 WHEN OTHERS THEN
12553   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12554          trace
12555             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
12556             ,p_level    => C_LEVEL_EXCEPTION
12557             ,p_module   => l_log_module);
12558   END IF;
12559 
12560   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
12561                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
12562                                     ,p_token_1      => 'ERROR'
12563                                     ,p_value_1      => sqlerrm
12564                                     );
12565 END;
12566 --
12567 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12568 
12569       trace
12570          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
12571          ,p_level    => C_LEVEL_PROCEDURE
12572          ,p_module   => l_log_module);
12573 
12574       trace
12575          (p_msg      => 'END of InsertHdrAnalyticalCriteria10'
12576          ,p_level    => C_LEVEL_PROCEDURE
12577          ,p_module   => l_log_module);
12578 END IF;
12579 --
12580 EXCEPTION
12581 WHEN xla_exceptions_pkg.application_exception THEN
12582   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12583        trace
12584            (p_msg      => 'Error. = '||sqlerrm
12585            ,p_level    => C_LEVEL_PROCEDURE
12586            ,p_module   => l_log_module);
12587   END IF;
12588   RAISE;
12589 WHEN OTHERS  THEN
12590  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
12591        trace
12592            (p_msg      => 'Error. = '||sqlerrm
12593            ,p_level    => C_LEVEL_PROCEDURE
12594            ,p_module   => l_log_module);
12595   END IF;
12596   xla_exceptions_pkg.raise_message
12597                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria10');
12598    --
12599 END InsertHdrAnalyticalCriteria10;
12600 
12601 --
12602 /*======================================================================+
12603 |                                                                       |
12604 | Insert Header Analytical Criteria 50                                  |
12605 |                                                                       |
12606 |                                                                       |
12607 +======================================================================*/
12608 --
12609 PROCEDURE InsertHdrAnalyticalCriteria50
12610 IS
12611 l_log_module         VARCHAR2(240);
12612 BEGIN
12613 --
12614 IF g_log_enabled THEN
12615       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria50';
12616 END IF;
12617 --
12618 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
12619 
12620       trace
12621          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria50'
12622          ,p_level    => C_LEVEL_PROCEDURE
12623          ,p_module   => l_log_module);
12624 END IF;
12625 --
12626 BEGIN
12627 
12628    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
12629 
12630       trace
12631          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
12632          ,p_level    => C_LEVEL_STATEMENT
12633          ,p_module   => l_log_module);
12634 
12635    END IF;
12636 --
12637 
12638 INSERT ALL
12639 WHEN anc_id_1 IS NOT NULL THEN
12640   INTO xla_ae_header_acs (
12641         ae_header_id , object_version_number
12642       , analytical_criterion_code
12643       , analytical_criterion_type_code
12644       , amb_context_code
12645       , ac1,ac2,ac3,ac4,ac5)
12646 VALUES (ae_header_id, C_OVN
12647 ,SUBSTRB(anc_id_1
12648        ,1
12649        ,INSTRB(anc_id_1,'(]',1,1) -1)
12650 ,SUBSTRB(anc_id_1
12651        ,INSTRB(anc_id_1,'(]',1,1) + 2
12652        ,INSTRB(anc_id_1,'(]',1,2) -
12653         INSTRB(anc_id_1,'(]',1,1) - 2)
12654 ,SUBSTRB(anc_id_1
12655        ,INSTRB(anc_id_1,'(]',1,2) + 2
12656        ,INSTRB(anc_id_1,'(]',1,3) -
12657         INSTRB(anc_id_1,'(]',1,2) - 2)
12658 ,SUBSTRB(anc_id_1
12659        ,INSTRB(anc_id_1,'(]',1,3) + 2
12660        ,INSTRB(anc_id_1,'(]',1,4) -
12661         INSTRB(anc_id_1,'(]',1,3) - 2)
12662 ,SUBSTRB(anc_id_1
12663        ,INSTRB(anc_id_1,'(]',1,4) + 2
12664        ,INSTRB(anc_id_1,'(]',1,5) -
12665         INSTRB(anc_id_1,'(]',1,4) - 2)
12666 ,SUBSTRB(anc_id_1
12667        ,INSTRB(anc_id_1,'(]',1,5) + 2
12668        ,INSTRB(anc_id_1,'(]',1,6) -
12669         INSTRB(anc_id_1,'(]',1,5) - 2)
12670 ,SUBSTRB(anc_id_1
12671        ,INSTRB(anc_id_1,'(]',1,6) + 2
12672        ,INSTRB(anc_id_1,'(]',1,7) -
12673         INSTRB(anc_id_1,'(]',1,6) - 2)
12674 ,SUBSTRB(anc_id_1
12675        ,INSTRB(anc_id_1,'(]',1,7) + 2
12676        ,LENGTHB(anc_id_1))
12677 )
12678 
12679 WHEN anc_id_2 IS NOT NULL THEN
12680   INTO xla_ae_header_acs (
12681         ae_header_id , object_version_number
12682       , analytical_criterion_code
12683       , analytical_criterion_type_code
12684       , amb_context_code
12685       , ac1,ac2,ac3,ac4,ac5)
12686 VALUES (ae_header_id, C_OVN
12687 ,SUBSTRB(anc_id_2
12688        ,1
12689        ,INSTRB(anc_id_2,'(]',1,1) -1)
12690 ,SUBSTRB(anc_id_2
12691        ,INSTRB(anc_id_2,'(]',1,1) + 2
12692        ,INSTRB(anc_id_2,'(]',1,2) -
12693         INSTRB(anc_id_2,'(]',1,1) - 2)
12694 ,SUBSTRB(anc_id_2
12695        ,INSTRB(anc_id_2,'(]',1,2) + 2
12696        ,INSTRB(anc_id_2,'(]',1,3) -
12697         INSTRB(anc_id_2,'(]',1,2) - 2)
12698 ,SUBSTRB(anc_id_2
12699        ,INSTRB(anc_id_2,'(]',1,3) + 2
12700        ,INSTRB(anc_id_2,'(]',1,4) -
12701         INSTRB(anc_id_2,'(]',1,3) - 2)
12702 ,SUBSTRB(anc_id_2
12703        ,INSTRB(anc_id_2,'(]',1,4) + 2
12704        ,INSTRB(anc_id_2,'(]',1,5) -
12705         INSTRB(anc_id_2,'(]',1,4) - 2)
12706 ,SUBSTRB(anc_id_2
12707        ,INSTRB(anc_id_2,'(]',1,5) + 2
12708        ,INSTRB(anc_id_2,'(]',1,6) -
12709         INSTRB(anc_id_2,'(]',1,5) - 2)
12710 ,SUBSTRB(anc_id_2
12711        ,INSTRB(anc_id_2,'(]',1,6) + 2
12712        ,INSTRB(anc_id_2,'(]',1,7) -
12713         INSTRB(anc_id_2,'(]',1,6) - 2)
12714 ,SUBSTRB(anc_id_2
12715        ,INSTRB(anc_id_2,'(]',1,7) + 2
12716        ,LENGTHB(anc_id_2))
12717 )
12718 
12719 WHEN anc_id_3 IS NOT NULL THEN
12720   INTO xla_ae_header_acs (
12721         ae_header_id , object_version_number
12722       , analytical_criterion_code
12723       , analytical_criterion_type_code
12724       , amb_context_code
12725       , ac1,ac2,ac3,ac4,ac5)
12726 VALUES (ae_header_id, C_OVN
12727 ,SUBSTRB(anc_id_3
12728        ,1
12729        ,INSTRB(anc_id_3,'(]',1,1) -1)
12730 ,SUBSTRB(anc_id_3
12731        ,INSTRB(anc_id_3,'(]',1,1) + 2
12732        ,INSTRB(anc_id_3,'(]',1,2) -
12733         INSTRB(anc_id_3,'(]',1,1) - 2)
12734 ,SUBSTRB(anc_id_3
12735        ,INSTRB(anc_id_3,'(]',1,2) + 2
12736        ,INSTRB(anc_id_3,'(]',1,3) -
12737         INSTRB(anc_id_3,'(]',1,2) - 2)
12738 ,SUBSTRB(anc_id_3
12739        ,INSTRB(anc_id_3,'(]',1,3) + 2
12740        ,INSTRB(anc_id_3,'(]',1,4) -
12741         INSTRB(anc_id_3,'(]',1,3) - 2)
12742 ,SUBSTRB(anc_id_3
12743        ,INSTRB(anc_id_3,'(]',1,4) + 2
12744        ,INSTRB(anc_id_3,'(]',1,5) -
12745         INSTRB(anc_id_3,'(]',1,4) - 2)
12746 ,SUBSTRB(anc_id_3
12747        ,INSTRB(anc_id_3,'(]',1,5) + 2
12748        ,INSTRB(anc_id_3,'(]',1,6) -
12749         INSTRB(anc_id_3,'(]',1,5) - 2)
12750 ,SUBSTRB(anc_id_3
12751        ,INSTRB(anc_id_3,'(]',1,6) + 2
12752        ,INSTRB(anc_id_3,'(]',1,7) -
12753         INSTRB(anc_id_3,'(]',1,6) - 2)
12754 ,SUBSTRB(anc_id_3
12755        ,INSTRB(anc_id_3,'(]',1,7) + 2
12756        ,LENGTHB(anc_id_3))
12757 )
12758 
12759 WHEN anc_id_4 IS NOT NULL THEN
12760   INTO xla_ae_header_acs (
12761         ae_header_id , object_version_number
12762       , analytical_criterion_code
12763       , analytical_criterion_type_code
12764       , amb_context_code
12765       , ac1,ac2,ac3,ac4,ac5)
12766 VALUES (ae_header_id, C_OVN
12767 ,SUBSTRB(anc_id_4
12768        ,1
12769        ,INSTRB(anc_id_4,'(]',1,1) -1)
12770 ,SUBSTRB(anc_id_4
12771        ,INSTRB(anc_id_4,'(]',1,1) + 2
12772        ,INSTRB(anc_id_4,'(]',1,2) -
12773         INSTRB(anc_id_4,'(]',1,1) - 2)
12774 ,SUBSTRB(anc_id_4
12775        ,INSTRB(anc_id_4,'(]',1,2) + 2
12776        ,INSTRB(anc_id_4,'(]',1,3) -
12777         INSTRB(anc_id_4,'(]',1,2) - 2)
12778 ,SUBSTRB(anc_id_4
12779        ,INSTRB(anc_id_4,'(]',1,3) + 2
12780        ,INSTRB(anc_id_4,'(]',1,4) -
12781         INSTRB(anc_id_4,'(]',1,3) - 2)
12782 ,SUBSTRB(anc_id_4
12783        ,INSTRB(anc_id_4,'(]',1,4) + 2
12784        ,INSTRB(anc_id_4,'(]',1,5) -
12785         INSTRB(anc_id_4,'(]',1,4) - 2)
12786 ,SUBSTRB(anc_id_4
12787        ,INSTRB(anc_id_4,'(]',1,5) + 2
12788        ,INSTRB(anc_id_4,'(]',1,6) -
12789         INSTRB(anc_id_4,'(]',1,5) - 2)
12790 ,SUBSTRB(anc_id_4
12791        ,INSTRB(anc_id_4,'(]',1,6) + 2
12792        ,INSTRB(anc_id_4,'(]',1,7) -
12793         INSTRB(anc_id_4,'(]',1,6) - 2)
12794 ,SUBSTRB(anc_id_4
12795        ,INSTRB(anc_id_4,'(]',1,7) + 2
12796        ,LENGTHB(anc_id_4))
12797 )
12798 
12799 WHEN anc_id_5 IS NOT NULL THEN
12800   INTO xla_ae_header_acs (
12801         ae_header_id , object_version_number
12802       , analytical_criterion_code
12803       , analytical_criterion_type_code
12804       , amb_context_code
12805       , ac1,ac2,ac3,ac4,ac5)
12806 VALUES (ae_header_id, C_OVN
12807 ,SUBSTRB(anc_id_5
12808        ,1
12809        ,INSTRB(anc_id_5,'(]',1,1) -1)
12810 ,SUBSTRB(anc_id_5
12811        ,INSTRB(anc_id_5,'(]',1,1) + 2
12812        ,INSTRB(anc_id_5,'(]',1,2) -
12813         INSTRB(anc_id_5,'(]',1,1) - 2)
12814 ,SUBSTRB(anc_id_5
12815        ,INSTRB(anc_id_5,'(]',1,2) + 2
12816        ,INSTRB(anc_id_5,'(]',1,3) -
12817         INSTRB(anc_id_5,'(]',1,2) - 2)
12818 ,SUBSTRB(anc_id_5
12819        ,INSTRB(anc_id_5,'(]',1,3) + 2
12820        ,INSTRB(anc_id_5,'(]',1,4) -
12821         INSTRB(anc_id_5,'(]',1,3) - 2)
12822 ,SUBSTRB(anc_id_5
12823        ,INSTRB(anc_id_5,'(]',1,4) + 2
12824        ,INSTRB(anc_id_5,'(]',1,5) -
12825         INSTRB(anc_id_5,'(]',1,4) - 2)
12826 ,SUBSTRB(anc_id_5
12827        ,INSTRB(anc_id_5,'(]',1,5) + 2
12828        ,INSTRB(anc_id_5,'(]',1,6) -
12829         INSTRB(anc_id_5,'(]',1,5) - 2)
12830 ,SUBSTRB(anc_id_5
12831        ,INSTRB(anc_id_5,'(]',1,6) + 2
12832        ,INSTRB(anc_id_5,'(]',1,7) -
12833         INSTRB(anc_id_5,'(]',1,6) - 2)
12834 ,SUBSTRB(anc_id_5
12835        ,INSTRB(anc_id_5,'(]',1,7) + 2
12836        ,LENGTHB(anc_id_5))
12837 )
12838 
12839 WHEN anc_id_6 IS NOT NULL THEN
12840   INTO xla_ae_header_acs (
12841         ae_header_id , object_version_number
12842       , analytical_criterion_code
12843       , analytical_criterion_type_code
12844       , amb_context_code
12845       , ac1,ac2,ac3,ac4,ac5)
12846 VALUES (ae_header_id, C_OVN
12847 ,SUBSTRB(anc_id_6
12848        ,1
12849        ,INSTRB(anc_id_6,'(]',1,1) -1)
12850 ,SUBSTRB(anc_id_6
12851        ,INSTRB(anc_id_6,'(]',1,1) + 2
12852        ,INSTRB(anc_id_6,'(]',1,2) -
12853         INSTRB(anc_id_6,'(]',1,1) - 2)
12854 ,SUBSTRB(anc_id_6
12855        ,INSTRB(anc_id_6,'(]',1,2) + 2
12856        ,INSTRB(anc_id_6,'(]',1,3) -
12857         INSTRB(anc_id_6,'(]',1,2) - 2)
12858 ,SUBSTRB(anc_id_6
12859        ,INSTRB(anc_id_6,'(]',1,3) + 2
12860        ,INSTRB(anc_id_6,'(]',1,4) -
12861         INSTRB(anc_id_6,'(]',1,3) - 2)
12862 ,SUBSTRB(anc_id_6
12863        ,INSTRB(anc_id_6,'(]',1,4) + 2
12864        ,INSTRB(anc_id_6,'(]',1,5) -
12865         INSTRB(anc_id_6,'(]',1,4) - 2)
12866 ,SUBSTRB(anc_id_6
12867        ,INSTRB(anc_id_6,'(]',1,5) + 2
12868        ,INSTRB(anc_id_6,'(]',1,6) -
12869         INSTRB(anc_id_6,'(]',1,5) - 2)
12870 ,SUBSTRB(anc_id_6
12871        ,INSTRB(anc_id_6,'(]',1,6) + 2
12872        ,INSTRB(anc_id_6,'(]',1,7) -
12873         INSTRB(anc_id_6,'(]',1,6) - 2)
12874 ,SUBSTRB(anc_id_6
12875        ,INSTRB(anc_id_6,'(]',1,7) + 2
12876        ,LENGTHB(anc_id_6))
12877 )
12878 
12879 WHEN anc_id_7 IS NOT NULL THEN
12880   INTO xla_ae_header_acs (
12881         ae_header_id , object_version_number
12882       , analytical_criterion_code
12883       , analytical_criterion_type_code
12884       , amb_context_code
12885       , ac1,ac2,ac3,ac4,ac5)
12886 VALUES (ae_header_id, C_OVN
12887 ,SUBSTRB(anc_id_7
12888        ,1
12889        ,INSTRB(anc_id_7,'(]',1,1) -1)
12890 ,SUBSTRB(anc_id_7
12891        ,INSTRB(anc_id_7,'(]',1,1) + 2
12892        ,INSTRB(anc_id_7,'(]',1,2) -
12893         INSTRB(anc_id_7,'(]',1,1) - 2)
12894 ,SUBSTRB(anc_id_7
12895        ,INSTRB(anc_id_7,'(]',1,2) + 2
12896        ,INSTRB(anc_id_7,'(]',1,3) -
12897         INSTRB(anc_id_7,'(]',1,2) - 2)
12898 ,SUBSTRB(anc_id_7
12899        ,INSTRB(anc_id_7,'(]',1,3) + 2
12900        ,INSTRB(anc_id_7,'(]',1,4) -
12901         INSTRB(anc_id_7,'(]',1,3) - 2)
12902 ,SUBSTRB(anc_id_7
12903        ,INSTRB(anc_id_7,'(]',1,4) + 2
12904        ,INSTRB(anc_id_7,'(]',1,5) -
12905         INSTRB(anc_id_7,'(]',1,4) - 2)
12906 ,SUBSTRB(anc_id_7
12907        ,INSTRB(anc_id_7,'(]',1,5) + 2
12908        ,INSTRB(anc_id_7,'(]',1,6) -
12909         INSTRB(anc_id_7,'(]',1,5) - 2)
12910 ,SUBSTRB(anc_id_7
12911        ,INSTRB(anc_id_7,'(]',1,6) + 2
12912        ,INSTRB(anc_id_7,'(]',1,7) -
12913         INSTRB(anc_id_7,'(]',1,6) - 2)
12914 ,SUBSTRB(anc_id_7
12915        ,INSTRB(anc_id_7,'(]',1,7) + 2
12916        ,LENGTHB(anc_id_7))
12917 )
12918 
12919 WHEN anc_id_8 IS NOT NULL THEN
12920   INTO xla_ae_header_acs (
12921         ae_header_id , object_version_number
12922       , analytical_criterion_code
12923       , analytical_criterion_type_code
12924       , amb_context_code
12925       , ac1,ac2,ac3,ac4,ac5)
12926 VALUES (ae_header_id, C_OVN
12927 ,SUBSTRB(anc_id_8
12928        ,1
12929        ,INSTRB(anc_id_8,'(]',1,1) -1)
12930 ,SUBSTRB(anc_id_8
12931        ,INSTRB(anc_id_8,'(]',1,1) + 2
12932        ,INSTRB(anc_id_8,'(]',1,2) -
12933         INSTRB(anc_id_8,'(]',1,1) - 2)
12934 ,SUBSTRB(anc_id_8
12935        ,INSTRB(anc_id_8,'(]',1,2) + 2
12936        ,INSTRB(anc_id_8,'(]',1,3) -
12937         INSTRB(anc_id_8,'(]',1,2) - 2)
12938 ,SUBSTRB(anc_id_8
12939        ,INSTRB(anc_id_8,'(]',1,3) + 2
12940        ,INSTRB(anc_id_8,'(]',1,4) -
12941         INSTRB(anc_id_8,'(]',1,3) - 2)
12942 ,SUBSTRB(anc_id_8
12943        ,INSTRB(anc_id_8,'(]',1,4) + 2
12944        ,INSTRB(anc_id_8,'(]',1,5) -
12945         INSTRB(anc_id_8,'(]',1,4) - 2)
12946 ,SUBSTRB(anc_id_8
12947        ,INSTRB(anc_id_8,'(]',1,5) + 2
12948        ,INSTRB(anc_id_8,'(]',1,6) -
12949         INSTRB(anc_id_8,'(]',1,5) - 2)
12950 ,SUBSTRB(anc_id_8
12951        ,INSTRB(anc_id_8,'(]',1,6) + 2
12952        ,INSTRB(anc_id_8,'(]',1,7) -
12953         INSTRB(anc_id_8,'(]',1,6) - 2)
12954 ,SUBSTRB(anc_id_8
12955        ,INSTRB(anc_id_8,'(]',1,7) + 2
12956        ,LENGTHB(anc_id_8))
12957 )
12958 
12959 WHEN anc_id_9 IS NOT NULL THEN
12960   INTO xla_ae_header_acs (
12961         ae_header_id , object_version_number
12962       , analytical_criterion_code
12963       , analytical_criterion_type_code
12964       , amb_context_code
12965       , ac1,ac2,ac3,ac4,ac5)
12966 VALUES (ae_header_id, C_OVN
12967 ,SUBSTRB(anc_id_9
12968        ,1
12969        ,INSTRB(anc_id_9,'(]',1,1) -1)
12970 ,SUBSTRB(anc_id_9
12971        ,INSTRB(anc_id_9,'(]',1,1) + 2
12972        ,INSTRB(anc_id_9,'(]',1,2) -
12973         INSTRB(anc_id_9,'(]',1,1) - 2)
12974 ,SUBSTRB(anc_id_9
12975        ,INSTRB(anc_id_9,'(]',1,2) + 2
12976        ,INSTRB(anc_id_9,'(]',1,3) -
12977         INSTRB(anc_id_9,'(]',1,2) - 2)
12978 ,SUBSTRB(anc_id_9
12979        ,INSTRB(anc_id_9,'(]',1,3) + 2
12980        ,INSTRB(anc_id_9,'(]',1,4) -
12981         INSTRB(anc_id_9,'(]',1,3) - 2)
12982 ,SUBSTRB(anc_id_9
12983        ,INSTRB(anc_id_9,'(]',1,4) + 2
12984        ,INSTRB(anc_id_9,'(]',1,5) -
12985         INSTRB(anc_id_9,'(]',1,4) - 2)
12986 ,SUBSTRB(anc_id_9
12987        ,INSTRB(anc_id_9,'(]',1,5) + 2
12988        ,INSTRB(anc_id_9,'(]',1,6) -
12989         INSTRB(anc_id_9,'(]',1,5) - 2)
12990 ,SUBSTRB(anc_id_9
12991        ,INSTRB(anc_id_9,'(]',1,6) + 2
12992        ,INSTRB(anc_id_9,'(]',1,7) -
12993         INSTRB(anc_id_9,'(]',1,6) - 2)
12994 ,SUBSTRB(anc_id_9
12995        ,INSTRB(anc_id_9,'(]',1,7) + 2
12996        ,LENGTHB(anc_id_9))
12997 )
12998 
12999 WHEN anc_id_10 IS NOT NULL THEN
13000   INTO xla_ae_header_acs (
13001         ae_header_id , object_version_number
13002       , analytical_criterion_code
13003       , analytical_criterion_type_code
13004       , amb_context_code
13005       , ac1,ac2,ac3,ac4,ac5)
13006 VALUES (ae_header_id, C_OVN
13007 ,SUBSTRB(anc_id_10
13008        ,1
13009        ,INSTRB(anc_id_10,'(]',1,1) -1)
13010 ,SUBSTRB(anc_id_10
13011        ,INSTRB(anc_id_10,'(]',1,1) + 2
13012        ,INSTRB(anc_id_10,'(]',1,2) -
13013         INSTRB(anc_id_10,'(]',1,1) - 2)
13014 ,SUBSTRB(anc_id_10
13015        ,INSTRB(anc_id_10,'(]',1,2) + 2
13016        ,INSTRB(anc_id_10,'(]',1,3) -
13017         INSTRB(anc_id_10,'(]',1,2) - 2)
13018 ,SUBSTRB(anc_id_10
13019        ,INSTRB(anc_id_10,'(]',1,3) + 2
13020        ,INSTRB(anc_id_10,'(]',1,4) -
13021         INSTRB(anc_id_10,'(]',1,3) - 2)
13022 ,SUBSTRB(anc_id_10
13023        ,INSTRB(anc_id_10,'(]',1,4) + 2
13024        ,INSTRB(anc_id_10,'(]',1,5) -
13025         INSTRB(anc_id_10,'(]',1,4) - 2)
13026 ,SUBSTRB(anc_id_10
13027        ,INSTRB(anc_id_10,'(]',1,5) + 2
13028        ,INSTRB(anc_id_10,'(]',1,6) -
13029         INSTRB(anc_id_10,'(]',1,5) - 2)
13030 ,SUBSTRB(anc_id_10
13031        ,INSTRB(anc_id_10,'(]',1,6) + 2
13032        ,INSTRB(anc_id_10,'(]',1,7) -
13033         INSTRB(anc_id_10,'(]',1,6) - 2)
13034 ,SUBSTRB(anc_id_10
13035        ,INSTRB(anc_id_10,'(]',1,7) + 2
13036        ,LENGTHB(anc_id_10))
13037 )
13038 
13039 WHEN anc_id_11 IS NOT NULL THEN
13040   INTO xla_ae_header_acs (
13041         ae_header_id , object_version_number
13042       , analytical_criterion_code
13043       , analytical_criterion_type_code
13044       , amb_context_code
13045       , ac1,ac2,ac3,ac4,ac5)
13046 VALUES (ae_header_id, C_OVN
13047 ,SUBSTRB(anc_id_11
13048        ,1
13049        ,INSTRB(anc_id_11,'(]',1,1) -1)
13050 ,SUBSTRB(anc_id_11
13051        ,INSTRB(anc_id_11,'(]',1,1) + 2
13052        ,INSTRB(anc_id_11,'(]',1,2) -
13053         INSTRB(anc_id_11,'(]',1,1) - 2)
13054 ,SUBSTRB(anc_id_11
13055        ,INSTRB(anc_id_11,'(]',1,2) + 2
13056        ,INSTRB(anc_id_11,'(]',1,3) -
13057         INSTRB(anc_id_11,'(]',1,2) - 2)
13058 ,SUBSTRB(anc_id_11
13059        ,INSTRB(anc_id_11,'(]',1,3) + 2
13060        ,INSTRB(anc_id_11,'(]',1,4) -
13061         INSTRB(anc_id_11,'(]',1,3) - 2)
13062 ,SUBSTRB(anc_id_11
13063        ,INSTRB(anc_id_11,'(]',1,4) + 2
13064        ,INSTRB(anc_id_11,'(]',1,5) -
13065         INSTRB(anc_id_11,'(]',1,4) - 2)
13066 ,SUBSTRB(anc_id_11
13067        ,INSTRB(anc_id_11,'(]',1,5) + 2
13068        ,INSTRB(anc_id_11,'(]',1,6) -
13069         INSTRB(anc_id_11,'(]',1,5) - 2)
13070 ,SUBSTRB(anc_id_11
13071        ,INSTRB(anc_id_11,'(]',1,6) + 2
13072        ,INSTRB(anc_id_11,'(]',1,7) -
13073         INSTRB(anc_id_11,'(]',1,6) - 2)
13074 ,SUBSTRB(anc_id_11
13075        ,INSTRB(anc_id_11,'(]',1,7) + 2
13076        ,LENGTHB(anc_id_11))
13077 )
13078 
13079 WHEN anc_id_12 IS NOT NULL THEN
13080   INTO xla_ae_header_acs (
13081         ae_header_id , object_version_number
13082       , analytical_criterion_code
13083       , analytical_criterion_type_code
13084       , amb_context_code
13085       , ac1,ac2,ac3,ac4,ac5)
13086 VALUES (ae_header_id, C_OVN
13087 ,SUBSTRB(anc_id_12
13088        ,1
13089        ,INSTRB(anc_id_12,'(]',1,1) -1)
13090 ,SUBSTRB(anc_id_12
13091        ,INSTRB(anc_id_12,'(]',1,1) + 2
13092        ,INSTRB(anc_id_12,'(]',1,2) -
13093         INSTRB(anc_id_12,'(]',1,1) - 2)
13094 ,SUBSTRB(anc_id_12
13095        ,INSTRB(anc_id_12,'(]',1,2) + 2
13096        ,INSTRB(anc_id_12,'(]',1,3) -
13097         INSTRB(anc_id_12,'(]',1,2) - 2)
13098 ,SUBSTRB(anc_id_12
13099        ,INSTRB(anc_id_12,'(]',1,3) + 2
13100        ,INSTRB(anc_id_12,'(]',1,4) -
13101         INSTRB(anc_id_12,'(]',1,3) - 2)
13102 ,SUBSTRB(anc_id_12
13103        ,INSTRB(anc_id_12,'(]',1,4) + 2
13104        ,INSTRB(anc_id_12,'(]',1,5) -
13105         INSTRB(anc_id_12,'(]',1,4) - 2)
13106 ,SUBSTRB(anc_id_12
13107        ,INSTRB(anc_id_12,'(]',1,5) + 2
13108        ,INSTRB(anc_id_12,'(]',1,6) -
13109         INSTRB(anc_id_12,'(]',1,5) - 2)
13110 ,SUBSTRB(anc_id_12
13111        ,INSTRB(anc_id_12,'(]',1,6) + 2
13112        ,INSTRB(anc_id_12,'(]',1,7) -
13113         INSTRB(anc_id_12,'(]',1,6) - 2)
13114 ,SUBSTRB(anc_id_12
13115        ,INSTRB(anc_id_12,'(]',1,7) + 2
13116        ,LENGTHB(anc_id_12))
13117 )
13118 
13119 WHEN anc_id_13 IS NOT NULL THEN
13120   INTO xla_ae_header_acs (
13121         ae_header_id , object_version_number
13122       , analytical_criterion_code
13123       , analytical_criterion_type_code
13124       , amb_context_code
13125       , ac1,ac2,ac3,ac4,ac5)
13126 VALUES (ae_header_id, C_OVN
13127 ,SUBSTRB(anc_id_13
13128        ,1
13129        ,INSTRB(anc_id_13,'(]',1,1) -1)
13130 ,SUBSTRB(anc_id_13
13131        ,INSTRB(anc_id_13,'(]',1,1) + 2
13132        ,INSTRB(anc_id_13,'(]',1,2) -
13133         INSTRB(anc_id_13,'(]',1,1) - 2)
13134 ,SUBSTRB(anc_id_13
13135        ,INSTRB(anc_id_13,'(]',1,2) + 2
13136        ,INSTRB(anc_id_13,'(]',1,3) -
13137         INSTRB(anc_id_13,'(]',1,2) - 2)
13138 ,SUBSTRB(anc_id_13
13139        ,INSTRB(anc_id_13,'(]',1,3) + 2
13140        ,INSTRB(anc_id_13,'(]',1,4) -
13141         INSTRB(anc_id_13,'(]',1,3) - 2)
13142 ,SUBSTRB(anc_id_13
13143        ,INSTRB(anc_id_13,'(]',1,4) + 2
13144        ,INSTRB(anc_id_13,'(]',1,5) -
13145         INSTRB(anc_id_13,'(]',1,4) - 2)
13146 ,SUBSTRB(anc_id_13
13147        ,INSTRB(anc_id_13,'(]',1,5) + 2
13148        ,INSTRB(anc_id_13,'(]',1,6) -
13149         INSTRB(anc_id_13,'(]',1,5) - 2)
13150 ,SUBSTRB(anc_id_13
13151        ,INSTRB(anc_id_13,'(]',1,6) + 2
13152        ,INSTRB(anc_id_13,'(]',1,7) -
13153         INSTRB(anc_id_13,'(]',1,6) - 2)
13154 ,SUBSTRB(anc_id_13
13155        ,INSTRB(anc_id_13,'(]',1,7) + 2
13156        ,LENGTHB(anc_id_13))
13157 )
13158 
13159 WHEN anc_id_14 IS NOT NULL THEN
13160   INTO xla_ae_header_acs (
13161         ae_header_id , object_version_number
13162       , analytical_criterion_code
13163       , analytical_criterion_type_code
13164       , amb_context_code
13165       , ac1,ac2,ac3,ac4,ac5)
13166 VALUES (ae_header_id, C_OVN
13167 ,SUBSTRB(anc_id_14
13168        ,1
13169        ,INSTRB(anc_id_14,'(]',1,1) -1)
13170 ,SUBSTRB(anc_id_14
13171        ,INSTRB(anc_id_14,'(]',1,1) + 2
13172        ,INSTRB(anc_id_14,'(]',1,2) -
13173         INSTRB(anc_id_14,'(]',1,1) - 2)
13174 ,SUBSTRB(anc_id_14
13175        ,INSTRB(anc_id_14,'(]',1,2) + 2
13176        ,INSTRB(anc_id_14,'(]',1,3) -
13177         INSTRB(anc_id_14,'(]',1,2) - 2)
13178 ,SUBSTRB(anc_id_14
13179        ,INSTRB(anc_id_14,'(]',1,3) + 2
13180        ,INSTRB(anc_id_14,'(]',1,4) -
13181         INSTRB(anc_id_14,'(]',1,3) - 2)
13182 ,SUBSTRB(anc_id_14
13183        ,INSTRB(anc_id_14,'(]',1,4) + 2
13184        ,INSTRB(anc_id_14,'(]',1,5) -
13185         INSTRB(anc_id_14,'(]',1,4) - 2)
13186 ,SUBSTRB(anc_id_14
13187        ,INSTRB(anc_id_14,'(]',1,5) + 2
13188        ,INSTRB(anc_id_14,'(]',1,6) -
13189         INSTRB(anc_id_14,'(]',1,5) - 2)
13190 ,SUBSTRB(anc_id_14
13191        ,INSTRB(anc_id_14,'(]',1,6) + 2
13192        ,INSTRB(anc_id_14,'(]',1,7) -
13193         INSTRB(anc_id_14,'(]',1,6) - 2)
13194 ,SUBSTRB(anc_id_14
13195        ,INSTRB(anc_id_14,'(]',1,7) + 2
13196        ,LENGTHB(anc_id_14))
13197 )
13198 
13199 WHEN anc_id_15 IS NOT NULL THEN
13200   INTO xla_ae_header_acs (
13201         ae_header_id , object_version_number
13202       , analytical_criterion_code
13203       , analytical_criterion_type_code
13204       , amb_context_code
13205       , ac1,ac2,ac3,ac4,ac5)
13206 VALUES (ae_header_id, C_OVN
13207 ,SUBSTRB(anc_id_15
13208        ,1
13209        ,INSTRB(anc_id_15,'(]',1,1) -1)
13210 ,SUBSTRB(anc_id_15
13211        ,INSTRB(anc_id_15,'(]',1,1) + 2
13212        ,INSTRB(anc_id_15,'(]',1,2) -
13213         INSTRB(anc_id_15,'(]',1,1) - 2)
13214 ,SUBSTRB(anc_id_15
13215        ,INSTRB(anc_id_15,'(]',1,2) + 2
13216        ,INSTRB(anc_id_15,'(]',1,3) -
13217         INSTRB(anc_id_15,'(]',1,2) - 2)
13218 ,SUBSTRB(anc_id_15
13219        ,INSTRB(anc_id_15,'(]',1,3) + 2
13220        ,INSTRB(anc_id_15,'(]',1,4) -
13221         INSTRB(anc_id_15,'(]',1,3) - 2)
13222 ,SUBSTRB(anc_id_15
13223        ,INSTRB(anc_id_15,'(]',1,4) + 2
13224        ,INSTRB(anc_id_15,'(]',1,5) -
13225         INSTRB(anc_id_15,'(]',1,4) - 2)
13226 ,SUBSTRB(anc_id_15
13227        ,INSTRB(anc_id_15,'(]',1,5) + 2
13228        ,INSTRB(anc_id_15,'(]',1,6) -
13229         INSTRB(anc_id_15,'(]',1,5) - 2)
13230 ,SUBSTRB(anc_id_15
13231        ,INSTRB(anc_id_15,'(]',1,6) + 2
13232        ,INSTRB(anc_id_15,'(]',1,7) -
13233         INSTRB(anc_id_15,'(]',1,6) - 2)
13234 ,SUBSTRB(anc_id_15
13235        ,INSTRB(anc_id_15,'(]',1,7) + 2
13236        ,LENGTHB(anc_id_15))
13237 )
13238 
13239 WHEN anc_id_16 IS NOT NULL THEN
13240   INTO xla_ae_header_acs (
13241         ae_header_id , object_version_number
13242       , analytical_criterion_code
13243       , analytical_criterion_type_code
13244       , amb_context_code
13245       , ac1,ac2,ac3,ac4,ac5)
13246 VALUES (ae_header_id, C_OVN
13247 ,SUBSTRB(anc_id_16
13248        ,1
13249        ,INSTRB(anc_id_16,'(]',1,1) -1)
13250 ,SUBSTRB(anc_id_16
13251        ,INSTRB(anc_id_16,'(]',1,1) + 2
13252        ,INSTRB(anc_id_16,'(]',1,2) -
13253         INSTRB(anc_id_16,'(]',1,1) - 2)
13254 ,SUBSTRB(anc_id_16
13255        ,INSTRB(anc_id_16,'(]',1,2) + 2
13256        ,INSTRB(anc_id_16,'(]',1,3) -
13257         INSTRB(anc_id_16,'(]',1,2) - 2)
13258 ,SUBSTRB(anc_id_16
13259        ,INSTRB(anc_id_16,'(]',1,3) + 2
13260        ,INSTRB(anc_id_16,'(]',1,4) -
13261         INSTRB(anc_id_16,'(]',1,3) - 2)
13262 ,SUBSTRB(anc_id_16
13263        ,INSTRB(anc_id_16,'(]',1,4) + 2
13264        ,INSTRB(anc_id_16,'(]',1,5) -
13265         INSTRB(anc_id_16,'(]',1,4) - 2)
13266 ,SUBSTRB(anc_id_16
13267        ,INSTRB(anc_id_16,'(]',1,5) + 2
13268        ,INSTRB(anc_id_16,'(]',1,6) -
13269         INSTRB(anc_id_16,'(]',1,5) - 2)
13270 ,SUBSTRB(anc_id_16
13271        ,INSTRB(anc_id_16,'(]',1,6) + 2
13272        ,INSTRB(anc_id_16,'(]',1,7) -
13273         INSTRB(anc_id_16,'(]',1,6) - 2)
13274 ,SUBSTRB(anc_id_16
13275        ,INSTRB(anc_id_16,'(]',1,7) + 2
13276        ,LENGTHB(anc_id_16))
13277 )
13278 
13279 WHEN anc_id_17 IS NOT NULL THEN
13280   INTO xla_ae_header_acs (
13281         ae_header_id , object_version_number
13282       , analytical_criterion_code
13283       , analytical_criterion_type_code
13284       , amb_context_code
13285       , ac1,ac2,ac3,ac4,ac5)
13286 VALUES (ae_header_id, C_OVN
13287 ,SUBSTRB(anc_id_17
13288        ,1
13289        ,INSTRB(anc_id_17,'(]',1,1) -1)
13290 ,SUBSTRB(anc_id_17
13291        ,INSTRB(anc_id_17,'(]',1,1) + 2
13292        ,INSTRB(anc_id_17,'(]',1,2) -
13293         INSTRB(anc_id_17,'(]',1,1) - 2)
13294 ,SUBSTRB(anc_id_17
13295        ,INSTRB(anc_id_17,'(]',1,2) + 2
13296        ,INSTRB(anc_id_17,'(]',1,3) -
13297         INSTRB(anc_id_17,'(]',1,2) - 2)
13298 ,SUBSTRB(anc_id_17
13299        ,INSTRB(anc_id_17,'(]',1,3) + 2
13300        ,INSTRB(anc_id_17,'(]',1,4) -
13301         INSTRB(anc_id_17,'(]',1,3) - 2)
13302 ,SUBSTRB(anc_id_17
13303        ,INSTRB(anc_id_17,'(]',1,4) + 2
13304        ,INSTRB(anc_id_17,'(]',1,5) -
13305         INSTRB(anc_id_17,'(]',1,4) - 2)
13306 ,SUBSTRB(anc_id_17
13307        ,INSTRB(anc_id_17,'(]',1,5) + 2
13308        ,INSTRB(anc_id_17,'(]',1,6) -
13309         INSTRB(anc_id_17,'(]',1,5) - 2)
13310 ,SUBSTRB(anc_id_17
13311        ,INSTRB(anc_id_17,'(]',1,6) + 2
13312        ,INSTRB(anc_id_17,'(]',1,7) -
13313         INSTRB(anc_id_17,'(]',1,6) - 2)
13314 ,SUBSTRB(anc_id_17
13315        ,INSTRB(anc_id_17,'(]',1,7) + 2
13316        ,LENGTHB(anc_id_17))
13317 )
13318 
13319 WHEN anc_id_18 IS NOT NULL THEN
13320   INTO xla_ae_header_acs (
13321         ae_header_id , object_version_number
13322       , analytical_criterion_code
13323       , analytical_criterion_type_code
13324       , amb_context_code
13325       , ac1,ac2,ac3,ac4,ac5)
13326 VALUES (ae_header_id, C_OVN
13327 ,SUBSTRB(anc_id_18
13328        ,1
13329        ,INSTRB(anc_id_18,'(]',1,1) -1)
13330 ,SUBSTRB(anc_id_18
13331        ,INSTRB(anc_id_18,'(]',1,1) + 2
13332        ,INSTRB(anc_id_18,'(]',1,2) -
13333         INSTRB(anc_id_18,'(]',1,1) - 2)
13334 ,SUBSTRB(anc_id_18
13335        ,INSTRB(anc_id_18,'(]',1,2) + 2
13336        ,INSTRB(anc_id_18,'(]',1,3) -
13337         INSTRB(anc_id_18,'(]',1,2) - 2)
13338 ,SUBSTRB(anc_id_18
13339        ,INSTRB(anc_id_18,'(]',1,3) + 2
13340        ,INSTRB(anc_id_18,'(]',1,4) -
13341         INSTRB(anc_id_18,'(]',1,3) - 2)
13342 ,SUBSTRB(anc_id_18
13343        ,INSTRB(anc_id_18,'(]',1,4) + 2
13344        ,INSTRB(anc_id_18,'(]',1,5) -
13345         INSTRB(anc_id_18,'(]',1,4) - 2)
13346 ,SUBSTRB(anc_id_18
13347        ,INSTRB(anc_id_18,'(]',1,5) + 2
13348        ,INSTRB(anc_id_18,'(]',1,6) -
13349         INSTRB(anc_id_18,'(]',1,5) - 2)
13350 ,SUBSTRB(anc_id_18
13351        ,INSTRB(anc_id_18,'(]',1,6) + 2
13352        ,INSTRB(anc_id_18,'(]',1,7) -
13353         INSTRB(anc_id_18,'(]',1,6) - 2)
13354 ,SUBSTRB(anc_id_18
13355        ,INSTRB(anc_id_18,'(]',1,7) + 2
13356        ,LENGTHB(anc_id_18))
13357 )
13358 
13359 WHEN anc_id_19 IS NOT NULL THEN
13360   INTO xla_ae_header_acs (
13361         ae_header_id , object_version_number
13362       , analytical_criterion_code
13363       , analytical_criterion_type_code
13364       , amb_context_code
13365       , ac1,ac2,ac3,ac4,ac5)
13366 VALUES (ae_header_id, C_OVN
13367 ,SUBSTRB(anc_id_19
13368        ,1
13369        ,INSTRB(anc_id_19,'(]',1,1) -1)
13370 ,SUBSTRB(anc_id_19
13371        ,INSTRB(anc_id_19,'(]',1,1) + 2
13372        ,INSTRB(anc_id_19,'(]',1,2) -
13373         INSTRB(anc_id_19,'(]',1,1) - 2)
13374 ,SUBSTRB(anc_id_19
13375        ,INSTRB(anc_id_19,'(]',1,2) + 2
13376        ,INSTRB(anc_id_19,'(]',1,3) -
13377         INSTRB(anc_id_19,'(]',1,2) - 2)
13378 ,SUBSTRB(anc_id_19
13379        ,INSTRB(anc_id_19,'(]',1,3) + 2
13380        ,INSTRB(anc_id_19,'(]',1,4) -
13381         INSTRB(anc_id_19,'(]',1,3) - 2)
13382 ,SUBSTRB(anc_id_19
13383        ,INSTRB(anc_id_19,'(]',1,4) + 2
13384        ,INSTRB(anc_id_19,'(]',1,5) -
13385         INSTRB(anc_id_19,'(]',1,4) - 2)
13386 ,SUBSTRB(anc_id_19
13387        ,INSTRB(anc_id_19,'(]',1,5) + 2
13388        ,INSTRB(anc_id_19,'(]',1,6) -
13389         INSTRB(anc_id_19,'(]',1,5) - 2)
13390 ,SUBSTRB(anc_id_19
13391        ,INSTRB(anc_id_19,'(]',1,6) + 2
13392        ,INSTRB(anc_id_19,'(]',1,7) -
13393         INSTRB(anc_id_19,'(]',1,6) - 2)
13394 ,SUBSTRB(anc_id_19
13395        ,INSTRB(anc_id_19,'(]',1,7) + 2
13396        ,LENGTHB(anc_id_19))
13397 )
13398 
13399 WHEN anc_id_20 IS NOT NULL THEN
13400   INTO xla_ae_header_acs (
13401         ae_header_id , object_version_number
13402       , analytical_criterion_code
13403       , analytical_criterion_type_code
13404       , amb_context_code
13405       , ac1,ac2,ac3,ac4,ac5)
13406 VALUES (ae_header_id, C_OVN
13407 ,SUBSTRB(anc_id_20
13408        ,1
13409        ,INSTRB(anc_id_20,'(]',1,1) -1)
13410 ,SUBSTRB(anc_id_20
13411        ,INSTRB(anc_id_20,'(]',1,1) + 2
13412        ,INSTRB(anc_id_20,'(]',1,2) -
13413         INSTRB(anc_id_20,'(]',1,1) - 2)
13414 ,SUBSTRB(anc_id_20
13415        ,INSTRB(anc_id_20,'(]',1,2) + 2
13416        ,INSTRB(anc_id_20,'(]',1,3) -
13417         INSTRB(anc_id_20,'(]',1,2) - 2)
13418 ,SUBSTRB(anc_id_20
13419        ,INSTRB(anc_id_20,'(]',1,3) + 2
13420        ,INSTRB(anc_id_20,'(]',1,4) -
13421         INSTRB(anc_id_20,'(]',1,3) - 2)
13422 ,SUBSTRB(anc_id_20
13423        ,INSTRB(anc_id_20,'(]',1,4) + 2
13424        ,INSTRB(anc_id_20,'(]',1,5) -
13425         INSTRB(anc_id_20,'(]',1,4) - 2)
13426 ,SUBSTRB(anc_id_20
13427        ,INSTRB(anc_id_20,'(]',1,5) + 2
13428        ,INSTRB(anc_id_20,'(]',1,6) -
13429         INSTRB(anc_id_20,'(]',1,5) - 2)
13430 ,SUBSTRB(anc_id_20
13431        ,INSTRB(anc_id_20,'(]',1,6) + 2
13432        ,INSTRB(anc_id_20,'(]',1,7) -
13433         INSTRB(anc_id_20,'(]',1,6) - 2)
13434 ,SUBSTRB(anc_id_20
13435        ,INSTRB(anc_id_20,'(]',1,7) + 2
13436        ,LENGTHB(anc_id_20))
13437 )
13438 
13439 WHEN anc_id_21 IS NOT NULL THEN
13440   INTO xla_ae_header_acs (
13441         ae_header_id , object_version_number
13442       , analytical_criterion_code
13443       , analytical_criterion_type_code
13444       , amb_context_code
13445       , ac1,ac2,ac3,ac4,ac5)
13446 VALUES (ae_header_id, C_OVN
13447 ,SUBSTRB(anc_id_21
13448        ,1
13449        ,INSTRB(anc_id_21,'(]',1,1) -1)
13450 ,SUBSTRB(anc_id_21
13451        ,INSTRB(anc_id_21,'(]',1,1) + 2
13452        ,INSTRB(anc_id_21,'(]',1,2) -
13453         INSTRB(anc_id_21,'(]',1,1) - 2)
13454 ,SUBSTRB(anc_id_21
13455        ,INSTRB(anc_id_21,'(]',1,2) + 2
13456        ,INSTRB(anc_id_21,'(]',1,3) -
13457         INSTRB(anc_id_21,'(]',1,2) - 2)
13458 ,SUBSTRB(anc_id_21
13459        ,INSTRB(anc_id_21,'(]',1,3) + 2
13460        ,INSTRB(anc_id_21,'(]',1,4) -
13461         INSTRB(anc_id_21,'(]',1,3) - 2)
13462 ,SUBSTRB(anc_id_21
13463        ,INSTRB(anc_id_21,'(]',1,4) + 2
13464        ,INSTRB(anc_id_21,'(]',1,5) -
13465         INSTRB(anc_id_21,'(]',1,4) - 2)
13466 ,SUBSTRB(anc_id_21
13467        ,INSTRB(anc_id_21,'(]',1,5) + 2
13468        ,INSTRB(anc_id_21,'(]',1,6) -
13469         INSTRB(anc_id_21,'(]',1,5) - 2)
13470 ,SUBSTRB(anc_id_21
13471        ,INSTRB(anc_id_21,'(]',1,6) + 2
13472        ,INSTRB(anc_id_21,'(]',1,7) -
13473         INSTRB(anc_id_21,'(]',1,6) - 2)
13474 ,SUBSTRB(anc_id_21
13475        ,INSTRB(anc_id_21,'(]',1,7) + 2
13476        ,LENGTHB(anc_id_21))
13477 )
13478 
13479 WHEN anc_id_22 IS NOT NULL THEN
13480   INTO xla_ae_header_acs (
13481         ae_header_id , object_version_number
13482       , analytical_criterion_code
13483       , analytical_criterion_type_code
13484       , amb_context_code
13485       , ac1,ac2,ac3,ac4,ac5)
13486 VALUES (ae_header_id, C_OVN
13487 ,SUBSTRB(anc_id_22
13488        ,1
13489        ,INSTRB(anc_id_22,'(]',1,1) -1)
13490 ,SUBSTRB(anc_id_22
13491        ,INSTRB(anc_id_22,'(]',1,1) + 2
13492        ,INSTRB(anc_id_22,'(]',1,2) -
13493         INSTRB(anc_id_22,'(]',1,1) - 2)
13494 ,SUBSTRB(anc_id_22
13495        ,INSTRB(anc_id_22,'(]',1,2) + 2
13496        ,INSTRB(anc_id_22,'(]',1,3) -
13497         INSTRB(anc_id_22,'(]',1,2) - 2)
13498 ,SUBSTRB(anc_id_22
13499        ,INSTRB(anc_id_22,'(]',1,3) + 2
13500        ,INSTRB(anc_id_22,'(]',1,4) -
13501         INSTRB(anc_id_22,'(]',1,3) - 2)
13502 ,SUBSTRB(anc_id_22
13503        ,INSTRB(anc_id_22,'(]',1,4) + 2
13504        ,INSTRB(anc_id_22,'(]',1,5) -
13505         INSTRB(anc_id_22,'(]',1,4) - 2)
13506 ,SUBSTRB(anc_id_22
13507        ,INSTRB(anc_id_22,'(]',1,5) + 2
13508        ,INSTRB(anc_id_22,'(]',1,6) -
13509         INSTRB(anc_id_22,'(]',1,5) - 2)
13510 ,SUBSTRB(anc_id_22
13511        ,INSTRB(anc_id_22,'(]',1,6) + 2
13512        ,INSTRB(anc_id_22,'(]',1,7) -
13513         INSTRB(anc_id_22,'(]',1,6) - 2)
13514 ,SUBSTRB(anc_id_22
13515        ,INSTRB(anc_id_22,'(]',1,7) + 2
13516        ,LENGTHB(anc_id_22))
13517 )
13518 
13519 WHEN anc_id_23 IS NOT NULL THEN
13520   INTO xla_ae_header_acs (
13521         ae_header_id , object_version_number
13522       , analytical_criterion_code
13523       , analytical_criterion_type_code
13524       , amb_context_code
13525       , ac1,ac2,ac3,ac4,ac5)
13526 VALUES (ae_header_id, C_OVN
13527 ,SUBSTRB(anc_id_23
13528        ,1
13529        ,INSTRB(anc_id_23,'(]',1,1) -1)
13530 ,SUBSTRB(anc_id_23
13531        ,INSTRB(anc_id_23,'(]',1,1) + 2
13532        ,INSTRB(anc_id_23,'(]',1,2) -
13533         INSTRB(anc_id_23,'(]',1,1) - 2)
13534 ,SUBSTRB(anc_id_23
13535        ,INSTRB(anc_id_23,'(]',1,2) + 2
13536        ,INSTRB(anc_id_23,'(]',1,3) -
13537         INSTRB(anc_id_23,'(]',1,2) - 2)
13538 ,SUBSTRB(anc_id_23
13539        ,INSTRB(anc_id_23,'(]',1,3) + 2
13540        ,INSTRB(anc_id_23,'(]',1,4) -
13541         INSTRB(anc_id_23,'(]',1,3) - 2)
13542 ,SUBSTRB(anc_id_23
13543        ,INSTRB(anc_id_23,'(]',1,4) + 2
13544        ,INSTRB(anc_id_23,'(]',1,5) -
13545         INSTRB(anc_id_23,'(]',1,4) - 2)
13546 ,SUBSTRB(anc_id_23
13547        ,INSTRB(anc_id_23,'(]',1,5) + 2
13548        ,INSTRB(anc_id_23,'(]',1,6) -
13549         INSTRB(anc_id_23,'(]',1,5) - 2)
13550 ,SUBSTRB(anc_id_23
13551        ,INSTRB(anc_id_23,'(]',1,6) + 2
13552        ,INSTRB(anc_id_23,'(]',1,7) -
13553         INSTRB(anc_id_23,'(]',1,6) - 2)
13554 ,SUBSTRB(anc_id_23
13555        ,INSTRB(anc_id_23,'(]',1,7) + 2
13556        ,LENGTHB(anc_id_23))
13557 )
13558 
13559 WHEN anc_id_24 IS NOT NULL THEN
13560   INTO xla_ae_header_acs (
13561         ae_header_id , object_version_number
13562       , analytical_criterion_code
13563       , analytical_criterion_type_code
13564       , amb_context_code
13565       , ac1,ac2,ac3,ac4,ac5)
13566 VALUES (ae_header_id, C_OVN
13567 ,SUBSTRB(anc_id_24
13568        ,1
13569        ,INSTRB(anc_id_24,'(]',1,1) -1)
13570 ,SUBSTRB(anc_id_24
13571        ,INSTRB(anc_id_24,'(]',1,1) + 2
13572        ,INSTRB(anc_id_24,'(]',1,2) -
13573         INSTRB(anc_id_24,'(]',1,1) - 2)
13574 ,SUBSTRB(anc_id_24
13575        ,INSTRB(anc_id_24,'(]',1,2) + 2
13576        ,INSTRB(anc_id_24,'(]',1,3) -
13577         INSTRB(anc_id_24,'(]',1,2) - 2)
13578 ,SUBSTRB(anc_id_24
13579        ,INSTRB(anc_id_24,'(]',1,3) + 2
13580        ,INSTRB(anc_id_24,'(]',1,4) -
13581         INSTRB(anc_id_24,'(]',1,3) - 2)
13582 ,SUBSTRB(anc_id_24
13583        ,INSTRB(anc_id_24,'(]',1,4) + 2
13584        ,INSTRB(anc_id_24,'(]',1,5) -
13585         INSTRB(anc_id_24,'(]',1,4) - 2)
13586 ,SUBSTRB(anc_id_24
13587        ,INSTRB(anc_id_24,'(]',1,5) + 2
13588        ,INSTRB(anc_id_24,'(]',1,6) -
13589         INSTRB(anc_id_24,'(]',1,5) - 2)
13590 ,SUBSTRB(anc_id_24
13591        ,INSTRB(anc_id_24,'(]',1,6) + 2
13592        ,INSTRB(anc_id_24,'(]',1,7) -
13593         INSTRB(anc_id_24,'(]',1,6) - 2)
13594 ,SUBSTRB(anc_id_24
13595        ,INSTRB(anc_id_24,'(]',1,7) + 2
13596        ,LENGTHB(anc_id_24))
13597 )
13598 
13599 WHEN anc_id_25 IS NOT NULL THEN
13600   INTO xla_ae_header_acs (
13601         ae_header_id , object_version_number
13602       , analytical_criterion_code
13603       , analytical_criterion_type_code
13604       , amb_context_code
13605       , ac1,ac2,ac3,ac4,ac5)
13606 VALUES (ae_header_id, C_OVN
13607 ,SUBSTRB(anc_id_25
13608        ,1
13609        ,INSTRB(anc_id_25,'(]',1,1) -1)
13610 ,SUBSTRB(anc_id_25
13611        ,INSTRB(anc_id_25,'(]',1,1) + 2
13612        ,INSTRB(anc_id_25,'(]',1,2) -
13613         INSTRB(anc_id_25,'(]',1,1) - 2)
13614 ,SUBSTRB(anc_id_25
13615        ,INSTRB(anc_id_25,'(]',1,2) + 2
13616        ,INSTRB(anc_id_25,'(]',1,3) -
13617         INSTRB(anc_id_25,'(]',1,2) - 2)
13618 ,SUBSTRB(anc_id_25
13619        ,INSTRB(anc_id_25,'(]',1,3) + 2
13620        ,INSTRB(anc_id_25,'(]',1,4) -
13621         INSTRB(anc_id_25,'(]',1,3) - 2)
13622 ,SUBSTRB(anc_id_25
13623        ,INSTRB(anc_id_25,'(]',1,4) + 2
13624        ,INSTRB(anc_id_25,'(]',1,5) -
13625         INSTRB(anc_id_25,'(]',1,4) - 2)
13626 ,SUBSTRB(anc_id_25
13627        ,INSTRB(anc_id_25,'(]',1,5) + 2
13628        ,INSTRB(anc_id_25,'(]',1,6) -
13629         INSTRB(anc_id_25,'(]',1,5) - 2)
13630 ,SUBSTRB(anc_id_25
13631        ,INSTRB(anc_id_25,'(]',1,6) + 2
13632        ,INSTRB(anc_id_25,'(]',1,7) -
13633         INSTRB(anc_id_25,'(]',1,6) - 2)
13634 ,SUBSTRB(anc_id_25
13635        ,INSTRB(anc_id_25,'(]',1,7) + 2
13636        ,LENGTHB(anc_id_25))
13637 )
13638 
13639 WHEN anc_id_26 IS NOT NULL THEN
13640   INTO xla_ae_header_acs (
13641         ae_header_id , object_version_number
13642       , analytical_criterion_code
13643       , analytical_criterion_type_code
13644       , amb_context_code
13645       , ac1,ac2,ac3,ac4,ac5)
13646 VALUES (ae_header_id, C_OVN
13647 ,SUBSTRB(anc_id_26
13648        ,1
13649        ,INSTRB(anc_id_26,'(]',1,1) -1)
13650 ,SUBSTRB(anc_id_26
13651        ,INSTRB(anc_id_26,'(]',1,1) + 2
13652        ,INSTRB(anc_id_26,'(]',1,2) -
13653         INSTRB(anc_id_26,'(]',1,1) - 2)
13654 ,SUBSTRB(anc_id_26
13655        ,INSTRB(anc_id_26,'(]',1,2) + 2
13656        ,INSTRB(anc_id_26,'(]',1,3) -
13657         INSTRB(anc_id_26,'(]',1,2) - 2)
13658 ,SUBSTRB(anc_id_26
13659        ,INSTRB(anc_id_26,'(]',1,3) + 2
13660        ,INSTRB(anc_id_26,'(]',1,4) -
13661         INSTRB(anc_id_26,'(]',1,3) - 2)
13662 ,SUBSTRB(anc_id_26
13663        ,INSTRB(anc_id_26,'(]',1,4) + 2
13664        ,INSTRB(anc_id_26,'(]',1,5) -
13665         INSTRB(anc_id_26,'(]',1,4) - 2)
13666 ,SUBSTRB(anc_id_26
13667        ,INSTRB(anc_id_26,'(]',1,5) + 2
13668        ,INSTRB(anc_id_26,'(]',1,6) -
13669         INSTRB(anc_id_26,'(]',1,5) - 2)
13670 ,SUBSTRB(anc_id_26
13671        ,INSTRB(anc_id_26,'(]',1,6) + 2
13672        ,INSTRB(anc_id_26,'(]',1,7) -
13673         INSTRB(anc_id_26,'(]',1,6) - 2)
13674 ,SUBSTRB(anc_id_26
13675        ,INSTRB(anc_id_26,'(]',1,7) + 2
13676        ,LENGTHB(anc_id_26))
13677 )
13678 
13679 WHEN anc_id_27 IS NOT NULL THEN
13680   INTO xla_ae_header_acs (
13681         ae_header_id , object_version_number
13682       , analytical_criterion_code
13683       , analytical_criterion_type_code
13684       , amb_context_code
13685       , ac1,ac2,ac3,ac4,ac5)
13686 VALUES (ae_header_id, C_OVN
13687 ,SUBSTRB(anc_id_27
13688        ,1
13689        ,INSTRB(anc_id_27,'(]',1,1) -1)
13690 ,SUBSTRB(anc_id_27
13691        ,INSTRB(anc_id_27,'(]',1,1) + 2
13692        ,INSTRB(anc_id_27,'(]',1,2) -
13693         INSTRB(anc_id_27,'(]',1,1) - 2)
13694 ,SUBSTRB(anc_id_27
13695        ,INSTRB(anc_id_27,'(]',1,2) + 2
13696        ,INSTRB(anc_id_27,'(]',1,3) -
13697         INSTRB(anc_id_27,'(]',1,2) - 2)
13698 ,SUBSTRB(anc_id_27
13699        ,INSTRB(anc_id_27,'(]',1,3) + 2
13700        ,INSTRB(anc_id_27,'(]',1,4) -
13701         INSTRB(anc_id_27,'(]',1,3) - 2)
13702 ,SUBSTRB(anc_id_27
13703        ,INSTRB(anc_id_27,'(]',1,4) + 2
13704        ,INSTRB(anc_id_27,'(]',1,5) -
13705         INSTRB(anc_id_27,'(]',1,4) - 2)
13706 ,SUBSTRB(anc_id_27
13707        ,INSTRB(anc_id_27,'(]',1,5) + 2
13708        ,INSTRB(anc_id_27,'(]',1,6) -
13709         INSTRB(anc_id_27,'(]',1,5) - 2)
13710 ,SUBSTRB(anc_id_27
13711        ,INSTRB(anc_id_27,'(]',1,6) + 2
13712        ,INSTRB(anc_id_27,'(]',1,7) -
13713         INSTRB(anc_id_27,'(]',1,6) - 2)
13714 ,SUBSTRB(anc_id_27
13715        ,INSTRB(anc_id_27,'(]',1,7) + 2
13716        ,LENGTHB(anc_id_27))
13717 )
13718 
13719 WHEN anc_id_28 IS NOT NULL THEN
13720   INTO xla_ae_header_acs (
13721         ae_header_id , object_version_number
13722       , analytical_criterion_code
13723       , analytical_criterion_type_code
13724       , amb_context_code
13725       , ac1,ac2,ac3,ac4,ac5)
13726 VALUES (ae_header_id, C_OVN
13727 ,SUBSTRB(anc_id_28
13728        ,1
13729        ,INSTRB(anc_id_28,'(]',1,1) -1)
13730 ,SUBSTRB(anc_id_28
13731        ,INSTRB(anc_id_28,'(]',1,1) + 2
13732        ,INSTRB(anc_id_28,'(]',1,2) -
13733         INSTRB(anc_id_28,'(]',1,1) - 2)
13734 ,SUBSTRB(anc_id_28
13735        ,INSTRB(anc_id_28,'(]',1,2) + 2
13736        ,INSTRB(anc_id_28,'(]',1,3) -
13737         INSTRB(anc_id_28,'(]',1,2) - 2)
13738 ,SUBSTRB(anc_id_28
13739        ,INSTRB(anc_id_28,'(]',1,3) + 2
13740        ,INSTRB(anc_id_28,'(]',1,4) -
13741         INSTRB(anc_id_28,'(]',1,3) - 2)
13742 ,SUBSTRB(anc_id_28
13743        ,INSTRB(anc_id_28,'(]',1,4) + 2
13744        ,INSTRB(anc_id_28,'(]',1,5) -
13745         INSTRB(anc_id_28,'(]',1,4) - 2)
13746 ,SUBSTRB(anc_id_28
13747        ,INSTRB(anc_id_28,'(]',1,5) + 2
13748        ,INSTRB(anc_id_28,'(]',1,6) -
13749         INSTRB(anc_id_28,'(]',1,5) - 2)
13750 ,SUBSTRB(anc_id_28
13751        ,INSTRB(anc_id_28,'(]',1,6) + 2
13752        ,INSTRB(anc_id_28,'(]',1,7) -
13753         INSTRB(anc_id_28,'(]',1,6) - 2)
13754 ,SUBSTRB(anc_id_28
13755        ,INSTRB(anc_id_28,'(]',1,7) + 2
13756        ,LENGTHB(anc_id_28))
13757 )
13758 
13759 WHEN anc_id_29 IS NOT NULL THEN
13760   INTO xla_ae_header_acs (
13761         ae_header_id , object_version_number
13762       , analytical_criterion_code
13763       , analytical_criterion_type_code
13764       , amb_context_code
13765       , ac1,ac2,ac3,ac4,ac5)
13766 VALUES (ae_header_id, C_OVN
13767 ,SUBSTRB(anc_id_29
13768        ,1
13769        ,INSTRB(anc_id_29,'(]',1,1) -1)
13770 ,SUBSTRB(anc_id_29
13771        ,INSTRB(anc_id_29,'(]',1,1) + 2
13772        ,INSTRB(anc_id_29,'(]',1,2) -
13773         INSTRB(anc_id_29,'(]',1,1) - 2)
13774 ,SUBSTRB(anc_id_29
13775        ,INSTRB(anc_id_29,'(]',1,2) + 2
13776        ,INSTRB(anc_id_29,'(]',1,3) -
13777         INSTRB(anc_id_29,'(]',1,2) - 2)
13778 ,SUBSTRB(anc_id_29
13779        ,INSTRB(anc_id_29,'(]',1,3) + 2
13780        ,INSTRB(anc_id_29,'(]',1,4) -
13781         INSTRB(anc_id_29,'(]',1,3) - 2)
13782 ,SUBSTRB(anc_id_29
13783        ,INSTRB(anc_id_29,'(]',1,4) + 2
13784        ,INSTRB(anc_id_29,'(]',1,5) -
13785         INSTRB(anc_id_29,'(]',1,4) - 2)
13786 ,SUBSTRB(anc_id_29
13787        ,INSTRB(anc_id_29,'(]',1,5) + 2
13788        ,INSTRB(anc_id_29,'(]',1,6) -
13789         INSTRB(anc_id_29,'(]',1,5) - 2)
13790 ,SUBSTRB(anc_id_29
13791        ,INSTRB(anc_id_29,'(]',1,6) + 2
13792        ,INSTRB(anc_id_29,'(]',1,7) -
13793         INSTRB(anc_id_29,'(]',1,6) - 2)
13794 ,SUBSTRB(anc_id_29
13795        ,INSTRB(anc_id_29,'(]',1,7) + 2
13796        ,LENGTHB(anc_id_29))
13797 )
13798 
13799 WHEN anc_id_30 IS NOT NULL THEN
13800   INTO xla_ae_header_acs (
13801         ae_header_id , object_version_number
13802       , analytical_criterion_code
13803       , analytical_criterion_type_code
13804       , amb_context_code
13805       , ac1,ac2,ac3,ac4,ac5)
13806 VALUES (ae_header_id, C_OVN
13807 ,SUBSTRB(anc_id_30
13808        ,1
13809        ,INSTRB(anc_id_30,'(]',1,1) -1)
13810 ,SUBSTRB(anc_id_30
13811        ,INSTRB(anc_id_30,'(]',1,1) + 2
13812        ,INSTRB(anc_id_30,'(]',1,2) -
13813         INSTRB(anc_id_30,'(]',1,1) - 2)
13814 ,SUBSTRB(anc_id_30
13815        ,INSTRB(anc_id_30,'(]',1,2) + 2
13816        ,INSTRB(anc_id_30,'(]',1,3) -
13817         INSTRB(anc_id_30,'(]',1,2) - 2)
13818 ,SUBSTRB(anc_id_30
13819        ,INSTRB(anc_id_30,'(]',1,3) + 2
13820        ,INSTRB(anc_id_30,'(]',1,4) -
13821         INSTRB(anc_id_30,'(]',1,3) - 2)
13822 ,SUBSTRB(anc_id_30
13823        ,INSTRB(anc_id_30,'(]',1,4) + 2
13824        ,INSTRB(anc_id_30,'(]',1,5) -
13825         INSTRB(anc_id_30,'(]',1,4) - 2)
13826 ,SUBSTRB(anc_id_30
13827        ,INSTRB(anc_id_30,'(]',1,5) + 2
13828        ,INSTRB(anc_id_30,'(]',1,6) -
13829         INSTRB(anc_id_30,'(]',1,5) - 2)
13830 ,SUBSTRB(anc_id_30
13831        ,INSTRB(anc_id_30,'(]',1,6) + 2
13832        ,INSTRB(anc_id_30,'(]',1,7) -
13833         INSTRB(anc_id_30,'(]',1,6) - 2)
13834 ,SUBSTRB(anc_id_30
13835        ,INSTRB(anc_id_30,'(]',1,7) + 2
13836        ,LENGTHB(anc_id_30))
13837 )
13838 
13839 WHEN anc_id_31 IS NOT NULL THEN
13840   INTO xla_ae_header_acs (
13841         ae_header_id , object_version_number
13842       , analytical_criterion_code
13843       , analytical_criterion_type_code
13844       , amb_context_code
13845       , ac1,ac2,ac3,ac4,ac5)
13846 VALUES (ae_header_id, C_OVN
13847 ,SUBSTRB(anc_id_31
13848        ,1
13849        ,INSTRB(anc_id_31,'(]',1,1) -1)
13850 ,SUBSTRB(anc_id_31
13851        ,INSTRB(anc_id_31,'(]',1,1) + 2
13852        ,INSTRB(anc_id_31,'(]',1,2) -
13853         INSTRB(anc_id_31,'(]',1,1) - 2)
13854 ,SUBSTRB(anc_id_31
13855        ,INSTRB(anc_id_31,'(]',1,2) + 2
13856        ,INSTRB(anc_id_31,'(]',1,3) -
13857         INSTRB(anc_id_31,'(]',1,2) - 2)
13858 ,SUBSTRB(anc_id_31
13859        ,INSTRB(anc_id_31,'(]',1,3) + 2
13860        ,INSTRB(anc_id_31,'(]',1,4) -
13861         INSTRB(anc_id_31,'(]',1,3) - 2)
13862 ,SUBSTRB(anc_id_31
13863        ,INSTRB(anc_id_31,'(]',1,4) + 2
13864        ,INSTRB(anc_id_31,'(]',1,5) -
13865         INSTRB(anc_id_31,'(]',1,4) - 2)
13866 ,SUBSTRB(anc_id_31
13867        ,INSTRB(anc_id_31,'(]',1,5) + 2
13868        ,INSTRB(anc_id_31,'(]',1,6) -
13869         INSTRB(anc_id_31,'(]',1,5) - 2)
13870 ,SUBSTRB(anc_id_31
13871        ,INSTRB(anc_id_31,'(]',1,6) + 2
13872        ,INSTRB(anc_id_31,'(]',1,7) -
13873         INSTRB(anc_id_31,'(]',1,6) - 2)
13874 ,SUBSTRB(anc_id_31
13875        ,INSTRB(anc_id_31,'(]',1,7) + 2
13876        ,LENGTHB(anc_id_31))
13877 )
13878 
13879 WHEN anc_id_32 IS NOT NULL THEN
13880   INTO xla_ae_header_acs (
13881         ae_header_id , object_version_number
13882       , analytical_criterion_code
13883       , analytical_criterion_type_code
13884       , amb_context_code
13885       , ac1,ac2,ac3,ac4,ac5)
13886 VALUES (ae_header_id, C_OVN
13887 ,SUBSTRB(anc_id_32
13888        ,1
13889        ,INSTRB(anc_id_32,'(]',1,1) -1)
13890 ,SUBSTRB(anc_id_32
13891        ,INSTRB(anc_id_32,'(]',1,1) + 2
13892        ,INSTRB(anc_id_32,'(]',1,2) -
13893         INSTRB(anc_id_32,'(]',1,1) - 2)
13894 ,SUBSTRB(anc_id_32
13895        ,INSTRB(anc_id_32,'(]',1,2) + 2
13896        ,INSTRB(anc_id_32,'(]',1,3) -
13897         INSTRB(anc_id_32,'(]',1,2) - 2)
13898 ,SUBSTRB(anc_id_32
13899        ,INSTRB(anc_id_32,'(]',1,3) + 2
13900        ,INSTRB(anc_id_32,'(]',1,4) -
13901         INSTRB(anc_id_32,'(]',1,3) - 2)
13902 ,SUBSTRB(anc_id_32
13903        ,INSTRB(anc_id_32,'(]',1,4) + 2
13904        ,INSTRB(anc_id_32,'(]',1,5) -
13905         INSTRB(anc_id_32,'(]',1,4) - 2)
13906 ,SUBSTRB(anc_id_32
13907        ,INSTRB(anc_id_32,'(]',1,5) + 2
13908        ,INSTRB(anc_id_32,'(]',1,6) -
13909         INSTRB(anc_id_32,'(]',1,5) - 2)
13910 ,SUBSTRB(anc_id_32
13911        ,INSTRB(anc_id_32,'(]',1,6) + 2
13912        ,INSTRB(anc_id_32,'(]',1,7) -
13913         INSTRB(anc_id_32,'(]',1,6) - 2)
13914 ,SUBSTRB(anc_id_32
13915        ,INSTRB(anc_id_32,'(]',1,7) + 2
13916        ,LENGTHB(anc_id_32))
13917 )
13918 
13919 WHEN anc_id_33 IS NOT NULL THEN
13920   INTO xla_ae_header_acs (
13921         ae_header_id , object_version_number
13922       , analytical_criterion_code
13923       , analytical_criterion_type_code
13924       , amb_context_code
13925       , ac1,ac2,ac3,ac4,ac5)
13926 VALUES (ae_header_id, C_OVN
13927 ,SUBSTRB(anc_id_33
13928        ,1
13929        ,INSTRB(anc_id_33,'(]',1,1) -1)
13930 ,SUBSTRB(anc_id_33
13931        ,INSTRB(anc_id_33,'(]',1,1) + 2
13932        ,INSTRB(anc_id_33,'(]',1,2) -
13933         INSTRB(anc_id_33,'(]',1,1) - 2)
13934 ,SUBSTRB(anc_id_33
13935        ,INSTRB(anc_id_33,'(]',1,2) + 2
13936        ,INSTRB(anc_id_33,'(]',1,3) -
13937         INSTRB(anc_id_33,'(]',1,2) - 2)
13938 ,SUBSTRB(anc_id_33
13939        ,INSTRB(anc_id_33,'(]',1,3) + 2
13940        ,INSTRB(anc_id_33,'(]',1,4) -
13941         INSTRB(anc_id_33,'(]',1,3) - 2)
13942 ,SUBSTRB(anc_id_33
13943        ,INSTRB(anc_id_33,'(]',1,4) + 2
13944        ,INSTRB(anc_id_33,'(]',1,5) -
13945         INSTRB(anc_id_33,'(]',1,4) - 2)
13946 ,SUBSTRB(anc_id_33
13947        ,INSTRB(anc_id_33,'(]',1,5) + 2
13948        ,INSTRB(anc_id_33,'(]',1,6) -
13949         INSTRB(anc_id_33,'(]',1,5) - 2)
13950 ,SUBSTRB(anc_id_33
13951        ,INSTRB(anc_id_33,'(]',1,6) + 2
13952        ,INSTRB(anc_id_33,'(]',1,7) -
13953         INSTRB(anc_id_33,'(]',1,6) - 2)
13954 ,SUBSTRB(anc_id_33
13955        ,INSTRB(anc_id_33,'(]',1,7) + 2
13956        ,LENGTHB(anc_id_33))
13957 )
13958 
13959 WHEN anc_id_34 IS NOT NULL THEN
13960   INTO xla_ae_header_acs (
13961         ae_header_id , object_version_number
13962       , analytical_criterion_code
13963       , analytical_criterion_type_code
13964       , amb_context_code
13965       , ac1,ac2,ac3,ac4,ac5)
13966 VALUES (ae_header_id, C_OVN
13967 ,SUBSTRB(anc_id_34
13968        ,1
13969        ,INSTRB(anc_id_34,'(]',1,1) -1)
13970 ,SUBSTRB(anc_id_34
13971        ,INSTRB(anc_id_34,'(]',1,1) + 2
13972        ,INSTRB(anc_id_34,'(]',1,2) -
13973         INSTRB(anc_id_34,'(]',1,1) - 2)
13974 ,SUBSTRB(anc_id_34
13975        ,INSTRB(anc_id_34,'(]',1,2) + 2
13976        ,INSTRB(anc_id_34,'(]',1,3) -
13977         INSTRB(anc_id_34,'(]',1,2) - 2)
13978 ,SUBSTRB(anc_id_34
13979        ,INSTRB(anc_id_34,'(]',1,3) + 2
13980        ,INSTRB(anc_id_34,'(]',1,4) -
13981         INSTRB(anc_id_34,'(]',1,3) - 2)
13982 ,SUBSTRB(anc_id_34
13983        ,INSTRB(anc_id_34,'(]',1,4) + 2
13984        ,INSTRB(anc_id_34,'(]',1,5) -
13985         INSTRB(anc_id_34,'(]',1,4) - 2)
13986 ,SUBSTRB(anc_id_34
13987        ,INSTRB(anc_id_34,'(]',1,5) + 2
13988        ,INSTRB(anc_id_34,'(]',1,6) -
13989         INSTRB(anc_id_34,'(]',1,5) - 2)
13990 ,SUBSTRB(anc_id_34
13991        ,INSTRB(anc_id_34,'(]',1,6) + 2
13992        ,INSTRB(anc_id_34,'(]',1,7) -
13993         INSTRB(anc_id_34,'(]',1,6) - 2)
13994 ,SUBSTRB(anc_id_34
13995        ,INSTRB(anc_id_34,'(]',1,7) + 2
13996        ,LENGTHB(anc_id_34))
13997 )
13998 
13999 WHEN anc_id_35 IS NOT NULL THEN
14000   INTO xla_ae_header_acs (
14001         ae_header_id , object_version_number
14002       , analytical_criterion_code
14003       , analytical_criterion_type_code
14004       , amb_context_code
14005       , ac1,ac2,ac3,ac4,ac5)
14006 VALUES (ae_header_id, C_OVN
14007 ,SUBSTRB(anc_id_35
14008        ,1
14009        ,INSTRB(anc_id_35,'(]',1,1) -1)
14010 ,SUBSTRB(anc_id_35
14011        ,INSTRB(anc_id_35,'(]',1,1) + 2
14012        ,INSTRB(anc_id_35,'(]',1,2) -
14013         INSTRB(anc_id_35,'(]',1,1) - 2)
14014 ,SUBSTRB(anc_id_35
14015        ,INSTRB(anc_id_35,'(]',1,2) + 2
14016        ,INSTRB(anc_id_35,'(]',1,3) -
14017         INSTRB(anc_id_35,'(]',1,2) - 2)
14018 ,SUBSTRB(anc_id_35
14019        ,INSTRB(anc_id_35,'(]',1,3) + 2
14020        ,INSTRB(anc_id_35,'(]',1,4) -
14021         INSTRB(anc_id_35,'(]',1,3) - 2)
14022 ,SUBSTRB(anc_id_35
14023        ,INSTRB(anc_id_35,'(]',1,4) + 2
14024        ,INSTRB(anc_id_35,'(]',1,5) -
14025         INSTRB(anc_id_35,'(]',1,4) - 2)
14026 ,SUBSTRB(anc_id_35
14027        ,INSTRB(anc_id_35,'(]',1,5) + 2
14028        ,INSTRB(anc_id_35,'(]',1,6) -
14029         INSTRB(anc_id_35,'(]',1,5) - 2)
14030 ,SUBSTRB(anc_id_35
14031        ,INSTRB(anc_id_35,'(]',1,6) + 2
14032        ,INSTRB(anc_id_35,'(]',1,7) -
14033         INSTRB(anc_id_35,'(]',1,6) - 2)
14034 ,SUBSTRB(anc_id_35
14035        ,INSTRB(anc_id_35,'(]',1,7) + 2
14036        ,LENGTHB(anc_id_35))
14037 )
14038 
14039 WHEN anc_id_36 IS NOT NULL THEN
14040   INTO xla_ae_header_acs (
14041         ae_header_id , object_version_number
14042       , analytical_criterion_code
14043       , analytical_criterion_type_code
14044       , amb_context_code
14045       , ac1,ac2,ac3,ac4,ac5)
14046 VALUES (ae_header_id, C_OVN
14047 ,SUBSTRB(anc_id_36
14048        ,1
14049        ,INSTRB(anc_id_36,'(]',1,1) -1)
14050 ,SUBSTRB(anc_id_36
14051        ,INSTRB(anc_id_36,'(]',1,1) + 2
14052        ,INSTRB(anc_id_36,'(]',1,2) -
14053         INSTRB(anc_id_36,'(]',1,1) - 2)
14054 ,SUBSTRB(anc_id_36
14055        ,INSTRB(anc_id_36,'(]',1,2) + 2
14056        ,INSTRB(anc_id_36,'(]',1,3) -
14057         INSTRB(anc_id_36,'(]',1,2) - 2)
14058 ,SUBSTRB(anc_id_36
14059        ,INSTRB(anc_id_36,'(]',1,3) + 2
14060        ,INSTRB(anc_id_36,'(]',1,4) -
14061         INSTRB(anc_id_36,'(]',1,3) - 2)
14062 ,SUBSTRB(anc_id_36
14063        ,INSTRB(anc_id_36,'(]',1,4) + 2
14064        ,INSTRB(anc_id_36,'(]',1,5) -
14065         INSTRB(anc_id_36,'(]',1,4) - 2)
14066 ,SUBSTRB(anc_id_36
14067        ,INSTRB(anc_id_36,'(]',1,5) + 2
14068        ,INSTRB(anc_id_36,'(]',1,6) -
14069         INSTRB(anc_id_36,'(]',1,5) - 2)
14070 ,SUBSTRB(anc_id_36
14071        ,INSTRB(anc_id_36,'(]',1,6) + 2
14072        ,INSTRB(anc_id_36,'(]',1,7) -
14073         INSTRB(anc_id_36,'(]',1,6) - 2)
14074 ,SUBSTRB(anc_id_36
14075        ,INSTRB(anc_id_36,'(]',1,7) + 2
14076        ,LENGTHB(anc_id_36))
14077 )
14078 
14079 WHEN anc_id_37 IS NOT NULL THEN
14080   INTO xla_ae_header_acs (
14081         ae_header_id , object_version_number
14082       , analytical_criterion_code
14083       , analytical_criterion_type_code
14084       , amb_context_code
14085       , ac1,ac2,ac3,ac4,ac5)
14086 VALUES (ae_header_id, C_OVN
14087 ,SUBSTRB(anc_id_37
14088        ,1
14089        ,INSTRB(anc_id_37,'(]',1,1) -1)
14090 ,SUBSTRB(anc_id_37
14091        ,INSTRB(anc_id_37,'(]',1,1) + 2
14092        ,INSTRB(anc_id_37,'(]',1,2) -
14093         INSTRB(anc_id_37,'(]',1,1) - 2)
14094 ,SUBSTRB(anc_id_37
14095        ,INSTRB(anc_id_37,'(]',1,2) + 2
14096        ,INSTRB(anc_id_37,'(]',1,3) -
14097         INSTRB(anc_id_37,'(]',1,2) - 2)
14098 ,SUBSTRB(anc_id_37
14099        ,INSTRB(anc_id_37,'(]',1,3) + 2
14100        ,INSTRB(anc_id_37,'(]',1,4) -
14101         INSTRB(anc_id_37,'(]',1,3) - 2)
14102 ,SUBSTRB(anc_id_37
14103        ,INSTRB(anc_id_37,'(]',1,4) + 2
14104        ,INSTRB(anc_id_37,'(]',1,5) -
14105         INSTRB(anc_id_37,'(]',1,4) - 2)
14106 ,SUBSTRB(anc_id_37
14107        ,INSTRB(anc_id_37,'(]',1,5) + 2
14108        ,INSTRB(anc_id_37,'(]',1,6) -
14109         INSTRB(anc_id_37,'(]',1,5) - 2)
14110 ,SUBSTRB(anc_id_37
14111        ,INSTRB(anc_id_37,'(]',1,6) + 2
14112        ,INSTRB(anc_id_37,'(]',1,7) -
14113         INSTRB(anc_id_37,'(]',1,6) - 2)
14114 ,SUBSTRB(anc_id_37
14115        ,INSTRB(anc_id_37,'(]',1,7) + 2
14116        ,LENGTHB(anc_id_37))
14117 )
14118 
14119 WHEN anc_id_38 IS NOT NULL THEN
14120   INTO xla_ae_header_acs (
14121         ae_header_id , object_version_number
14122       , analytical_criterion_code
14123       , analytical_criterion_type_code
14124       , amb_context_code
14125       , ac1,ac2,ac3,ac4,ac5)
14126 VALUES (ae_header_id, C_OVN
14127 ,SUBSTRB(anc_id_38
14128        ,1
14129        ,INSTRB(anc_id_38,'(]',1,1) -1)
14130 ,SUBSTRB(anc_id_38
14131        ,INSTRB(anc_id_38,'(]',1,1) + 2
14132        ,INSTRB(anc_id_38,'(]',1,2) -
14133         INSTRB(anc_id_38,'(]',1,1) - 2)
14134 ,SUBSTRB(anc_id_38
14135        ,INSTRB(anc_id_38,'(]',1,2) + 2
14136        ,INSTRB(anc_id_38,'(]',1,3) -
14137         INSTRB(anc_id_38,'(]',1,2) - 2)
14138 ,SUBSTRB(anc_id_38
14139        ,INSTRB(anc_id_38,'(]',1,3) + 2
14140        ,INSTRB(anc_id_38,'(]',1,4) -
14141         INSTRB(anc_id_38,'(]',1,3) - 2)
14142 ,SUBSTRB(anc_id_38
14143        ,INSTRB(anc_id_38,'(]',1,4) + 2
14144        ,INSTRB(anc_id_38,'(]',1,5) -
14145         INSTRB(anc_id_38,'(]',1,4) - 2)
14146 ,SUBSTRB(anc_id_38
14147        ,INSTRB(anc_id_38,'(]',1,5) + 2
14148        ,INSTRB(anc_id_38,'(]',1,6) -
14149         INSTRB(anc_id_38,'(]',1,5) - 2)
14150 ,SUBSTRB(anc_id_38
14151        ,INSTRB(anc_id_38,'(]',1,6) + 2
14152        ,INSTRB(anc_id_38,'(]',1,7) -
14153         INSTRB(anc_id_38,'(]',1,6) - 2)
14154 ,SUBSTRB(anc_id_38
14155        ,INSTRB(anc_id_38,'(]',1,7) + 2
14156        ,LENGTHB(anc_id_38))
14157 )
14158 
14159 WHEN anc_id_39 IS NOT NULL THEN
14160   INTO xla_ae_header_acs (
14161         ae_header_id , object_version_number
14162       , analytical_criterion_code
14163       , analytical_criterion_type_code
14164       , amb_context_code
14165       , ac1,ac2,ac3,ac4,ac5)
14166 VALUES (ae_header_id, C_OVN
14167 ,SUBSTRB(anc_id_39
14168        ,1
14169        ,INSTRB(anc_id_39,'(]',1,1) -1)
14170 ,SUBSTRB(anc_id_39
14171        ,INSTRB(anc_id_39,'(]',1,1) + 2
14172        ,INSTRB(anc_id_39,'(]',1,2) -
14173         INSTRB(anc_id_39,'(]',1,1) - 2)
14174 ,SUBSTRB(anc_id_39
14175        ,INSTRB(anc_id_39,'(]',1,2) + 2
14176        ,INSTRB(anc_id_39,'(]',1,3) -
14177         INSTRB(anc_id_39,'(]',1,2) - 2)
14178 ,SUBSTRB(anc_id_39
14179        ,INSTRB(anc_id_39,'(]',1,3) + 2
14180        ,INSTRB(anc_id_39,'(]',1,4) -
14181         INSTRB(anc_id_39,'(]',1,3) - 2)
14182 ,SUBSTRB(anc_id_39
14183        ,INSTRB(anc_id_39,'(]',1,4) + 2
14184        ,INSTRB(anc_id_39,'(]',1,5) -
14185         INSTRB(anc_id_39,'(]',1,4) - 2)
14186 ,SUBSTRB(anc_id_39
14187        ,INSTRB(anc_id_39,'(]',1,5) + 2
14188        ,INSTRB(anc_id_39,'(]',1,6) -
14189         INSTRB(anc_id_39,'(]',1,5) - 2)
14190 ,SUBSTRB(anc_id_39
14191        ,INSTRB(anc_id_39,'(]',1,6) + 2
14192        ,INSTRB(anc_id_39,'(]',1,7) -
14193         INSTRB(anc_id_39,'(]',1,6) - 2)
14194 ,SUBSTRB(anc_id_39
14195        ,INSTRB(anc_id_39,'(]',1,7) + 2
14196        ,LENGTHB(anc_id_39))
14197 )
14198 
14199 WHEN anc_id_40 IS NOT NULL THEN
14200   INTO xla_ae_header_acs (
14201         ae_header_id , object_version_number
14202       , analytical_criterion_code
14203       , analytical_criterion_type_code
14204       , amb_context_code
14205       , ac1,ac2,ac3,ac4,ac5)
14206 VALUES (ae_header_id, C_OVN
14207 ,SUBSTRB(anc_id_40
14208        ,1
14209        ,INSTRB(anc_id_40,'(]',1,1) -1)
14210 ,SUBSTRB(anc_id_40
14211        ,INSTRB(anc_id_40,'(]',1,1) + 2
14212        ,INSTRB(anc_id_40,'(]',1,2) -
14213         INSTRB(anc_id_40,'(]',1,1) - 2)
14214 ,SUBSTRB(anc_id_40
14215        ,INSTRB(anc_id_40,'(]',1,2) + 2
14216        ,INSTRB(anc_id_40,'(]',1,3) -
14217         INSTRB(anc_id_40,'(]',1,2) - 2)
14218 ,SUBSTRB(anc_id_40
14219        ,INSTRB(anc_id_40,'(]',1,3) + 2
14220        ,INSTRB(anc_id_40,'(]',1,4) -
14221         INSTRB(anc_id_40,'(]',1,3) - 2)
14222 ,SUBSTRB(anc_id_40
14223        ,INSTRB(anc_id_40,'(]',1,4) + 2
14224        ,INSTRB(anc_id_40,'(]',1,5) -
14225         INSTRB(anc_id_40,'(]',1,4) - 2)
14226 ,SUBSTRB(anc_id_40
14227        ,INSTRB(anc_id_40,'(]',1,5) + 2
14228        ,INSTRB(anc_id_40,'(]',1,6) -
14229         INSTRB(anc_id_40,'(]',1,5) - 2)
14230 ,SUBSTRB(anc_id_40
14231        ,INSTRB(anc_id_40,'(]',1,6) + 2
14232        ,INSTRB(anc_id_40,'(]',1,7) -
14233         INSTRB(anc_id_40,'(]',1,6) - 2)
14234 ,SUBSTRB(anc_id_40
14235        ,INSTRB(anc_id_40,'(]',1,7) + 2
14236        ,LENGTHB(anc_id_40))
14237 )
14238 
14239 WHEN anc_id_41 IS NOT NULL THEN
14240   INTO xla_ae_header_acs (
14241         ae_header_id , object_version_number
14242       , analytical_criterion_code
14243       , analytical_criterion_type_code
14244       , amb_context_code
14245       , ac1,ac2,ac3,ac4,ac5)
14246 VALUES (ae_header_id, C_OVN
14247 ,SUBSTRB(anc_id_41
14248        ,1
14249        ,INSTRB(anc_id_41,'(]',1,1) -1)
14250 ,SUBSTRB(anc_id_41
14251        ,INSTRB(anc_id_41,'(]',1,1) + 2
14252        ,INSTRB(anc_id_41,'(]',1,2) -
14253         INSTRB(anc_id_41,'(]',1,1) - 2)
14254 ,SUBSTRB(anc_id_41
14255        ,INSTRB(anc_id_41,'(]',1,2) + 2
14256        ,INSTRB(anc_id_41,'(]',1,3) -
14257         INSTRB(anc_id_41,'(]',1,2) - 2)
14258 ,SUBSTRB(anc_id_41
14259        ,INSTRB(anc_id_41,'(]',1,3) + 2
14260        ,INSTRB(anc_id_41,'(]',1,4) -
14261         INSTRB(anc_id_41,'(]',1,3) - 2)
14262 ,SUBSTRB(anc_id_41
14263        ,INSTRB(anc_id_41,'(]',1,4) + 2
14264        ,INSTRB(anc_id_41,'(]',1,5) -
14265         INSTRB(anc_id_41,'(]',1,4) - 2)
14266 ,SUBSTRB(anc_id_41
14267        ,INSTRB(anc_id_41,'(]',1,5) + 2
14268        ,INSTRB(anc_id_41,'(]',1,6) -
14269         INSTRB(anc_id_41,'(]',1,5) - 2)
14270 ,SUBSTRB(anc_id_41
14271        ,INSTRB(anc_id_41,'(]',1,6) + 2
14272        ,INSTRB(anc_id_41,'(]',1,7) -
14273         INSTRB(anc_id_41,'(]',1,6) - 2)
14274 ,SUBSTRB(anc_id_41
14275        ,INSTRB(anc_id_41,'(]',1,7) + 2
14276        ,LENGTHB(anc_id_41))
14277 )
14278 
14279 WHEN anc_id_42 IS NOT NULL THEN
14280   INTO xla_ae_header_acs (
14281         ae_header_id , object_version_number
14282       , analytical_criterion_code
14283       , analytical_criterion_type_code
14284       , amb_context_code
14285       , ac1,ac2,ac3,ac4,ac5)
14286 VALUES (ae_header_id, C_OVN
14287 ,SUBSTRB(anc_id_42
14288        ,1
14289        ,INSTRB(anc_id_42,'(]',1,1) -1)
14290 ,SUBSTRB(anc_id_42
14291        ,INSTRB(anc_id_42,'(]',1,1) + 2
14292        ,INSTRB(anc_id_42,'(]',1,2) -
14293         INSTRB(anc_id_42,'(]',1,1) - 2)
14294 ,SUBSTRB(anc_id_42
14295        ,INSTRB(anc_id_42,'(]',1,2) + 2
14296        ,INSTRB(anc_id_42,'(]',1,3) -
14297         INSTRB(anc_id_42,'(]',1,2) - 2)
14298 ,SUBSTRB(anc_id_42
14299        ,INSTRB(anc_id_42,'(]',1,3) + 2
14300        ,INSTRB(anc_id_42,'(]',1,4) -
14301         INSTRB(anc_id_42,'(]',1,3) - 2)
14302 ,SUBSTRB(anc_id_42
14303        ,INSTRB(anc_id_42,'(]',1,4) + 2
14304        ,INSTRB(anc_id_42,'(]',1,5) -
14305         INSTRB(anc_id_42,'(]',1,4) - 2)
14306 ,SUBSTRB(anc_id_42
14307        ,INSTRB(anc_id_42,'(]',1,5) + 2
14308        ,INSTRB(anc_id_42,'(]',1,6) -
14309         INSTRB(anc_id_42,'(]',1,5) - 2)
14310 ,SUBSTRB(anc_id_42
14311        ,INSTRB(anc_id_42,'(]',1,6) + 2
14312        ,INSTRB(anc_id_42,'(]',1,7) -
14313         INSTRB(anc_id_42,'(]',1,6) - 2)
14314 ,SUBSTRB(anc_id_42
14315        ,INSTRB(anc_id_42,'(]',1,7) + 2
14316        ,LENGTHB(anc_id_42))
14317 )
14318 
14319 WHEN anc_id_43 IS NOT NULL THEN
14320   INTO xla_ae_header_acs (
14321         ae_header_id , object_version_number
14322       , analytical_criterion_code
14323       , analytical_criterion_type_code
14324       , amb_context_code
14325       , ac1,ac2,ac3,ac4,ac5)
14326 VALUES (ae_header_id, C_OVN
14327 ,SUBSTRB(anc_id_43
14328        ,1
14329        ,INSTRB(anc_id_43,'(]',1,1) -1)
14330 ,SUBSTRB(anc_id_43
14331        ,INSTRB(anc_id_43,'(]',1,1) + 2
14332        ,INSTRB(anc_id_43,'(]',1,2) -
14333         INSTRB(anc_id_43,'(]',1,1) - 2)
14334 ,SUBSTRB(anc_id_43
14335        ,INSTRB(anc_id_43,'(]',1,2) + 2
14336        ,INSTRB(anc_id_43,'(]',1,3) -
14337         INSTRB(anc_id_43,'(]',1,2) - 2)
14338 ,SUBSTRB(anc_id_43
14339        ,INSTRB(anc_id_43,'(]',1,3) + 2
14340        ,INSTRB(anc_id_43,'(]',1,4) -
14341         INSTRB(anc_id_43,'(]',1,3) - 2)
14342 ,SUBSTRB(anc_id_43
14343        ,INSTRB(anc_id_43,'(]',1,4) + 2
14344        ,INSTRB(anc_id_43,'(]',1,5) -
14345         INSTRB(anc_id_43,'(]',1,4) - 2)
14346 ,SUBSTRB(anc_id_43
14347        ,INSTRB(anc_id_43,'(]',1,5) + 2
14348        ,INSTRB(anc_id_43,'(]',1,6) -
14349         INSTRB(anc_id_43,'(]',1,5) - 2)
14350 ,SUBSTRB(anc_id_43
14351        ,INSTRB(anc_id_43,'(]',1,6) + 2
14352        ,INSTRB(anc_id_43,'(]',1,7) -
14353         INSTRB(anc_id_43,'(]',1,6) - 2)
14354 ,SUBSTRB(anc_id_43
14355        ,INSTRB(anc_id_43,'(]',1,7) + 2
14356        ,LENGTHB(anc_id_43))
14357 )
14358 
14359 WHEN anc_id_44 IS NOT NULL THEN
14360   INTO xla_ae_header_acs (
14361         ae_header_id , object_version_number
14362       , analytical_criterion_code
14363       , analytical_criterion_type_code
14364       , amb_context_code
14365       , ac1,ac2,ac3,ac4,ac5)
14366 VALUES (ae_header_id, C_OVN
14367 ,SUBSTRB(anc_id_44
14368        ,1
14369        ,INSTRB(anc_id_44,'(]',1,1) -1)
14370 ,SUBSTRB(anc_id_44
14371        ,INSTRB(anc_id_44,'(]',1,1) + 2
14372        ,INSTRB(anc_id_44,'(]',1,2) -
14373         INSTRB(anc_id_44,'(]',1,1) - 2)
14374 ,SUBSTRB(anc_id_44
14375        ,INSTRB(anc_id_44,'(]',1,2) + 2
14376        ,INSTRB(anc_id_44,'(]',1,3) -
14377         INSTRB(anc_id_44,'(]',1,2) - 2)
14378 ,SUBSTRB(anc_id_44
14379        ,INSTRB(anc_id_44,'(]',1,3) + 2
14380        ,INSTRB(anc_id_44,'(]',1,4) -
14381         INSTRB(anc_id_44,'(]',1,3) - 2)
14382 ,SUBSTRB(anc_id_44
14383        ,INSTRB(anc_id_44,'(]',1,4) + 2
14384        ,INSTRB(anc_id_44,'(]',1,5) -
14385         INSTRB(anc_id_44,'(]',1,4) - 2)
14386 ,SUBSTRB(anc_id_44
14387        ,INSTRB(anc_id_44,'(]',1,5) + 2
14388        ,INSTRB(anc_id_44,'(]',1,6) -
14389         INSTRB(anc_id_44,'(]',1,5) - 2)
14390 ,SUBSTRB(anc_id_44
14391        ,INSTRB(anc_id_44,'(]',1,6) + 2
14392        ,INSTRB(anc_id_44,'(]',1,7) -
14393         INSTRB(anc_id_44,'(]',1,6) - 2)
14394 ,SUBSTRB(anc_id_44
14395        ,INSTRB(anc_id_44,'(]',1,7) + 2
14396        ,LENGTHB(anc_id_44))
14397 )
14398 
14399 WHEN anc_id_45 IS NOT NULL THEN
14400   INTO xla_ae_header_acs (
14401         ae_header_id , object_version_number
14402       , analytical_criterion_code
14403       , analytical_criterion_type_code
14404       , amb_context_code
14405       , ac1,ac2,ac3,ac4,ac5)
14406 VALUES (ae_header_id, C_OVN
14407 ,SUBSTRB(anc_id_45
14408        ,1
14409        ,INSTRB(anc_id_45,'(]',1,1) -1)
14410 ,SUBSTRB(anc_id_45
14411        ,INSTRB(anc_id_45,'(]',1,1) + 2
14412        ,INSTRB(anc_id_45,'(]',1,2) -
14413         INSTRB(anc_id_45,'(]',1,1) - 2)
14414 ,SUBSTRB(anc_id_45
14415        ,INSTRB(anc_id_45,'(]',1,2) + 2
14416        ,INSTRB(anc_id_45,'(]',1,3) -
14417         INSTRB(anc_id_45,'(]',1,2) - 2)
14418 ,SUBSTRB(anc_id_45
14419        ,INSTRB(anc_id_45,'(]',1,3) + 2
14420        ,INSTRB(anc_id_45,'(]',1,4) -
14421         INSTRB(anc_id_45,'(]',1,3) - 2)
14422 ,SUBSTRB(anc_id_45
14423        ,INSTRB(anc_id_45,'(]',1,4) + 2
14424        ,INSTRB(anc_id_45,'(]',1,5) -
14425         INSTRB(anc_id_45,'(]',1,4) - 2)
14426 ,SUBSTRB(anc_id_45
14427        ,INSTRB(anc_id_45,'(]',1,5) + 2
14428        ,INSTRB(anc_id_45,'(]',1,6) -
14429         INSTRB(anc_id_45,'(]',1,5) - 2)
14430 ,SUBSTRB(anc_id_45
14431        ,INSTRB(anc_id_45,'(]',1,6) + 2
14432        ,INSTRB(anc_id_45,'(]',1,7) -
14433         INSTRB(anc_id_45,'(]',1,6) - 2)
14434 ,SUBSTRB(anc_id_45
14435        ,INSTRB(anc_id_45,'(]',1,7) + 2
14436        ,LENGTHB(anc_id_45))
14437 )
14438 
14439 WHEN anc_id_46 IS NOT NULL THEN
14440   INTO xla_ae_header_acs (
14441         ae_header_id , object_version_number
14442       , analytical_criterion_code
14443       , analytical_criterion_type_code
14444       , amb_context_code
14445       , ac1,ac2,ac3,ac4,ac5)
14446 VALUES (ae_header_id, C_OVN
14447 ,SUBSTRB(anc_id_46
14448        ,1
14449        ,INSTRB(anc_id_46,'(]',1,1) -1)
14450 ,SUBSTRB(anc_id_46
14451        ,INSTRB(anc_id_46,'(]',1,1) + 2
14452        ,INSTRB(anc_id_46,'(]',1,2) -
14453         INSTRB(anc_id_46,'(]',1,1) - 2)
14454 ,SUBSTRB(anc_id_46
14455        ,INSTRB(anc_id_46,'(]',1,2) + 2
14456        ,INSTRB(anc_id_46,'(]',1,3) -
14457         INSTRB(anc_id_46,'(]',1,2) - 2)
14458 ,SUBSTRB(anc_id_46
14459        ,INSTRB(anc_id_46,'(]',1,3) + 2
14460        ,INSTRB(anc_id_46,'(]',1,4) -
14461         INSTRB(anc_id_46,'(]',1,3) - 2)
14462 ,SUBSTRB(anc_id_46
14463        ,INSTRB(anc_id_46,'(]',1,4) + 2
14464        ,INSTRB(anc_id_46,'(]',1,5) -
14465         INSTRB(anc_id_46,'(]',1,4) - 2)
14466 ,SUBSTRB(anc_id_46
14467        ,INSTRB(anc_id_46,'(]',1,5) + 2
14468        ,INSTRB(anc_id_46,'(]',1,6) -
14469         INSTRB(anc_id_46,'(]',1,5) - 2)
14470 ,SUBSTRB(anc_id_46
14471        ,INSTRB(anc_id_46,'(]',1,6) + 2
14472        ,INSTRB(anc_id_46,'(]',1,7) -
14473         INSTRB(anc_id_46,'(]',1,6) - 2)
14474 ,SUBSTRB(anc_id_46
14475        ,INSTRB(anc_id_46,'(]',1,7) + 2
14476        ,LENGTHB(anc_id_46))
14477 )
14478 
14479 WHEN anc_id_47 IS NOT NULL THEN
14480   INTO xla_ae_header_acs (
14481         ae_header_id , object_version_number
14482       , analytical_criterion_code
14483       , analytical_criterion_type_code
14484       , amb_context_code
14485       , ac1,ac2,ac3,ac4,ac5)
14486 VALUES (ae_header_id, C_OVN
14487 ,SUBSTRB(anc_id_47
14488        ,1
14489        ,INSTRB(anc_id_47,'(]',1,1) -1)
14490 ,SUBSTRB(anc_id_47
14491        ,INSTRB(anc_id_47,'(]',1,1) + 2
14492        ,INSTRB(anc_id_47,'(]',1,2) -
14493         INSTRB(anc_id_47,'(]',1,1) - 2)
14494 ,SUBSTRB(anc_id_47
14495        ,INSTRB(anc_id_47,'(]',1,2) + 2
14496        ,INSTRB(anc_id_47,'(]',1,3) -
14497         INSTRB(anc_id_47,'(]',1,2) - 2)
14498 ,SUBSTRB(anc_id_47
14499        ,INSTRB(anc_id_47,'(]',1,3) + 2
14500        ,INSTRB(anc_id_47,'(]',1,4) -
14501         INSTRB(anc_id_47,'(]',1,3) - 2)
14502 ,SUBSTRB(anc_id_47
14503        ,INSTRB(anc_id_47,'(]',1,4) + 2
14504        ,INSTRB(anc_id_47,'(]',1,5) -
14505         INSTRB(anc_id_47,'(]',1,4) - 2)
14506 ,SUBSTRB(anc_id_47
14507        ,INSTRB(anc_id_47,'(]',1,5) + 2
14508        ,INSTRB(anc_id_47,'(]',1,6) -
14509         INSTRB(anc_id_47,'(]',1,5) - 2)
14510 ,SUBSTRB(anc_id_47
14511        ,INSTRB(anc_id_47,'(]',1,6) + 2
14512        ,INSTRB(anc_id_47,'(]',1,7) -
14513         INSTRB(anc_id_47,'(]',1,6) - 2)
14514 ,SUBSTRB(anc_id_47
14515        ,INSTRB(anc_id_47,'(]',1,7) + 2
14516        ,LENGTHB(anc_id_47))
14517 )
14518 
14519 WHEN anc_id_48 IS NOT NULL THEN
14520   INTO xla_ae_header_acs (
14521         ae_header_id , object_version_number
14522       , analytical_criterion_code
14523       , analytical_criterion_type_code
14524       , amb_context_code
14525       , ac1,ac2,ac3,ac4,ac5)
14526 VALUES (ae_header_id, C_OVN
14527 ,SUBSTRB(anc_id_48
14528        ,1
14529        ,INSTRB(anc_id_48,'(]',1,1) -1)
14530 ,SUBSTRB(anc_id_48
14531        ,INSTRB(anc_id_48,'(]',1,1) + 2
14532        ,INSTRB(anc_id_48,'(]',1,2) -
14533         INSTRB(anc_id_48,'(]',1,1) - 2)
14534 ,SUBSTRB(anc_id_48
14535        ,INSTRB(anc_id_48,'(]',1,2) + 2
14536        ,INSTRB(anc_id_48,'(]',1,3) -
14537         INSTRB(anc_id_48,'(]',1,2) - 2)
14538 ,SUBSTRB(anc_id_48
14539        ,INSTRB(anc_id_48,'(]',1,3) + 2
14540        ,INSTRB(anc_id_48,'(]',1,4) -
14541         INSTRB(anc_id_48,'(]',1,3) - 2)
14542 ,SUBSTRB(anc_id_48
14543        ,INSTRB(anc_id_48,'(]',1,4) + 2
14544        ,INSTRB(anc_id_48,'(]',1,5) -
14545         INSTRB(anc_id_48,'(]',1,4) - 2)
14546 ,SUBSTRB(anc_id_48
14547        ,INSTRB(anc_id_48,'(]',1,5) + 2
14548        ,INSTRB(anc_id_48,'(]',1,6) -
14549         INSTRB(anc_id_48,'(]',1,5) - 2)
14550 ,SUBSTRB(anc_id_48
14551        ,INSTRB(anc_id_48,'(]',1,6) + 2
14552        ,INSTRB(anc_id_48,'(]',1,7) -
14553         INSTRB(anc_id_48,'(]',1,6) - 2)
14554 ,SUBSTRB(anc_id_48
14555        ,INSTRB(anc_id_48,'(]',1,7) + 2
14556        ,LENGTHB(anc_id_48))
14557 )
14558 
14559 WHEN anc_id_49 IS NOT NULL THEN
14560   INTO xla_ae_header_acs (
14561         ae_header_id , object_version_number
14562       , analytical_criterion_code
14563       , analytical_criterion_type_code
14564       , amb_context_code
14565       , ac1,ac2,ac3,ac4,ac5)
14566 VALUES (ae_header_id, C_OVN
14567 ,SUBSTRB(anc_id_49
14568        ,1
14569        ,INSTRB(anc_id_49,'(]',1,1) -1)
14570 ,SUBSTRB(anc_id_49
14571        ,INSTRB(anc_id_49,'(]',1,1) + 2
14572        ,INSTRB(anc_id_49,'(]',1,2) -
14573         INSTRB(anc_id_49,'(]',1,1) - 2)
14574 ,SUBSTRB(anc_id_49
14575        ,INSTRB(anc_id_49,'(]',1,2) + 2
14576        ,INSTRB(anc_id_49,'(]',1,3) -
14577         INSTRB(anc_id_49,'(]',1,2) - 2)
14578 ,SUBSTRB(anc_id_49
14579        ,INSTRB(anc_id_49,'(]',1,3) + 2
14580        ,INSTRB(anc_id_49,'(]',1,4) -
14581         INSTRB(anc_id_49,'(]',1,3) - 2)
14582 ,SUBSTRB(anc_id_49
14583        ,INSTRB(anc_id_49,'(]',1,4) + 2
14584        ,INSTRB(anc_id_49,'(]',1,5) -
14585         INSTRB(anc_id_49,'(]',1,4) - 2)
14586 ,SUBSTRB(anc_id_49
14587        ,INSTRB(anc_id_49,'(]',1,5) + 2
14588        ,INSTRB(anc_id_49,'(]',1,6) -
14589         INSTRB(anc_id_49,'(]',1,5) - 2)
14590 ,SUBSTRB(anc_id_49
14591        ,INSTRB(anc_id_49,'(]',1,6) + 2
14592        ,INSTRB(anc_id_49,'(]',1,7) -
14593         INSTRB(anc_id_49,'(]',1,6) - 2)
14594 ,SUBSTRB(anc_id_49
14595        ,INSTRB(anc_id_49,'(]',1,7) + 2
14596        ,LENGTHB(anc_id_49))
14597 )
14598 
14599 WHEN anc_id_50 IS NOT NULL THEN
14600   INTO xla_ae_header_acs (
14601         ae_header_id , object_version_number
14602       , analytical_criterion_code
14603       , analytical_criterion_type_code
14604       , amb_context_code
14605       , ac1,ac2,ac3,ac4,ac5)
14606 VALUES (ae_header_id, C_OVN
14607 ,SUBSTRB(anc_id_50
14608        ,1
14609        ,INSTRB(anc_id_50,'(]',1,1) -1)
14610 ,SUBSTRB(anc_id_50
14611        ,INSTRB(anc_id_50,'(]',1,1) + 2
14612        ,INSTRB(anc_id_50,'(]',1,2) -
14613         INSTRB(anc_id_50,'(]',1,1) - 2)
14614 ,SUBSTRB(anc_id_50
14615        ,INSTRB(anc_id_50,'(]',1,2) + 2
14616        ,INSTRB(anc_id_50,'(]',1,3) -
14617         INSTRB(anc_id_50,'(]',1,2) - 2)
14618 ,SUBSTRB(anc_id_50
14619        ,INSTRB(anc_id_50,'(]',1,3) + 2
14620        ,INSTRB(anc_id_50,'(]',1,4) -
14621         INSTRB(anc_id_50,'(]',1,3) - 2)
14622 ,SUBSTRB(anc_id_50
14623        ,INSTRB(anc_id_50,'(]',1,4) + 2
14624        ,INSTRB(anc_id_50,'(]',1,5) -
14625         INSTRB(anc_id_50,'(]',1,4) - 2)
14626 ,SUBSTRB(anc_id_50
14627        ,INSTRB(anc_id_50,'(]',1,5) + 2
14628        ,INSTRB(anc_id_50,'(]',1,6) -
14629         INSTRB(anc_id_50,'(]',1,5) - 2)
14630 ,SUBSTRB(anc_id_50
14631        ,INSTRB(anc_id_50,'(]',1,6) + 2
14632        ,INSTRB(anc_id_50,'(]',1,7) -
14633         INSTRB(anc_id_50,'(]',1,6) - 2)
14634 ,SUBSTRB(anc_id_50
14635        ,INSTRB(anc_id_50,'(]',1,7) + 2
14636        ,LENGTHB(anc_id_50))
14637 )
14638 
14639 SELECT  ae_header_id
14640       , anc_id_1
14641       , anc_id_2
14642       , anc_id_3
14643       , anc_id_4
14644       , anc_id_5
14645       , anc_id_6
14646       , anc_id_7
14647       , anc_id_8
14648       , anc_id_9
14649       , anc_id_10
14650       , anc_id_11
14651       , anc_id_12
14652       , anc_id_13
14653       , anc_id_14
14654       , anc_id_15
14655       , anc_id_16
14656       , anc_id_17
14657       , anc_id_18
14658       , anc_id_19
14659       , anc_id_20
14660       , anc_id_21
14661       , anc_id_22
14662       , anc_id_23
14663       , anc_id_24
14664       , anc_id_25
14665       , anc_id_26
14666       , anc_id_27
14667       , anc_id_28
14668       , anc_id_29
14669       , anc_id_30
14670       , anc_id_31
14671       , anc_id_32
14672       , anc_id_33
14673       , anc_id_34
14674       , anc_id_35
14675       , anc_id_36
14676       , anc_id_37
14677       , anc_id_38
14678       , anc_id_39
14679       , anc_id_40
14680       , anc_id_41
14681       , anc_id_42
14682       , anc_id_43
14683       , anc_id_44
14684       , anc_id_45
14685       , anc_id_46
14686       , anc_id_47
14687       , anc_id_48
14688       , anc_id_49
14689       , anc_id_50
14690  FROM  xla_ae_headers_gt
14691 WHERE  ae_header_id is not null;
14692 
14693 --
14694 IF (C_LEVEL_EVENT >= g_log_level) THEN
14695       trace
14696          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
14697          ,p_level    => C_LEVEL_EVENT
14698          ,p_module   => l_log_module);
14699 END IF;
14700 
14701 --
14702 EXCEPTION
14703 WHEN OTHERS THEN
14704   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
14705          trace
14706             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
14707             ,p_level    => C_LEVEL_EXCEPTION
14708             ,p_module   => l_log_module);
14709   END IF;
14710 
14711   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
14712                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
14713                                     ,p_token_1      => 'ERROR'
14714                                     ,p_value_1      => sqlerrm
14715                                     );
14716 END;
14717 --
14718 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14719 
14720       trace
14721          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
14722          ,p_level    => C_LEVEL_PROCEDURE
14723          ,p_module   => l_log_module);
14724 
14725       trace
14726          (p_msg      => 'END of InsertHdrAnalyticalCriteria50'
14727          ,p_level    => C_LEVEL_PROCEDURE
14728          ,p_module   => l_log_module);
14729 END IF;
14730 --
14731 EXCEPTION
14732 WHEN xla_exceptions_pkg.application_exception THEN
14733   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
14734        trace
14735            (p_msg      => 'Error. = '||sqlerrm
14736            ,p_level    => C_LEVEL_PROCEDURE
14737            ,p_module   => l_log_module);
14738   END IF;
14739   RAISE;
14740 WHEN OTHERS  THEN
14741  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
14742        trace
14743            (p_msg      => 'Error. = '||sqlerrm
14744            ,p_level    => C_LEVEL_PROCEDURE
14745            ,p_module   => l_log_module);
14746   END IF;
14747   xla_exceptions_pkg.raise_message
14748                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria50');
14749    --
14750 END InsertHdrAnalyticalCriteria50;
14751 
14752 --
14753 /*======================================================================+
14754 |                                                                       |
14755 | Insert Header Analytical Criteria 100                                 |
14756 |                                                                       |
14757 |                                                                       |
14758 +======================================================================*/
14759 --
14760 PROCEDURE InsertHdrAnalyticalCriteria100
14761 IS
14762 l_log_module         VARCHAR2(240);
14763 BEGIN
14764 --
14765 IF g_log_enabled THEN
14766       l_log_module := C_DEFAULT_MODULE||'.InsertHdrAnalyticalCriteria100';
14767 END IF;
14768 --
14769 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
14770 
14771       trace
14772          (p_msg      => 'BEGIN of InsertHdrAnalyticalCriteria100'
14773          ,p_level    => C_LEVEL_PROCEDURE
14774          ,p_module   => l_log_module);
14775 END IF;
14776 --
14777 BEGIN
14778 
14779    IF (C_LEVEL_STATEMENT >= g_log_level) THEN
14780 
14781       trace
14782          (p_msg      => 'SQL - Insert into xla_ae_header_acs'
14783          ,p_level    => C_LEVEL_STATEMENT
14784          ,p_module   => l_log_module);
14785 
14786    END IF;
14787 --
14788 
14789 INSERT ALL
14790 WHEN anc_id_1 IS NOT NULL THEN
14791   INTO xla_ae_header_acs (
14792         ae_header_id , object_version_number
14793       , analytical_criterion_code
14794       , analytical_criterion_type_code
14795       , amb_context_code
14796       , ac1,ac2,ac3,ac4,ac5)
14797 VALUES (ae_header_id, C_OVN
14798 ,SUBSTRB(anc_id_1
14799        ,1
14800        ,INSTRB(anc_id_1,'(]',1,1) -1)
14801 ,SUBSTRB(anc_id_1
14802        ,INSTRB(anc_id_1,'(]',1,1) + 2
14803        ,INSTRB(anc_id_1,'(]',1,2) -
14804         INSTRB(anc_id_1,'(]',1,1) - 2)
14805 ,SUBSTRB(anc_id_1
14806        ,INSTRB(anc_id_1,'(]',1,2) + 2
14807        ,INSTRB(anc_id_1,'(]',1,3) -
14808         INSTRB(anc_id_1,'(]',1,2) - 2)
14809 ,SUBSTRB(anc_id_1
14810        ,INSTRB(anc_id_1,'(]',1,3) + 2
14811        ,INSTRB(anc_id_1,'(]',1,4) -
14812         INSTRB(anc_id_1,'(]',1,3) - 2)
14813 ,SUBSTRB(anc_id_1
14814        ,INSTRB(anc_id_1,'(]',1,4) + 2
14815        ,INSTRB(anc_id_1,'(]',1,5) -
14816         INSTRB(anc_id_1,'(]',1,4) - 2)
14817 ,SUBSTRB(anc_id_1
14818        ,INSTRB(anc_id_1,'(]',1,5) + 2
14819        ,INSTRB(anc_id_1,'(]',1,6) -
14820         INSTRB(anc_id_1,'(]',1,5) - 2)
14821 ,SUBSTRB(anc_id_1
14822        ,INSTRB(anc_id_1,'(]',1,6) + 2
14823        ,INSTRB(anc_id_1,'(]',1,7) -
14824         INSTRB(anc_id_1,'(]',1,6) - 2)
14825 ,SUBSTRB(anc_id_1
14826        ,INSTRB(anc_id_1,'(]',1,7) + 2
14827        ,LENGTHB(anc_id_1))
14828 )
14829 
14830 WHEN anc_id_2 IS NOT NULL THEN
14831   INTO xla_ae_header_acs (
14832         ae_header_id , object_version_number
14833       , analytical_criterion_code
14834       , analytical_criterion_type_code
14835       , amb_context_code
14836       , ac1,ac2,ac3,ac4,ac5)
14837 VALUES (ae_header_id, C_OVN
14838 ,SUBSTRB(anc_id_2
14839        ,1
14840        ,INSTRB(anc_id_2,'(]',1,1) -1)
14841 ,SUBSTRB(anc_id_2
14842        ,INSTRB(anc_id_2,'(]',1,1) + 2
14843        ,INSTRB(anc_id_2,'(]',1,2) -
14844         INSTRB(anc_id_2,'(]',1,1) - 2)
14845 ,SUBSTRB(anc_id_2
14846        ,INSTRB(anc_id_2,'(]',1,2) + 2
14847        ,INSTRB(anc_id_2,'(]',1,3) -
14848         INSTRB(anc_id_2,'(]',1,2) - 2)
14849 ,SUBSTRB(anc_id_2
14850        ,INSTRB(anc_id_2,'(]',1,3) + 2
14851        ,INSTRB(anc_id_2,'(]',1,4) -
14852         INSTRB(anc_id_2,'(]',1,3) - 2)
14853 ,SUBSTRB(anc_id_2
14854        ,INSTRB(anc_id_2,'(]',1,4) + 2
14855        ,INSTRB(anc_id_2,'(]',1,5) -
14856         INSTRB(anc_id_2,'(]',1,4) - 2)
14857 ,SUBSTRB(anc_id_2
14858        ,INSTRB(anc_id_2,'(]',1,5) + 2
14859        ,INSTRB(anc_id_2,'(]',1,6) -
14860         INSTRB(anc_id_2,'(]',1,5) - 2)
14861 ,SUBSTRB(anc_id_2
14862        ,INSTRB(anc_id_2,'(]',1,6) + 2
14863        ,INSTRB(anc_id_2,'(]',1,7) -
14864         INSTRB(anc_id_2,'(]',1,6) - 2)
14865 ,SUBSTRB(anc_id_2
14866        ,INSTRB(anc_id_2,'(]',1,7) + 2
14867        ,LENGTHB(anc_id_2))
14868 )
14869 
14870 WHEN anc_id_3 IS NOT NULL THEN
14871   INTO xla_ae_header_acs (
14872         ae_header_id , object_version_number
14873       , analytical_criterion_code
14874       , analytical_criterion_type_code
14875       , amb_context_code
14876       , ac1,ac2,ac3,ac4,ac5)
14877 VALUES (ae_header_id, C_OVN
14878 ,SUBSTRB(anc_id_3
14879        ,1
14880        ,INSTRB(anc_id_3,'(]',1,1) -1)
14881 ,SUBSTRB(anc_id_3
14882        ,INSTRB(anc_id_3,'(]',1,1) + 2
14883        ,INSTRB(anc_id_3,'(]',1,2) -
14884         INSTRB(anc_id_3,'(]',1,1) - 2)
14885 ,SUBSTRB(anc_id_3
14886        ,INSTRB(anc_id_3,'(]',1,2) + 2
14887        ,INSTRB(anc_id_3,'(]',1,3) -
14888         INSTRB(anc_id_3,'(]',1,2) - 2)
14889 ,SUBSTRB(anc_id_3
14890        ,INSTRB(anc_id_3,'(]',1,3) + 2
14891        ,INSTRB(anc_id_3,'(]',1,4) -
14892         INSTRB(anc_id_3,'(]',1,3) - 2)
14893 ,SUBSTRB(anc_id_3
14894        ,INSTRB(anc_id_3,'(]',1,4) + 2
14895        ,INSTRB(anc_id_3,'(]',1,5) -
14896         INSTRB(anc_id_3,'(]',1,4) - 2)
14897 ,SUBSTRB(anc_id_3
14898        ,INSTRB(anc_id_3,'(]',1,5) + 2
14899        ,INSTRB(anc_id_3,'(]',1,6) -
14900         INSTRB(anc_id_3,'(]',1,5) - 2)
14901 ,SUBSTRB(anc_id_3
14902        ,INSTRB(anc_id_3,'(]',1,6) + 2
14903        ,INSTRB(anc_id_3,'(]',1,7) -
14904         INSTRB(anc_id_3,'(]',1,6) - 2)
14905 ,SUBSTRB(anc_id_3
14906        ,INSTRB(anc_id_3,'(]',1,7) + 2
14907        ,LENGTHB(anc_id_3))
14908 )
14909 
14910 WHEN anc_id_4 IS NOT NULL THEN
14911   INTO xla_ae_header_acs (
14912         ae_header_id , object_version_number
14913       , analytical_criterion_code
14914       , analytical_criterion_type_code
14915       , amb_context_code
14916       , ac1,ac2,ac3,ac4,ac5)
14917 VALUES (ae_header_id, C_OVN
14918 ,SUBSTRB(anc_id_4
14919        ,1
14920        ,INSTRB(anc_id_4,'(]',1,1) -1)
14921 ,SUBSTRB(anc_id_4
14922        ,INSTRB(anc_id_4,'(]',1,1) + 2
14923        ,INSTRB(anc_id_4,'(]',1,2) -
14924         INSTRB(anc_id_4,'(]',1,1) - 2)
14925 ,SUBSTRB(anc_id_4
14926        ,INSTRB(anc_id_4,'(]',1,2) + 2
14927        ,INSTRB(anc_id_4,'(]',1,3) -
14928         INSTRB(anc_id_4,'(]',1,2) - 2)
14929 ,SUBSTRB(anc_id_4
14930        ,INSTRB(anc_id_4,'(]',1,3) + 2
14931        ,INSTRB(anc_id_4,'(]',1,4) -
14932         INSTRB(anc_id_4,'(]',1,3) - 2)
14933 ,SUBSTRB(anc_id_4
14934        ,INSTRB(anc_id_4,'(]',1,4) + 2
14935        ,INSTRB(anc_id_4,'(]',1,5) -
14936         INSTRB(anc_id_4,'(]',1,4) - 2)
14937 ,SUBSTRB(anc_id_4
14938        ,INSTRB(anc_id_4,'(]',1,5) + 2
14939        ,INSTRB(anc_id_4,'(]',1,6) -
14940         INSTRB(anc_id_4,'(]',1,5) - 2)
14941 ,SUBSTRB(anc_id_4
14942        ,INSTRB(anc_id_4,'(]',1,6) + 2
14943        ,INSTRB(anc_id_4,'(]',1,7) -
14944         INSTRB(anc_id_4,'(]',1,6) - 2)
14945 ,SUBSTRB(anc_id_4
14946        ,INSTRB(anc_id_4,'(]',1,7) + 2
14947        ,LENGTHB(anc_id_4))
14948 )
14949 
14950 WHEN anc_id_5 IS NOT NULL THEN
14951   INTO xla_ae_header_acs (
14952         ae_header_id , object_version_number
14953       , analytical_criterion_code
14954       , analytical_criterion_type_code
14955       , amb_context_code
14956       , ac1,ac2,ac3,ac4,ac5)
14957 VALUES (ae_header_id, C_OVN
14958 ,SUBSTRB(anc_id_5
14959        ,1
14960        ,INSTRB(anc_id_5,'(]',1,1) -1)
14961 ,SUBSTRB(anc_id_5
14962        ,INSTRB(anc_id_5,'(]',1,1) + 2
14963        ,INSTRB(anc_id_5,'(]',1,2) -
14964         INSTRB(anc_id_5,'(]',1,1) - 2)
14965 ,SUBSTRB(anc_id_5
14966        ,INSTRB(anc_id_5,'(]',1,2) + 2
14967        ,INSTRB(anc_id_5,'(]',1,3) -
14968         INSTRB(anc_id_5,'(]',1,2) - 2)
14969 ,SUBSTRB(anc_id_5
14970        ,INSTRB(anc_id_5,'(]',1,3) + 2
14971        ,INSTRB(anc_id_5,'(]',1,4) -
14972         INSTRB(anc_id_5,'(]',1,3) - 2)
14973 ,SUBSTRB(anc_id_5
14974        ,INSTRB(anc_id_5,'(]',1,4) + 2
14975        ,INSTRB(anc_id_5,'(]',1,5) -
14976         INSTRB(anc_id_5,'(]',1,4) - 2)
14977 ,SUBSTRB(anc_id_5
14978        ,INSTRB(anc_id_5,'(]',1,5) + 2
14979        ,INSTRB(anc_id_5,'(]',1,6) -
14980         INSTRB(anc_id_5,'(]',1,5) - 2)
14981 ,SUBSTRB(anc_id_5
14982        ,INSTRB(anc_id_5,'(]',1,6) + 2
14983        ,INSTRB(anc_id_5,'(]',1,7) -
14984         INSTRB(anc_id_5,'(]',1,6) - 2)
14985 ,SUBSTRB(anc_id_5
14986        ,INSTRB(anc_id_5,'(]',1,7) + 2
14987        ,LENGTHB(anc_id_5))
14988 )
14989 
14990 WHEN anc_id_6 IS NOT NULL THEN
14991   INTO xla_ae_header_acs (
14992         ae_header_id , object_version_number
14993       , analytical_criterion_code
14994       , analytical_criterion_type_code
14995       , amb_context_code
14996       , ac1,ac2,ac3,ac4,ac5)
14997 VALUES (ae_header_id, C_OVN
14998 ,SUBSTRB(anc_id_6
14999        ,1
15000        ,INSTRB(anc_id_6,'(]',1,1) -1)
15001 ,SUBSTRB(anc_id_6
15002        ,INSTRB(anc_id_6,'(]',1,1) + 2
15003        ,INSTRB(anc_id_6,'(]',1,2) -
15004         INSTRB(anc_id_6,'(]',1,1) - 2)
15005 ,SUBSTRB(anc_id_6
15006        ,INSTRB(anc_id_6,'(]',1,2) + 2
15007        ,INSTRB(anc_id_6,'(]',1,3) -
15008         INSTRB(anc_id_6,'(]',1,2) - 2)
15009 ,SUBSTRB(anc_id_6
15010        ,INSTRB(anc_id_6,'(]',1,3) + 2
15011        ,INSTRB(anc_id_6,'(]',1,4) -
15012         INSTRB(anc_id_6,'(]',1,3) - 2)
15013 ,SUBSTRB(anc_id_6
15014        ,INSTRB(anc_id_6,'(]',1,4) + 2
15015        ,INSTRB(anc_id_6,'(]',1,5) -
15016         INSTRB(anc_id_6,'(]',1,4) - 2)
15017 ,SUBSTRB(anc_id_6
15018        ,INSTRB(anc_id_6,'(]',1,5) + 2
15019        ,INSTRB(anc_id_6,'(]',1,6) -
15020         INSTRB(anc_id_6,'(]',1,5) - 2)
15021 ,SUBSTRB(anc_id_6
15022        ,INSTRB(anc_id_6,'(]',1,6) + 2
15023        ,INSTRB(anc_id_6,'(]',1,7) -
15024         INSTRB(anc_id_6,'(]',1,6) - 2)
15025 ,SUBSTRB(anc_id_6
15026        ,INSTRB(anc_id_6,'(]',1,7) + 2
15027        ,LENGTHB(anc_id_6))
15028 )
15029 
15030 WHEN anc_id_7 IS NOT NULL THEN
15031   INTO xla_ae_header_acs (
15032         ae_header_id , object_version_number
15033       , analytical_criterion_code
15034       , analytical_criterion_type_code
15035       , amb_context_code
15036       , ac1,ac2,ac3,ac4,ac5)
15037 VALUES (ae_header_id, C_OVN
15038 ,SUBSTRB(anc_id_7
15039        ,1
15040        ,INSTRB(anc_id_7,'(]',1,1) -1)
15041 ,SUBSTRB(anc_id_7
15042        ,INSTRB(anc_id_7,'(]',1,1) + 2
15043        ,INSTRB(anc_id_7,'(]',1,2) -
15044         INSTRB(anc_id_7,'(]',1,1) - 2)
15045 ,SUBSTRB(anc_id_7
15046        ,INSTRB(anc_id_7,'(]',1,2) + 2
15047        ,INSTRB(anc_id_7,'(]',1,3) -
15048         INSTRB(anc_id_7,'(]',1,2) - 2)
15049 ,SUBSTRB(anc_id_7
15050        ,INSTRB(anc_id_7,'(]',1,3) + 2
15051        ,INSTRB(anc_id_7,'(]',1,4) -
15052         INSTRB(anc_id_7,'(]',1,3) - 2)
15053 ,SUBSTRB(anc_id_7
15054        ,INSTRB(anc_id_7,'(]',1,4) + 2
15055        ,INSTRB(anc_id_7,'(]',1,5) -
15056         INSTRB(anc_id_7,'(]',1,4) - 2)
15057 ,SUBSTRB(anc_id_7
15058        ,INSTRB(anc_id_7,'(]',1,5) + 2
15059        ,INSTRB(anc_id_7,'(]',1,6) -
15060         INSTRB(anc_id_7,'(]',1,5) - 2)
15061 ,SUBSTRB(anc_id_7
15062        ,INSTRB(anc_id_7,'(]',1,6) + 2
15063        ,INSTRB(anc_id_7,'(]',1,7) -
15064         INSTRB(anc_id_7,'(]',1,6) - 2)
15065 ,SUBSTRB(anc_id_7
15066        ,INSTRB(anc_id_7,'(]',1,7) + 2
15067        ,LENGTHB(anc_id_7))
15068 )
15069 
15070 WHEN anc_id_8 IS NOT NULL THEN
15071   INTO xla_ae_header_acs (
15072         ae_header_id , object_version_number
15073       , analytical_criterion_code
15074       , analytical_criterion_type_code
15075       , amb_context_code
15076       , ac1,ac2,ac3,ac4,ac5)
15077 VALUES (ae_header_id, C_OVN
15078 ,SUBSTRB(anc_id_8
15079        ,1
15080        ,INSTRB(anc_id_8,'(]',1,1) -1)
15081 ,SUBSTRB(anc_id_8
15082        ,INSTRB(anc_id_8,'(]',1,1) + 2
15083        ,INSTRB(anc_id_8,'(]',1,2) -
15084         INSTRB(anc_id_8,'(]',1,1) - 2)
15085 ,SUBSTRB(anc_id_8
15086        ,INSTRB(anc_id_8,'(]',1,2) + 2
15087        ,INSTRB(anc_id_8,'(]',1,3) -
15088         INSTRB(anc_id_8,'(]',1,2) - 2)
15089 ,SUBSTRB(anc_id_8
15090        ,INSTRB(anc_id_8,'(]',1,3) + 2
15091        ,INSTRB(anc_id_8,'(]',1,4) -
15092         INSTRB(anc_id_8,'(]',1,3) - 2)
15093 ,SUBSTRB(anc_id_8
15094        ,INSTRB(anc_id_8,'(]',1,4) + 2
15095        ,INSTRB(anc_id_8,'(]',1,5) -
15096         INSTRB(anc_id_8,'(]',1,4) - 2)
15097 ,SUBSTRB(anc_id_8
15098        ,INSTRB(anc_id_8,'(]',1,5) + 2
15099        ,INSTRB(anc_id_8,'(]',1,6) -
15100         INSTRB(anc_id_8,'(]',1,5) - 2)
15101 ,SUBSTRB(anc_id_8
15102        ,INSTRB(anc_id_8,'(]',1,6) + 2
15103        ,INSTRB(anc_id_8,'(]',1,7) -
15104         INSTRB(anc_id_8,'(]',1,6) - 2)
15105 ,SUBSTRB(anc_id_8
15106        ,INSTRB(anc_id_8,'(]',1,7) + 2
15107        ,LENGTHB(anc_id_8))
15108 )
15109 
15110 WHEN anc_id_9 IS NOT NULL THEN
15111   INTO xla_ae_header_acs (
15112         ae_header_id , object_version_number
15113       , analytical_criterion_code
15114       , analytical_criterion_type_code
15115       , amb_context_code
15116       , ac1,ac2,ac3,ac4,ac5)
15117 VALUES (ae_header_id, C_OVN
15118 ,SUBSTRB(anc_id_9
15119        ,1
15120        ,INSTRB(anc_id_9,'(]',1,1) -1)
15121 ,SUBSTRB(anc_id_9
15122        ,INSTRB(anc_id_9,'(]',1,1) + 2
15123        ,INSTRB(anc_id_9,'(]',1,2) -
15124         INSTRB(anc_id_9,'(]',1,1) - 2)
15125 ,SUBSTRB(anc_id_9
15126        ,INSTRB(anc_id_9,'(]',1,2) + 2
15127        ,INSTRB(anc_id_9,'(]',1,3) -
15128         INSTRB(anc_id_9,'(]',1,2) - 2)
15129 ,SUBSTRB(anc_id_9
15130        ,INSTRB(anc_id_9,'(]',1,3) + 2
15131        ,INSTRB(anc_id_9,'(]',1,4) -
15132         INSTRB(anc_id_9,'(]',1,3) - 2)
15133 ,SUBSTRB(anc_id_9
15134        ,INSTRB(anc_id_9,'(]',1,4) + 2
15135        ,INSTRB(anc_id_9,'(]',1,5) -
15136         INSTRB(anc_id_9,'(]',1,4) - 2)
15137 ,SUBSTRB(anc_id_9
15138        ,INSTRB(anc_id_9,'(]',1,5) + 2
15139        ,INSTRB(anc_id_9,'(]',1,6) -
15140         INSTRB(anc_id_9,'(]',1,5) - 2)
15141 ,SUBSTRB(anc_id_9
15142        ,INSTRB(anc_id_9,'(]',1,6) + 2
15143        ,INSTRB(anc_id_9,'(]',1,7) -
15144         INSTRB(anc_id_9,'(]',1,6) - 2)
15145 ,SUBSTRB(anc_id_9
15146        ,INSTRB(anc_id_9,'(]',1,7) + 2
15147        ,LENGTHB(anc_id_9))
15148 )
15149 
15150 WHEN anc_id_10 IS NOT NULL THEN
15151   INTO xla_ae_header_acs (
15152         ae_header_id , object_version_number
15153       , analytical_criterion_code
15154       , analytical_criterion_type_code
15155       , amb_context_code
15156       , ac1,ac2,ac3,ac4,ac5)
15157 VALUES (ae_header_id, C_OVN
15158 ,SUBSTRB(anc_id_10
15159        ,1
15160        ,INSTRB(anc_id_10,'(]',1,1) -1)
15161 ,SUBSTRB(anc_id_10
15162        ,INSTRB(anc_id_10,'(]',1,1) + 2
15163        ,INSTRB(anc_id_10,'(]',1,2) -
15164         INSTRB(anc_id_10,'(]',1,1) - 2)
15165 ,SUBSTRB(anc_id_10
15166        ,INSTRB(anc_id_10,'(]',1,2) + 2
15167        ,INSTRB(anc_id_10,'(]',1,3) -
15168         INSTRB(anc_id_10,'(]',1,2) - 2)
15169 ,SUBSTRB(anc_id_10
15170        ,INSTRB(anc_id_10,'(]',1,3) + 2
15171        ,INSTRB(anc_id_10,'(]',1,4) -
15172         INSTRB(anc_id_10,'(]',1,3) - 2)
15173 ,SUBSTRB(anc_id_10
15174        ,INSTRB(anc_id_10,'(]',1,4) + 2
15175        ,INSTRB(anc_id_10,'(]',1,5) -
15176         INSTRB(anc_id_10,'(]',1,4) - 2)
15177 ,SUBSTRB(anc_id_10
15178        ,INSTRB(anc_id_10,'(]',1,5) + 2
15179        ,INSTRB(anc_id_10,'(]',1,6) -
15180         INSTRB(anc_id_10,'(]',1,5) - 2)
15181 ,SUBSTRB(anc_id_10
15182        ,INSTRB(anc_id_10,'(]',1,6) + 2
15183        ,INSTRB(anc_id_10,'(]',1,7) -
15184         INSTRB(anc_id_10,'(]',1,6) - 2)
15185 ,SUBSTRB(anc_id_10
15186        ,INSTRB(anc_id_10,'(]',1,7) + 2
15187        ,LENGTHB(anc_id_10))
15188 )
15189 
15190 WHEN anc_id_11 IS NOT NULL THEN
15191   INTO xla_ae_header_acs (
15192         ae_header_id , object_version_number
15193       , analytical_criterion_code
15194       , analytical_criterion_type_code
15195       , amb_context_code
15196       , ac1,ac2,ac3,ac4,ac5)
15197 VALUES (ae_header_id, C_OVN
15198 ,SUBSTRB(anc_id_11
15199        ,1
15200        ,INSTRB(anc_id_11,'(]',1,1) -1)
15201 ,SUBSTRB(anc_id_11
15202        ,INSTRB(anc_id_11,'(]',1,1) + 2
15203        ,INSTRB(anc_id_11,'(]',1,2) -
15204         INSTRB(anc_id_11,'(]',1,1) - 2)
15205 ,SUBSTRB(anc_id_11
15206        ,INSTRB(anc_id_11,'(]',1,2) + 2
15207        ,INSTRB(anc_id_11,'(]',1,3) -
15208         INSTRB(anc_id_11,'(]',1,2) - 2)
15209 ,SUBSTRB(anc_id_11
15210        ,INSTRB(anc_id_11,'(]',1,3) + 2
15211        ,INSTRB(anc_id_11,'(]',1,4) -
15212         INSTRB(anc_id_11,'(]',1,3) - 2)
15213 ,SUBSTRB(anc_id_11
15214        ,INSTRB(anc_id_11,'(]',1,4) + 2
15215        ,INSTRB(anc_id_11,'(]',1,5) -
15216         INSTRB(anc_id_11,'(]',1,4) - 2)
15217 ,SUBSTRB(anc_id_11
15218        ,INSTRB(anc_id_11,'(]',1,5) + 2
15219        ,INSTRB(anc_id_11,'(]',1,6) -
15220         INSTRB(anc_id_11,'(]',1,5) - 2)
15221 ,SUBSTRB(anc_id_11
15222        ,INSTRB(anc_id_11,'(]',1,6) + 2
15223        ,INSTRB(anc_id_11,'(]',1,7) -
15224         INSTRB(anc_id_11,'(]',1,6) - 2)
15225 ,SUBSTRB(anc_id_11
15226        ,INSTRB(anc_id_11,'(]',1,7) + 2
15227        ,LENGTHB(anc_id_11))
15228 )
15229 
15230 WHEN anc_id_12 IS NOT NULL THEN
15231   INTO xla_ae_header_acs (
15232         ae_header_id , object_version_number
15233       , analytical_criterion_code
15234       , analytical_criterion_type_code
15235       , amb_context_code
15236       , ac1,ac2,ac3,ac4,ac5)
15237 VALUES (ae_header_id, C_OVN
15238 ,SUBSTRB(anc_id_12
15239        ,1
15240        ,INSTRB(anc_id_12,'(]',1,1) -1)
15241 ,SUBSTRB(anc_id_12
15242        ,INSTRB(anc_id_12,'(]',1,1) + 2
15243        ,INSTRB(anc_id_12,'(]',1,2) -
15244         INSTRB(anc_id_12,'(]',1,1) - 2)
15245 ,SUBSTRB(anc_id_12
15246        ,INSTRB(anc_id_12,'(]',1,2) + 2
15247        ,INSTRB(anc_id_12,'(]',1,3) -
15248         INSTRB(anc_id_12,'(]',1,2) - 2)
15249 ,SUBSTRB(anc_id_12
15250        ,INSTRB(anc_id_12,'(]',1,3) + 2
15251        ,INSTRB(anc_id_12,'(]',1,4) -
15252         INSTRB(anc_id_12,'(]',1,3) - 2)
15253 ,SUBSTRB(anc_id_12
15254        ,INSTRB(anc_id_12,'(]',1,4) + 2
15255        ,INSTRB(anc_id_12,'(]',1,5) -
15256         INSTRB(anc_id_12,'(]',1,4) - 2)
15257 ,SUBSTRB(anc_id_12
15258        ,INSTRB(anc_id_12,'(]',1,5) + 2
15259        ,INSTRB(anc_id_12,'(]',1,6) -
15260         INSTRB(anc_id_12,'(]',1,5) - 2)
15261 ,SUBSTRB(anc_id_12
15262        ,INSTRB(anc_id_12,'(]',1,6) + 2
15263        ,INSTRB(anc_id_12,'(]',1,7) -
15264         INSTRB(anc_id_12,'(]',1,6) - 2)
15265 ,SUBSTRB(anc_id_12
15266        ,INSTRB(anc_id_12,'(]',1,7) + 2
15267        ,LENGTHB(anc_id_12))
15268 )
15269 
15270 WHEN anc_id_13 IS NOT NULL THEN
15271   INTO xla_ae_header_acs (
15272         ae_header_id , object_version_number
15273       , analytical_criterion_code
15274       , analytical_criterion_type_code
15275       , amb_context_code
15276       , ac1,ac2,ac3,ac4,ac5)
15277 VALUES (ae_header_id, C_OVN
15278 ,SUBSTRB(anc_id_13
15279        ,1
15280        ,INSTRB(anc_id_13,'(]',1,1) -1)
15281 ,SUBSTRB(anc_id_13
15282        ,INSTRB(anc_id_13,'(]',1,1) + 2
15283        ,INSTRB(anc_id_13,'(]',1,2) -
15284         INSTRB(anc_id_13,'(]',1,1) - 2)
15285 ,SUBSTRB(anc_id_13
15286        ,INSTRB(anc_id_13,'(]',1,2) + 2
15287        ,INSTRB(anc_id_13,'(]',1,3) -
15288         INSTRB(anc_id_13,'(]',1,2) - 2)
15289 ,SUBSTRB(anc_id_13
15290        ,INSTRB(anc_id_13,'(]',1,3) + 2
15291        ,INSTRB(anc_id_13,'(]',1,4) -
15292         INSTRB(anc_id_13,'(]',1,3) - 2)
15293 ,SUBSTRB(anc_id_13
15294        ,INSTRB(anc_id_13,'(]',1,4) + 2
15295        ,INSTRB(anc_id_13,'(]',1,5) -
15296         INSTRB(anc_id_13,'(]',1,4) - 2)
15297 ,SUBSTRB(anc_id_13
15298        ,INSTRB(anc_id_13,'(]',1,5) + 2
15299        ,INSTRB(anc_id_13,'(]',1,6) -
15300         INSTRB(anc_id_13,'(]',1,5) - 2)
15301 ,SUBSTRB(anc_id_13
15302        ,INSTRB(anc_id_13,'(]',1,6) + 2
15303        ,INSTRB(anc_id_13,'(]',1,7) -
15304         INSTRB(anc_id_13,'(]',1,6) - 2)
15305 ,SUBSTRB(anc_id_13
15306        ,INSTRB(anc_id_13,'(]',1,7) + 2
15307        ,LENGTHB(anc_id_13))
15308 )
15309 
15310 WHEN anc_id_14 IS NOT NULL THEN
15311   INTO xla_ae_header_acs (
15312         ae_header_id , object_version_number
15313       , analytical_criterion_code
15314       , analytical_criterion_type_code
15315       , amb_context_code
15316       , ac1,ac2,ac3,ac4,ac5)
15317 VALUES (ae_header_id, C_OVN
15318 ,SUBSTRB(anc_id_14
15319        ,1
15320        ,INSTRB(anc_id_14,'(]',1,1) -1)
15321 ,SUBSTRB(anc_id_14
15322        ,INSTRB(anc_id_14,'(]',1,1) + 2
15323        ,INSTRB(anc_id_14,'(]',1,2) -
15324         INSTRB(anc_id_14,'(]',1,1) - 2)
15325 ,SUBSTRB(anc_id_14
15326        ,INSTRB(anc_id_14,'(]',1,2) + 2
15327        ,INSTRB(anc_id_14,'(]',1,3) -
15328         INSTRB(anc_id_14,'(]',1,2) - 2)
15329 ,SUBSTRB(anc_id_14
15330        ,INSTRB(anc_id_14,'(]',1,3) + 2
15331        ,INSTRB(anc_id_14,'(]',1,4) -
15332         INSTRB(anc_id_14,'(]',1,3) - 2)
15333 ,SUBSTRB(anc_id_14
15334        ,INSTRB(anc_id_14,'(]',1,4) + 2
15335        ,INSTRB(anc_id_14,'(]',1,5) -
15336         INSTRB(anc_id_14,'(]',1,4) - 2)
15337 ,SUBSTRB(anc_id_14
15338        ,INSTRB(anc_id_14,'(]',1,5) + 2
15339        ,INSTRB(anc_id_14,'(]',1,6) -
15340         INSTRB(anc_id_14,'(]',1,5) - 2)
15341 ,SUBSTRB(anc_id_14
15342        ,INSTRB(anc_id_14,'(]',1,6) + 2
15343        ,INSTRB(anc_id_14,'(]',1,7) -
15344         INSTRB(anc_id_14,'(]',1,6) - 2)
15345 ,SUBSTRB(anc_id_14
15346        ,INSTRB(anc_id_14,'(]',1,7) + 2
15347        ,LENGTHB(anc_id_14))
15348 )
15349 
15350 WHEN anc_id_15 IS NOT NULL THEN
15351   INTO xla_ae_header_acs (
15352         ae_header_id , object_version_number
15353       , analytical_criterion_code
15354       , analytical_criterion_type_code
15355       , amb_context_code
15356       , ac1,ac2,ac3,ac4,ac5)
15357 VALUES (ae_header_id, C_OVN
15358 ,SUBSTRB(anc_id_15
15359        ,1
15360        ,INSTRB(anc_id_15,'(]',1,1) -1)
15361 ,SUBSTRB(anc_id_15
15362        ,INSTRB(anc_id_15,'(]',1,1) + 2
15363        ,INSTRB(anc_id_15,'(]',1,2) -
15364         INSTRB(anc_id_15,'(]',1,1) - 2)
15365 ,SUBSTRB(anc_id_15
15366        ,INSTRB(anc_id_15,'(]',1,2) + 2
15367        ,INSTRB(anc_id_15,'(]',1,3) -
15368         INSTRB(anc_id_15,'(]',1,2) - 2)
15369 ,SUBSTRB(anc_id_15
15370        ,INSTRB(anc_id_15,'(]',1,3) + 2
15371        ,INSTRB(anc_id_15,'(]',1,4) -
15372         INSTRB(anc_id_15,'(]',1,3) - 2)
15373 ,SUBSTRB(anc_id_15
15374        ,INSTRB(anc_id_15,'(]',1,4) + 2
15375        ,INSTRB(anc_id_15,'(]',1,5) -
15376         INSTRB(anc_id_15,'(]',1,4) - 2)
15377 ,SUBSTRB(anc_id_15
15378        ,INSTRB(anc_id_15,'(]',1,5) + 2
15379        ,INSTRB(anc_id_15,'(]',1,6) -
15380         INSTRB(anc_id_15,'(]',1,5) - 2)
15381 ,SUBSTRB(anc_id_15
15382        ,INSTRB(anc_id_15,'(]',1,6) + 2
15383        ,INSTRB(anc_id_15,'(]',1,7) -
15384         INSTRB(anc_id_15,'(]',1,6) - 2)
15385 ,SUBSTRB(anc_id_15
15386        ,INSTRB(anc_id_15,'(]',1,7) + 2
15387        ,LENGTHB(anc_id_15))
15388 )
15389 
15390 WHEN anc_id_16 IS NOT NULL THEN
15391   INTO xla_ae_header_acs (
15392         ae_header_id , object_version_number
15393       , analytical_criterion_code
15394       , analytical_criterion_type_code
15395       , amb_context_code
15396       , ac1,ac2,ac3,ac4,ac5)
15397 VALUES (ae_header_id, C_OVN
15398 ,SUBSTRB(anc_id_16
15399        ,1
15400        ,INSTRB(anc_id_16,'(]',1,1) -1)
15401 ,SUBSTRB(anc_id_16
15402        ,INSTRB(anc_id_16,'(]',1,1) + 2
15403        ,INSTRB(anc_id_16,'(]',1,2) -
15404         INSTRB(anc_id_16,'(]',1,1) - 2)
15405 ,SUBSTRB(anc_id_16
15406        ,INSTRB(anc_id_16,'(]',1,2) + 2
15407        ,INSTRB(anc_id_16,'(]',1,3) -
15408         INSTRB(anc_id_16,'(]',1,2) - 2)
15409 ,SUBSTRB(anc_id_16
15410        ,INSTRB(anc_id_16,'(]',1,3) + 2
15411        ,INSTRB(anc_id_16,'(]',1,4) -
15412         INSTRB(anc_id_16,'(]',1,3) - 2)
15413 ,SUBSTRB(anc_id_16
15414        ,INSTRB(anc_id_16,'(]',1,4) + 2
15415        ,INSTRB(anc_id_16,'(]',1,5) -
15416         INSTRB(anc_id_16,'(]',1,4) - 2)
15417 ,SUBSTRB(anc_id_16
15418        ,INSTRB(anc_id_16,'(]',1,5) + 2
15419        ,INSTRB(anc_id_16,'(]',1,6) -
15420         INSTRB(anc_id_16,'(]',1,5) - 2)
15421 ,SUBSTRB(anc_id_16
15422        ,INSTRB(anc_id_16,'(]',1,6) + 2
15423        ,INSTRB(anc_id_16,'(]',1,7) -
15424         INSTRB(anc_id_16,'(]',1,6) - 2)
15425 ,SUBSTRB(anc_id_16
15426        ,INSTRB(anc_id_16,'(]',1,7) + 2
15427        ,LENGTHB(anc_id_16))
15428 )
15429 
15430 WHEN anc_id_17 IS NOT NULL THEN
15431   INTO xla_ae_header_acs (
15432         ae_header_id , object_version_number
15433       , analytical_criterion_code
15434       , analytical_criterion_type_code
15435       , amb_context_code
15436       , ac1,ac2,ac3,ac4,ac5)
15437 VALUES (ae_header_id, C_OVN
15438 ,SUBSTRB(anc_id_17
15439        ,1
15440        ,INSTRB(anc_id_17,'(]',1,1) -1)
15441 ,SUBSTRB(anc_id_17
15442        ,INSTRB(anc_id_17,'(]',1,1) + 2
15443        ,INSTRB(anc_id_17,'(]',1,2) -
15444         INSTRB(anc_id_17,'(]',1,1) - 2)
15445 ,SUBSTRB(anc_id_17
15446        ,INSTRB(anc_id_17,'(]',1,2) + 2
15447        ,INSTRB(anc_id_17,'(]',1,3) -
15448         INSTRB(anc_id_17,'(]',1,2) - 2)
15449 ,SUBSTRB(anc_id_17
15450        ,INSTRB(anc_id_17,'(]',1,3) + 2
15451        ,INSTRB(anc_id_17,'(]',1,4) -
15452         INSTRB(anc_id_17,'(]',1,3) - 2)
15453 ,SUBSTRB(anc_id_17
15454        ,INSTRB(anc_id_17,'(]',1,4) + 2
15455        ,INSTRB(anc_id_17,'(]',1,5) -
15456         INSTRB(anc_id_17,'(]',1,4) - 2)
15457 ,SUBSTRB(anc_id_17
15458        ,INSTRB(anc_id_17,'(]',1,5) + 2
15459        ,INSTRB(anc_id_17,'(]',1,6) -
15460         INSTRB(anc_id_17,'(]',1,5) - 2)
15461 ,SUBSTRB(anc_id_17
15462        ,INSTRB(anc_id_17,'(]',1,6) + 2
15463        ,INSTRB(anc_id_17,'(]',1,7) -
15464         INSTRB(anc_id_17,'(]',1,6) - 2)
15465 ,SUBSTRB(anc_id_17
15466        ,INSTRB(anc_id_17,'(]',1,7) + 2
15467        ,LENGTHB(anc_id_17))
15468 )
15469 
15470 WHEN anc_id_18 IS NOT NULL THEN
15471   INTO xla_ae_header_acs (
15472         ae_header_id , object_version_number
15473       , analytical_criterion_code
15474       , analytical_criterion_type_code
15475       , amb_context_code
15476       , ac1,ac2,ac3,ac4,ac5)
15477 VALUES (ae_header_id, C_OVN
15478 ,SUBSTRB(anc_id_18
15479        ,1
15480        ,INSTRB(anc_id_18,'(]',1,1) -1)
15481 ,SUBSTRB(anc_id_18
15482        ,INSTRB(anc_id_18,'(]',1,1) + 2
15483        ,INSTRB(anc_id_18,'(]',1,2) -
15484         INSTRB(anc_id_18,'(]',1,1) - 2)
15485 ,SUBSTRB(anc_id_18
15486        ,INSTRB(anc_id_18,'(]',1,2) + 2
15487        ,INSTRB(anc_id_18,'(]',1,3) -
15488         INSTRB(anc_id_18,'(]',1,2) - 2)
15489 ,SUBSTRB(anc_id_18
15490        ,INSTRB(anc_id_18,'(]',1,3) + 2
15491        ,INSTRB(anc_id_18,'(]',1,4) -
15492         INSTRB(anc_id_18,'(]',1,3) - 2)
15493 ,SUBSTRB(anc_id_18
15494        ,INSTRB(anc_id_18,'(]',1,4) + 2
15495        ,INSTRB(anc_id_18,'(]',1,5) -
15496         INSTRB(anc_id_18,'(]',1,4) - 2)
15497 ,SUBSTRB(anc_id_18
15498        ,INSTRB(anc_id_18,'(]',1,5) + 2
15499        ,INSTRB(anc_id_18,'(]',1,6) -
15500         INSTRB(anc_id_18,'(]',1,5) - 2)
15501 ,SUBSTRB(anc_id_18
15502        ,INSTRB(anc_id_18,'(]',1,6) + 2
15503        ,INSTRB(anc_id_18,'(]',1,7) -
15504         INSTRB(anc_id_18,'(]',1,6) - 2)
15505 ,SUBSTRB(anc_id_18
15506        ,INSTRB(anc_id_18,'(]',1,7) + 2
15507        ,LENGTHB(anc_id_18))
15508 )
15509 
15510 WHEN anc_id_19 IS NOT NULL THEN
15511   INTO xla_ae_header_acs (
15512         ae_header_id , object_version_number
15513       , analytical_criterion_code
15514       , analytical_criterion_type_code
15515       , amb_context_code
15516       , ac1,ac2,ac3,ac4,ac5)
15517 VALUES (ae_header_id, C_OVN
15518 ,SUBSTRB(anc_id_19
15519        ,1
15520        ,INSTRB(anc_id_19,'(]',1,1) -1)
15521 ,SUBSTRB(anc_id_19
15522        ,INSTRB(anc_id_19,'(]',1,1) + 2
15523        ,INSTRB(anc_id_19,'(]',1,2) -
15524         INSTRB(anc_id_19,'(]',1,1) - 2)
15525 ,SUBSTRB(anc_id_19
15526        ,INSTRB(anc_id_19,'(]',1,2) + 2
15527        ,INSTRB(anc_id_19,'(]',1,3) -
15528         INSTRB(anc_id_19,'(]',1,2) - 2)
15529 ,SUBSTRB(anc_id_19
15530        ,INSTRB(anc_id_19,'(]',1,3) + 2
15531        ,INSTRB(anc_id_19,'(]',1,4) -
15532         INSTRB(anc_id_19,'(]',1,3) - 2)
15533 ,SUBSTRB(anc_id_19
15534        ,INSTRB(anc_id_19,'(]',1,4) + 2
15535        ,INSTRB(anc_id_19,'(]',1,5) -
15536         INSTRB(anc_id_19,'(]',1,4) - 2)
15537 ,SUBSTRB(anc_id_19
15538        ,INSTRB(anc_id_19,'(]',1,5) + 2
15539        ,INSTRB(anc_id_19,'(]',1,6) -
15540         INSTRB(anc_id_19,'(]',1,5) - 2)
15541 ,SUBSTRB(anc_id_19
15542        ,INSTRB(anc_id_19,'(]',1,6) + 2
15543        ,INSTRB(anc_id_19,'(]',1,7) -
15544         INSTRB(anc_id_19,'(]',1,6) - 2)
15545 ,SUBSTRB(anc_id_19
15546        ,INSTRB(anc_id_19,'(]',1,7) + 2
15547        ,LENGTHB(anc_id_19))
15548 )
15549 
15550 WHEN anc_id_20 IS NOT NULL THEN
15551   INTO xla_ae_header_acs (
15552         ae_header_id , object_version_number
15553       , analytical_criterion_code
15554       , analytical_criterion_type_code
15555       , amb_context_code
15556       , ac1,ac2,ac3,ac4,ac5)
15557 VALUES (ae_header_id, C_OVN
15558 ,SUBSTRB(anc_id_20
15559        ,1
15560        ,INSTRB(anc_id_20,'(]',1,1) -1)
15561 ,SUBSTRB(anc_id_20
15562        ,INSTRB(anc_id_20,'(]',1,1) + 2
15563        ,INSTRB(anc_id_20,'(]',1,2) -
15564         INSTRB(anc_id_20,'(]',1,1) - 2)
15565 ,SUBSTRB(anc_id_20
15566        ,INSTRB(anc_id_20,'(]',1,2) + 2
15567        ,INSTRB(anc_id_20,'(]',1,3) -
15568         INSTRB(anc_id_20,'(]',1,2) - 2)
15569 ,SUBSTRB(anc_id_20
15570        ,INSTRB(anc_id_20,'(]',1,3) + 2
15571        ,INSTRB(anc_id_20,'(]',1,4) -
15572         INSTRB(anc_id_20,'(]',1,3) - 2)
15573 ,SUBSTRB(anc_id_20
15574        ,INSTRB(anc_id_20,'(]',1,4) + 2
15575        ,INSTRB(anc_id_20,'(]',1,5) -
15576         INSTRB(anc_id_20,'(]',1,4) - 2)
15577 ,SUBSTRB(anc_id_20
15578        ,INSTRB(anc_id_20,'(]',1,5) + 2
15579        ,INSTRB(anc_id_20,'(]',1,6) -
15580         INSTRB(anc_id_20,'(]',1,5) - 2)
15581 ,SUBSTRB(anc_id_20
15582        ,INSTRB(anc_id_20,'(]',1,6) + 2
15583        ,INSTRB(anc_id_20,'(]',1,7) -
15584         INSTRB(anc_id_20,'(]',1,6) - 2)
15585 ,SUBSTRB(anc_id_20
15586        ,INSTRB(anc_id_20,'(]',1,7) + 2
15587        ,LENGTHB(anc_id_20))
15588 )
15589 
15590 WHEN anc_id_21 IS NOT NULL THEN
15591   INTO xla_ae_header_acs (
15592         ae_header_id , object_version_number
15593       , analytical_criterion_code
15594       , analytical_criterion_type_code
15595       , amb_context_code
15596       , ac1,ac2,ac3,ac4,ac5)
15597 VALUES (ae_header_id, C_OVN
15598 ,SUBSTRB(anc_id_21
15599        ,1
15600        ,INSTRB(anc_id_21,'(]',1,1) -1)
15601 ,SUBSTRB(anc_id_21
15602        ,INSTRB(anc_id_21,'(]',1,1) + 2
15603        ,INSTRB(anc_id_21,'(]',1,2) -
15604         INSTRB(anc_id_21,'(]',1,1) - 2)
15605 ,SUBSTRB(anc_id_21
15606        ,INSTRB(anc_id_21,'(]',1,2) + 2
15607        ,INSTRB(anc_id_21,'(]',1,3) -
15608         INSTRB(anc_id_21,'(]',1,2) - 2)
15609 ,SUBSTRB(anc_id_21
15610        ,INSTRB(anc_id_21,'(]',1,3) + 2
15611        ,INSTRB(anc_id_21,'(]',1,4) -
15612         INSTRB(anc_id_21,'(]',1,3) - 2)
15613 ,SUBSTRB(anc_id_21
15614        ,INSTRB(anc_id_21,'(]',1,4) + 2
15615        ,INSTRB(anc_id_21,'(]',1,5) -
15616         INSTRB(anc_id_21,'(]',1,4) - 2)
15617 ,SUBSTRB(anc_id_21
15618        ,INSTRB(anc_id_21,'(]',1,5) + 2
15619        ,INSTRB(anc_id_21,'(]',1,6) -
15620         INSTRB(anc_id_21,'(]',1,5) - 2)
15621 ,SUBSTRB(anc_id_21
15622        ,INSTRB(anc_id_21,'(]',1,6) + 2
15623        ,INSTRB(anc_id_21,'(]',1,7) -
15624         INSTRB(anc_id_21,'(]',1,6) - 2)
15625 ,SUBSTRB(anc_id_21
15626        ,INSTRB(anc_id_21,'(]',1,7) + 2
15627        ,LENGTHB(anc_id_21))
15628 )
15629 
15630 WHEN anc_id_22 IS NOT NULL THEN
15631   INTO xla_ae_header_acs (
15632         ae_header_id , object_version_number
15633       , analytical_criterion_code
15634       , analytical_criterion_type_code
15635       , amb_context_code
15636       , ac1,ac2,ac3,ac4,ac5)
15637 VALUES (ae_header_id, C_OVN
15638 ,SUBSTRB(anc_id_22
15639        ,1
15640        ,INSTRB(anc_id_22,'(]',1,1) -1)
15641 ,SUBSTRB(anc_id_22
15642        ,INSTRB(anc_id_22,'(]',1,1) + 2
15643        ,INSTRB(anc_id_22,'(]',1,2) -
15644         INSTRB(anc_id_22,'(]',1,1) - 2)
15645 ,SUBSTRB(anc_id_22
15646        ,INSTRB(anc_id_22,'(]',1,2) + 2
15647        ,INSTRB(anc_id_22,'(]',1,3) -
15648         INSTRB(anc_id_22,'(]',1,2) - 2)
15649 ,SUBSTRB(anc_id_22
15650        ,INSTRB(anc_id_22,'(]',1,3) + 2
15651        ,INSTRB(anc_id_22,'(]',1,4) -
15652         INSTRB(anc_id_22,'(]',1,3) - 2)
15653 ,SUBSTRB(anc_id_22
15654        ,INSTRB(anc_id_22,'(]',1,4) + 2
15655        ,INSTRB(anc_id_22,'(]',1,5) -
15656         INSTRB(anc_id_22,'(]',1,4) - 2)
15657 ,SUBSTRB(anc_id_22
15658        ,INSTRB(anc_id_22,'(]',1,5) + 2
15659        ,INSTRB(anc_id_22,'(]',1,6) -
15660         INSTRB(anc_id_22,'(]',1,5) - 2)
15661 ,SUBSTRB(anc_id_22
15662        ,INSTRB(anc_id_22,'(]',1,6) + 2
15663        ,INSTRB(anc_id_22,'(]',1,7) -
15664         INSTRB(anc_id_22,'(]',1,6) - 2)
15665 ,SUBSTRB(anc_id_22
15666        ,INSTRB(anc_id_22,'(]',1,7) + 2
15667        ,LENGTHB(anc_id_22))
15668 )
15669 
15670 WHEN anc_id_23 IS NOT NULL THEN
15671   INTO xla_ae_header_acs (
15672         ae_header_id , object_version_number
15673       , analytical_criterion_code
15674       , analytical_criterion_type_code
15675       , amb_context_code
15676       , ac1,ac2,ac3,ac4,ac5)
15677 VALUES (ae_header_id, C_OVN
15678 ,SUBSTRB(anc_id_23
15679        ,1
15680        ,INSTRB(anc_id_23,'(]',1,1) -1)
15681 ,SUBSTRB(anc_id_23
15682        ,INSTRB(anc_id_23,'(]',1,1) + 2
15683        ,INSTRB(anc_id_23,'(]',1,2) -
15684         INSTRB(anc_id_23,'(]',1,1) - 2)
15685 ,SUBSTRB(anc_id_23
15686        ,INSTRB(anc_id_23,'(]',1,2) + 2
15687        ,INSTRB(anc_id_23,'(]',1,3) -
15688         INSTRB(anc_id_23,'(]',1,2) - 2)
15689 ,SUBSTRB(anc_id_23
15690        ,INSTRB(anc_id_23,'(]',1,3) + 2
15691        ,INSTRB(anc_id_23,'(]',1,4) -
15692         INSTRB(anc_id_23,'(]',1,3) - 2)
15693 ,SUBSTRB(anc_id_23
15694        ,INSTRB(anc_id_23,'(]',1,4) + 2
15695        ,INSTRB(anc_id_23,'(]',1,5) -
15696         INSTRB(anc_id_23,'(]',1,4) - 2)
15697 ,SUBSTRB(anc_id_23
15698        ,INSTRB(anc_id_23,'(]',1,5) + 2
15699        ,INSTRB(anc_id_23,'(]',1,6) -
15700         INSTRB(anc_id_23,'(]',1,5) - 2)
15701 ,SUBSTRB(anc_id_23
15702        ,INSTRB(anc_id_23,'(]',1,6) + 2
15703        ,INSTRB(anc_id_23,'(]',1,7) -
15704         INSTRB(anc_id_23,'(]',1,6) - 2)
15705 ,SUBSTRB(anc_id_23
15706        ,INSTRB(anc_id_23,'(]',1,7) + 2
15707        ,LENGTHB(anc_id_23))
15708 )
15709 
15710 WHEN anc_id_24 IS NOT NULL THEN
15711   INTO xla_ae_header_acs (
15712         ae_header_id , object_version_number
15713       , analytical_criterion_code
15714       , analytical_criterion_type_code
15715       , amb_context_code
15716       , ac1,ac2,ac3,ac4,ac5)
15717 VALUES (ae_header_id, C_OVN
15718 ,SUBSTRB(anc_id_24
15719        ,1
15720        ,INSTRB(anc_id_24,'(]',1,1) -1)
15721 ,SUBSTRB(anc_id_24
15722        ,INSTRB(anc_id_24,'(]',1,1) + 2
15723        ,INSTRB(anc_id_24,'(]',1,2) -
15724         INSTRB(anc_id_24,'(]',1,1) - 2)
15725 ,SUBSTRB(anc_id_24
15726        ,INSTRB(anc_id_24,'(]',1,2) + 2
15727        ,INSTRB(anc_id_24,'(]',1,3) -
15728         INSTRB(anc_id_24,'(]',1,2) - 2)
15729 ,SUBSTRB(anc_id_24
15730        ,INSTRB(anc_id_24,'(]',1,3) + 2
15731        ,INSTRB(anc_id_24,'(]',1,4) -
15732         INSTRB(anc_id_24,'(]',1,3) - 2)
15733 ,SUBSTRB(anc_id_24
15734        ,INSTRB(anc_id_24,'(]',1,4) + 2
15735        ,INSTRB(anc_id_24,'(]',1,5) -
15736         INSTRB(anc_id_24,'(]',1,4) - 2)
15737 ,SUBSTRB(anc_id_24
15738        ,INSTRB(anc_id_24,'(]',1,5) + 2
15739        ,INSTRB(anc_id_24,'(]',1,6) -
15740         INSTRB(anc_id_24,'(]',1,5) - 2)
15741 ,SUBSTRB(anc_id_24
15742        ,INSTRB(anc_id_24,'(]',1,6) + 2
15743        ,INSTRB(anc_id_24,'(]',1,7) -
15744         INSTRB(anc_id_24,'(]',1,6) - 2)
15745 ,SUBSTRB(anc_id_24
15746        ,INSTRB(anc_id_24,'(]',1,7) + 2
15747        ,LENGTHB(anc_id_24))
15748 )
15749 
15750 WHEN anc_id_25 IS NOT NULL THEN
15751   INTO xla_ae_header_acs (
15752         ae_header_id , object_version_number
15753       , analytical_criterion_code
15754       , analytical_criterion_type_code
15755       , amb_context_code
15756       , ac1,ac2,ac3,ac4,ac5)
15757 VALUES (ae_header_id, C_OVN
15758 ,SUBSTRB(anc_id_25
15759        ,1
15760        ,INSTRB(anc_id_25,'(]',1,1) -1)
15761 ,SUBSTRB(anc_id_25
15762        ,INSTRB(anc_id_25,'(]',1,1) + 2
15763        ,INSTRB(anc_id_25,'(]',1,2) -
15764         INSTRB(anc_id_25,'(]',1,1) - 2)
15765 ,SUBSTRB(anc_id_25
15766        ,INSTRB(anc_id_25,'(]',1,2) + 2
15767        ,INSTRB(anc_id_25,'(]',1,3) -
15768         INSTRB(anc_id_25,'(]',1,2) - 2)
15769 ,SUBSTRB(anc_id_25
15770        ,INSTRB(anc_id_25,'(]',1,3) + 2
15771        ,INSTRB(anc_id_25,'(]',1,4) -
15772         INSTRB(anc_id_25,'(]',1,3) - 2)
15773 ,SUBSTRB(anc_id_25
15774        ,INSTRB(anc_id_25,'(]',1,4) + 2
15775        ,INSTRB(anc_id_25,'(]',1,5) -
15776         INSTRB(anc_id_25,'(]',1,4) - 2)
15777 ,SUBSTRB(anc_id_25
15778        ,INSTRB(anc_id_25,'(]',1,5) + 2
15779        ,INSTRB(anc_id_25,'(]',1,6) -
15780         INSTRB(anc_id_25,'(]',1,5) - 2)
15781 ,SUBSTRB(anc_id_25
15782        ,INSTRB(anc_id_25,'(]',1,6) + 2
15783        ,INSTRB(anc_id_25,'(]',1,7) -
15784         INSTRB(anc_id_25,'(]',1,6) - 2)
15785 ,SUBSTRB(anc_id_25
15786        ,INSTRB(anc_id_25,'(]',1,7) + 2
15787        ,LENGTHB(anc_id_25))
15788 )
15789 
15790 WHEN anc_id_26 IS NOT NULL THEN
15791   INTO xla_ae_header_acs (
15792         ae_header_id , object_version_number
15793       , analytical_criterion_code
15794       , analytical_criterion_type_code
15795       , amb_context_code
15796       , ac1,ac2,ac3,ac4,ac5)
15797 VALUES (ae_header_id, C_OVN
15798 ,SUBSTRB(anc_id_26
15799        ,1
15800        ,INSTRB(anc_id_26,'(]',1,1) -1)
15801 ,SUBSTRB(anc_id_26
15802        ,INSTRB(anc_id_26,'(]',1,1) + 2
15803        ,INSTRB(anc_id_26,'(]',1,2) -
15804         INSTRB(anc_id_26,'(]',1,1) - 2)
15805 ,SUBSTRB(anc_id_26
15806        ,INSTRB(anc_id_26,'(]',1,2) + 2
15807        ,INSTRB(anc_id_26,'(]',1,3) -
15808         INSTRB(anc_id_26,'(]',1,2) - 2)
15809 ,SUBSTRB(anc_id_26
15810        ,INSTRB(anc_id_26,'(]',1,3) + 2
15811        ,INSTRB(anc_id_26,'(]',1,4) -
15812         INSTRB(anc_id_26,'(]',1,3) - 2)
15813 ,SUBSTRB(anc_id_26
15814        ,INSTRB(anc_id_26,'(]',1,4) + 2
15815        ,INSTRB(anc_id_26,'(]',1,5) -
15816         INSTRB(anc_id_26,'(]',1,4) - 2)
15817 ,SUBSTRB(anc_id_26
15818        ,INSTRB(anc_id_26,'(]',1,5) + 2
15819        ,INSTRB(anc_id_26,'(]',1,6) -
15820         INSTRB(anc_id_26,'(]',1,5) - 2)
15821 ,SUBSTRB(anc_id_26
15822        ,INSTRB(anc_id_26,'(]',1,6) + 2
15823        ,INSTRB(anc_id_26,'(]',1,7) -
15824         INSTRB(anc_id_26,'(]',1,6) - 2)
15825 ,SUBSTRB(anc_id_26
15826        ,INSTRB(anc_id_26,'(]',1,7) + 2
15827        ,LENGTHB(anc_id_26))
15828 )
15829 
15830 WHEN anc_id_27 IS NOT NULL THEN
15831   INTO xla_ae_header_acs (
15832         ae_header_id , object_version_number
15833       , analytical_criterion_code
15834       , analytical_criterion_type_code
15835       , amb_context_code
15836       , ac1,ac2,ac3,ac4,ac5)
15837 VALUES (ae_header_id, C_OVN
15838 ,SUBSTRB(anc_id_27
15839        ,1
15840        ,INSTRB(anc_id_27,'(]',1,1) -1)
15841 ,SUBSTRB(anc_id_27
15842        ,INSTRB(anc_id_27,'(]',1,1) + 2
15843        ,INSTRB(anc_id_27,'(]',1,2) -
15844         INSTRB(anc_id_27,'(]',1,1) - 2)
15845 ,SUBSTRB(anc_id_27
15846        ,INSTRB(anc_id_27,'(]',1,2) + 2
15847        ,INSTRB(anc_id_27,'(]',1,3) -
15848         INSTRB(anc_id_27,'(]',1,2) - 2)
15849 ,SUBSTRB(anc_id_27
15850        ,INSTRB(anc_id_27,'(]',1,3) + 2
15851        ,INSTRB(anc_id_27,'(]',1,4) -
15852         INSTRB(anc_id_27,'(]',1,3) - 2)
15853 ,SUBSTRB(anc_id_27
15854        ,INSTRB(anc_id_27,'(]',1,4) + 2
15855        ,INSTRB(anc_id_27,'(]',1,5) -
15856         INSTRB(anc_id_27,'(]',1,4) - 2)
15857 ,SUBSTRB(anc_id_27
15858        ,INSTRB(anc_id_27,'(]',1,5) + 2
15859        ,INSTRB(anc_id_27,'(]',1,6) -
15860         INSTRB(anc_id_27,'(]',1,5) - 2)
15861 ,SUBSTRB(anc_id_27
15862        ,INSTRB(anc_id_27,'(]',1,6) + 2
15863        ,INSTRB(anc_id_27,'(]',1,7) -
15864         INSTRB(anc_id_27,'(]',1,6) - 2)
15865 ,SUBSTRB(anc_id_27
15866        ,INSTRB(anc_id_27,'(]',1,7) + 2
15867        ,LENGTHB(anc_id_27))
15868 )
15869 
15870 WHEN anc_id_28 IS NOT NULL THEN
15871   INTO xla_ae_header_acs (
15872         ae_header_id , object_version_number
15873       , analytical_criterion_code
15874       , analytical_criterion_type_code
15875       , amb_context_code
15876       , ac1,ac2,ac3,ac4,ac5)
15877 VALUES (ae_header_id, C_OVN
15878 ,SUBSTRB(anc_id_28
15879        ,1
15880        ,INSTRB(anc_id_28,'(]',1,1) -1)
15881 ,SUBSTRB(anc_id_28
15882        ,INSTRB(anc_id_28,'(]',1,1) + 2
15883        ,INSTRB(anc_id_28,'(]',1,2) -
15884         INSTRB(anc_id_28,'(]',1,1) - 2)
15885 ,SUBSTRB(anc_id_28
15886        ,INSTRB(anc_id_28,'(]',1,2) + 2
15887        ,INSTRB(anc_id_28,'(]',1,3) -
15888         INSTRB(anc_id_28,'(]',1,2) - 2)
15889 ,SUBSTRB(anc_id_28
15890        ,INSTRB(anc_id_28,'(]',1,3) + 2
15891        ,INSTRB(anc_id_28,'(]',1,4) -
15892         INSTRB(anc_id_28,'(]',1,3) - 2)
15893 ,SUBSTRB(anc_id_28
15894        ,INSTRB(anc_id_28,'(]',1,4) + 2
15895        ,INSTRB(anc_id_28,'(]',1,5) -
15896         INSTRB(anc_id_28,'(]',1,4) - 2)
15897 ,SUBSTRB(anc_id_28
15898        ,INSTRB(anc_id_28,'(]',1,5) + 2
15899        ,INSTRB(anc_id_28,'(]',1,6) -
15900         INSTRB(anc_id_28,'(]',1,5) - 2)
15901 ,SUBSTRB(anc_id_28
15902        ,INSTRB(anc_id_28,'(]',1,6) + 2
15903        ,INSTRB(anc_id_28,'(]',1,7) -
15904         INSTRB(anc_id_28,'(]',1,6) - 2)
15905 ,SUBSTRB(anc_id_28
15906        ,INSTRB(anc_id_28,'(]',1,7) + 2
15907        ,LENGTHB(anc_id_28))
15908 )
15909 
15910 WHEN anc_id_29 IS NOT NULL THEN
15911   INTO xla_ae_header_acs (
15912         ae_header_id , object_version_number
15913       , analytical_criterion_code
15914       , analytical_criterion_type_code
15915       , amb_context_code
15916       , ac1,ac2,ac3,ac4,ac5)
15917 VALUES (ae_header_id, C_OVN
15918 ,SUBSTRB(anc_id_29
15919        ,1
15920        ,INSTRB(anc_id_29,'(]',1,1) -1)
15921 ,SUBSTRB(anc_id_29
15922        ,INSTRB(anc_id_29,'(]',1,1) + 2
15923        ,INSTRB(anc_id_29,'(]',1,2) -
15924         INSTRB(anc_id_29,'(]',1,1) - 2)
15925 ,SUBSTRB(anc_id_29
15926        ,INSTRB(anc_id_29,'(]',1,2) + 2
15927        ,INSTRB(anc_id_29,'(]',1,3) -
15928         INSTRB(anc_id_29,'(]',1,2) - 2)
15929 ,SUBSTRB(anc_id_29
15930        ,INSTRB(anc_id_29,'(]',1,3) + 2
15931        ,INSTRB(anc_id_29,'(]',1,4) -
15932         INSTRB(anc_id_29,'(]',1,3) - 2)
15933 ,SUBSTRB(anc_id_29
15934        ,INSTRB(anc_id_29,'(]',1,4) + 2
15935        ,INSTRB(anc_id_29,'(]',1,5) -
15936         INSTRB(anc_id_29,'(]',1,4) - 2)
15937 ,SUBSTRB(anc_id_29
15938        ,INSTRB(anc_id_29,'(]',1,5) + 2
15939        ,INSTRB(anc_id_29,'(]',1,6) -
15940         INSTRB(anc_id_29,'(]',1,5) - 2)
15941 ,SUBSTRB(anc_id_29
15942        ,INSTRB(anc_id_29,'(]',1,6) + 2
15943        ,INSTRB(anc_id_29,'(]',1,7) -
15944         INSTRB(anc_id_29,'(]',1,6) - 2)
15945 ,SUBSTRB(anc_id_29
15946        ,INSTRB(anc_id_29,'(]',1,7) + 2
15947        ,LENGTHB(anc_id_29))
15948 )
15949 
15950 WHEN anc_id_30 IS NOT NULL THEN
15951   INTO xla_ae_header_acs (
15952         ae_header_id , object_version_number
15953       , analytical_criterion_code
15954       , analytical_criterion_type_code
15955       , amb_context_code
15956       , ac1,ac2,ac3,ac4,ac5)
15957 VALUES (ae_header_id, C_OVN
15958 ,SUBSTRB(anc_id_30
15959        ,1
15960        ,INSTRB(anc_id_30,'(]',1,1) -1)
15961 ,SUBSTRB(anc_id_30
15962        ,INSTRB(anc_id_30,'(]',1,1) + 2
15963        ,INSTRB(anc_id_30,'(]',1,2) -
15964         INSTRB(anc_id_30,'(]',1,1) - 2)
15965 ,SUBSTRB(anc_id_30
15966        ,INSTRB(anc_id_30,'(]',1,2) + 2
15967        ,INSTRB(anc_id_30,'(]',1,3) -
15968         INSTRB(anc_id_30,'(]',1,2) - 2)
15969 ,SUBSTRB(anc_id_30
15970        ,INSTRB(anc_id_30,'(]',1,3) + 2
15971        ,INSTRB(anc_id_30,'(]',1,4) -
15972         INSTRB(anc_id_30,'(]',1,3) - 2)
15973 ,SUBSTRB(anc_id_30
15974        ,INSTRB(anc_id_30,'(]',1,4) + 2
15975        ,INSTRB(anc_id_30,'(]',1,5) -
15976         INSTRB(anc_id_30,'(]',1,4) - 2)
15977 ,SUBSTRB(anc_id_30
15978        ,INSTRB(anc_id_30,'(]',1,5) + 2
15979        ,INSTRB(anc_id_30,'(]',1,6) -
15980         INSTRB(anc_id_30,'(]',1,5) - 2)
15981 ,SUBSTRB(anc_id_30
15982        ,INSTRB(anc_id_30,'(]',1,6) + 2
15983        ,INSTRB(anc_id_30,'(]',1,7) -
15984         INSTRB(anc_id_30,'(]',1,6) - 2)
15985 ,SUBSTRB(anc_id_30
15986        ,INSTRB(anc_id_30,'(]',1,7) + 2
15987        ,LENGTHB(anc_id_30))
15988 )
15989 
15990 WHEN anc_id_31 IS NOT NULL THEN
15991   INTO xla_ae_header_acs (
15992         ae_header_id , object_version_number
15993       , analytical_criterion_code
15994       , analytical_criterion_type_code
15995       , amb_context_code
15996       , ac1,ac2,ac3,ac4,ac5)
15997 VALUES (ae_header_id, C_OVN
15998 ,SUBSTRB(anc_id_31
15999        ,1
16000        ,INSTRB(anc_id_31,'(]',1,1) -1)
16001 ,SUBSTRB(anc_id_31
16002        ,INSTRB(anc_id_31,'(]',1,1) + 2
16003        ,INSTRB(anc_id_31,'(]',1,2) -
16004         INSTRB(anc_id_31,'(]',1,1) - 2)
16005 ,SUBSTRB(anc_id_31
16006        ,INSTRB(anc_id_31,'(]',1,2) + 2
16007        ,INSTRB(anc_id_31,'(]',1,3) -
16008         INSTRB(anc_id_31,'(]',1,2) - 2)
16009 ,SUBSTRB(anc_id_31
16010        ,INSTRB(anc_id_31,'(]',1,3) + 2
16011        ,INSTRB(anc_id_31,'(]',1,4) -
16012         INSTRB(anc_id_31,'(]',1,3) - 2)
16013 ,SUBSTRB(anc_id_31
16014        ,INSTRB(anc_id_31,'(]',1,4) + 2
16015        ,INSTRB(anc_id_31,'(]',1,5) -
16016         INSTRB(anc_id_31,'(]',1,4) - 2)
16017 ,SUBSTRB(anc_id_31
16018        ,INSTRB(anc_id_31,'(]',1,5) + 2
16019        ,INSTRB(anc_id_31,'(]',1,6) -
16020         INSTRB(anc_id_31,'(]',1,5) - 2)
16021 ,SUBSTRB(anc_id_31
16022        ,INSTRB(anc_id_31,'(]',1,6) + 2
16023        ,INSTRB(anc_id_31,'(]',1,7) -
16024         INSTRB(anc_id_31,'(]',1,6) - 2)
16025 ,SUBSTRB(anc_id_31
16026        ,INSTRB(anc_id_31,'(]',1,7) + 2
16027        ,LENGTHB(anc_id_31))
16028 )
16029 
16030 WHEN anc_id_32 IS NOT NULL THEN
16031   INTO xla_ae_header_acs (
16032         ae_header_id , object_version_number
16033       , analytical_criterion_code
16034       , analytical_criterion_type_code
16035       , amb_context_code
16036       , ac1,ac2,ac3,ac4,ac5)
16037 VALUES (ae_header_id, C_OVN
16038 ,SUBSTRB(anc_id_32
16039        ,1
16040        ,INSTRB(anc_id_32,'(]',1,1) -1)
16041 ,SUBSTRB(anc_id_32
16042        ,INSTRB(anc_id_32,'(]',1,1) + 2
16043        ,INSTRB(anc_id_32,'(]',1,2) -
16044         INSTRB(anc_id_32,'(]',1,1) - 2)
16045 ,SUBSTRB(anc_id_32
16046        ,INSTRB(anc_id_32,'(]',1,2) + 2
16047        ,INSTRB(anc_id_32,'(]',1,3) -
16048         INSTRB(anc_id_32,'(]',1,2) - 2)
16049 ,SUBSTRB(anc_id_32
16050        ,INSTRB(anc_id_32,'(]',1,3) + 2
16051        ,INSTRB(anc_id_32,'(]',1,4) -
16052         INSTRB(anc_id_32,'(]',1,3) - 2)
16053 ,SUBSTRB(anc_id_32
16054        ,INSTRB(anc_id_32,'(]',1,4) + 2
16055        ,INSTRB(anc_id_32,'(]',1,5) -
16056         INSTRB(anc_id_32,'(]',1,4) - 2)
16057 ,SUBSTRB(anc_id_32
16058        ,INSTRB(anc_id_32,'(]',1,5) + 2
16059        ,INSTRB(anc_id_32,'(]',1,6) -
16060         INSTRB(anc_id_32,'(]',1,5) - 2)
16061 ,SUBSTRB(anc_id_32
16062        ,INSTRB(anc_id_32,'(]',1,6) + 2
16063        ,INSTRB(anc_id_32,'(]',1,7) -
16064         INSTRB(anc_id_32,'(]',1,6) - 2)
16065 ,SUBSTRB(anc_id_32
16066        ,INSTRB(anc_id_32,'(]',1,7) + 2
16067        ,LENGTHB(anc_id_32))
16068 )
16069 
16070 WHEN anc_id_33 IS NOT NULL THEN
16071   INTO xla_ae_header_acs (
16072         ae_header_id , object_version_number
16073       , analytical_criterion_code
16074       , analytical_criterion_type_code
16075       , amb_context_code
16076       , ac1,ac2,ac3,ac4,ac5)
16077 VALUES (ae_header_id, C_OVN
16078 ,SUBSTRB(anc_id_33
16079        ,1
16080        ,INSTRB(anc_id_33,'(]',1,1) -1)
16081 ,SUBSTRB(anc_id_33
16082        ,INSTRB(anc_id_33,'(]',1,1) + 2
16083        ,INSTRB(anc_id_33,'(]',1,2) -
16084         INSTRB(anc_id_33,'(]',1,1) - 2)
16085 ,SUBSTRB(anc_id_33
16086        ,INSTRB(anc_id_33,'(]',1,2) + 2
16087        ,INSTRB(anc_id_33,'(]',1,3) -
16088         INSTRB(anc_id_33,'(]',1,2) - 2)
16089 ,SUBSTRB(anc_id_33
16090        ,INSTRB(anc_id_33,'(]',1,3) + 2
16091        ,INSTRB(anc_id_33,'(]',1,4) -
16092         INSTRB(anc_id_33,'(]',1,3) - 2)
16093 ,SUBSTRB(anc_id_33
16094        ,INSTRB(anc_id_33,'(]',1,4) + 2
16095        ,INSTRB(anc_id_33,'(]',1,5) -
16096         INSTRB(anc_id_33,'(]',1,4) - 2)
16097 ,SUBSTRB(anc_id_33
16098        ,INSTRB(anc_id_33,'(]',1,5) + 2
16099        ,INSTRB(anc_id_33,'(]',1,6) -
16100         INSTRB(anc_id_33,'(]',1,5) - 2)
16101 ,SUBSTRB(anc_id_33
16102        ,INSTRB(anc_id_33,'(]',1,6) + 2
16103        ,INSTRB(anc_id_33,'(]',1,7) -
16104         INSTRB(anc_id_33,'(]',1,6) - 2)
16105 ,SUBSTRB(anc_id_33
16106        ,INSTRB(anc_id_33,'(]',1,7) + 2
16107        ,LENGTHB(anc_id_33))
16108 )
16109 
16110 WHEN anc_id_34 IS NOT NULL THEN
16111   INTO xla_ae_header_acs (
16112         ae_header_id , object_version_number
16113       , analytical_criterion_code
16114       , analytical_criterion_type_code
16115       , amb_context_code
16116       , ac1,ac2,ac3,ac4,ac5)
16117 VALUES (ae_header_id, C_OVN
16118 ,SUBSTRB(anc_id_34
16119        ,1
16120        ,INSTRB(anc_id_34,'(]',1,1) -1)
16121 ,SUBSTRB(anc_id_34
16122        ,INSTRB(anc_id_34,'(]',1,1) + 2
16123        ,INSTRB(anc_id_34,'(]',1,2) -
16124         INSTRB(anc_id_34,'(]',1,1) - 2)
16125 ,SUBSTRB(anc_id_34
16126        ,INSTRB(anc_id_34,'(]',1,2) + 2
16127        ,INSTRB(anc_id_34,'(]',1,3) -
16128         INSTRB(anc_id_34,'(]',1,2) - 2)
16129 ,SUBSTRB(anc_id_34
16130        ,INSTRB(anc_id_34,'(]',1,3) + 2
16131        ,INSTRB(anc_id_34,'(]',1,4) -
16132         INSTRB(anc_id_34,'(]',1,3) - 2)
16133 ,SUBSTRB(anc_id_34
16134        ,INSTRB(anc_id_34,'(]',1,4) + 2
16135        ,INSTRB(anc_id_34,'(]',1,5) -
16136         INSTRB(anc_id_34,'(]',1,4) - 2)
16137 ,SUBSTRB(anc_id_34
16138        ,INSTRB(anc_id_34,'(]',1,5) + 2
16139        ,INSTRB(anc_id_34,'(]',1,6) -
16140         INSTRB(anc_id_34,'(]',1,5) - 2)
16141 ,SUBSTRB(anc_id_34
16142        ,INSTRB(anc_id_34,'(]',1,6) + 2
16143        ,INSTRB(anc_id_34,'(]',1,7) -
16144         INSTRB(anc_id_34,'(]',1,6) - 2)
16145 ,SUBSTRB(anc_id_34
16146        ,INSTRB(anc_id_34,'(]',1,7) + 2
16147        ,LENGTHB(anc_id_34))
16148 )
16149 
16150 WHEN anc_id_35 IS NOT NULL THEN
16151   INTO xla_ae_header_acs (
16152         ae_header_id , object_version_number
16153       , analytical_criterion_code
16154       , analytical_criterion_type_code
16155       , amb_context_code
16156       , ac1,ac2,ac3,ac4,ac5)
16157 VALUES (ae_header_id, C_OVN
16158 ,SUBSTRB(anc_id_35
16159        ,1
16160        ,INSTRB(anc_id_35,'(]',1,1) -1)
16161 ,SUBSTRB(anc_id_35
16162        ,INSTRB(anc_id_35,'(]',1,1) + 2
16163        ,INSTRB(anc_id_35,'(]',1,2) -
16164         INSTRB(anc_id_35,'(]',1,1) - 2)
16165 ,SUBSTRB(anc_id_35
16166        ,INSTRB(anc_id_35,'(]',1,2) + 2
16167        ,INSTRB(anc_id_35,'(]',1,3) -
16168         INSTRB(anc_id_35,'(]',1,2) - 2)
16169 ,SUBSTRB(anc_id_35
16170        ,INSTRB(anc_id_35,'(]',1,3) + 2
16171        ,INSTRB(anc_id_35,'(]',1,4) -
16172         INSTRB(anc_id_35,'(]',1,3) - 2)
16173 ,SUBSTRB(anc_id_35
16174        ,INSTRB(anc_id_35,'(]',1,4) + 2
16175        ,INSTRB(anc_id_35,'(]',1,5) -
16176         INSTRB(anc_id_35,'(]',1,4) - 2)
16177 ,SUBSTRB(anc_id_35
16178        ,INSTRB(anc_id_35,'(]',1,5) + 2
16179        ,INSTRB(anc_id_35,'(]',1,6) -
16180         INSTRB(anc_id_35,'(]',1,5) - 2)
16181 ,SUBSTRB(anc_id_35
16182        ,INSTRB(anc_id_35,'(]',1,6) + 2
16183        ,INSTRB(anc_id_35,'(]',1,7) -
16184         INSTRB(anc_id_35,'(]',1,6) - 2)
16185 ,SUBSTRB(anc_id_35
16186        ,INSTRB(anc_id_35,'(]',1,7) + 2
16187        ,LENGTHB(anc_id_35))
16188 )
16189 
16190 WHEN anc_id_36 IS NOT NULL THEN
16191   INTO xla_ae_header_acs (
16192         ae_header_id , object_version_number
16193       , analytical_criterion_code
16194       , analytical_criterion_type_code
16195       , amb_context_code
16196       , ac1,ac2,ac3,ac4,ac5)
16197 VALUES (ae_header_id, C_OVN
16198 ,SUBSTRB(anc_id_36
16199        ,1
16200        ,INSTRB(anc_id_36,'(]',1,1) -1)
16201 ,SUBSTRB(anc_id_36
16202        ,INSTRB(anc_id_36,'(]',1,1) + 2
16203        ,INSTRB(anc_id_36,'(]',1,2) -
16204         INSTRB(anc_id_36,'(]',1,1) - 2)
16205 ,SUBSTRB(anc_id_36
16206        ,INSTRB(anc_id_36,'(]',1,2) + 2
16207        ,INSTRB(anc_id_36,'(]',1,3) -
16208         INSTRB(anc_id_36,'(]',1,2) - 2)
16209 ,SUBSTRB(anc_id_36
16210        ,INSTRB(anc_id_36,'(]',1,3) + 2
16211        ,INSTRB(anc_id_36,'(]',1,4) -
16212         INSTRB(anc_id_36,'(]',1,3) - 2)
16213 ,SUBSTRB(anc_id_36
16214        ,INSTRB(anc_id_36,'(]',1,4) + 2
16215        ,INSTRB(anc_id_36,'(]',1,5) -
16216         INSTRB(anc_id_36,'(]',1,4) - 2)
16217 ,SUBSTRB(anc_id_36
16218        ,INSTRB(anc_id_36,'(]',1,5) + 2
16219        ,INSTRB(anc_id_36,'(]',1,6) -
16220         INSTRB(anc_id_36,'(]',1,5) - 2)
16221 ,SUBSTRB(anc_id_36
16222        ,INSTRB(anc_id_36,'(]',1,6) + 2
16223        ,INSTRB(anc_id_36,'(]',1,7) -
16224         INSTRB(anc_id_36,'(]',1,6) - 2)
16225 ,SUBSTRB(anc_id_36
16226        ,INSTRB(anc_id_36,'(]',1,7) + 2
16227        ,LENGTHB(anc_id_36))
16228 )
16229 
16230 WHEN anc_id_37 IS NOT NULL THEN
16231   INTO xla_ae_header_acs (
16232         ae_header_id , object_version_number
16233       , analytical_criterion_code
16234       , analytical_criterion_type_code
16235       , amb_context_code
16236       , ac1,ac2,ac3,ac4,ac5)
16237 VALUES (ae_header_id, C_OVN
16238 ,SUBSTRB(anc_id_37
16239        ,1
16240        ,INSTRB(anc_id_37,'(]',1,1) -1)
16241 ,SUBSTRB(anc_id_37
16242        ,INSTRB(anc_id_37,'(]',1,1) + 2
16243        ,INSTRB(anc_id_37,'(]',1,2) -
16244         INSTRB(anc_id_37,'(]',1,1) - 2)
16245 ,SUBSTRB(anc_id_37
16246        ,INSTRB(anc_id_37,'(]',1,2) + 2
16247        ,INSTRB(anc_id_37,'(]',1,3) -
16248         INSTRB(anc_id_37,'(]',1,2) - 2)
16249 ,SUBSTRB(anc_id_37
16250        ,INSTRB(anc_id_37,'(]',1,3) + 2
16251        ,INSTRB(anc_id_37,'(]',1,4) -
16252         INSTRB(anc_id_37,'(]',1,3) - 2)
16253 ,SUBSTRB(anc_id_37
16254        ,INSTRB(anc_id_37,'(]',1,4) + 2
16255        ,INSTRB(anc_id_37,'(]',1,5) -
16256         INSTRB(anc_id_37,'(]',1,4) - 2)
16257 ,SUBSTRB(anc_id_37
16258        ,INSTRB(anc_id_37,'(]',1,5) + 2
16259        ,INSTRB(anc_id_37,'(]',1,6) -
16260         INSTRB(anc_id_37,'(]',1,5) - 2)
16261 ,SUBSTRB(anc_id_37
16262        ,INSTRB(anc_id_37,'(]',1,6) + 2
16263        ,INSTRB(anc_id_37,'(]',1,7) -
16264         INSTRB(anc_id_37,'(]',1,6) - 2)
16265 ,SUBSTRB(anc_id_37
16266        ,INSTRB(anc_id_37,'(]',1,7) + 2
16267        ,LENGTHB(anc_id_37))
16268 )
16269 
16270 WHEN anc_id_38 IS NOT NULL THEN
16271   INTO xla_ae_header_acs (
16272         ae_header_id , object_version_number
16273       , analytical_criterion_code
16274       , analytical_criterion_type_code
16275       , amb_context_code
16276       , ac1,ac2,ac3,ac4,ac5)
16277 VALUES (ae_header_id, C_OVN
16278 ,SUBSTRB(anc_id_38
16279        ,1
16280        ,INSTRB(anc_id_38,'(]',1,1) -1)
16281 ,SUBSTRB(anc_id_38
16282        ,INSTRB(anc_id_38,'(]',1,1) + 2
16283        ,INSTRB(anc_id_38,'(]',1,2) -
16284         INSTRB(anc_id_38,'(]',1,1) - 2)
16285 ,SUBSTRB(anc_id_38
16286        ,INSTRB(anc_id_38,'(]',1,2) + 2
16287        ,INSTRB(anc_id_38,'(]',1,3) -
16288         INSTRB(anc_id_38,'(]',1,2) - 2)
16289 ,SUBSTRB(anc_id_38
16290        ,INSTRB(anc_id_38,'(]',1,3) + 2
16291        ,INSTRB(anc_id_38,'(]',1,4) -
16292         INSTRB(anc_id_38,'(]',1,3) - 2)
16293 ,SUBSTRB(anc_id_38
16294        ,INSTRB(anc_id_38,'(]',1,4) + 2
16295        ,INSTRB(anc_id_38,'(]',1,5) -
16296         INSTRB(anc_id_38,'(]',1,4) - 2)
16297 ,SUBSTRB(anc_id_38
16298        ,INSTRB(anc_id_38,'(]',1,5) + 2
16299        ,INSTRB(anc_id_38,'(]',1,6) -
16300         INSTRB(anc_id_38,'(]',1,5) - 2)
16301 ,SUBSTRB(anc_id_38
16302        ,INSTRB(anc_id_38,'(]',1,6) + 2
16303        ,INSTRB(anc_id_38,'(]',1,7) -
16304         INSTRB(anc_id_38,'(]',1,6) - 2)
16305 ,SUBSTRB(anc_id_38
16306        ,INSTRB(anc_id_38,'(]',1,7) + 2
16307        ,LENGTHB(anc_id_38))
16308 )
16309 
16310 WHEN anc_id_39 IS NOT NULL THEN
16311   INTO xla_ae_header_acs (
16312         ae_header_id , object_version_number
16313       , analytical_criterion_code
16314       , analytical_criterion_type_code
16315       , amb_context_code
16316       , ac1,ac2,ac3,ac4,ac5)
16317 VALUES (ae_header_id, C_OVN
16318 ,SUBSTRB(anc_id_39
16319        ,1
16320        ,INSTRB(anc_id_39,'(]',1,1) -1)
16321 ,SUBSTRB(anc_id_39
16322        ,INSTRB(anc_id_39,'(]',1,1) + 2
16323        ,INSTRB(anc_id_39,'(]',1,2) -
16324         INSTRB(anc_id_39,'(]',1,1) - 2)
16325 ,SUBSTRB(anc_id_39
16326        ,INSTRB(anc_id_39,'(]',1,2) + 2
16327        ,INSTRB(anc_id_39,'(]',1,3) -
16328         INSTRB(anc_id_39,'(]',1,2) - 2)
16329 ,SUBSTRB(anc_id_39
16330        ,INSTRB(anc_id_39,'(]',1,3) + 2
16331        ,INSTRB(anc_id_39,'(]',1,4) -
16332         INSTRB(anc_id_39,'(]',1,3) - 2)
16333 ,SUBSTRB(anc_id_39
16334        ,INSTRB(anc_id_39,'(]',1,4) + 2
16335        ,INSTRB(anc_id_39,'(]',1,5) -
16336         INSTRB(anc_id_39,'(]',1,4) - 2)
16337 ,SUBSTRB(anc_id_39
16338        ,INSTRB(anc_id_39,'(]',1,5) + 2
16339        ,INSTRB(anc_id_39,'(]',1,6) -
16340         INSTRB(anc_id_39,'(]',1,5) - 2)
16341 ,SUBSTRB(anc_id_39
16342        ,INSTRB(anc_id_39,'(]',1,6) + 2
16343        ,INSTRB(anc_id_39,'(]',1,7) -
16344         INSTRB(anc_id_39,'(]',1,6) - 2)
16345 ,SUBSTRB(anc_id_39
16346        ,INSTRB(anc_id_39,'(]',1,7) + 2
16347        ,LENGTHB(anc_id_39))
16348 )
16349 
16350 WHEN anc_id_40 IS NOT NULL THEN
16351   INTO xla_ae_header_acs (
16352         ae_header_id , object_version_number
16353       , analytical_criterion_code
16354       , analytical_criterion_type_code
16355       , amb_context_code
16356       , ac1,ac2,ac3,ac4,ac5)
16357 VALUES (ae_header_id, C_OVN
16358 ,SUBSTRB(anc_id_40
16359        ,1
16360        ,INSTRB(anc_id_40,'(]',1,1) -1)
16361 ,SUBSTRB(anc_id_40
16362        ,INSTRB(anc_id_40,'(]',1,1) + 2
16363        ,INSTRB(anc_id_40,'(]',1,2) -
16364         INSTRB(anc_id_40,'(]',1,1) - 2)
16365 ,SUBSTRB(anc_id_40
16366        ,INSTRB(anc_id_40,'(]',1,2) + 2
16367        ,INSTRB(anc_id_40,'(]',1,3) -
16368         INSTRB(anc_id_40,'(]',1,2) - 2)
16369 ,SUBSTRB(anc_id_40
16370        ,INSTRB(anc_id_40,'(]',1,3) + 2
16371        ,INSTRB(anc_id_40,'(]',1,4) -
16372         INSTRB(anc_id_40,'(]',1,3) - 2)
16373 ,SUBSTRB(anc_id_40
16374        ,INSTRB(anc_id_40,'(]',1,4) + 2
16375        ,INSTRB(anc_id_40,'(]',1,5) -
16376         INSTRB(anc_id_40,'(]',1,4) - 2)
16377 ,SUBSTRB(anc_id_40
16378        ,INSTRB(anc_id_40,'(]',1,5) + 2
16379        ,INSTRB(anc_id_40,'(]',1,6) -
16380         INSTRB(anc_id_40,'(]',1,5) - 2)
16381 ,SUBSTRB(anc_id_40
16382        ,INSTRB(anc_id_40,'(]',1,6) + 2
16383        ,INSTRB(anc_id_40,'(]',1,7) -
16384         INSTRB(anc_id_40,'(]',1,6) - 2)
16385 ,SUBSTRB(anc_id_40
16386        ,INSTRB(anc_id_40,'(]',1,7) + 2
16387        ,LENGTHB(anc_id_40))
16388 )
16389 
16390 WHEN anc_id_41 IS NOT NULL THEN
16391   INTO xla_ae_header_acs (
16392         ae_header_id , object_version_number
16393       , analytical_criterion_code
16394       , analytical_criterion_type_code
16395       , amb_context_code
16396       , ac1,ac2,ac3,ac4,ac5)
16397 VALUES (ae_header_id, C_OVN
16398 ,SUBSTRB(anc_id_41
16399        ,1
16400        ,INSTRB(anc_id_41,'(]',1,1) -1)
16401 ,SUBSTRB(anc_id_41
16402        ,INSTRB(anc_id_41,'(]',1,1) + 2
16403        ,INSTRB(anc_id_41,'(]',1,2) -
16404         INSTRB(anc_id_41,'(]',1,1) - 2)
16405 ,SUBSTRB(anc_id_41
16406        ,INSTRB(anc_id_41,'(]',1,2) + 2
16407        ,INSTRB(anc_id_41,'(]',1,3) -
16408         INSTRB(anc_id_41,'(]',1,2) - 2)
16409 ,SUBSTRB(anc_id_41
16410        ,INSTRB(anc_id_41,'(]',1,3) + 2
16411        ,INSTRB(anc_id_41,'(]',1,4) -
16412         INSTRB(anc_id_41,'(]',1,3) - 2)
16413 ,SUBSTRB(anc_id_41
16414        ,INSTRB(anc_id_41,'(]',1,4) + 2
16415        ,INSTRB(anc_id_41,'(]',1,5) -
16416         INSTRB(anc_id_41,'(]',1,4) - 2)
16417 ,SUBSTRB(anc_id_41
16418        ,INSTRB(anc_id_41,'(]',1,5) + 2
16419        ,INSTRB(anc_id_41,'(]',1,6) -
16420         INSTRB(anc_id_41,'(]',1,5) - 2)
16421 ,SUBSTRB(anc_id_41
16422        ,INSTRB(anc_id_41,'(]',1,6) + 2
16423        ,INSTRB(anc_id_41,'(]',1,7) -
16424         INSTRB(anc_id_41,'(]',1,6) - 2)
16425 ,SUBSTRB(anc_id_41
16426        ,INSTRB(anc_id_41,'(]',1,7) + 2
16427        ,LENGTHB(anc_id_41))
16428 )
16429 
16430 WHEN anc_id_42 IS NOT NULL THEN
16431   INTO xla_ae_header_acs (
16432         ae_header_id , object_version_number
16433       , analytical_criterion_code
16434       , analytical_criterion_type_code
16435       , amb_context_code
16436       , ac1,ac2,ac3,ac4,ac5)
16437 VALUES (ae_header_id, C_OVN
16438 ,SUBSTRB(anc_id_42
16439        ,1
16440        ,INSTRB(anc_id_42,'(]',1,1) -1)
16441 ,SUBSTRB(anc_id_42
16442        ,INSTRB(anc_id_42,'(]',1,1) + 2
16443        ,INSTRB(anc_id_42,'(]',1,2) -
16444         INSTRB(anc_id_42,'(]',1,1) - 2)
16445 ,SUBSTRB(anc_id_42
16446        ,INSTRB(anc_id_42,'(]',1,2) + 2
16447        ,INSTRB(anc_id_42,'(]',1,3) -
16448         INSTRB(anc_id_42,'(]',1,2) - 2)
16449 ,SUBSTRB(anc_id_42
16450        ,INSTRB(anc_id_42,'(]',1,3) + 2
16451        ,INSTRB(anc_id_42,'(]',1,4) -
16452         INSTRB(anc_id_42,'(]',1,3) - 2)
16453 ,SUBSTRB(anc_id_42
16454        ,INSTRB(anc_id_42,'(]',1,4) + 2
16455        ,INSTRB(anc_id_42,'(]',1,5) -
16456         INSTRB(anc_id_42,'(]',1,4) - 2)
16457 ,SUBSTRB(anc_id_42
16458        ,INSTRB(anc_id_42,'(]',1,5) + 2
16459        ,INSTRB(anc_id_42,'(]',1,6) -
16460         INSTRB(anc_id_42,'(]',1,5) - 2)
16461 ,SUBSTRB(anc_id_42
16462        ,INSTRB(anc_id_42,'(]',1,6) + 2
16463        ,INSTRB(anc_id_42,'(]',1,7) -
16464         INSTRB(anc_id_42,'(]',1,6) - 2)
16465 ,SUBSTRB(anc_id_42
16466        ,INSTRB(anc_id_42,'(]',1,7) + 2
16467        ,LENGTHB(anc_id_42))
16468 )
16469 
16470 WHEN anc_id_43 IS NOT NULL THEN
16471   INTO xla_ae_header_acs (
16472         ae_header_id , object_version_number
16473       , analytical_criterion_code
16474       , analytical_criterion_type_code
16475       , amb_context_code
16476       , ac1,ac2,ac3,ac4,ac5)
16477 VALUES (ae_header_id, C_OVN
16478 ,SUBSTRB(anc_id_43
16479        ,1
16480        ,INSTRB(anc_id_43,'(]',1,1) -1)
16481 ,SUBSTRB(anc_id_43
16482        ,INSTRB(anc_id_43,'(]',1,1) + 2
16483        ,INSTRB(anc_id_43,'(]',1,2) -
16484         INSTRB(anc_id_43,'(]',1,1) - 2)
16485 ,SUBSTRB(anc_id_43
16486        ,INSTRB(anc_id_43,'(]',1,2) + 2
16487        ,INSTRB(anc_id_43,'(]',1,3) -
16488         INSTRB(anc_id_43,'(]',1,2) - 2)
16489 ,SUBSTRB(anc_id_43
16490        ,INSTRB(anc_id_43,'(]',1,3) + 2
16491        ,INSTRB(anc_id_43,'(]',1,4) -
16492         INSTRB(anc_id_43,'(]',1,3) - 2)
16493 ,SUBSTRB(anc_id_43
16494        ,INSTRB(anc_id_43,'(]',1,4) + 2
16495        ,INSTRB(anc_id_43,'(]',1,5) -
16496         INSTRB(anc_id_43,'(]',1,4) - 2)
16497 ,SUBSTRB(anc_id_43
16498        ,INSTRB(anc_id_43,'(]',1,5) + 2
16499        ,INSTRB(anc_id_43,'(]',1,6) -
16500         INSTRB(anc_id_43,'(]',1,5) - 2)
16501 ,SUBSTRB(anc_id_43
16502        ,INSTRB(anc_id_43,'(]',1,6) + 2
16503        ,INSTRB(anc_id_43,'(]',1,7) -
16504         INSTRB(anc_id_43,'(]',1,6) - 2)
16505 ,SUBSTRB(anc_id_43
16506        ,INSTRB(anc_id_43,'(]',1,7) + 2
16507        ,LENGTHB(anc_id_43))
16508 )
16509 
16510 WHEN anc_id_44 IS NOT NULL THEN
16511   INTO xla_ae_header_acs (
16512         ae_header_id , object_version_number
16513       , analytical_criterion_code
16514       , analytical_criterion_type_code
16515       , amb_context_code
16516       , ac1,ac2,ac3,ac4,ac5)
16517 VALUES (ae_header_id, C_OVN
16518 ,SUBSTRB(anc_id_44
16519        ,1
16520        ,INSTRB(anc_id_44,'(]',1,1) -1)
16521 ,SUBSTRB(anc_id_44
16522        ,INSTRB(anc_id_44,'(]',1,1) + 2
16523        ,INSTRB(anc_id_44,'(]',1,2) -
16524         INSTRB(anc_id_44,'(]',1,1) - 2)
16525 ,SUBSTRB(anc_id_44
16526        ,INSTRB(anc_id_44,'(]',1,2) + 2
16527        ,INSTRB(anc_id_44,'(]',1,3) -
16528         INSTRB(anc_id_44,'(]',1,2) - 2)
16529 ,SUBSTRB(anc_id_44
16530        ,INSTRB(anc_id_44,'(]',1,3) + 2
16531        ,INSTRB(anc_id_44,'(]',1,4) -
16532         INSTRB(anc_id_44,'(]',1,3) - 2)
16533 ,SUBSTRB(anc_id_44
16534        ,INSTRB(anc_id_44,'(]',1,4) + 2
16535        ,INSTRB(anc_id_44,'(]',1,5) -
16536         INSTRB(anc_id_44,'(]',1,4) - 2)
16537 ,SUBSTRB(anc_id_44
16538        ,INSTRB(anc_id_44,'(]',1,5) + 2
16539        ,INSTRB(anc_id_44,'(]',1,6) -
16540         INSTRB(anc_id_44,'(]',1,5) - 2)
16541 ,SUBSTRB(anc_id_44
16542        ,INSTRB(anc_id_44,'(]',1,6) + 2
16543        ,INSTRB(anc_id_44,'(]',1,7) -
16544         INSTRB(anc_id_44,'(]',1,6) - 2)
16545 ,SUBSTRB(anc_id_44
16546        ,INSTRB(anc_id_44,'(]',1,7) + 2
16547        ,LENGTHB(anc_id_44))
16548 )
16549 
16550 WHEN anc_id_45 IS NOT NULL THEN
16551   INTO xla_ae_header_acs (
16552         ae_header_id , object_version_number
16553       , analytical_criterion_code
16554       , analytical_criterion_type_code
16555       , amb_context_code
16556       , ac1,ac2,ac3,ac4,ac5)
16557 VALUES (ae_header_id, C_OVN
16558 ,SUBSTRB(anc_id_45
16559        ,1
16560        ,INSTRB(anc_id_45,'(]',1,1) -1)
16561 ,SUBSTRB(anc_id_45
16562        ,INSTRB(anc_id_45,'(]',1,1) + 2
16563        ,INSTRB(anc_id_45,'(]',1,2) -
16564         INSTRB(anc_id_45,'(]',1,1) - 2)
16565 ,SUBSTRB(anc_id_45
16566        ,INSTRB(anc_id_45,'(]',1,2) + 2
16567        ,INSTRB(anc_id_45,'(]',1,3) -
16568         INSTRB(anc_id_45,'(]',1,2) - 2)
16569 ,SUBSTRB(anc_id_45
16570        ,INSTRB(anc_id_45,'(]',1,3) + 2
16571        ,INSTRB(anc_id_45,'(]',1,4) -
16572         INSTRB(anc_id_45,'(]',1,3) - 2)
16573 ,SUBSTRB(anc_id_45
16574        ,INSTRB(anc_id_45,'(]',1,4) + 2
16575        ,INSTRB(anc_id_45,'(]',1,5) -
16576         INSTRB(anc_id_45,'(]',1,4) - 2)
16577 ,SUBSTRB(anc_id_45
16578        ,INSTRB(anc_id_45,'(]',1,5) + 2
16579        ,INSTRB(anc_id_45,'(]',1,6) -
16580         INSTRB(anc_id_45,'(]',1,5) - 2)
16581 ,SUBSTRB(anc_id_45
16582        ,INSTRB(anc_id_45,'(]',1,6) + 2
16583        ,INSTRB(anc_id_45,'(]',1,7) -
16584         INSTRB(anc_id_45,'(]',1,6) - 2)
16585 ,SUBSTRB(anc_id_45
16586        ,INSTRB(anc_id_45,'(]',1,7) + 2
16587        ,LENGTHB(anc_id_45))
16588 )
16589 
16590 WHEN anc_id_46 IS NOT NULL THEN
16591   INTO xla_ae_header_acs (
16592         ae_header_id , object_version_number
16593       , analytical_criterion_code
16594       , analytical_criterion_type_code
16595       , amb_context_code
16596       , ac1,ac2,ac3,ac4,ac5)
16597 VALUES (ae_header_id, C_OVN
16598 ,SUBSTRB(anc_id_46
16599        ,1
16600        ,INSTRB(anc_id_46,'(]',1,1) -1)
16601 ,SUBSTRB(anc_id_46
16602        ,INSTRB(anc_id_46,'(]',1,1) + 2
16603        ,INSTRB(anc_id_46,'(]',1,2) -
16604         INSTRB(anc_id_46,'(]',1,1) - 2)
16605 ,SUBSTRB(anc_id_46
16606        ,INSTRB(anc_id_46,'(]',1,2) + 2
16607        ,INSTRB(anc_id_46,'(]',1,3) -
16608         INSTRB(anc_id_46,'(]',1,2) - 2)
16609 ,SUBSTRB(anc_id_46
16610        ,INSTRB(anc_id_46,'(]',1,3) + 2
16611        ,INSTRB(anc_id_46,'(]',1,4) -
16612         INSTRB(anc_id_46,'(]',1,3) - 2)
16613 ,SUBSTRB(anc_id_46
16614        ,INSTRB(anc_id_46,'(]',1,4) + 2
16615        ,INSTRB(anc_id_46,'(]',1,5) -
16616         INSTRB(anc_id_46,'(]',1,4) - 2)
16617 ,SUBSTRB(anc_id_46
16618        ,INSTRB(anc_id_46,'(]',1,5) + 2
16619        ,INSTRB(anc_id_46,'(]',1,6) -
16620         INSTRB(anc_id_46,'(]',1,5) - 2)
16621 ,SUBSTRB(anc_id_46
16622        ,INSTRB(anc_id_46,'(]',1,6) + 2
16623        ,INSTRB(anc_id_46,'(]',1,7) -
16624         INSTRB(anc_id_46,'(]',1,6) - 2)
16625 ,SUBSTRB(anc_id_46
16626        ,INSTRB(anc_id_46,'(]',1,7) + 2
16627        ,LENGTHB(anc_id_46))
16628 )
16629 
16630 WHEN anc_id_47 IS NOT NULL THEN
16631   INTO xla_ae_header_acs (
16632         ae_header_id , object_version_number
16633       , analytical_criterion_code
16634       , analytical_criterion_type_code
16635       , amb_context_code
16636       , ac1,ac2,ac3,ac4,ac5)
16637 VALUES (ae_header_id, C_OVN
16638 ,SUBSTRB(anc_id_47
16639        ,1
16640        ,INSTRB(anc_id_47,'(]',1,1) -1)
16641 ,SUBSTRB(anc_id_47
16642        ,INSTRB(anc_id_47,'(]',1,1) + 2
16643        ,INSTRB(anc_id_47,'(]',1,2) -
16644         INSTRB(anc_id_47,'(]',1,1) - 2)
16645 ,SUBSTRB(anc_id_47
16646        ,INSTRB(anc_id_47,'(]',1,2) + 2
16647        ,INSTRB(anc_id_47,'(]',1,3) -
16648         INSTRB(anc_id_47,'(]',1,2) - 2)
16649 ,SUBSTRB(anc_id_47
16650        ,INSTRB(anc_id_47,'(]',1,3) + 2
16651        ,INSTRB(anc_id_47,'(]',1,4) -
16652         INSTRB(anc_id_47,'(]',1,3) - 2)
16653 ,SUBSTRB(anc_id_47
16654        ,INSTRB(anc_id_47,'(]',1,4) + 2
16655        ,INSTRB(anc_id_47,'(]',1,5) -
16656         INSTRB(anc_id_47,'(]',1,4) - 2)
16657 ,SUBSTRB(anc_id_47
16658        ,INSTRB(anc_id_47,'(]',1,5) + 2
16659        ,INSTRB(anc_id_47,'(]',1,6) -
16660         INSTRB(anc_id_47,'(]',1,5) - 2)
16661 ,SUBSTRB(anc_id_47
16662        ,INSTRB(anc_id_47,'(]',1,6) + 2
16663        ,INSTRB(anc_id_47,'(]',1,7) -
16664         INSTRB(anc_id_47,'(]',1,6) - 2)
16665 ,SUBSTRB(anc_id_47
16666        ,INSTRB(anc_id_47,'(]',1,7) + 2
16667        ,LENGTHB(anc_id_47))
16668 )
16669 
16670 WHEN anc_id_48 IS NOT NULL THEN
16671   INTO xla_ae_header_acs (
16672         ae_header_id , object_version_number
16673       , analytical_criterion_code
16674       , analytical_criterion_type_code
16675       , amb_context_code
16676       , ac1,ac2,ac3,ac4,ac5)
16677 VALUES (ae_header_id, C_OVN
16678 ,SUBSTRB(anc_id_48
16679        ,1
16680        ,INSTRB(anc_id_48,'(]',1,1) -1)
16681 ,SUBSTRB(anc_id_48
16682        ,INSTRB(anc_id_48,'(]',1,1) + 2
16683        ,INSTRB(anc_id_48,'(]',1,2) -
16684         INSTRB(anc_id_48,'(]',1,1) - 2)
16685 ,SUBSTRB(anc_id_48
16686        ,INSTRB(anc_id_48,'(]',1,2) + 2
16687        ,INSTRB(anc_id_48,'(]',1,3) -
16688         INSTRB(anc_id_48,'(]',1,2) - 2)
16689 ,SUBSTRB(anc_id_48
16690        ,INSTRB(anc_id_48,'(]',1,3) + 2
16691        ,INSTRB(anc_id_48,'(]',1,4) -
16692         INSTRB(anc_id_48,'(]',1,3) - 2)
16693 ,SUBSTRB(anc_id_48
16694        ,INSTRB(anc_id_48,'(]',1,4) + 2
16695        ,INSTRB(anc_id_48,'(]',1,5) -
16696         INSTRB(anc_id_48,'(]',1,4) - 2)
16697 ,SUBSTRB(anc_id_48
16698        ,INSTRB(anc_id_48,'(]',1,5) + 2
16699        ,INSTRB(anc_id_48,'(]',1,6) -
16700         INSTRB(anc_id_48,'(]',1,5) - 2)
16701 ,SUBSTRB(anc_id_48
16702        ,INSTRB(anc_id_48,'(]',1,6) + 2
16703        ,INSTRB(anc_id_48,'(]',1,7) -
16704         INSTRB(anc_id_48,'(]',1,6) - 2)
16705 ,SUBSTRB(anc_id_48
16706        ,INSTRB(anc_id_48,'(]',1,7) + 2
16707        ,LENGTHB(anc_id_48))
16708 )
16709 
16710 WHEN anc_id_49 IS NOT NULL THEN
16711   INTO xla_ae_header_acs (
16712         ae_header_id , object_version_number
16713       , analytical_criterion_code
16714       , analytical_criterion_type_code
16715       , amb_context_code
16716       , ac1,ac2,ac3,ac4,ac5)
16717 VALUES (ae_header_id, C_OVN
16718 ,SUBSTRB(anc_id_49
16719        ,1
16720        ,INSTRB(anc_id_49,'(]',1,1) -1)
16721 ,SUBSTRB(anc_id_49
16722        ,INSTRB(anc_id_49,'(]',1,1) + 2
16723        ,INSTRB(anc_id_49,'(]',1,2) -
16724         INSTRB(anc_id_49,'(]',1,1) - 2)
16725 ,SUBSTRB(anc_id_49
16726        ,INSTRB(anc_id_49,'(]',1,2) + 2
16727        ,INSTRB(anc_id_49,'(]',1,3) -
16728         INSTRB(anc_id_49,'(]',1,2) - 2)
16729 ,SUBSTRB(anc_id_49
16730        ,INSTRB(anc_id_49,'(]',1,3) + 2
16731        ,INSTRB(anc_id_49,'(]',1,4) -
16732         INSTRB(anc_id_49,'(]',1,3) - 2)
16733 ,SUBSTRB(anc_id_49
16734        ,INSTRB(anc_id_49,'(]',1,4) + 2
16735        ,INSTRB(anc_id_49,'(]',1,5) -
16736         INSTRB(anc_id_49,'(]',1,4) - 2)
16737 ,SUBSTRB(anc_id_49
16738        ,INSTRB(anc_id_49,'(]',1,5) + 2
16739        ,INSTRB(anc_id_49,'(]',1,6) -
16740         INSTRB(anc_id_49,'(]',1,5) - 2)
16741 ,SUBSTRB(anc_id_49
16742        ,INSTRB(anc_id_49,'(]',1,6) + 2
16743        ,INSTRB(anc_id_49,'(]',1,7) -
16744         INSTRB(anc_id_49,'(]',1,6) - 2)
16745 ,SUBSTRB(anc_id_49
16746        ,INSTRB(anc_id_49,'(]',1,7) + 2
16747        ,LENGTHB(anc_id_49))
16748 )
16749 
16750 WHEN anc_id_50 IS NOT NULL THEN
16751   INTO xla_ae_header_acs (
16752         ae_header_id , object_version_number
16753       , analytical_criterion_code
16754       , analytical_criterion_type_code
16755       , amb_context_code
16756       , ac1,ac2,ac3,ac4,ac5)
16757 VALUES (ae_header_id, C_OVN
16758 ,SUBSTRB(anc_id_50
16759        ,1
16760        ,INSTRB(anc_id_50,'(]',1,1) -1)
16761 ,SUBSTRB(anc_id_50
16762        ,INSTRB(anc_id_50,'(]',1,1) + 2
16763        ,INSTRB(anc_id_50,'(]',1,2) -
16764         INSTRB(anc_id_50,'(]',1,1) - 2)
16765 ,SUBSTRB(anc_id_50
16766        ,INSTRB(anc_id_50,'(]',1,2) + 2
16767        ,INSTRB(anc_id_50,'(]',1,3) -
16768         INSTRB(anc_id_50,'(]',1,2) - 2)
16769 ,SUBSTRB(anc_id_50
16770        ,INSTRB(anc_id_50,'(]',1,3) + 2
16771        ,INSTRB(anc_id_50,'(]',1,4) -
16772         INSTRB(anc_id_50,'(]',1,3) - 2)
16773 ,SUBSTRB(anc_id_50
16774        ,INSTRB(anc_id_50,'(]',1,4) + 2
16775        ,INSTRB(anc_id_50,'(]',1,5) -
16776         INSTRB(anc_id_50,'(]',1,4) - 2)
16777 ,SUBSTRB(anc_id_50
16778        ,INSTRB(anc_id_50,'(]',1,5) + 2
16779        ,INSTRB(anc_id_50,'(]',1,6) -
16780         INSTRB(anc_id_50,'(]',1,5) - 2)
16781 ,SUBSTRB(anc_id_50
16782        ,INSTRB(anc_id_50,'(]',1,6) + 2
16783        ,INSTRB(anc_id_50,'(]',1,7) -
16784         INSTRB(anc_id_50,'(]',1,6) - 2)
16785 ,SUBSTRB(anc_id_50
16786        ,INSTRB(anc_id_50,'(]',1,7) + 2
16787        ,LENGTHB(anc_id_50))
16788 )
16789 
16790 WHEN anc_id_51 IS NOT NULL THEN
16791   INTO xla_ae_header_acs (
16792         ae_header_id , object_version_number
16793       , analytical_criterion_code
16794       , analytical_criterion_type_code
16795       , amb_context_code
16796       , ac1,ac2,ac3,ac4,ac5)
16797 VALUES (ae_header_id, C_OVN
16798 ,SUBSTRB(anc_id_51
16799        ,1
16800        ,INSTRB(anc_id_51,'(]',1,1) -1)
16801 ,SUBSTRB(anc_id_51
16802        ,INSTRB(anc_id_51,'(]',1,1) + 2
16803        ,INSTRB(anc_id_51,'(]',1,2) -
16804         INSTRB(anc_id_51,'(]',1,1) - 2)
16805 ,SUBSTRB(anc_id_51
16806        ,INSTRB(anc_id_51,'(]',1,2) + 2
16807        ,INSTRB(anc_id_51,'(]',1,3) -
16808         INSTRB(anc_id_51,'(]',1,2) - 2)
16809 ,SUBSTRB(anc_id_51
16810        ,INSTRB(anc_id_51,'(]',1,3) + 2
16811        ,INSTRB(anc_id_51,'(]',1,4) -
16812         INSTRB(anc_id_51,'(]',1,3) - 2)
16813 ,SUBSTRB(anc_id_51
16814        ,INSTRB(anc_id_51,'(]',1,4) + 2
16815        ,INSTRB(anc_id_51,'(]',1,5) -
16816         INSTRB(anc_id_51,'(]',1,4) - 2)
16817 ,SUBSTRB(anc_id_51
16818        ,INSTRB(anc_id_51,'(]',1,5) + 2
16819        ,INSTRB(anc_id_51,'(]',1,6) -
16820         INSTRB(anc_id_51,'(]',1,5) - 2)
16821 ,SUBSTRB(anc_id_51
16822        ,INSTRB(anc_id_51,'(]',1,6) + 2
16823        ,INSTRB(anc_id_51,'(]',1,7) -
16824         INSTRB(anc_id_51,'(]',1,6) - 2)
16825 ,SUBSTRB(anc_id_51
16826        ,INSTRB(anc_id_51,'(]',1,7) + 2
16827        ,LENGTHB(anc_id_51))
16828 )
16829 
16830 WHEN anc_id_52 IS NOT NULL THEN
16831   INTO xla_ae_header_acs (
16832         ae_header_id , object_version_number
16833       , analytical_criterion_code
16834       , analytical_criterion_type_code
16835       , amb_context_code
16836       , ac1,ac2,ac3,ac4,ac5)
16837 VALUES (ae_header_id, C_OVN
16838 ,SUBSTRB(anc_id_52
16839        ,1
16840        ,INSTRB(anc_id_52,'(]',1,1) -1)
16841 ,SUBSTRB(anc_id_52
16842        ,INSTRB(anc_id_52,'(]',1,1) + 2
16843        ,INSTRB(anc_id_52,'(]',1,2) -
16844         INSTRB(anc_id_52,'(]',1,1) - 2)
16845 ,SUBSTRB(anc_id_52
16846        ,INSTRB(anc_id_52,'(]',1,2) + 2
16847        ,INSTRB(anc_id_52,'(]',1,3) -
16848         INSTRB(anc_id_52,'(]',1,2) - 2)
16849 ,SUBSTRB(anc_id_52
16850        ,INSTRB(anc_id_52,'(]',1,3) + 2
16851        ,INSTRB(anc_id_52,'(]',1,4) -
16852         INSTRB(anc_id_52,'(]',1,3) - 2)
16853 ,SUBSTRB(anc_id_52
16854        ,INSTRB(anc_id_52,'(]',1,4) + 2
16855        ,INSTRB(anc_id_52,'(]',1,5) -
16856         INSTRB(anc_id_52,'(]',1,4) - 2)
16857 ,SUBSTRB(anc_id_52
16858        ,INSTRB(anc_id_52,'(]',1,5) + 2
16859        ,INSTRB(anc_id_52,'(]',1,6) -
16860         INSTRB(anc_id_52,'(]',1,5) - 2)
16861 ,SUBSTRB(anc_id_52
16862        ,INSTRB(anc_id_52,'(]',1,6) + 2
16863        ,INSTRB(anc_id_52,'(]',1,7) -
16864         INSTRB(anc_id_52,'(]',1,6) - 2)
16865 ,SUBSTRB(anc_id_52
16866        ,INSTRB(anc_id_52,'(]',1,7) + 2
16867        ,LENGTHB(anc_id_52))
16868 )
16869 
16870 WHEN anc_id_53 IS NOT NULL THEN
16871   INTO xla_ae_header_acs (
16872         ae_header_id , object_version_number
16873       , analytical_criterion_code
16874       , analytical_criterion_type_code
16875       , amb_context_code
16876       , ac1,ac2,ac3,ac4,ac5)
16877 VALUES (ae_header_id, C_OVN
16878 ,SUBSTRB(anc_id_53
16879        ,1
16880        ,INSTRB(anc_id_53,'(]',1,1) -1)
16881 ,SUBSTRB(anc_id_53
16882        ,INSTRB(anc_id_53,'(]',1,1) + 2
16883        ,INSTRB(anc_id_53,'(]',1,2) -
16884         INSTRB(anc_id_53,'(]',1,1) - 2)
16885 ,SUBSTRB(anc_id_53
16886        ,INSTRB(anc_id_53,'(]',1,2) + 2
16887        ,INSTRB(anc_id_53,'(]',1,3) -
16888         INSTRB(anc_id_53,'(]',1,2) - 2)
16889 ,SUBSTRB(anc_id_53
16890        ,INSTRB(anc_id_53,'(]',1,3) + 2
16891        ,INSTRB(anc_id_53,'(]',1,4) -
16892         INSTRB(anc_id_53,'(]',1,3) - 2)
16893 ,SUBSTRB(anc_id_53
16894        ,INSTRB(anc_id_53,'(]',1,4) + 2
16895        ,INSTRB(anc_id_53,'(]',1,5) -
16896         INSTRB(anc_id_53,'(]',1,4) - 2)
16897 ,SUBSTRB(anc_id_53
16898        ,INSTRB(anc_id_53,'(]',1,5) + 2
16899        ,INSTRB(anc_id_53,'(]',1,6) -
16900         INSTRB(anc_id_53,'(]',1,5) - 2)
16901 ,SUBSTRB(anc_id_53
16902        ,INSTRB(anc_id_53,'(]',1,6) + 2
16903        ,INSTRB(anc_id_53,'(]',1,7) -
16904         INSTRB(anc_id_53,'(]',1,6) - 2)
16905 ,SUBSTRB(anc_id_53
16906        ,INSTRB(anc_id_53,'(]',1,7) + 2
16907        ,LENGTHB(anc_id_53))
16908 )
16909 
16910 WHEN anc_id_54 IS NOT NULL THEN
16911   INTO xla_ae_header_acs (
16912         ae_header_id , object_version_number
16913       , analytical_criterion_code
16914       , analytical_criterion_type_code
16915       , amb_context_code
16916       , ac1,ac2,ac3,ac4,ac5)
16917 VALUES (ae_header_id, C_OVN
16918 ,SUBSTRB(anc_id_54
16919        ,1
16920        ,INSTRB(anc_id_54,'(]',1,1) -1)
16921 ,SUBSTRB(anc_id_54
16922        ,INSTRB(anc_id_54,'(]',1,1) + 2
16923        ,INSTRB(anc_id_54,'(]',1,2) -
16924         INSTRB(anc_id_54,'(]',1,1) - 2)
16925 ,SUBSTRB(anc_id_54
16926        ,INSTRB(anc_id_54,'(]',1,2) + 2
16927        ,INSTRB(anc_id_54,'(]',1,3) -
16928         INSTRB(anc_id_54,'(]',1,2) - 2)
16929 ,SUBSTRB(anc_id_54
16930        ,INSTRB(anc_id_54,'(]',1,3) + 2
16931        ,INSTRB(anc_id_54,'(]',1,4) -
16932         INSTRB(anc_id_54,'(]',1,3) - 2)
16933 ,SUBSTRB(anc_id_54
16934        ,INSTRB(anc_id_54,'(]',1,4) + 2
16935        ,INSTRB(anc_id_54,'(]',1,5) -
16936         INSTRB(anc_id_54,'(]',1,4) - 2)
16937 ,SUBSTRB(anc_id_54
16938        ,INSTRB(anc_id_54,'(]',1,5) + 2
16939        ,INSTRB(anc_id_54,'(]',1,6) -
16940         INSTRB(anc_id_54,'(]',1,5) - 2)
16941 ,SUBSTRB(anc_id_54
16942        ,INSTRB(anc_id_54,'(]',1,6) + 2
16943        ,INSTRB(anc_id_54,'(]',1,7) -
16944         INSTRB(anc_id_54,'(]',1,6) - 2)
16945 ,SUBSTRB(anc_id_54
16946        ,INSTRB(anc_id_54,'(]',1,7) + 2
16947        ,LENGTHB(anc_id_54))
16948 )
16949 
16950 WHEN anc_id_55 IS NOT NULL THEN
16951   INTO xla_ae_header_acs (
16952         ae_header_id , object_version_number
16953       , analytical_criterion_code
16954       , analytical_criterion_type_code
16955       , amb_context_code
16956       , ac1,ac2,ac3,ac4,ac5)
16957 VALUES (ae_header_id, C_OVN
16958 ,SUBSTRB(anc_id_55
16959        ,1
16960        ,INSTRB(anc_id_55,'(]',1,1) -1)
16961 ,SUBSTRB(anc_id_55
16962        ,INSTRB(anc_id_55,'(]',1,1) + 2
16963        ,INSTRB(anc_id_55,'(]',1,2) -
16964         INSTRB(anc_id_55,'(]',1,1) - 2)
16965 ,SUBSTRB(anc_id_55
16966        ,INSTRB(anc_id_55,'(]',1,2) + 2
16967        ,INSTRB(anc_id_55,'(]',1,3) -
16968         INSTRB(anc_id_55,'(]',1,2) - 2)
16969 ,SUBSTRB(anc_id_55
16970        ,INSTRB(anc_id_55,'(]',1,3) + 2
16971        ,INSTRB(anc_id_55,'(]',1,4) -
16972         INSTRB(anc_id_55,'(]',1,3) - 2)
16973 ,SUBSTRB(anc_id_55
16974        ,INSTRB(anc_id_55,'(]',1,4) + 2
16975        ,INSTRB(anc_id_55,'(]',1,5) -
16976         INSTRB(anc_id_55,'(]',1,4) - 2)
16977 ,SUBSTRB(anc_id_55
16978        ,INSTRB(anc_id_55,'(]',1,5) + 2
16979        ,INSTRB(anc_id_55,'(]',1,6) -
16980         INSTRB(anc_id_55,'(]',1,5) - 2)
16981 ,SUBSTRB(anc_id_55
16982        ,INSTRB(anc_id_55,'(]',1,6) + 2
16983        ,INSTRB(anc_id_55,'(]',1,7) -
16984         INSTRB(anc_id_55,'(]',1,6) - 2)
16985 ,SUBSTRB(anc_id_55
16986        ,INSTRB(anc_id_55,'(]',1,7) + 2
16987        ,LENGTHB(anc_id_55))
16988 )
16989 
16990 WHEN anc_id_56 IS NOT NULL THEN
16991   INTO xla_ae_header_acs (
16992         ae_header_id , object_version_number
16993       , analytical_criterion_code
16994       , analytical_criterion_type_code
16995       , amb_context_code
16996       , ac1,ac2,ac3,ac4,ac5)
16997 VALUES (ae_header_id, C_OVN
16998 ,SUBSTRB(anc_id_56
16999        ,1
17000        ,INSTRB(anc_id_56,'(]',1,1) -1)
17001 ,SUBSTRB(anc_id_56
17002        ,INSTRB(anc_id_56,'(]',1,1) + 2
17003        ,INSTRB(anc_id_56,'(]',1,2) -
17004         INSTRB(anc_id_56,'(]',1,1) - 2)
17005 ,SUBSTRB(anc_id_56
17006        ,INSTRB(anc_id_56,'(]',1,2) + 2
17007        ,INSTRB(anc_id_56,'(]',1,3) -
17008         INSTRB(anc_id_56,'(]',1,2) - 2)
17009 ,SUBSTRB(anc_id_56
17010        ,INSTRB(anc_id_56,'(]',1,3) + 2
17011        ,INSTRB(anc_id_56,'(]',1,4) -
17012         INSTRB(anc_id_56,'(]',1,3) - 2)
17013 ,SUBSTRB(anc_id_56
17014        ,INSTRB(anc_id_56,'(]',1,4) + 2
17015        ,INSTRB(anc_id_56,'(]',1,5) -
17016         INSTRB(anc_id_56,'(]',1,4) - 2)
17017 ,SUBSTRB(anc_id_56
17018        ,INSTRB(anc_id_56,'(]',1,5) + 2
17019        ,INSTRB(anc_id_56,'(]',1,6) -
17020         INSTRB(anc_id_56,'(]',1,5) - 2)
17021 ,SUBSTRB(anc_id_56
17022        ,INSTRB(anc_id_56,'(]',1,6) + 2
17023        ,INSTRB(anc_id_56,'(]',1,7) -
17024         INSTRB(anc_id_56,'(]',1,6) - 2)
17025 ,SUBSTRB(anc_id_56
17026        ,INSTRB(anc_id_56,'(]',1,7) + 2
17027        ,LENGTHB(anc_id_56))
17028 )
17029 
17030 WHEN anc_id_57 IS NOT NULL THEN
17031   INTO xla_ae_header_acs (
17032         ae_header_id , object_version_number
17033       , analytical_criterion_code
17034       , analytical_criterion_type_code
17035       , amb_context_code
17036       , ac1,ac2,ac3,ac4,ac5)
17037 VALUES (ae_header_id, C_OVN
17038 ,SUBSTRB(anc_id_57
17039        ,1
17040        ,INSTRB(anc_id_57,'(]',1,1) -1)
17041 ,SUBSTRB(anc_id_57
17042        ,INSTRB(anc_id_57,'(]',1,1) + 2
17043        ,INSTRB(anc_id_57,'(]',1,2) -
17044         INSTRB(anc_id_57,'(]',1,1) - 2)
17045 ,SUBSTRB(anc_id_57
17046        ,INSTRB(anc_id_57,'(]',1,2) + 2
17047        ,INSTRB(anc_id_57,'(]',1,3) -
17048         INSTRB(anc_id_57,'(]',1,2) - 2)
17049 ,SUBSTRB(anc_id_57
17050        ,INSTRB(anc_id_57,'(]',1,3) + 2
17051        ,INSTRB(anc_id_57,'(]',1,4) -
17052         INSTRB(anc_id_57,'(]',1,3) - 2)
17053 ,SUBSTRB(anc_id_57
17054        ,INSTRB(anc_id_57,'(]',1,4) + 2
17055        ,INSTRB(anc_id_57,'(]',1,5) -
17056         INSTRB(anc_id_57,'(]',1,4) - 2)
17057 ,SUBSTRB(anc_id_57
17058        ,INSTRB(anc_id_57,'(]',1,5) + 2
17059        ,INSTRB(anc_id_57,'(]',1,6) -
17060         INSTRB(anc_id_57,'(]',1,5) - 2)
17061 ,SUBSTRB(anc_id_57
17062        ,INSTRB(anc_id_57,'(]',1,6) + 2
17063        ,INSTRB(anc_id_57,'(]',1,7) -
17064         INSTRB(anc_id_57,'(]',1,6) - 2)
17065 ,SUBSTRB(anc_id_57
17066        ,INSTRB(anc_id_57,'(]',1,7) + 2
17067        ,LENGTHB(anc_id_57))
17068 )
17069 
17070 WHEN anc_id_58 IS NOT NULL THEN
17071   INTO xla_ae_header_acs (
17072         ae_header_id , object_version_number
17073       , analytical_criterion_code
17074       , analytical_criterion_type_code
17075       , amb_context_code
17076       , ac1,ac2,ac3,ac4,ac5)
17077 VALUES (ae_header_id, C_OVN
17078 ,SUBSTRB(anc_id_58
17079        ,1
17080        ,INSTRB(anc_id_58,'(]',1,1) -1)
17081 ,SUBSTRB(anc_id_58
17082        ,INSTRB(anc_id_58,'(]',1,1) + 2
17083        ,INSTRB(anc_id_58,'(]',1,2) -
17084         INSTRB(anc_id_58,'(]',1,1) - 2)
17085 ,SUBSTRB(anc_id_58
17086        ,INSTRB(anc_id_58,'(]',1,2) + 2
17087        ,INSTRB(anc_id_58,'(]',1,3) -
17088         INSTRB(anc_id_58,'(]',1,2) - 2)
17089 ,SUBSTRB(anc_id_58
17090        ,INSTRB(anc_id_58,'(]',1,3) + 2
17091        ,INSTRB(anc_id_58,'(]',1,4) -
17092         INSTRB(anc_id_58,'(]',1,3) - 2)
17093 ,SUBSTRB(anc_id_58
17094        ,INSTRB(anc_id_58,'(]',1,4) + 2
17095        ,INSTRB(anc_id_58,'(]',1,5) -
17096         INSTRB(anc_id_58,'(]',1,4) - 2)
17097 ,SUBSTRB(anc_id_58
17098        ,INSTRB(anc_id_58,'(]',1,5) + 2
17099        ,INSTRB(anc_id_58,'(]',1,6) -
17100         INSTRB(anc_id_58,'(]',1,5) - 2)
17101 ,SUBSTRB(anc_id_58
17102        ,INSTRB(anc_id_58,'(]',1,6) + 2
17103        ,INSTRB(anc_id_58,'(]',1,7) -
17104         INSTRB(anc_id_58,'(]',1,6) - 2)
17105 ,SUBSTRB(anc_id_58
17106        ,INSTRB(anc_id_58,'(]',1,7) + 2
17107        ,LENGTHB(anc_id_58))
17108 )
17109 
17110 WHEN anc_id_59 IS NOT NULL THEN
17111   INTO xla_ae_header_acs (
17112         ae_header_id , object_version_number
17113       , analytical_criterion_code
17114       , analytical_criterion_type_code
17115       , amb_context_code
17116       , ac1,ac2,ac3,ac4,ac5)
17117 VALUES (ae_header_id, C_OVN
17118 ,SUBSTRB(anc_id_59
17119        ,1
17120        ,INSTRB(anc_id_59,'(]',1,1) -1)
17121 ,SUBSTRB(anc_id_59
17122        ,INSTRB(anc_id_59,'(]',1,1) + 2
17123        ,INSTRB(anc_id_59,'(]',1,2) -
17124         INSTRB(anc_id_59,'(]',1,1) - 2)
17125 ,SUBSTRB(anc_id_59
17126        ,INSTRB(anc_id_59,'(]',1,2) + 2
17127        ,INSTRB(anc_id_59,'(]',1,3) -
17128         INSTRB(anc_id_59,'(]',1,2) - 2)
17129 ,SUBSTRB(anc_id_59
17130        ,INSTRB(anc_id_59,'(]',1,3) + 2
17131        ,INSTRB(anc_id_59,'(]',1,4) -
17132         INSTRB(anc_id_59,'(]',1,3) - 2)
17133 ,SUBSTRB(anc_id_59
17134        ,INSTRB(anc_id_59,'(]',1,4) + 2
17135        ,INSTRB(anc_id_59,'(]',1,5) -
17136         INSTRB(anc_id_59,'(]',1,4) - 2)
17137 ,SUBSTRB(anc_id_59
17138        ,INSTRB(anc_id_59,'(]',1,5) + 2
17139        ,INSTRB(anc_id_59,'(]',1,6) -
17140         INSTRB(anc_id_59,'(]',1,5) - 2)
17141 ,SUBSTRB(anc_id_59
17142        ,INSTRB(anc_id_59,'(]',1,6) + 2
17143        ,INSTRB(anc_id_59,'(]',1,7) -
17144         INSTRB(anc_id_59,'(]',1,6) - 2)
17145 ,SUBSTRB(anc_id_59
17146        ,INSTRB(anc_id_59,'(]',1,7) + 2
17147        ,LENGTHB(anc_id_59))
17148 )
17149 
17150 WHEN anc_id_60 IS NOT NULL THEN
17151   INTO xla_ae_header_acs (
17152         ae_header_id , object_version_number
17153       , analytical_criterion_code
17154       , analytical_criterion_type_code
17155       , amb_context_code
17156       , ac1,ac2,ac3,ac4,ac5)
17157 VALUES (ae_header_id, C_OVN
17158 ,SUBSTRB(anc_id_60
17159        ,1
17160        ,INSTRB(anc_id_60,'(]',1,1) -1)
17161 ,SUBSTRB(anc_id_60
17162        ,INSTRB(anc_id_60,'(]',1,1) + 2
17163        ,INSTRB(anc_id_60,'(]',1,2) -
17164         INSTRB(anc_id_60,'(]',1,1) - 2)
17165 ,SUBSTRB(anc_id_60
17166        ,INSTRB(anc_id_60,'(]',1,2) + 2
17167        ,INSTRB(anc_id_60,'(]',1,3) -
17168         INSTRB(anc_id_60,'(]',1,2) - 2)
17169 ,SUBSTRB(anc_id_60
17170        ,INSTRB(anc_id_60,'(]',1,3) + 2
17171        ,INSTRB(anc_id_60,'(]',1,4) -
17172         INSTRB(anc_id_60,'(]',1,3) - 2)
17173 ,SUBSTRB(anc_id_60
17174        ,INSTRB(anc_id_60,'(]',1,4) + 2
17175        ,INSTRB(anc_id_60,'(]',1,5) -
17176         INSTRB(anc_id_60,'(]',1,4) - 2)
17177 ,SUBSTRB(anc_id_60
17178        ,INSTRB(anc_id_60,'(]',1,5) + 2
17179        ,INSTRB(anc_id_60,'(]',1,6) -
17180         INSTRB(anc_id_60,'(]',1,5) - 2)
17181 ,SUBSTRB(anc_id_60
17182        ,INSTRB(anc_id_60,'(]',1,6) + 2
17183        ,INSTRB(anc_id_60,'(]',1,7) -
17184         INSTRB(anc_id_60,'(]',1,6) - 2)
17185 ,SUBSTRB(anc_id_60
17186        ,INSTRB(anc_id_60,'(]',1,7) + 2
17187        ,LENGTHB(anc_id_60))
17188 )
17189 
17190 WHEN anc_id_61 IS NOT NULL THEN
17191   INTO xla_ae_header_acs (
17192         ae_header_id , object_version_number
17193       , analytical_criterion_code
17194       , analytical_criterion_type_code
17195       , amb_context_code
17196       , ac1,ac2,ac3,ac4,ac5)
17197 VALUES (ae_header_id, C_OVN
17198 ,SUBSTRB(anc_id_61
17199        ,1
17200        ,INSTRB(anc_id_61,'(]',1,1) -1)
17201 ,SUBSTRB(anc_id_61
17202        ,INSTRB(anc_id_61,'(]',1,1) + 2
17203        ,INSTRB(anc_id_61,'(]',1,2) -
17204         INSTRB(anc_id_61,'(]',1,1) - 2)
17205 ,SUBSTRB(anc_id_61
17206        ,INSTRB(anc_id_61,'(]',1,2) + 2
17207        ,INSTRB(anc_id_61,'(]',1,3) -
17208         INSTRB(anc_id_61,'(]',1,2) - 2)
17209 ,SUBSTRB(anc_id_61
17210        ,INSTRB(anc_id_61,'(]',1,3) + 2
17211        ,INSTRB(anc_id_61,'(]',1,4) -
17212         INSTRB(anc_id_61,'(]',1,3) - 2)
17213 ,SUBSTRB(anc_id_61
17214        ,INSTRB(anc_id_61,'(]',1,4) + 2
17215        ,INSTRB(anc_id_61,'(]',1,5) -
17216         INSTRB(anc_id_61,'(]',1,4) - 2)
17217 ,SUBSTRB(anc_id_61
17218        ,INSTRB(anc_id_61,'(]',1,5) + 2
17219        ,INSTRB(anc_id_61,'(]',1,6) -
17220         INSTRB(anc_id_61,'(]',1,5) - 2)
17221 ,SUBSTRB(anc_id_61
17222        ,INSTRB(anc_id_61,'(]',1,6) + 2
17223        ,INSTRB(anc_id_61,'(]',1,7) -
17224         INSTRB(anc_id_61,'(]',1,6) - 2)
17225 ,SUBSTRB(anc_id_61
17226        ,INSTRB(anc_id_61,'(]',1,7) + 2
17227        ,LENGTHB(anc_id_61))
17228 )
17229 
17230 WHEN anc_id_62 IS NOT NULL THEN
17231   INTO xla_ae_header_acs (
17232         ae_header_id , object_version_number
17233       , analytical_criterion_code
17234       , analytical_criterion_type_code
17235       , amb_context_code
17236       , ac1,ac2,ac3,ac4,ac5)
17237 VALUES (ae_header_id, C_OVN
17238 ,SUBSTRB(anc_id_62
17239        ,1
17240        ,INSTRB(anc_id_62,'(]',1,1) -1)
17241 ,SUBSTRB(anc_id_62
17242        ,INSTRB(anc_id_62,'(]',1,1) + 2
17243        ,INSTRB(anc_id_62,'(]',1,2) -
17244         INSTRB(anc_id_62,'(]',1,1) - 2)
17245 ,SUBSTRB(anc_id_62
17246        ,INSTRB(anc_id_62,'(]',1,2) + 2
17247        ,INSTRB(anc_id_62,'(]',1,3) -
17248         INSTRB(anc_id_62,'(]',1,2) - 2)
17249 ,SUBSTRB(anc_id_62
17250        ,INSTRB(anc_id_62,'(]',1,3) + 2
17251        ,INSTRB(anc_id_62,'(]',1,4) -
17252         INSTRB(anc_id_62,'(]',1,3) - 2)
17253 ,SUBSTRB(anc_id_62
17254        ,INSTRB(anc_id_62,'(]',1,4) + 2
17255        ,INSTRB(anc_id_62,'(]',1,5) -
17256         INSTRB(anc_id_62,'(]',1,4) - 2)
17257 ,SUBSTRB(anc_id_62
17258        ,INSTRB(anc_id_62,'(]',1,5) + 2
17259        ,INSTRB(anc_id_62,'(]',1,6) -
17260         INSTRB(anc_id_62,'(]',1,5) - 2)
17261 ,SUBSTRB(anc_id_62
17262        ,INSTRB(anc_id_62,'(]',1,6) + 2
17263        ,INSTRB(anc_id_62,'(]',1,7) -
17264         INSTRB(anc_id_62,'(]',1,6) - 2)
17265 ,SUBSTRB(anc_id_62
17266        ,INSTRB(anc_id_62,'(]',1,7) + 2
17267        ,LENGTHB(anc_id_62))
17268 )
17269 
17270 WHEN anc_id_63 IS NOT NULL THEN
17271   INTO xla_ae_header_acs (
17272         ae_header_id , object_version_number
17273       , analytical_criterion_code
17274       , analytical_criterion_type_code
17275       , amb_context_code
17276       , ac1,ac2,ac3,ac4,ac5)
17277 VALUES (ae_header_id, C_OVN
17278 ,SUBSTRB(anc_id_63
17279        ,1
17280        ,INSTRB(anc_id_63,'(]',1,1) -1)
17281 ,SUBSTRB(anc_id_63
17282        ,INSTRB(anc_id_63,'(]',1,1) + 2
17283        ,INSTRB(anc_id_63,'(]',1,2) -
17284         INSTRB(anc_id_63,'(]',1,1) - 2)
17285 ,SUBSTRB(anc_id_63
17286        ,INSTRB(anc_id_63,'(]',1,2) + 2
17287        ,INSTRB(anc_id_63,'(]',1,3) -
17288         INSTRB(anc_id_63,'(]',1,2) - 2)
17289 ,SUBSTRB(anc_id_63
17290        ,INSTRB(anc_id_63,'(]',1,3) + 2
17291        ,INSTRB(anc_id_63,'(]',1,4) -
17292         INSTRB(anc_id_63,'(]',1,3) - 2)
17293 ,SUBSTRB(anc_id_63
17294        ,INSTRB(anc_id_63,'(]',1,4) + 2
17295        ,INSTRB(anc_id_63,'(]',1,5) -
17296         INSTRB(anc_id_63,'(]',1,4) - 2)
17297 ,SUBSTRB(anc_id_63
17298        ,INSTRB(anc_id_63,'(]',1,5) + 2
17299        ,INSTRB(anc_id_63,'(]',1,6) -
17300         INSTRB(anc_id_63,'(]',1,5) - 2)
17301 ,SUBSTRB(anc_id_63
17302        ,INSTRB(anc_id_63,'(]',1,6) + 2
17303        ,INSTRB(anc_id_63,'(]',1,7) -
17304         INSTRB(anc_id_63,'(]',1,6) - 2)
17305 ,SUBSTRB(anc_id_63
17306        ,INSTRB(anc_id_63,'(]',1,7) + 2
17307        ,LENGTHB(anc_id_63))
17308 )
17309 
17310 WHEN anc_id_64 IS NOT NULL THEN
17311   INTO xla_ae_header_acs (
17312         ae_header_id , object_version_number
17313       , analytical_criterion_code
17314       , analytical_criterion_type_code
17315       , amb_context_code
17316       , ac1,ac2,ac3,ac4,ac5)
17317 VALUES (ae_header_id, C_OVN
17318 ,SUBSTRB(anc_id_64
17319        ,1
17320        ,INSTRB(anc_id_64,'(]',1,1) -1)
17321 ,SUBSTRB(anc_id_64
17322        ,INSTRB(anc_id_64,'(]',1,1) + 2
17323        ,INSTRB(anc_id_64,'(]',1,2) -
17324         INSTRB(anc_id_64,'(]',1,1) - 2)
17325 ,SUBSTRB(anc_id_64
17326        ,INSTRB(anc_id_64,'(]',1,2) + 2
17327        ,INSTRB(anc_id_64,'(]',1,3) -
17328         INSTRB(anc_id_64,'(]',1,2) - 2)
17329 ,SUBSTRB(anc_id_64
17330        ,INSTRB(anc_id_64,'(]',1,3) + 2
17331        ,INSTRB(anc_id_64,'(]',1,4) -
17332         INSTRB(anc_id_64,'(]',1,3) - 2)
17333 ,SUBSTRB(anc_id_64
17334        ,INSTRB(anc_id_64,'(]',1,4) + 2
17335        ,INSTRB(anc_id_64,'(]',1,5) -
17336         INSTRB(anc_id_64,'(]',1,4) - 2)
17337 ,SUBSTRB(anc_id_64
17338        ,INSTRB(anc_id_64,'(]',1,5) + 2
17339        ,INSTRB(anc_id_64,'(]',1,6) -
17340         INSTRB(anc_id_64,'(]',1,5) - 2)
17341 ,SUBSTRB(anc_id_64
17342        ,INSTRB(anc_id_64,'(]',1,6) + 2
17343        ,INSTRB(anc_id_64,'(]',1,7) -
17344         INSTRB(anc_id_64,'(]',1,6) - 2)
17345 ,SUBSTRB(anc_id_64
17346        ,INSTRB(anc_id_64,'(]',1,7) + 2
17347        ,LENGTHB(anc_id_64))
17348 )
17349 
17350 WHEN anc_id_65 IS NOT NULL THEN
17351   INTO xla_ae_header_acs (
17352         ae_header_id , object_version_number
17353       , analytical_criterion_code
17354       , analytical_criterion_type_code
17355       , amb_context_code
17356       , ac1,ac2,ac3,ac4,ac5)
17357 VALUES (ae_header_id, C_OVN
17358 ,SUBSTRB(anc_id_65
17359        ,1
17360        ,INSTRB(anc_id_65,'(]',1,1) -1)
17361 ,SUBSTRB(anc_id_65
17362        ,INSTRB(anc_id_65,'(]',1,1) + 2
17363        ,INSTRB(anc_id_65,'(]',1,2) -
17364         INSTRB(anc_id_65,'(]',1,1) - 2)
17365 ,SUBSTRB(anc_id_65
17366        ,INSTRB(anc_id_65,'(]',1,2) + 2
17367        ,INSTRB(anc_id_65,'(]',1,3) -
17368         INSTRB(anc_id_65,'(]',1,2) - 2)
17369 ,SUBSTRB(anc_id_65
17370        ,INSTRB(anc_id_65,'(]',1,3) + 2
17371        ,INSTRB(anc_id_65,'(]',1,4) -
17372         INSTRB(anc_id_65,'(]',1,3) - 2)
17373 ,SUBSTRB(anc_id_65
17374        ,INSTRB(anc_id_65,'(]',1,4) + 2
17375        ,INSTRB(anc_id_65,'(]',1,5) -
17376         INSTRB(anc_id_65,'(]',1,4) - 2)
17377 ,SUBSTRB(anc_id_65
17378        ,INSTRB(anc_id_65,'(]',1,5) + 2
17379        ,INSTRB(anc_id_65,'(]',1,6) -
17380         INSTRB(anc_id_65,'(]',1,5) - 2)
17381 ,SUBSTRB(anc_id_65
17382        ,INSTRB(anc_id_65,'(]',1,6) + 2
17383        ,INSTRB(anc_id_65,'(]',1,7) -
17384         INSTRB(anc_id_65,'(]',1,6) - 2)
17385 ,SUBSTRB(anc_id_65
17386        ,INSTRB(anc_id_65,'(]',1,7) + 2
17387        ,LENGTHB(anc_id_65))
17388 )
17389 
17390 WHEN anc_id_66 IS NOT NULL THEN
17391   INTO xla_ae_header_acs (
17392         ae_header_id , object_version_number
17393       , analytical_criterion_code
17394       , analytical_criterion_type_code
17395       , amb_context_code
17396       , ac1,ac2,ac3,ac4,ac5)
17397 VALUES (ae_header_id, C_OVN
17398 ,SUBSTRB(anc_id_66
17399        ,1
17400        ,INSTRB(anc_id_66,'(]',1,1) -1)
17401 ,SUBSTRB(anc_id_66
17402        ,INSTRB(anc_id_66,'(]',1,1) + 2
17403        ,INSTRB(anc_id_66,'(]',1,2) -
17404         INSTRB(anc_id_66,'(]',1,1) - 2)
17405 ,SUBSTRB(anc_id_66
17406        ,INSTRB(anc_id_66,'(]',1,2) + 2
17407        ,INSTRB(anc_id_66,'(]',1,3) -
17408         INSTRB(anc_id_66,'(]',1,2) - 2)
17409 ,SUBSTRB(anc_id_66
17410        ,INSTRB(anc_id_66,'(]',1,3) + 2
17411        ,INSTRB(anc_id_66,'(]',1,4) -
17412         INSTRB(anc_id_66,'(]',1,3) - 2)
17413 ,SUBSTRB(anc_id_66
17414        ,INSTRB(anc_id_66,'(]',1,4) + 2
17415        ,INSTRB(anc_id_66,'(]',1,5) -
17416         INSTRB(anc_id_66,'(]',1,4) - 2)
17417 ,SUBSTRB(anc_id_66
17418        ,INSTRB(anc_id_66,'(]',1,5) + 2
17419        ,INSTRB(anc_id_66,'(]',1,6) -
17420         INSTRB(anc_id_66,'(]',1,5) - 2)
17421 ,SUBSTRB(anc_id_66
17422        ,INSTRB(anc_id_66,'(]',1,6) + 2
17423        ,INSTRB(anc_id_66,'(]',1,7) -
17424         INSTRB(anc_id_66,'(]',1,6) - 2)
17425 ,SUBSTRB(anc_id_66
17426        ,INSTRB(anc_id_66,'(]',1,7) + 2
17427        ,LENGTHB(anc_id_66))
17428 )
17429 
17430 WHEN anc_id_67 IS NOT NULL THEN
17431   INTO xla_ae_header_acs (
17432         ae_header_id , object_version_number
17433       , analytical_criterion_code
17434       , analytical_criterion_type_code
17435       , amb_context_code
17436       , ac1,ac2,ac3,ac4,ac5)
17437 VALUES (ae_header_id, C_OVN
17438 ,SUBSTRB(anc_id_67
17439        ,1
17440        ,INSTRB(anc_id_67,'(]',1,1) -1)
17441 ,SUBSTRB(anc_id_67
17442        ,INSTRB(anc_id_67,'(]',1,1) + 2
17443        ,INSTRB(anc_id_67,'(]',1,2) -
17444         INSTRB(anc_id_67,'(]',1,1) - 2)
17445 ,SUBSTRB(anc_id_67
17446        ,INSTRB(anc_id_67,'(]',1,2) + 2
17447        ,INSTRB(anc_id_67,'(]',1,3) -
17448         INSTRB(anc_id_67,'(]',1,2) - 2)
17449 ,SUBSTRB(anc_id_67
17450        ,INSTRB(anc_id_67,'(]',1,3) + 2
17451        ,INSTRB(anc_id_67,'(]',1,4) -
17452         INSTRB(anc_id_67,'(]',1,3) - 2)
17453 ,SUBSTRB(anc_id_67
17454        ,INSTRB(anc_id_67,'(]',1,4) + 2
17455        ,INSTRB(anc_id_67,'(]',1,5) -
17456         INSTRB(anc_id_67,'(]',1,4) - 2)
17457 ,SUBSTRB(anc_id_67
17458        ,INSTRB(anc_id_67,'(]',1,5) + 2
17459        ,INSTRB(anc_id_67,'(]',1,6) -
17460         INSTRB(anc_id_67,'(]',1,5) - 2)
17461 ,SUBSTRB(anc_id_67
17462        ,INSTRB(anc_id_67,'(]',1,6) + 2
17463        ,INSTRB(anc_id_67,'(]',1,7) -
17464         INSTRB(anc_id_67,'(]',1,6) - 2)
17465 ,SUBSTRB(anc_id_67
17466        ,INSTRB(anc_id_67,'(]',1,7) + 2
17467        ,LENGTHB(anc_id_67))
17468 )
17469 
17470 WHEN anc_id_68 IS NOT NULL THEN
17471   INTO xla_ae_header_acs (
17472         ae_header_id , object_version_number
17473       , analytical_criterion_code
17474       , analytical_criterion_type_code
17475       , amb_context_code
17476       , ac1,ac2,ac3,ac4,ac5)
17477 VALUES (ae_header_id, C_OVN
17478 ,SUBSTRB(anc_id_68
17479        ,1
17480        ,INSTRB(anc_id_68,'(]',1,1) -1)
17481 ,SUBSTRB(anc_id_68
17482        ,INSTRB(anc_id_68,'(]',1,1) + 2
17483        ,INSTRB(anc_id_68,'(]',1,2) -
17484         INSTRB(anc_id_68,'(]',1,1) - 2)
17485 ,SUBSTRB(anc_id_68
17486        ,INSTRB(anc_id_68,'(]',1,2) + 2
17487        ,INSTRB(anc_id_68,'(]',1,3) -
17488         INSTRB(anc_id_68,'(]',1,2) - 2)
17489 ,SUBSTRB(anc_id_68
17490        ,INSTRB(anc_id_68,'(]',1,3) + 2
17491        ,INSTRB(anc_id_68,'(]',1,4) -
17492         INSTRB(anc_id_68,'(]',1,3) - 2)
17493 ,SUBSTRB(anc_id_68
17494        ,INSTRB(anc_id_68,'(]',1,4) + 2
17495        ,INSTRB(anc_id_68,'(]',1,5) -
17496         INSTRB(anc_id_68,'(]',1,4) - 2)
17497 ,SUBSTRB(anc_id_68
17498        ,INSTRB(anc_id_68,'(]',1,5) + 2
17499        ,INSTRB(anc_id_68,'(]',1,6) -
17500         INSTRB(anc_id_68,'(]',1,5) - 2)
17501 ,SUBSTRB(anc_id_68
17502        ,INSTRB(anc_id_68,'(]',1,6) + 2
17503        ,INSTRB(anc_id_68,'(]',1,7) -
17504         INSTRB(anc_id_68,'(]',1,6) - 2)
17505 ,SUBSTRB(anc_id_68
17506        ,INSTRB(anc_id_68,'(]',1,7) + 2
17507        ,LENGTHB(anc_id_68))
17508 )
17509 
17510 WHEN anc_id_69 IS NOT NULL THEN
17511   INTO xla_ae_header_acs (
17512         ae_header_id , object_version_number
17513       , analytical_criterion_code
17514       , analytical_criterion_type_code
17515       , amb_context_code
17516       , ac1,ac2,ac3,ac4,ac5)
17517 VALUES (ae_header_id, C_OVN
17518 ,SUBSTRB(anc_id_69
17519        ,1
17520        ,INSTRB(anc_id_69,'(]',1,1) -1)
17521 ,SUBSTRB(anc_id_69
17522        ,INSTRB(anc_id_69,'(]',1,1) + 2
17523        ,INSTRB(anc_id_69,'(]',1,2) -
17524         INSTRB(anc_id_69,'(]',1,1) - 2)
17525 ,SUBSTRB(anc_id_69
17526        ,INSTRB(anc_id_69,'(]',1,2) + 2
17527        ,INSTRB(anc_id_69,'(]',1,3) -
17528         INSTRB(anc_id_69,'(]',1,2) - 2)
17529 ,SUBSTRB(anc_id_69
17530        ,INSTRB(anc_id_69,'(]',1,3) + 2
17531        ,INSTRB(anc_id_69,'(]',1,4) -
17532         INSTRB(anc_id_69,'(]',1,3) - 2)
17533 ,SUBSTRB(anc_id_69
17534        ,INSTRB(anc_id_69,'(]',1,4) + 2
17535        ,INSTRB(anc_id_69,'(]',1,5) -
17536         INSTRB(anc_id_69,'(]',1,4) - 2)
17537 ,SUBSTRB(anc_id_69
17538        ,INSTRB(anc_id_69,'(]',1,5) + 2
17539        ,INSTRB(anc_id_69,'(]',1,6) -
17540         INSTRB(anc_id_69,'(]',1,5) - 2)
17541 ,SUBSTRB(anc_id_69
17542        ,INSTRB(anc_id_69,'(]',1,6) + 2
17543        ,INSTRB(anc_id_69,'(]',1,7) -
17544         INSTRB(anc_id_69,'(]',1,6) - 2)
17545 ,SUBSTRB(anc_id_69
17546        ,INSTRB(anc_id_69,'(]',1,7) + 2
17547        ,LENGTHB(anc_id_69))
17548 )
17549 
17550 WHEN anc_id_70 IS NOT NULL THEN
17551   INTO xla_ae_header_acs (
17552         ae_header_id , object_version_number
17553       , analytical_criterion_code
17554       , analytical_criterion_type_code
17555       , amb_context_code
17556       , ac1,ac2,ac3,ac4,ac5)
17557 VALUES (ae_header_id, C_OVN
17558 ,SUBSTRB(anc_id_70
17559        ,1
17560        ,INSTRB(anc_id_70,'(]',1,1) -1)
17561 ,SUBSTRB(anc_id_70
17562        ,INSTRB(anc_id_70,'(]',1,1) + 2
17563        ,INSTRB(anc_id_70,'(]',1,2) -
17564         INSTRB(anc_id_70,'(]',1,1) - 2)
17565 ,SUBSTRB(anc_id_70
17566        ,INSTRB(anc_id_70,'(]',1,2) + 2
17567        ,INSTRB(anc_id_70,'(]',1,3) -
17568         INSTRB(anc_id_70,'(]',1,2) - 2)
17569 ,SUBSTRB(anc_id_70
17570        ,INSTRB(anc_id_70,'(]',1,3) + 2
17571        ,INSTRB(anc_id_70,'(]',1,4) -
17572         INSTRB(anc_id_70,'(]',1,3) - 2)
17573 ,SUBSTRB(anc_id_70
17574        ,INSTRB(anc_id_70,'(]',1,4) + 2
17575        ,INSTRB(anc_id_70,'(]',1,5) -
17576         INSTRB(anc_id_70,'(]',1,4) - 2)
17577 ,SUBSTRB(anc_id_70
17578        ,INSTRB(anc_id_70,'(]',1,5) + 2
17579        ,INSTRB(anc_id_70,'(]',1,6) -
17580         INSTRB(anc_id_70,'(]',1,5) - 2)
17581 ,SUBSTRB(anc_id_70
17582        ,INSTRB(anc_id_70,'(]',1,6) + 2
17583        ,INSTRB(anc_id_70,'(]',1,7) -
17584         INSTRB(anc_id_70,'(]',1,6) - 2)
17585 ,SUBSTRB(anc_id_70
17586        ,INSTRB(anc_id_70,'(]',1,7) + 2
17587        ,LENGTHB(anc_id_70))
17588 )
17589 
17590 WHEN anc_id_71 IS NOT NULL THEN
17591   INTO xla_ae_header_acs (
17592         ae_header_id , object_version_number
17593       , analytical_criterion_code
17594       , analytical_criterion_type_code
17595       , amb_context_code
17596       , ac1,ac2,ac3,ac4,ac5)
17597 VALUES (ae_header_id, C_OVN
17598 ,SUBSTRB(anc_id_71
17599        ,1
17600        ,INSTRB(anc_id_71,'(]',1,1) -1)
17601 ,SUBSTRB(anc_id_71
17602        ,INSTRB(anc_id_71,'(]',1,1) + 2
17603        ,INSTRB(anc_id_71,'(]',1,2) -
17604         INSTRB(anc_id_71,'(]',1,1) - 2)
17605 ,SUBSTRB(anc_id_71
17606        ,INSTRB(anc_id_71,'(]',1,2) + 2
17607        ,INSTRB(anc_id_71,'(]',1,3) -
17608         INSTRB(anc_id_71,'(]',1,2) - 2)
17609 ,SUBSTRB(anc_id_71
17610        ,INSTRB(anc_id_71,'(]',1,3) + 2
17611        ,INSTRB(anc_id_71,'(]',1,4) -
17612         INSTRB(anc_id_71,'(]',1,3) - 2)
17613 ,SUBSTRB(anc_id_71
17614        ,INSTRB(anc_id_71,'(]',1,4) + 2
17615        ,INSTRB(anc_id_71,'(]',1,5) -
17616         INSTRB(anc_id_71,'(]',1,4) - 2)
17617 ,SUBSTRB(anc_id_71
17618        ,INSTRB(anc_id_71,'(]',1,5) + 2
17619        ,INSTRB(anc_id_71,'(]',1,6) -
17620         INSTRB(anc_id_71,'(]',1,5) - 2)
17621 ,SUBSTRB(anc_id_71
17622        ,INSTRB(anc_id_71,'(]',1,6) + 2
17623        ,INSTRB(anc_id_71,'(]',1,7) -
17624         INSTRB(anc_id_71,'(]',1,6) - 2)
17625 ,SUBSTRB(anc_id_71
17626        ,INSTRB(anc_id_71,'(]',1,7) + 2
17627        ,LENGTHB(anc_id_71))
17628 )
17629 
17630 WHEN anc_id_72 IS NOT NULL THEN
17631   INTO xla_ae_header_acs (
17632         ae_header_id , object_version_number
17633       , analytical_criterion_code
17634       , analytical_criterion_type_code
17635       , amb_context_code
17636       , ac1,ac2,ac3,ac4,ac5)
17637 VALUES (ae_header_id, C_OVN
17638 ,SUBSTRB(anc_id_72
17639        ,1
17640        ,INSTRB(anc_id_72,'(]',1,1) -1)
17641 ,SUBSTRB(anc_id_72
17642        ,INSTRB(anc_id_72,'(]',1,1) + 2
17643        ,INSTRB(anc_id_72,'(]',1,2) -
17644         INSTRB(anc_id_72,'(]',1,1) - 2)
17645 ,SUBSTRB(anc_id_72
17646        ,INSTRB(anc_id_72,'(]',1,2) + 2
17647        ,INSTRB(anc_id_72,'(]',1,3) -
17648         INSTRB(anc_id_72,'(]',1,2) - 2)
17649 ,SUBSTRB(anc_id_72
17650        ,INSTRB(anc_id_72,'(]',1,3) + 2
17651        ,INSTRB(anc_id_72,'(]',1,4) -
17652         INSTRB(anc_id_72,'(]',1,3) - 2)
17653 ,SUBSTRB(anc_id_72
17654        ,INSTRB(anc_id_72,'(]',1,4) + 2
17655        ,INSTRB(anc_id_72,'(]',1,5) -
17656         INSTRB(anc_id_72,'(]',1,4) - 2)
17657 ,SUBSTRB(anc_id_72
17658        ,INSTRB(anc_id_72,'(]',1,5) + 2
17659        ,INSTRB(anc_id_72,'(]',1,6) -
17660         INSTRB(anc_id_72,'(]',1,5) - 2)
17661 ,SUBSTRB(anc_id_72
17662        ,INSTRB(anc_id_72,'(]',1,6) + 2
17663        ,INSTRB(anc_id_72,'(]',1,7) -
17664         INSTRB(anc_id_72,'(]',1,6) - 2)
17665 ,SUBSTRB(anc_id_72
17666        ,INSTRB(anc_id_72,'(]',1,7) + 2
17667        ,LENGTHB(anc_id_72))
17668 )
17669 
17670 WHEN anc_id_73 IS NOT NULL THEN
17671   INTO xla_ae_header_acs (
17672         ae_header_id , object_version_number
17673       , analytical_criterion_code
17674       , analytical_criterion_type_code
17675       , amb_context_code
17676       , ac1,ac2,ac3,ac4,ac5)
17677 VALUES (ae_header_id, C_OVN
17678 ,SUBSTRB(anc_id_73
17679        ,1
17680        ,INSTRB(anc_id_73,'(]',1,1) -1)
17681 ,SUBSTRB(anc_id_73
17682        ,INSTRB(anc_id_73,'(]',1,1) + 2
17683        ,INSTRB(anc_id_73,'(]',1,2) -
17684         INSTRB(anc_id_73,'(]',1,1) - 2)
17685 ,SUBSTRB(anc_id_73
17686        ,INSTRB(anc_id_73,'(]',1,2) + 2
17687        ,INSTRB(anc_id_73,'(]',1,3) -
17688         INSTRB(anc_id_73,'(]',1,2) - 2)
17689 ,SUBSTRB(anc_id_73
17690        ,INSTRB(anc_id_73,'(]',1,3) + 2
17691        ,INSTRB(anc_id_73,'(]',1,4) -
17692         INSTRB(anc_id_73,'(]',1,3) - 2)
17693 ,SUBSTRB(anc_id_73
17694        ,INSTRB(anc_id_73,'(]',1,4) + 2
17695        ,INSTRB(anc_id_73,'(]',1,5) -
17696         INSTRB(anc_id_73,'(]',1,4) - 2)
17697 ,SUBSTRB(anc_id_73
17698        ,INSTRB(anc_id_73,'(]',1,5) + 2
17699        ,INSTRB(anc_id_73,'(]',1,6) -
17700         INSTRB(anc_id_73,'(]',1,5) - 2)
17701 ,SUBSTRB(anc_id_73
17702        ,INSTRB(anc_id_73,'(]',1,6) + 2
17703        ,INSTRB(anc_id_73,'(]',1,7) -
17704         INSTRB(anc_id_73,'(]',1,6) - 2)
17705 ,SUBSTRB(anc_id_73
17706        ,INSTRB(anc_id_73,'(]',1,7) + 2
17707        ,LENGTHB(anc_id_73))
17708 )
17709 
17710 WHEN anc_id_74 IS NOT NULL THEN
17711   INTO xla_ae_header_acs (
17712         ae_header_id , object_version_number
17713       , analytical_criterion_code
17714       , analytical_criterion_type_code
17715       , amb_context_code
17716       , ac1,ac2,ac3,ac4,ac5)
17717 VALUES (ae_header_id, C_OVN
17718 ,SUBSTRB(anc_id_74
17719        ,1
17720        ,INSTRB(anc_id_74,'(]',1,1) -1)
17721 ,SUBSTRB(anc_id_74
17722        ,INSTRB(anc_id_74,'(]',1,1) + 2
17723        ,INSTRB(anc_id_74,'(]',1,2) -
17724         INSTRB(anc_id_74,'(]',1,1) - 2)
17725 ,SUBSTRB(anc_id_74
17726        ,INSTRB(anc_id_74,'(]',1,2) + 2
17727        ,INSTRB(anc_id_74,'(]',1,3) -
17728         INSTRB(anc_id_74,'(]',1,2) - 2)
17729 ,SUBSTRB(anc_id_74
17730        ,INSTRB(anc_id_74,'(]',1,3) + 2
17731        ,INSTRB(anc_id_74,'(]',1,4) -
17732         INSTRB(anc_id_74,'(]',1,3) - 2)
17733 ,SUBSTRB(anc_id_74
17734        ,INSTRB(anc_id_74,'(]',1,4) + 2
17735        ,INSTRB(anc_id_74,'(]',1,5) -
17736         INSTRB(anc_id_74,'(]',1,4) - 2)
17737 ,SUBSTRB(anc_id_74
17738        ,INSTRB(anc_id_74,'(]',1,5) + 2
17739        ,INSTRB(anc_id_74,'(]',1,6) -
17740         INSTRB(anc_id_74,'(]',1,5) - 2)
17741 ,SUBSTRB(anc_id_74
17742        ,INSTRB(anc_id_74,'(]',1,6) + 2
17743        ,INSTRB(anc_id_74,'(]',1,7) -
17744         INSTRB(anc_id_74,'(]',1,6) - 2)
17745 ,SUBSTRB(anc_id_74
17746        ,INSTRB(anc_id_74,'(]',1,7) + 2
17747        ,LENGTHB(anc_id_74))
17748 )
17749 
17750 WHEN anc_id_75 IS NOT NULL THEN
17751   INTO xla_ae_header_acs (
17752         ae_header_id , object_version_number
17753       , analytical_criterion_code
17754       , analytical_criterion_type_code
17755       , amb_context_code
17756       , ac1,ac2,ac3,ac4,ac5)
17757 VALUES (ae_header_id, C_OVN
17758 ,SUBSTRB(anc_id_75
17759        ,1
17760        ,INSTRB(anc_id_75,'(]',1,1) -1)
17761 ,SUBSTRB(anc_id_75
17762        ,INSTRB(anc_id_75,'(]',1,1) + 2
17763        ,INSTRB(anc_id_75,'(]',1,2) -
17764         INSTRB(anc_id_75,'(]',1,1) - 2)
17765 ,SUBSTRB(anc_id_75
17766        ,INSTRB(anc_id_75,'(]',1,2) + 2
17767        ,INSTRB(anc_id_75,'(]',1,3) -
17768         INSTRB(anc_id_75,'(]',1,2) - 2)
17769 ,SUBSTRB(anc_id_75
17770        ,INSTRB(anc_id_75,'(]',1,3) + 2
17771        ,INSTRB(anc_id_75,'(]',1,4) -
17772         INSTRB(anc_id_75,'(]',1,3) - 2)
17773 ,SUBSTRB(anc_id_75
17774        ,INSTRB(anc_id_75,'(]',1,4) + 2
17775        ,INSTRB(anc_id_75,'(]',1,5) -
17776         INSTRB(anc_id_75,'(]',1,4) - 2)
17777 ,SUBSTRB(anc_id_75
17778        ,INSTRB(anc_id_75,'(]',1,5) + 2
17779        ,INSTRB(anc_id_75,'(]',1,6) -
17780         INSTRB(anc_id_75,'(]',1,5) - 2)
17781 ,SUBSTRB(anc_id_75
17782        ,INSTRB(anc_id_75,'(]',1,6) + 2
17783        ,INSTRB(anc_id_75,'(]',1,7) -
17784         INSTRB(anc_id_75,'(]',1,6) - 2)
17785 ,SUBSTRB(anc_id_75
17786        ,INSTRB(anc_id_75,'(]',1,7) + 2
17787        ,LENGTHB(anc_id_75))
17788 )
17789 
17790 WHEN anc_id_76 IS NOT NULL THEN
17791   INTO xla_ae_header_acs (
17792         ae_header_id , object_version_number
17793       , analytical_criterion_code
17794       , analytical_criterion_type_code
17795       , amb_context_code
17796       , ac1,ac2,ac3,ac4,ac5)
17797 VALUES (ae_header_id, C_OVN
17798 ,SUBSTRB(anc_id_76
17799        ,1
17800        ,INSTRB(anc_id_76,'(]',1,1) -1)
17801 ,SUBSTRB(anc_id_76
17802        ,INSTRB(anc_id_76,'(]',1,1) + 2
17803        ,INSTRB(anc_id_76,'(]',1,2) -
17804         INSTRB(anc_id_76,'(]',1,1) - 2)
17805 ,SUBSTRB(anc_id_76
17806        ,INSTRB(anc_id_76,'(]',1,2) + 2
17807        ,INSTRB(anc_id_76,'(]',1,3) -
17808         INSTRB(anc_id_76,'(]',1,2) - 2)
17809 ,SUBSTRB(anc_id_76
17810        ,INSTRB(anc_id_76,'(]',1,3) + 2
17811        ,INSTRB(anc_id_76,'(]',1,4) -
17812         INSTRB(anc_id_76,'(]',1,3) - 2)
17813 ,SUBSTRB(anc_id_76
17814        ,INSTRB(anc_id_76,'(]',1,4) + 2
17815        ,INSTRB(anc_id_76,'(]',1,5) -
17816         INSTRB(anc_id_76,'(]',1,4) - 2)
17817 ,SUBSTRB(anc_id_76
17818        ,INSTRB(anc_id_76,'(]',1,5) + 2
17819        ,INSTRB(anc_id_76,'(]',1,6) -
17820         INSTRB(anc_id_76,'(]',1,5) - 2)
17821 ,SUBSTRB(anc_id_76
17822        ,INSTRB(anc_id_76,'(]',1,6) + 2
17823        ,INSTRB(anc_id_76,'(]',1,7) -
17824         INSTRB(anc_id_76,'(]',1,6) - 2)
17825 ,SUBSTRB(anc_id_76
17826        ,INSTRB(anc_id_76,'(]',1,7) + 2
17827        ,LENGTHB(anc_id_76))
17828 )
17829 
17830 WHEN anc_id_77 IS NOT NULL THEN
17831   INTO xla_ae_header_acs (
17832         ae_header_id , object_version_number
17833       , analytical_criterion_code
17834       , analytical_criterion_type_code
17835       , amb_context_code
17836       , ac1,ac2,ac3,ac4,ac5)
17837 VALUES (ae_header_id, C_OVN
17838 ,SUBSTRB(anc_id_77
17839        ,1
17840        ,INSTRB(anc_id_77,'(]',1,1) -1)
17841 ,SUBSTRB(anc_id_77
17842        ,INSTRB(anc_id_77,'(]',1,1) + 2
17843        ,INSTRB(anc_id_77,'(]',1,2) -
17844         INSTRB(anc_id_77,'(]',1,1) - 2)
17845 ,SUBSTRB(anc_id_77
17846        ,INSTRB(anc_id_77,'(]',1,2) + 2
17847        ,INSTRB(anc_id_77,'(]',1,3) -
17848         INSTRB(anc_id_77,'(]',1,2) - 2)
17849 ,SUBSTRB(anc_id_77
17850        ,INSTRB(anc_id_77,'(]',1,3) + 2
17851        ,INSTRB(anc_id_77,'(]',1,4) -
17852         INSTRB(anc_id_77,'(]',1,3) - 2)
17853 ,SUBSTRB(anc_id_77
17854        ,INSTRB(anc_id_77,'(]',1,4) + 2
17855        ,INSTRB(anc_id_77,'(]',1,5) -
17856         INSTRB(anc_id_77,'(]',1,4) - 2)
17857 ,SUBSTRB(anc_id_77
17858        ,INSTRB(anc_id_77,'(]',1,5) + 2
17859        ,INSTRB(anc_id_77,'(]',1,6) -
17860         INSTRB(anc_id_77,'(]',1,5) - 2)
17861 ,SUBSTRB(anc_id_77
17862        ,INSTRB(anc_id_77,'(]',1,6) + 2
17863        ,INSTRB(anc_id_77,'(]',1,7) -
17864         INSTRB(anc_id_77,'(]',1,6) - 2)
17865 ,SUBSTRB(anc_id_77
17866        ,INSTRB(anc_id_77,'(]',1,7) + 2
17867        ,LENGTHB(anc_id_77))
17868 )
17869 
17870 WHEN anc_id_78 IS NOT NULL THEN
17871   INTO xla_ae_header_acs (
17872         ae_header_id , object_version_number
17873       , analytical_criterion_code
17874       , analytical_criterion_type_code
17875       , amb_context_code
17876       , ac1,ac2,ac3,ac4,ac5)
17877 VALUES (ae_header_id, C_OVN
17878 ,SUBSTRB(anc_id_78
17879        ,1
17880        ,INSTRB(anc_id_78,'(]',1,1) -1)
17881 ,SUBSTRB(anc_id_78
17882        ,INSTRB(anc_id_78,'(]',1,1) + 2
17883        ,INSTRB(anc_id_78,'(]',1,2) -
17884         INSTRB(anc_id_78,'(]',1,1) - 2)
17885 ,SUBSTRB(anc_id_78
17886        ,INSTRB(anc_id_78,'(]',1,2) + 2
17887        ,INSTRB(anc_id_78,'(]',1,3) -
17888         INSTRB(anc_id_78,'(]',1,2) - 2)
17889 ,SUBSTRB(anc_id_78
17890        ,INSTRB(anc_id_78,'(]',1,3) + 2
17891        ,INSTRB(anc_id_78,'(]',1,4) -
17892         INSTRB(anc_id_78,'(]',1,3) - 2)
17893 ,SUBSTRB(anc_id_78
17894        ,INSTRB(anc_id_78,'(]',1,4) + 2
17895        ,INSTRB(anc_id_78,'(]',1,5) -
17896         INSTRB(anc_id_78,'(]',1,4) - 2)
17897 ,SUBSTRB(anc_id_78
17898        ,INSTRB(anc_id_78,'(]',1,5) + 2
17899        ,INSTRB(anc_id_78,'(]',1,6) -
17900         INSTRB(anc_id_78,'(]',1,5) - 2)
17901 ,SUBSTRB(anc_id_78
17902        ,INSTRB(anc_id_78,'(]',1,6) + 2
17903        ,INSTRB(anc_id_78,'(]',1,7) -
17904         INSTRB(anc_id_78,'(]',1,6) - 2)
17905 ,SUBSTRB(anc_id_78
17906        ,INSTRB(anc_id_78,'(]',1,7) + 2
17907        ,LENGTHB(anc_id_78))
17908 )
17909 
17910 WHEN anc_id_79 IS NOT NULL THEN
17911   INTO xla_ae_header_acs (
17912         ae_header_id , object_version_number
17913       , analytical_criterion_code
17914       , analytical_criterion_type_code
17915       , amb_context_code
17916       , ac1,ac2,ac3,ac4,ac5)
17917 VALUES (ae_header_id, C_OVN
17918 ,SUBSTRB(anc_id_79
17919        ,1
17920        ,INSTRB(anc_id_79,'(]',1,1) -1)
17921 ,SUBSTRB(anc_id_79
17922        ,INSTRB(anc_id_79,'(]',1,1) + 2
17923        ,INSTRB(anc_id_79,'(]',1,2) -
17924         INSTRB(anc_id_79,'(]',1,1) - 2)
17925 ,SUBSTRB(anc_id_79
17926        ,INSTRB(anc_id_79,'(]',1,2) + 2
17927        ,INSTRB(anc_id_79,'(]',1,3) -
17928         INSTRB(anc_id_79,'(]',1,2) - 2)
17929 ,SUBSTRB(anc_id_79
17930        ,INSTRB(anc_id_79,'(]',1,3) + 2
17931        ,INSTRB(anc_id_79,'(]',1,4) -
17932         INSTRB(anc_id_79,'(]',1,3) - 2)
17933 ,SUBSTRB(anc_id_79
17934        ,INSTRB(anc_id_79,'(]',1,4) + 2
17935        ,INSTRB(anc_id_79,'(]',1,5) -
17936         INSTRB(anc_id_79,'(]',1,4) - 2)
17937 ,SUBSTRB(anc_id_79
17938        ,INSTRB(anc_id_79,'(]',1,5) + 2
17939        ,INSTRB(anc_id_79,'(]',1,6) -
17940         INSTRB(anc_id_79,'(]',1,5) - 2)
17941 ,SUBSTRB(anc_id_79
17942        ,INSTRB(anc_id_79,'(]',1,6) + 2
17943        ,INSTRB(anc_id_79,'(]',1,7) -
17944         INSTRB(anc_id_79,'(]',1,6) - 2)
17945 ,SUBSTRB(anc_id_79
17946        ,INSTRB(anc_id_79,'(]',1,7) + 2
17947        ,LENGTHB(anc_id_79))
17948 )
17949 
17950 WHEN anc_id_80 IS NOT NULL THEN
17951   INTO xla_ae_header_acs (
17952         ae_header_id , object_version_number
17953       , analytical_criterion_code
17954       , analytical_criterion_type_code
17955       , amb_context_code
17956       , ac1,ac2,ac3,ac4,ac5)
17957 VALUES (ae_header_id, C_OVN
17958 ,SUBSTRB(anc_id_80
17959        ,1
17960        ,INSTRB(anc_id_80,'(]',1,1) -1)
17961 ,SUBSTRB(anc_id_80
17962        ,INSTRB(anc_id_80,'(]',1,1) + 2
17963        ,INSTRB(anc_id_80,'(]',1,2) -
17964         INSTRB(anc_id_80,'(]',1,1) - 2)
17965 ,SUBSTRB(anc_id_80
17966        ,INSTRB(anc_id_80,'(]',1,2) + 2
17967        ,INSTRB(anc_id_80,'(]',1,3) -
17968         INSTRB(anc_id_80,'(]',1,2) - 2)
17969 ,SUBSTRB(anc_id_80
17970        ,INSTRB(anc_id_80,'(]',1,3) + 2
17971        ,INSTRB(anc_id_80,'(]',1,4) -
17972         INSTRB(anc_id_80,'(]',1,3) - 2)
17973 ,SUBSTRB(anc_id_80
17974        ,INSTRB(anc_id_80,'(]',1,4) + 2
17975        ,INSTRB(anc_id_80,'(]',1,5) -
17976         INSTRB(anc_id_80,'(]',1,4) - 2)
17977 ,SUBSTRB(anc_id_80
17978        ,INSTRB(anc_id_80,'(]',1,5) + 2
17979        ,INSTRB(anc_id_80,'(]',1,6) -
17980         INSTRB(anc_id_80,'(]',1,5) - 2)
17981 ,SUBSTRB(anc_id_80
17982        ,INSTRB(anc_id_80,'(]',1,6) + 2
17983        ,INSTRB(anc_id_80,'(]',1,7) -
17984         INSTRB(anc_id_80,'(]',1,6) - 2)
17985 ,SUBSTRB(anc_id_80
17986        ,INSTRB(anc_id_80,'(]',1,7) + 2
17987        ,LENGTHB(anc_id_80))
17988 )
17989 
17990 WHEN anc_id_81 IS NOT NULL THEN
17991   INTO xla_ae_header_acs (
17992         ae_header_id , object_version_number
17993       , analytical_criterion_code
17994       , analytical_criterion_type_code
17995       , amb_context_code
17996       , ac1,ac2,ac3,ac4,ac5)
17997 VALUES (ae_header_id, C_OVN
17998 ,SUBSTRB(anc_id_81
17999        ,1
18000        ,INSTRB(anc_id_81,'(]',1,1) -1)
18001 ,SUBSTRB(anc_id_81
18002        ,INSTRB(anc_id_81,'(]',1,1) + 2
18003        ,INSTRB(anc_id_81,'(]',1,2) -
18004         INSTRB(anc_id_81,'(]',1,1) - 2)
18005 ,SUBSTRB(anc_id_81
18006        ,INSTRB(anc_id_81,'(]',1,2) + 2
18007        ,INSTRB(anc_id_81,'(]',1,3) -
18008         INSTRB(anc_id_81,'(]',1,2) - 2)
18009 ,SUBSTRB(anc_id_81
18010        ,INSTRB(anc_id_81,'(]',1,3) + 2
18011        ,INSTRB(anc_id_81,'(]',1,4) -
18012         INSTRB(anc_id_81,'(]',1,3) - 2)
18013 ,SUBSTRB(anc_id_81
18014        ,INSTRB(anc_id_81,'(]',1,4) + 2
18015        ,INSTRB(anc_id_81,'(]',1,5) -
18016         INSTRB(anc_id_81,'(]',1,4) - 2)
18017 ,SUBSTRB(anc_id_81
18018        ,INSTRB(anc_id_81,'(]',1,5) + 2
18019        ,INSTRB(anc_id_81,'(]',1,6) -
18020         INSTRB(anc_id_81,'(]',1,5) - 2)
18021 ,SUBSTRB(anc_id_81
18022        ,INSTRB(anc_id_81,'(]',1,6) + 2
18023        ,INSTRB(anc_id_81,'(]',1,7) -
18024         INSTRB(anc_id_81,'(]',1,6) - 2)
18025 ,SUBSTRB(anc_id_81
18026        ,INSTRB(anc_id_81,'(]',1,7) + 2
18027        ,LENGTHB(anc_id_81))
18028 )
18029 
18030 WHEN anc_id_82 IS NOT NULL THEN
18031   INTO xla_ae_header_acs (
18032         ae_header_id , object_version_number
18033       , analytical_criterion_code
18034       , analytical_criterion_type_code
18035       , amb_context_code
18036       , ac1,ac2,ac3,ac4,ac5)
18037 VALUES (ae_header_id, C_OVN
18038 ,SUBSTRB(anc_id_82
18039        ,1
18040        ,INSTRB(anc_id_82,'(]',1,1) -1)
18041 ,SUBSTRB(anc_id_82
18042        ,INSTRB(anc_id_82,'(]',1,1) + 2
18043        ,INSTRB(anc_id_82,'(]',1,2) -
18044         INSTRB(anc_id_82,'(]',1,1) - 2)
18045 ,SUBSTRB(anc_id_82
18046        ,INSTRB(anc_id_82,'(]',1,2) + 2
18047        ,INSTRB(anc_id_82,'(]',1,3) -
18048         INSTRB(anc_id_82,'(]',1,2) - 2)
18049 ,SUBSTRB(anc_id_82
18050        ,INSTRB(anc_id_82,'(]',1,3) + 2
18051        ,INSTRB(anc_id_82,'(]',1,4) -
18052         INSTRB(anc_id_82,'(]',1,3) - 2)
18053 ,SUBSTRB(anc_id_82
18054        ,INSTRB(anc_id_82,'(]',1,4) + 2
18055        ,INSTRB(anc_id_82,'(]',1,5) -
18056         INSTRB(anc_id_82,'(]',1,4) - 2)
18057 ,SUBSTRB(anc_id_82
18058        ,INSTRB(anc_id_82,'(]',1,5) + 2
18059        ,INSTRB(anc_id_82,'(]',1,6) -
18060         INSTRB(anc_id_82,'(]',1,5) - 2)
18061 ,SUBSTRB(anc_id_82
18062        ,INSTRB(anc_id_82,'(]',1,6) + 2
18063        ,INSTRB(anc_id_82,'(]',1,7) -
18064         INSTRB(anc_id_82,'(]',1,6) - 2)
18065 ,SUBSTRB(anc_id_82
18066        ,INSTRB(anc_id_82,'(]',1,7) + 2
18067        ,LENGTHB(anc_id_82))
18068 )
18069 
18070 WHEN anc_id_83 IS NOT NULL THEN
18071   INTO xla_ae_header_acs (
18072         ae_header_id , object_version_number
18073       , analytical_criterion_code
18074       , analytical_criterion_type_code
18075       , amb_context_code
18076       , ac1,ac2,ac3,ac4,ac5)
18077 VALUES (ae_header_id, C_OVN
18078 ,SUBSTRB(anc_id_83
18079        ,1
18080        ,INSTRB(anc_id_83,'(]',1,1) -1)
18081 ,SUBSTRB(anc_id_83
18082        ,INSTRB(anc_id_83,'(]',1,1) + 2
18083        ,INSTRB(anc_id_83,'(]',1,2) -
18084         INSTRB(anc_id_83,'(]',1,1) - 2)
18085 ,SUBSTRB(anc_id_83
18086        ,INSTRB(anc_id_83,'(]',1,2) + 2
18087        ,INSTRB(anc_id_83,'(]',1,3) -
18088         INSTRB(anc_id_83,'(]',1,2) - 2)
18089 ,SUBSTRB(anc_id_83
18090        ,INSTRB(anc_id_83,'(]',1,3) + 2
18091        ,INSTRB(anc_id_83,'(]',1,4) -
18092         INSTRB(anc_id_83,'(]',1,3) - 2)
18093 ,SUBSTRB(anc_id_83
18094        ,INSTRB(anc_id_83,'(]',1,4) + 2
18095        ,INSTRB(anc_id_83,'(]',1,5) -
18096         INSTRB(anc_id_83,'(]',1,4) - 2)
18097 ,SUBSTRB(anc_id_83
18098        ,INSTRB(anc_id_83,'(]',1,5) + 2
18099        ,INSTRB(anc_id_83,'(]',1,6) -
18100         INSTRB(anc_id_83,'(]',1,5) - 2)
18101 ,SUBSTRB(anc_id_83
18102        ,INSTRB(anc_id_83,'(]',1,6) + 2
18103        ,INSTRB(anc_id_83,'(]',1,7) -
18104         INSTRB(anc_id_83,'(]',1,6) - 2)
18105 ,SUBSTRB(anc_id_83
18106        ,INSTRB(anc_id_83,'(]',1,7) + 2
18107        ,LENGTHB(anc_id_83))
18108 )
18109 
18110 WHEN anc_id_84 IS NOT NULL THEN
18111   INTO xla_ae_header_acs (
18112         ae_header_id , object_version_number
18113       , analytical_criterion_code
18114       , analytical_criterion_type_code
18115       , amb_context_code
18116       , ac1,ac2,ac3,ac4,ac5)
18117 VALUES (ae_header_id, C_OVN
18118 ,SUBSTRB(anc_id_84
18119        ,1
18120        ,INSTRB(anc_id_84,'(]',1,1) -1)
18121 ,SUBSTRB(anc_id_84
18122        ,INSTRB(anc_id_84,'(]',1,1) + 2
18123        ,INSTRB(anc_id_84,'(]',1,2) -
18124         INSTRB(anc_id_84,'(]',1,1) - 2)
18125 ,SUBSTRB(anc_id_84
18126        ,INSTRB(anc_id_84,'(]',1,2) + 2
18127        ,INSTRB(anc_id_84,'(]',1,3) -
18128         INSTRB(anc_id_84,'(]',1,2) - 2)
18129 ,SUBSTRB(anc_id_84
18130        ,INSTRB(anc_id_84,'(]',1,3) + 2
18131        ,INSTRB(anc_id_84,'(]',1,4) -
18132         INSTRB(anc_id_84,'(]',1,3) - 2)
18133 ,SUBSTRB(anc_id_84
18134        ,INSTRB(anc_id_84,'(]',1,4) + 2
18135        ,INSTRB(anc_id_84,'(]',1,5) -
18136         INSTRB(anc_id_84,'(]',1,4) - 2)
18137 ,SUBSTRB(anc_id_84
18138        ,INSTRB(anc_id_84,'(]',1,5) + 2
18139        ,INSTRB(anc_id_84,'(]',1,6) -
18140         INSTRB(anc_id_84,'(]',1,5) - 2)
18141 ,SUBSTRB(anc_id_84
18142        ,INSTRB(anc_id_84,'(]',1,6) + 2
18143        ,INSTRB(anc_id_84,'(]',1,7) -
18144         INSTRB(anc_id_84,'(]',1,6) - 2)
18145 ,SUBSTRB(anc_id_84
18146        ,INSTRB(anc_id_84,'(]',1,7) + 2
18147        ,LENGTHB(anc_id_84))
18148 )
18149 
18150 WHEN anc_id_85 IS NOT NULL THEN
18151   INTO xla_ae_header_acs (
18152         ae_header_id , object_version_number
18153       , analytical_criterion_code
18154       , analytical_criterion_type_code
18155       , amb_context_code
18156       , ac1,ac2,ac3,ac4,ac5)
18157 VALUES (ae_header_id, C_OVN
18158 ,SUBSTRB(anc_id_85
18159        ,1
18160        ,INSTRB(anc_id_85,'(]',1,1) -1)
18161 ,SUBSTRB(anc_id_85
18162        ,INSTRB(anc_id_85,'(]',1,1) + 2
18163        ,INSTRB(anc_id_85,'(]',1,2) -
18164         INSTRB(anc_id_85,'(]',1,1) - 2)
18165 ,SUBSTRB(anc_id_85
18166        ,INSTRB(anc_id_85,'(]',1,2) + 2
18167        ,INSTRB(anc_id_85,'(]',1,3) -
18168         INSTRB(anc_id_85,'(]',1,2) - 2)
18169 ,SUBSTRB(anc_id_85
18170        ,INSTRB(anc_id_85,'(]',1,3) + 2
18171        ,INSTRB(anc_id_85,'(]',1,4) -
18172         INSTRB(anc_id_85,'(]',1,3) - 2)
18173 ,SUBSTRB(anc_id_85
18174        ,INSTRB(anc_id_85,'(]',1,4) + 2
18175        ,INSTRB(anc_id_85,'(]',1,5) -
18176         INSTRB(anc_id_85,'(]',1,4) - 2)
18177 ,SUBSTRB(anc_id_85
18178        ,INSTRB(anc_id_85,'(]',1,5) + 2
18179        ,INSTRB(anc_id_85,'(]',1,6) -
18180         INSTRB(anc_id_85,'(]',1,5) - 2)
18181 ,SUBSTRB(anc_id_85
18182        ,INSTRB(anc_id_85,'(]',1,6) + 2
18183        ,INSTRB(anc_id_85,'(]',1,7) -
18184         INSTRB(anc_id_85,'(]',1,6) - 2)
18185 ,SUBSTRB(anc_id_85
18186        ,INSTRB(anc_id_85,'(]',1,7) + 2
18187        ,LENGTHB(anc_id_85))
18188 )
18189 
18190 WHEN anc_id_86 IS NOT NULL THEN
18191   INTO xla_ae_header_acs (
18192         ae_header_id , object_version_number
18193       , analytical_criterion_code
18194       , analytical_criterion_type_code
18195       , amb_context_code
18196       , ac1,ac2,ac3,ac4,ac5)
18197 VALUES (ae_header_id, C_OVN
18198 ,SUBSTRB(anc_id_86
18199        ,1
18200        ,INSTRB(anc_id_86,'(]',1,1) -1)
18201 ,SUBSTRB(anc_id_86
18202        ,INSTRB(anc_id_86,'(]',1,1) + 2
18203        ,INSTRB(anc_id_86,'(]',1,2) -
18204         INSTRB(anc_id_86,'(]',1,1) - 2)
18205 ,SUBSTRB(anc_id_86
18206        ,INSTRB(anc_id_86,'(]',1,2) + 2
18207        ,INSTRB(anc_id_86,'(]',1,3) -
18208         INSTRB(anc_id_86,'(]',1,2) - 2)
18209 ,SUBSTRB(anc_id_86
18210        ,INSTRB(anc_id_86,'(]',1,3) + 2
18211        ,INSTRB(anc_id_86,'(]',1,4) -
18212         INSTRB(anc_id_86,'(]',1,3) - 2)
18213 ,SUBSTRB(anc_id_86
18214        ,INSTRB(anc_id_86,'(]',1,4) + 2
18215        ,INSTRB(anc_id_86,'(]',1,5) -
18216         INSTRB(anc_id_86,'(]',1,4) - 2)
18217 ,SUBSTRB(anc_id_86
18218        ,INSTRB(anc_id_86,'(]',1,5) + 2
18219        ,INSTRB(anc_id_86,'(]',1,6) -
18220         INSTRB(anc_id_86,'(]',1,5) - 2)
18221 ,SUBSTRB(anc_id_86
18222        ,INSTRB(anc_id_86,'(]',1,6) + 2
18223        ,INSTRB(anc_id_86,'(]',1,7) -
18224         INSTRB(anc_id_86,'(]',1,6) - 2)
18225 ,SUBSTRB(anc_id_86
18226        ,INSTRB(anc_id_86,'(]',1,7) + 2
18227        ,LENGTHB(anc_id_86))
18228 )
18229 
18230 WHEN anc_id_87 IS NOT NULL THEN
18231   INTO xla_ae_header_acs (
18232         ae_header_id , object_version_number
18233       , analytical_criterion_code
18234       , analytical_criterion_type_code
18235       , amb_context_code
18236       , ac1,ac2,ac3,ac4,ac5)
18237 VALUES (ae_header_id, C_OVN
18238 ,SUBSTRB(anc_id_87
18239        ,1
18240        ,INSTRB(anc_id_87,'(]',1,1) -1)
18241 ,SUBSTRB(anc_id_87
18242        ,INSTRB(anc_id_87,'(]',1,1) + 2
18243        ,INSTRB(anc_id_87,'(]',1,2) -
18244         INSTRB(anc_id_87,'(]',1,1) - 2)
18245 ,SUBSTRB(anc_id_87
18246        ,INSTRB(anc_id_87,'(]',1,2) + 2
18247        ,INSTRB(anc_id_87,'(]',1,3) -
18248         INSTRB(anc_id_87,'(]',1,2) - 2)
18249 ,SUBSTRB(anc_id_87
18250        ,INSTRB(anc_id_87,'(]',1,3) + 2
18251        ,INSTRB(anc_id_87,'(]',1,4) -
18252         INSTRB(anc_id_87,'(]',1,3) - 2)
18253 ,SUBSTRB(anc_id_87
18254        ,INSTRB(anc_id_87,'(]',1,4) + 2
18255        ,INSTRB(anc_id_87,'(]',1,5) -
18256         INSTRB(anc_id_87,'(]',1,4) - 2)
18257 ,SUBSTRB(anc_id_87
18258        ,INSTRB(anc_id_87,'(]',1,5) + 2
18259        ,INSTRB(anc_id_87,'(]',1,6) -
18260         INSTRB(anc_id_87,'(]',1,5) - 2)
18261 ,SUBSTRB(anc_id_87
18262        ,INSTRB(anc_id_87,'(]',1,6) + 2
18263        ,INSTRB(anc_id_87,'(]',1,7) -
18264         INSTRB(anc_id_87,'(]',1,6) - 2)
18265 ,SUBSTRB(anc_id_87
18266        ,INSTRB(anc_id_87,'(]',1,7) + 2
18267        ,LENGTHB(anc_id_87))
18268 )
18269 
18270 WHEN anc_id_88 IS NOT NULL THEN
18271   INTO xla_ae_header_acs (
18272         ae_header_id , object_version_number
18273       , analytical_criterion_code
18274       , analytical_criterion_type_code
18275       , amb_context_code
18276       , ac1,ac2,ac3,ac4,ac5)
18277 VALUES (ae_header_id, C_OVN
18278 ,SUBSTRB(anc_id_88
18279        ,1
18280        ,INSTRB(anc_id_88,'(]',1,1) -1)
18281 ,SUBSTRB(anc_id_88
18282        ,INSTRB(anc_id_88,'(]',1,1) + 2
18283        ,INSTRB(anc_id_88,'(]',1,2) -
18284         INSTRB(anc_id_88,'(]',1,1) - 2)
18285 ,SUBSTRB(anc_id_88
18286        ,INSTRB(anc_id_88,'(]',1,2) + 2
18287        ,INSTRB(anc_id_88,'(]',1,3) -
18288         INSTRB(anc_id_88,'(]',1,2) - 2)
18289 ,SUBSTRB(anc_id_88
18290        ,INSTRB(anc_id_88,'(]',1,3) + 2
18291        ,INSTRB(anc_id_88,'(]',1,4) -
18292         INSTRB(anc_id_88,'(]',1,3) - 2)
18293 ,SUBSTRB(anc_id_88
18294        ,INSTRB(anc_id_88,'(]',1,4) + 2
18295        ,INSTRB(anc_id_88,'(]',1,5) -
18296         INSTRB(anc_id_88,'(]',1,4) - 2)
18297 ,SUBSTRB(anc_id_88
18298        ,INSTRB(anc_id_88,'(]',1,5) + 2
18299        ,INSTRB(anc_id_88,'(]',1,6) -
18300         INSTRB(anc_id_88,'(]',1,5) - 2)
18301 ,SUBSTRB(anc_id_88
18302        ,INSTRB(anc_id_88,'(]',1,6) + 2
18303        ,INSTRB(anc_id_88,'(]',1,7) -
18304         INSTRB(anc_id_88,'(]',1,6) - 2)
18305 ,SUBSTRB(anc_id_88
18306        ,INSTRB(anc_id_88,'(]',1,7) + 2
18307        ,LENGTHB(anc_id_88))
18308 )
18309 
18310 WHEN anc_id_89 IS NOT NULL THEN
18311   INTO xla_ae_header_acs (
18312         ae_header_id , object_version_number
18313       , analytical_criterion_code
18314       , analytical_criterion_type_code
18315       , amb_context_code
18316       , ac1,ac2,ac3,ac4,ac5)
18317 VALUES (ae_header_id, C_OVN
18318 ,SUBSTRB(anc_id_89
18319        ,1
18320        ,INSTRB(anc_id_89,'(]',1,1) -1)
18321 ,SUBSTRB(anc_id_89
18322        ,INSTRB(anc_id_89,'(]',1,1) + 2
18323        ,INSTRB(anc_id_89,'(]',1,2) -
18324         INSTRB(anc_id_89,'(]',1,1) - 2)
18325 ,SUBSTRB(anc_id_89
18326        ,INSTRB(anc_id_89,'(]',1,2) + 2
18327        ,INSTRB(anc_id_89,'(]',1,3) -
18328         INSTRB(anc_id_89,'(]',1,2) - 2)
18329 ,SUBSTRB(anc_id_89
18330        ,INSTRB(anc_id_89,'(]',1,3) + 2
18331        ,INSTRB(anc_id_89,'(]',1,4) -
18332         INSTRB(anc_id_89,'(]',1,3) - 2)
18333 ,SUBSTRB(anc_id_89
18334        ,INSTRB(anc_id_89,'(]',1,4) + 2
18335        ,INSTRB(anc_id_89,'(]',1,5) -
18336         INSTRB(anc_id_89,'(]',1,4) - 2)
18337 ,SUBSTRB(anc_id_89
18338        ,INSTRB(anc_id_89,'(]',1,5) + 2
18339        ,INSTRB(anc_id_89,'(]',1,6) -
18340         INSTRB(anc_id_89,'(]',1,5) - 2)
18341 ,SUBSTRB(anc_id_89
18342        ,INSTRB(anc_id_89,'(]',1,6) + 2
18343        ,INSTRB(anc_id_89,'(]',1,7) -
18344         INSTRB(anc_id_89,'(]',1,6) - 2)
18345 ,SUBSTRB(anc_id_89
18346        ,INSTRB(anc_id_89,'(]',1,7) + 2
18347        ,LENGTHB(anc_id_89))
18348 )
18349 
18350 WHEN anc_id_90 IS NOT NULL THEN
18351   INTO xla_ae_header_acs (
18352         ae_header_id , object_version_number
18353       , analytical_criterion_code
18354       , analytical_criterion_type_code
18355       , amb_context_code
18356       , ac1,ac2,ac3,ac4,ac5)
18357 VALUES (ae_header_id, C_OVN
18358 ,SUBSTRB(anc_id_90
18359        ,1
18360        ,INSTRB(anc_id_90,'(]',1,1) -1)
18361 ,SUBSTRB(anc_id_90
18362        ,INSTRB(anc_id_90,'(]',1,1) + 2
18363        ,INSTRB(anc_id_90,'(]',1,2) -
18364         INSTRB(anc_id_90,'(]',1,1) - 2)
18365 ,SUBSTRB(anc_id_90
18366        ,INSTRB(anc_id_90,'(]',1,2) + 2
18367        ,INSTRB(anc_id_90,'(]',1,3) -
18368         INSTRB(anc_id_90,'(]',1,2) - 2)
18369 ,SUBSTRB(anc_id_90
18370        ,INSTRB(anc_id_90,'(]',1,3) + 2
18371        ,INSTRB(anc_id_90,'(]',1,4) -
18372         INSTRB(anc_id_90,'(]',1,3) - 2)
18373 ,SUBSTRB(anc_id_90
18374        ,INSTRB(anc_id_90,'(]',1,4) + 2
18375        ,INSTRB(anc_id_90,'(]',1,5) -
18376         INSTRB(anc_id_90,'(]',1,4) - 2)
18377 ,SUBSTRB(anc_id_90
18378        ,INSTRB(anc_id_90,'(]',1,5) + 2
18379        ,INSTRB(anc_id_90,'(]',1,6) -
18380         INSTRB(anc_id_90,'(]',1,5) - 2)
18381 ,SUBSTRB(anc_id_90
18382        ,INSTRB(anc_id_90,'(]',1,6) + 2
18383        ,INSTRB(anc_id_90,'(]',1,7) -
18384         INSTRB(anc_id_90,'(]',1,6) - 2)
18385 ,SUBSTRB(anc_id_90
18386        ,INSTRB(anc_id_90,'(]',1,7) + 2
18387        ,LENGTHB(anc_id_90))
18388 )
18389 
18390 WHEN anc_id_91 IS NOT NULL THEN
18391   INTO xla_ae_header_acs (
18392         ae_header_id , object_version_number
18393       , analytical_criterion_code
18394       , analytical_criterion_type_code
18395       , amb_context_code
18396       , ac1,ac2,ac3,ac4,ac5)
18397 VALUES (ae_header_id, C_OVN
18398 ,SUBSTRB(anc_id_91
18399        ,1
18400        ,INSTRB(anc_id_91,'(]',1,1) -1)
18401 ,SUBSTRB(anc_id_91
18402        ,INSTRB(anc_id_91,'(]',1,1) + 2
18403        ,INSTRB(anc_id_91,'(]',1,2) -
18404         INSTRB(anc_id_91,'(]',1,1) - 2)
18405 ,SUBSTRB(anc_id_91
18406        ,INSTRB(anc_id_91,'(]',1,2) + 2
18407        ,INSTRB(anc_id_91,'(]',1,3) -
18408         INSTRB(anc_id_91,'(]',1,2) - 2)
18409 ,SUBSTRB(anc_id_91
18410        ,INSTRB(anc_id_91,'(]',1,3) + 2
18411        ,INSTRB(anc_id_91,'(]',1,4) -
18412         INSTRB(anc_id_91,'(]',1,3) - 2)
18413 ,SUBSTRB(anc_id_91
18414        ,INSTRB(anc_id_91,'(]',1,4) + 2
18415        ,INSTRB(anc_id_91,'(]',1,5) -
18416         INSTRB(anc_id_91,'(]',1,4) - 2)
18417 ,SUBSTRB(anc_id_91
18418        ,INSTRB(anc_id_91,'(]',1,5) + 2
18419        ,INSTRB(anc_id_91,'(]',1,6) -
18420         INSTRB(anc_id_91,'(]',1,5) - 2)
18421 ,SUBSTRB(anc_id_91
18422        ,INSTRB(anc_id_91,'(]',1,6) + 2
18423        ,INSTRB(anc_id_91,'(]',1,7) -
18424         INSTRB(anc_id_91,'(]',1,6) - 2)
18425 ,SUBSTRB(anc_id_91
18426        ,INSTRB(anc_id_91,'(]',1,7) + 2
18427        ,LENGTHB(anc_id_91))
18428 )
18429 
18430 WHEN anc_id_92 IS NOT NULL THEN
18431   INTO xla_ae_header_acs (
18432         ae_header_id , object_version_number
18433       , analytical_criterion_code
18434       , analytical_criterion_type_code
18435       , amb_context_code
18436       , ac1,ac2,ac3,ac4,ac5)
18437 VALUES (ae_header_id, C_OVN
18438 ,SUBSTRB(anc_id_92
18439        ,1
18440        ,INSTRB(anc_id_92,'(]',1,1) -1)
18441 ,SUBSTRB(anc_id_92
18442        ,INSTRB(anc_id_92,'(]',1,1) + 2
18443        ,INSTRB(anc_id_92,'(]',1,2) -
18444         INSTRB(anc_id_92,'(]',1,1) - 2)
18445 ,SUBSTRB(anc_id_92
18446        ,INSTRB(anc_id_92,'(]',1,2) + 2
18447        ,INSTRB(anc_id_92,'(]',1,3) -
18448         INSTRB(anc_id_92,'(]',1,2) - 2)
18449 ,SUBSTRB(anc_id_92
18450        ,INSTRB(anc_id_92,'(]',1,3) + 2
18451        ,INSTRB(anc_id_92,'(]',1,4) -
18452         INSTRB(anc_id_92,'(]',1,3) - 2)
18453 ,SUBSTRB(anc_id_92
18454        ,INSTRB(anc_id_92,'(]',1,4) + 2
18455        ,INSTRB(anc_id_92,'(]',1,5) -
18456         INSTRB(anc_id_92,'(]',1,4) - 2)
18457 ,SUBSTRB(anc_id_92
18458        ,INSTRB(anc_id_92,'(]',1,5) + 2
18459        ,INSTRB(anc_id_92,'(]',1,6) -
18460         INSTRB(anc_id_92,'(]',1,5) - 2)
18461 ,SUBSTRB(anc_id_92
18462        ,INSTRB(anc_id_92,'(]',1,6) + 2
18463        ,INSTRB(anc_id_92,'(]',1,7) -
18464         INSTRB(anc_id_92,'(]',1,6) - 2)
18465 ,SUBSTRB(anc_id_92
18466        ,INSTRB(anc_id_92,'(]',1,7) + 2
18467        ,LENGTHB(anc_id_92))
18468 )
18469 
18470 WHEN anc_id_93 IS NOT NULL THEN
18471   INTO xla_ae_header_acs (
18472         ae_header_id , object_version_number
18473       , analytical_criterion_code
18474       , analytical_criterion_type_code
18475       , amb_context_code
18476       , ac1,ac2,ac3,ac4,ac5)
18477 VALUES (ae_header_id, C_OVN
18478 ,SUBSTRB(anc_id_93
18479        ,1
18480        ,INSTRB(anc_id_93,'(]',1,1) -1)
18481 ,SUBSTRB(anc_id_93
18482        ,INSTRB(anc_id_93,'(]',1,1) + 2
18483        ,INSTRB(anc_id_93,'(]',1,2) -
18484         INSTRB(anc_id_93,'(]',1,1) - 2)
18485 ,SUBSTRB(anc_id_93
18486        ,INSTRB(anc_id_93,'(]',1,2) + 2
18487        ,INSTRB(anc_id_93,'(]',1,3) -
18488         INSTRB(anc_id_93,'(]',1,2) - 2)
18489 ,SUBSTRB(anc_id_93
18490        ,INSTRB(anc_id_93,'(]',1,3) + 2
18491        ,INSTRB(anc_id_93,'(]',1,4) -
18492         INSTRB(anc_id_93,'(]',1,3) - 2)
18493 ,SUBSTRB(anc_id_93
18494        ,INSTRB(anc_id_93,'(]',1,4) + 2
18495        ,INSTRB(anc_id_93,'(]',1,5) -
18496         INSTRB(anc_id_93,'(]',1,4) - 2)
18497 ,SUBSTRB(anc_id_93
18498        ,INSTRB(anc_id_93,'(]',1,5) + 2
18499        ,INSTRB(anc_id_93,'(]',1,6) -
18500         INSTRB(anc_id_93,'(]',1,5) - 2)
18501 ,SUBSTRB(anc_id_93
18502        ,INSTRB(anc_id_93,'(]',1,6) + 2
18503        ,INSTRB(anc_id_93,'(]',1,7) -
18504         INSTRB(anc_id_93,'(]',1,6) - 2)
18505 ,SUBSTRB(anc_id_93
18506        ,INSTRB(anc_id_93,'(]',1,7) + 2
18507        ,LENGTHB(anc_id_93))
18508 )
18509 
18510 WHEN anc_id_94 IS NOT NULL THEN
18511   INTO xla_ae_header_acs (
18512         ae_header_id , object_version_number
18513       , analytical_criterion_code
18514       , analytical_criterion_type_code
18515       , amb_context_code
18516       , ac1,ac2,ac3,ac4,ac5)
18517 VALUES (ae_header_id, C_OVN
18518 ,SUBSTRB(anc_id_94
18519        ,1
18520        ,INSTRB(anc_id_94,'(]',1,1) -1)
18521 ,SUBSTRB(anc_id_94
18522        ,INSTRB(anc_id_94,'(]',1,1) + 2
18523        ,INSTRB(anc_id_94,'(]',1,2) -
18524         INSTRB(anc_id_94,'(]',1,1) - 2)
18525 ,SUBSTRB(anc_id_94
18526        ,INSTRB(anc_id_94,'(]',1,2) + 2
18527        ,INSTRB(anc_id_94,'(]',1,3) -
18528         INSTRB(anc_id_94,'(]',1,2) - 2)
18529 ,SUBSTRB(anc_id_94
18530        ,INSTRB(anc_id_94,'(]',1,3) + 2
18531        ,INSTRB(anc_id_94,'(]',1,4) -
18532         INSTRB(anc_id_94,'(]',1,3) - 2)
18533 ,SUBSTRB(anc_id_94
18534        ,INSTRB(anc_id_94,'(]',1,4) + 2
18535        ,INSTRB(anc_id_94,'(]',1,5) -
18536         INSTRB(anc_id_94,'(]',1,4) - 2)
18537 ,SUBSTRB(anc_id_94
18538        ,INSTRB(anc_id_94,'(]',1,5) + 2
18539        ,INSTRB(anc_id_94,'(]',1,6) -
18540         INSTRB(anc_id_94,'(]',1,5) - 2)
18541 ,SUBSTRB(anc_id_94
18542        ,INSTRB(anc_id_94,'(]',1,6) + 2
18543        ,INSTRB(anc_id_94,'(]',1,7) -
18544         INSTRB(anc_id_94,'(]',1,6) - 2)
18545 ,SUBSTRB(anc_id_94
18546        ,INSTRB(anc_id_94,'(]',1,7) + 2
18547        ,LENGTHB(anc_id_94))
18548 )
18549 
18550 WHEN anc_id_95 IS NOT NULL THEN
18551   INTO xla_ae_header_acs (
18552         ae_header_id , object_version_number
18553       , analytical_criterion_code
18554       , analytical_criterion_type_code
18555       , amb_context_code
18556       , ac1,ac2,ac3,ac4,ac5)
18557 VALUES (ae_header_id, C_OVN
18558 ,SUBSTRB(anc_id_95
18559        ,1
18560        ,INSTRB(anc_id_95,'(]',1,1) -1)
18561 ,SUBSTRB(anc_id_95
18562        ,INSTRB(anc_id_95,'(]',1,1) + 2
18563        ,INSTRB(anc_id_95,'(]',1,2) -
18564         INSTRB(anc_id_95,'(]',1,1) - 2)
18565 ,SUBSTRB(anc_id_95
18566        ,INSTRB(anc_id_95,'(]',1,2) + 2
18567        ,INSTRB(anc_id_95,'(]',1,3) -
18568         INSTRB(anc_id_95,'(]',1,2) - 2)
18569 ,SUBSTRB(anc_id_95
18570        ,INSTRB(anc_id_95,'(]',1,3) + 2
18571        ,INSTRB(anc_id_95,'(]',1,4) -
18572         INSTRB(anc_id_95,'(]',1,3) - 2)
18573 ,SUBSTRB(anc_id_95
18574        ,INSTRB(anc_id_95,'(]',1,4) + 2
18575        ,INSTRB(anc_id_95,'(]',1,5) -
18576         INSTRB(anc_id_95,'(]',1,4) - 2)
18577 ,SUBSTRB(anc_id_95
18578        ,INSTRB(anc_id_95,'(]',1,5) + 2
18579        ,INSTRB(anc_id_95,'(]',1,6) -
18580         INSTRB(anc_id_95,'(]',1,5) - 2)
18581 ,SUBSTRB(anc_id_95
18582        ,INSTRB(anc_id_95,'(]',1,6) + 2
18583        ,INSTRB(anc_id_95,'(]',1,7) -
18584         INSTRB(anc_id_95,'(]',1,6) - 2)
18585 ,SUBSTRB(anc_id_95
18586        ,INSTRB(anc_id_95,'(]',1,7) + 2
18587        ,LENGTHB(anc_id_95))
18588 )
18589 
18590 WHEN anc_id_96 IS NOT NULL THEN
18591   INTO xla_ae_header_acs (
18592         ae_header_id , object_version_number
18593       , analytical_criterion_code
18594       , analytical_criterion_type_code
18595       , amb_context_code
18596       , ac1,ac2,ac3,ac4,ac5)
18597 VALUES (ae_header_id, C_OVN
18598 ,SUBSTRB(anc_id_96
18599        ,1
18600        ,INSTRB(anc_id_96,'(]',1,1) -1)
18601 ,SUBSTRB(anc_id_96
18602        ,INSTRB(anc_id_96,'(]',1,1) + 2
18603        ,INSTRB(anc_id_96,'(]',1,2) -
18604         INSTRB(anc_id_96,'(]',1,1) - 2)
18605 ,SUBSTRB(anc_id_96
18606        ,INSTRB(anc_id_96,'(]',1,2) + 2
18607        ,INSTRB(anc_id_96,'(]',1,3) -
18608         INSTRB(anc_id_96,'(]',1,2) - 2)
18609 ,SUBSTRB(anc_id_96
18610        ,INSTRB(anc_id_96,'(]',1,3) + 2
18611        ,INSTRB(anc_id_96,'(]',1,4) -
18612         INSTRB(anc_id_96,'(]',1,3) - 2)
18613 ,SUBSTRB(anc_id_96
18614        ,INSTRB(anc_id_96,'(]',1,4) + 2
18615        ,INSTRB(anc_id_96,'(]',1,5) -
18616         INSTRB(anc_id_96,'(]',1,4) - 2)
18617 ,SUBSTRB(anc_id_96
18618        ,INSTRB(anc_id_96,'(]',1,5) + 2
18619        ,INSTRB(anc_id_96,'(]',1,6) -
18620         INSTRB(anc_id_96,'(]',1,5) - 2)
18621 ,SUBSTRB(anc_id_96
18622        ,INSTRB(anc_id_96,'(]',1,6) + 2
18623        ,INSTRB(anc_id_96,'(]',1,7) -
18624         INSTRB(anc_id_96,'(]',1,6) - 2)
18625 ,SUBSTRB(anc_id_96
18626        ,INSTRB(anc_id_96,'(]',1,7) + 2
18627        ,LENGTHB(anc_id_96))
18628 )
18629 
18630 WHEN anc_id_97 IS NOT NULL THEN
18631   INTO xla_ae_header_acs (
18632         ae_header_id , object_version_number
18633       , analytical_criterion_code
18634       , analytical_criterion_type_code
18635       , amb_context_code
18636       , ac1,ac2,ac3,ac4,ac5)
18637 VALUES (ae_header_id, C_OVN
18638 ,SUBSTRB(anc_id_97
18639        ,1
18640        ,INSTRB(anc_id_97,'(]',1,1) -1)
18641 ,SUBSTRB(anc_id_97
18642        ,INSTRB(anc_id_97,'(]',1,1) + 2
18643        ,INSTRB(anc_id_97,'(]',1,2) -
18644         INSTRB(anc_id_97,'(]',1,1) - 2)
18645 ,SUBSTRB(anc_id_97
18646        ,INSTRB(anc_id_97,'(]',1,2) + 2
18647        ,INSTRB(anc_id_97,'(]',1,3) -
18648         INSTRB(anc_id_97,'(]',1,2) - 2)
18649 ,SUBSTRB(anc_id_97
18650        ,INSTRB(anc_id_97,'(]',1,3) + 2
18651        ,INSTRB(anc_id_97,'(]',1,4) -
18652         INSTRB(anc_id_97,'(]',1,3) - 2)
18653 ,SUBSTRB(anc_id_97
18654        ,INSTRB(anc_id_97,'(]',1,4) + 2
18655        ,INSTRB(anc_id_97,'(]',1,5) -
18656         INSTRB(anc_id_97,'(]',1,4) - 2)
18657 ,SUBSTRB(anc_id_97
18658        ,INSTRB(anc_id_97,'(]',1,5) + 2
18659        ,INSTRB(anc_id_97,'(]',1,6) -
18660         INSTRB(anc_id_97,'(]',1,5) - 2)
18661 ,SUBSTRB(anc_id_97
18662        ,INSTRB(anc_id_97,'(]',1,6) + 2
18663        ,INSTRB(anc_id_97,'(]',1,7) -
18664         INSTRB(anc_id_97,'(]',1,6) - 2)
18665 ,SUBSTRB(anc_id_97
18666        ,INSTRB(anc_id_97,'(]',1,7) + 2
18667        ,LENGTHB(anc_id_97))
18668 )
18669 
18670 WHEN anc_id_98 IS NOT NULL THEN
18671   INTO xla_ae_header_acs (
18672         ae_header_id , object_version_number
18673       , analytical_criterion_code
18674       , analytical_criterion_type_code
18675       , amb_context_code
18676       , ac1,ac2,ac3,ac4,ac5)
18677 VALUES (ae_header_id, C_OVN
18678 ,SUBSTRB(anc_id_98
18679        ,1
18680        ,INSTRB(anc_id_98,'(]',1,1) -1)
18681 ,SUBSTRB(anc_id_98
18682        ,INSTRB(anc_id_98,'(]',1,1) + 2
18683        ,INSTRB(anc_id_98,'(]',1,2) -
18684         INSTRB(anc_id_98,'(]',1,1) - 2)
18685 ,SUBSTRB(anc_id_98
18686        ,INSTRB(anc_id_98,'(]',1,2) + 2
18687        ,INSTRB(anc_id_98,'(]',1,3) -
18688         INSTRB(anc_id_98,'(]',1,2) - 2)
18689 ,SUBSTRB(anc_id_98
18690        ,INSTRB(anc_id_98,'(]',1,3) + 2
18691        ,INSTRB(anc_id_98,'(]',1,4) -
18692         INSTRB(anc_id_98,'(]',1,3) - 2)
18693 ,SUBSTRB(anc_id_98
18694        ,INSTRB(anc_id_98,'(]',1,4) + 2
18695        ,INSTRB(anc_id_98,'(]',1,5) -
18696         INSTRB(anc_id_98,'(]',1,4) - 2)
18697 ,SUBSTRB(anc_id_98
18698        ,INSTRB(anc_id_98,'(]',1,5) + 2
18699        ,INSTRB(anc_id_98,'(]',1,6) -
18700         INSTRB(anc_id_98,'(]',1,5) - 2)
18701 ,SUBSTRB(anc_id_98
18702        ,INSTRB(anc_id_98,'(]',1,6) + 2
18703        ,INSTRB(anc_id_98,'(]',1,7) -
18704         INSTRB(anc_id_98,'(]',1,6) - 2)
18705 ,SUBSTRB(anc_id_98
18706        ,INSTRB(anc_id_98,'(]',1,7) + 2
18707        ,LENGTHB(anc_id_98))
18708 )
18709 
18710 WHEN anc_id_99 IS NOT NULL THEN
18711   INTO xla_ae_header_acs (
18712         ae_header_id , object_version_number
18713       , analytical_criterion_code
18714       , analytical_criterion_type_code
18715       , amb_context_code
18716       , ac1,ac2,ac3,ac4,ac5)
18717 VALUES (ae_header_id, C_OVN
18718 ,SUBSTRB(anc_id_99
18719        ,1
18720        ,INSTRB(anc_id_99,'(]',1,1) -1)
18721 ,SUBSTRB(anc_id_99
18722        ,INSTRB(anc_id_99,'(]',1,1) + 2
18723        ,INSTRB(anc_id_99,'(]',1,2) -
18724         INSTRB(anc_id_99,'(]',1,1) - 2)
18725 ,SUBSTRB(anc_id_99
18726        ,INSTRB(anc_id_99,'(]',1,2) + 2
18727        ,INSTRB(anc_id_99,'(]',1,3) -
18728         INSTRB(anc_id_99,'(]',1,2) - 2)
18729 ,SUBSTRB(anc_id_99
18730        ,INSTRB(anc_id_99,'(]',1,3) + 2
18731        ,INSTRB(anc_id_99,'(]',1,4) -
18732         INSTRB(anc_id_99,'(]',1,3) - 2)
18733 ,SUBSTRB(anc_id_99
18734        ,INSTRB(anc_id_99,'(]',1,4) + 2
18735        ,INSTRB(anc_id_99,'(]',1,5) -
18736         INSTRB(anc_id_99,'(]',1,4) - 2)
18737 ,SUBSTRB(anc_id_99
18738        ,INSTRB(anc_id_99,'(]',1,5) + 2
18739        ,INSTRB(anc_id_99,'(]',1,6) -
18740         INSTRB(anc_id_99,'(]',1,5) - 2)
18741 ,SUBSTRB(anc_id_99
18742        ,INSTRB(anc_id_99,'(]',1,6) + 2
18743        ,INSTRB(anc_id_99,'(]',1,7) -
18744         INSTRB(anc_id_99,'(]',1,6) - 2)
18745 ,SUBSTRB(anc_id_99
18746        ,INSTRB(anc_id_99,'(]',1,7) + 2
18747        ,LENGTHB(anc_id_99))
18748 )
18749 
18750 WHEN anc_id_100 IS NOT NULL THEN
18751   INTO xla_ae_header_acs (
18752         ae_header_id , object_version_number
18753       , analytical_criterion_code
18754       , analytical_criterion_type_code
18755       , amb_context_code
18756       , ac1,ac2,ac3,ac4,ac5)
18757 VALUES (ae_header_id, C_OVN
18758 ,SUBSTRB(anc_id_100
18759        ,1
18760        ,INSTRB(anc_id_100,'(]',1,1) -1)
18761 ,SUBSTRB(anc_id_100
18762        ,INSTRB(anc_id_100,'(]',1,1) + 2
18763        ,INSTRB(anc_id_100,'(]',1,2) -
18764         INSTRB(anc_id_100,'(]',1,1) - 2)
18765 ,SUBSTRB(anc_id_100
18766        ,INSTRB(anc_id_100,'(]',1,2) + 2
18767        ,INSTRB(anc_id_100,'(]',1,3) -
18768         INSTRB(anc_id_100,'(]',1,2) - 2)
18769 ,SUBSTRB(anc_id_100
18770        ,INSTRB(anc_id_100,'(]',1,3) + 2
18771        ,INSTRB(anc_id_100,'(]',1,4) -
18772         INSTRB(anc_id_100,'(]',1,3) - 2)
18773 ,SUBSTRB(anc_id_100
18774        ,INSTRB(anc_id_100,'(]',1,4) + 2
18775        ,INSTRB(anc_id_100,'(]',1,5) -
18776         INSTRB(anc_id_100,'(]',1,4) - 2)
18777 ,SUBSTRB(anc_id_100
18778        ,INSTRB(anc_id_100,'(]',1,5) + 2
18779        ,INSTRB(anc_id_100,'(]',1,6) -
18780         INSTRB(anc_id_100,'(]',1,5) - 2)
18781 ,SUBSTRB(anc_id_100
18782        ,INSTRB(anc_id_100,'(]',1,6) + 2
18783        ,INSTRB(anc_id_100,'(]',1,7) -
18784         INSTRB(anc_id_100,'(]',1,6) - 2)
18785 ,SUBSTRB(anc_id_100
18786        ,INSTRB(anc_id_100,'(]',1,7) + 2
18787        ,LENGTHB(anc_id_100))
18788 )
18789 SELECT  ae_header_id
18790       , anc_id_1
18791       , anc_id_2
18792       , anc_id_3
18793       , anc_id_4
18794       , anc_id_5
18795       , anc_id_6
18796       , anc_id_7
18797       , anc_id_8
18798       , anc_id_9
18799       , anc_id_10
18800       , anc_id_11
18801       , anc_id_12
18802       , anc_id_13
18803       , anc_id_14
18804       , anc_id_15
18805       , anc_id_16
18806       , anc_id_17
18807       , anc_id_18
18808       , anc_id_19
18809       , anc_id_20
18810       , anc_id_21
18811       , anc_id_22
18812       , anc_id_23
18813       , anc_id_24
18814       , anc_id_25
18815       , anc_id_26
18816       , anc_id_27
18817       , anc_id_28
18818       , anc_id_29
18819       , anc_id_30
18820       , anc_id_31
18821       , anc_id_32
18822       , anc_id_33
18823       , anc_id_34
18824       , anc_id_35
18825       , anc_id_36
18826       , anc_id_37
18827       , anc_id_38
18828       , anc_id_39
18829       , anc_id_40
18830       , anc_id_41
18831       , anc_id_42
18832       , anc_id_43
18833       , anc_id_44
18834       , anc_id_45
18835       , anc_id_46
18836       , anc_id_47
18837       , anc_id_48
18838       , anc_id_49
18839       , anc_id_50
18840       , anc_id_51
18841       , anc_id_52
18842       , anc_id_53
18843       , anc_id_54
18844       , anc_id_55
18845       , anc_id_56
18846       , anc_id_57
18847       , anc_id_58
18848       , anc_id_59
18849       , anc_id_60
18850       , anc_id_61
18851       , anc_id_62
18852       , anc_id_63
18853       , anc_id_64
18854       , anc_id_65
18855       , anc_id_66
18856       , anc_id_67
18857       , anc_id_68
18858       , anc_id_69
18859       , anc_id_70
18860       , anc_id_71
18861       , anc_id_72
18862       , anc_id_73
18863       , anc_id_74
18864       , anc_id_75
18865       , anc_id_76
18866       , anc_id_77
18867       , anc_id_78
18868       , anc_id_79
18869       , anc_id_80
18870       , anc_id_81
18871       , anc_id_82
18872       , anc_id_83
18873       , anc_id_84
18874       , anc_id_85
18875       , anc_id_86
18876       , anc_id_87
18877       , anc_id_88
18878       , anc_id_89
18879       , anc_id_90
18880       , anc_id_91
18881       , anc_id_92
18882       , anc_id_93
18883       , anc_id_94
18884       , anc_id_95
18885       , anc_id_96
18886       , anc_id_97
18887       , anc_id_98
18888       , anc_id_99
18889       , anc_id_100
18890  FROM  xla_ae_headers_gt
18891 WHERE  ae_header_id is not null;
18892 
18893 --
18894 IF (C_LEVEL_EVENT >= g_log_level) THEN
18895       trace
18896          (p_msg      => '# header analytical criteria inserted into xla_ae_header_acs = '||SQL%ROWCOUNT
18897          ,p_level    => C_LEVEL_EVENT
18898          ,p_module   => l_log_module);
18899 END IF;
18900 
18901 --
18902 EXCEPTION
18903 WHEN OTHERS THEN
18904   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
18905          trace
18906             (p_msg      => 'ERROR: XLA_AP_CANNOT_INSERT_JE ='||sqlerrm
18907             ,p_level    => C_LEVEL_EXCEPTION
18908             ,p_module   => l_log_module);
18909   END IF;
18910 
18911   xla_exceptions_pkg.raise_message  (p_appli_s_name => 'XLA'
18912                                     ,p_msg_name     => 'XLA_AP_CANNOT_INSERT_JE'
18913                                     ,p_token_1      => 'ERROR'
18914                                     ,p_value_1      => sqlerrm
18915                                     );
18916 END;
18917 --
18918 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18919 
18920       trace
18921          (p_msg      => 'return value. = '||TO_CHAR(SQL%ROWCOUNT)
18922          ,p_level    => C_LEVEL_PROCEDURE
18923          ,p_module   => l_log_module);
18924 
18925       trace
18926          (p_msg      => 'END of InsertHdrAnalyticalCriteria100'
18927          ,p_level    => C_LEVEL_PROCEDURE
18928          ,p_module   => l_log_module);
18929 END IF;
18930 --
18931 EXCEPTION
18932 WHEN xla_exceptions_pkg.application_exception THEN
18933   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
18934        trace
18935            (p_msg      => 'Error. = '||sqlerrm
18936            ,p_level    => C_LEVEL_PROCEDURE
18937            ,p_module   => l_log_module);
18938   END IF;
18939   RAISE;
18940 WHEN OTHERS  THEN
18941  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
18942        trace
18943            (p_msg      => 'Error. = '||sqlerrm
18944            ,p_level    => C_LEVEL_PROCEDURE
18945            ,p_module   => l_log_module);
18946   END IF;
18947   xla_exceptions_pkg.raise_message
18948                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertHdrAnalyticalCriteria100');
18949    --
18950 END InsertHdrAnalyticalCriteria100;
18951 --
18952 /*======================================================================+
18953 |                                                                       |
18954 | Insert final headers and distribution links                           |
18955 |                                                                       |
18956 | Returns 0 if lines inserted in final tables                           |
18957 | Otherwise 2 (if no lines inserted in final tables)                    |
18958 +======================================================================*/
18959 --
18960 FUNCTION InsertJournalEntries
18961 (p_application_id         IN INTEGER
18962 ,p_accounting_batch_id    IN NUMBER
18963 ,p_end_date               IN DATE     -- 4262811
18964 -- bulk performance
18965 ,p_accounting_mode        IN VARCHAR2
18966 ,p_budgetary_control_mode IN VARCHAR2) -- 4458381 Public Sector Enh
18967 RETURN NUMBER
18968 IS
18969   l_result             NUMBER;
18970   l_log_module         VARCHAR2(240);
18971 BEGIN
18972 
18973   --
18974   IF g_log_enabled THEN
18975     l_log_module := C_DEFAULT_MODULE||'.InsertJournalEntries';
18976   END IF;
18977   --
18978   IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
18979     trace(p_msg      => 'BEGIN of InsertJournalEntries'
18980          ,p_level    => C_LEVEL_PROCEDURE
18981          ,p_module   => l_log_module);
18982   END IF;
18983   --
18984   SetStandardWhoColumn;
18985   --l_result := XLA_AE_CODE_COMBINATION_PKG.BuildCcids;
18986 
18987   --=========================
18988   -- Insert journal entries
18989   --=========================
18990 
18991   l_result := 0;
18992   GetLineNumber;
18993 
18994   IF (InsertLines(p_application_id, p_budgetary_control_mode) +
18995       InsertHeaders(p_application_id,p_accounting_batch_id
18996                    ,p_end_date  -- 4262811
18997                    -- bulk performance
18998                    ,p_accounting_mode) > 0 ) THEN
18999 
19000       InsertLinks(p_application_id);
19001       AdjustMpaLine(p_application_id);   -- 4262811b
19002 
19003       --
19004       -- Retrieve the number ACs assigned. Call Insert ACs only when
19005       -- ACs are assigned.
19006       --
19007       g_line_ac_count := xla_analytical_criteria_pkg.get_line_ac_count;
19008       g_hdr_ac_count  := xla_analytical_criteria_pkg.get_hdr_ac_count;
19009 
19010       IF g_line_ac_count > 0 THEN
19011          InsertAnalyticalCriteria;
19012       END IF;
19013 
19014       IF g_hdr_ac_count > 0 THEN
19015          InsertHdrAnalyticalCriteria;
19016       END IF;
19017    -- AdjustMpaRevLine(p_application_id);   -- added for 4669308, removed for 5017009
19018 
19019       l_result := 0;
19020 
19021     ELSE
19022       l_result:= 2;
19023     END IF;
19024 
19025   --
19026   IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19027       trace(p_msg      => 'return value. = '||TO_CHAR(l_result)
19028            ,p_level    => C_LEVEL_PROCEDURE
19029            ,p_module   => l_log_module);
19030       trace(p_msg      => 'END of InsertJournalEntries'
19031            ,p_level    => C_LEVEL_PROCEDURE
19032            ,p_module   => l_log_module);
19033   END IF;
19034   --
19035   RETURN l_result;
19036 EXCEPTION
19037 WHEN xla_exceptions_pkg.application_exception THEN
19038  IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19039        trace
19040            (p_msg      => 'Error. = '||sqlerrm
19041            ,p_level    => C_LEVEL_PROCEDURE
19042            ,p_module   => l_log_module);
19043   END IF;
19044   RAISE;
19045 WHEN OTHERS  THEN
19046   IF (C_LEVEL_EXCEPTION >= g_log_level) THEN
19047        trace
19048            (p_msg      => 'Error. = '||sqlerrm
19049            ,p_level    => C_LEVEL_PROCEDURE
19050            ,p_module   => l_log_module);
19051   END IF;
19052   xla_exceptions_pkg.raise_message
19053                 (p_location => 'XLA_AE_JOURNAL_ENTRY_PKG.InsertJournalEntries');
19054    --
19055 END InsertJournalEntries;
19056 --
19057 
19058 /*======================================================================+
19059 |                                                                       |
19060 | Public PROCEDURE - 4219869                                            |
19061 |                                                                       |
19062 |  Update the journal entry header status for specified balance type.   |
19063 +======================================================================*/
19064 --
19065 PROCEDURE UpdateJournalEntryStatus(  p_hdr_idx              IN NUMBER
19066                                    , p_balance_type_code    IN VARCHAR2
19067 )
19068 IS
19069 l_log_module         VARCHAR2(240);
19070 BEGIN
19071 IF g_log_enabled THEN
19072       l_log_module := C_DEFAULT_MODULE||'.UpdateJournalEntryStatus';
19073 END IF;
19074 --
19075 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19076 trace
19077      (p_msg      => 'BEGIN of UpdateJournalEntryStatus'
19078      ,p_level    => C_LEVEL_PROCEDURE
19079      ,p_module   => l_log_module);
19080 END IF;
19081 
19082 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19083     trace
19084          (p_msg      => 'g_global_status [0 is valid, 1 is invalid] = '||g_global_status
19085          ,p_level    => C_LEVEL_STATEMENT
19086          ,p_module   => l_log_module);
19087 END IF;
19088 
19089 IF g_global_status = C_INVALID THEN
19090    CASE p_balance_type_code
19091       WHEN 'A' THEN
19092          XLA_AE_HEADER_PKG.g_rec_header_new.array_actual_status(p_hdr_idx) := C_INVALID;
19093       WHEN 'B' THEN
19094          XLA_AE_HEADER_PKG.g_rec_header_new.array_budget_status(p_hdr_idx) := C_INVALID;
19095       WHEN 'E' THEN
19096          XLA_AE_HEADER_PKG.g_rec_header_new.array_encumbrance_status(p_hdr_idx) := C_INVALID;
19097    END CASE;
19098    --
19099    -- update event status on the header record to invalid if the line created is invalid.
19100    --
19101    XLA_AE_HEADER_PKG.g_rec_header_new.array_event_status(p_hdr_idx) := 'I';
19102    --
19103    -- reset the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
19104    --
19105    g_global_status := C_VALID;
19106    --
19107 END IF;
19108 
19109 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19110 trace
19111      (p_msg      => 'END of UpdateJournalEntryStatus'
19112      ,p_level    => C_LEVEL_PROCEDURE
19113      ,p_module   => l_log_module);
19114 END IF;
19115 
19116 EXCEPTION
19117 --
19118 WHEN xla_exceptions_pkg.application_exception THEN
19119   RAISE;
19120 WHEN OTHERS  THEN
19121        xla_exceptions_pkg.raise_message
19122                (p_location => 'xla_ae_journal_entry_pkg.UpdateJournalEntryStatus');
19123   --
19124 END UpdateJournalEntryStatus;
19125 
19126 /*======================================================================+
19127 |                                                                       |
19128 | Public PROCEDURE - 4262811 (for MPA)                                  |
19129 |                                                                       |
19130 |  Update the journal entry header status for specified balance type.   |
19131 |                                                                       |
19132 |  Parameter: p_hdr_idx                                                 |
19133 |                                                                       |
19134 +======================================================================*/
19135 --
19136 PROCEDURE UpdateJournalEntryStatus(  p_hdr_idx              IN NUMBER
19137 )
19138 IS
19139 l_log_module         VARCHAR2(240);
19140 BEGIN
19141 IF g_log_enabled THEN
19142       l_log_module := C_DEFAULT_MODULE||'.UpdateJournalEntryStatus - p_hdr_idx';
19143 END IF;
19144 --
19145 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19146 trace
19147      (p_msg      => 'BEGIN of UpdateJournalEntryStatus - p_hdr_idx'
19148      ,p_level    => C_LEVEL_PROCEDURE
19149      ,p_module   => l_log_module);
19150 END IF;
19151 
19152 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19153     trace
19154          (p_msg      => 'g_global_status [0 is valid, 1 is invalid] = '||g_global_status -- 5019460
19155          ,p_level    => C_LEVEL_STATEMENT
19156          ,p_module   => l_log_module);
19157 END IF;
19158 
19159 IF g_global_status = C_INVALID THEN
19160 
19161    XLA_AE_HEADER_PKG.g_rec_header_new.array_actual_status(p_hdr_idx)      := C_INVALID;
19162    XLA_AE_HEADER_PKG.g_rec_header_new.array_budget_status(p_hdr_idx)      := C_INVALID;
19163    XLA_AE_HEADER_PKG.g_rec_header_new.array_encumbrance_status(p_hdr_idx) := C_INVALID;
19164    --
19165    -- update event status on the header record to invalid if the line created is invalid.
19166    --
19167    XLA_AE_HEADER_PKG.g_rec_header_new.array_event_status(p_hdr_idx) := 'I';
19168    --
19169    -- reset the XLA_AE_JOURNAL_ENTRY_PKG.g_global_status to C_VALID (0)
19170    --
19171    g_global_status := C_VALID;
19172    --
19173 END IF;
19174 
19175 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19176 trace
19177      (p_msg      => 'END of UpdateJournalEntryStatus - p_hdr_idx'
19178      ,p_level    => C_LEVEL_PROCEDURE
19179      ,p_module   => l_log_module);
19180 END IF;
19181 
19182 EXCEPTION
19183 --
19184 WHEN xla_exceptions_pkg.application_exception THEN
19185   RAISE;
19186 WHEN OTHERS  THEN
19187        xla_exceptions_pkg.raise_message
19188                (p_location => 'xla_ae_journal_entry_pkg.UpdateJournalEntryStatus - p_hdr_idx');
19189   --
19190 END UpdateJournalEntryStatus;
19191 
19192 
19193 /*======================================================================+
19194 |                                                                       |
19195 | PRIVATE Procedure: insert_diag_event                                  |
19196 |                                                                       |
19197 |    Called by Diagnostic framework to store event info.                |
19198 +======================================================================*/
19199 --
19200 PROCEDURE insert_diag_event(
19201                                p_event_id                       IN NUMBER
19202                               ,p_application_id                 IN NUMBER
19203                               ,p_ledger_id                      IN NUMBER
19204                               ,p_transaction_num                IN VARCHAR2
19205                               ,p_entity_code                    IN VARCHAR2
19206                               ,p_event_class_code               IN VARCHAR2
19207                               ,p_event_type_code                IN VARCHAR2
19208                               ,p_event_number                   IN NUMBER
19209                               ,p_event_date                     IN DATE
19210 )
19211 IS
19212 l_log_module         VARCHAR2(240);
19213 l_count              NUMBER;
19214 BEGIN
19215 IF g_log_enabled THEN
19216       l_log_module := C_DEFAULT_MODULE||'.insert_diag_event';
19217 END IF;
19218 --
19219 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19220 trace
19221      (p_msg      => 'BEGIN of insert_diag_event'
19222      ,p_level    => C_LEVEL_PROCEDURE
19223      ,p_module   => l_log_module);
19224 END IF;
19225 
19226 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19227      trace
19228          (p_msg      => 'SQL- Insert xla_diag_events the event_id ='||p_event_id
19229          ,p_level    => C_LEVEL_STATEMENT
19230          ,p_module   => l_log_module);
19231 END IF;
19232 
19233 INSERT INTO xla_diag_events
19234    (
19235         event_id
19236       , application_id
19237       , ledger_id
19238       , transaction_number
19239       , event_number
19240       , event_date
19241       , entity_code
19242       , event_class_code
19243       , event_type_code
19244       , created_by
19245       , creation_date
19246       , last_update_date
19247       , last_updated_by
19248       , last_update_login
19249       , program_update_date
19250       , program_application_id
19251       , program_id
19252       , request_id
19253    )
19254  SELECT
19255        xe.event_id
19256      , p_application_id
19257      , p_ledger_id
19258      , p_transaction_num
19259      , p_event_number
19260      , p_event_date
19261      , p_entity_code
19262      , p_event_class_code
19263      , p_event_type_code
19264      , xla_environment_pkg.g_Usr_Id
19265      , TRUNC(SYSDATE)
19266      , TRUNC(SYSDATE)
19267      , xla_environment_pkg.g_Usr_Id
19268      , xla_environment_pkg.g_Login_Id
19269      , TRUNC(SYSDATE)
19270      , xla_environment_pkg.g_Prog_Appl_Id
19271      , xla_environment_pkg.g_Prog_Id
19272      , xla_environment_pkg.g_Req_Id
19273   FROM xla_events_gt xe
19274  WHERE xe.event_id = p_event_id
19275    AND NOT EXISTS ( SELECT 'x'
19276                        FROM xla_diag_events
19277                       WHERE event_id       = p_event_id
19278                         AND application_id = p_application_id
19279                         AND ledger_id      = p_ledger_id
19280                    )
19281  ;
19282 
19283 IF (C_LEVEL_STATEMENT >= g_log_level) THEN
19284     trace
19285          (p_msg      => 'Number of Diagnostic events inserted = '||SQL%ROWCOUNT
19286          ,p_level    => C_LEVEL_STATEMENT
19287          ,p_module   => l_log_module);
19288 END IF;
19289 
19290 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19291 trace
19292      (p_msg      => 'END of insert_diag_event'
19293      ,p_level    => C_LEVEL_PROCEDURE
19294      ,p_module   => l_log_module);
19295 END IF;
19296 
19297 EXCEPTION
19298 --
19299 WHEN xla_exceptions_pkg.application_exception THEN
19300   RAISE;
19301 WHEN OTHERS  THEN
19302        xla_exceptions_pkg.raise_message
19303                (p_location => 'xla_ae_journal_entry_pkg.insert_diag_event');
19304   --
19305 END insert_diag_event;
19306 
19307 /*======================================================================+
19308 |                                                                       |
19309 +======================================================================*/
19310 PROCEDURE set_event_info
19311    (p_application_id          IN NUMBER
19312    ,p_primary_ledger_id       IN NUMBER
19313    ,p_base_ledger_id          IN NUMBER
19314    ,p_target_ledger_id        IN NUMBER
19315    ,p_entity_id               IN NUMBER
19316    ,p_legal_entity_id         IN NUMBER
19317    ,p_entity_code             IN VARCHAR2
19318    ,p_transaction_num         IN VARCHAR2
19319    ,p_event_id                IN NUMBER
19320    ,p_event_class_code        IN VARCHAR2
19321    ,p_event_type_code         IN VARCHAR2
19322    ,p_event_number            IN NUMBER
19323    ,p_event_date              IN DATE
19324    ,p_transaction_date        IN DATE
19325    ,p_reference_num_1         IN NUMBER
19326    ,p_reference_num_2         IN NUMBER
19327    ,p_reference_num_3         IN NUMBER
19328    ,p_reference_num_4         IN NUMBER
19329    ,p_reference_char_1        IN VARCHAR2
19330    ,p_reference_char_2        IN VARCHAR2
19331    ,p_reference_char_3        IN VARCHAR2
19332    ,p_reference_char_4        IN VARCHAR2
19333    ,p_reference_date_1        IN DATE
19334    ,p_reference_date_2        IN DATE
19335    ,p_reference_date_3        IN DATE
19336    ,p_reference_date_4        IN DATE
19337    ,p_event_created_by        IN VARCHAR2
19338    ,p_budgetary_control_flag  IN VARCHAR2  -- 4458381 Public Sector Enh
19339 ) IS
19340 l_temp               BOOLEAN;
19341 l_log_module         VARCHAR2(240);
19342 BEGIN
19343 --
19344 IF g_log_enabled THEN
19345       l_log_module := C_DEFAULT_MODULE||'.set_event_info';
19346 END IF;
19347 --
19348 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19349       trace
19350          (p_msg      => 'BEGIN of set_event_info'
19351          ,p_level    => C_LEVEL_PROCEDURE
19352          ,p_module   => l_log_module);
19353 
19354       trace
19355          (p_msg      => 'p_event_id = '||p_event_id
19356          ,p_level    => C_LEVEL_PROCEDURE
19357          ,p_module   => l_log_module);
19358 END IF;
19359 --
19360 g_cache_event.application_id       := p_application_id;
19361 --g_cache_event.application_name     := g_array_event(p_event_id).array_value_char('application_name');
19362 g_cache_event.ledger_id            := p_primary_ledger_id;
19363 g_cache_event.base_ledger_id       := p_base_ledger_id;
19364 g_cache_event.target_ledger_id     := p_target_ledger_id;
19365 g_cache_event.legal_entity_id      := p_legal_entity_id;
19366 g_cache_event.entity_id            := p_entity_id;
19367 g_cache_event.entity_code          := p_entity_code;
19368 g_cache_event.transaction_num      := p_transaction_num;
19369 g_cache_event.event_id             := p_event_id;
19370 g_cache_event.event_class          := p_event_class_code;
19371 g_cache_event.event_type           := p_event_type_code;
19372 g_cache_event.event_number         := p_event_number;
19373 g_cache_event.event_date           := p_event_date;
19374 g_cache_event.transaction_date     := p_transaction_date;
19375 g_cache_event.reference_num_1      := p_reference_num_1;
19376 g_cache_event.reference_num_2      := p_reference_num_2;
19377 g_cache_event.reference_num_3      := p_reference_num_3;
19378 g_cache_event.reference_num_4      := p_reference_num_4;
19379 g_cache_event.reference_char_1     := p_reference_char_1;
19380 g_cache_event.reference_char_2     := p_reference_char_2;
19381 g_cache_event.reference_char_3     := p_reference_char_3;
19382 g_cache_event.reference_char_4     := p_reference_char_4;
19383 g_cache_event.reference_date_1     := p_reference_date_1;
19384 g_cache_event.reference_date_2     := p_reference_date_2;
19385 g_cache_event.reference_date_3     := p_reference_date_3;
19386 g_cache_event.reference_date_4     := p_reference_date_4;
19387 g_cache_event.event_created_by     := p_event_created_by;
19388 g_cache_event.budgetary_control_flag:= p_budgetary_control_flag; -- 4458381 Public Sector Enh
19389 --g_cache_event.accounting_mode      := g_array_event(p_event_id).array_value_char('accounting_mode');
19390 --g_cache_event.accounting_batch_id  := g_array_event(p_event_id).array_value_num('accounting_batch_id');
19391 
19392 l_temp := GetTranslatedEventInfo;
19393 
19394 IF ( xla_accounting_engine_pkg.g_diagnostics_mode = 'Y' )THEN
19395 
19396    trace
19397          (p_msg      => '-> Call Extract Source Values Disagnostics routine'
19398          ,p_level    => C_LEVEL_STATEMENT
19399          ,p_module   => l_log_module);
19400 
19401    insert_diag_event ( p_event_id         => p_event_id
19402                       ,p_application_id   => p_application_id
19403                       ,p_ledger_id        => p_primary_ledger_id
19404                       ,p_transaction_num  => p_transaction_num
19405                       ,p_entity_code      => p_entity_code
19406                       ,p_event_class_code => p_event_class_code
19407                       ,p_event_type_code  => p_event_type_code
19408                       ,p_event_number     => p_event_number
19409                       ,p_event_date       => p_event_date
19410                       );
19411 END IF;
19412 
19413 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19414       trace
19415          (p_msg      => 'END of set_event_info'
19416          ,p_level    => C_LEVEL_PROCEDURE
19417          ,p_module   => l_log_module);
19418 END IF;
19419 END set_event_info;
19420 
19421 /*======================================================================+
19422 |   PRIVATE PROCEDURE :   Insert_ANC_Inv_Canc                           |
19423 |   Bug# 7382288:Insert analytical criteria for invoice cancellation    |
19424 |    into xla_ae_line_acs table if analytical criteria exists for       |
19425 |   invoice validation event.                                           |
19426 +======================================================================*/
19427 procedure Insert_ANC_Inv_Canc
19428 is
19429 l_rowcount           NUMBER;
19430 l_log_module         VARCHAR2(240);
19431 l_array_base_ledgers    xla_accounting_cache_pkg.t_array_ledger_id;
19432 BEGIN
19433 IF g_log_enabled THEN
19434       l_log_module := C_DEFAULT_MODULE||'.InsertAnalyticalCriteria_Inv_canc';
19435 END IF;
19436 --
19437 IF (C_LEVEL_PROCEDURE >= g_log_level) THEN
19438 
19439       trace
19440          (p_msg      => 'BEGIN of InsertAnalyticalCriteria_Inv_canc'
19441          ,p_level    => C_LEVEL_PROCEDURE
19442          ,p_module   => l_log_module);
19443 END IF;
19444 
19445 l_rowcount  := 0;
19446 l_array_base_ledgers := xla_accounting_cache_pkg.GetLedgers;
19447 
19448 for i in 1..l_array_base_ledgers.count loop
19449 insert into xla_ae_line_acs (
19450 	ae_header_id,
19451 	ae_line_num,
19452 	analytical_criterion_code,
19453 	analytical_criterion_type_code,
19454 	amb_context_code,
19455 	object_version_number,
19456 	ac1,
19457 	ac2,
19458 	ac3,
19459 	ac4,
19460 	ac5)
19461 	(select    /*+ index(gt XLA_AE_LINES_GT_U1) */
19462                        gt.ae_header_id,
19463                        gt.ae_line_num,
19464                        la.analytical_criterion_code,
19465                        la.analytical_criterion_type_code,
19466                        la.amb_context_code,
19467                        la.object_version_number,
19468                        la.ac1,
19469                        la.ac2,
19470                        la.ac3,
19471                        la.ac4,
19472                        la.ac5
19473                 from xla_ae_line_acs la,
19474                      xla_ae_lines_gt gt
19475                 where la.ae_header_id=gt.ref_ae_header_id
19476                 and gt.ref_ae_header_id<> gt.ae_header_id
19477                 and la.ae_line_num = gt.ref_ae_line_num
19478                 and gt.ref_ae_line_num is not null
19479                 and gt.temp_line_num <0
19480                 and gt.ledger_id = l_array_base_ledgers(i)
19481                 and gt.reversal_code='REVERSAL'
19482 		group by
19483                        gt.ae_header_id,
19484                        gt.ae_line_num,
19485                        la.analytical_criterion_code,
19486                        la.analytical_criterion_type_code,
19487                        la.amb_context_code,
19488                        la.object_version_number,
19489                        la.ac1,
19490                        la.ac2,
19491                        la.ac3,
19492                        la.ac4,
19493                        la.ac5
19494 	);
19495   end loop;
19496 
19497 
19498 
19499    l_rowcount := SQL%ROWCOUNT;
19500 
19501    IF (C_LEVEL_EVENT >= g_log_level) THEN
19502       trace
19503          (p_msg      => '# line analytical criteria inserted in xla_ae_line_acs for invoice cancellation = '||l_rowcount
19504          ,p_level    => C_LEVEL_EVENT
19505          ,p_module   => l_log_module);
19506    END IF;
19507 
19508 
19509 END Insert_ANC_Inv_Canc;
19510 --=============================================================================
19511 --
19512 --
19513 --
19514 --
19515 --
19516 --
19517 --
19518 --
19519 --
19520 --
19521 --
19522 --
19523 --
19524 --
19525 --
19526 --
19527 --
19528 --
19529 --
19530 --
19531 --
19532 --
19533 --=============================================================================
19534 --=============================================================================
19535 --          *********** Initialization routine **********
19536 --=============================================================================
19537 
19538 BEGIN
19539 
19540    g_log_level      := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
19541    g_log_enabled    := fnd_log.test
19542                           (log_level  => g_log_level
19543                           ,module     => C_DEFAULT_MODULE);
19544 
19545    IF NOT g_log_enabled  THEN
19546       g_log_level := C_LEVEL_LOG_DISABLED;
19547    END IF;
19548 
19549 END xla_ae_journal_entry_pkg;