DBA Data[Home] [Help]

PACKAGE BODY: APPS.JE_ES_MODELO_190_ALL_UPGRADE

Source


1 PACKAGE BODY je_es_modelo_190_all_upgrade AS
2 /* $Header: jeesupgb.pls 120.0 2006/05/19 17:59:58 rjreddy noship $ */
3 
4 PROCEDURE upgrade_main (errbuf OUT NOCOPY varchar2,
5                         retcode OUT NOCOPY number) IS
6 
7 l_message VARCHAR2(1000);
8 l_row_count NUMBER := 0;
9 
10 l_org_id NUMBER(15);
11 l_return_status VARCHAR2(10);
12 l_msg_count NUMBER;
13 l_msg_data VARCHAR2(1000);
14 l_legal_entity_id NUMBER;
15 
16 BEGIN
17 
18 retcode := 0;
19 errbuf := NULL;
20 
21 -- Get the profile org id.
22 l_org_id := FND_PROFILE.VALUE('ORG_ID');
23 
24 IF l_org_id IS NOT NULL THEN
25 
26     fnd_file.put_line(fnd_file.log, 'Org id: '||l_org_id);
27     xle_upgrade_utils.get_default_legal_context(x_return_status => l_return_status,
28 		x_msg_count => l_msg_count,
29 		x_msg_data  => l_msg_data,
30 		p_org_id => l_org_id,
31 		x_dlc    => l_legal_entity_id);
32 
33     fnd_file.put_line(fnd_file.log, 'Ret Status: '||l_return_status);
34     fnd_file.put_line(fnd_file.log, 'Msg Data: '||l_msg_data);
35 
36     -- If the return status is not error, then continue with the process
37     IF l_return_status IS NULL THEN
38 
39           IF (l_legal_entity_id IS NOT NULL) THEN
40 
41                      UPDATE je_es_modelo_190_all
42                      SET legal_entity_id = l_legal_entity_id
43                      WHERE legal_entity_id IS NULL
44                      AND org_id IS NULL;
45 
46                       l_message := 'Updated '||SQL%ROWCOUNT||' rows in table JE_ES_MODELO_190_ALL with legal entity id: '||l_legal_entity_id;
47                       fnd_file.put_line(fnd_file.log,l_message);
48 
49          ELSE
50                       -- IF legal entity id is null.
51                       l_message := 'Unable to Update Legal Entities for the table je_es_modelo_190_all
52                          because no Legal Entity was found.';
53                       fnd_file.put_line(fnd_file.log,l_message);
54 
55                      ROLLBACK;
56                      retcode := 2;
57                      errbuf  := l_message;
58 
59           END IF;
60 
61    ELSE
62 
63           l_message :=  'Error - Upgrade process could not complete: '||l_msg_data;
64           FND_FILE.PUT_LINE(FND_FILE.LOG, l_message);
65           retcode := 2;
66           errbuf  := l_message;
67           RETURN;
68 
69    END IF;
70 
71 END IF;
72 
73 l_message := 'Upgrade completed successfully.';
74 fnd_file.put_line(fnd_file.log,l_message);
75 COMMIT;
76 
77 EXCEPTION WHEN OTHERS THEN
78    ROLLBACK;
79    l_message := 'Error - Upgrade process could not complete: '||sqlcode||': '||sqlerrm;
80    retcode := 2;
81    errbuf  := l_message;
82    fnd_file.put_line(fnd_file.log, l_message);
83 
84 END upgrade_main;
85 
86 END je_es_modelo_190_all_upgrade;
87