根据ccid取得账户,更改某段值再创建账户,返回新的ccid

CREATE OR REPLACE PACKAGE cux_cuxaprebate_utl IS

 
  * ===============================================
  *   PROGRAM NAME:
  *          cux_price_utl_pkg
  *   DESCRIPTION:
  *          CUX:应付发票平台返利开发FORM 工具包
  *   HISTORY:
  *        1.00 2013-12-01 cxy
  * ==============================================*/
  /* =============================================
  *   FUNCTION / PROCEDURE
  *       create_account
  *   DESCRIPTION:
  *       根据ccid取得账户,更改某段值再创建账户,返回新的ccid
  *   ARGUMENT:
          p_sql_stmt :动态SQL语句
  *   RETURN:
  *        N/A
  *   HISTORY:
  *        1.00 2013-12-01 cxy
  * =============================================*/
  PROCEDURE create_account(p_org_id IN NUMBER,
                           p_ccid   IN NUMBER,
                           x_ccid   OUT NUMBER);

END cux_cuxaprebate_utl;
/
CREATE OR REPLACE PACKAGE BODY cux_cuxaprebate_utl IS
  -- Constant Variable
  g_pkg_name        CONSTANT VARCHAR2(30) := 'cux_CUXAPREBATE_utl';
  g_conc_request_id CONSTANT NUMBER := fnd_global.conc_request_id;
  g_login_id     NUMBER := fnd_global.conc_login_id;
  g_user_id      NUMBER := fnd_global.user_id;
  g_prog_appl_id NUMBER := fnd_global.prog_appl_id;
  g_prog_id      NUMBER := fnd_global.conc_program_id;
  g_request_id      CONSTANT NUMBER := fnd_global.conc_request_id;
  g_conc_program_id CONSTANT NUMBER := fnd_global.conc_program_id;
  -- Global constant variable
  g_debug_flag VARCHAR2(1) := nvl(fnd_profile.value('AFLOG_ENABLED'), 'N');
  g_bg_id CONSTANT NUMBER := fnd_profile.value('PER_BUSINESS_GROUP_ID');
  TYPE account_type IS TABLE OF VARCHAR2(20) INDEX BY BINARY_INTEGER;
  v_account_type account_type;
 /* =============================================
  *   FUNCTION / PROCEDURE
  *       create_account
  *   DESCRIPTION:
  *       根据ccid取得账户,更改某段值再创建账户,返回新的ccid
  *   ARGUMENT:
          p_org_id :OU ID
	  p_ccid   :原ccid
 	  x_ccid   :生成新的ccid
  *   RETURN:
  *        N/A
  *   HISTORY:
  *        1.00 2013-12-01 cxy
  * =============================================*/
  PROCEDURE create_account(p_org_id IN NUMBER,
                           p_ccid   IN NUMBER,
                           x_ccid   OUT NUMBER) IS
    comma_location NUMBER := 0;
    v_location     VARCHAR2(100);
    v_count        NUMBER := 0;
    account        VARCHAR2(100) := '06.0.212101.0.0.0.0';
    account_adj    VARCHAR2(100);
    prev_location  NUMBER := 0;
    v_account      VARCHAR2(100);
    x_account      VARCHAR2(100);
  
    p_segment1 VARCHAR2(30);
    p_segment2 VARCHAR2(30);
    p_segment3 VARCHAR2(30);
    p_segment4 VARCHAR2(30);
    p_segment5 VARCHAR2(30);
    p_segment6 VARCHAR2(30);
    p_segment7 VARCHAR2(30);
    --x_ccid    NUMBER;
    v_segment3 VARCHAR2(30);
  BEGIN
    --在最后一个段后面加一个点
    account     := cux_flex_pkg.get_gl_flexfields(p_ccid   => p_ccid,
                                                  p_return => 'A');
    account_adj := account || '.';
    LOOP
      v_count        := v_count + 1;
      comma_location := instr(account_adj, '.', comma_location + 1);
      EXIT WHEN comma_location = 0;
      v_location := substr(account_adj,
                           prev_location + 1,
                           comma_location - prev_location - 1);
      prev_location := comma_location;
      v_account_type(v_account_type.count + 1) := v_location;
    
    END LOOP;
    SELECT attribute1
      INTO v_segment3
      FROM cux_lookup_codes v
     WHERE v.lookup_type = 'CUX_PUBLIC_ACCOUNT_DEFINE'
       AND v.enabled_flag = 'Y'
       AND v.lookup_code = 'AP_REBATE_MD';
    v_account_type(3) := v_segment3;
    FOR i IN v_account_type.first .. v_account_type.last LOOP
      IF i = 1 THEN
        p_segment1 := v_account_type(i);
      ELSIF i = 2 THEN
        p_segment2 := v_account_type(i);
      ELSIF i = 3 THEN
        p_segment3 := v_account_type(i);
      ELSIF i = 4 THEN
        p_segment4 := v_account_type(i);
      ELSIF i = 5 THEN
        p_segment5 := v_account_type(i);
      ELSIF i = 6 THEN
        p_segment6 := v_account_type(i);
      ELSIF i = 7 THEN
        p_segment7 := v_account_type(i);
      END IF;
    END LOOP;
  
    x_ccid := cux_gl_public_pkg.get_code_combination_id(p_org_id   => 101,
                                                        p_segment1 => p_segment1,
                                                        p_segment2 => p_segment2,
                                                        p_segment3 => p_segment3,
                                                        p_segment4 => p_segment4,
                                                        p_segment5 => p_segment5,
                                                        p_segment6 => p_segment6,
                                                        p_segment7 => p_segment7);
    /* dbms_output.put_line(x_ccid);*/
  END;

END cux_cuxaprebate_utl;
/

转载于:https://www.cnblogs.com/wanghang/p/6299528.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值