DBA Data[Home] [Help]

PACKAGE BODY: APPS.ARP_ADJUSTMENTS_PKG

Source


1 PACKAGE BODY ARP_ADJUSTMENTS_PKG AS
2 /* $Header: ARTIADJB.pls 120.7.12010000.2 2008/11/19 06:01:43 pbapna ship $ */
3 
4 pg_base_curr_code     gl_sets_of_books.currency_code%type;
5 pg_base_precision     fnd_currencies.precision%type;
6 pg_base_min_acc_unit  fnd_currencies.minimum_accountable_unit%type;
7 
8 pg_msg_level_debug   binary_integer;
9 
10   /*--------------------------------------------------------+
11    |  Dummy constants for use in update and lock operations |
12    +--------------------------------------------------------*/
13 
14   AR_TEXT_DUMMY   CONSTANT VARCHAR2(10) := '~~!@#$*&^';
15   AR_TEXT3_DUMMY  CONSTANT VARCHAR2(10) := '~!@';
16   AR_FLAG_DUMMY   CONSTANT VARCHAR2(10) := '~';
17   AR_NUMBER_DUMMY CONSTANT NUMBER(15)   := -999999999999999;
18   AR_DATE_DUMMY   CONSTANT DATE         := to_date(1, 'J');
19 
20   /*---------------------------------------------------------------+
21    |  Package global variables to hold the parsed update cursors.  |
22    |  This allows the cursors to be reused without being reparsed. |
23    +---------------------------------------------------------------*/
24 
25   pg_cursor1  integer := NULL;
26   pg_cursor2  integer := NULL;
27   pg_cursor3  integer := NULL;
28   pg_cursor4  integer := NULL;
29   pg_cursor5  integer := NULL;
30 
31   /*-------------------------------------+
32    |  WHO column values from FND_GLOBAL  |
33    +-------------------------------------*/
34 
35   pg_conc_login_id    number;
36   pg_login_id         number;
37   pg_prog_appl_id     number;
38   pg_conc_program_id  number;
39 
40 
41 /*===========================================================================+
42  | PROCEDURE                                                                 |
43  |    bind_adj_variables                                                     |
44  |                                                                           |
45  | DESCRIPTION                                                               |
46  |    Binds variables from the record variable to the bind variables         |
47  |    in the dynamic SQL update statement.                                   |
48  |                                                                           |
49  | SCOPE - PRIVATE                                                           |
50  |                                                                           |
51  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
52  |    dbms_sql.bind_variable                                                 |
53  |    arp_util.debug                                                         |
54  |                                                                           |
55  | ARGUMENTS  : IN:                                                          |
56  |                    p_update_cursor  - ID of the update cursor             |
57  |                    p_adj_rec       - ar_adjustments record  		     |
58  |		      p_exchange_rate					     |
59  |		      p_currency_code					     |
60  |		      p_precision					     |
61  |		      p_mau						     |
62  |              OUT:                                                         |
63  |                    None                                                   |
64  |                                                                           |
65  | RETURNS    : NONE                                                         |
66  |                                                                           |
67  | NOTES                                                                     |
68  |                                                                           |
69  | MODIFICATION HISTORY                                                      |
70  |     29-JUN-95  Charlie Tomberg     Created                                |
71  |                                                                           |
72  |     03-FEB-00  Saloni Shah         Changes made for BR/BOE project.       |
73  |                                    Need to get the value of accounting    |
74  |                                    affect flag for the receivables trx    |
75  |                                    to set the postable flag.              |
76  |     20/11/2001 Veena Rao	      Bug 2098727 last_update_date is now    |
77  |					set to sysdate in procedure          |
78  |					construct_adj_update_stmt.           |
79  |					Deleted the lines which bound        |
80  |					last_update_date in this procedure   |
81  |                                                                           |
82  +===========================================================================*/
83 
84 
85 PROCEDURE bind_adj_variables(p_update_cursor IN integer,
86                              p_adj_rec       IN ar_adjustments%rowtype,
87                              p_exchange_rate IN
88                                       ar_payment_schedules.exchange_rate%type,
89                              p_currency_code IN
90                                       fnd_currencies.currency_code%type,
91                              p_precision     IN fnd_currencies.precision%type,
92                              p_mau           IN
93                                fnd_currencies.minimum_accountable_unit%type)
94           IS
95 
96 l_accounting_affect_flag ar_receivables_trx.accounting_affect_flag%type;
97 l_adj_post_to_gl_flag    ra_cust_trx_types.adj_post_to_gl%type;
98 
99 BEGIN
100 
101    arp_util.debug('arp_adjustments_pkg.bind_adj_variables()+');
102 
103 
104   /*----------------------------------------+
105    |  Rounding and exchange rate variables  |
106    +----------------------------------------*/
107 
108 /*
109   9/18/96 H.Kaukovuo
110   Commented out NOCOPY because calculating accounted amount cannot be done
111   at this level!
112 
113    dbms_sql.bind_variable(p_update_cursor, ':exchange_rate',
114                           p_exchange_rate);
115 
116    dbms_sql.bind_variable(p_update_cursor, ':currency_code',
117                           p_currency_code);
118 
119    dbms_sql.bind_variable(p_update_cursor, ':precision',
120                           p_precision);
121 
122    dbms_sql.bind_variable(p_update_cursor, ':mau',
123                           p_mau);
124 */
125 
126 
127   /*--------------------------------------------+
128    |  Change made for BR/BOE project.           |
129    |  Get the value for accounting_affect_flag  |
130    +--------------------------------------------*/
131 
132      /*Bug 7461503 Changes for adjustment posting */
133         SELECT decode(ctt.post_to_gl,'Y','Y' ,nvl(ctt.adj_post_to_gl,'N'))
134         INTO   l_adj_post_to_gl_flag
135         FROM   ra_customer_trx ct,ra_cust_trx_types ctt
136         WHERE  ct.customer_trx_id=p_adj_rec.customer_trx_id
137         AND    ctt.cust_trx_type_id=ct.cust_trx_type_id;
138 
139      IF l_adj_post_to_gl_flag  = 'Y' THEN
140        SELECT NVL(accounting_affect_flag , 'Y')
141        INTO  l_accounting_affect_flag
142        FROM  ar_receivables_trx
143        WHERE receivables_trx_id = p_adj_rec.receivables_trx_id;
144 
145      ELSE
146         l_accounting_affect_flag := 'N';
147      END IF;
148 
149 
150   /*------------------+
151    |  Dummy constants |
152    +------------------*/
153 
154    dbms_sql.bind_variable(p_update_cursor, ':ar_text_dummy',
155                           AR_TEXT_DUMMY);
156 
157    dbms_sql.bind_variable(p_update_cursor, ':ar_text3_dummy',
158                           AR_TEXT3_DUMMY);
159 
160    dbms_sql.bind_variable(p_update_cursor, ':ar_flag_dummy',
161                           AR_FLAG_DUMMY);
162 
163    dbms_sql.bind_variable(p_update_cursor, ':ar_number_dummy',
164                           AR_NUMBER_DUMMY);
165 
166    dbms_sql.bind_variable(p_update_cursor, ':ar_date_dummy',
167                           AR_DATE_DUMMY);
168 
169   /*------------------+
170    |  WHO variables   |
171    +------------------*/
172 
173    dbms_sql.bind_variable(p_update_cursor, ':pg_user_id',
174                           pg_user_id);
175 
176    dbms_sql.bind_variable(p_update_cursor, ':pg_login_id',
177                           pg_login_id);
178 
179    dbms_sql.bind_variable(p_update_cursor, ':pg_conc_login_id',
180                           pg_conc_login_id);
181 
182   /*----------------------------------------------+
183    |  Bind variables for all columns in the table |
184    +----------------------------------------------*/
185 
186 
187    /*---------------------------------------------+
188     | Change made for BR/BOE project              |
189     | Bind accounting_affect_flag.                |
190     +---------------------------------------------*/
191 
192    dbms_sql.bind_variable(p_update_cursor, ':accounting_affect_flag',
193                           l_accounting_affect_flag);
194 
195    dbms_sql.bind_variable(p_update_cursor, ':adjustment_id',
196                           p_adj_rec.adjustment_id);
197 
198    dbms_sql.bind_variable(p_update_cursor, ':amount',
199                           p_adj_rec.amount);
200 
201    -- 9/18/96 H.Kaukovuo	Added for bug fix 403019
202    dbms_sql.bind_variable(p_update_cursor, ':acctd_amount',
203                           p_adj_rec.acctd_amount);
204 
205    dbms_sql.bind_variable(p_update_cursor, ':apply_date',
206                           p_adj_rec.apply_date);
207 
208    dbms_sql.bind_variable(p_update_cursor, ':gl_date',
209                           p_adj_rec.gl_date);
210 
211    dbms_sql.bind_variable(p_update_cursor, ':gl_posted_date',
212                           p_adj_rec.gl_posted_date);
213 
214    dbms_sql.bind_variable(p_update_cursor, ':set_of_books_id',
215                           p_adj_rec.set_of_books_id);
216 
217    dbms_sql.bind_variable(p_update_cursor, ':code_combination_id',
218                           p_adj_rec.code_combination_id);
219 
220    dbms_sql.bind_variable(p_update_cursor, ':type',
221                           p_adj_rec.type);
222 
223    dbms_sql.bind_variable(p_update_cursor, ':adjustment_type',
224                           p_adj_rec.adjustment_type);
225 
226    dbms_sql.bind_variable(p_update_cursor, ':status',
227                           p_adj_rec.status);
228 
229    dbms_sql.bind_variable(p_update_cursor, ':line_adjusted',
230                           p_adj_rec.line_adjusted);
231 
232    dbms_sql.bind_variable(p_update_cursor, ':freight_adjusted',
233                           p_adj_rec.freight_adjusted);
234 
235    dbms_sql.bind_variable(p_update_cursor, ':tax_adjusted',
236                           p_adj_rec.tax_adjusted);
237 
238    dbms_sql.bind_variable(p_update_cursor, ':receivables_charges_adjusted',
239                           p_adj_rec.receivables_charges_adjusted);
240 
241    dbms_sql.bind_variable(p_update_cursor, ':batch_id',
242                           p_adj_rec.batch_id);
243 
244    dbms_sql.bind_variable(p_update_cursor, ':customer_trx_id',
245                           p_adj_rec.customer_trx_id);
246 
247    dbms_sql.bind_variable(p_update_cursor, ':subsequent_trx_id',
248                           p_adj_rec.subsequent_trx_id);
249 
250    dbms_sql.bind_variable(p_update_cursor, ':customer_trx_line_id',
251                           p_adj_rec.customer_trx_line_id);
252 
253    dbms_sql.bind_variable(p_update_cursor, ':associated_cash_receipt_id',
254                           p_adj_rec.associated_cash_receipt_id);
255 
256    dbms_sql.bind_variable(p_update_cursor, ':chargeback_customer_trx_id',
257                           p_adj_rec.chargeback_customer_trx_id);
258 
259    dbms_sql.bind_variable(p_update_cursor, ':payment_schedule_id',
260                           p_adj_rec.payment_schedule_id);
261 
262    dbms_sql.bind_variable(p_update_cursor, ':receivables_trx_id',
263                           p_adj_rec.receivables_trx_id);
264 
265    dbms_sql.bind_variable(p_update_cursor, ':distribution_set_id',
266                           p_adj_rec.distribution_set_id);
267 
268    dbms_sql.bind_variable(p_update_cursor, ':associated_application_id',
269                           p_adj_rec.associated_application_id);
270 
271    dbms_sql.bind_variable(p_update_cursor, ':comments',
272                           p_adj_rec.comments);
273 
274    dbms_sql.bind_variable(p_update_cursor, ':automatically_generated',
275                           p_adj_rec.automatically_generated);
276 
277    dbms_sql.bind_variable(p_update_cursor, ':created_from',
278                           p_adj_rec.created_from);
279 
280    dbms_sql.bind_variable(p_update_cursor, ':reason_code',
281                           p_adj_rec.reason_code);
282 
283    dbms_sql.bind_variable(p_update_cursor, ':adjustment_number',
284                           p_adj_rec.adjustment_number);
285 
286    dbms_sql.bind_variable(p_update_cursor, ':doc_sequence_value',
287                           p_adj_rec.doc_sequence_value);
288 
289    dbms_sql.bind_variable(p_update_cursor, ':doc_sequence_id',
290                           p_adj_rec.doc_sequence_id);
291 
292    dbms_sql.bind_variable(p_update_cursor, ':ussgl_transaction_code',
293                           p_adj_rec.ussgl_transaction_code);
294 
295    dbms_sql.bind_variable(p_update_cursor, ':ussgl_transaction_code_context',
296                           p_adj_rec.ussgl_transaction_code_context);
297 
298    dbms_sql.bind_variable(p_update_cursor, ':attribute_category',
299                           p_adj_rec.attribute_category);
300 
301    dbms_sql.bind_variable(p_update_cursor, ':attribute1',
302                           p_adj_rec.attribute1);
303 
304    dbms_sql.bind_variable(p_update_cursor, ':attribute2',
305                           p_adj_rec.attribute2);
306 
307    dbms_sql.bind_variable(p_update_cursor, ':attribute3',
308                           p_adj_rec.attribute3);
309 
310    dbms_sql.bind_variable(p_update_cursor, ':attribute4',
311                           p_adj_rec.attribute4);
312 
313    dbms_sql.bind_variable(p_update_cursor, ':attribute5',
314                           p_adj_rec.attribute5);
315 
316    dbms_sql.bind_variable(p_update_cursor, ':attribute6',
317                           p_adj_rec.attribute6);
318 
319    dbms_sql.bind_variable(p_update_cursor, ':attribute7',
320                           p_adj_rec.attribute7);
321 
322    dbms_sql.bind_variable(p_update_cursor, ':attribute8',
323                           p_adj_rec.attribute8);
324 
325    dbms_sql.bind_variable(p_update_cursor, ':attribute9',
326                           p_adj_rec.attribute9);
327 
328    dbms_sql.bind_variable(p_update_cursor, ':attribute10',
329                           p_adj_rec.attribute10);
330 
331    dbms_sql.bind_variable(p_update_cursor, ':attribute11',
332                           p_adj_rec.attribute11);
333 
334    dbms_sql.bind_variable(p_update_cursor, ':attribute12',
335                           p_adj_rec.attribute12);
336 
337    dbms_sql.bind_variable(p_update_cursor, ':attribute13',
338                           p_adj_rec.attribute13);
339 
340    dbms_sql.bind_variable(p_update_cursor, ':attribute14',
341                           p_adj_rec.attribute14);
342 
343    dbms_sql.bind_variable(p_update_cursor, ':attribute15',
344                           p_adj_rec.attribute15);
345 
346    dbms_sql.bind_variable(p_update_cursor, ':posting_control_id',
347                           p_adj_rec.posting_control_id);
348 
349    dbms_sql.bind_variable(p_update_cursor, ':last_update_login',
350                           p_adj_rec.last_update_login);
351 
352    dbms_sql.bind_variable(p_update_cursor, ':created_by',
353                           p_adj_rec.created_by);
354 
355    dbms_sql.bind_variable(p_update_cursor, ':creation_date',
356                           p_adj_rec.creation_date);
357 
358    dbms_sql.bind_variable(p_update_cursor, ':program_application_id',
359                           p_adj_rec.program_application_id);
360 
361    dbms_sql.bind_variable(p_update_cursor, ':program_id',
362                           p_adj_rec.program_id);
363 
364    dbms_sql.bind_variable(p_update_cursor, ':program_update_date',
365                           p_adj_rec.program_update_date);
366 
367    dbms_sql.bind_variable(p_update_cursor, ':request_id',
368                           p_adj_rec.request_id);
369 
370    arp_util.debug('arp_adjustments_pkg.bind_adj_variables()-');
371 
372 EXCEPTION
373     WHEN OTHERS THEN
374         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.bind_adj_variables()');
375         RAISE;
376 
377 END;
378 
379 
380 /*===========================================================================+
381  | PROCEDURE                                                                 |
382  |    construct_adj_update_stmt 					     |
383  |                                                                           |
384  | DESCRIPTION                                                               |
385  |    Copies the text of the dynamic SQL update statement into the           |
386  |    out NOCOPY paramater. The update statement does not contain a where clause    |
387  |    since this is the dynamic part that is added later.                    |
388  |                                                                           |
389  | SCOPE - PRIVATE                                                           |
390  |                                                                           |
391  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
392  |    arp_util.debug                                                         |
393  |                                                                           |
394  | ARGUMENTS  : IN:                                                          |
395  |                    None.                                                  |
396  |              OUT:                                                         |
397  |                    update_text  - text of the update statement            |
398  |                                                                           |
399  | RETURNS    : NONE                                                         |
400  |                                                                           |
401  | NOTES                                                                     |
402  |    This statement only updates columns in the srep record that do not     |
403  |    contain the dummy values that indicate that they should not be changed.|
404  |                                                                           |
405  | MODIFICATION HISTORY                                                      |
406  |     29-JUN-95  Charlie Tomberg     Created                                |
407  |     9/18/1996  Harri Kaukovuo      Bug fix 403019. Procedure was always
408  |				      recalculating accounted amount (the
409  |				      wrong way, BTW).
410  |     20/11/2001 Veena Rao	      Bug 2098727 last_update_date should be |
411  |					set to sysdate. This is in compliance|
412  |					with INSERT operation now.           |
413  +===========================================================================*/
414 
415 PROCEDURE construct_adj_update_stmt( update_text OUT NOCOPY varchar2) IS
416 
417 
418 BEGIN
419 
420    arp_util.debug('arp_adjustments_pkg.construct_adj_update_stmt()+');
421 
422    update_text :=
423  'UPDATE ar_adjustments
424    SET    adjustment_id =
425                DECODE(:adjustment_id,
426                       :ar_number_dummy, adjustment_id,
427                                         :adjustment_id),
428           amount =
429                DECODE(:amount,
430                       :ar_number_dummy, amount,
431                                         :amount),
432           acctd_amount =
433 	       DECODE (:acctd_amount
434 			, :ar_number_dummy, acctd_amount
435 			, :acctd_amount),
436           apply_date =
437                DECODE(:apply_date,
438                       :ar_date_dummy, apply_date,
439                                         :apply_date),
440           gl_date =
441                DECODE(:gl_date,
442                       :ar_date_dummy, gl_date,
443                                         :gl_date),
444           gl_posted_date =
445                DECODE(:gl_posted_date,
446                       :ar_date_dummy, gl_posted_date,
447                                         :gl_posted_date),
448           set_of_books_id =
449                DECODE(:set_of_books_id,
450                       :ar_number_dummy, set_of_books_id,
451                                         :set_of_books_id),
452           code_combination_id =
453                DECODE(:code_combination_id,
454                       :ar_number_dummy, code_combination_id,
455                                         :code_combination_id),
456           type =
457                DECODE(:type,
458                       :ar_text_dummy, type,
459                                         :type),
460           adjustment_type =
461                DECODE(:adjustment_type,
462                       :ar_text3_dummy, adjustment_type,
463                                         :adjustment_type),
464           status =
465                DECODE(:status,
466                       :ar_text_dummy, status,
467                                         :status),
468           line_adjusted =
469                DECODE(:line_adjusted,
470                       :ar_number_dummy, line_adjusted,
471                                         :line_adjusted),
472           freight_adjusted =
473                DECODE(:freight_adjusted,
474                       :ar_number_dummy, freight_adjusted,
475                                         :freight_adjusted),
476           tax_adjusted =
477                DECODE(:tax_adjusted,
478                       :ar_number_dummy, tax_adjusted,
479                                         :tax_adjusted),
480           receivables_charges_adjusted =
481                DECODE(:receivables_charges_adjusted,
482                       :ar_number_dummy, receivables_charges_adjusted,
483                                         :receivables_charges_adjusted),
484           batch_id =
485                DECODE(:batch_id,
486                       :ar_number_dummy, batch_id,
487                                         :batch_id),
488           customer_trx_id =
489                DECODE(:customer_trx_id,
490                       :ar_number_dummy, customer_trx_id,
491                                         :customer_trx_id),
492           subsequent_trx_id =
493                DECODE(:subsequent_trx_id,
494                       :ar_number_dummy, subsequent_trx_id,
495                                         :subsequent_trx_id),
496           customer_trx_line_id =
497                DECODE(:customer_trx_line_id,
498                       :ar_number_dummy, customer_trx_line_id,
499                                         :customer_trx_line_id),
500           associated_cash_receipt_id =
501                DECODE(:associated_cash_receipt_id,
502                       :ar_number_dummy, associated_cash_receipt_id,
503                                         :associated_cash_receipt_id),
504           chargeback_customer_trx_id =
505                DECODE(:chargeback_customer_trx_id,
506                       :ar_number_dummy, chargeback_customer_trx_id,
507                                         :chargeback_customer_trx_id),
508           payment_schedule_id =
509                DECODE(:payment_schedule_id,
510                       :ar_number_dummy, payment_schedule_id,
511                                         :payment_schedule_id),
512           receivables_trx_id =
513                DECODE(:receivables_trx_id,
514                       :ar_number_dummy, receivables_trx_id,
515                                         :receivables_trx_id),
516           distribution_set_id =
517                DECODE(:distribution_set_id,
518                       :ar_number_dummy, distribution_set_id,
519                                         :distribution_set_id),
520           associated_application_id =
521                DECODE(:associated_application_id,
522                       :ar_number_dummy, associated_application_id,
523                                         :associated_application_id),
524           comments =
525                DECODE(:comments,
526                       :ar_text_dummy, comments,
527                                         :comments),
528           automatically_generated =
529                DECODE(:automatically_generated,
530                       :ar_flag_dummy, automatically_generated,
531                                         :automatically_generated),
532           created_from =
533                DECODE(:created_from,
534                       :ar_text_dummy, created_from,
535                                         :created_from),
536           reason_code =
537                DECODE(:reason_code,
538                       :ar_text_dummy, reason_code,
539                                         :reason_code),
540 
541           postable = DECODE(
542                               DECODE(:status,
543                                      :ar_text_dummy, status,
544                                                      :status ),
545                              ''A'', DECODE(NVL(:accounting_affect_flag,''Y''), ''N'', ''N'',''Y''),
546                                    ''N''
547                            ),
548 
549           approved_by =
550                   DECODE(
551                            DECODE(:adjustment_type,
552                                   :ar_text3_dummy, adjustment_type,
553                                                    :adjustment_type),
554                            ''C'', NULL,
555                                 DECODE(
556                                          DECODE(:status,
557                                                 :ar_text_dummy, status,
558                                                                 :status),
559                                         ''A'', :pg_user_id,
560                                              NULL
561                                       )
562                        ),
563           adjustment_number =
564                DECODE(:adjustment_number,
565                       :ar_text_dummy, adjustment_number,
566                                         :adjustment_number),
567           doc_sequence_value =
568                DECODE(:doc_sequence_value,
569                       :ar_number_dummy, doc_sequence_value,
570                                         :doc_sequence_value),
571           doc_sequence_id =
572                DECODE(:doc_sequence_id,
573                       :ar_number_dummy, doc_sequence_id,
574                                         :doc_sequence_id),
575           ussgl_transaction_code =
576                DECODE(:ussgl_transaction_code,
577                       :ar_text_dummy, ussgl_transaction_code,
578                                         :ussgl_transaction_code),
579           ussgl_transaction_code_context =
580                DECODE(:ussgl_transaction_code_context,
581                       :ar_text_dummy, ussgl_transaction_code_context,
582                                         :ussgl_transaction_code_context),
583           attribute_category =
584                DECODE(:attribute_category,
585                       :ar_text_dummy, attribute_category,
586                                         :attribute_category),
587           attribute1 =
588                DECODE(:attribute1,
589                       :ar_text_dummy, attribute1,
590                                         :attribute1),
591           attribute2 =
592                DECODE(:attribute2,
593                       :ar_text_dummy, attribute2,
594                                         :attribute2),
595           attribute3 =
596                DECODE(:attribute3,
597                       :ar_text_dummy, attribute3,
598                                         :attribute3),
599           attribute4 =
600                DECODE(:attribute4,
601                       :ar_text_dummy, attribute4,
602                                         :attribute4),
603           attribute5 =
604                DECODE(:attribute5,
605                       :ar_text_dummy, attribute5,
606                                         :attribute5),
607           attribute6 =
608                DECODE(:attribute6,
609                       :ar_text_dummy, attribute6,
610                                         :attribute6),
611           attribute7 =
612                DECODE(:attribute7,
613                       :ar_text_dummy, attribute7,
614                                         :attribute7),
615           attribute8 =
616                DECODE(:attribute8,
617                       :ar_text_dummy, attribute8,
618                                         :attribute8),
619           attribute9 =
620                DECODE(:attribute9,
621                       :ar_text_dummy, attribute9,
622                                         :attribute9),
623           attribute10 =
624                DECODE(:attribute10,
625                       :ar_text_dummy, attribute10,
626                                         :attribute10),
627           attribute11 =
628                DECODE(:attribute11,
629                       :ar_text_dummy, attribute11,
630                                         :attribute11),
631           attribute12 =
632                DECODE(:attribute12,
633                       :ar_text_dummy, attribute12,
634                                         :attribute12),
635           attribute13 =
636                DECODE(:attribute13,
637                       :ar_text_dummy, attribute13,
638                                         :attribute13),
639           attribute14 =
640                DECODE(:attribute14,
641                       :ar_text_dummy, attribute14,
642                                         :attribute14),
643           attribute15 =
644                DECODE(:attribute15,
645                       :ar_text_dummy, attribute15,
646                                         :attribute15),
647           posting_control_id =
648                DECODE(:posting_control_id,
649                       :ar_number_dummy, posting_control_id,
650                                         :posting_control_id),
651           last_updated_by =
652              NVL(
653                   DECODE(
654                            DECODE(:adjustment_type,
655                                   :ar_text3_dummy, adjustment_type,
656                                                    :adjustment_type),
657                            ''C'', NULL,
658                                 DECODE(
659                                          DECODE(:status,
660                                                 :ar_text_dummy, status,
661                                                                 :status),
662                                         ''A'', :pg_user_id,
663                                              NULL
664                                       )
665                         ),    -- approved_by
666                   :pg_user_id
667                 ),
668           last_update_date =  sysdate , --Bug 2098727
669 
670           last_update_login =
671                DECODE(:last_update_login,
672                       :ar_number_dummy, nvl(:pg_conc_login_id,
673                                             :pg_login_id),
674                                         :last_update_login),
675           created_by =
676                DECODE(:created_by,
677                       :ar_number_dummy, created_by,
678                                         :created_by),
679           creation_date =
680                DECODE(:creation_date,
681                       :ar_date_dummy, creation_date,
682                                         :creation_date),
683           program_application_id =
684                DECODE(:program_application_id,
685                       :ar_number_dummy, program_application_id,
686                                         :program_application_id),
687           program_id =
688                DECODE(:program_id,
689                       :ar_number_dummy, program_id,
690                                         :program_id),
691           program_update_date =
692                DECODE(:program_update_date,
693                       :ar_date_dummy, program_update_date,
694                                         :program_update_date),
695           request_id =
696                DECODE(:request_id,
697                       :ar_number_dummy, request_id,
698                                         :request_id)';
699 
700    arp_util.debug('arp_adjustments_pkg.construct_adj_update_stmt()-');
701 
702 EXCEPTION
703     WHEN OTHERS THEN
704        arp_util.debug('EXCEPTION:  arp_adjustments_pkg.construct_adj_update_stmt()');
705        RAISE;
706 
707 END;
708 
709 /*===========================================================================+
710  | PROCEDURE                                                                 |
711  |    generic_update                                                         |
712  |                                                                           |
713  | DESCRIPTION                                                               |
714  |     This procedure Updates records in ar_adjustments  	             |
715  |     identified by the where clause that is passed in as a parameter. Only |
716  |     those columns in the srep record parameter that do not contain the    |
717  |     special dummy values are updated. 				     |
718  |                                                                           |
719  | SCOPE - PRIVATE                                                           |
720  |                                                                           |
721  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
722  |    arp_util.debug                                                         |
723  |    dbms_sql.open_cursor 						     |
724  |    dbms_sql.parse							     |
725  |    dbms_sql.execute							     |
726  |    dbms_sql.close_cursor						     |
727  |                                                                           |
728  | ARGUMENTS  : IN:                                                          |
729  |		      p_update_cursor  - identifies the cursor to use 	     |
730  |                    p_where_clause   - identifies which rows to update     |
731  | 		      p_where1         - value to bind into where clause     |
732  |                    p_exchange_rate                                        |
733  |		      p_adj_rec        - contains the new srep values        |
734  |              OUT:                                                         |
735  |                    None						     |
736  |                                                                           |
737  | RETURNS    : NONE                                                         |
738  |                                                                           |
739  | NOTES                                                                     |
740  |                                                                           |
741  | MODIFICATION HISTORY                                                      |
742  |     29-JUN-95  Charlie Tomberg     Created                                |
743  |                                                                           |
744  +===========================================================================*/
745 
746 PROCEDURE generic_update(p_update_cursor IN OUT NOCOPY integer,
747 			 p_where_clause  IN varchar2,
748 			 p_where1        IN number,
749                          p_exchange_rate IN
750                                        ar_payment_schedules.exchange_rate%type,
751                          p_adj_rec       IN ar_adjustments%rowtype)
752           IS
753 
754    l_count             number;
755    l_update_statement  varchar2(25000);
756    l_adj_key_value_list   gl_ca_utility_pkg.r_key_value_arr;
757    adj_array   dbms_sql.number_table;
758 
759 BEGIN
760    arp_util.debug('arp_adjustments_pkg.generic_update()+');
761 
762    arp_util.debug('');
763    arp_util.debug('-------- parameters for generic_update() ------');
764 
765    arp_util.debug('p_update_cursor      = ' || p_update_cursor);
766    arp_util.debug('p_where_clause       = ' || p_where_clause);
767    arp_util.debug('p_where1             = ' || p_where1);
768    arp_util.debug('p_exchange_rate      = ' || p_exchange_rate);
769 
770    arp_adjustments_pkg.display_adj_rec(p_adj_rec);
771 
772   /*--------------------------------------------------------------+
773    |  If this update statement has not already been parsed, 	  |
774    |  construct the statement and parse it.			  |
775    |  Otherwise, use the already parsed statement and rebind its  |
776    |  variables.						  |
777    +--------------------------------------------------------------*/
778 
779    IF (p_update_cursor IS NULL)
780    THEN
781 
782          p_update_cursor := dbms_sql.open_cursor;
783 
784          /*---------------------------------+
785           |  Construct the update statement |
786           +---------------------------------*/
787 
788          arp_adjustments_pkg.construct_adj_update_stmt(l_update_statement);
789 
790          l_update_statement := l_update_statement || p_where_clause;
791 
792          /*  add on mrc variables for bulk collect */
793          l_update_statement := l_update_statement ||
794              ' RETURNING adjustment_id INTO :adj_key_value ';
795 
796          /*-----------------------------------------------+
797           |  Parse, bind, execute and close the statement |
798           +-----------------------------------------------*/
799 
800          dbms_sql.parse(p_update_cursor,
801                         l_update_statement,
802                         dbms_sql.v7);
803 
804    END IF;
805 
806    arp_adjustments_pkg.bind_adj_variables(p_update_cursor,
807                                   p_adj_rec,
808                                   p_exchange_rate,
809                                   pg_base_curr_code,
810                                   pg_base_precision,
811                                   pg_base_min_acc_unit);
812 
813   /*---------------------------+
814    | Bind output variable      |
815    +---------------------------*/
816    dbms_sql.bind_array(p_update_cursor,':adj_key_value',
817                           adj_array);
818 
819   /*-----------------------------------------+
820    |  Bind the variables in the where clause |
821    +-----------------------------------------*/
822 
823    dbms_sql.bind_variable(p_update_cursor, ':where_1',
824                           p_where1);
825 
826    l_count := dbms_sql.execute(p_update_cursor);
827 
828    arp_util.debug( to_char(l_count) || ' rows updated');
829 
830    /*------------------------------------------+
831     | get RETURNING COLUMN into OUT NOCOPY bind array |
832     +------------------------------------------*/
833 
834     dbms_sql.variable_value( p_update_cursor, ':adj_key_value', adj_array);
835 
836 
837    /*------------------------------------------------------------+
838     |  Raise the NO_DATA_FOUND exception if no rows were updated |
839     +------------------------------------------------------------*/
840 
841    IF   (l_count = 0)
842    THEN RAISE NO_DATA_FOUND;
843    END IF;
844 
845 --{BUG4301323
846 --    FOR I in adj_array.FIRST..adj_array.LAST LOOP
847        /*---------------------------------------------+
848         | call mrc engine to update AR_MC_ADJUSTMENTS |
849         +---------------------------------------------*/
850 --       ar_mrc_engine.maintain_mrc_data(
851 --                        p_event_mode       => 'UPDATE',
852 --                        p_table_name       => 'AR_ADJUSTMENTS',
853 --                        p_mode             => 'SINGLE',
854 --                        p_key_value        => adj_array(I));
855 --   END LOOP;
856 
857 
858    arp_util.debug('arp_adjustments_pkg.generic_update()-');
859 
860 EXCEPTION
861     WHEN OTHERS THEN
862         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.generic_update()');
863 
864         arp_util.debug('');
865         arp_util.debug('-------- parameters for generic_update() ------');
866 
867         arp_util.debug('p_update_cursor      = ' || p_update_cursor);
868         arp_util.debug('p_where_clause       = ' || p_where_clause);
869         arp_util.debug('p_where1             = ' || p_where1);
870         arp_adjustments_pkg.display_adj_rec(p_adj_rec);
871 
872         arp_util.debug(l_update_statement);
873         arp_util.debug('Error at character: ' ||
874                            to_char(dbms_sql.last_error_position));
875         RAISE;
876 END;
877 
878 /*===========================================================================+
879  | PROCEDURE                                                                 |
880  |    set_to_dummy							     |
881  |                                                                           |
882  | DESCRIPTION                                                               |
883  |    This procedure initializes all columns in the parameter srep record    |
884  |    to the appropriate dummy value for its datatype.			     |
885  |    									     |
886  |    The dummy values are defined in the following package level constants: |
887  |	AR_TEXT_DUMMY 							     |
888  |	AR_TEXT3_DUMMY 							     |
889  |	AR_NUMBER_DUMMY							     |
890  |	AR_DATE_DUMMY							     |
891  |                                                                           |
892  | SCOPE - PUBLIC                                                            |
893  |                                                                           |
894  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
895  |    arp_util.debug                                                         |
896  |                                                                           |
897  | ARGUMENTS  : IN:                                                          |
898  |                    None						     |
899  |              OUT:                                                         |
900  |                    p_adj_rec   - The record to initialize		     |
901  |                                                                           |
902  | RETURNS    : NONE                                                         |
903  |                                                                           |
904  | NOTES                                                                     |
905  |                                                                           |
906  | MODIFICATION HISTORY                                                      |
907  |     29-JUN-95  Charlie Tomberg     Created                                |
908  |                                                                           |
909  +===========================================================================*/
910 
911 PROCEDURE set_to_dummy( p_adj_rec OUT NOCOPY ar_adjustments%rowtype) IS
912 
913 BEGIN
914 
915     arp_util.debug('arp_adjustments_pkg.set_to_dummy()+');
916 
917     p_adj_rec.adjustment_id			:= AR_NUMBER_DUMMY;
918     p_adj_rec.amount				:= AR_NUMBER_DUMMY;
919     p_adj_rec.acctd_amount			:= AR_NUMBER_DUMMY;
920     p_adj_rec.apply_date			:= AR_DATE_DUMMY;
921     p_adj_rec.gl_date				:= AR_DATE_DUMMY;
922     p_adj_rec.gl_posted_date			:= AR_DATE_DUMMY;
923     p_adj_rec.set_of_books_id			:= AR_NUMBER_DUMMY;
924     p_adj_rec.code_combination_id		:= AR_NUMBER_DUMMY;
925     p_adj_rec.type				:= AR_TEXT_DUMMY;
926     p_adj_rec.adjustment_type			:= AR_TEXT3_DUMMY;
927     p_adj_rec.status				:= AR_TEXT_DUMMY;
928     p_adj_rec.line_adjusted			:= AR_NUMBER_DUMMY;
929     p_adj_rec.freight_adjusted			:= AR_NUMBER_DUMMY;
930     p_adj_rec.tax_adjusted			:= AR_NUMBER_DUMMY;
931     p_adj_rec.receivables_charges_adjusted	:= AR_NUMBER_DUMMY;
932     p_adj_rec.batch_id				:= AR_NUMBER_DUMMY;
933     p_adj_rec.customer_trx_id			:= AR_NUMBER_DUMMY;
934     p_adj_rec.subsequent_trx_id			:= AR_NUMBER_DUMMY;
935     p_adj_rec.customer_trx_line_id		:= AR_NUMBER_DUMMY;
936     p_adj_rec.associated_cash_receipt_id	:= AR_NUMBER_DUMMY;
937     p_adj_rec.chargeback_customer_trx_id	:= AR_NUMBER_DUMMY;
938     p_adj_rec.payment_schedule_id		:= AR_NUMBER_DUMMY;
939     p_adj_rec.receivables_trx_id		:= AR_NUMBER_DUMMY;
940     p_adj_rec.distribution_set_id		:= AR_NUMBER_DUMMY;
941     p_adj_rec.associated_application_id		:= AR_NUMBER_DUMMY;
942     p_adj_rec.comments				:= AR_TEXT_DUMMY;
943     p_adj_rec.automatically_generated		:= AR_FLAG_DUMMY;
944     p_adj_rec.created_from			:= AR_TEXT_DUMMY;
945     p_adj_rec.reason_code			:= AR_TEXT_DUMMY;
946     p_adj_rec.postable				:= AR_FLAG_DUMMY;
947     p_adj_rec.approved_by			:= AR_NUMBER_DUMMY;
948     p_adj_rec.adjustment_number			:= AR_TEXT_DUMMY;
949     p_adj_rec.doc_sequence_value		:= AR_NUMBER_DUMMY;
950     p_adj_rec.doc_sequence_id			:= AR_NUMBER_DUMMY;
951     p_adj_rec.ussgl_transaction_code		:= AR_TEXT_DUMMY;
952     p_adj_rec.ussgl_transaction_code_context	:= AR_TEXT_DUMMY;
953     p_adj_rec.attribute_category		:= AR_TEXT_DUMMY;
954     p_adj_rec.attribute1			:= AR_TEXT_DUMMY;
955     p_adj_rec.attribute2			:= AR_TEXT_DUMMY;
956     p_adj_rec.attribute3			:= AR_TEXT_DUMMY;
957     p_adj_rec.attribute4			:= AR_TEXT_DUMMY;
958     p_adj_rec.attribute5			:= AR_TEXT_DUMMY;
959     p_adj_rec.attribute6			:= AR_TEXT_DUMMY;
960     p_adj_rec.attribute7			:= AR_TEXT_DUMMY;
961     p_adj_rec.attribute8			:= AR_TEXT_DUMMY;
962     p_adj_rec.attribute9			:= AR_TEXT_DUMMY;
963     p_adj_rec.attribute10			:= AR_TEXT_DUMMY;
964     p_adj_rec.attribute11			:= AR_TEXT_DUMMY;
965     p_adj_rec.attribute12			:= AR_TEXT_DUMMY;
966     p_adj_rec.attribute13			:= AR_TEXT_DUMMY;
967     p_adj_rec.attribute14			:= AR_TEXT_DUMMY;
968     p_adj_rec.attribute15			:= AR_TEXT_DUMMY;
969     p_adj_rec.posting_control_id		:= AR_NUMBER_DUMMY;
970     p_adj_rec.last_updated_by			:= AR_NUMBER_DUMMY;
971     p_adj_rec.last_update_date			:= AR_DATE_DUMMY;
972     p_adj_rec.last_update_login			:= AR_NUMBER_DUMMY;
973     p_adj_rec.created_by			:= AR_NUMBER_DUMMY;
974     p_adj_rec.creation_date			:= AR_DATE_DUMMY;
975     p_adj_rec.program_application_id		:= AR_NUMBER_DUMMY;
976     p_adj_rec.program_id			:= AR_NUMBER_DUMMY;
977     p_adj_rec.program_update_date		:= AR_DATE_DUMMY;
978     p_adj_rec.request_id			:= AR_NUMBER_DUMMY;
979 
980     arp_util.debug('arp_adjustments_pkg.set_to_dummy()-');
981 
982 EXCEPTION
983     WHEN OTHERS THEN
984         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.set_to_dummy()');
985         RAISE;
986 
987 END;
988 
989 
990 /*===========================================================================+
991  | PROCEDURE                                                                 |
992  |    lock_p								     |
993  |                                                                           |
994  | DESCRIPTION                                                               |
995  |    This procedure locks the ar_adjustments row identified by  |
996  |    p_adjustment_id parameter.				     |
997  |                                                                           |
998  | SCOPE - PUBLIC                                                            |
999  |                                                                           |
1000  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1001  |    arp_util.debug                                                         |
1002  |                                                                           |
1003  | ARGUMENTS  : IN:                                                          |
1004  |                  p_adjustment_id - identifies the row to lock |
1005  |              OUT:                                                         |
1006  |                  None						     |
1007  |                                                                           |
1008  | RETURNS    : NONE                                                         |
1009  |                                                                           |
1010  | NOTES                                                                     |
1011  |                                                                           |
1012  | MODIFICATION HISTORY                                                      |
1013  |     29-JUN-95  Charlie Tomberg     Created                                |
1014  |                                                                           |
1015  +===========================================================================*/
1016 
1017 PROCEDURE lock_p( p_adjustment_id IN ar_adjustments.adjustment_id%type
1018                 )
1019           IS
1020 
1021     l_adjustment_id  ar_adjustments.adjustment_id%type;
1022 
1023 BEGIN
1024     arp_util.debug('arp_adjustments_pkg.lock_p()+');
1025 
1026 
1027     SELECT        adjustment_id
1028     INTO          l_adjustment_id
1029     FROM          ar_adjustments
1030     WHERE         adjustment_id = p_adjustment_id
1031     FOR UPDATE OF adjustment_id NOWAIT;
1032 
1033     arp_util.debug('arp_adjustments_pkg.lock_p()-');
1034 
1035     EXCEPTION
1036         WHEN  OTHERS THEN
1037 	    arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_p' );
1038             RAISE;
1039 END;
1040 
1041 /*===========================================================================+
1042  | PROCEDURE                                                                 |
1043  |    lock_f_ct_id							     |
1044  |                                                                           |
1045  | DESCRIPTION                                                               |
1046  |    This procedure locks the ar_adjustments rows identified by  	     |
1047  |    p_customer_trx_id parameter.					     |
1048  |                                                                           |
1049  | SCOPE - PUBLIC                                                            |
1050  |                                                                           |
1051  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1052  |    arp_util.debug                                                         |
1053  |                                                                           |
1054  | ARGUMENTS  : IN:                                                          |
1055  |                  p_customer_trx_id 	- identifies the rows to lock	     |
1056  |              OUT:                                                         |
1057  |                  None						     |
1058  |                                                                           |
1059  | RETURNS    : NONE                                                         |
1060  |                                                                           |
1061  | NOTES                                                                     |
1062  |                                                                           |
1063  | MODIFICATION HISTORY                                                      |
1064  |     29-JUN-95  Charlie Tomberg     Created                                |
1065  |                                                                           |
1066  +===========================================================================*/
1067 
1068 PROCEDURE lock_f_ct_id( p_customer_trx_id
1069                            IN ra_customer_trx.customer_trx_id%type )
1070           IS
1071 
1072     CURSOR LOCK_C IS
1073     SELECT        adjustment_id
1074     FROM          ar_adjustments
1075     WHERE         customer_trx_id = p_customer_trx_id
1076     FOR UPDATE OF adjustment_id NOWAIT;
1077 
1078 
1079 BEGIN
1080     arp_util.debug('arp_adjustments_pkg.lock_f_ct_id()+');
1081 
1082     OPEN lock_c;
1083     CLOSE lock_c;
1084 
1085     arp_util.debug('arp_adjustments_pkg.lock_f_ct_id()-');
1086 
1087     EXCEPTION
1088         WHEN  OTHERS THEN
1089 	    arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_f_ct_id' );
1090             RAISE;
1091 END;
1092 
1093 /*===========================================================================+
1094  | PROCEDURE                                                                 |
1095  |    lock_f_st_id							     |
1096  |                                                                           |
1097  | DESCRIPTION                                                               |
1098  |    This procedure locks the ar_adjustments rows identified by  	     |
1099  |    p_subsequent_trx_id parameter.					     |
1100  |                                                                           |
1101  | SCOPE - PUBLIC                                                            |
1102  |                                                                           |
1103  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1104  |    arp_util.debug                                                         |
1105  |                                                                           |
1106  | ARGUMENTS  : IN:                                                          |
1107  |                p_subsequent_trx_id - identifies the rows to lock	     |
1108  |              OUT:                                                         |
1109  |                  None						     |
1110  |                                                                           |
1111  | RETURNS    : NONE                                                         |
1112  |                                                                           |
1113  | NOTES                                                                     |
1114  |                                                                           |
1115  | MODIFICATION HISTORY                                                      |
1116  |     29-JUN-95  Charlie Tomberg     Created                                |
1117  |                                                                           |
1118  +===========================================================================*/
1119 
1120 PROCEDURE lock_f_st_id( p_subsequent_trx_id
1121                            IN ra_customer_trx.customer_trx_id%type )
1122           IS
1123 
1124     CURSOR LOCK_C IS
1125     SELECT        adjustment_id
1126     FROM          ar_adjustments
1127     WHERE         subsequent_trx_id = p_subsequent_trx_id
1128     FOR UPDATE OF adjustment_id NOWAIT;
1129 
1130 
1131 BEGIN
1132     arp_util.debug('arp_adjustments_pkg.lock_f_st_id()+');
1133 
1134     OPEN lock_c;
1135     CLOSE lock_c;
1136 
1137     arp_util.debug('arp_adjustments_pkg.lock_f_st_id()-');
1138 
1139     EXCEPTION
1140         WHEN  OTHERS THEN
1141 	    arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_f_st_id' );
1142             RAISE;
1143 END;
1144 
1145 /*===========================================================================+
1146  | PROCEDURE                                                                 |
1147  |    lock_f_ps_id							     |
1148  |                                                                           |
1149  | DESCRIPTION                                                               |
1150  |    This procedure locks the ar_adjustments rows identified by  	     |
1151  |    p_payment_schedule_trx_id parameter.				     |
1152  |                                                                           |
1153  | SCOPE - PUBLIC                                                            |
1154  |                                                                           |
1155  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1156  |    arp_util.debug                                                         |
1157  |                                                                           |
1158  | ARGUMENTS  : IN:                                                          |
1159  |                p_payment_schedule_id - identifies the rows to lock	     |
1160  |              OUT:                                                         |
1161  |                  None						     |
1162  |                                                                           |
1163  | RETURNS    : NONE                                                         |
1164  |                                                                           |
1165  | NOTES                                                                     |
1166  |                                                                           |
1167  | MODIFICATION HISTORY                                                      |
1168  |     29-JUN-95  Charlie Tomberg     Created                                |
1169  |                                                                           |
1170  +===========================================================================*/
1171 
1172 PROCEDURE lock_f_ps_id( p_payment_schedule_id
1173                            IN ar_payment_schedules.payment_schedule_id%type )
1174           IS
1175 
1176     CURSOR LOCK_C IS
1177     SELECT        adjustment_id
1178     FROM          ar_adjustments
1179     WHERE         payment_schedule_id = p_payment_schedule_id
1180     FOR UPDATE OF adjustment_id NOWAIT;
1181 
1182 
1183 BEGIN
1184     arp_util.debug('arp_adjustments_pkg.lock_f_ps_id()+');
1185 
1186     OPEN lock_c;
1187     CLOSE lock_c;
1188 
1189     arp_util.debug('arp_adjustments_pkg.lock_f_ps_id()-');
1190 
1191     EXCEPTION
1192         WHEN  OTHERS THEN
1193 	    arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_f_ps_id' );
1194             RAISE;
1195 END;
1196 
1197 /*===========================================================================+
1198  | PROCEDURE                                                                 |
1199  |    lock_f_ctl_id							     |
1200  |                                                                           |
1201  | DESCRIPTION                                                               |
1202  |    This procedure locks the ar_adjustments rows identified by 	     |
1203  |    p_customer_trx_line_id parameter.					     |
1204  |                                                                           |
1205  | SCOPE - PUBLIC                                                            |
1206  |                                                                           |
1207  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1208  |    arp_util.debug                                                         |
1209  |                                                                           |
1210  | ARGUMENTS  : IN:                                                          |
1211  |                  p_customer_trx_line_id - identifies the rows to lock     |
1212  |              OUT:                                                         |
1213  |                  None						     |
1214  |                                                                           |
1215  | RETURNS    : NONE                                                         |
1216  |                                                                           |
1217  | NOTES                                                                     |
1218  |                                                                           |
1219  | MODIFICATION HISTORY                                                      |
1220  |     29-JUN-95  Charlie Tomberg     Created                                |
1221  |                                                                           |
1222  +===========================================================================*/
1223 
1224 PROCEDURE lock_f_ctl_id( p_customer_trx_line_id
1225                            IN ra_customer_trx_lines.customer_trx_line_id%type)
1226           IS
1227 
1228     CURSOR lock_c IS
1229     SELECT        adjustment_id
1230     FROM          ar_adjustments
1231     WHERE         customer_trx_line_id = p_customer_trx_line_id
1232     FOR UPDATE OF adjustment_id NOWAIT;
1233 
1234 BEGIN
1235     arp_util.debug('arp_adjustments_pkg.lock_f_ctl_id()+');
1236 
1237     OPEN lock_c;
1238     CLOSE lock_c;
1239 
1240     arp_util.debug('arp_adjustments_pkg.lock_f_ctl_id()-');
1241 
1242     EXCEPTION
1243         WHEN  OTHERS THEN
1244 	    arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_f_ctl_id' );
1245             RAISE;
1246 END;
1247 
1248 /*===========================================================================+
1249  | PROCEDURE                                                                 |
1250  |    lock_fetch_p							     |
1251  |                                                                           |
1252  | DESCRIPTION                                                               |
1253  |    This procedure locks the ar_adjustments row identified   		     |
1254  |    by the p_adjustment_id parameter and populates the         	     |
1255  |    p_adj_rec parameter with the row that was locked.		     	     |
1256  |                                                                           |
1257  | SCOPE - PUBLIC                                                            |
1258  |                                                                           |
1259  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1260  |    arp_util.debug                                                         |
1261  |                                                                           |
1262  | ARGUMENTS  : IN:                                                          |
1263  |                  p_adjustment_id - identifies the row to lock 	     |
1264  |              OUT:                                                         |
1265  |                  p_adj_rec			- contains the locked row    |
1266  |                                                                           |
1267  | RETURNS    : NONE                                                         |
1268  |                                                                           |
1269  | NOTES                                                                     |
1270  |                                                                           |
1271  | MODIFICATION HISTORY                                                      |
1272  |     29-JUN-95  Charlie Tomberg     Created                                |
1273  |                                                                           |
1274  +===========================================================================*/
1275 
1276 PROCEDURE lock_fetch_p( p_adj_rec IN OUT NOCOPY ar_adjustments%rowtype,
1277                         p_adjustment_id IN
1278 		ar_adjustments.adjustment_id%type) IS
1279 
1280 BEGIN
1281     arp_util.debug('arp_adjustments_pkg.lock_fetch_p()+');
1282 
1283     SELECT        *
1284     INTO          p_adj_rec
1285     FROM          ar_adjustments
1286     WHERE         adjustment_id = p_adjustment_id
1287     FOR UPDATE OF adjustment_id NOWAIT;
1288 
1289     arp_util.debug('arp_adjustments_pkg.lock_fetch_p()-');
1290 
1291     EXCEPTION
1292         WHEN  OTHERS THEN
1293             arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_fetch_p' );
1294             RAISE;
1295 END;
1296 
1297 /*===========================================================================+
1298  | PROCEDURE                                                                 |
1299  |    lock_compare_p							     |
1300  |                                                                           |
1301  | DESCRIPTION                                                               |
1302  |    This procedure locks the ar_adjustments row identified 		     |
1303  |    by the p_adjustment_id parameter only if no columns in   		     |
1304  |    that row have changed from when they were first selected in the form.  |
1305  |                                                                           |
1306  | SCOPE - PUBLIC                                                            |
1307  |                                                                           |
1308  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1309  |    arp_util.debug                                                         |
1310  |                                                                           |
1311  | ARGUMENTS  : IN:                                                          |
1312  |                 p_adjustment_id - identifies the row to lock 	     |
1313  | 		   p_adj_rec    	- srep record for comparison	     |
1314  |              OUT:                                                         |
1315  |                    None						     |
1316  |                                                                           |
1317  | RETURNS    : NONE                                                         |
1318  |                                                                           |
1319  | NOTES                                                                     |
1320  |                                                                           |
1321  | MODIFICATION HISTORY                                                      |
1322  |     29-JUN-95  Charlie Tomberg     Created                                |
1323  |                                                                           |
1324  +===========================================================================*/
1325 
1326 PROCEDURE lock_compare_p( p_adj_rec IN ar_adjustments%rowtype,
1327                           p_adjustment_id IN ar_adjustments.adjustment_id%type)
1328           IS
1329 
1330     l_new_adj_rec  ar_adjustments%rowtype;
1331 
1332 BEGIN
1333     arp_util.debug('arp_adjustments_pkg.lock_compare_p()+');
1334 
1335     SELECT   *
1336     INTO     l_new_adj_rec
1337     FROM     ar_adjustments adj
1338     WHERE    adj.adjustment_id = p_adjustment_id
1339     AND
1340        (
1341            NVL(adj.adjustment_id, AR_NUMBER_DUMMY) =
1342            NVL(
1343                  DECODE(p_adj_rec.adjustment_id,
1344                         AR_NUMBER_DUMMY, adj.adjustment_id,
1345                                          p_adj_rec.adjustment_id),
1346                  AR_NUMBER_DUMMY
1347               )
1348          AND
1349            NVL(adj.amount, AR_NUMBER_DUMMY) =
1350            NVL(
1351                  DECODE(p_adj_rec.amount,
1352                         AR_NUMBER_DUMMY, adj.amount,
1353                                          p_adj_rec.amount),
1354                  AR_NUMBER_DUMMY
1355               )
1356          AND
1357            NVL(adj.acctd_amount, AR_NUMBER_DUMMY) =
1358            NVL(
1359                  DECODE(p_adj_rec.acctd_amount,
1360                         AR_NUMBER_DUMMY, adj.acctd_amount,
1361                                          p_adj_rec.acctd_amount),
1362                  AR_NUMBER_DUMMY
1363               )
1364          AND
1365            NVL(TRUNC(adj.apply_date), AR_DATE_DUMMY) =
1366            NVL(
1367                  DECODE(p_adj_rec.apply_date,
1368                         AR_DATE_DUMMY, TRUNC(adj.apply_date),
1369                                          p_adj_rec.apply_date),
1370                  AR_DATE_DUMMY
1371               )
1372          AND
1373            NVL(TRUNC(adj.gl_date), AR_DATE_DUMMY) =
1374            NVL(
1375                  DECODE(p_adj_rec.gl_date,
1376                         AR_DATE_DUMMY, TRUNC(adj.gl_date),
1377                                          p_adj_rec.gl_date),
1378                  AR_DATE_DUMMY
1379               )
1380          AND
1381            NVL(TRUNC(adj.gl_posted_date), AR_DATE_DUMMY) =
1382            NVL(
1383                  DECODE(p_adj_rec.gl_posted_date,
1384                         AR_DATE_DUMMY, TRUNC(adj.gl_posted_date),
1385                                          p_adj_rec.gl_posted_date),
1386                  AR_DATE_DUMMY
1387               )
1388          AND
1389            NVL(adj.set_of_books_id, AR_NUMBER_DUMMY) =
1390            NVL(
1391                  DECODE(p_adj_rec.set_of_books_id,
1392                         AR_NUMBER_DUMMY, adj.set_of_books_id,
1393                                          p_adj_rec.set_of_books_id),
1394                  AR_NUMBER_DUMMY
1395               )
1396          AND
1397            NVL(adj.code_combination_id, AR_NUMBER_DUMMY) =
1398            NVL(
1399                  DECODE(p_adj_rec.code_combination_id,
1400                         AR_NUMBER_DUMMY, adj.code_combination_id,
1401                                          p_adj_rec.code_combination_id),
1402                  AR_NUMBER_DUMMY
1403               )
1404          AND
1405            NVL(adj.type, AR_TEXT_DUMMY) =
1406            NVL(
1407                  DECODE(p_adj_rec.type,
1408                         AR_TEXT_DUMMY, adj.type,
1409                                          p_adj_rec.type),
1410                  AR_TEXT_DUMMY
1411               )
1412          AND
1413            NVL(adj.adjustment_type, AR_TEXT3_DUMMY) =
1414            NVL(
1415                  DECODE(p_adj_rec.adjustment_type,
1416                         AR_TEXT3_DUMMY, adj.adjustment_type,
1417                                          p_adj_rec.adjustment_type),
1418                  AR_TEXT3_DUMMY
1419               )
1420          AND
1421            NVL(adj.status, AR_TEXT_DUMMY) =
1422            NVL(
1423                  DECODE(p_adj_rec.status,
1424                         AR_TEXT_DUMMY, adj.status,
1425                                          p_adj_rec.status),
1426                  AR_TEXT_DUMMY
1427               )
1428          AND
1429            NVL(adj.line_adjusted, AR_NUMBER_DUMMY) =
1430            NVL(
1431                  DECODE(p_adj_rec.line_adjusted,
1432                         AR_NUMBER_DUMMY, adj.line_adjusted,
1433                                          p_adj_rec.line_adjusted),
1434                  AR_NUMBER_DUMMY
1435               )
1436          AND
1437            NVL(adj.freight_adjusted, AR_NUMBER_DUMMY) =
1438            NVL(
1439                  DECODE(p_adj_rec.freight_adjusted,
1440                         AR_NUMBER_DUMMY, adj.freight_adjusted,
1441                                          p_adj_rec.freight_adjusted),
1442                  AR_NUMBER_DUMMY
1443               )
1444          AND
1445            NVL(adj.tax_adjusted, AR_NUMBER_DUMMY) =
1446            NVL(
1447                  DECODE(p_adj_rec.tax_adjusted,
1448                         AR_NUMBER_DUMMY, adj.tax_adjusted,
1449                                          p_adj_rec.tax_adjusted),
1450                  AR_NUMBER_DUMMY
1451               )
1452          AND
1453            NVL(adj.receivables_charges_adjusted, AR_NUMBER_DUMMY) =
1454            NVL(
1455                  DECODE(p_adj_rec.receivables_charges_adjusted,
1456                         AR_NUMBER_DUMMY, adj.receivables_charges_adjusted,
1457                                       p_adj_rec.receivables_charges_adjusted),
1458                  AR_NUMBER_DUMMY
1459               )
1460          AND
1461            NVL(adj.batch_id, AR_NUMBER_DUMMY) =
1462            NVL(
1463                  DECODE(p_adj_rec.batch_id,
1464                         AR_NUMBER_DUMMY, adj.batch_id,
1465                                          p_adj_rec.batch_id),
1466                  AR_NUMBER_DUMMY
1467               )
1468          AND
1469            NVL(adj.customer_trx_id, AR_NUMBER_DUMMY) =
1470            NVL(
1471                  DECODE(p_adj_rec.customer_trx_id,
1472                         AR_NUMBER_DUMMY, adj.customer_trx_id,
1473                                          p_adj_rec.customer_trx_id),
1474                  AR_NUMBER_DUMMY
1475               )
1476          AND
1477            NVL(adj.subsequent_trx_id, AR_NUMBER_DUMMY) =
1478            NVL(
1479                  DECODE(p_adj_rec.subsequent_trx_id,
1480                         AR_NUMBER_DUMMY, adj.subsequent_trx_id,
1481                                          p_adj_rec.subsequent_trx_id),
1482                  AR_NUMBER_DUMMY
1483               )
1484          AND
1485            NVL(adj.customer_trx_line_id, AR_NUMBER_DUMMY) =
1486            NVL(
1487                  DECODE(p_adj_rec.customer_trx_line_id,
1488                         AR_NUMBER_DUMMY, adj.customer_trx_line_id,
1489                                          p_adj_rec.customer_trx_line_id),
1490                  AR_NUMBER_DUMMY
1491               )
1492          AND
1493            NVL(adj.associated_cash_receipt_id, AR_NUMBER_DUMMY) =
1494            NVL(
1495                  DECODE(p_adj_rec.associated_cash_receipt_id,
1496                         AR_NUMBER_DUMMY, adj.associated_cash_receipt_id,
1497                                          p_adj_rec.associated_cash_receipt_id),
1498                  AR_NUMBER_DUMMY
1499               )
1500          AND
1501            NVL(adj.chargeback_customer_trx_id, AR_NUMBER_DUMMY) =
1502            NVL(
1503                  DECODE(p_adj_rec.chargeback_customer_trx_id,
1504                         AR_NUMBER_DUMMY, adj.chargeback_customer_trx_id,
1505                                          p_adj_rec.chargeback_customer_trx_id),
1506                  AR_NUMBER_DUMMY
1507               )
1508          AND
1509            NVL(adj.payment_schedule_id, AR_NUMBER_DUMMY) =
1510            NVL(
1511                  DECODE(p_adj_rec.payment_schedule_id,
1512                         AR_NUMBER_DUMMY, adj.payment_schedule_id,
1513                                          p_adj_rec.payment_schedule_id),
1514                  AR_NUMBER_DUMMY
1515               )
1516          AND
1517            NVL(adj.receivables_trx_id, AR_NUMBER_DUMMY) =
1518            NVL(
1519                  DECODE(p_adj_rec.receivables_trx_id,
1520                         AR_NUMBER_DUMMY, adj.receivables_trx_id,
1521                                          p_adj_rec.receivables_trx_id),
1522                  AR_NUMBER_DUMMY
1523               )
1524          AND
1525            NVL(adj.distribution_set_id, AR_NUMBER_DUMMY) =
1526            NVL(
1527                  DECODE(p_adj_rec.distribution_set_id,
1528                         AR_NUMBER_DUMMY, adj.distribution_set_id,
1529                                          p_adj_rec.distribution_set_id),
1530                  AR_NUMBER_DUMMY
1531               )
1532          AND
1533            NVL(adj.associated_application_id, AR_NUMBER_DUMMY) =
1534            NVL(
1535                  DECODE(p_adj_rec.associated_application_id,
1536                         AR_NUMBER_DUMMY, adj.associated_application_id,
1537                                          p_adj_rec.associated_application_id),
1538                  AR_NUMBER_DUMMY
1539               )
1540          AND
1541            NVL(adj.comments, AR_TEXT_DUMMY) =
1542            NVL(
1543                  DECODE(p_adj_rec.comments,
1544                         AR_TEXT_DUMMY, adj.comments,
1545                                          p_adj_rec.comments),
1546                  AR_TEXT_DUMMY
1547               )
1548          AND
1549            NVL(adj.automatically_generated, AR_FLAG_DUMMY) =
1550            NVL(
1551                  DECODE(p_adj_rec.automatically_generated,
1552                         AR_FLAG_DUMMY, adj.automatically_generated,
1553                                          p_adj_rec.automatically_generated),
1554                  AR_FLAG_DUMMY
1555               )
1556          AND
1557            NVL(adj.created_from, AR_TEXT_DUMMY) =
1558            NVL(
1559                  DECODE(p_adj_rec.created_from,
1560                         AR_TEXT_DUMMY, adj.created_from,
1561                                          p_adj_rec.created_from),
1562                  AR_TEXT_DUMMY
1563               )
1564          AND
1565            NVL(adj.reason_code, AR_TEXT_DUMMY) =
1566            NVL(
1567                  DECODE(p_adj_rec.reason_code,
1568                         AR_TEXT_DUMMY, adj.reason_code,
1569                                          p_adj_rec.reason_code),
1570                  AR_TEXT_DUMMY
1571               )
1572          AND
1573            NVL(adj.postable, AR_FLAG_DUMMY) =
1574            NVL(
1575                  DECODE(p_adj_rec.postable,
1576                         AR_FLAG_DUMMY, adj.postable,
1577                                          p_adj_rec.postable),
1578                  AR_FLAG_DUMMY
1579               )
1580          AND
1581            NVL(adj.approved_by, AR_NUMBER_DUMMY) =
1582            NVL(
1583                  DECODE(p_adj_rec.approved_by,
1584                         AR_NUMBER_DUMMY, adj.approved_by,
1585                                          p_adj_rec.approved_by),
1586                  AR_NUMBER_DUMMY
1587               )
1588          AND
1589            NVL(adj.adjustment_number, AR_TEXT_DUMMY) =
1590            NVL(
1591                  DECODE(p_adj_rec.adjustment_number,
1592                         AR_TEXT_DUMMY, adj.adjustment_number,
1593                                          p_adj_rec.adjustment_number),
1594                  AR_TEXT_DUMMY
1595               )
1596          AND
1597            NVL(adj.doc_sequence_value, AR_NUMBER_DUMMY) =
1598            NVL(
1599                  DECODE(p_adj_rec.doc_sequence_value,
1600                         AR_NUMBER_DUMMY, adj.doc_sequence_value,
1601                                          p_adj_rec.doc_sequence_value),
1602                  AR_NUMBER_DUMMY
1603               )
1604          AND
1605            NVL(adj.doc_sequence_id, AR_NUMBER_DUMMY) =
1606            NVL(
1607                  DECODE(p_adj_rec.doc_sequence_id,
1608                         AR_NUMBER_DUMMY, adj.doc_sequence_id,
1609                                          p_adj_rec.doc_sequence_id),
1610                  AR_NUMBER_DUMMY
1611               )
1612          AND
1613            NVL(adj.ussgl_transaction_code, AR_TEXT_DUMMY) =
1614            NVL(
1615                  DECODE(p_adj_rec.ussgl_transaction_code,
1616                         AR_TEXT_DUMMY, adj.ussgl_transaction_code,
1617                                          p_adj_rec.ussgl_transaction_code),
1618                  AR_TEXT_DUMMY
1619               )
1620          AND
1621            NVL(adj.ussgl_transaction_code_context, AR_TEXT_DUMMY) =
1622            NVL(
1623                  DECODE(p_adj_rec.ussgl_transaction_code_context,
1624                         AR_TEXT_DUMMY, adj.ussgl_transaction_code_context,
1625                                      p_adj_rec.ussgl_transaction_code_context),
1626                  AR_TEXT_DUMMY
1627               )
1628       )
1629    AND
1630       (
1631            NVL(adj.attribute_category, AR_TEXT_DUMMY) =
1632            NVL(
1633                  DECODE(p_adj_rec.attribute_category,
1634                         AR_TEXT_DUMMY, adj.attribute_category,
1635                                          p_adj_rec.attribute_category),
1636                  AR_TEXT_DUMMY
1637               )
1638          AND
1639            NVL(adj.attribute1, AR_TEXT_DUMMY) =
1640            NVL(
1641                  DECODE(p_adj_rec.attribute1,
1642                         AR_TEXT_DUMMY, adj.attribute1,
1643                                          p_adj_rec.attribute1),
1644                  AR_TEXT_DUMMY
1645               )
1646          AND
1647            NVL(adj.attribute2, AR_TEXT_DUMMY) =
1648            NVL(
1649                  DECODE(p_adj_rec.attribute2,
1650                         AR_TEXT_DUMMY, adj.attribute2,
1651                                          p_adj_rec.attribute2),
1652                  AR_TEXT_DUMMY
1653               )
1654          AND
1655            NVL(adj.attribute3, AR_TEXT_DUMMY) =
1656            NVL(
1657                  DECODE(p_adj_rec.attribute3,
1658                         AR_TEXT_DUMMY, adj.attribute3,
1659                                          p_adj_rec.attribute3),
1660                  AR_TEXT_DUMMY
1661               )
1662          AND
1663            NVL(adj.attribute4, AR_TEXT_DUMMY) =
1664            NVL(
1665                  DECODE(p_adj_rec.attribute4,
1666                         AR_TEXT_DUMMY, adj.attribute4,
1667                                          p_adj_rec.attribute4),
1668                  AR_TEXT_DUMMY
1669               )
1670          AND
1671            NVL(adj.attribute5, AR_TEXT_DUMMY) =
1672            NVL(
1673                  DECODE(p_adj_rec.attribute5,
1674                         AR_TEXT_DUMMY, adj.attribute5,
1675                                          p_adj_rec.attribute5),
1676                  AR_TEXT_DUMMY
1677               )
1678          AND
1679            NVL(adj.attribute6, AR_TEXT_DUMMY) =
1680            NVL(
1681                  DECODE(p_adj_rec.attribute6,
1682                         AR_TEXT_DUMMY, adj.attribute6,
1683                                          p_adj_rec.attribute6),
1684                  AR_TEXT_DUMMY
1685               )
1686          AND
1687            NVL(adj.attribute7, AR_TEXT_DUMMY) =
1688            NVL(
1689                  DECODE(p_adj_rec.attribute7,
1690                         AR_TEXT_DUMMY, adj.attribute7,
1691                                          p_adj_rec.attribute7),
1692                  AR_TEXT_DUMMY
1693               )
1694          AND
1695            NVL(adj.attribute8, AR_TEXT_DUMMY) =
1696            NVL(
1697                  DECODE(p_adj_rec.attribute8,
1698                         AR_TEXT_DUMMY, adj.attribute8,
1699                                          p_adj_rec.attribute8),
1700                  AR_TEXT_DUMMY
1701               )
1702          AND
1703            NVL(adj.attribute9, AR_TEXT_DUMMY) =
1704            NVL(
1705                  DECODE(p_adj_rec.attribute9,
1706                         AR_TEXT_DUMMY, adj.attribute9,
1707                                          p_adj_rec.attribute9),
1708                  AR_TEXT_DUMMY
1709               )
1710          AND
1711            NVL(adj.attribute10, AR_TEXT_DUMMY) =
1712            NVL(
1713                  DECODE(p_adj_rec.attribute10,
1714                         AR_TEXT_DUMMY, adj.attribute10,
1715                                          p_adj_rec.attribute10),
1716                  AR_TEXT_DUMMY
1717               )
1718          AND
1719            NVL(adj.attribute11, AR_TEXT_DUMMY) =
1720            NVL(
1721                  DECODE(p_adj_rec.attribute11,
1722                         AR_TEXT_DUMMY, adj.attribute11,
1723                                          p_adj_rec.attribute11),
1724                  AR_TEXT_DUMMY
1725               )
1726          AND
1727            NVL(adj.attribute12, AR_TEXT_DUMMY) =
1728            NVL(
1729                  DECODE(p_adj_rec.attribute12,
1730                         AR_TEXT_DUMMY, adj.attribute12,
1731                                          p_adj_rec.attribute12),
1732                  AR_TEXT_DUMMY
1733               )
1734          AND
1735            NVL(adj.attribute13, AR_TEXT_DUMMY) =
1736            NVL(
1737                  DECODE(p_adj_rec.attribute13,
1738                         AR_TEXT_DUMMY, adj.attribute13,
1739                                          p_adj_rec.attribute13),
1740                  AR_TEXT_DUMMY
1741               )
1742          AND
1743            NVL(adj.attribute14, AR_TEXT_DUMMY) =
1744            NVL(
1745                  DECODE(p_adj_rec.attribute14,
1746                         AR_TEXT_DUMMY, adj.attribute14,
1747                                          p_adj_rec.attribute14),
1748                  AR_TEXT_DUMMY
1749               )
1750          AND
1751            NVL(adj.attribute15, AR_TEXT_DUMMY) =
1752            NVL(
1753                  DECODE(p_adj_rec.attribute15,
1754                         AR_TEXT_DUMMY, adj.attribute15,
1755                                          p_adj_rec.attribute15),
1756                  AR_TEXT_DUMMY
1757               )
1758          AND
1759            NVL(adj.posting_control_id, AR_NUMBER_DUMMY) =
1760            NVL(
1761                  DECODE(p_adj_rec.posting_control_id,
1762                         AR_NUMBER_DUMMY, adj.posting_control_id,
1763                                          p_adj_rec.posting_control_id),
1764                  AR_NUMBER_DUMMY
1765               )
1766          AND
1767            NVL(adj.last_updated_by, AR_NUMBER_DUMMY) =
1768            NVL(
1769                  DECODE(p_adj_rec.last_updated_by,
1770                         AR_NUMBER_DUMMY, adj.last_updated_by,
1771                                          p_adj_rec.last_updated_by),
1772                  AR_NUMBER_DUMMY
1773               )
1774          AND
1775            NVL(TRUNC(adj.last_update_date), AR_DATE_DUMMY) =
1776            NVL(
1777                  DECODE(p_adj_rec.last_update_date,
1778                         AR_DATE_DUMMY, TRUNC(adj.last_update_date),
1779                                          p_adj_rec.last_update_date),
1780                  AR_DATE_DUMMY
1781               )
1782          AND
1783            NVL(adj.last_update_login, AR_NUMBER_DUMMY) =
1784            NVL(
1785                  DECODE(p_adj_rec.last_update_login,
1786                         AR_NUMBER_DUMMY, adj.last_update_login,
1787                                          p_adj_rec.last_update_login),
1788                  AR_NUMBER_DUMMY
1789               )
1790          AND
1791            NVL(adj.created_by, AR_NUMBER_DUMMY) =
1792            NVL(
1793                  DECODE(p_adj_rec.created_by,
1794                         AR_NUMBER_DUMMY, adj.created_by,
1795                                          p_adj_rec.created_by),
1796                  AR_NUMBER_DUMMY
1797               )
1798          AND
1799            NVL(TRUNC(adj.creation_date), AR_DATE_DUMMY) =
1800            NVL(
1801                  DECODE(p_adj_rec.creation_date,
1802                         AR_DATE_DUMMY, TRUNC(adj.creation_date),
1803                                          p_adj_rec.creation_date),
1804                  AR_DATE_DUMMY
1805               )
1806          AND
1807            NVL(adj.program_application_id, AR_NUMBER_DUMMY) =
1808            NVL(
1809                  DECODE(p_adj_rec.program_application_id,
1810                         AR_NUMBER_DUMMY, adj.program_application_id,
1811                                          p_adj_rec.program_application_id),
1812                  AR_NUMBER_DUMMY
1813               )
1814          AND
1815            NVL(adj.program_id, AR_NUMBER_DUMMY) =
1816            NVL(
1817                  DECODE(p_adj_rec.program_id,
1818                         AR_NUMBER_DUMMY, adj.program_id,
1819                                          p_adj_rec.program_id),
1820                  AR_NUMBER_DUMMY
1821               )
1822          AND
1823            NVL(TRUNC(adj.program_update_date), AR_DATE_DUMMY) =
1824            NVL(
1825                  DECODE(p_adj_rec.program_update_date,
1826                         AR_DATE_DUMMY, TRUNC(adj.program_update_date),
1827                                          p_adj_rec.program_update_date),
1828                  AR_DATE_DUMMY
1829               )
1830          AND
1831            NVL(adj.request_id, AR_NUMBER_DUMMY) =
1832            NVL(
1833                  DECODE(p_adj_rec.request_id,
1834                         AR_NUMBER_DUMMY, adj.request_id,
1835                                          p_adj_rec.request_id),
1836                  AR_NUMBER_DUMMY
1837               )
1838        )
1839     FOR UPDATE OF adjustment_id NOWAIT;
1840 
1841 
1842     arp_util.debug('arp_adjustments_pkg.lock_compare_p()-');
1843 
1844     EXCEPTION
1845         WHEN  NO_DATA_FOUND THEN
1846                 arp_util.debug(
1847              'EXCEPTION: arp_adjustments_pkg.l.lock_compare_p NO_DATA_FOUND' );
1848 
1849                 arp_util.debug('');
1850                 arp_util.debug('============= Old Record =============');
1851                 display_adj_p(p_adjustment_id);
1852                 arp_util.debug('');
1853                 arp_util.debug('============= New Record =============');
1854                 display_adj_rec(p_adj_rec);
1855 
1856                 FND_MESSAGE.Set_Name('FND', 'FORM_RECORD_CHANGED');
1857                 APP_EXCEPTION.Raise_Exception;
1858 
1859         WHEN  OTHERS THEN
1860             arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.lock_compare_p' );
1861             RAISE;
1862 END;
1863 
1864 /*===========================================================================+
1865  | PROCEDURE                                                                 |
1866  |    lock_compare_cover                                                     |
1867  |                                                                           |
1868  | DESCRIPTION                                                               |
1869  |    This procedure locks the ar_adjustments row identified                 |
1870  |    by the p_adjustment_id parameter only if no columns in                 |
1871  |    that row have changed from when they were first selected in the form.  |
1872  |                                                                           |
1873  | SCOPE - PUBLIC                                                            |
1874  |                                                                           |
1875  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
1876  |    arp_util.debug                                                         |
1877  |                                                                           |
1878  | ARGUMENTS  : IN:                                                          |
1879  |                  p_adjustment_id                                          |
1880  |                  p_amount                                                 |
1881  |                  p_acctd_amount                                           |
1882  |                  p_apply_date                                             |
1883  |                  p_gl_date                                                |
1884  |                  p_gl_posted_date                                         |
1885  |                  p_set_of_books_id                                        |
1886  |                  p_code_combination_id                                    |
1887  |                  p_type                                                   |
1888  |                  p_adjustment_type                                        |
1889  |                  p_status                                                 |
1890  |                  p_line_adjusted                                          |
1891  |                  p_freight_adjusted                                       |
1892  |                  p_tax_adjusted                                           |
1893  |                  p_receivables_charges_adj                                |
1894  |                  p_batch_id                                               |
1895  |                  p_customer_trx_id                                        |
1896  |                  p_subsequent_trx_id                                      |
1897  |                  p_customer_trx_line_id                                   |
1898  |                  p_associated_cash_receipt_id                             |
1899  |                  p_chargeback_customer_trx_id                             |
1900  |                  p_payment_schedule_id                                    |
1901  |                  p_receivables_trx_id                                     |
1902  |                  p_distribution_set_id                                    |
1903  |                  p_associated_application_id                              |
1904  |                  p_comments                                               |
1905  |                  p_automatically_generated                                |
1906  |                  p_created_from                                           |
1907  |                  p_reason_code                                            |
1908  |                  p_postable                                               |
1909  |                  p_approved_by                                            |
1910  |                  p_adjustment_number                                      |
1911  |                  p_doc_sequence_value                                     |
1912  |                  p_doc_sequence_id                                        |
1913  |                  p_ussgl_transaction_code                                 |
1914  |                  p_ussgl_trans_code_context                               |
1915  |                  p_attribute_category                                     |
1916  |                  p_attribute1                                             |
1917  |                  p_attribute2                                             |
1918  |                  p_attribute3                                             |
1919  |                  p_attribute4                                             |
1920  |                  p_attribute5                                             |
1921  |                  p_attribute6                                             |
1922  |                  p_attribute7                                             |
1923  |                  p_attribute8                                             |
1924  |                  p_attribute9                                             |
1925  |                  p_attribute10                                            |
1926  |                  p_attribute11                                            |
1927  |                  p_attribute12                                            |
1928  |                  p_attribute13                                            |
1929  |                  p_attribute14                                            |
1930  |                  p_attribute15                                            |
1931  |                  p_posting_control_id                                     |
1932  |                  p_last_updated_by                                        |
1933  |                  p_last_update_date                                       |
1934  |                  p_last_update_login                                      |
1935  |                  p_created_by                                             |
1936  |                  p_creation_date                                          |
1937  |                  p_program_application_id                                 |
1938  |                  p_program_id                                             |
1939  |                  p_program_update_date                                    |
1940  |                  p_request_id                                             |
1941  |              OUT:                                                         |
1942  |                  None                                                     |
1943  |                                                                           |
1944  | RETURNS    : NONE                                                         |
1945  |                                                                           |
1946  | NOTES                                                                     |
1947  |                                                                           |
1948  | MODIFICATION HISTORY                                                      |
1949  |     08-JUL-96  Charlie Tomberg     Created                                |
1950  |                                                                           |
1951  +===========================================================================*/
1952 
1953 PROCEDURE lock_compare_cover(
1954                               p_adjustment_id                   IN number,
1955                               p_amount                          IN number,
1956                               p_acctd_amount                    IN number,
1957                               p_apply_date                      IN date,
1958                               p_gl_date                         IN date,
1959                               p_gl_posted_date                  IN date,
1960                               p_set_of_books_id                 IN number,
1961                               p_code_combination_id             IN number,
1962                               p_type                            IN varchar2,
1963                               p_adjustment_type                 IN varchar2,
1964                               p_status                          IN varchar2,
1965                               p_line_adjusted                   IN number,
1966                               p_freight_adjusted                IN number,
1967                               p_tax_adjusted                    IN number,
1968                               p_receivables_charges_adj         IN number,
1969                               p_batch_id                        IN number,
1970                               p_customer_trx_id                 IN number,
1971                               p_subsequent_trx_id               IN number,
1972                               p_customer_trx_line_id            IN number,
1973                               p_associated_cash_receipt_id      IN number,
1974                               p_chargeback_customer_trx_id      IN number,
1975                               p_payment_schedule_id             IN number,
1976                               p_receivables_trx_id              IN number,
1977                               p_distribution_set_id             IN number,
1978                               p_associated_application_id       IN number,
1979                               p_comments                        IN varchar2,
1980                               p_automatically_generated         IN varchar2,
1981                               p_created_from                    IN varchar2,
1982                               p_reason_code                     IN varchar2,
1983                               p_postable                        IN varchar2,
1984                               p_approved_by                     IN number,
1985                               p_adjustment_number               IN varchar2,
1986                               p_doc_sequence_value              IN number,
1987                               p_doc_sequence_id                 IN number,
1988                               p_ussgl_transaction_code          IN varchar2,
1989                               p_ussgl_trans_code_context        IN varchar2,
1990                               p_attribute_category              IN varchar2,
1991                               p_attribute1                      IN varchar2,
1992                               p_attribute2                      IN varchar2,
1993                               p_attribute3                      IN varchar2,
1994                               p_attribute4                      IN varchar2,
1995                               p_attribute5                      IN varchar2,
1996                               p_attribute6                      IN varchar2,
1997                               p_attribute7                      IN varchar2,
1998                               p_attribute8                      IN varchar2,
1999                               p_attribute9                      IN varchar2,
2000                               p_attribute10                     IN varchar2,
2001                               p_attribute11                     IN varchar2,
2002                               p_attribute12                     IN varchar2,
2003                               p_attribute13                     IN varchar2,
2004                               p_attribute14                     IN varchar2,
2005                               p_attribute15                     IN varchar2,
2006                               p_posting_control_id              IN number,
2007                               p_last_updated_by                 IN number,
2008                               p_last_update_date                IN date,
2009                               p_last_update_login               IN number,
2010                               p_created_by                      IN number,
2011                               p_creation_date                   IN date,
2012                               p_program_application_id          IN number,
2013                               p_program_id                      IN number,
2014                               p_program_update_date             IN date,
2015                               p_request_id                      IN number )
2016           IS
2017 
2018     l_adj_rec  ar_adjustments%rowtype;
2019 
2020 BEGIN
2021     arp_util.debug('arp_adjustments_pkg.lock_compare_cover()+');
2022 
2023   /*----------------------------------------------------+
2024    |  Populate the adjustment record with the values    |
2025    |  passed in as parameters.                          |
2026    +----------------------------------------------------*/
2027 
2028    set_to_dummy(l_adj_rec);
2029 
2030 
2031     l_adj_rec.adjustment_id                     := p_adjustment_id;
2032     l_adj_rec.amount                            := p_amount;
2033     l_adj_rec.acctd_amount                      := p_acctd_amount;
2034     l_adj_rec.apply_date                        := p_apply_date;
2035     l_adj_rec.gl_date                           := p_gl_date;
2036     l_adj_rec.gl_posted_date                    := p_gl_posted_date;
2037     l_adj_rec.set_of_books_id                   := p_set_of_books_id;
2038     l_adj_rec.code_combination_id               := p_code_combination_id;
2039     l_adj_rec.type                              := p_type;
2040     l_adj_rec.adjustment_type                   := p_adjustment_type;
2041     l_adj_rec.status                            := p_status;
2042     l_adj_rec.line_adjusted                     := p_line_adjusted;
2043     l_adj_rec.freight_adjusted                  := p_freight_adjusted;
2044     l_adj_rec.tax_adjusted                      := p_tax_adjusted;
2045     l_adj_rec.receivables_charges_adjusted      := p_receivables_charges_adj ;
2046     l_adj_rec.batch_id                          := p_batch_id;
2047     l_adj_rec.customer_trx_id                   := p_customer_trx_id;
2048     l_adj_rec.subsequent_trx_id                 := p_subsequent_trx_id;
2049     l_adj_rec.customer_trx_line_id              := p_customer_trx_line_id;
2050     l_adj_rec.associated_cash_receipt_id   := p_associated_cash_receipt_id;
2051     l_adj_rec.chargeback_customer_trx_id   := p_chargeback_customer_trx_id;
2052     l_adj_rec.payment_schedule_id               := p_payment_schedule_id;
2053     l_adj_rec.receivables_trx_id                := p_receivables_trx_id;
2054     l_adj_rec.distribution_set_id               := p_distribution_set_id;
2055     l_adj_rec.associated_application_id         := p_associated_application_id;
2056     l_adj_rec.comments                          := p_comments;
2057     l_adj_rec.automatically_generated           := p_automatically_generated;
2058     l_adj_rec.created_from                      := p_created_from;
2059     l_adj_rec.reason_code                       := p_reason_code;
2060     l_adj_rec.postable                          := p_postable;
2061     l_adj_rec.approved_by                       := p_approved_by;
2062     l_adj_rec.adjustment_number                 := p_adjustment_number;
2063     l_adj_rec.doc_sequence_value                := p_doc_sequence_value;
2064     l_adj_rec.doc_sequence_id                   := p_doc_sequence_id;
2065     l_adj_rec.ussgl_transaction_code            := p_ussgl_transaction_code;
2066     l_adj_rec.ussgl_transaction_code_context    := p_ussgl_trans_code_context;
2067     l_adj_rec.attribute_category                := p_attribute_category;
2068     l_adj_rec.attribute1                        := p_attribute1;
2069     l_adj_rec.attribute2                        := p_attribute2;
2070     l_adj_rec.attribute3                        := p_attribute3;
2071     l_adj_rec.attribute4                        := p_attribute4;
2072     l_adj_rec.attribute5                        := p_attribute5;
2073     l_adj_rec.attribute6                        := p_attribute6;
2074     l_adj_rec.attribute7                        := p_attribute7;
2075     l_adj_rec.attribute8                        := p_attribute8;
2076     l_adj_rec.attribute9                        := p_attribute9;
2077     l_adj_rec.attribute10                       := p_attribute10;
2078     l_adj_rec.attribute11                       := p_attribute11;
2079     l_adj_rec.attribute12                       := p_attribute12;
2080     l_adj_rec.attribute13                       := p_attribute13;
2081     l_adj_rec.attribute14                       := p_attribute14;
2082     l_adj_rec.attribute15                       := p_attribute15;
2083     l_adj_rec.posting_control_id                := p_posting_control_id;
2084     l_adj_rec.last_updated_by                   := p_last_updated_by;
2085     l_adj_rec.last_update_date                  := p_last_update_date;
2086     l_adj_rec.last_update_login                 := p_last_update_login;
2087     l_adj_rec.created_by                        := p_created_by;
2088     l_adj_rec.creation_date                     := p_creation_date;
2089     l_adj_rec.program_application_id            := p_program_application_id;
2090     l_adj_rec.program_id                        := p_program_id;
2091     l_adj_rec.program_update_date               := p_program_update_date;
2092     l_adj_rec.request_id                        := p_request_id;
2093 
2094   /*-----------------------------------------+
2095    |  Call the standard header table handler |
2096    +-----------------------------------------*/
2097 
2098    lock_compare_p( l_adj_rec, p_adjustment_id);
2099 
2100    arp_util.debug('arp_adjustments_pkg.lock_compare_cover()-');
2101 
2102 EXCEPTION
2103   WHEN OTHERS THEN
2104     arp_util.debug('EXCEPTION : arp_adjustments_pkg.lock_compare_cover()');
2105 
2106     arp_util.debug('----- parameters for lock_compare_cover() ' ||
2107                    '-----');
2108     arp_util.debug('p_adjustment_id                     = ' ||
2109                    TO_CHAR(p_adjustment_id));
2110     arp_util.debug('p_amount                            = ' ||
2111                    TO_CHAR(p_amount));
2112     arp_util.debug('p_acctd_amount                      = ' ||
2113                    TO_CHAR(p_acctd_amount));
2114     arp_util.debug('p_apply_date                        = ' ||
2115                    TO_CHAR(p_apply_date, 'DD-MON-YYYY'));
2116     arp_util.debug('p_gl_date                           = ' ||
2117                    TO_CHAR(p_gl_date, 'DD-MON-YYYY'));
2118     arp_util.debug('p_gl_posted_date                    = ' ||
2119                    TO_CHAR(p_gl_posted_date, 'DD-MON-YYYY'));
2120     arp_util.debug('p_set_of_books_id                   = ' ||
2121                    TO_CHAR(p_set_of_books_id));
2122     arp_util.debug('p_code_combination_id               = ' ||
2123                    TO_CHAR(p_code_combination_id));
2124     arp_util.debug('p_type                              = ' ||
2125                    p_type);
2126     arp_util.debug('p_adjustment_type                   = ' ||
2127                    p_adjustment_type);
2128     arp_util.debug('p_status                            = ' ||
2129                    p_status);
2130     arp_util.debug('p_line_adjusted                     = ' ||
2131                    TO_CHAR(p_line_adjusted));
2132     arp_util.debug('p_freight_adjusted                  = ' ||
2133                    TO_CHAR(p_freight_adjusted));
2134     arp_util.debug('p_tax_adjusted                      = ' ||
2135                    TO_CHAR(p_tax_adjusted));
2136     arp_util.debug('p_receivables_charges_adj           = ' ||
2137                    TO_CHAR(p_receivables_charges_adj ));
2138     arp_util.debug('p_batch_id                          = ' ||
2139                    TO_CHAR(p_batch_id));
2140     arp_util.debug('p_customer_trx_id                   = ' ||
2141                    TO_CHAR(p_customer_trx_id));
2142     arp_util.debug('p_subsequent_trx_id                 = ' ||
2143                    TO_CHAR(p_subsequent_trx_id));
2144     arp_util.debug('p_customer_trx_line_id              = ' ||
2145                    TO_CHAR(p_customer_trx_line_id));
2146     arp_util.debug('p_associated_cash_receipt_id        = ' ||
2147                    TO_CHAR(p_associated_cash_receipt_id));
2148     arp_util.debug('p_chargeback_customer_trx_id        = ' ||
2149                    TO_CHAR(p_chargeback_customer_trx_id));
2150     arp_util.debug('p_payment_schedule_id               = ' ||
2151                    TO_CHAR(p_payment_schedule_id));
2152     arp_util.debug('p_receivables_trx_id                = ' ||
2153                    TO_CHAR(p_receivables_trx_id));
2154     arp_util.debug('p_distribution_set_id               = ' ||
2155                    TO_CHAR(p_distribution_set_id));
2156     arp_util.debug('p_associated_application_id         = ' ||
2157                    TO_CHAR(p_associated_application_id));
2158     arp_util.debug('p_comments                          = ' ||
2159                    p_comments);
2160     arp_util.debug('p_automatically_generated           = ' ||
2161                    p_automatically_generated);
2162     arp_util.debug('p_created_from                      = ' ||
2163                    p_created_from);
2164     arp_util.debug('p_reason_code                       = ' ||
2165                    p_reason_code);
2166     arp_util.debug('p_postable                          = ' ||
2167                    p_postable);
2168     arp_util.debug('p_approved_by                       = ' ||
2169                    TO_CHAR(p_approved_by));
2170     arp_util.debug('p_adjustment_number                 = ' ||
2171                    p_adjustment_number);
2172     arp_util.debug('p_doc_sequence_value                = ' ||
2173                    TO_CHAR(p_doc_sequence_value));
2174     arp_util.debug('p_doc_sequence_id                   = ' ||
2175                    TO_CHAR(p_doc_sequence_id));
2176     arp_util.debug('p_ussgl_transaction_code            = ' ||
2177                    p_ussgl_transaction_code);
2178     arp_util.debug('p_ussgl_trans_code_context          = ' ||
2179                    p_ussgl_trans_code_context);
2180     arp_util.debug('p_attribute_category                = ' ||
2181                    p_attribute_category);
2182     arp_util.debug('p_attribute1                        = ' ||
2183                    p_attribute1);
2184     arp_util.debug('p_attribute2                        = ' ||
2185                    p_attribute2);
2186     arp_util.debug('p_attribute3                        = ' ||
2187                    p_attribute3);
2188     arp_util.debug('p_attribute4                        = ' ||
2189                    p_attribute4);
2190     arp_util.debug('p_attribute5                        = ' ||
2191                    p_attribute5);
2192     arp_util.debug('p_attribute6                        = ' ||
2193                    p_attribute6);
2194     arp_util.debug('p_attribute7                        = ' ||
2195                    p_attribute7);
2196     arp_util.debug('p_attribute8                        = ' ||
2197                    p_attribute8);
2198     arp_util.debug('p_attribute9                        = ' ||
2199                    p_attribute9);
2200     arp_util.debug('p_attribute10                       = ' ||
2201                    p_attribute10);
2202     arp_util.debug('p_attribute11                       = ' ||
2203                    p_attribute11);
2204     arp_util.debug('p_attribute12                       = ' ||
2205                    p_attribute12);
2206     arp_util.debug('p_attribute13                       = ' ||
2207                    p_attribute13);
2208     arp_util.debug('p_attribute14                       = ' ||
2209                    p_attribute14);
2210     arp_util.debug('p_attribute15                       = ' ||
2211                    p_attribute15);
2212     arp_util.debug('p_posting_control_id                = ' ||
2213                    TO_CHAR(p_posting_control_id));
2214     arp_util.debug('p_last_updated_by                   = ' ||
2215                    TO_CHAR(p_last_updated_by));
2216     arp_util.debug('p_last_update_date                  = ' ||
2217                    TO_CHAR(p_last_update_date, 'DD-MON-YYYY'));
2218     arp_util.debug('p_last_update_login                 = ' ||
2219                    TO_CHAR(p_last_update_login));
2220     arp_util.debug('p_created_by                        = ' ||
2221                    TO_CHAR(p_created_by));
2222     arp_util.debug('p_creation_date                     = ' ||
2223                    TO_CHAR(p_creation_date, 'DD-MON-YYYY'));
2224     arp_util.debug('p_program_application_id            = ' ||
2225                    TO_CHAR(p_program_application_id));
2226     arp_util.debug('p_program_id                        = ' ||
2227                    TO_CHAR(p_program_id));
2228     arp_util.debug('p_program_update_date               = ' ||
2229                    TO_CHAR(p_program_update_date, 'DD-MON-YYYY'));
2230     arp_util.debug('p_request_id                        = ' ||
2231                    TO_CHAR(p_request_id));
2232 
2233     RAISE;
2234 
2235 END;
2236 
2237 /*===========================================================================+
2238  | PROCEDURE                                                                 |
2239  |    fetch_p								     |
2240  |                                                                           |
2241  | DESCRIPTION                                                               |
2242  |    This procedure fetches a single row from ar_adjustments  		     |
2243  |    into a variable specified as a parameter based on the table's primary  |
2244  |    key, adjustment_id					 	     |
2245  |                                                                           |
2246  | SCOPE - PUBLIC                                                            |
2247  |                                                                           |
2248  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2249  |    arp_util.debug                                                         |
2250  |                                                                           |
2251  | ARGUMENTS  : IN:                                                          |
2252  |              p_adjustment_id - identifies the record to fetch 	     |
2253  |              OUT:                                                         |
2254  |                    p_adj_rec  - contains the fetched record	     	     |
2255  |                                                                           |
2256  | RETURNS    : NONE                                                         |
2257  |                                                                           |
2258  | NOTES                                                                     |
2259  |                                                                           |
2260  | MODIFICATION HISTORY                                                      |
2261  |     29-JUN-95  Charlie Tomberg     Created                                |
2262  |                                                                           |
2263  +===========================================================================*/
2264 
2265 PROCEDURE fetch_p( p_adj_rec         OUT NOCOPY ar_adjustments%rowtype,
2266                    p_adjustment_id    IN ar_adjustments.adjustment_id%type)
2267           IS
2268 
2269 BEGIN
2270     arp_util.debug('arp_adjustments_pkg.fetch_p()+');
2271 
2272     SELECT *
2273     INTO   p_adj_rec
2274     FROM   ar_adjustments
2275     WHERE  adjustment_id = p_adjustment_id;
2276 
2277     arp_util.debug('arp_adjustments_pkg.fetch_p()-');
2278 
2279     EXCEPTION
2280         WHEN  OTHERS THEN
2281             arp_util.debug( 'EXCEPTION: arp_adjustments_pkg.fetch_p' );
2282             RAISE;
2283 END;
2284 
2285 /*===========================================================================+
2286  | PROCEDURE                                                                 |
2287  |    delete_p								     |
2288  |                                                                           |
2289  | DESCRIPTION                                                               |
2290  |    This procedure deletes the ar_adjustments row identified 		     |
2291  |    by the p_adjustment_id parameter.					     |
2292  |                                                                           |
2293  | SCOPE - PUBLIC                                                            |
2294  |                                                                           |
2295  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2296  |    arp_util.debug                                                         |
2297  |                                                                           |
2298  | ARGUMENTS  : IN:                                                          |
2299  |              p_adjustment_id  - identifies the rows to delete	     |
2300  |              OUT:                                                         |
2301  |              None						             |
2302  |                                                                           |
2303  | RETURNS    : NONE                                                         |
2304  |                                                                           |
2305  | NOTES                                                                     |
2306  |                                                                           |
2307  | MODIFICATION HISTORY                                                      |
2308  |     29-JUN-95  Charlie Tomberg     Created                                |
2309  |     16-OCT-00  Debbie Jancis       Added call to the central MRC library  |
2310  |                                    for MRC integration                    |
2311  |                                                                           |
2312  +===========================================================================*/
2313 
2314 procedure delete_p( p_adjustment_id IN ar_adjustments.adjustment_id%type)
2315        IS
2316 
2317 
2318 BEGIN
2319 
2320 
2321    arp_util.debug('arp_adjustments_pkg.delete_p()+');
2322 
2323    DELETE FROM ar_adjustments
2324    WHERE       adjustment_id = p_adjustment_id;
2325 
2326    /*---------------------------------+
2327     | Calling central MRC library     |
2328     | for MRC Integration             |
2329     +---------------------------------*/
2330 /*BUG4301323
2331     ar_mrc_engine.maintain_mrc_data(
2332                         p_event_mode       => 'DELETE',
2333                         p_table_name       => 'AR_ADJUSTMENTS',
2334                         p_mode             => 'SINGLE',
2335                         p_key_value        => p_adjustment_id);
2336 */
2337    arp_util.debug('arp_adjustments_pkg.delete_p()-');
2338 
2339 EXCEPTION
2340     WHEN OTHERS THEN
2341         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.delete_p()');
2342 
2343 	RAISE;
2344 
2345 END;
2346 
2347 /*===========================================================================+
2348  | PROCEDURE                                                                 |
2349  |    delete_f_ct_id							     |
2350  |                                                                           |
2351  | DESCRIPTION                                                               |
2352  |    This procedure deletes the ar_adjustments rows identified		     |
2353  |    by the p_customer_trx_id parameter.				     |
2354  |                                                                           |
2355  | SCOPE - PUBLIC                                                            |
2356  |                                                                           |
2357  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2358  |    arp_util.debug                                                         |
2359  |                                                                           |
2360  | ARGUMENTS  : IN:                                                          |
2361  |           	      p_customer_trx_id  - identifies the rows to delete     |
2362  |              OUT:                                                         |
2363  |                    None					             |
2364  |                                                                           |
2365  | RETURNS    : NONE                                                         |
2366  |                                                                           |
2367  | NOTES                                                                     |
2368  |                                                                           |
2369  | MODIFICATION HISTORY                                                      |
2370  |     29-JUN-95  Charlie Tomberg     Created                                |
2371  |     16-OCT-00  Debbie Jancis       Added call to the central MRC library  |
2372  |                                    for MRC integration                    |
2373  |                                                                           |
2374  +===========================================================================*/
2375 
2376 procedure delete_f_ct_id( p_customer_trx_id
2377                             IN ra_customer_trx.customer_trx_id%type)
2378        IS
2379 
2380  l_adj_key_value_list  gl_ca_utility_pkg.r_key_value_arr;
2381 
2382 BEGIN
2383 
2384 
2385    arp_util.debug('arp_adjustments_pkg.delete_f_ct_id()+');
2386 
2387    DELETE FROM ar_adjustments
2388    WHERE       customer_trx_id = p_customer_trx_id
2389    RETURNING adjustment_id
2390    BULK COLLECT INTO l_adj_key_value_list;
2391 
2392    /*---------------------------------+
2393     | Calling central MRC library     |
2394     | for MRC Integration             |
2395     +---------------------------------*/
2396 /*4301323
2397     ar_mrc_engine.maintain_mrc_data(
2398                         p_event_mode       => 'DELETE',
2399                         p_table_name       => 'AR_ADJUSTMENTS',
2400                         p_mode             => 'BATCH',
2401                         p_key_value_list   => l_adj_key_value_list);
2402 */
2403 
2404    arp_util.debug('arp_adjustments_pkg.delete_f_ct_id()-');
2405 
2406 EXCEPTION
2407     WHEN OTHERS THEN
2408         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.delete_f_ct_id()');
2409 
2410 	RAISE;
2411 
2412 END;
2413 
2414 /*===========================================================================+
2415  | PROCEDURE                                                                 |
2416  |    delete_f_st_id							     |
2417  |                                                                           |
2418  | DESCRIPTION                                                               |
2419  |    This procedure deletes the ar_adjustments rows identified		     |
2420  |    by the p_subsequent_trx_id parameter.				     |
2421  |                                                                           |
2422  | SCOPE - PUBLIC                                                            |
2423  |                                                                           |
2424  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2425  |    arp_util.debug                                                         |
2426  |                                                                           |
2427  | ARGUMENTS  : IN:                                                          |
2428  |           	      p_subsequent_trx_id  - identifies the rows to delete   |
2429  |              OUT:                                                         |
2430  |                    None					             |
2431  |                                                                           |
2432  | RETURNS    : NONE                                                         |
2433  |                                                                           |
2434  | NOTES                                                                     |
2435  |                                                                           |
2436  | MODIFICATION HISTORY                                                      |
2437  |     29-JUN-95  Charlie Tomberg     Created                                |
2438  |     16-OCT-00  Debbie Jancis       Added call to the central MRC library  |
2439  |                                    for MRC integration                    |
2440  |                                                                           |
2441  +===========================================================================*/
2442 
2443 procedure delete_f_st_id( p_subsequent_trx_id
2444                             IN ra_customer_trx.customer_trx_id%type)
2445        IS
2446 
2447  l_adj_key_value_list  gl_ca_utility_pkg.r_key_value_arr;
2448 
2449 BEGIN
2450 
2451 
2452    arp_util.debug('arp_adjustments_pkg.delete_f_st_id()+');
2453 
2454    DELETE FROM ar_adjustments
2455    WHERE       subsequent_trx_id = p_subsequent_trx_id
2456    RETURNING adjustment_id
2457    BULK COLLECT INTO l_adj_key_value_list;
2458 
2459    /*---------------------------------+
2460     | Calling central MRC library     |
2461     | for MRC Integration             |
2462     +---------------------------------*/
2463 /*4301323
2464     ar_mrc_engine.maintain_mrc_data(
2465                         p_event_mode       => 'DELETE',
2466                         p_table_name       => 'AR_ADJUSTMENTS',
2467                         p_mode             => 'BATCH',
2468                         p_key_value_list   => l_adj_key_value_list);
2469 */
2470 
2471    arp_util.debug('arp_adjustments_pkg.delete_f_st_id()-');
2472 
2473 EXCEPTION
2474     WHEN OTHERS THEN
2475         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.delete_f_st_id()');
2476 
2477 	RAISE;
2478 
2479 END;
2480 
2481 
2482 /*===========================================================================+
2483  | PROCEDURE                                                                 |
2484  |    delete_f_ps_id							     |
2485  |                                                                           |
2486  | DESCRIPTION                                                               |
2487  |    This procedure deletes the ar_adjustments rows identified		     |
2488  |    by the p_payment_schedule_id parameter.				     |
2489  |                                                                           |
2490  | SCOPE - PUBLIC                                                            |
2491  |                                                                           |
2492  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2493  |    arp_util.debug                                                         |
2494  |                                                                           |
2495  | ARGUMENTS  : IN:                                                          |
2496  |           	      p_payment_schedule_id  - identifies the rows to delete |
2497  |              OUT:                                                         |
2498  |                    None					             |
2499  |                                                                           |
2500  | RETURNS    : NONE                                                         |
2501  |                                                                           |
2502  | NOTES                                                                     |
2503  |                                                                           |
2504  | MODIFICATION HISTORY                                                      |
2505  |     29-JUN-95  Charlie Tomberg     Created                                |
2506  |     16-OCT-00  Debbie Jancis       Added call to the central MRC library  |
2507  |                                    for MRC integration                    |
2508  |                                                                           |
2509  +===========================================================================*/
2510 
2511 procedure delete_f_ps_id( p_payment_schedule_id
2512                             IN ar_payment_schedules.payment_schedule_id%type)
2513        IS
2514 
2515  l_adj_key_value_list  gl_ca_utility_pkg.r_key_value_arr;
2516 
2517 BEGIN
2518 
2519 
2520    arp_util.debug('arp_adjustments_pkg.delete_f_ps_id()+');
2521 
2522    DELETE FROM ar_adjustments
2523    WHERE       payment_schedule_id = p_payment_schedule_id
2524    RETURNING adjustment_id
2525    BULK COLLECT INTO l_adj_key_value_list;
2526 
2527    /*---------------------------------+
2528     | Calling central MRC library     |
2529     | for MRC Integration             |
2530     +---------------------------------*/
2531 /*4301323
2532     ar_mrc_engine.maintain_mrc_data(
2533                         p_event_mode       => 'DELETE',
2534                         p_table_name       => 'AR_ADJUSTMENTS',
2535                         p_mode             => 'BATCH',
2536                         p_key_value_list   => l_adj_key_value_list);
2537 */
2538 
2539    arp_util.debug('arp_adjustments_pkg.delete_f_ps_id()-');
2540 
2541 EXCEPTION
2542     WHEN OTHERS THEN
2543         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.delete_f_ps_id()');
2544 
2545 	RAISE;
2546 
2547 END;
2548 
2549 /*===========================================================================+
2550  | PROCEDURE                                                                 |
2551  |    delete_f_ctl_id							     |
2552  |                                                                           |
2553  | DESCRIPTION                                                               |
2554  |    This procedure deletes the ar_adjustments rows identified 	     |
2555  |    by the p_customer_trx_line_id parameter.				     |
2556  |                                                                           |
2557  | SCOPE - PUBLIC                                                            |
2558  |                                                                           |
2559  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2560  |    arp_util.debug                                                         |
2561  |                                                                           |
2562  | ARGUMENTS  : IN:                                                          |
2563  |        	    p_customer_trx_line_id  - identifies the rows to delete  |
2564  |              OUT:                                                         |
2565  |                  None					             |
2566  |                                                                           |
2567  | RETURNS    : NONE                                                         |
2568  |                                                                           |
2569  | NOTES                                                                     |
2570  |                                                                           |
2571  | MODIFICATION HISTORY                                                      |
2572  |     29-JUN-95  Charlie Tomberg     Created                                |
2573  |     16-OCT-00  Debbie Jancis       Added call to the central MRC library  |
2574  |                                    for MRC integration                    |
2575  |                                                                           |
2576  +===========================================================================*/
2577 
2578 procedure delete_f_ctl_id( p_customer_trx_line_id
2579                          IN ra_customer_trx_lines.customer_trx_line_id%type)
2580        IS
2581 
2582  l_adj_key_value_list  gl_ca_utility_pkg.r_key_value_arr;
2583 
2584 BEGIN
2585 
2586 
2587    arp_util.debug('arp_adjustments_pkg.delete_f_ctl_id()+');
2588 
2589    DELETE FROM ar_adjustments
2590    WHERE       customer_trx_line_id = p_customer_trx_line_id
2591    RETURNING adjustment_id
2592    BULK COLLECT INTO l_adj_key_value_list;
2593 
2594    /*---------------------------------+
2595     | Calling central MRC library     |
2596     | for MRC Integration             |
2597     +---------------------------------*/
2598 /*BUG4301323
2599     ar_mrc_engine.maintain_mrc_data(
2600                         p_event_mode       => 'DELETE',
2601                         p_table_name       => 'AR_ADJUSTMENTS',
2602                         p_mode             => 'BATCH',
2603                         p_key_value_list   => l_adj_key_value_list);
2604 */
2605    arp_util.debug('arp_adjustments_pkg.delete_f_ctl_id()-');
2606 
2607 EXCEPTION
2608     WHEN OTHERS THEN
2609         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.delete_f_ctl_id()');
2610 
2611 	RAISE;
2612 
2613 END;
2614 
2615 /*===========================================================================+
2616  | PROCEDURE                                                                 |
2617  |    update_p								     |
2618  |                                                                           |
2619  | DESCRIPTION                                                               |
2620  |    This procedure updates the ar_adjustments row identified		     |
2621  |    by the p_adjustment_id parameter.					     |
2622  |                                                                           |
2623  | SCOPE - PUBLIC                                                            |
2624  |                                                                           |
2625  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2626  |    arp_util.debug                                                         |
2627  |                                                                           |
2628  | ARGUMENTS  : IN:                                                          |
2629  |               p_adjustment_id - identifies the row to update		     |
2630  |               p_exchange_rate                                             |
2631  |               p_adj_rec                 - contains the new column values  |
2632  |              OUT:                                                         |
2633  |                    None						     |
2634  |                                                                           |
2635  | RETURNS    : NONE                                                         |
2636  |                                                                           |
2637  | NOTES                                                                     |
2638  |     set_to_dummy must be called before the values in p_adj_rec are        |
2639  |     changed and this function is called.				     |
2640  |                                                                           |
2641  | MODIFICATION HISTORY                                                      |
2642  |     29-JUN-95  Charlie Tomberg     Created                                |
2643  |                                                                           |
2644  +===========================================================================*/
2645 
2646 PROCEDURE update_p( p_adj_rec IN ar_adjustments%rowtype,
2647                     p_adjustment_id  IN  ar_adjustments.adjustment_id%type,
2648                     p_exchange_rate  IN ar_payment_schedules.exchange_rate%type
2649                   )
2650           IS
2651 
2652 
2653 BEGIN
2654 
2655    arp_util.debug('arp_adjustments_pkg.update_p()+  ' ||
2656                       to_char(sysdate, 'HH:MI:SS'));
2657 
2658    arp_adjustments_pkg.generic_update(  pg_cursor1,
2659 			       ' WHERE adjustment_id = :where_1',
2660                                p_adjustment_id,
2661                                p_exchange_rate,
2662                                p_adj_rec);
2663 
2664    arp_util.debug('arp_adjustments_pkg.update_p()-  ' ||
2665                       to_char(sysdate, 'HH:MI:SS'));
2666 
2667 
2668 EXCEPTION
2669     WHEN OTHERS THEN
2670         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.update_p()');
2671         RAISE;
2672 END;
2673 
2674 
2675 /*===========================================================================+
2676  | PROCEDURE                                                                 |
2677  |    update_f_ct_id							     |
2678  |                                                                           |
2679  | DESCRIPTION                                                               |
2680  |    This procedure updates the ar_adjustments rows identified		     |
2681  |    by the p_customer_trx_id parameter.				     |
2682  |                                                                           |
2683  | SCOPE - PUBLIC                                                            |
2684  |                                                                           |
2685  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2686  |    arp_util.debug                                                         |
2687  |                                                                           |
2688  | ARGUMENTS  : IN:                                                          |
2689  |               p_customer_trx_id	    - identifies the rows to update  |
2690  |               p_exchange_rate                                             |
2691  |               p_adj_rec                 - contains the new column values  |
2692  |              OUT:                                                         |
2693  |                    None						     |
2694  |                                                                           |
2695  | RETURNS    : NONE                                                         |
2696  |                                                                           |
2697  | NOTES                                                                     |
2698  |     set_to_dummy must be called before the values in p_adj_rec are        |
2699  |     changed and this function is called.				     |
2700  |                                                                           |
2701  | MODIFICATION HISTORY                                                      |
2702  |     29-JUN-95  Charlie Tomberg     Created                                |
2703  |                                                                           |
2704  +===========================================================================*/
2705 
2706 PROCEDURE update_f_ct_id( p_adj_rec IN ar_adjustments%rowtype,
2707                  p_customer_trx_id  IN ra_customer_trx.customer_trx_id%type,
2708                  p_exchange_rate  IN ar_payment_schedules.exchange_rate%type)
2709           IS
2710 
2711 
2712 BEGIN
2713 
2714    arp_util.debug('arp_adjustments_pkg.update_f_ct_id()+  ' ||
2715                       to_char(sysdate, 'HH:MI:SS'));
2716 
2717    arp_adjustments_pkg.generic_update(  pg_cursor2,
2718 			       ' WHERE customer_trx_id = :where_1',
2719                                p_customer_trx_id,
2720                                p_exchange_rate,
2721                                p_adj_rec);
2722 
2723    arp_util.debug('arp_adjustments_pkg.update_f_ct_id()-  ' ||
2724                       to_char(sysdate, 'HH:MI:SS'));
2725 
2726 
2727 EXCEPTION
2728     WHEN OTHERS THEN
2729         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.update_f_ct_id()');
2730         RAISE;
2731 END;
2732 
2733 /*===========================================================================+
2734  | PROCEDURE                                                                 |
2735  |    update_f_st_id							     |
2736  |                                                                           |
2737  | DESCRIPTION                                                               |
2738  |    This procedure updates the ar_adjustments rows identified		     |
2739  |    by the p_subsequent_trx_id parameter.				     |
2740  |                                                                           |
2741  | SCOPE - PUBLIC                                                            |
2742  |                                                                           |
2743  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2744  |    arp_util.debug                                                         |
2745  |                                                                           |
2746  | ARGUMENTS  : IN:                                                          |
2747  |               p_subsequent_trx_id	    - identifies the rows to update  |
2748  |               p_exchange_rate                                             |
2749  |               p_adj_rec                 - contains the new column values  |
2750  |              OUT:                                                         |
2751  |                    None						     |
2752  |                                                                           |
2753  | RETURNS    : NONE                                                         |
2754  |                                                                           |
2755  | NOTES                                                                     |
2756  |     set_to_dummy must be called before the values in p_adj_rec are        |
2757  |     changed and this function is called.				     |
2758  |                                                                           |
2759  | MODIFICATION HISTORY                                                      |
2760  |     29-JUN-95  Charlie Tomberg     Created                                |
2761  |                                                                           |
2762  +===========================================================================*/
2763 
2764 PROCEDURE update_f_st_id( p_adj_rec IN ar_adjustments%rowtype,
2765                  p_subsequent_trx_id  IN ra_customer_trx.customer_trx_id%type,
2766                  p_exchange_rate  IN ar_payment_schedules.exchange_rate%type)
2767           IS
2768 
2769 BEGIN
2770 
2771    arp_util.debug('arp_adjustments_pkg.update_f_st_id()+  ' ||
2772                       to_char(sysdate, 'HH:MI:SS'));
2773 
2774    arp_adjustments_pkg.generic_update(  pg_cursor3,
2775 			       ' WHERE subsequent_trx_id = :where_1',
2776                                p_subsequent_trx_id,
2777                                p_exchange_rate,
2778                                p_adj_rec);
2779 
2780 
2781    arp_util.debug('arp_adjustments_pkg.update_f_st_id()-  ' ||
2782                       to_char(sysdate, 'HH:MI:SS'));
2783 
2784 
2785 EXCEPTION
2786     WHEN OTHERS THEN
2787         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.update_f_st_id()');
2788         RAISE;
2789 END;
2790 
2791 /*===========================================================================+
2792  | PROCEDURE                                                                 |
2793  |    update_f_ps_id							     |
2794  |                                                                           |
2795  | DESCRIPTION                                                               |
2796  |    This procedure updates the ar_adjustments rows identified		     |
2797  |    by the p_payment_schedule_id parameter.				     |
2798  |                                                                           |
2799  | SCOPE - PUBLIC                                                            |
2800  |                                                                           |
2801  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2802  |    arp_util.debug                                                         |
2803  |                                                                           |
2804  | ARGUMENTS  : IN:                                                          |
2805  |               p_payment_schedule_id	    - identifies the rows to update  |
2806  |               p_exchange_rate                                             |
2807  |               p_adj_rec                 - contains the new column values  |
2808  |              OUT:                                                         |
2809  |                    None						     |
2810  |                                                                           |
2811  | RETURNS    : NONE                                                         |
2812  |                                                                           |
2813  | NOTES                                                                     |
2814  |     set_to_dummy must be called before the values in p_adj_rec are        |
2815  |     changed and this function is called.				     |
2816  |                                                                           |
2817  | MODIFICATION HISTORY                                                      |
2818  |     29-JUN-95  Charlie Tomberg     Created                                |
2819  |                                                                           |
2820  +===========================================================================*/
2821 
2822 PROCEDURE update_f_ps_id( p_adj_rec              IN ar_adjustments%rowtype,
2823                           p_payment_schedule_id  IN
2824                               ar_payment_schedules.payment_schedule_id%type,
2825                           p_exchange_rate        IN
2826                               ar_payment_schedules.exchange_rate%type)
2827           IS
2828 
2829 
2830 BEGIN
2831 
2832    arp_util.debug('arp_adjustments_pkg.update_f_ps_id()+  ' ||
2833                       to_char(sysdate, 'HH:MI:SS'));
2834 
2835    arp_adjustments_pkg.generic_update(  pg_cursor4,
2836 			       ' WHERE payment_schedule_id = :where_1',
2837                                p_payment_schedule_id,
2838                                p_exchange_rate,
2839                                p_adj_rec);
2840 
2841    arp_util.debug('arp_adjustments_pkg.update_f_ps_id()-  ' ||
2842                       to_char(sysdate, 'HH:MI:SS'));
2843 
2844 
2845 EXCEPTION
2846     WHEN OTHERS THEN
2847         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.update_f_ps_id()');
2848         RAISE;
2849 END;
2850 
2851 
2852 /*===========================================================================+
2853  | PROCEDURE                                                                 |
2854  |    update_f_ctl_id							     |
2855  |                                                                           |
2856  | DESCRIPTION                                                               |
2857  |    This procedure updates the ar_adjustments rows identified 	     |
2858  |    by the p_customer_trx_line_id parameter.				     |
2859  |                                                                           |
2860  | SCOPE - PUBLIC                                                            |
2861  |                                                                           |
2862  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2863  |    arp_util.debug                                                         |
2864  |                                                                           |
2865  | ARGUMENTS  : IN:                                                          |
2866  |               p_customer_trx_line_id	    - identifies the rows to update  |
2867  |               p_exchange_rate                                             |
2868  |               p_adj_rec                 - contains the new column values  |
2869  |              OUT:                                                         |
2870  |                    None						     |
2871  |                                                                           |
2872  | RETURNS    : NONE                                                         |
2873  |                                                                           |
2874  | NOTES                                                                     |
2875  |     set_to_dummy must be called before the values in p_adj_rec are        |
2876  |     changed and this function is called.				     |
2877  |                                                                           |
2878  | MODIFICATION HISTORY                                                      |
2879  |     29-JUN-95  Charlie Tomberg     Created                                |
2880  |                                                                           |
2881  +===========================================================================*/
2882 
2883 PROCEDURE update_f_ctl_id( p_adj_rec IN ar_adjustments%rowtype,
2884                            p_customer_trx_line_id  IN
2885                                ra_customer_trx_lines.customer_trx_line_id%type,
2886                            p_exchange_rate         IN
2887                                ar_payment_schedules.exchange_rate%type)
2888           IS
2889 
2890 
2891 BEGIN
2892 
2893    arp_util.debug('arp_adjustments_pkg.update_f_ctl_id()+  ' ||
2894                       to_char(sysdate, 'HH:MI:SS'));
2895 
2896    arp_adjustments_pkg.generic_update(  pg_cursor5,
2897 			       ' WHERE customer_trx_line_id = :where_1',
2898                                p_customer_trx_line_id,
2899                                p_exchange_rate,
2900                                p_adj_rec);
2901 
2902    arp_util.debug('arp_adjustments_pkg.update_f_ctl_id()-  ' ||
2903                       to_char(sysdate, 'HH:MI:SS'));
2904 
2905 
2906 EXCEPTION
2907     WHEN OTHERS THEN
2908         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.update_f_ctl_id()');
2909         RAISE;
2910 END;
2911 
2912 
2913 /*===========================================================================+
2914  | PROCEDURE                                                                 |
2915  |    insert_p								     |
2916  |                                                                           |
2917  | DESCRIPTION                                                               |
2918  |    This procedure inserts a row into ar_adjustments that   		     |
2919  |    contains the column values specified in the p_adj_rec parameter.       |
2920  |                                                                           |
2921  | SCOPE - PUBLIC                                                            |
2922  |                                                                           |
2923  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
2924  |    arp_util.debug                                                         |
2925  |                                                                           |
2926  | ARGUMENTS  : IN:                                                          |
2927  |                    p_adj_rec            - contains the new column values  |
2928  |              OUT:                                                         |
2929  |                    p_adjustment_id - unique ID of the new row  	     |
2930  |                    p_adjustment_number                                    |
2931  |                                                                           |
2932  | RETURNS    : NONE                                                         |
2933  |                                                                           |
2934  | NOTES                                                                     |
2935  |                                                                           |
2936  | MODIFICATION HISTORY                                                      |
2937  |     29-JUN-95  Charlie Tomberg     Created                                |
2938  |     24-AUG-95  Martin Johnson      Added parameter p_adjustment_number.   |
2939  |                                    Get adjustment_number from the sequence|
2940  |                                    Calculate acctd_amount if it's not     |
2941  |                                      passed in.                           |
2942  |     06-SEP-95  Martin Johnson      Replaced arp_standard.functional_amount|
2943  |                                      with arpcurr.functional_amount       |
2944  |                                                                           |
2945  |     03-FEB-00  Saloni Shah         Changes made for BR/BOE project.       |
2946  |                                    Need to get the value of accounting    |
2947  |                                    affect flag for the receivables trx    |
2948  |                                    to set the postable flag.              |
2949  |                                    The postable flag for an adjustment    |
2950  |                                    is set to 'N' if the                   |
2951  |                                    accounting_affect_flag of the          |
2952  |                                    receivables_trx is 'N'.                |
2953  |     15-OCT-00  Debbie Jancis       Enh:  MRC integration.   Called central|
2954  |                                    library for insertion of ar_adjustments|
2955  +===========================================================================*/
2956 
2957 PROCEDURE insert_p( p_adj_rec            IN  ar_adjustments%rowtype,
2958                     p_exchange_rate      IN
2959                       ar_payment_schedules.exchange_rate%type,
2960                     p_adjustment_number OUT NOCOPY
2961                       ar_adjustments.adjustment_number%type,
2962                     p_adjustment_id     OUT NOCOPY  ar_adjustments.adjustment_id%type
2963 
2964                   ) IS
2965 
2966     l_adjustment_id     ar_adjustments.adjustment_id%type;
2967     l_adjustment_number ar_adjustments.adjustment_number%type;
2968     l_accounting_affect_flag ar_receivables_trx.accounting_affect_flag%type;
2969     l_adj_post_to_gl_flag    ra_cust_trx_types.adj_post_to_gl%type;
2970 
2971 BEGIN
2972 
2973     arp_util.debug('arp_adjustments_pkg.insert_p()+');
2974 
2975     p_adjustment_id := NULL;
2976     p_adjustment_number := NULL;
2977 
2978     /*---------------------------*
2979      | Get the unique identifier |
2980      *---------------------------*/
2981 
2982         SELECT AR_ADJUSTMENTS_S.NEXTVAL,
2983                AR_ADJUSTMENT_NUMBER_S.NEXTVAL
2984         INTO   l_adjustment_id,
2985                l_adjustment_number
2986         FROM   DUAL;
2987 
2988        /*--------------------------------------------+
2989         |  Change made for BR/BOE project.           |
2990         |  Get the value for accounting_affect_flag  |
2991         +--------------------------------------------*/
2992 
2993           SELECT NVL(accounting_affect_flag , 'Y')
2994           INTO  l_accounting_affect_flag
2995           FROM  ar_receivables_trx
2996           WHERE receivables_trx_id = p_adj_rec.receivables_trx_id;
2997 
2998 	/* Bug 7461503 get value of added flag in transaction types*/
2999 
3000 	SELECT decode(ctt.post_to_gl,'Y','Y', nvl(ctt.adj_post_to_gl ,'N'))
3001         INTO   l_adj_post_to_gl_flag
3002 	FROM   ra_customer_trx ct,ra_cust_trx_types ctt
3003         WHERE  ct.customer_trx_id=p_adj_rec.customer_trx_id
3004 	AND    ctt.cust_trx_type_id=ct.cust_trx_type_id;
3005 
3006 
3007     /*-------------------*
3008      | Insert the record |
3009      *-------------------*/
3010 
3011       INSERT INTO ar_adjustments
3012        (
3013           adjustment_id,
3014           amount,
3015           acctd_amount,
3016           apply_date,
3017           gl_date,
3018           gl_posted_date,
3019           set_of_books_id,
3020           code_combination_id,
3021           type,
3022           adjustment_type,
3023           status,
3024           line_adjusted,
3025           freight_adjusted,
3026           tax_adjusted,
3027           receivables_charges_adjusted,
3028           batch_id,
3029           customer_trx_id,
3030           subsequent_trx_id,
3031           customer_trx_line_id,
3032           associated_cash_receipt_id,
3033           chargeback_customer_trx_id,
3034           payment_schedule_id,
3035           receivables_trx_id,
3036           distribution_set_id,
3037           associated_application_id,
3038           comments,
3039           automatically_generated,
3040           created_from,
3041           reason_code,
3042           postable,
3043           approved_by,
3044           adjustment_number,
3045           doc_sequence_value,
3046           doc_sequence_id,
3047           ussgl_transaction_code,
3048           ussgl_transaction_code_context,
3049           attribute_category,
3050           attribute1,
3051           attribute2,
3052           attribute3,
3053           attribute4,
3054           attribute5,
3055           attribute6,
3056           attribute7,
3057           attribute8,
3058           attribute9,
3059           attribute10,
3060           attribute11,
3061           attribute12,
3062           attribute13,
3063           attribute14,
3064           attribute15,
3065           posting_control_id,
3066           last_updated_by,
3067           last_update_date,
3068           last_update_login,
3069           created_by,
3070           creation_date,
3071           program_application_id,
3072           program_id,
3073           program_update_date,
3074           request_id,org_id
3075 --{Late Charge Project
3076 ,interest_header_id
3077 ,interest_line_id )
3078        VALUES
3079        (
3080          l_adjustment_id,
3081          p_adj_rec.amount,
3082          nvl(p_adj_rec.acctd_amount,
3083              decode(p_adj_rec.amount,
3084                     null, to_number(null),
3085                           arpcurr.functional_amount(
3086                                                     p_adj_rec.amount,
3087  				     		    pg_base_curr_code,
3088 			  		            nvl(p_exchange_rate, 1),
3089 					            pg_base_precision,
3090  					            pg_base_min_acc_unit)
3091                    )
3092             ),
3093          p_adj_rec.apply_date,
3094          p_adj_rec.gl_date,
3095          p_adj_rec.gl_posted_date,
3096          arp_global.set_of_books_id,
3097          p_adj_rec.code_combination_id,
3098          p_adj_rec.type,
3099          p_adj_rec.adjustment_type,
3100          p_adj_rec.status,
3101          p_adj_rec.line_adjusted,
3102          p_adj_rec.freight_adjusted,
3103          p_adj_rec.tax_adjusted,
3104          p_adj_rec.receivables_charges_adjusted,
3105          p_adj_rec.batch_id,
3106          p_adj_rec.customer_trx_id,
3107          p_adj_rec.subsequent_trx_id,
3108          p_adj_rec.customer_trx_line_id,
3109          p_adj_rec.associated_cash_receipt_id,
3110          p_adj_rec.chargeback_customer_trx_id,
3111          p_adj_rec.payment_schedule_id,
3112          p_adj_rec.receivables_trx_id,
3113          p_adj_rec.distribution_set_id,
3114          p_adj_rec.associated_application_id,
3115          p_adj_rec.comments,
3116          p_adj_rec.automatically_generated,
3117          p_adj_rec.created_from,
3118          p_adj_rec.reason_code,
3119      /*-----------------------------------------+
3120       |  The postable flag for an adjustment    |
3121       |  is set to 'N' if the                   |
3122       |  accounting_affect_flag of the          |
3123       |  receivables_trx is 'N'.                |
3124       +-----------------------------------------*/
3125       /* bug 7461503 added logic to select postable value based on new flag in transaction type*/
3126          decode(p_adj_rec.status,
3127                 'A',decode(NVL(l_adj_post_to_gl_flag,'N'),'Y',decode(NVL(l_accounting_affect_flag,'Y'), 'N','N','Y'),'N'),
3128                      'N'),
3129          nvl(p_adj_rec.approved_by,
3130              decode(p_adj_rec.adjustment_type,
3131                     'C', null,
3132                          decode(p_adj_rec.status,
3133                                 'A', pg_user_id,
3134                                      null))),
3135          l_adjustment_number,
3136          p_adj_rec.doc_sequence_value,
3137          p_adj_rec.doc_sequence_id,
3138          p_adj_rec.ussgl_transaction_code,
3139          p_adj_rec.ussgl_transaction_code_context,
3140          p_adj_rec.attribute_category,
3141          p_adj_rec.attribute1,
3142          p_adj_rec.attribute2,
3143          p_adj_rec.attribute3,
3144          p_adj_rec.attribute4,
3145          p_adj_rec.attribute5,
3146          p_adj_rec.attribute6,
3147          p_adj_rec.attribute7,
3148          p_adj_rec.attribute8,
3149          p_adj_rec.attribute9,
3150          p_adj_rec.attribute10,
3151          p_adj_rec.attribute11,
3152          p_adj_rec.attribute12,
3153          p_adj_rec.attribute13,
3154          p_adj_rec.attribute14,
3155          p_adj_rec.attribute15,
3156          -3,
3157          pg_user_id,			/* last_updated_by */
3158          sysdate,			/*last_update_date */
3159          nvl(pg_conc_login_id,
3160              pg_login_id),		/* last_update_login */
3161          pg_user_id,			/* created_by */
3162          sysdate, 			/* creation_date */
3163          pg_prog_appl_id,		/* program_application_id */
3164          pg_conc_program_id,		/* program_id */
3165          sysdate,			/* program_update_date */
3166          p_adj_rec.request_id		/* request_id */
3167          ,arp_global.sysparam.org_id
3168 --{Late Charge Project
3169                ,p_adj_rec.interest_header_id
3170                ,p_adj_rec.interest_line_id
3171        );
3172 
3173    p_adjustment_id := l_adjustment_id;
3174    p_adjustment_number := l_adjustment_number;
3175 
3176    arp_util.debug('p_adjustment_id = ' || to_char(p_adjustment_id));
3177    arp_util.debug('l_adjust_id = ' || to_char(l_adjustment_id));
3178    /*-------------------------------------------+
3179     | Call central MRC library for insertion    |
3180     | into MRC tables                           |
3181     +-------------------------------------------*/
3182 /*BUG4301323
3183    ar_mrc_engine.maintain_mrc_data( p_event_mode => 'INSERT',
3184                                     p_table_name => 'AR_ADJUSTMENTS',
3185                                     p_mode       => 'SINGLE',
3186                                     p_key_value  => p_adjustment_id);
3187 
3188 */
3189    arp_util.debug('arp_adjustments_pkg.insert_p()-');
3190 
3191 EXCEPTION
3192     WHEN OTHERS THEN
3193         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.insert_p()');
3194 	RAISE;
3195 END;
3196 
3197 /*===========================================================================+
3198  | FUNCTION                                                                  |
3199  |    merge_adj_rec							     |
3200  |                                                                           |
3201  | DESCRIPTION                                                               |
3202  |    Merges the changed columns in p_new_adj_rec into the same columns      |
3203  |    p_old_adj_rec and puts the result into p_out_adj_rec. Columns that     |
3204  |    contain the dummy values are not changed.				     |
3205  |    									     |
3206  | SCOPE - PUBLIC                                                            |
3207  |                                                                           |
3208  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
3209  |    arp_util.debug                                                         |
3210  |                                                                           |
3211  | ARGUMENTS  : IN:                                                          |
3212  |                    p_old_adj_rec					     |
3213  |                    p_new_adj_rec					     |
3214  |              OUT:                                                         |
3215  |                    p_new_adj_rec					     |
3216  |                                                                           |
3217  | NOTES                                                                     |
3218  |                                                                           |
3219  | MODIFICATION HISTORY                                                      |
3220  |     11-SEP-95  Charlie Tomberg     Created                                |
3221  |                                                                           |
3222  +===========================================================================*/
3223 
3224 PROCEDURE  merge_adj_recs( p_old_adj_rec    IN  ar_adjustments%rowtype,
3225                            p_new_adj_rec    IN  ar_adjustments%rowtype,
3226                            p_out_adj_rec   OUT NOCOPY  ar_adjustments%rowtype ) IS
3227 
3228 BEGIN
3229 
3230     arp_util.debug('arp_adjustments_pkg.merge_adj_recs()+');
3231 
3232     IF    (p_new_adj_rec.adjustment_id = AR_NUMBER_DUMMY)
3233     THEN  p_out_adj_rec.adjustment_id  := p_old_adj_rec.adjustment_id;
3234     ELSE  p_out_adj_rec.adjustment_id  := p_new_adj_rec.adjustment_id;
3235     END IF;
3236 
3237     IF    (p_new_adj_rec.amount = AR_NUMBER_DUMMY)
3238     THEN  p_out_adj_rec.amount  := p_old_adj_rec.amount;
3239     ELSE  p_out_adj_rec.amount  := p_new_adj_rec.amount;
3240     END IF;
3241 
3242     IF    (p_new_adj_rec.acctd_amount = AR_NUMBER_DUMMY)
3243     THEN  p_out_adj_rec.acctd_amount  := p_old_adj_rec.acctd_amount;
3244     ELSE  p_out_adj_rec.acctd_amount  := p_new_adj_rec.acctd_amount;
3245     END IF;
3246 
3247     IF    (p_new_adj_rec.apply_date = AR_DATE_DUMMY)
3248     THEN  p_out_adj_rec.apply_date  := p_old_adj_rec.apply_date;
3249     ELSE  p_out_adj_rec.apply_date  := p_new_adj_rec.apply_date;
3250     END IF;
3251 
3252     IF    (p_new_adj_rec.gl_date = AR_DATE_DUMMY)
3253     THEN  p_out_adj_rec.gl_date  := p_old_adj_rec.gl_date;
3254     ELSE  p_out_adj_rec.gl_date  := p_new_adj_rec.gl_date;
3255     END IF;
3256 
3257     IF    (p_new_adj_rec.gl_posted_date = AR_DATE_DUMMY)
3258     THEN  p_out_adj_rec.gl_posted_date  := p_old_adj_rec.gl_posted_date;
3259     ELSE  p_out_adj_rec.gl_posted_date  := p_new_adj_rec.gl_posted_date;
3260     END IF;
3261 
3262     IF    (p_new_adj_rec.set_of_books_id = AR_NUMBER_DUMMY)
3263     THEN  p_out_adj_rec.set_of_books_id  := p_old_adj_rec.set_of_books_id;
3264     ELSE  p_out_adj_rec.set_of_books_id  := p_new_adj_rec.set_of_books_id;
3265     END IF;
3266 
3267     IF    (p_new_adj_rec.code_combination_id = AR_NUMBER_DUMMY)
3268     THEN  p_out_adj_rec.code_combination_id  :=
3269                                             p_old_adj_rec.code_combination_id;
3270     ELSE  p_out_adj_rec.code_combination_id  :=
3271                                             p_new_adj_rec.code_combination_id;
3272     END IF;
3273 
3274     IF    (p_new_adj_rec.type = AR_TEXT_DUMMY)
3275     THEN  p_out_adj_rec.type  := p_old_adj_rec.type;
3276     ELSE  p_out_adj_rec.type  := p_new_adj_rec.type;
3277     END IF;
3278 
3279     IF    (p_new_adj_rec.adjustment_type = AR_TEXT3_DUMMY)
3280     THEN  p_out_adj_rec.adjustment_type  := p_old_adj_rec.adjustment_type;
3281     ELSE  p_out_adj_rec.adjustment_type  := p_new_adj_rec.adjustment_type;
3282     END IF;
3283 
3284     IF    (p_new_adj_rec.status = AR_TEXT_DUMMY)
3285     THEN  p_out_adj_rec.status  := p_old_adj_rec.status;
3286     ELSE  p_out_adj_rec.status  := p_new_adj_rec.status;
3287     END IF;
3288 
3289     IF    (p_new_adj_rec.line_adjusted = AR_NUMBER_DUMMY)
3290     THEN  p_out_adj_rec.line_adjusted  := p_old_adj_rec.line_adjusted;
3291     ELSE  p_out_adj_rec.line_adjusted  := p_new_adj_rec.line_adjusted;
3292     END IF;
3293 
3294     IF    (p_new_adj_rec.freight_adjusted = AR_NUMBER_DUMMY)
3295     THEN  p_out_adj_rec.freight_adjusted  := p_old_adj_rec.freight_adjusted;
3296     ELSE  p_out_adj_rec.freight_adjusted  := p_new_adj_rec.freight_adjusted;
3297     END IF;
3298 
3299     IF    (p_new_adj_rec.tax_adjusted = AR_NUMBER_DUMMY)
3300     THEN  p_out_adj_rec.tax_adjusted  := p_old_adj_rec.tax_adjusted;
3301     ELSE  p_out_adj_rec.tax_adjusted  := p_new_adj_rec.tax_adjusted;
3302     END IF;
3303 
3304     IF    (p_new_adj_rec.receivables_charges_adjusted = AR_NUMBER_DUMMY)
3305     THEN  p_out_adj_rec.receivables_charges_adjusted  :=
3306                                    p_old_adj_rec.receivables_charges_adjusted;
3307     ELSE  p_out_adj_rec.receivables_charges_adjusted  :=
3308                                    p_new_adj_rec.receivables_charges_adjusted;
3309     END IF;
3310 
3311     IF    (p_new_adj_rec.batch_id = AR_NUMBER_DUMMY)
3312     THEN  p_out_adj_rec.batch_id  := p_old_adj_rec.batch_id;
3313     ELSE  p_out_adj_rec.batch_id  := p_new_adj_rec.batch_id;
3314     END IF;
3315 
3316     IF    (p_new_adj_rec.customer_trx_id = AR_NUMBER_DUMMY)
3317     THEN  p_out_adj_rec.customer_trx_id  := p_old_adj_rec.customer_trx_id;
3318     ELSE  p_out_adj_rec.customer_trx_id  := p_new_adj_rec.customer_trx_id;
3319     END IF;
3320 
3321     IF    (p_new_adj_rec.subsequent_trx_id = AR_NUMBER_DUMMY)
3322     THEN  p_out_adj_rec.subsequent_trx_id  := p_old_adj_rec.subsequent_trx_id;
3323     ELSE  p_out_adj_rec.subsequent_trx_id  := p_new_adj_rec.subsequent_trx_id;
3324     END IF;
3325 
3326     IF    (p_new_adj_rec.customer_trx_line_id = AR_NUMBER_DUMMY)
3327     THEN  p_out_adj_rec.customer_trx_line_id  :=
3328                                             p_old_adj_rec.customer_trx_line_id;
3329     ELSE  p_out_adj_rec.customer_trx_line_id  :=
3330                                             p_new_adj_rec.customer_trx_line_id;
3331     END IF;
3332 
3333     IF    (p_new_adj_rec.associated_cash_receipt_id = AR_NUMBER_DUMMY)
3334     THEN  p_out_adj_rec.associated_cash_receipt_id  :=
3335                                       p_old_adj_rec.associated_cash_receipt_id;
3336     ELSE  p_out_adj_rec.associated_cash_receipt_id  :=
3337                                       p_new_adj_rec.associated_cash_receipt_id;
3338     END IF;
3339 
3340     IF    (p_new_adj_rec.chargeback_customer_trx_id = AR_NUMBER_DUMMY)
3341     THEN  p_out_adj_rec.chargeback_customer_trx_id  :=
3342                                       p_old_adj_rec.chargeback_customer_trx_id;
3343     ELSE  p_out_adj_rec.chargeback_customer_trx_id  :=
3344                                       p_new_adj_rec.chargeback_customer_trx_id;
3345     END IF;
3346 
3347     IF    (p_new_adj_rec.payment_schedule_id = AR_NUMBER_DUMMY)
3348     THEN  p_out_adj_rec.payment_schedule_id  :=
3349                                             p_old_adj_rec.payment_schedule_id;
3350     ELSE  p_out_adj_rec.payment_schedule_id  :=
3351                                             p_new_adj_rec.payment_schedule_id;
3352     END IF;
3353 
3354     IF    (p_new_adj_rec.receivables_trx_id = AR_NUMBER_DUMMY)
3355     THEN  p_out_adj_rec.receivables_trx_id  :=
3356                                               p_old_adj_rec.receivables_trx_id;
3357     ELSE  p_out_adj_rec.receivables_trx_id  :=
3358                                               p_new_adj_rec.receivables_trx_id;
3359     END IF;
3360 
3361     IF    (p_new_adj_rec.distribution_set_id = AR_NUMBER_DUMMY)
3362     THEN  p_out_adj_rec.distribution_set_id  :=
3363                                              p_old_adj_rec.distribution_set_id;
3364     ELSE  p_out_adj_rec.distribution_set_id  :=
3365                                              p_new_adj_rec.distribution_set_id;
3366     END IF;
3367 
3368     IF    (p_new_adj_rec.associated_application_id = AR_NUMBER_DUMMY)
3369     THEN  p_out_adj_rec.associated_application_id  :=
3370                                        p_old_adj_rec.associated_application_id;
3371     ELSE  p_out_adj_rec.associated_application_id  :=
3372                                        p_new_adj_rec.associated_application_id;
3373     END IF;
3374 
3375     IF    (p_new_adj_rec.comments = AR_TEXT_DUMMY)
3376     THEN  p_out_adj_rec.comments  := p_old_adj_rec.comments;
3377     ELSE  p_out_adj_rec.comments  := p_new_adj_rec.comments;
3378     END IF;
3379 
3380     IF    (p_new_adj_rec.automatically_generated = AR_FLAG_DUMMY)
3381     THEN  p_out_adj_rec.automatically_generated  :=
3382                                        p_old_adj_rec.automatically_generated;
3383     ELSE  p_out_adj_rec.automatically_generated  :=
3384                                        p_new_adj_rec.automatically_generated;
3385     END IF;
3386 
3387     IF    (p_new_adj_rec.created_from = AR_TEXT_DUMMY)
3388     THEN  p_out_adj_rec.created_from  := p_old_adj_rec.created_from;
3389     ELSE  p_out_adj_rec.created_from  := p_new_adj_rec.created_from;
3390     END IF;
3391 
3392     IF    (p_new_adj_rec.reason_code = AR_TEXT_DUMMY)
3393     THEN  p_out_adj_rec.reason_code  := p_old_adj_rec.reason_code;
3394     ELSE  p_out_adj_rec.reason_code  := p_new_adj_rec.reason_code;
3395     END IF;
3396 
3397     IF    (p_new_adj_rec.postable = AR_FLAG_DUMMY)
3398     THEN  p_out_adj_rec.postable  := p_old_adj_rec.postable;
3399     ELSE  p_out_adj_rec.postable  := p_new_adj_rec.postable;
3400     END IF;
3401 
3402     IF    (p_new_adj_rec.approved_by = AR_NUMBER_DUMMY)
3403     THEN  p_out_adj_rec.approved_by  := p_old_adj_rec.approved_by;
3404     ELSE  p_out_adj_rec.approved_by  := p_new_adj_rec.approved_by;
3405     END IF;
3406 
3407     IF    (p_new_adj_rec.adjustment_number = AR_TEXT_DUMMY)
3408     THEN  p_out_adj_rec.adjustment_number  := p_old_adj_rec.adjustment_number;
3409     ELSE  p_out_adj_rec.adjustment_number  := p_new_adj_rec.adjustment_number;
3410     END IF;
3411 
3412     IF    (p_new_adj_rec.doc_sequence_value = AR_NUMBER_DUMMY)
3413     THEN  p_out_adj_rec.doc_sequence_value  :=
3414                                               p_old_adj_rec.doc_sequence_value;
3415     ELSE  p_out_adj_rec.doc_sequence_value  :=
3416                                               p_new_adj_rec.doc_sequence_value;
3417     END IF;
3418 
3419     IF    (p_new_adj_rec.doc_sequence_id = AR_NUMBER_DUMMY)
3420     THEN  p_out_adj_rec.doc_sequence_id  := p_old_adj_rec.doc_sequence_id;
3421     ELSE  p_out_adj_rec.doc_sequence_id  := p_new_adj_rec.doc_sequence_id;
3422     END IF;
3423 
3424     IF    (p_new_adj_rec.ussgl_transaction_code = AR_TEXT_DUMMY)
3425     THEN  p_out_adj_rec.ussgl_transaction_code  :=
3426                                           p_old_adj_rec.ussgl_transaction_code;
3427     ELSE  p_out_adj_rec.ussgl_transaction_code  :=
3428                                           p_new_adj_rec.ussgl_transaction_code;
3429     END IF;
3430 
3431     IF    (p_new_adj_rec.ussgl_transaction_code_context = AR_TEXT_DUMMY)
3432     THEN  p_out_adj_rec.ussgl_transaction_code_context  :=
3433                                  p_old_adj_rec.ussgl_transaction_code_context;
3434     ELSE  p_out_adj_rec.ussgl_transaction_code_context  :=
3435                                  p_new_adj_rec.ussgl_transaction_code_context;
3436     END IF;
3437 
3438     IF    (p_new_adj_rec.attribute_category = AR_TEXT_DUMMY)
3439     THEN  p_out_adj_rec.attribute_category  :=
3440                                               p_old_adj_rec.attribute_category;
3441     ELSE  p_out_adj_rec.attribute_category  :=
3442                                               p_new_adj_rec.attribute_category;
3443     END IF;
3444 
3445     IF    (p_new_adj_rec.attribute1 = AR_TEXT_DUMMY)
3446     THEN  p_out_adj_rec.attribute1  := p_old_adj_rec.attribute1;
3447     ELSE  p_out_adj_rec.attribute1  := p_new_adj_rec.attribute1;
3448     END IF;
3449 
3450     IF    (p_new_adj_rec.attribute2 = AR_TEXT_DUMMY)
3451     THEN  p_out_adj_rec.attribute2  := p_old_adj_rec.attribute2;
3452     ELSE  p_out_adj_rec.attribute2  := p_new_adj_rec.attribute2;
3453     END IF;
3454 
3455     IF    (p_new_adj_rec.attribute3 = AR_TEXT_DUMMY)
3456     THEN  p_out_adj_rec.attribute3  := p_old_adj_rec.attribute3;
3457     ELSE  p_out_adj_rec.attribute3  := p_new_adj_rec.attribute3;
3458     END IF;
3459 
3460     IF    (p_new_adj_rec.attribute4 = AR_TEXT_DUMMY)
3461     THEN  p_out_adj_rec.attribute4  := p_old_adj_rec.attribute4;
3462     ELSE  p_out_adj_rec.attribute4  := p_new_adj_rec.attribute4;
3463     END IF;
3464 
3465     IF    (p_new_adj_rec.attribute5 = AR_TEXT_DUMMY)
3466     THEN  p_out_adj_rec.attribute5  := p_old_adj_rec.attribute5;
3467     ELSE  p_out_adj_rec.attribute5  := p_new_adj_rec.attribute5;
3468     END IF;
3469 
3470     IF    (p_new_adj_rec.attribute6 = AR_TEXT_DUMMY)
3471     THEN  p_out_adj_rec.attribute6  := p_old_adj_rec.attribute6;
3472     ELSE  p_out_adj_rec.attribute6  := p_new_adj_rec.attribute6;
3473     END IF;
3474 
3475     IF    (p_new_adj_rec.attribute7 = AR_TEXT_DUMMY)
3476     THEN  p_out_adj_rec.attribute7  := p_old_adj_rec.attribute7;
3477     ELSE  p_out_adj_rec.attribute7  := p_new_adj_rec.attribute7;
3478     END IF;
3479 
3480     IF    (p_new_adj_rec.attribute8 = AR_TEXT_DUMMY)
3481     THEN  p_out_adj_rec.attribute8  := p_old_adj_rec.attribute8;
3482     ELSE  p_out_adj_rec.attribute8  := p_new_adj_rec.attribute8;
3483     END IF;
3484 
3485     IF    (p_new_adj_rec.attribute9 = AR_TEXT_DUMMY)
3486     THEN  p_out_adj_rec.attribute9  := p_old_adj_rec.attribute9;
3487     ELSE  p_out_adj_rec.attribute9  := p_new_adj_rec.attribute9;
3488     END IF;
3489 
3490     IF    (p_new_adj_rec.attribute10 = AR_TEXT_DUMMY)
3491     THEN  p_out_adj_rec.attribute10  := p_old_adj_rec.attribute10;
3492     ELSE  p_out_adj_rec.attribute10  := p_new_adj_rec.attribute10;
3493     END IF;
3494 
3495     IF    (p_new_adj_rec.attribute11 = AR_TEXT_DUMMY)
3496     THEN  p_out_adj_rec.attribute11  := p_old_adj_rec.attribute11;
3497     ELSE  p_out_adj_rec.attribute11  := p_new_adj_rec.attribute11;
3498     END IF;
3499 
3500     IF    (p_new_adj_rec.attribute12 = AR_TEXT_DUMMY)
3501     THEN  p_out_adj_rec.attribute12  := p_old_adj_rec.attribute12;
3502     ELSE  p_out_adj_rec.attribute12  := p_new_adj_rec.attribute12;
3503     END IF;
3504 
3505     IF    (p_new_adj_rec.attribute13 = AR_TEXT_DUMMY)
3506     THEN  p_out_adj_rec.attribute13  := p_old_adj_rec.attribute13;
3507     ELSE  p_out_adj_rec.attribute13  := p_new_adj_rec.attribute13;
3508     END IF;
3509 
3510     IF    (p_new_adj_rec.attribute14 = AR_TEXT_DUMMY)
3511     THEN  p_out_adj_rec.attribute14  := p_old_adj_rec.attribute14;
3512     ELSE  p_out_adj_rec.attribute14  := p_new_adj_rec.attribute14;
3513     END IF;
3514 
3515     IF    (p_new_adj_rec.attribute15 = AR_TEXT_DUMMY)
3516     THEN  p_out_adj_rec.attribute15  := p_old_adj_rec.attribute15;
3517     ELSE  p_out_adj_rec.attribute15  := p_new_adj_rec.attribute15;
3518     END IF;
3519 
3520     IF    (p_new_adj_rec.posting_control_id = AR_NUMBER_DUMMY)
3521     THEN  p_out_adj_rec.posting_control_id  :=
3522                                              p_old_adj_rec.posting_control_id;
3523     ELSE  p_out_adj_rec.posting_control_id  :=
3524                                              p_new_adj_rec.posting_control_id;
3525     END IF;
3526 
3527     IF    (p_new_adj_rec.last_updated_by = AR_NUMBER_DUMMY)
3528     THEN  p_out_adj_rec.last_updated_by  := p_old_adj_rec.last_updated_by;
3529     ELSE  p_out_adj_rec.last_updated_by  := p_new_adj_rec.last_updated_by;
3530     END IF;
3531 
3532     IF    (p_new_adj_rec.last_update_date = AR_DATE_DUMMY)
3533     THEN  p_out_adj_rec.last_update_date  := p_old_adj_rec.last_update_date;
3534     ELSE  p_out_adj_rec.last_update_date  := p_new_adj_rec.last_update_date;
3535     END IF;
3536 
3537     IF    (p_new_adj_rec.last_update_login = AR_NUMBER_DUMMY)
3538     THEN  p_out_adj_rec.last_update_login  := p_old_adj_rec.last_update_login;
3539     ELSE  p_out_adj_rec.last_update_login  := p_new_adj_rec.last_update_login;
3540     END IF;
3541 
3542     IF    (p_new_adj_rec.created_by = AR_NUMBER_DUMMY)
3543     THEN  p_out_adj_rec.created_by  := p_old_adj_rec.created_by;
3544     ELSE  p_out_adj_rec.created_by  := p_new_adj_rec.created_by;
3545     END IF;
3546 
3547     IF    (p_new_adj_rec.creation_date = AR_DATE_DUMMY)
3548     THEN  p_out_adj_rec.creation_date  := p_old_adj_rec.creation_date;
3549     ELSE  p_out_adj_rec.creation_date  := p_new_adj_rec.creation_date;
3550     END IF;
3551 
3552     IF    (p_new_adj_rec.program_application_id = AR_NUMBER_DUMMY)
3553     THEN  p_out_adj_rec.program_application_id  :=
3554                                          p_old_adj_rec.program_application_id;
3555     ELSE  p_out_adj_rec.program_application_id  :=
3556                                          p_new_adj_rec.program_application_id;
3557     END IF;
3558 
3559     IF    (p_new_adj_rec.program_id = AR_NUMBER_DUMMY)
3560     THEN  p_out_adj_rec.program_id  := p_old_adj_rec.program_id;
3561     ELSE  p_out_adj_rec.program_id  := p_new_adj_rec.program_id;
3562     END IF;
3563 
3564     IF    (p_new_adj_rec.program_update_date = AR_DATE_DUMMY)
3565     THEN  p_out_adj_rec.program_update_date  :=
3566                                              p_old_adj_rec.program_update_date;
3567     ELSE  p_out_adj_rec.program_update_date  :=
3568                                              p_new_adj_rec.program_update_date;
3569     END IF;
3570 
3571     IF    (p_new_adj_rec.request_id = AR_NUMBER_DUMMY)
3572     THEN  p_out_adj_rec.request_id  := p_old_adj_rec.request_id;
3573     ELSE  p_out_adj_rec.request_id  := p_new_adj_rec.request_id;
3574     END IF;
3575 
3576     arp_util.debug('arp_adjustments_pkg.merge_adj_recs()-');
3577 
3578 
3579 EXCEPTION
3580     WHEN OTHERS THEN
3581         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.merge_adj_recs()');
3582 
3583         arp_util.debug('------ old adjustment record ------');
3584         arp_adjustments_pkg.display_adj_rec( p_old_adj_rec );
3585         arp_util.debug('');
3586         arp_util.debug('------ new adjustment record ------');
3587         arp_adjustments_pkg.display_adj_rec( p_new_adj_rec );
3588         RAISE;
3589 
3590 END;
3591 
3592 /*===========================================================================+
3593  | PROCEDURE                                                                 |
3594  |    display_adj_rec                                                        |
3595  |                                                                           |
3596  | DESCRIPTION                                                               |
3597  |    Displays the values of all columns except creation_date and            |
3598  |    last_update_date.                                                      |
3599  |                                                                           |
3600  | SCOPE - PRIVATE                                                           |
3601  |                                                                           |
3602  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
3603  |    arp_util.debug                                                         |
3604  |                                                                           |
3605  | ARGUMENTS  : IN:                                                          |
3606  |                       p_adj_rec                                           |
3607  |              OUT:                                                         |
3608  |          IN/ OUT:                                                         |
3609  |                                                                           |
3610  | RETURNS    : NONE                                                         |
3611  |                                                                           |
3612  | NOTES                                                                     |
3613  |                                                                           |
3614  | MODIFICATION HISTORY                                                      |
3615  |     29-AUG-95  Martin Johnson      Created                                |
3616  |                                                                           |
3617  +===========================================================================*/
3618 
3619 PROCEDURE display_adj_rec(
3620             p_adj_rec IN ar_adjustments%rowtype) IS
3621 
3622 BEGIN
3623    arp_util.debug('arp_adjustments_pkg.display_adj_rec()+',
3624                  pg_msg_level_debug);
3625 
3626    arp_util.debug('******** Dump of ar_adjustments record *********');
3627 
3628    arp_util.debug('adjustment_id                  : '||
3629                                      p_adj_rec.adjustment_id);
3630    arp_util.debug('acctd_amount                   : '||
3631                                      p_adj_rec.acctd_amount);
3632    arp_util.debug('adjustment_type                : '||
3633                                      p_adj_rec.adjustment_type);
3634    arp_util.debug('amount                         : '||
3635                                      p_adj_rec.amount);
3636    arp_util.debug('code_combination_id            : '||
3637                                      p_adj_rec.code_combination_id);
3638    arp_util.debug('created_by                     : '||
3639                                      p_adj_rec.created_by);
3640    arp_util.debug('gl_date                        : '||
3641                                      p_adj_rec.gl_date);
3642    arp_util.debug('last_updated_by                : '||
3643                                      p_adj_rec.last_updated_by);
3644    arp_util.debug('set_of_books_id                : '||
3645                                      p_adj_rec.set_of_books_id);
3646    arp_util.debug('status                         : '||
3647                                      p_adj_rec.status);
3648    arp_util.debug('type                           : '||
3649                                      p_adj_rec.type);
3650    arp_util.debug('created_from                   : '||
3651                                      p_adj_rec.created_from);
3652    arp_util.debug('adjustment_number              : '||
3653                                      p_adj_rec.adjustment_number);
3654    arp_util.debug('apply_date                     : '||
3655                                      p_adj_rec.apply_date);
3656    arp_util.debug('approved_by                    : '||
3657                                      p_adj_rec.approved_by);
3658    arp_util.debug('associated_cash_receipt_id     : '||
3659                                      p_adj_rec.associated_cash_receipt_id);
3660    arp_util.debug('automatically_generated        : '||
3661                                      p_adj_rec.automatically_generated);
3662    arp_util.debug('batch_id                       : '||
3663                                      p_adj_rec.batch_id);
3664    arp_util.debug('chargeback_customer_trx_id     : '||
3665                                      p_adj_rec.chargeback_customer_trx_id);
3666    arp_util.debug('comments                       : '||
3667                                      p_adj_rec.comments);
3668    arp_util.debug('customer_trx_id                : '||
3669                                      p_adj_rec.customer_trx_id);
3670    arp_util.debug('customer_trx_line_id           : '||
3671                                      p_adj_rec.customer_trx_line_id);
3672    arp_util.debug('distribution_set_id            : '||
3673                                      p_adj_rec.distribution_set_id);
3674    arp_util.debug('freight_adjusted               : '||
3675                                      p_adj_rec.freight_adjusted);
3676    arp_util.debug('gl_posted_date                 : '||
3677                                      p_adj_rec.gl_posted_date);
3678    arp_util.debug('last_update_login              : '||
3679                                      p_adj_rec.last_update_login);
3680    arp_util.debug('line_adjusted                  : '||
3681                                      p_adj_rec.line_adjusted);
3682    arp_util.debug('payment_schedule_id            : '||
3683                                      p_adj_rec.payment_schedule_id);
3684    arp_util.debug('postable                       : '||
3685                                      p_adj_rec.postable);
3686    arp_util.debug('posting_control_id             : '||
3687                                      p_adj_rec.posting_control_id);
3688    arp_util.debug('reason_code                    : '||
3689                                      p_adj_rec.reason_code);
3690    arp_util.debug('receivables_charges_adjusted   : '||
3691                                      p_adj_rec.receivables_charges_adjusted);
3692    arp_util.debug('receivables_trx_id             : '||
3693                                      p_adj_rec.receivables_trx_id);
3694    arp_util.debug('subsequent_trx_id              : '||
3695                                      p_adj_rec.subsequent_trx_id);
3696    arp_util.debug('tax_adjusted                   : '||
3697                                      p_adj_rec.tax_adjusted);
3698    arp_util.debug('attribute_category             : '||
3699                                      p_adj_rec.attribute_category);
3700    arp_util.debug('attribute1                     : '||
3701                                      p_adj_rec.attribute1);
3702    arp_util.debug('attribute2                     : '||
3703                                      p_adj_rec.attribute2);
3704    arp_util.debug('attribute3                     : '||
3705                                      p_adj_rec.attribute3);
3706    arp_util.debug('attribute4                     : '||
3707                                      p_adj_rec.attribute4);
3708    arp_util.debug('attribute5                     : '||
3709                                      p_adj_rec.attribute5);
3710    arp_util.debug('attribute6                     : '||
3711                                      p_adj_rec.attribute6);
3712    arp_util.debug('attribute7                     : '||
3713                                      p_adj_rec.attribute7);
3714    arp_util.debug('attribute8                     : '||
3715                                      p_adj_rec.attribute8);
3716    arp_util.debug('attribute9                     : '||
3717                                      p_adj_rec.attribute9);
3718    arp_util.debug('attribute10                    : '||
3719                                      p_adj_rec.attribute10);
3720    arp_util.debug('attribute11                    : '||
3721                                      p_adj_rec.attribute11);
3722    arp_util.debug('attribute12                    : '||
3723                                      p_adj_rec.attribute12);
3724    arp_util.debug('attribute13                    : '||
3725                                      p_adj_rec.attribute13);
3726    arp_util.debug('attribute14                    : '||
3727                                      p_adj_rec.attribute14);
3728    arp_util.debug('attribute15                    : '||
3729                                      p_adj_rec.attribute15);
3730    arp_util.debug('ussgl_transaction_code         : '||
3731                                      p_adj_rec.ussgl_transaction_code);
3732    arp_util.debug('ussgl_transaction_code_context : '||
3733                                      p_adj_rec.ussgl_transaction_code_context);
3734    arp_util.debug('request_id                     : '||
3735                                      p_adj_rec.request_id);
3736    arp_util.debug('program_update_date            : '||
3737                                      p_adj_rec.program_update_date);
3738    arp_util.debug('program_id                     : '||
3739                                      p_adj_rec.program_id);
3740    arp_util.debug('program_application_id         : '||
3741                                      p_adj_rec.program_application_id);
3742    arp_util.debug('doc_sequence_id                : '||
3743                                      p_adj_rec.doc_sequence_id);
3744    arp_util.debug('doc_sequence_value             : '||
3745                                      p_adj_rec.doc_sequence_value);
3746    arp_util.debug('associated_application_id      : '||
3747                                      p_adj_rec.associated_application_id);
3748 
3749    arp_util.debug('arp_adjustments_pkg.display_adj_rec()-',
3750                  pg_msg_level_debug);
3751 
3752 EXCEPTION
3753     WHEN OTHERS THEN
3754         arp_util.debug('EXCEPTION: arp_adjustments_pkg.display_adj_rec()');
3755         RAISE;
3756 END;
3757 
3758 /*===========================================================================+
3759  | PROCEDURE                                                                 |
3760  |    display_adj_p                                                          |
3761  |                                                                           |
3762  | DESCRIPTION                                                               |
3763  |    Displays the values of all columns except creation_date and            |
3764  |    last_update_date.                                                      |
3765  |                                                                           |
3766  | SCOPE - PUBLIC                                                            |
3767  |                                                                           |
3768  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
3769  |    arp_util.debug                                                         |
3770  |                                                                           |
3771  | ARGUMENTS  : IN:                                                          |
3772  |                p_adjustment_id                                            |
3773  |              OUT:                                                         |
3774  |          IN/ OUT:                                                         |
3775  |                                                                           |
3776  | RETURNS    : NONE                                                         |
3777  |                                                                           |
3778  | NOTES                                                                     |
3779  |                                                                           |
3780  | MODIFICATION HISTORY                                                      |
3781  |     29-AUG-95  Martin Johnson      Created                                |
3782  |                                                                           |
3783  +===========================================================================*/
3784 
3785 PROCEDURE display_adj_p(p_adjustment_id IN ar_adjustments.adjustment_id%type)
3786 
3787 IS
3788 
3789    l_adj_rec ar_adjustments%rowtype;
3790 
3791 BEGIN
3792    arp_util.debug('arp_adjustments_pkg.display_adj_p()+',
3793                   pg_msg_level_debug);
3794 
3795    fetch_p(l_adj_rec, p_adjustment_id);
3796 
3797    display_adj_rec(l_adj_rec);
3798 
3799    arp_util.debug('arp_adjustments_pkg.display_adj_p()-',
3800                   pg_msg_level_debug);
3801 
3802 
3803 EXCEPTION
3804     WHEN OTHERS THEN
3805         arp_util.debug('EXCEPTION: arp_adjustments_pkg.display_adj_p()');
3806 
3807         arp_util.debug('');
3808         arp_util.debug('-------- parameters for display_adj_p() ------');
3809         arp_util.debug('p_adjustment_id  = ' || p_adjustment_id );
3810 
3811         RAISE;
3812 END;
3813 
3814 /*===========================================================================+
3815  | FUNCTION                                                                  |
3816  |    get_text_dummy							     |
3817  |                                                                           |
3818  | DESCRIPTION                                                               |
3819  |    This procedure returns the value of the AR_TEXT_DUMMY constant.        |
3820  |    									     |
3821  | SCOPE - PUBLIC                                                            |
3822  |                                                                           |
3823  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
3824  |    arp_util.debug                                                         |
3825  |                                                                           |
3826  | ARGUMENTS  : IN:                                                          |
3827  |                    None						     |
3828  |              OUT:                                                         |
3829  |                    None						     |
3830  |                                                                           |
3831  | RETURNS    : value of AR_TEXT_DUMMY                                       |
3832  |                                                                           |
3833  | NOTES                                                                     |
3834  |                                                                           |
3835  | MODIFICATION HISTORY                                                      |
3836  |     06-SEP-95  Martin Johnson      Created                                |
3837  |                                                                           |
3838  +===========================================================================*/
3839 
3840 FUNCTION get_text_dummy(p_null IN NUMBER DEFAULT null) RETURN varchar2 IS
3841 
3842 BEGIN
3843 
3844     arp_util.debug('arp_adjustments_pkg.get_text_dummy()+');
3845 
3846     arp_util.debug('arp_adjustments_pkg.get_text_dummy()-');
3847 
3848     return(AR_TEXT_DUMMY);
3849 
3850 EXCEPTION
3851     WHEN OTHERS THEN
3852         arp_util.debug('EXCEPTION:  arp_adjustments_pkg.get_text_dummy()');
3853         RAISE;
3854 
3855 END;
3856 
3857 
3858   /*---------------------------------------------+
3859    |   Package initialization section.           |
3860    |   Sets WHO column variables for later use.  |
3861    +---------------------------------------------*/
3862 
3863 BEGIN
3864 
3865   pg_user_id          := fnd_global.user_id;
3866   pg_conc_login_id    := fnd_global.conc_login_id;
3867   pg_login_id         := fnd_global.login_id;
3868   pg_prog_appl_id     := fnd_global.prog_appl_id;
3869   pg_conc_program_id  := fnd_global.conc_program_id;
3870 
3871   pg_base_curr_code    := arp_global.functional_currency;
3872   pg_base_precision    := arp_global.base_precision;
3873   pg_base_min_acc_unit := arp_global.base_min_acc_unit;
3874 
3875   pg_msg_level_debug := arp_global.MSG_LEVEL_DEBUG;
3876 
3877 END ARP_ADJUSTMENTS_PKG;