溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何進(jìn)行基于R12 Business Event+Workflow的分析

發(fā)布時間:2021-11-08 10:28:24 來源:億速云 閱讀:128 作者:柒染 欄目:建站服務(wù)器

這篇文章將為大家詳細(xì)講解有關(guān)如何進(jìn)行基于R12 Business Event+Workflow的分析,文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個參考,希望大家閱讀完這篇文章后對相關(guān)知識有一定的了解。

今天做了個Business events + Workflow 的例子,記錄一下。

功能描述:

當(dāng)表中新增一條INVOICE信息,自動觸發(fā)Business events, 然后調(diào)用Workflow,發(fā)Notification 給審批者審批。

 

主要目的是測試Business events 的功能,學(xué)習(xí)一下。

 

測是測通了,但做完后,發(fā)覺并沒有了解Business events的優(yōu)勢,因?yàn)檫@樣的功能,完全可以在記錄新增時直接調(diào)用Workflow來處理,感覺系統(tǒng)標(biāo)準(zhǔn)的Business events也無非是在某個操作完成后,觸發(fā)一個Events,來完成后繼的操作,就算有延遲處理(Defer)的功能,似乎我們也可通過database job 來實(shí)現(xiàn),訂閱(Subscriptions)功能也似乎可以寫Package來實(shí)現(xiàn)不同的業(yè)務(wù)邏輯的分支處理。

 

如果有TX看到我的困惑,請不吝賜教!

 

下面是例子的詳細(xì)步驟。

 

1.  建立客戶化表如何進(jìn)行基于R12 Business Event+Workflow的分析如何進(jìn)行基于R12 Business Event+Workflow的分析

 

 

Notification的定義如下:

 

如何進(jìn)行基于R12 Business Event+Workflow的分析如何進(jìn)行基于R12 Business Event+Workflow的分析

注意Performer的定義,即為接收人

 

上傳Workflow并注冊至系統(tǒng)

 

Event subscription 的定義
如何進(jìn)行基于R12 Business Event+Workflow的分析

 
如何進(jìn)行基于R12 Business Event+Workflow的分析

注意,Phase 定義在100以下的為即時處理

注意: PL/SQL Rule Function 里為客制化的程序,用來完成Event 信息的保存和Event的初始化

Workflow Type 里既為上面開發(fā)的Workflow, Process 為里面唯一的 create or replace package body c_customer_invoice_pkg is

  --用來生成測試數(shù)據(jù)及調(diào)用Events

  procedure insert_data is

  

    l_invoice_id number;

  begin

  

    select c_apps.c_customer_invoice_s.nextval into l_invoice_id from dual;

    --Insert 數(shù)據(jù)
    --3137為我的user id,此為測試方便,直接用。

    insert into c_apps.c_customer_invoices_all

      (invoice_id,

       invoice_date,

       invoice_amount,

       submit_id,

       submit_date,

       approval_id,

       approval_date,

       approval_memo,

       approval_status)

    values

      (l_invoice_id, sysdate, 1000, 3137, sysdate, null, null, null, null);

    commit;

    --調(diào)用過程啟動Event

    raise_event(l_invoice_id, 3137);

  end insert_data;

  

  --用來啟動Event

  PROCEDURE raise_event(pi_invoice_id in NUMBER, pi_submit_id in NUMBER) is

  

    l_parameter_list wf_parameter_list_t := wf_parameter_list_t();

    l_parameter_t    wf_parameter_t := wf_parameter_t(null, null);

    l_event_key      NUMBER;

    l_event_data     varchar2(300);

  

    l_message varchar2(10);

  

  BEGIN

    

    --用invoice id 做為event key

    l_event_key := pi_invoice_id;

    

    --定義event的參數(shù)  

    l_parameter_t.setName('INVOICE_ID');

    l_parameter_t.setVALUE(pi_invoice_id);

    l_parameter_list.extend;

    l_parameter_list(1) := l_parameter_t;

  

    l_parameter_t.setName('SUBMIT_ID');

    l_parameter_t.setVALUE(pi_submit_id);

    l_parameter_list.extend;

    l_parameter_list(2) := l_parameter_t;

  

    --啟動  

    wf_event.raise(p_event_name => 'oracle.apps.c_apps.invoice.approval',

                   p_event_key  => l_event_key,

                   --p_event_data => l_event_data,

                   p_parameters => l_parameter_list);

    commit;

  

    l_parameter_list.DELETE;   

     

  END raise_event;

  --此過程設(shè)置在Subscription的rule function中,用來往表中寫入Event信息  

  FUNCTION rule_function(p_subscription in RAW,

                         p_event        in out NOCOPY WF_EVENT_T)

    return varchar2 is

  

    l_rule            VARCHAR2(20);

    l_parameter_list  wf_parameter_list_t := wf_parameter_list_t();

    l_parameter_t     wf_parameter_t := wf_parameter_t(null, null);

    i_parameter_name  l_parameter_t.name%type;

    i_parameter_value l_parameter_t.value%type;

    i                 pls_integer;

  

    l_invoice_id l_parameter_t.value%type;

    l_submit_id  l_parameter_t.value%type;

  BEGIN

  

    if p_event.geteventname() = 'oracle.apps.c_apps.invoice.approval' then

      --獲取Event的參數(shù)

      l_parameter_list := p_event.getParameterList();

      if l_parameter_list is not null then

        i := l_parameter_list.FIRST;

        --獲取參數(shù)的值

        while (i <= l_parameter_list.LAST) loop

          i_parameter_name  := null;

          i_parameter_value := null;

        

          i_parameter_name  := l_parameter_list(i).getName();

          i_parameter_value := l_parameter_list(i).getValue();

        

          if i_parameter_name is not null then

            if i_parameter_name = 'INVOICE_ID' then

              l_invoice_id := i_parameter_value;

            elsif i_parameter_name = 'SUBMIT_ID' then

              l_submit_id := i_parameter_value;

            end if;

          end if;

          i := l_parameter_list.NEXT(i);

        end loop;

      

      end if;

      --寫入Event表

      insert into c_apps.c_customer_invoice_events

        (event_id,

         event_name,

         event_key,

         event_data,

         event_date,

         invoice_id,

         submit_id)

      values

        (c_apps.c_customer_invoice_event_s.nextval,

         p_event.getEventName,

         p_event.getEventKey,

         p_event.getEventData,

         sysdate,

         l_invoice_id,

         l_submit_id);

      

      --調(diào)用系統(tǒng)標(biāo)準(zhǔn)的Event rule

      l_rule := wf_rule.default_rule(p_subscription, p_event);

    

    end if;

    return('SUCCESS');

  EXCEPTION

    WHEN OTHERS THEN

      wf_core.context('c_customer_invoice_pkg',

                      'rule_function',

                      p_event.geteventname(),

                      p_subscription);

      wf_event.seterrorinfo(p_event, 'ERROR');

      RETURN 'ERROR';

  END rule_function;

  --用于Workflow,取得submit/approval的人員信息及發(fā)票信息

  PROCEDURE get_submit_info(itemtype  IN VARCHAR2,

                            itemkey   IN VARCHAR2,

                            actid     IN NUMBER,

                            funcmode  IN VARCHAR2,

                            resultout OUT NOCOPY VARCHAR2) is

    l_invoice_id     NUMBER;

    l_invoice_amount NUMBER;

    l_invoice_date   date;

  

    l_orig_system wf_roles.orig_system%TYPE := 'PER';

  

    l_submit_id           NUMBER;

    l_submit_name         wf_roles.NAME%TYPE;

    l_submit_display_name wf_roles.display_name%TYPE;

  

    l_approval_id           NUMBER;

    l_approval_name         wf_roles.NAME%TYPE;

    l_approval_display_name wf_roles.display_name%TYPE;

  begin

    IF (funcmode <> wf_engine.eng_run) THEN

    

      resultout := wf_engine.eng_null;

      RETURN;

    

    END IF;

  

    l_invoice_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                                itemkey  => itemkey,

                                                aname    => 'INVOICE_ID');

  

    l_submit_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                               itemkey  => itemkey,

                                               aname    => 'SUBMIT_ID');

  

    wf_directory.GetRoleName(p_orig_system    => l_orig_system,

                             p_orig_system_id => l_submit_id,

                             p_name           => l_submit_name,

                             p_display_name   => l_submit_display_name);

  

    wf_engine.setitemattrtext(itemtype => itemtype,

                              itemkey  => itemkey,

                              aname    => 'SUBMIT_NAME',

                              avalue   => l_submit_name);

  

    wf_engine.setitemattrtext(itemtype => itemtype,

                              itemkey  => itemkey,

                              aname    => 'SUBMIT_DSP_NAME',

                              avalue   => l_submit_display_name);

  

    wf_directory.GetRoleName(p_orig_system    => l_orig_system,

                             p_orig_system_id => l_submit_id,

                             p_name           => l_approval_name,

                             p_display_name   => l_approval_display_name);

  

    wf_engine.setitemattrnumber(itemtype => itemtype,

                                itemkey  => itemkey,

                                aname    => 'APPROVAL_ID',

                                avalue   => l_submit_id);

    wf_engine.setitemattrtext(itemtype => itemtype,

                              itemkey  => itemkey,

                              aname    => 'APPROVAL_NAME',

                              avalue   => l_approval_name);

  

    wf_engine.setitemattrtext(itemtype => itemtype,

                              itemkey  => itemkey,

                              aname    => 'APPROVAL_DSP_NAME',

                              avalue   => l_approval_display_name);

  

    select invoice_amount, invoice_date

      into l_invoice_amount, l_invoice_date

      from c_apps.c_customer_invoices_all

     where invoice_id = l_invoice_id;

  

    wf_engine.setitemattrnumber(itemtype => itemtype,

                                itemkey  => itemkey,

                                aname    => 'INVOICE_AMOUNT',

                                avalue   => l_invoice_amount);

  

    wf_engine.SetItemAttrDate(itemtype => itemtype,

                              itemkey  => itemkey,

                              aname    => 'INVOICE_DATE',

                              avalue   => l_invoice_date);

    resultout := 'COMPLETE';

  EXCEPTION

    when others then

      wf_core.context('C_CUSTOMER_INVOICE_PKG',

                      'get_submit_info',

                      itemtype,

                      itemkey,

                      TO_CHAR(actid),

                      funcmode,

                      SQLERRM);

      raise;

  end get_submit_info;

  

  --用于Workflow的審批分支

  PROCEDURE invoice_approval(itemtype  IN VARCHAR2,

                             itemkey   IN VARCHAR2,

                             actid     IN NUMBER,

                             funcmode  IN VARCHAR2,

                             resultout OUT NOCOPY VARCHAR2) is

  

    l_invoice_id    NUMBER;

    l_approval_memo c_apps.c_customer_invoices_all.approval_memo%TYPE;

    l_approval_id   NUMBER;

  

  begin

    IF (funcmode <> wf_engine.eng_run) THEN

    

      resultout := wf_engine.eng_null;

      RETURN;

    

    END IF;

    l_invoice_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                                itemkey  => itemkey,

                                                aname    => 'INVOICE_ID');

  

    l_approval_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                                 itemkey  => itemkey,

                                                 aname    => 'APPROVAL_ID');

  

    l_approval_memo := wf_engine.getitemattrtext(itemtype => itemtype,

                                                 itemkey  => itemkey,

                                                 aname    => 'APPROVAL_MEMO');

  

    UPDATE c_apps.c_customer_invoices_all

       SET approval_id     = l_approval_id,

           approval_date   = sysdate,

           approval_memo   = l_approval_memo,

           approval_status = 'Y'

     WHERE invoice_id = l_invoice_id;

    resultout := 'COMPLETE';

  EXCEPTION

    when others then

      wf_core.context('C_CUSTOMER_INVOICE_PKG',

                      'invoice_approval',

                      itemtype,

                      itemkey,

                      TO_CHAR(actid),

                      funcmode,

                      SQLERRM);

      raise;

  end invoice_approval;

  

  --用于Workflow的拒絕分支

  PROCEDURE invoice_reject(itemtype  IN VARCHAR2,

                           itemkey   IN VARCHAR2,

                           actid     IN NUMBER,

                           funcmode  IN VARCHAR2,

                           resultout OUT NOCOPY VARCHAR2) is

  

    l_invoice_id    NUMBER;

    l_approval_memo c_apps.c_customer_invoices_all.approval_memo%TYPE;

    l_approval_id   NUMBER;

  

  begin

    IF (funcmode <> wf_engine.eng_run) THEN

    

      resultout := wf_engine.eng_null;

      RETURN;

    

    END IF;

    l_invoice_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                                itemkey  => itemkey,

                                                aname    => 'INVOICE_ID');

  

    l_approval_id := wf_engine.getitemattrnumber(itemtype => itemtype,

                                                 itemkey  => itemkey,

                                                 aname    => 'APPROVAL_ID');

  

    l_approval_memo := wf_engine.getitemattrtext(itemtype => itemtype,

                                                 itemkey  => itemkey,

                                                 aname    => 'APPROVAL_MEMO');

  

    UPDATE c_apps.c_customer_invoices_all

       SET approval_id     = l_approval_id,

           approval_date   = sysdate,

           approval_memo   = l_approval_memo,

           approval_status = 'N'

     WHERE invoice_id = l_invoice_id;

    resultout := 'COMPLETE';

  EXCEPTION

    when others then

      wf_core.context('C_CUSTOMER_INVOICE_PKG',

                      'invoice_reject',

                      itemtype,

                      itemkey,

                      TO_CHAR(actid),

                      funcmode,

                      SQLERRM);

      raise;

  end invoice_reject;

end c_customer_invoice_pkg;


最后在PL/SQL中執(zhí)行

BEGIN

   c_customer_invoice_pkg.insert_data;

end;

查看Event表,記錄生成,進(jìn)入系統(tǒng),發(fā)現(xiàn)Notification已經(jīng)收到,可以正常審批!

關(guān)于如何進(jìn)行基于R12 Business Event+Workflow的分析就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI