Thursday, March 10, 2016

API to populate loc_id HZ_LOCATIONS R12 (HZ_TAX_ASSIGNMENT_V2PUB. CREATE_LOC_ASSIGNMENT )

API to populate loc_id HZ_LOCATIONS R12 (HZ_TAX_ASSIGNMENT_V2PUB. CREATE_LOC_ASSIGNMENT )



                                                                                                                         
This routine is used to populate loc_id after a location is created or modified. It also creates or updates a record in the HZ_LOCATIONS_PROFILES table. This is called when a customer account site is created. This is to ensure tax validation. It creates a record in the HZ_LOC_ASSIGNMENTS table with location_id (foreign key to HZ_LOCATIONS.LOCATION_ID), loc_id (foreign key to AR_LOCATION_COMBINATIONS.LOCATION_ID) and org_id (operating unit identifier)
API: HZ_TAX_ASSIGNMENT_V2PUB. CREATE_LOC_ASSIGNMENT
BASE TABLES AFFECTED : HZ_LOC_ASSIGNMENTS
TEST INSTANCE : R12.1.3 
NOTES:
Enter the value of the Parameter Location_Id as a value which exists in  HZ_LOCATIONS table.
SCRIPT:

/* Formatted on 2011/03/20 12:59 (Formatter Plus v4.8.8) */
SET SERVEROUTPUT ON;

DECLARE
   p_location_id         NUMBER;
   p_created_by_module   VARCHAR2 (500);
   p_application_id      NUMBER;
   x_return_status       VARCHAR2 (2000);
   x_msg_count           NUMBER;
   x_msg_data            VARCHAR2 (2000);
   x_loc_id              NUMBER;
BEGIN
-- Setting the Context --
   mo_global.init ('AR');
   fnd_global.apps_initialize (user_id           => 1318,
                               resp_id           => 50559,
                               resp_appl_id      => 222
                              );
   mo_global.set_policy_context ('S', 204);
   fnd_global.set_nls_context ('AMERICAN');
-- Initializing the Mandatory API parameters
   p_location_id := 28215;
   p_created_by_module := 'BO_API';
   DBMS_OUTPUT.put_line
              ('Calling the API hz_tax_assignment_v2pub.create_loc_assignment');
   hz_tax_assignment_v2pub.create_loc_assignment
                      (
                       p_init_msg_list          => fnd_api.g_true,
                       p_location_id            => p_location_id,
                       p_lock_flag              => fnd_api.g_true,
                       p_created_by_module      => p_created_by_module,
                       p_application_id         => p_application_id,
                       x_return_status          => x_return_status,
                       x_msg_count              => x_msg_count,
                       x_msg_data               => x_msg_data,
                       x_loc_id                 => x_loc_id
                      );           

   IF x_return_status = fnd_api.g_ret_sts_success
   THEN
      COMMIT;
      DBMS_OUTPUT.put_line ('Assignment of Location is Successful ');
      DBMS_OUTPUT.put_line ('Output information ....');
      DBMS_OUTPUT.put_line ('Location Id       = ' || TO_CHAR (p_location_id));
      DBMS_OUTPUT.put_line (   'Created By Moudle = '
                            || SUBSTR (p_created_by_module, 1, 30)
                           );
   ELSE
      DBMS_OUTPUT.put_line ('Assignment of Location got failed:' || x_msg_data
                           );
      ROLLBACK;

      FOR i IN 1 .. x_msg_count
      LOOP
         x_msg_data := fnd_msg_pub.get (p_msg_index => i, p_encoded => 'F');
         DBMS_OUTPUT.put_line (i || ') ' || x_msg_data);
      END LOOP;
   END IF;

   DBMS_OUTPUT.put_line ('Completion of API');
END;
/

VERFICATION SCRIPT:
SELECT location_id,
       loc_id,
       org_id,
       created_by,
       created_by_module
  FROM hz_loc_assignments
 WHERE location_id = '28215'; 


No comments:

Post a Comment

Types of animations

Animation is a diverse and creative field with a variety of styles that artists and filmmakers use to bring their visions to life. Here are ...