DBA Data[Home] [Help]

PACKAGE BODY: APPS.HZ_ORGANIZATION_INFO_V2PVT

Source


1 PACKAGE BODY HZ_ORGANIZATION_INFO_V2PVT AS
2 /*$Header: ARHORI1B.pls 120.2 2005/06/16 21:12:53 jhuang noship $ */
3 
4 --------------------------------------
5 -- declaration of private global varibles
6 --------------------------------------
7 
8 DEFAULT_CREATED_BY_MODULE     CONSTANT VARCHAR2(10) := 'TCA_V1_API';
9 x_msg_count                            NUMBER;
10 x_msg_data                             VARCHAR2(2000);
11 
12 --------------------------------------
13 -- private procedures and functions
14 --------------------------------------
15 
16 PROCEDURE v2_financial_report_pre (
17     p_create_update_flag                    IN     VARCHAR2,
18     p_financial_report_rec                  IN     HZ_ORG_INFO_PUB.FINANCIAL_REPORTS_REC_TYPE,
19     x_financial_report_rec                  OUT     NOCOPY HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_REPORT_REC_TYPE
20 ) IS
21 
22 BEGIN
23 
24         IF p_financial_report_rec.financial_report_id IS NULL THEN
25             x_financial_report_rec.financial_report_id := FND_API.G_MISS_NUM;
26         ELSIF p_financial_report_rec.financial_report_id <> FND_API.G_MISS_NUM THEN
27             x_financial_report_rec.financial_report_id := p_financial_report_rec.financial_report_id;
28         END IF;
29 
30         IF p_financial_report_rec.party_id IS NULL THEN
31             x_financial_report_rec.party_id := FND_API.G_MISS_NUM;
32         ELSIF p_financial_report_rec.party_id <> FND_API.G_MISS_NUM THEN
33             x_financial_report_rec.party_id := p_financial_report_rec.party_id;
34         END IF;
35 
36         IF p_financial_report_rec.type_of_financial_report IS NULL THEN
37             x_financial_report_rec.type_of_financial_report := FND_API.G_MISS_CHAR;
38         ELSIF p_financial_report_rec.type_of_financial_report <> FND_API.G_MISS_CHAR THEN
39             x_financial_report_rec.type_of_financial_report := p_financial_report_rec.type_of_financial_report;
40         END IF;
41 
42         IF p_financial_report_rec.document_reference IS NULL THEN
43             x_financial_report_rec.document_reference := FND_API.G_MISS_CHAR;
44         ELSIF p_financial_report_rec.document_reference <> FND_API.G_MISS_CHAR THEN
45             x_financial_report_rec.document_reference := p_financial_report_rec.document_reference;
46         END IF;
47 
48         IF p_financial_report_rec.date_report_issued IS NULL THEN
49             x_financial_report_rec.date_report_issued := FND_API.G_MISS_DATE;
50         ELSIF p_financial_report_rec.date_report_issued <> FND_API.G_MISS_DATE THEN
51             x_financial_report_rec.date_report_issued := p_financial_report_rec.date_report_issued;
52         END IF;
53 
54         IF p_financial_report_rec.issued_period IS NULL THEN
55             x_financial_report_rec.issued_period := FND_API.G_MISS_CHAR;
56         ELSIF p_financial_report_rec.issued_period <> FND_API.G_MISS_CHAR THEN
57             x_financial_report_rec.issued_period := p_financial_report_rec.issued_period;
58         END IF;
59 
60         IF p_financial_report_rec.report_start_date IS NULL THEN
61             x_financial_report_rec.report_start_date := FND_API.G_MISS_DATE;
62         ELSIF p_financial_report_rec.report_start_date <> FND_API.G_MISS_DATE THEN
63             x_financial_report_rec.report_start_date := p_financial_report_rec.report_start_date;
64         END IF;
65 
66         IF p_financial_report_rec.report_end_date IS NULL THEN
67             x_financial_report_rec.report_end_date := FND_API.G_MISS_DATE;
68         ELSIF p_financial_report_rec.report_end_date <> FND_API.G_MISS_DATE THEN
69             x_financial_report_rec.report_end_date := p_financial_report_rec.report_end_date;
70         END IF;
71 
72         IF p_financial_report_rec.actual_content_source IS NULL THEN
73             x_financial_report_rec.actual_content_source := FND_API.G_MISS_CHAR;
74         ELSIF p_financial_report_rec.actual_content_source <> FND_API.G_MISS_CHAR THEN
75             x_financial_report_rec.actual_content_source := p_financial_report_rec.actual_content_source;
76         END IF;
77 
78         IF p_financial_report_rec.requiring_authority IS NULL THEN
79             x_financial_report_rec.requiring_authority := FND_API.G_MISS_CHAR;
80         ELSIF p_financial_report_rec.requiring_authority <> FND_API.G_MISS_CHAR THEN
81             x_financial_report_rec.requiring_authority := p_financial_report_rec.requiring_authority;
82         END IF;
83 
84         IF p_financial_report_rec.audit_ind IS NULL THEN
85             x_financial_report_rec.audit_ind := FND_API.G_MISS_CHAR;
86         ELSIF p_financial_report_rec.audit_ind <> FND_API.G_MISS_CHAR THEN
87             x_financial_report_rec.audit_ind := p_financial_report_rec.audit_ind;
88         END IF;
89 
90         IF p_financial_report_rec.consolidated_ind IS NULL THEN
91             x_financial_report_rec.consolidated_ind := FND_API.G_MISS_CHAR;
92         ELSIF p_financial_report_rec.consolidated_ind <> FND_API.G_MISS_CHAR THEN
93             x_financial_report_rec.consolidated_ind := p_financial_report_rec.consolidated_ind;
94         END IF;
95 
96         IF p_financial_report_rec.estimated_ind IS NULL THEN
97             x_financial_report_rec.estimated_ind := FND_API.G_MISS_CHAR;
98         ELSIF p_financial_report_rec.estimated_ind <> FND_API.G_MISS_CHAR THEN
99             x_financial_report_rec.estimated_ind := p_financial_report_rec.estimated_ind;
100         END IF;
101 
102         IF p_financial_report_rec.fiscal_ind IS NULL THEN
103             x_financial_report_rec.fiscal_ind := FND_API.G_MISS_CHAR;
104         ELSIF p_financial_report_rec.fiscal_ind <> FND_API.G_MISS_CHAR THEN
105             x_financial_report_rec.fiscal_ind := p_financial_report_rec.fiscal_ind;
106         END IF;
107 
108         --Bug 2940399: Added FINAL_IND column in financial_report_rec_type. Hence added code
109         --to copy from v1 record.
110         IF p_financial_report_rec.final_ind IS NULL THEN
111             x_financial_report_rec.final_ind := FND_API.G_MISS_CHAR;
112         ELSIF p_financial_report_rec.final_ind <> FND_API.G_MISS_CHAR THEN
113             x_financial_report_rec.final_ind := p_financial_report_rec.final_ind;
114         END IF;
115 
116         IF p_financial_report_rec.forecast_ind IS NULL THEN
117             x_financial_report_rec.forecast_ind := FND_API.G_MISS_CHAR;
118         ELSIF p_financial_report_rec.forecast_ind <> FND_API.G_MISS_CHAR THEN
119             x_financial_report_rec.forecast_ind := p_financial_report_rec.forecast_ind;
120         END IF;
121 
122         IF p_financial_report_rec.opening_ind IS NULL THEN
123             x_financial_report_rec.opening_ind := FND_API.G_MISS_CHAR;
124         ELSIF p_financial_report_rec.opening_ind <> FND_API.G_MISS_CHAR THEN
125             x_financial_report_rec.opening_ind := p_financial_report_rec.opening_ind;
126         END IF;
127 
128         IF p_financial_report_rec.proforma_ind IS NULL THEN
129             x_financial_report_rec.proforma_ind := FND_API.G_MISS_CHAR;
130         ELSIF p_financial_report_rec.proforma_ind <> FND_API.G_MISS_CHAR THEN
131             x_financial_report_rec.proforma_ind := p_financial_report_rec.proforma_ind;
132         END IF;
133 
134         IF p_financial_report_rec.qualified_ind IS NULL THEN
135             x_financial_report_rec.qualified_ind := FND_API.G_MISS_CHAR;
136         ELSIF p_financial_report_rec.qualified_ind <> FND_API.G_MISS_CHAR THEN
137             x_financial_report_rec.qualified_ind := p_financial_report_rec.qualified_ind;
138         END IF;
139 
140         IF p_financial_report_rec.restated_ind IS NULL THEN
141             x_financial_report_rec.restated_ind := FND_API.G_MISS_CHAR;
142         ELSIF p_financial_report_rec.restated_ind <> FND_API.G_MISS_CHAR THEN
143             x_financial_report_rec.restated_ind := p_financial_report_rec.restated_ind;
144         END IF;
145 
146         IF p_financial_report_rec.signed_by_principals_ind IS NULL THEN
147             x_financial_report_rec.signed_by_principals_ind := FND_API.G_MISS_CHAR;
148         ELSIF p_financial_report_rec.signed_by_principals_ind <> FND_API.G_MISS_CHAR THEN
149             x_financial_report_rec.signed_by_principals_ind := p_financial_report_rec.signed_by_principals_ind;
150         END IF;
151 
152         IF p_financial_report_rec.trial_balance_ind IS NULL THEN
153             x_financial_report_rec.trial_balance_ind := FND_API.G_MISS_CHAR;
154         ELSIF p_financial_report_rec.trial_balance_ind <> FND_API.G_MISS_CHAR THEN
155             x_financial_report_rec.trial_balance_ind := p_financial_report_rec.trial_balance_ind;
156         END IF;
157 
158         IF p_financial_report_rec.unbalanced_ind IS NULL THEN
159             x_financial_report_rec.unbalanced_ind := FND_API.G_MISS_CHAR;
160         ELSIF p_financial_report_rec.unbalanced_ind <> FND_API.G_MISS_CHAR THEN
161             x_financial_report_rec.unbalanced_ind := p_financial_report_rec.unbalanced_ind;
162         END IF;
163 
164         IF p_financial_report_rec.status IS NULL THEN
165             x_financial_report_rec.status := FND_API.G_MISS_CHAR;
166         ELSIF p_financial_report_rec.status <> FND_API.G_MISS_CHAR THEN
167             x_financial_report_rec.status := p_financial_report_rec.status;
168         END IF;
169 
170         IF p_create_update_flag = 'C' THEN
171             x_financial_report_rec.created_by_module := DEFAULT_CREATED_BY_MODULE;
172         END IF;
173 
174 END v2_financial_report_pre;
175 
176 --------------------------------------------------
177 -- public procedures and functions
178 --------------------------------------------------
179 
180 PROCEDURE v2_create_financial_report (
181     p_financial_report_rec        IN     HZ_ORG_INFO_PUB.FINANCIAL_REPORTS_REC_TYPE,
182     x_return_status               IN OUT  NOCOPY VARCHAR2,
183     x_financial_report_id            OUT  NOCOPY NUMBER
184 ) IS
185 
186     l_financial_report_rec         HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_REPORT_REC_TYPE;
187 
188 BEGIN
189 
190     -- pre-process v1 and v2 record.
191     v2_financial_report_pre (
192         'C',
193         p_financial_report_rec,
194         l_financial_report_rec );
195     -- call V2 API.
196 
197     HZ_ORGANIZATION_INFO_V2PUB.create_financial_report (
198         p_financial_report_rec             => l_financial_report_rec,
199         x_financial_report_id              => x_financial_report_id,
200         x_return_status                    => x_return_status,
201         x_msg_count                        => x_msg_count,
202         x_msg_data                         => x_msg_data );
203 
204 END v2_create_financial_report;
205 
206 
207 PROCEDURE v2_update_financial_report (
208     p_financial_report_rec        IN     HZ_ORG_INFO_PUB.FINANCIAL_REPORTS_REC_TYPE,
209     p_last_update_date            IN OUT  NOCOPY DATE,
210     x_return_status               IN OUT  NOCOPY VARCHAR2
211 ) IS
212 
213     l_financial_report_rec        HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_REPORT_REC_TYPE;
214     l_last_update_date            DATE;
215     l_rowid                       ROWID := NULL;
216     l_object_version_number       NUMBER;
217 
218 BEGIN
219 
220     -- check required fields:
221     IF p_last_update_date IS NULL OR
222        p_last_update_date = FND_API.G_MISS_DATE
223     THEN
224        FND_MESSAGE.SET_NAME('AR', 'HZ_API_MISSING_COLUMN');
225        FND_MESSAGE.SET_TOKEN('COLUMN', 'p_last_update_date');
226        FND_MSG_PUB.ADD;
227        RAISE FND_API.G_EXC_ERROR;
228     END IF;
229 
230     -- get object_version_number
231     BEGIN
232         SELECT ROWID, OBJECT_VERSION_NUMBER, LAST_UPDATE_DATE
233         INTO l_rowid, l_object_version_number, l_last_update_date
234         FROM HZ_FINANCIAL_REPORTS
235         WHERE FINANCIAL_REPORT_ID  = p_financial_report_rec.financial_report_id;
236 
237         IF TO_CHAR( p_last_update_date, 'DD-MON-YYYY HH:MI:SS') <>
238            TO_CHAR( l_last_update_date, 'DD-MON-YYYY HH:MI:SS')
239         THEN
240             FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_RECORD_CHANGED' );
241             FND_MESSAGE.SET_TOKEN( 'TABLE', 'hz_financial_reports' );
242             FND_MSG_PUB.ADD;
243             RAISE FND_API.G_EXC_ERROR;
244         END IF;
245     EXCEPTION
246         WHEN NO_DATA_FOUND THEN
247             FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_NO_RECORD' );
248             FND_MESSAGE.SET_TOKEN( 'RECORD', 'financial reports' );
249             FND_MESSAGE.SET_TOKEN( 'VALUE',
250                 NVL( TO_CHAR( p_financial_report_rec.financial_report_id ), 'null' ) );
251             FND_MSG_PUB.ADD;
252             RAISE FND_API.G_EXC_ERROR;
253     END;
254 
255     -- pre-process v1 and v2 record.
256     v2_financial_report_pre (
257         'U',
258         p_financial_report_rec,
259         l_financial_report_rec );
260 
261     -- call V2 API.
262     HZ_ORGANIZATION_INFO_V2PUB.update_financial_report (
263         p_financial_report_rec              => l_financial_report_rec,
264         p_object_version_number             => l_object_version_number,
265         x_return_status                     => x_return_status,
266         x_msg_count                         => x_msg_count,
267         x_msg_data                          => x_msg_data
268     );
269 
270 END v2_update_financial_report;
271 
272 PROCEDURE v2_financial_number_pre (
273     p_create_update_flag                    IN     VARCHAR2,
274     p_financial_number_rec                  IN     HZ_ORG_INFO_PUB.FINANCIAL_NUMBERS_REC_TYPE,
275     x_financial_number_rec                  OUT     NOCOPY HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_NUMBER_REC_TYPE
276 ) IS
277 
278 BEGIN
279 
280         IF p_financial_number_rec.financial_number_id IS NULL THEN
281             x_financial_number_rec.financial_number_id := FND_API.G_MISS_NUM;
282         ELSIF p_financial_number_rec.financial_number_id <> FND_API.G_MISS_NUM THEN
283             x_financial_number_rec.financial_number_id := p_financial_number_rec.financial_number_id;
284         END IF;
285 
286         IF p_financial_number_rec.financial_report_id IS NULL THEN
287             x_financial_number_rec.financial_report_id := FND_API.G_MISS_NUM;
291 
288         ELSIF p_financial_number_rec.financial_report_id <> FND_API.G_MISS_NUM THEN
289             x_financial_number_rec.financial_report_id := p_financial_number_rec.financial_report_id;
290         END IF;
292         IF p_financial_number_rec.financial_number IS NULL THEN
293             x_financial_number_rec.financial_number := FND_API.G_MISS_NUM;
294         ELSIF p_financial_number_rec.financial_number <> FND_API.G_MISS_NUM THEN
295             x_financial_number_rec.financial_number := p_financial_number_rec.financial_number;
296         END IF;
297 
298         IF p_financial_number_rec.financial_number_name IS NULL THEN
299             x_financial_number_rec.financial_number_name := FND_API.G_MISS_CHAR;
300         ELSIF p_financial_number_rec.financial_number_name <> FND_API.G_MISS_CHAR THEN
301             x_financial_number_rec.financial_number_name := p_financial_number_rec.financial_number_name;
302         END IF;
303 
304         IF p_financial_number_rec.financial_units_applied IS NULL THEN
305             x_financial_number_rec.financial_units_applied := FND_API.G_MISS_NUM;
306         ELSIF p_financial_number_rec.financial_units_applied <> FND_API.G_MISS_NUM THEN
307             x_financial_number_rec.financial_units_applied := p_financial_number_rec.financial_units_applied;
308         END IF;
309 
310         IF p_financial_number_rec.financial_number_currency IS NULL THEN
311             x_financial_number_rec.financial_number_currency := FND_API.G_MISS_CHAR;
312         ELSIF p_financial_number_rec.financial_number_currency <> FND_API.G_MISS_CHAR THEN
313             x_financial_number_rec.financial_number_currency := p_financial_number_rec.financial_number_currency;
314         END IF;
315 
316         IF p_financial_number_rec.projected_actual_flag IS NULL THEN
317             x_financial_number_rec.projected_actual_flag := FND_API.G_MISS_CHAR;
318         ELSIF p_financial_number_rec.projected_actual_flag <> FND_API.G_MISS_CHAR THEN
319             x_financial_number_rec.projected_actual_flag := p_financial_number_rec.projected_actual_flag;
320         END IF;
321 
322         IF p_financial_number_rec.content_source_type IS NULL THEN
323             x_financial_number_rec.content_source_type := FND_API.G_MISS_CHAR;
324         ELSIF p_financial_number_rec.content_source_type <> FND_API.G_MISS_CHAR THEN
325             x_financial_number_rec.content_source_type := p_financial_number_rec.content_source_type;
326         END IF;
327 
328         IF p_financial_number_rec.status IS NULL THEN
329             x_financial_number_rec.status := FND_API.G_MISS_CHAR;
330         ELSIF p_financial_number_rec.status <> FND_API.G_MISS_CHAR THEN
331             x_financial_number_rec.status := p_financial_number_rec.status;
332         END IF;
333 
334         IF p_create_update_flag = 'C' THEN
335             x_financial_number_rec.created_by_module := DEFAULT_CREATED_BY_MODULE;
336         END IF;
337 
338 END v2_financial_number_pre;
339 
340 --------------------------------------------------
341 -- public procedures and functions
342 --------------------------------------------------
343 
344 PROCEDURE v2_create_financial_number (
345     p_financial_number_rec        IN     HZ_ORG_INFO_PUB.FINANCIAL_NUMBERS_REC_TYPE,
346     x_return_status               IN OUT  NOCOPY VARCHAR2,
347     x_financial_number_id            OUT  NOCOPY NUMBER
348 ) IS
349 
350     l_financial_number_rec         HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_NUMBER_REC_TYPE;
351 
352 BEGIN
353 
354     -- pre-process v1 and v2 record.
355     v2_financial_number_pre (
356         'C',
357         p_financial_number_rec,
358         l_financial_number_rec );
359 
360     -- call V2 API.
361     HZ_ORGANIZATION_INFO_V2PUB.create_financial_number (
362         p_financial_number_rec             => l_financial_number_rec,
363         x_financial_number_id              => x_financial_number_id,
364         x_return_status                    => x_return_status,
365         x_msg_count                        => x_msg_count,
366         x_msg_data                         => x_msg_data );
367 
368 END v2_create_financial_number;
369 
370 
371 PROCEDURE v2_update_financial_number (
372     p_financial_number_rec        IN     HZ_ORG_INFO_PUB.FINANCIAL_NUMBERS_REC_TYPE,
373     p_last_update_date            IN OUT  NOCOPY DATE,
374     x_return_status               IN OUT  NOCOPY VARCHAR2
375 ) IS
376 
377     l_financial_number_rec        HZ_ORGANIZATION_INFO_V2PUB.FINANCIAL_NUMBER_REC_TYPE;
378     l_last_update_date            DATE;
379     l_rowid                       ROWID := NULL;
380     l_object_version_number       NUMBER;
381 
382 BEGIN
383 
384     -- check required fields:
385     IF p_last_update_date IS NULL OR
386        p_last_update_date = FND_API.G_MISS_DATE
387     THEN
388        FND_MESSAGE.SET_NAME('AR', 'HZ_API_MISSING_COLUMN');
389        FND_MESSAGE.SET_TOKEN('COLUMN', 'p_last_update_date');
390        FND_MSG_PUB.ADD;
391        RAISE FND_API.G_EXC_ERROR;
392     END IF;
393 
394     -- get object_version_number
395     BEGIN
396         SELECT ROWID, OBJECT_VERSION_NUMBER, LAST_UPDATE_DATE
397         INTO l_rowid, l_object_version_number, l_last_update_date
398         FROM HZ_FINANCIAL_NUMBERS
399         WHERE FINANCIAL_NUMBER_ID  = p_financial_number_rec.financial_number_id;
400 
401         IF TO_CHAR( p_last_update_date, 'DD-MON-YYYY HH:MI:SS') <>
402            TO_CHAR( l_last_update_date, 'DD-MON-YYYY HH:MI:SS')
403         THEN
404             FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_RECORD_CHANGED' );
405             FND_MESSAGE.SET_TOKEN( 'TABLE', 'hz_financial_numbers' );
406             FND_MSG_PUB.ADD;
407             RAISE FND_API.G_EXC_ERROR;
408         END IF;
409     EXCEPTION
410         WHEN NO_DATA_FOUND THEN
411             FND_MESSAGE.SET_NAME( 'AR', 'HZ_API_NO_RECORD' );
412             FND_MESSAGE.SET_TOKEN( 'RECORD', 'financial numbers' );
413             FND_MESSAGE.SET_TOKEN( 'VALUE',
414                 NVL( TO_CHAR( p_financial_number_rec.financial_number_id ), 'null' ) );
415             FND_MSG_PUB.ADD;
416             RAISE FND_API.G_EXC_ERROR;
417     END;
418 
419     -- pre-process v1 and v2 record.
420     v2_financial_number_pre (
421         'U',
422         p_financial_number_rec,
423         l_financial_number_rec );
424 
425     -- call V2 API.
426     HZ_ORGANIZATION_INFO_V2PUB.update_financial_number (
427         p_financial_number_rec              => l_financial_number_rec,
428         p_object_version_number             => l_object_version_number,
429         x_return_status                     => x_return_status,
430         x_msg_count                         => x_msg_count,
431         x_msg_data                          => x_msg_data
432     );
433 
434 END v2_update_financial_number;
435 
436 END HZ_ORGANIZATION_INFO_V2PVT;