Sample Code for API AR_CASH_RECEIPT_API.PUB by Pranay Tiwari

AR_CASH_RECEIPT_API.PUB  is the API to create receipts in Oracle , And below is the sample API code.


Mandatory Input Parameters for API

Currency
Amount
Receipt Method Id 
Customer Id 
Customer Site Use id 
Org Id 



Query to derive Receipt Method id 

         SELECT   receipt_method_id
           FROM   ar_receipt_methods
          WHERE   name = <Receipt Method Name >

Query to derive Cust Account and Site Use id 



SELECT   hca.cust_Account_id, hcsu.site_use_id
  FROM   HZ_PARTIES HP,
         HZ_CUST_ACCOUNTS HCA,
         HZ_CUST_ACCT_SITES_ALL HCAS,
         HZ_CUST_SITE_USES_ALL HCSU
 WHERE       HP.PARTY_ID = HCA.PARTY_ID
         AND HCA.CUST_ACCOUNT_ID = HCAS.CUST_ACCOUNT_ID
         AND HCAS.CUST_aCCT_SITE_ID = HCSU.CUST_aCCT_SITE_ID
         and hp.party_name=<Customer Name>
         AND hcsu.org_id = <ORG ID>


<Code Begins >
DECLARE
   l_return_status     VARCHAR2 (1);
   l_msg_count         NUMBER;
   l_msg_data          VARCHAR2 (240);
   l_count             NUMBER;
   l_cash_receipt_id   NUMBER;
   l_msg_data_out      VARCHAR2 (240);
   l_mesg              VARCHAR2 (240);
   p_count             NUMBER;
   p_user_id           NUMBER;
   p_resp_id           NUMBER;
   p_resp_appl_id      NUMBER;
   l_receipt_amt       varchar2 (240);
   l_receipt_num       varchar2 (240);
   l_cust_name         varchar2 (240);
BEGIN
   mo_global.SET_POLICY_CONTEXT ('S', 414);                     -- your org id
   mo_global.init ('AR');
   fnd_global.apps_initialize (1648, 20678, 222);
   ar_receipt_api_pub.create_cash (
      p_api_version            => 1.0,
      p_init_msg_list          => fnd_api.g_true,
      p_commit                 => fnd_api.g_true,
      p_validation_level       => fnd_api.g_valid_level_full,
      x_return_status          => l_return_status,
      x_msg_count              => l_msg_count,
      x_msg_data               => l_msg_data,
      p_currency_code          => 'USD',
      p_amount                 => 2000,
      p_receipt_number         => '9099',  --Receipt Number
      p_customer_id            => 17786,                     --cust account id
      p_customer_site_use_id   => 4960,                         ---site use id
      p_receipt_method_id      => 14023,  ---Receipt Method id
      P_ORG_ID                 => 414,
      p_cr_id                  => l_cash_receipt_id
   );
   DBMS_OUTPUT.put_line ('Status ' || l_return_status);
   DBMS_OUTPUT.put_line ('Cash Receipt id ' || l_cash_receipt_id);
   DBMS_OUTPUT.put_line ('Message count ' || l_msg_count);

   IF l_msg_count = 1
   THEN
      DBMS_OUTPUT.put_line ('l_msg_data ' || l_msg_data);
   ELSIF l_msg_count > 1
   THEN
      LOOP
         p_count := p_count + 1;
         l_msg_data := fnd_msg_pub.get (fnd_msg_pub.g_next, fnd_api.g_false);

         IF l_msg_data IS NULL
         THEN
            EXIT;
         END IF;

         DBMS_OUTPUT.put_line ('Message' || p_count || '.' || l_msg_data);
      END LOOP;
   END IF;
COMMIT;
END;
/

<Code Ends>

Comments

Popular posts from this blog

Sample HZ API's script to Create Contacts and Contact Points in Oracle

REST integration built-in OIC to read Large files with size more than 10MB