DBA Data[Home] [Help]

PACKAGE BODY: APPS.GMS_STREAMLINE_PROC

Source


1 package body GMS_STREAMLINE_PROC as
2 /* $Header: gmsstrmb.pls 120.6 2007/02/07 10:51:09 vthakkar 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 
95   SELECT set_of_books_id, org_id INTO l_sob_id, l_org_id from pa_implementations;
96 
97   stage := '110';
98 
99     WHILE (loop_count < 10) LOOP
100 
101        loop_count := loop_count +1;
102 
103        stage := '120';
104 
105        l_process_label :=  PARSE_STREAM(process_stream,'-',l_position);
106 
107        If (l_process_label is NULL) then
108           exit;
109        End if;
110 
111        stage := '130';
112 
113        if (l_process_label = 'DVC')  Then
114 
115          -- GMS: Distribute Supplier Invoice Adjustment Costs and Funds Check
116 
117 	 -- Bug 2931481 : Added system_linkage_function('VI') parameter and added NULL parameters
118 	 -- Bug 4522760 : Added two more parameters in the call after project_id
119 
120          FND_REQUEST.set_org_id(l_org_id);
121 
122 	 ret_value := fnd_request.submit_request( 'GMS','GMSFCIAR',NULL,NULL,FALSE,
123                                                       project_id,NULL,NULL,through_date,NULL,NULL,NULL,NULL,'VI');
124 
125        stage := '140';
126 
127        Elsif (l_process_label = 'EXP')  Then
128 
129            -- fund check and costing of expense report
130 
131            -- Bug 2931481 : Added system_linkage_function('ER') parameter and added NULL parameters
132 	   -- Bug 4522760 : Added one NULL parameter in the call before 'ER'
133 
134 	   FND_REQUEST.set_org_id(l_org_id);
135 
136            ret_value := fnd_request.submit_request( 'GMS','GMSFCERR',NULL,NULL,FALSE,NULL,
137                                                        project_id,NULL, through_date,NULL,NULL,NULL,NULL,NULL,'ER');
138        stage := '150';
139 
140        Elsif (l_process_label = 'LAB')  Then
141 
142 
143            -- GMS: Costing and Funds Check on Straight Time Labor
144 
145             -- Bug 1656851: Added System Linkage Parameter 'ST'
146 	    -- Bug 4522760: Added two more parameters in the call before through_date
147 
148 	    FND_REQUEST.set_org_id(l_org_id);
149 
150             ret_value := fnd_request.submit_request( 'GMS','GMSFCSTR',NULL,NULL,FALSE,NULL,
151                                                      project_id,NULL,NULL,NULL, through_date,NULL,NULL,NULL,NULL,NULL,'ST');
152 
153        stage := '160';
154 
155        Elsif (l_process_label in ('DUSG', 'DPJ', 'DINV', 'DWIP', 'DBTC'))  Then
156 
157 
158 
159 
160 
161 
162             -- GMS: Costing and Funds Check on Usages, Misc, Inv, Wip, Burden
163 
164             -- Bug 1656851: Added System Linkage Parameter 'US'
165 	    -- Bug 4502802; Added two more param
166 
167 	    l_sys_link := ltrim(l_process_label,'D');
168 
169 	    FND_REQUEST.set_org_id(l_org_id);
170 
171             ret_value := fnd_request.submit_request( 'GMS','GMSFCUSR',NULL,NULL,FALSE,NULL,
172                                                        project_id,NULL,NULL,through_date, l_sys_link, NULL,NULL,NULL,NULL,'US');
173 
174 	    stage := '170';
175 
176        Elsif l_process_label in ('DTBC') Then
177 
178 	        -- PRC: Distribute Total Burdened Cost
179 
180 		 FND_REQUEST.set_org_id(l_org_id);
181 
182 	         ret_value := fnd_request.submit_request( 'PA','PACODTBC',NULL,NULL,FALSE,
183                                                        NULL, project_id, through_date, NULL, NULL, NULL, NULL, debug_mode_flag);
184 		 stage := '175';
185 
186 
187 
188        Elsif (l_process_label in ('EUSG', 'EPJ', 'EINV', 'EWIP', 'EBTC','ETBC', 'ELAB', 'ESC')) THEN
189 
190             CASE l_process_label
191 	         WHEN 'EUSG' THEN l_proc_Cat := 'USAGE_COST';
192 		 WHEN 'EPJ'  THEN l_proc_Cat := 'MISCELLANEOUS_COST';
193 		 WHEN 'EINV' THEN l_proc_Cat := 'INVENTORY_COST';
194 		 WHEN 'EWIP' THEN l_proc_Cat := 'WIP_COST';
195 		 WHEN 'EBTC' THEN l_proc_Cat := 'BTC_COST';
196 		 WHEN 'ELAB' THEN l_proc_Cat := 'LABOR_COST';
197 		 WHEN 'ESC'  THEN l_proc_Cat := 'SUPPLIER_COST';
198 		 WHEN 'ETBC' THEN l_proc_Cat := 'TBC_COST';
199 	     END CASE;
200 
201 
202 	      -- PRC: Generate Cost Accounting Events
203 
204 	      FND_REQUEST.set_org_id(l_org_id);
205 
206 	      ret_value := fnd_request.submit_request( 'PA', 'PAGCAE', NULL, NULL, FALSE, l_proc_cat, through_date, NULL,
207 	                                               NULL, NULL, NULL, NULL);
208 
209        stage := '180';
210 
211 	Elsif  (l_process_label in ('AUSG', 'APJ', 'AINV', 'AWIP', 'ABTC','ATBC', 'ALAB', 'ASC')) THEN
212 
213             CASE l_process_label
214 	         WHEN 'AUSG' THEN l_proc_Cat := 'USAGE_COST';
215 		 WHEN 'APJ'  THEN l_proc_Cat := 'MISCELLANEOUS_COST';
216 		 WHEN 'AINV' THEN l_proc_Cat := 'INVENTORY_COST';
217 		 WHEN 'AWIP' THEN l_proc_Cat := 'WIP_COST';
218 		 WHEN 'ABTC' THEN l_proc_Cat := 'BTC_COST';
219 		 WHEN 'ALAB' THEN l_proc_Cat := 'LABOR_COST';
220 		 WHEN 'ASC'  THEN l_proc_Cat := 'SUPPLIER_COST';
221 		 WHEN 'ATBC' THEN l_proc_Cat := 'TBC_COST';
222 	     END CASE;
223 
224 	      -- PRC: Create Accounting
225 
226 	      FND_REQUEST.set_org_id(l_org_id);
227 
228               ret_value := fnd_request.submit_request( 'PA', 'PAXACCPB', NULL, NULL, FALSE, 275, 275, 'Y', l_sob_id,
229 	                                               l_proc_cat, NVL(through_date,TO_CHAR(SYSDATE,'YYYY/MM/DD')), 'Y', 'Y', 'F', 'Y', 'N', 'S', 'Y', 'Y',
230 						       'N', NULL, NULL, 'N', NULL, NULL, NULL, NULL, NULL, NULL,
231 						       NULL, 'Final', NULL, NULL, NULL, NULL, NULL, NULL, l_org_id,
232 						       NULL, NULL, NULL, NULL, NULL, NULL, 'N', 'N');
233 
234        stage := '190';
235 
236 
237        Else
238            L_process := NULL;
239            ret_value := NULL;
240        End if;
241 
242        stage := '200';
243 
244        If (ret_value is null) then
245            RETCODE := 2;
246            ERRBUF  := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||': No process submitted.';
247            exit;
248        stage := '210';
249        Elsif (ret_value  = 0) then
250            ROLLBACK;
251            RETCODE := 2;
252            ERRBUF  := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||' : Failed to spawn process' ;
253            exit;
254        stage := '220';
255        Else
256            commit;
257              -- Wait for cuncurrent process to complete.
258               If fnd_concurrent.wait_for_request (ret_value, 30, 0, phase, l_status,
259                                                    dev_phase, dev_status, mesg) then
260                 Null;
261               end if;
262        End if;
263 
264        l_position := l_position + 1;
265 
266     END LOOP;
267    EXCEPTION
268     WHEN OTHERS THEN
269        ROLLBACK;
270        RETCODE := 2;
271        ERRBUF  := 'Error in GMS_STREAMLINE_PROC.GMSISLPR at stage '||stage||' : '||sqlerrm;
272 
273 END GMSISLPR;
274 
275 end GMS_STREAMLINE_PROC;