DBA Data[Home] [Help]

PACKAGE BODY: APPS.ARP_PROCESS_FREIGHT

Source


1 PACKAGE BODY ARP_PROCESS_FREIGHT AS
2 /* $Header: ARTEFRTB.pls 120.6.12010000.1 2008/07/24 16:55:59 appldev ship $ */
3 
4 pg_number_dummy number;
5 pg_date_dummy date;
6 
7 /* Bug 3604027 */
8 pg_base_precision          fnd_currencies.precision%type;
9 pg_base_min_acc_unit       fnd_currencies.minimum_accountable_unit%type;
10 pg_trx_header_level_rounding ar_system_parameters.TRX_HEADER_LEVEL_ROUNDING%TYPE;
11 
12 /*===========================================================================+
13  | PROCEDURE                                                                 |
14  |    check_frt_line_count                                                   |
15  |                                                                           |
16  | DESCRIPTION                                                               |
17  |    Checks for the number for freight lines defined at the header/line     |
18  |    level. Raises exception                                                |
19  |       - if more than one freight line at line/header level                |
20  |       - if freight is being defined at both line/header level             |
21  |                                                                           |
22  | SCOPE - PRIVATE                                                           |
23  |                                                                           |
24  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
25  |    arp_util.debug                                                         |
26  |                                                                           |
27  | ARGUMENTS  : IN:                                                          |
28  |                   p_frt_rec                                               |
29  |              OUT:                                                         |
30  |          IN/ OUT:                                                         |
31  |                                                                           |
32  | RETURNS    : NONE                                                         |
33  |                                                                           |
34  | NOTES                                                                     |
35  |                                                                           |
36  | MODIFICATION HISTORY                                                      |
37  |     12-JUL-95  Subash Chadalavada  Created                                |
38  |                                                                           |
39  +===========================================================================*/
40 
41 PROCEDURE check_frt_line_count(
42   p_frt_rec               IN ra_customer_trx_lines%rowtype)
43 IS
44   l_frt_count number;
45 
46 BEGIN
47 
48    arp_util.debug('arp_process_freight.check_frt_line_count()+');
49 
50    SELECT count(*)
51    INTO   l_frt_count
52    FROM   ra_customer_trx_lines ctl
53    WHERE  ctl.customer_trx_id = p_frt_rec.customer_trx_id
54    AND    ctl.line_type = 'FREIGHT'
55    AND    (
56            (
57               ctl.link_to_cust_trx_line_id is null   /* HEADER freight */
58            )
59            OR
60            (
61               ctl.link_to_cust_trx_line_id = p_frt_rec.link_to_cust_trx_line_id
62                                                      /* freight for the same LINE */
63            )
64            OR
65            (
66               p_frt_rec.link_to_cust_trx_line_id is null
67                                                      /* LINE freight exits, and */
68                                                      /* trying to insert HEADER */
69                                                      /* freight                 */
70            )
71           );
72 
73    IF (l_frt_count > 0)
74    THEN
75       fnd_message.set_name('AR', 'AR_RAXTRX-1699');
76       app_exception.raise_exception;
77    END IF;
78 
79    arp_util.debug('arp_process_freight.check_frt_line_count()-');
80 
81 EXCEPTION
82     WHEN OTHERS THEN
83       arp_util.debug('EXCEPTION:  arp_process_freight.check_frt_line_count()');
84 
85       arp_ctl_pkg.display_line_rec(p_frt_rec);
86 
87       RAISE;
88 END;
89 
90 
91 /*===========================================================================+
92  | PROCEDURE                                                                 |
93  |    validate_insert_freight                                                |
94  |                                                                           |
95  | DESCRIPTION                                                               |
96  |    Validates row that is going to be inserted into ra_customer_trx_lines  |
97  |                                                                           |
98  | SCOPE - PRIVATE                                                           |
99  |                                                                           |
100  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
101  |    arp_util.debug                                                         |
102  |                                                                           |
103  | ARGUMENTS  : IN:                                                          |
104  |                   p_frt_rec                                               |
105  |              OUT:                                                         |
106  |          IN/ OUT:                                                         |
107  |                                                                           |
108  | RETURNS    : NONE                                                         |
109  |                                                                           |
110  | NOTES                                                                     |
111  |                                                                           |
112  | MODIFICATION HISTORY                                                      |
113  |     12-JUL-95  Subash Chadalavada  Created                                |
114  |                                                                           |
115  +===========================================================================*/
116 
117 PROCEDURE validate_insert_freight(
118   p_frt_rec               IN ra_customer_trx_lines%rowtype)
119 IS
120 
121 BEGIN
122 
123    arp_util.debug('arp_process_freight.validate_insert_freight()+');
124 
125    -- check if freight is not defined at both header and line level
126    --       if multiple freight lines are being defined at header
127    --          or for each line
128    arp_process_freight.check_frt_line_count(p_frt_rec);
129 
130    -- other possible checks
131    --     over-application for CMs
132    --     freight allowed flag on transaction type
133 
134    arp_util.debug('arp_process_freight.validate_insert_freight()-');
135 
136 EXCEPTION
137     WHEN OTHERS THEN
138      arp_util.debug('EXCEPTION:  arp_process_freight.validate_insert_freight()');
139      RAISE;
140 END;
141 
142 /*===========================================================================+
143  | PROCEDURE                                                                 |
144  |    validate_update_freight                                                |
145  |                                                                           |
146  | DESCRIPTION                                                               |
147  |    Validation for the freight line that is being updated                  |
148  |                                                                           |
149  | SCOPE - PRIVATE                                                           |
150  |                                                                           |
151  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
152  |    arp_util.debug                                                         |
153  |                                                                           |
154  | ARGUMENTS  : IN:                                                          |
155  |                   p_frt_rec                                               |
156  |              OUT:                                                         |
157  |          IN/ OUT:                                                         |
158  |                                                                           |
159  | RETURNS    : NONE                                                         |
160  |                                                                           |
161  | NOTES                                                                     |
162  |                                                                           |
163  | MODIFICATION HISTORY                                                      |
164  |     12-JUL-95  Subash Chadalavada  Created                                |
165  |                                                                           |
166  +===========================================================================*/
167 
168 PROCEDURE validate_update_freight(
169   p_frt_rec               IN ra_customer_trx_lines%rowtype)
170 IS
171 
172 BEGIN
173 
174    arp_util.debug('arp_process_freight.validate_update_freight()+');
175 
176    arp_util.debug('arp_process_freight.validate_update_freight()-');
177 
178 EXCEPTION
179     WHEN OTHERS THEN
180      arp_util.debug('EXCEPTION:  arp_process_freight.validate_update_freight()');
181      RAISE;
182 
183 END;
184 
185 
186 /*===========================================================================+
187  | PROCEDURE                                                                 |
188  |    validate_delete_freight                                                |
189  |                                                                           |
190  | DESCRIPTION                                                               |
191  |    Validation for the freight line that is being deleted                  |
192  |                                                                           |
193  | SCOPE - PRIVATE                                                           |
194  |                                                                           |
195  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
196  |    arp_util.debug                                                         |
197  |                                                                           |
198  | ARGUMENTS  : IN:                                                          |
199  |                   p_customer_trx_id                                       |
200  |                   p_customer_trx_line_id                                  |
201  |                   p_complete_flag                                         |
202  |              OUT:                                                         |
203  |          IN/ OUT:                                                         |
204  |                                                                           |
205  | RETURNS    : NONE                                                         |
206  |                                                                           |
207  | NOTES                                                                     |
208  |                                                                           |
209  | MODIFICATION HISTORY                                                      |
210  |     12-JUL-95  Subash Chadalavada  Created                                |
211  |                                                                           |
212  +===========================================================================*/
213 
214 PROCEDURE validate_delete_freight(
215   p_customer_trx_id		IN ra_customer_trx.customer_trx_id%type,
216   p_customer_trx_line_id	IN ra_customer_trx_lines.customer_trx_line_id%type,
217   p_complete_flag		IN ra_customer_trx.complete_flag%type
218 )
219 IS
220 
221 BEGIN
222 
223    arp_util.debug('arp_process_freight.validate_delete_freight()+');
224 
225    IF (p_complete_flag = 'Y')
226    THEN
227       -- ensure that this is not the last line to be deleted
228       arp_trx_validate.check_has_one_line(p_customer_trx_id);
229    END IF;
230 
231    arp_util.debug('arp_process_freight.validate_delete_freight()-');
232 
233 EXCEPTION
234     WHEN OTHERS THEN
235      arp_util.debug('EXCEPTION:  arp_process_freight.validate_delete_freight()');
236      RAISE;
237 
238 END;
239 
240 /*===========================================================================+
241  | PROCEDURE                                                                 |
242  |    set_flags                                                              |
243  |                                                                           |
244  | DESCRIPTION                                                               |
245  |    Sets various change and status flags for the current record.           |
246  |                                                                           |
247  | SCOPE - PRIVATE                                                           |
248  |                                                                           |
249  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
250  |    arp_util.debug                                                         |
251  |                                                                           |
252  | ARGUMENTS  : IN:                                                          |
253  |                   p_new_frt_rec                                           |
254  |                   p_new_ccid                                              |
255  |                   p_new_gl_date                                           |
256  |              OUT:                                                         |
257  |                   p_amount_changed_flag                                   |
258  |                   p_ccid_changed_flag                                     |
259  |                   p_gl_date_changed_flag                                  |
260  |          IN/ OUT:                                                         |
261  |                    None                                                   |
262  |                                                                           |
263  | RETURNS    : NONE                                                         |
264  |                                                                           |
265  | NOTES                                                                     |
266  |                                                                           |
267  | MODIFICATION HISTORY                                                      |
268  |      12-JUL-95	Subash Chadalavada		Created              |
269  |                                                                           |
270  +===========================================================================*/
271 PROCEDURE set_flags(
272   p_customer_trx_line_id    IN ra_customer_trx_lines.customer_trx_line_id%type,
273   p_new_frt_rec             IN ra_customer_trx_lines%rowtype,
274   p_new_ccid                IN
275                       ra_cust_trx_line_gl_dist.code_combination_id%type,
276   p_new_gl_date             IN ra_cust_trx_line_gl_dist.gl_date%type,
277   p_amount_changed_flag     OUT NOCOPY boolean,
278   p_ccid_changed_flag       OUT NOCOPY boolean,
279   p_gl_date_changed_flag    OUT NOCOPY boolean) IS
280 
281   l_old_frt_rec       ra_customer_trx_lines%rowtype;
282   l_old_gl_date       ra_cust_trx_line_gl_dist.gl_date%type;
283   l_old_ccid          ra_cust_trx_line_gl_dist.code_combination_id%type;
284 
285 BEGIN
286    arp_util.debug('arp_process_freight.set_flags()+');
287 
288    arp_ctl_pkg.fetch_p(l_old_frt_rec, p_customer_trx_line_id);
289 
290    IF ((p_new_frt_rec.extended_amount <> l_old_frt_rec.extended_amount)
291        and
292       (p_new_frt_rec.extended_amount <> pg_number_dummy))
293    THEN
294       p_amount_changed_flag := TRUE;
295    else
296       p_amount_changed_flag := FALSE;
297    END IF;
298 
299    select max(code_combination_id),
300           max(gl_date)
301    into   l_old_ccid,
302           l_old_gl_date
303    from   ra_cust_trx_line_gl_dist
304    where  customer_trx_line_id = p_customer_trx_line_id;
305 
306    IF (nvl(l_old_ccid, 0) <> nvl(p_new_ccid, 0)) THEN
307       p_ccid_changed_flag := TRUE;
308    else
309       p_ccid_changed_flag := FALSE;
310    END IF;
311 
312    IF ((nvl(l_old_gl_date, to_date('01-01-0001', 'DD-MM-YYYY')) <>
313           nvl(p_new_gl_date, to_date('01-01-0001', 'DD-MM-YYYY')))
314        AND
315        (p_new_gl_date <> pg_date_dummy))
316    THEN
317       p_gl_date_changed_flag := TRUE;
318    ELSE
319       p_gl_date_changed_flag := FALSE;
320    END IF;
321 
322    arp_util.debug('arp_process_freight.set_flags()-');
323 
324 EXCEPTION
325    WHEN OTHERS THEN
326      arp_util.debug('arp_process_freight.set_flags()');
327      arp_util.debug('customer_trx_line_id : '||
328                      p_new_frt_rec.customer_trx_line_id);
329      arp_util.debug('p_new_ccid           : '||p_new_ccid);
330      arp_util.debug('p_new_gl_date        : '||p_new_gl_date);
331      RAISE;
332 END;
333 
334 
335 /*===========================================================================+
336  | PROCEDURE                                                                 |
337  |    insert_freight                                                         |
338  |                                                                           |
339  | DESCRIPTION                                                               |
340  |    Inserts a freight record into RA_CUSTOMER_TRX_LINES                    |
341  |                                                                           |
342  | SCOPE - PRIVATE                                                           |
343  |                                                                           |
344  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
345  |    dbms_sql.bind_variable                                                 |
346  |    arp_util.debug                                                         |
347  |                                                                           |
348  | ARGUMENTS  : IN:                                                          |
349  |                    p_form_name                                            |
350  |                    p_form_version                                         |
351  |                    p_trx_class                                            |
352  |                    p_gl_date                                              |
353  |                    p_frt_ccid                                             |
354  |              OUT:                                                         |
355  |                    p_customer_trx_line_id                                 |
356  |                    p_status                                               |
357  |          IN/ OUT:                                                         |
358  |                    p_frt_rec                                              |
359  |                                                                           |
360  | RETURNS    : NONE                                                         |
361  |                                                                           |
362  | NOTES                                                                     |
363  |                                                                           |
364  | MODIFICATION HISTORY                                                      |
365  |      12-JUL-95	Subash Chadalavada		Created              |
366  |                                                                           |
367  +===========================================================================*/
368 
369 PROCEDURE insert_freight(
370   p_form_name			IN varchar2,
371   p_form_version		IN number,
372   p_frt_rec			IN OUT NOCOPY ra_customer_trx_lines%rowtype,
373   p_trx_class			IN ra_cust_trx_types.type%type,
374   p_gl_date			IN ra_cust_trx_line_gl_dist.gl_date%type,
375   p_frt_ccid			IN
376                           ra_cust_trx_line_gl_dist.code_combination_id%type,
377   p_customer_trx_line_id	OUT NOCOPY
378                           ra_customer_trx_lines.customer_trx_line_id%type,
379   p_status                      OUT NOCOPY varchar2,
380   p_run_autoacc_flag      IN varchar2  DEFAULT 'Y')
381 
382 IS
383 
384   l_customer_trx_line_id	ra_customer_trx_lines.customer_trx_line_id%type;
385   l_result			integer;
386   l_ccid
387 			ra_cust_trx_line_gl_dist.code_combination_id%type;
388   l_concat_segments		varchar2(200);
389   l_num_failed_dist_rows	number;
390   l_rows_processed		number;
391   l_errorbuf			varchar2(200);
392 
393   /* bug 3604027 */
394   l_error_message VARCHAR2(128) := '';
395   l_dist_count NUMBER;
396 
397 BEGIN
398 
399    arp_util.debug('arp_process_freight.insert_freight()+');
400 
401    p_status := 'OK';
402 
403    -- check form version to determine IF it is compatible with the
404    -- entity handler.
405    arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
406 
407    -- Lock rows in other tables that reference this customer_trx_id
408    arp_trx_util.lock_transaction(p_frt_rec.customer_trx_id);
409 
410    --
411    -- !!!! NEED TO CHECK FOR OVERAPPLICATION FOR CMS !!!!
412    --
413 
414    -- do validation
415 
416    arp_process_freight.validate_insert_freight(p_frt_rec);
417 
418    /*--------------------+
419     |  pre-insert logic  |
420     +--------------------*/
421 
422    IF (p_trx_class = 'CM') THEN
423        p_frt_rec.revenue_amount := p_frt_rec.extended_amount;
424    END IF;
425 
426    -- call table handler
427    ARP_CTL_PKG.insert_p(p_frt_rec, l_customer_trx_line_id);
428 
429    p_customer_trx_line_id := l_customer_trx_line_id;
430    /*--------------------+
431     | post-insert logic  |
432     +--------------------*/
433    -- call auto-accounting to insert the freight distribution
434 
435    IF ( p_run_autoacc_flag = 'Y' )
436    THEN
437 
438          BEGIN
439              arp_auto_accounting.do_autoaccounting(
440                                       'I',
441                                       'FREIGHT',
442                                       p_frt_rec.customer_trx_id,
443                                       l_customer_trx_line_id,
444                                       null,
445                                       null,
446                                       p_gl_date,
447                                       null,
448                                       p_frt_rec.extended_amount,
449                                       p_frt_ccid,
450                                       null,
451                                       null,
452                                       null,
453                                       null,
454                                       null,
455                                       l_ccid,
456                                       l_concat_segments,
457                                       l_num_failed_dist_rows);
458 
459              /* Bug 3604027 */
460              IF  arp_rounding.correct_dist_rounding_errors(
461                                         NULL,
462                                         p_frt_rec.customer_trx_id ,
463                                         l_customer_trx_line_id,
464                                         l_dist_count,
465                                         l_error_message ,
466                                         pg_base_precision ,
467                                         pg_base_min_acc_unit ,
468                                         'ALL' ,
469                                         NULL,
470                                         'N' ,
471                                         pg_trx_header_level_rounding ,
472                                         'N',
473                                         'N') = 0 -- FALSE
474              THEN
475                 arp_util.debug('EXCEPTION:  Insert Freight');
476                 arp_util.debug(l_error_message);
477                 fnd_message.set_name('AR', 'AR_PLCRE_FHLR_CCID');
478                 APP_EXCEPTION.raise_exception;
479              END IF;
480          EXCEPTION
481            WHEN arp_auto_accounting.no_ccid THEN
482              p_status := 'ARP_AUTO_ACCOUNTING.NO_CCID';
483            WHEN NO_DATA_FOUND THEN
484              null;
485            WHEN OTHERS THEN
486              RAISE;
487          END;
488 
489    END IF;
490 
491    --
492    -- The payment schedule record will be updated in the post-commit logic
493    --
494    arp_util.debug('arp_process_freight.insert_freight()-');
495 
496 EXCEPTION
497    when OTHERS THEN
498      -- display all relevent information
499      arp_util.debug('EXCEPTION: arp_process_freight.insert_freight()');
500      arp_util.debug('  p_form_name            : '||p_form_name );
501      arp_util.debug('  p_form_version         : '||p_form_version);
502      arp_util.debug('  p_trx_class            : '||p_trx_class);
503      arp_util.debug('  p_gl_date              : '||p_gl_date);
504      arp_util.debug('  p_frt_ccid             : '||p_frt_ccid);
505 
506      arp_ctl_pkg.display_line_rec(p_frt_rec);
507      RAISE;
508 END;
509 
510 /*===========================================================================+
511  | PROCEDURE                                                                 |
512  |    update_freight                                                         |
513  |                                                                           |
514  | DESCRIPTION                                                               |
515  |    Updates freight record in RA_CUSTOMER_TRX_LINES                        |
516  |                                                                           |
517  | SCOPE - PRIVATE                                                           |
518  |                                                                           |
519  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
520  |    dbms_sql.bind_variable                                                 |
521  |    arp_util.debug                                                         |
522  |                                                                           |
523  | ARGUMENTS  : IN:                                                          |
524  |                    p_form_name                                            |
525  |                    p_form_version                                         |
526  |                    p_trx_class                                            |
527  |                    p_gl_date                                              |
528  |                    p_frt_ccid                                             |
529  |                    p_complete_flag                                        |
530  |                    p_open_rec_flag                                        |
531  |              OUT:                                                         |
532  |                    p_status                                               |
533  |          IN/ OUT:                                                         |
534  |                    p_frt_rec                                              |
535  |                                                                           |
536  | RETURNS    : NONE                                                         |
537  |                                                                           |
538  | NOTES                                                                     |
539  |                                                                           |
540  | MODIFICATION HISTORY                                                      |
541  |      12-JUL-95       Subash Chadalavada              Created              |
542  |                                                                           |
543  +===========================================================================*/
544 PROCEDURE update_freight(
545   p_form_name                   IN varchar2,
546   p_form_version                IN number,
547   p_customer_trx_id             IN ra_customer_trx.customer_trx_id%type,
548   p_customer_trx_line_id        IN ra_customer_trx_lines.customer_trx_line_id%type,
549   p_frt_rec                     IN OUT NOCOPY ra_customer_trx_lines%rowtype,
550   p_trx_class                   IN ra_cust_trx_types.type%type,
551   p_gl_date			IN
552                         ra_cust_trx_line_gl_dist.gl_date%type,
553   p_frt_ccid			IN
554                         ra_cust_trx_line_gl_dist.code_combination_id%type,
555   p_complete_flag               IN varchar2,
556   p_open_rec_flag               IN varchar2,
557   p_status                      OUT NOCOPY varchar2)
558 IS
559 
560   l_amount_changed_flag         boolean;
561   l_ccid_changed_flag           boolean;
562   l_gl_date_changed_flag        boolean;
563 
564   /* bug 3604027 */
565   l_error_message VARCHAR2(128) := '';
566   l_dist_count NUMBER;
567 
568 
569 BEGIN
570    arp_util.debug('arp_process_freight.update_freight()+');
571 
572    -- check form version to determine IF it is compatible with the
573    -- entity handler.
574    arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
575 
576    -- Lock rows in other tables that reference this customer_trx_id
577    arp_trx_util.lock_transaction(p_customer_trx_id);
578 
579    --
580    -- !!!! NEED TO CHECK FOR OVERAPPLICATION FOR CMs !!!!
581    --
582    IF (p_trx_class = 'CM') THEN
583        -- validate for overapplication, sign
584        -- populate revenue amounts
585        IF (p_frt_rec.extended_amount <> pg_number_dummy)
586        THEN
587           p_frt_rec.revenue_amount := p_frt_rec.extended_amount;
588        END IF;
589    END IF;
590 
591 
592    -- do validation
593 
594    arp_process_freight.validate_update_freight(p_frt_rec);
595 
596    /*--------------------+
597     |  pre-update logic  |
598     +--------------------*/
599    -- none
600    arp_process_freight.set_flags(p_customer_trx_line_id,
601                                  p_frt_rec,
602                                  p_frt_ccid,
603                                  p_gl_date,
604                                  l_amount_changed_flag,
605                                  l_ccid_changed_flag,
606                                  l_gl_date_changed_flag);
607 
608    -- call the table handler
609    arp_ctl_pkg.update_p(p_frt_rec, p_customer_trx_line_id);
610 
611    /*--------------------+
612     |  post-update logic |
613     +--------------------*/
614    IF ((l_amount_changed_flag  = TRUE)
615        OR
616        (l_ccid_changed_flag    = TRUE)
617        OR
618        (l_gl_date_changed_flag = TRUE))
619    THEN
620       IF p_trx_class in ('INV', 'DM')
621       THEN
622          -- update the distribution record
623          arp_process_invoice.freight_post_update(
624                                 p_frt_rec,
625                                 p_gl_date,
626                                 p_frt_ccid,
627                                 p_status);
628       ELSE
629          -- call the credit memo module to update the distribution
630          -- record and other CM tables
631          arp_process_credit.freight_post_update(
632                                 p_frt_rec,
633                                 p_gl_date,
634                                 p_frt_ccid);
635       END IF;
636 
637    END IF;
638    /* Bug 3604027 */
639    IF  arp_rounding.correct_dist_rounding_errors(
640                                         NULL,
641                                         p_frt_rec.customer_trx_id ,
642                                         p_customer_trx_line_id,
643                                         l_dist_count,
644                                         l_error_message ,
645                                         pg_base_precision ,
646                                         pg_base_min_acc_unit ,
647                                         'ALL' ,
648                                         NULL,
649                                         'N' ,
650                                         pg_trx_header_level_rounding ,
651                                         'N',
652                                         'N') = 0 -- FALSE
653    THEN
654       arp_util.debug('EXCEPTION:  Update Freight');
655       arp_util.debug(l_error_message);
656       fnd_message.set_name('AR', 'AR_PLCRE_FHLR_CCID');
657       APP_EXCEPTION.raise_exception;
658    END IF;
659 
660 
661    arp_util.debug('arp_process_freight.update_freight()-');
662 
663 
664 EXCEPTION
665    WHEN OTHERS THEN
666    -- display all relevent information
667    arp_util.debug('EXCEPTION: arp_process_freight.update_freight()');
668    arp_util.debug('p_form_name            : '||p_form_name );
669    arp_util.debug('p_form_version         : '||p_form_version);
670    arp_util.debug('p_frt_ccid             : '||p_frt_ccid);
671    arp_util.debug('p_gl_date              : '||p_gl_date);
672    arp_util.debug('p_trx_class            : '||p_trx_class);
673    arp_util.debug('p_complete_flag        : '||p_complete_flag);
674    arp_util.debug('p_open_rec_flag        : '||p_open_rec_flag);
675 
676    arp_ctl_pkg.display_line_p(p_frt_rec.customer_trx_line_id);
677 
678    RAISE;
679 END;
680 
681 /*===========================================================================+
682  | PROCEDURE                                                                 |
683  |    delete_freight                                                         |
684  |                                                                           |
685  | DESCRIPTION                                                               |
686  |    Deletes freight record from RA_CUSTOMER_TRX_LINES                      |
687  |                                                                           |
688  | SCOPE - PRIVATE                                                           |
689  |                                                                           |
690  | EXETERNAL PROCEDURES/FUNCTIONS ACCESSED                                   |
691  |    dbms_sql.bind_variable                                                 |
692  |    arp_util.debug                                                         |
693  |                                                                           |
694  | ARGUMENTS  : IN:                                                          |
695  |                    p_form_name                                            |
696  |                    p_form_version                                         |
697  |                    p_trx_class                                            |
698  |                    p_complete_flag                                        |
699  |                    p_open_rec_flag                                        |
700  |                    p_customer_trx_id                                      |
701  |                    p_customer_trx_line_id                                 |
702  |              OUT:                                                         |
703  |          IN/ OUT:                                                         |
704  |                                                                           |
705  | RETURNS    : NONE                                                         |
706  |                                                                           |
707  | NOTES                                                                     |
708  |                                                                           |
709  | MODIFICATION HISTORY                                                      |
710  |      12-JUL-95       Subash Chadalavada              Created              |
711  |                                                                           |
712  +===========================================================================*/
713 
714 
715 PROCEDURE delete_freight(
716   p_form_name                   IN varchar2,
717   p_form_version                IN number,
718   p_trx_class                   IN ra_cust_trx_types.type%type,
719   p_complete_flag		IN varchar2,
720   p_open_rec_flag		IN varchar2,
721   p_customer_trx_id             IN ra_customer_trx.customer_trx_id%type,
722   p_customer_trx_line_id        IN ra_customer_trx_lines.customer_trx_line_id%type)
723 IS
724   l_gt_one_line			BOOLEAN;
725 
726   /* bug 3604027 */
727   l_error_message VARCHAR2(128) := '';
728   l_dist_count NUMBER;
729 
730 BEGIN
731 
732    arp_util.debug('arp_process_freight.delete_freight()+');
733 
734    --
735    -- check form version to determine IF it is compatible with the
736    -- entity handler.
737    --
738    arp_trx_validate.ar_entity_version_check(p_form_name, p_form_version);
739 
740    -- Lock rows in other tables that reference this customer_trx_id
741    arp_trx_util.lock_transaction(p_customer_trx_id);
742 
743    -- do validation
744    arp_process_freight.validate_delete_freight(p_customer_trx_id,
745                                                p_customer_trx_line_id,
746                                                p_complete_flag);
747 
748    /*--------------------+
749     |  pre-delete logic  |
750     +--------------------*/
751 
752    -- delete the distribution record
753    arp_ctlgd_pkg.delete_f_ctl_id(p_customer_trx_line_id, null, null);
754 
755    -- call the table handler
756    arp_ctl_pkg.delete_p(p_customer_trx_line_id);
757 
758    /*--------------------+
759     |  post-delete logic |
760     +--------------------*/
761    /* Bug 3604027 */
762    IF  arp_rounding.correct_dist_rounding_errors(
763                                         NULL,
764                                         p_customer_trx_id ,
765                                         p_customer_trx_line_id,
766                                         l_dist_count,
767                                         l_error_message ,
768                                         pg_base_precision ,
769                                         pg_base_min_acc_unit ,
770                                         'ALL' ,
771                                         NULL,
772                                         'N' ,
773                                         pg_trx_header_level_rounding ,
774                                         'N',
775                                         'N') = 0 -- FALSE
776    THEN
777       arp_util.debug('EXCEPTION:  Delete Freight');
778       arp_util.debug(l_error_message);
779       fnd_message.set_name('AR', 'AR_PLCRE_FHLR_CCID');
780       APP_EXCEPTION.raise_exception;
781    END IF;
782 
783    arp_util.debug('arp_process_freight.delete_freight()-');
784 
785 EXCEPTION
786 
787   WHEN OTHERS THEN
788      -- display all relevent information
789      arp_util.debug('EXCEPTION: ARP_PROCESS_FREIGHT.delete_freight()');
790      arp_util.debug('p_form_name            : '||p_form_name );
791      arp_util.debug('p_form_version         : '||p_form_version);
792      arp_util.debug('p_customer_trx_id      : '||p_customer_trx_id);
793      arp_util.debug('p_customer_trx_line_id : '||p_customer_trx_line_id);
794      arp_util.debug('p_trx_class            : '||p_trx_class);
795      arp_util.debug('p_complete_flag        : '||p_complete_flag);
796 
797      arp_ctl_pkg.display_line_p(p_customer_trx_line_id);
798      RAISE;
799 END;
800 
801 PROCEDURE init IS
802 BEGIN
803     pg_number_dummy       := arp_ctl_pkg.get_number_dummy;
804     pg_date_dummy         := arp_ct_pkg.get_date_dummy;
805 
806     /* bug 3604027 */
807     pg_base_precision    := arp_global.base_precision;
808     pg_base_min_acc_unit := arp_global.base_min_acc_unit;
809     pg_trx_header_level_rounding  := arp_global.sysparam.trx_header_level_rounding;
810 END init;
811 
812 BEGIN
813   init;
814 END ARP_PROCESS_FREIGHT;