EBS日记账冲销API

–日记账冲销分为 红字冲销 和 借贷相反 两种,下例为红字冲销日记账。

DECLARE
    l_request_id NUMBER;
    --等待请求字段
    l_bl_result  BOOLEAN;
    l_phase      VARCHAR2(240);
    l_status     VARCHAR2(240);
    l_dev_phase  VARCHAR2(240);
    l_dev_status VARCHAR2(240);
    l_message    VARCHAR2(240);
 
    l_period_status VARCHAR2(1);
    l_start_date    DATE;
    l_end_date      DATE;
    l_period_num    NUMBER;
    l_period_year   NUMBER;
 
    CURSOR chk_sec_header_status IS
        SELECT 1
        FROM   gl_ledgers    gl
              ,gl_je_headers gh
        WHERE  gl.ledger_id = gh.ledger_id
        AND    gh.je_header_id = 2
        AND    gl.ledger_category_code = 'PRIMARY'
        AND    EXISTS (SELECT 1
                FROM   gl_je_headers gh1
                      ,gl_ledgers    gl1
                WHERE  gh1.parent_je_header_id = gh.je_header_id
                AND    gl1.ledger_id = gh1.ledger_id
                AND    gl1.ledger_category_code = 'SECONDARY'
                AND    gl1.automate_sec_jrnl_rev_flag IN ('Y'
                                                         ,'A')
                AND    gh1.status != 'P');
    l_has_sec_unpost_hdr_jrnl NUMBER;
BEGIN
 
    fnd_global.apps_initialize(user_id      => 1110
                              ,resp_id      => 50719
                              ,resp_appl_id => 20007);
 
    --校验期间
    gl_period_statuses_pkg.select_columns(101
                                         ,2023
                                         ,'2018-07'
                                         ,l_period_status
                                         ,l_start_date
                                         ,l_end_date
                                         ,l_period_num
                                         ,l_period_year);
 
    IF (nvl(l_period_status
           ,'X') NOT IN ('O'
                         ,'F')) THEN
        fnd_message.set_name(application => 'SQLGL'
                            ,NAME        => 'GL_JE_NO_REV_HEADER_BAD_PERIOD');
        dbms_output.put_line('Error Message  = ' || fnd_message.get);
    END IF;
 
    OPEN chk_sec_header_status;
    FETCH chk_sec_header_status
        INTO l_has_sec_unpost_hdr_jrnl;
    IF chk_sec_header_status%FOUND THEN
        l_has_sec_unpost_hdr_jrnl := 1;
    END IF;
    CLOSE chk_sec_header_status;
 
    IF nvl(l_has_sec_unpost_hdr_jrnl
          ,0) = 1 THEN
        fnd_message.set_name(application => 'SQLGL'
                            ,NAME        => 'GL_COR_SEC_UNPOSTED_ERROR');
        dbms_output.put_line('Error Message  = ' || fnd_message.get);
    END IF;
 
    UPDATE gl_je_headers b
    SET    b.accrual_rev_flag             = 'Y'
          ,b.accrual_rev_change_sign_flag = 'Y'
          ,b.accrual_rev_period_name      = '2018-07'
    WHERE  b.je_header_id = 2;
    COMMIT;
 
    l_request_id := fnd_request.submit_request(application => 'SQLGL' --应用简称
                                              ,program     => 'GLPREV' --并发简称:日记帐导入
                                              ,description => '' --说明
                                              ,start_time  => '' --请求开始时间,格式为标准日期格式,为空表示立即开始
                                              ,sub_request => FALSE --是否子请求
                                              ,argument1   => fnd_profile.value('GL_ACCESS_SET_ID') --帐套标识或者数据访问权限集
                                              ,argument2   => to_char(2) --日记账头ID
                                              ,argument3   => chr(0) --参数结束
                                               );
    IF l_request_id <= 0 THEN
        dbms_output.put_line('提交冲销日记账请求失败 !');
    ELSE
        COMMIT;
        dbms_output.put_line('请求编号:' || l_request_id);
    
        l_bl_result := fnd_concurrent.wait_for_request(request_id => l_request_id
                                                      ,INTERVAL   => 1 -- interval second for check 
                                                      ,max_wait   => 360 -- max_wait, Max amount of time to wait (in seconds)
                                                      ,phase      => l_phase
                                                      ,status     => l_status
                                                      ,dev_phase  => l_dev_phase
                                                      ,dev_status => l_dev_status
                                                      ,message    => l_message);
    
        dbms_output.put_line('  l_phase = ' || l_phase);
        dbms_output.put_line('  l_status = ' || l_status);
        dbms_output.put_line('  l_dev_phase = ' || l_dev_phase);
        dbms_output.put_line('  l_dev_status = ' || l_dev_status);
        dbms_output.put_line('  l_message = ' || l_message);
    
        --请求的状态为完成并且为正常
        IF l_dev_phase <> 'COMPLETE'
           OR l_dev_status <> 'NORMAL' THEN
            dbms_output.put_line('Reverse Journal :  冲销日记账出现异常错误,查看请求: ' || l_request_id);
            dbms_output.put_line('Reverse Journal :  冲销日记账出现异常错误,错误消息: ' || l_message);
        ELSE
            dbms_output.put_line('------>03.Reverse Journal :  冲销日记账成功');
        END IF;
    END IF;
END;

————————————————
版权声明:本文为CSDN博主「OO好久不见OO」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/longtimetoc/java/article/details/81197853

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值