参考:http://blog.csdn.net/rfb0204421/article/details/8204097
DECLARE
l_ccid NUMBER;
l_msg VARCHAR2(1000);
l_chart_of_account_id NUMBER;
l_set_of_book_id NUMBER;
BEGIN
--l_set_of_book_id := fnd_profile.value('GL_SET_OF_BKS_ID');
SELECT gsob.chart_of_accounts_id,gsob.set_of_books_id
INTO l_chart_of_account_id,l_set_of_book_id
FROM gl_sets_of_books gsob
WHERE gsob.set_of_books_id = 7002;
dbms_output.put_line('l_set_of_book_id: '||l_set_of_book_id||
', l_chart_of_account_id: '||l_chart_of_account_id);
-- get the code combination id according to the concatenated segments
-- 已存在的组合,返回CCID,不存在的组合,自动创建并返回CCID
l_ccid := fnd_flex_ext.get_ccid(application_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => l_chart_of_account_id,
validation_date => SYSDATE,
concatenated_segments => '87.0000.4611.410.000000.000000.100001');
IF l_ccid = 0 THEN
-- get the error message
l_msg := fnd_message.get;
-- output the error message
dbms_output.put_line(l_msg);
ELSE
-- output the code combination id
dbms_output.put_line(l_ccid);
END IF;
END;