DBA Data[Home] [Help]

PACKAGE BODY: APPS.JE_GR_TRIAL_BALANCE

Source


1 PACKAGE BODY JE_GR_TRIAL_BALANCE as
2 /* $Header: jegrftbb.pls 120.4.12020000.2 2012/07/18 12:56:32 rshergil noship $ */
3 
4 /*------------------------------------------------------------------+
5  | Package Cursor and Variables                                     |
6  +------------------------------------------------------------------*/
7 
8 /* The following v_n_% variables are needed to include the delimiter
9    in the account segment value as well as the parent level values */
10 
11 v_1_width NUMBER := 0;
12 v_1_start NUMBER := 0;
13 v_1_end   NUMBER := 0;
14 v_2_width NUMBER := 0;
15 v_2_start NUMBER := 0;
16 v_2_end   NUMBER := 0;
17 v_3_width NUMBER := 0;
18 v_3_start NUMBER := 0;
19 v_3_end   NUMBER := 0;
20 v_4_width NUMBER := 0;
21 v_4_start NUMBER := 0;
22 v_4_end   NUMBER := 0;
23 v_5_width NUMBER := 0;
24 v_5_start NUMBER := 0;
25 v_5_end   NUMBER := 0;
26 v_6_width NUMBER := 0;
27 v_6_start NUMBER := 0;
28 v_6_end   NUMBER := 0;
29 v_7_width NUMBER := 0;
30 v_7_start NUMBER := 0;
31 v_7_end   NUMBER := 0;
32 v_8_width NUMBER := 0;
33 v_8_start NUMBER := 0;
34 v_8_end   NUMBER := 0;
35 v_9_width NUMBER := 0;
36 v_9_start NUMBER := 0;
37 v_9_end   NUMBER := 0;
38 
39 
40 /*------------------------------------------------------------------+
41  | Private Procedures/Functions - Specification                     |
42  +------------------------------------------------------------------*/
43 
44 PROCEDURE clean_up_hierarchy (p_idx IN NUMBER);
45 PROCEDURE insert_delimiter   (p_idx IN NUMBER, p_delimiter VARCHAR2);
46 
47 /*------------------------------------------------------------------+
48  | Public Procedures/Functions                                      |
49  +------------------------------------------------------------------*/
50 
51 /*------------------------------------------------------------------+
52  | PROCEDURE: init_account_hierarchy                                |
53  +------------------------------------------------------------------*/
54 
55 FUNCTION  init_account_hierarchy (p_request_id        IN     NUMBER,
56                                   p_delimiter         IN     VARCHAR2,
57                                   p_retcode           IN OUT NOCOPY NUMBER,
58 				  p_errmsg            IN OUT NOCOPY VARCHAR2)
59 RETURN NUMBER is
60 
61 v_idx			           NUMBER;
62 v_parent_value         varchar2(100);
63 v_child_value          varchar2(100);
64 v_hier_level           NUMBER;
65 v_step                 varchar2(100);
66 v_found_parent         BOOLEAN;
67 v_max_levels           NUMBER := 0;
68 v_status               BOOLEAN;
69 v_chart_of_accounts_id NUMBER;
70 v_acct_segnum          NUMBER;
71 v_appcol_name          VARCHAR2(100);
72 v_prompt               VARCHAR2(100);
73 v_value_set_name       VARCHAR2(100);
74 v_value_set_id         NUMBER;
75 v_seg_name             VARCHAR2(100);
76 v_flexfield            FND_FLEX_KEY_API.flexfield_type;
77 v_structure            FND_FLEX_KEY_API.structure_type;
78 v_segment              FND_FLEX_KEY_API.segment_type;
79 v_set_of_books_id      NUMBER;
80 
81 /* This cursor selects all the account segments that we need to get parents
82    for */
83 
87    where  request_id = c_request_id;
84 cursor c_account_values (c_request_id NUMBER) is
85    select distinct account_segment
86    from   gl_rx_trial_balance_itf
88 
89 
90 /* This cursor select the parent of a child value */
91 
92 cursor c_parent_value (c_flex_value_set_id NUMBER, c_child_value varchar2) is
93    select
94      c.parent_flex_value,
95      to_number(fv.hierarchy_level)
96    from
97      FND_FLEX_VALUES FV,
98      FND_FLEX_VALUE_CHILDREN_V C
99    where
100      c.flex_value_set_id =  c_flex_value_set_id and
101      c.flex_value = c_child_value and
102      fv.flex_value_set_id = c.flex_value_set_id and
103      fv.flex_value = c.parent_flex_value
104    order by fv.hierarchy_level desc;
105 
106 begin
107 
108  v_step := 'c_account_values loop';
109 
110  /* If this is not the first call, don't populate global PL/SQL table again */
111 
112  if (g_request_id = p_request_id) then goto done; end if;
113 
114  g_request_id := p_request_id;
115 
116  v_set_of_books_id := fnd_profile.value('GL_SET_OF_BKS_ID');
117 
118  select chart_of_accounts_id
119  into   v_chart_of_accounts_id
120  from   gl_sets_of_books
121  where  set_of_books_id = v_set_of_books_id;
122 
123  v_status := FND_FLEX_APIS.GET_QUALIFIER_SEGNUM (
124                 		appl_id           => 101,
125 				key_flex_code     => 'GL#',
126 				structure_number  => v_chart_of_accounts_id,
127 				flex_qual_name    => 'GL_ACCOUNT',
128 				segment_number    => v_acct_segnum);
129 
130  v_status := FND_FLEX_APIS.GET_SEGMENT_INFO (
131  		  	    	x_application_id  => 101,
132 				x_id_flex_code    => 'GL#',
133 				x_id_flex_num     => v_chart_of_accounts_id,
134 				x_seg_num         => v_acct_segnum,
135                 		x_seg_name        => v_seg_name,
136 				x_appcol_name     => v_appcol_name,
137 				x_prompt          => v_prompt,
138 				x_value_set_name  => v_value_set_name);
139 
140  /* Bug 2560279: Set up session mode. */
141  FND_FLEX_KEY_API.set_session_mode('customer_data');
142 
143  v_flexfield    := FND_FLEX_KEY_API.FIND_FLEXFIELD ('SQLGL', 'GL#');
144  v_structure    := FND_FLEX_KEY_API.FIND_STRUCTURE (v_flexfield, v_chart_of_accounts_id);
145  v_segment      := FND_FLEX_KEY_API.FIND_SEGMENT   (v_flexfield, v_structure, v_seg_name);
146  v_value_set_id := v_segment.value_set_id;
147 
148  open c_account_values (p_request_id);
149 
150  /* The following loop fetches all accounts for which we have to find
151     the parents */
152 
153  LOOP
154 
155    fetch c_account_values into v_child_value;
156    exit  when c_account_values%NOTFOUND;
157 
158    v_step := 'c_parent_value_loop';
159 
160    /* Initalize global PL/SQL table */
161 
162    g_account_tab(g_idx).account := v_child_value;
163    g_account_tab(g_idx).delimit_account := v_child_value;
164    g_account_tab(g_idx).levels  := 0;
165    g_account_tab(g_idx).L1      := '';
166    g_account_tab(g_idx).L2      := '';
167    g_account_tab(g_idx).L3      := '';
168    g_account_tab(g_idx).L4      := '';
169    g_account_tab(g_idx).L5      := '';
170    g_account_tab(g_idx).L6      := '';
171    g_account_tab(g_idx).L7      := '';
172    g_account_tab(g_idx).L8      := '';
173    g_account_tab(g_idx).L9      := '';
174 
175    /* The following loop takes the child value and goes up the
176       hierarchy until the top level parent was found. It stores
177       one record per account in global PL/SQL table g_account_tab. */
178 
179    LOOP
180 
181      v_step := 'c_parent_value_loop';
182 
183      open  c_parent_value (v_value_set_id, v_child_value);
184      fetch c_parent_value into v_parent_value, v_hier_level;
185      exit  when c_parent_value%NOTFOUND; /* At top of hierarchy */
186 
187      /* Populate PL/SQL table */
188 
189      if    (v_hier_level = 1) then
190 	        g_account_tab(g_idx).L1     := v_parent_value;
191 	        g_account_tab(g_idx).levels := 1;
192 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
193 	 elsif (v_hier_level = 2) then
194 	        g_account_tab(g_idx).L2     := v_parent_value;
195 	        g_account_tab(g_idx).levels := 2;
196 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
197 	 elsif (v_hier_level = 3) then
198 	        g_account_tab(g_idx).L3     := v_parent_value;
199 	        g_account_tab(g_idx).levels := 3;
200 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
201 	 elsif (v_hier_level = 4) then
202 	        g_account_tab(g_idx).L4     := v_parent_value;
203 	        g_account_tab(g_idx).levels := 4;
204 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
205 	 elsif (v_hier_level = 5) then
206 	        g_account_tab(g_idx).L5     := v_parent_value;
207 	        g_account_tab(g_idx).levels := 5;
208 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
209 	 elsif (v_hier_level = 6) then
210 	        g_account_tab(g_idx).L6     := v_parent_value;
211 	        g_account_tab(g_idx).levels := 6;
212 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
213 	 elsif (v_hier_level = 7) then
214 	        g_account_tab(g_idx).L7     := v_parent_value;
215 	        g_account_tab(g_idx).levels := 7;
216 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
217 	 elsif (v_hier_level = 8) then
218 	        g_account_tab(g_idx).L8     := v_parent_value;
219 	        g_account_tab(g_idx).levels := 8;
220 		if (v_max_levels < v_hier_level) then v_max_levels := v_hier_level; end if;
221 	 elsif (v_hier_level = 9) then
225 
222 	        g_account_tab(g_idx).L9     := v_parent_value;
223 	        g_account_tab(g_idx).levels := 9;
224 	 end if; close c_parent_value;
226      /* for next open/fetch/close round the current parent will be the new child */
227 
228      v_child_value := v_parent_value;
229 
230    end loop;
231 
232    close c_parent_value;
233 
234    g_idx := g_idx + 1;
235 
236  END LOOP;
237 
238  close c_account_values;
239 
240  /* Insert delimiter at correct position for account segment value and
241     parent level value */
242 
243  FOR v_idx in 0..g_idx-1 LOOP
244 
245   if (g_account_tab(v_idx).levels > 0)
246   then
247 
248     /* We need to clean up the level hierarchy in case there are any gaps
249        between the top level parent and the actual account (lowest level entry) */
250 
251     clean_up_hierarchy (v_idx);
252 
253     /* Insert the delimiter into both the account and the parent level values */
254 
255     insert_delimiter (v_idx, p_delimiter);
256 
257   end if;
258 
259  END LOOP;
260 
261  <<done>>
262 
263  return(v_max_levels);
264 
265 EXCEPTION
266   WHEN OTHERS THEN
267      if c_account_values%ISOPEN then close c_account_values; end if;
268      if c_parent_value%ISOPEN   then close c_parent_value;   end if;
269      p_retcode := -1;
270 	 p_errmsg  := 'Error occurred in je_gr_trial_balance.init_account_hierarchy: ' || sqlerrm;
271 	 return(v_max_levels);
272 end;
273 
274 /*------------------------------------------------------------------+
275  | FUNCTION: get_level_value                                        |
276  +------------------------------------------------------------------*/
277 
278 FUNCTION get_level_value  (p_level   IN     NUMBER,
279                            p_account IN     VARCHAR2)
280 RETURN VARCHAR2 is
281 
282 v_idx	       NUMBER;
283 v_string       VARCHAR2(150);
284 
285 BEGIN
286  v_string := '';
287  FOR v_idx in 0..g_idx-1 LOOP
288 
289     if (g_account_tab(v_idx).account = p_account)
290     then
291        if    (p_level = 0) then v_string := g_account_tab(v_idx).delimit_account;
292        elsif (p_level = 1) then v_string := g_account_tab(v_idx).L1;
293        elsif (p_level = 2) then v_string := g_account_tab(v_idx).L2;
294        elsif (p_level = 3) then v_string := g_account_tab(v_idx).L3;
295        elsif (p_level = 4) then v_string := g_account_tab(v_idx).L4;
296        elsif (p_level = 5) then v_string := g_account_tab(v_idx).L5;
297        elsif (p_level = 6) then v_string := g_account_tab(v_idx).L6;
298        elsif (p_level = 7) then v_string := g_account_tab(v_idx).L7;
299        elsif (p_level = 8) then v_string := g_account_tab(v_idx).L8;
300        elsif (p_level = 9) then v_string := g_account_tab(v_idx).L9;
301        end if;
302     end if;
303 
304  END LOOP;
305 
306  return(v_string);
307 
308 EXCEPTION
309   WHEN OTHERS THEN
310      return(NULL);
311 END;
312 
313 
314 /*------------------------------------------------------------------+
315  | Private Procedures                                               |
316  +------------------------------------------------------------------*/
317 
318 /*------------------------------------------------------------------+
319  | PROCEDURE: clean_up_hierarchy                                    |
320  +------------------------------------------------------------------*/
321 
322 PROCEDURE clean_up_hierarchy (p_idx IN NUMBER) IS
323 
324 v_clean_level          NUMBER;
325 
326 BEGIN
327 
328   /* Clean up the hierarchy for each account; have to do this in case there
329      is a gap in the hierarchy between the top level entry (L1) and the lowest
330      level entry (account) */
331 
332    v_clean_level := 0;
333 
334    /* Determine if cleanup needs to be performed */
335 
336    if    (g_account_tab(p_idx).L1 is NULL) then
337        v_clean_level := 1;
338    elsif (g_account_tab(p_idx).L2 is NULL) then
339        v_clean_level := 2;
340    elsif (g_account_tab(p_idx).L3 is NULL) then
341        v_clean_level := 3;
342    elsif (g_account_tab(p_idx).L4 is NULL) then
343        v_clean_level := 4;
344    elsif (g_account_tab(p_idx).L5 is NULL) then
345        v_clean_level := 5;
346    elsif (g_account_tab(p_idx).L6 is NULL) then
347        v_clean_level := 6;
348    elsif (g_account_tab(p_idx).L7 is NULL) then
349        v_clean_level := 7;
350    elsif (g_account_tab(p_idx).L8 is NULL) then
351        v_clean_level := 8;
352    elsif (g_account_tab(p_idx).L9 is NULL) then
353        v_clean_level := 9;
354    end if;
355 
356    if (v_clean_level > 0) then /* have to do clean up */
357 
358       if (v_clean_level < 10) then g_account_tab(p_idx).L9 := ''; end if;
359       if (v_clean_level < 9)  then g_account_tab(p_idx).L8 := ''; end if;
360       if (v_clean_level < 8)  then g_account_tab(p_idx).L7 := ''; end if;
361       if (v_clean_level < 7)  then g_account_tab(p_idx).L6 := ''; end if;
362       if (v_clean_level < 6)  then g_account_tab(p_idx).L5 := ''; end if;
363       if (v_clean_level < 5)  then g_account_tab(p_idx).L4 := ''; end if;
364       if (v_clean_level < 4)  then g_account_tab(p_idx).L3 := ''; end if;
365       if (v_clean_level < 3)  then g_account_tab(p_idx).L2 := ''; end if;
366       if (v_clean_level < 2)  then g_account_tab(p_idx).L1 := ''; end if;
367 
368       g_account_tab(p_idx).levels := v_clean_level - 1;
369 
370    end if;
371 
372 END;
373 
377 
374 /*------------------------------------------------------------------+
375  | PROCEDURE: insert_delimiter                                      |
376  +------------------------------------------------------------------*/
378 
379 PROCEDURE insert_delimiter (p_idx IN NUMBER, p_delimiter IN VARCHAR2) IS
380 BEGIN
381 
382    /* Initialize delimiter variables */
383 
384    v_1_width  := 0;   v_1_start  := 0;   v_1_end    := 0;
385    v_2_width  := 0;   v_2_start  := 0;   v_2_end    := 0;
386    v_3_width  := 0;   v_3_start  := 0;   v_3_end    := 0;
387    v_4_width  := 0;   v_4_start  := 0;   v_4_end    := 0;
388    v_5_width  := 0;   v_5_start  := 0;   v_5_end    := 0;
389    v_6_width  := 0;   v_6_start  := 0;   v_6_end    := 0;
390    v_7_width  := 0;   v_7_start  := 0;   v_7_end    := 0;
391    v_8_width  := 0;   v_8_start  := 0;   v_8_end    := 0;
392    v_9_width  := 0;   v_9_start  := 0;   v_9_end    := 0;
393 
394    /* Now we will determine the start position and width of each parent level
395       value */
396 
397    if    (g_account_tab(p_idx).L1 is not NULL) then
398 			  v_1_width := length(g_account_tab(p_idx).L1);
399 			  v_1_start := 1;
400    			  v_1_end   := length(g_account_tab(p_idx).L1);
401    end if;
402 
403   /* Bug 2226088: In the following if statements, replaced
404        v_2_width := length(g_account_tab(p_idx).L2) - v_<number>_width;
405      with
406        v_2_width := length(g_account_tab(p_idx).L2) - v_<number>_end;
407      to insert the delimiter in the correct position. */
408 
409    if    (g_account_tab(p_idx).L2 is not NULL) then
410                           v_2_width := length(g_account_tab(p_idx).L2) - v_1_end;
411 			  v_2_start := v_1_end + 1;
412 			  v_2_end   := v_2_start + v_2_width - 1;
413    end if;
414    if    (g_account_tab(p_idx).L3 is not NULL) then
415                           v_3_width := length(g_account_tab(p_idx).L3) - v_2_end;
416 			  v_3_start := v_2_end + 1;
417 			  v_3_end   := v_3_start + v_3_width - 1;
418    end if;
419    if    (g_account_tab(p_idx).L4 is not NULL) then
420                           v_4_width := length(g_account_tab(p_idx).L4) - v_3_end;
421 			  v_4_start := v_3_end + 1;
422 			  v_4_end   := v_4_start + v_4_width - 1;
423    end if;
424    if    (g_account_tab(p_idx).L5 is not NULL) then
425                           v_5_width := length(g_account_tab(p_idx).L5) - v_4_end;
426 			  v_5_start := v_4_end + 1;
427 			  v_5_end   := v_5_start + v_5_width - 1;
428    end if;
429    if    (g_account_tab(p_idx).L6 is not NULL) then
430                           v_6_width := length(g_account_tab(p_idx).L6) - v_5_end;
431 			  v_6_start := v_5_end + 1;
432 			  v_6_end   := v_6_start + v_6_width - 1;
433    end if;
434    if    (g_account_tab(p_idx).L7 is not NULL) then
435                           v_7_width := length(g_account_tab(p_idx).L7) - v_6_end;
436 			  v_7_start := v_6_end + 1;
437 			  v_7_end   := v_7_start + v_7_width - 1;
438    end if;
439    if    (g_account_tab(p_idx).L8 is not NULL) then
440                           v_8_width := length(g_account_tab(p_idx).L8) - v_7_end;
441 			  v_8_start := v_7_end + 1;
442 			  v_8_end   := v_8_start + v_8_width - 1;
443    end if;
444    if    (g_account_tab(p_idx).L9 is not NULL) then
445                           v_9_width := length(g_account_tab(p_idx).L9) - v_8_end;
446 			  v_9_start := v_8_end + 1;
447 			  v_9_end   := v_9_start + v_9_width - 1;
448    end if;
449 
450    /* Start delimiting - the logic is to insert the delimiter into the parent (L1 through L9) and
451       then to also insert it into the delimited account, g_account_tab(p_idx).delimit_account */
452 
453    if  (g_account_tab(p_idx).L1 is not NULL) then
454        g_account_tab(p_idx).delimit_account :=
455 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
456 	                          substr(g_account_tab(p_idx).account, v_1_end + 1, 999);
457    end if;
458 
459    if  (g_account_tab(p_idx).L2 is not NULL) then
460        g_account_tab(p_idx).delimit_account :=
461 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
462 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
463 	                          substr(g_account_tab(p_idx).account, v_2_end + 1, 999);
464 
465        g_account_tab(p_idx).L2 := substr(g_account_tab(p_idx).L2, v_1_start, v_1_width) || p_delimiter ||
466 	                          substr(g_account_tab(p_idx).L2, v_2_start, v_2_width);
467 
468    end if;
469 
470    if  (g_account_tab(p_idx).L3 is not NULL) then
471        g_account_tab(p_idx).delimit_account :=
472 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
473 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
474 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
475 	                          substr(g_account_tab(p_idx).account, v_3_end + 1, 999);
476 
477        g_account_tab(p_idx).L3 := substr(g_account_tab(p_idx).L3, v_1_start, v_1_width) || p_delimiter ||
478 	                          substr(g_account_tab(p_idx).L3, v_2_start, v_2_width) || p_delimiter ||
479 	                          substr(g_account_tab(p_idx).L3, v_3_start, v_3_width);
480    end if;
481 
482    if  (g_account_tab(p_idx).L4 is not NULL) then
483        g_account_tab(p_idx).delimit_account :=
484 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
485 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
489 
486 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
487 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
488 	                          substr(g_account_tab(p_idx).account, v_4_end + 1, 999);
490        g_account_tab(p_idx).L4 := substr(g_account_tab(p_idx).L4, v_1_start, v_1_width) || p_delimiter ||
491 	                          substr(g_account_tab(p_idx).L4, v_2_start, v_2_width) || p_delimiter ||
492 	                          substr(g_account_tab(p_idx).L4, v_3_start, v_3_width) || p_delimiter ||
493 	                          substr(g_account_tab(p_idx).L4, v_4_start, v_4_width);
494    end if;
495 
496    if  (g_account_tab(p_idx).L5 is not NULL) then
497        g_account_tab(p_idx).delimit_account :=
498 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
499 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
500 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
501 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
502 	                          substr(g_account_tab(p_idx).account, v_5_start, v_5_width) || p_delimiter ||
503 	                          substr(g_account_tab(p_idx).account, v_5_end + 1, 999);
504 
505        g_account_tab(p_idx).L5 := substr(g_account_tab(p_idx).L5, v_1_start, v_1_width) || p_delimiter ||
506 	                          substr(g_account_tab(p_idx).L5, v_2_start, v_2_width) || p_delimiter ||
507 	                          substr(g_account_tab(p_idx).L5, v_3_start, v_3_width) || p_delimiter ||
508 	                          substr(g_account_tab(p_idx).L5, v_4_start, v_4_width) || p_delimiter ||
509 	                          substr(g_account_tab(p_idx).L5, v_5_start, v_5_width);
510    end if;
511 
512    if  (g_account_tab(p_idx).L6 is not NULL) then
513        g_account_tab(p_idx).delimit_account :=
514 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
515 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
516 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
517 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
518 	                          substr(g_account_tab(p_idx).account, v_5_start, v_5_width) || p_delimiter ||
519 	                          substr(g_account_tab(p_idx).account, v_6_start, v_6_width) || p_delimiter ||
520 	                          substr(g_account_tab(p_idx).account, v_6_end + 1, 999);
521 
522        g_account_tab(p_idx).L6 := substr(g_account_tab(p_idx).L6, v_1_start, v_1_width) || p_delimiter ||
523 	                          substr(g_account_tab(p_idx).L6, v_2_start, v_2_width) || p_delimiter ||
524 	                          substr(g_account_tab(p_idx).L6, v_3_start, v_3_width) || p_delimiter ||
525 	                          substr(g_account_tab(p_idx).L6, v_4_start, v_4_width) || p_delimiter ||
526 	                          substr(g_account_tab(p_idx).L6, v_5_start, v_5_width) || p_delimiter ||
527 	                          substr(g_account_tab(p_idx).L6, v_6_start, v_6_width);
528    end if;
529 
530    if  (g_account_tab(p_idx).L7 is not NULL) then
531        g_account_tab(p_idx).delimit_account :=
532 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
533 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
534 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
535 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
536 	                          substr(g_account_tab(p_idx).account, v_5_start, v_5_width) || p_delimiter ||
537 	                          substr(g_account_tab(p_idx).account, v_6_start, v_6_width) || p_delimiter ||
538 	                          substr(g_account_tab(p_idx).account, v_7_start, v_7_width) || p_delimiter ||
539 	                          substr(g_account_tab(p_idx).account, v_7_end + 1, 999);
540 
541        g_account_tab(p_idx).L7 := substr(g_account_tab(p_idx).L7, v_1_start, v_1_width) || p_delimiter ||
542 	                          substr(g_account_tab(p_idx).L7, v_2_start, v_2_width) || p_delimiter ||
543 	                          substr(g_account_tab(p_idx).L7, v_3_start, v_3_width) || p_delimiter ||
544 	                          substr(g_account_tab(p_idx).L7, v_4_start, v_4_width) || p_delimiter ||
545 	                          substr(g_account_tab(p_idx).L7, v_5_start, v_5_width) || p_delimiter ||
546 	                          substr(g_account_tab(p_idx).L7, v_6_start, v_6_width) || p_delimiter ||
550    if  (g_account_tab(p_idx).L8 is not NULL) then
547 	                          substr(g_account_tab(p_idx).L7, v_7_start, v_7_width);
548    end if;
549 
551        g_account_tab(p_idx).delimit_account :=
552 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
553 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
554 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
555 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
556 	                          substr(g_account_tab(p_idx).account, v_5_start, v_5_width) || p_delimiter ||
557 	                          substr(g_account_tab(p_idx).account, v_6_start, v_6_width) || p_delimiter ||
558 	                          substr(g_account_tab(p_idx).account, v_7_start, v_7_width) || p_delimiter ||
559 	                          substr(g_account_tab(p_idx).account, v_8_start, v_8_width) || p_delimiter ||
560 	                          substr(g_account_tab(p_idx).account, v_8_end + 1, 999);
561 
562        g_account_tab(p_idx).L8 := substr(g_account_tab(p_idx).L8, v_1_start, v_1_width) || p_delimiter ||
563 	                          substr(g_account_tab(p_idx).L8, v_2_start, v_2_width) || p_delimiter ||
564 	                          substr(g_account_tab(p_idx).L8, v_3_start, v_3_width) || p_delimiter ||
565 	                          substr(g_account_tab(p_idx).L8, v_4_start, v_4_width) || p_delimiter ||
566 	                          substr(g_account_tab(p_idx).L8, v_5_start, v_5_width) || p_delimiter ||
567 	                          substr(g_account_tab(p_idx).L8, v_6_start, v_6_width) || p_delimiter ||
568 	                          substr(g_account_tab(p_idx).L8, v_7_start, v_7_width) || p_delimiter ||
569 	                          substr(g_account_tab(p_idx).L8, v_8_start, v_8_width);
570    end if;
571 
572    if  (g_account_tab(p_idx).L9 is not NULL) then
573 
574        g_account_tab(p_idx).delimit_account :=
575 	                          substr(g_account_tab(p_idx).account, v_1_start, v_1_width) || p_delimiter ||
579 	                          substr(g_account_tab(p_idx).account, v_5_start, v_5_width) || p_delimiter ||
576 	                          substr(g_account_tab(p_idx).account, v_2_start, v_2_width) || p_delimiter ||
577 	                          substr(g_account_tab(p_idx).account, v_3_start, v_3_width) || p_delimiter ||
578 	                          substr(g_account_tab(p_idx).account, v_4_start, v_4_width) || p_delimiter ||
580 	                          substr(g_account_tab(p_idx).account, v_6_start, v_6_width) || p_delimiter ||
581 	                          substr(g_account_tab(p_idx).account, v_7_start, v_7_width) || p_delimiter ||
582 	                          substr(g_account_tab(p_idx).account, v_8_start, v_8_width) || p_delimiter ||
583 	                          substr(g_account_tab(p_idx).account, v_9_start, v_9_width) || p_delimiter ||
584 	                          substr(g_account_tab(p_idx).account, v_9_end + 1, 999);
585 
586        g_account_tab(p_idx).L9 := substr(g_account_tab(p_idx).L9, v_1_start, v_1_width) || p_delimiter ||
587 	                          substr(g_account_tab(p_idx).L9, v_2_start, v_2_width) || p_delimiter ||
588 	                          substr(g_account_tab(p_idx).L9, v_3_start, v_3_width) || p_delimiter ||
589 	                          substr(g_account_tab(p_idx).L9, v_4_start, v_4_width) || p_delimiter ||
590 	                          substr(g_account_tab(p_idx).L9, v_5_start, v_5_width) || p_delimiter ||
591 	                          substr(g_account_tab(p_idx).L9, v_6_start, v_6_width) || p_delimiter ||
592 	                          substr(g_account_tab(p_idx).L9, v_7_start, v_7_width) || p_delimiter ||
593 	                          substr(g_account_tab(p_idx).L9, v_8_start, v_8_width) || p_delimiter ||
594 	                          substr(g_account_tab(p_idx).L9, v_9_start, v_9_width);
595    end if;
596 
597 end;
598 
599 END JE_GR_TRIAL_BALANCE;