Wednesday, April 18, 2012

How to Create/Update Party,Customer,Site using Business Object as parameter

--BPEL process calls EBS TCA (Trading Community Architecture) APIs via Apps Adapter to create and update
--Organizations (Parties) and Customers (Accounts) accordingly. TCA provides hz_org_cust_bo_pub API uses
--object types as parameters and is called Business Object(BO) API.

--Following is an example of how to create and update TCA party, customer, customer site etc
--Declare HZ_ORG_CUST_BO business object type variable to pass the customer payload:-

------------

DECLARE
  
   l_hz_org_cust_bo   hz_org_cust_bo;
   x_xml              XMLTYPE;
   l_return_status    VARCHAR2 (4000);
   l_msg_count        NUMBER;
   l_org_id           NUMBER;
   l_msg_data         VARCHAR2 (4000);

BEGIN
-- Initialize to set the context
fnd_global.apps_initialize(<user_id>, <resp_id>, <resp_appl_id>);

-- This select statement should be of XMLTYPE datatype and should hold the HZ_ORG_CUST_BO type payload
-- starting and ending with HZ_ORG_CUST_BO_OBJ tag

   SELECT xml_data
     INTO x_xml
     FROM ar_custxml;

   x_xml.toobject (l_hz_org_cust_bo);

-- Call API to Create/Update Party/Customer details using Business Object as parameter
   hz_org_cust_bo_pub.save_org_cust_bo 
      (p_init_msg_list          => fnd_api.g_true,
       p_validate_bo_flag       => fnd_api.g_false,
       p_org_cust_obj           => l_hz_org_cust_bo,
       p_created_by_module      => 'BO_API',
       x_return_status          => l_return_status,
       x_msg_count              => l_msg_count,
       x_msg_data               => l_msg_data,
       x_organization_id        => l_org_id
              );
   COMMIT;
   DBMS_OUTPUT.put_line ('x' || l_return_status);
   DBMS_OUTPUT.put_line ('x' || l_msg_data || l_msg_count);
   DBMS_OUTPUT.put_line ('l_org_id: ' || l_org_id);

   IF l_msg_count > 1
   THEN
      FOR i IN 1 .. l_msg_count
      LOOP
         DBMS_OUTPUT.put_line
                      (   i
                       || '. '
                       || SUBSTR
                      fnd_msg_pub.get (p_encoded =>  
                                fnd_api.g_false),
                                1,
                                255
                               )
                      );
      END LOOP;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line (SQLERRM);
END;
/

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. Hi Sirish

    I am trying to use the same BO API. I have found interesting statements from your script-
    <<
    SELECT xml_data
    INTO x_xml
    FROM ar_custxml;
    x_xml.toobject (l_hz_org_cust_bo);
    >>
    Can you please provide some details on ar_custxml? I would like to build similar to that one.

    Thanks
    Sreedhar

    ReplyDelete