DBA Data[Home] [Help]

PACKAGE BODY: APPS.WIP_MTLTEMPPROC_GRP

Source


1 package body wip_mtlTempProc_grp as
2  /* $Header: wiptmppb.pls 115.18 2003/10/13 19:16:59 kmreddy ship $ */
3 
4   non_txactable_value CONSTANT VARCHAR2(1) := 'N';
5 
6   g_pkgName constant varchar2(30) := 'wip_mtlTempProc_grp';
7 
8   procedure processTemp(p_initMsgList IN VARCHAR2,
9                         p_processInv IN VARCHAR2, --whether or not to call inventory TM
10                         p_txnHdrID IN NUMBER,
11                         p_mtlTxnBusinessFlowCode IN NUMBER := null,
12                         x_returnStatus OUT NOCOPY VARCHAR2,
13                         x_errorMsg OUT NOCOPY VARCHAR2) IS
14     l_errMsg VARCHAR2(2000);
15     l_errCode VARCHAR2(2000);
16     l_params wip_logger.param_tbl_t;
17     l_retStatus VARCHAR2(1);
18     l_logRetStatus VARCHAR2(1);
19     l_retCode NUMBER;
20     l_logLevel NUMBER := to_number(fnd_log.g_current_runtime_level);
21     l_flowSchedCount NUMBER;
22     l_procName VARCHAR2(30) := 'processTemp';
23   begin
24 -------------------------------------------------------------
25 --Initial Preprocessing
26 -------------------------------------------------------------
27 
28     savepoint wiptmppb0;
29 
30     if (l_logLevel <= wip_constants.trace_logging) then
31       l_params(1).paramName := 'p_initMsgList';
32       l_params(1).paramValue := p_initMsgList;
33       l_params(2).paramName := 'p_processInv';
34       l_params(2).paramValue := p_processInv;
35       l_params(3).paramName := 'p_txnHdrID';
36       l_params(3).paramValue := p_txnHdrID;
37       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
38                             p_params       => l_params,
39                             x_returnStatus => x_returnStatus);
40       if(x_returnStatus <> fnd_api.g_ret_sts_success) then
41         raise fnd_api.g_exc_unexpected_error;
42       end if;
43     end if;
44 
45     if(fnd_api.to_boolean(p_initMsgList)) then
46       fnd_msg_pub.initialize;
47     end if;
48 
49     l_retCode := inv_lpn_trx_pub.process_lpn_trx(p_trx_hdr_id       => p_txnHdrID,
50                                                  p_business_flow_code => p_mtlTxnBusinessFlowCode,
51                                                  x_proc_msg         => x_errorMsg);
52 
53     if(nvl(l_retCode, -1) <> 0) then
54       fnd_msg_pub.initialize;
55       fnd_message.set_name('FND', 'FND_GENERIC_MESSAGE');
56       fnd_message.set_token('MESSAGE', x_errorMsg);
57       x_returnStatus := fnd_api.g_ret_sts_error;
58     else
59       x_returnStatus := fnd_api.g_ret_sts_success;
60     end if;
61 
62     if (l_logLevel <= wip_constants.trace_logging) then
63       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
64                            p_procReturnStatus => x_returnStatus,
65                            p_msg              => 'normal completion. errMsg:' || x_errorMsg,
66                            x_returnStatus     => l_retStatus);
67       wip_logger.cleanup(l_retStatus);
68     end if;
69   exception
70     when others then
71       rollback to wiptmppb0;
72       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
73       fnd_msg_pub.add_exc_msg(p_pkg_name       => g_pkgName,
74                               p_procedure_name => l_procName,
75                               p_error_text     => SQLERRM);
76       wip_utilities.get_message_stack(p_msg => x_errorMsg,
77                                      p_delete_stack => fnd_api.g_false,
78                                      p_separator => ' ');
79       fnd_message.set_name('WIP', 'MTL_PROC_FAIL');
80       l_errCode := fnd_message.get;
81 
82       update mtl_material_transactions_temp
83          set process_flag = 'E',
84              error_code = substr(l_errCode,1,240),
85              error_explanation = substr(x_errorMsg,1,240)
86        where transaction_header_id = p_txnHdrID
87          and process_flag in ('Y', 'W')
88          and transaction_source_type_id = 5
89          and transaction_action_id in (wip_constants.isscomp_action,
90                                        wip_constants.retcomp_action,
91                                        wip_constants.issnegc_action,
92                                        wip_constants.retnegc_action);
93 
94       if (l_logLevel <= wip_constants.trace_logging) then
95         wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
96                              p_procReturnStatus => x_returnStatus,
97                              p_msg              => 'unhandled exception: ' || SQLERRM,
98                              x_returnStatus     => l_retStatus);
99         wip_logger.cleanup(l_retStatus);
100       end if;
101   end processTemp;
102 
103   procedure processWIP(p_txnTmpID IN NUMBER,
104                        x_returnStatus OUT NOCOPY VARCHAR2,
105                        x_errorMsg OUT NOCOPY VARCHAR2) is
106     l_reqID NUMBER;
107     l_logLevel NUMBER := fnd_log.g_current_runtime_level;
108   begin
109     savepoint wiptmppb100;
110     if(l_logLevel <= wip_constants.trace_logging) then
111       --if a concurrent request, put the session ID in the concurrent
112       --request''s log file.
113       l_reqID := fnd_global.conc_request_id;
114       if(nvl(l_reqID, -1) <> -1) then
115         fnd_file.put_line(which => fnd_file.log,
116                           buff => 'AUDSID: ' || fnd_global.session_id);
117       end if;
118     end if;
119     wip_mtlTempProc_priv.processWIP(p_txnTmpID => p_txnTmpID,
120                                     p_endDebug => fnd_api.g_false,
121                                     p_processLpn => fnd_api.g_false,
122                                     x_returnStatus => x_returnStatus,
123                                     x_errorMsg => x_errorMsg);
124   exception
125     when others then
126       rollback to wiptmppb100;
127       x_returnStatus := fnd_api.g_ret_sts_unexp_error;
128       fnd_msg_pub.add_exc_msg(p_pkg_name => 'wip_mtlTempProc_grp',
129                               p_procedure_name => 'processWIP',
130                               p_error_text => SQLERRM);
131       x_errorMsg := substrb(SQLERRM, 1, 240);
132   end processWIP;
133 
134   function isTxnIDRequired(p_txnTmpID IN NUMBER) return boolean is
135     l_txnSrcTypID NUMBER;
136     l_wipEntityType NUMBER;
137     l_wipEntityID NUMBER;
138     l_orgID NUMBER;
139     l_txnActionID NUMBER;
140     l_procName VARCHAR2(30) := 'isTxnIDRequired';
141     l_retStatus VARCHAR2(1);
142     l_logLevel NUMBER := to_number(fnd_log.g_current_runtime_level);
143     l_params wip_logger.param_tbl_t;
144   begin
145     if (l_logLevel <= wip_constants.trace_logging) then
146       l_params(1).paramName := 'p_txnTmpID';
147       l_params(1).paramValue := p_txnTmpID;
148       wip_logger.entryPoint(p_procName     => g_pkgName || '.' || l_procName,
149                             p_params       => l_params,
150                             x_returnStatus => l_retStatus);
151     end if;
152 
153     select transaction_source_type_id,
154            wip_entity_type,
155            transaction_source_id,
156            organization_id,
157            transaction_action_id
158       into l_txnSrcTypID,
159            l_wipEntityType,
160            l_wipEntityID,
161            l_orgID,
162            l_txnActionID
163       from mtl_material_transactions_temp
164      where transaction_temp_id = p_txnTmpID;
165 
166     if(l_logLevel <= wip_constants.full_logging) then
167       wip_logger.log('   txn src type:' || l_txnSrcTypID, l_retStatus);
168       wip_logger.log('wip entity type:' || l_wipEntityType, l_retStatus);
169       wip_logger.log('  wip entity id:' || l_wipEntityID, l_retStatus);
170       wip_logger.log('         org id:' || l_orgID, l_retStatus);
171       wip_logger.log('  txn action id:' || l_txnActionID, l_retStatus);
172     end if;
173 
174     if(l_txnSrcTypID = 5) then
175       if(l_wipEntityType = wip_constants.repetitive) then
176         if (l_logLevel <= wip_constants.trace_logging) then
177           wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
178                                p_procReturnStatus => 'true',
179                                p_msg              => 'found repetitive',
180                                x_returnStatus     => l_retStatus);
181           wip_logger.cleanup(l_retStatus);
182         end if;
183         return true;
184       elsif(l_wipEntityType is null) then
185         select entity_type
186           into l_wipEntityType
187           from wip_entities
188          where wip_entity_id = l_wipEntityID
189            and organization_id = l_orgID;
190 
191         if (l_logLevel <= wip_constants.trace_logging) then
192           wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
193                                p_procReturnStatus => l_wipEntityType || '==' || wip_constants.repetitive,
194                                p_msg              => 'queried for wip_entity_type',
195                                x_returnStatus     => l_retStatus);
196           wip_logger.cleanup(l_retStatus);
197         end if;
198         return (l_wipEntityType = wip_constants.repetitive);
199       end if;
200     end if;
201 
202     if (l_logLevel <= wip_constants.trace_logging) then
203       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
204                            p_procReturnStatus => 'false',
205                            p_msg              => 'not repetitive',
206                            x_returnStatus     => l_retStatus);
207       wip_logger.cleanup(l_retStatus);
208     end if;
209     return false;
210   exception
211     when others then
212     if (l_logLevel <= wip_constants.trace_logging) then
213       wip_logger.exitPoint(p_procName         => g_pkgName || '.' || l_procName,
214                            p_procReturnStatus => 'false',
215                            p_msg              => 'sql error:' || SQLERRM,
216                            x_returnStatus     => l_retStatus);
217       wip_logger.cleanup(l_retStatus);
218     end if;
219     return false;
220   end isTxnIDRequired;
221 
222 end wip_mtlTempProc_grp;