DBA Data[Home] [Help]

PACKAGE BODY: APPS.GL_JE_LINES_PKG

Source


1 PACKAGE BODY GL_JE_LINES_PKG as
2 /* $Header: glijelnb.pls 120.18.12010000.3 2009/05/28 11:53:05 skotakar ship $ */
3 
4   --
5   -- PRIVATE VARIABLES
6   --
7 
8   -- Keeps track of the last entered and accounted currencies
9   -- and their minimum accountable unit and precision
10   current_entered_currency  	VARCHAR2(15);
11   entered_precision 		NUMBER;
12   entered_mau			NUMBER;
13   current_accounted_currency  	VARCHAR2(15);
14   accounted_precision 		NUMBER;
15   accounted_mau			NUMBER;
16 
17   -- Keeps track of the current delimiter
18   delim               	VARCHAR2(1) := '';
19   delim_coa_id		NUMBER := '';
20 
21   --
22   -- PUBLIC FUNCTIONS
23   --
24   PROCEDURE check_unique(header_id NUMBER, line_num NUMBER,
25                          row_id VARCHAR2) IS
26     CURSOR chk_duplicates is
27       SELECT 'Duplicate'
28       FROM   GL_JE_LINES jel
29       WHERE  jel.je_header_id = header_id
30       AND    jel.je_line_num = line_num
31       AND    (   row_id is null
32               OR jel.rowid <> row_id);
33     dummy VARCHAR2(100);
34   BEGIN
35     OPEN chk_duplicates;
36     FETCH chk_duplicates INTO dummy;
37 
38     IF chk_duplicates%FOUND THEN
39       CLOSE chk_duplicates;
40       fnd_message.set_name('SQLGL', 'GL_DUPLICATE_JE_LINE_NUM');
41       app_exception.raise_exception;
42     END IF;
43 
44     CLOSE chk_duplicates;
45 
46   EXCEPTION
47     WHEN app_exceptions.application_exception THEN
48       RAISE;
49     WHEN OTHERS THEN
50       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
51       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.check_unique');
52       RAISE;
53   END check_unique;
54 
55   PROCEDURE delete_lines(header_id  NUMBER) IS
56   BEGIN
57     -- Delete all of the lines in that header
58     DELETE gl_je_lines
59     WHERE  je_header_id = header_id;
60 
61     -- Delete the reference lines if any.
62     GL_IMPORT_REFERENCES_PKG.delete_lines (header_id);
63 
64   EXCEPTION
65     WHEN app_exceptions.application_exception THEN
66       RAISE;
67     WHEN OTHERS THEN
68       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
69       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.delete_lines');
70       RAISE;
71   END delete_lines;
72 
73   PROCEDURE update_lines(header_id		NUMBER,
74 			 x_period_name          VARCHAR2,
75 			 x_effective_date       DATE,
76 			 conversion_denom_rate  NUMBER,
77 			 conversion_numer_rate  NUMBER,
78 			 entered_currency	VARCHAR2,
79 			 accounted_currency	VARCHAR2,
80                          ignore_ignore_flag     VARCHAR2,
81 			 clear_stat		VARCHAR2,
82 			 user_id		NUMBER,
83 			 login_id		NUMBER) IS
84     ext_precision 	NUMBER;
85     entered_divisor	NUMBER := 1;
86     accounted_divisor	NUMBER := 1;
87   BEGIN
88 
89     IF (conversion_numer_rate <> -1) THEN
90       -- Get the minimum accountable unit and the precision
91       -- of the accounted currency
92       IF (accounted_currency <> nvl(current_accounted_currency,
93 	  			    '01234567890123456789')
94          ) THEN
95         current_accounted_currency := accounted_currency;
96 
97         -- Get the precision and minimum accountable
98         -- unit for the accounted currency
99         fnd_currency.get_info(current_accounted_currency,
100                               accounted_precision,
101                               ext_precision,
102                               accounted_mau);
103       END IF;
104 
105       -- Get the minimum accountable unit and the precision
106       -- of the entered currency
107       IF (entered_currency <> nvl(current_entered_currency,
108 	  			  '01234567890123456789')
109          ) THEN
110         current_entered_currency := entered_currency;
111 
112         IF (current_entered_currency = current_accounted_currency) THEN
113           entered_precision := accounted_precision;
114 	  entered_mau := accounted_mau;
115         ELSE
116           -- Get the precision and minimum accountable
117           -- unit for the accounted currency
118           fnd_currency.get_info(current_entered_currency,
119                                 entered_precision,
120                                 ext_precision,
121                               entered_mau);
122         END IF;
123       END IF;
124 
125       -- Get the minimum unit for the entered currency
126       IF (entered_mau IS NULL) THEN
127         entered_divisor := power(10, -1 * entered_precision);
128       ELSE
129         entered_divisor := entered_mau;
130       END IF;
131 
132       -- Get the minimum unit for the accounted currency
133       IF (accounted_mau IS NULL) THEN
134         accounted_divisor := power(10, -1 * accounted_precision);
135       ELSE
136         accounted_divisor := accounted_mau;
137       END IF;
138     END IF;
139 
140     UPDATE gl_je_lines
141     SET period_name	  = x_period_name,
142 	effective_date	  = x_effective_date,
143 	entered_dr	  = decode(conversion_numer_rate, -1, entered_dr,
144 			      round(entered_dr/entered_divisor)*entered_divisor),
145 	entered_cr	  = decode(conversion_numer_rate, -1, entered_cr,
146 			      round(entered_cr/entered_divisor)*entered_divisor),
147 	accounted_dr	  = decode(conversion_numer_rate, -1, accounted_dr,
148                               decode(decode(ignore_ignore_flag,
149 				       'Y', 'N',
150 				       ignore_rate_flag),
151 				'Y', accounted_dr,
152 				round((((round(entered_dr/entered_divisor)
153                                           *entered_divisor)
154                                           /conversion_denom_rate)
155                                           *conversion_numer_rate)
156                                       / accounted_divisor)*accounted_divisor)),
157 	accounted_cr	  = decode(conversion_numer_rate, -1, accounted_cr,
158                               decode(decode(ignore_ignore_flag,
159 				       'Y', 'N',
160 				       ignore_rate_flag),
161 				'Y', accounted_cr,
162 				round((((round(entered_cr/entered_divisor)
163                                           *entered_divisor)
164                                           /conversion_denom_rate)
165                                           *conversion_numer_rate)
166                                       / accounted_divisor)*accounted_divisor)),
167         ignore_rate_flag  = decode(ignore_ignore_flag, 'Y', null,
168                                                        ignore_rate_flag),
169 	stat_amount       = decode(clear_stat, 'Y', null, stat_amount),
170         last_update_date  = sysdate,
171 	last_updated_by	  = user_id,
172 	last_update_login = login_id
173     WHERE  je_header_id = header_id;
174 
175   EXCEPTION
176     WHEN OTHERS THEN
177       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
178       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.update_lines');
179       RAISE;
180   END update_lines;
181 
182   PROCEDURE calculate_totals(	header_id				NUMBER,
183 		      		running_total_dr		IN OUT NOCOPY	NUMBER,
184 		      		running_total_cr		IN OUT NOCOPY	NUMBER,
185 		      		running_total_accounted_dr	IN OUT NOCOPY	NUMBER,
186 		      		running_total_accounted_cr	IN OUT NOCOPY	NUMBER
187                             ) IS
188     CURSOR calc_totals is
189       SELECT sum(nvl(entered_dr, 0)),
190              sum(nvl(entered_cr, 0)),
191              sum(nvl(accounted_dr, 0)),
192              sum(nvl(accounted_cr, 0))
193       FROM   GL_JE_LINES jel
194       WHERE  jel.je_header_id = header_id;
195   BEGIN
196     OPEN calc_totals;
197     FETCH calc_totals INTO running_total_dr, running_total_cr,
198 			   running_total_accounted_dr,
199 			   running_total_accounted_cr;
200 
201     IF calc_totals%NOTFOUND THEN
202       CLOSE calc_totals;
203       RAISE NO_DATA_FOUND;
204     END IF;
205 
206     CLOSE calc_totals;
207 
208   EXCEPTION
209     WHEN OTHERS THEN
210       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
211       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.calculate_totals');
212       RAISE;
213   END calculate_totals;
214 
215   FUNCTION header_has_stat(header_id	NUMBER) RETURN BOOLEAN IS
216     CURSOR has_stat is
217       SELECT stat_amount
218       FROM   GL_JE_LINES jel
219       WHERE  jel.je_header_id = header_id
220       AND    stat_amount IS NOT NULL;
221     dummy   NUMBER;
222   BEGIN
223     OPEN has_stat;
224     FETCH has_stat INTO dummy;
225 
226     IF has_stat%NOTFOUND THEN
227       CLOSE has_stat;
228       RETURN(FALSE);
229     END IF;
230 
231     CLOSE has_stat;
232     RETURN(TRUE);
233   EXCEPTION
234     WHEN OTHERS THEN
235       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
236       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.header_has_stat');
237       RAISE;
238   END header_has_stat;
239 
240   FUNCTION header_has_tax(header_id	NUMBER) RETURN BOOLEAN IS
241     CURSOR has_tax is
242       SELECT 'Has tax'
243       FROM   GL_JE_LINES jel
244       WHERE  jel.je_header_id = header_id
245       AND    tax_type_code IS NOT NULL;
246     dummy   VARCHAR2(100);
247   BEGIN
248     OPEN has_tax;
249     FETCH has_tax INTO dummy;
250 
251     IF has_tax%NOTFOUND THEN
252       CLOSE has_tax;
253       RETURN(FALSE);
254     END IF;
255 
256     CLOSE has_tax;
257     RETURN(TRUE);
258   EXCEPTION
259     WHEN OTHERS THEN
260       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
261       fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.header_has_tax');
262       RAISE;
263   END header_has_tax;
264 
265   PROCEDURE populate_fields(x_ledger_id				NUMBER,
266                             x_org_id                            NUMBER,
267 			    x_coa_id				NUMBER,
268 			    x_ccid				NUMBER,
269 			    x_account_num		IN OUT NOCOPY	VARCHAR2,
270 			    x_account_type		IN OUT NOCOPY	VARCHAR2,
271                             x_jgzz_recon_flag           IN OUT NOCOPY   VARCHAR2,
272 			    x_tax_enabled			 VARCHAR2,
273 			    x_taxable_account		IN OUT NOCOPY  VARCHAR2,
274 			    x_stat_enabled			VARCHAR2,
275 			    x_unit_of_measure		IN OUT NOCOPY  VARCHAR2,
276 			    x_tax_code_id			NUMBER,
277 			    x_tax_type_code			VARCHAR2,
278 			    x_tax_code			IN OUT NOCOPY  VARCHAR2) IS
279     dummy_tax_type_code	VARCHAR2(1);
280     dummy_tax_code  	VARCHAR2(50);
281     dummy_tax_code_id	NUMBER;
282     dummy_rounding_code VARCHAR2(1);
283     dummy_incl_tax_flag VARCHAR2(1);
284     temp_return_status VARCHAR2(1);
285     err_msg             VARCHAR2(2000);
286   BEGIN
287     IF (nvl(delim_coa_id, -1) <> x_coa_id) THEN
288       -- Get the delimiter
289       delim := fnd_flex_apis.get_segment_delimiter(
290         	 x_application_id 	=> 101,
291       	  	 x_id_flex_code		=> 'GL#',
292       		 x_id_flex_num		=> x_coa_id);
293     END IF;
294 
295     IF (fnd_flex_keyval.validate_ccid(
296             	appl_short_name 	=> 'SQLGL',
297 	    	key_flex_code		=> 'GL#',
298 	    	structure_number	=> x_coa_id,
299 		combination_id		=> x_ccid,
300 		displayable		=> 'GL_ACCOUNT')
301        ) THEN
302       x_account_num  := replace(fnd_flex_keyval.concatenated_values,
303 				'
304 ', delim);
305       x_account_type := fnd_flex_keyval.qualifier_value('GL_ACCOUNT_TYPE');
306 
307       IF (x_tax_code_id IS NOT NULL) THEN
308 
309         temp_return_status :=null;
310         err_msg :=null;
311 
312         zx_gl_tax_options_pkg.get_tax_rate_code
313         (  1.0,
314            x_tax_type_code,
315            x_tax_code_id,
316            x_tax_code,
317            temp_return_status, err_msg
318         );
319 
320         IF (temp_return_status = 'E') THEN
321           FND_MESSAGE.Set_Name('ZX', err_msg);
322           fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.populate_fields');
323          -- APP_EXCEPTION.Raise_Exception;
324         ELSIF (temp_return_status = 'U') THEN
325           fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
326           fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.populate_fields');
327           APP_EXCEPTION.Raise_Exception;
328         END IF;
329       END IF;
330 
331       gl_je_lines_pkg.init_acct_dependencies(
332 	x_ledger_id 		=> x_ledger_id,
333         x_org_id                => x_org_id,
334 	x_coa_id		=> x_coa_id,
335         x_ccid			=> x_ccid,
336 	x_account_num		=> x_account_num,
337         x_account_type		=> x_account_type,
338 	x_tax_enabled   	=> x_tax_enabled,
339 	x_taxable_account	=> x_taxable_account,
340 	x_get_default_tax_info 	=> 'N',
341 	x_eff_date		=> sysdate,
342 	x_default_tax_type_code	=> dummy_tax_type_code,
343 	x_default_tax_code	=> dummy_tax_code,
344         x_default_tax_code_id   => dummy_tax_code_id,
345         x_default_rounding_code => dummy_rounding_code,
346         x_default_incl_tax_flag => dummy_incl_tax_flag,
347 	x_stat_enabled		=> x_stat_enabled,
348 	x_unit_of_measure	=> x_unit_of_measure,
349         x_jgzz_recon_flag       => x_jgzz_recon_flag);
350 
351      ELSE
352        fnd_message.set_encoded(fnd_flex_keyval.encoded_error_message);
353        app_exception.raise_exception;
354     END IF;
355 
356   END populate_fields;
357 
358   PROCEDURE init_acct_dependencies(
359 			    x_ledger_id				NUMBER,
360 			    x_org_id                            NUMBER,
361 			    x_coa_id				NUMBER,
362                             x_ccid                              NUMBER,
363 			    x_account_num			VARCHAR2,
364 			    x_account_type			VARCHAR2,
365 			    x_tax_enabled			VARCHAR2,
366 			    x_taxable_account		IN OUT NOCOPY  VARCHAR2,
367 			    x_get_default_tax_info		VARCHAR2,
368 			    x_eff_date				DATE,
369 			    x_default_tax_type_code	IN OUT NOCOPY  VARCHAR2,
370 			    x_default_tax_code		IN OUT NOCOPY  VARCHAR2,
371 			    x_default_tax_code_id	IN OUT NOCOPY  NUMBER,
372 			    x_default_rounding_code	IN OUT NOCOPY	VARCHAR2,
373 			    x_default_incl_tax_flag	IN OUT NOCOPY	VARCHAR2,
374 			    x_stat_enabled			VARCHAR2,
375 			    x_unit_of_measure		IN OUT NOCOPY  VARCHAR2,
376                             x_jgzz_recon_flag           IN OUT NOCOPY  VARCHAR2) IS
377 
378     description 		VARCHAR2(255);
379 
380     coa_id			NUMBER := x_coa_id;
381     acct_num			VARCHAR2(25) := x_account_num;
382 
383     dummy			NUMBER;
384 
385     x_default_taxable_flag	VARCHAR2(1);
386     tmp_recon_flag              VARCHAR2(1);
387     dummy_return_status         VARCHAR2(1);
388     err_msg                     VARCHAR2(2000);
389     return_status VARCHAR2(30);
390     msg_count     NUMBER;
391     msg_data      VARCHAR2(2000);
392     le_id         NUMBER;
393     p_date        DATE;
394   BEGIN
395     -- initialize everything
396     x_unit_of_measure := null;
397 
398     -- If tax is enabled, then determine if by default this
399     -- account is tax
400     x_default_taxable_flag := 'N';
401     x_taxable_account := 'N';
402 
403     IF (nvl(x_tax_enabled,'N') = 'Y') THEN
404 
405       le_id := XLE_UTILITIES_GRP.Get_DefaultLegalContext_OU(
406                x_org_id);
407       ZX_API_PUB.set_tax_security_context(1.0, null, null, null,
408             return_status, msg_count, msg_data, x_org_id, le_id,
409             x_eff_date, NULL, NULL, p_date);
410 
411       SELECT max(decode(allow_rate_override_flag, 'N', 1, 0))
412       INTO   dummy
413       FROM  zx_account_rates    rates
414       WHERE  rates.ledger_id = x_ledger_id
415       AND    rates.account_segment_value = x_account_num
416       AND    rates.tax_class = 'NON_TAXABLE';
417 
418       IF (dummy IS NULL) THEN
419 	x_default_taxable_flag := 'Y';
420 	x_taxable_account := 'Y';
421       ELSIF (dummy = 0) THEN
422 	x_default_taxable_flag := 'N';
423 	x_taxable_account := 'Y';
424       ELSE
425 	x_default_taxable_flag := 'N';
426 	x_taxable_account := 'N';
427       END IF;
428 
429     ELSE
430       x_default_taxable_flag := 'N';
431       x_taxable_account := 'Y';
432     END IF;
433 
434     -- Get the other defaults, if desired
435     IF (    (x_tax_enabled = 'Y')
436 	AND (x_default_taxable_flag = 'Y')
437 	AND (x_get_default_tax_info = 'Y')
438        ) THEN
439 
440       x_default_tax_type_code := null;
441       x_default_tax_code := null;
442       x_default_tax_code_id := null;
443       x_default_rounding_code := null;
444       x_default_incl_tax_flag := null;
445 
446       -- Get the default tax code id
447       x_default_tax_type_code := default_tax_type(
448                                    'I', x_ledger_id, x_org_id,
449                                    x_account_num, x_account_type);
450 
451       IF (x_default_tax_type_code IS NOT NULL) THEN
452 
453         x_default_tax_code_id := to_number(default_tax_code(
454 	  		                     'I', x_ledger_id, x_org_id,
455 					     x_account_num,
456 			                     x_default_tax_type_code,
457 					     x_eff_date));
458 
459         -- Get the tax code associated with the default tax code id
460         IF (x_default_tax_code_id IS NOT NULL) THEN
461           dummy_return_status :=null;
462           err_msg :=null;
463 
464           zx_gl_tax_options_pkg.get_tax_rate_code
465           (   1.0,
466               x_default_tax_type_code,
467               x_default_tax_code_id,
468               x_default_tax_code,
469               dummy_return_status, err_msg
470            );
471 
472           IF (dummy_return_status = 'E') THEN
473             FND_MESSAGE.Set_Name('ZX', err_msg);
474             fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.init_acct_dependencies');
475             -- APP_EXCEPTION.Raise_Exception;
476           ELSIF (dummy_return_status = 'U') THEN
477             fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
478             fnd_message.set_token('PROCEDURE', 'gl_je_lines_pkg.init_acct_dependencies');
479             APP_EXCEPTION.Raise_Exception;
480           END IF;
481 
482           -- Get the default rounding rule code and default include tax flag
483           get_tax_defaults(x_ledger_id, x_org_id, x_account_num,
484 	      	           x_default_tax_type_code, x_default_rounding_code,
485                            x_default_incl_tax_flag);
486         END IF;
487       END IF;
488     END IF;
489 
490     IF (nvl(x_stat_enabled,'N') = 'Y') THEN
491       BEGIN
492         gl_stat_account_uom_pkg.select_columns(
493             coa_id,
494             acct_num,
495             x_unit_of_measure,
496             description);
497       EXCEPTION
498         WHEN NO_DATA_FOUND THEN
499           x_unit_of_measure := null;
500         WHEN OTHERS THEN
501           RAISE;
502       END;
503     END IF;
504 
505     -- If the ccid exists, get the jgzz_recon_flag from it
506     IF (nvl(x_ccid,-1) <> -1) THEN
507         BEGIN
508           SELECT jgzz_recon_flag
509           INTO tmp_recon_flag
510           FROM gl_code_combinations
511           WHERE code_combination_id = x_ccid;
512 
513           x_jgzz_recon_flag := tmp_recon_flag;
514         EXCEPTION
515           WHEN NO_DATA_FOUND THEN
516             x_jgzz_recon_flag := null;
517         END;
518       ELSE
519         IF (fnd_flex_keyval.validate_segs(
520                	operation       => 'CHECK_SEGMENTS',
521 		appl_short_name	=> 'SQLGL',
522 		key_flex_code	=> 'GL#',
523 		structure_number=> coa_id,
524 		concat_segments	=> x_account_num,
525                 displayable     => 'GL_ACCOUNT',
526                 validation_date	=> NULL,
527                 allow_nulls     => TRUE,
528                 allow_orphans   => TRUE)) THEN
529           x_jgzz_recon_flag := fnd_flex_keyval.qualifier_value('RECONCILIATION FLAG');
530         ELSE
531           x_jgzz_recon_flag := 'Y';
532         END IF;
533     END IF;
534   END init_acct_dependencies;
535 
536   PROCEDURE get_tax_defaults(x_ledger_id			NUMBER,
537                              x_org_id                           NUMBER,
538 			     x_account_value			VARCHAR2,
539 			     x_tax_type_code			VARCHAR2,
540 			     x_default_rounding_code	IN OUT NOCOPY	VARCHAR2,
541 			     x_default_incl_tax_flag	IN OUT NOCOPY	VARCHAR2
542 			    ) IS
543 
544   BEGIN
545 
546     x_default_rounding_code := default_rounding_rule(
547 				 'I', x_ledger_id,
548 				 x_org_id, x_tax_type_code);
549 
550     x_default_incl_tax_flag := default_includes_tax(
551 				 'I', x_ledger_id,
552 				 x_org_id, x_account_value, x_tax_type_code);
553 
554   END get_tax_defaults;
555 
556 
557   FUNCTION default_tax_type(output_type			IN VARCHAR2,
558 			    x_ledger_id                 IN NUMBER,
559                             x_org_id                    IN NUMBER,
560                             x_account_value             IN VARCHAR2,
561                             x_account_type              IN VARCHAR2
562                            ) RETURN VARCHAR2 IS
563 
564     num_defaults                NUMBER;
565     default_tax_type            VARCHAR2(80) := '';
566     default_tax_type_code       VARCHAR2(1)  := '';
567     le_id         NUMBER;
568     p_date        DATE;
569     return_status VARCHAR2(30);
570     msg_count     NUMBER;
571     msg_data      VARCHAR2(2000);
572   BEGIN
573     default_tax_type := '';
574     default_tax_type_code := '';
575 
576     le_id := XLE_UTILITIES_GRP.Get_DefaultLegalContext_OU(x_org_id);
577     ZX_API_PUB.set_tax_security_context(1.0, null, null, null,
578                return_status, msg_count, msg_data, x_org_id, le_id,
579                sysdate, NULL, NULL, p_date);
580 
581     SELECT count(*), max(decode(rates.tax_class, 'INPUT', 'I', 'OUTPUT', 'O', NULL, 'T'))
582     INTO    num_defaults, default_tax_type_code
583     FROM    zx_account_rates  rates
584     WHERE   rates.ledger_id = x_ledger_id
585     AND     rates.account_segment_value = x_account_value
586     AND     nvl(rates.tax_class,'T') <> 'NON_TAXABLE';
587 
588     -- If there are two or more default rows, then don't
589     -- default
590     IF (num_defaults >= 2) THEN
591       default_tax_type := '';
592       default_tax_type_code := '';
593 
594     -- If there are no default rows, then default based
595     -- upon the account type
596     ELSIF (num_defaults = 0) THEN
597       default_tax_type_code :='T';
598     END IF;
599 
600     IF (    (default_tax_type_code IS NOT NULL)
601 	AND (output_type = 'V')
602        ) THEN
603       SELECT l.meaning
604       INTO default_tax_type
605       FROM gl_lookups l
606       WHERE l.lookup_type = 'TAX_TYPE'
607       AND   l.lookup_code = default_tax_type_code;
608     END IF;
609 
610     IF (output_type = 'I') THEN
611       RETURN(default_tax_type_code);
612     ELSE
613       RETURN(default_tax_type);
614     END IF;
615 
616   END default_tax_type;
617 
618   FUNCTION default_tax_code(output_type			IN VARCHAR2,
619 			    x_ledger_id			IN NUMBER,
620                             x_org_id                    IN NUMBER,
621 			    x_account_value		IN VARCHAR2,
622 			    x_acct_type			IN VARCHAR2,
623 			    x_eff_date			IN DATE
624                            ) RETURN VARCHAR2 IS
625 
626     temp_regime_code  varchar2(30);
627     temp_tax varchar2(50);
628     temp_status varchar2(30);
629     default_tax_code varchar2(50);
630     default_tax_code_id NUMBER(15);
631     temp_rounding_rule varchar2(30);
632     temp_includes_tax_flag varchar2(1);
633     temp_return_status varchar2(1);
634     err_msg varchar2(2000);
635     le_id  NUMBER;
636   BEGIN
637   le_id := XLE_UTILITIES_GRP.Get_DefaultLegalContext_OU(x_org_id);
638 
639    zx_gl_tax_options_pkg.get_default_values(
640            1.0, x_ledger_id, x_org_id, le_id,
641             x_account_value, x_acct_type,
642             x_eff_date,
643             temp_regime_code,
644             temp_tax,
645             temp_status,
646             default_tax_code,
647             default_tax_code_id,
648             temp_rounding_rule,
649             temp_includes_tax_flag,
650             temp_return_status, err_msg);
651 
652     IF (temp_return_status = 'E') THEN
653       FND_MESSAGE.Set_Name('ZX', err_msg);
654       fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_tax_code');
655       --APP_EXCEPTION.Raise_Exception;
656     ELSIF (temp_return_status = 'U') THEN
657      fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
658      fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_tax_code');
659      APP_EXCEPTION.Raise_Exception;
660     END IF;
661 
662     IF (output_type = 'I') THEN
663        RETURN(to_char(default_tax_code_id));
664     ELSE
665        RETURN(default_tax_code);
666     END IF;
667   END default_tax_code;
668 
669 
670   FUNCTION default_rounding_rule(output_type			IN VARCHAR2,
671 				 x_ledger_id			IN NUMBER,
672                                  x_org_id                       IN NUMBER,
673 			         x_tax_type			IN VARCHAR2
674                                 ) RETURN VARCHAR2 IS
675 
676     default_rounding_rule 	VARCHAR2(80);
677     default_rounding_rule_code 	VARCHAR2(1);
678     temp_return_status         VARCHAR2(1);
679     err_msg                    VARCHAR2(2000);
680     le_id  NUMBER;
681   BEGIN
682     default_rounding_rule := null;
683     default_rounding_rule_code := null;
684     le_id := XLE_UTILITIES_GRP.Get_DefaultLegalContext_OU(x_org_id);
685 
686     zx_gl_tax_options_pkg.get_rounding_rule_code
687    (
688     1.0,
689      x_ledger_id ,
690      x_org_id ,
691      le_id,
692      x_tax_type,
693      default_rounding_rule_code,
694      temp_return_status,
695      err_msg
696     );
697 
698     IF (temp_return_status = 'E') THEN
699       FND_MESSAGE.Set_Name('ZX', err_msg);
700       fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_rounding_rule');
701       --APP_EXCEPTION.Raise_Exception;
702     ELSIF (temp_return_status = 'U') THEN
703       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
704       fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_rounding_rule');
705       APP_EXCEPTION.Raise_Exception;
706     END IF;
707 
708     IF default_rounding_rule_code IS NOT NULL THEN
709       SELECT l.lookup_code, l.meaning
710       INTO   default_rounding_rule_code,
711              default_rounding_rule
712       FROM   gl_lookups l
713       WHERE  l.lookup_type = 'TAX_ROUNDING_RULE'
714       AND    l.lookup_code = default_rounding_rule_code;
715     END IF;
716 
717     IF (output_type = 'I') THEN
718       RETURN(default_rounding_rule_code);
719     ELSE
720       RETURN(default_rounding_rule);
721     END IF;
722 
723   END default_rounding_rule;
724 
725 
726   FUNCTION default_includes_tax(output_type			IN VARCHAR2,
727 				x_ledger_id			IN NUMBER,
728                                 x_org_id                        IN NUMBER,
729 			        x_account_value			IN VARCHAR2,
730 			        x_tax_type			IN VARCHAR2
731                                ) RETURN VARCHAR2 IS
732 
733     default_includes_tax 	VARCHAR2(80);
734     default_includes_tax_flag 	VARCHAR2(1);
735 
736     temp_regime_code  varchar2(30);
737     temp_tax varchar2(50);
738     temp_status varchar2(30);
739     default_tax_code varchar2(50);
740     default_tax_code_id NUMBER(15);
741     temp_rounding_rule varchar2(30);
742     temp_includes_tax_flag varchar2(1);
743     temp_return_status varchar2(1);
744     err_msg varchar2(2000);
745     le_id NUMBER(15);
746   BEGIN
747     default_includes_tax := null;
748     default_includes_tax_flag := null;
749     le_id := XLE_UTILITIES_GRP.Get_DefaultLegalContext_OU(x_org_id);
750 
751     zx_gl_tax_options_pkg.get_default_tax_include_flag
752     (
753       1.0,
754       x_ledger_id,
755       x_org_id,
756       le_id,
757       x_account_value,
758       x_tax_type,
759       temp_includes_tax_flag,
760       temp_return_status,
761       err_msg);
762 
763     IF (temp_return_status = 'E') THEN
764       FND_MESSAGE.Set_Name('ZX', err_msg);
765       fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_includes_tax');
766      -- APP_EXCEPTION.Raise_Exception;
767     ELSIF (temp_return_status = 'U') THEN
768       fnd_message.set_name('SQLGL', 'GL_UNHANDLED_EXCEPTION');
769       fnd_message.set_token('FUNCTION', 'gl_je_lines_pkg.default_includes_tax');
770       APP_EXCEPTION.Raise_Exception;
771     END IF;
772 
773     IF temp_includes_tax_flag IS NOT NULL THEN
774       SELECT l.lookup_code, l.meaning
775       INTO   default_includes_tax_flag,
776              default_includes_tax
777       FROM   gl_lookups l
778       WHERE  l.lookup_type = 'YES/NO'
779       AND    l.lookup_code = temp_includes_tax_flag;
780     END IF;
781 
782     IF (output_type = 'I') THEN
783       RETURN(default_includes_tax_flag);
784     ELSE
785       RETURN(default_includes_tax);
786     END IF;
787 
788   END default_includes_tax;
789 
790   PROCEDURE Insert_Row(X_Rowid                   IN OUT NOCOPY VARCHAR2,
791                        X_Je_Header_Id            IN OUT NOCOPY NUMBER,
792                        X_Je_Line_Num                    NUMBER,
793                        X_Last_Update_Date               DATE,
794                        X_Last_Updated_By                NUMBER,
795                        X_Ledger_id                      NUMBER,
796                        X_Code_Combination_Id            NUMBER,
797                        X_Period_Name                    VARCHAR2,
798                        X_Effective_Date                 DATE,
799                        X_Status                         VARCHAR2,
800                        X_Creation_Date                  DATE,
801                        X_Created_By                     NUMBER,
802                        X_Last_Update_Login              NUMBER,
803                        X_Entered_Dr                     NUMBER,
804                        X_Entered_Cr                     NUMBER,
805                        X_Accounted_Dr                   NUMBER,
806                        X_Accounted_Cr                   NUMBER,
807                        X_Description                    VARCHAR2,
808                        X_Reference_1                    VARCHAR2,
809                        X_Reference_2                    VARCHAR2,
810                        X_Reference_3                    VARCHAR2,
811                        X_Reference_4                    VARCHAR2,
812                        X_Reference_5                    VARCHAR2,
813                        X_Attribute1                     VARCHAR2,
814                        X_Attribute2                     VARCHAR2,
815                        X_Attribute3                     VARCHAR2,
816                        X_Attribute4                     VARCHAR2,
817                        X_Attribute5                     VARCHAR2,
818                        X_Attribute6                     VARCHAR2,
819                        X_Attribute7                     VARCHAR2,
820                        X_Attribute8                     VARCHAR2,
821                        X_Attribute9                     VARCHAR2,
822                        X_Attribute10                    VARCHAR2,
823                        X_Attribute11                    VARCHAR2,
824                        X_Attribute12                    VARCHAR2,
825                        X_Attribute13                    VARCHAR2,
826                        X_Attribute14                    VARCHAR2,
827                        X_Attribute15                    VARCHAR2,
828                        X_Attribute16                    VARCHAR2,
829                        X_Attribute17                    VARCHAR2,
830                        X_Attribute18                    VARCHAR2,
831                        X_Attribute19                    VARCHAR2,
832                        X_Attribute20                    VARCHAR2,
833                        X_Context                        VARCHAR2,
834                        X_Context2                       VARCHAR2,
835                        X_Invoice_Date                   DATE,
836                        X_Tax_Code                       VARCHAR2,
837                        X_Invoice_Identifier             VARCHAR2,
838                        X_Invoice_Amount                 NUMBER,
839                        X_No1                            VARCHAR2,
840                        X_Stat_Amount                    NUMBER,
841                        X_Ignore_Rate_Flag               VARCHAR2,
842                        X_Context3                       VARCHAR2,
843                        X_Ussgl_Transaction_Code         VARCHAR2,
844                        X_Subledger_Doc_Sequence_Id      NUMBER,
845                        X_Context4                       VARCHAR2,
846                        X_Subledger_Doc_Sequence_Value   NUMBER,
847                        X_Reference_6                    VARCHAR2,
848                        X_Reference_7                    VARCHAR2,
849                        X_Reference_8                    VARCHAR2,
850                        X_Reference_9                    VARCHAR2,
851                        X_Reference_10                   VARCHAR2,
852                        X_Recon_On_Flag			VARCHAR2,
853 		       X_Recon_Rowid	  IN OUT NOCOPY VARCHAR2,
854 		       X_Jgzz_Recon_Status		VARCHAR2,
855 		       X_Jgzz_Recon_Date		DATE,
856 		       X_Jgzz_Recon_Id			NUMBER,
857 		       X_Jgzz_Recon_Ref			VARCHAR2,
858 		       X_Taxable_Line_Flag		VARCHAR2,
859 		       X_Tax_Type_Code			VARCHAR2,
860 		       X_Tax_Code_Id			NUMBER,
861 		       X_Tax_Rounding_Rule_Code		VARCHAR2,
862 		       X_Amount_Includes_Tax_Flag	VARCHAR2,
863 		       X_Tax_Document_Identifier	VARCHAR2,
864 		       X_Tax_Document_Date		DATE,
865 		       X_Tax_Customer_Name		VARCHAR2,
866 		       X_Tax_Customer_Reference		VARCHAR2,
867 		       X_Tax_Registration_Number	VARCHAR2,
868 		       X_Tax_Line_Flag			VARCHAR2,
869 		       X_Tax_Group_Id			NUMBER,
870                        X_Third_Party_Id		        VARCHAR2,
871 		       X_Global_Attribute1              VARCHAR2,
872                        X_Global_Attribute2              VARCHAR2,
873                        X_Global_Attribute3              VARCHAR2,
874                        X_Global_Attribute4              VARCHAR2,
875                        X_Global_Attribute5              VARCHAR2,
876                        X_Global_Attribute6              VARCHAR2,
877                        X_Global_Attribute7              VARCHAR2,
878                        X_Global_Attribute8              VARCHAR2,
879                        X_Global_Attribute9              VARCHAR2,
880                        X_Global_Attribute10             VARCHAR2,
881                        X_Global_Attribute_Category      VARCHAR2
882    ) IS
883      CURSOR C IS SELECT rowid FROM GL_JE_LINES
884                  WHERE je_header_id = X_Je_Header_Id
885                  AND   je_line_num = X_Je_Line_Num;
886 
887       dummy RowId;
888     BEGIN
889 
890       -- Get the header id, if it has not yet been retrieved
891       IF (X_Je_Header_Id IS NULL) THEN
892         X_Je_Header_Id := gl_je_headers_pkg.get_unique_id;
893       END IF;
894 
895       -- Add any new segment values
896       gl_je_segment_values_pkg.insert_ccid_segment_values(
897          X_Je_Header_Id,
898          X_Code_Combination_Id,
899          X_Last_Updated_By,
900          X_Last_Update_Login);
901 
902       INSERT INTO GL_JE_LINES (
903                je_header_id,
904                je_line_num,
905                last_update_date,
906                last_updated_by,
907                ledger_id,
908                code_combination_id,
909                period_name,
910                effective_date,
911                status,
912                creation_date,
913                created_by,
914                last_update_login,
915                entered_dr,
916                entered_cr,
917                accounted_dr,
918                accounted_cr,
919                description,
920                reference_1,
921                reference_2,
922                reference_3,
923                reference_4,
924                reference_5,
925                attribute1,
926                attribute2,
927                attribute3,
928                attribute4,
929                attribute5,
930                attribute6,
931                attribute7,
932                attribute8,
933                attribute9,
934                attribute10,
935                attribute11,
936                attribute12,
937                attribute13,
938                attribute14,
939                attribute15,
940                attribute16,
941                attribute17,
942                attribute18,
943                attribute19,
944                attribute20,
945                context,
946                context2,
947                invoice_date,
948                tax_code,
949                invoice_identifier,
950                invoice_amount,
951                no1,
952                stat_amount,
953                ignore_rate_flag,
954                context3,
955                ussgl_transaction_code,
956                subledger_doc_sequence_id,
957                context4,
958                subledger_doc_sequence_value,
959                reference_6,
960                reference_7,
961                reference_8,
962                reference_9,
963                reference_10,
964 	       taxable_line_flag,
965 	       tax_type_code,
966 	       tax_code_id,
967 	       tax_rounding_rule_code,
968 	       amount_includes_tax_flag,
969 	       tax_document_identifier,
970 	       tax_document_date,
971 	       tax_customer_name,
972 	       tax_customer_reference,
973 	       tax_registration_number,
974 	       tax_line_flag,
975 	       tax_group_id,
976                co_third_party,
977 	       global_attribute1,
978 	       global_attribute2,
979 	       global_attribute3,
980 	       global_attribute4,
981 	       global_attribute5,
982 	       global_attribute6,
983 	       global_attribute7,
984 	       global_attribute8,
985 	       global_attribute9,
986 	       global_attribute10,
987 	       global_attribute_category
988              ) VALUES (
989                X_Je_Header_Id,
990                X_Je_Line_Num,
991                X_Last_Update_Date,
992                X_Last_Updated_By,
993                X_Ledger_id,
994                X_Code_Combination_Id,
995                X_Period_Name,
996                X_Effective_Date,
997                X_Status,
998                X_Creation_Date,
999                X_Created_By,
1000                X_Last_Update_Login,
1001                X_Entered_Dr,
1002                X_Entered_Cr,
1003                X_Accounted_Dr,
1004                X_Accounted_Cr,
1005                X_Description,
1006                X_Reference_1,
1007                X_Reference_2,
1008                X_Reference_3,
1009                X_Reference_4,
1010                X_Reference_5,
1011                X_Attribute1,
1012                X_Attribute2,
1013                X_Attribute3,
1014                X_Attribute4,
1015                X_Attribute5,
1016                X_Attribute6,
1017                X_Attribute7,
1018                X_Attribute8,
1019                X_Attribute9,
1020                X_Attribute10,
1021                X_Attribute11,
1022                X_Attribute12,
1023                X_Attribute13,
1024                X_Attribute14,
1025                X_Attribute15,
1026                X_Attribute16,
1027                X_Attribute17,
1028                X_Attribute18,
1029                X_Attribute19,
1030                X_Attribute20,
1031                X_Context,
1032                X_Context2,
1033                X_Invoice_Date,
1034                X_Tax_Code,
1035                X_Invoice_Identifier,
1036                X_Invoice_Amount,
1037                X_No1,
1038                X_Stat_Amount,
1039                X_Ignore_Rate_Flag,
1040                X_Context3,
1041                X_Ussgl_Transaction_Code,
1042                X_Subledger_Doc_Sequence_Id,
1043                X_Context4,
1044                X_Subledger_Doc_Sequence_Value,
1045                X_Reference_6,
1046                X_Reference_7,
1047                X_Reference_8,
1048                X_Reference_9,
1049                X_Reference_10,
1050 	       X_Taxable_Line_Flag,
1051 	       X_Tax_Type_Code,
1052 	       X_Tax_Code_Id,
1053 	       X_Tax_Rounding_Rule_Code,
1054 	       X_Amount_Includes_Tax_Flag,
1055 	       X_Tax_Document_Identifier,
1056 	       X_Tax_Document_Date,
1057 	       X_Tax_Customer_Name,
1058 	       X_Tax_Customer_Reference,
1059 	       X_Tax_Registration_Number,
1060 	       X_Tax_Line_Flag,
1061 	       X_Tax_Group_Id,
1062                X_Third_Party_Id,
1063                X_Global_Attribute1,
1064 	       X_Global_Attribute2,
1065 	       X_Global_Attribute3,
1066 	       X_Global_Attribute4,
1067 	       X_Global_Attribute5,
1068 	       X_Global_Attribute6,
1069 	       X_Global_Attribute7,
1070 	       X_Global_Attribute8,
1071 	       X_Global_Attribute9,
1072 	       X_Global_Attribute10,
1073 	       X_Global_Attribute_Category
1074              );
1075 
1076     OPEN C;
1077     FETCH C INTO X_Rowid;
1078     if (C%NOTFOUND) then
1079       CLOSE C;
1080       Raise NO_DATA_FOUND;
1081     end if;
1082     CLOSE C;
1083 
1084     -- Insert a reconciliation row if reconciliation is on
1085     IF (X_Recon_On_Flag = 'Y') THEN
1086       gl_je_lines_recon_pkg.insert_row(
1087         X_Rowid=>X_Recon_Rowid,
1088         X_Je_Header_Id=>X_Je_Header_id,
1089         X_Je_Line_Num=>X_Je_Line_Num,
1090         X_Ledger_Id=>X_Ledger_Id,
1091         X_Jgzz_Recon_Status=>X_Jgzz_Recon_Status,
1092         X_Jgzz_Recon_Date=>X_Jgzz_Recon_Date,
1093         X_Jgzz_Recon_Id=>X_Jgzz_Recon_Id,
1094         X_Jgzz_Recon_Ref=>X_Jgzz_Recon_Ref,
1095         X_Last_Update_Date=>X_Last_Update_Date,
1096         X_Last_Updated_By=>X_Last_Updated_By,
1097         X_Last_Update_Login=>X_Last_Update_Login);
1098     END IF;
1099   END Insert_Row;
1100 
1101 
1102 
1103   PROCEDURE Lock_Row(X_Rowid                            VARCHAR2,
1104                      X_Je_Header_Id                     NUMBER,
1105                      X_Je_Line_Num                      NUMBER,
1106                      X_Ledger_id 			NUMBER,
1107                      X_Code_Combination_Id              NUMBER,
1108                      X_Period_Name                      VARCHAR2,
1109                      X_Effective_Date                   DATE,
1110                      X_Status                           VARCHAR2,
1111                      X_Entered_Dr                       NUMBER,
1112                      X_Entered_Cr                       NUMBER,
1113                      X_Accounted_Dr                     NUMBER,
1114                      X_Accounted_Cr                     NUMBER,
1115                      X_Description                      VARCHAR2,
1116                      X_Reference_1                      VARCHAR2,
1117                      X_Reference_2                      VARCHAR2,
1118                      X_Reference_3                      VARCHAR2,
1119                      X_Reference_4                      VARCHAR2,
1120                      X_Reference_5                      VARCHAR2,
1121                      X_Attribute1                       VARCHAR2,
1122                      X_Attribute2                       VARCHAR2,
1123                      X_Attribute3                       VARCHAR2,
1124                      X_Attribute4                       VARCHAR2,
1125                      X_Attribute5                       VARCHAR2,
1126                      X_Attribute6                       VARCHAR2,
1127                      X_Attribute7                       VARCHAR2,
1128                      X_Attribute8                       VARCHAR2,
1129                      X_Attribute9                       VARCHAR2,
1130                      X_Attribute10                      VARCHAR2,
1131                      X_Attribute11                      VARCHAR2,
1132                      X_Attribute12                      VARCHAR2,
1133                      X_Attribute13                      VARCHAR2,
1134                      X_Attribute14                      VARCHAR2,
1135                      X_Attribute15                      VARCHAR2,
1136                      X_Attribute16                      VARCHAR2,
1137                      X_Attribute17                      VARCHAR2,
1138                      X_Attribute18                      VARCHAR2,
1139                      X_Attribute19                      VARCHAR2,
1140                      X_Attribute20                      VARCHAR2,
1141                      X_Context                          VARCHAR2,
1142                      X_Context2                         VARCHAR2,
1143                      X_Invoice_Date                     DATE,
1144                      X_Tax_Code                         VARCHAR2,
1145                      X_Invoice_Identifier               VARCHAR2,
1146                      X_Invoice_Amount                   NUMBER,
1147                      X_No1                              VARCHAR2,
1148                      X_Stat_Amount                      NUMBER,
1149                      X_Ignore_Rate_Flag                 VARCHAR2,
1150                      X_Context3                         VARCHAR2,
1151                      X_Ussgl_Transaction_Code           VARCHAR2,
1152                      X_Subledger_Doc_Sequence_Id        NUMBER,
1153                      X_Context4                         VARCHAR2,
1154                      X_Subledger_Doc_Sequence_Value     NUMBER,
1155                      X_Reference_6                      VARCHAR2,
1156                      X_Reference_7                      VARCHAR2,
1157                      X_Reference_8                      VARCHAR2,
1158                      X_Reference_9                      VARCHAR2,
1159                      X_Reference_10                     VARCHAR2,
1160 		     X_Recon_Rowid	                VARCHAR2,
1161 		     X_Jgzz_Recon_Status		VARCHAR2,
1162 		     X_Jgzz_Recon_Date			DATE,
1163 		     X_Jgzz_Recon_Id			NUMBER,
1164 		     X_Jgzz_Recon_Ref			VARCHAR2,
1165 		     X_Taxable_Line_Flag		VARCHAR2,
1166 		     X_Tax_Type_Code			VARCHAR2,
1167 		     X_Tax_Code_Id			NUMBER,
1168 		     X_Tax_Rounding_Rule_Code		VARCHAR2,
1169 		     X_Amount_Includes_Tax_Flag		VARCHAR2,
1170 		     X_Tax_Document_Identifier		VARCHAR2,
1171 		     X_Tax_Document_Date		DATE,
1172 		     X_Tax_Customer_Name		VARCHAR2,
1173 		     X_Tax_Customer_Reference		VARCHAR2,
1174 		     X_Tax_Registration_Number		VARCHAR2,
1175 		     X_Tax_Line_Flag			VARCHAR2,
1176 		     X_Tax_Group_Id			NUMBER,
1177                      X_Third_Party_Id		        VARCHAR2,
1178 		     X_Global_Attribute1                VARCHAR2,
1179                      X_Global_Attribute2                VARCHAR2,
1180                      X_Global_Attribute3                VARCHAR2,
1181                      X_Global_Attribute4                VARCHAR2,
1182                      X_Global_Attribute5                VARCHAR2,
1183                      X_Global_Attribute6                VARCHAR2,
1184                      X_Global_Attribute7                VARCHAR2,
1185                      X_Global_Attribute8                VARCHAR2,
1186                      X_Global_Attribute9                VARCHAR2,
1187                      X_Global_Attribute10               VARCHAR2,
1188                      X_Global_Attribute_Category        VARCHAR2
1189   ) IS
1190     CURSOR C IS
1191         SELECT *
1192         FROM   GL_JE_LINES
1193         WHERE  rowid = X_Rowid
1194         FOR UPDATE of Je_Header_Id NOWAIT;
1195     Recinfo C%ROWTYPE;
1196   BEGIN
1197     OPEN C;
1198     FETCH C INTO Recinfo;
1199     if (C%NOTFOUND) then
1200       CLOSE C;
1201       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_DELETED');
1202       APP_EXCEPTION.Raise_Exception;
1203     end if;
1204     CLOSE C;
1205 
1206     if (
1207                (Recinfo.je_header_id = X_Je_Header_Id)
1208            AND (Recinfo.je_line_num = X_Je_Line_Num)
1209            AND (Recinfo.ledger_id = X_Ledger_id)
1210            AND (Recinfo.code_combination_id = X_Code_Combination_Id)
1211            AND (Recinfo.period_name = X_Period_Name)
1212            AND (Recinfo.effective_date = X_Effective_Date)
1213            AND (Recinfo.status = X_Status)
1214            AND (   (Recinfo.entered_dr = X_Entered_Dr)
1215                 OR (    (Recinfo.entered_dr IS NULL)
1216                     AND (X_Entered_Dr IS NULL)))
1217            AND (   (Recinfo.entered_cr = X_Entered_Cr)
1218                 OR (    (Recinfo.entered_cr IS NULL)
1219                     AND (X_Entered_Cr IS NULL)))
1220            AND (   (Recinfo.accounted_dr = X_Accounted_Dr)
1221                 OR (    (Recinfo.accounted_dr IS NULL)
1222                     AND (X_Accounted_Dr IS NULL)))
1223            AND (   (Recinfo.accounted_cr = X_Accounted_Cr)
1224                 OR (    (Recinfo.accounted_cr IS NULL)
1225                     AND (X_Accounted_Cr IS NULL)))
1226            AND (   (Recinfo.description = X_Description)
1227                 OR (    (rtrim(Recinfo.description,' ') IS NULL)
1228                     AND (X_Description IS NULL)))
1229            AND (   (Recinfo.reference_1 = X_Reference_1)
1230                 OR (    (rtrim(Recinfo.reference_1,' ') IS NULL)
1231                     AND (X_Reference_1 IS NULL)))
1232            AND (   (Recinfo.reference_2 = X_Reference_2)
1233                 OR (    (rtrim(Recinfo.reference_2,' ') IS NULL)
1234                     AND (X_Reference_2 IS NULL)))
1235            AND (   (Recinfo.reference_3 = X_Reference_3)
1236                 OR (    (rtrim(Recinfo.reference_3,' ') IS NULL)
1237                     AND (X_Reference_3 IS NULL)))
1238            AND (   (Recinfo.reference_4 = X_Reference_4)
1239                 OR (    (rtrim(Recinfo.reference_4,' ') IS NULL)
1240                     AND (X_Reference_4 IS NULL)))
1241            AND (   (Recinfo.reference_5 = X_Reference_5)
1242                 OR (    (rtrim(Recinfo.reference_5,' ') IS NULL)
1243                     AND (X_Reference_5 IS NULL)))
1244            AND (   (Recinfo.attribute1 = X_Attribute1)
1245                 OR (    (rtrim(Recinfo.attribute1,' ') IS NULL)
1246                     AND (X_Attribute1 IS NULL)))
1247            AND (   (Recinfo.attribute2 = X_Attribute2)
1248                 OR (    (rtrim(Recinfo.attribute2,' ') IS NULL)
1249                     AND (X_Attribute2 IS NULL)))
1250            AND (   (Recinfo.attribute3 = X_Attribute3)
1251                 OR (    (rtrim(Recinfo.attribute3,' ') IS NULL)
1252                     AND (X_Attribute3 IS NULL)))
1253            AND (   (Recinfo.attribute4 = X_Attribute4)
1254                 OR (    (rtrim(Recinfo.attribute4,' ') IS NULL)
1255                     AND (X_Attribute4 IS NULL)))
1256            AND (   (Recinfo.attribute5 = X_Attribute5)
1257                 OR (    (rtrim(Recinfo.attribute5,' ') IS NULL)
1258                     AND (X_Attribute5 IS NULL)))
1259            AND (   (Recinfo.attribute6 = X_Attribute6)
1260                 OR (    (rtrim(Recinfo.attribute6,' ') IS NULL)
1261                     AND (X_Attribute6 IS NULL)))
1262            AND (   (Recinfo.attribute7 = X_Attribute7)
1263                 OR (    (rtrim(Recinfo.attribute7,' ') IS NULL)
1264                     AND (X_Attribute7 IS NULL)))
1265            AND (   (Recinfo.attribute8 = X_Attribute8)
1266                 OR (    (rtrim(Recinfo.attribute8,' ') IS NULL)
1267                     AND (X_Attribute8 IS NULL)))
1268            AND (   (Recinfo.attribute9 = X_Attribute9)
1269                 OR (    (rtrim(Recinfo.attribute9,' ') IS NULL)
1270                     AND (X_Attribute9 IS NULL)))
1271            AND (   (Recinfo.attribute10 = X_Attribute10)
1272                 OR (    (rtrim(Recinfo.attribute10,' ') IS NULL)
1273                     AND (X_Attribute10 IS NULL)))
1274            AND (   (Recinfo.attribute11 = X_Attribute11)
1275                 OR (    (rtrim(Recinfo.attribute11,' ') IS NULL)
1276                     AND (X_Attribute11 IS NULL)))
1277            AND (   (Recinfo.attribute12 = X_Attribute12)
1278                 OR (    (rtrim(Recinfo.attribute12,' ') IS NULL)
1279                     AND (X_Attribute12 IS NULL)))
1280            AND (   (Recinfo.attribute13 = X_Attribute13)
1281                 OR (    (rtrim(Recinfo.attribute13,' ') IS NULL)
1282                     AND (X_Attribute13 IS NULL)))
1283            AND (   (Recinfo.attribute14 = X_Attribute14)
1284                 OR (    (rtrim(Recinfo.attribute14,' ') IS NULL)
1285                     AND (X_Attribute14 IS NULL)))
1286            AND (   (Recinfo.attribute15 = X_Attribute15)
1287                 OR (    (rtrim(Recinfo.attribute15,' ') IS NULL)
1288                     AND (X_Attribute15 IS NULL)))
1289            AND (   (Recinfo.attribute16 = X_Attribute16)
1290                 OR (    (rtrim(Recinfo.attribute16,' ') IS NULL)
1291                     AND (X_Attribute16 IS NULL)))
1292            AND (   (Recinfo.attribute17 = X_Attribute17)
1293                 OR (    (rtrim(Recinfo.attribute17,' ') IS NULL)
1294                     AND (X_Attribute17 IS NULL)))
1295            AND (   (Recinfo.attribute18 = X_Attribute18)
1296                 OR (    (rtrim(Recinfo.attribute18,' ') IS NULL)
1297                     AND (X_Attribute18 IS NULL)))
1298            AND (   (Recinfo.attribute19 = X_Attribute19)
1299                 OR (    (rtrim(Recinfo.attribute19,' ') IS NULL)
1300                     AND (X_Attribute19 IS NULL)))
1301            AND (   (Recinfo.attribute20 = X_Attribute20)
1302                 OR (    (rtrim(Recinfo.attribute20,' ') IS NULL)
1303                     AND (X_Attribute20 IS NULL)))
1304            AND (   (Recinfo.context = X_Context)
1305                 OR (    (rtrim(Recinfo.context,' ') IS NULL)
1306                     AND (X_Context IS NULL)))
1307            AND (   (Recinfo.context2 = X_Context2)
1308                 OR (    (rtrim(Recinfo.context2,' ') IS NULL)
1309                     AND (X_Context2 IS NULL)))
1310            AND (   (Recinfo.invoice_date = X_Invoice_Date)
1311                 OR (    (Recinfo.invoice_date IS NULL)
1312                     AND (X_Invoice_Date IS NULL)))
1313            AND (   (Recinfo.tax_code = X_Tax_Code)
1314                 OR (    (rtrim(Recinfo.tax_code,' ') IS NULL)
1315                     AND (X_Tax_Code IS NULL)))
1316            AND (   (Recinfo.invoice_identifier = X_Invoice_Identifier)
1317                 OR (    (rtrim(Recinfo.invoice_identifier,' ') IS NULL)
1318                     AND (X_Invoice_Identifier IS NULL)))
1319            AND (   (Recinfo.invoice_amount = X_Invoice_Amount)
1320                 OR (    (Recinfo.invoice_amount IS NULL)
1321                     AND (X_Invoice_Amount IS NULL)))
1322            AND (   (Recinfo.no1 = X_No1)
1323                 OR (    (rtrim(Recinfo.no1,' ') IS NULL)
1324                     AND (X_No1 IS NULL)))
1325            AND (   (Recinfo.stat_amount = X_Stat_Amount)
1326                 OR (    (Recinfo.stat_amount IS NULL)
1327                     AND (X_Stat_Amount IS NULL)))
1328            AND (   (Recinfo.ignore_rate_flag = X_Ignore_Rate_Flag)
1329                 OR (    (rtrim(Recinfo.ignore_rate_flag,' ') IS NULL)
1330                     AND (X_Ignore_Rate_Flag IS NULL)))
1331            AND (   (Recinfo.context3 = X_Context3)
1332                 OR (    (rtrim(Recinfo.context3,' ') IS NULL)
1333                     AND (X_Context3 IS NULL)))
1334            AND (   (Recinfo.ussgl_transaction_code = X_Ussgl_Transaction_Code)
1335                 OR (    (rtrim(Recinfo.ussgl_transaction_code,' ') IS NULL)
1336                     AND (X_Ussgl_Transaction_Code IS NULL)))
1337            AND (   (Recinfo.subledger_doc_sequence_id
1338                       = X_Subledger_Doc_Sequence_Id)
1339                 OR (    (Recinfo.subledger_doc_sequence_id IS NULL)
1340                     AND (X_Subledger_Doc_Sequence_Id IS NULL)))
1341            AND (   (Recinfo.context4 = X_Context4)
1342                 OR (    (rtrim(Recinfo.context4,' ') IS NULL)
1343                     AND (X_Context4 IS NULL)))
1344            AND (   (Recinfo.subledger_doc_sequence_value
1345                       = X_Subledger_Doc_Sequence_Value)
1346                 OR (    (Recinfo.subledger_doc_sequence_value IS NULL)
1347                     AND (X_Subledger_Doc_Sequence_Value IS NULL)))
1348            AND (   (Recinfo.reference_6 = X_Reference_6)
1349                 OR (    (rtrim(Recinfo.reference_6,' ') IS NULL)
1350                     AND (X_Reference_6 IS NULL)))
1351            AND (   (Recinfo.reference_7 = X_Reference_7)
1352                 OR (    (rtrim(Recinfo.reference_7,' ') IS NULL)
1353                     AND (X_Reference_7 IS NULL)))
1354            AND (   (Recinfo.reference_8 = X_Reference_8)
1355                 OR (    (rtrim(Recinfo.reference_8,' ') IS NULL)
1356                     AND (X_Reference_8 IS NULL)))
1357            AND (   (Recinfo.reference_9 = X_Reference_9)
1358                 OR (    (rtrim(Recinfo.reference_9,' ') IS NULL)
1359                     AND (X_Reference_9 IS NULL)))
1360            AND (   (Recinfo.reference_10 = X_Reference_10)
1361                 OR (    (rtrim(Recinfo.reference_10,' ') IS NULL)
1362                     AND (X_Reference_10 IS NULL)))
1363       ) then
1364         if (
1365                (   (Recinfo.taxable_line_flag = X_Taxable_Line_Flag)
1366                 OR (    (Recinfo.taxable_line_flag IS NULL)
1367                     AND (X_Taxable_Line_Flag IS NULL)))
1368            AND (   (Recinfo.tax_type_code = X_Tax_Type_Code)
1369                 OR (    (Recinfo.tax_type_code IS NULL)
1370                     AND (X_Tax_Type_Code IS NULL)))
1371            AND (   (Recinfo.tax_code_id = X_Tax_Code_Id)
1372                 OR (    (Recinfo.tax_code_id IS NULL)
1373                     AND (X_Tax_Code_Id IS NULL)))
1374            AND (   (Recinfo.tax_rounding_rule_code = X_Tax_Rounding_Rule_Code)
1375                 OR (    (Recinfo.tax_rounding_rule_code IS NULL)
1376                     AND (X_Tax_Rounding_Rule_Code IS NULL)))
1377            AND (   (Recinfo.amount_includes_tax_flag
1378                       = X_Amount_Includes_Tax_Flag)
1379                 OR (    (Recinfo.amount_includes_tax_flag IS NULL)
1380                     AND (X_Amount_Includes_Tax_Flag IS NULL)))
1381            AND (   (Recinfo.tax_document_identifier=X_Tax_Document_Identifier)
1382                 OR (    (Recinfo.tax_document_identifier IS NULL)
1383                     AND (X_Tax_Document_Identifier IS NULL)))
1384            AND (   (Recinfo.tax_document_date=X_Tax_Document_Date)
1385                 OR (    (Recinfo.tax_document_date IS NULL)
1386                     AND (X_Tax_Document_Date IS NULL)))
1387            AND (   (Recinfo.tax_customer_name=X_Tax_Customer_Name)
1388                 OR (    (Recinfo.tax_customer_name IS NULL)
1389                     AND (X_Tax_Customer_Name IS NULL)))
1390            AND (   (Recinfo.tax_customer_reference=X_Tax_Customer_Reference)
1391                 OR (    (Recinfo.tax_customer_reference IS NULL)
1392                     AND (X_Tax_Customer_Reference IS NULL)))
1393            AND (   (Recinfo.tax_registration_number=X_Tax_Registration_Number)
1394                 OR (    (Recinfo.tax_registration_number IS NULL)
1395                     AND (X_Tax_Registration_Number IS NULL)))
1396            AND (   (Recinfo.tax_line_flag=X_Tax_Line_Flag)
1397                 OR (    (Recinfo.tax_line_flag IS NULL)
1398                     AND (X_Tax_Line_Flag IS NULL)))
1399            AND (   (Recinfo.tax_group_id=X_Tax_Group_Id)
1400                 OR (    (Recinfo.tax_group_id IS NULL)
1401                     AND (X_Tax_Group_Id IS NULL)))
1402            AND (   (Recinfo.co_third_party=X_Third_Party_Id)
1403                 OR (    (Recinfo.co_third_party IS NULL)
1404                     AND (X_Third_Party_Id IS NULL)))
1405            AND (   (Recinfo.global_attribute1=X_Global_Attribute1)
1406                 OR (    (Recinfo.global_attribute1 IS NULL)
1407                     AND (X_Global_Attribute1 IS NULL)))
1408            AND (   (Recinfo.global_attribute2=X_Global_Attribute2)
1409                 OR (    (Recinfo.global_attribute2 IS NULL)
1410                     AND (X_Global_Attribute2 IS NULL)))
1411            AND (   (Recinfo.global_attribute3=X_Global_Attribute3)
1412                 OR (    (Recinfo.global_attribute3 IS NULL)
1413                     AND (X_Global_Attribute3 IS NULL)))
1414            AND (   (Recinfo.global_attribute4=X_Global_Attribute4)
1415                 OR (    (Recinfo.global_attribute4 IS NULL)
1416                     AND (X_Global_Attribute4 IS NULL)))
1417            AND (   (Recinfo.global_attribute5=X_Global_Attribute5)
1418                 OR (    (Recinfo.global_attribute5 IS NULL)
1419                     AND (X_Global_Attribute5 IS NULL)))
1420            AND (   (Recinfo.global_attribute6=X_Global_Attribute6)
1421                 OR (    (Recinfo.global_attribute6 IS NULL)
1422                     AND (X_Global_Attribute6 IS NULL)))
1423            AND (   (Recinfo.global_attribute7=X_Global_Attribute7)
1424                 OR (    (Recinfo.global_attribute7 IS NULL)
1425                     AND (X_Global_Attribute7 IS NULL)))
1426            AND (   (Recinfo.global_attribute8=X_Global_Attribute8)
1427                 OR (    (Recinfo.global_attribute8 IS NULL)
1428                     AND (X_Global_Attribute8 IS NULL)))
1429            AND (   (Recinfo.global_attribute9=X_Global_Attribute9)
1430                 OR (    (Recinfo.global_attribute9 IS NULL)
1431                     AND (X_Global_Attribute9 IS NULL)))
1432            AND (   (Recinfo.global_attribute10=X_Global_Attribute10)
1433                 OR (    (Recinfo.global_attribute10 IS NULL)
1434                     AND (X_Global_Attribute10 IS NULL)))
1435            AND (   (Recinfo.global_attribute_category
1436                      =X_Global_Attribute_Category)
1437                 OR (    (Recinfo.global_attribute_category IS NULL)
1438                     AND (X_Global_Attribute_Category IS NULL)))
1439          ) then
1440 
1441            IF (X_Recon_Rowid IS NOT NULL) THEN
1442              gl_je_lines_recon_pkg.lock_row(
1443                X_RowId => X_Recon_Rowid,
1444                X_Je_Header_Id=>X_Je_Header_id,
1445                X_Je_Line_Num=>X_Je_Line_Num,
1446                X_Ledger_Id=>X_Ledger_Id,
1447                X_Jgzz_Recon_Status=>X_Jgzz_Recon_Status,
1448                X_Jgzz_Recon_Date=>X_Jgzz_Recon_Date,
1449                X_Jgzz_Recon_Id=>X_Jgzz_Recon_Id,
1450                X_Jgzz_Recon_Ref=>X_Jgzz_Recon_Ref);
1451            END IF;
1452          else
1453            FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
1454            APP_EXCEPTION.RAISE_EXCEPTION;
1455          end if;
1456     else
1457       FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
1458       APP_EXCEPTION.RAISE_EXCEPTION;
1459     end if;
1460   END Lock_Row;
1461 
1462   PROCEDURE Update_Row(X_Rowid                          VARCHAR2,
1463                        X_Je_Header_Id                   NUMBER,
1464                        X_Je_Line_Num                    NUMBER,
1465                        X_Last_Update_Date               DATE,
1466                        X_Last_Updated_By                NUMBER,
1467                        X_Ledger_Id			NUMBER,
1468                        X_Code_Combination_Id            NUMBER,
1469                        X_Period_Name                    VARCHAR2,
1470                        X_Effective_Date                 DATE,
1471                        X_Status                         VARCHAR2,
1472                        X_Last_Update_Login              NUMBER,
1473                        X_Entered_Dr                     NUMBER,
1474                        X_Entered_Cr                     NUMBER,
1475                        X_Accounted_Dr                   NUMBER,
1476                        X_Accounted_Cr                   NUMBER,
1477                        X_Description                    VARCHAR2,
1478                        X_Reference_1                    VARCHAR2,
1479                        X_Reference_2                    VARCHAR2,
1480                        X_Reference_3                    VARCHAR2,
1481                        X_Reference_4                    VARCHAR2,
1482                        X_Reference_5                    VARCHAR2,
1483                        X_Attribute1                     VARCHAR2,
1484                        X_Attribute2                     VARCHAR2,
1485                        X_Attribute3                     VARCHAR2,
1486                        X_Attribute4                     VARCHAR2,
1487                        X_Attribute5                     VARCHAR2,
1488                        X_Attribute6                     VARCHAR2,
1489                        X_Attribute7                     VARCHAR2,
1490                        X_Attribute8                     VARCHAR2,
1491                        X_Attribute9                     VARCHAR2,
1492                        X_Attribute10                    VARCHAR2,
1493                        X_Attribute11                    VARCHAR2,
1494                        X_Attribute12                    VARCHAR2,
1495                        X_Attribute13                    VARCHAR2,
1496                        X_Attribute14                    VARCHAR2,
1497                        X_Attribute15                    VARCHAR2,
1498                        X_Attribute16                    VARCHAR2,
1499                        X_Attribute17                    VARCHAR2,
1500                        X_Attribute18                    VARCHAR2,
1501                        X_Attribute19                    VARCHAR2,
1502                        X_Attribute20                    VARCHAR2,
1503                        X_Context                        VARCHAR2,
1504                        X_Context2                       VARCHAR2,
1505                        X_Invoice_Date                   DATE,
1506                        X_Tax_Code                       VARCHAR2,
1507                        X_Invoice_Identifier             VARCHAR2,
1508                        X_Invoice_Amount                 NUMBER,
1509                        X_No1                            VARCHAR2,
1510                        X_Stat_Amount                    NUMBER,
1511                        X_Ignore_Rate_Flag               VARCHAR2,
1512                        X_Context3                       VARCHAR2,
1513                        X_Ussgl_Transaction_Code         VARCHAR2,
1514                        X_Subledger_Doc_Sequence_Id      NUMBER,
1515                        X_Context4                       VARCHAR2,
1516                        X_Subledger_Doc_Sequence_Value   NUMBER,
1517                        X_Reference_6                    VARCHAR2,
1518                        X_Reference_7                    VARCHAR2,
1519                        X_Reference_8                    VARCHAR2,
1520                        X_Reference_9                    VARCHAR2,
1521                        X_Reference_10                   VARCHAR2,
1522                        X_Recon_On_Flag			VARCHAR2,
1523 		       X_Recon_Rowid	  IN OUT NOCOPY VARCHAR2,
1524 		       X_Jgzz_Recon_Status		VARCHAR2,
1525 		       X_Jgzz_Recon_Date		DATE,
1526 		       X_Jgzz_Recon_Id			NUMBER,
1527 		       X_Jgzz_Recon_Ref			VARCHAR2,
1528 		       X_Taxable_Line_Flag		VARCHAR2,
1529 		       X_Tax_Type_Code			VARCHAR2,
1530 		       X_Tax_Code_Id			NUMBER,
1531 		       X_Tax_Rounding_Rule_Code		VARCHAR2,
1532 		       X_Amount_Includes_Tax_Flag	VARCHAR2,
1533 		       X_Tax_Document_Identifier	VARCHAR2,
1534 		       X_Tax_Document_Date		DATE,
1535 		       X_Tax_Customer_Name		VARCHAR2,
1536 		       X_Tax_Customer_Reference		VARCHAR2,
1537 		       X_Tax_Registration_Number	VARCHAR2,
1538 		       X_Tax_Line_Flag			VARCHAR2,
1539 		       X_Tax_Group_Id			NUMBER,
1540                        X_Third_Party_Id		        VARCHAR2,
1541 		       X_Global_Attribute1              VARCHAR2,
1542                        X_Global_Attribute2              VARCHAR2,
1543                        X_Global_Attribute3              VARCHAR2,
1544                        X_Global_Attribute4              VARCHAR2,
1545                        X_Global_Attribute5              VARCHAR2,
1546                        X_Global_Attribute6              VARCHAR2,
1547                        X_Global_Attribute7              VARCHAR2,
1548                        X_Global_Attribute8              VARCHAR2,
1549                        X_Global_Attribute9              VARCHAR2,
1550                        X_Global_Attribute10             VARCHAR2,
1551                        X_Global_Attribute_Category      VARCHAR2
1552 
1553  ) IS
1554  BEGIN
1555    -- Add any new segment values
1556    gl_je_segment_values_pkg.insert_ccid_segment_values(
1557       X_Je_Header_Id,
1558       X_Code_Combination_Id,
1559       X_Last_Updated_By,
1560       X_Last_Update_Login);
1561 
1562    UPDATE GL_JE_LINES
1563    SET
1564      je_header_id                      =     X_Je_Header_Id,
1565      je_line_num                       =     X_Je_Line_Num,
1566      last_update_date                  =     X_Last_Update_Date,
1567      last_updated_by                   =     X_Last_Updated_By,
1568      ledger_id                         =     X_Ledger_Id,
1569      code_combination_id               =     X_Code_Combination_Id,
1570      period_name                       =     X_Period_Name,
1571      effective_date                    =     X_Effective_Date,
1572      status                            =     X_Status,
1573      last_update_login                 =     X_Last_Update_Login,
1574      entered_dr                        =     X_Entered_Dr,
1575      entered_cr                        =     X_Entered_Cr,
1576      accounted_dr                      =     X_Accounted_Dr,
1577      accounted_cr                      =     X_Accounted_Cr,
1578      description                       =     X_Description,
1579      reference_1                       =     X_Reference_1,
1580      reference_2                       =     X_Reference_2,
1581      reference_3                       =     X_Reference_3,
1582      reference_4                       =     X_Reference_4,
1583      reference_5                       =     X_Reference_5,
1584      attribute1                        =     X_Attribute1,
1585      attribute2                        =     X_Attribute2,
1586      attribute3                        =     X_Attribute3,
1587      attribute4                        =     X_Attribute4,
1588      attribute5                        =     X_Attribute5,
1589      attribute6                        =     X_Attribute6,
1590      attribute7                        =     X_Attribute7,
1591      attribute8                        =     X_Attribute8,
1592      attribute9                        =     X_Attribute9,
1593      attribute10                       =     X_Attribute10,
1594      attribute11                       =     X_Attribute11,
1595      attribute12                       =     X_Attribute12,
1596      attribute13                       =     X_Attribute13,
1597      attribute14                       =     X_Attribute14,
1598      attribute15                       =     X_Attribute15,
1599      attribute16                       =     X_Attribute16,
1600      attribute17                       =     X_Attribute17,
1601      attribute18                       =     X_Attribute18,
1602      attribute19                       =     X_Attribute19,
1603      attribute20                       =     X_Attribute20,
1604      context                           =     X_Context,
1605      context2                          =     X_Context2,
1606      invoice_date                      =     X_Invoice_Date,
1607      tax_code                          =     X_Tax_Code,
1608      invoice_identifier                =     X_Invoice_Identifier,
1609      invoice_amount                    =     X_Invoice_Amount,
1610      no1                               =     X_No1,
1611      stat_amount                       =     X_Stat_Amount,
1612      ignore_rate_flag                  =     X_Ignore_Rate_Flag,
1613      context3                          =     X_Context3,
1614      ussgl_transaction_code            =     X_Ussgl_Transaction_Code,
1615      subledger_doc_sequence_id         =     X_Subledger_Doc_Sequence_Id,
1616      context4                          =     X_Context4,
1617      subledger_doc_sequence_value      =     X_Subledger_Doc_Sequence_Value,
1618      reference_6                       =     X_Reference_6,
1619      reference_7                       =     X_Reference_7,
1620      reference_8                       =     X_Reference_8,
1621      reference_9                       =     X_Reference_9,
1622      reference_10                      =     X_Reference_10,
1623      taxable_line_flag		       =     X_Taxable_Line_Flag,
1624      tax_type_code		       =     X_Tax_Type_Code,
1625      tax_code_id                       =     X_Tax_Code_Id,
1626      tax_rounding_rule_code            =     X_Tax_Rounding_Rule_Code,
1627      amount_includes_tax_flag          =     X_Amount_Includes_Tax_Flag,
1628      tax_document_identifier           =     X_Tax_Document_Identifier,
1629      tax_document_date                 =     X_Tax_Document_Date,
1630      tax_customer_name                 =     X_Tax_Customer_Name,
1631      tax_customer_reference            =     X_Tax_Customer_Reference,
1632      tax_registration_number           =     X_Tax_Registration_Number,
1633      tax_line_flag                     =     X_Tax_Line_Flag,
1634      tax_group_id                      =     X_Tax_Group_Id,
1635      co_third_party                    =     X_Third_Party_Id,
1636      global_attribute1                 =     X_Global_Attribute1,
1637      global_attribute2                 =     X_Global_Attribute2,
1638      global_attribute3                 =     X_Global_Attribute3,
1639      global_attribute4                 =     X_Global_Attribute4,
1640      global_attribute5                 =     X_Global_Attribute5,
1641      global_attribute6                 =     X_Global_Attribute6,
1642      global_attribute7                 =     X_Global_Attribute7,
1643      global_attribute8                 =     X_Global_Attribute8,
1644      global_attribute9                 =     X_Global_Attribute9,
1645      global_attribute10                =     X_Global_Attribute10,
1646      global_attribute_category         =     X_Global_Attribute_Category
1647    WHERE rowid = X_rowid;
1648 
1649    IF (SQL%NOTFOUND) THEN
1650      Raise NO_DATA_FOUND;
1651    END IF;
1652 
1653    -- If no row exists, insert one if reconciliation is now on
1654    IF (X_Recon_Rowid IS NULL) THEN
1655      IF (X_Recon_On_Flag = 'Y') THEN
1656        gl_je_lines_recon_pkg.insert_row(
1657          X_Rowid=>X_Recon_Rowid,
1658          X_Je_Header_Id=>X_Je_Header_id,
1659          X_Je_Line_Num=>X_Je_Line_Num,
1660          X_Ledger_Id=>X_Ledger_Id,
1661          X_Jgzz_Recon_Status=>X_Jgzz_Recon_Status,
1662          X_Jgzz_Recon_Date=>X_Jgzz_Recon_Date,
1663          X_Jgzz_Recon_Id=>X_Jgzz_Recon_Id,
1664          X_Jgzz_Recon_Ref=>X_Jgzz_Recon_Ref,
1665          X_Last_Update_Date=>X_Last_Update_Date,
1666          X_Last_Updated_By=>X_Last_Updated_By,
1667          X_Last_Update_Login=>X_Last_Update_Login);
1668      END IF;
1669 
1670    -- If a row exists, update it if reconciliation is on.  Delete it if
1671    -- reconciliation is off.
1672    ELSE
1673      IF (X_Recon_On_Flag = 'Y') THEN
1674        gl_je_lines_recon_pkg.update_row(
1675          X_Rowid=>X_Recon_Rowid,
1676          X_Je_Header_Id=>X_Je_Header_id,
1677          X_Je_Line_Num=>X_Je_Line_Num,
1678          X_Ledger_Id=>X_Ledger_Id,
1679          X_Jgzz_Recon_Status=>X_Jgzz_Recon_Status,
1680          X_Jgzz_Recon_Date=>X_Jgzz_Recon_Date,
1681          X_Jgzz_Recon_Id=>X_Jgzz_Recon_Id,
1682          X_Jgzz_Recon_Ref=>X_Jgzz_Recon_Ref,
1683          X_Last_Update_Date=>X_Last_Update_Date,
1684          X_Last_Updated_By=>X_Last_Updated_By,
1685          X_Last_Update_Login=>X_Last_Update_Login);
1686      ELSE
1687        gl_je_lines_recon_pkg.delete_row(
1688          X_Rowid=>X_Recon_Rowid);
1689        X_Recon_Rowid := null;
1690      END IF;
1691    END IF;
1692   END Update_Row;
1693 
1694   PROCEDURE Delete_Row(X_Rowid                          VARCHAR2,
1695                        X_Recon_Rowid			VARCHAR2) IS
1696      CURSOR c_del_line (lv_row_id VARCHAR2 )IS
1697      SELECT je_line_num,je_header_id
1698      FROM GL_JE_LINES
1699      WHERE rowid = lv_row_id ;
1700 
1701      lv_header_id number;
1702      lv_line_num number;
1703   BEGIN
1704     OPEN c_del_line ( X_Rowid);
1705     FETCH c_del_line into lv_line_num , lv_header_id ;
1706     CLOSE c_del_line;
1707 
1708     DELETE FROM GL_JE_LINES
1709     WHERE  rowid = X_Rowid;
1710 
1711     if (SQL%NOTFOUND) then
1712       Raise NO_DATA_FOUND;
1713     end if;
1714 
1715     -- To delete the reference lines if any in GL_IMPORT_REFERENCES
1716     GL_IMPORT_REFERENCES_PKG.delete_line (lv_header_id ,lv_line_num );
1717 
1718     -- Delete any reconciliation row
1719     IF (X_Recon_Rowid IS NOT NULL) THEN
1720            gl_je_lines_recon_pkg.delete_row(
1721              X_Rowid=>X_Recon_Rowid);
1722     END IF;
1723   END Delete_Row;
1724 
1725 END GL_JE_LINES_PKG;