API to add a Claim Line to already existing Claim

SET serveroutput ON;
 
DECLARE
   l_return_status           VARCHAR2 (1);
   l_msg_count               NUMBER;
   l_msg_data                VARCHAR2 (20000);
   l_resp_name               VARCHAR2 (100) := 'Oracle Trade Management User';
   l_user_name               VARCHAR2 (100) := 'SYSADMIN';
   l_claim_number   CONSTANT VARCHAR2 (25)  := 'CLA10107';
   l_appl_id                 NUMBER;
   l_resp_id                 NUMBER;
   l_user_id                 NUMBER;
   l_org_id                  NUMBER;
   l_line_counter            NUMBER         := 1;
   l_claim_id                NUMBER;
   l_api_version    CONSTANT NUMBER         := 1.0;
   l_error_index             NUMBER;
   l_claim_line_pub_tbl      ozf_claim_pub.claim_line_tbl_type;
 
   CURSOR csr_claim_id (cv_claim_number IN VARCHAR2)
   IS
      SELECT claim_id, org_id
        FROM ozf_claims_all
       WHERE claim_number = cv_claim_number;
BEGIN
------------------------------------------
-- Initialization
------------------------------------------
   OPEN csr_claim_id (l_claim_number);
 
   FETCH csr_claim_id
    INTO l_claim_id, l_org_id;
 
   CLOSE csr_claim_id;
 
   SELECT application_id, responsibility_id
     INTO l_appl_id, l_resp_id
     FROM fnd_responsibility_vl
    WHERE responsibility_name = l_resp_name;
 
   SELECT user_id
     INTO l_user_id
     FROM fnd_user
    WHERE user_name = l_user_name;
 
   fnd_global.apps_initialize (l_user_id, l_resp_id, l_appl_id);
   mo_global.init ('OZF');
   mo_global.set_policy_context ('S', l_org_id);
   DBMS_OUTPUT.put_line ('==================================');
   DBMS_OUTPUT.put_line ('INITIALIZATION');
   DBMS_OUTPUT.put_line ('USER : ' || l_user_name || ' (' || l_user_id || ')');
   DBMS_OUTPUT.put_line ('ORG : ' || SUBSTR (USERENV ('CLIENT_INFO'), 1, 10));
   DBMS_OUTPUT.put_line ('==================================');
   fnd_msg_pub.g_msg_level_threshold := 1;
   l_claim_line_pub_tbl (1).claim_id := l_claim_id;
   l_claim_line_pub_tbl (1).claim_currency_amount := 7;
 
   l_claim_line_pub_tbl (2).claim_id := l_claim_id;
   l_claim_line_pub_tbl (2).claim_currency_amount := 3;
   ozf_claim_pub.create_claim_line_tbl
                                    (p_api_version           => l_api_version,
                                     p_init_msg_list         => fnd_api.g_false,
                                     p_commit                => fnd_api.g_false,
                                     p_validation_level      => p_validation_level,
                                     x_return_status         => l_return_status,
                                     x_msg_data              => l_msg_data,
                                     x_msg_count             => l_msg_count,
                                     p_claim_line_tbl        => l_claim_line_pub_tbl,
                                     x_error_index           => l_error_index
                                    );
   DBMS_OUTPUT.put_line ('Success ? ' || l_return_status);
 
   IF l_return_status = fnd_api.g_ret_sts_success
   THEN
      DBMS_OUTPUT.put_line ('----- Update of Claim sucessfull-----');
      DBMS_OUTPUT.put_line ('----- Line -----');
   END IF;
 
   fnd_msg_pub.count_and_get (p_encoded      => fnd_api.g_false,
                              p_count        => l_msg_count,
                              p_data         => l_msg_data
                             );
 
   FOR i IN 1 .. l_msg_count
   LOOP
      DBMS_OUTPUT.put_line (SUBSTR (fnd_msg_pub.get (p_msg_index      => i,
                                                     p_encoded        => 'F'
                                                    ),
                                    1,
                                    254
                                   )
                           );
   END LOOP;
 
   DBMS_OUTPUT.put_line ('========= END =========');
END;
/
 
COMMIT ;