1] FND_FLEX_EXT.GET_COMBINATION_ID:

This API Finds combination_id for given set of key flexfield segment values. Segment values must be input in segments(1) – segments(n_segments) in the order displayed.

It also creates a new combination if it is valid and the flexfield allows dynamic inserts and the combination does not already exist. It commit the transaction soon after calling this function since if a combination is created it will prevent other users creating similar combinations on any flexfield until a commit is issued.

It performs all checks on values including security and cross-validation. Value security rules will be checked for the current user identified in the FND_GLOBAL package.

Generally pass in SYSDATE for validation date. If validation date is null, this function considers expired values valid and checks all cross-validation rules even if they are outdated.

This function returns TRUE if combination valid or FALSE and sets error message using FND_MESSAGE utility on error or if invalid. If this function returns FALSE, use GET_MESSAGE to get the text of the error message in the language of the database, or GET_ENCODED_MESSAGE to get the error message in a language-independent encoded format.

The Combination_id output may be NULL if combination is invalid.

 SET serveroutput ON;
DECLARE
l_application_short_name VARCHAR2();
l_key_flex_code VARCHAR2();
l_structure_num NUMBER;
l_validation_date DATE;
n_segments NUMBER;
SEGMENTS APPS.FND_FLEX_EXT.SEGMENTARRAY;
l_combination_id NUMBER;
l_data_set NUMBER;
l_return BOOLEAN;
l_message VARCHAR2();
BEGIN
l_application_short_name := 'SQLGL';
l_key_flex_code := 'GL#';
SELECT id_flex_num
INTO l_structure_num
FROM apps.fnd_id_flex_structures
WHERE ID_FLEX_CODE = 'GL#'
AND ID_FLEX_STRUCTURE_CODE=<ACCOUNTING_FLEXFIELD>;
l_validation_date := SYSDATE;
n_segments := ;
segments() := '';
segments() := '';
segments() := '';
segments() := '';
segments() := '';
segments() := '';
l_data_set := NULL;
l_return := FND_FLEX_EXT.GET_COMBINATION_ID(
31 application_short_name => l_application_short_name,
32 key_flex_code => l_key_flex_code,
33 structure_number => l_structure_num,
34 validation_date => l_validation_date,
35 n_segments => n_segments,
36 segments => segments,
37 combination_id => l_combination_id,
38 data_set =>
l_data_set);
l_message:= FND_FLEX_EXT.GET_MESSAGE;
IF l_return THEN
DBMS_OUTPUT.PUT_LINE('l_Return = TRUE');
DBMS_OUTPUT.PUT_LINE('COMBINATION_ID = ' || l_combination_id);
ELSE DBMS_OUTPUT.PUT_LINE('Error: '||l_message);
END IF;

2] FND_FLEX_EXT.get_ccid:

This API gets combination id for the specified key flexfield segments.It is identical to get_combination_id() except this function takes segment values in a string concatenated by the segment  delimiter for this flexfield, and returns a positive combination id if valid or 0 on error.。

 Declare
v_ChartOfAccoutsId Number := ; --GL帐户键弹性域结构ID
v_AccountName Varchar2() := '11.110822.4105160101.00.000000000000.000000.000000' --GL帐户
v_CodeCombinationId Number; --GL帐户ID
Begin
v_CodeCombinationId := Fnd_Flex_ext.get_ccid(application_short_name => 'SQLGL', --用应产品简称
7 key_flex_code => 'GL#', --键弹性域代码
8 structure_number => v_ChartOfAccoutsId, --键弹性域结构编号
9 validation_date => to_char(SYSDATE,'YYYY/MM/DD HH24:MI:SS'), --帐户有效日期
10 concatenated_segments => v_AccountName); --
If (Nvl(v_CodeCombinationId, ) = ) Then
Dbms_Output.put_line('GL帐户组合失败');
Else
Dbms_Output.put_line('获得GL帐户ID:' || v_CodeCombinationId);
End If;
End;

3] FND_FLEX_KEYVAL.VALIDATE_SEGS:

These key flexfields server validations API are a low level interface to key flexfields validation.  They are designed to allow access to all the flexfields functionality, and to allow the user to get only the information they need in return.  Because of their generality, these functions are more difficult to use than those in the FND_FLEX_EXT package.  Oracle strongly suggests using the functions in FND_FLEX_EXT package if at all possible.

This function finds combination from given segment values.  Segments are passed in as a concatenated string in increasing order of segment_number (display order).

Various Operations that can be performed are:

  • ‘FIND_COMBINATION’ – Combination must already exist.所给定的组合字段必须在系统中已经被定义
  • ‘CREATE_COMBINATION’ – Combination is created if doesn’t exist.如果组合字段不存在,则在系统中创建该组合
  • ‘CREATE_COMB_NO_AT’ – same as create_combination but does not use an autonomous transaction.功能和CREATE_COMBINATION相同,只是不像前者要使用相对独立的子事务autonomous transaction
  • ‘CHECK_COMBINATION’ – Checks if combination valid, doesn’t create.只是检查一下给定的组合字段是否合法,不管检查结果如何,都不创建新的组合
  • ‘DEFAULT_COMBINATION’ – Returns minimal default combination.返回默认的最小组合
  • ‘CHECK_SEGMENTS’ – Validates segments individually.分别验证字段

If validation date is NULL checks all cross-validation rules. It returns TRUE if combination valid or FALSE and sets error message on server if invalid. Use the default values if you do not want any special functionality.

 SET serveroutput ON;
DECLARE
l_segment1 GL_CODE_COMBINATIONS.SEGMENT1%TYPE;
l_segment2 GL_CODE_COMBINATIONS.SEGMENT2%TYPE;
l_segment3 GL_CODE_COMBINATIONS.SEGMENT3%TYPE;
l_segment4 GL_CODE_COMBINATIONS.SEGMENT4%TYPE;
l_segment5 GL_CODE_COMBINATIONS.SEGMENT5%TYPE;
l_segment6 GL_CODE_COMBINATIONS.SEGMENT6%TYPE;
l_valid_combination BOOLEAN;
l_cr_combination BOOLEAN;
l_ccid GL_CODE_COMBINATIONS_KFV.code_combination_id%TYPE;
l_structure_num FND_ID_FLEX_STRUCTURES.ID_FLEX_NUM%TYPE;
l_conc_segs GL_CODE_COMBINATIONS_KFV.CONCATENATED_SEGMENTS%TYPE;
p_error_msg1 VARCHAR2();
p_error_msg2 VARCHAR2();
BEGIN
l_segment1 := '';
l_segment2 := '';
l_segment3 := '';
l_segment4 := '';
l_segment5 := '';
l_segment6 := '';
l_conc_segs := l_segment1 || '.' || l_segment2 || '.' || l_segment3 || '.' ||
l_segment4 || '.' || l_segment5 || '.' || l_segment6;
BEGIN
SELECT id_flex_num
INTO l_structure_num
FROM apps.fnd_id_flex_structures
WHERE id_flex_code = 'GL#'
AND id_flex_structure_code = 'EPC_GL_ACCOUNTING_FLEXFIELD';
EXCEPTION
WHEN OTHERS THEN
l_structure_num := NULL;
END;
---------------Check if CCID exits with the above Concatenated Segments---------------
BEGIN
SELECT code_combination_id
INTO l_ccid
FROM apps.gl_code_combinations_kfv
WHERE concatenated_segments = l_conc_segs;
EXCEPTION
WHEN OTHERS THEN
l_ccid := NULL;
END;
IF l_ccid IS NOT NULL THEN
------------------------The CCID is Available----------------------
DBMS_OUTPUT.PUT_LINE('COMBINATION_ID= ' || l_ccid);
ELSE
DBMS_OUTPUT.PUT_LINE('This is a New Combination. Validation Starts....');
------------Validate the New Combination--------------------------
l_valid_combination := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS(operation => 'CHECK_COMBINATION',
52 appl_short_name => 'SQLGL',
53 key_flex_code => 'GL#',
54 structure_number => L_STRUCTURE_NUM,
55 concat_segments => L_CONC_SEGS);
p_error_msg1 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
IF l_valid_combination then
DBMS_OUTPUT.PUT_LINE('Validation Successful! Creating the Combination...');
-------------------Create the New CCID--------------------------
L_CR_COMBINATION := APPS.FND_FLEX_KEYVAL.VALIDATE_SEGS(operation => 'CREATE_COMBINATION',
appl_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => L_STRUCTURE_NUM,
concat_segments => L_CONC_SEGS);
p_error_msg2 := FND_FLEX_KEYVAL.ERROR_MESSAGE;
IF l_cr_combination THEN
-------------------Fetch the New CCID--------------------------
SELECT code_combination_id
INTO l_ccid
FROM apps.gl_code_combinations_kfv
WHERE concatenated_segments = l_conc_segs;
DBMS_OUTPUT.PUT_LINE('NEW COMBINATION_ID = ' || l_ccid);
ELSE
-------------Error in creating a combination-----------------
DBMS_OUTPUT.PUT_LINE('Error in creating the combination: ' ||
p_error_msg2);
END IF;
ELSE
--------The segments in the account string are not defined in gl value set----------
DBMS_OUTPUT.PUT_LINE('Error in validating the combination: ' ||
p_error_msg1);
END IF;
END IF;
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE(SQLCODE || ' ' || SQLERRM);
END;
- appl_short_name 应用程序简称,例如总账模块对应的应用简称为SQLGL
- key_flex_code 键弹性域代码,可以在键弹性域定义界面找到,例如 GL#等等
- structure_number  指定键弹性域下的某个结构NUM,可以在键弹性域定义界面找到,对应字段为ID_FLEX_NUM
- concat_segments  要获取组合描述字段的对应的“值“组合字段,例如: 102-00-0000-50110000-000-000000
一旦初始化验证字段成功,那么描述组合字段便可以通过调用fnd_flex_keyval.concatenated_descriptions()来得到了。
 SQL> declare
pi_concat_segs varchar2() := '102-00-0000-50110000-000-000000';
po_desc varchar2();
BEGIN
IF fnd_flex_keyval.validate_segs(operation => 'FIND_COMBINATION',
appl_short_name => 'SQLGL',
key_flex_code => 'GL#',
structure_number => ,
concat_segments => pi_concat_segs ) THEN
po_desc := fnd_flex_keyval.concatenated_descriptions();
ELSE
po_desc := null;
END IF;
dbms_output.put_line(po_desc);
END;
/
xxxxx -Corp-Common-F/G Sales \- External \- Ge-External-Spare
PL/SQL procedure successfully completed

转:通过API获取和创建 Oracle GL Account Code Combination ID’s (CCID’s)的几种方法汇总的更多相关文章

  1. PHP获取POST数据的几种方法汇总

    一.PHP获取POST数据的几种方法 方法1.最常见的方法是:$_POST['fieldname']; 说明:只能接收Content-Type: application/x-www-form-urle ...

  2. Oracle SQL Developer中查看解释计划Explain Plan的两种方法

    方法一: 比如要查看解释计划的SQL是:select * from hy_emp 那么在输入窗口输入: EXPLAIN PLAN FOR select * from hy_emp 之后执行,输出窗口会 ...

  3. Oracle中,将毫秒数转换为timestamp类型的两种方法

    在许多场景中,开发人员习惯用1970-01-01 00:00:00.000以来的毫秒数来表示具体的时间,这样可以将数据以NUMBER类型存储到数据库中,在某些时候方便比较,同样,有些时候我们需要 把这 ...

  4. Oracle删除重复记录只保留一条数据的几种方法

    1. 问题描述 BBSCOMMENT表为BBSDETAIL的从表,记录商户评价信息.因为数据倒腾来倒腾去的,有很多重复数据.表结构如下: COMMENT_ID NOT NULL NUMBER --主键 ...

  5. Web APi之控制器创建过程及原理解析(八)

    前言 中秋歇了歇,途中也时不时去看看有关创建控制器的原理以及解析,时间拖得比较长,实在是有点心有余而力不足,但又想着既然诺下了要写完原理一系列,还需有始有终.废话少说,直入主题. HttpContro ...

  6. 劳动节脑洞大开!利用Debug API 获取 加壳客户端的MD5值

    系统 : Windows xp 程序 : 某游戏客户端 程序下载地址 :不提供 要求 : 远程注入 & 获取MD5值 使用工具 : vc++6.0 & OD 案例说明: 该游戏客户端对 ...

  7. 利用腾讯企业邮箱开放API获取账户未读邮件数初探

    公司一直使用腾讯提供的免费企业邮箱服务,今天用管理员帐户登录后发现,原来现在腾讯的企业邮箱也开放了部分API 你可以通过开放接口实现以下功能: 数据同步 数据同步可以帮助你同步部门成员信息,你还可以创 ...

  8. C# 通过豆瓣网络编程API获取图书信息

    这篇文章主要是关于如何通过豆瓣API获取信息的书籍,起初,我看到了原来的想法的内容是"C# 网络编程之网页简单下载实现"中通过HttpWebResponse类下载源代码,再通过正則 ...

  9. 调用ZoomEye API获取信息

    最近在提高自己编程能力,拿一些实用的小工具练下.该脚本为python语言,主要涉及模块urllib,json,os模块. 功能:调用ZoomEye API获取信息 import urllib.requ ...

随机推荐

  1. 用U盘安装系统

    下述的前提就是:如果你想要装win7,win8系统的话,你需要准备一个大于等于4G的U盘,但是如果你想装XP,Ubuntu等小系统就可以只要1G的U盘就行了,温馨提示,记得将U盘里的重要东西移走,因为 ...

  2. bzoj1930

    一开始我觉得这不是一个弱弱的费用流吗? 每个豆豆拆点,入点出点随便连连 由于肯定是DAG图,边权为正的最大费用肯定能增广出来 于是我们只要跑总流量为2的最大费用最大流不就行了吗 但是 这样会TLE,因 ...

  3. DD_belatedPNG,IE6下PNG透明解决方案

    我们知道IE6是不支持透明的PNG的,这无疑限制了网页设计的发挥空间. 然而整个互联网上解决这个IE6的透明PNG的方案也是多不胜数,从使用IE特有的滤镜或是e­xpression,再到javascr ...

  4. iOS上百度输入法引起的问题

     /*      UIKeyboardWillShowNotification 通知下的数据            百度     {         UIKeyboardAnimationCurveU ...

  5. POJ 2240 Arbitrage spfa 判正环

    d[i]代表从起点出发可以获得最多的钱数,松弛是d[v]=r*d[u],求最长路,看有没有正环 然后这题输入有毒,千万别用cin 因为是大输入,组数比较多,然后找字符串用strcmp就好,千万不要用m ...

  6. LoadRunner 你不知道的事之——内存使用

    LoadRunner的使用相信大家很熟悉,但是可能很少有人去关注一个Vuser 在以线程模式和进程模式下的内存开销情况,下面通过个人的试验得出一组数据供大家参考,只有你真正了解了,才能做的更深入. 测 ...

  7. mongodb c++ driver(2.53)windows编译

    编译环境: (1) 下载python2.7, 使用x86_32位,因为scons只有32位安装包可用: (2) 下载scons2.3.0,The current production release ...

  8. Java笔记(三)……基础语法

    关键字 标识符 在程序中自定义的一些名称 由26个英文字母大小写,数字:0-9,符号:_ $组成 定义合法标识符规则: 数字不可以开头. 不可以使用关键字. Java中严格区分大小写. 注意:在起名字 ...

  9. oracle 日志学习(转载)

    一,重做日志概念 重做日志文件(redo log file)对于Oracle数据库至关重要.它们是数据库的事务日志.通常只用于恢复,不过也可以用于以下工作: q 系统崩溃后的实例恢复 q 通过备份恢复 ...

  10. 六种简单方法提升ASP.NET Web API性能

    ASP.NET Web API 是非常棒的技术.编写 Web API 十分容易,以致于很多开发者没有在应用程序结构设计上花时间来获得很好的执行性能. 在本文中,我将介绍8项提高 ASP.NET Web ...