DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_MGD_MVT_CONC_PGM

Source


1 PACKAGE BODY INV_MGD_MVT_CONC_PGM AS
2 -- $Header: INVCPRGB.pls 120.2 2006/05/25 18:03:54 yawang noship $
3 --+=======================================================================+
4 --|               Copyright (c) 1998 Oracle Corporation                   |
5 --|                       Redwood Shores, CA, USA                         |
6 --|                         All rights reserved.                          |
7 --+=======================================================================+
8 --| FILENAME                                                              |
9 --|    INVCPRGB.pls                                                       |
10 --|                                                                       |
11 --| DESCRIPTION                                                           |
12 --|     Body of INV_MGD_MVT_CONC_PGM                                      |
13 --|                                                                       |
14 --| PROCEDURE LIST                                                        |
15 --|     Run_Movement_Stats                                                |
16 --|     Run_Exception_verification                                        |
17 --|     Run_Reset_Movement_Stats                                          |
18 --|     Run_Purge_Movement_Stats                                          |
19 --|     Run_Export_Data                                                   |
20 --|                                                                       |
21 --| HISTORY                                                               |
22 --|     04/01/2000 pseshadr     Created                                   |
23 --|     10/15/2001 yawang       Add procedure Run_Export_Data             |
24 --|     11/09/2001 yawang       Modify procedure Run_Reset_Status to add  |
25 --|                             parameter p_movement_status               |
26 --|     03/18/2002 yawang       Add currency code and exchange rate to    |
27 --|                             Run_Export_Data                           |
28 --|     11/22/2002 vma          Add NOCOPY to OUT paramters. Print to LOG |
29 --|                             only if debug profile option is enabled.  |
30 --|     12/02/2004 vma          Reverse the order of x_errbuf and         |
31 --|                             x_retcode in API signatures to follow     |
32 --|                             Concurrent Manager standard.              |
33 --+=======================================================================
34 
35 --===================
36 -- CONSTANTS
37 --===================
38 G_MODULE_NAME CONSTANT VARCHAR2(100) := 'inv.plsql.INV_MGD_MVT_CONC_PGM.';
39 G_PKG_NAME CONSTANT VARCHAR2(30) := 'INV_MGD_MVT_CONC_PGM';
40 
41 --===================
42 -- PRIVATE PROCEDURES
43 --===================
44 
45 --========================================================================
46 -- PROCEDURE : Run_Movement_Stats      PUBLIC
47 -- PARAMETERS: x_errbuf                error buffer
48 --             x_retcode               0 success, 1 warning, 2 error
49 --             p_legal_entity_id       Legal ENtity ID
50 --             p_start_date            Transaction range (start date)
51 --             p_end_date              Transaction range (end date)
52 --             p_source_type           Transaction source type (PO,SO,RMA etc)
53 -- COMMENT   : This is the concurrent program for movement statistics.
54 --========================================================================
55 PROCEDURE Run_Movement_Stats
56 ( x_errbuf         OUT NOCOPY VARCHAR2
57 , x_retcode        OUT NOCOPY VARCHAR2
58 , p_legal_entity_id IN  NUMBER
59 , p_start_date     IN  VARCHAR2
60 , p_end_date       IN  VARCHAR2
61 , p_source_type    IN  VARCHAR2
62 )
63 IS
64 l_return_status         VARCHAR2(1);
65 l_msg_count             NUMBER;
66 l_msg_data              VARCHAR2(100);
67 l_le_start_date         DATE;
68 l_server_start_date     DATE;
69 l_le_end_date           DATE;
70 l_server_end_date       DATE;
71 l_procedure_name CONSTANT VARCHAR2(30) := 'Run_Movement_Stats';
72 
73 BEGIN
74   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
75   THEN
76     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
77                   , G_MODULE_NAME || l_procedure_name || '.begin'
78                   ,'enter procedure'
79                   );
80   END IF;
81 
82   -- initialize the message stack
83   FND_MSG_PUB.Initialize;
84 
85   --Convert legal entity char date to date format
86   l_le_start_date := TRUNC(FND_DATE.canonical_to_date(p_start_date));
87 
88   --Fix bug5047762, deduct 1 second from 00:00:00 of next day to make
89   --sure it is within last second of p_end_date
90   IF p_end_date IS NOT NULL
91   THEN
92     l_le_end_date := TRUNC(FND_DATE.canonical_to_date(p_end_date) + 1) - 1/(24*60*60);
93   END IF;
94 
95   --Fix bug3731618, no movement record generated if the end date is not specified
96   --Set correct legal entity end date
97   /*IF p_end_date IS NULL
98   THEN
99     l_le_end_date := TRUNC(sysdate+1);
100   ELSE
101     l_le_end_date := TRUNC(FND_DATE.canonical_to_date(p_end_date) + 1);
102   END IF;
103 */
104 
105   --Timezone support, convert legal entity time to server time
106   l_server_start_date := INV_LE_TIMEZONE_PUB.Get_Server_Day_Time_For_Le
107   ( p_le_date => l_le_start_date
108   , p_le_id   => p_legal_entity_id
109   );
110 
111   IF p_end_date IS NULL
112   THEN
113     l_server_end_date := TRUNC(sysdate+1) - 1/(24*60*60);
114   ELSE
115     l_server_end_date := INV_LE_TIMEZONE_PUB.Get_Server_Day_Time_For_Le
116     ( p_le_date => l_le_end_date
117     , p_le_id   => p_legal_entity_id
118     );
119   END IF;
120 
121   -- Call the transaction proxy which processes all the transactions.
122   INV_MGD_MVT_STATS_PROC.PROCESS_TRANSACTION
123   ( p_api_version_number   => 1.0
124   , p_init_msg_list        => FND_API.G_FALSE
125   , p_legal_entity_id      => p_legal_entity_id
126   , p_start_date           => l_server_start_date
127   , p_end_date             => l_server_end_date
128   , p_source_type          => NVL(p_source_type,'ALL')
129   , x_msg_count            => l_msg_count
130   , x_msg_data             => l_msg_data
131   , x_return_status        => l_return_status
132   );
133 
134   IF l_return_status = FND_API.G_RET_STS_SUCCESS
135   THEN
136     x_retcode := 0;
137     x_errbuf := NULL;
138   ELSE
139     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
140   END IF;
141 
142   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
143   THEN
144     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
145                   , G_MODULE_NAME || l_procedure_name || '.end'
146                   ,'exit procedure'
147                   );
148   END IF;
149 
150 EXCEPTION
151   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
152     x_retcode := 2;
153     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
154 
155     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
156     THEN
157       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
158                     , G_MODULE_NAME || l_procedure_name||' in unexpected exception'
159                     , x_errbuf
160                     );
161     END IF;
162   WHEN OTHERS THEN
163     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
164     THEN
165       FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
166                              , 'Run_Movement_Stats'
167                              );
168     END IF;
169 
170     x_retcode := 2;
171     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
172 
173     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
174     THEN
175       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
176                     , G_MODULE_NAME || l_procedure_name||' in others exception'
177                     , x_errbuf
178                     );
179     END IF;
180 END Run_Movement_Stats;
181 
182 
183 --========================================================================
184 -- PROCEDURE : Run_Exception_Verification      PUBLIC
185 -- PARAMETERS: x_retcode              0 success, 1 warning, 2 error
186 --             x_errbuf               error buffer
187 --             p_legal_entity_id      Legal Entity
188 --             p_economic_zone_code   Economic Zone
189 --             p_usage_type           Usage Type
190 --             p_stat_type            Stat. Type
191 ---            p_period_name          Movement Statistics Period
192 --             p_document_source_type Document Source Type
193 --                                    (PO,SO,INV,RMA,RTV)
194 ---
195 --=======================================================================--
196 PROCEDURE Run_Exception_verification
197 ( x_errbuf                     OUT NOCOPY VARCHAR2
198 , x_retcode                    OUT NOCOPY VARCHAR2
199 , p_legal_entity_id            IN  NUMBER
200 , p_economic_zone_code         IN  VARCHAR2
201 , p_usage_type                 IN  VARCHAR2
202 , p_stat_type                  IN  VARCHAR2
203 , p_period_name                IN  VARCHAR2
204 , p_document_source_type       IN  VARCHAR2
205 )
206 IS
207  x_return_status   VARCHAR2(10);
208  x_msg_count       NUMBER;
209  x_msg_data        VARCHAR2(1000);
210  l_procedure_name CONSTANT VARCHAR2(30) := 'Run_Exception_verification';
211 
212 BEGIN
213   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
214   THEN
215     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
216                   , G_MODULE_NAME || l_procedure_name || '.begin'
217                   ,'enter procedure'
218                   );
219   END IF;
220 
221   -- Initialize the Message Stack
222   FND_MSG_PUB.Initialize;
223 
224 -- Call Exception verification procedure that validates all the transactions
225 
226   INV_MGD_MVT_VALIDATE_PROC.Validate_Transaction
227     ( p_api_version_number       => 1.0
228     , p_init_msg_list            => FND_API.G_FALSE
229     , p_legal_entity_id          => p_legal_entity_id
230     , p_economic_zone_code       => p_economic_zone_code
231     , p_usage_type               => p_usage_type
232     , p_stat_type                => p_stat_type
233     , p_period_name              => p_period_name
234     , p_document_source_type     => p_document_source_type
235     , x_return_status            => x_return_status
236     , x_msg_count                => x_msg_count
237     , x_msg_data                 => x_msg_data
238     );
239 
240   IF x_return_status = FND_API.G_RET_STS_SUCCESS
241   THEN
242     x_retcode := 0;
243     x_errbuf := NULL;
244   ELSE
245     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
246   END IF;
247 
248   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
249   THEN
250     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
251                   , G_MODULE_NAME || l_procedure_name || '.end'
252                   ,'exit procedure'
253                   );
254   END IF;
255 
256 EXCEPTION
257   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
258     x_retcode := 2;
259     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
260 
261     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
262     THEN
263       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
264                     , G_MODULE_NAME || l_procedure_name
265                     , x_errbuf
266                     );
267     END IF;
268   WHEN OTHERS THEN
269     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
270     THEN
271       FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
272                               , 'Run Exception Verification'
273                               );
274     END IF;
275 
276     x_errbuf  := FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE);
277     x_retcode := 2;
278 
279     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
280     THEN
281       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
282                     , G_MODULE_NAME || l_procedure_name
283                     , x_errbuf
284                     );
285     END IF;
286 END Run_Exception_Verification;
287 
288 --========================================================================
289 -- PROCEDURE : Run_Reset_Status        PUBLIC
290 -- PARAMETERS: x_retcode               0 success, 1 warning, 2 error
291 --             x_errbuf                error buffer
292 --             p_legal_entity_id       Legal Entity
293 --             p_economic_zone         Economic Zone
294 --             p_usage_type            Usage Type
295 --             p_stat_type             Status Type
296 --             p_period_name           Period Name
297 --             p_document_source_type  Document Source Type
298 --                                     (PO,SO,INV,RMA,RTV)
299 --             p_reset_option          Reset Status Option
300 --                                     (All, Ignore Only, Exclude Ignore)
301 -- COMMENT:    This is the concurrent program for running the Reset
302 --             Transaction Status.
303 --
304 -- History:    11/09/2001 yawang       Add parameter p_reset_option, called
305 --                                     procedure version has increased to 2.0
306 --=======================================================================--
307 
308 PROCEDURE Run_Reset_Status
309 ( x_errbuf                     OUT  NOCOPY VARCHAR2
310 , x_retcode                    OUT  NOCOPY VARCHAR2
311 , p_legal_entity_id            IN   NUMBER
312 , p_economic_zone              IN   VARCHAR2
313 , p_usage_type                 IN   VARCHAR2
314 , p_stat_type                  IN   VARCHAR2
315 , p_period_name                IN   VARCHAR2
316 , p_document_source_type       IN   VARCHAR2
317 , p_reset_option               IN   VARCHAR2
318 )
319 
320 IS
321   l_return_status         VARCHAR2(10);
322   l_msg_count             NUMBER;
323   l_msg_data              VARCHAR2(1000);
324   l_procedure_name CONSTANT VARCHAR2(30) := 'Run_Reset_Status';
325 
326 BEGIN
327   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
328   THEN
329     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
330                   , G_MODULE_NAME || l_procedure_name || '.begin'
331                   ,'enter procedure'
332                   );
333   END IF;
334 
335   -- Initialize the Message Stack
336   FND_MSG_PUB.Initialize;
337 
338   -- Call the Reset Transaction procedure to reset the status to Open
339   INV_MGD_MVT_RESET_TRANS.Reset_Transaction_Status
340   ( p_api_version_number    => 2.0
341   , p_init_msg_list         => FND_API.G_FALSE
342   , p_legal_entity_id       => p_legal_entity_id
343   , p_zone_code             => p_economic_zone
344   , p_usage_type            => p_usage_type
345   , p_stat_type             => p_stat_type
346   , p_period_name           => p_period_name
347   , p_document_source_type  => p_document_source_type
348   , p_reset_option          => p_reset_option
349   , x_return_status         => l_return_status
350   , x_msg_count             => l_msg_count
351   , x_msg_data              => l_msg_data
352   );
353 
354   IF l_return_status = FND_API.G_RET_STS_SUCCESS
355   THEN
356     x_retcode := 0;
357     x_errbuf := NULL;
358   ELSE
359     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
360   END IF;
361 
362   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
363   THEN
364     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
365                   , G_MODULE_NAME || l_procedure_name || '.end'
366                   ,'exit procedure'
367                   );
368   END IF;
369 EXCEPTION
370   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
371     x_retcode := 2;
372     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
373 
374     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
375     THEN
376       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
377                     , G_MODULE_NAME || l_procedure_name
378                     , x_errbuf
379                     );
380     END IF;
381   WHEN OTHERS THEN
382     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
383     THEN
384       FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
385                              , 'Run_Reset_Status'
386                              );
387     END IF;
388 
389     x_retcode := 2;
390     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
391 
392     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
393     THEN
394       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
395                     , G_MODULE_NAME || l_procedure_name
396                     , x_errbuf
397                     );
398     END IF;
399 END Run_Reset_Status;
400 
401 
402 --========================================================================
403 -- PROCEDURE : Run_Purge_Movement_Statistics        PUBLIC
404 -- PARAMETERS: x_retcode               0 success, 1 warning, 2 error
405 --             x_errbuf                error buffer
406 --             p_legal_entity_id       Legal Entity
407 --             p_economic_zone         Econimic Zone
408 --             p_usage_type            Usage Type
409 --             p_stat_type             Status Type
410 --             p_period_name           Period Name
411 --             p_document_source_type  Document Source Type
412 --                                     (PO,SO,INV,RMA,RTV)
413 -- COMMENT:    This is the concurrent program to run the Purging
414 --             of the movement transactions .
415 --=======================================================================--
416 
417 PROCEDURE Run_Purge_Movement_Stats
418 ( x_errbuf                     OUT  NOCOPY VARCHAR2
419 , x_retcode                    OUT  NOCOPY VARCHAR2
420 , p_legal_entity_id            IN   NUMBER
421 , p_economic_zone              IN   VARCHAR2
422 , p_usage_type                 IN   VARCHAR2
423 , p_stat_type                  IN   VARCHAR2
424 , p_period_name                IN   VARCHAR2
425 , p_document_source_type       IN   VARCHAR2
426 )
427 
428 IS
429   x_return_status         VARCHAR2(10);
430   x_msg_count             NUMBER;
431   x_msg_data              VARCHAR2(1000);
432   l_procedure_name CONSTANT VARCHAR2(30) := 'Run_Purge_Movement_Stats';
433 
434 BEGIN
435   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
436   THEN
437     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
438                   , G_MODULE_NAME || l_procedure_name || '.begin'
439                   ,'enter procedure'
440                   );
441   END IF;
442 
443   -- Initialize the Message Stack
444   FND_MSG_PUB.Initialize;
445 
446   -- Call the Purge Movement Transactions procedure to purge the transactions.
447 
448   INV_MGD_MVT_PURGE_TRANS.Purge_Movement_Transactions
449     ( p_api_version_number    => 1.0
450     , p_init_msg_list         => FND_API.G_FALSE
451     , p_legal_entity_id       => p_legal_entity_id
452     , p_zone_code             => p_economic_zone
453     , p_usage_type            => p_usage_type
454     , p_stat_type             => p_stat_type
455     , p_period_name           => p_period_name
456     , p_document_source_type  => p_document_source_type
457     , x_return_status         => x_return_status
458     , x_msg_count             => x_msg_count
459     , x_msg_data              => x_msg_data
460     );
461 
462   IF x_return_status = FND_API.G_RET_STS_SUCCESS
463   THEN
464     x_retcode := 0;
465     x_errbuf := NULL;
466   ELSE
467     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
468   END IF;
469 
470   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
471   THEN
472     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
473                   , G_MODULE_NAME || l_procedure_name || '.end'
474                   ,'exit procedure'
475                   );
476   END IF;
477 EXCEPTION
478   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
479     x_retcode := 2;
480     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
481 
482     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
483     THEN
484       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
485                     , G_MODULE_NAME || l_procedure_name
486                     , x_errbuf
487                     );
488     END IF;
489   WHEN OTHERS THEN
490     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
491     THEN
492       FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
493                              , 'Run_Purge_Movement_Statistics'
494                              );
495     END IF;
496 
497     x_retcode := 2;
498     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
499 
500     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
501     THEN
502       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
503                     , G_MODULE_NAME || l_procedure_name
504                     , x_errbuf
505                     );
506     END IF;
507 END Run_Purge_Movement_Stats;
508 
509 
510 --========================================================================
511 -- PROCEDURE : Run_Export_Data         PUBLIC
512 -- PARAMETERS: x_retcode               0 success, 1 warning, 2 error
513 --             x_errbuf                error buffer
514 --             p_legal_entity_id       Legal Entity
515 --             p_zone_code             Economic Zone
516 --             p_usage_type            Usage Type
517 --             p_stat_type             Statistical Type
518 --             p_period_name           Period Name
519 --             p_movement_type         Movement Type
520 --             p_currency_code         Currency Code
521 --             p_exchange_rate         Exchange Rate
522 --             p_inverse_rate          Y - display inverse rate
523 --                                     N - display non-inverse rate
524 --             p_rate_type             Exchange rate type
525 --                                     p_inverse_rate and p_rate_type are hidded
526 --                                     parameters in application, they are used to
527 --                                     determine list of value of exchange rate
528 --             p_amount_display        display whole number or currency precision
529 --
530 -- COMMENT   : This is the concurrent program specification for Run_Export_Data
531 --             used in IDEP declaration. It will generate a flat file in out
532 --             directory for specified movement type and report reference and
533 --             the records included in this file need to be in status of 'F'
534 --
535 --=======================================================================--
536 
537 PROCEDURE Run_Export_Data
538 ( x_errbuf               OUT  NOCOPY VARCHAR2
539 , x_retcode              OUT  NOCOPY VARCHAR2
540 , p_legal_entity_id      IN   NUMBER
541 , p_zone_code            IN   VARCHAR2
542 , p_usage_type           IN   VARCHAR2
543 , p_stat_type            IN   VARCHAR2
544 , p_movement_type        IN   VARCHAR2
545 , p_period_name          IN   VARCHAR2
546 , p_amount_display       IN   VARCHAR2
547 , p_currency_code        IN   VARCHAR2
548 , p_inverse_rate         IN   VARCHAR2
549 , p_rate_type            IN   NUMBER
550 , p_exchange_rate_char   IN   VARCHAR2
551 )
552 IS
553   l_return_status        VARCHAR2(10);
554   l_msg_count            NUMBER;
555   l_msg_data             VARCHAR2(2000);
556   l_procedure_name CONSTANT VARCHAR2(30) := 'Run_Export_Data';
557 BEGIN
558   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
559   THEN
560     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
561                   , G_MODULE_NAME || l_procedure_name || '.begin'
562                   ,'enter procedure'
563                   );
564   END IF;
565 
566   -- Initialize the Message Stack
567   FND_MSG_PUB.Initialize;
568 
569   -- Call the Run Export Data procedure to generate the flat data file
570   INV_MGD_MVT_EXPORT_DATA.Generate_Export_Data
571   ( p_api_version_number => 1.0
572   , p_init_msg_list      => FND_API.G_FALSE
573   , p_legal_entity_id    => p_legal_entity_id
574   , p_zone_code          => p_zone_code
575   , p_usage_type         => p_usage_type
576   , p_stat_type          => p_stat_type
577   , p_movement_type      => p_movement_type
578   , p_period_name        => p_period_name
579   , p_amount_display     => p_amount_display
580   , p_currency_code      => p_currency_code
581   , p_exchange_rate_char => p_exchange_rate_char
582   , x_return_status      => l_return_status
583   , x_msg_count          => l_msg_count
584   , x_msg_data           => l_msg_data);
585 
586   IF l_return_status = FND_API.G_RET_STS_SUCCESS
587   THEN
588     x_retcode := 0;
589     x_errbuf := NULL;
590   ELSE
591     RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
592   END IF;
593 
594   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
595   THEN
596     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE
597                   , G_MODULE_NAME || l_procedure_name || '.end'
598                   ,'exit procedure'
599                   );
600   END IF;
601 EXCEPTION
602   WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
603     x_retcode := 2;
604     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
605 
606     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
607     THEN
608       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
609                     , G_MODULE_NAME || l_procedure_name
610                     , x_errbuf
611                     );
612     END IF;
613   WHEN OTHERS THEN
614     IF FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
615     THEN
616       FND_MSG_PUB.Add_Exc_Msg( G_PKG_NAME
617                              , 'Run_Export_Data'
618                              );
619     END IF;
620 
621     x_retcode := 2;
622     x_errbuf  := substrb(FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE),1,250);
623 
624     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL)
625     THEN
626       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED
627                     , G_MODULE_NAME || l_procedure_name
628                     , x_errbuf
629                     );
630     END IF;
631 END Run_Export_Data;
632 
633 END INV_MGD_MVT_CONC_PGM;