Form个性化--调用自定义程序库

现在我们来看另外一个内置类型--调用自定义程序库。自定义程序库,即Oracle提供的Custom.pll库,当我们使用调用自定义程序库时,Form默认执行的是custom.event()过程,而参数,便是我们传进去的变元了。实际上,custom.pll还有更强大的作用,大家有兴趣可以下载附件中的文档看一下。

言归正传,回到原来的话题,依然是创建菜单项按钮提交请求,使用custom.pll来实现。刚才已经介绍了调用了自定义程序库的执行机制,那么接下来,就是在custom.pll中添加代码啦,首先,从服务器$AU_TOP/resources目录下载custom.pll文件,使用form. builder打开文件,和编辑其他package一样,编写代码:


procedure event(event_name varchar2) is
  form_name      varchar2(30) := name_in('system.current_form');
  block_name     varchar2(30) := name_in('system.cursor_block');
begin
  if event_name = 'CALL_CUSTOM_EVENT' then
    if (form_name = 'APXINWKB' and block_name = 'INV_SUM_FOLDER') then
      declare
        l_group_name     varchar2(60) := block_name||'_MULTI';
        l_rec_group_id    recordgroup;
        l_curr_rec_num   number;
        l_num_records    number;
        l_invoice_id_str   varchar2(2000);
        l_curr_record      number;
        l_success            boolean;
        l_request_number           number;
        e_check_error_exception exception;
      begin
      -- 获取选中的invoice
      l_rec_group_id := find_group(block_name||'_MULTI');
     
      if not id_null(l_rec_group_id) then
        l_num_records := get_group_row_count(find_group(l_group_name));
       
        if l_num_records > 0 then
          l_invoice_id_str := null;
          -- 对选中的记录进行循环
          for i in 1..l_num_records loop
            l_curr_rec_num := get_group_number_cell(l_group_name||'.REC_NUM',i);
            go_record(l_curr_rec_num);
            -- 组合invoice id作为请求参数
            if l_invoice_id_str is null then
              l_invoice_id_str := name_in(block_name||'.INVOICE_ID');
            else
              l_invoice_id_str := l_invoice_id_str||','||name_in(block_name||'.INVOICE_ID');
            end if;
          end loop;

          if l_invoice_id_str is not null then
            l_invoice_id_str := '('||l_invoice_id_str||')';
            -- 加载模板
            l_success := fnd_request.add_layout('XXBG','XXBGREQP','zh','CN','PDF');
            if l_success then
              -- 设置请求的业务实体
              fnd_request.set_org_id(l_org_id);
              -- 提交打印付款申请请求
              l_request_number :=
                     fnd_request.submit_request(
                            'XXBG',
                            'XXBGREQP',
                            '',
                            '',
                            FALSE,
                            l_invoice_id_str,
                            CHR(0), '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '',
                            '', '', '', '', '', '', '', '', '', '');
             
              if l_request_number = 0 then
                fnd_message.retrieve;
                fnd_message.error;
              else
                if app_form.quietcommit then
                  fnd_message.set_name('SQLGL','GL_REQUEST_SUBMITTED');
                  fnd_message.set_TOKEN('REQUEST_ID', to_char(l_request_number), FALSE);
                  fnd_message.show;
                end if;
                -- 弹出请求窗口
                fnd_function.execute( function_name => 'FND_FNDRSRUN',
                       open_flag   => 'Y',
                       session_flag  => 'Y',
                       other_params  => 'DODT_REQ_ID="'||TO_CHAR(l_request_number)||'"');
              end if;
            end if;
          end if;
          go_record(l_curr_record);
        else
          fnd_message.set_name('', 'Please select one record');
          raise e_check_error_exception;
        end if;
      end if;
      exception
        when e_check_error_exception then
          fnd_message.error;
          raise form_trigger_failure;
      end;
    end if;
  end if;
end event;

由于我使用了app_form.quietcommit过程,所以,要把appcore库添加到custom下面才可以使用。

完成后上传custom.pll到服务器目录,使用

11i: f60gen module_type=LIBRARY module=CUSTOM userid=apps/apps

R12:frmcmp_batch module_type=LIBRARY module=CUSTOM userid=apps/apps 编译pll文件,退出应用重新登陆,效果就出来了。本程序在R12环境测试过。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/126211/viewspace-691278/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/126211/viewspace-691278/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值