The following lines contain the word 'select', 'insert', 'update' or 'delete':
PROCEDURE update_entries_from_gt;
SELECT min(start_date)
INTO l_end_date
FROM gl_period_statuses
WHERE ledger_id=p_ledger_id
AND adjustment_period_flag = 'N'
AND CLOSING_STATUS in (C_PERIOD_STATUS_O, C_PERIOD_STATUS_F, C_PERIOD_STATUS_N)
AND start_date>p_end_date
AND application_id = 101;
SELECT max(end_date)
INTO l_end_date
FROM gl_period_statuses
WHERE ledger_id=p_ledger_id
AND adjustment_period_flag = 'N'
AND end_date>=p_end_date
AND application_id = 101;
SELECT 1
FROM gl_je_headers gjh
, xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND gjh.period_name = p_period_name
AND gjh.status = 'P'
AND (gjh.parent_je_header_id is not null or xs.je_source_name is null)
AND gjh.close_acct_seq_version_id is null
AND gjh.default_effective_date>= p_start_date
AND gjh.default_effective_date< p_end_date;
SELECT 1
FROM gl_je_headers gjh
, xla_subledgers xs
WHERE ledger_id = p_ledger_id
AND period_name = p_period_name
AND gjh.status = 'P'
AND (gjh.parent_je_header_id is not null or xs.je_source_name is null)
AND close_acct_seq_version_id is null
AND nvl(gjh.reference_date, gjh.posted_date) >= p_start_date
AND nvl(gjh.reference_date, gjh.posted_date) < p_end_date;
SELECT 1
FROM gl_je_headers gjh
, xla_subledgers xs
WHERE ledger_id = p_ledger_id
AND period_name = p_period_name
AND gjh.status = 'P'
AND (gjh.parent_je_header_id is not null or xs.je_source_name is null)
AND close_acct_seq_version_id is null
AND gjh.posted_date >= p_start_date
AND gjh.posted_date < p_end_date;
SELECT 1
FROM gl_period_statuses
WHERE ledger_id = p_ledger_id
AND start_date
SELECT trunc(start_date), trunc(end_date), adjustment_period_flag
INTO l_start_date, l_end_date, l_adjustment_flag
FROM GL_PERIOD_STATUSES
WHERE ledger_id = p_ledger_id
AND period_name = p_period_name
AND application_id = 101;
SELECT nvl(SORT_OPTION, DATE_TYPE)
INTO l_sort_date
FROM FUN_SEQ_CONTEXTS
WHERE SEQ_CONTEXT_ID = l_gl_seq_context_id;
SELECT nvl(SORT_OPTION, DATE_TYPE)
INTO l_sort_date
FROM FUN_SEQ_CONTEXTS
WHERE SEQ_CONTEXT_ID = l_xla_seq_context_id;
SELECT trunc(max(start_date))
INTO l_start_date
FROM gl_period_statuses
WHERE ledger_id = p_ledger_id
AND start_date <= l_start_date
AND adjustment_period_flag = 'N'
AND application_id = 101;
update_entries_from_gt;
SELECT 1
FROM gl_period_statuses
WHERE ledger_id = p_ledger_id
AND start_date
SELECT trunc(start_date), trunc(end_date), adjustment_period_flag
INTO l_start_date, l_end_date, l_adjustment_flag
FROM GL_PERIOD_STATUSES
WHERE ledger_id = p_ledger_id
AND period_name = p_period_name
AND application_id = 101;
SELECT nvl(SORT_OPTION, DATE_TYPE)
INTO l_sort_date
FROM FUN_SEQ_CONTEXTS
WHERE SEQ_CONTEXT_ID = l_gl_seq_context_id;
SELECT nvl(SORT_OPTION, DATE_TYPE)
INTO l_sort_date
FROM FUN_SEQ_CONTEXTS
WHERE SEQ_CONTEXT_ID = l_xla_seq_context_id;
PROCEDURE update_entries_from_gt is
l_log_module VARCHAR2(240);
l_log_module := C_DEFAULT_MODULE||'.update_entries_from_gt';
(p_msg => 'BEGIN of procedure update_entries_from_gt'
,p_level => C_LEVEL_PROCEDURE
,p_module => l_log_module);
UPDATE gl_je_headers gjh
SET (gjh.close_acct_seq_value
,gjh.close_acct_seq_version_id
,gjh.close_acct_seq_assign_id) =
(select xgt.sequence_value
,xgt.sequence_version_id
,xgt.sequence_assign_id
FROM xla_seq_je_headers_gt xgt
WHERE xgt.application_id = 101
AND gjh.je_header_id = xgt.ae_header_id)
WHERE gjh.je_header_id in (select ae_header_id from xla_seq_je_headers_gt where application_id=101);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
UPDATE xla_ae_headers xah
SET (xah.close_acct_seq_value
,xah.close_acct_seq_version_id
,xah.close_acct_seq_assign_id) =
(SELECT xgt.sequence_value
,xgt.sequence_version_id
,xgt.sequence_assign_id
FROM xla_seq_je_headers_gt xgt
WHERE xgt.application_id = 602
AND xah.ae_header_id = xgt.ae_header_id)
WHERE xah.ae_header_id in (select ae_header_id from xla_seq_je_headers_gt where application_id=602);
UPDATE (SELECT xah.close_acct_seq_value
,xah.close_acct_seq_version_id
,xah.close_acct_seq_assign_id
,xgt.sequence_assign_id
,xgt.sequence_version_id
,xgt.sequence_value
FROM xla_ae_headers xah
,xla_seq_je_headers_gt xgt
WHERE xgt.application_id = 602
AND xah.ae_header_id = xgt.ae_header_id)
SET close_acct_seq_value=sequence_value
,close_acct_seq_version_id = sequence_version_id
,close_acct_seq_assign_id = sequence_assign_id;
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
(p_msg => 'end of procedure update_entries_from_gt'
,p_level => C_LEVEL_PROCEDURE
,p_module => l_log_module);
END update_entries_from_gt;
SELECT min(close_acct_seq_value), close_acct_seq_version_id
FROM (
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM xla_ae_headers
WHERE ledger_id=p_ledger_id
AND accounting_date >= p_start_date
AND accounting_date < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F'
UNION
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM gl_je_headers
WHERE ledger_id=p_ledger_id
AND default_effective_date >= p_start_date
AND default_effective_date < p_end_date
AND status = 'P'
AND close_acct_seq_version_id is not null
)
GROUP BY close_acct_seq_version_id;
SELECT min(close_acct_seq_value), close_acct_seq_version_id
FROM (
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM xla_ae_headers
WHERE ledger_id=p_ledger_id
AND nvl(reference_date, accounting_date) >= p_start_date
AND nvl(reference_date, accounting_date) < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F'
UNION
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM gl_je_headers gjh, gl_period_statuses gps
WHERE gjh.ledger_id=p_ledger_id
AND nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) >= p_start_date
AND nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) < p_end_date
AND gjh.status = 'P'
AND gjh.close_acct_seq_version_id is not null
AND gps.application_id = 101
AND gps.ledger_id=p_ledger_id
AND gps.period_name = gjh.period_name
)
GROUP BY close_acct_seq_version_id;
SELECT min(close_acct_seq_value), close_acct_seq_version_id
FROM (
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM xla_ae_headers
WHERE ledger_id=p_ledger_id
AND nvl(completed_date,accounting_date)>= p_start_date
AND nvl(completed_date,accounting_date) < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F'
UNION
SELECT close_acct_seq_value, close_acct_seq_version_id
FROM gl_je_headers
WHERE ledger_id=p_ledger_id
AND posted_date >= p_start_date
AND posted_date < p_end_date
AND status = 'P'
AND close_acct_seq_version_id is not null
)
GROUP BY close_acct_seq_version_id;
UPDATE xla_ae_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE ledger_id=p_ledger_id
AND accounting_date >= p_start_date
AND accounting_date < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F';
UPDATE gl_je_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE ledger_id=p_ledger_id
AND default_effective_date >= p_start_date
AND default_effective_date < p_end_date
AND status = 'P'
AND close_acct_seq_version_id is not null;
UPDATE xla_ae_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE ledger_id=p_ledger_id
AND nvl(reference_date, accounting_date) >= p_start_date
AND nvl(reference_date, accounting_date) < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F';
UPDATE gl_je_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE je_header_id in
(
SELECT gjh.je_header_id
FROM gl_je_headers gjh, gl_period_statuses gps
WHERE gjh.ledger_id=p_ledger_id
AND nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) >= p_start_date
AND nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) < p_end_date
AND gjh.status = 'P'
AND gjh.close_acct_seq_version_id is not null
AND gps.application_id = 101
AND gps.ledger_id=p_ledger_id
AND gps.period_name = gjh.period_name
);
UPDATE xla_ae_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE ledger_id=p_ledger_id
AND nvl(completed_date,accounting_date) >= p_start_date
AND nvl(completed_date,accounting_date) < p_end_date
AND close_acct_seq_version_id is not null
AND gl_transfer_status_code = 'Y'
AND accounting_entry_status_code = 'F';
UPDATE gl_je_headers
SET close_acct_seq_value = null
,close_acct_seq_version_id = null
,close_acct_seq_assign_id = null
WHERE ledger_id=p_ledger_id
AND posted_date >= p_start_date
AND posted_date < p_end_date
AND status = 'P'
AND close_acct_seq_version_id is not null;
SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
WHERE
glsv.ledger_id = l_ledger_id
AND glsv.segment_type_code = 'B'
AND glsv.parent_record_id = glnsv.record_id
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'N'
AND glsv.Status_code is NULL
AND glnsv.Status_code is NULL;
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date,
decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND gjh.default_effective_date >= p_start_date
AND gjh.default_effective_date < p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source = xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,gl_je_segment_values gljsv
WHERE gljsv.je_header_id = gjh.je_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND gljsv.segment_type_code = 'B'
AND gljsv.segment_type_code = glsv.segment_type_code (+)
AND gljsv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id (+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND nvl(gjh.reference_date
,decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) >= p_start_date
AND nvl(gjh.reference_date
,decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) < p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND nvl(gjh.je_from_sla_flag,'N') = 'N'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378 upgraded journal entries
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source = xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,gl_je_segment_values gljsv
WHERE gljsv.je_header_id = gjh.je_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND gljsv.segment_type_code = 'B'
AND gljsv.segment_type_code = glsv.segment_type_code (+)
AND gljsv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id (+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND gjh.posted_date>= p_start_date
AND gjh.posted_date< p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378 upgraded journal entries
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source=xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,gl_je_segment_values gljsv
WHERE gljsv.je_header_id = gjh.je_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND gljsv.segment_type_code = 'B'
AND gljsv.segment_type_code = glsv.segment_type_code (+)
AND gljsv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id (+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND xah.accounting_date >= p_start_date
AND xah.accounting_date < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,xla_ae_segment_values xasv
WHERE xah.ae_header_id = xasv.ae_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND xasv.segment_type_code = 'B'
AND xasv.segment_type_code = glsv.segment_type_code (+)
AND xasv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id (+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND nvl(xah.reference_date, xah.accounting_date) >= p_start_date
AND nvl(xah.reference_date, xah.accounting_date) < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,xla_ae_segment_values xasv
WHERE xah.ae_header_id = xasv.ae_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND xasv.segment_type_code = 'B'
AND xasv.segment_type_code = glsv.segment_type_code (+)
AND xasv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id(+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND nvl(xah.completed_date, xah.accounting_date) >= p_start_date
AND nvl(xah.completed_date, xah.accounting_date) < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
AND exists
(SELECT 1
FROM gl_ledger_segment_values glsv
,gl_ledger_norm_seg_vals glnsv
,xla_ae_segment_values xasv
WHERE xah.ae_header_id = xasv.ae_header_id
AND glsv.ledger_id (+) = p_ledger_id
AND xasv.segment_type_code = 'B'
AND xasv.segment_type_code = glsv.segment_type_code (+)
AND xasv.segment_value = glsv.segment_value (+)
AND glsv.parent_record_id = glnsv.record_id(+)
AND glsv.status_code is NULL
AND glnsv.status_code is NULL
AND nvl(glnsv.sla_sequencing_flag, 'Y') = 'Y')
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date,
decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND gjh.default_effective_date >= p_start_date
AND gjh.default_effective_date < p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378 upgraded journal entries
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source = xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND nvl(gjh.reference_date
,decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) >= p_start_date
AND nvl(gjh.reference_date
,decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date)) < p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND nvl(gjh.je_from_sla_flag,'N') = 'N'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378 upgraded journal entries
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source = xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 101
,p_ledger_id
,gjh.je_header_id
,gjh.je_source
,gjh.je_category
,gjh.default_effective_date
,nvl(gjh.reference_date, decode(gps.adjustment_period_flag, 'Y', gjh.posted_date, gjh.default_effective_date))
,gjh.posted_date
FROM gl_je_headers gjh
,gl_period_statuses gps
,xla_subledgers xs
WHERE gjh.ledger_id = p_ledger_id
AND gjh.posted_date>= p_start_date
AND gjh.posted_date< p_end_date
AND gjh.status = 'P'
AND gjh.actual_flag = 'A'
AND ( gjh.parent_je_header_id is not null
OR xs.je_source_name is null
-- 6722378 upgraded journal entries
OR (gjh.global_attribute_category = 'JE.GR.GLXJEENT.HEADER' AND xs.je_source_name = 'Project Accounting')
)
AND gjh.je_source=xs.je_source_name (+)
AND gps.application_id = 101
AND gjh.period_name = gps.period_name
AND gps.ledger_id = p_ledger_id
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND xah.accounting_date >= p_start_date
AND xah.accounting_date < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND nvl(xah.reference_date, xah.accounting_date) >= p_start_date
AND nvl(xah.reference_date, xah.accounting_date) < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);
INSERT INTO XLA_SEQ_JE_HEADERS_GT
(application_id
,ledger_id
,ae_header_id
,je_source_name
,je_category_name
,gl_date
,reference_date
,completion_posted_date)
(SELECT 602
,p_ledger_id
,xah.ae_header_id
,xs.je_source_name
,xah.je_category_name
,xah.accounting_date
,nvl(xah.reference_date, xah.accounting_date)
,nvl(xah.completed_date, xah.accounting_date)
FROM xla_ae_headers xah
,xla_subledgers xs
WHERE xah.ledger_id = p_ledger_id
AND nvl(xah.completed_date, xah.accounting_date)>= p_start_date
AND nvl(xah.completed_date, xah.accounting_date) < p_end_date
AND xah.accounting_entry_status_code = 'F'
AND xah.gl_transfer_status_code = 'Y'
AND xah.application_id = xs.application_id
AND xah.balance_type_code = 'A'
);
(p_msg => '#number of rows inserted:'||to_char(SQL%ROWCOUNT)
,p_level => C_LEVEL_STATEMENT
,p_module => l_log_module);