创建或者查找GL账户(code_combination_id)

需求:

创建或者查找现在账户ID ,需要通过一下三个步骤:


1. 得到账簿的CHART_OF_ACCOUNTS_ID

2. 得到账户弹性域分隔符

3. 调用标准的API得到账户组合id


具体实现如下:

1. 得到账簿的CHART_OF_ACCOUNTS_ID实现code:

SELECT sob.chart_of_accounts_id
  INTO l_chart_of_accounts_id
  FROM financials_system_params_all fsp, gl_sets_of_books sob
 WHERE org_id = p_org_id
   AND sob.set_of_books_id = fsp.set_of_books_id;

2. 得到账户弹性域分隔符实现code:

    SELECT concatenated_segment_delimiter
      INTO l_segment_delimiter
      FROM fnd_id_flex_structures
     WHERE application_id = 101
       AND id_flex_code = 'GL#'
       AND id_flex_num = l_chart_of_accounts_id;
 

3. 调用标准的API得到账户组合id(不存在则创建并返回ID):

DECLARE
  x_account_id NUMBER;
BEGIN
  IF fnd_flex_keyval.validate_segs(operation        => 'CREATE_COMBINATION',
                                   appl_short_name  => 'SQLGL',
                                   key_flex_code    => 'GL#',
                                   structure_number => l_chart_of_accounts_id,
                                   concat_segments  => l_temp_segment1 ||
                                                       l_segment_delimiter ||
                                                       lv_segment2 ||
                                                       l_segment_delimiter ||
                                                       lv_segment3 ||
                                                       l_segment_delimiter ||
                                                       lv_segment4 ||
                                                       l_segment_delimiter ||
                                                       lv_segment5 ||
                                                       l_segment_delimiter ||
                                                       lv_segment6 ||
                                                       l_segment_delimiter ||
                                                       lv_segment7 ||
                                                       l_segment_delimiter ||
                                                       lv_segment8,
                                   validation_date  => NULL) THEN
    -- Success                                   
    x_account_id := fnd_flex_keyval.combination_id;
  ELSE
    x_account_id := NULL;
  END IF;
  dbms_output.put_line(x_account_id);
END;






你可能感兴趣的:(创建或者查找GL账户(code_combination_id))