DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKS_SUBSCR_ELEMS_PVT

Source


1 PACKAGE BODY OKS_SUBSCR_ELEMS_PVT AS
2 /* $Header: OKSSELEB.pls 120.1 2005/10/05 04:08:28 jvorugan noship $ */
3   ---------------------------------------------------------------------------
4   -- PROCEDURE load_error_tbl
5   ---------------------------------------------------------------------------
6   PROCEDURE load_error_tbl (
7     px_error_rec                   IN OUT NOCOPY OKC_API.ERROR_REC_TYPE,
8     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
9 
10     j                              INTEGER := NVL(px_error_tbl.LAST, 0) + 1;
11     last_msg_idx                   INTEGER := FND_MSG_PUB.COUNT_MSG;
12     l_msg_idx                      INTEGER := FND_MSG_PUB.G_NEXT;
13   BEGIN
14     -- FND_MSG_PUB has a small error in it.  If we call FND_MSG_PUB.COUNT_AND_GET before
15     -- we call FND_MSG_PUB.GET, the variable FND_MSG_PUB uses to control the index of the
16     -- message stack gets set to 1.  This makes sense until we call FND_MSG_PUB.GET which
17     -- automatically increments the index by 1, (making it 2), however, when the GET function
18     -- attempts to pull message 2, we get a NO_DATA_FOUND exception because there isn't any
19     -- message 2.  To circumvent this problem, check the amount of messages and compensate.
20     -- Again, this error only occurs when 1 message is on the stack because COUNT_AND_GET
21     -- will only update the index variable when 1 and only 1 message is on the stack.
22     IF (last_msg_idx = 1) THEN
23       l_msg_idx := FND_MSG_PUB.G_FIRST;
24     END IF;
25     LOOP
26       fnd_msg_pub.get(
27             p_msg_index     => l_msg_idx,
28             p_encoded       => fnd_api.g_false,
29             p_data          => px_error_rec.msg_data,
30             p_msg_index_out => px_error_rec.msg_count);
31       px_error_tbl(j) := px_error_rec;
32       j := j + 1;
33     EXIT WHEN (px_error_rec.msg_count = last_msg_idx);
34     END LOOP;
35   END load_error_tbl;
36   ---------------------------------------------------------------------------
37   -- FUNCTION find_highest_exception
38   ---------------------------------------------------------------------------
39   -- Finds the highest exception (G_RET_STS_UNEXP_ERROR)
40   -- in a OKC_API.ERROR_TBL_TYPE, and returns it.
41   FUNCTION find_highest_exception(
42     p_error_tbl                    IN OKC_API.ERROR_TBL_TYPE
43   ) RETURN VARCHAR2 IS
44     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
45     i                              INTEGER := 1;
46   BEGIN
47     IF (p_error_tbl.COUNT > 0) THEN
48       i := p_error_tbl.FIRST;
49       LOOP
50         IF (p_error_tbl(i).error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
51           IF (l_return_status <> OKC_API.G_RET_STS_UNEXP_ERROR) THEN
52             l_return_status := p_error_tbl(i).error_type;
53           END IF;
54         END IF;
55         EXIT WHEN (i = p_error_tbl.LAST);
56         i := p_error_tbl.NEXT(i);
57       END LOOP;
58     END IF;
59     RETURN(l_return_status);
60   END find_highest_exception;
61   ---------------------------------------------------------------------------
62   -- FUNCTION get_seq_id
63   ---------------------------------------------------------------------------
64   FUNCTION get_seq_id RETURN NUMBER IS
65   BEGIN
66     RETURN(okc_p_util.raw_to_number(sys_guid()));
67   END get_seq_id;
68 
69   ---------------------------------------------------------------------------
70   -- PROCEDURE qc
71   ---------------------------------------------------------------------------
72   PROCEDURE qc IS
73   BEGIN
74     null;
75   END qc;
76 
77   ---------------------------------------------------------------------------
78   -- PROCEDURE change_version
79   ---------------------------------------------------------------------------
80   PROCEDURE change_version IS
81   BEGIN
82     null;
83   END change_version;
84 
85   ---------------------------------------------------------------------------
86   -- PROCEDURE api_copy
87   ---------------------------------------------------------------------------
88   PROCEDURE api_copy IS
89   BEGIN
90     null;
91   END api_copy;
92 
93   ---------------------------------------------------------------------------
94   -- FUNCTION get_rec for: OKS_SUBSCR_ELEMENTS_V
95   ---------------------------------------------------------------------------
96   FUNCTION get_rec (
97     p_scev_rec                     IN scev_rec_type,
98     x_no_data_found                OUT NOCOPY BOOLEAN
99   ) RETURN scev_rec_type IS
100     CURSOR oks_sce_pk_csr (p_id IN NUMBER) IS
101     SELECT
102             ID,
103             OSH_ID,
104             DNZ_CHR_ID,
105             DNZ_CLE_ID,
106             LINKED_FLAG,
107             SEQ_NO,
108             OM_INTERFACE_DATE,
109             AMOUNT,
110             START_DATE,
111             END_DATE,
112             QUANTITY,
113             UOM_CODE,
114             ORDER_HEADER_ID,
115             ORDER_LINE_ID,
116             OBJECT_VERSION_NUMBER,
117             CREATED_BY,
118             CREATION_DATE,
119             LAST_UPDATED_BY,
120             LAST_UPDATE_DATE,
121             LAST_UPDATE_LOGIN
122       FROM Oks_Subscr_Elements_V
123      WHERE oks_subscr_elements_v.id = p_id;
124     l_oks_sce_pk                   oks_sce_pk_csr%ROWTYPE;
125     l_scev_rec                     scev_rec_type;
126   BEGIN
127     x_no_data_found := TRUE;
128     -- Get current database values
129     OPEN oks_sce_pk_csr (p_scev_rec.id);
130     FETCH oks_sce_pk_csr INTO
131               l_scev_rec.id,
132               l_scev_rec.osh_id,
133               l_scev_rec.dnz_chr_id,
134               l_scev_rec.dnz_cle_id,
135               l_scev_rec.linked_flag,
136               l_scev_rec.seq_no,
137               l_scev_rec.om_interface_date,
138               l_scev_rec.amount,
139               l_scev_rec.start_date,
140               l_scev_rec.end_date,
141               l_scev_rec.quantity,
142               l_scev_rec.uom_code,
143               l_scev_rec.order_header_id,
144               l_scev_rec.order_line_id,
145               l_scev_rec.object_version_number,
146               l_scev_rec.created_by,
147               l_scev_rec.creation_date,
148               l_scev_rec.last_updated_by,
149               l_scev_rec.last_update_date,
150               l_scev_rec.last_update_login;
151     x_no_data_found := oks_sce_pk_csr%NOTFOUND;
152     CLOSE oks_sce_pk_csr;
153     RETURN(l_scev_rec);
154   END get_rec;
155 
156   ------------------------------------------------------------------
157   -- This version of get_rec sets error messages if no data found --
158   ------------------------------------------------------------------
159   FUNCTION get_rec (
160     p_scev_rec                     IN scev_rec_type,
161     x_return_status                OUT NOCOPY VARCHAR2
162   ) RETURN scev_rec_type IS
163     l_scev_rec                     scev_rec_type;
164     l_row_notfound                 BOOLEAN := TRUE;
165   BEGIN
166     x_return_status := OKC_API.G_RET_STS_SUCCESS;
167     l_scev_rec := get_rec(p_scev_rec, l_row_notfound);
168     IF (l_row_notfound) THEN
169       OKC_API.set_message(G_APP_NAME,G_INVALID_VALUE,G_COL_NAME_TOKEN,'ID');
170       x_return_status := OKC_API.G_RET_STS_ERROR;
171     END IF;
172     RETURN(l_scev_rec);
173   END get_rec;
174   -----------------------------------------------------------
175   -- So we don't have to pass an "l_row_notfound" variable --
176   -----------------------------------------------------------
177   FUNCTION get_rec (
178     p_scev_rec                     IN scev_rec_type
179   ) RETURN scev_rec_type IS
180     l_row_not_found                BOOLEAN := TRUE;
181   BEGIN
182     RETURN(get_rec(p_scev_rec, l_row_not_found));
183   END get_rec;
184   ---------------------------------------------------------------------------
185   -- FUNCTION get_rec for: OKS_SUBSCR_ELEMENTS
186   ---------------------------------------------------------------------------
187   FUNCTION get_rec (
188     p_sbe_rec                      IN sbe_rec_type,
189     x_no_data_found                OUT NOCOPY BOOLEAN
190   ) RETURN sbe_rec_type IS
191     CURSOR oks_subscr_elements_pk_csr (p_id IN NUMBER) IS
192     SELECT
193             ID,
194             OSH_ID,
195             DNZ_CHR_ID,
196             DNZ_CLE_ID,
197             LINKED_FLAG,
198             SEQ_NO,
199             OM_INTERFACE_DATE,
200             AMOUNT,
201             START_DATE,
202             END_DATE,
203             QUANTITY,
204             UOM_CODE,
205             ORDER_HEADER_ID,
206             ORDER_LINE_ID,
207             OBJECT_VERSION_NUMBER,
208             CREATED_BY,
209             CREATION_DATE,
210             LAST_UPDATED_BY,
211             LAST_UPDATE_DATE,
212             LAST_UPDATE_LOGIN
213       FROM Oks_Subscr_Elements
214      WHERE oks_subscr_elements.id = p_id;
215     l_oks_subscr_elements_pk       oks_subscr_elements_pk_csr%ROWTYPE;
216     l_sbe_rec                      sbe_rec_type;
217   BEGIN
218     x_no_data_found := TRUE;
219     -- Get current database values
220     OPEN oks_subscr_elements_pk_csr (p_sbe_rec.id);
221     FETCH oks_subscr_elements_pk_csr INTO
222               l_sbe_rec.id,
223               l_sbe_rec.osh_id,
224               l_sbe_rec.dnz_chr_id,
225               l_sbe_rec.dnz_cle_id,
226               l_sbe_rec.linked_flag,
227               l_sbe_rec.seq_no,
228               l_sbe_rec.om_interface_date,
229               l_sbe_rec.amount,
230               l_sbe_rec.start_date,
231               l_sbe_rec.end_date,
232               l_sbe_rec.quantity,
233               l_sbe_rec.uom_code,
234               l_sbe_rec.order_header_id,
235               l_sbe_rec.order_line_id,
236               l_sbe_rec.object_version_number,
237               l_sbe_rec.created_by,
238               l_sbe_rec.creation_date,
239               l_sbe_rec.last_updated_by,
240               l_sbe_rec.last_update_date,
241               l_sbe_rec.last_update_login;
242     x_no_data_found := oks_subscr_elements_pk_csr%NOTFOUND;
243     CLOSE oks_subscr_elements_pk_csr;
244     RETURN(l_sbe_rec);
245   END get_rec;
246 
247   ------------------------------------------------------------------
248   -- This version of get_rec sets error messages if no data found --
249   ------------------------------------------------------------------
250   FUNCTION get_rec (
251     p_sbe_rec                      IN sbe_rec_type,
252     x_return_status                OUT NOCOPY VARCHAR2
253   ) RETURN sbe_rec_type IS
254     l_sbe_rec                      sbe_rec_type;
255     l_row_notfound                 BOOLEAN := TRUE;
256   BEGIN
257     x_return_status := OKC_API.G_RET_STS_SUCCESS;
258     l_sbe_rec := get_rec(p_sbe_rec, l_row_notfound);
259     IF (l_row_notfound) THEN
260       OKC_API.set_message(G_APP_NAME,G_INVALID_VALUE,G_COL_NAME_TOKEN,'ID');
261       x_return_status := OKC_API.G_RET_STS_ERROR;
262     END IF;
263     RETURN(l_sbe_rec);
264   END get_rec;
265   -----------------------------------------------------------
266   -- So we don't have to pass an "l_row_notfound" variable --
267   -----------------------------------------------------------
268   FUNCTION get_rec (
269     p_sbe_rec                      IN sbe_rec_type
270   ) RETURN sbe_rec_type IS
271     l_row_not_found                BOOLEAN := TRUE;
272   BEGIN
273     RETURN(get_rec(p_sbe_rec, l_row_not_found));
274   END get_rec;
275   ---------------------------------------------------------------------------
276   -- FUNCTION null_out_defaults for: OKS_SUBSCR_ELEMENTS_V
277   ---------------------------------------------------------------------------
278   FUNCTION null_out_defaults (
279     p_scev_rec   IN scev_rec_type
280   ) RETURN scev_rec_type IS
281     l_scev_rec                     scev_rec_type := p_scev_rec;
282   BEGIN
283     IF (l_scev_rec.id = OKC_API.G_MISS_NUM ) THEN
284       l_scev_rec.id := NULL;
285     END IF;
286     IF (l_scev_rec.osh_id = OKC_API.G_MISS_NUM ) THEN
287       l_scev_rec.osh_id := NULL;
288     END IF;
289     IF (l_scev_rec.dnz_chr_id = OKC_API.G_MISS_NUM ) THEN
290       l_scev_rec.dnz_chr_id := NULL;
291     END IF;
292     IF (l_scev_rec.dnz_cle_id = OKC_API.G_MISS_NUM ) THEN
293       l_scev_rec.dnz_cle_id := NULL;
294     END IF;
295     IF (l_scev_rec.linked_flag = OKC_API.G_MISS_CHAR ) THEN
296       l_scev_rec.linked_flag := NULL;
297     END IF;
298     IF (l_scev_rec.seq_no = OKC_API.G_MISS_NUM ) THEN
299       l_scev_rec.seq_no := NULL;
300     END IF;
301     IF (l_scev_rec.om_interface_date = OKC_API.G_MISS_DATE ) THEN
302       l_scev_rec.om_interface_date := NULL;
303     END IF;
304     IF (l_scev_rec.amount = OKC_API.G_MISS_NUM ) THEN
305       l_scev_rec.amount := NULL;
306     END IF;
307     IF (l_scev_rec.start_date = OKC_API.G_MISS_DATE ) THEN
308       l_scev_rec.start_date := NULL;
309     END IF;
310     IF (l_scev_rec.end_date = OKC_API.G_MISS_DATE ) THEN
311       l_scev_rec.end_date := NULL;
312     END IF;
313     IF (l_scev_rec.quantity = OKC_API.G_MISS_NUM ) THEN
314       l_scev_rec.quantity := NULL;
315     END IF;
316     IF (l_scev_rec.uom_code = OKC_API.G_MISS_CHAR ) THEN
317       l_scev_rec.uom_code := NULL;
318     END IF;
319     IF (l_scev_rec.order_header_id = OKC_API.G_MISS_NUM ) THEN
320       l_scev_rec.order_header_id := NULL;
321     END IF;
322     IF (l_scev_rec.order_line_id = OKC_API.G_MISS_NUM ) THEN
323       l_scev_rec.order_line_id := NULL;
324     END IF;
325     IF (l_scev_rec.object_version_number = OKC_API.G_MISS_NUM ) THEN
326       l_scev_rec.object_version_number := NULL;
327     END IF;
328     IF (l_scev_rec.created_by = OKC_API.G_MISS_NUM ) THEN
329       l_scev_rec.created_by := NULL;
330     END IF;
331     IF (l_scev_rec.creation_date = OKC_API.G_MISS_DATE ) THEN
332       l_scev_rec.creation_date := NULL;
333     END IF;
334     IF (l_scev_rec.last_updated_by = OKC_API.G_MISS_NUM ) THEN
335       l_scev_rec.last_updated_by := NULL;
336     END IF;
337     IF (l_scev_rec.last_update_date = OKC_API.G_MISS_DATE ) THEN
338       l_scev_rec.last_update_date := NULL;
339     END IF;
340     IF (l_scev_rec.last_update_login = OKC_API.G_MISS_NUM ) THEN
341       l_scev_rec.last_update_login := NULL;
342     END IF;
343     RETURN(l_scev_rec);
344   END null_out_defaults;
345   ---------------------------------
346   -- Validate_Attributes for: ID --
347   ---------------------------------
348   PROCEDURE validate_id(
349     x_return_status                OUT NOCOPY VARCHAR2,
350     p_id                           IN NUMBER) IS
351   BEGIN
352     x_return_status := OKC_API.G_RET_STS_SUCCESS;
353     IF (p_id = OKC_API.G_MISS_NUM OR
354         p_id IS NULL)
355     THEN
356       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'id');
357       x_return_status := OKC_API.G_RET_STS_ERROR;
358       RAISE G_EXCEPTION_HALT_VALIDATION;
359     END IF;
360   EXCEPTION
361     WHEN G_EXCEPTION_HALT_VALIDATION THEN
362       null;
363     WHEN OTHERS THEN
364       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
365                           ,p_msg_name     => G_UNEXPECTED_ERROR
366                           ,p_token1       => G_SQLCODE_TOKEN
367                           ,p_token1_value => SQLCODE
368                           ,p_token2       => G_SQLERRM_TOKEN
369                           ,p_token2_value => SQLERRM);
370       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
371   END validate_id;
372   -------------------------------------
373   -- Validate_Attributes for: OSH_ID --
374   -------------------------------------
375   PROCEDURE validate_osh_id(
376     x_return_status                OUT NOCOPY VARCHAR2,
377     p_osh_id                       IN NUMBER) IS
378   BEGIN
379     x_return_status := OKC_API.G_RET_STS_SUCCESS;
380     IF (p_osh_id = OKC_API.G_MISS_NUM OR
381         p_osh_id IS NULL)
382     THEN
383       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'osh_id');
384       x_return_status := OKC_API.G_RET_STS_ERROR;
385       RAISE G_EXCEPTION_HALT_VALIDATION;
386     END IF;
387   EXCEPTION
388     WHEN G_EXCEPTION_HALT_VALIDATION THEN
389       null;
390     WHEN OTHERS THEN
391       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
392                           ,p_msg_name     => G_UNEXPECTED_ERROR
393                           ,p_token1       => G_SQLCODE_TOKEN
394                           ,p_token1_value => SQLCODE
395                           ,p_token2       => G_SQLERRM_TOKEN
396                           ,p_token2_value => SQLERRM);
397       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
398   END validate_osh_id;
399   -----------------------------------------
400   -- Validate_Attributes for: DNZ_CHR_ID --
401   -----------------------------------------
402   PROCEDURE validate_dnz_chr_id(
403     x_return_status                OUT NOCOPY VARCHAR2,
404     p_dnz_chr_id                   IN NUMBER) IS
405   BEGIN
406     x_return_status := OKC_API.G_RET_STS_SUCCESS;
407     IF (p_dnz_chr_id = OKC_API.G_MISS_NUM OR
408         p_dnz_chr_id IS NULL)
409     THEN
410       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'dnz_chr_id');
411       x_return_status := OKC_API.G_RET_STS_ERROR;
412       RAISE G_EXCEPTION_HALT_VALIDATION;
413     END IF;
414   EXCEPTION
415     WHEN G_EXCEPTION_HALT_VALIDATION THEN
416       null;
417     WHEN OTHERS THEN
418       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
419                           ,p_msg_name     => G_UNEXPECTED_ERROR
420                           ,p_token1       => G_SQLCODE_TOKEN
421                           ,p_token1_value => SQLCODE
422                           ,p_token2       => G_SQLERRM_TOKEN
423                           ,p_token2_value => SQLERRM);
424       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
425   END validate_dnz_chr_id;
426   -------------------------------------
427   -- Validate_Attributes for: SEQ_NO --
428   -------------------------------------
429   PROCEDURE validate_seq_no(
430     x_return_status                OUT NOCOPY VARCHAR2,
431     p_seq_no                       IN NUMBER) IS
432   BEGIN
433     x_return_status := OKC_API.G_RET_STS_SUCCESS;
434     IF (p_seq_no = OKC_API.G_MISS_NUM OR
435         p_seq_no IS NULL)
436     THEN
437       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'seq_no');
438       x_return_status := OKC_API.G_RET_STS_ERROR;
439       RAISE G_EXCEPTION_HALT_VALIDATION;
440     END IF;
441   EXCEPTION
442     WHEN G_EXCEPTION_HALT_VALIDATION THEN
443       null;
444     WHEN OTHERS THEN
445       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
446                           ,p_msg_name     => G_UNEXPECTED_ERROR
447                           ,p_token1       => G_SQLCODE_TOKEN
448                           ,p_token1_value => SQLCODE
449                           ,p_token2       => G_SQLERRM_TOKEN
450                           ,p_token2_value => SQLERRM);
451       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
452   END validate_seq_no;
453   ---------------------------------------
454   -- Validate_Attributes for: UOM_CODE --
455   ---------------------------------------
456   PROCEDURE validate_uom_code(
457     x_return_status                OUT NOCOPY VARCHAR2,
458     p_uom_code                     IN VARCHAR2) IS
459   BEGIN
460     x_return_status := OKC_API.G_RET_STS_SUCCESS;
461     IF (p_uom_code = OKC_API.G_MISS_CHAR OR
462         p_uom_code IS NULL)
463     THEN
464       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'uom_code');
465       x_return_status := OKC_API.G_RET_STS_ERROR;
466       RAISE G_EXCEPTION_HALT_VALIDATION;
467     END IF;
468   EXCEPTION
469     WHEN G_EXCEPTION_HALT_VALIDATION THEN
470       null;
471     WHEN OTHERS THEN
472       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
473                           ,p_msg_name     => G_UNEXPECTED_ERROR
474                           ,p_token1       => G_SQLCODE_TOKEN
475                           ,p_token1_value => SQLCODE
476                           ,p_token2       => G_SQLERRM_TOKEN
477                           ,p_token2_value => SQLERRM);
478       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
479   END validate_uom_code;
480   ----------------------------------------------------
481   -- Validate_Attributes for: OBJECT_VERSION_NUMBER --
482   ----------------------------------------------------
483   PROCEDURE validate_object_version_number(
484     x_return_status                OUT NOCOPY VARCHAR2,
485     p_object_version_number        IN NUMBER) IS
486   BEGIN
487     x_return_status := OKC_API.G_RET_STS_SUCCESS;
488     IF (p_object_version_number = OKC_API.G_MISS_NUM OR
489         p_object_version_number IS NULL)
490     THEN
491       OKC_API.set_message(G_APP_NAME, G_REQUIRED_VALUE, G_COL_NAME_TOKEN, 'object_version_number');
492       x_return_status := OKC_API.G_RET_STS_ERROR;
493       RAISE G_EXCEPTION_HALT_VALIDATION;
494     END IF;
495   EXCEPTION
496     WHEN G_EXCEPTION_HALT_VALIDATION THEN
497       null;
498     WHEN OTHERS THEN
499       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
500                           ,p_msg_name     => G_UNEXPECTED_ERROR
501                           ,p_token1       => G_SQLCODE_TOKEN
502                           ,p_token1_value => SQLCODE
503                           ,p_token2       => G_SQLERRM_TOKEN
504                           ,p_token2_value => SQLERRM);
505       x_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
506   END validate_object_version_number;
507   ---------------------------------------------------------------------------
508   -- FUNCTION Validate_Attributes
509   ---------------------------------------------------------------------------
510   ---------------------------------------------------
511   -- Validate_Attributes for:OKS_SUBSCR_ELEMENTS_V --
512   ---------------------------------------------------
513   FUNCTION Validate_Attributes (
514     p_scev_rec                     IN scev_rec_type
515   ) RETURN VARCHAR2 IS
516     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
517     x_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
518   BEGIN
519     -----------------------------
520     -- Column Level Validation --
521     -----------------------------
522     -- ***
523     -- id
524     -- ***
525     validate_id(x_return_status, p_scev_rec.id);
526     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
527       l_return_status := x_return_status;
528       RAISE G_EXCEPTION_HALT_VALIDATION;
529     END IF;
530 
531     -- ***
532     -- osh_id
533     -- ***
534     validate_osh_id(x_return_status, p_scev_rec.osh_id);
535     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
536       l_return_status := x_return_status;
537       RAISE G_EXCEPTION_HALT_VALIDATION;
538     END IF;
539 
540     -- ***
541     -- dnz_chr_id
542     -- ***
543     validate_dnz_chr_id(x_return_status, p_scev_rec.dnz_chr_id);
544     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
545       l_return_status := x_return_status;
546       RAISE G_EXCEPTION_HALT_VALIDATION;
547     END IF;
548 
549     -- ***
550     -- seq_no
551     -- ***
552     validate_seq_no(x_return_status, p_scev_rec.seq_no);
553     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
554       l_return_status := x_return_status;
555       RAISE G_EXCEPTION_HALT_VALIDATION;
556     END IF;
557 
558     -- ***
559     -- uom_code
560     -- ***
561     validate_uom_code(x_return_status, p_scev_rec.uom_code);
562     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
563       l_return_status := x_return_status;
564       RAISE G_EXCEPTION_HALT_VALIDATION;
565     END IF;
566 
567     -- ***
568     -- object_version_number
569     -- ***
570     validate_object_version_number(x_return_status, p_scev_rec.object_version_number);
571     IF (x_return_status <> OKC_API.G_RET_STS_SUCCESS) THEN
572       l_return_status := x_return_status;
573       RAISE G_EXCEPTION_HALT_VALIDATION;
574     END IF;
575 
576     RETURN(l_return_status);
577   EXCEPTION
578     WHEN G_EXCEPTION_HALT_VALIDATION THEN
579       RETURN(l_return_status);
580     WHEN OTHERS THEN
581       OKC_API.SET_MESSAGE( p_app_name     => G_APP_NAME
582                           ,p_msg_name     => G_UNEXPECTED_ERROR
583                           ,p_token1       => G_SQLCODE_TOKEN
584                           ,p_token1_value => SQLCODE
585                           ,p_token2       => G_SQLERRM_TOKEN
586                           ,p_token2_value => SQLERRM);
587       l_return_status := OKC_API.G_RET_STS_UNEXP_ERROR;
588       RETURN(l_return_status);
589   END Validate_Attributes;
590   ---------------------------------------------------------------------------
591   -- PROCEDURE Validate_Record
592   ---------------------------------------------------------------------------
593   -----------------------------------------------
594   -- Validate Record for:OKS_SUBSCR_ELEMENTS_V --
595   -----------------------------------------------
596   FUNCTION Validate_Record (
597     p_scev_rec IN scev_rec_type,
598     p_db_scev_rec IN scev_rec_type
599   ) RETURN VARCHAR2 IS
600     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
601   BEGIN
602     RETURN (l_return_status);
603   END Validate_Record;
604   FUNCTION Validate_Record (
605     p_scev_rec IN scev_rec_type
606   ) RETURN VARCHAR2 IS
607     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
608     l_db_scev_rec                  scev_rec_type := get_rec(p_scev_rec);
609   BEGIN
610     l_return_status := Validate_Record(p_scev_rec => p_scev_rec,
611                                        p_db_scev_rec => l_db_scev_rec);
612     RETURN (l_return_status);
613   END Validate_Record;
614 
615   ---------------------------------------------------------------------------
616   -- PROCEDURE Migrate
617   ---------------------------------------------------------------------------
618   PROCEDURE migrate (
619     p_from IN scev_rec_type,
620     p_to   IN OUT NOCOPY sbe_rec_type
621   ) IS
622   BEGIN
623     p_to.id := p_from.id;
624     p_to.osh_id := p_from.osh_id;
625     p_to.dnz_chr_id := p_from.dnz_chr_id;
626     p_to.dnz_cle_id := p_from.dnz_cle_id;
627     p_to.linked_flag := p_from.linked_flag;
628     p_to.seq_no := p_from.seq_no;
629     p_to.om_interface_date := p_from.om_interface_date;
630     p_to.amount := p_from.amount;
631     p_to.start_date := p_from.start_date;
632     p_to.end_date := p_from.end_date;
633     p_to.quantity := p_from.quantity;
634     p_to.uom_code := p_from.uom_code;
635     p_to.order_header_id := p_from.order_header_id;
636     p_to.order_line_id := p_from.order_line_id;
637     p_to.object_version_number := p_from.object_version_number;
638     p_to.created_by := p_from.created_by;
639     p_to.creation_date := p_from.creation_date;
640     p_to.last_updated_by := p_from.last_updated_by;
641     p_to.last_update_date := p_from.last_update_date;
642     p_to.last_update_login := p_from.last_update_login;
643   END migrate;
644   PROCEDURE migrate (
645     p_from IN sbe_rec_type,
646     p_to   IN OUT NOCOPY scev_rec_type
647   ) IS
648   BEGIN
649     p_to.id := p_from.id;
650     p_to.osh_id := p_from.osh_id;
651     p_to.dnz_chr_id := p_from.dnz_chr_id;
652     p_to.dnz_cle_id := p_from.dnz_cle_id;
653     p_to.linked_flag := p_from.linked_flag;
654     p_to.seq_no := p_from.seq_no;
655     p_to.om_interface_date := p_from.om_interface_date;
656     p_to.amount := p_from.amount;
657     p_to.start_date := p_from.start_date;
658     p_to.end_date := p_from.end_date;
659     p_to.quantity := p_from.quantity;
660     p_to.uom_code := p_from.uom_code;
661     p_to.order_header_id := p_from.order_header_id;
662     p_to.order_line_id := p_from.order_line_id;
663     p_to.object_version_number := p_from.object_version_number;
664     p_to.created_by := p_from.created_by;
665     p_to.creation_date := p_from.creation_date;
666     p_to.last_updated_by := p_from.last_updated_by;
667     p_to.last_update_date := p_from.last_update_date;
668     p_to.last_update_login := p_from.last_update_login;
669   END migrate;
670   ---------------------------------------------------------------------------
671   -- PROCEDURE validate_row
672   ---------------------------------------------------------------------------
673   --------------------------------------------
674   -- validate_row for:OKS_SUBSCR_ELEMENTS_V --
675   --------------------------------------------
676   PROCEDURE validate_row(
677     p_api_version                  IN NUMBER,
678     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
679     x_return_status                OUT NOCOPY VARCHAR2,
680     x_msg_count                    OUT NOCOPY NUMBER,
681     x_msg_data                     OUT NOCOPY VARCHAR2,
682     p_scev_rec                     IN scev_rec_type) IS
683 
684     l_api_version                  CONSTANT NUMBER := 1;
685     l_api_name                     CONSTANT VARCHAR2(30) := 'V_validate_row';
686     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
687     l_scev_rec                     scev_rec_type := p_scev_rec;
688     l_sbe_rec                      sbe_rec_type;
689     l_sbe_rec                      sbe_rec_type;
690   BEGIN
691     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
692                                               G_PKG_NAME,
693                                               p_init_msg_list,
694                                               l_api_version,
695                                               p_api_version,
696                                               '_PVT',
697                                               x_return_status);
698     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
699       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
700     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
701       RAISE OKC_API.G_EXCEPTION_ERROR;
702     END IF;
703     --- Validate all non-missing attributes (Item Level Validation)
704     l_return_status := Validate_Attributes(l_scev_rec);
705     --- If any errors happen abort API
706     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
707       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
708     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
709       RAISE OKC_API.G_EXCEPTION_ERROR;
710     END IF;
711     l_return_status := Validate_Record(l_scev_rec);
712     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
713       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
714     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
715       RAISE OKC_API.G_EXCEPTION_ERROR;
716     END IF;
717     x_return_status := l_return_status;
718   EXCEPTION
719     WHEN OKC_API.G_EXCEPTION_ERROR THEN
720       x_return_status := OKC_API.HANDLE_EXCEPTIONS
721       (
722         l_api_name,
723         G_PKG_NAME,
724         'OKC_API.G_RET_STS_ERROR',
725         x_msg_count,
726         x_msg_data,
727         '_PVT'
728       );
729     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
730       x_return_status := OKC_API.HANDLE_EXCEPTIONS
731       (
732         l_api_name,
733         G_PKG_NAME,
734         'OKC_API.G_RET_STS_UNEXP_ERROR',
735         x_msg_count,
736         x_msg_data,
737         '_PVT'
738       );
739     WHEN OTHERS THEN
740       x_return_status := OKC_API.HANDLE_EXCEPTIONS
741       (
742         l_api_name,
743         G_PKG_NAME,
744         'OTHERS',
745         x_msg_count,
746         x_msg_data,
747         '_PVT'
748       );
749   END validate_row;
750   -------------------------------------------------------
751   -- PL/SQL TBL validate_row for:OKS_SUBSCR_ELEMENTS_V --
752   -------------------------------------------------------
753   PROCEDURE validate_row(
754     p_api_version                  IN NUMBER,
755     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
756     x_return_status                OUT NOCOPY VARCHAR2,
757     x_msg_count                    OUT NOCOPY NUMBER,
758     x_msg_data                     OUT NOCOPY VARCHAR2,
759     p_scev_tbl                     IN scev_tbl_type,
760     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
761 
762     l_api_version                  CONSTANT NUMBER := 1;
763     l_api_name                     CONSTANT VARCHAR2(30) := 'V_error_tbl_validate_row';
764     i                              NUMBER := 0;
765   BEGIN
766     OKC_API.init_msg_list(p_init_msg_list);
767     -- Make sure PL/SQL table has records in it before passing
768     IF (p_scev_tbl.COUNT > 0) THEN
769       i := p_scev_tbl.FIRST;
770       LOOP
771         DECLARE
772           l_error_rec         OKC_API.ERROR_REC_TYPE;
773         BEGIN
774           l_error_rec.api_name := l_api_name;
775           l_error_rec.api_package := G_PKG_NAME;
776           l_error_rec.idx := i;
777           validate_row (
778             p_api_version                  => p_api_version,
779             p_init_msg_list                => OKC_API.G_FALSE,
780             x_return_status                => l_error_rec.error_type,
781             x_msg_count                    => l_error_rec.msg_count,
782             x_msg_data                     => l_error_rec.msg_data,
783             p_scev_rec                     => p_scev_tbl(i));
784           IF (l_error_rec.error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
785             l_error_rec.sqlcode := SQLCODE;
786             load_error_tbl(l_error_rec, px_error_tbl);
787           ELSE
788             x_msg_count := l_error_rec.msg_count;
789             x_msg_data := l_error_rec.msg_data;
790           END IF;
791         EXCEPTION
792           WHEN OKC_API.G_EXCEPTION_ERROR THEN
793             l_error_rec.error_type := OKC_API.G_RET_STS_ERROR;
794             l_error_rec.sqlcode := SQLCODE;
795             load_error_tbl(l_error_rec, px_error_tbl);
796           WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
797             l_error_rec.error_type := OKC_API.G_RET_STS_UNEXP_ERROR;
798             l_error_rec.sqlcode := SQLCODE;
799             load_error_tbl(l_error_rec, px_error_tbl);
800           WHEN OTHERS THEN
801             l_error_rec.error_type := 'OTHERS';
802             l_error_rec.sqlcode := SQLCODE;
803             load_error_tbl(l_error_rec, px_error_tbl);
804         END;
805         EXIT WHEN (i = p_scev_tbl.LAST);
806         i := p_scev_tbl.NEXT(i);
807       END LOOP;
808     END IF;
809     -- Loop through the error_tbl to find the error with the highest severity
810     -- and return it.
811     x_return_status := find_highest_exception(px_error_tbl);
812     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
813   EXCEPTION
814     WHEN OKC_API.G_EXCEPTION_ERROR THEN
815       x_return_status := OKC_API.HANDLE_EXCEPTIONS
816       (
817         l_api_name,
818         G_PKG_NAME,
819         'OKC_API.G_RET_STS_ERROR',
820         x_msg_count,
821         x_msg_data,
822         '_PVT'
823       );
824     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
825       x_return_status := OKC_API.HANDLE_EXCEPTIONS
826       (
827         l_api_name,
828         G_PKG_NAME,
829         'OKC_API.G_RET_STS_UNEXP_ERROR',
830         x_msg_count,
831         x_msg_data,
832         '_PVT'
833       );
834     WHEN OTHERS THEN
835       x_return_status := OKC_API.HANDLE_EXCEPTIONS
836       (
837         l_api_name,
838         G_PKG_NAME,
839         'OTHERS',
840         x_msg_count,
841         x_msg_data,
842         '_PVT'
843       );
844   END validate_row;
845 
846   -------------------------------------------------------
847   -- PL/SQL TBL validate_row for:OKS_SUBSCR_ELEMENTS_V --
848   -------------------------------------------------------
849   PROCEDURE validate_row(
850     p_api_version                  IN NUMBER,
851     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
852     x_return_status                OUT NOCOPY VARCHAR2,
853     x_msg_count                    OUT NOCOPY NUMBER,
854     x_msg_data                     OUT NOCOPY VARCHAR2,
855     p_scev_tbl                     IN scev_tbl_type) IS
856 
857     l_api_version                  CONSTANT NUMBER := 1;
858     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_validate_row';
859     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
860     l_error_tbl                    OKC_API.ERROR_TBL_TYPE;
861   BEGIN
862     OKC_API.init_msg_list(p_init_msg_list);
863     -- Make sure PL/SQL table has records in it before passing
864     IF (p_scev_tbl.COUNT > 0) THEN
865       validate_row (
866         p_api_version                  => p_api_version,
867         p_init_msg_list                => OKC_API.G_FALSE,
868         x_return_status                => x_return_status,
869         x_msg_count                    => x_msg_count,
870         x_msg_data                     => x_msg_data,
871         p_scev_tbl                     => p_scev_tbl,
872         px_error_tbl                   => l_error_tbl);
873     END IF;
874     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
875   EXCEPTION
876     WHEN OKC_API.G_EXCEPTION_ERROR THEN
877       x_return_status := OKC_API.HANDLE_EXCEPTIONS
878       (
879         l_api_name,
880         G_PKG_NAME,
881         'OKC_API.G_RET_STS_ERROR',
882         x_msg_count,
883         x_msg_data,
884         '_PVT'
885       );
886     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
887       x_return_status := OKC_API.HANDLE_EXCEPTIONS
888       (
889         l_api_name,
890         G_PKG_NAME,
891         'OKC_API.G_RET_STS_UNEXP_ERROR',
892         x_msg_count,
893         x_msg_data,
894         '_PVT'
895       );
896     WHEN OTHERS THEN
897       x_return_status := OKC_API.HANDLE_EXCEPTIONS
898       (
899         l_api_name,
900         G_PKG_NAME,
901         'OTHERS',
902         x_msg_count,
903         x_msg_data,
904         '_PVT'
905       );
906   END validate_row;
907 
908   ---------------------------------------------------------------------------
909   -- PROCEDURE insert_row
910   ---------------------------------------------------------------------------
911   ----------------------------------------
912   -- insert_row for:OKS_SUBSCR_ELEMENTS --
913   ----------------------------------------
914   PROCEDURE insert_row(
915     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
916     x_return_status                OUT NOCOPY VARCHAR2,
917     x_msg_count                    OUT NOCOPY NUMBER,
918     x_msg_data                     OUT NOCOPY VARCHAR2,
919     p_sbe_rec                      IN sbe_rec_type,
920     x_sbe_rec                      OUT NOCOPY sbe_rec_type) IS
921 
922     l_api_version                  CONSTANT NUMBER := 1;
923     l_api_name                     CONSTANT VARCHAR2(30) := 'B_insert_row';
924     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
925     l_sbe_rec                      sbe_rec_type := p_sbe_rec;
926     l_def_sbe_rec                  sbe_rec_type;
927     --------------------------------------------
928     -- Set_Attributes for:OKS_SUBSCR_ELEMENTS --
929     --------------------------------------------
930     FUNCTION Set_Attributes (
931       p_sbe_rec IN sbe_rec_type,
932       x_sbe_rec OUT NOCOPY sbe_rec_type
933     ) RETURN VARCHAR2 IS
934       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
935     BEGIN
936       x_sbe_rec := p_sbe_rec;
937       RETURN(l_return_status);
938     END Set_Attributes;
939   BEGIN
940     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
941                                               p_init_msg_list,
942                                               '_PVT',
943                                               x_return_status);
944     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
945       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
946     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
947       RAISE OKC_API.G_EXCEPTION_ERROR;
948     END IF;
949     --- Setting item atributes
950     l_return_status := Set_Attributes(
951       p_sbe_rec,                         -- IN
952       l_sbe_rec);                        -- OUT
953     --- If any errors happen abort API
954     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
955       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
956     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
957       RAISE OKC_API.G_EXCEPTION_ERROR;
958     END IF;
959     INSERT INTO OKS_SUBSCR_ELEMENTS(
960       id,
961       osh_id,
962       dnz_chr_id,
963       dnz_cle_id,
964       linked_flag,
965       seq_no,
966       om_interface_date,
967       amount,
968       start_date,
969       end_date,
970       quantity,
971       uom_code,
972       order_header_id,
973       order_line_id,
974       object_version_number,
975       created_by,
976       creation_date,
977       last_updated_by,
978       last_update_date,
979       last_update_login)
980     VALUES (
981       l_sbe_rec.id,
982       l_sbe_rec.osh_id,
983       l_sbe_rec.dnz_chr_id,
984       l_sbe_rec.dnz_cle_id,
985       l_sbe_rec.linked_flag,
986       l_sbe_rec.seq_no,
987       l_sbe_rec.om_interface_date,
988       l_sbe_rec.amount,
989       l_sbe_rec.start_date,
990       l_sbe_rec.end_date,
991       l_sbe_rec.quantity,
992       l_sbe_rec.uom_code,
993       l_sbe_rec.order_header_id,
994       l_sbe_rec.order_line_id,
995       l_sbe_rec.object_version_number,
996       l_sbe_rec.created_by,
997       l_sbe_rec.creation_date,
998       l_sbe_rec.last_updated_by,
999       l_sbe_rec.last_update_date,
1000       l_sbe_rec.last_update_login);
1001     -- Set OUT values
1002     x_sbe_rec := l_sbe_rec;
1003     x_return_status := l_return_status;
1004     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1005   EXCEPTION
1006     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1007       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1008       (
1009         l_api_name,
1010         G_PKG_NAME,
1011         'OKC_API.G_RET_STS_ERROR',
1012         x_msg_count,
1013         x_msg_data,
1014         '_PVT'
1015       );
1016     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1017       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1018       (
1019         l_api_name,
1020         G_PKG_NAME,
1021         'OKC_API.G_RET_STS_UNEXP_ERROR',
1022         x_msg_count,
1023         x_msg_data,
1024         '_PVT'
1025       );
1026     WHEN OTHERS THEN
1027       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1028       (
1029         l_api_name,
1030         G_PKG_NAME,
1031         'OTHERS',
1032         x_msg_count,
1033         x_msg_data,
1034         '_PVT'
1035       );
1036   END insert_row;
1037   -------------------------------------------
1038   -- insert_row for :OKS_SUBSCR_ELEMENTS_V --
1039   -------------------------------------------
1040   PROCEDURE insert_row(
1041     p_api_version                  IN NUMBER,
1042     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1043     x_return_status                OUT NOCOPY VARCHAR2,
1044     x_msg_count                    OUT NOCOPY NUMBER,
1045     x_msg_data                     OUT NOCOPY VARCHAR2,
1046     p_scev_rec                     IN scev_rec_type,
1047     x_scev_rec                     OUT NOCOPY scev_rec_type) IS
1048 
1049     l_api_version                  CONSTANT NUMBER := 1;
1050     l_api_name                     CONSTANT VARCHAR2(30) := 'V_insert_row';
1051     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1052     l_scev_rec                     scev_rec_type := p_scev_rec;
1053     l_def_scev_rec                 scev_rec_type;
1054     l_sbe_rec                      sbe_rec_type;
1055     lx_sbe_rec                     sbe_rec_type;
1056     -------------------------------
1057     -- FUNCTION fill_who_columns --
1058     -------------------------------
1059     FUNCTION fill_who_columns (
1060       p_scev_rec IN scev_rec_type
1061     ) RETURN scev_rec_type IS
1062       l_scev_rec scev_rec_type := p_scev_rec;
1063     BEGIN
1064       l_scev_rec.CREATION_DATE := SYSDATE;
1065       l_scev_rec.CREATED_BY := FND_GLOBAL.USER_ID;
1066       l_scev_rec.LAST_UPDATE_DATE := l_scev_rec.CREATION_DATE;
1067       l_scev_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
1068       l_scev_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
1069       RETURN(l_scev_rec);
1070     END fill_who_columns;
1071     ----------------------------------------------
1072     -- Set_Attributes for:OKS_SUBSCR_ELEMENTS_V --
1073     ----------------------------------------------
1074     FUNCTION Set_Attributes (
1075       p_scev_rec IN scev_rec_type,
1076       x_scev_rec OUT NOCOPY scev_rec_type
1077     ) RETURN VARCHAR2 IS
1078       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1079     BEGIN
1080       x_scev_rec := p_scev_rec;
1081       x_scev_rec.OBJECT_VERSION_NUMBER := 1;
1082       RETURN(l_return_status);
1083     END Set_Attributes;
1084   BEGIN
1085     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1086                                               G_PKG_NAME,
1087                                               p_init_msg_list,
1088                                               l_api_version,
1089                                               p_api_version,
1090                                               '_PVT',
1091                                               x_return_status);
1092     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1093       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1094     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1095       RAISE OKC_API.G_EXCEPTION_ERROR;
1096     END IF;
1097     l_scev_rec := null_out_defaults(p_scev_rec);
1098     -- Set primary key value
1099     l_scev_rec.ID := get_seq_id;
1100     -- Setting item attributes
1101     l_return_Status := Set_Attributes(
1102       l_scev_rec,                        -- IN
1103       l_def_scev_rec);                   -- OUT
1104     --- If any errors happen abort API
1105     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1106       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1107     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1108       RAISE OKC_API.G_EXCEPTION_ERROR;
1109     END IF;
1110     l_def_scev_rec := fill_who_columns(l_def_scev_rec);
1111     --- Validate all non-missing attributes (Item Level Validation)
1112     l_return_status := Validate_Attributes(l_def_scev_rec);
1113     --- If any errors happen abort API
1114     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1115       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1116     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1117       RAISE OKC_API.G_EXCEPTION_ERROR;
1118     END IF;
1119     l_return_status := Validate_Record(l_def_scev_rec);
1120     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1121       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1122     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1123       RAISE OKC_API.G_EXCEPTION_ERROR;
1124     END IF;
1125     -----------------------------------------
1126     -- Move VIEW record to "Child" records --
1127     -----------------------------------------
1128     migrate(l_def_scev_rec, l_sbe_rec);
1129     -----------------------------------------------
1130     -- Call the INSERT_ROW for each child record --
1131     -----------------------------------------------
1132     insert_row(
1133       p_init_msg_list,
1134       l_return_status,
1135       x_msg_count,
1136       x_msg_data,
1137       l_sbe_rec,
1138       lx_sbe_rec
1139     );
1140     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1141       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1142     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1143       RAISE OKC_API.G_EXCEPTION_ERROR;
1144     END IF;
1145     migrate(lx_sbe_rec, l_def_scev_rec);
1146     -- Set OUT values
1147     x_scev_rec := l_def_scev_rec;
1148     x_return_status := l_return_status;
1149     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1150   EXCEPTION
1151     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1152       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1153       (
1154         l_api_name,
1155         G_PKG_NAME,
1156         'OKC_API.G_RET_STS_ERROR',
1157         x_msg_count,
1158         x_msg_data,
1159         '_PVT'
1160       );
1161     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1162       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1163       (
1164         l_api_name,
1165         G_PKG_NAME,
1166         'OKC_API.G_RET_STS_UNEXP_ERROR',
1167         x_msg_count,
1168         x_msg_data,
1169         '_PVT'
1170       );
1171     WHEN OTHERS THEN
1172       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1173       (
1174         l_api_name,
1175         G_PKG_NAME,
1176         'OTHERS',
1177         x_msg_count,
1178         x_msg_data,
1179         '_PVT'
1180       );
1181   END insert_row;
1182   ----------------------------------------
1183   -- PL/SQL TBL insert_row for:SCEV_TBL --
1184   ----------------------------------------
1185   PROCEDURE insert_row(
1186     p_api_version                  IN NUMBER,
1187     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1188     x_return_status                OUT NOCOPY VARCHAR2,
1189     x_msg_count                    OUT NOCOPY NUMBER,
1190     x_msg_data                     OUT NOCOPY VARCHAR2,
1191     p_scev_tbl                     IN scev_tbl_type,
1192     x_scev_tbl                     OUT NOCOPY scev_tbl_type,
1193     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
1194 
1195     l_api_version                  CONSTANT NUMBER := 1;
1196     l_api_name                     CONSTANT VARCHAR2(30) := 'V_error_tbl_insert_row';
1197     i                              NUMBER := 0;
1198   BEGIN
1199     OKC_API.init_msg_list(p_init_msg_list);
1200     -- Make sure PL/SQL table has records in it before passing
1201     IF (p_scev_tbl.COUNT > 0) THEN
1202       i := p_scev_tbl.FIRST;
1203       LOOP
1204         DECLARE
1205           l_error_rec         OKC_API.ERROR_REC_TYPE;
1206         BEGIN
1207           l_error_rec.api_name := l_api_name;
1208           l_error_rec.api_package := G_PKG_NAME;
1209           l_error_rec.idx := i;
1210           insert_row (
1211             p_api_version                  => p_api_version,
1212             p_init_msg_list                => OKC_API.G_FALSE,
1213             x_return_status                => l_error_rec.error_type,
1214             x_msg_count                    => l_error_rec.msg_count,
1215             x_msg_data                     => l_error_rec.msg_data,
1216             p_scev_rec                     => p_scev_tbl(i),
1217             x_scev_rec                     => x_scev_tbl(i));
1218           IF (l_error_rec.error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
1219             l_error_rec.sqlcode := SQLCODE;
1220             load_error_tbl(l_error_rec, px_error_tbl);
1221           ELSE
1222             x_msg_count := l_error_rec.msg_count;
1223             x_msg_data := l_error_rec.msg_data;
1224           END IF;
1225         EXCEPTION
1226           WHEN OKC_API.G_EXCEPTION_ERROR THEN
1227             l_error_rec.error_type := OKC_API.G_RET_STS_ERROR;
1228             l_error_rec.sqlcode := SQLCODE;
1229             load_error_tbl(l_error_rec, px_error_tbl);
1230           WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1231             l_error_rec.error_type := OKC_API.G_RET_STS_UNEXP_ERROR;
1232             l_error_rec.sqlcode := SQLCODE;
1233             load_error_tbl(l_error_rec, px_error_tbl);
1234           WHEN OTHERS THEN
1235             l_error_rec.error_type := 'OTHERS';
1236             l_error_rec.sqlcode := SQLCODE;
1237             load_error_tbl(l_error_rec, px_error_tbl);
1238         END;
1239         EXIT WHEN (i = p_scev_tbl.LAST);
1240         i := p_scev_tbl.NEXT(i);
1241       END LOOP;
1242     END IF;
1243     -- Loop through the error_tbl to find the error with the highest severity
1244     -- and return it.
1245     x_return_status := find_highest_exception(px_error_tbl);
1246     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1247   EXCEPTION
1248     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1249       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1250       (
1251         l_api_name,
1252         G_PKG_NAME,
1253         'OKC_API.G_RET_STS_ERROR',
1254         x_msg_count,
1255         x_msg_data,
1256         '_PVT'
1257       );
1258     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1259       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1260       (
1261         l_api_name,
1262         G_PKG_NAME,
1263         'OKC_API.G_RET_STS_UNEXP_ERROR',
1264         x_msg_count,
1265         x_msg_data,
1266         '_PVT'
1267       );
1268     WHEN OTHERS THEN
1269       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1270       (
1271         l_api_name,
1272         G_PKG_NAME,
1273         'OTHERS',
1274         x_msg_count,
1275         x_msg_data,
1276         '_PVT'
1277       );
1278   END insert_row;
1279 
1280   ----------------------------------------
1281   -- PL/SQL TBL insert_row for:SCEV_TBL --
1282   ----------------------------------------
1283   PROCEDURE insert_row(
1284     p_api_version                  IN NUMBER,
1285     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1286     x_return_status                OUT NOCOPY VARCHAR2,
1287     x_msg_count                    OUT NOCOPY NUMBER,
1288     x_msg_data                     OUT NOCOPY VARCHAR2,
1289     p_scev_tbl                     IN scev_tbl_type,
1290     x_scev_tbl                     OUT NOCOPY scev_tbl_type) IS
1291 
1292     l_api_version                  CONSTANT NUMBER := 1;
1293     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_insert_row';
1294     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1295     l_error_tbl                    OKC_API.ERROR_TBL_TYPE;
1296   BEGIN
1297     OKC_API.init_msg_list(p_init_msg_list);
1298     -- Make sure PL/SQL table has records in it before passing
1299     IF (p_scev_tbl.COUNT > 0) THEN
1300       insert_row (
1301         p_api_version                  => p_api_version,
1302         p_init_msg_list                => OKC_API.G_FALSE,
1303         x_return_status                => x_return_status,
1304         x_msg_count                    => x_msg_count,
1305         x_msg_data                     => x_msg_data,
1306         p_scev_tbl                     => p_scev_tbl,
1307         x_scev_tbl                     => x_scev_tbl,
1308         px_error_tbl                   => l_error_tbl);
1309     END IF;
1310     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1311   EXCEPTION
1312     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1313       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1314       (
1315         l_api_name,
1316         G_PKG_NAME,
1317         'OKC_API.G_RET_STS_ERROR',
1318         x_msg_count,
1319         x_msg_data,
1320         '_PVT'
1321       );
1322     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1323       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1324       (
1325         l_api_name,
1326         G_PKG_NAME,
1327         'OKC_API.G_RET_STS_UNEXP_ERROR',
1328         x_msg_count,
1329         x_msg_data,
1330         '_PVT'
1331       );
1332     WHEN OTHERS THEN
1333       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1334       (
1335         l_api_name,
1336         G_PKG_NAME,
1337         'OTHERS',
1338         x_msg_count,
1339         x_msg_data,
1340         '_PVT'
1341       );
1342   END insert_row;
1343 
1344   ---------------------------------------------------------------------------
1345   -- PROCEDURE lock_row
1346   ---------------------------------------------------------------------------
1347   --------------------------------------
1348   -- lock_row for:OKS_SUBSCR_ELEMENTS --
1349   --------------------------------------
1350   PROCEDURE lock_row(
1351     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1352     x_return_status                OUT NOCOPY VARCHAR2,
1353     x_msg_count                    OUT NOCOPY NUMBER,
1354     x_msg_data                     OUT NOCOPY VARCHAR2,
1355     p_sbe_rec                      IN sbe_rec_type) IS
1356 
1357     E_Resource_Busy                EXCEPTION;
1358     PRAGMA EXCEPTION_INIT(E_Resource_Busy, -00054);
1359     CURSOR lock_csr (p_sbe_rec IN sbe_rec_type) IS
1360     SELECT OBJECT_VERSION_NUMBER
1361       FROM OKS_SUBSCR_ELEMENTS
1362      WHERE ID = p_sbe_rec.id
1363        AND OBJECT_VERSION_NUMBER = p_sbe_rec.object_version_number
1364     FOR UPDATE OF OBJECT_VERSION_NUMBER NOWAIT;
1365 
1366     CURSOR lchk_csr (p_sbe_rec IN sbe_rec_type) IS
1367     SELECT OBJECT_VERSION_NUMBER
1368       FROM OKS_SUBSCR_ELEMENTS
1369      WHERE ID = p_sbe_rec.id;
1370     l_api_version                  CONSTANT NUMBER := 1;
1371     l_api_name                     CONSTANT VARCHAR2(30) := 'B_lock_row';
1372     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1373     l_object_version_number        OKS_SUBSCR_ELEMENTS.OBJECT_VERSION_NUMBER%TYPE;
1374     lc_object_version_number       OKS_SUBSCR_ELEMENTS.OBJECT_VERSION_NUMBER%TYPE;
1375     l_row_notfound                 BOOLEAN := FALSE;
1376     lc_row_notfound                BOOLEAN := FALSE;
1377   BEGIN
1378     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1379                                               p_init_msg_list,
1380                                               '_PVT',
1381                                               x_return_status);
1382     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1383       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1384     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1385       RAISE OKC_API.G_EXCEPTION_ERROR;
1386     END IF;
1387     BEGIN
1388       OPEN lock_csr(p_sbe_rec);
1389       FETCH lock_csr INTO l_object_version_number;
1390       l_row_notfound := lock_csr%NOTFOUND;
1391       CLOSE lock_csr;
1392     EXCEPTION
1393       WHEN E_Resource_Busy THEN
1394         IF (lock_csr%ISOPEN) THEN
1395           CLOSE lock_csr;
1396         END IF;
1397         OKC_API.set_message(G_FND_APP,G_FORM_UNABLE_TO_RESERVE_REC);
1398         RAISE APP_EXCEPTIONS.RECORD_LOCK_EXCEPTION;
1399     END;
1400 
1401     IF ( l_row_notfound ) THEN
1402       OPEN lchk_csr(p_sbe_rec);
1403       FETCH lchk_csr INTO lc_object_version_number;
1404       lc_row_notfound := lchk_csr%NOTFOUND;
1405       CLOSE lchk_csr;
1406     END IF;
1407     IF (lc_row_notfound) THEN
1408       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_DELETED);
1409       RAISE OKC_API.G_EXCEPTION_ERROR;
1410     ELSIF lc_object_version_number > p_sbe_rec.object_version_number THEN
1411       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1412       RAISE OKC_API.G_EXCEPTION_ERROR;
1413     ELSIF lc_object_version_number <> p_sbe_rec.object_version_number THEN
1414       OKC_API.set_message(G_FND_APP,G_FORM_RECORD_CHANGED);
1415       RAISE OKC_API.G_EXCEPTION_ERROR;
1416     ELSIF lc_object_version_number = -1 THEN
1417       OKC_API.set_message(G_APP_NAME,G_RECORD_LOGICALLY_DELETED);
1418       RAISE OKC_API.G_EXCEPTION_ERROR;
1419     END IF;
1420     x_return_status := l_return_status;
1421     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1422   EXCEPTION
1423     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1424       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1425       (
1426         l_api_name,
1427         G_PKG_NAME,
1428         'OKC_API.G_RET_STS_ERROR',
1429         x_msg_count,
1430         x_msg_data,
1431         '_PVT'
1432       );
1433     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1434       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1435       (
1436         l_api_name,
1437         G_PKG_NAME,
1438         'OKC_API.G_RET_STS_UNEXP_ERROR',
1439         x_msg_count,
1440         x_msg_data,
1441         '_PVT'
1442       );
1443     WHEN OTHERS THEN
1444       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1445       (
1446         l_api_name,
1447         G_PKG_NAME,
1448         'OTHERS',
1449         x_msg_count,
1450         x_msg_data,
1451         '_PVT'
1452       );
1453   END lock_row;
1454   -----------------------------------------
1455   -- lock_row for: OKS_SUBSCR_ELEMENTS_V --
1456   -----------------------------------------
1457   PROCEDURE lock_row(
1458     p_api_version                  IN NUMBER,
1459     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1460     x_return_status                OUT NOCOPY VARCHAR2,
1461     x_msg_count                    OUT NOCOPY NUMBER,
1462     x_msg_data                     OUT NOCOPY VARCHAR2,
1463     p_scev_rec                     IN scev_rec_type) IS
1464 
1465     l_api_version                  CONSTANT NUMBER := 1;
1466     l_api_name                     CONSTANT VARCHAR2(30) := 'V_lock_row';
1467     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1468     l_sbe_rec                      sbe_rec_type;
1469   BEGIN
1470     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1471                                               G_PKG_NAME,
1472                                               p_init_msg_list,
1473                                               l_api_version,
1474                                               p_api_version,
1475                                               '_PVT',
1476                                               x_return_status);
1477     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1478       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1479     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1480       RAISE OKC_API.G_EXCEPTION_ERROR;
1481     END IF;
1482     -----------------------------------------
1483     -- Move VIEW record to "Child" records --
1484     -----------------------------------------
1485     migrate(p_scev_rec, l_sbe_rec);
1486     ---------------------------------------------
1487     -- Call the LOCK_ROW for each child record --
1488     ---------------------------------------------
1489     lock_row(
1490       p_init_msg_list,
1491       l_return_status,
1492       x_msg_count,
1493       x_msg_data,
1494       l_sbe_rec
1495     );
1496     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1497       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1498     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1499       RAISE OKC_API.G_EXCEPTION_ERROR;
1500     END IF;
1501     x_return_status := l_return_status;
1502     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1503   EXCEPTION
1504     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1505       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1506       (
1507         l_api_name,
1508         G_PKG_NAME,
1509         'OKC_API.G_RET_STS_ERROR',
1510         x_msg_count,
1511         x_msg_data,
1512         '_PVT'
1513       );
1514     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1515       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1516       (
1517         l_api_name,
1518         G_PKG_NAME,
1519         'OKC_API.G_RET_STS_UNEXP_ERROR',
1520         x_msg_count,
1521         x_msg_data,
1522         '_PVT'
1523       );
1524     WHEN OTHERS THEN
1525       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1526       (
1527         l_api_name,
1528         G_PKG_NAME,
1529         'OTHERS',
1530         x_msg_count,
1531         x_msg_data,
1532         '_PVT'
1533       );
1534   END lock_row;
1535   --------------------------------------
1536   -- PL/SQL TBL lock_row for:SCEV_TBL --
1537   --------------------------------------
1538   PROCEDURE lock_row(
1539     p_api_version                  IN NUMBER,
1540     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1541     x_return_status                OUT NOCOPY VARCHAR2,
1542     x_msg_count                    OUT NOCOPY NUMBER,
1543     x_msg_data                     OUT NOCOPY VARCHAR2,
1544     p_scev_tbl                     IN scev_tbl_type,
1545     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
1546 
1547     l_api_version                  CONSTANT NUMBER := 1;
1548     l_api_name                     CONSTANT VARCHAR2(30) := 'V_error_tbl_lock_row';
1549     i                              NUMBER := 0;
1550   BEGIN
1551     OKC_API.init_msg_list(p_init_msg_list);
1552     -- Make sure PL/SQL table has recrods in it before passing
1553     IF (p_scev_tbl.COUNT > 0) THEN
1554       i := p_scev_tbl.FIRST;
1555       LOOP
1556         DECLARE
1557           l_error_rec         OKC_API.ERROR_REC_TYPE;
1558         BEGIN
1559           l_error_rec.api_name := l_api_name;
1560           l_error_rec.api_package := G_PKG_NAME;
1561           l_error_rec.idx := i;
1562           lock_row(
1563             p_api_version                  => p_api_version,
1564             p_init_msg_list                => OKC_API.G_FALSE,
1565             x_return_status                => l_error_rec.error_type,
1566             x_msg_count                    => l_error_rec.msg_count,
1567             x_msg_data                     => l_error_rec.msg_data,
1568             p_scev_rec                     => p_scev_tbl(i));
1569           IF (l_error_rec.error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
1570             l_error_rec.sqlcode := SQLCODE;
1571             load_error_tbl(l_error_rec, px_error_tbl);
1572           ELSE
1573             x_msg_count := l_error_rec.msg_count;
1574             x_msg_data := l_error_rec.msg_data;
1575           END IF;
1576         EXCEPTION
1577           WHEN OKC_API.G_EXCEPTION_ERROR THEN
1578             l_error_rec.error_type := OKC_API.G_RET_STS_ERROR;
1579             l_error_rec.sqlcode := SQLCODE;
1580             load_error_tbl(l_error_rec, px_error_tbl);
1581           WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1582             l_error_rec.error_type := OKC_API.G_RET_STS_UNEXP_ERROR;
1583             l_error_rec.sqlcode := SQLCODE;
1584             load_error_tbl(l_error_rec, px_error_tbl);
1585           WHEN OTHERS THEN
1586             l_error_rec.error_type := 'OTHERS';
1587             l_error_rec.sqlcode := SQLCODE;
1588             load_error_tbl(l_error_rec, px_error_tbl);
1589         END;
1590         EXIT WHEN (i = p_scev_tbl.LAST);
1591         i := p_scev_tbl.NEXT(i);
1592       END LOOP;
1593     END IF;
1594     -- Loop through the error_tbl to find the error with the highest severity
1595     -- and return it.
1596     x_return_status := find_highest_exception(px_error_tbl);
1597     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1598   EXCEPTION
1599     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1600       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1601       (
1602         l_api_name,
1603         G_PKG_NAME,
1604         'OKC_API.G_RET_STS_ERROR',
1605         x_msg_count,
1606         x_msg_data,
1607         '_PVT'
1608       );
1609     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1610       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1611       (
1612         l_api_name,
1613         G_PKG_NAME,
1614         'OKC_API.G_RET_STS_UNEXP_ERROR',
1615         x_msg_count,
1616         x_msg_data,
1617         '_PVT'
1618       );
1619     WHEN OTHERS THEN
1620       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1621       (
1622         l_api_name,
1623         G_PKG_NAME,
1624         'OTHERS',
1625         x_msg_count,
1626         x_msg_data,
1627         '_PVT'
1628       );
1629   END lock_row;
1630   --------------------------------------
1631   -- PL/SQL TBL lock_row for:SCEV_TBL --
1632   --------------------------------------
1633   PROCEDURE lock_row(
1634     p_api_version                  IN NUMBER,
1635     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1636     x_return_status                OUT NOCOPY VARCHAR2,
1637     x_msg_count                    OUT NOCOPY NUMBER,
1638     x_msg_data                     OUT NOCOPY VARCHAR2,
1639     p_scev_tbl                     IN scev_tbl_type) IS
1640 
1641     l_api_version                  CONSTANT NUMBER := 1;
1642     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_lock_row';
1643     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1644     l_error_tbl                    OKC_API.ERROR_TBL_TYPE;
1645   BEGIN
1646     OKC_API.init_msg_list(p_init_msg_list);
1647     -- Make sure PL/SQL table has recrods in it before passing
1648     IF (p_scev_tbl.COUNT > 0) THEN
1649       lock_row(
1650         p_api_version                  => p_api_version,
1651         p_init_msg_list                => OKC_API.G_FALSE,
1652         x_return_status                => x_return_status,
1653         x_msg_count                    => x_msg_count,
1654         x_msg_data                     => x_msg_data,
1655         p_scev_tbl                     => p_scev_tbl,
1656         px_error_tbl                   => l_error_tbl);
1657     END IF;
1658     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1659   EXCEPTION
1660     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1661       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1662       (
1663         l_api_name,
1664         G_PKG_NAME,
1665         'OKC_API.G_RET_STS_ERROR',
1666         x_msg_count,
1667         x_msg_data,
1668         '_PVT'
1669       );
1670     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1671       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1672       (
1673         l_api_name,
1674         G_PKG_NAME,
1675         'OKC_API.G_RET_STS_UNEXP_ERROR',
1676         x_msg_count,
1677         x_msg_data,
1678         '_PVT'
1679       );
1680     WHEN OTHERS THEN
1681       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1682       (
1683         l_api_name,
1684         G_PKG_NAME,
1685         'OTHERS',
1686         x_msg_count,
1687         x_msg_data,
1688         '_PVT'
1689       );
1690   END lock_row;
1691   ---------------------------------------------------------------------------
1692   -- PROCEDURE update_row
1693   ---------------------------------------------------------------------------
1694   ----------------------------------------
1695   -- update_row for:OKS_SUBSCR_ELEMENTS --
1696   ----------------------------------------
1697   PROCEDURE update_row(
1698     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1699     x_return_status                OUT NOCOPY VARCHAR2,
1700     x_msg_count                    OUT NOCOPY NUMBER,
1701     x_msg_data                     OUT NOCOPY VARCHAR2,
1702     p_sbe_rec                      IN sbe_rec_type,
1703     x_sbe_rec                      OUT NOCOPY sbe_rec_type) IS
1704 
1705     l_api_version                  CONSTANT NUMBER := 1;
1706     l_api_name                     CONSTANT VARCHAR2(30) := 'B_update_row';
1707     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1708     l_sbe_rec                      sbe_rec_type := p_sbe_rec;
1709     l_def_sbe_rec                  sbe_rec_type;
1710     l_row_notfound                 BOOLEAN := TRUE;
1711     ----------------------------------
1712     -- FUNCTION populate_new_record --
1713     ----------------------------------
1714     FUNCTION populate_new_record (
1715       p_sbe_rec IN sbe_rec_type,
1716       x_sbe_rec OUT NOCOPY sbe_rec_type
1717     ) RETURN VARCHAR2 IS
1718       l_sbe_rec                      sbe_rec_type;
1719       l_row_notfound                 BOOLEAN := TRUE;
1720       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1721     BEGIN
1722       x_sbe_rec := p_sbe_rec;
1723       -- Get current database values
1724       l_sbe_rec := get_rec(p_sbe_rec, l_return_status);
1725       IF (l_return_status = OKC_API.G_RET_STS_SUCCESS) THEN
1726         IF (x_sbe_rec.id = OKC_API.G_MISS_NUM)
1727         THEN
1728           x_sbe_rec.id := l_sbe_rec.id;
1729         END IF;
1730         IF (x_sbe_rec.osh_id = OKC_API.G_MISS_NUM)
1731         THEN
1732           x_sbe_rec.osh_id := l_sbe_rec.osh_id;
1733         END IF;
1734         IF (x_sbe_rec.dnz_chr_id = OKC_API.G_MISS_NUM)
1735         THEN
1736           x_sbe_rec.dnz_chr_id := l_sbe_rec.dnz_chr_id;
1737         END IF;
1738         IF (x_sbe_rec.dnz_cle_id = OKC_API.G_MISS_NUM)
1739         THEN
1740           x_sbe_rec.dnz_cle_id := l_sbe_rec.dnz_cle_id;
1741         END IF;
1742         IF (x_sbe_rec.linked_flag = OKC_API.G_MISS_CHAR)
1743         THEN
1744           x_sbe_rec.linked_flag := l_sbe_rec.linked_flag;
1745         END IF;
1746         IF (x_sbe_rec.seq_no = OKC_API.G_MISS_NUM)
1747         THEN
1748           x_sbe_rec.seq_no := l_sbe_rec.seq_no;
1749         END IF;
1750         IF (x_sbe_rec.om_interface_date = OKC_API.G_MISS_DATE)
1751         THEN
1752           x_sbe_rec.om_interface_date := l_sbe_rec.om_interface_date;
1753         END IF;
1754         IF (x_sbe_rec.amount = OKC_API.G_MISS_NUM)
1755         THEN
1756           x_sbe_rec.amount := l_sbe_rec.amount;
1757         END IF;
1758         IF (x_sbe_rec.start_date = OKC_API.G_MISS_DATE)
1759         THEN
1760           x_sbe_rec.start_date := l_sbe_rec.start_date;
1761         END IF;
1762         IF (x_sbe_rec.end_date = OKC_API.G_MISS_DATE)
1763         THEN
1764           x_sbe_rec.end_date := l_sbe_rec.end_date;
1765         END IF;
1766         IF (x_sbe_rec.quantity = OKC_API.G_MISS_NUM)
1767         THEN
1768           x_sbe_rec.quantity := l_sbe_rec.quantity;
1769         END IF;
1770         IF (x_sbe_rec.uom_code = OKC_API.G_MISS_CHAR)
1771         THEN
1772           x_sbe_rec.uom_code := l_sbe_rec.uom_code;
1773         END IF;
1774         IF (x_sbe_rec.order_header_id = OKC_API.G_MISS_NUM)
1775         THEN
1776           x_sbe_rec.order_header_id := l_sbe_rec.order_header_id;
1777         END IF;
1778         IF (x_sbe_rec.order_line_id = OKC_API.G_MISS_NUM)
1779         THEN
1780           x_sbe_rec.order_line_id := l_sbe_rec.order_line_id;
1781         END IF;
1782         IF (x_sbe_rec.object_version_number = OKC_API.G_MISS_NUM)
1783         THEN
1784           x_sbe_rec.object_version_number := l_sbe_rec.object_version_number;
1785         END IF;
1786         IF (x_sbe_rec.created_by = OKC_API.G_MISS_NUM)
1787         THEN
1788           x_sbe_rec.created_by := l_sbe_rec.created_by;
1789         END IF;
1790         IF (x_sbe_rec.creation_date = OKC_API.G_MISS_DATE)
1791         THEN
1792           x_sbe_rec.creation_date := l_sbe_rec.creation_date;
1793         END IF;
1794         IF (x_sbe_rec.last_updated_by = OKC_API.G_MISS_NUM)
1795         THEN
1796           x_sbe_rec.last_updated_by := l_sbe_rec.last_updated_by;
1797         END IF;
1798         IF (x_sbe_rec.last_update_date = OKC_API.G_MISS_DATE)
1799         THEN
1800           x_sbe_rec.last_update_date := l_sbe_rec.last_update_date;
1801         END IF;
1802         IF (x_sbe_rec.last_update_login = OKC_API.G_MISS_NUM)
1803         THEN
1804           x_sbe_rec.last_update_login := l_sbe_rec.last_update_login;
1805         END IF;
1806       END IF;
1807       RETURN(l_return_status);
1808     END populate_new_record;
1809     --------------------------------------------
1810     -- Set_Attributes for:OKS_SUBSCR_ELEMENTS --
1811     --------------------------------------------
1812     FUNCTION Set_Attributes (
1813       p_sbe_rec IN sbe_rec_type,
1814       x_sbe_rec OUT NOCOPY sbe_rec_type
1815     ) RETURN VARCHAR2 IS
1816       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1817     BEGIN
1818       x_sbe_rec := p_sbe_rec;
1819       x_sbe_rec.OBJECT_VERSION_NUMBER := p_sbe_rec.OBJECT_VERSION_NUMBER + 1;
1820       RETURN(l_return_status);
1821     END Set_Attributes;
1822   BEGIN
1823     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
1824                                               p_init_msg_list,
1825                                               '_PVT',
1826                                               x_return_status);
1827     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1828       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1829     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1830       RAISE OKC_API.G_EXCEPTION_ERROR;
1831     END IF;
1832     --- Setting item attributes
1833     l_return_status := Set_Attributes(
1834       p_sbe_rec,                         -- IN
1835       l_sbe_rec);                        -- OUT
1836     --- If any errors happen abort API
1837     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1838       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1839     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1840       RAISE OKC_API.G_EXCEPTION_ERROR;
1841     END IF;
1842     l_return_status := populate_new_record(l_sbe_rec, l_def_sbe_rec);
1843     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
1844       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
1845     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
1846       RAISE OKC_API.G_EXCEPTION_ERROR;
1847     END IF;
1848     UPDATE OKS_SUBSCR_ELEMENTS
1849     SET OSH_ID = l_def_sbe_rec.osh_id,
1850         DNZ_CHR_ID = l_def_sbe_rec.dnz_chr_id,
1851         DNZ_CLE_ID = l_def_sbe_rec.dnz_cle_id,
1852         LINKED_FLAG = l_def_sbe_rec.linked_flag,
1853         SEQ_NO = l_def_sbe_rec.seq_no,
1854         OM_INTERFACE_DATE = l_def_sbe_rec.om_interface_date,
1855         AMOUNT = l_def_sbe_rec.amount,
1856         START_DATE = l_def_sbe_rec.start_date,
1857         END_DATE = l_def_sbe_rec.end_date,
1858         QUANTITY = l_def_sbe_rec.quantity,
1859         UOM_CODE = l_def_sbe_rec.uom_code,
1860         ORDER_HEADER_ID = l_def_sbe_rec.order_header_id,
1861         ORDER_LINE_ID = l_def_sbe_rec.order_line_id,
1862         OBJECT_VERSION_NUMBER = l_def_sbe_rec.object_version_number,
1863         CREATED_BY = l_def_sbe_rec.created_by,
1864         CREATION_DATE = l_def_sbe_rec.creation_date,
1865         LAST_UPDATED_BY = l_def_sbe_rec.last_updated_by,
1866         LAST_UPDATE_DATE = l_def_sbe_rec.last_update_date,
1867         LAST_UPDATE_LOGIN = l_def_sbe_rec.last_update_login
1868     WHERE ID = l_def_sbe_rec.id;
1869 
1870     x_sbe_rec := l_sbe_rec;
1871     x_return_status := l_return_status;
1872     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
1873   EXCEPTION
1874     WHEN OKC_API.G_EXCEPTION_ERROR THEN
1875       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1876       (
1877         l_api_name,
1878         G_PKG_NAME,
1879         'OKC_API.G_RET_STS_ERROR',
1880         x_msg_count,
1881         x_msg_data,
1882         '_PVT'
1883       );
1884     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
1885       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1886       (
1887         l_api_name,
1888         G_PKG_NAME,
1889         'OKC_API.G_RET_STS_UNEXP_ERROR',
1890         x_msg_count,
1891         x_msg_data,
1892         '_PVT'
1893       );
1894     WHEN OTHERS THEN
1895       x_return_status := OKC_API.HANDLE_EXCEPTIONS
1896       (
1897         l_api_name,
1898         G_PKG_NAME,
1899         'OTHERS',
1900         x_msg_count,
1901         x_msg_data,
1902         '_PVT'
1903       );
1904   END update_row;
1905   ------------------------------------------
1906   -- update_row for:OKS_SUBSCR_ELEMENTS_V --
1907   ------------------------------------------
1908   PROCEDURE update_row(
1909     p_api_version                  IN NUMBER,
1910     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
1911     x_return_status                OUT NOCOPY VARCHAR2,
1912     x_msg_count                    OUT NOCOPY NUMBER,
1913     x_msg_data                     OUT NOCOPY VARCHAR2,
1914     p_scev_rec                     IN scev_rec_type,
1915     x_scev_rec                     OUT NOCOPY scev_rec_type) IS
1916 
1917     l_api_version                  CONSTANT NUMBER := 1;
1918     l_api_name                     CONSTANT VARCHAR2(30) := 'V_update_row';
1919     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1920     l_scev_rec                     scev_rec_type := p_scev_rec;
1921     l_def_scev_rec                 scev_rec_type;
1922     l_db_scev_rec                  scev_rec_type;
1923     l_sbe_rec                      sbe_rec_type;
1924     lx_sbe_rec                     sbe_rec_type;
1925     -------------------------------
1926     -- FUNCTION fill_who_columns --
1927     -------------------------------
1928     FUNCTION fill_who_columns (
1929       p_scev_rec IN scev_rec_type
1930     ) RETURN scev_rec_type IS
1931       l_scev_rec scev_rec_type := p_scev_rec;
1932     BEGIN
1933       l_scev_rec.LAST_UPDATE_DATE := SYSDATE;
1934       l_scev_rec.LAST_UPDATED_BY := FND_GLOBAL.USER_ID;
1935       l_scev_rec.LAST_UPDATE_LOGIN := FND_GLOBAL.LOGIN_ID;
1936       RETURN(l_scev_rec);
1937     END fill_who_columns;
1938     ----------------------------------
1939     -- FUNCTION populate_new_record --
1940     ----------------------------------
1941     FUNCTION populate_new_record (
1942       p_scev_rec IN scev_rec_type,
1943       x_scev_rec OUT NOCOPY scev_rec_type
1944     ) RETURN VARCHAR2 IS
1945       l_row_notfound                 BOOLEAN := TRUE;
1946       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
1947     BEGIN
1948       x_scev_rec := p_scev_rec;
1949       -- Get current database values
1950       -- NOTE: Never assign the OBJECT_VERSION_NUMBER.  Force the user to pass it
1951       --       so it may be verified through LOCK_ROW.
1952       l_db_scev_rec := get_rec(p_scev_rec, l_return_status);
1953       IF (l_return_status = OKC_API.G_RET_STS_SUCCESS) THEN
1954         IF (x_scev_rec.id = OKC_API.G_MISS_NUM)
1955         THEN
1956           x_scev_rec.id := l_db_scev_rec.id;
1957         END IF;
1958         IF (x_scev_rec.osh_id = OKC_API.G_MISS_NUM)
1959         THEN
1960           x_scev_rec.osh_id := l_db_scev_rec.osh_id;
1961         END IF;
1962         IF (x_scev_rec.dnz_chr_id = OKC_API.G_MISS_NUM)
1963         THEN
1964           x_scev_rec.dnz_chr_id := l_db_scev_rec.dnz_chr_id;
1965         END IF;
1966         IF (x_scev_rec.dnz_cle_id = OKC_API.G_MISS_NUM)
1967         THEN
1968           x_scev_rec.dnz_cle_id := l_db_scev_rec.dnz_cle_id;
1969         END IF;
1970         IF (x_scev_rec.linked_flag = OKC_API.G_MISS_CHAR)
1971         THEN
1972           x_scev_rec.linked_flag := l_db_scev_rec.linked_flag;
1973         END IF;
1974         IF (x_scev_rec.seq_no = OKC_API.G_MISS_NUM)
1975         THEN
1976           x_scev_rec.seq_no := l_db_scev_rec.seq_no;
1977         END IF;
1978         IF (x_scev_rec.om_interface_date = OKC_API.G_MISS_DATE)
1979         THEN
1980           x_scev_rec.om_interface_date := l_db_scev_rec.om_interface_date;
1981         END IF;
1982         IF (x_scev_rec.amount = OKC_API.G_MISS_NUM)
1983         THEN
1984           x_scev_rec.amount := l_db_scev_rec.amount;
1985         END IF;
1986         IF (x_scev_rec.start_date = OKC_API.G_MISS_DATE)
1987         THEN
1988           x_scev_rec.start_date := l_db_scev_rec.start_date;
1989         END IF;
1990         IF (x_scev_rec.end_date = OKC_API.G_MISS_DATE)
1991         THEN
1992           x_scev_rec.end_date := l_db_scev_rec.end_date;
1993         END IF;
1994         IF (x_scev_rec.quantity = OKC_API.G_MISS_NUM)
1995         THEN
1996           x_scev_rec.quantity := l_db_scev_rec.quantity;
1997         END IF;
1998         IF (x_scev_rec.uom_code = OKC_API.G_MISS_CHAR)
1999         THEN
2000           x_scev_rec.uom_code := l_db_scev_rec.uom_code;
2001         END IF;
2002         IF (x_scev_rec.order_header_id = OKC_API.G_MISS_NUM)
2003         THEN
2004           x_scev_rec.order_header_id := l_db_scev_rec.order_header_id;
2005         END IF;
2006         IF (x_scev_rec.order_line_id = OKC_API.G_MISS_NUM)
2007         THEN
2008           x_scev_rec.order_line_id := l_db_scev_rec.order_line_id;
2009         END IF;
2010         IF (x_scev_rec.created_by = OKC_API.G_MISS_NUM)
2011         THEN
2012           x_scev_rec.created_by := l_db_scev_rec.created_by;
2013         END IF;
2014         IF (x_scev_rec.creation_date = OKC_API.G_MISS_DATE)
2015         THEN
2016           x_scev_rec.creation_date := l_db_scev_rec.creation_date;
2017         END IF;
2018         IF (x_scev_rec.last_updated_by = OKC_API.G_MISS_NUM)
2019         THEN
2020           x_scev_rec.last_updated_by := l_db_scev_rec.last_updated_by;
2021         END IF;
2022         IF (x_scev_rec.last_update_date = OKC_API.G_MISS_DATE)
2023         THEN
2024           x_scev_rec.last_update_date := l_db_scev_rec.last_update_date;
2025         END IF;
2026         IF (x_scev_rec.last_update_login = OKC_API.G_MISS_NUM)
2027         THEN
2028           x_scev_rec.last_update_login := l_db_scev_rec.last_update_login;
2029         END IF;
2030       END IF;
2031       RETURN(l_return_status);
2032     END populate_new_record;
2033     ----------------------------------------------
2034     -- Set_Attributes for:OKS_SUBSCR_ELEMENTS_V --
2035     ----------------------------------------------
2036     FUNCTION Set_Attributes (
2037       p_scev_rec IN scev_rec_type,
2038       x_scev_rec OUT NOCOPY scev_rec_type
2039     ) RETURN VARCHAR2 IS
2040       l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2041     BEGIN
2042       x_scev_rec := p_scev_rec;
2043       RETURN(l_return_status);
2044     END Set_Attributes;
2045   BEGIN
2046     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2047                                               G_PKG_NAME,
2048                                               p_init_msg_list,
2049                                               l_api_version,
2050                                               p_api_version,
2051                                               '_PVT',
2052                                               x_return_status);
2053     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2054       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2055     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2056       RAISE OKC_API.G_EXCEPTION_ERROR;
2057     END IF;
2058     --- Setting item attributes
2059     l_return_status := Set_Attributes(
2060       p_scev_rec,                        -- IN
2061       x_scev_rec);                       -- OUT
2062     --- If any errors happen abort API
2063     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2064       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2065     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2066       RAISE OKC_API.G_EXCEPTION_ERROR;
2067     END IF;
2068     l_return_status := populate_new_record(l_scev_rec, l_def_scev_rec);
2069     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2070       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2071     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2072       RAISE OKC_API.G_EXCEPTION_ERROR;
2073     END IF;
2074     l_def_scev_rec := fill_who_columns(l_def_scev_rec);
2075     --- Validate all non-missing attributes (Item Level Validation)
2076     l_return_status := Validate_Attributes(l_def_scev_rec);
2077     --- If any errors happen abort API
2078     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2079       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2080     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2081       RAISE OKC_API.G_EXCEPTION_ERROR;
2082     END IF;
2083     l_return_status := Validate_Record(l_def_scev_rec, l_db_scev_rec);
2084     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2085       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2086     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2087       RAISE OKC_API.G_EXCEPTION_ERROR;
2088     END IF;
2089 
2090     -- Lock the Record
2091     lock_row(
2092       p_api_version                  => p_api_version,
2093       p_init_msg_list                => p_init_msg_list,
2094       x_return_status                => l_return_status,
2095       x_msg_count                    => x_msg_count,
2096       x_msg_data                     => x_msg_data,
2097       p_scev_rec                     => p_scev_rec);
2098     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2099       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2100     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2101       RAISE OKC_API.G_EXCEPTION_ERROR;
2102     END IF;
2103 
2104     -----------------------------------------
2105     -- Move VIEW record to "Child" records --
2106     -----------------------------------------
2107     migrate(l_def_scev_rec, l_sbe_rec);
2108     -----------------------------------------------
2109     -- Call the UPDATE_ROW for each child record --
2110     -----------------------------------------------
2111     update_row(
2112       p_init_msg_list,
2113       l_return_status,
2114       x_msg_count,
2115       x_msg_data,
2116       l_sbe_rec,
2117       lx_sbe_rec
2118     );
2119     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2120       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2121     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2122       RAISE OKC_API.G_EXCEPTION_ERROR;
2123     END IF;
2124     migrate(lx_sbe_rec, l_def_scev_rec);
2125     x_scev_rec := l_def_scev_rec;
2126     x_return_status := l_return_status;
2127     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2128   EXCEPTION
2129     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2130       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2131       (
2132         l_api_name,
2133         G_PKG_NAME,
2134         'OKC_API.G_RET_STS_ERROR',
2135         x_msg_count,
2136         x_msg_data,
2137         '_PVT'
2138       );
2139     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2140       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2141       (
2142         l_api_name,
2143         G_PKG_NAME,
2144         'OKC_API.G_RET_STS_UNEXP_ERROR',
2145         x_msg_count,
2146         x_msg_data,
2147         '_PVT'
2148       );
2149     WHEN OTHERS THEN
2150       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2151       (
2152         l_api_name,
2153         G_PKG_NAME,
2154         'OTHERS',
2155         x_msg_count,
2156         x_msg_data,
2157         '_PVT'
2158       );
2159   END update_row;
2160   ----------------------------------------
2161   -- PL/SQL TBL update_row for:scev_tbl --
2162   ----------------------------------------
2163   PROCEDURE update_row(
2164     p_api_version                  IN NUMBER,
2165     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2166     x_return_status                OUT NOCOPY VARCHAR2,
2167     x_msg_count                    OUT NOCOPY NUMBER,
2168     x_msg_data                     OUT NOCOPY VARCHAR2,
2169     p_scev_tbl                     IN scev_tbl_type,
2170     x_scev_tbl                     OUT NOCOPY scev_tbl_type,
2171     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
2172 
2173     l_api_version                  CONSTANT NUMBER := 1;
2174     l_api_name                     CONSTANT VARCHAR2(30) := 'V_error_tbl_update_row';
2175     i                              NUMBER := 0;
2176   BEGIN
2177     OKC_API.init_msg_list(p_init_msg_list);
2178     -- Make sure PL/SQL table has records in it before passing
2179     IF (p_scev_tbl.COUNT > 0) THEN
2180       i := p_scev_tbl.FIRST;
2181       LOOP
2182         DECLARE
2183           l_error_rec         OKC_API.ERROR_REC_TYPE;
2184         BEGIN
2185           l_error_rec.api_name := l_api_name;
2186           l_error_rec.api_package := G_PKG_NAME;
2187           l_error_rec.idx := i;
2188           update_row (
2189             p_api_version                  => p_api_version,
2190             p_init_msg_list                => OKC_API.G_FALSE,
2191             x_return_status                => l_error_rec.error_type,
2192             x_msg_count                    => l_error_rec.msg_count,
2193             x_msg_data                     => l_error_rec.msg_data,
2194             p_scev_rec                     => p_scev_tbl(i),
2195             x_scev_rec                     => x_scev_tbl(i));
2196           IF (l_error_rec.error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
2197             l_error_rec.sqlcode := SQLCODE;
2198             load_error_tbl(l_error_rec, px_error_tbl);
2199           ELSE
2200             x_msg_count := l_error_rec.msg_count;
2201             x_msg_data := l_error_rec.msg_data;
2202           END IF;
2203         EXCEPTION
2204           WHEN OKC_API.G_EXCEPTION_ERROR THEN
2205             l_error_rec.error_type := OKC_API.G_RET_STS_ERROR;
2206             l_error_rec.sqlcode := SQLCODE;
2207             load_error_tbl(l_error_rec, px_error_tbl);
2208           WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2209             l_error_rec.error_type := OKC_API.G_RET_STS_UNEXP_ERROR;
2210             l_error_rec.sqlcode := SQLCODE;
2211             load_error_tbl(l_error_rec, px_error_tbl);
2212           WHEN OTHERS THEN
2213             l_error_rec.error_type := 'OTHERS';
2214             l_error_rec.sqlcode := SQLCODE;
2215             load_error_tbl(l_error_rec, px_error_tbl);
2216         END;
2217         EXIT WHEN (i = p_scev_tbl.LAST);
2218         i := p_scev_tbl.NEXT(i);
2219       END LOOP;
2220     END IF;
2221     -- Loop through the error_tbl to find the error with the highest severity
2222     -- and return it.
2223     x_return_status := find_highest_exception(px_error_tbl);
2224     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2225   EXCEPTION
2226     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2227       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2228       (
2229         l_api_name,
2230         G_PKG_NAME,
2231         'OKC_API.G_RET_STS_ERROR',
2232         x_msg_count,
2233         x_msg_data,
2234         '_PVT'
2235       );
2236     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2237       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2238       (
2239         l_api_name,
2240         G_PKG_NAME,
2241         'OKC_API.G_RET_STS_UNEXP_ERROR',
2242         x_msg_count,
2243         x_msg_data,
2244         '_PVT'
2245       );
2246     WHEN OTHERS THEN
2247       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2248       (
2249         l_api_name,
2250         G_PKG_NAME,
2251         'OTHERS',
2252         x_msg_count,
2253         x_msg_data,
2254         '_PVT'
2255       );
2256   END update_row;
2257 
2258   ----------------------------------------
2259   -- PL/SQL TBL update_row for:SCEV_TBL --
2260   ----------------------------------------
2261   PROCEDURE update_row(
2262     p_api_version                  IN NUMBER,
2263     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2264     x_return_status                OUT NOCOPY VARCHAR2,
2265     x_msg_count                    OUT NOCOPY NUMBER,
2266     x_msg_data                     OUT NOCOPY VARCHAR2,
2267     p_scev_tbl                     IN scev_tbl_type,
2268     x_scev_tbl                     OUT NOCOPY scev_tbl_type) IS
2269 
2270     l_api_version                  CONSTANT NUMBER := 1;
2271     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_update_row';
2272     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2273     l_error_tbl                    OKC_API.ERROR_TBL_TYPE;
2274   BEGIN
2275     OKC_API.init_msg_list(p_init_msg_list);
2276     -- Make sure PL/SQL table has records in it before passing
2277     IF (p_scev_tbl.COUNT > 0) THEN
2278       update_row (
2279         p_api_version                  => p_api_version,
2280         p_init_msg_list                => OKC_API.G_FALSE,
2281         x_return_status                => x_return_status,
2282         x_msg_count                    => x_msg_count,
2283         x_msg_data                     => x_msg_data,
2284         p_scev_tbl                     => p_scev_tbl,
2285         x_scev_tbl                     => x_scev_tbl,
2286         px_error_tbl                   => l_error_tbl);
2287     END IF;
2288     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2289   EXCEPTION
2290     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2291       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2292       (
2293         l_api_name,
2294         G_PKG_NAME,
2295         'OKC_API.G_RET_STS_ERROR',
2296         x_msg_count,
2297         x_msg_data,
2298         '_PVT'
2299       );
2300     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2301       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2302       (
2303         l_api_name,
2304         G_PKG_NAME,
2305         'OKC_API.G_RET_STS_UNEXP_ERROR',
2306         x_msg_count,
2307         x_msg_data,
2308         '_PVT'
2309       );
2310     WHEN OTHERS THEN
2311       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2312       (
2313         l_api_name,
2314         G_PKG_NAME,
2315         'OTHERS',
2316         x_msg_count,
2317         x_msg_data,
2318         '_PVT'
2319       );
2320   END update_row;
2321 
2322   ---------------------------------------------------------------------------
2323   -- PROCEDURE delete_row
2324   ---------------------------------------------------------------------------
2325   ----------------------------------------
2326   -- delete_row for:OKS_SUBSCR_ELEMENTS --
2327   ----------------------------------------
2328   PROCEDURE delete_row(
2329     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2330     x_return_status                OUT NOCOPY VARCHAR2,
2331     x_msg_count                    OUT NOCOPY NUMBER,
2332     x_msg_data                     OUT NOCOPY VARCHAR2,
2333     p_sbe_rec                      IN sbe_rec_type) IS
2334 
2335     l_api_version                  CONSTANT NUMBER := 1;
2336     l_api_name                     CONSTANT VARCHAR2(30) := 'B_delete_row';
2337     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2338     l_sbe_rec                      sbe_rec_type := p_sbe_rec;
2339     l_row_notfound                 BOOLEAN := TRUE;
2340   BEGIN
2341     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2342                                               p_init_msg_list,
2343                                               '_PVT',
2344                                               x_return_status);
2345     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2346       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2347     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2348       RAISE OKC_API.G_EXCEPTION_ERROR;
2349     END IF;
2350 
2351     DELETE FROM OKS_SUBSCR_ELEMENTS
2352      WHERE ID = p_sbe_rec.id;
2353 
2354     x_return_status := l_return_status;
2355     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2356   EXCEPTION
2357     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2358       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2359       (
2360         l_api_name,
2361         G_PKG_NAME,
2362         'OKC_API.G_RET_STS_ERROR',
2363         x_msg_count,
2364         x_msg_data,
2365         '_PVT'
2366       );
2367     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2368       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2369       (
2370         l_api_name,
2371         G_PKG_NAME,
2372         'OKC_API.G_RET_STS_UNEXP_ERROR',
2373         x_msg_count,
2374         x_msg_data,
2375         '_PVT'
2376       );
2377     WHEN OTHERS THEN
2378       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2379       (
2380         l_api_name,
2381         G_PKG_NAME,
2382         'OTHERS',
2383         x_msg_count,
2384         x_msg_data,
2385         '_PVT'
2386       );
2387   END delete_row;
2388   ------------------------------------------
2389   -- delete_row for:OKS_SUBSCR_ELEMENTS_V --
2390   ------------------------------------------
2391   PROCEDURE delete_row(
2392     p_api_version                  IN NUMBER,
2393     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2394     x_return_status                OUT NOCOPY VARCHAR2,
2395     x_msg_count                    OUT NOCOPY NUMBER,
2396     x_msg_data                     OUT NOCOPY VARCHAR2,
2397     p_scev_rec                     IN scev_rec_type) IS
2398 
2399     l_api_version                  CONSTANT NUMBER := 1;
2400     l_api_name                     CONSTANT VARCHAR2(30) := 'V_delete_row';
2401     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2402     l_scev_rec                     scev_rec_type := p_scev_rec;
2403     l_sbe_rec                      sbe_rec_type;
2404   BEGIN
2405     l_return_status := OKC_API.START_ACTIVITY(l_api_name,
2406                                               G_PKG_NAME,
2407                                               p_init_msg_list,
2408                                               l_api_version,
2409                                               p_api_version,
2410                                               '_PVT',
2411                                               x_return_status);
2412     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2413       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2414     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2415       RAISE OKC_API.G_EXCEPTION_ERROR;
2416     END IF;
2417     -----------------------------------------
2418     -- Move VIEW record to "Child" records --
2419     -----------------------------------------
2420     migrate(l_scev_rec, l_sbe_rec);
2421     -----------------------------------------------
2422     -- Call the DELETE_ROW for each child record --
2423     -----------------------------------------------
2424     delete_row(
2425       p_init_msg_list,
2426       l_return_status,
2427       x_msg_count,
2428       x_msg_data,
2429       l_sbe_rec
2430     );
2431     IF (l_return_status = OKC_API.G_RET_STS_UNEXP_ERROR) THEN
2432       RAISE OKC_API.G_EXCEPTION_UNEXPECTED_ERROR;
2433     ELSIF (l_return_status = OKC_API.G_RET_STS_ERROR) THEN
2434       RAISE OKC_API.G_EXCEPTION_ERROR;
2435     END IF;
2436     x_return_status := l_return_status;
2437     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2438   EXCEPTION
2439     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2440       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2441       (
2442         l_api_name,
2443         G_PKG_NAME,
2444         'OKC_API.G_RET_STS_ERROR',
2445         x_msg_count,
2446         x_msg_data,
2447         '_PVT'
2448       );
2449     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2450       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2451       (
2452         l_api_name,
2453         G_PKG_NAME,
2454         'OKC_API.G_RET_STS_UNEXP_ERROR',
2455         x_msg_count,
2456         x_msg_data,
2457         '_PVT'
2458       );
2459     WHEN OTHERS THEN
2460       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2461       (
2462         l_api_name,
2463         G_PKG_NAME,
2464         'OTHERS',
2465         x_msg_count,
2466         x_msg_data,
2467         '_PVT'
2468       );
2469   END delete_row;
2470   -----------------------------------------------------
2471   -- PL/SQL TBL delete_row for:OKS_SUBSCR_ELEMENTS_V --
2472   -----------------------------------------------------
2473   PROCEDURE delete_row(
2474     p_api_version                  IN NUMBER,
2475     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2476     x_return_status                OUT NOCOPY VARCHAR2,
2477     x_msg_count                    OUT NOCOPY NUMBER,
2478     x_msg_data                     OUT NOCOPY VARCHAR2,
2479     p_scev_tbl                     IN scev_tbl_type,
2480     px_error_tbl                   IN OUT NOCOPY OKC_API.ERROR_TBL_TYPE) IS
2481 
2482     l_api_version                  CONSTANT NUMBER := 1;
2483     l_api_name                     CONSTANT VARCHAR2(30) := 'V_error_tbl_delete_row';
2484     i                              NUMBER := 0;
2485   BEGIN
2486     OKC_API.init_msg_list(p_init_msg_list);
2487     -- Make sure PL/SQL table has records in it before passing
2488     IF (p_scev_tbl.COUNT > 0) THEN
2489       i := p_scev_tbl.FIRST;
2490       LOOP
2491         DECLARE
2492           l_error_rec         OKC_API.ERROR_REC_TYPE;
2493         BEGIN
2494           l_error_rec.api_name := l_api_name;
2495           l_error_rec.api_package := G_PKG_NAME;
2496           l_error_rec.idx := i;
2497           delete_row (
2498             p_api_version                  => p_api_version,
2499             p_init_msg_list                => OKC_API.G_FALSE,
2500             x_return_status                => l_error_rec.error_type,
2501             x_msg_count                    => l_error_rec.msg_count,
2502             x_msg_data                     => l_error_rec.msg_data,
2503             p_scev_rec                     => p_scev_tbl(i));
2504           IF (l_error_rec.error_type <> OKC_API.G_RET_STS_SUCCESS) THEN
2505             l_error_rec.sqlcode := SQLCODE;
2506             load_error_tbl(l_error_rec, px_error_tbl);
2507           ELSE
2508             x_msg_count := l_error_rec.msg_count;
2509             x_msg_data := l_error_rec.msg_data;
2510           END IF;
2511         EXCEPTION
2512           WHEN OKC_API.G_EXCEPTION_ERROR THEN
2513             l_error_rec.error_type := OKC_API.G_RET_STS_ERROR;
2514             l_error_rec.sqlcode := SQLCODE;
2515             load_error_tbl(l_error_rec, px_error_tbl);
2516           WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2517             l_error_rec.error_type := OKC_API.G_RET_STS_UNEXP_ERROR;
2518             l_error_rec.sqlcode := SQLCODE;
2519             load_error_tbl(l_error_rec, px_error_tbl);
2520           WHEN OTHERS THEN
2521             l_error_rec.error_type := 'OTHERS';
2522             l_error_rec.sqlcode := SQLCODE;
2523             load_error_tbl(l_error_rec, px_error_tbl);
2524         END;
2525         EXIT WHEN (i = p_scev_tbl.LAST);
2526         i := p_scev_tbl.NEXT(i);
2527       END LOOP;
2528     END IF;
2529     -- Loop through the error_tbl to find the error with the highest severity
2530     -- and return it.
2531     x_return_status := find_highest_exception(px_error_tbl);
2532     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2533   EXCEPTION
2534     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2535       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2536       (
2537         l_api_name,
2538         G_PKG_NAME,
2539         'OKC_API.G_RET_STS_ERROR',
2540         x_msg_count,
2541         x_msg_data,
2542         '_PVT'
2543       );
2544     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2545       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2546       (
2547         l_api_name,
2548         G_PKG_NAME,
2549         'OKC_API.G_RET_STS_UNEXP_ERROR',
2550         x_msg_count,
2551         x_msg_data,
2552         '_PVT'
2553       );
2554     WHEN OTHERS THEN
2555       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2556       (
2557         l_api_name,
2558         G_PKG_NAME,
2559         'OTHERS',
2560         x_msg_count,
2561         x_msg_data,
2562         '_PVT'
2563       );
2564   END delete_row;
2565 
2566   -----------------------------------------------------
2567   -- PL/SQL TBL delete_row for:OKS_SUBSCR_ELEMENTS_V --
2568   -----------------------------------------------------
2569   PROCEDURE delete_row(
2570     p_api_version                  IN NUMBER,
2571     p_init_msg_list                IN VARCHAR2 DEFAULT OKC_API.G_FALSE,
2572     x_return_status                OUT NOCOPY VARCHAR2,
2573     x_msg_count                    OUT NOCOPY NUMBER,
2574     x_msg_data                     OUT NOCOPY VARCHAR2,
2575     p_scev_tbl                     IN scev_tbl_type) IS
2576 
2577     l_api_version                  CONSTANT NUMBER := 1;
2578     l_api_name                     CONSTANT VARCHAR2(30) := 'V_tbl_delete_row';
2579     l_return_status                VARCHAR2(1) := OKC_API.G_RET_STS_SUCCESS;
2580     l_error_tbl                    OKC_API.ERROR_TBL_TYPE;
2581   BEGIN
2582     OKC_API.init_msg_list(p_init_msg_list);
2583     -- Make sure PL/SQL table has records in it before passing
2584     IF (p_scev_tbl.COUNT > 0) THEN
2585       delete_row (
2586         p_api_version                  => p_api_version,
2587         p_init_msg_list                => OKC_API.G_FALSE,
2588         x_return_status                => x_return_status,
2589         x_msg_count                    => x_msg_count,
2590         x_msg_data                     => x_msg_data,
2591         p_scev_tbl                     => p_scev_tbl,
2592         px_error_tbl                   => l_error_tbl);
2593     END IF;
2594     OKC_API.END_ACTIVITY(x_msg_count, x_msg_data);
2595   EXCEPTION
2596     WHEN OKC_API.G_EXCEPTION_ERROR THEN
2597       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2598       (
2599         l_api_name,
2600         G_PKG_NAME,
2601         'OKC_API.G_RET_STS_ERROR',
2602         x_msg_count,
2603         x_msg_data,
2604         '_PVT'
2605       );
2606     WHEN OKC_API.G_EXCEPTION_UNEXPECTED_ERROR THEN
2607       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2608       (
2609         l_api_name,
2610         G_PKG_NAME,
2611         'OKC_API.G_RET_STS_UNEXP_ERROR',
2612         x_msg_count,
2613         x_msg_data,
2614         '_PVT'
2615       );
2616     WHEN OTHERS THEN
2617       x_return_status := OKC_API.HANDLE_EXCEPTIONS
2618       (
2619         l_api_name,
2620         G_PKG_NAME,
2621         'OTHERS',
2622         x_msg_count,
2623         x_msg_data,
2624         '_PVT'
2625       );
2626   END delete_row;
2627 
2628 END OKS_SUBSCR_ELEMS_PVT;