I have used below script to create CCID (Code Combination ID) in
General Ledger.
Procedure:
CREATE OR
REPLACE PROCEDURE APPS.CREATE_CCID_PRC(
p_seg1 VARCHAR2,
p_seg2 VARCHAR2,
p_seg3 VARCHAR2,
p_seg4 VARCHAR2,
p_seg5 VARCHAR2,
p_seg6
VARCHAR2,
p_seg7 VARCHAR2,
p_ccid_out OUT NUMBER,
p_err_out OUT VARCHAR2 )
IS
l_code_combination_id NUMBER;
l_boolean BOOLEAN;
l_segment_array apps.fnd_flex_ext.segmentarray;
x_ccid VARCHAR2(100);
ln_org_id NUMBER;
l_error VARCHAR2(4000):=NULL;
l_exception EXCEPTION;
ln_structure_num NUMBER;
BEGIN
ln_org_id := 0;
ln_structure_num := 0;
-- Get
Org ID
BEGIN
SELECT organization_id
INTO ln_org_id
FROM hr_operating_units
WHERE name = 'ABC Operating Unit'
AND (date_to IS NULL OR date_to > SYSDATE);
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line('Error in Operating Unit:'||SQLERRM);
END;
--
-- Get
ID Flex Number
BEGIN
SELECT id_flex_num
INTO ln_structure_num
FROM apps.fnd_id_flex_structures
WHERE id_flex_code = 'GL#'
AND id_flex_structure_code='CUMMINS_ACCOUNTING_FLEXFIELD'
AND enabled_flag = 'Y'
GROUP BY id_flex_num;
EXCEPTION
WHEN others THEN
fnd_file.put_line('Error in
Flex number:'||SQLERRM);
END;
--
apps.fnd_global.apps_initialize(user_id =>
fnd_profile.VALUE('USER_ID'),
resp_id => fnd_profile.VALUE('RESP_ID'),
resp_appl_id =>
fnd_profile.VALUE('RESP_APPL_ID') );
mo_global.set_policy_context('S',ln_org_id);
--
l_segment_array(1) := p_seg1;
l_segment_array(2) := p_seg2;
l_segment_array(3) := p_seg3;
l_segment_array(4) := p_seg4;
l_segment_array(5) := p_seg5;
l_segment_array(6) := p_seg6;
l_segment_array(7) := p_seg7;
--
l_boolean := apps.fnd_flex_ext.get_combination_id
( application_short_name => 'SQLGL'
( application_short_name => 'SQLGL'
, key_flex_code => 'GL#'
,
structure_number => ln_structure_num
,
validation_date => SYSDATE
, n_segments => 7
,
segments => l_segment_array
, combination_id => l_code_combination_id
);
x_ccid := l_code_combination_id;
fnd_file.put_line(fnd_file.LOG,'l_code_combination_id:
'||l_code_combination_id||fnd_flex_ext.get_message);
p_err_out := fnd_flex_ext.get_message;
p_ccid_out:= (l_code_combination_id);
EXCEPTION
WHEN
OTHERS THEN
l_error:= ('Error:-'||sqlerrm);
fnd_file.put_line(fnd_file.LOG,l_error);
END;
/
--------------------------------------------
Once procedure
created then text it using below PLSQL block:
SET
SERVEROUTPUT ON;
DECLARE
l_err
VARCHAR2(4000);
l_ccid
NUMBER;
BEGIN
apps.create_ccid_prc(
p_seg1 => '453',
p_seg2 => '453',
p_seg3 => '4530000',
p_seg4 => '00905003',
p_seg5 => '000',
p_seg6 => '00000',
p_seg7 => '0000',
p_ccid_out => l_ccid,
p_err_out => l_err
);
--
dbms_output.put_line(l_ccid);
dbms_output.put_line(l_err);
EXCEPTION WHEN
OTHERS THEN
dbms_output.put_line('Error is: '||sqlerrm);
END;
/
No comments:
Post a Comment