1 package body wsm_infinite_scheduler_grp as
2 /* $Header: WSMGIFSB.pls 115.3 2003/10/28 21:41:14 zchen noship $ */
3
4 --private types
5 type num_tbl_t is table of number;
6 type date_tbl_t is table of date;
7 --private procedures
8
9
10 -------------------------------------------------------------------------
11 -- This API is a group API to schedule a lot based job based on
12 -- resources usages, assuming infinite resource availibility. It will
13 -- validate the parameter and call WSM private API to schedule the job.
14 -- and then update the schedule dates in WDJ, WO, WOR, WCO, WCOR.
15 -- OSFM scheduler will only schedule current and future operations
16 -- All the completed operations will not be re-scheduled
17 --
18 -- Parameters:
19 -- + p_initMsgList: Clear the message stack before processing?
20 -- True (fnd_api.g_true) should be passed
21 -- unless relevant messages are being saved
22 -- on the stack. This value defaults to true.
23 --
24 -- + p_endDebug: Pass true (fnd_api.g_true) unless the
25 -- debug session will be ended at a later
26 -- point by the caller. This value defaults
27 -- to true
28 --
29 -- + p_orgID: The organization of the entity.
30 --
31 -- + p_wipEntityID: The entity to reschedule.
32 --
33 -- + p_scheduleMode: will have the following values
34 --
35 -- MIDPOINT CONSTANT NUMBER := 6;
36 -- MIDPOINT_FORWARDS CONSTANT NUMBER := 7;
37 -- MIDPOINT_BACKWARDS CONSTANT NUMBER := 8;
38 -- CURRENT_OP CONSTANT NUMBER := 9;
39 -- CURRENT_SUB_GRP CONSTANT NUMBER := 11;
40 --
41 -- - If p_scheduleMode = WIP_CONSTANTS.CURRENT_OP,
42 -- p_opSeqNum must be given, only operation
43 -- p_opSeqNum will be scheduled
44 -- - If p_scheduleMode = WIP_CONSTANTS.MIDPOINT,
45 -- p_opSeqNum must be given, all the current and
46 -- future operations will be scheduled
47 -- - If p_scheduleMode = WIP_CONSTANTS.MIDPOINT_FORWARDS,
48 -- p_opSeqNum must be given, all operations after and
49 -- include p_opSeqNum will be scheduled
50 -- - If p_scheduleMode = WIP_CONSTANTS.MIDPOINT_BACKWARDS,
51 -- p_opSeqNum must be given, all operations before and
52 -- include p_opSeqNum will be scheduled
53 -- - If p_scheduleMode = WIP_CONSTANTS.CURRENT_SUB_GRP,
54 -- p_opSeqNum and p_resSeqNum must be given, only
55 -- resources with the same (substitute_group_number,
56 -- replacement_group_number) as this resource will be
57 -- scheduled
58 --
59 -- + p_startDate: The start anchor date of either the operation
60 -- or resource.
61 --
62 -- + p_endDate: The end anchor date of either the operation
63 -- or resource.
64 --
65 -- + p_opSeqNum: Populate to midpoint schedule.
66 -- Should be negative if passing current job op_seq_num,
67 -- should be possitive if passing routing op_seq_num
68 --
69 -- + p_resSeqNum: Populate to midpoint schedule down to the resource
70 -- level, only used if p_opSeqNum is populated.
71 -- pass -JOB_OP_SEQ_NUM if it is the current op
72 --
73 -- + x_returnStatus:fnd_api.g_ret_sts_success if the entity
74 -- was scheduled successfully.
75 --
76 -- + x_errorMsg: The error message. The error message will also
77 -- be left on the stack.
78 -------------------------------------------------------------------------
79
80 procedure schedule(
81 p_initMsgList in varchar2 := null,
82 p_endDebug in varchar2 := null,
83 p_orgID in number,
84 p_wipEntityID in number,
85 p_scheduleMode in number := null,
86 p_startDate in date := null,
87 p_endDate in date := null,
88 p_opSeqNum in number := null,
89 p_resSeqNum in number := null,
90 x_returnStatus out nocopy varchar2,
91 x_errorMsg out nocopy varchar2) is
92
93 l_logLevel NUMBER := fnd_log.g_current_runtime_level;
94 l_params wip_logger.param_tbl_t;
95 l_retStatus VARCHAR2(1);
96 l_resTbls wip_infResSched_grp.op_res_rectbl_t;
97 l_repLineID NUMBER;
98 l_opTbl num_tbl_t;
99 l_assignedUnits num_tbl_t;
100
101 l_curJobOpSeqNum NUMBER := null; -- current job op_seq_num
102 l_strRtgOpSeqNum NUMBER := null; -- routing start op_seq_num
103 l_endRtgOpSeqNum NUMBER := null; -- routing end op_seq_num
104
105 e_invalid_mode exception;
106
107 begin
108
109 if (l_logLevel <= wip_constants.trace_logging) then
110 l_params(1).paramName := 'p_wipEntityID';
111 l_params(1).paramValue := p_wipEntityID;
112
113 wip_logger.entryPoint(
114 p_procName => 'wsm_infinite_scheduler_grp.schedule',
115 p_params => l_params,
116 x_returnStatus => x_returnStatus);
117 if(x_returnStatus <> fnd_api.g_ret_sts_success) then
118 raise fnd_api.g_exc_unexpected_error;
119 end if;
120 end if;
121 x_returnStatus := fnd_api.g_ret_sts_success;
122
123 -- do validation here
124 if (l_logLevel <= wip_constants.full_logging) then
125 wip_logger.log('validate parameters p_scheduleMode...', l_retStatus);
126 end if;
127 if p_scheduleMode NOT IN (
128 WIP_CONSTANTS.MIDPOINT,
129 WIP_CONSTANTS.MIDPOINT_FORWARDS,
130 WIP_CONSTANTS.MIDPOINT_BACKWARDS,
131 WIP_CONSTANTS.CURRENT_OP,
132 --WIP_CONSTANTS.CURRENT_OP_RES
133 WIP_CONSTANTS.CURRENT_SUB_GRP )
134 then
135 raise e_invalid_mode;
136 end if;
137
138 -- call private API
139 if (l_logLevel <= wip_constants.full_logging) then
140 wip_logger.log('scheduling lot based job...', l_retStatus);
141 end if;
142 wsm_infinite_scheduler_pvt.schedule(
143 p_initMsgList => p_initMsgList,
144 p_endDebug => p_endDebug,
145 p_orgID => p_orgID,
146 p_wipEntityID => p_wipEntityID,
147 p_scheduleMode => p_scheduleMode,
148 p_startDate => p_startDate,
149 p_endDate => p_endDate,
150 p_opSeqNum => p_opSeqNum,
151 p_resSeqNum => p_resSeqNum,
152 x_returnStatus => x_returnStatus,
153 x_errorMsg => x_errorMsg);
154 if(x_returnStatus <> fnd_api.g_ret_sts_success) then
155 raise fnd_api.g_exc_unexpected_error;
156 end if;
157
158 exception
159
160 when e_invalid_mode then
161 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
162 x_errorMsg := 'p_scheduleMode = ' || p_scheduleMode || ' is not supported';
163 if (l_logLevel <= wip_constants.trace_logging) then
164 wip_logger.exitPoint(
165 p_procName => 'wsm_infinite_scheduler_grp.schedule',
166 p_procReturnStatus => x_returnStatus,
167 p_msg => 'error: ' || x_errorMsg,
168 x_returnStatus => l_retStatus);
169 if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_true))) then
170 wip_logger.cleanup(l_retStatus);
171 end if;
172 end if;
173
174 when fnd_api.g_exc_unexpected_error then
175 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
176 wip_utilities.get_message_stack(
177 p_msg => x_errorMsg,
178 p_delete_stack => fnd_api.g_false);
179 if (l_logLevel <= wip_constants.trace_logging) then
180 wip_logger.exitPoint(
181 p_procName => 'wsm_infinite_scheduler_grp.schedule',
182 p_procReturnStatus => x_returnStatus,
183 p_msg => 'error: ' || x_errorMsg,
184 x_returnStatus => l_retStatus);
185 if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_true))) then
186 wip_logger.cleanup(l_retStatus);
187 end if;
188 end if;
189
190 when others then
191 x_returnStatus := fnd_api.g_ret_sts_unexp_error;
192 fnd_msg_pub.add_exc_msg(
193 p_pkg_name => 'wsm_infinite_scheduler_grp',
194 p_procedure_name => 'schedule',
195 p_error_text => SQLERRM);
196 wip_utilities.get_message_stack(
197 p_msg => x_errorMsg,
198 p_delete_stack => fnd_api.g_false);
199 if (l_logLevel <= wip_constants.trace_logging) then
200 wip_logger.exitPoint(
201 p_procName => 'wsm_infinite_scheduler_grp.schedule',
202 p_procReturnStatus => x_returnStatus,
203 p_msg => 'unexp error: ' || x_errorMsg,
204 x_returnStatus => l_retStatus);
205 if(fnd_api.to_boolean(nvl(p_endDebug, fnd_api.g_true))) then
206 wip_logger.cleanup(l_retStatus);
207 end if;
208 end if;
209
210 end schedule;
211
212
213
214
215 end wsm_infinite_scheduler_grp;