148: -- Validation
149: -----------------------------------------------------------------------------------
150: SELECT MAX(NVL(gl_transfer_status_code,'N')) -- N, NT, S, Y
151: INTO l_gl_transfer_status_code
152: FROM xla_ae_headers
153: WHERE application_id = p_application_id
154: AND event_id = p_event_id;
155:
156: IF l_gl_transfer_status_code IS NULL THEN
288: xah.entity_id, xah.accounting_date,
289: xah.ledger_id, e.legal_entity_id, xah.accrual_reversal_flag,
290: xe.budgetary_control_flag
291: FROM xla_gl_ledgers_v xgl
292: , xla_ae_headers xah
293: , xla_subledgers xsu
294: , xla_transaction_entities e
295: , xla_events xe
296: WHERE xgl.ledger_id = xah.ledger_id
304: AND xe.event_id = xah.event_id
305: AND xah.accounting_entry_status_code = C_STATUS_FINAL_CODE
306: AND xah.parent_ae_header_id IS NULL
307: AND NOT EXISTS (SELECT 1
308: FROM xla_ae_headers xah2
309: WHERE xah2.application_id = p_application_id
310: AND xah2.event_id = p_event_id
311: AND xah2.accounting_entry_status_code = C_STATUS_FINAL_CODE
312: AND NVL(xah2.gl_transfer_status_code,'N') IN ('N','NT')); -- can be reversed only if it is transferred
387: /* Bug 7011889 - Bulk collecting header ids into an array */
388:
389: SELECT xah.ae_header_id BULK COLLECT INTO l_array_je_header_id
390: FROM xla_gl_ledgers_v xgl
391: , xla_ae_headers xah
392: , xla_subledgers xsu
393: , xla_transaction_entities e
394: , xla_events xe
395: WHERE xgl.ledger_id = xah.ledger_id
403: AND xe.event_id = xah.event_id
404: AND xah.accounting_entry_status_code = C_STATUS_FINAL_CODE
405: AND xah.parent_ae_header_id IS NULL
406: AND NOT EXISTS (SELECT 1
407: FROM xla_ae_headers xah2
408: WHERE xah2.application_id = p_application_id
409: AND xah2.event_id = p_event_id
410: AND xah2.accounting_entry_status_code = C_STATUS_FINAL_CODE
411: AND NVL(xah2.gl_transfer_status_code,'N') IN ('N','NT'));
460: INTO l_mpa_acc_rev_flag
461: FROM xla_ae_lines
462: WHERE application_id = p_application_id
463: AND ae_header_id in (SELECT ae_header_id
464: FROM xla_ae_headers
465: WHERE event_id = p_event_id
466: AND application_id = p_application_id);
467:
468: IF (C_LEVEL_STATEMENT >= g_log_level) THEN
489: -- less work in subsequent APIs, and anyway rollback if there is error
490: -------------------------------------------------------------------------
491: IF l_mpa_acc_rev_flag = 'Y' THEN
492: FOR i in (SELECT ae_header_id
493: FROM xla_ae_headers
494: WHERE application_id = p_application_id
495: AND event_id = p_event_id
496: AND parent_ae_header_id IS NOT NULL
497: AND accounting_entry_status_code <> C_STATUS_FINAL_CODE ) LOOP
510: DELETE xla_distribution_links
511: WHERE application_id = p_application_id
512: AND ae_header_id = i.ae_header_id;
513: --
514: DELETE xla_ae_headers
515: WHERE application_id = p_application_id
516: AND ae_header_id = i.ae_header_id;
517: --
518: END LOOP;
520:
521: -----------------------------------------------------------------------------------
522: -- Currently, xla_journal_entries_pkg.reverse_journal_entry only process MANUAL entry
523: -----------------------------------------------------------------------------------
524: update xla_ae_headers
525: set accounting_entry_type_code = 'MANUAL'
526: where application_id = p_application_id
527: and event_id = p_event_id;
528:
824: -------------------------------------------------------------------------------
825: -- set original entries to link to new event, entity. Also update Description
826: -------------------------------------------------------------------------------
827: IF (C_LEVEL_STATEMENT >= g_log_level) THEN
828: trace(p_msg => 'Update xla_ae_headers',
829: p_module => l_log_module,
830: p_level => C_LEVEL_STATEMENT);
831: END IF;
832: UPDATE xla_ae_headers
828: trace(p_msg => 'Update xla_ae_headers',
829: p_module => l_log_module,
830: p_level => C_LEVEL_STATEMENT);
831: END IF;
832: UPDATE xla_ae_headers
833: SET entity_id = x_new_entity_id
834: ,event_id = x_new_event_id
835: ,event_type_code = 'MANUAL'
836: ,description = 'Data fix entry: event_id of '||p_event_id
883: trace(p_msg => 'Update descriptions',
884: p_module => l_log_module,
885: p_level => C_LEVEL_STATEMENT);
886: END IF;
887: UPDATE xla_ae_headers
888: SET description = 'Data fix reversal entry: event_id of '||x_new_event_id
889: WHERE application_id = p_application_id
890: AND event_id = x_rev_event_id
891: RETURNING ae_header_id BULK COLLECT INTO l_array_ae_header_id;
1142:
1143: -- Initialize global variables
1144: x_return_status := FND_API.G_RET_STS_SUCCESS;
1145:
1146: UPDATE xla_ae_headers
1147: SET gl_transfer_status_code = 'NT'
1148: WHERE application_id = p_application_id
1149: AND ae_header_id = p_ae_header_id
1150: AND accounting_entry_status_code = C_STATUS_FINAL_CODE
1248: x_return_status := FND_API.G_RET_STS_SUCCESS;
1249:
1250: SELECT count(*)
1251: INTO l_dummy
1252: FROM xla_ae_headers
1253: WHERE application_id = p_application_id
1254: AND ae_header_id = p_ae_header_id
1255: AND accounting_entry_status_code = C_STATUS_FINAL_CODE;
1256:
1348: p_level => C_LEVEL_PROCEDURE);
1349: END IF;
1350:
1351: -----------------------------------------------------
1352: -- audit xla_ae_headers
1353: -----------------------------------------------------
1354: IF p_ae_header_id IS NOT NULL THEN
1355: IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1356: trace(p_msg => 'Audit xla_ae_headers.',
1352: -- audit xla_ae_headers
1353: -----------------------------------------------------
1354: IF p_ae_header_id IS NOT NULL THEN
1355: IF (C_LEVEL_STATEMENT >= g_log_level) THEN
1356: trace(p_msg => 'Audit xla_ae_headers.',
1357: p_module => l_log_module,
1358: p_level => C_LEVEL_STATEMENT);
1359: END IF;
1360: UPDATE XLA_AE_HEADERS
1356: trace(p_msg => 'Audit xla_ae_headers.',
1357: p_module => l_log_module,
1358: p_level => C_LEVEL_STATEMENT);
1359: END IF;
1360: UPDATE XLA_AE_HEADERS
1361: SET LAST_UPDATE_DATE = sysdate
1362: ,UPG_BATCH_ID = -9999
1363: WHERE application_id = p_application_id
1364: AND ae_header_id = p_ae_header_id;
1401: trace(p_msg => 'Audit all details of xla_events.',
1402: p_module => l_log_module,
1403: p_level => C_LEVEL_STATEMENT);
1404: END IF;
1405: UPDATE XLA_AE_HEADERS
1406: SET LAST_UPDATE_DATE = sysdate
1407: ,UPG_BATCH_ID = -9999
1408: WHERE application_id = p_application_id
1409: AND event_id = p_event_id