DBA Data[Home] [Help]

PACKAGE BODY: APPS.CN_PREPOSTBATCHES

Source


1 PACKAGE BODY CN_PREPOSTBATCHES AS
2 -- $Header: cntpbatb.pls 120.2 2005/09/14 12:32:40 fmburu ship $
3 
4 -- Default Posting Batch.Load_Status Value
5 C_UNLOADED     CONSTANT VARCHAR2(30) := 'UNLOADED';
6 G_PKG_NAME       CONSTANT VARCHAR2(30) := 'CN_PREPOSTBATCHES';
7 G_LAST_UPDATE_DATE        DATE         := SYSDATE;
8 G_LAST_UPDATED_BY         NUMBER       := FND_GLOBAL.USER_ID;
9 G_CREATION_DATE           DATE         := SYSDATE;
10 G_CREATED_BY              NUMBER       := FND_GLOBAL.USER_ID;
11 G_LAST_UPDATE_LOGIN       NUMBER       := FND_GLOBAL.LOGIN_ID;
12 
13 PROCEDURE Get_UID( x_posting_batch_id  IN OUT NOCOPY NUMBER )
14 IS
15    CURSOR get_id IS
16       SELECT cn_posting_batches_s.nextval
17       FROM   dual;
18 BEGIN
19    OPEN  get_id;
20    FETCH get_id INTO x_posting_batch_id;
21    CLOSE get_id;
22 END Get_UID;
23 
24 PROCEDURE Insert_Record
25 (   x_rowid                          IN OUT NOCOPY VARCHAR2,
26     x_posting_batch_id                      NUMBER,
27     x_name                                  VARCHAR2,
28     x_start_date                            DATE    ,
29     x_end_date                              DATE    ,
30     x_load_status                           VARCHAR2    := C_UNLOADED,
31     x_attribute_category                    VARCHAR2,
32     x_attribute1                            VARCHAR2,
33     x_attribute2                            VARCHAR2,
34     x_attribute3                            VARCHAR2,
35     x_attribute4                            VARCHAR2,
36     x_attribute5                            VARCHAR2,
37     x_attribute6                            VARCHAR2,
38     x_attribute7                            VARCHAR2,
39     x_attribute8                            VARCHAR2,
40     x_attribute9                            VARCHAR2,
41     x_attribute10                           VARCHAR2,
42     x_attribute11                           VARCHAR2,
43     x_attribute12                           VARCHAR2,
44     x_attribute13                           VARCHAR2,
45     x_attribute14                           VARCHAR2,
46     x_attribute15                           VARCHAR2,
47     x_last_update_date                      DATE    ,
48     x_last_updated_by                       NUMBER  ,
49     x_last_update_login                     NUMBER  ,
50     x_creation_date                         DATE        := G_CREATION_DATE,
51     x_created_by                            NUMBER      := G_CREATED_BY,
52     p_org_id                                NUMBER
53   )
54 IS
55       l_api_name                  CONSTANT VARCHAR2(30)      := 'Insert_Record';
56 BEGIN
57    INSERT INTO cn_posting_batches(
58       posting_batch_id,
59       name,
60       start_date,
61       end_date,
62       load_status,
63       attribute_category,
64       attribute1      ,
65       attribute2      ,
66       attribute3      ,
67       attribute4      ,
68       attribute5      ,
69       attribute6      ,
70       attribute7      ,
71       attribute8      ,
72       attribute9      ,
73       attribute10      ,
74       attribute11      ,
75       attribute12      ,
76       attribute13      ,
77       attribute14      ,
78       attribute15      ,
79       last_update_date,
80       last_updated_by,
81       last_update_login,
82       creation_date,
83       created_by,
84       org_id
85       )
86    VALUES(
87       x_posting_batch_id,
88       x_name,
89       x_start_date,
90       x_end_date,
91       x_load_status,
92       x_attribute_category,
93       x_attribute1      ,
94       x_attribute2      ,
95       x_attribute3      ,
96       x_attribute4      ,
97       x_attribute5      ,
98       x_attribute6      ,
99       x_attribute7      ,
100       x_attribute8      ,
101       x_attribute9      ,
102       x_attribute10      ,
103       x_attribute11      ,
104       x_attribute12      ,
105       x_attribute13      ,
106       x_attribute14      ,
107       x_attribute15      ,
108       x_last_update_date,
109       x_last_updated_by,
110       x_last_update_login,
111       x_creation_date,
112       x_created_by,
113       p_org_id
114       );
115 END Insert_Record;
116 
117 PROCEDURE Begin_Record
118 (     x_operation              IN       VARCHAR2                    ,
119       x_rowid                  IN OUT NOCOPY   VARCHAR2                    ,
120       x_posting_batch_rec      IN OUT NOCOPY   posting_batch_rec_type      ,
121       x_program_type           IN       VARCHAR2,
122       p_org_id                 IN NUMBER
123 )
124 IS
125       l_api_name               CONSTANT VARCHAR2(30)      := 'Begin_Record';
126       l_api_version            CONSTANT NUMBER            := 1.0;
127       l_posting_batch_rec      posting_batch_rec_type;
128 BEGIN
129 
130       IF x_operation = 'INSERT' THEN
131 
132          Insert_Record(
133           x_rowid,
134           x_posting_batch_rec.posting_batch_id,
135           x_posting_batch_rec.name,
136           x_posting_batch_rec.start_date,
137           x_posting_batch_rec.end_date,
138           C_UNLOADED,
139           x_posting_batch_rec.attribute_category,
140           x_posting_batch_rec.attribute1      ,
141           x_posting_batch_rec.attribute2      ,
142           x_posting_batch_rec.attribute3      ,
143           x_posting_batch_rec.attribute4      ,
144           x_posting_batch_rec.attribute5      ,
145           x_posting_batch_rec.attribute6      ,
146           x_posting_batch_rec.attribute7      ,
147           x_posting_batch_rec.attribute8      ,
148           x_posting_batch_rec.attribute9      ,
149           x_posting_batch_rec.attribute10      ,
150           x_posting_batch_rec.attribute11      ,
151           x_posting_batch_rec.attribute12      ,
152           x_posting_batch_rec.attribute13      ,
153           x_posting_batch_rec.attribute14      ,
154           x_posting_batch_rec.attribute15      ,
155           x_posting_batch_rec.last_update_date,
156           x_posting_batch_rec.last_updated_by,
157           x_posting_batch_rec.last_update_login,
158           x_posting_batch_rec.creation_date,
159           x_posting_batch_rec.created_by,
160           p_org_id
161          );
162 
163       END IF;
164 END Begin_Record;
165 
166 PROCEDURE posting_conc
167 (  errbuf               OUT NOCOPY   VARCHAR2,
168    retcode              OUT NOCOPY   NUMBER,
169    start_date           IN    VARCHAR2,
170    end_date             IN    VARCHAR2,
171    p_org_id             IN    NUMBER
172 )
173 IS
174   l_api_version         NUMBER := 1.0;
175   l_init_msg_list       VARCHAR2(1) := FND_API.G_TRUE;
176   l_commit              VARCHAR2(1) := FND_API.G_TRUE;
177   l_return_status       VARCHAR2(50);
178   l_msg_count           NUMBER;
179   l_msg_data            VARCHAR2(2000);
180   l_proc_audit_id       NUMBER(15);
181   ABORT                 EXCEPTION;
182 
183   -- to convert from FND_STANDARD_DATE value set to DATE (concurrent manager
184   -- passes as VARCHAR2)
185   l_start_date          DATE := fnd_date.canonical_to_date(start_date);
186   l_end_date            DATE := fnd_date.canonical_to_date(end_date);
187 
188 BEGIN
189   retcode := 0; -- success = 0, warning = 1, fail = 2
190 
191   cn_message_pkg.begin_batch(x_process_type => 'POSTING',
192            x_process_audit_id => l_proc_audit_id,
193            x_parent_proc_audit_id => l_proc_audit_id,
194            x_request_id => fnd_global.conc_request_id,
195            p_org_id       => p_org_id);
196 
197   cn_message_pkg.debug('Start Posting Details...');
198 
199   IF (l_end_date IS NULL OR l_start_date > l_end_date) THEN
200      cn_message_pkg.debug('End_date is null or start date is later than the end date.');
201      RAISE ABORT;
202   END IF;
203 
204   --initialize message list
205   fnd_msg_pub.initialize;
206 
207   cn_posting_pvt.posting_details(l_api_version,
208              l_init_msg_list,
209              l_commit,
210              l_return_status,
211              l_msg_count,
212              l_msg_data,
213              l_start_date,
214              l_end_date,
215              l_proc_audit_id);
216 
217   IF (l_return_status <> FND_API.G_RET_STS_SUCCESS) THEN
218      retcode := 2; -- failure
219   END IF;
220 
221   cn_api.get_fnd_message(l_msg_count, l_msg_data);
222   cn_message_pkg.debug('End of Posting Details.');
223   cn_message_pkg.end_batch(l_proc_audit_id);
224 
225   IF retcode = 0 THEN
226      fnd_message.set_name('CN', 'ALL_PROCESS_DONE_OK');
227      fnd_msg_pub.ADD;
228      errbuf := fnd_msg_pub.get(p_msg_index => fnd_msg_pub.g_last,
229              p_encoded => fnd_api.g_false);
230    ELSIF retcode = 1 THEN
231      fnd_message.set_name('CN', 'ALL_PROCESS_DONE_WARN');
232      fnd_msg_pub.ADD;
233      errbuf := fnd_msg_pub.get(p_msg_index => fnd_msg_pub.g_last,
234              p_encoded => fnd_api.g_false);
235    ELSE
236      fnd_message.set_name('CN', 'ALL_PROCESS_DONE_FAIL');
237      fnd_msg_pub.ADD;
238      errbuf := fnd_msg_pub.get(p_msg_index => fnd_msg_pub.g_last,
239              p_encoded => fnd_api.g_false);
240   END IF;
241 
242 EXCEPTION
243    WHEN OTHERS THEN
244       retcode := 2;
245       errbuf := SQLCODE||' '||Sqlerrm;
246       cn_message_pkg.end_batch(l_proc_audit_id);
247 END posting_conc;
248 
249 END CN_PREPOSTBATCHES;