DBA Data[Home] [Help]

PACKAGE BODY: APPS.GCS_PURGE_PKG

Source


1 PACKAGE BODY GCS_PURGE_PKG AS
2 /* $Header: gcs_purgeb.pls 120.4 2007/10/09 13:49:41 rthati noship $ */
3 -- Procedure
4 --   purge_cons_runs
5 -- Purpose
6 --   An API for master to submit request to worker
7 -- Arguments
8 --   x_retcode                   Return code
9 --   x_errbuf                    Buffer error
10 --   p_consolidation_hierarchy   Consolidation hierarchy
11 --   p_consolidation_entity      Consolidation entity
12 --   p_cal_period_id             Period
13 --   p_balance_type_code         Balance type code
14 -- Modification History
15 --   Person           Date        Comments
16 --   ramesh.thati    25-09-2007   Purge Program - Bug # 6447909
17 -- Notes
18 --
19    g_api			VARCHAR2(200)	:=	'gcs.plsql.GCS_PURGE_PKG';
20 
21    PROCEDURE purge_cons_runs
22      (
23        x_retcode                  OUT NOCOPY VARCHAR2,
24        x_errbuf                   OUT NOCOPY VARCHAR2,
25        p_consolidation_hierarchy  IN NUMBER,
26        p_consolidation_entity     IN NUMBER,
27        p_cal_period_id            IN NUMBER,
28        p_balance_type_code        IN VARCHAR2
29      )
30    IS
31      p_key         VARCHAR2(30);
32      v_Num_Workers NUMBER;
33    BEGIN
34      IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_PROCEDURE) THEN
35        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS.begin', '<<Enter>>');
36        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS', 'Consolidation Hierarchy    :  ' || p_consolidation_hierarchy);
37        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS', 'Consolidation Entity       :  ' || p_consolidation_entity);
38        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS', 'Calendar Period            :  ' || p_cal_period_id);
39        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS', 'Balance Type               :  ' || p_balance_type_code);
40      END IF;
41 
42      fnd_file.put_line(fnd_file.log, 'Beginning Consolidation Purge Program');
43      fnd_file.put_line(fnd_file.log, '<<Parameter Listings>>');
44      fnd_file.put_line(fnd_file.log, 'Consolidation Hierarchy	:	' || p_consolidation_hierarchy);
45      fnd_file.put_line(fnd_file.log, 'Consolidation Entity	    :	' || p_consolidation_entity);
46      fnd_file.put_line(fnd_file.log, 'Calendar Period		    :	' || p_cal_period_id);
47      fnd_file.put_line(fnd_file.log, 'Balance Type              :   ' || p_balance_type_code);
48      fnd_file.put_line(fnd_file.log, '<<End of Parameter Listings>>');
49 
50     BEGIN
51       SELECT nvl(value,1)*2 no_of_workers
52       INTO v_Num_Workers
53       FROM v$parameter
54       WHERE NAME = 'cpu_count';
55 
56       EXCEPTION
57       WHEN OTHERS THEN
58         IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_STATEMENT) THEN
59           FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, g_api || '.PURGE_CONS_RUNS_WORKER', SubStr('Getting number of workers-'||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
60         END IF;
61         fnd_file.put_line(fnd_file.log, SubStr('Getting number of workers-'||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
62         x_retcode :='2';
63     END;
64 
65     BEGIN
66       SELECT run_name
67       INTO   p_key
68       FROM  gcs_cons_eng_runs gcer
69       WHERE gcer.hierarchy_id       =  p_consolidation_hierarchy
70       AND   gcer.cal_period_id      =  p_cal_period_id
71       AND   gcer.balance_type_code  =  p_balance_type_code
72       AND   gcer.most_recent_flag   =  'Y'
73       AND   gcer.run_entity_id      =  p_consolidation_entity;
74     EXCEPTION
75       WHEN OTHERS THEN
76         IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_STATEMENT) THEN
77           FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, g_api || '.PURGE_CONS_RUNS_WORKER', SubStr('Getting the Unique Key(p_key)'||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
78         END IF;
79         fnd_file.put_line(fnd_file.log, SubStr('Getting the Unique Key(p_key)'||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
80         x_retcode :='2';
81     END;
82 
83     -- AD Parallel framework Manager processing
84 
85     --Purge all the info from ad processing tables
86    ad_parallel_updates_pkg.purge_processed_units(X_owner  => 'GCS',
87                                                  X_table  => 'GCS_CONS_ENG_RUNS',
88                                                  X_script => p_key);
89 
90    ad_parallel_updates_pkg.delete_update_information(X_update_type => ad_parallel_updates_pkg.ROWID_RANGE,
91                                                      X_owner       =>  'GCS',
92                                                      X_table       =>  'GCS_CONS_ENG_RUNS',
93                                                      X_script      =>  p_key);
94 
95    -- submit purge worker
96    AD_CONC_UTILS_PKG.submit_subrequests(X_errbuf                    => x_errbuf,
97                                         X_retcode                   => x_retcode,
98                                         X_WorkerConc_app_shortname  => 'GCS',
99                                         X_WorkerConc_progname       => 'FCH_PURGE_PROGRAM_WORKER',
100                                         X_batch_size                => 10000,
101                                         X_Num_Workers               => v_Num_Workers,
102                                         X_Argument4                 => p_consolidation_hierarchy,
103                                         X_Argument5                 => p_consolidation_entity,
104                                         X_Argument6                 => p_cal_period_id,
105                                         X_Argument7                 => p_balance_type_code);
106 
107      -- To commit the overall transaction
108      COMMIT;
109      IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_PROCEDURE) THEN
110        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS.end', '<<Enter>>');
111      END IF;
112    EXCEPTION
113    WHEN OTHERS THEN
114         ROLLBACK;
115         fnd_file.put_line(fnd_file.log, SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
116         x_retcode :='2';
117    END purge_cons_runs; -- end of procedure purge_cons_runs
118 
119 -- Procedure
120 --   purge_cons_runs_worker
121 -- Purpose
122 --   An API for worker to purge its own set of rows. To purge historical data
123 --   with regard to consolidation runs.It will not purge manual adjustments or
124 --   rules generated entries. It will purge only Automatically generated entries
125 -- Arguments
126 --   x_retcode                   Return code
127 --   x_errbuf                    Buffer error
128 --   p_batch_size                No of rows to process
129 --   p_Worker_Id                 Worker ID,
130 --   p_Num_Workers               total Number of workers
131 --   p_consolidation_hierarchy   Consolidation hierarchy
132 --   p_consolidation_entity      Consolidation entity
133 --   p_cal_period_id             Period
134 --   p_balance_type_code         Balance type code
135 -- Modification History
136 --   Person           Date        Comments
137 --   ramesh.thati    25-09-2007   Purge Program - Bug # 6447909
138 -- Notes
139 --
140    PROCEDURE purge_cons_runs_worker
141       (
142        X_errbuf                  OUT NOCOPY VARCHAR2,
143        X_retcode                 OUT NOCOPY VARCHAR2,
144        p_batch_size              IN NUMBER,
145        p_Worker_Id               IN NUMBER,
146        p_Num_Workers             IN NUMBER,
147        p_consolidation_hierarchy IN NUMBER,
148        p_consolidation_entity    IN NUMBER,
149        p_cal_period_id           IN NUMBER,
150        p_balance_type_code       IN VARCHAR2
151      )
152    IS
153 -- Cursor definition
154 -- Cursor to get the run_name and run_entity_id information by considering the
155 -- following cases
156 -- i) Not latest runs (most_recent_flag <> 'y').
157 -- i) Not already purged runs (status_code <> 'PURGED')
158 
159    CURSOR c_purge_cons_entity ( p_consolidation_hierarchy IN NUMBER,
160                                 p_consolidation_entity	  IN NUMBER,
161                                 p_cal_period_id           IN NUMBER,
162                                 p_balance_type_code       IN VARCHAR2,
163                                 p_start_rowid                ROWID,
164                                 p_end_rowid                  ROWID
165                                ) IS
166    SELECT DISTINCT run_name, run_entity_id, entity_name
167    FROM  gcs_cons_eng_runs gcer,
168          fem_entities_tl fem
169    WHERE gcer.run_entity_id            =  fem.entity_id
170    AND   gcer.hierarchy_id             =  p_consolidation_hierarchy
171    AND   gcer.cal_period_id            =  p_cal_period_id
172    AND   gcer.balance_type_code        =  p_balance_type_code
173    AND   gcer.most_recent_flag         <> 'Y'
174    AND   gcer.status_code              <> 'PURGED'
175    AND   (gcer.associated_run_name IS NULL
176           OR (gcer.associated_run_name IS NOT NULL
177               AND NOT EXISTS (
178                               SELECT run_name
179                               FROM   gcs_cons_eng_runs gcer_inner
180                               WHERE  gcer_inner.hierarchy_id=p_consolidation_hierarchy
181                               AND    gcer_inner.cal_period_id = p_cal_period_id
182                               AND    gcer_inner.balance_type_code = p_balance_type_code
183                               AND    gcer_inner.most_recent_flag = 'Y'
184                               AND    gcer_inner.run_name=gcer.associated_run_name
185                               AND    gcer_inner.run_entity_id=gcer.run_entity_id
186                              )
187               )
188          )
189    AND   fem.language                  =  userenv('lang')
190    AND   gcer.ROWID BETWEEN p_start_rowid AND p_end_rowid
191    START WITH gcer.run_entity_id       =  p_consolidation_entity
192    AND   gcer.hierarchy_id             =  p_consolidation_hierarchy
193    AND   gcer.cal_period_id            =  p_cal_period_id
194    AND   gcer.balance_type_code        =  p_balance_type_code
195    CONNECT BY PRIOR gcer.run_entity_id =  gcer.parent_entity_id
196    AND   gcer.hierarchy_id             =  p_consolidation_hierarchy
197    AND   gcer.cal_period_id            =  p_cal_period_id
198    AND   gcer.balance_type_code        =  p_balance_type_code;
199 
200 
201 -- Cursor to the entry_id and stat_entry_id that belong to perticular run_name
202 -- and run_entity_id. The following cases are considered to get the entry ids
203 -- i)   All the entris that do not belong lastest run are eligible for purging.
204 -- ii)  Only AUTOMATIC entries from gcs_entry_headers table are eligible for purging.
205 -- iii) stat_entry_ids along with entry_ids are also eligible for purging
206 
207    CURSOR c_purge_entry(p_consolidation_hierarchy   IN NUMBER,
208                         p_cal_period_id             IN NUMBER,
209                         p_balance_type_code         IN VARCHAR2,
210                         p_run_name                  IN VARCHAR2,
211                         p_run_entity_id             IN NUMBER
212                        ) IS
213    SELECT  DISTINCT gcerd_outer.entry_id,gcerd_outer.child_entity_id,geh.entry_name,geh.description
214    FROM    gcs_cons_eng_runs     gcer_outer,
215            gcs_cons_eng_run_dtls gcerd_outer,
216            gcs_entry_headers     geh
217    WHERE   gcer_outer.run_name                 =  gcerd_outer.run_name
218    AND     gcer_outer.run_entity_id            =  gcerd_outer.consolidation_entity_id
219    AND     gcerd_outer.entry_id                =  geh.entry_id
220    AND     geh.entry_type_code                 =  'AUTOMATIC'
221    AND     gcerd_outer.run_name                =  p_run_name
222    AND     gcerd_outer.consolidation_entity_id =  p_run_entity_id
223    AND     gcerd_outer.entry_id IS NOT NULL
224    AND     NOT EXISTS (
225                         SELECT 'X'
226                         FROM  gcs_cons_eng_runs     gcer_inner,
227                               gcs_cons_eng_run_dtls gcerd_inner
228                         WHERE gcer_inner.most_recent_flag  = 'Y'
229                         AND   gcer_inner.hierarchy_id      = gcer_outer.hierarchy_id
230                         AND   gcer_inner.run_entity_id     = gcer_outer.run_entity_id
231                         AND   gcer_inner.cal_period_id     = gcer_outer.cal_period_id
232                         AND   gcer_inner.balance_type_code = gcer_outer.balance_type_code
233                         AND   gcerd_inner.entry_id         = gcerd_outer.entry_id
234                         AND   gcer_inner.run_name          = gcerd_inner.run_name
235                        )
236    UNION ALL
237 
238    SELECT  DISTINCT gcerd_outer.stat_entry_id,gcerd_outer.child_entity_id,geh.entry_name,geh.description
239    FROM    gcs_cons_eng_runs     gcer_outer,
240            gcs_cons_eng_run_dtls gcerd_outer,
241            gcs_entry_headers     geh
242    WHERE   gcer_outer.run_name                   =  gcerd_outer.run_name
243    AND     gcer_outer.run_entity_id              =  gcerd_outer.consolidation_entity_id
244    AND     gcerd_outer.stat_entry_id             =  geh.entry_id
245    AND     geh.entry_type_code                   =  'AUTOMATIC'
246    AND     gcerd_outer.run_name                  =  p_run_name
247    AND     gcerd_outer.consolidation_entity_id   =  p_run_entity_id
248    AND     gcerd_outer.stat_entry_id IS NOT NULL
249    AND     NOT EXISTS (
250                        SELECT 'X'
251                        FROM  gcs_cons_eng_runs     gcer_inner,
252                              gcs_cons_eng_run_dtls gcerd_inner
253                        WHERE gcer_inner.most_recent_flag  = 'Y'
254                        AND   gcer_inner.hierarchy_id      = gcer_outer.hierarchy_id
255                        AND   gcer_inner.run_entity_id     = gcer_outer.run_entity_id
256                        AND   gcer_inner.cal_period_id     = gcer_outer.cal_period_id
257                        AND   gcer_inner.balance_type_code = gcer_outer.balance_type_code
258                        AND   gcerd_inner.stat_entry_id    = gcerd_outer.stat_entry_id
259                        AND   gcer_inner.run_name          = gcerd_inner.run_name
260                      );
261 
262 -- Type Definition
263 -- To collect the result of cursor c_purge_cons_entity
264    TYPE t_purge_cons_entity_id IS TABLE OF c_purge_cons_entity%ROWTYPE;
265 -- To collect the result of cursor c_purge_entry
266    TYPE t_purge_entry_id       IS TABLE OF c_purge_entry%ROWTYPE;
267 
268 -- Local Variable definition
269    l_purge_cons_entity_list   t_purge_cons_entity_id;
270    l_purge_entry_id_rec       t_purge_entry_id;
271    l_run_name                 NUMBER;
272    l_entity_name              VARCHAR2(100);
273    v_product                  VARCHAR2(30) := 'GCS';
274    v_table_name               VARCHAR2(30) := 'GCS_CONS_ENG_RUNS';
275    p_key                      VARCHAR2(30);
276    v_status                   VARCHAR2(30);
277    v_industry                 VARCHAR2(30);
278    v_retstatus                BOOLEAN;
279    v_table_owner              VARCHAR2(30);
280    v_any_rows_to_process      BOOLEAN := FALSE;
281    v_start_rowid              ROWID;
282    v_end_rowid                ROWID;
283    v_rows_processed           NUMBER:=0;
284    v_module_name              VARCHAR2(100);
285 
286 
287    BEGIN
288      IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_PROCEDURE) THEN
289        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER.begin', '<<Enter>>');
290        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER', 'Consolidation Hierarchy    :  ' || p_consolidation_hierarchy);
291        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER', 'Consolidation Entity       :  ' || p_consolidation_entity);
292        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER', 'Calendar Period            :  ' || p_cal_period_id);
293        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER', 'Balance Type               :  ' || p_balance_type_code);
294      END IF;
295 
296      fnd_file.put_line(fnd_file.log, 'Beginning Consolidation Purge Program');
297      fnd_file.put_line(fnd_file.log, '<<Parameter Listings>>');
298      fnd_file.put_line(fnd_file.log, 'Consolidation Hierarchy	:	' || p_consolidation_hierarchy);
299      fnd_file.put_line(fnd_file.log, 'Consolidation Entity	    :	' || p_consolidation_entity);
300      fnd_file.put_line(fnd_file.log, 'Calendar Period		    :	' || p_cal_period_id);
301      fnd_file.put_line(fnd_file.log, 'Balance Type		        :	' || p_balance_type_code);
302      fnd_file.put_line(fnd_file.log, '<<End of Parameter Listings>>');
303 
304       --
305       -- Get schema name of the table for ROWID range processing
306       --
307       v_retstatus := fnd_installation.get_app_info( v_product,
308                                                     v_status,
309                                                     v_industry,
310                                                     v_table_owner);
311 
312       IF ((v_retstatus = FALSE) OR (v_table_owner IS NULL)) THEN
313         raise_application_error(-20001, 'Cannot get schema name for product : '||v_product);
314       END IF;
315 
316       -- Worker processing
317       -- To Generate Unique key
318 
319       SELECT run_name
320       INTO   p_key
321       FROM   gcs_cons_eng_runs gcer
322       WHERE  gcer.hierarchy_id       =  p_consolidation_hierarchy
323       AND    gcer.cal_period_id      =  p_cal_period_id
324       AND    gcer.balance_type_code  =  p_balance_type_code
325       AND    gcer.most_recent_flag   = 'Y'
326       AND    gcer.run_entity_id      = p_consolidation_entity;
327 
328       -- To initialize the rowid range
329       ad_parallel_updates_pkg.initialize_rowid_range( ad_parallel_updates_pkg.ROWID_RANGE,
330                                                       v_table_owner,
331                                                       v_table_name,
332                                                       p_key,
333                                                       p_Worker_Id,
334                                                       p_Num_Workers,
335                                                       p_batch_size,
336                                                       0);
337 
338       -- To get its repective rowid range
339       ad_parallel_updates_pkg.get_rowid_range( v_start_rowid,
340                                                v_end_rowid,
341                                                v_any_rows_to_process,
342                                                p_batch_size,
343                                                TRUE);
344 
345      -- v_any_rows_to_process = TRUE  means there are some rows to process
346      -- v_any_rows_to_process = FALSE means there are no rows to process
347      IF (v_any_rows_to_process = FALSE) THEN
348        fnd_file.put_line(fnd_file.log, '<<------------------- No Rows to Process---------------------->>');
349      END IF;
350      -- This loop will be keep on repeated until all the rows allocated to a
351      -- worker are processed i.e until v_any_rows_to_process becomes FALSE
352      WHILE (v_any_rows_to_process = TRUE) LOOP
353        -- Initially the number of rows prcessed are set zero.
354        v_rows_processed :=0;
355        -- Opening the cursor c_purge_cons_entity to collect the run names and run_entity_id
356        -- that eligible for purging
357        OPEN c_purge_cons_entity( p_consolidation_hierarchy,
358                                  p_consolidation_entity,
359                                  p_cal_period_id,
360                                  p_balance_type_code,
361                                  v_start_rowid,
362                                  v_end_rowid);
363        LOOP
364          FETCH c_purge_cons_entity BULK COLLECT INTO l_purge_cons_entity_list LIMIT 1000;
365          IF(l_purge_cons_entity_list.FIRST IS NOT NULL AND
366             l_purge_cons_entity_list.LAST IS NOT NULL) THEN
367            FOR i IN l_purge_cons_entity_list.FIRST .. l_purge_cons_entity_list.LAST LOOP
368              -- Opening the cursor to get the entries that belong to current run
369              -- and but not belong to most recent run
370              OPEN c_purge_entry(p_consolidation_hierarchy,
371                                 p_cal_period_id,
372                                 p_balance_type_code,
373                                 l_purge_cons_entity_list(i).run_name,
374                                 l_purge_cons_entity_list(i).run_entity_id);
375              LOOP
376                FETCH c_purge_entry BULK COLLECT INTO l_purge_entry_id_rec LIMIT 1000;
377                IF (l_purge_entry_id_rec.FIRST IS NOT NULL AND
378                    l_purge_entry_id_rec.LAST IS NOT NULL) THEN
379                  -- To print the header information like Run Name and Consolidation entity in log file
380                  fnd_file.put_line(fnd_file.log, '+------------------------------------+--------------------------+-------------------------------------------------------------------------------------------+');
381                  fnd_file.put_line(fnd_file.log, '| Run Name                           : '|| rpad(l_purge_cons_entity_list(i).run_name,117,' ')||'|');
382                  fnd_file.put_line(fnd_file.log, '| Consolidation Entity ID            : '|| rpad(l_purge_cons_entity_list(i).entity_name,117,' ')||'|');
383                  fnd_file.put_line(fnd_file.log, '+------------------------------------+--------------------------+-------------------------------------------------------------------------------------------+');
384                  fnd_file.put_line(fnd_file.log, '| Child Entity                       | Entry Name               | Description                                                                               |');
385                  fnd_file.put_line(fnd_file.log, '+------------------------------------+--------------------------+-------------------------------------------------------------------------------------------+');
386 
387                  FOR j IN l_purge_entry_id_rec.FIRST .. l_purge_entry_id_rec.LAST LOOP
388                    IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_STATEMENT) THEN
389                      FND_LOG.STRING(FND_LOG.LEVEL_STATEMENT, g_api || '.PURGE_CONS_RUNS_WORKER', 'Run Name           :  ' ||l_purge_cons_entity_list(i).run_name ||
390                                                                                                  'Run Entity ID      :  ' ||l_purge_cons_entity_list(i).run_entity_id||
391                                                                                                  'Entry ID:          :  ' ||l_purge_entry_id_rec(j).entry_id||
392                                                                                                  'Child Entity ID    :  ' ||l_purge_entry_id_rec(j).child_entity_id);
393                    END IF;
394                    -- To purge the entry line information
395                    DELETE FROM gcs_entry_lines WHERE entry_id   = l_purge_entry_id_rec(j).entry_id;
396                    -- To purge the entry header information
397                    DELETE FROM gcs_entry_headers WHERE entry_id = l_purge_entry_id_rec(j).entry_id;
398                    -- To get the Child entity name
399                    SELECT entity_name
400                    INTO   l_entity_name
401                    FROM   fem_entities_tl fem
402                    WHERE  fem.entity_id = l_purge_entry_id_rec(j).child_entity_id
403                    AND    fem.language  = userenv('lang');
404                    -- To print purged informatin into log file
405                    fnd_file.put_line(fnd_file.log,'| '||rpad(l_entity_name,35,' ')||'| '||
406                                                         rpad(l_purge_entry_id_rec(j).entry_name,25,' ')||'| '||
407                                                         rpad(l_purge_entry_id_rec(j).description,90,' ')||'|');
408                  END LOOP; -- end of inner for loop
409                END IF;
410                EXIT WHEN c_purge_entry%NOTFOUND;
411              END LOOP; -- end of inner cursor(c_purge_entry) loop
412              CLOSE c_purge_entry;
413 
414              -- To purge the run detial information
415              DELETE FROM gcs_cons_eng_run_dtls gcerd
416              WHERE gcerd.run_name                =  l_purge_cons_entity_list(i).run_name
417              AND   gcerd.consolidation_entity_id =  l_purge_cons_entity_list(i).run_entity_id;
418 
419              -- To update the run information to PURGED.
420              UPDATE gcs_cons_eng_runs
421              SET    status_code   = 'PURGED'
422              WHERE  run_name      = l_purge_cons_entity_list(i).run_name
423              AND    run_entity_id = l_purge_cons_entity_list(i).run_entity_id;
424              -- To keep track of how many rows processed so far
425              v_rows_processed := v_rows_processed + SQL%ROWCOUNT;
426            END LOOP; -- end of outer cursor forloop
427          END IF;
428          EXIT WHEN c_purge_cons_entity%NOTFOUND;
429        END LOOP; -- enf of outer cursor(c_purge_cons_entity) loop
430        fnd_file.put_line(fnd_file.log, '+------------------------------------+--------------------------+-------------------------------------------------------------------------------------------+');
431        CLOSE c_purge_cons_entity;
432        --To update number rows processed so far
433        ad_parallel_updates_pkg.processed_rowid_range( v_rows_processed, v_end_rowid);
434        COMMIT;
435        --To get next of rows for processing
436        ad_parallel_updates_pkg.get_rowid_range( v_start_rowid,
437                                                 v_end_rowid,
438                                                 v_any_rows_to_process,
439                                                 p_batch_size,
440                                                 FALSE);
441      END LOOP; -- while loop for parallel processsing
442      X_retcode := AD_CONC_UTILS_PKG.CONC_SUCCESS;
443      IF (FND_LOG.G_CURRENT_RUNTIME_LEVEL         <=      FND_LOG.LEVEL_PROCEDURE) THEN
444        FND_LOG.STRING(FND_LOG.LEVEL_PROCEDURE, g_api || '.PURGE_CONS_RUNS_WORKER.end', '<<Enter>>');
445      END IF;
446      EXCEPTION
447      WHEN OTHERS THEN
448        ROLLBACK;
449        fnd_file.put_line(fnd_file.log, SubStr('Error '||TO_CHAR(SQLCODE)||': '||SQLERRM, 1, 255));
450        x_retcode :='2';
451    END purge_cons_runs_worker; -- end of procedure purge_cons_runs
452 END GCS_PURGE_PKG; -- end of package GCS_PURGE_PKG