1556: Element Type ID as input parameters. This procedure determines the different accounts that need to be
1557: charged and the amounts that need to be charged until a particular Date. The logic
1558: used to arrive at the charging instructions is derived from CREATE_DISTRIBUTION_LINES
1559: in Oracle Labor Distribution.
1560: Finally, the procedure creates encumbrance lines in PSP_ENC_LINES.
1561: *************************************************************************/
1562:
1563: /**********************************************************************************
1564: CODING LOGIC
3438: l_return_status VARCHAR2(1);
3439: BEGIN
3440: --For Enh. Bug 2259310 : Changed the enc_control_tab from array of records to records of array and hence the change
3441: --in the way each element of record to be accessed.
3442: --Instead of calling INSERT_ROW of PSP_ENC_LINES for each CI of an assignment, all the lines are collated into an
3443: --array for an assignment and inserted using Oracle 8i feature
3444:
3445: /* added to skip creation of lines with zero dollars Bug 1671971:- Subha */
3446: IF l_encumbrance_amount <> 0 THEN
3566: fnd_file.put_line(fnd_file.log,DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
3567: IF (g_error_message IS NULL) THEN
3568: g_error_message := 'INSERT_INTO_ENC_LINES: ' || SQLERRM;
3569: END IF;
3570: fnd_msg_pub.add_exc_msg('PSP_ENC_LINES','INSERT_INTO_ENC_LINES');
3571: p_return_status := fnd_api.g_ret_sts_unexp_error;
3572: END insert_into_enc_lines;
3573:
3574: --------------------------- INSERT INTO CONTROL TABLES --------------------------------------
3879: Created By: lveerubh
3880:
3881: Date Created By:08-MAR-2002
3882:
3883: Purpose: To insert into psp_enc_lines from Array. This procedure has been introduced to bulk insert
3884: into psp_enc_lines from the record of collection t_enc_lines_array.
3885: Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3886: Who When What
3887: lveerubh 08-MAR-2002 Created the procedure
3880:
3881: Date Created By:08-MAR-2002
3882:
3883: Purpose: To insert into psp_enc_lines from Array. This procedure has been introduced to bulk insert
3884: into psp_enc_lines from the record of collection t_enc_lines_array.
3885: Introduced as part of Enhnacement Enc Redesign : Bug 2259310.
3886: Who When What
3887: lveerubh 08-MAR-2002 Created the procedure
3888: ********************************************************************************************************************************/
3896: l_last_updated_by NUMBER DEFAULT NVL(FND_GLOBAL.USER_ID, -1);
3897: l_last_update_login NUMBER DEFAULT NVL(FND_GLOBAL.LOGIN_ID, -1);
3898: BEGIN
3899: FORALL i IN 1 .. t_enc_lines_array2.r_enc_element_type_id.COUNT
3900: insert into psp_enc_lines
3901: (
3902: enc_element_type_id,
3903: enc_line_id,
3904: business_group_id,
3956: hierarchy_code
3957: )
3958: values (
3959: t_enc_lines_array2.r_enc_element_type_id(i)
3960: ,PSP_ENC_LINES_S.NEXTVAL
3961: ,p_business_group_id
3962: , t_enc_lines_array2.r_encumbrance_date(i)
3963: , t_enc_lines_array2.r_dr_cr_flag(i)
3964: ,round( t_enc_lines_array2.r_encumbrance_amount(i),g_precision) -- introduced rounding for BUg 2916848 Ilo Ehnc.
4012: , t_enc_lines_array2.r_orig_expenditure_type(i)
4013: , t_enc_lines_array2.r_hierarchy_code(i)
4014: );
4015:
4016: DELETE psp_enc_lines
4017: WHERE payroll_id = p_payroll_id
4018: AND business_group_id = p_business_group_id
4019: AND set_of_books_id = p_set_of_books_id
4020: AND encumbrance_amount = 0;
6892: p_element_type_id NUMBER,
6893: p_enc_begin_date DATE) IS
6894: SELECT COUNT(1),
6895: NVL(MAX(pelh.encumbrance_date),p_enc_begin_date)
6896: FROM psp_enc_lines_history pelh
6897: WHERE pelh.assignment_id = l_assignment_id
6898: AND pelh.enc_element_type_id = p_element_type_id
6899: AND pelh.payroll_id = l_payroll_id;
6900:
6939: CURSOR c_max_enc_lines_date (p_assignment_id NUMBER,
6940: p_element_type_id NUMBER,
6941: p_enc_begin_date DATE) IS
6942: SELECT COUNT(1), NVL(MAX(pel.encumbrance_date),p_enc_begin_date)
6943: FROM psp_enc_lines pel
6944: WHERE pel.enc_element_type_id = p_element_type_id
6945: AND pel.assignment_id = p_assignment_id
6946: AND pel.payroll_id = l_payroll_id;
6947:
7051: asg_array asgid_tab,
7052: term_date_array term_date_tab);
7053: t_assignments t_asg_id_rec;
7054:
7055: TYPE enclinesasg_tab IS TABLE OF psp_enc_lines.assignment_id%TYPE INDEX BY BINARY_INTEGER;
7056: TYPE enclinesele_tab IS TABLE OF psp_enc_lines.enc_element_type_id%TYPE INDEX BY BINARY_INTEGER;
7057: TYPE enclinesdat_tab IS TABLE OF psp_enc_lines.encumbrance_date%TYPE INDEX BY BINARY_INTEGER;
7058: TYPE t_enclines_rec IS RECORD
7059: (asg_array enclinesasg_tab,
7052: term_date_array term_date_tab);
7053: t_assignments t_asg_id_rec;
7054:
7055: TYPE enclinesasg_tab IS TABLE OF psp_enc_lines.assignment_id%TYPE INDEX BY BINARY_INTEGER;
7056: TYPE enclinesele_tab IS TABLE OF psp_enc_lines.enc_element_type_id%TYPE INDEX BY BINARY_INTEGER;
7057: TYPE enclinesdat_tab IS TABLE OF psp_enc_lines.encumbrance_date%TYPE INDEX BY BINARY_INTEGER;
7058: TYPE t_enclines_rec IS RECORD
7059: (asg_array enclinesasg_tab,
7060: ele_array enclinesele_tab,
7053: t_assignments t_asg_id_rec;
7054:
7055: TYPE enclinesasg_tab IS TABLE OF psp_enc_lines.assignment_id%TYPE INDEX BY BINARY_INTEGER;
7056: TYPE enclinesele_tab IS TABLE OF psp_enc_lines.enc_element_type_id%TYPE INDEX BY BINARY_INTEGER;
7057: TYPE enclinesdat_tab IS TABLE OF psp_enc_lines.encumbrance_date%TYPE INDEX BY BINARY_INTEGER;
7058: TYPE t_enclines_rec IS RECORD
7059: (asg_array enclinesasg_tab,
7060: ele_array enclinesele_tab,
7061: dat_array enclinesdat_tab);
7534: END IF;
7535: hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Completed verify_changes for l_assignment_id: ' || l_assignment_id || ' payroll_id: ' || l_payroll_id);
7536: ELSE
7537: IF (l_liq_all_count > 0) THEN
7538: UPDATE psp_enc_lines_history pelh
7539: SET change_flag = 'N'
7540: WHERE assignment_id = l_assignment_id
7541: AND payroll_id = l_payroll_id
7542: AND change_flag = 'U'
7551: WHERE assignment_id = l_assignment_id
7552: AND payroll_id = l_payroll_id
7553: AND change_type = 'ZZ';
7554: ELSE
7555: UPDATE psp_enc_lines_history pelh
7556: SET change_flag = 'N'
7557: WHERE assignment_id = l_assignment_id
7558: AND payroll_id = l_payroll_id
7559: AND change_flag = 'U'
7567: -- and ptp.time_period_id = ppa.time_period_id -- Added for 11661463 -- Commented for the Bug 12647364
7568: ),l_enc_begin_date)) );
7569:
7570: hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' Updated lines to be liquidated by regular liquidation');
7571: UPDATE psp_enc_lines_history pelh
7572: SET change_flag = 'U'
7573: WHERE assignment_id = l_assignment_id
7574: AND payroll_id = l_payroll_id
7575: AND change_flag = 'N'
7849: AND pesl.status_code = 'N'
7850: AND pesl.superceded_line_id IS NOT NULL);
7851:
7852: fnd_stats.gather_table_stats('PSP', 'PSP_ENC_CONTROLS');
7853: fnd_stats.gather_table_stats('PSP', 'PSP_ENC_LINES');
7854: fnd_stats.gather_table_stats('PSP', 'PSP_ENC_SUMMARY_LINES');
7855: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Completed Gather Statistics');
7856:
7857: DELETE FROM psp_enc_controls pec
7856:
7857: DELETE FROM psp_enc_controls pec
7858: WHERE pec.payroll_action_id = p_payroll_action_id
7859: AND NOT EXISTS (SELECT 1
7860: FROM psp_enc_lines pel
7861: WHERE pel.enc_control_id = pec.enc_control_id);
7862: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines in psp_enc_controls which doesnt have a line in psp_enc_lines');
7863:
7864: UPDATE psp_enc_controls pec
7858: WHERE pec.payroll_action_id = p_payroll_action_id
7859: AND NOT EXISTS (SELECT 1
7860: FROM psp_enc_lines pel
7861: WHERE pel.enc_control_id = pec.enc_control_id);
7862: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted lines in psp_enc_controls which doesnt have a line in psp_enc_lines');
7863:
7864: UPDATE psp_enc_controls pec
7865: SET (action_code,
7866: number_of_dr, number_of_cr,
7873: SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7874: SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'G', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0))),
7875: SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'D', pel.encumbrance_amount, 0), 0))),
7876: SUM(fnd_number.canonical_to_number(DECODE(pel.gl_project_flag, 'P', DECODE(pel.dr_cr_flag, 'C', pel.encumbrance_amount, 0), 0)))
7877: FROM psp_enc_lines pel
7878: WHERE pel.enc_control_id = pec.enc_control_id)
7879: WHERE payroll_action_id = p_payroll_action_id;
7880: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Updated summary columns in psp_enc_controls');
7881:
8111: NVL(pelh.attribute10, 'NULL_VALUE'),
8112: NVL(pelh.default_reason_code, 'NULL'),
8113: NVL(pelh.suspense_reason_code, 'NULL'),
8114: hierarchy_code
8115: FROM psp_enc_lines_history pelh
8116: WHERE pelh.change_flag = 'U'
8117: AND payroll_id = p_payroll_id
8118: AND assignment_id = p_assignment_id;
8119:
8118: AND assignment_id = p_assignment_id;
8119:
8120: CURSOR modified_summary_lines_cur IS
8121: SELECT DISTINCT enc_summary_line_id
8122: FROM psp_enc_lines_history
8123: WHERE change_flag = 'N'
8124: AND payroll_id = p_payroll_id
8125: AND assignment_id = p_assignment_id;
8126:
8132: p_payroll_id: ' || p_payroll_id || ' p_assignment_id: ' || p_assignment_id || '
8133: p_business_group_id: ' || p_business_group_id || ' p_set_of_books_id: ' || p_set_of_books_id || '
8134: p_enc_line_type: ' || p_enc_line_type);
8135:
8136: UPDATE psp_enc_lines_history
8137: SET change_flag = 'N'
8138: WHERE assignment_id = p_assignment_id
8139: AND payroll_id = p_payroll_id
8140: AND change_flag = 'U'
8141: AND status_code = 'A';
8142:
8143: IF (g_dff_grouping_option = 'N') THEN
8144: FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
8145: UPDATE psp_enc_lines_history pelh
8146: SET change_flag='U'
8147: WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
8148: AND change_flag = 'N'
8149: AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
8163: AND pelh.assignment_id = p_assignment_id
8164: AND pelh.payroll_id = p_payroll_id;
8165: ELSE
8166: FORALL recno IN 1 .. t_enc_lines_array.r_time_period_id.COUNT
8167: UPDATE psp_enc_lines_history pelh
8168: SET change_flag='U'
8169: WHERE time_period_id = t_enc_lines_array.r_time_period_id(recno)
8170: AND change_flag = 'N'
8171: AND pelh.encumbrance_date = t_enc_lines_array.r_encumbrance_date(recno)
8203:
8204: hr_utility.trace('l_enc_summary_line_id_tl.COUNT: ' || l_enc_summary_line_id_tl.COUNT);
8205:
8206: FORALL recno IN 1..l_enc_summary_line_id_tl.COUNT
8207: UPDATE psp_enc_lines_history pelh
8208: SET change_flag='N'
8209: WHERE enc_summary_line_id = l_enc_summary_line_id_tl(recno)
8210: AND change_flag='U';
8211:
8544: WHERE pesl.assignment_id = p_assignment_id
8545: AND pesl.payroll_id = p_payroll_id
8546: AND pesl.status_code = 'A'
8547: AND pesl.enc_summary_line_id IN (SELECT pelh.enc_summary_line_id
8548: FROM psp_enc_lines_history pelh
8549: WHERE pelh.change_flag = 'N'
8550: AND pelh.assignment_id = p_assignment_id
8551: AND pelh.payroll_id = p_payroll_id);
8552: hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' No of liquidation lines created: ' || SQL%ROWCOUNT);
8597: DECODE(g_dff_grouping_option, 'Y', pel.attribute8, NULL) attribute8,
8598: DECODE(g_dff_grouping_option, 'Y', pel.attribute9, NULL) attribute9,
8599: DECODE(g_dff_grouping_option, 'Y', pel.attribute10, NULL) attribute10,
8600: pa.org_id
8601: FROM PSP_ENC_LINES pel,
8602: PSP_ORGANIZATION_ACCOUNTS pos,
8603: pa_projects_all pa
8604: WHERE pel.ENCUMBRANCE_AMOUNT <> 0
8605: AND pel.assignment_id = p_assignment_id
8723: hr_utility.trace(fnd_date.date_to_canonical(SYSDATE) || ' No of Summary lines created (t_sum_lines.enc_control_id.COUNT): ' || t_sum_lines.enc_control_id.COUNT);
8724:
8725: IF (g_dff_grouping_option = 'Y') THEN
8726: FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8727: UPDATE psp_enc_lines pel
8728: SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8729: WHERE payroll_action_id = p_payroll_action_id
8730: AND pel.assignment_id = p_assignment_id
8731: AND pel.payroll_id = p_payroll_id
8753: AND NVL(pel.attribute9, 'NULL') = NVL(t_sum_lines.attribute9(recno), 'NULL')
8754: AND NVL(pel.attribute10, 'NULL') = NVL(t_sum_lines.attribute10(recno), 'NULL');
8755: ELSE
8756: FORALL recno IN 1..t_sum_lines.enc_summary_line_id.COUNT
8757: UPDATE psp_enc_lines pel
8758: SET enc_summary_line_id = t_sum_lines.enc_summary_line_id(recno)
8759: WHERE payroll_action_id = p_payroll_action_id
8760: AND pel.assignment_id = p_assignment_id
8761: AND pel.payroll_id = p_payroll_id
10121: FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
10122: CLOSE superceded_line_cur;
10123:
10124: FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10125: UPDATE psp_enc_lines_history
10126: SET change_flag = 'N'
10127: WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10128: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10129:
10124: FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10125: UPDATE psp_enc_lines_history
10126: SET change_flag = 'N'
10127: WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10128: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10129:
10130: DELETE psp_enc_summary_lines
10131: WHERE payroll_action_id = p_payroll_action_id;
10132: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10130: DELETE psp_enc_summary_lines
10131: WHERE payroll_action_id = p_payroll_action_id;
10132: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10133:
10134: DELETE psp_enc_lines
10135: WHERE payroll_action_id = p_payroll_action_id;
10136: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10137:
10138: DELETE psp_enc_controls
10132: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10133:
10134: DELETE psp_enc_lines
10135: WHERE payroll_action_id = p_payroll_action_id;
10136: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10137:
10138: DELETE psp_enc_controls
10139: WHERE payroll_action_id = p_payroll_action_id;
10140: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
10239: FETCH superceded_line_cur BULK COLLECT INTO t_superceded_lines.enc_summary_line_id;
10240: CLOSE superceded_line_cur;
10241:
10242: FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10243: UPDATE psp_enc_lines_history
10244: SET change_flag = 'N'
10245: WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10246: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10247:
10242: FORALL recno IN 1..t_superceded_lines.enc_summary_line_id.COUNT
10243: UPDATE psp_enc_lines_history
10244: SET change_flag = 'N'
10245: WHERE enc_summary_line_id = t_superceded_lines.enc_summary_line_id(recno);
10246: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Reverted respective superceded lines in psp_enc_lines_history');
10247:
10248: DELETE psp_enc_summary_lines
10249: WHERE payroll_action_id = p_payroll_action_id
10250: AND assignment_id = l_assignments(recno);
10249: WHERE payroll_action_id = p_payroll_action_id
10250: AND assignment_id = l_assignments(recno);
10251: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_summary_lines');
10252:
10253: DELETE psp_enc_lines
10254: WHERE payroll_action_id = p_payroll_action_id
10255: AND assignment_id = l_assignments(recno);
10256: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10257:
10252:
10253: DELETE psp_enc_lines
10254: WHERE payroll_action_id = p_payroll_action_id
10255: AND assignment_id = l_assignments(recno);
10256: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_lines');
10257:
10258: DELETE psp_enc_controls pec
10259: WHERE payroll_action_id = p_payroll_action_id
10260: AND NOT EXISTS (SELECT 1
10257:
10258: DELETE psp_enc_controls pec
10259: WHERE payroll_action_id = p_payroll_action_id
10260: AND NOT EXISTS (SELECT 1
10261: FROM psp_enc_lines pel
10262: WHERE payroll_action_id = p_payroll_action_id
10263: AND pel.enc_control_id = pec.enc_control_id);
10264: fnd_file.put_line(fnd_file.log, fnd_date.date_to_canonical(SYSDATE) || ' Deleted respective lines in psp_enc_controls');
10265:
11881: NVL(expenditure_organization_id, -99),
11882: NVL(expenditure_type, '-99'),
11883: enc_start_date,
11884: enc_end_date
11885: FROM psp_enc_lines
11886: WHERE payroll_action_id = p_payroll_action_id
11887: AND assignment_id = p_assignment_id
11888: AND payroll_id = p_payroll_id
11889: ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11898: NVL(expenditure_organization_id, -99),
11899: NVL(expenditure_type, '-99'),
11900: enc_start_date,
11901: enc_end_date
11902: FROM psp_enc_lines_history
11903: WHERE assignment_id = p_assignment_id
11904: AND payroll_id = p_payroll_id
11905: AND change_flag = 'N'
11906: ORDER BY 1, 2, 3, 4, 5, 6, 7, 8, 9, 10;
11981: END IF;
11982: END LOOP;
11983:
11984: FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
11985: UPDATE psp_enc_lines
11986: SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
11987: hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
11988: WHERE payroll_action_id = p_payroll_action_id
11989: AND assignment_id = p_assignment_id
11996: AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
11997: AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
11998:
11999: FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12000: UPDATE psp_enc_lines
12001: SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12002: hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12003: WHERE payroll_action_id = p_payroll_action_id
12004: AND assignment_id = p_assignment_id
12097: END IF;
12098: END LOOP;
12099:
12100: FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12101: UPDATE psp_enc_lines_history
12102: SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12103: hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12104: WHERE assignment_id = p_assignment_id
12105: AND payroll_id = p_payroll_id
12112: AND enc_start_date <= t_enc_nlines.enc_end_date(recno)
12113: AND enc_end_date >= t_enc_nlines.enc_start_date(recno);
12114:
12115: FORALL recno IN 1..t_enc_nlines.element_type_id.COUNT
12116: UPDATE psp_enc_lines_history
12117: SET hierarchy_start_date = t_enc_nlines.enc_start_date(recno),
12118: hierarchy_end_date = t_enc_nlines.enc_end_date(recno)
12119: WHERE assignment_id = p_assignment_id
12120: AND payroll_id = p_payroll_id