DBA Data[Home] [Help]

PACKAGE BODY: APPS.JG_GLOBE_FLEX_VAL

Source


1 PACKAGE BODY JG_GLOBE_FLEX_VAL AS
2 /* $Header: jggdfvb.pls 120.23.12020000.6 2013/02/22 10:37:08 abhijsar ship $ */
3 
4 
5   ------------------------------------------------------------------
6   --                                                             ---
7   --                      PRIVATE section                        ---
8   --                                                             ---
9   ------------------------------------------------------------------
10 
11   --
12   -- Table Type Defintion to Store Flexfield Name and Context Code.
13   --
14   TYPE ContextList IS TABLE OF VARCHAR2(70) INDEX BY BINARY_INTEGER;
15 
16   --
17   -- Global Variable Definition
18   --
19   g_context_tab  ContextList;              -- Context Code Table
20   g_table_size   BINARY_INTEGER DEFAULT 0; -- Table Size
21 
22   --
23   -- Find
24   --
25   -- PURPOSE
26   -- Find index of flexfield and context code combination.
27   --
28   -- RETURN
29   -- Table index if found, g_table_size if not found.
30   --
31 --  PG_DEBUG varchar2(1) := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
32 
33 -- Bug 8859419 Start
34 
35    G_CURRENT_RUNTIME_LEVEL     NUMBER       := FND_LOG.G_CURRENT_RUNTIME_LEVEL;
36    G_LEVEL_UNEXPECTED CONSTANT NUMBER       := FND_LOG.LEVEL_UNEXPECTED;
37    G_LEVEL_ERROR      CONSTANT NUMBER       := FND_LOG.LEVEL_ERROR;
38    G_LEVEL_EXCEPTION  CONSTANT NUMBER       := FND_LOG.LEVEL_EXCEPTION;
39    G_LEVEL_EVENT      CONSTANT NUMBER       := FND_LOG.LEVEL_EVENT;
40    G_LEVEL_PROCEDURE  CONSTANT NUMBER       := FND_LOG.LEVEL_PROCEDURE;
41    G_LEVEL_STATEMENT  CONSTANT NUMBER       := FND_LOG.LEVEL_STATEMENT;
42    G_MODULE_NAME      CONSTANT VARCHAR2(50) := 'JG.PLSQL.JG_GLOBE_FLEX_VAL';
43 
44 -- Bug 8859419 End
45 
46   FUNCTION find
47        (p_flexfield_and_context IN VARCHAR2) RETURN BINARY_INTEGER IS
48 
49     l_flex_and_context  VARCHAR2(70);
50     l_table_index       BINARY_INTEGER;
51     l_found             BOOLEAN;
52 
53   BEGIN
54     l_flex_and_context := p_flexfield_and_context;
55     l_table_index := 0;
56     l_found     := FALSE;
57 
58     WHILE (l_table_index < g_table_size) AND (NOT l_found) LOOP
59       IF g_context_tab(l_table_index) = l_flex_and_context THEN
60         l_found := TRUE;
61 
62       ELSE
63         l_table_index := l_table_index + 1;
64       END IF;
65     END LOOP;
66 
67     RETURN l_table_index;
68 
69   END find;
70 
71   --
72   -- Is_Defined
73   --
74   -- PURPOSE
75   -- Check if a context code is defined.
76   --
77   -- RETURN
78   -- TRUE if the context code is defined.
79   --
80   FUNCTION is_defined
81        (p_flexfield_name   IN  VARCHAR2,
82         p_context_code     IN  VARCHAR2) RETURN BOOLEAN IS
83 
84     l_context_code   VARCHAR2(30);
85 
86     CURSOR c_context IS
87       SELECT fc.descriptive_flex_context_code
88       FROM fnd_descr_flex_contexts fc
89       WHERE fc.application_id = 7003
90       AND fc.descriptive_flex_context_code = p_context_code
91       AND fc.descriptive_flexfield_name = p_flexfield_name
92       AND fc.enabled_flag = 'Y';
93 
94   BEGIN
95     OPEN c_context;
96     FETCH c_context INTO l_context_code;
97     IF (c_context%NOTFOUND) THEN
98       RETURN  FALSE;
99     ELSE
100       RETURN  TRUE;
101 
102     END IF;
103 
104     CLOSE c_context;
105 
106   END is_defined;
107 
108   --
109   -- Check_Mixed_Countries():
110   --
111   -- PURPOSE
112   -- Check if a context code is valid.
113   --
114   -- RETURN
115   --  Error Code if a context code is invalid.
116   --
117   FUNCTION check_mixed_countries
118        (p_category1        IN VARCHAR2,
119         p_category2        IN VARCHAR2,
120         p_category3        IN VARCHAR2) RETURN VARCHAR2 IS
121 
122     l_country1    VARCHAR2(5);
123     l_country2    VARCHAR2(5);
124     l_country3    VARCHAR2(5);
125     l_errcode     VARCHAR2(3);
126 
127   BEGIN
128     l_country1    := SUBSTRB(p_category1,1,5);
129     l_country2    := SUBSTRB(p_category2,1,5);
130     l_country3    := SUBSTRB(p_category3,1,5);
131     l_errcode     := NULL;
132     --
133     -- When 2 or more out of 3 countries are null:
134 
135     --
136     IF (l_country1 IS NULL AND l_country2 IS NULL) OR
137        (l_country1 IS NULL AND l_country3 IS NULL) OR
138        (l_country2 IS NULL AND l_country3 IS NULL)
139     THEN
140       RETURN (l_errcode);
141     END IF;
142     --
143     -- When one or none out of 3 countries is null:
144     --
145     IF (l_country1 = l_country2 AND l_country1 = l_country3) OR
146        (l_country1 = l_country2 AND l_country3 IS NULL) OR
147        (l_country1 = l_country3 AND l_country2 IS NULL) OR
148        (l_country2 = l_country3 AND l_country1 IS NULL)
149     THEN
150         RETURN (l_errcode);
151     END IF;
152 
153     --
154     -- Return the error code in case of invalid context code
155     --
156     l_errcode := 't4,';
157     RETURN (l_errcode);
158 
159   END check_mixed_countries;
160 
161   ---------------------------------------------------------------------------
162   --    CHECK_ATTR_EXISTS():
163   --       Check if GLOBAL_ATTRIBUTE(n) has NOT NULL value to indicate if
164   --       global flexfield has a value.
165   ---------------------------------------------------------------------------
166   FUNCTION check_attr_exists
167        (p_global_attribute_category  IN    VARCHAR2,
168         p_global_attribute1          IN    VARCHAR2,
169         p_global_attribute2          IN    VARCHAR2,
170         p_global_attribute3          IN    VARCHAR2,
171         p_global_attribute4          IN    VARCHAR2,
172         p_global_attribute5          IN    VARCHAR2,
173         p_global_attribute6          IN    VARCHAR2,
174         p_global_attribute7          IN    VARCHAR2,
175         p_global_attribute8          IN    VARCHAR2,
176         p_global_attribute9          IN    VARCHAR2,
177         p_global_attribute10         IN    VARCHAR2,
178         p_global_attribute11         IN    VARCHAR2,
179         p_global_attribute12         IN    VARCHAR2,
180         p_global_attribute13         IN    VARCHAR2,
181         p_global_attribute14         IN    VARCHAR2,
182         p_global_attribute15         IN    VARCHAR2,
183         p_global_attribute16         IN    VARCHAR2,
184         p_global_attribute17         IN    VARCHAR2,
185         p_global_attribute18         IN    VARCHAR2,
186         p_global_attribute19         IN    VARCHAR2,
187         p_global_attribute20         IN    VARCHAR2) RETURN BOOLEAN IS
188 
189   BEGIN
190     IF (p_global_attribute1  IS NOT NULL) or
191        (p_global_attribute2  IS NOT NULL) or
192        (p_global_attribute3  IS NOT NULL) or
193        (p_global_attribute4  IS NOT NULL) or
194        (p_global_attribute5  IS NOT NULL) or
195        (p_global_attribute6  IS NOT NULL) or
196        (p_global_attribute7  IS NOT NULL) or
197        (p_global_attribute8  IS NOT NULL) or
198        (p_global_attribute9  IS NOT NULL) or
199        (p_global_attribute10 IS NOT NULL) or
200        (p_global_attribute11 IS NOT NULL) or
201        (p_global_attribute12 IS NOT NULL) or
202        (p_global_attribute13 IS NOT NULL) or
203        (p_global_attribute14 IS NOT NULL) or
204        (p_global_attribute15 IS NOT NULL) or
205        (p_global_attribute16 IS NOT NULL) or
206        (p_global_attribute17 IS NOT NULL) or
207        (p_global_attribute18 IS NOT NULL) or
208        (p_global_attribute19 IS NOT NULL) or
209        (p_global_attribute20 IS NOT NULL) THEN
210 
211       IF p_global_attribute_category IS NOT NULL THEN  -- Check if at least one
212          return(TRUE);                                 -- attributes is NOT NULL
213       ELSE
214          return(FALSE);
215       END IF;
216 
217     ELSE
218         return(TRUE);
219 
220     END IF;
221   END check_attr_exists;
222 
223   --
224   -- Modified version of check_attr_exists
225   --
226   FUNCTION check_attr_exists
227        (p_glob_attr_set IN  jg_globe_flex_val_shared.GdfRec) RETURN BOOLEAN IS
228 
229   BEGIN
230     IF (p_glob_attr_set.global_attribute1  IS NOT NULL) or
231        (p_glob_attr_set.global_attribute2  IS NOT NULL) or
232        (p_glob_attr_set.global_attribute3  IS NOT NULL) or
233        (p_glob_attr_set.global_attribute4  IS NOT NULL) or
234        (p_glob_attr_set.global_attribute5  IS NOT NULL) or
235        (p_glob_attr_set.global_attribute6  IS NOT NULL) or
236        (p_glob_attr_set.global_attribute7  IS NOT NULL) or
237        (p_glob_attr_set.global_attribute8  IS NOT NULL) or
238        (p_glob_attr_set.global_attribute9  IS NOT NULL) or
239        (p_glob_attr_set.global_attribute10 IS NOT NULL) or
240        (p_glob_attr_set.global_attribute11 IS NOT NULL) or
241        (p_glob_attr_set.global_attribute12 IS NOT NULL) or
242        (p_glob_attr_set.global_attribute13 IS NOT NULL) or
243        (p_glob_attr_set.global_attribute14 IS NOT NULL) or
244        (p_glob_attr_set.global_attribute15 IS NOT NULL) or
245        (p_glob_attr_set.global_attribute16 IS NOT NULL) or
246        (p_glob_attr_set.global_attribute17 IS NOT NULL) or
247        (p_glob_attr_set.global_attribute18 IS NOT NULL) or
248        (p_glob_attr_set.global_attribute19 IS NOT NULL) or
249        (p_glob_attr_set.global_attribute20 IS NOT NULL) THEN
250 
251       IF p_glob_attr_set.global_attribute_category IS NOT NULL THEN
252          return(TRUE);
253       ELSE
254          return(FALSE);
255       END IF;
256 
257     ELSE
258         return(TRUE);
259 
260     END IF;
261   END check_attr_exists;
262   --
263   -- End of modification
264   --
265 
266   ---------------------------------------------------------------------------
267   --  CHECK_CONTEXT_CODE():
268   --     Check if specified GLOBAL_ATTRIBUTE_CATEGORY has a valid context
269   --     code definition of the flexfield.
270   --     P_CALLING_PROGRAM_NAME is the program name from which this procedure
271   --     The logic is based on the assumption that before the invoices are
272   --     uploaded from the flat file, the global_attribute columns are mapped
273   --     correctly as per the pre seeded data for the global flexfields.
274   --
275   --     There is no global flexfield in Invoice Gateway of R11i for Korea,
276   --     China, and Canada, so comment out for their context.
277   ---------------------------------------------------------------------------
278   FUNCTION check_context_code(
279       p_calling_program_name    IN    VARCHAR2,
280       p_context_code            IN    VARCHAR2) RETURN BOOLEAN IS
281 
282     --
283     -- Following variables are used in AR validation
284     -- Note: Default value of l_flexfield_name is p_calling_program_name.
285     --       It looks confusing but in case of AR Flexfield name is passed to
286     --       p_calling_program_name
287     --
288     l_table_index      BINARY_INTEGER;
289     l_defined          BOOLEAN;
290     l_flexfield_name   VARCHAR2(40);
291     l_context_code     VARCHAR2(30);
292     l_flex_and_context VARCHAR2(70);
293 
294 
295   BEGIN
296     l_flexfield_name   := p_calling_program_name;
297     l_context_code     := p_context_code;
298     --
299     -- AP global flexflield contexts.
300     --
301     -- Bug 16070012 Start
302     If fv_install.enabled Then
303          RETURN(TRUE);
304     End If;
305     -- Bug 16070012 Start
306     IF p_calling_program_name = 'APXIIMPT' THEN --Invoice Gatewayvalidation prog
307       IF p_context_code IN ('JA.TH.APXIISIM.INVOICES_INTF',
308                             'JA.TW.APXIISIM.INVOICES_FOLDER',
309                             'JA.SG.APXIISIM.INVOICES_FOLDER',
310     --                      'JA.KR.APXIISIM.INVOICES_FOLDER',
311                             'JA.CN.APXIISIM.INVOICES_FOLDER', --Uncommented as per bug#13580187
312     --                      'JA.KR.APXIISIM.LINES_FOLDER',
313     --                      'JA.CA.APXIISIM.LINES_FOLDER',
314                             'JA.IN.APXINWKB.DISTRIBUTIONS',  --Added for bug #14679875
315                             'JE.BE.APXIISIM.EFT',
316                             'JE.CH.APXIISIM.DTA',
317                             'JE.CH.APXIISIM.SAD',
318                             'JE.DK.APXIISIM.EDI_INFO',
319                             'JE.DK.APXIISIM.GIRO_DOMESTIC',
320                             'JE.DK.APXIISIM.GIRO_FOREIGN',
321                             'JE.DK.APXIISIM.UNIT_DOMESTIC',
322                             'JE.DK.APXIISIM.UNIT_FOREIGN',
323                             'JE.ES.APXIISIM.MODELO349',
324                             'JE.ES.APXIISIM.MODELO347',
325                             'JE.ES.APXIISIM.MODELO347PR',
326                             'JE.ES.APXIISIM.OTHER',
327                             'JE.FI.APXIISIM.A_LOMAKE',
328                             'JE.FI.APXIISIM.B_LOMAKE',
329                             'JE.FI.APXIISIM.KKL_VIITE',
330                             'JE.FI.APXIISIM.VAPAA_VIITE',
331                             'JE.FR.APXIISIM.TAX_RULE',
332                             'JE.NL.APXIISIM.FOREIGN',
333                             'JE.NO.APXIISIM.NORWAY',
334                             'JE.SE.APXIISIM.BANK_SISU',
335                             'JE.SE.APXIISIM.BANK_UTLI',
336                             'JE.SE.APXIISIM.BANK_INLAND',
337                             'JE.SE.APXIISIM.POST_INLAND',
338                             'JE.SE.APXIISIM.POST_UTLAND',
339                             'JE.CZ.APXIISIM.INVOICE_INFO',
340                             'JE.HU.APXIISIM.TAX_DATE',
341                             'JE.PL.APXIISIM.INVOICE_INFO',
342                           --'JE.HU.APXIISIM.STAT_CODE',
343                           --'JE.PL.APXIISIM.STAT_CODE',
344                             'JE.IL.APXIISIM.INVOICE_INFO',
345                             'JE.IL.APXIISIM.IMPORT_DOC',
346                             'JL.AR.APXIISIM.INVOICES_FOLDER',
347                             'JL.AR.APXIISIM.LINES_FOLDER',
348        'JL.CO.APXIISIM.INVOICES_FOLDER', -- Added for Bug3233307
349                             'JL.CO.APXIISIM.LINES_FOLDER',
350                             'JL.BR.APXIISIM.INVOICES_FOLDER',
351                             'JL.BR.APXIISIM.LINES_FOLDER',
352                             'JE.IT.APXIISIM.DISTRIBUTIONS',
353                             'JL.CL.APXIISIM.INVOICES_FOLDER',
354 
355  		-- Added as the part of ECE Enhancement --
356 
357         	            'JE.SK.APXIISIM.INVOICE_INFO',
358 		            'JE.CZ.APXIISIM.FINAL',
359                             'JE.HU.APXIISIM.FINAL',
360                             'JE.PL.APXIISIM.FINAL',
361                             'JE.SK.APXIISIM.FINAL',
362                             'JE.PL.APXIISIM.INSURANCE_INFO',
363 
364        	-- Added as the part of RLP Enhancement bug 5741915 --
365 
366         --BUG:9237440 start
367 			    --'JE.RU.APXINWKB.XXRL_INVOICE',
368 			    --'JE.RU.APXINWKB.XXRL_SUM_DIF',
369 			    --'JE.RU.APXINWKB.XXRL_DISTRIBUT',
370 			    'JE.RU.APXIISIM.XXRL_INVOICE',
371 			    'JE.RU.APXIISIM.XXRL_SUM_DIF',
372 			    'JE.RU.APXIISIM.XXRL_DISTRIBUT'
373 	--BUG:9237440 End
374                            )
375 
376       THEN
377          RETURN(TRUE);
378       ELSE
379       -- Bug 9482539 -- Start
380            l_flex_and_context := l_flexfield_name || l_context_code;
381 
382            --
383            --  Search index for a context code.
384            --
385            l_table_index := find(l_flex_and_context);
386 
387            IF l_table_index < g_table_size THEN
388                RETURN (TRUE);
389            ELSE
390               l_defined := is_defined(l_flexfield_name, l_context_code);
391                  IF (l_defined) THEN
392                      g_context_tab(g_table_size) := l_flexfield_name || l_context_code;
393                      g_table_size := g_table_size + 1;
394                      RETURN (TRUE);
395                  ELSE
396                      RETURN (FALSE);
397                 END IF;
398           END IF;
399       -- Bug 9482539 -- End
400       END IF;
401 
402 --Changed to the new HZ flexfield definitions
403      /* ELSIF (p_calling_program_name = 'JG_RA_CUSTOMERS') OR
404           (p_calling_program_name = 'JG_RA_ADDRESSES') OR
405           (p_calling_program_name = 'JG_RA_SITE_USES') OR
406           (p_calling_program_name = 'JG_AR_CUSTOMER_PROFILES') OR
407           (p_calling_program_name = 'JG_AR_CUSTOMER_PROFILE_AMOUNTS')THEN
408     */
409     ELSIF (p_calling_program_name = 'JG_HZ_CUST_ACCOUNTS') OR
410           (p_calling_program_name = 'JG_HZ_CUST_ACCT_SITES') OR
411           (p_calling_program_name = 'JG_HZ_CUST_SITE_USES') OR
412           (p_calling_program_name = 'JG_HZ_CUSTOMER_PROFILES') OR
413           (p_calling_program_name = 'JG_HZ_CUST_PROFILE_AMTS')THEN
414 
415       --
416       -- 1. Search combination of flexfield and context code in PL/SQL Table.
417       -- 2. If it's not stored in PL/SQL Table,check if the combination is valid
418       -- 3. If the combination is valid, add it to the PL/SQL Table and return
419       --    TRUE. Otherwise, return FALSE.
420       --
421 
422       --
423       --  Concatenate Flexfield and Context Code  to check if
424       --  the combination is valid.
425       --
426       l_flex_and_context := l_flexfield_name || l_context_code;
427 
428       --
429       --  Search index for a context code.
430       --
431       l_table_index := find(l_flex_and_context);
432 
433       IF l_table_index < g_table_size THEN
434         RETURN (TRUE);
435 
436       ELSE
437         l_defined := is_defined(l_flexfield_name, l_context_code);
438         IF (l_defined) THEN
439           g_context_tab(g_table_size) := l_flexfield_name || l_context_code;
440           g_table_size := g_table_size + 1;
441           RETURN (TRUE);
442 
443         ELSE
444           RETURN (FALSE);
445 
446         END IF;
447       END IF;
448     --
449     -- End of AR validation.
450     --
451 
452     --
453     -- Other Products such as FA, etc.  ADD NEW ENTRY IF NECESSARY.
454     --
455     ELSE
456       RETURN(FALSE);
457 
458     END IF;
459   END check_context_code;
460 
461   FUNCTION check_each_gdf(p_flexfield_name   VARCHAR2,
462                            p_glob_attr_set   jg_globe_flex_val_shared.GdfRec,
463                            p_glob_attr_gen   jg_globe_flex_val_shared.GenRec)
464  RETURN VARCHAR2 IS
465 
466  l_errcode VARCHAR2(10) DEFAULT NULL;
467 
468   BEGIN
469      IF check_attr_exists(p_glob_attr_set) <> TRUE THEN
470         --
471         -- Store the error code to be returned
472         --
473                 l_errcode := 'i1,';
474 
475      END IF;
476 
477      IF p_glob_attr_set.global_attribute_category IS NOT NULL THEN
478         IF check_context_code(p_flexfield_name,
479                        p_glob_attr_set.global_attribute_category) <> TRUE THEN
480           --
481           --  Concatenate the error code to be returned
482           --
483           -- Changed to refer to the new flexfield definitions
484 
485           --IF p_flexfield_name ='JG_RA_CUSTOMERS' THEN
486            IF p_flexfield_name = 'JG_HZ_CUST_ACCOUNTS' THEN
487                 l_errcode := l_errcode||'i2,';
488 
489           --ELSIF p_flexfield_name = 'JG_RA_ADDRESSES' THEN
490             ELSIF p_flexfield_name = 'JG_HZ_CUST_ACCT_SITES' THEN
491                 l_errcode := l_errcode||'n1,';
492 
493    --ELSIF p_flexfield_name = 'JG_RA_SITE_USES' THEN
494           ELSIF p_flexfield_name = 'JG_HZ_CUST_SITE_USES' THEN
495                 l_errcode := l_errcode||'p2,';
496 
497          -- ELSIF p_flexfield_name = 'JG_AR_CUSTOMER_PROFILES' THEN
498           ELSIF p_flexfield_name = 'JG_HZ_CUSTOMER_PROFILES' THEN
499                 l_errcode := l_errcode||'r3,';
500 
501           --ELSIF p_flexfield_name = 'JG_AR_CUSTOMER_PROFILE_AMOUNTS' THEN
502           ELSIF p_flexfield_name = 'JG_HZ_CUST_PROFILE_AMTS' THEN
503                 l_errcode := l_errcode||'i2,';
504 
505           END IF;
506        END IF;
507      END IF;
508 
509   --
510   -- Return the concatenated error code
511   --
512   return(l_errcode);
513 
514   END check_each_gdf;
515 
516   ---------------------------------------------------------------------------
517   --                                                                      ---
518   --                           PUBLIC section                             ---
519   --                                                                      ---
520   ---------------------------------------------------------------------------
521 
522   ---------------------------------------------------------------------------
523   --    REASSIGN_CONTEXT_CODE():
524   --       Reassign global_attribute_category before transfering data
525   --       from interface tables
526   --
527   -- Prod         Current Code             ->          Target Code
528   ---------------------------------------------------------------------------
529   --  AP    JA.CN.APXIISIM.INVOICES_FOLDER     JA.CN.APXINWKB.INVOICES
530   --  AP    JA.KR.APXIISIM.INVOICES_FOLDER     JA.KR.APXINWKB.AP_INVOICES
531   --  AP    JA.TH.APXIISIM.INVOICES_INTF       JA.TH.APXINWKB.INVOICES
532   --  AP    JA.TW.APXIISIM.INVOICES_FOLDER     JA.TW.APXINWKB.INVOICES
533   --  AP    JA.SG.APXIISIM.INVOICES_FOLDER     JA.TW.APXINWKB.INVOICES
534   --  AP    JA.KR.APXIISIM.LINES_FOLDER        JA.KR.APXINWKB.INVOICE_DISTR
535   --  AP    JA.CA.APXIISIM.LINES_FOLDER        JA.CA.APXINWKB.INVOICE_DISTR
536   --
537   --  AP    JE.BE.APXIISIM.EFT                BE.EFT Payments
538   --  AP    JE.CH.APXIISIM.DTA                CH.Swiss DTA Payment
539   --  AP    JE.CH.APXIISIM.SAD                CH.Swiss SAD Payment
540   --  AP    JE.DK.APXIISIM.EDI_INFO           JE.DK.APXINWKB.EDI_INFO
541   --  AP    JE.DK.APXIISIM.GIRO_DOMESTIC      DK.GiroBank Domestic
542   --  AP    JE.DK.APXIISIM.GIRO_FOREIGN       DK.GiroBank Foreign
543   --  AP    JE.DK.APXIISIM.UNIT_DOMESTIC      DK.Unitel Domestic
544   --  AP    JE.DK.APXIISIM.UNIT_FOREIGN       DK.Unitel Foreign
545   --  AP    JE.FI.APXIISIM.A_LOMAKE           FI.A-lomake
546   --  AP    JE.FI.APXIISIM.B_LOMAKE           FI.B-lomake
547   --  AP    JE.FI.APXIISIM.KKL_VIITE          FI.Konekielinen viite
548   --  AP    JE.FI.APXIISIM.VAPAA_VIITE        FI.Vapaa viite
549   --  AP    JE.NL.APXIISIM.FOREIGN            NL.Foreign Payments
550   --  AP    JE.NO.APXIISIM.NORWAY             NO.Norway
551   --  AP    JE.SE.APXIISIM.BANK_SISU          SE.Bankgiro SISU
552   --  AP    JE.SE.APXIISIM.BANK_UTLI          SE.Bankgiro UTLI
553   --  AP    JE.SE.APXIISIM.POST_INLAND        SE.Postgiro Inland
554   --  AP    JE.SE.APXIISIM.POST_UTLAND        SE.Postgiro Utland
555   --  AP    JE.SE.APXIISIM.BANK_INLAND        SE.Bankgiro Inland
556   --  AP    JE.CZ.APXIISIM.INVOICE_INFO      JE.CZ.APXINWKB.INVOICE_INFO
557   --  AP    JE.HU.APXIISIM.TAX_DATE          JE.HU.APXINWKB.TAX_DATE
558   --  AP    JE.PL.APXIISIM.INVOICE_INFO      JE.PL.APXINWKB.INVOICE_INFO
559   --  AP    JE.HU.APXIISIM.STAT_CODE         JE.HU.APXINWKB.STAT_CODE
560   --  AP    JE.PL.APXIISIM.STAT_CODE         JE.PL.APXINWKB.STAT_CODE
561   --  AP    JL.AR.APXIISIM.INVOICES_FOLDER   JL.AR.APXINWKB.INVOICES
562   --  AP    JL.AR.APXIISIM.LINES_FOLDER      JL.AR.APXINWKB.DISTRIBUTIONS
563   --  AP    JL.CO.APXIISIM.INVOICES_FOLDER   JL.CO.APXINWKB.INVOICES  -- Added for bug3233307
564   --  AP    JL.CO.APXIISIM.LINES_FOLDER      JL.CO.APXINWKB.DISTRIBUTIONS
565   --  AP    JL.BR.APXIISIM.INVOICES_FOLDER   JL.BR.APXINWKB.AP_INVOICES
566   --  AP    JL.BR.APXIISIM.LINES_FOLDER      JL.BR.APXINWKB.D_SUM_FOLDER
567   --  AP    JE.IT.APXIISIM.DISTRIBUTIONS     JE.IT.APXINWKB.DISTRIBUTIONS
568   --  AP    JL.CL.APXIISIM.INVOICES_FOLDER   JL.CL.APXINWKB.AP_INVOICES
569 
570  -- Added below as part of ECE Enhancement --
571 
572   --  AP    JE.SK.APXIISIM.INVOICE_INFO      JE.SK.APXINWKB.INVOICE_INFO
573   --  AP    JE.HU.APXIISIM.FINAL             JE.HU.APXINWKB.FINAL
574   --  AP    JE.PL.APXIISIM.FINAL             JE.PL.APXINWKB.FINAL
575   --  AP    JE.CZ.APXIISIM.FINAL         JE.CZ.APXINWKB.FINAL
576   --  AP    JE.SK.APXIISIM.FINAL         JE.SK.APXINWKB.FINAL
577   --  AP    JE.PL.APXIISIM.INSURANCE_INFO    JE.PL.APXINWKB.INSURANCE_INFO
578 
579   -- Added below as part of RLP Enhancement --
580 
581   --  AP    JE.RU.APXIISIM.XXRL_INVOICE      JE.RU.APXINWKB.XXRL_INVOICE
582   --  AP    JE.RU.APXIISIM.XXRL_SUM_DIF	     JE.RU.APXINWKB.XXRL_SUM_DIF
583   --  AP    JE.RU.APXIISIM.XXRL_DISTRIBUT    JE.RU.APXINWKB.XXRL_DISTRIBUT
584 
585   --  AP    JE.IL.APXIISIM.INVOICE_INFO      JE.IL.APXINWKB.INVOICE_INFO
586   --  AP    JE.IL.APXIISIM.IMPORT_DOC        JE.IL.APXINWKB.IMPORT_DOC
587 
588   --                   <<  ADD ADDITIONAL ENTRY HERE   >>
589   --
590   --     There is no global flexfield in Invoice Gateway of R11i for Korea,
591   --     China, and Canada, so comment out for their context.
592   --
593   ---------------------------------------------------------------------------
594   FUNCTION reassign_context_code(
595          p_global_context_code   IN OUT NOCOPY   VARCHAR2) RETURN BOOLEAN IS
596 
597   l_defined BOOLEAN;
598 
599   BEGIN
600     IF (p_global_context_code IS NULL) THEN
601       RETURN(TRUE);
602     ELSIF (p_global_context_code = 'JA.TH.APXIISIM.INVOICES_INTF') THEN
603       p_global_context_code := 'JA.TH.APXINWKB.INVOICES';
604       RETURN(TRUE);
605     ELSIF (p_global_context_code = 'JA.TW.APXIISIM.INVOICES_FOLDER') THEN
606       p_global_context_code := 'JA.TW.APXINWKB.INVOICES';
607       RETURN(TRUE);
608     ELSIF (p_global_context_code = 'JA.SG.APXIISIM.INVOICES_FOLDER') THEN
609       p_global_context_code := 'JA.SG.APXINWKB.INVOICES';
610       RETURN(TRUE);
611     ELSIF (p_global_context_code = 'JA.CN.APXIISIM.INVOICES_FOLDER') THEN -- Uncommented as per bug#13580187
612       p_global_context_code := 'JA.CN.APXINWKB.INVOICES'; -- Uncommented as per bug#13580187
613       RETURN(TRUE);  -- Uncommented as per bug#13580187
614   --  ELSIF (p_global_context_code = 'JA.KR.APXIISIM.INVOICES_FOLDER') THEN
615   --    p_global_context_code := 'JA.KR.APXINWKB.AP_INVOICES';
616   --    RETURN(TRUE);
617   --  ELSIF (p_global_context_code = 'JA.KR.APXIISIM.LINES_FOLDER') THEN
618   --    p_global_context_code := 'JA.KR.APXINWKB.INVOICE_DISTR';
619   --    RETURN(TRUE);
620   --  ELSIF (p_global_context_code = 'JA.CA.APXIISIM.LINES_FOLDER') THEN
621   --    p_global_context_code := 'JA.CA.APXINWKB.INVOICE_DISTR';
622   --    RETURN(TRUE);
623 
624   -- Added for RLP project
625   --BUG:9237440 modified the APXINWKB to APXIISIM in if condition for RU.
626     -- Bug 14101265 Start
627     ELSIF (p_global_context_code = 'JA.CN.APXIISIM.LINES_FOLDER') THEN
628       p_global_context_code := 'JA.CN.APXINWKB.DISTRIBUTIONS';
629       RETURN(TRUE);
630     -- Bug 14101265 End
631      ELSIF (p_global_context_code = 'JE.RU.APXIISIM.XXRL_INVOICE') THEN
632        p_global_context_code := 'JE.RU.APXINWKB.XXRL_INVOICE';
633        RETURN(TRUE);
634      ELSIF (p_global_context_code = 'JE.RU.APXIISIM.XXRL_SUM_DIF') THEN
635        p_global_context_code := 'JE.RU.APXINWKB.XXRL_SUM_DIF';
636        RETURN(TRUE);
637      ELSIF (p_global_context_code = 'JE.RU.APXIISIM.XXRL_DISTRIBUT') THEN
638        p_global_context_code := 'JE.RU.APXINWKB.XXRL_DISTRIBUT';
639        RETURN(TRUE);
640 
641     ELSIF (p_global_context_code = 'JE.BE.APXIISIM.EFT') THEN
642       p_global_context_code := 'BE.EFT Payments';
643       RETURN(TRUE);
644     ELSIF (p_global_context_code = 'JE.CH.APXIISIM.DTA') THEN
645       p_global_context_code := 'CH.Swiss DTA Payment';
646       RETURN(TRUE);
647     ELSIF (p_global_context_code = 'JE.CH.APXIISIM.SAD') THEN
648       p_global_context_code := 'CH.Swiss SAD Payment';
649       RETURN(TRUE);
650     ELSIF (p_global_context_code = 'JE.DK.APXIISIM.EDI_INFO') THEN
651       p_global_context_code := 'JE.DK.APXINWKB.EDI_INFO';
652       RETURN(TRUE);
653     ELSIF (p_global_context_code = 'JE.DK.APXIISIM.GIRO_DOMESTIC') THEN
654       p_global_context_code := 'DK.GiroBank Domestic';
655       RETURN(TRUE);
656     ELSIF (p_global_context_code = 'JE.DK.APXIISIM.GIRO_FOREIGN') THEN
657       p_global_context_code := 'DK.GiroBank Foreign';
658       RETURN(TRUE);
659     ELSIF (p_global_context_code = 'JE.DK.APXIISIM.UNIT_DOMESTIC') THEN
660       p_global_context_code := 'DK.Unitel Domestic';
661       RETURN(TRUE);
662     ELSIF (p_global_context_code = 'JE.DK.APXIISIM.UNIT_FOREIGN') THEN
663       p_global_context_code := 'DK.Unitel Foreign';
664       RETURN(TRUE);
665     ELSIF (p_global_context_code = 'JE.FI.APXIISIM.A_LOMAKE') THEN
666       p_global_context_code := 'FI.A-lomake';
667       RETURN(TRUE);
668     ELSIF (p_global_context_code = 'JE.FI.APXIISIM.B_LOMAKE') THEN
669       p_global_context_code := 'FI.B-lomake';
670       RETURN(TRUE);
671     ELSIF (p_global_context_code = 'JE.FI.APXIISIM.KKL_VIITE') THEN
672       p_global_context_code := 'FI.Konekielinen viite';
673       RETURN(TRUE);
674     ELSIF (p_global_context_code = 'JE.FI.APXIISIM.VAPAA_VIITE') THEN
675       p_global_context_code := 'FI.Vapaa viite';
676       RETURN(TRUE);
677     ELSIF (p_global_context_code = 'JE.NL.APXIISIM.FOREIGN') THEN
678       p_global_context_code := 'NL.Foreign Payments';
679       RETURN(TRUE);
680     ELSIF (p_global_context_code = 'JE.NO.APXIISIM.NORWAY') THEN
681       p_global_context_code := 'NO.Norway';
682       RETURN(TRUE);
683     ELSIF (p_global_context_code = 'JE.SE.APXIISIM.BANK_SISU') THEN
684       p_global_context_code := 'SE.Bankgiro SISU';
685       RETURN(TRUE);
686     ELSIF (p_global_context_code = 'JE.SE.APXIISIM.BANK_UTLI') THEN
687       p_global_context_code := 'SE.Bankgiro UTLI';
688       RETURN(TRUE);
689     ELSIF (p_global_context_code = 'JE.SE.APXIISIM.BANK_INLAND') THEN
690       p_global_context_code := 'SE.Bankgiro Inland';
691       RETURN(TRUE);
692     ELSIF (p_global_context_code = 'JE.SE.APXIISIM.POST_INLAND') THEN
693       p_global_context_code := 'SE.Postgiro Inland';
694       RETURN(TRUE);
695     ELSIF (p_global_context_code = 'JE.SE.APXIISIM.POST_UTLAND') THEN
696       p_global_context_code := 'SE.Postgiro Utland';
697       RETURN(TRUE);
698     ELSIF (p_global_context_code = 'JE.CZ.APXIISIM.INVOICE_INFO') THEN
699       p_global_context_code := 'JE.CZ.APXINWKB.INVOICE_INFO';
700       RETURN(TRUE);
701     ELSIF (p_global_context_code = 'JE.HU.APXIISIM.TAX_DATE') THEN
702       p_global_context_code := 'JE.HU.APXINWKB.TAX_DATE';
703       RETURN(TRUE);
704     ELSIF (p_global_context_code = 'JE.PL.APXIISIM.INVOICE_INFO') THEN
705       p_global_context_code := 'JE.PL.APXINWKB.INVOICE_INFO';
706       RETURN(TRUE);
707 
708 
709 -- Commeneted the below as part of the ECE Project
710 
711 /*
712     ELSIF (p_global_context_code = 'JE.HU.APXIISIM.STAT_CODE') THEN
713       p_global_context_code := 'JE.HU.APXINWKB.STAT_CODE';
714       RETURN(TRUE);
715     ELSIF (p_global_context_code = 'JE.PL.APXIISIM.STAT_CODE') THEN
716       p_global_context_code := 'JE.PL.APXINWKB.STAT_CODE';
717       RETURN(TRUE);    */
718 
719     ELSIF (p_global_context_code = 'JL.AR.APXIISIM.INVOICES_FOLDER') THEN
720       p_global_context_code:='JL.AR.APXINWKB.INVOICES';
721       RETURN(TRUE);
722     ELSIF (p_global_context_code ='JL.AR.APXIISIM.LINES_FOLDER') THEN
723            p_global_context_code := 'JL.AR.APXINWKB.DISTRIBUTIONS';
724            RETURN(TRUE);
725     -- Bug 3233307
726     ELSIF (p_global_context_code = 'JL.CO.APXIISIM.INVOICES_FOLDER') THEN
727            p_global_context_code:= 'JL.CO.APXINWKB.INVOICES';
728            RETURN(TRUE);
729     ELSIF (p_global_context_code = 'JL.CO.APXIISIM.LINES_FOLDER') THEN
730            p_global_context_code := 'JL.CO.APXINWKB.DISTRIBUTIONS';
731            RETURN(TRUE);
732     ELSIF (p_global_context_code = 'JL.BR.APXIISIM.INVOICES_FOLDER') THEN
733       p_global_context_code := 'JL.BR.APXINWKB.AP_INVOICES';
734       RETURN(TRUE);
735     ELSIF (p_global_context_code ='JL.BR.APXIISIM.LINES_FOLDER') THEN
736       p_global_context_code := 'JL.BR.APXINWKB.D_SUM_FOLDER';
737       RETURN(TRUE);
738     ELSIF (p_global_context_code ='JE.IT.APXIISIM.DISTRIBUTIONS') OR (p_global_context_code = 'JE.IT.APXINWKB.LINES') THEN
739       p_global_context_code := 'JE.IT.APXINWKB.LINES';
740       RETURN(TRUE);
741     ELSIF (p_global_context_code ='JE.ES.APXIISIM.MODELO349') THEN
742       p_global_context_code := 'JE.ES.APXINWKB.MODELO349';
743       RETURN(TRUE);
744     ELSIF (p_global_context_code ='JE.ES.APXIISIM.MODELO347') THEN
745       p_global_context_code := 'JE.ES.APXINWKB.MODELO347';
746       RETURN(TRUE);
747     ELSIF (p_global_context_code ='JE.ES.APXIISIM.OTHER') THEN
748       p_global_context_code := 'JE.ES.APXINWKB.OTHER';
749       RETURN(TRUE);
750     ELSIF (p_global_context_code ='JE.ES.APXIISIM.MODELO347PR') THEN
751       p_global_context_code := 'JE.ES.APXINWKB.MODELO347PR';
752       RETURN(TRUE);
753 
754      ELSIF (p_global_context_code ='JE.FR.APXIISIM.TAX_RULE') THEN
755       p_global_context_code := 'JE.FR.APXINWKB.TAX_RULE';
756       RETURN(TRUE);
757     ELSIF (p_global_context_code = 'JL.CL.APXIISIM.INVOICES_FOLDER') THEN
758       p_global_context_code:='JL.CL.APXINWKB.AP_INVOICES';
759       RETURN(TRUE);
760 
761  -- Added the below as part of the ECE Project
762 
763     ELSIF (p_global_context_code = 'JE.SK.APXIISIM.INVOICE_INFO') THEN
764       p_global_context_code := 'JE.SK.APXINWKB.INVOICE_INFO';
765       RETURN(TRUE);
766     ELSIF (p_global_context_code = 'JE.PL.APXIISIM.INSURANCE_INFO') THEN
767       p_global_context_code := 'JE.PL.APXINWKB.INSURANCE_INFO';
768       RETURN(TRUE);
769     ELSIF (p_global_context_code = 'JE.HU.APXIISIM.FINAL') THEN
770       p_global_context_code := 'JE.HU.APXINWKB.FINAL';
771       RETURN(TRUE);
772     ELSIF (p_global_context_code = 'JE.PL.APXIISIM.FINAL') THEN
773       p_global_context_code := 'JE.PL.APXINWKB.FINAL';
774       RETURN(TRUE);
775     ELSIF (p_global_context_code = 'JE.CZ.APXIISIM.FINAL') THEN
776       p_global_context_code := 'JE.CZ.APXINWKB.FINAL';
777       RETURN(TRUE);
778     ELSIF (p_global_context_code = 'JE.SK.APXIISIM.FINAL') THEN
779       p_global_context_code := 'JE.SK.APXINWKB.FINAL';
780       RETURN(TRUE);
781     ELSIF (p_global_context_code = 'JE.IL.APXIISIM.INVOICE_INFO') THEN
782       p_global_context_code := 'JE.IL.APXINWKB.INVOICE_INFO';
783       RETURN(TRUE);
784     ELSIF (p_global_context_code = 'JE.IL.APXIISIM.IMPORT_DOC') THEN
785       p_global_context_code := 'JE.IL.APXINWKB.IMPORT_DOC';
786       RETURN(TRUE);
787     ELSIF  (p_global_context_code = 'JL.MX.FAXMADDS.FA_MASS_ADD') THEN
788 	p_global_context_code := 'JL.MX.FAXMADDS.FA_MASS_ADD';
789       --p_global_context_code := 'JL.MX.FAXASSET.ADDITIONS_ADD';
790       RETURN(TRUE);
791     ELSIF  (p_global_context_code = 'JL.AR.FAXMADDS.FA_MASS_ADD') THEN
792       p_global_context_code := 'JL.AR.FAXMADDS.FA_MASS_ADD';
793      -- p_global_context_code := 'JL.AR.FAXASSET.ADDITIONS_ADD';
794       RETURN(TRUE);
795     ELSIF  (p_global_context_code = 'JL.CL.FAXMADDS.FA_MASS_ADD') THEN
796       p_global_context_code := 'JL.CL.FAXMADDS.FA_MASS_ADD';
797       --p_global_context_code := 'JL.CL.FAXASSET.ADDITIONS_ADD';
798       RETURN(TRUE);
799     ELSIF  (p_global_context_code = 'JL.CO.FAXMADDS.FA_MASS_ADD') THEN
800       p_global_context_code := 'JL.CO.FAXMADDS.FA_MASS_ADD';
801       --p_global_context_code := 'JL.CO.FAXASSET.ADDITIONS_ADD';
802       RETURN(TRUE);
803     -- Bug 14241404 Start
804     ELSIF  (p_global_context_code = 'JL.BR.INVIDTMP.Fiscal') THEN
805       p_global_context_code := 'JL.BR.INVIDITM.XX.Fiscal';
806       RETURN(TRUE);
807     -- Bug 14241404 End
808 --  << ADD NEW ENTRY HERE >>
809 --  ELSIF (p_global_context_code = 'CURRENT CONTEXT CODE') THEN
810 --    p_global_context_code := 'TARGET CONTEXT CODE';
811 --    RETURN(TRUE);
812 
813     ELSE
814 
815 	-- Bug 9743290
816 	-- In case if the execution enter into this section, mostly the context is not owned by Global Dev. It must be owned by Oracle Consulting.
817 	-- We have requested oracle consulting team to follow a standing naming convention to make the below generic logic to work.
818 	-- The source and destination context should be same except the formname.
819 
820 	IF substr(p_global_context_code,7,instr(p_global_context_code,'.',1,3)-7) = 'FAXMADDS' THEN
821 	  l_defined := is_defined('JG_FA_ADDITIONS', replace(p_global_context_code,'FAXMADDS','FAXASSET'));
822 
823 		  IF l_defined THEN
824 		     p_global_context_code := replace(p_global_context_code,'FAXMADDS','FAXASSET');
825 		  END IF;
826 
827 	  RETURN(l_defined);
828 	ELSIF substr(p_global_context_code,7,instr(p_global_context_code,'.',1,3)-7) = 'APXIISIM' THEN
829 	 l_defined := is_defined('JG_AP_INVOICES', replace(p_global_context_code,'APXIISIM','APXINWKB'));
830 
831 		  IF l_defined THEN
832 		     p_global_context_code := replace(p_global_context_code,'APXIISIM','APXINWKB');
833 		  END IF;
834 
835 	  RETURN(l_defined);
836 	END IF;
837 
838    END IF;
839 
840    RETURN(FALSE);
841 
842   END reassign_context_code;
843 
844   ---------------------------------------------------------------------------
845   -- CHECK_ATTR_VALUE():
846   --   Check global flexfield information prior to inserting it into
847   --   the table upon which the global flexfield is defined.
848   --   This procedure will indicate an error if any of the values are
849   --   invalid
850   --   The parameters p_core_prod_arg1 to p_core_prod_arg30 are defined
851   --   considering the future expansion we may need to include global
852   --   flexfield validation for other products.
853   --------------------------------------------------------------------------
854   PROCEDURE check_attr_value
855      (p_calling_program_name       IN     VARCHAR2,
856       p_global_attribute_category  IN     VARCHAR2,
857       p_global_attribute1          IN OUT NOCOPY     VARCHAR2,
858       p_global_attribute2          IN OUT NOCOPY     VARCHAR2,
859       p_global_attribute3          IN OUT NOCOPY     VARCHAR2,
860       p_global_attribute4          IN OUT NOCOPY     VARCHAR2,
861       p_global_attribute5          IN OUT NOCOPY     VARCHAR2,
862       p_global_attribute6          IN OUT NOCOPY     VARCHAR2,
863       p_global_attribute7          IN OUT NOCOPY     VARCHAR2,
864       p_global_attribute8          IN OUT NOCOPY     VARCHAR2,
865       p_global_attribute9          IN OUT NOCOPY     VARCHAR2,
866       p_global_attribute10         IN OUT NOCOPY     VARCHAR2,
867       p_global_attribute11         IN OUT NOCOPY     VARCHAR2,
868       p_global_attribute12         IN OUT NOCOPY     VARCHAR2,
869       p_global_attribute13         IN OUT NOCOPY     VARCHAR2,
870       p_global_attribute14         IN OUT NOCOPY     VARCHAR2,
871       p_global_attribute15         IN OUT NOCOPY     VARCHAR2,
872       p_global_attribute16         IN OUT NOCOPY     VARCHAR2,
873       p_global_attribute17         IN OUT NOCOPY     VARCHAR2,
874       p_global_attribute18         IN OUT NOCOPY     VARCHAR2,
875       p_global_attribute19         IN OUT NOCOPY     VARCHAR2,
876       p_global_attribute20         IN OUT NOCOPY     VARCHAR2,
877       p_core_prod_arg1             IN     VARCHAR2 ,
878       p_core_prod_arg2             IN     VARCHAR2 ,
879       p_core_prod_arg3             IN     VARCHAR2 ,
880       p_core_prod_arg4             IN     VARCHAR2 ,
881       p_core_prod_arg5           IN     VARCHAR2 ,
882       p_core_prod_arg6           IN     VARCHAR2 ,
883       p_core_prod_arg7             IN     VARCHAR2 ,
884       p_core_prod_arg8             IN     VARCHAR2 ,
885       p_core_prod_arg9             IN     VARCHAR2 ,
886       p_core_prod_arg10            IN     VARCHAR2 ,
887       p_core_prod_arg11            IN     VARCHAR2 ,
888       p_core_prod_arg12            IN     VARCHAR2 ,
889       p_core_prod_arg13            IN     VARCHAR2 ,
890       p_core_prod_arg14            IN     VARCHAR2 ,
891       p_core_prod_arg15            IN     VARCHAR2 ,
892       p_core_prod_arg16            IN     VARCHAR2 ,
893       p_core_prod_arg17            IN     VARCHAR2 ,
894       p_core_prod_arg18            IN     VARCHAR2 ,
895       p_core_prod_arg19            IN     VARCHAR2 ,
896       p_core_prod_arg20            IN     VARCHAR2 ,
897       p_core_prod_arg21            IN     VARCHAR2 ,
898       p_core_prod_arg22            IN     VARCHAR2 ,
899       p_core_prod_arg23            IN     VARCHAR2 ,
900       p_core_prod_arg24            IN     VARCHAR2 ,
901       p_core_prod_arg25            IN     VARCHAR2 ,
902       p_core_prod_arg26            IN     VARCHAR2 ,
903       p_core_prod_arg27            IN     VARCHAR2 ,
904       p_core_prod_arg28            IN     VARCHAR2 ,
905       p_core_prod_arg29            IN     VARCHAR2 ,
906       p_core_prod_arg30            IN     VARCHAR2 ,
907       p_current_status             OUT NOCOPY    VARCHAR2) IS
908 
909   BEGIN
910     IF p_calling_program_name = 'APXIIMPT' THEN
911        check_attr_value_ap
912           (p_calling_program_name,
913            TO_NUMBER(p_core_prod_arg1), -- Set of Books Id
914            fnd_date.canonical_to_date(p_core_prod_arg2),   -- Invoice Date
915            p_core_prod_arg3,            -- Parent Table
916            TO_NUMBER(p_core_prod_arg4), -- Parent Id
917            TO_NUMBER(p_core_prod_arg5), -- Default Last Updated By
918            TO_NUMBER(p_core_prod_arg6), -- Default Last Update Login
919 	   TO_NUMBER(p_core_prod_arg8), -- Vendor Site ID -For DK EDI
920 	   p_core_prod_arg9,		-- payment curency code - FOR DK EDI
921            p_core_prod_arg10,           -- Item Type Lookup Code - FOR BR
922            p_global_attribute_category,
923            p_global_attribute1,
924            p_global_attribute2,
925            p_global_attribute3,
926            p_global_attribute4,
927            p_global_attribute5,
928            p_global_attribute6,
929            p_global_attribute7,
930            p_global_attribute8,
931            p_global_attribute9,
932            p_global_attribute10,
933            p_global_attribute11,
934            p_global_attribute12,
935            p_global_attribute13,
936            p_global_attribute14,
937            p_global_attribute15,
938            p_global_attribute16,
939            p_global_attribute17,
940            p_global_attribute18,
941            p_global_attribute19,
942            p_global_attribute20,
943            p_current_status,
944            p_core_prod_arg7);          -- Current Calling Sequence
945     END IF;
946 
947   --
948   -- AR validation is implemented in check_attr_value_ar
949   -- due to the data model changes in TCA.
950   --
951 
952   END CHECK_ATTR_VALUE;
953 
954   ---------------------------------------------------------------------------
955   -- CHECK_ATTR_VALUE_AP():
956   --    This procedure validates AP global flexfield.
957   --    Currently the procedure validates the following flexfields.
958   --    JG_AP_INVOICES_INTERFACE
959   --    JG_AP_INVOICE_LINES_INTERFACE
960   --    Whenever the validation fails, a record is inserted into the
961   --    AP_INTERFACE_REJECTIONS table.
962   --------------------------------------------------------------------------
963   PROCEDURE check_attr_value_ap(
964       p_calling_program_name  		IN    VARCHAR2,
965       p_set_of_books_id     		IN    NUMBER,
966       p_invoice_date                    IN    DATE,
967       p_parent_table          		IN    VARCHAR2,
968       p_parent_id          		IN    NUMBER,
969       p_default_last_updated_by		IN    NUMBER,
970       p_default_last_update_login	IN    NUMBER,
971       p_inv_vendor_site_id		IN    NUMBER,
972       p_inv_payment_currency_code	IN    VARCHAR2,
973       p_line_type_lookup_code           IN    VARCHAR2,
974       p_global_attribute_category       IN    VARCHAR2,
975       p_global_attribute1   		IN OUT NOCOPY    VARCHAR2,
976       p_global_attribute2   		IN OUT NOCOPY    VARCHAR2,
977       p_global_attribute3   		IN OUT NOCOPY    VARCHAR2,
978       p_global_attribute4   		IN OUT NOCOPY    VARCHAR2,
979       p_global_attribute5   		IN OUT NOCOPY    VARCHAR2,
980       p_global_attribute6   		IN OUT NOCOPY    VARCHAR2,
981       p_global_attribute7   		IN OUT NOCOPY    VARCHAR2,
982       p_global_attribute8   		IN OUT NOCOPY    VARCHAR2,
983       p_global_attribute9   		IN OUT NOCOPY    VARCHAR2,
984       p_global_attribute10  		IN OUT NOCOPY    VARCHAR2,
985       p_global_attribute11  		IN OUT NOCOPY    VARCHAR2,
986       p_global_attribute12  		IN OUT NOCOPY    VARCHAR2,
987       p_global_attribute13  		IN OUT NOCOPY    VARCHAR2,
988       p_global_attribute14  		IN OUT NOCOPY    VARCHAR2,
989       p_global_attribute15  		IN OUT NOCOPY    VARCHAR2,
990       p_global_attribute16  		IN OUT NOCOPY    VARCHAR2,
991       p_global_attribute17  		IN OUT NOCOPY    VARCHAR2,
992       p_global_attribute18  		IN OUT NOCOPY    VARCHAR2,
993       p_global_attribute19  		IN OUT NOCOPY    VARCHAR2,
994       p_global_attribute20  		IN OUT NOCOPY    VARCHAR2,
995       p_current_invoice_status		OUT NOCOPY   VARCHAR2,
996       p_calling_sequence       		IN    VARCHAR2) IS
997 
998      l_credit_exists            VARCHAR2(1);
999      l_current_invoice_status1  VARCHAR2(1);
1000      l_current_invoice_status2  VARCHAR2(1);
1001 
1002      l_debug_loc                VARCHAR2(30);
1003      l_curr_calling_sequence    VARCHAR2(2000);
1004      l_debug_info               VARCHAR2(100);
1005 
1006   BEGIN
1007      l_current_invoice_status1   := 'Y';
1008      l_current_invoice_status2   := 'Y';
1009 
1010      l_debug_loc                 := 'check_attr_value_ap';
1011 
1012   -------------------------- DEBUG INFORMATION ------------------------------
1013   l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
1014   l_debug_info := 'Check if value exists in global attribute columns where not expected';
1015   ---------------------------------------------------------------------------
1016   --
1017   -- Check AP Context Integrity
1018   --
1019   check_ap_context_integrity
1020           (p_calling_program_name,
1021            p_parent_table,
1022            p_parent_id,
1023            p_default_last_updated_by,
1024            p_default_last_update_login,
1025            p_global_attribute_category,
1026            p_global_attribute1,
1027            p_global_attribute2,
1028            p_global_attribute3,
1029            p_global_attribute4,
1030            p_global_attribute5,
1031            p_global_attribute6,
1032            p_global_attribute7,
1033            p_global_attribute8,
1034            p_global_attribute9,
1035            p_global_attribute10,
1036            p_global_attribute11,
1037            p_global_attribute12,
1038            p_global_attribute13,
1039            p_global_attribute14,
1040            p_global_attribute15,
1041            p_global_attribute16,
1042            p_global_attribute17,
1043            p_global_attribute18,
1044            p_global_attribute19,
1045            p_global_attribute20,
1046            l_current_invoice_status1,
1047            l_curr_calling_sequence);          -- Current Calling Sequence
1048 
1049   --
1050   --  Added to improve performance. Return if global flexfield is null.
1051   --
1052   IF (p_global_attribute_category IS NULL) THEN
1053      p_current_invoice_status := l_current_invoice_status1;
1054      RETURN;
1055   END IF;
1056 
1057   --
1058   -- Check AP Business Rules
1059   --
1060   check_ap_business_rules
1061           (p_calling_program_name,
1062            p_set_of_books_id,
1063            p_invoice_date,
1064            p_parent_table,
1065            p_parent_id,
1066            p_default_last_updated_by,
1067            p_default_last_update_login,
1068       	   p_inv_vendor_site_id,
1069            p_inv_payment_currency_code,
1070            p_line_type_lookup_code,
1071            p_global_attribute_category,
1072            p_global_attribute1,
1073            p_global_attribute2,
1074            p_global_attribute3,
1075            p_global_attribute4,
1076            p_global_attribute5,
1077            p_global_attribute6,
1078            p_global_attribute7,
1079            p_global_attribute8,
1080            p_global_attribute9,
1081            p_global_attribute10,
1082            p_global_attribute11,
1083            p_global_attribute12,
1084            p_global_attribute13,
1085            p_global_attribute14,
1086            p_global_attribute15,
1087            p_global_attribute16,
1088            p_global_attribute17,
1089            p_global_attribute18,
1090            p_global_attribute19,
1091            p_global_attribute20,
1092            l_current_invoice_status2,
1093            l_curr_calling_sequence);          -- Current Calling Sequence
1094 
1095     IF (l_current_invoice_status1 = 'N') or (l_current_invoice_status2 = 'N') THEN
1096         p_current_invoice_status := 'N';
1097     ELSE
1098         p_current_invoice_status := 'Y';
1099     END IF;
1100 
1101   EXCEPTION
1102     WHEN OTHERS THEN
1103       IF (SQLCODE <> -20001) THEN
1104         FND_MESSAGE.SET_NAME('SQLAP', 'AP_DEBUG');
1105         FND_MESSAGE.SET_TOKEN('ERROR', 'SQLERRM');
1106         FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', l_curr_calling_sequence);
1107         FND_MESSAGE.SET_TOKEN('PARAMETERS',
1108                         'Calling Program Name = '||p_calling_program_name
1109                     ||', Set Of Books Id = '||to_char(p_set_of_books_id)
1110                     ||', Parent Table = '||p_parent_table
1111                     ||', Parent Id = '||to_char(p_parent_id)
1112                     ||', Last Updated By = '||to_char(p_default_last_updated_by)
1113                     ||', Last Update Login = '||to_char(p_default_last_update_login)
1114                     ||', Global Attribute Category = '||p_global_attribute_category
1115                     ||', Global Attribute1 = '||p_global_attribute1
1116                     ||', Global Attribute2 = '||p_global_attribute2
1117                     ||', Global Attribute3 = '||p_global_attribute3
1118                     ||', Global Attribute4 = '||p_global_attribute4
1119                     ||', Global Attribute5 = '||p_global_attribute5
1120                     ||', Global Attribute6 = '||p_global_attribute6
1121                     ||', Global Attribute7 = '||p_global_attribute7
1122                     ||', Global Attribute8 = '||p_global_attribute8
1123                     ||', Global Attribute9 = '||p_global_attribute9
1124                     ||', Global Attribute10 = '||p_global_attribute10
1125                     ||', Global Attribute11 = '||p_global_attribute11
1126                     ||', Global Attribute12 = '||p_global_attribute12
1127                     ||', Global Attribute13 = '||p_global_attribute13
1128                     ||', Global Attribute14 = '||p_global_attribute14
1129                     ||', Global Attribute15 = '||p_global_attribute15
1130                     ||', Global Attribute16 = '||p_global_attribute16
1131                     ||', Global Attribute17 = '||p_global_attribute17
1132                     ||', Global Attribute18 = '||p_global_attribute18
1133                     ||', Global Attribute19 = '||p_global_attribute19
1134                     ||', Global Attribute20 = '||p_global_attribute20);
1135         FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1136       END IF;
1137     APP_EXCEPTION.RAISE_EXCEPTION;
1138   END check_attr_value_ap;
1139 
1140   ---------------------------------------------------------------------------
1141   --  CHECK_AP_CONTEXT_INTEGRITY()
1142   --  Check ap context integrity.
1143   ---------------------------------------------------------------------------
1144   PROCEDURE check_ap_context_integrity(
1145          p_calling_program_name            IN    VARCHAR2,
1146          p_parent_table                    IN    VARCHAR2,
1147          p_parent_id                       IN    NUMBER,
1148          p_default_last_updated_by         IN    NUMBER,
1149          p_default_last_update_login       IN    NUMBER,
1150          p_global_attribute_category       IN    VARCHAR2,
1151          p_global_attribute1               IN    VARCHAR2,
1152          p_global_attribute2               IN    VARCHAR2,
1153          p_global_attribute3               IN    VARCHAR2,
1154          p_global_attribute4               IN    VARCHAR2,
1155          p_global_attribute5               IN    VARCHAR2,
1156          p_global_attribute6               IN    VARCHAR2,
1157          p_global_attribute7               IN    VARCHAR2,
1158          p_global_attribute8               IN    VARCHAR2,
1159          p_global_attribute9               IN    VARCHAR2,
1160          p_global_attribute10              IN    VARCHAR2,
1161          p_global_attribute11              IN    VARCHAR2,
1162          p_global_attribute12              IN    VARCHAR2,
1163          p_global_attribute13              IN    VARCHAR2,
1164          p_global_attribute14              IN    VARCHAR2,
1165          p_global_attribute15              IN    VARCHAR2,
1166          p_global_attribute16              IN    VARCHAR2,
1167          p_global_attribute17              IN    VARCHAR2,
1168          p_global_attribute18              IN    VARCHAR2,
1169          p_global_attribute19              IN    VARCHAR2,
1170          p_global_attribute20              IN    VARCHAR2,
1171          p_current_invoice_status          OUT NOCOPY   VARCHAR2,
1172          p_calling_sequence                IN    VARCHAR2) IS
1173 
1174      l_current_invoice_status1       VARCHAR2(1);
1175      l_current_invoice_status2       VARCHAR2(1);
1176 
1177      l_debug_loc                     VARCHAR2(30);
1178      l_curr_calling_sequence         VARCHAR2(2000);
1179      l_debug_info                    VARCHAR2(100);
1180 
1181   BEGIN
1182      l_debug_loc  := 'check_ap_context_integrity';
1183     -------------------------- DEBUG INFORMATION ------------------------------
1184     l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
1185     l_debug_info := 'Reject invalid context code';
1186     ---------------------------------------------------------------------------
1187     --
1188     -- Reject when global attribute value found where not expected.
1189     --
1190     reject_value_found
1191           (p_parent_table,
1192            p_parent_id,
1193            p_default_last_updated_by,
1194            p_default_last_update_login,
1195            p_global_attribute_category,
1196            p_global_attribute1,
1197            p_global_attribute2,
1198            p_global_attribute3,
1199            p_global_attribute4,
1200            p_global_attribute5,
1201            p_global_attribute6,
1202            p_global_attribute7,
1203            p_global_attribute8,
1204            p_global_attribute9,
1205            p_global_attribute10,
1206            p_global_attribute11,
1207            p_global_attribute12,
1208            p_global_attribute13,
1209            p_global_attribute14,
1210            p_global_attribute15,
1211            p_global_attribute16,
1212            p_global_attribute17,
1213            p_global_attribute18,
1214            p_global_attribute19,
1215            p_global_attribute20,
1216            l_current_invoice_status1,
1217            l_curr_calling_sequence);          -- Current Calling Sequence
1218 
1219     --
1220     -- Reject invalid global attribute category.
1221     --
1222     reject_invalid_context_code
1223           (p_calling_program_name,
1224            p_parent_table,
1225            p_parent_id,
1226            p_default_last_updated_by,
1227            p_default_last_update_login,
1228            p_global_attribute_category,
1229            l_current_invoice_status2,
1230            l_curr_calling_sequence);          -- Current Calling Sequence
1231 
1232     IF (l_current_invoice_status1 = 'N') or (l_current_invoice_status2 = 'N') THEN
1233         p_current_invoice_status := 'N';
1234     END IF;
1235 
1236   END check_ap_context_integrity;
1237 
1238   ---------------------------------------------------------------------------
1239   --  REJECT_VALUE_FOUND()
1240   --  Reject when global attribute value found where not expected.
1241   ---------------------------------------------------------------------------
1242   PROCEDURE reject_value_found(
1243          p_parent_table                    IN    VARCHAR2,
1244          p_parent_id                       IN    NUMBER,
1245          p_default_last_updated_by         IN    NUMBER,
1246          p_default_last_update_login       IN    NUMBER,
1247          p_global_attribute_category       IN    VARCHAR2,
1248          p_global_attribute1               IN    VARCHAR2,
1249          p_global_attribute2               IN    VARCHAR2,
1250          p_global_attribute3               IN    VARCHAR2,
1251          p_global_attribute4               IN    VARCHAR2,
1252          p_global_attribute5               IN    VARCHAR2,
1253          p_global_attribute6               IN    VARCHAR2,
1254          p_global_attribute7               IN    VARCHAR2,
1255          p_global_attribute8               IN    VARCHAR2,
1256          p_global_attribute9               IN    VARCHAR2,
1257          p_global_attribute10              IN    VARCHAR2,
1258          p_global_attribute11              IN    VARCHAR2,
1259          p_global_attribute12              IN    VARCHAR2,
1260          p_global_attribute13              IN    VARCHAR2,
1261          p_global_attribute14              IN    VARCHAR2,
1262          p_global_attribute15              IN    VARCHAR2,
1263          p_global_attribute16              IN    VARCHAR2,
1264          p_global_attribute17              IN    VARCHAR2,
1265          p_global_attribute18              IN    VARCHAR2,
1266          p_global_attribute19              IN    VARCHAR2,
1267          p_global_attribute20              IN    VARCHAR2,
1268          p_current_invoice_status          OUT NOCOPY   VARCHAR2,
1269          p_calling_sequence                IN    VARCHAR2) IS
1270 
1271      l_debug_loc                     VARCHAR2(30);
1272      l_curr_calling_sequence         VARCHAR2(2000);
1273      l_debug_info                    VARCHAR2(100);
1274 
1275   BEGIN
1276      l_debug_loc  := 'reject_value_found';
1277     -------------------------- DEBUG INFORMATION ------------------------------
1278     l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
1279     l_debug_info := 'Reject invalid context code';
1280     ---------------------------------------------------------------------------
1281     IF (check_attr_exists(
1282         p_global_attribute_category,
1283         p_global_attribute1,
1284         p_global_attribute2,
1285         p_global_attribute3,
1286         p_global_attribute4,
1287         p_global_attribute5,
1288         p_global_attribute6,
1289         p_global_attribute7,
1290         p_global_attribute8,
1291         p_global_attribute9,
1292         p_global_attribute10,
1293         p_global_attribute11,
1294         p_global_attribute12,
1295         p_global_attribute13,
1296         p_global_attribute14,
1297         p_global_attribute15,
1298         p_global_attribute16,
1299         p_global_attribute17,
1300         p_global_attribute18,
1301         p_global_attribute19,
1302         p_global_attribute20) <> TRUE)
1303     THEN
1304       jg_globe_flex_val_shared.insert_rejections(p_parent_table,
1305                         p_parent_id,
1306                         'GLOBAL_ATTR_VALUE_FOUND',
1307                         p_default_last_updated_by,
1308                         p_default_last_update_login,
1309                         p_calling_sequence);
1310       p_current_invoice_status := 'N';
1311     END IF;
1312   END reject_value_found;
1313 
1314   ---------------------------------------------------------------------------
1315   --  REJECT_INVALID_CONTEXT_CODE()
1316   --  Reject when global attribute value found where not expected.
1317   ---------------------------------------------------------------------------
1318   PROCEDURE reject_invalid_context_code(
1319          p_calling_program_name            IN    VARCHAR2,
1320          p_parent_table                    IN    VARCHAR2,
1321          p_parent_id                       IN    NUMBER,
1322          p_default_last_updated_by         IN    NUMBER,
1323          p_default_last_update_login       IN    NUMBER,
1324          p_global_attribute_category       IN    VARCHAR2,
1325          p_current_invoice_status          OUT NOCOPY   VARCHAR2,
1326          p_calling_sequence                IN    VARCHAR2) IS
1327 
1328      l_debug_loc                     VARCHAR2(30);
1329      l_curr_calling_sequence         VARCHAR2(2000);
1330      l_debug_info                    VARCHAR2(100);
1331 
1332   BEGIN
1333      l_debug_loc     := 'reject_invalid_context_code';
1334     -------------------------- DEBUG INFORMATION ------------------------------
1335     l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
1336     l_debug_info := 'Reject invalid context code';
1337     ---------------------------------------------------------------------------
1338     IF p_global_attribute_category IS NOT NULL THEN
1339       l_debug_info := 'Check if specified context value is valid';
1340       IF (check_context_code(
1341                      p_calling_program_name,
1342                      p_global_attribute_category) <> TRUE)
1343       THEN
1344         jg_globe_flex_val_shared.insert_rejections(p_parent_table,
1345                           p_parent_id,
1346                           'INVALID_GLOBAL_CONTEXT',
1347                           p_default_last_updated_by,
1348                           p_default_last_update_login,
1349                           p_calling_sequence);
1350         p_current_invoice_status := 'N';
1351       END IF;
1352     END IF;
1353   END reject_invalid_context_code;
1354 
1355   ---------------------------------------------------------------------------
1356   -- CHECK_AP_BUSINESS_RULES():
1357   --    This procedure validates AP global flexfield values.
1358   --    Currently the procedure validates the following flexfields.
1359   --    JG_AP_INVOICES_INTERFACE
1360   --    JG_AP_INVOICE_LINES_INTERFACE
1361   --    Whenever the validation fails, a record is inserted into the
1362   --    AP_INTERFACE_REJECTIONS table.
1363   --------------------------------------------------------------------------
1364   PROCEDURE check_ap_business_rules(
1365       p_calling_program_name            IN    VARCHAR2,
1366       p_set_of_books_id                 IN    NUMBER,
1367       p_invoice_date                    IN    DATE,
1368       p_parent_table                    IN    VARCHAR2,
1369       p_parent_id                       IN    NUMBER,
1370       p_default_last_updated_by         IN    NUMBER,
1371       p_default_last_update_login       IN    NUMBER,
1372       p_inv_vendor_site_id              IN    NUMBER,
1373       p_inv_payment_currency_code       IN    VARCHAR2,
1374       p_line_type_lookup_code           IN    VARCHAR2,
1375       p_global_attribute_category       IN    VARCHAR2,
1376       p_global_attribute1               IN OUT NOCOPY    VARCHAR2,
1377       p_global_attribute2               IN OUT NOCOPY    VARCHAR2,
1378       p_global_attribute3               IN OUT NOCOPY    VARCHAR2,
1379       p_global_attribute4               IN OUT NOCOPY    VARCHAR2,
1380       p_global_attribute5               IN OUT NOCOPY    VARCHAR2,
1381       p_global_attribute6               IN OUT NOCOPY    VARCHAR2,
1382       p_global_attribute7               IN OUT NOCOPY    VARCHAR2,
1383       p_global_attribute8               IN OUT NOCOPY    VARCHAR2,
1384       p_global_attribute9               IN OUT NOCOPY    VARCHAR2,
1385       p_global_attribute10              IN OUT NOCOPY    VARCHAR2,
1386       p_global_attribute11              IN OUT NOCOPY    VARCHAR2,
1387       p_global_attribute12              IN OUT NOCOPY    VARCHAR2,
1388       p_global_attribute13              IN OUT NOCOPY    VARCHAR2,
1389       p_global_attribute14              IN OUT NOCOPY    VARCHAR2,
1390       p_global_attribute15              IN OUT NOCOPY    VARCHAR2,
1391       p_global_attribute16              IN OUT NOCOPY    VARCHAR2,
1392       p_global_attribute17              IN OUT NOCOPY    VARCHAR2,
1393       p_global_attribute18              IN OUT NOCOPY    VARCHAR2,
1394       p_global_attribute19              IN OUT NOCOPY    VARCHAR2,
1395       p_global_attribute20              IN OUT NOCOPY    VARCHAR2,
1396       p_current_invoice_status          OUT NOCOPY   VARCHAR2,
1397       p_calling_sequence                IN    VARCHAR2) IS
1398 
1399      l_credit_exists VARCHAR2(1);
1400 
1401      l_debug_loc                     VARCHAR2(30);
1402      l_curr_calling_sequence         VARCHAR2(2000);
1403      l_debug_info                    VARCHAR2(100);
1404   BEGIN
1405      l_debug_loc  := 'check_ap_business_rules';
1406 
1407   -------------------------- DEBUG INFORMATION ------------------------------
1408   l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
1409   l_debug_info := 'Check ap business rules';
1410   ---------------------------------------------------------------------------
1411 
1412      p_current_invoice_status := 'Y'; -- Initialize record status variable
1413 
1414   --------------------------------------------------------------------------------------
1415   --                         Global Flexfield Validation
1416   --------------------------------------------------------------------------------------
1417   --  You can add your own validation code for your global flexfields.
1418   --  You should not include arguments(GLOBAL_ATTRIBUTE(n)) you do not validate
1419   --  in your procedure.
1420   --  Form Name: APXIISIM
1421   --------------------------------------------------------------------------------------
1422   --   Header Level Validation - Block Name: INVOICES_FOLDER
1423   --------------------------------------------------------------------------------------
1424   --    1-1. JA.KR.APXIISIM.INVOICES_FOLDER
1425   --    1-2. JA.CN.APXIISIM.INVOICES_FOLDER
1426   --    1-3. JA.TH.APXIISIM.INVOICES_INTF
1427   --    1-4. JA.TW.APXIISIM.INVOICES_FOLDER
1428   --    1-5. JA.SG.APXIISIM.INVOICES_FOLDER
1429   --    1-6. JE.BE.APXIISIM.EFT
1430   --    1-7. JE.CH.APXIISIM.DTA
1431   --    1-8. JE.CH.APXIISIM.SAD
1432   --    1-9.0 JE.DK.APXIISIM.EDI_INFO
1433   --    1-9. JE.DK.APXIISIM.GIRO_DOMESTIC
1434   --    1-10.JE.DK.APXIISIM.GIRO_FOREIGN
1435   --    1-11.JE.DK.APXIISIM.UNIT_DOMESTIC
1436   --    1-12.JE.DK.APXIISIM.UNIT_FOREIGN
1437   --    1-13.JE.FI.APXIISIM.A_LOMAKE
1438   --    1-14.JE.FI.APXIISIM.B_LOMAKE
1439   --    1-15.JE.FI.APXIISIM.KKL_VIITE
1440   --    1-16.JE.FI.APXIISIM.VAPAA_VIITE
1441   --    1-17.JE.NL.APXIISIM.FOREIGN
1442   --    1-19.JE.NO.APXIISIM.NORWAY
1443   --    1-20.JE.SE.APXIISIM.BANK_SISU
1444   --    1-21.JE.SE.APXIISIM.BANK_UTLI
1445   --    1-22.JE.SE.APXIISIM.POST_INLAND
1446   --    1-23.JE.SE.APXIISIM.POST_UTLAND
1447   --    1-24.JE.CZ.APXIISIM.INVOICE_INFO
1448   --    1-25.JE.HU.APXIISIM.TAX_DATE
1449   --    1-26.JE.PL.APXIISIM.INVOICE_INFO
1450   --    1-27.JL.AR.APXIISIM.INVOICES_FOLDER
1451   --    1-27a.JL.CO.APXIISIM.INVOICES_FOLDER -- Bug 3233307
1452   --    1-28.JL.BR.APXIISIM.INVOICES_FOLDER
1453   --    1-29.JL.CL.APXIISIM.INVOICES_FOLDER
1454   --    1-30.JE.SK.APXIISIM.INVOICE_INFO
1455   --------------------------------------------------------------------------------------
1456   --   Line Level Validation   - Block Name: INVOICE_LINES_FOLDER
1457   --------------------------------------------------------------------------------------
1458   --    2-1.  JA.KR.APXIISIM.LINES_FOLDER
1459   --    2-2.  JA.CA.APXIISIM.LINES_FOLDER
1460   --    2-3.  JE.HU.APXIISIM.STAT_CODE
1461   --    2-4.  JE.PL.APXIISIM.STAT_CODE
1462   --    2-5.  JL.AR.APXIISIM.LINES_FOLDER
1463   --    2-6.  JL.CO.APXIIFIX.LINES_FOLDER
1464   --    2-7.  JL.BR.APXIISIM.LINES_FOLDER
1465   --    2-8.  JE.HU.APXIISIM.FINAL
1466   --    2-9.  JE.PL.APXIISIM.FINAL
1467   --    2-10. JE.CZ.APXIISIM.FINAL
1468   --    2-11. JE.SK.APXIISIM.FINAL
1469   --    2-12. JE.PL.APXIISIM.INSURANCE_INFO
1470 
1471   --
1472   --     There is no global flexfield in Invoice Gateway of R11i for Korea,
1473   --     China, and Canada, so comment out for their context.
1474   --------------------------------------------------------------------------------------
1475 
1476   --
1477   --    1-1. JA.KR.APXIISIM.INVOICES_FOLDER
1478   --
1479   IF (p_global_attribute_category in ('JA.TH.APXIISIM.INVOICES_INTF',
1480                                       'JA.TW.APXIISIM.INVOICES_FOLDER',
1481   --                                  'JA.KR.APXIISIM.INVOICES_FOLDER',
1482                                       'JA.CN.APXIISIM.INVOICES_FOLDER',  -- Uncommented as per bug#13580187
1483   --                                  'JA.KR.APXIISIM.LINES_FOLDER',
1484   --                                  'JA.CA.APXIISIM.LINES_FOLDER'
1485                                       'JA.SG.APXIISIM.INVOICES_FOLDER')) THEN
1486    ja_interface_val.ap_business_rules(
1487       p_calling_program_name,
1488       p_set_of_books_id,
1489       p_invoice_date,
1490       p_parent_table,
1491       p_parent_id,
1492       p_default_last_updated_by,
1493       p_default_last_update_login,
1494       p_global_attribute_category,
1495       p_global_attribute1,
1496       p_global_attribute2,
1497       p_global_attribute3,
1498       p_global_attribute4,
1499       p_global_attribute5,
1500       p_global_attribute6,
1501       p_global_attribute7,
1502       p_global_attribute8,
1503       p_global_attribute9,
1504       p_global_attribute10,
1505       p_global_attribute11,
1506       p_global_attribute12,
1507       p_global_attribute13,
1508       p_global_attribute14,
1509       p_global_attribute15,
1510       p_global_attribute16,
1511       p_global_attribute17,
1512       p_global_attribute18,
1513       p_global_attribute19,
1514       p_global_attribute20,
1515       p_current_invoice_status,
1516       p_calling_sequence);
1517 
1518   ELSIF (p_global_attribute_category in ('JE.BE.APXIISIM.EFT',
1519                                          'JE.CH.APXIISIM.DTA',
1520                                          'JE.CH.APXIISIM.SAD',
1521 					 'JE.DK.APXIISIM.EDI_INFO',
1522                                          'JE.DK.APXIISIM.GIRO_DOMESTIC',
1523                                          'JE.DK.APXIISIM.GIRO_FOREIGN',
1524                                          'JE.DK.APXIISIM.UNIT_DOMESTIC',
1525                                          'JE.DK.APXIISIM.UNIT_FOREIGN',
1526                                          'JE.ES.APXIISIM.MODELO349',
1527                                          'JE.FI.APXIISIM.A_LOMAKE',
1528                                          'JE.FI.APXIISIM.B_LOMAKE',
1529                                          'JE.FI.APXIISIM.KKL_VIITE',
1530                                          'JE.FI.APXIISIM.VAPAA_VIITE',
1531                                          'JE.NL.APXIISIM.FOREIGN',
1532                                          'JE.NO.APXIISIM.NORWAY',
1533                                          'JE.SE.APXIISIM.BANK_SISU',
1534                                          'JE.SE.APXIISIM.BANK_UTLI',
1535                                          'JE.SE.APXIISIM.BANK_INLAND',
1536                                          'JE.SE.APXIISIM.POST_INLAND',
1537                                          'JE.SE.APXIISIM.POST_UTLAND',
1538                                          'JE.CZ.APXIISIM.INVOICE_INFO',
1539                                          'JE.HU.APXIISIM.TAX_DATE',
1540                                          'JE.PL.APXIISIM.INVOICE_INFO',
1541                                        --'JE.HU.APXIISIM.STAT_CODE',
1542                                          'JE.IT.APXIISIM.DISTRIBUTIONS',
1543                                      --  'JE.PL.APXIISIM.STAT_CODE'
1544                                          'JE.SK.APXIISIM.INVOICE_INFO',
1545                                          'JE.SK.APXIISIM.FINAL',
1546                                          'JE.HU.APXIISIM.FINAL',
1547                                          'JE.CZ.APXIISIM.FINAL',
1548                                          'JE.PL.APXIISIM.FINAL',
1549 					 'JE.PL.APXIISIM.INSURANCE_INFO'
1550 					) ) THEN
1551 
1552    je_interface_val.ap_business_rules(
1553       p_calling_program_name,
1554       p_set_of_books_id,
1555       p_invoice_date,
1556       p_parent_table,
1557       p_parent_id,
1558       p_default_last_updated_by,
1559       p_default_last_update_login,
1560       p_inv_vendor_site_id,
1561       p_inv_payment_currency_code,
1562       p_global_attribute_category,
1563       p_global_attribute1,
1564       p_global_attribute2,
1565       p_global_attribute3,
1566       p_global_attribute4,
1567       p_global_attribute5,
1568       p_global_attribute6,
1569       p_global_attribute7,
1570       p_global_attribute8,
1571       p_global_attribute9,
1572       p_global_attribute10,
1573       p_global_attribute11,
1574       p_global_attribute12,
1575       p_global_attribute13,
1576       p_global_attribute14,
1577       p_global_attribute15,
1578       p_global_attribute16,
1579       p_global_attribute17,
1580       p_global_attribute18,
1581       p_global_attribute19,
1582       p_global_attribute20,
1583       p_current_invoice_status,
1584       p_calling_sequence);
1585 
1586   ELSIF (p_global_attribute_category in ('JL.AR.APXIISIM.INVOICES_FOLDER',
1587                                          'JL.AR.APXIISIM.LINES_FOLDER',
1588 				         'JL.CO.APXIISIM.INVOICES_FOLDER', -- Bug 3233307
1589                                          'JL.CO.APXIISIM.LINES_FOLDER',
1590                                          'JL.BR.APXIISIM.INVOICES_FOLDER',
1591                                          'JL.BR.APXIISIM.LINES_FOLDER',
1592                                          'JL.CL.APXIISIM.INVOICES_FOLDER')) THEN
1593    jl_interface_val.ap_business_rules(
1594       p_calling_program_name,
1595       p_set_of_books_id,
1596       p_invoice_date,
1597       p_parent_table,
1598       p_parent_id,
1599       p_default_last_updated_by,
1600       p_default_last_update_login,
1601       p_line_type_lookup_code,
1602       p_global_attribute_category,
1603       p_global_attribute1,
1604       p_global_attribute2,
1605       p_global_attribute3,
1606       p_global_attribute4,
1607       p_global_attribute5,
1608       p_global_attribute6,
1609       p_global_attribute7,
1610       p_global_attribute8,
1611       p_global_attribute9,
1612       p_global_attribute10,
1613       p_global_attribute11,
1614       p_global_attribute12,
1615       p_global_attribute13,
1616       p_global_attribute14,
1617       p_global_attribute15,
1618       p_global_attribute16,
1619       p_global_attribute17,
1620       p_global_attribute18,
1621       p_global_attribute19,
1622       p_global_attribute20,
1623       p_current_invoice_status,
1624       p_calling_sequence);
1625 
1626   END IF;
1627 
1628   EXCEPTION
1629     WHEN OTHERS THEN
1630       IF (SQLCODE <> -20001) THEN
1631         FND_MESSAGE.SET_NAME('SQLAP', 'AP_DEBUG');
1632         FND_MESSAGE.SET_TOKEN('ERROR', 'SQLERRM');
1633         FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE', l_curr_calling_sequence);
1634         FND_MESSAGE.SET_TOKEN('PARAMETERS',
1635                         'Set Of Books Id = '||to_char(p_set_of_books_id)
1636                     ||', Parent Table = '||p_parent_table
1637                     ||', Parent Id = '||to_char(p_parent_id)
1638                     ||', Last Updated By = '||to_char(p_default_last_updated_by)
1639                     ||', Last Update Login = '||to_char(p_default_last_update_login)
1640                     ||', Global Attribute Category = '||p_global_attribute_category
1641                     ||', Global Attribute1 = '||p_global_attribute1
1642                     ||', Global Attribute2 = '||p_global_attribute2
1643                     ||', Global Attribute3 = '||p_global_attribute3
1644                     ||', Global Attribute4 = '||p_global_attribute4
1645                     ||', Global Attribute5 = '||p_global_attribute5
1646                     ||', Global Attribute6 = '||p_global_attribute6
1647                     ||', Global Attribute7 = '||p_global_attribute7
1648                     ||', Global Attribute8 = '||p_global_attribute8
1649                     ||', Global Attribute9 = '||p_global_attribute9
1650                     ||', Global Attribute10 = '||p_global_attribute10
1651                     ||', Global Attribute11 = '||p_global_attribute11
1652                     ||', Global Attribute12 = '||p_global_attribute12
1653                     ||', Global Attribute13 = '||p_global_attribute13
1654                     ||', Global Attribute14 = '||p_global_attribute14
1655                     ||', Global Attribute15 = '||p_global_attribute15
1656                     ||', Global Attribute16 = '||p_global_attribute16
1657                     ||', Global Attribute17 = '||p_global_attribute17
1658                     ||', Global Attribute18 = '||p_global_attribute18
1659                     ||', Global Attribute19 = '||p_global_attribute19
1660                     ||', Global Attribute20 = '||p_global_attribute20);
1661         FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
1662       END IF;
1663     APP_EXCEPTION.RAISE_EXCEPTION;
1664   END check_ap_business_rules;
1665 
1666 
1667   -- Call global flexfield validations procedure for validating the Tax ID and
1668   -- global flexfield segments in RA_CUSTOMERS_INTERFACE
1669 
1670   PROCEDURE ar_cust_interface(p_request_id         IN   NUMBER,
1671                               p_org_id             IN   NUMBER,
1672 -- This org_id is not used for data partitioning
1673                               p_sob_id             IN   NUMBER,
1674                               p_user_id            IN   NUMBER,
1675                               p_application_id     IN   NUMBER,
1676                               p_language           IN   NUMBER,
1677                               p_program_id         IN   NUMBER,
1678                               p_prog_appl_id       IN   NUMBER,
1679                               p_last_update_login  IN   NUMBER,
1680                               p_int_table_name     IN   VARCHAR2
1681   ) IS
1682 
1683   l_current_status            VARCHAR2(1);
1684   l_error_count               NUMBER(15):=0;
1685 
1686   --
1687   -- Modified to implement new TCA model
1688   --
1689   -- This is for new RA_CUSTOMERS_INTERFACE model.
1690   -- You can delete old model once you completed.
1691   --
1692   -- This revision includes following columns:
1693   --
1694   -- customer_name,
1695   -- customer_number,
1696   -- jg_zz_fiscal_code,
1697   -- orig_system_customer_ref,
1698   -- insert_update_flag
1699   -- global_attribute_category
1700   -- global_attribute1..20
1701   -- gdf_address_attr_cat
1702   -- gdf_address_attr1..20
1703   -- gdf_site_use_attr_cat
1704   -- gdf_site_use_attr1..20
1705   --
1706 
1707   CURSOR ra_customers_interface IS
1708     SELECT  i.customer_name, i.customer_number, i.jgzz_fiscal_code,
1709             i.orig_system_customer_ref,i.insert_update_flag,
1710             i.cust_tax_reference,
1711             i.global_attribute_category,i.global_attribute1,
1712             i.global_attribute2,i.global_attribute3,i.global_attribute4,
1713             i.global_attribute5,i.global_attribute6,i.global_attribute7,
1714             i.global_attribute8,i.global_attribute9,i.global_attribute10,
1715             i.global_attribute11,i.global_attribute12,i.global_attribute13,
1716             i.global_attribute14,i.global_attribute15,i.global_attribute16,
1717             i.global_attribute17,i.global_attribute18,i.global_attribute19,
1718             i.global_attribute20,
1719             i.gdf_address_attr_cat,i.gdf_address_attribute1,
1720             i.gdf_address_attribute2,i.gdf_address_attribute3,i.gdf_address_attribute4,
1721             i.gdf_address_attribute5,i.gdf_address_attribute6,i.gdf_address_attribute7,
1722             i.gdf_address_attribute8,i.gdf_address_attribute9,i.gdf_address_attribute10,
1723             i.gdf_address_attribute11,i.gdf_address_attribute12,i.gdf_address_attribute13,
1724             i.gdf_address_attribute14,i.gdf_address_attribute15,i.gdf_address_attribute16,
1725             i.gdf_address_attribute17,i.gdf_address_attribute18,i.gdf_address_attribute19,
1726             i.gdf_address_attribute20,
1727             i.gdf_site_use_attr_cat,i.gdf_site_use_attribute1,
1728             i.gdf_site_use_attribute2,i.gdf_site_use_attribute3,i.gdf_site_use_attribute4,
1729             i.gdf_site_use_attribute5,i.gdf_site_use_attribute6,i.gdf_site_use_attribute7,
1730             i.gdf_site_use_attribute8,i.gdf_site_use_attribute9,i.gdf_site_use_attribute10,
1731             i.gdf_site_use_attribute11,i.gdf_site_use_attribute12,i.gdf_site_use_attribute13,
1732             i.gdf_site_use_attribute14,i.gdf_site_use_attribute15,i.gdf_site_use_attribute16,
1733             i.gdf_site_use_attribute17,i.gdf_site_use_attribute18,i.gdf_site_use_attribute19,
1734             i.gdf_site_use_attribute20,
1735             i.rowid
1736     FROM    ra_customers_interface i
1737     WHERE   i.request_id = p_request_id
1738     AND     nvl(i.validated_flag,'N') <> 'Y';
1739 
1740   --
1741   -- Still under development.
1742   -- Need to make sure which columns to be selected.
1743   --
1744   -- This revision includes following columns:
1745   --
1746   -- gdf_cust_prof_attr_cat
1747   -- gdf_cust_prof_attr1..20
1748   --
1749 
1750   CURSOR ra_customer_profiles_interface IS
1751     SELECT  i.global_attribute_category,i.global_attribute1,
1752             i.global_attribute2,i.global_attribute3,i.global_attribute4,
1753             i.global_attribute5,i.global_attribute6,i.global_attribute7,
1754             i.global_attribute8,i.global_attribute9,i.global_attribute10,
1755             i.global_attribute11,i.global_attribute12,i.global_attribute13,
1756             i.global_attribute14,i.global_attribute15,i.global_attribute16,
1757             i.global_attribute17,i.global_attribute18,i.global_attribute19,
1758             i.global_attribute20,
1759             i.gdf_cust_prof_attr_cat,i.gdf_cust_prof_attribute1,
1760             i.gdf_cust_prof_attribute2,i.gdf_cust_prof_attribute3,i.gdf_cust_prof_attribute4,
1761             i.gdf_cust_prof_attribute5,i.gdf_cust_prof_attribute6,i.gdf_cust_prof_attribute7,
1762             i.gdf_cust_prof_attribute8,i.gdf_cust_prof_attribute9,i.gdf_cust_prof_attribute10,
1763             i.gdf_cust_prof_attribute11,i.gdf_cust_prof_attribute12,i.gdf_cust_prof_attribute13,
1764             i.gdf_cust_prof_attribute14,i.gdf_cust_prof_attribute15,i.gdf_cust_prof_attribute16,
1765             i.gdf_cust_prof_attribute17,i.gdf_cust_prof_attribute18,i.gdf_cust_prof_attribute19,
1766             i.gdf_cust_prof_attribute20,
1767             i.rowid
1768     FROM    ra_customer_profiles_interface i
1769     WHERE   i.request_id = p_request_id
1770     AND     nvl(i.validated_flag,'N') <> 'Y';
1771 
1772 
1773   gdf_rec1           jg_globe_flex_val_shared.GdfRec;  /* New Record Variable */
1774   gdf_rec2           jg_globe_flex_val_shared.GdfRec;  /* New Record Variable */
1775   gdf_rec3           jg_globe_flex_val_shared.GdfRec;  /* New Record Variable */
1776   gdf_general_rec    jg_globe_flex_val_shared.GenRec;  /* New Record Variable */
1777 
1778   --
1779   -- End of modification
1780   --
1781 
1782   CURSOR generate_number IS
1783     SELECT s.generate_customer_number
1784     FROM   ar_system_parameters s
1785     WHERE  s.set_of_books_id  = p_sob_id;
1786   l_cust_man_numbering ar_system_parameters.generate_customer_number%TYPE;
1787 
1788   PG_DEBUG varchar2(1);
1789 
1790   BEGIN
1791 
1792   PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
1793     --  arp_standard.enable_debug;
1794 
1795     --  If there is a performance problem for Customers other than Chile,
1796     --  Colombia and Argentina, the performance can be improved by
1797     --  uncommenting the Return Statement given below.
1798     --  There will not be any validations for global flexfields if this
1799     --  Return statement is uncommented.
1800 
1801     --  RETURN;
1802 
1803        IF PG_DEBUG in ('Y', 'C') THEN
1804           arp_standard.debug('check_attr_value: ' || 'Begin AR Cust Interface procedure');
1805           arp_standard.debug('check_attr_value: ' || 'Global Descr Flex Field Validation Begin: '
1806                                   || to_char(sysdate, 'DD-MON-RR HH:MI:SS'));
1807        END IF;
1808 
1809     -- Get Customer Numbering - Automatic/Manual from AR_SYSTEM_PARAMETERS
1810 
1811     IF p_int_table_name = 'CUSTOMER' THEN
1812       OPEN generate_number;
1813       FETCH generate_number INTO l_cust_man_numbering;
1814       CLOSE generate_number;
1815 
1816       FOR idx_cur IN ra_customers_interface LOOP
1817          --
1818          -- Modified to implement new TCA model
1819          --
1820         gdf_rec1.global_attribute_category := idx_cur.global_attribute_category;
1821          gdf_rec1.global_attribute1  := idx_cur.global_attribute1;
1822          gdf_rec1.global_attribute2  := idx_cur.global_attribute2;
1823          gdf_rec1.global_attribute3  := idx_cur.global_attribute3;
1824          gdf_rec1.global_attribute4  := idx_cur.global_attribute4;
1825          gdf_rec1.global_attribute5  := idx_cur.global_attribute5;
1826          gdf_rec1.global_attribute6  := idx_cur.global_attribute6;
1827          gdf_rec1.global_attribute7  := idx_cur.global_attribute7;
1828          gdf_rec1.global_attribute8  := idx_cur.global_attribute8;
1829          gdf_rec1.global_attribute9  := idx_cur.global_attribute9;
1830          gdf_rec1.global_attribute10 := idx_cur.global_attribute10;
1831          gdf_rec1.global_attribute11 := idx_cur.global_attribute11;
1832          gdf_rec1.global_attribute12 := idx_cur.global_attribute12;
1833          gdf_rec1.global_attribute13 := idx_cur.global_attribute13;
1834          gdf_rec1.global_attribute14 := idx_cur.global_attribute14;
1835          gdf_rec1.global_attribute15 := idx_cur.global_attribute15;
1836          gdf_rec1.global_attribute16 := idx_cur.global_attribute16;
1837          gdf_rec1.global_attribute17 := idx_cur.global_attribute17;
1838          gdf_rec1.global_attribute18 := idx_cur.global_attribute18;
1839          gdf_rec1.global_attribute19 := idx_cur.global_attribute19;
1840          gdf_rec1.global_attribute20 := idx_cur.global_attribute20;
1841 
1842          gdf_rec2.global_attribute_category := idx_cur.gdf_address_attr_cat;
1843          gdf_rec2.global_attribute1  := idx_cur.gdf_address_attribute1;
1844          gdf_rec2.global_attribute2  := idx_cur.gdf_address_attribute2;
1845          gdf_rec2.global_attribute3  := idx_cur.gdf_address_attribute3;
1846          gdf_rec2.global_attribute4  := idx_cur.gdf_address_attribute4;
1847          gdf_rec2.global_attribute5  := idx_cur.gdf_address_attribute5;
1848          gdf_rec2.global_attribute6  := idx_cur.gdf_address_attribute6;
1849          gdf_rec2.global_attribute7  := idx_cur.gdf_address_attribute7;
1850          gdf_rec2.global_attribute8  := idx_cur.gdf_address_attribute8;
1851          gdf_rec2.global_attribute9  := idx_cur.gdf_address_attribute9;
1852          gdf_rec2.global_attribute10 := idx_cur.gdf_address_attribute10;
1853          gdf_rec2.global_attribute11 := idx_cur.gdf_address_attribute11;
1854          gdf_rec2.global_attribute12 := idx_cur.gdf_address_attribute12;
1855          gdf_rec2.global_attribute13 := idx_cur.gdf_address_attribute13;
1856          gdf_rec2.global_attribute14 := idx_cur.gdf_address_attribute14;
1857          gdf_rec2.global_attribute15 := idx_cur.gdf_address_attribute15;
1858          gdf_rec2.global_attribute16 := idx_cur.gdf_address_attribute16;
1859          gdf_rec2.global_attribute17 := idx_cur.gdf_address_attribute17;
1860          gdf_rec2.global_attribute18 := idx_cur.gdf_address_attribute18;
1861          gdf_rec2.global_attribute19 := idx_cur.gdf_address_attribute19;
1862          gdf_rec2.global_attribute20 := idx_cur.gdf_address_attribute20;
1863 
1864          gdf_rec3.global_attribute_category := idx_cur.gdf_site_use_attr_cat;
1865          gdf_rec3.global_attribute1  := idx_cur.gdf_site_use_attribute1;
1866          gdf_rec3.global_attribute2  := idx_cur.gdf_site_use_attribute2;
1867          gdf_rec3.global_attribute3  := idx_cur.gdf_site_use_attribute3;
1868          gdf_rec3.global_attribute4  := idx_cur.gdf_site_use_attribute4;
1869          gdf_rec3.global_attribute5  := idx_cur.gdf_site_use_attribute5;
1870          gdf_rec3.global_attribute6  := idx_cur.gdf_site_use_attribute6;
1871          gdf_rec3.global_attribute7  := idx_cur.gdf_site_use_attribute7;
1872          gdf_rec3.global_attribute8  := idx_cur.gdf_site_use_attribute8;
1873          gdf_rec3.global_attribute9  := idx_cur.gdf_site_use_attribute9;
1874          gdf_rec3.global_attribute10 := idx_cur.gdf_site_use_attribute10;
1875          gdf_rec3.global_attribute11 := idx_cur.gdf_site_use_attribute11;
1876          gdf_rec3.global_attribute12 := idx_cur.gdf_site_use_attribute12;
1877          gdf_rec3.global_attribute13 := idx_cur.gdf_site_use_attribute13;
1878          gdf_rec3.global_attribute14 := idx_cur.gdf_site_use_attribute14;
1879          gdf_rec3.global_attribute15 := idx_cur.gdf_site_use_attribute15;
1880          gdf_rec3.global_attribute16 := idx_cur.gdf_site_use_attribute16;
1881          gdf_rec3.global_attribute17 := idx_cur.gdf_site_use_attribute17;
1882          gdf_rec3.global_attribute18 := idx_cur.gdf_site_use_attribute18;
1883          gdf_rec3.global_attribute19 := idx_cur.gdf_site_use_attribute19;
1884          gdf_rec3.global_attribute20 := idx_cur.gdf_site_use_attribute20;
1885 
1886          gdf_general_rec.core_prod_arg1  := p_sob_id;
1887          gdf_general_rec.core_prod_arg2  := idx_cur.rowid;
1888          gdf_general_rec.core_prod_arg3  := idx_cur.customer_name;
1889          gdf_general_rec.core_prod_arg4  := idx_cur.customer_number;
1890          gdf_general_rec.core_prod_arg5  := idx_cur.jgzz_fiscal_code;
1891          gdf_general_rec.core_prod_arg6  := l_cust_man_numbering;
1892          gdf_general_rec.core_prod_arg7  := idx_cur.orig_system_customer_ref;
1893          gdf_general_rec.core_prod_arg8  := idx_cur.insert_update_flag;
1894          gdf_general_rec.core_prod_arg9  := p_request_id;
1895          gdf_general_rec.core_prod_arg10 := idx_cur.cust_tax_reference;
1896          gdf_general_rec.core_prod_arg11 := 'RACUST';
1897 --
1898 -- Checks the validity of the attributes and performs business logic
1899 --
1900              CHECK_ATTR_VALUE_AR( 'CUSTOMER',
1901                                gdf_rec1,
1902                                gdf_rec2,
1903                                gdf_rec3,
1904                                gdf_general_rec,
1905                                l_current_status);
1906          --
1907          -- End of modification
1908          --
1909 
1910         IF l_current_status = 'E' THEN
1911           l_error_count := l_error_count + 1;
1912         END IF;
1913 
1914       END LOOP;
1915          IF PG_DEBUG in ('Y', 'C') THEN
1916             arp_standard.debug('check_attr_value: ' || 'Records in error = '|| l_error_count);
1917          END IF;
1918 
1919     --
1920     -- Modified to implement new TCA model
1921     --
1922     -- This LOOP is for RA_CUSTOMER_PROFILE_INTERFACE model.
1923     --
1924     ELSIF p_int_table_name = 'PROFILE' THEN
1925 
1926       OPEN generate_number;
1927       FETCH generate_number INTO l_cust_man_numbering;
1928       CLOSE generate_number;
1929       FOR idx_cur IN ra_customer_profiles_interface LOOP
1930         gdf_rec1.global_attribute_category := idx_cur.global_attribute_category;
1931          gdf_rec1.global_attribute1  := idx_cur.global_attribute1;
1932          gdf_rec1.global_attribute2  := idx_cur.global_attribute2;
1933          gdf_rec1.global_attribute3  := idx_cur.global_attribute3;
1934          gdf_rec1.global_attribute4  := idx_cur.global_attribute4;
1935          gdf_rec1.global_attribute5  := idx_cur.global_attribute5;
1936          gdf_rec1.global_attribute6  := idx_cur.global_attribute6;
1937          gdf_rec1.global_attribute7  := idx_cur.global_attribute7;
1938          gdf_rec1.global_attribute8  := idx_cur.global_attribute8;
1939          gdf_rec1.global_attribute9  := idx_cur.global_attribute9;
1940          gdf_rec1.global_attribute10 := idx_cur.global_attribute10;
1941          gdf_rec1.global_attribute11 := idx_cur.global_attribute11;
1942          gdf_rec1.global_attribute12 := idx_cur.global_attribute12;
1943          gdf_rec1.global_attribute13 := idx_cur.global_attribute13;
1944          gdf_rec1.global_attribute14 := idx_cur.global_attribute14;
1945          gdf_rec1.global_attribute15 := idx_cur.global_attribute15;
1946          gdf_rec1.global_attribute16 := idx_cur.global_attribute16;
1947          gdf_rec1.global_attribute17 := idx_cur.global_attribute17;
1948          gdf_rec1.global_attribute18 := idx_cur.global_attribute18;
1949          gdf_rec1.global_attribute19 := idx_cur.global_attribute19;
1950          gdf_rec1.global_attribute20 := idx_cur.global_attribute20;
1951 
1952          gdf_rec2.global_attribute_category := idx_cur.gdf_cust_prof_attr_cat;
1953          gdf_rec2.global_attribute1  := idx_cur.gdf_cust_prof_attribute1;
1954          gdf_rec2.global_attribute2  := idx_cur.gdf_cust_prof_attribute2;
1955          gdf_rec2.global_attribute3  := idx_cur.gdf_cust_prof_attribute3;
1956          gdf_rec2.global_attribute4  := idx_cur.gdf_cust_prof_attribute4;
1957          gdf_rec2.global_attribute5  := idx_cur.gdf_cust_prof_attribute5;
1958          gdf_rec2.global_attribute6  := idx_cur.gdf_cust_prof_attribute6;
1959          gdf_rec2.global_attribute7  := idx_cur.gdf_cust_prof_attribute7;
1960          gdf_rec2.global_attribute8  := idx_cur.gdf_cust_prof_attribute8;
1961          gdf_rec2.global_attribute9  := idx_cur.gdf_cust_prof_attribute9;
1962          gdf_rec2.global_attribute10 := idx_cur.gdf_cust_prof_attribute10;
1963          gdf_rec2.global_attribute11 := idx_cur.gdf_cust_prof_attribute11;
1964          gdf_rec2.global_attribute12 := idx_cur.gdf_cust_prof_attribute12;
1965          gdf_rec2.global_attribute13 := idx_cur.gdf_cust_prof_attribute13;
1966          gdf_rec2.global_attribute14 := idx_cur.gdf_cust_prof_attribute14;
1967          gdf_rec2.global_attribute15 := idx_cur.gdf_cust_prof_attribute15;
1968          gdf_rec2.global_attribute16 := idx_cur.gdf_cust_prof_attribute16;
1969          gdf_rec2.global_attribute17 := idx_cur.gdf_cust_prof_attribute17;
1970          gdf_rec2.global_attribute18 := idx_cur.gdf_cust_prof_attribute18;
1971          gdf_rec2.global_attribute19 := idx_cur.gdf_cust_prof_attribute19;
1972          gdf_rec2.global_attribute20 := idx_cur.gdf_cust_prof_attribute20;
1973 
1974          gdf_general_rec.core_prod_arg1  := p_sob_id;
1975          gdf_general_rec.core_prod_arg2  := idx_cur.rowid;
1976          gdf_general_rec.core_prod_arg9  := p_request_id;
1977          gdf_general_rec.core_prod_arg11 := 'RACUST';
1978 
1979 --
1980 -- Checks the validity of the attributes and performs business logic
1981 --
1982 
1983          CHECK_ATTR_VALUE_AR( 'PROFILE',
1984                                gdf_rec1,
1985                                gdf_rec2,
1986                                gdf_rec3,
1987                                gdf_general_rec,
1988                                l_current_status);
1989 
1990       IF l_current_status = 'E' THEN
1991          l_error_count := l_error_count + 1;
1992       END IF;
1993 
1994       END LOOP;
1995 
1996     END IF;
1997     --
1998     -- End of modification
1999     --
2000 
2001   EXCEPTION
2002   WHEN NO_DATA_FOUND THEN
2003     IF PG_DEBUG in ('Y', 'C') THEN
2004        arp_standard.debug('Not calling JG_GLOBE_FLEX_VAL_PKG.CHECK_ATTR_VALUE');
2005        arp_standard.debug('check_attr_value: ' || 'Global Descr Flex Field Validation end: '
2006                              || to_char(sysdate, 'DD-MON-RR HH:MI:SS'));
2007     END IF;
2008   WHEN OTHERS THEN
2009     IF PG_DEBUG in ('Y', 'C') THEN
2010        arp_standard.debug('check_attr_value: ' || 'Exception calling JG_GLOBE_FLEX_VAL.ar_cust_interface');
2011        arp_standard.debug('check_attr_value: ' || SQLERRM);
2012        arp_standard.debug('check_attr_value: ' || 'Global Descr Flex Field Validation end: '
2013                              || to_char(sysdate, 'DD-MON-RR HH:MI:SS'));
2014     END IF;
2015   END ar_cust_interface;
2016 
2017 
2018 ---------------------------------------------------------------------------
2019   -- CHECK_ATTR_VALUE_AR():
2020   -- This procedure validates AR global flexfield.
2021  --------------------------------------------------------------------------
2022 
2023   --
2024   -- Modified version of check_attr_value_ar
2025   --
2026   PROCEDURE check_attr_value_ar
2027      (p_int_table_name           IN     VARCHAR2,
2028       p_glob_attr_set1           IN     jg_globe_flex_val_shared.GdfRec,
2029       p_glob_attr_set2           IN     jg_globe_flex_val_shared.GdfRec,
2030       p_glob_attr_set3           IN     jg_globe_flex_val_shared.GdfRec,
2031       p_glob_attr_general        IN     jg_globe_flex_val_shared.GenRec,
2032       p_current_record_status    OUT NOCOPY    VARCHAR2
2033       ) IS
2034 
2035   l_current_record_status1      VARCHAR2(1);
2036   l_current_record_status2      VARCHAR2(1);
2037   PG_DEBUG varchar2(1);
2038 
2039   BEGIN
2040   PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
2041   l_current_record_status1  :='S';
2042   l_current_record_status2  :='S';
2043 
2044   --arp_standard.enable_debug;
2045   -------------------------- DEBUG INFORMATION ---------------------------------
2046   IF PG_DEBUG in ('Y', 'C') THEN
2047      arp_standard.debug('Begin check_attr_value_ar procedure in JG_GLOBE_FLEX_VAL p
2048 ackage');
2049   END IF;
2050   ------------------------------------------------------------------------------
2051 
2052   --
2053   -- Check AR Context Integrity
2054   --
2055    check_ar_context_integrity
2056           (p_int_table_name,
2057            p_glob_attr_set1,
2058            p_glob_attr_set2,
2059            p_glob_attr_set3,
2060            p_glob_attr_general,
2061            l_current_record_status1);
2062 
2063   --
2064   -- If generic validation succeeds then,check AR Business Rules
2065   --
2066   IF (l_current_record_status1 <>  'E') THEN
2067 --Call check_ar_business_rules for customer interface
2068         IF p_int_table_name = 'CUSTOMER' THEN
2069            check_ar_business_rules
2070                         (p_int_table_name,
2071                          p_glob_attr_set1,
2072                          p_glob_attr_set2,
2073                          p_glob_attr_set3,
2074                          p_glob_attr_general,
2075                          l_current_record_status2,
2076                          NULL);
2077                 IF (l_current_record_status2 = 'E') THEN
2078                         p_current_record_status := 'E';
2079                 ELSE
2080                         p_current_record_status := 'S';
2081                 END IF;
2082 --Call check_ar_business_rules for customer profile interface
2083           ELSIF p_int_table_name='PROFILE' THEN
2084                 check_ar_business_rules
2085                         (p_int_table_name,
2086 		         p_glob_attr_set1,
2087                          p_glob_attr_set2,
2088                          p_glob_attr_set3,
2089                          p_glob_attr_general,
2090                          l_current_record_status2,
2091                          NULL);
2092                 IF (l_current_record_status2 = 'E') THEN
2093                         p_current_record_status := 'E';
2094                 ELSE
2095                         p_current_record_status := 'S';
2096                 END IF;
2097           END IF;
2098 --End of modification
2099 
2100   ELSE
2101         -- Return the error status
2102          p_current_record_status := 'E';
2103   END IF;
2104 
2105   EXCEPTION
2106     WHEN OTHERS THEN
2107        IF PG_DEBUG in ('Y', 'C') THEN
2108           arp_standard.debug('Exception calling JG_GLOBE_FLEX_VAL.CHECK_ATTR_VALUE_
2109 AR()');
2110           arp_standard.debug('check_attr_value: ' || SQLERRM);
2111        END IF;
2112   END check_attr_value_ar;
2113   --
2114   -- End of modification
2115   --
2116 
2117   ---------------------------------------------------------------------------
2118   --  CHECK_AR_CONTEXT_INTEGRITY()
2119   --  Check ar context integrity.
2120   ---------------------------------------------------------------------------
2121   --
2122   -- Modified version of ar_context_integrity
2123   --
2124   PROCEDURE check_ar_context_integrity(
2125          p_int_table_name           IN     VARCHAR2,
2126          p_glob_attr_set1           IN     jg_globe_flex_val_shared.GdfRec,
2127          p_glob_attr_set2           IN     jg_globe_flex_val_shared.GdfRec,
2128          p_glob_attr_set3           IN     jg_globe_flex_val_shared.GdfRec,
2129          p_glob_attr_general        IN     jg_globe_flex_val_shared.GenRec,
2130          p_current_record_status    OUT NOCOPY    VARCHAR2) IS
2131 
2132   l_errcode1    varchar2(10) DEFAULT NULL;
2133   l_errcode     varchar2(50) DEFAULT NULL;
2134   PG_DEBUG varchar2(1);
2135 
2136   BEGIN
2137   PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
2138 
2139   --
2140   -- Check whether multiple country context exists in a single record.
2141   --
2142  l_errcode1 := check_mixed_countries(p_glob_attr_set1.global_attribute_category,
2143                                   p_glob_attr_set2.global_attribute_category,
2144                                p_glob_attr_set3.global_attribute_category);
2145 
2146  -- Concatenate the error codes into one variable
2147     l_errcode := l_errcode1;
2148 
2149   --
2150   -- Reject when global attribute value found where not expected
2151   --
2152     IF p_int_table_name = 'CUSTOMER' THEN
2153 
2154    -- Check for JG_HZ_CUST_ACCOUNTS and not JG_RA_CUSTOMERS
2155 
2156    /*l_errcode1 := check_each_gdf('JG_RA_CUSTOMERS',
2157                                      p_glob_attr_set1,
2158                                      p_glob_attr_general);*/
2159 
2160        l_errcode1 := check_each_gdf('JG_HZ_CUST_ACCOUNTS',
2161                                      p_glob_attr_set1,
2162                                      p_glob_attr_general);
2163 
2164         -- Concatenate the error codes to update the STATUS column
2165 
2166         l_errcode := l_errcode||l_errcode1;
2167 
2168         -- Check for JG_HZ_CUST_ACCT_SITES and not JG_RA_ADDRESSES
2169 
2170         /*l_errcode1 := check_each_gdf('JG_RA_ADDRESSES',
2171                                      p_glob_attr_set2,
2172                                      p_glob_attr_general);*/
2173 
2174         l_errcode1 := check_each_gdf('JG_HZ_CUST_ACCT_SITES',
2175                                      p_glob_attr_set2,
2176                                      p_glob_attr_general);
2177 
2178         l_errcode := l_errcode||l_errcode1;
2179 
2180         -- Check for JG_HZ_CUST_ACCT_SITES and not JG_RA_SITE_USES
2181 
2182        /*l_errcode1 := check_each_gdf('JG_RA_SITE_USES',
2183                                      p_glob_attr_set2,
2184                                      p_glob_attr_general);*/
2185 
2186 
2187         l_errcode1 := check_each_gdf('JG_HZ_CUST_SITE_USES',
2188                                      p_glob_attr_set3,
2189                                      p_glob_attr_general);
2190 
2191         l_errcode := l_errcode||l_errcode1;
2192 
2193        -- Bugfix 1999861. Added condition to check for any error,
2194        -- before updating interface table.
2195 
2196        IF l_errcode IS NOT NULL THEN
2197           --
2198           -- Update STATUS column of the customer interface table
2199           --
2200           JG_GLOBE_FLEX_VAL_SHARED.UPDATE_RA_CUSTOMERS_INTERFACE(
2201                                 l_errcode,
2202                                 p_glob_attr_general.core_prod_arg2,
2203                                 'E');
2204        END IF;
2205 
2206     ELSIF p_int_table_name = 'PROFILE' THEN
2207 
2208        -- Check for JG_HZ_CUSTOMER_PROFILES
2209        -- Since the existing global_attributes 1..20 in
2210        -- ra_customer_profiles_interface are used for profile amounts and
2211        -- gdf_cust_prof_attributes1..20 are used for customer_profiles,
2212        -- we are passing p_glob_attr_set2 argument for JG_HZ_CUSTOMER_PROFILES
2213        -- and p_glob_attr_set1 argument for JG_HZ_CUST_PROFILE_AMTS.
2214 
2215        /*l_errcode1 := check_each_gdf('JG_AR_CUSTOMER_PROFILES',
2216                                      p_glob_attr_set2,
2217                                      p_glob_attr_general);*/
2218 
2219        l_errcode1 := check_each_gdf('JG_HZ_CUSTOMER_PROFILES',
2220                                      p_glob_attr_set2,
2221                                      p_glob_attr_general);
2222        l_errcode := l_errcode||l_errcode1;
2223 
2224        -- Check for JG_HZ_CUST_PROFILE_AMNTS and not JG_AR_CUSTOMER_PROFILE_AMOUNTS
2225 
2226         /*l_errcode1 := check_each_gdf('JG_AR_CUSTOMER_PROFILE_AMOUNTS',
2227                                      p_glob_attr_set2,
2228                                      p_glob_attr_general);*/
2229 
2230        l_errcode1 := check_each_gdf('JG_HZ_CUST_PROFILE_AMTS',
2231                                      p_glob_attr_set1,
2232                                      p_glob_attr_general);
2233        l_errcode := l_errcode||l_errcode1;
2234 
2235        --
2236        -- Update STATUS column of the profile interface table
2237        --
2238       JG_GLOBE_FLEX_VAL_SHARED.UPDATE_INTERFACE_STATUS(
2239                                 p_glob_attr_general.core_prod_arg2,
2240                                 'RA_CUSTOMER_PROFILES_INTERFACE',
2241                                 l_errcode,
2242                                 'E');
2243 
2244     END IF;
2245 
2246     --
2247     -- Return the record status
2248     --
2249     IF l_errcode is NOT NULL THEN
2250        p_current_record_status := 'E';
2251     ELSE
2252        p_current_record_status := 'S';
2253     END IF;
2254 
2255   EXCEPTION
2256       WHEN OTHERS THEN
2257         IF PG_DEBUG in ('Y', 'C') THEN
2258            arp_standard.debug('check_ar_context_integrity: ' || 'Exception calling JG_GLOBE_FLEX_VAL.CHECK_AR_CONTEXT
2259 _INTEGRITY()');
2260            arp_standard.debug('check_ar_context_integrity: ' || SQLERRM);
2261         END IF;
2262 
2263   END check_ar_context_integrity;
2264 
2265   --
2266   -- End of modification
2267   --
2268 
2269   ---------------------------------------------------------------------------
2270   -- CHECK_AR_BUSINESS_RULES():
2271   --    This procedure validates AR global flexfield values.
2272   --------------------------------------------------------------------------
2273 /*
2274   PROCEDURE check_ar_business_rules(
2275       p_calling_program_name            IN    VARCHAR2,
2276       p_sob_id                          IN    NUMBER,
2277       p_row_id                          IN    VARCHAR2,
2278       p_customer_name                   IN    VARCHAR2,
2279       p_customer_number                 IN    VARCHAR2,
2280       p_jgzz_fiscal_code                IN    VARCHAR2,
2281       p_generate_customer_number        IN    VARCHAR2,
2282       p_orig_system_customer_ref        IN    VARCHAR2,
2283       p_insert_update_flag              IN    VARCHAR2,
2284       p_request_id                      IN    NUMBER,
2285       p_global_attribute_category       IN    VARCHAR2,
2286       p_global_attribute1               IN    VARCHAR2,
2287       p_global_attribute2               IN    VARCHAR2,
2288       p_global_attribute3               IN    VARCHAR2,
2289       p_global_attribute4               IN    VARCHAR2,
2290       p_global_attribute5               IN    VARCHAR2,
2291       p_global_attribute6               IN    VARCHAR2,
2292       p_global_attribute7               IN    VARCHAR2,
2293       p_global_attribute8               IN    VARCHAR2,
2294       p_global_attribute9               IN    VARCHAR2,
2295       p_global_attribute10              IN    VARCHAR2,
2296       p_global_attribute11              IN    VARCHAR2,
2297       p_global_attribute12              IN    VARCHAR2,
2298       p_global_attribute13              IN    VARCHAR2,
2299       p_global_attribute14              IN    VARCHAR2,
2300       p_global_attribute15              IN    VARCHAR2,
2301       p_global_attribute16              IN    VARCHAR2,
2302       p_global_attribute17              IN    VARCHAR2,
2303       p_global_attribute18              IN    VARCHAR2,
2304       p_global_attribute19              IN    VARCHAR2,
2305       p_global_attribute20              IN    VARCHAR2,
2306       p_current_record_status           OUT NOCOPY   VARCHAR2) IS
2307 
2308   l_current_record_status       VARCHAR2(1):='S';
2309 
2310  BEGIN
2311   -------------------------- DEBUG INFORMATION ------------------------------
2312   IF PG_DEBUG in ('Y', 'C') THEN
2313      arp_standard.debug('check_ar_business_rules: ' || 'Begin Check ar business rules');
2314   END IF;
2315   ---------------------------------------------------------------------------
2316 
2317   ------------------------------------------------------------------------------
2318 --------
2319   --                         Global Flexfield Validation
2320   ------------------------------------------------------------------------------
2321 --------
2322   --  You can add your own validation code for your global flexfields.
2323   --
2324   --  Form Name:  ARXCUDCI
2325   ------------------------------------------------------------------------------
2326 --------
2327   --   Header Level Validation - Block Name: CUST
2328   ------------------------------------------------------------------------------
2329 --------
2330   --    1-1. JL.CL.ARXCUDCI.CUSTOMERS
2331   --    1-2. JL.CO.ARXCUDCI.CUSTOMERS
2332   --    1-3. JL.AR.ARXCUDCI.CUSTOMERS
2333   --    1-4. JL.BR.ARXCUDCI.Additional
2334 --------------------------------------------------------------------------------
2335 ------
2336 
2337   --    1-1. JL.CL.ARXCUDCI.RA_CUSTOMERS
2338   --
2339   IF (p_global_attribute_category in ( 'JL.CL.ARXCUDCI.CUSTOMERS',
2340                                        'JL.CO.ARXCUDCI.CUSTOMERS',
2341                                        'JL.BR.ARXCUDCI.Additional',
2342                                        'JL.AR.ARXCUDCI.CUSTOMERS')) THEN
2343    jl_interface_val.ar_business_rules(
2344                 p_calling_program_name,
2345                 p_sob_id,
2346                 p_row_id,
2347                 p_customer_name,
2348                 p_customer_number,
2349                 p_jgzz_fiscal_code,
2350                 p_generate_customer_number,
2351                 p_orig_system_customer_ref,
2352                 p_insert_update_flag,
2353                 p_request_id,
2354                 p_global_attribute_category,
2355                 p_global_attribute1,
2356                 p_global_attribute2,
2357                 p_global_attribute3,
2358                 p_global_attribute4,
2359                 p_global_attribute5,
2360                 p_global_attribute6,
2361                 p_global_attribute7,
2362                 p_global_attribute8,
2363                 p_global_attribute9,
2364                 p_global_attribute10,
2365                 p_global_attribute11,
2366                 p_global_attribute12,
2367                 p_global_attribute13,
2368                 p_global_attribute14,
2369                 p_global_attribute15,
2370                 p_global_attribute16,
2371                 p_global_attribute17,
2372                 p_global_attribute18,
2373                 p_global_attribute19,
2374                 p_global_attribute20,
2375                 l_current_record_status);
2376   END IF;
2377 
2378       p_current_record_status := l_current_record_status;
2379 
2380   EXCEPTION
2381     WHEN OTHERS THEN
2382       IF PG_DEBUG in ('Y', 'C') THEN
2383          arp_standard.debug('Exception in JG_GLOBE_FLEX_VAL.CHECK_AR_BUSINESS_RULES()');
2384          arp_standard.debug('check_ar_business_rules: ' || SQLERRM);
2385       END IF;
2386   END check_ar_business_rules;
2387 */
2388 
2389 --
2390 -- Modified version of check_ar_business_rules
2391 --
2392   PROCEDURE check_ar_business_rules(
2393       p_int_table_name            IN    VARCHAR2,
2394       p_glob_attr_set1            IN    jg_globe_flex_val_shared.GdfRec,
2395       p_glob_attr_set2            IN    jg_globe_flex_val_shared.GdfRec,
2396       p_glob_attr_set3            IN    jg_globe_flex_val_shared.GdfRec,
2397       p_glob_attr_general         IN    jg_globe_flex_val_shared.GenRec,
2398       p_current_record_status     OUT NOCOPY   VARCHAR2,
2399       p_org_id                    IN  NUMBER ) IS --2354736
2400 
2401 
2402   l_current_record_status  VARCHAR2(1);
2403   l_product_code           VARCHAR2(10);
2404   l_org_id                 NUMBER;
2405   PG_DEBUG varchar2(1);
2406 
2407  BEGIN
2408 
2409   PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
2410 
2411   if p_org_id is null then
2412     --l_org_id :=  to_number(fnd_profile.value ('ORG_ID'));
2413     --
2414     --Bug 4499004
2415     --
2416     SELECT org_id into l_org_id FROM fnd_concurrent_requests
2417     WHERE request_id = fnd_global.conc_request_id ;
2418 
2419     fnd_request.set_org_id(l_org_id);
2420   end if;
2421 
2422   l_current_record_status  := 'S';
2423   --2354736
2424   l_product_code := JG_ZZ_SHARED_PKG.GET_PRODUCT(l_org_id,NULL, null);
2425 
2426   --IF sys_context('JG',l_product_code) = 'JA' THEN  --2354736
2427   IF l_product_code = 'JA' THEN
2428   --IF sys_context('JG','JGZZ_PRODUCT_CODE') = 'JA' THEN
2429 
2430     ja_interface_val.ar_business_rules(
2431                   'CUSTOMER',
2432                   p_glob_attr_set1,
2433                   p_glob_attr_set2,
2434                   p_glob_attr_set3,
2435                   p_glob_attr_general,
2436                   l_current_record_status);
2437 
2438 --Validate for the customer address and customer profile
2439   --ELSIF sys_context('JG',l_product_code) = 'JL' THEN  --2354736
2440   ELSIF l_product_code = 'JL' THEN
2441   --ELSIF sys_context('JG','JGZZ_PRODUCT_CODE') = 'JL' THEN
2442 
2443            jl_interface_val.ar_business_rules(
2444     		p_int_table_name,
2445     		p_glob_attr_set1,
2446     		p_glob_attr_set2,
2447     		p_glob_attr_set3,
2448     		p_glob_attr_general,
2449 	        l_current_record_status);
2450           --Validate for the customer in JE Amar added
2451     ELSIF l_product_code = 'JE' THEN
2452   --ELSIF sys_context('JG',l_product_code) = 'JE' THEN  --2354736
2453   --ELSIF sys_context('JG','JGZZ_PRODUCT_CODE') = 'JE' THEN
2454           je_interface_val.ar_business_rules(
2455                'CUSTOMER',
2456                p_glob_attr_set1,
2457                p_glob_attr_set2,
2458                p_glob_attr_set3,
2459                p_glob_attr_general,
2460                l_current_record_status);
2461            -- End Validate for the customer in JE Amar Added.
2462 
2463    END IF;
2464 
2465   p_current_record_status := l_current_record_status;
2466 
2467   EXCEPTION
2468     WHEN OTHERS THEN
2469       IF PG_DEBUG in ('Y', 'C') THEN
2470          arp_standard.debug('Exception in JG_GLOBE_FLEX_VAL.CHECK_AR_BUSINESS_RULES()');
2471          arp_standard.debug('check_ar_business_rules: ' || SQLERRM);
2472       END IF;
2473   END check_ar_business_rules;
2474 
2475 
2476 --
2477 -- End of modification
2478 --
2479 
2480 -- The Following procedure is stubbed out due to the obsoletion of table jg_zz_invoice_info.
2481 -- The table was used in the different EFT solution in JE and this functionality is now
2482 -- covered in Oracle Payments.
2483 
2484 PROCEDURE insert_jg_zz_invoice_info
2485      (p_invoice_id                      IN     NUMBER,
2486       p_global_attribute_category       IN OUT NOCOPY VARCHAR2,
2487       p_global_attribute1               IN OUT NOCOPY VARCHAR2,
2488       p_global_attribute2               IN OUT NOCOPY VARCHAR2,
2489       p_global_attribute3               IN OUT NOCOPY VARCHAR2,
2490       p_global_attribute4               IN OUT NOCOPY VARCHAR2,
2491       p_global_attribute5               IN OUT NOCOPY VARCHAR2,
2492       p_global_attribute6               IN OUT NOCOPY VARCHAR2,
2493       p_global_attribute7               IN OUT NOCOPY VARCHAR2,
2494       p_global_attribute8               IN OUT NOCOPY VARCHAR2,
2495       p_global_attribute9               IN OUT NOCOPY VARCHAR2,
2496       p_global_attribute10              IN OUT NOCOPY VARCHAR2,
2497       p_global_attribute11              IN OUT NOCOPY VARCHAR2,
2498       p_global_attribute12              IN OUT NOCOPY VARCHAR2,
2499       p_global_attribute13              IN OUT NOCOPY VARCHAR2,
2500       p_global_attribute14              IN OUT NOCOPY VARCHAR2,
2501       p_global_attribute15              IN OUT NOCOPY VARCHAR2,
2502       p_global_attribute16              IN OUT NOCOPY VARCHAR2,
2503       p_global_attribute17              IN OUT NOCOPY VARCHAR2,
2504       p_global_attribute18              IN OUT NOCOPY VARCHAR2,
2505       p_global_attribute19              IN OUT NOCOPY VARCHAR2,
2506       p_global_attribute20              IN OUT NOCOPY VARCHAR2,
2507       p_last_updated_by                 IN     NUMBER,
2508       p_last_update_date                IN     DATE,
2509       p_last_update_login               IN     NUMBER,
2510       p_created_by                      IN     NUMBER,
2511       p_creation_date                   IN     DATE,
2512       p_calling_sequence                IN     VARCHAR2) IS
2513 
2514         l_debug_loc                     VARCHAR2(30);
2515         l_curr_calling_sequence         VARCHAR2(2000);
2516         l_debug_info                    VARCHAR2(100);
2517    PG_DEBUG varchar2(1);
2518 
2519   BEGIN
2520 	NULL;
2521 --  PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
2522 --        l_debug_loc   := 'Insert_Jg_Zz_Invoice_Info';
2523 --
2524 --    -------------------------- DEBUG INFORMATION ------------------------------
2525 --    l_curr_calling_sequence := 'jg_globe_flex_val.'||l_debug_loc||'<-'||p_calling_sequence;
2526 --    l_debug_info := 'Insert invoices to jg_zz_invice_info';
2527 --    ---------------------------------------------------------------------------
2528 --  IF p_global_attribute_category IN ('BE.EFT Payments','CH.Swiss DTA Payment','CH.Swiss SAD Payment',
2529 --                                     'DK','DK.GiroBank Domestic','DK.GiroBank Foreign',
2530 --                                     'DK.Unitel Domestic','DK.Unitel Foreign','FI.A-lomake',
2531 --                                     'FI.B-lomake','FI.Konekielinen viite','FI.Vapaa viite',
2532 --                                     'NL.Foreign Payments','NO','NO.Norway',
2533 --                                     'SE.Bankgiro SISU','SE.Bankgiro UTLI','SE.Postgiro Inland',
2534 --                                    'SE.Postgiro Utland' , 'SE.Bankgiro Inland') THEN
2535 --    INSERT INTO jg_zz_invoice_info
2536 --       (invoice_id,
2537 --       jgzz_attribute_category,
2538 --        jgzz_invoice_info1,
2539 --        jgzz_invoice_info2,
2540 --        jgzz_invoice_info3,
2541 --        jgzz_invoice_info4,
2542 --        jgzz_invoice_info5,
2543 --        jgzz_invoice_info6,
2544 --        jgzz_invoice_info7,
2545 --        jgzz_invoice_info8,
2546 --        jgzz_invoice_info9,
2547 --        jgzz_invoice_info10,
2548 --        jgzz_invoice_info11,
2549 --        jgzz_invoice_info12,
2550 --        jgzz_invoice_info13,
2551 --        jgzz_invoice_info14,
2552 --        jgzz_invoice_info15,
2553 --        jgzz_invoice_info16,
2554 --        jgzz_invoice_info17,
2555 --        jgzz_invoice_info18,
2556 --        jgzz_invoice_info19,
2557 --        jgzz_invoice_info20, --This table has up to 30 columns,however
2558 --        last_updated_by,     --column 21 thru 30 are invalid since the
2559 --        last_update_date,    --base table has only 20 global flexfields.
2560 --        last_update_login,   --Hence, no insertion to those columns are
2561 --        created_by,          --required. Their values will always be null.
2562 --        creation_date)       -- Agreed by Jason.
2563 --    SELECT
2564 --        p_invoice_id,
2565 --        p_global_attribute_category,
2566 --        p_global_attribute1,
2567 --        p_global_attribute2,
2568 --        p_global_attribute3,
2569 --        p_global_attribute4,
2570 --        p_global_attribute5,
2571 --        p_global_attribute6,
2572 --        p_global_attribute7,
2573 --        p_global_attribute8,
2574 --        p_global_attribute9,
2575 --        p_global_attribute10,
2576 --        p_global_attribute11,
2577 --        p_global_attribute12,
2578 --        p_global_attribute13,
2579 --        p_global_attribute14,
2580 --        p_global_attribute15,
2581 --        p_global_attribute16,
2582 --        p_global_attribute17,
2583 --        p_global_attribute18,
2584 --        p_global_attribute19,
2585 --        p_global_attribute20,
2586 --        p_last_updated_by,
2587 --        DECODE(p_last_update_date,NULL,sysdate,p_last_update_date),
2588 --        p_last_update_login,
2589 --        p_created_by,
2590 --        DECODE(p_creation_date,NULL,sysdate,p_creation_date)
2591 --    FROM DUAL;
2592 --
2593 --        p_global_attribute_category := NULL;
2594 --        p_global_attribute1         := NULL;
2595 --        p_global_attribute2         := NULL;
2596 --        p_global_attribute3         := NULL;
2597 --        p_global_attribute4         := NULL;
2598 --        p_global_attribute5         := NULL;
2599 --        p_global_attribute6         := NULL;
2600 --        p_global_attribute7         := NULL;
2601 --        p_global_attribute8         := NULL;
2602 --        p_global_attribute9         := NULL;
2603 --        p_global_attribute10        := NULL;
2604 --        p_global_attribute11        := NULL;
2605 --        p_global_attribute12        := NULL;
2606 --        p_global_attribute13        := NULL;
2607 --        p_global_attribute14        := NULL;
2608 --        p_global_attribute15        := NULL;
2609 --        p_global_attribute16        := NULL;
2610 --        p_global_attribute17        := NULL;
2611 --        p_global_attribute18        := NULL;
2612 --        p_global_attribute19        := NULL;
2613 --        p_global_attribute20        := NULL;
2614 --
2615 --  END IF;
2616 --  EXCEPTION
2617 --    WHEN OTHERS THEN
2618 --      IF (SQLCODE <> -20001) THEN
2619 --        FND_MESSAGE.SET_NAME('SQLAP','AP_DEBUG');
2620 --        FND_MESSAGE.SET_TOKEN('ERROR',SQLERRM);
2621 --        FND_MESSAGE.SET_TOKEN('CALLING_SEQUENCE',l_curr_calling_sequence);
2622 --        FND_MESSAGE.SET_TOKEN('DEBUG_INFO',l_debug_info);
2623 --      END IF;
2624 --      APP_EXCEPTION.RAISE_EXCEPTION;
2625   END;
2626 
2627   PROCEDURE insert_global_tables
2628      (p_table_name        IN VARCHAR2,
2629       p_key_column1       IN VARCHAR2,
2630       p_key_column2       IN VARCHAR2,
2631       p_key_column3       IN VARCHAR2,
2632       p_key_column4       IN VARCHAR2,
2633       p_key_column5       IN VARCHAR2,
2634       p_key_column6       IN VARCHAR2) IS
2635 
2636     l_product_code  VARCHAR2(2);
2637   PG_DEBUG varchar2(1);
2638 
2639   BEGIN
2640   PG_DEBUG := NVL(FND_PROFILE.value('AR_ENABLE_DEBUG_OUTPUT'), 'N');
2641 
2642     l_product_code := fnd_profile.value('JG_PRODUCT_CODE');
2643 
2644     IF l_product_code = 'JL' THEN
2645       --
2646       -- Call jl cover package
2647       --
2648       -- jl_interface_val.insert_global_tables(
2649       --                  p_table_name
2650       --                 ,p_key_column1
2651       --                 ,p_key_column2
2652       --                 ,p_key_column3
2653       --                 ,p_key_column4
2654       --                 ,p_key_column5
2655       --                 ,p_key_column6
2656       --
2657       NULL;
2658     END IF;
2659   EXCEPTION
2660     WHEN OTHERS THEN
2661       arp_standard.debug('Exception calling JG_GLOBE_FLEX_VAL.insert_global_tabl
2662 es');
2663       arp_standard.debug(SQLERRM);
2664       app_exception.raise_exception;
2665   END;
2666 
2667 -- Bug 8859419 Start
2668 
2669    -- Evaluates whether a specific GDF context exists                 |
2670 
2671    Function Gdf_Context_Exists(p_gdf_context IN Varchar2) Return Boolean IS
2672       /* Checks whether the context is enabled for the country. It checks the contexts
2673          only for the JG_RA_CUSTOMER_TRX_LINES gdf. */
2674 
2675       --Bug 9080741 Modified cursor to be generic for all countries
2676       Cursor C_Gdf_Context Is
2677           Select 'Yes' exist_flag
2678           From fnd_descr_flex_contexts
2679           Where application_id  = 7003
2680           And descriptive_flexfield_name like 'JG_AP_INVOICE_DISTRIBUTIONS'
2681           And descriptive_flex_context_code = p_gdf_context
2682           --And substr(descriptive_flex_context_code, 4, 2) =  cp_country_code
2683           and enabled_flag = 'Y';
2684       l_exist Varchar2(30);
2685       l_country_code Varchar2(30);
2686       l_api_name CONSTANT VARCHAR2(200) := 'Gdf_Context_Exists';
2687       l_debug_info Varchar2(2000);
2688    Begin
2689       l_debug_info := 'Begining of Function';
2690       If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2691          Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2692       End If;
2693 
2694       l_exist := 'No';
2695 
2696       --Bug 9080741
2697       --fnd_profile.get('JGZZ_COUNTRY_CODE', l_country_code);
2698       --l_debug_info := 'Country Code is : ' || l_country_code;
2699       --If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2700         -- Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2701       --End If;
2702 
2703       --If (l_country_code = 'AR') THEN --Bug 9080741
2704          l_debug_info := 'Index Value : ' || p_gdf_context;
2705          If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2706             Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2707          End If;
2708          If G_GDF_CONTEXT_T.Count > 0 Then
2709             If G_GDF_CONTEXT_T.Exists(p_gdf_context) Then
2710                l_exist := 'Yes';
2711                l_debug_info := 'GDF Context ' || p_gdf_context || ' found in the PL/SQL Table' ;
2712                If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2713                   Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2714                End If;
2715             Else
2716                For C_Gdf_Context_Rec in C_Gdf_Context Loop
2717                   G_GDF_CONTEXT_T(p_gdf_context).global_attribute_category := p_gdf_context;
2718                   l_exist := C_Gdf_Context_Rec.exist_flag;
2719                   l_debug_info := 'GDF Context ' || p_gdf_context || ' found in the Database' ;
2720                   If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2721                      Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2722                   End If;
2723                End Loop;
2724             End If;
2725          Else
2726             For C_Gdf_Context_Rec in C_Gdf_Context Loop
2727                G_GDF_CONTEXT_T(p_gdf_context).global_attribute_category := p_gdf_context;
2728                l_exist := C_Gdf_Context_Rec.exist_flag;
2729                l_debug_info := 'GDF Context ' || p_gdf_context || ' found in the Database' ;
2730                If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2731                   Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2732                End If;
2733             End Loop;
2734          End If;
2735       --End If;
2736       If upper(l_exist) = 'YES' THEN
2737          l_debug_info := 'GDF Context ' || p_gdf_context || ' found, returning TRUE' ;
2738          If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2739             Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2740          End If;
2741          Return TRUE;
2742       Else
2743          l_debug_info := 'GDF Context ' || p_gdf_context || ' not found , returning FALSE' ;
2744          If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) Then
2745              Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2746          End If;
2747          Return FALSE;
2748       End If;
2749    Exception
2750       When Others Then
2751          l_debug_info := 'Exception Encountered, returning FALSE' ;
2752          If (G_LEVEL_STATEMENT >= G_CURRENT_RUNTIME_LEVEL) THEN
2753             Fnd_Log.String(G_LEVEL_STATEMENT,G_MODULE_NAME||l_api_name,l_debug_info);
2754          End If;
2755          Return FALSE;
2756    End Gdf_Context_Exists;
2757 
2758 -- Bug 8859419 End
2759 END jg_globe_flex_val;