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