1 PACKAGE OKS_RENEW_CONTRACT_PVT AUTHID CURRENT_USER AS
2 /* $Header: OKSRRENKS.pls 120.4.12000000.1 2007/01/16 22:11:49 appldev ship $*/
3
4
5 TYPE validation_rec_type IS RECORD(
6 code VARCHAR2(50),
7 message VARCHAR2(4000)
8 );
9 TYPE validation_tbl_type IS TABLE OF validation_rec_type INDEX BY BINARY_INTEGER;
10
11 G_PKG_NAME CONSTANT VARCHAR2(30) := 'OKS_RENEW_CONTRACT_PVT';
12 G_OKS_APP_NAME CONSTANT VARCHAR2(3) := 'OKS'; --all new nessages should use this
13
14 G_BULK_FETCH_LIMIT CONSTANT NUMBER := 1000;
15
16 G_VALIDATE_ALL CONSTANT VARCHAR2(1) := 'A';
17 G_VALIDATE_ERRORS CONSTANT VARCHAR2(1) := 'E';
18
19 G_VALID_STS_SUCCESS CONSTANT VARCHAR2(1) := 'S';
20 G_VALID_STS_WARNING CONSTANT VARCHAR2(1) := 'W';
21 G_VALID_STS_ERROR CONSTANT VARCHAR2(1) := 'E';
22
23
24 /*
25 From R12 onwards, this procedure should be used to renew service contracts.
26 It will be redesigned to do the following
27 1. Improve performance
28 2. Reduce dependence on OKC code
29 3. Incorporate functional design changes for R12
30 4. Comply with current Oracle Applications coding and logging standards
31 5. Ease of maintenance
32
33 Parameters
34 p_chr_id : id of the contract being renewed, mandatory
35 p_new_contract_number : contract number for the renewed contract, optional
36 p_new_contract_modifier : contract modifier for the renewed contract, optional
37 p_new_start_date : start date for the renewed contract, optional
38 p_new_end_date : end date for the renewed contract, optional
39 p_new_duration : duration for renewed contract, optional
40 p_new_uom_code : period for the renewed contract, optional
41 p_renewal_called_from_ui : 'Y' - called from UI, N - called from Events
42 x_chr_id : id of the renewed contract
43
44 Defaulting rules
45 1. If p_new_contract_number is not passed, uses the source contract_number
46 2. If p_new_contract_modifier is not passed, generated this as
47 fnd_profile.VALUE('OKC_CONTRACT_IDENTIFIER') || to_char(SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
48 3. If p_new_start_date is not passed, defaults to source contract end_date +1
49 4. If p_new_end_date is not passed, derived from p_new_duration/p_new_uom_code
50 and p_new_start_date. If p_new_duration/p_new_uom_code are also not passed
51 used the source contract duration/period
52 */
53
54 PROCEDURE RENEW_CONTRACT
55 (
56 p_api_version IN NUMBER,
57 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
58 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
59 p_chr_id IN NUMBER,
60 p_new_contract_number IN okc_k_headers_b.contract_number%TYPE,
61 p_new_contract_modifier IN okc_k_headers_b.contract_number_modifier%TYPE,
62 p_new_start_date IN DATE,
63 p_new_end_date IN DATE,
64 p_new_duration IN NUMBER,
65 p_new_uom_code IN MTL_UNITS_OF_MEASURE_TL.uom_code%TYPE,
66 p_renewal_called_from_ui IN VARCHAR2 DEFAULT 'Y',
67 x_chr_id OUT NOCOPY NUMBER,
68 x_msg_count OUT NOCOPY NUMBER,
69 x_msg_data OUT NOCOPY VARCHAR2,
70 x_return_status OUT NOCOPY VARCHAR2
71 );
72
73
74
75 /* R12 procedure that validates if a contract can be renewed
76 p_chr_id : contract id of the contract being renewed
77 p_date : start date of the renewal, if not passed defaults to end date + 1 of the source contract
78 p_validation_level : A - do all checks including warnings, E - do only error checks
79 x_rnrl_rec : returns the effective renewal rules for the contract
80 x_validation_status : S - Success (OK for renewal), W - Warnings (Ok for renewal)
81 E - Erros (Cannot be renewed)
82 x_validation_tbl : Validation error and warning messages
83 */
84 PROCEDURE VALIDATE_RENEWAL
85 (
86 p_api_version IN NUMBER DEFAULT 1,
87 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
88 x_return_status OUT NOCOPY VARCHAR2,
89 x_msg_count OUT NOCOPY NUMBER,
90 x_msg_data OUT NOCOPY VARCHAR2,
91 p_chr_id IN NUMBER,
92 p_date IN DATE,
93 p_validation_level IN VARCHAR2 DEFAULT G_VALIDATE_ALL,
94 x_rnrl_rec OUT NOCOPY OKS_RENEW_UTIL_PVT.rnrl_rec_type,
95 x_validation_status OUT NOCOPY VARCHAR2,
96 x_validation_tbl OUT NOCOPY validation_tbl_type
97 );
98
99 /*
100 Procedure for updating invoice_text col in table OKC_K_LINES_TL
101 with the current line start date and end date. Called during renewal,
102 after line dates are adjusted. Uses bulk calls to get and set the invoice text
103 Parameters
104 p_chr_id : id of the contract whose lines need to be updated
105 */
106 PROCEDURE UPDATE_INVOICE_TEXT
107 (
108 p_api_version IN NUMBER DEFAULT 1,
109 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
110 p_commit IN VARCHAR2 DEFAULT FND_API.G_FALSE,
111 x_return_status OUT NOCOPY VARCHAR2,
112 x_msg_count OUT NOCOPY NUMBER,
113 x_msg_data OUT NOCOPY VARCHAR2,
114 p_chr_id IN NUMBER
115 );
116
117 /*
118 Procedure for getting the user id and name of the contact on whose behalf the
119 contract workflow is launched during renewal
120 Parameters
121 p_chr_id : id of the contract for which the workflow is launched
122 p_hdesk_user_id : fnd user id of the help desk user id setup in GCD. Optional,
123 if not passed will be derived from GCD.
124
125 If no vendor/merchant contact bases on jtf object 'OKX_SALEPERS' can be found for the contract
126 header, the help desk user is used. This behaviour is from R12 onwards, prior to this if a
127 salesrep was not found, contract admin and then contract approver would be used.
128 */
129 PROCEDURE GET_USER_NAME
130 (
131 p_api_version IN NUMBER DEFAULT 1,
132 p_init_msg_list IN VARCHAR2 DEFAULT FND_API.G_FALSE,
133 x_return_status OUT NOCOPY VARCHAR2,
134 x_msg_count OUT NOCOPY NUMBER,
135 x_msg_data OUT NOCOPY VARCHAR2,
136 p_chr_id IN NUMBER,
137 p_hdesk_user_id IN NUMBER,
138 x_user_id OUT NOCOPY NUMBER,
139 x_user_name OUT NOCOPY VARCHAR2
140 );
141
142
143 END OKS_RENEW_CONTRACT_PVT;