[Home] [Help]
PACKAGE BODY: APPS.GMS_STREAMLINE_PROC
Source
1 package body GMS_STREAMLINE_PROC as
2 /* $Header: gmsstrmb.pls 120.6.12020000.2 2012/07/18 09:34:35 admarath ship $ */
3
4 -- function to return a delimited string from a stream.
5
6 function PARSE_STREAM(stream_text in varchar2,
7 stream_seperator in varchar2,
8 stream_position in number)
9 return varchar2 is
10
11 l_process varchar2(30);
12 l_start_position number;
13 l_end_position number;
14
15 BEGIN
16 If ((stream_text is NULL) or
17 (stream_seperator is NULL) or
18 (stream_position is NULL))
19 Then
20 return NULL;
21 End if;
22
23 -- get start position
24
25 If (stream_position = 1) then
26 l_start_position := 1;
27 Elsif (stream_position > 1) then
28 l_start_position := instr(stream_text,stream_seperator,1,(stream_position - 1));
29 If (l_start_position = 0) then
30 return NULL;
31 Else
32 l_start_position := l_start_position + 1;
33 End if;
34 End if;
35 -- get end position
36 l_end_position := instr(stream_text,stream_seperator,1,stream_position);
37 If (l_end_position = 0) then
38 NULL;
39 Else
40 l_end_position := l_end_position - 1;
41 End if;
42 -- get the process
43 If (l_end_position = 0) then
44 l_process := substr(stream_text, l_start_position);
45 Else
46 l_process := substr(stream_text, l_start_position,(l_end_position - l_start_position + 1));
47 End if;
48
49 return l_process;
50
51 END PARSE_STREAM;
52
53 -- Procedure for GMS streamline interface process
54
55 -- The datatype of variable through_date has been chaned to varchar2.
56 -- Refer Bug 2644176.
57 procedure GMSISLPR(errbuf out NOCOPY varchar2,
58 retcode out NOCOPY varchar2,
59 process_stream in varchar2,
60 project_id in number ,
61 through_date in varchar2 ,
62 reschedule_interval in number ,
63 reschedule_time in date ,
64 stop_date in date ,
65 adjust_dates in varchar2 ,
66 debug_mode in varchar2
67 ) is
68
69 l_process_label varchar2(10);
70 l_process varchar2(10);
71 l_application varchar2(10);
72 l_position number := 1;
73 ret_value number;
74 l_status varchar2(30);
75 dev_phase varchar2(30);
76 dev_status varchar2(30);
77 mesg varchar2(30);
78 phase varchar2(30);
79 loop_count number := 0;
80 stage varchar2(10);
81
82 user_id varchar2(15); -- User id initiated the process
83 debug_mode_flag varchar2(1); -- stores the debug mode set for the application /* Bug 4367120 */
84 l_org_id number;
85 l_sob_id number;
86 l_sys_link varchar2(3);
87 l_proc_Cat varchar2(30);
88
89 BEGIN
90
91 stage := '100';
92
93 debug_mode_flag := NVL(FND_PROFILE.value('PA_DEBUG_MODE'), 'N');
94 user_id := NVL(FND_PROFILE.value('USER_ID'), -1); -- for bug 6673370
95
96 SELECT set_of_books_id, org_id INTO l_sob_id, l_org_id from pa_implementations;
97
98 stage := '110';
99
100 WHILE (loop_count < 10) LOOP
101
102 loop_count := loop_count +1;
103
104 stage := '120';
105
106 l_process_label := PARSE_STREAM(process_stream,'-',l_position);
107
108 If (l_process_label is NULL) then
109 exit;
110 End if;
111
112 stage := '130';
113
114 if (l_process_label = 'DVC') Then
115
116 -- GMS: Distribute Supplier Invoice Adjustment Costs and Funds Check
117
118 -- Bug 2931481 : Added system_linkage_function('VI') parameter and added NULL parameters
119 -- Bug 4522760 : Added two more parameters in the call after project_id
120
121 FND_REQUEST.set_org_id(l_org_id);
122
123 ret_value := fnd_request.submit_request( 'GMS','GMSFCIAR',NULL,NULL,FALSE,
124 project_id,NULL,NULL,through_date,NULL,NULL,NULL,NULL,'VI');
125
126 stage := '140';
127
128 Elsif (l_process_label = 'EXP') Then
129
130 -- fund check and costing of expense report
131
132 -- Bug 2931481 : Added system_linkage_function('ER') parameter and added NULL parameters
133 -- Bug 4522760 : Added one NULL parameter in the call before 'ER'
134
135 FND_REQUEST.set_org_id(l_org_id);
136
137 ret_value := fnd_request.submit_request( 'GMS','GMSFCERR',NULL,NULL,FALSE,NULL,
138 project_id,NULL, through_date,NULL,NULL,NULL,NULL,NULL,'ER');
139 stage := '150';
140
141 Elsif (l_process_label = 'LAB') Then
142
143
144 -- GMS: Costing and Funds Check on Straight Time Labor
145
146 -- Bug 1656851: Added System Linkage Parameter 'ST'
147 -- Bug 4522760: Added two more parameters in the call before through_date
148
149 FND_REQUEST.set_org_id(l_org_id);
150
151 ret_value := fnd_request.submit_request( 'GMS','GMSFCSTR',NULL,NULL,FALSE,NULL,
152 project_id,NULL,NULL,NULL, through_date,NULL,NULL,NULL,NULL,NULL,'ST');
153
154 stage := '160';
155
156 Elsif (l_process_label in ('DUSG', 'DPJ', 'DINV', 'DWIP', 'DBTC')) Then
157
158
159
160
161
162
163 -- GMS: Costing and Funds Check on Usages, Misc, Inv, Wip, Burden
164
165 -- Bug 1656851: Added System Linkage Parameter 'US'
166 -- Bug 4502802; Added two more param
167
168 l_sys_link := ltrim(l_process_label,'D');
169
170 FND_REQUEST.set_org_id(l_org_id);
171
172 ret_value := fnd_request.submit_request( 'GMS','GMSFCUSR',NULL,NULL,FALSE,NULL,
173 project_id,NULL,NULL,through_date, l_sys_link, NULL,NULL,NULL,NULL,'US');
174
175 stage := '170';
176
177 Elsif l_process_label in ('DTBC') Then
178
179 -- PRC: Distribute Total Burdened Cost
180
181 FND_REQUEST.set_org_id(l_org_id);
182
183 ret_value := fnd_request.submit_request( 'PA','PACODTBC',NULL,NULL,FALSE,
184 NULL, project_id, through_date, NULL, NULL, NULL, NULL, debug_mode_flag);
185 stage := '175';
186
187
188
189 Elsif (l_process_label in ('EUSG', 'EPJ', 'EINV', 'EWIP', 'EBTC','ETBC', 'ELAB', 'ESC')) THEN
190
191 CASE l_process_label
192 WHEN 'EUSG' THEN l_proc_Cat := 'USAGE_COST';
193 WHEN 'EPJ' THEN l_proc_Cat := 'MISCELLANEOUS_COST';
194 WHEN 'EINV' THEN l_proc_Cat := 'INVENTORY_COST';
195 WHEN 'EWIP' THEN l_proc_Cat := 'WIP_COST';
196 WHEN 'EBTC' THEN l_proc_Cat := 'BTC_COST';
197 WHEN 'ELAB' THEN l_proc_Cat := 'LABOR_COST';
198 WHEN 'ESC' THEN l_proc_Cat := 'SUPPLIER_COST';
199 WHEN 'ETBC' THEN l_proc_Cat := 'TBC_COST';
200 END CASE;
201
202
203 -- PRC: Generate Cost Accounting Events
204
205 FND_REQUEST.set_org_id(l_org_id);
206
207 ret_value := fnd_request.submit_request( 'PA', 'PAGCAE', NULL, NULL, FALSE, l_proc_cat, through_date, NULL,
208 NULL, NULL, NULL, NULL);
209
210 stage := '180';
211
212 Elsif (l_process_label in ('AUSG', 'APJ', 'AINV', 'AWIP', 'ABTC','ATBC', 'ALAB', 'ASC')) THEN
213
214 CASE l_process_label
215 WHEN 'AUSG' THEN l_proc_Cat := 'USAGE_COST';
216 WHEN 'APJ' THEN l_proc_Cat := 'MISCELLANEOUS_COST';
217 WHEN 'AINV' THEN l_proc_Cat := 'INVENTORY_COST';
218 WHEN 'AWIP' THEN l_proc_Cat := 'WIP_COST';
219 WHEN 'ABTC' THEN l_proc_Cat := 'BTC_COST';
220 WHEN 'ALAB' THEN l_proc_Cat := 'LABOR_COST';
221 WHEN 'ASC' THEN l_proc_Cat := 'SUPPLIER_COST';
222 WHEN 'ATBC' THEN l_proc_Cat := 'TBC_COST';
223 END CASE;
224
225 -- PRC: Create Accounting
226
227 FND_REQUEST.set_org_id(l_org_id);
228
229 ret_value := fnd_request.submit_request( 'PA', 'PAXACCPB', NULL, NULL, FALSE, 275, 275, 'Y', l_sob_id,
230 l_proc_cat, NVL(through_date,TO_CHAR(SYSDATE,'YYYY/MM/DD')), 'Y', 'Y', 'F', 'Y', 'N', 'S', 'Y', 'Y',
231 'N', NULL, NULL, 'N', NULL, NULL, NULL, NULL, NULL, NULL,
232 NULL, 'Final', NULL, NULL, NULL, NULL, NULL, NULL, l_org_id,
233 NULL, NULL, NULL, NULL, NULL, NULL, 'N', 'N',user_id); --added for bug 6673370
234
235 stage := '190';
236
237
238 Else
239 L_process := NULL;
240 ret_value := NULL;
241 End if;
242
243 stage := '200';
244
245 If (ret_value is null) then
246 RETCODE := 2;
247 ERRBUF := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||': No process submitted.';
248 exit;
249 stage := '210';
250 Elsif (ret_value = 0) then
251 ROLLBACK;
252 RETCODE := 2;
253 ERRBUF := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||' : Failed to spawn process' ;
254 exit;
255 stage := '220';
256 Else
257 commit;
258 -- Wait for cuncurrent process to complete.
259 If fnd_concurrent.wait_for_request (ret_value, 30, 0, phase, l_status,
260 dev_phase, dev_status, mesg) then
261 Null;
262 end if;
263 End if;
264
265 l_position := l_position + 1;
266
267 END LOOP;
268 EXCEPTION
269 WHEN OTHERS THEN
270 ROLLBACK;
271 RETCODE := 2;
272 ERRBUF := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||' : '||sqlerrm;
273
274 END GMSISLPR;
275
276 end GMS_STREAMLINE_PROC;