DBA Data[Home] [Help]

PACKAGE BODY: APPS.PSA_MFAR_TRANSACTIONS

Source


1 PACKAGE BODY PSA_MFAR_TRANSACTIONS AS
2 /* $Header: PSAMFTXB.pls 120.15 2006/09/13 14:00:54 agovil ship $ */
3 
4 g_cust_trx_id		ra_customer_trx_all.customer_trx_id%type;
5 g_set_of_books_id	ra_customer_trx_all.set_of_books_id%type;
6 g_receivables_ccid	ra_cust_trx_line_gl_dist_all.code_combination_id%type;
7 g_run_id		NUMBER;
8 --===========================FND_LOG.START=====================================
9 g_state_level NUMBER	:=	FND_LOG.LEVEL_STATEMENT;
10 g_proc_level  NUMBER	:=	FND_LOG.LEVEL_PROCEDURE;
11 g_event_level NUMBER	:=	FND_LOG.LEVEL_EVENT;
12 g_excep_level NUMBER	:=	FND_LOG.LEVEL_EXCEPTION;
13 g_error_level NUMBER	:=	FND_LOG.LEVEL_ERROR;
14 g_unexp_level NUMBER	:=	FND_LOG.LEVEL_UNEXPECTED;
15 g_path        VARCHAR2(50)  := 'PSA.PLSQL.PSAMFTXB.PSA_MFAR_TRANSACTIONS.';
16 --===========================FND_LOG.END=======================================
17 
18 --
19 -- LOCAL PROCEDURES
20 --
21 
22 FUNCTION generate_trx_dist
23 		(errbuf                OUT NOCOPY  VARCHAR2,
24                  retcode               OUT NOCOPY  VARCHAR2,
25  		 p_error_message       OUT NOCOPY  VARCHAR2) RETURN BOOLEAN;
26 
27 FUNCTION  transaction_is_complete RETURN BOOLEAN;
28 FUNCTION  transaction_modified    RETURN BOOLEAN;
29 
30 -- for debug messages.
31 l_exception_error      VARCHAR2(3000);
32 
33 FUNCTION create_distributions
34 		(errbuf                OUT NOCOPY  VARCHAR2,
35                  retcode               OUT NOCOPY  VARCHAR2,
36                  p_cust_trx_id		IN NUMBER,
37 		 p_set_of_books_id	IN NUMBER,
38 		 p_run_id		IN NUMBER,
39 		 p_error_message       OUT NOCOPY  VARCHAR2) RETURN BOOLEAN
40 IS
41 
42 	CURSOR c_trx_dist
43 	IS
44 	  SELECT A.cust_trx_line_gl_dist_id	gl_dist_id,
45 		 A.code_combination_id		rev_ccid,
46 		 B.mf_receivables_ccid		mf_ccid,
47 	         B.prev_mf_receivables_ccid     prev_mf_ccid
48 	 FROM 	 ra_cust_trx_line_gl_dist_all 	A,
49 	  	 psa_mf_trx_dist_all 		B
50 	 WHERE 	 A.cust_trx_line_gl_dist_id	= B.cust_trx_line_gl_dist_id
51 	 AND 	 A.customer_trx_id		= g_cust_trx_id;
52          /* bug 2737029
53          AND EXISTS
54                 (SELECT 1 FROM ra_customer_trx_lines_all x
55                  WHERE x.customer_trx_line_id = A.customer_trx_line_id
56                  AND NVL(extended_amount,0) <> 0);
57             bug 2737029 */
58 
59 	CURSOR c_trx_type
60 	IS
61 	SELECT	A.rowid row_id
62 	 FROM	ra_customer_trx_all	A,
63 	  	ra_cust_trx_types_all	B
64 	 WHERE	A.customer_trx_id 	= g_cust_trx_id
65 	 AND	A.cust_trx_type_id	= B.cust_trx_type_id
66                  And    (B.type = 'INV' OR B.type = 'DM')
67 	 FOR UPDATE;
68 
69 	l_trx_dist_rec			c_trx_dist%rowtype;
70 	l_trx_type			c_trx_type%rowtype;
71 	l_temp_rec_ccid 		ra_cust_trx_line_gl_dist_all.code_combination_id%type;
72 
73         l_errbuf		        VARCHAR2(2000);
74         l_retcode                       VARCHAR2(1);
75 
76 	-- EXCEPTION
77 	FLEX_COMPARE_ERROR		EXCEPTION;
78         generate_trx_dist_excep         EXCEPTION;
79         -- ========================= FND LOG ===========================
80         l_full_path VARCHAR2(100) := g_path || 'create_distributions';
81         -- ========================= FND LOG ===========================
82 BEGIN
83 
84    retcode := 'F';
85 
86    -- ========================= FND LOG ===========================
87    psa_utils.debug_other_string(g_state_level,l_full_path,'  ');
88    psa_utils.debug_other_string(g_state_level,l_full_path,' Create_distributions ');
89    psa_utils.debug_other_string(g_state_level,l_full_path,'  ');
90    psa_utils.debug_other_string(g_state_level,l_full_path,' PARAMETERS : ');
91    psa_utils.debug_other_string(g_state_level,l_full_path,' ============ ');
92    psa_utils.debug_other_string(g_state_level,l_full_path,' p_cust_trx_id         -->' || p_cust_trx_id);
93    psa_utils.debug_other_string(g_state_level,l_full_path,' p_set_of_books_id     -->' || p_set_of_books_id);
94    psa_utils.debug_other_string(g_state_level,l_full_path,' p_run_id              -->' || p_run_id);
95    psa_utils.debug_other_string(g_state_level,l_full_path,'  ');
96    -- ========================= FND LOG ===========================
97 
98 --	IF arp_global.sysparam.accounting_method = 'CASH' THEN
99 
100 --	   retcode := 'S';
101 --	   RETURN TRUE;
102 
103 --	END IF;
104 
105 	--
106 	-- Initialize global variables
107 	--
108 
109 	g_cust_trx_id     := p_cust_trx_id;
110 	g_set_of_books_id := p_set_of_books_id;
111 	g_run_id	  := p_run_id;
112 
113         -- ========================= FND LOG ===========================
114         psa_utils.debug_other_string(g_state_level,l_full_path,
115 	                              ' Create_distribution --> Is transaction compelete ? ');
116         -- ========================= FND LOG ===========================
117 
118 	IF (transaction_is_complete) THEN
119         -- ========================= FND LOG ===========================
120         psa_utils.debug_other_string(g_state_level,l_full_path,
121 	                              ' Create_distribution --> Transaction is complete ');
122         -- ========================= FND LOG ===========================
123 
124 	   SELECT  code_combination_id
125 	     INTO  g_receivables_ccid
126 	     FROM  ra_cust_trx_line_gl_dist_all
127 	     WHERE customer_trx_id = g_cust_trx_id
128 	     AND   account_class = 'REC'
129 	     AND   account_set_flag = 'N';
130 
131         -- ========================= FND LOG ===========================
132         psa_utils.debug_other_string(g_state_level,l_full_path,
133 	                            '  Create_distribution --> g_receivables_ccid --> ' || g_receivables_ccid);
134         -- ========================= FND LOG ===========================
135 
136 	   --
137 	   -- Check if distributions already created
138 	   --
139 
140 	   OPEN  c_trx_dist;
141 	   FETCH c_trx_dist INTO l_trx_dist_rec;
142 	   CLOSE c_trx_dist;
143 
144            -- ========================= FND LOG ===========================
145            psa_utils.debug_other_string(g_state_level,l_full_path,
146 	                                 ' #cust_trx_line_gl_dist_id --> ' || l_trx_dist_rec.gl_dist_id
147 					 || ' #code_combination_id      --> ' || l_trx_dist_rec.rev_ccid
148 					 || ' #mf_receivables_ccid      --> ' || l_trx_dist_rec.mf_ccid
149 					 || ' #prev_mf_receivables_ccid --> ' || l_trx_dist_rec.prev_mf_ccid);
150            -- ========================= FND LOG ===========================
151 
152 	   IF l_trx_dist_rec.gl_dist_id Is Not Null  THEN	-- Transaction Distributions already created
153  	      IF (transaction_modified) THEN
154 
155                  IF NOT (GENERATE_TRX_DIST (l_errbuf, l_retcode, l_exception_error)) THEN
156                     -- ========================= FND LOG ===========================
157                     psa_utils.debug_other_string(g_state_level,l_full_path,
158 		                                  ' Create_distribution --> GENERATE_TRX_DIST -> FALSE');
159                     -- ========================= FND LOG ===========================
160                     RAISE generate_trx_dist_excep;
161                  ELSE
162                     -- ========================= FND LOG ===========================
163                     psa_utils.debug_other_string(g_state_level,l_full_path,
164 		                                  ' Create_distribution --> GENERATE_TRX_DIST -> TRUE');
165                     -- ========================= FND LOG ===========================
166                  END IF;
167 
168 	      ELSE
169 
170 		OPEN c_trx_dist;
171 		LOOP
172 		    FETCH c_trx_dist INTO  l_trx_dist_rec;
173 		    EXIT WHEN c_trx_dist%NOTFOUND;
174 
175                     -- ========================= FND LOG ===========================
176                     psa_utils.debug_other_string(g_state_level,l_full_path,
177 		                                  ' Create_distribution --> calling  PSA_MFAR_UTILS.OVERRIDE_SEGMENTS');
178                     -- ========================= FND LOG ===========================
179 
180 		    IF NOT (PSA_MFAR_UTILS.OVERRIDE_SEGMENTS (
181 		                                              p_primary_ccid    => g_receivables_ccid,
182 		    					      p_override_ccid   => l_trx_dist_rec.rev_ccid,
183 							      p_set_of_books_id => g_set_of_books_id,
184 							      p_trx_type        => 'TRX',
185 							      p_ccid            => l_temp_rec_ccid)) THEN
186 
187                        -- ========================= FND LOG ===========================
188                        psa_utils.debug_other_string(g_state_level,l_full_path,
189 		                                     ' Create_distribution --> Raising FLEX_COMPARE_ERROR ');
190                        -- ========================= FND LOG ===========================
191                        RAISE FLEX_COMPARE_ERROR;
192 		    END IF;
193 
194 		   IF NOT (l_temp_rec_ccid = l_trx_dist_rec.prev_mf_ccid) THEN
195 
196                       IF NOT (GENERATE_TRX_DIST (l_errbuf, l_retcode, l_exception_error)) THEN
197                          -- ========================= FND LOG ===========================
198                          psa_utils.debug_other_string(g_state_level,l_full_path,
199 			                               ' Create_distribution --> GENERATE_TRX_DIST -> FALSE');
200                          -- ========================= FND LOG ===========================
201                          RAISE generate_trx_dist_excep;
202                       ELSE
203                          -- ========================= FND LOG ===========================
204                          psa_utils.debug_other_string(g_state_level,l_full_path,
205 			                               ' Create_distribution --> GENERATE_TRX_DIST -> TRUE');
206                          -- ========================= FND LOG ===========================
207                       END IF;
208 
209                       EXIT;
210 		   END IF;
211 
212 		END LOOP;
213 		CLOSE c_trx_dist;
214 	     END IF;
215 
216 	   ELSE						-- New transaction distributions to be created
217 
218 		OPEN	c_trx_type;
219 		FETCH	c_trx_type INTO l_trx_type;
220 		CLOSE	c_trx_type;
221 
222                 -- ========================= FND LOG ===========================
223                 psa_utils.debug_other_string(g_state_level,l_full_path,
224 		                              ' Create_distribution --> Else part --> Type - Invoice OR DM');
225                 -- ========================= FND LOG ===========================
226 
227 		IF l_trx_type.row_id Is Not Null THEN	-- Transaction is an invoice or a debit memo
228                       IF NOT (GENERATE_TRX_DIST (l_errbuf, l_retcode, l_exception_error)) THEN
229                          -- ========================= FND LOG ===========================
230                          psa_utils.debug_other_string(g_state_level,l_full_path,
231 			                               ' Create_distribution --> GENERATE_TRX_DIST -> FALSE');
232                          -- ========================= FND LOG ===========================
233                          RAISE generate_trx_dist_excep;
234                       ELSE
235                         -- ========================= FND LOG ===========================
236                         psa_utils.debug_other_string(g_state_level,l_full_path,
237 			                              ' Create_distribution --> GENERATE_TRX_DIST -> TRUE');
238                         -- ========================= FND LOG ===========================
239                       END IF;
240 		END IF;
241 
242 	   END IF;
243 	END IF;
244 
245      retcode := 'S';
246      RETURN TRUE;
247 
248 EXCEPTION
249 	WHEN GENERATE_TRX_DIST_EXCEP THEN
250 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
251 	                                            g_cust_trx_id, Null, l_exception_error);
252 	  p_error_message := l_exception_error;
253 	  retcode := 'F';
254           -- ========================= FND LOG ===========================
255           psa_utils.debug_other_string(g_excep_level,l_full_path,p_error_message);
256           -- ========================= FND LOG ===========================
257 	  RETURN FALSE;
258 
259 	WHEN FLEX_COMPARE_ERROR THEN
260 	  l_exception_error := 'EXCEPTION - FLEX_COMPARE_ERROR PACKAGE - PSA_MFAR_TRANSACTIONS.CREATE_DISTRIBUTIONS: '||FND_MESSAGE.GET;
261 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
262 	                                            g_cust_trx_id, Null, l_exception_error);
263 
264 	  p_error_message := l_exception_error;
265 	  retcode := 'F';
266           -- ========================= FND LOG ===========================
267           psa_utils.debug_other_string(g_excep_level,l_full_path,p_error_message);
268           -- ========================= FND LOG ===========================
269 	  RETURN FALSE;
270 
274 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
271 	WHEN OTHERS THEN
272 	  l_exception_error := 'EXCEPTION - OTHERS PACKAGE - PSA_MFAR_TRANSACTIONS.CREATE_DISTRIBUTIONS: '
273 	                         || sqlerrm;
275 	                                            g_cust_trx_id, Null, l_exception_error);
276 
277 	  retcode := 'F';
278 	  p_error_message := l_exception_error;
279           -- ========================= FND LOG ===========================
280           psa_utils.debug_other_string(g_excep_level,l_full_path,p_error_message);
281           psa_utils.debug_unexpected_msg(l_full_path);
282           -- ========================= FND LOG ===========================
283           RETURN FALSE;
284 
285 END create_distributions;
286 
287 /****************************************** GENERATE_TRX_DIST ****************************************/
288 
289 FUNCTION generate_trx_dist
290 		(errbuf                OUT NOCOPY  VARCHAR2,
291                  retcode               OUT NOCOPY  VARCHAR2,
292  		 p_error_message       OUT NOCOPY  VARCHAR2) RETURN BOOLEAN
293 IS
294 
295   -- Bug 3671841, query modified to improve performance
296   CURSOR c_trx_gl_dist
297   IS
298     SELECT cust_trx_line_gl_dist_id,
299 	   code_combination_id
300     FROM   ra_cust_trx_line_gl_dist_all y
301     WHERE  customer_trx_id  = g_cust_trx_id
302     AND    account_class <> 'REC'
303     AND    NOT EXISTS ( SELECT 'x'
304                         FROM  psa_mf_trx_dist_all psa
305 			WHERE psa.cust_trx_line_gl_dist_id = y.cust_trx_line_gl_dist_id
306                       );
307    /* bug 2737029
308     AND EXISTS
309            ( SELECT 1 FROM ra_customer_trx_lines_all x
310              WHERE  x.customer_trx_line_id = y.customer_trx_line_id
311              AND    NVL(extended_amount, 0) <> 0);
312       bug 2737029 */
313 
314 	l_revenue_ccid		ra_cust_trx_line_gl_dist_all.code_combination_id%type;
315 	l_ccid			ra_cust_trx_line_gl_dist_all.code_combination_id%type;
316 	l_trx_gl_dist_rec	c_trx_gl_dist%rowtype;
317 	l_rowid			ROWID;
318         -- ========================= FND LOG ===========================
319         l_full_path VARCHAR2(100) := g_path || 'generate_trx_dist';
320         -- ========================= FND LOG ===========================
321 
322 	-- EXCEPTION
323 
324 	l_exception_error	VARCHAR2(2000);
325 	FLEX_BUILD_ERROR	EXCEPTION;
326 
327 BEGIN
328 	--
329 	-- Delete existing records if any
330 	--
331 
332 	Delete FROM psa_mf_trx_dist_all
333 	WHERE  cust_trx_line_gl_dist_id In
334 			(SELECT	cust_trx_line_gl_dist_id
335 			   FROM ra_cust_trx_line_gl_dist_all
336 			  WHERE	customer_trx_id = g_cust_trx_id)
337 	AND  posting_control_id IS NULL;
338 
339         -- ========================= FND LOG ===========================
340         psa_utils.debug_other_string(g_state_level,l_full_path,
341 	                              ' Generate_trx_dist --> delete from psa_mf_trx_dist_all -->'
342 				      || SQL%ROWCOUNT);
343         -- ========================= FND LOG ===========================
344 
345 	--
346 	-- Get revenue/tax/freight ccid's and create
347 	-- corresponding receivable ccid
348 	--
349 
350 	OPEN   c_trx_gl_dist;
351 	LOOP
352 
353 	   FETCH  c_trx_gl_dist INTO l_trx_gl_dist_rec;
354 	   EXIT WHEN c_trx_gl_dist%notfound;
355 
356 	   l_revenue_ccid := l_trx_gl_dist_rec.code_combination_id;
357 
358 	   --
359 	   -- Retrieve/Generate receivable ccid
360 	   --
361 
362            -- ========================= FND LOG ===========================
363            psa_utils.debug_other_string(g_state_level,l_full_path,
364 	                                 ' Generate_trx_dist --> psa_mfar_utils.override_segments : ');
365            psa_utils.debug_other_string(g_state_level,l_full_path,
366 	                                 ' Generate_trx_dist --> g_receivables_ccid  --> '
367 					 || g_receivables_ccid);
368            psa_utils.debug_other_string(g_state_level,l_full_path,
369 	                                 ' Generate_trx_dist --> l_revenue_ccid      --> ' || l_revenue_ccid);
370            psa_utils.debug_other_string(g_state_level,l_full_path,
371 	                                 ' Generate_trx_dist --> g_set_of_books_id   --> '
372 					 || g_set_of_books_id);
373            psa_utils.debug_other_string(g_state_level,l_full_path,
374 	                                 ' Generate_trx_dist --> transaction type    --> ' || 'TRX');
375            psa_utils.debug_other_string(g_state_level,l_full_path,
376 	                                 ' Generate_trx_dist --> l_ccid              --> ' || l_ccid);
377            -- ========================= FND LOG ===========================
378 
379 
380 	   IF NOT (PSA_MFAR_UTILS.OVERRIDE_SEGMENTS (g_receivables_ccid,
381 						     l_revenue_ccid,
382 						     g_set_of_books_id,
383 						     'TRX',
384 						     l_ccid))	THEN
385 
386              -- ========================= FND LOG ===========================
387              psa_utils.debug_other_string(g_state_level,l_full_path,
388 	                                  ' Generate_trx_dist --> PSA_MFAR_UTILS.OVERRIDE_SEGMENTS --> FALSE');
389              -- ========================= FND LOG ===========================
390              RAISE FLEX_BUILD_ERROR;
391 	   END IF;
392 
393 	   --
394 	   -- Insert into psa_mf_trx_dist_all table
395 	   --
396 
397 	   PSA_MFAR_TRANSACTION_COVER_PKG.INSERT_ROW
401 		 X_PREV_MF_RECEIVABLES_CCID => l_ccid,
398 	   	(X_ROWID 		    => l_rowid,
399 		 X_CUST_TRX_LINE_GL_DIST_ID => l_trx_gl_dist_rec.cust_trx_line_gl_dist_id,
400 		 X_RECEIVABLES_CCID	    => l_ccid,
402 		 X_MODE			    => 'R');
403 
404            -- ========================= FND LOG ===========================
405            psa_utils.debug_other_string(g_state_level,l_full_path,
406 	                                 ' Generate_trx_dist --> PSA_MFAR_TRANSACTION_COVER_PKG.INSERT_ROW ');
407            -- ========================= FND LOG ===========================
408 
409 	END LOOP;
410 	CLOSE c_trx_gl_dist;
411         retcode := 'S';
412         RETURN TRUE;
413 
414 EXCEPTION
415 	WHEN FLEX_BUILD_ERROR THEN
416 	  p_error_message := 'EXCEPTION - FLEX_BUILD_ERROR PACKAGE - PSA_MFAR_TRANSACTIONS.GENERATE_TRX_DIST: '||FND_MESSAGE.GET;
417 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
418 	                                            g_cust_trx_id, Null, p_error_message);
419           retcode := 'F';
420           -- ========================= FND LOG ===========================
421           psa_utils.debug_other_string(g_excep_level,l_full_path,p_error_message);
422           -- ========================= FND LOG ===========================
423           RETURN FALSE;
424 
425 	WHEN OTHERS THEN
426           p_error_message := 'EXCEPTION - WHEN OTHERS - PSA_MFAR_TRANSACTIONS.GENERATE_TRX_DIST: '|| SQLERRM;
427 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
428 	                                            g_cust_trx_id, Null, p_error_message);
429           retcode := 'F';
430           -- ========================= FND LOG ===========================
431           psa_utils.debug_other_string(g_excep_level,l_full_path,p_error_message);
432           psa_utils.debug_unexpected_msg(l_full_path);
433           -- ========================= FND LOG ===========================
434 	  RETURN FALSE;
435 
436 END generate_trx_dist;
437 
438  /****************************************** TRANSCTION_IS_COMPLETE ****************************************/
439 
440 FUNCTION transaction_is_complete RETURN BOOLEAN IS
441 
442    CURSOR c_trx_complete
443    IS
444       SELECT complete_flag
445       FROM   ra_customer_trx_all
446       WHERE  customer_trx_id = g_cust_trx_id;
447 
448       l_trx_complete_rec	c_trx_complete%rowtype;
449       -- ========================= FND LOG ===========================
450       l_full_path VARCHAR2(100) := g_path || 'transaction_is_complete';
451       -- ========================= FND LOG ===========================
452 
453 BEGIN
454 
455      OPEN  c_trx_complete;
456      FETCH c_trx_complete INTO l_trx_complete_rec;
457      CLOSE c_trx_complete;
458 
459      IF l_trx_complete_rec.complete_flag = 'Y' THEN
460         -- ========================= FND LOG ===========================
461         psa_utils.debug_other_string(g_state_level,l_full_path,' Transaction_is_complete -->  return TRUE');
462         -- ========================= FND LOG ===========================
463   	RETURN TRUE;
464      ELSE
465         -- ========================= FND LOG ===========================
466         psa_utils.debug_other_string(g_state_level,l_full_path,' Transaction_is_complete -->  return FALSE');
467         -- ========================= FND LOG ===========================
468      	RETURN FALSE;
469      END IF;
470 
471 EXCEPTION
472 	WHEN OTHERS THEN
473 	  l_exception_error := 'EXCEPTION - OTHERS PACKAGE - PSA_MFAR_TRANSACTIONS.TRANSACTION_IS_COMPLETE: '
474 	                          || SQLERRM;
475 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION', g_cust_trx_id, Null,
476 	  					   l_exception_error);
477           -- ========================= FND LOG ===========================
478           psa_utils.debug_other_string(g_excep_level,l_full_path,l_exception_error);
479           psa_utils.debug_unexpected_msg(l_full_path);
480           -- ========================= FND LOG ===========================
481           RETURN FALSE;
482 
483 END transaction_is_complete;
484 
485  /****************************************** TRANSACTION_MODIFIED ****************************************/
486 
487 FUNCTION transaction_modified RETURN BOOLEAN IS
488 
489 	CURSOR c_core_trx_count IS
490 		SELECT 	count(cust_trx_line_gl_dist_id) core_count
491 		  FROM 	ra_cust_trx_line_gl_dist_all
492 		 WHERE 	customer_trx_id  = g_cust_trx_id
493 		   AND 	account_class <> 'REC';
494 
495 	CURSOR c_mf_trx_count IS
496 		SELECT	count(B.cust_trx_line_gl_dist_id) mf_dist_count
497 		  FROM 	ra_cust_trx_line_gl_dist_all 	A,
498 		  	psa_mf_trx_dist_all 		B
499 		 WHERE 	A.cust_trx_line_gl_dist_id	= B.cust_trx_line_gl_dist_id
500 		   AND 	A.customer_trx_id		= g_cust_trx_id;
501 
502 	l_core_count	NUMBER;
503 	l_mf_dist_count NUMBER;
504         -- ========================= FND LOG ===========================
505         l_full_path VARCHAR2(100) := g_path || 'transaction_modified';
506         -- ========================= FND LOG ===========================
507 BEGIN
508 	OPEN  c_core_trx_count;
509 	FETCH c_core_trx_count INTO l_core_count;
510 	CLOSE c_core_trx_count;
511 
512         -- ========================= FND LOG ===========================
513         psa_utils.debug_other_string(g_state_level,l_full_path,
514 	                              ' Transaction_modified --> l_core_count --> ' || l_core_count);
515         -- ========================= FND LOG ===========================
516 
517 	OPEN  c_mf_trx_count;
518 	FETCH c_mf_trx_count INTO l_mf_dist_count;
519 	CLOSE c_mf_trx_count;
520 
521         -- ========================= FND LOG ===========================
522         psa_utils.debug_other_string(g_state_level,l_full_path,
523 	                              ' Transaction_modified --> l_mf_dist_count --> ' || l_mf_dist_count);
524         -- ========================= FND LOG ===========================
525 
526         -- Bug 3671841, Delete statement commented and now placed in PSAMFG2B.pls
527         /*
528 	DELETE FROM psa_mf_trx_dist_all
529 	WHERE  cust_trx_line_gl_dist_id Not In
530 	 ( SELECT cust_trx_line_gl_dist_id FROM ra_cust_trx_line_gl_dist_all );
531         */
532 
533         -- ========================= FND LOG ===========================
534         psa_utils.debug_other_string(g_state_level,l_full_path,
535 	                              ' Transaction_modified --> delete psa_mf_trx_dist_all --> '
536 				      || SQL%ROWCOUNT);
537         -- ========================= FND LOG ===========================
538 
539 	IF l_core_count <> l_mf_dist_count THEN
540 	   RETURN TRUE;
541 	ELSE
542 	   RETURN FALSE;
543 	END IF;
544 
545 EXCEPTION
546 	WHEN OTHERS THEN
547 	  l_exception_error := 'EXCEPTION - OTHERS PACKAGE - PSA_MFAR_TRANSACTIONS.TRANSACTION_MODIFIED: '
548 	                         || SQLERRM;
549 	  PSA_MFAR_UTILS.INSERT_DISTRIBUTIONS_LOG (g_run_id, 'TRANSACTION',
550 	                                            g_cust_trx_id, Null,l_exception_error);
551           -- ========================= FND LOG ===========================
552           psa_utils.debug_other_string(g_excep_level,l_full_path,l_exception_error);
553           psa_utils.debug_unexpected_msg(l_full_path);
554           -- ========================= FND LOG ===========================
555 	  RETURN FALSE;
556 
557 END  transaction_modified;
558 
559 END PSA_MFAR_TRANSACTIONS;