[Home] [Help]
PACKAGE BODY: APPS.OKC_RENEWAL_OUTCOME_PUB
Source
1 Package Body OKC_RENEWAL_OUTCOME_PUB AS
2 /* $Header: OKCPORWB.pls 120.0 2005/05/25 19:33:46 appldev noship $*/
3 l_debug VARCHAR2(1) := NVL(FND_PROFILE.VALUE('AFLOG_ENABLED'),'N');
4
5 PROCEDURE Renewal_Outcome( p_api_version IN NUMBER
6 ,p_init_msg_list IN VARCHAR2
7 ,x_return_status OUT NOCOPY VARCHAR2
8 ,x_msg_count OUT NOCOPY NUMBER
9 ,x_msg_data OUT NOCOPY VARCHAR2
10 --
11 -- ,x_contract_id OUT NOCOPY number
12 --
13 ,p_contract_id IN NUMBER
14 ,p_contract_number IN VARCHAR2
15 ,p_contract_version IN VARCHAR2
16 ,p_contract_modifier IN VARCHAR2
17 ,p_object_version_number IN NUMBER
18 ,p_new_contract_number IN VARCHAR2
19 ,p_new_contract_modifier IN VARCHAR2
20 ,p_start_date IN DATE
21 ,p_end_date IN DATE
22 ,p_orig_start_date IN DATE
23 ,p_orig_end_date IN DATE
24 ,p_uom_code IN VARCHAR2
25 ,p_duration IN NUMBER
26 ,p_context IN VARCHAR2
27 ,p_perpetual_flag IN VARCHAR2
28 --
29 ,p_do_commit IN VARCHAR2) IS
30
31 -- Variables
32 l_api_name CONSTANT VARCHAR2(30) := 'Renewal Outcome';
33 l_api_version CONSTANT NUMBER := 1.0;
34 l_return_status VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
35 l_msg_count NUMBER;
36 l_msg_data VARCHAR2(1000);
37 l_init_msg_list VARCHAR2(3) := 'F';
38 l_new_chr_id NUMBER;
39 -- l_renew_in_parameters_rec renew_in_parameters_rec;
40 l_renew_in_parameters_rec OKC_RENEW_PVT.renew_in_parameters_rec;
41
42 l_contract_id number;
43 l_contract_number okc_k_headers_v.contract_number%type;
44 l_contract_version varchar2(9);
45 l_contract_modifier okc_k_headers_v.contract_number_modifier%type;
46 l_object_version_number number;
47 l_new_contract_number okc_k_headers_v.contract_number%type;
48 l_new_contract_modifier okc_k_headers_v.contract_number_modifier%type;
49 l_start_date date;
50 l_end_date date;
51 l_new_end_date date;
52 l_orig_start_date date;
53 l_orig_end_date date;
54 l_uom_code okx_units_of_measure_v.uom_code%type;
55 l_duration number;
56 l_context VARCHAR2(30);
57 l_perpetual_flag VARCHAR2(1);
58
59
60 l_default_contract_number okc_k_headers_v.contract_number%type;
61
62 -- get new start date and end date
63 /* CURSOR c_new_start_date IS
64 SELECT contract_number, end_date + 1, end_date + 1 + (end_date - start_date)
65 FROM okc_k_headers_v
66 where id = p_contract_id;*/
67 CURSOR c_get_dates IS
68 SELECT contract_number, start_date, end_date
69 FROM okc_k_headers_v
70 where id = p_contract_id;
71
72 BEGIN
73
74
75 If p_contract_id = OKC_API.G_MISS_NUM Then
76 l_contract_id := Null;
77 Else
78 l_contract_id := p_contract_id;
79 End If;
80 If p_contract_number = OKC_API.G_MISS_CHAR Then
81 l_contract_number := Null;
82 Else
83 l_contract_number := p_contract_number;
84 End If;
85 If p_contract_version = OKC_API.G_MISS_CHAR Then
86 l_contract_version := Null;
87 Else
88 l_contract_version := p_contract_version;
89 End If;
90 If p_contract_modifier = OKC_API.G_MISS_CHAR Then
91 l_contract_modifier := Null;
92 Else
93 l_contract_modifier := p_contract_modifier;
94 End If;
95 If p_object_version_number = OKC_API.G_MISS_NUM Then
96 l_object_version_number := Null;
97 Else
98 l_object_version_number := p_object_version_number;
99 End If;
100 If p_new_contract_number = OKC_API.G_MISS_CHAR Then
101 l_new_contract_number := Null;
102 Else
103 l_new_contract_number := p_new_contract_number;
104 End If;
105 If p_new_contract_modifier = OKC_API.G_MISS_CHAR Then
106 l_new_contract_modifier := Null;
107 Else
108 l_new_contract_modifier := p_new_contract_modifier;
109 End If;
110 If p_start_date = OKC_API.G_MISS_DATE Then
111 l_start_date := Null;
112 Else
113 l_start_date := p_start_date;
114 End If;
115 If p_end_date = OKC_API.G_MISS_DATE Then
116 l_end_date := Null;
117 Else
118 l_end_date := p_end_date;
119 End If;
120 If p_orig_start_date = OKC_API.G_MISS_DATE Then
121 l_orig_start_date := Null;
122 Else
123 l_orig_start_date := p_orig_start_date;
124 End If;
125 If p_orig_end_date = OKC_API.G_MISS_DATE Then
126 l_orig_end_date := Null;
127 else
128 l_orig_end_date := p_orig_end_date;
129 End If;
130 If p_uom_code = OKC_API.G_MISS_CHAR Then
131 l_uom_code := Null;
132 else
133 l_uom_code := p_uom_code;
134 End If;
135 If p_duration = OKC_API.G_MISS_NUM Then
136 l_duration := Null;
137 else
138 l_duration := p_duration;
139 End If;
140 --
141 If p_context= OKC_API.G_MISS_CHAR Then
142 l_context:= Null;
143 ELSE
144 l_context := p_context;
145 End If;
146 If p_perpetual_flag= OKC_API.G_MISS_CHAR Then
147 l_perpetual_flag:= Null;
148 ELSE
149 l_perpetual_flag:=p_perpetual_flag;
150 End If;
151
152 -- default contract number
153 l_new_contract_modifier := fnd_profile.value('OKC_CONTRACT_IDENTIFIER')|| sysdate || To_char(sysdate,' HH24:MI:SS');
154
155 -- get start date (and end date if required) of new contract (i.e. end date of old contract + 1)
156 OPEN c_get_dates;
157 FETCH c_get_dates INTO l_default_contract_number, l_orig_start_date, l_orig_end_date;
158 CLOSE c_get_dates;
159
160 IF l_new_contract_number IS NULL THEN
161 l_new_contract_number := l_default_contract_number;
162 END IF;
163 l_start_date := l_orig_end_date + 1;
164 IF l_duration IS NULL OR l_uom_code IS NULL THEN
165 -- get new duration and period using the orig start date and end date
166 okc_time_util_pub.get_duration
167 (l_orig_start_date,
168 l_orig_end_date,
169 l_duration,
170 l_uom_code,
171 l_return_status
172 );
173
174 l_end_date := OKC_TIME_UTIL_PUB.get_enddate(l_start_date,
175 l_uom_code,
176 l_duration
177 );
178
179 END IF;
180
181 -- assign params to each field in rec
182 l_renew_in_parameters_rec.p_contract_id := l_contract_id;
183 l_renew_in_parameters_rec.p_contract_number := l_contract_number;
184 l_renew_in_parameters_rec.p_contract_version := l_contract_version;
185 l_renew_in_parameters_rec.p_contract_modifier := l_contract_modifier;
186 l_renew_in_parameters_rec.p_object_version_number := l_object_version_number;
187 l_renew_in_parameters_rec.p_new_contract_number := l_new_contract_number;
188 l_renew_in_parameters_rec.p_new_contract_modifier := l_new_contract_modifier;
189 l_renew_in_parameters_rec.p_start_date := l_start_date;
190 l_renew_in_parameters_rec.p_end_date := l_end_date;
191 l_renew_in_parameters_rec.p_orig_start_date := l_orig_start_date;
192 l_renew_in_parameters_rec.p_orig_end_date := l_orig_end_date;
193 l_renew_in_parameters_rec.p_uom_code := l_uom_code;
194 l_renew_in_parameters_rec.p_duration := l_duration;
195 l_renew_in_parameters_rec.p_context := l_context;
196 l_renew_in_parameters_rec.p_perpetual_flag := l_perpetual_flag;
197
198 -- call okc_renew_pub.pre_renew.
199 OKC_RENEW_PUB.PRE_RENEW( p_api_version => l_api_version
200 ,p_init_msg_list => OKC_API.G_TRUE
201 ,x_return_status => l_return_status
202 ,x_msg_count => l_msg_count
203 ,x_msg_data => l_msg_data
204 ,x_contract_id => l_new_chr_id
205 ,p_renew_in_parameters_rec => l_renew_in_parameters_rec
206 ,p_renewal_called_from_ui => 'N'
207 ,p_do_commit => OKC_API.G_TRUE );
208
209 x_msg_count := l_msg_count;
210 x_return_status := l_return_status;
211 x_msg_data := l_msg_data;
212 -- x_contract_id := l_new_chr_id;
213
214 IF x_return_status = okc_api.g_ret_sts_success THEN
215 OKC_API.set_message(p_app_name => 'OKC',
216 p_msg_name => 'OKC_OC_SUCCESS',
217 p_token1 => 'PROCESS',
218 p_token1_value => 'Renewal');
219 ELSE
220 OKC_API.SET_MESSAGE(p_app_name => 'OKC',
221 p_msg_name => 'OKC_OC_FAILED',
222 p_token1 => 'PROCESS',
223 p_token1_value => 'Renewal',
224 p_token2 => 'MESSAGE1',
225 p_token2_value => 'Error Stack is :',
226 p_token3 => 'MESSAGE2',
227 p_token3_value => l_msg_data);
228 END IF;
229
230
231 EXCEPTION
232 when others then
233 OKC_API.SET_MESSAGE(p_app_name => 'OKC',
234 p_msg_name => 'OKC_OC_FAILED',
235 p_token1 => 'PROCESS',
236 p_token1_value => 'Renewal',
237 p_token2 => 'MESSAGE1',
238 p_token2_value => 'Error Stack is :',
239 p_token3 => 'MESSAGE2',
240 p_token3_value => l_msg_data);
241 x_return_status := l_return_status;
242
243 END RENEWAL_OUTCOME;
244
245 END OKC_RENEWAL_OUTCOME_PUB;