【OracleEBS】 在PL/SQL中调用Oracle ERP请求

 

 

procedure prc_do_import_request(prm_org     in number,
                                  prm_appcode out number,
                                  prm_appmsg  out varchar2) is
    custom_exception exception;
    success        boolean;
    v_request_id   number;
    v_phase        varchar2(30);
    v_status       varchar2(30);
    v_dev_phase    varchar2(30);
    v_dev_status   varchar2(30);
    v_message      varchar2(1000);
    v_request_flag boolean;
    v_start_time   varchar2(30);
  begin
    prm_appcode := 0;
    --初始化设置
    fnd_global.apps_initialize(user_id      => global_user_id,--用户id
                               resp_id      => global_resp_id,          --责任id  
                               resp_appl_id => global_resp_appl_id);   --应用id
    --设置打印参数
    success := fnd_request.set_print_options(printer => global_printer,
                                             style   => global_style,
                                             copies  => global_copies);
    if not success then
      raise custom_exception;
    end if;
    v_start_time := to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS');
    --调用请求
    v_request_id := fnd_request.submit_request('INV',   --应用
                                               'INCOIN',                  --程序
                                               '',                              --程序说明
                                               v_start_time,               --开始时间
                                               false,                        --是否作为子请求提交,该请求如果是被其它请求调用设为true,否则为false
                                               prm_org,                    --自定义参数1:组织机构
                                               '1',                             --自定义参数2 :
                                               '1',                             --自定义参数3:
                                               '1',                             --自定义参数4:
                                               '1',                             --自定义参数5:
                                               '1',                             --自定义参数6:
                                               '1',                             --自定义参数7:
                                               chr(0));                       --结束标识
    if v_request_id = 0 then
      raise custom_exception;
    else
      commit;
    end if;
    --等待
    v_request_flag := fnd_concurrent.wait_for_request(request_id => v_request_id,--返回的请求id
                                                      interval   => 5,                                     --重复检测时间差
                                                      max_wait   => 0,                                       --最长等待时间,0为一直等待  
                                                      phase      => v_phase,                                                          
                                                      status     => v_status,
                                                      dev_phase  => v_dev_phase,
                                                      dev_status => v_dev_status,
                                                      message    => v_message);
    if v_request_flag then
      if v_dev_status = 'NORMAL' then
        null;
      else
        raise custom_exception;
      end if;
    else
      raise custom_exception;
    end if;
  exception
    when custom_exception then
      prm_appcode := -1;
      prm_appmsg  := '错误提示:导入ERP正式表出错!' || sqlerrm;
    when others then
      prm_appcode := -1;
      prm_appmsg  := '错误提示:导入ERP正式表出错!' || sqlerrm;
  end prc_do_import_request;

 

posted @ 2024-04-07 16:29  Iven_lin  阅读(81)  评论(0编辑  收藏  举报