Post_Outbound_BizAPI

The Post_Outbound_BizAPI procedure automatically creates an application message with the supplied message body record attached as an XML document. The XML document is temporarily stored in a text column and is therefore not visible in the Solution Manager client. 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 XML document is moved to the binary body.

This function has been created specifically for the purpose of sending outbound BizAPI messages. Users should construct the message body as a record 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 having any BizApi in the application server. This can be achieved by setting message type to EVENT_BIZAPI (from IFS Applications7 SP3). In IFS Applications 2004 this can be achieved by setting the BizApi name to $REPLICATION:<NAME>$ - the message function attribute in the Application Message will contain the value of <NAME>.

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.

PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		     IN     VARCHAR2,
   message_body_             IN OUT type_record_,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG' );
PROCEDURE Post_Outbound_Bizapi (
   bizapi_name_		     IN     VARCHAR2,
   message_body_             IN OUT type_record_,
   sender_                   IN     VARCHAR2 DEFAULT NULL,
   receiver_                 IN     VARCHAR2 DEFAULT 'CONNECT',
   message_type_             IN     VARCHAR2 DEFAULT 'CONNECT',
   message_function_         IN     VARCHAR2 DEFAULT 'CONNECT_MSG',
   message_id_               IN OUT NUMBER );
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 );

Parameters

bizapi_name_
    Name of the BizAPI as specified in the repository. For example 'SEND_ORDER_CONFIRMATION'. The value will be entered in FNDCN_APPLICATION_MESSAGE_TAB.MESSAGE_FUNCTION.

message_body_
    A record that corresponds to the BizAPI view definition. This record 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_
    NOT USED.

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

Record handling

Post_Outbound_BizAPI will automatically issue a PLSQLAP_Record_API.Clear_Record procedure call removing the input record.

Example

DECLARE
   appl_user_ PLSQLAP_Record_API.type_record_;
BEGIN
   -- create a record corresponding to the view which is the BizAPIs parameter
   appl_user_ := PLSQLAP_Record_API.New_Record('APPLICATION_USER.APPLICATION_USER');
   PLSQLAP_Record_API.Set_Value(appl_user_, 'APPLICATION_USER_ID', 'TESTID');

   -- post the BizAPI to IFS Connect. A correct application message with the given record 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
/
-- IFS Applications 2004 - no BizApi present in Extended Server.
-- If a BizApi exist it will NOT be called.
DECLARE
   appl_user_ PLSQLAP_Record_API.type_record_;
BEGIN
   -- create a record corresponding to the view which is the BizAPIs parameter
   appl_user_ := PLSQLAP_Record_API.New_Record('APPLICATION_USER.APPLICATION_USER');
   PLSQLAP_Record_API.Set_Value(appl_user_, 'APPLICATION_USER_ID', 'TESTID');

   -- post the BizAPI to IFS Connect. A correct application message with the given record as XML body will
   -- be created. The application message will then be routed according to configured message routing.
   PLSQLAP_Server_API.Post_Outbound_BizAPI('$REPLICATION:SEND_APPL_USER$',appl_user_);
END;
/
COMMIT
/
-- IFS Applications7 SP3 - no BizApi present in Extended Server.
-- If a BizApi exist it will NOT be called.
DECLARE
   appl_user_ PLSQLAP_Record_API.type_record_;
BEGIN
   -- create a record corresponding to the view which is the BizAPIs parameter
   appl_user_ := PLSQLAP_Record_API.New_Record('APPLICATION_USER.APPLICATION_USER');
   PLSQLAP_Record_API.Set_Value(appl_user_, 'APPLICATION_USER_ID', 'TESTID');

   -- post the BizAPI to IFS Connect. A correct application message with the given record as XML body will
   -- be created. The application message will then be routed according to configured message routing.
   PLSQLAP_Server_API.Post_Outbound_BizAPI(
      bizapi_name   => 'SEND_APPL_USER',
      message_body_ => appl_user_,
      message_type_ => 'EVENT_BIZAPI');
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
/