Tuesday 5 February 2019

API to update the customer locations

API to update the customer locations:

Please find the below steps for update customer locations

/* Formatted on 2/1/2018 6:54:52 PM (QP5 v5.163.1008.3004) */
DECLARE
p_location_rec          HZ_LOCATION_V2PUB.LOCATION_REC_TYPE;
p_object_version_number NUMBER;
x_return_status         VARCHAR2(2000);
x_msg_count             NUMBER;
x_msg_data              VARCHAR2(2000);
l_loc_update_cnt         NUMBER := 0;


 CURSOR Location_update
   IS
   
      SELECT A.LOCATION_ID location_id,
                  A.ADDRESS1 address1,
                  A.ADDRESS2 address2,
                  A.ADDRESS3 address3,
                  A.POSTAL_CODE postal_code,
                  A.COUNTRY country ,
  A.CITY city,
  B.object_version_number object_version_number
   FROM APPS.IRON_ES_LOCATION_UPDATE_STG A,
             APPS.HZ_LOCATIONS B
   WHERE A.LOCATION_ID = B.LOCATION_ID
                                               
       
BEGIN

      fnd_client_info.set_org_context ('3106');

 FOR j IN Location_update
   LOOP

p_location_rec.location_id := j.LOCATION_ID;
p_location_rec.address1    := j.address1;
p_location_rec.address2    := ' ';
p_location_rec.address3 :=' ';
p_location_rec.postal_code :=trim(j.postal_code);
p_location_rec.country :=j.country;
p_location_rec.city := j.city;
p_object_version_number    := j.object_version_number;



hz_location_v2pub.update_location
            (
             p_init_msg_list           => FND_API.G_TRUE,
             p_location_rec            => p_location_rec,
             p_object_version_number   => p_object_version_number,
             x_return_status           => x_return_status,
             x_msg_count               => x_msg_count,
             x_msg_data                => x_msg_data
                  );

--END;
   COMMIT;
      l_loc_update_cnt := l_loc_update_cnt + 1;
   END LOOP;

   DBMS_OUTPUT.put_line ('Location update  Count ' || l_loc_update_cnt);
  -- DBMS_OUTPUT.put_line ('Location update  Count ' || j.address3);
   dbms_output.put_line(x_return_status);
 dbms_output.put_line(x_msg_data);
END;

No comments:

Post a Comment