Wednesday 7 June 2023

API Script to Terminate Service Contract/Line/Subline in Oracle Apps

oks_terminate_contract_pub.Terminate_Contract


set serveroutput on size 100000;

DECLARE
   l_return_status   VARCHAR2 (100);
   l_date_term       DATE;
   L_MSG_DATA        VARCHAR2 (1000);
   l_msg_count       NUMBER;
   l_msg_index_out   NUMBER;
   l_user_id        NUMBER;
   l_resp_id        NUMBER;
   l_resp_appl_id   NUMBER;
BEGIN
/*Note:-
P_contract_id            --> Contract Header Id
Line Id                     --> Contract Line Id
P_subline_id              --> Contract Subline Id
P_termination_date    --> Termination Date
p_fullcredit_yn          --> Indicates if full credit has to be given during termination and default value is ‘N’
p_suppress_credit_yn --> Indicates if credit has to be suppressed during termination and default value is ‘N’
p_term_reason_code  --> Termination Reason
p_override_amount    --> Override Amount*/
   BEGIN
    SELECT user_id
      INTO l_user_id
      FROM fnd_user
     WHERE user_name = 'TEST_USER';    
   END;
  
   BEGIN
    SELECT responsibility_id, application_id
      INTO l_resp_id, l_resp_appl_id
      FROM fnd_responsibility_tl
     WHERE responsibility_name = 'NUAN NDI Ireland Service Contracts Manager'
       and application_id = 515 ;  --Service Contracts
   END;
  
   fnd_global.apps_initialize (user_id        => l_user_id,
                               resp_id        => l_resp_id,
                               resp_appl_id   => l_resp_appl_id
                              );
                             
   okc_context.set_okc_org_context (p_chr_id => 1953781);
  
   oks_terminate_contract_pub.Terminate_Contract(
      p_contract_id          => 1953781,
      p_line_id              => NULL,
      p_subline_id           => NULL,
      P_Termination_Date     => TO_DATE ('17-OCT-2022'),
      p_fullcredit_yn        => 'N', --Indicates if full credit has to be given during termination and default value is ‘N’
      p_suppress_credit_yn   => 'N', --Indicates if credit has to be suppressed during termination and default value is ‘N’
      p_term_reason_code     => 'RMA',
      p_override_amount      => NULL,
      x_return_status        => l_return_status);
  
   DBMS_OUTPUT.put_line ('l_return_status - ' || l_return_status);
   IF l_return_status = 'S'
   THEN
      COMMIT;
   END IF;
  
   IF l_return_status <> 'S'
   THEN
      FOR i IN 1 .. fnd_msg_pub.count_msg
      LOOP
         fnd_msg_pub.get (p_msg_index       => i,
                          p_encoded         => 'T',
                          p_data            => l_msg_data,
                          p_msg_index_out   => l_msg_index_out);
         fnd_message.set_encoded (l_msg_data);
         l_msg_data := fnd_message.get;
         DBMS_OUTPUT.put_line (l_msg_data);
      END LOOP;
   END IF;
END;
/

No comments:

Post a Comment