Post_Outbound_BizAPI

The Post_Outbound_BizAPI procedures automatically create an application message with the supplied message body record or document attached as an XML document. Some versions of the method accept XML document as CLOB data instead of record/document. The XML document is stored in a text column (CLOB). When the message is processed by the Plsql Access Provider, pre-routing is done placing the message in the proper queue. When the message is processed in the application server the final routing is done and the resulting XML document after BizAPI execution is stored to the binary body (BLOB).

These functions have been created specifically for the purpose of sending outbound BizAPI messages. Users should construct the message body as a document that corresponds to the BizAPI view definition. Specifying sender, receiver, message_type and message_function is optional.

NOTE: It is possible to send a message without calling any BizApi in the application server. This can be achieved by setting bizapi_name_ to NULL.

NOTE: If bizapi_name_ is not NULL and message_type_ is not equal 'CONNECT', the application server will make a try to call the named BizAPI, but will not fail if not found. If message_type_ equals 'EVENT_BIZAPI' the application server will not make any attempt to find the BizAPI.

The post is done as a part of the current transaction. If a rollback occurs after a call to Post_Outbound_BizAPI the posted message is also rolled back.

NOTE: Failure to find a queue for an in-order message will throw an exception rather then putting the message to the ERROR queue.

PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		  IN     VARCHAR2,
   message_body_             IN OUT <one of: type_record_ or Plsqlap_Document_API.Document>,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG' -- currently not used
   subject_                  IN     VARCHAR2 DEFAULT NULL,
   in_order_                 IN     BOOLEAN  DEFAULT FALSE );
PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		  IN     VARCHAR2,
   message_body_             IN OUT <one of: type_record_ or Plsqlap_Document_API.Document>,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG', -- currently not used
   message_id_               IN OUT NUMBER,
   subject_                  IN     VARCHAR2 DEFAULT NULL,
   in_order_                 IN     BOOLEAN  DEFAULT FALSE );
PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		  IN     VARCHAR2,
   xml_                      IN     CLOB,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG', -- currently not used
   subject_                  IN     VARCHAR2 DEFAULT NULL,
   external_message_id_      IN     VARCHAR2 DEFAULT NULL,
   in_order_                 IN     BOOLEAN  DEFAULT FALSE );
PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		  IN     VARCHAR2,
   xml_                      IN     CLOB,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG', -- currently not used
   message_id_               IN OUT NUMBER,
   external_message_id_      IN     VARCHAR2 DEFAULT NULL,
   subject_                  IN     VARCHAR2 DEFAULT NULL,
   in_order_                 IN     BOOLEAN  DEFAULT FALSE );

Parameters

bizapi_name_
    Name of the BizAPI as specified in the repository or NULL if no BizAPI should be called. For example 'SEND_ORDER_CONFIRMATION'. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.MESSAGE_FUNCTION..

message_body_
    A Record or Document that corresponds to the BizAPI view definition. This record/document will automatically be converted to XML and attached as a binary body to the message before it is sent.

xml_
    An XML document that corresponds to the BizAPI view definition. The XML is attached as a binary body to the message before it is sent.

sender_
    Optional identity of sending organization. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.SENDER.

receiver_
    Optional identity of receiving organization. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.RECEIVER.

message_type_
    Optional. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.MESSAGE_TYPE.

message_function_
    CURRENTLY NOT USED.

message_id_
    Returns the message id in the Middleware Server queue, FNDCN_APPLICATION_MESSAGE_TAB.APPLICATION_MESSAGE_ID.

subject_
    Optional subject. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.SUBJECT.

external_message_id_
    Optional reference to an external message. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.EXTERNAL_MESSAGE_ID.

in_order_
    Flag denoting if the message should be put to an InOrder queue. Default FALSE. If TRUE and it is not possible to find a queue or the found queue is not InOrder, an exception will be raised..

Record handling

Post_Outbound_BizAPI will automatically issue a PLSQLAP_Record_API.Clear_Record procedure call removing the input record. If working with Documents (recommended) the cleaning is not required.

Example

DECLARE
   appl_user_ PLSQLAP_Document_API.Document;
BEGIN
   -- create a document corresponding to the view which is the BizAPIs parameter
   appl_user_ := PLSQLAP_Document_API.New_Document('APPLICATION_USER.APPLICATION_USER');
   PLSQLAP_Document_API.Add_Attribute(appl_user_, 'APPLICATION_USER_ID', 'TESTID');

   -- post the BizAPI to IFS Connect. A correct application message with the given document as XML body will
   -- be created. The application message will then be routed according to configured message routing.
   PLSQLAP_Server_API.Post_Outbound_BizAPI('SEND_APPL_USER', appl_user_);
END;
/
COMMIT
/
DECLARE
   tf_ VARCHAR2(30) := 'yyyy-mm-dd-hh24.mi.ss';
   id_ NUMBER := 1029;
   xml_ XMLType;
   CURSOR c_invoices (customer_id_ NUMBER) IS
      SELECT xmlelement("TRN_CUSTOMER_INVOICES",
                xmlelement("INVOICES",
                   xmlagg(
                      xmlelement("TRN_CUSTOMER_INVOICE",
                         xmlelement("COMPANY_ID", a.company_id),
                         xmlelement("BRANCH_ID", a.branch_id),
                         xmlelement("CUSTOMER_ID", a.customer_id),
                         xmlelement("INVOICE_ID", a.invoice_id),
                         xmlelement("INVOICE_DATE", TO_CHAR(a.invoice_date,tf_)),
                         xmlelement("DUE_DATE", TO_CHAR(a.due_date,tf_)),
                         xmlelement("INVOICE_AMOUNT", a.invoice_amount),
                         xmlelement("COMMENTS", a.comments),
                         xmlelement("PAYMENT_TERMS", a.payment_terms),
                         xmlelement("ORDER_ID", a.order_id),
         (SELECT xmlelement("ITEMS",
                    xmlagg(
                       xmlelement("TRN_CUSTOMER_INVOICE_ITEM",
                          xmlelement("ITEM_NO", b.item_no),
                          xmlelement("DESCRIPTION",b.description),
                          xmlelement("PRICE", b.price),
                          xmlelement("QUANTITY", b.quantity),
                          xmlelement("AMOUNT", b.amount),
                          xmlelement("PRODUCT_ID", b.product_id) )))
          FROM  trn_customer_invoice_item b
          WHERE b.company_id = a.company_id
            AND b.branch_id  = a.branch_id
            AND b.invoice_id = a.invoice_id) )))) xml_data
      FROM  trn_customer_invoice a
      WHERE a.customer_id = customer_id_;
BEGIN
   FOR rec_ IN c_invoices(id_) LOOP
      xml_ := rec_.xml_data;
   END LOOP;
   PLSQLAP_Server_API.Post_Outbound_BizAPI(
      bizapi_name_  => 'SEND_CUSTOMER_INVOICES',
      xml_          => xml_.getClobVal(),
      message_type_ => 'EVENT_BIZAPI');
END;
/
COMMIT
/