PL/SQL API to Cancel Dispute on an Invoice Transaction

Oracle has provided an API IEX_DISPUTE_PUB.CANCEL_DISPUTE which is part of Advanced Collections to cancel a dispute on an Invoice Transaction. Below is the sample API script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
SET serveroutput ON;
---
---
 
DECLARE
   lv_return_status_txt   VARCHAR2 (1000);
   lv_msg_count_num       NUMBER;
   lv_msg_count_txt       VARCHAR2 (10000);
   lv_cm_request_id       VARCHAR2 (1000);
   lv_index_num           NUMBER;
   lv_err_msg_stack_txt   VARCHAR2 (4000);
   l_user_id              NUMBER;
   l_responsibility_id    NUMBER           := 22941;     -- collections agent
   l_customer_trx_id      NUMBER           := 468415;
   l_org_id               NUMBER;
 
   CURSOR c_user_id
   IS
      SELECT user_id
        FROM fnd_user
       WHERE user_name = UPPER ('CHAUDHARYN');
 
   CURSOR c_org_id
   IS
      SELECT org_id
        FROM ra_customer_trx_all
       WHERE customer_trx_id = l_customer_trx_id;
BEGIN
   OPEN c_user_id;
 
   FETCH c_user_id
    INTO l_user_id;
 
   CLOSE c_user_id;
 
   OPEN c_org_id;
 
   FETCH c_org_id
    INTO l_org_id;
 
   CLOSE c_org_id;
 
   IF l_user_id IS NULL
   THEN
      DBMS_OUTPUT.put_line (' Please enter correct User Name ');
   END IF;
 
   IF l_org_id IS NULL
   THEN
      DBMS_OUTPUT.put_line ('Please enter correct Customer Trx Id ');
   END IF;
 
   mo_global.set_policy_context ('S', l_org_id);
   fnd_global.apps_initialize (l_user_id, l_responsibility_id, 695);
   arp_standard.enable_debug;
   iex_dispute_pub.cancel_dispute
                                (p_api_version          => 1.0,
                                 p_commit               => 'T',
                                 p_dispute_id           => 9006, --from RA_CM_REQUESTS_ALL.request_id
                                 p_cancel_comments      => 'XX Cancelled from API',
                                 x_return_status        => lv_return_status_txt,
                                 x_msg_count            => lv_msg_count_num,
                                 x_msg_data             => lv_msg_count_txt
                                );
   COMMIT;
 
   IF lv_return_status_txt = 'S'
   THEN
      DBMS_OUTPUT.put_line (' Dispute Cancelled successfully ');
   END IF;
 
   DBMS_OUTPUT.put_line ('x_return_status : ' || lv_return_status_txt);
 
   IF lv_return_status_txt != 'S'
   THEN
      DBMS_OUTPUT.put_line (   'Error: '
                            || lv_return_status_txt
                            || '; '
                            || lv_msg_count_txt
                           );
 
      FOR lv_index_num IN 1 .. lv_msg_count_num
      LOOP
         lv_err_msg_stack_txt :=
              fnd_msg_pub.get (p_msg_index      => lv_index_num,
                               p_encoded        => 'F');
         DBMS_OUTPUT.put_line (lv_err_msg_stack_txt);
      END LOOP;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Exception raised => ' || SQLERRM);
END;
/