PO Accrual CCID
/* Formatted on DD/MM/RRRR 15:31(Formatter Plus v4.8.8) */FUNCTION xx_po_accrual_ccid (
p_coa_cid IN NUMBER,
p_expense_ccid IN NUMBER,
p_org_id IN NUMBER
)
RETURN NUMBER
/*-------------------------------------------------------------------------*/
--| Function Name : xx_po_accrual_ccid |--
--| Description : Extraction of Accrual Code combination info |--
--| |--
/*-------------------------------------------------------------------------*/
IS
x_delim VARCHAR2 (10) DEFAULT NULL;
x_co_seg_num NUMBER;
x_cc_seg_num NUMBER;
x_acc_seg_num NUMBER;
x_acc1_seg_num NUMBER;
x_acc2_seg_num NUMBER;
x_acc3_seg_num NUMBER;
x_acc4_seg_num NUMBER;
nsegments NUMBER;
x_def_acc_ccid NUMBER DEFAULT NULL;
x_def_segments_array fnd_flex_ext.segmentarray;
x_exp_segments_array fnd_flex_ext.segmentarray;
x_acc_segments_array fnd_flex_ext.segmentarray;
x_concatenated_segments fnd_shorthand_flex_aliases.concatenated_segments%TYPE
DEFAULT NULL;
x_error VARCHAR2 (2000) DEFAULT NULL;
x_segments_array fnd_flex_ext.segmentarray;
x_accrual_ccid NUMBER;
l_sqlcode VARCHAR2 (30) := SQLCODE;
l_sqlerrm VARCHAR2 (400) := SUBSTR (SQLERRM, 1, 399);
BEGIN
/* Get GL Accounting Flexfield delimiter */
x_delim := fnd_flex_ext.get_delimiter ('SQLGL', 'GL#', p_coa_cid);
/* Get Balancing Segment Number */
IF NOT (fnd_flex_apis.get_qualifier_segnum
(appl_id => 101,
key_flex_code => 'GL#',
structure_number => p_coa_cid,
flex_qual_name => 'GL_BALANCING',
segment_number => x_co_seg_num
)
)
THEN
x_co_seg_num := NULL;
END IF;
/* Get Cost Center Segment Number */
IF NOT (fnd_flex_apis.get_qualifier_segnum
(appl_id => 101,
key_flex_code => 'GL#',
structure_number => p_coa_cid,
flex_qual_name => 'FA_COST_CTR',
segment_number => x_cc_seg_num
)
)
THEN
x_cc_seg_num := NULL;
END IF;
/* Get Natural Account Segment Number */
IF NOT (fnd_flex_apis.get_qualifier_segnum (appl_id => 101,
key_flex_code => 'GL#',
structure_number => p_coa_cid,
flex_qual_name => 'GL_ACCOUNT',
segment_number => x_acc_seg_num
)
)
THEN
x_acc_seg_num := NULL;
END IF;
/* Get Sub Account 1 Segment Number */
SELECT segment_num
INTO x_acc1_seg_num
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND id_flex_num = p_coa_cid
AND enabled_flag = 'Y'
AND segment_name = 'Sub Account1';
/* Get Sub Account 2 Segment Number */
SELECT segment_num
INTO x_acc2_seg_num
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND id_flex_num = p_coa_cid
AND enabled_flag = 'Y'
AND segment_name = 'Sub Account2';
/* Get Voyage Segment Number */
SELECT segment_num
INTO x_acc3_seg_num
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND id_flex_num = p_coa_cid
AND enabled_flag = 'Y'
AND segment_name = 'Voyage';
/* Get Future Segment Number */
SELECT segment_num
INTO x_acc4_seg_num
FROM fnd_id_flex_segments
WHERE application_id = 101
AND id_flex_code = 'GL#'
AND id_flex_num = p_coa_cid
AND enabled_flag = 'Y'
AND segment_name = 'Future';
/* Get default accrual ccid */
SELECT accrued_code_combination_id
INTO x_def_acc_ccid
FROM po_system_parameters_all
WHERE org_id = p_org_id;
IF fnd_flex_ext.get_segments (application_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => p_coa_cid,
combination_id => x_def_acc_ccid,
n_segments => nsegments,
segments => x_def_segments_array
)
THEN
NULL;
END IF;
/* break up expense account into segments */
IF fnd_flex_ext.get_segments (application_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => p_coa_cid,
combination_id => p_expense_ccid,
n_segments => nsegments,
segments => x_exp_segments_array
)
THEN
NULL;
END IF;
IF xx_po_get_alias_mapping (p_coa_cid,
'ACC',
x_exp_segments_array (x_acc_seg_num),
x_concatenated_segments,
x_error
)
THEN
nsegments :=
fnd_flex_ext.breakup_segments (x_concatenated_segments,
x_delim,
x_acc_segments_array
);
x_segments_array (x_acc_seg_num) := x_acc_segments_array (x_acc_seg_num);
ELSE
x_segments_array (x_acc_seg_num) :=
x_def_segments_array (x_acc_seg_num);
END IF;
x_segments_array (x_co_seg_num) := x_exp_segments_array (x_co_seg_num);
x_segments_array (x_cc_seg_num) := x_exp_segments_array (x_cc_seg_num);
x_segments_array (x_acc1_seg_num) := x_def_segments_array (x_acc1_seg_num);
x_segments_array (x_acc2_seg_num) := x_def_segments_array (x_acc2_seg_num);
x_segments_array (x_acc3_seg_num) := x_def_segments_array (x_acc3_seg_num);
x_segments_array (x_acc4_seg_num) := x_def_segments_array (x_acc4_seg_num);
IF NOT (fnd_flex_ext.get_combination_id (application_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => p_coa_cid,
validation_date => SYSDATE,
n_segments => nsegments,
segments => x_segments_array,
combination_id => x_accrual_ccid
)
)
THEN
x_accrual_ccid := -1;
END IF;
RETURN x_accrual_ccid;
EXCEPTION
WHEN OTHERS
THEN
--p_errordesc := 'Provide any one value properly' || SQLERRM;
--RETURN p_errordesc;
-- NULL;
l_sqlcode := SQLCODE;
l_sqlerrm := SUBSTR (SQLERRM, 1, 399);
/*-------------------------------------------------------------------------*/
--| Procedure Name : xxsri_error_handling_proc |--
--| Description : Calling Error Handling Common Procedure |--
--| |--
/*-------------------------------------------------------------------------*/
xxsri_error_handling_proc
(p_record_id => l_sqlcode,
p_proc_name => 'xxsri_po_generic_inter_pkg',
p_table_name => 'xx_po_accrual_ccid',
p_column_name => '',
p_error_identifier => l_sqlcode,
p_error_description => l_sqlerrm,
p_error_creation_date => SYSDATE,
p_request_id => '',
p_comments => 'Data Not Insert into Custom Table',
p_source_system => p_coa_cid,
p_oracle_po_number => p_expense_ccid
);
COMMIT;
END xx_po_accrual_ccid;
0 comments:
Post a Comment