DBA Data[Home] [Help]

APPS.PSP_ENC_UPDATE_LINES SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 8

Procedure Update_Enc_lines (errbuf 	    out NOCOPY varchar2,
                            retcode 	    out NOCOPY	varchar2,
                            p_payroll_id    IN	Number,
                            p_enc_line_type IN	VARCHAR2,
                            p_business_group_id IN Number,
                            p_set_of_books_id IN Number) IS
BEGIN
	NULL;
Line: 63

SELECT  DISTINCT  action_code
FROM   	psp_enc_controls
WHERE  	action_code = 'N'
AND     payroll_id=p_payroll_id;
Line: 68

/ * Following cursors are added for Enh. Restart Update Enc Proces * /
CURSOR inprogress_count_cur IS
--SELECT count(*)		Commented for bug fix 3434626
SELECT DISTINCT action_code
FROM   psp_enc_controls
WHERE  action_type in ('U','N','Q')
AND    action_code IN ('IU' , 'IC')	-- Introduced 'IC' check for bug fix 3434626
/ * action code = 'IU' means Failure due to db crash * /
AND    payroll_id = p_payroll_id
AND    business_group_id = p_business_group_id
AND    set_of_books_id = p_set_of_books_id
ORDER BY action_code DESC;	-- Introduced for bug fix 3434626
Line: 83

SELECT	NVL(action_type, p_enc_line_type)
FROM	psp_enc_controls
WHERE	action_code = 'IC'
AND	payroll_id = p_payroll_id
AND	business_group_id = p_business_group_id
AND	set_of_books_id = p_set_of_books_id
AND	rownum = 1; 	End of comment for bug fix 3434626	***** /
Line: 92

SELECT	processed_flag
FROM	psp_enc_changed_assignments peca
WHERE	processed_flag IS NOT NULL
AND	payroll_id = p_payroll_id
AND	ROWNUM = 1;
Line: 101

SELECT	 count(change_flag)
FROM 	 psp_enc_lines_history pelh,
	 psp_enc_changed_assignments peca
WHERE 	 pelh.change_flag	= 'N'
AND   	 pelh.payroll_id 	=  p_payroll_id
AND	 rownum			= 1
AND	 pelh.assignment_id 	=  peca.assignment_id
AND      peca.payroll_id 	= p_payroll_id
AND      peca.request_id 	IS NOT NULL
AND     ((p_enc_line_type 	= 'Q'  AND     peca.change_type	IN ('LS', 'ET', 'AS', 'QU'))
OR      p_enc_line_type 	= 'U');
Line: 123

/ * Following Variables are added for Enh. Restart Update Enc Process * /
--l_inprogress_count              NUMBER DEFAULT  -1; 	-- Added for Restart, count in-progress control recs	Commented for bug fix 3434626
Line: 132

SELECT	meaning
FROM	fnd_lookups
WHERE	lookup_type = 'PSP_ENC_LINE_TYPES'
AND	lookup_code = l_enc_line_type;
Line: 145

SELECT	DISTINCT liquidate_request_id
FROM	psp_enc_controls
WHERE	payroll_id = p_payroll_id
AND	action_code = 'IT';
Line: 151

SELECT	TO_NUMBER(argument3),
	fnd_date.canonical_to_date(fnd_date.date_to_canonical(argument4))
FROM	fnd_concurrent_requests
WHERE	request_id = l_liquidate_request_id;
Line: 157

SELECT	full_name
FROM	per_people_f
WHERE	person_id = l_person_id
AND	l_termination_date BETWEEN effective_start_date and effective_end_date;
Line: 185

 	 / * Following code is added for Enh.Restart Update Process.  * /
   	OPEN  inprogress_count_cur;
Line: 213

                         fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES',g_error_api_path);   --- added this line for 2444657
Line: 230

		UPDATE	psp_enc_changed_assignments
		SET	processed_flag = p_enc_line_type
		WHERE	payroll_id = p_payroll_id
		AND	p_enc_line_type = 'U'
			OR	(	p_enc_line_type = 'Q'
				AND	change_type IN ('AS', 'LS', 'ET', 'QU'));
Line: 257

               				/ * commented following proc Restart Update Enc process * /
               				/ * clean_up_when_error; * /
Line: 267

END IF;   / * create_inprogress_count ,Enh. Restart Update Encumbrance Proecss * /
Line: 302

         		/ * commented following proc Restart Update Enc process * /
        	 	/ * clean_up_when_error; * /
Line: 346

			 / * commented following line for update Restart * /
  	  		/ *  clean_up_when_error; * /
Line: 382

		g_error_api_path := 'UPDATE_ENC_LINES:'||g_error_api_path;
Line: 383

     		fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES',g_error_api_path || sqlerrm);
Line: 391

		g_error_api_path := 'UPDATE_ENC_LINES:'||g_error_api_path||' UNEXPECTED ERROR';
Line: 392

     		fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES',g_error_api_path || sqlerrm);
Line: 399

end update_enc_lines;
Line: 406

			        Redesign-Pre Process Bug #2259310.Introdced Bulk Update For
			        1. Marking chage_flag ='U'for unchanged lines in psp_enc_lines_history
			        2. Marking change_flag ='N' for unmodfied lines in psp_enc_lines_history,
			           which are having same summary_line_id as modified lines.

				Introduced Bulk Delete to delete newly created lines in psp_enc_lines
				where the corresponding history lines are flagged as unmodified
				i.e change_flag ='U'.

lveerubh	07-May-2002	Introduced Deletion of controls when there are no corresponding lines present-Bug 2359599
***************************************************************************************************** /

Procedure verify_changes(p_payroll_id 		IN 	NUMBER,
			 p_business_group_id 	IN 	NUMBER,
			 p_set_of_books_id 	IN 	NUMBER,
			 p_enc_line_type 	IN	VARCHAR2,
			 l_retcode 		OUT NOCOPY 	VARCHAR2) IS

	CURSOR	new_control_recs IS
	SELECT	enc_control_id,
		time_period_id
	FROM	psp_enc_controls
	WHERE	payroll_id = p_payroll_id
	AND	action_code = 'IC';
Line: 594

	SELECT distinct pel.time_period_id,
	pel.encumbrance_date,
	pel.dr_cr_flag,
	pel.encumbrance_amount,
	pel.gl_project_flag,
	NVL(pel.schedule_line_id,-99),
	NVL(pel.org_schedule_id, -99),
	NVL(pel.default_org_account_id, -99),
	NVL(pel.suspense_org_account_id, -99),
	NVL(pel.element_account_id, -99),
	NVL(project_id, -99),
	NVL(pel.task_id, -99),
	NVL(pel.award_id, -99),
	NVL(pel.expenditure_type, '-99'),
	NVL(pel.expenditure_organization_id, -99),
	NVL(pel.gl_code_combination_id, -99),
	pel.assignment_id,
        NVL(pel.attribute1,-99),
        NVL(pel.attribute2,-99),
        NVL(pel.attribute3,-99),
        NVL(pel.attribute4,-99),
        NVL(pel.attribute5,-99),
        NVL(pel.attribute6,-99),
        NVL(pel.attribute7,-99),
        NVL(pel.attribute8,-99),
        NVL(pel.attribute9,-99),
        NVL(pel.attribute10,-99)
  	FROM psp_enc_lines pel
	WHERE   enc_control_id in  (Select enc_control_id
        FROM    psp_enc_controls pec
        WHERE   payroll_id = p_payroll_id
	AND	pec.enc_control_id = pel.enc_control_id
	AND     action_code = 'IC');
Line: 631

 	SELECT distinct pelh.time_period_id ,
	pelh.encumbrance_date ,
	pelh.dr_cr_flag,
	pelh.encumbrance_amount ,
	pelh.gl_project_flag,
	NVL(pelh.schedule_line_id,-99) ,
	NVL(pelh.org_schedule_id, -99) ,
	NVL(pelh.default_org_account_id, -99),
	NVL(pelh.suspense_org_account_id, -99),
	NVL(pelh.element_account_id, -99) ,
	NVL(pelh.project_id, -99),
	NVL(pelh.task_id, -99) ,
	NVL(pelh.award_id, -99),
	NVL(pelh.expenditure_type, '-99') ,
	NVL(pelh.expenditure_organization_id, -99) ,
	NVL(pelh.gl_code_combination_id, -99),
	pelh.assignment_id,
        NVL(pelh.attribute1,-99),
        NVL(pelh.attribute2,-99),
        NVL(pelh.attribute3,-99),
        NVL(pelh.attribute4,-99),
        NVL(pelh.attribute5,-99),
        NVL(pelh.attribute6,-99),
        NVL(pelh.attribute7,-99),
        NVL(pelh.attribute8,-99),
        NVL(pelh.attribute9,-99),
        NVL(pelh.attribute10,-99)
	FROM	psp_enc_lines_history pelh
	where	pelh.change_flag = 'U'
	AND     payroll_id = p_payroll_id;
Line: 697

		/ * Following BULK update identifies all newly lines that are unchanged from the
		earlier line created in history. * /
                / * Commenting for  Bug 3821553

		IF (l_grouping_option = 'N') THEN	-- Introduced IF for bug fix 2908859
			FORALL i IN 1 .. l_enc_control_id_tl.COUNT
			UPDATE	psp_enc_lines_history pelh
			SET	change_flag='U'
			WHERE	pelh.assignment_id IN (SELECT	peca.assignment_id
						FROM	psp_enc_changed_assignments peca
						WHERE	peca.payroll_id = p_payroll_id
				--		AND	peca.request_id = g_request_id) commented for bug 2330057
                                        	AND     peca.request_id IS NOT NULL)
			AND	time_period_id = l_time_period_id_tl(i)
			AND	change_flag = 'N'
			AND	EXISTS (SELECT	1
					FROM	psp_enc_lines pel
					WHERE	pel.enc_control_id = l_enc_control_id_tl(i)
					AND	pel.time_period_id = l_time_period_id_tl(i)
					AND	pel.change_flag = 'N'
					AND	pelh.encumbrance_date = pel.encumbrance_date
					AND	pelh.dr_cr_flag = pel.dr_cr_flag
					AND	pelh.encumbrance_amount = pel.encumbrance_amount
					AND	pelh.gl_project_flag = pel.gl_project_flag
					AND	NVL(pelh.schedule_line_id,-99) = NVL(pel.schedule_line_id,-99)
					AND	NVL(pelh.org_schedule_id, -99) = NVL(pel.org_schedule_id, -99)
					AND	NVL(pelh.default_org_account_id, -99) = NVL(pel.default_org_account_id, -99)
					AND	NVL(pelh.suspense_org_account_id, -99) = NVL(pel.suspense_org_account_id, -99)
					AND	NVL(pelh.element_account_id, -99) = NVL(pel.element_account_id, -99)
					AND	NVL(pelh.project_id, -99) = NVL(project_id, -99)
					AND	NVL(pelh.task_id, -99) = NVL(pel.task_id, -99)
					AND	NVL(pelh.award_id, -99) = NVL(pel.award_id, -99)
					AND	NVL(pelh.expenditure_type, '-99') = NVL(pel.expenditure_type, '-99')
					AND	NVL(pelh.expenditure_organization_id, -99) = NVL(pel.expenditure_organization_id, -99)
					AND	NVL(pelh.gl_code_combination_id, -99) = NVL(pel.gl_code_combination_id, -99)
                                	AND     pelh.assignment_id = pel.assignment_id);   ----added for 3230387
Line: 735

				UPDATE psp_enc_lines_history pelh
				SET	change_flag='U'
				WHERE	pelh.assignment_id IN (SELECT	peca.assignment_id
							FROM	psp_enc_changed_assignments peca
							WHERE	peca.payroll_id = p_payroll_id
							AND	peca.request_id IS NOT NULL)
				AND	time_period_id = l_time_period_id_tl(i)
				AND	change_flag = 'N'
				AND	EXISTS (SELECT 1
						FROM	psp_enc_lines pel
						WHERE	pel.enc_control_id = l_enc_control_id_tl(i)
						AND	pel.time_period_id = l_time_period_id_tl(i)
						AND	pel.change_flag = 'N'
						AND	pelh.encumbrance_date = pel.encumbrance_date
						AND	pelh.dr_cr_flag = pel.dr_cr_flag
						AND	pelh.encumbrance_amount = pel.encumbrance_amount
						AND	pelh.gl_project_flag = pel.gl_project_flag
						AND	NVL(pelh.schedule_line_id,-99) = NVL(pel.schedule_line_id,-99)
						AND	NVL(pelh.org_schedule_id, -99) = NVL(pel.org_schedule_id, -99)
						AND	NVL(pelh.default_org_account_id, -99) = NVL(pel.default_org_account_id, -99)
						AND	NVL(pelh.suspense_org_account_id, -99) = NVL(pel.suspense_org_account_id, -99)
						AND	NVL(pelh.element_account_id, -99) = NVL(pel.element_account_id, -99)
						AND	NVL(pelh.project_id, -99) = NVL(project_id, -99)
						AND	NVL(pelh.task_id, -99) = NVL(pel.task_id, -99)
						AND	NVL(pelh.award_id, -99) = NVL(pel.award_id, -99)
						AND	NVL(pelh.expenditure_type, '-99') = NVL(pel.expenditure_type, '-99')
						AND	NVL(pelh.expenditure_organization_id, -99) = NVL(pel.expenditure_organization_id, -99)
						AND	NVL(pelh.gl_code_combination_id, -99) = NVL(pel.gl_code_combination_id, -99)
						AND	NVL(pelh.attribute_category, 'NULL') = NVL(pel.attribute_category, 'NULL')
						AND	NVL(pelh.attribute1, 'NULL') = NVL(pel.attribute1, 'NULL')
						AND	NVL(pelh.attribute2, 'NULL') = NVL(pel.attribute2, 'NULL')
						AND	NVL(pelh.attribute3, 'NULL') = NVL(pel.attribute3, 'NULL')
						AND	NVL(pelh.attribute4, 'NULL') = NVL(pel.attribute4, 'NULL')
						AND	NVL(pelh.attribute5, 'NULL') = NVL(pel.attribute5, 'NULL')
						AND	NVL(pelh.attribute6, 'NULL') = NVL(pel.attribute6, 'NULL')
						AND	NVL(pelh.attribute7, 'NULL') = NVL(pel.attribute7, 'NULL')
						AND	NVL(pelh.attribute8, 'NULL') = NVL(pel.attribute8, 'NULL')
						AND	NVL(pelh.attribute9, 'NULL') = NVL(pel.attribute9, 'NULL')
						AND	NVL(pelh.attribute10, 'NULL') = NVL(pel.attribute10, 'NULL')
						AND	pelh.assignment_id = pel.assignment_id);
Line: 784

                  UPDATE  psp_enc_lines_history pelh
                  SET     change_flag='U'
                  WHERE   time_period_id = l_time_period_id_tl(i)
                  AND     change_flag = 'N'
                  AND     pelh.encumbrance_date = l_encumbrance_date_tl(I)
                  AND     pelh.dr_cr_flag = l_dr_cr_flag_tl(I)
                  AND     pelh.encumbrance_amount = l_encumbrance_amount_tl(I)
                  AND     pelh.gl_project_flag = l_gl_project_flag_tl(I)
                  AND     NVL(pelh.schedule_line_id,-99) = l_schedule_line_id_tl(I)
                  AND     NVL(pelh.org_schedule_id, -99) = l_org_schedule_id_tl(I)
                  AND     NVL(pelh.default_org_account_id, -99) = l_default_org_account_id_tl(I)
                  AND     NVL(pelh.suspense_org_account_id, -99) = l_suspense_org_account_id_tl(I)
                  AND     NVL(pelh.element_account_id, -99) = l_element_account_id_tl(I)
                  AND     NVL(pelh.project_id, -99) = l_project_id_tl(I)
                  AND     NVL(pelh.task_id, -99) = l_task_id_tl(i)
                  AND     NVL(pelh.award_id, -99) = l_award_id_tl(i)
                  AND     NVL(pelh.expenditure_type, '-99') = l_expenditure_type_tl(I)
                  AND     NVL(pelh.expenditure_organization_id, -99) = l_exp_organization_id_tl(i)
                  AND     NVL(pelh.gl_code_combination_id, -99) = l_gl_code_combination_id_tl(i)
                  AND     pelh.assignment_id = l_assignment_id_tl(i);
Line: 808

                  UPDATE  psp_enc_lines_history pelh
                  SET     change_flag='U'
                  WHERE   time_period_id = l_time_period_id_tl(i)
                  AND     change_flag = 'N'
                  AND     pelh.encumbrance_date = l_encumbrance_date_tl(I)
                  AND     pelh.dr_cr_flag = l_dr_cr_flag_tl(I)
                  AND     pelh.encumbrance_amount = l_encumbrance_amount_tl(I)
                  AND     pelh.gl_project_flag = l_gl_project_flag_tl(I)
                  AND     NVL(pelh.schedule_line_id,-99) = l_schedule_line_id_tl(I)
                  AND     NVL(pelh.org_schedule_id, -99) = l_org_schedule_id_tl(I)
                  AND     NVL(pelh.default_org_account_id, -99) = l_default_org_account_id_tl(I)
                  AND     NVL(pelh.suspense_org_account_id, -99) = l_suspense_org_account_id_tl(I)
                  AND     NVL(pelh.element_account_id, -99) = l_element_account_id_tl(I)
                  AND     NVL(pelh.project_id, -99) = l_project_id_tl(I)
                  AND     NVL(pelh.task_id, -99) = l_task_id_tl(i)
                  AND     NVL(pelh.award_id, -99) = l_award_id_tl(i)
                  AND     NVL(pelh.expenditure_type, '-99') = l_expenditure_type_tl(I)
                  AND     NVL(pelh.expenditure_organization_id, -99) = l_exp_organization_id_tl(i)
                  AND     NVL(pelh.gl_code_combination_id, -99) = l_gl_code_combination_id_tl(i)
                  AND     pelh.assignment_id = l_assignment_id_tl(i)
                        -- removed nvl on rhs and changed NULL to -99 on lhs for 4072324
                  AND     NVL(pelh.attribute1, '-99') = l_attribute1_tl(i)
		  AND	  NVL(pelh.attribute2, '-99') = l_attribute2_tl(i)
		  AND	  NVL(pelh.attribute3, '-99') = l_attribute3_tl(i)
		  AND	  NVL(pelh.attribute4, '-99') = l_attribute4_tl(i)
		  AND	  NVL(pelh.attribute5, '-99') = l_attribute5_tl(i)
		  AND	  NVL(pelh.attribute6, '-99') = l_attribute6_tl(i)
		  AND	  NVL(pelh.attribute7, '-99') = l_attribute7_tl(i)
		  AND	  NVL(pelh.attribute8, '-99') = l_attribute8_tl(i)
		  AND	  NVL(pelh.attribute9, '-99') = l_attribute9_tl(i)
		  AND	  NVL(pelh.attribute10, '-99') = l_attribute10_tl(i);
Line: 860

		UPDATE	psp_enc_lines_history pelh
		SET	change_flag='N'
		WHERE	enc_summary_line_id in	(SELECT enc_summary_line_id
						FROM	psp_enc_lines_history
						WHERE	change_flag = 'N'
						AND	time_period_id = l_time_period_id_tl(i))
		AND	change_flag='U'
		AND	time_period_id=l_time_period_id_tl(i);
Line: 879

                 l_time_period_id_tl.delete;
Line: 880

                 l_encumbrance_date_tl.delete;
Line: 881

                 l_dr_cr_flag_tl.delete;
Line: 882

                 l_encumbrance_amount_tl.delete;
Line: 883

                 l_gl_project_flag_tl.delete;
Line: 884

                 l_schedule_line_id_tl.delete;
Line: 885

                 l_org_schedule_id_tl.delete;
Line: 886

                 l_default_org_account_id_tl.delete;
Line: 887

                 l_suspense_org_account_id_tl.delete;
Line: 888

                 l_element_account_id_tl.delete;
Line: 889

                 l_project_id_tl.delete;
Line: 890

                 l_task_id_tl.delete;
Line: 891

                 l_award_id_tl.delete;
Line: 892

                 l_expenditure_type_tl.delete;
Line: 893

                 l_exp_organization_id_tl.delete;
Line: 894

                 l_gl_code_combination_id_tl.delete;
Line: 895

                 l_assignment_id_tl.delete;
Line: 896

                 l_attribute1_tl.delete;
Line: 897

                 l_attribute2_tl.delete;
Line: 898

                 l_attribute3_tl.delete;
Line: 899

                 l_attribute4_tl.delete;
Line: 900

                 l_attribute5_tl.delete;
Line: 901

                 l_attribute6_tl.delete;
Line: 902

                 l_attribute7_tl.delete;
Line: 903

                 l_attribute8_tl.delete;
Line: 904

                 l_attribute9_tl.delete;
Line: 905

                 l_attribute10_tl.delete;
Line: 918

		/ * Delete all those duplicate lines in psp_enc_lines that need not be summarized.	* /
                / * Commenting the code for Bug 3821553
		IF (l_grouping_option = 'N') THEN	-- Introduced IF for bug fix 2908859
			FORALL i IN 1 .. l_enc_control_id_tl.COUNT
			DELETE	psp_enc_lines pel
			WHERE	time_period_id = l_time_period_id_tl(i)
			AND	change_flag = 'N'
			AND	EXISTS	(SELECT	1
					FROM	psp_enc_lines_history pelh
--				WHERE	pelh.enc_control_id = l_enc_control_id_tl(i)
					WHERE	pelh.time_period_id = l_time_period_id_tl(i)
					AND	pelh.change_flag = 'U'
					AND	pelh.encumbrance_date = pel.encumbrance_date
					AND	pelh.dr_cr_flag = pel.dr_cr_flag
					AND	pelh.encumbrance_amount = pel.encumbrance_amount
					AND	pelh.gl_project_flag = pel.gl_project_flag
					AND	NVL(pelh.schedule_line_id,-99) = NVL(pel.schedule_line_id,-99)
					AND	NVL(pelh.org_schedule_id, -99) = NVL(pel.org_schedule_id, -99)
					AND	NVL(pelh.default_org_account_id, -99) = NVL(pel.default_org_account_id, -99)
					AND	NVL(pelh.suspense_org_account_id, -99) = NVL(pel.suspense_org_account_id, -99)
					AND	NVL(pelh.element_account_id, -99) = NVL(pel.element_account_id, -99)
					AND	NVL(pelh.project_id, -99) = NVL(project_id, -99)
					AND	NVL(pelh.task_id, -99) = NVL(pel.task_id, -99)
					AND	NVL(pelh.award_id, -99) = NVL(pel.award_id, -99)
					AND	NVL(pelh.expenditure_type, '-99') = NVL(pel.expenditure_type, '-99')
					AND	NVL(pelh.expenditure_organization_id, -99) = NVL(pel.expenditure_organization_id, -99)
					AND	NVL(pelh.gl_code_combination_id, -99) = NVL(pel.gl_code_combination_id, -99)
                                	AND     pel.assignment_id = pelh.assignment_id);    --- 3230387
Line: 948

				DELETE psp_enc_lines pel
				WHERE	time_period_id = l_time_period_id_tl(i)
				AND	change_flag = 'N'
				AND	EXISTS (SELECT 1
						FROM	psp_enc_lines_history pelh
						WHERE	pelh.time_period_id = l_time_period_id_tl(i)
						AND	pelh.change_flag = 'U'
						AND	pelh.encumbrance_date = pel.encumbrance_date
						AND	pelh.dr_cr_flag = pel.dr_cr_flag
						AND	pelh.encumbrance_amount = pel.encumbrance_amount
						AND	pelh.gl_project_flag = pel.gl_project_flag
						AND	NVL(pelh.schedule_line_id,-99) = NVL(pel.schedule_line_id,-99)
						AND	NVL(pelh.org_schedule_id, -99) = NVL(pel.org_schedule_id, -99)
						AND	NVL(pelh.default_org_account_id, -99) = NVL(pel.default_org_account_id, -99)
						AND	NVL(pelh.suspense_org_account_id, -99) = NVL(pel.suspense_org_account_id, -99)
						AND	NVL(pelh.element_account_id, -99) = NVL(pel.element_account_id, -99)
						AND	NVL(pelh.project_id, -99) = NVL(project_id, -99)
						AND	NVL(pelh.task_id, -99) = NVL(pel.task_id, -99)
						AND	NVL(pelh.award_id, -99) = NVL(pel.award_id, -99)
						AND	NVL(pelh.expenditure_type, '-99') = NVL(pel.expenditure_type, '-99')
						AND	NVL(pelh.expenditure_organization_id, -99) = NVL(pel.expenditure_organization_id, -99)
						AND	NVL(pelh.gl_code_combination_id, -99) = NVL(pel.gl_code_combination_id, -99)
						AND	NVL(pelh.attribute_category, 'NULL') = NVL(pel.attribute_category, 'NULL')
						AND	NVL(pelh.attribute1, 'NULL') = NVL(pel.attribute1, 'NULL')
						AND	NVL(pelh.attribute2, 'NULL') = NVL(pel.attribute2, 'NULL')
						AND	NVL(pelh.attribute3, 'NULL') = NVL(pel.attribute3, 'NULL')
						AND	NVL(pelh.attribute4, 'NULL') = NVL(pel.attribute4, 'NULL')
						AND	NVL(pelh.attribute5, 'NULL') = NVL(pel.attribute5, 'NULL')
						AND	NVL(pelh.attribute6, 'NULL') = NVL(pel.attribute6, 'NULL')
						AND	NVL(pelh.attribute7, 'NULL') = NVL(pel.attribute7, 'NULL')
						AND	NVL(pelh.attribute8, 'NULL') = NVL(pel.attribute8, 'NULL')
						AND	NVL(pelh.attribute9, 'NULL') = NVL(pel.attribute9, 'NULL')
						AND	NVL(pelh.attribute10, 'NULL') = NVL(pel.attribute10, 'NULL')
						AND	pel.assignment_id = pelh.assignment_id);
Line: 990

                       DELETE	psp_enc_lines pel
		       WHERE	time_period_id = l_time_period_id_tl(i)
		       AND	pel.change_flag = 'N'
		       AND	pel.encumbrance_date = l_encumbrance_date_tl(i)
      		       AND	pel.dr_cr_flag = l_dr_cr_flag_tl(i)
		       AND	pel.encumbrance_amount = l_encumbrance_amount_tl(i)
		       AND	pel.gl_project_flag = l_gl_project_flag_tl(i)
		       AND	NVL(pel.schedule_line_id,-99) = l_schedule_line_id_tl(i)
		       AND	NVL(pel.org_schedule_id, -99) = l_org_schedule_id_tl(i)
		       AND	NVL(pel.default_org_account_id, -99) = l_default_org_account_id_tl(i)
		       AND	NVL(pel.suspense_org_account_id, -99) = l_suspense_org_account_id_tl(i)
		       AND	NVL(pel.element_account_id, -99) = l_element_account_id_tl(i)
		       AND	NVL(pel.project_id, -99) = l_project_id_tl(I)
		       AND	NVL(pel.task_id, -99) = l_task_id_tl(i)
		       AND	NVL(pel.award_id, -99) = l_award_id_tl(i)
		       AND	NVL(pel.expenditure_type, '-99') = l_expenditure_type_tl(i)
		       AND	NVL(pel.expenditure_organization_id, -99) = l_exp_organization_id_tl(i)
		       AND	NVL(pel.gl_code_combination_id, -99) = l_gl_code_combination_id_tl(i)
                       AND      pel.assignment_id = l_assignment_id_tl(i);
Line: 1013

                       DELETE	psp_enc_lines pel
		       WHERE	time_period_id = l_time_period_id_tl(i)
		       AND	pel.change_flag = 'N'
		       AND	pel.encumbrance_date = l_encumbrance_date_tl(i)
      		       AND	pel.dr_cr_flag = l_dr_cr_flag_tl(i)
		       AND	pel.encumbrance_amount = l_encumbrance_amount_tl(i)
		       AND	pel.gl_project_flag = l_gl_project_flag_tl(i)
		       AND	NVL(pel.schedule_line_id,-99) = l_schedule_line_id_tl(i)
		       AND	NVL(pel.org_schedule_id, -99) = l_org_schedule_id_tl(i)
		       AND	NVL(pel.default_org_account_id, -99) = l_default_org_account_id_tl(i)
		       AND	NVL(pel.suspense_org_account_id, -99) = l_suspense_org_account_id_tl(i)
		       AND	NVL(pel.element_account_id, -99) = l_element_account_id_tl(i)
		       AND	NVL(pel.project_id, -99) = l_project_id_tl(I)
		       AND	NVL(pel.task_id, -99) = l_task_id_tl(i)
		       AND	NVL(pel.award_id, -99) = l_award_id_tl(i)
		       AND	NVL(pel.expenditure_type, '-99') = l_expenditure_type_tl(i)
		       AND	NVL(pel.expenditure_organization_id, -99) = l_exp_organization_id_tl(i)
		       AND	NVL(pel.gl_code_combination_id, -99) = l_gl_code_combination_id_tl(i)
                       AND      pel.assignment_id = l_assignment_id_tl(i)
                       -- removed nvl on rhs, not necessary.. for 4072324
                       AND      NVL(pel.attribute1, '-99') = l_attribute1_tl(i)
                       AND	NVL(pel.attribute2, '-99') = l_attribute2_tl(i)
		       AND	NVL(pel.attribute3, '-99') = l_attribute3_tl(i)
		       AND	NVL(pel.attribute4, '-99') = l_attribute4_tl(i)
		       AND	NVL(pel.attribute5, '-99') = l_attribute5_tl(i)
		       AND	NVL(pel.attribute6, '-99') = l_attribute6_tl(i)
		       AND	NVL(pel.attribute7, '-99') = l_attribute7_tl(i)
		       AND	NVL(pel.attribute8, '-99') = l_attribute8_tl(i)
		       AND	NVL(pel.attribute9, '-99') = l_attribute9_tl(i)
		       AND	NVL(pel.attribute10, '-99') = l_attribute10_tl(i);
Line: 1048

                 l_time_period_id_tl.delete;
Line: 1049

                 l_encumbrance_date_tl.delete;
Line: 1050

                 l_dr_cr_flag_tl.delete;
Line: 1051

                 l_encumbrance_amount_tl.delete;
Line: 1052

                 l_gl_project_flag_tl.delete;
Line: 1053

                 l_schedule_line_id_tl.delete;
Line: 1054

                 l_org_schedule_id_tl.delete;
Line: 1055

                 l_default_org_account_id_tl.delete;
Line: 1056

                 l_suspense_org_account_id_tl.delete;
Line: 1057

                 l_element_account_id_tl.delete;
Line: 1058

                 l_project_id_tl.delete;
Line: 1059

                 l_task_id_tl.delete;
Line: 1060

                 l_award_id_tl.delete;
Line: 1061

                 l_expenditure_type_tl.delete;
Line: 1062

                 l_exp_organization_id_tl.delete;
Line: 1063

                 l_gl_code_combination_id_tl.delete;
Line: 1064

                 l_assignment_id_tl.delete;
Line: 1065

                 l_attribute1_tl.delete;
Line: 1066

                 l_attribute2_tl.delete;
Line: 1067

                 l_attribute3_tl.delete;
Line: 1068

                 l_attribute4_tl.delete;
Line: 1069

                 l_attribute5_tl.delete;
Line: 1070

                 l_attribute6_tl.delete;
Line: 1071

                 l_attribute7_tl.delete;
Line: 1072

                 l_attribute8_tl.delete;
Line: 1073

                 l_attribute9_tl.delete;
Line: 1074

                 l_attribute10_tl.delete;
Line: 1077

				DELETE  FROM psp_enc_controls pec
				WHERE   pec.action_type 	IN 	('U','Q')
				AND 	pec.action_code 	=	'IC'
				AND 	pec.payroll_id 		= 	p_payroll_id
				AND 	 NOT EXISTS (	SELECT 	1
							FROM  	psp_enc_lines pel
							WHERE   pel.enc_control_id = pec.enc_control_id);
Line: 1090

	    		fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES','VERIFY_CHANGES');
Line: 1100

This procedure has been introduced for the Bug 2110930 -Quick Update Encumbrance Enhancement.
The procedure shall be invoked in Q (quick update) or U (update) mode to move the processed
assignments to history

Know limitations, enhancements or remarks

Change History

Who             When            What
ddubey         21-Dec-01       Created
ddubey	       07-Mar-02       Re Engineered the procedure for Enh. Encumbrance Re design
			       Pre process,Bug #2259310.

************************************************************************************************* /
  PROCEDURE  move_qkupd_rec_to_hist( p_payroll_id	 IN	NUMBER,
	   			     p_enc_line_type	 IN	VARCHAR2,
	   			     p_business_group_id IN     NUMBER,
                                     p_set_of_books_id   IN     NUMBER,
				     p_return_status	OUT NOCOPY	VARCHAR2)
  IS
	/ *	Commented the following for big fix 2324917
		Cursor to dislay no of assignments processed by update
  	CURSOR	get_no_asg_to_move IS
	SELECT	COUNT(DISTINCT peca.assignment_id)
	FROM	psp_enc_changed_assignments peca
	WHERE	peca.request_id = g_request_id;
Line: 1133

		/ * Moving records to psp_enc_changed_asg_history table .Also inserting concurrent request_id
		   into history for debugging purpose * /
		INSERT INTO     psp_enc_changed_asg_history
					(request_id, assignment_id, payroll_id, change_type,processing_module, created_by
					,creation_date, processed_flag, reference_id, action_type)
				SELECT	g_request_id, peca.assignment_id, peca.payroll_id, peca.change_type,
					p_enc_line_type, l_global_user_id, SYSDATE, NULL, NVL(peca.reference_id, 0),
					NVL(peca.action_type, p_enc_line_type)
				FROM	psp_enc_changed_assignments peca
			--	WHERE	peca.request_id = g_request_id; commented as a part of bug 2330057
Line: 1151

		DELETE		psp_enc_changed_assignments peca
	--	WHERE		peca.request_id	=g_request_id; commented as a part of bug 2330057
Line: 1166

			/ * Displaying no of records moved to history in quick update mode * /
			fnd_message.set_name('PSP','PSP_ENC_NUM_ASG');
Line: 1179

     		 fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES','MOVE_QKUPD_REC_TO_HIST');
Line: 1185

The following procedure is added for Enh. Resstart Update Encumbrance process
Created By	: ddubey

Date Created By : 16-Jan-01

Change History

Who             When            What
ddubey         16-jan-2001      Created

**************************************************************** /
procedure cleanup_on_success	( p_enc_line_type in varchar2,
                                  p_payroll_id    in number,
                                  p_business_group_id in number,
                                  p_set_of_books_id in number,
                                  p_invalid_suspense in Varchar2,
                                  p_return_status out NOCOPY varchar2) is

/ ***************************************************************************
For Bug 2359599 : Controls are deleted in the Verify changes procedure
       CURSOR	pending_enc_lines_cur Is
       SELECT	count(*)
       FROM	psp_enc_lines
       WHERE	payroll_id = p_payroll_id
       AND	rownum = 1;
Line: 1217

	        -- Restart Update Enc related change.
/ ***************************************************************************
For Bug 2359599 : Controls are deleted in the Verify changes procedure
                OPEN	pending_enc_lines_cur;
Line: 1226

                   DELETE FROM psp_Enc_controls
                   WHERE action_type = p_enc_line_type
                   AND	 payroll_id  = p_payroll_id
                   AND	 action_code='IC';
Line: 1234

	  --Modified the Update statement to include the assignment_id check for Bug 2345813
                    UPDATE  psp_enc_lines_history pelh
                    SET     pelh.change_flag='L'
                    WHERE   pelh.change_flag='N'
                    AND     pelh.payroll_id = p_payroll_id
		--  AND	   EXISTS            (SELECT   1  Commented for Bug 3821553
                    and    pelh.assignment_id in (SELECT peca.assignment_id -- Introduced for bug 3821553
                      	  	              FROM    psp_enc_changed_assignments peca
                       		              WHERE   peca.payroll_id = p_payroll_id
--                       		              AND     pelh.assignment_id = peca.assignment_id Commented for Bug 3821553
                       		              AND     peca.request_id IS NOT NULL
          				      AND     ((p_enc_line_type = 'Q'
                                                	AND     peca.change_type IN ('LS', 'ET', 'AS', 'QU'))
                                        		OR      p_enc_line_type = 'U'));
Line: 1250

	            UPDATE	psp_enc_lines_history
		    SET  	change_flag = 'N'
   		    WHERE	change_flag = 'U'
		    AND		payroll_id = p_payroll_id;
Line: 1266

          	/ * New code added for restart update process * /
          	 UPDATE psp_enc_controls
          	 SET    action_code = 'N'
          	 WHERE  action_code = 'IC'
          	 AND    payroll_id = p_payroll_id
          	 AND    set_of_books_id = p_set_of_books_id
          	 AND    business_group_id = p_business_group_id;
Line: 1278

                 fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES',g_error_api_path);
Line: 1298

    SELECT LINE.enc_control_id,
           count(decode(LINE.dr_cr_flag, 'D', 'x',null))  number_of_dr,
           count(decode(LINE.dr_cr_flag, 'C', 'x', null)) number_of_cr,
           sum(decode(LINE.dr_cr_flag,'D',LINE.encumbrance_amount,0)) total_dr_amount ,
           sum(decode(LINE.dr_cr_flag,'C',LINE.encumbrance_amount,0)) total_cr_amount,
           sum(decode(LINE.dr_cr_flag,'D',decode(LINE.gl_project_flag,'G',LINE.encumbrance_amount,0),0)) gl_dr_amount,
           sum(decode(LINE.dr_cr_flag,'C',decode(LINE.gl_project_flag,'G',LINE.encumbrance_amount,0),0)) gl_cr_amount,
           sum(decode(LINE.dr_cr_flag,'D',decode(LINE.gl_project_flag,'P',LINE.encumbrance_amount,0),0)) ogm_dr_amount,
           sum(decode(LINE.dr_cr_flag,'C',decode(LINE.gl_project_flag,'P',LINE.encumbrance_amount,0),0)) ogm_cr_amount
      FROM  psp_enc_lines LINE
      WHERE LINE.assignment_id in (SELECT assignment_id FROM psp_enc_changed_assignments peca
                                   WHERE peca.payroll_id=p_payroll_id
                                     AND peca.request_id IS NOT NULL
                                     AND (p_action_type = 'U' or  peca.change_type IN ('LS', 'ET', 'AS', 'QU')))
       AND LINE.enc_control_id in (SELECT CTRL2.enc_control_id FROM psp_enc_controls CTRL2
                                    WHERE CTRL2.action_code = 'IC' and CTRL2.payroll_id = p_payroll_id)
      GROUP BY LINE.enc_control_id;
Line: 1319

  UPDATE psp_enc_lines_history pelh
     SET pelh.change_flag='L'
   WHERE pelh.change_flag='N'
     AND pelh.payroll_id = p_payroll_id
     AND pelh.enc_summary_line_id in
            (select superceded_line_id
               from psp_enc_summary_lines
              where status_code = 'L'
                and ((gms_batch_name is not null  and p_gms_batch_name is not null and gms_batch_name = p_gms_batch_name)
                 or (group_id is not null and p_accepted_group_id is not null and group_id = p_accepted_group_id))
                 and enc_control_id in
                      (select enc_control_id
                         from psp_enc_controls
                        where run_id = p_run_id
                          and action_code in ('P','L')));
Line: 1336

    UPDATE psp_enc_lines_history
       SET change_flag = 'N'
     WHERE change_flag = 'U'
       AND payroll_id = p_payroll_id;
Line: 1341

  INSERT INTO psp_enc_changed_asg_history
       (request_id, assignment_id, payroll_id, change_type,processing_module, created_by
       ,creation_date, processed_flag, reference_id, action_type)
    SELECT  g_request_id, peca.assignment_id, peca.payroll_id, peca.change_type,
        p_action_type, l_global_user_id, SYSDATE, NULL, NVL(peca.reference_id, 0),
         NVL(peca.action_type, p_action_type)
     FROM psp_enc_changed_assignments peca
     WHERE payroll_id =p_payroll_id
       AND peca.request_id IS NOT NULL
       AND  ((p_action_type = 'Q' AND  peca.change_type IN ('LS', 'ET', 'AS', 'QU'))
             OR  p_action_type = 'U')
       AND peca.assignment_id NOT IN
           (  select distinct assignment_id
              from psp_enc_summary_lines
              where status_code = 'R'
              and ((gms_batch_name is not null  and p_gms_batch_name is not null and gms_batch_name = p_gms_batch_name)
              or (group_id is not null  and p_rejected_group_id is not null and group_id = p_rejected_group_id))
                 and enc_control_id in
                    (select enc_control_id
                     from psp_enc_controls
                      where run_id = p_run_id
                        and action_code in ('P','L')));
Line: 1364

    DELETE psp_enc_changed_assignments peca
     WHERE peca.payroll_id=p_payroll_id
       AND peca.request_id IS NOT NULL
       AND  ((p_action_type = 'Q' AND  peca.change_type IN ('LS', 'ET', 'AS', 'QU'))
        OR  p_action_type = 'U')
       AND peca.assignment_id NOT IN
            (select distinct assignment_id
               from psp_enc_summary_lines
              where status_code = 'R'
                and ((gms_batch_name is not null and p_gms_batch_name is not null and gms_batch_name = p_gms_batch_name)
                    or (group_id is not null and  p_rejected_group_id is not null and p_rejected_group_id = group_id))
                and enc_control_id in
                    (select enc_control_id
                     from psp_enc_controls
                      where run_id = p_run_id
                       and action_code in ('P','L')))  ;
Line: 1389

     update psp_enc_controls
        set number_of_dr= number_of_dr - control_rec.number_of_dr,
            number_of_cr = number_of_cr - control_rec.number_of_cr,
            total_dr_amount= total_dr_amount - control_rec.total_dr_amount,
            total_cr_amount= total_cr_amount - control_rec.total_cr_amount,
            gl_dr_amount = gl_dr_amount -control_rec.gl_dr_amount,
            gl_cr_amount = gl_cr_amount -control_rec.gl_cr_amount,
            ogm_dr_amount= ogm_dr_amount - control_rec.ogm_dr_amount,
            ogm_cr_amount= ogm_cr_amount - control_rec.ogm_cr_amount
       where enc_control_id  = control_rec.enc_control_id;
Line: 1401

    DELETE psp_enc_lines LINE
    WHERE  LINE.assignment_id in (SELECT assignment_id FROM psp_enc_changed_assignments peca
                                   WHERE peca.payroll_id=p_payroll_id
                                     AND peca.request_id IS NOT NULL
                                     AND (p_action_type = 'U' or peca.change_type IN ('LS', 'ET', 'AS', 'QU')))
       AND LINE.enc_control_id in (SELECT CTRL2.enc_control_id
                                      FROM psp_enc_controls CTRL2
                                     WHERE  CTRL2.action_code = 'IC' and CTRL2.payroll_id = p_payroll_id);
Line: 1411

    DELETE psp_enc_controls CTRL
     WHERE CTRL.action_code = 'IC'
       AND CTRL.payroll_id = p_payroll_id
       AND NOT EXISTS ( SELECT 1
                        FROM psp_enc_lines LINE
                        WHERE LINE.enc_control_id = CTRL.enc_control_id);
Line: 1419

                 UPDATE psp_enc_controls
                 SET    action_code = 'N'
                 WHERE  action_code = 'IC'
                 AND    payroll_id = p_payroll_id
                 AND    set_of_books_id = p_set_of_books_id
                 AND    business_group_id = p_business_group_id;
Line: 1431

      fnd_msg_pub.add_exc_msg('PSP_ENC_UPDATE_LINES','ROLLBACK_REJECTED_ASG');
Line: 1434

	End of comment of for Creatwe and Update multi-thread	*****/
END psp_enc_update_lines;