DBA Data[Home] [Help]

PACKAGE BODY: APPS.JE_IT_TAX_EX_UPGRADE2

Source


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